@qredence/fleet 0.5.5 → 0.5.7
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/CHANGELOG.md +12 -0
- package/dist/web/client/assets/action-swap-roll-BB8DFMuf.js +1 -0
- package/dist/web/client/assets/agent-activity-CDcDNVC6.js +1 -0
- package/dist/web/client/assets/agent-disclosure-B8SnhQXL.js +1 -0
- package/dist/web/client/assets/analytics-stub-B8MIkiDB.js +1 -0
- package/dist/web/client/assets/artifacts-panel-CmHYXfoo.js +1 -0
- package/dist/web/client/assets/button-BV9NafmI.js +1 -0
- package/dist/web/client/assets/chat-command-palette-DiG-i3uJ.js +1 -0
- package/dist/web/client/assets/check-JjHKAZas.js +1 -0
- package/dist/web/client/assets/chevron-up-CnSvySGH.js +1 -0
- package/dist/web/client/assets/circle-alert-CONlFReH.js +1 -0
- package/dist/web/client/assets/circle-x-CkKCB__4.js +1 -0
- package/dist/web/client/assets/citations-CpTFUvx7.js +2 -0
- package/dist/web/client/assets/collapsible-BoXtZZWN.js +1 -0
- package/dist/web/client/assets/command-Cx-UYeQ9.js +1 -0
- package/dist/web/client/assets/createBaseUIEventDetails-DV0dQrBX.js +1 -0
- package/dist/web/client/assets/dialog-Dh7WpGIu.js +1 -0
- package/dist/web/client/assets/dist-BPaFisIZ.js +41 -0
- package/dist/web/client/assets/earth-DGZXAN5r.js +1 -0
- package/dist/web/client/assets/ease-u56MhKYS.js +1 -0
- package/dist/web/client/assets/file-text-T-NcAlZs.js +1 -0
- package/dist/web/client/assets/fleet-message-queue-B6zAK-hX.js +1 -0
- package/dist/web/client/assets/{fleet-pi-tool-renderer-B0Y7ou0U.js → fleet-pi-tool-renderer-Btq9mDUe.js} +28 -28
- package/dist/web/client/assets/fleet-reasoning-panel-MtbSdoCv.js +1 -0
- package/dist/web/client/assets/fleet-subagent-list-iszvrvy_.js +1 -0
- package/dist/web/client/assets/fleet-tool-timeline-COzPrwr8.js +1 -0
- package/dist/web/client/assets/{fork-picker-dialog-C2cVJUbf.js → fork-picker-dialog-CAhWx0G5.js} +1 -1
- package/dist/web/client/assets/gauge-DNpstbBn.js +1 -0
- package/dist/web/client/assets/generative-text-renderer-C1JrmYfx.js +6 -0
- package/dist/web/client/assets/globals-Bfr0jrPq.css +2 -0
- package/dist/web/client/assets/horizontal-resize-Bl3AyBJg.js +1 -0
- package/dist/web/client/assets/image-BbPmlw-n.js +1 -0
- package/dist/web/client/assets/index-QgUwd4m8.js +12 -0
- package/dist/web/client/assets/input-Bol3TP4v.js +1 -0
- package/dist/web/client/assets/input-group-D5gi9zBK.js +1 -0
- package/dist/web/client/assets/{markdown-DG7pUdsX.js → markdown-RD_ydkyD.js} +2 -2
- package/dist/web/client/assets/{markdown-code-BgMzpy7O.js → markdown-code-ETqXqY8E.js} +1 -1
- package/dist/web/client/assets/message-square-hbDao-A1.js +1 -0
- package/dist/web/client/assets/model-selector-list-CJY9pyt2.js +1 -0
- package/dist/web/client/assets/notify-DKTqXChG.js +1 -0
- package/dist/web/client/assets/{openui-renderer-CCfQqUfE.js → openui-renderer-BZMghkzQ.js} +7 -7
- package/dist/web/client/assets/prompt-suggestions-CXM6knMK.js +1 -0
- package/dist/web/client/assets/provider-catalog-CHKFGwHr.js +1 -0
- package/dist/web/client/assets/provider-label-KkqVX1CI.js +1 -0
- package/dist/web/client/assets/range-BWOHiLNe.js +1 -0
- package/dist/web/client/assets/refresh-cw-IThTJ3j-.js +1 -0
- package/dist/web/client/assets/{resource-helpers-ULlyU8qK.js → resource-helpers-Q2T0YCMO.js} +1 -1
- package/dist/web/client/assets/resources-panel-Bo8dfUdm.js +1 -0
- package/dist/web/client/assets/right-panel-context-B2VAZ2p4.js +1 -0
- package/dist/web/client/assets/right-panel-registry-C5fQcBKw.js +2 -0
- package/dist/web/client/assets/routes-C1hRkRkv.js +16 -0
- package/dist/web/client/assets/safe-external-url-D3PJJIcM.js +1 -0
- package/dist/web/client/assets/settings-dialog-CvvM6T0m.js +1 -0
- package/dist/web/client/assets/{sparkles-C5H3Jtgf.js → shield-check-CkA2viVW.js} +1 -1
- package/dist/web/client/assets/{skeleton-loaders-fStjEeRP.js → skeleton-loaders-DjGv9LLA.js} +1 -1
- package/dist/web/client/assets/sparkles-DuclzqlE.js +1 -0
- package/dist/web/client/assets/{subagent-chat-panel-D-qw4uWb.js → subagent-chat-panel-tGCg6gcn.js} +1 -1
- package/dist/web/client/assets/subagent-transcript-NO0PR8RU.js +1 -0
- package/dist/web/client/assets/subagent-utils-CQbaJ1g-.js +1 -0
- package/dist/web/client/assets/subagents-panel-BkFLsQQY.js +1 -0
- package/dist/web/client/assets/surfaces-cW-gp56p.js +1 -0
- package/dist/web/client/assets/switch-CcOFiQBK.js +1 -0
- package/dist/web/client/assets/terminal-DOS1s1gm.js +1 -0
- package/dist/web/client/assets/toast-ATq44uAL.js +1 -0
- package/dist/web/client/assets/tool-result-pklnrxSW.js +4 -0
- package/dist/web/client/assets/use-reduced-motion-eORd7fqW.js +9 -0
- package/dist/web/client/assets/useBaseUiId-CHqXB2UQ.js +1 -0
- package/dist/web/client/assets/useControlled-CJJ9BOQB.js +1 -0
- package/dist/web/client/assets/workspace-panel-BmMW7h7b.js +1 -0
- package/dist/web/client/assets/wrench-BJNNe07k.js +1 -0
- package/dist/web/client/assets/x-CsRC_tCI.js +1 -0
- package/dist/web/client/bundle-budget.json +10 -0
- package/dist/web/server/{_tanstack-start-manifest_v-DZc7dwm7-6ZQLGXB7.js → _tanstack-start-manifest_v-B4BnRTa_-DR7WQTT5.js} +35 -27
- package/dist/web/server/agent-activity-Dx6AlDhN-JXOL2EXK.js +514 -0
- package/dist/web/server/{artifacts-panel-Bt7YUzm4-NCBMXJ25.js → artifacts-panel-CloS3-ij-XWYXKL6A.js} +26 -18
- package/dist/web/server/{chat-command-palette-Co1L3rUY-RQLNME4T.js → chat-command-palette-Cc0uGvNm-GKENKTO7.js} +23 -18
- package/dist/web/server/{chunk-2V6B62OF.js → chunk-3B6M63AO.js} +12 -15
- package/dist/web/server/chunk-3D4Z32XA.js +22 -0
- package/dist/web/server/{chunk-SR65ARVS.js → chunk-3SSHBMDS.js} +16 -12
- package/dist/web/server/chunk-4PQ6OD6J.js +22 -0
- package/dist/web/server/chunk-56SEDI5N.js +19 -0
- package/dist/web/server/chunk-6QNW66XR.js +19 -0
- package/dist/web/server/chunk-744IIIDL.js +19 -0
- package/dist/web/server/{chunk-52SJQXO4.js → chunk-7PQTPSEE.js} +568 -568
- package/dist/web/server/{chunk-LSIHVSUT.js → chunk-7SR6WDM2.js} +2 -2
- package/dist/web/server/chunk-ANL4B775.js +60 -0
- package/dist/web/server/chunk-BNQWMQHD.js +35 -0
- package/dist/web/server/{chunk-BLVCDQ7E.js → chunk-C5X6G26O.js} +1 -19
- package/dist/web/server/chunk-C66BSNA6.js +42 -0
- package/dist/web/server/{chunk-XLCTCC4W.js → chunk-DEUBJJZN.js} +4 -59
- package/dist/web/server/chunk-E365EOXJ.js +35 -0
- package/dist/web/server/{chunk-5WZFFNFY.js → chunk-EFAGCVZ3.js} +2 -23
- package/dist/web/server/{chunk-56HSKUBD.js → chunk-EGQ6ZX4D.js} +23 -298
- package/dist/web/server/{chunk-TO3YPLNZ.js → chunk-EKBKGAWX.js} +12 -10
- package/dist/web/server/{chunk-5RQ6QAZX.js → chunk-F6MGAW3L.js} +2 -2
- package/dist/web/server/chunk-GABXCOY3.js +37 -0
- package/dist/web/server/chunk-GV7DJIHY.js +36 -0
- package/dist/web/server/{chunk-6D524OCJ.js → chunk-HSJMLO36.js} +6 -253
- package/dist/web/server/{chunk-46VQY7SG.js → chunk-HU4AIJV3.js} +4 -4
- package/dist/web/server/{chunk-PDRD2X5G.js → chunk-HZY3LBGP.js} +145 -1
- package/dist/web/server/{chunk-UKINNXJY.js → chunk-J6MRJXUH.js} +22 -15
- package/dist/web/server/{chunk-RX62LUDV.js → chunk-JOSTE7WK.js} +7 -5
- package/dist/web/server/{chunk-QJBEWT4E.js → chunk-K3BXQG3N.js} +27 -292
- package/dist/web/server/chunk-K4ESBQ3R.js +20 -0
- package/dist/web/server/{chunk-3HUI75QM.js → chunk-KZSM3BHO.js} +16 -107
- package/dist/web/server/chunk-L46H6IDX.js +13 -0
- package/dist/web/server/chunk-LNGWHEE6.js +206 -0
- package/dist/web/server/{chunk-WZNZQNI4.js → chunk-MOSVTKH5.js} +39 -36
- package/dist/web/server/{chunk-MDYA4NXK.js → chunk-NJRYX4A2.js} +4 -4
- package/dist/web/server/chunk-NNMZQN7Q.js +296 -0
- package/dist/web/server/{chunk-AWFOBHH4.js → chunk-NPPG2GTW.js} +7 -7
- package/dist/web/server/{chunk-Y4MHIA7B.js → chunk-PJNYH5SR.js} +7 -295
- package/dist/web/server/{chunk-7APYEQIO.js → chunk-QAE5SXDK.js} +1 -24
- package/dist/web/server/chunk-QTFCJGOY.js +189 -0
- package/dist/web/server/{chunk-AECEK3K7.js → chunk-RANJ6OJ3.js} +9 -9
- package/dist/web/server/chunk-RPBSDXJ4.js +62 -0
- package/dist/web/server/{chunk-VRLTWOVJ.js → chunk-RYHIJMFD.js} +57 -33
- package/dist/web/server/{chunk-NLIUTTKL.js → chunk-S3PQ6HKH.js} +1 -16
- package/dist/web/server/chunk-SG4W4SPQ.js +31 -0
- package/dist/web/server/{chunk-LESNF5O4.js → chunk-T23OO4SC.js} +2 -11
- package/dist/web/server/{chunk-BEMDNODD.js → chunk-UNZJQ7CY.js} +6 -4
- package/dist/web/server/chunk-V3S6BVXO.js +22 -0
- package/dist/web/server/{chunk-SZ65K4CO.js → chunk-W5GRNHV5.js} +6 -4
- package/dist/web/server/{chunk-FZRBAPUM.js → chunk-XKYEXPLQ.js} +2 -17
- package/dist/web/server/{chunk-6GMKRR3C.js → chunk-XNYQSCB2.js} +2 -2
- package/dist/web/server/chunk-YHXAXJ6I.js +22 -0
- package/dist/web/server/chunk-YLMXYMLG.js +86 -0
- package/dist/web/server/chunk-YNGDUWCF.js +56 -0
- package/dist/web/server/chunk-ZJFA4F5X.js +280 -0
- package/dist/web/server/fleet-message-queue-Bn0_3Efe-G4BZR2EU.js +74 -0
- package/dist/web/server/fleet-pi-tool-renderer-C52SZmPx-CIAH3IV7.js +51 -0
- package/dist/web/server/fleet-reasoning-panel-C_e7wzVm-SDHEWDQT.js +199 -0
- package/dist/web/server/fleet-subagent-list-CQltKswG-EKCMQHDI.js +18 -0
- package/dist/web/server/fleet-tool-timeline-KENErMKg-HTN7SW3D.js +16 -0
- package/dist/web/server/{fork-picker-dialog-DCzuGelH-TN2Q5OXI.js → fork-picker-dialog-DK9YGQuB-4QEFWRU4.js} +6 -5
- package/dist/web/server/{markdown-Boni3lHk-AZGKDNAR.js → markdown-QcSUaLyd-6DJUK5NC.js} +1 -1
- package/dist/web/server/{markdown-code-BrWukbg3-D2GN4Y77.js → markdown-code-Dyo1_13a-52ZQZSPE.js} +2 -2
- package/dist/web/server/model-selector-list-CEfWjRc--GBW2GUO6.js +289 -0
- package/dist/web/server/{openui-renderer-c36_GYes-HX46N4M5.js → openui-renderer-Dk0Ak9cW-MUJQHDAS.js} +16 -13
- package/dist/web/server/prompt-suggestions-BOmHi4-J-C563CHFU.js +30 -0
- package/dist/web/server/{resources-panel-CwKh4U9f-D3VDEMDW.js → resources-panel-B03M8bEp-SZG726N5.js} +7 -6
- package/dist/web/server/{router-_ZpegqiQ-QIE44PIB.js → router-BE9HcX2W-JMQ3JWE5.js} +39 -24
- package/dist/web/server/{routes-Ct81-8Tq-LHRMOS7R.js → routes-CJTRGB1Z-WJKXJFFT.js} +704 -1463
- package/dist/web/server/server.js +2 -2
- package/dist/web/server/{settings-dialog-B4uUS6f--AZ4I4ZOT.js → settings-dialog-yDibpbBH-TCLJ7NRJ.js} +42 -31
- package/dist/web/server/{subagent-chat-panel-C97S3WID-DLOAD5TG.js → subagent-chat-panel-B1YoZIKO-DFRUDQJ2.js} +39 -20
- package/dist/web/server/{subagents-panel-iHpvMIZy-LI6XK66M.js → subagents-panel-dJJwpsEL-FTWWCHND.js} +41 -22
- package/dist/web/server/{workspace-panel-CHPoiXEo-YB4WS3MK.js → workspace-panel-BC_H8Jri-5MHAEQQS.js} +22 -18
- package/package.json +1 -1
- package/dist/web/client/assets/action-swap-roll-DX5o_33Q.js +0 -1
- package/dist/web/client/assets/analytics-stub-Jh3lkb8P.js +0 -1
- package/dist/web/client/assets/artifacts-panel-C3yewUBP.js +0 -1
- package/dist/web/client/assets/button-0At5xSyU.js +0 -1
- package/dist/web/client/assets/chat-command-palette-D0xDK1j4.js +0 -1
- package/dist/web/client/assets/command-CQzrtjyj.js +0 -2
- package/dist/web/client/assets/dialog-DZ44tBtH.js +0 -1
- package/dist/web/client/assets/dist-MNgIFxqY.js +0 -41
- package/dist/web/client/assets/ease-vFBiNFNK.js +0 -9
- package/dist/web/client/assets/file-text-BhQ0ZnoU.js +0 -1
- package/dist/web/client/assets/generative-text-renderer-SS9c1kNX.js +0 -6
- package/dist/web/client/assets/globals-D_Hy9bT1.css +0 -2
- package/dist/web/client/assets/horizontal-resize-C1TpRLNC.js +0 -1
- package/dist/web/client/assets/index-C9FloFgj.js +0 -12
- package/dist/web/client/assets/input-CqC82Agz.js +0 -1
- package/dist/web/client/assets/input-group-H0TG-mkU.js +0 -1
- package/dist/web/client/assets/notify-Duj26eeZ.js +0 -1
- package/dist/web/client/assets/provider-catalog-BZhZuKSz.js +0 -1
- package/dist/web/client/assets/provider-label-jKm8v18u.js +0 -1
- package/dist/web/client/assets/range-65lubOFp.js +0 -2
- package/dist/web/client/assets/resources-panel-DSU7VGX2.js +0 -1
- package/dist/web/client/assets/routes-DSTyx_J0.js +0 -16
- package/dist/web/client/assets/safe-external-url-Bl_78dpZ.js +0 -1
- package/dist/web/client/assets/settings-dialog-CkfpTKfM.js +0 -1
- package/dist/web/client/assets/subagent-transcript-C7oRwEEP.js +0 -1
- package/dist/web/client/assets/subagents-panel-aSMWZP9p.js +0 -1
- package/dist/web/client/assets/switch-BFEBpUEU.js +0 -1
- package/dist/web/client/assets/toast-C4s7FYYa.js +0 -1
- package/dist/web/client/assets/tool-result-C2NvnN32.js +0 -4
- package/dist/web/client/assets/useBaseUiId-B9f7fokB.js +0 -1
- package/dist/web/client/assets/useControlled-CoY1jSuL.js +0 -1
- package/dist/web/client/assets/workspace-panel-CjdXlEvd.js +0 -1
- package/dist/web/client/assets/x-BgciQ7_C.js +0 -1
- package/dist/web/server/fleet-pi-tool-renderer-CE45vM6T-2UQN6RJM.js +0 -37
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./bundle-mjs-DKHVkVWu.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{d as i,l as a,m as o,n as s,o as c,p as l,r as u,u as d}from"./ease-vFBiNFNK.js";import{t as f}from"./x-BgciQ7_C.js";import{t as p}from"./utils-Eg7xtNmV.js";import{t as m}from"./createLucideIcon-DwxZHm0M.js";import{i as h,n as g,r as _,t as v}from"./tool-result-C2NvnN32.js";import{_ as y,b,g as x,h as S,l as C,m as w,n as T,p as E,t as D,v as O,y as k}from"./range-65lubOFp.js";import{n as A}from"./useControlled-CoY1jSuL.js";import{t as j}from"./chevron-down-BEVGmnSb.js";import{t as M}from"./chevron-right-DrJxToLs.js";import{n as ee,t as te}from"./safe-external-url-Bl_78dpZ.js";import{n as ne,t as re}from"./file-text-BhQ0ZnoU.js";import{n as ie,t as ae}from"./loader-circle-6JG5RwxH.js";import{a as oe,i as se,l as ce,n as le,o as ue,r as de,s as fe,t as pe}from"./action-swap-roll-DX5o_33Q.js";import{a as me,i as he,n as ge,r as _e,t as ve}from"./ipython-tool-BrMePqD-.js";import{i as ye,n as be,r as xe,t as Se}from"./sparkles-C5H3Jtgf.js";import{t as Ce}from"./eye-B0DFz5hL.js";import{t as we}from"./rotate-ccw-WNFNkKQD.js";import{t as Te}from"./search-eWVnAJsb.js";import{t as N}from"./preload-helper-Czpn1I53.js";import{a as Ee,i as De,n as Oe,o as ke,r as Ae,s as je}from"./dist-H-qlGkmT.js";import"./cn-C8c0S2mI.js";import{r as Me}from"./workspace-path-nav-C0AQNZyy.js";var Ne=m(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),Pe=m(`chevrons-up`,[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]),Fe=m(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),Ie=m(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),P=t(n(),1),F=r(),Le=new Map;function Re(e){return{state:e.state,inputJson:JSON.stringify(e.input||{}),outputJson:JSON.stringify(e.output||{})}}function ze(e,t){let n=Le.get(e),r=Re(t);if(!n)return Le.set(e,r),!0;let i=n.state!==r.state||n.inputJson!==r.inputJson||n.outputJson!==r.outputJson;return i&&Le.set(e,r),i}function Be(e,t){if(e.toolCallId!==t.toolCallId||e.type!==t.type)return!1;let n=t.toolCallId;return n?!ze(n,t):e.state===t.state}function Ve(e){return e.output!==void 0&&e.output!==null||e.state===`error`||e.state===`result`}function He(e,t){return Be(e.part,t.part)?Ve(t.part)?!0:e.chatStatus===t.chatStatus:!1}function Ue(e){if(e<1e3)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function I(e,t){let n=e.state!==`output-available`&&e.state!==`output-error`,r=e.state===`output-error`||e.state===`output-available`&&e.output?.success===!1,i=e.state===`output-available`&&!r;return{isPending:n&&t===`streaming`,isError:r,isSuccess:i,isInterrupted:n&&t!==`streaming`&&t!==void 0}}var L=`__custom__`;function We(e){return String.fromCharCode(65+e)}function Ge(e,t,n){if(!e||e.kind===`skip`)return{selectedIds:[],customText:``,textValue:``};if(t===`text`)return{selectedIds:[],customText:``,textValue:e.text??``};let r=new Set(e.selectedIds??[]),i=e.text??``;return n&&i.trim().length>0&&r.add(L),{selectedIds:Array.from(r),customText:i,textValue:``}}function Ke({questions:e,questionIndex:t=1,totalQuestions:n,onPreviousQuestion:r,onNextQuestion:i,submitLabel:a=`Send`,nextLabel:o=`Next`,skipLabel:s=`Skip`,allowSkip:c=!0,initialAnswer:l,onSubmit:u,onSkip:d,className:f}){let m=n??e.length,h=Math.max(1,Math.min(t,m)),g=e[h-1],_=g?.allowCustom??!1,[v,y]=(0,P.useState)(()=>Ge(l,g?.kind,_).selectedIds),[b,x]=(0,P.useState)(()=>Ge(l,g?.kind,_).customText),[S,C]=(0,P.useState)(()=>Ge(l,g?.kind,_).textValue),w=m>1&&(!!r||!!i),T=h>1,E=h<m,D=h>=m,O=(0,P.useMemo)(()=>new Set(v),[v]),k=D?a:o,A=(0,P.useMemo)(()=>{if(g?.kind===`text`)return S.trim().length>0;let e=v.filter(e=>e!==L).length+ +(b.trim().length>0);if(g?.kind===`single`)return e===1;let t=g?.minSelections??1,n=g?.maxSelections;return e<t||typeof n==`number`&&e>n?!1:e>0},[g?.kind,g?.minSelections,g?.maxSelections,v,b,S]),j=e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},M=e=>{y([e])},ee=e=>{if(x(e),g){if(g.kind===`single`){y(e.trim().length>0?[L]:[]);return}y(t=>{let n=t.includes(L);return e.trim().length>0&&!n?[...t,L]:e.trim().length===0&&n?t.filter(e=>e!==L):t})}};return g?(0,F.jsxs)(`div`,{className:p(`flex flex-col gap-2 bg-background px-3 py-2`,f),children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between gap-px`,"data-total-questions":m,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-an-tool-color`,children:[(0,F.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded px-1 text-sm font-medium text-an-tool-color-muted`,children:h}),(0,F.jsx)(`span`,{children:g.title})]})}),g.kind!==`text`&&(g.options?.length??0)>0&&(0,F.jsxs)(`div`,{className:`flex flex-col gap-px`,children:[g.options.map((e,t)=>{let n=e.id??e.value??e.label,r=O.has(n);return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{g.kind===`single`?(M(n),_&&x(``)):j(n)},className:`-mx-2 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-an-background-secondary`,children:[(0,F.jsx)(`span`,{className:p(`inline-flex h-5 min-w-5 items-center justify-center rounded border px-1 text-sm font-medium`,r?`border-an-primary-color bg-an-primary-color text-an-send-button-color`:`border-border bg-transparent text-an-tool-color-muted`),children:We(t)}),(0,F.jsxs)(`span`,{className:`text-sm text-an-tool-color`,children:[e.label,e.description&&(0,F.jsxs)(`span`,{className:`text-an-tool-color-muted`,children:[` `,e.description]})]})]},n)}),_&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,F.jsx)(`span`,{className:p(`inline-flex h-5 min-w-5 items-center justify-center rounded border px-1 text-sm font-medium`,v.includes(L)?`border-an-primary-color bg-an-primary-color text-an-send-button-color`:`border-border bg-transparent text-an-tool-color-muted`),children:We(g.options.length)}),(0,F.jsx)(`input`,{value:b,onChange:e=>ee(e.target.value),placeholder:g.customPlaceholder??`Type your answer`,className:`h-7 w-full rounded-md border border-border bg-background px-2 text-base text-an-tool-color md:text-sm`})]})]}),g.kind===`text`&&(0,F.jsx)(`textarea`,{value:S,onChange:e=>C(e.target.value),placeholder:g.placeholder??`Type your answer`,rows:3,className:`w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 text-base text-an-tool-color md:text-sm`}),(0,F.jsxs)(`div`,{className:p(`flex items-center gap-1.5`,w?`justify-between`:`justify-end`),children:[w&&(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r&&(0,F.jsx)(`button`,{type:`button`,onClick:r,disabled:!T,className:`h-6 rounded px-2 text-sm text-muted-foreground hover:text-an-tool-color disabled:opacity-60`,children:`Previous`}),i&&(0,F.jsx)(`button`,{type:`button`,onClick:i,disabled:!E,className:`h-6 rounded px-2 text-sm text-muted-foreground hover:text-an-tool-color disabled:opacity-60`,children:`Next`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[c&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{d?.(),u({kind:`skip`})},className:`h-6 rounded px-2 text-sm text-muted-foreground transition-[background-color,color,transform] duration-150 hover:bg-muted/50 hover:text-an-tool-color active:scale-[0.98]`,children:s}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{if(!A||!g)return;if(g.kind===`text`){u({kind:`text`,questionId:g.id,text:S.trim()});return}let e=v.filter(e=>e!==L),t=b.trim()||void 0;u({kind:g.kind,questionId:g.id,selectedIds:e,text:t||void 0})},disabled:!A,className:`h-6 rounded bg-an-primary-color px-2.5 text-sm font-medium text-an-send-button-color transition-[background-color,transform] duration-150 hover:bg-an-primary-color/90 active:scale-[0.98] disabled:opacity-60 disabled:hover:bg-an-primary-color disabled:active:scale-100`,children:k})]})]})]}):null}function qe(e){if(e.kind===`skip`)return`Skipped`;if(e.kind===`text`)return e.text||`Answered`;let t=e.selectedIds?.length?e.selectedIds.join(`, `):``;return e.text?t?`${t} (${e.text})`:e.text:t||`Answered`}function Je({part:e}){let[t,n]=(0,P.useState)(e.input?.questionIndex??1),r=e.input?.questions??[],i=e.input?.totalQuestions??r.length,a=typeof e.input?.questionIndex==`number`,o=a?e.input?.questionIndex??1:r.length>0?t:e.input?.questionIndex??1,s=Math.max(1,Math.min(o,i)),c=r[s-1],[l,u]=(0,P.useState)({}),[d,f]=(0,P.useState)(e.input?.questionIndex);e.input?.questionIndex!==d&&(f(e.input?.questionIndex),typeof e.input?.questionIndex==`number`&&n(e.input.questionIndex));let[p,m]=(0,P.useState)(e.toolCallId);e.toolCallId!==p&&(m(e.toolCallId),u({}),n(e.input?.questionIndex??1));let h=e.output?.answer,g=Object.keys(l).length,_=i===1?!!h||g>=1:i>0&&g>=i,v=i>1&&!_,y=s>1,b=s<i,x=(0,P.useMemo)(()=>!_||i<=1?[]:Array.from({length:i},(e,t)=>({index:t+1,answer:l[t+1]})),[_,l,i]),S=(0,P.useMemo)(()=>_?x.length>0?x.map(e=>`${e.index}: ${e.answer?qe(e.answer):`Pending`}`).join(` • `):h?qe(h):l[s]?qe(l[s]):`Pending`:``,[_,x,h,l,s]);if(!c)return null;let C=()=>{y&&(e.input?.onPreviousQuestion?.(),a||n(e=>Math.max(1,e-1)))},w=()=>{b&&(e.input?.onNextQuestion?.(),a||n(e=>Math.min(i,e+1)))};return(0,F.jsxs)(`div`,{className:`overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,F.jsxs)(`div`,{className:`flex h-7 items-center justify-between border-b border-border px-3 text-xs text-an-tool-color-muted`,children:[(0,F.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(O,{className:`h-3.5 w-3.5`}),`Question`]}),v&&(0,F.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:C,disabled:!y,className:`inline-flex size-5 items-center justify-center rounded-[4px] hover:bg-an-background-secondary disabled:opacity-40`,"aria-label":`Previous question`,children:(0,F.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,F.jsxs)(`span`,{children:[s,` of `,i]}),(0,F.jsx)(`button`,{type:`button`,onClick:w,disabled:!b,className:`inline-flex size-5 items-center justify-center rounded-[4px] hover:bg-an-background-secondary disabled:opacity-40`,"aria-label":`Next question`,children:(0,F.jsx)(j,{className:`h-3.5 w-3.5`})})]})]}),_?(0,F.jsx)(`div`,{className:`bg-background px-3 py-2 text-xs text-an-tool-color-muted`,children:S}):(0,F.jsx)(Ke,{questions:r,questionIndex:s,totalQuestions:i,initialAnswer:l[s],submitLabel:e.input?.submitLabel,nextLabel:e.input?.nextLabel,skipLabel:e.input?.skipLabel,allowSkip:e.input?.allowSkip,onSubmit:t=>{u(e=>({...e,[s]:t})),e.input?.onSubmitAnswer?.(t),s<i&&w()}},`${s}-${c.title}`)]})}function Ye(e){if(!e)return``;let t=Me(e);if(t!==e)return t;if(e.startsWith(`/`)){let t=e.split(`/`),n=[`apps`,`packages`,`src`,`lib`,`components`],r=t.findIndex(e=>n.includes(e));if(r>0)return t.slice(r).join(`/`)}return e}function Xe(e,t){let n=e.split(`
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./bundle-mjs-DKHVkVWu.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{d as i,l as a,n as o,o as s,r as c,u as l}from"./ease-u56MhKYS.js";import{n as u,t as d}from"./use-reduced-motion-eORd7fqW.js";import{t as f}from"./utils-Eg7xtNmV.js";import{t as p}from"./createLucideIcon-DwxZHm0M.js";import{i as m,n as h,r as g,t as _}from"./tool-result-pklnrxSW.js";import{a as v,c as y,i as b,l as x,o as S,r as C,s as w}from"./citations-CpTFUvx7.js";import{t as T}from"./check-JjHKAZas.js";import{t as E}from"./chevron-down-BEVGmnSb.js";import{t as D}from"./chevron-right-DrJxToLs.js";import{t as O}from"./chevron-up-CnSvySGH.js";import{t as k}from"./circle-alert-CONlFReH.js";import{n as A,t as j}from"./loader-circle-6JG5RwxH.js";import{t as M}from"./circle-x-CkKCB__4.js";import{a as N,i as ee,n as te,r as ne,t as re}from"./ipython-tool-BrMePqD-.js";import{n as ie,t as ae}from"./action-swap-roll-BB8DFMuf.js";import{n as oe,r as se,t as ce}from"./shield-check-CkA2viVW.js";import{t as le}from"./eye-B0DFz5hL.js";import{t as ue}from"./file-text-T-NcAlZs.js";import{t as de}from"./rotate-ccw-WNFNkKQD.js";import{t as fe}from"./search-eWVnAJsb.js";import{t as pe}from"./sparkles-DuclzqlE.js";import{t as me}from"./terminal-DOS1s1gm.js";import{t as he}from"./wrench-BJNNe07k.js";import{t as ge}from"./x-CsRC_tCI.js";import{t as P}from"./preload-helper-Czpn1I53.js";import{a as _e,i as ve,n as ye,o as be,r as xe,s as Se}from"./dist-H-qlGkmT.js";import"./cn-C8c0S2mI.js";import{r as Ce}from"./workspace-path-nav-C0AQNZyy.js";import{n as we,r as Te,t as Ee}from"./collapsible-BoXtZZWN.js";import{t as De}from"./agent-disclosure-B8SnhQXL.js";import{t as Oe}from"./safe-external-url-D3PJJIcM.js";import{o as ke}from"./surfaces-cW-gp56p.js";import{n as Ae,t as je}from"./range-BWOHiLNe.js";var Me=p(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),Ne=p(`chevrons-up`,[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]),Pe=p(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),Fe=p(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),F=t(n(),1),I=r(),Ie=new Map;function Le(e){return{state:e.state,inputJson:JSON.stringify(e.input||{}),outputJson:JSON.stringify(e.output||{})}}function Re(e,t){let n=Ie.get(e),r=Le(t);if(!n)return Ie.set(e,r),!0;let i=n.state!==r.state||n.inputJson!==r.inputJson||n.outputJson!==r.outputJson;return i&&Ie.set(e,r),i}function ze(e,t){if(e.toolCallId!==t.toolCallId||e.type!==t.type)return!1;let n=t.toolCallId;return n?!Re(n,t):e.state===t.state}function Be(e){return e.output!==void 0&&e.output!==null||e.state===`error`||e.state===`result`}function Ve(e,t){return ze(e.part,t.part)?Be(t.part)?!0:e.chatStatus===t.chatStatus:!1}function He(e){if(e<1e3)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function Ue(e,t){let n=e.state!==`output-available`&&e.state!==`output-error`,r=e.state===`output-error`||e.state===`output-available`&&e.output?.success===!1,i=e.state===`output-available`&&!r;return{isPending:n&&t===`streaming`,isError:r,isSuccess:i,isInterrupted:n&&t!==`streaming`&&t!==void 0}}var We=`__custom__`;function Ge(e){return String.fromCharCode(65+e)}function Ke(e,t,n){if(!e||e.kind===`skip`)return{selectedIds:[],customText:``,textValue:``};if(t===`text`)return{selectedIds:[],customText:``,textValue:e.text??``};let r=new Set(e.selectedIds??[]),i=e.text??``;return n&&i.trim().length>0&&r.add(We),{selectedIds:Array.from(r),customText:i,textValue:``}}function qe({questions:e,questionIndex:t=1,totalQuestions:n,onPreviousQuestion:r,onNextQuestion:i,submitLabel:a=`Send`,nextLabel:o=`Next`,skipLabel:s=`Skip`,allowSkip:c=!0,initialAnswer:l,onSubmit:u,onSkip:d,className:p}){let m=n??e.length,h=Math.max(1,Math.min(t,m)),g=e[h-1],_=g?.allowCustom??!1,[v,y]=(0,F.useState)(()=>Ke(l,g?.kind,_).selectedIds),[b,x]=(0,F.useState)(()=>Ke(l,g?.kind,_).customText),[S,C]=(0,F.useState)(()=>Ke(l,g?.kind,_).textValue),w=m>1&&(!!r||!!i),T=h>1,E=h<m,D=h>=m,O=(0,F.useMemo)(()=>new Set(v),[v]),k=D?a:o,A=(0,F.useMemo)(()=>{if(g?.kind===`text`)return S.trim().length>0;let e=v.filter(e=>e!==We).length+ +(b.trim().length>0);if(g?.kind===`single`)return e===1;let t=g?.minSelections??1,n=g?.maxSelections;return e<t||typeof n==`number`&&e>n?!1:e>0},[g?.kind,g?.minSelections,g?.maxSelections,v,b,S]),j=e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},M=e=>{y([e])},N=e=>{if(x(e),g){if(g.kind===`single`){y(e.trim().length>0?[We]:[]);return}y(t=>{let n=t.includes(We);return e.trim().length>0&&!n?[...t,We]:e.trim().length===0&&n?t.filter(e=>e!==We):t})}};return g?(0,I.jsxs)(`div`,{className:f(`flex flex-col gap-2 bg-background px-3 py-2`,p),children:[(0,I.jsx)(`div`,{className:`flex items-center justify-between gap-px`,"data-total-questions":m,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-an-tool-color`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded px-1 text-sm font-medium text-an-tool-color-muted`,children:h}),(0,I.jsx)(`span`,{children:g.title})]})}),g.kind!==`text`&&(g.options?.length??0)>0&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-px`,children:[g.options.map((e,t)=>{let n=e.id??e.value??e.label,r=O.has(n);return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{g.kind===`single`?(M(n),_&&x(``)):j(n)},className:`-mx-2 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-an-background-secondary`,children:[(0,I.jsx)(`span`,{className:f(`inline-flex h-5 min-w-5 items-center justify-center rounded border px-1 text-sm font-medium`,r?`border-an-primary-color bg-an-primary-color text-an-send-button-color`:`border-border bg-transparent text-an-tool-color-muted`),children:Ge(t)}),(0,I.jsxs)(`span`,{className:`text-sm text-an-tool-color`,children:[e.label,e.description&&(0,I.jsxs)(`span`,{className:`text-an-tool-color-muted`,children:[` `,e.description]})]})]},n)}),_&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,I.jsx)(`span`,{className:f(`inline-flex h-5 min-w-5 items-center justify-center rounded border px-1 text-sm font-medium`,v.includes(We)?`border-an-primary-color bg-an-primary-color text-an-send-button-color`:`border-border bg-transparent text-an-tool-color-muted`),children:Ge(g.options.length)}),(0,I.jsx)(`input`,{value:b,onChange:e=>N(e.target.value),placeholder:g.customPlaceholder??`Type your answer`,className:`h-7 w-full rounded-md border border-border bg-background px-2 text-base text-an-tool-color md:text-sm`})]})]}),g.kind===`text`&&(0,I.jsx)(`textarea`,{value:S,onChange:e=>C(e.target.value),placeholder:g.placeholder??`Type your answer`,rows:3,className:`w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 text-base text-an-tool-color md:text-sm`}),(0,I.jsxs)(`div`,{className:f(`flex items-center gap-1.5`,w?`justify-between`:`justify-end`),children:[w&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r&&(0,I.jsx)(`button`,{type:`button`,onClick:r,disabled:!T,className:`h-6 rounded px-2 text-sm text-muted-foreground hover:text-an-tool-color disabled:opacity-60`,children:`Previous`}),i&&(0,I.jsx)(`button`,{type:`button`,onClick:i,disabled:!E,className:`h-6 rounded px-2 text-sm text-muted-foreground hover:text-an-tool-color disabled:opacity-60`,children:`Next`})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[c&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{d?.(),u({kind:`skip`})},className:`h-6 rounded px-2 text-sm text-muted-foreground transition-[background-color,color,transform] duration-150 hover:bg-muted/50 hover:text-an-tool-color active:scale-[0.98]`,children:s}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{if(!A||!g)return;if(g.kind===`text`){u({kind:`text`,questionId:g.id,text:S.trim()});return}let e=v.filter(e=>e!==We),t=b.trim()||void 0;u({kind:g.kind,questionId:g.id,selectedIds:e,text:t||void 0})},disabled:!A,className:`h-6 rounded bg-an-primary-color px-2.5 text-sm font-medium text-an-send-button-color transition-[background-color,transform] duration-150 hover:bg-an-primary-color/90 active:scale-[0.98] disabled:opacity-60 disabled:hover:bg-an-primary-color disabled:active:scale-100`,children:k})]})]})]}):null}function Je(e){if(e.kind===`skip`)return`Skipped`;if(e.kind===`text`)return e.text||`Answered`;let t=e.selectedIds?.length?e.selectedIds.join(`, `):``;return e.text?t?`${t} (${e.text})`:e.text:t||`Answered`}function Ye({part:e}){let[t,n]=(0,F.useState)(e.input?.questionIndex??1),r=e.input?.questions??[],i=e.input?.totalQuestions??r.length,a=typeof e.input?.questionIndex==`number`,o=a?e.input?.questionIndex??1:r.length>0?t:e.input?.questionIndex??1,s=Math.max(1,Math.min(o,i)),c=r[s-1],[l,u]=(0,F.useState)({}),[d,f]=(0,F.useState)(e.input?.questionIndex);e.input?.questionIndex!==d&&(f(e.input?.questionIndex),typeof e.input?.questionIndex==`number`&&n(e.input.questionIndex));let[p,m]=(0,F.useState)(e.toolCallId);e.toolCallId!==p&&(m(e.toolCallId),u({}),n(e.input?.questionIndex??1));let h=e.output?.answer,g=Object.keys(l).length,_=i===1?!!h||g>=1:i>0&&g>=i,v=i>1&&!_,y=s>1,b=s<i,x=(0,F.useMemo)(()=>!_||i<=1?[]:Array.from({length:i},(e,t)=>({index:t+1,answer:l[t+1]})),[_,l,i]),S=(0,F.useMemo)(()=>_?x.length>0?x.map(e=>`${e.index}: ${e.answer?Je(e.answer):`Pending`}`).join(` • `):h?Je(h):l[s]?Je(l[s]):`Pending`:``,[_,x,h,l,s]);if(!c)return null;let C=()=>{y&&(e.input?.onPreviousQuestion?.(),a||n(e=>Math.max(1,e-1)))},T=()=>{b&&(e.input?.onNextQuestion?.(),a||n(e=>Math.min(i,e+1)))};return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,I.jsxs)(`div`,{className:`flex h-7 items-center justify-between border-b border-border px-3 text-xs text-an-tool-color-muted`,children:[(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,I.jsx)(w,{className:`h-3.5 w-3.5`}),`Question`]}),v&&(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:C,disabled:!y,className:`inline-flex size-5 items-center justify-center rounded-[4px] hover:bg-an-background-secondary disabled:opacity-40`,"aria-label":`Previous question`,children:(0,I.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,I.jsxs)(`span`,{children:[s,` of `,i]}),(0,I.jsx)(`button`,{type:`button`,onClick:T,disabled:!b,className:`inline-flex size-5 items-center justify-center rounded-[4px] hover:bg-an-background-secondary disabled:opacity-40`,"aria-label":`Next question`,children:(0,I.jsx)(E,{className:`h-3.5 w-3.5`})})]})]}),_?(0,I.jsx)(`div`,{className:`bg-background px-3 py-2 text-xs text-an-tool-color-muted`,children:S}):(0,I.jsx)(qe,{questions:r,questionIndex:s,totalQuestions:i,initialAnswer:l[s],submitLabel:e.input?.submitLabel,nextLabel:e.input?.nextLabel,skipLabel:e.input?.skipLabel,allowSkip:e.input?.allowSkip,onSubmit:t=>{u(e=>({...e,[s]:t})),e.input?.onSubmitAnswer?.(t),s<i&&T()}},`${s}-${c.title}`)]})}function Xe(e){if(!e)return``;let t=Ce(e);if(t!==e)return t;if(e.startsWith(`/`)){let t=e.split(`/`),n=[`apps`,`packages`,`src`,`lib`,`components`],r=t.findIndex(e=>n.includes(e));if(r>0)return t.slice(r).join(`/`)}return e}function Ze(e,t){let n=e.split(`
|
|
2
2
|
`),r=t.split(`
|
|
3
|
-
`),i=Math.max(n.length,r.length),a=0,o=0;for(let e=0;e<i;e++)n[e]!==void 0&&r[e]!==void 0?n[e]!==r[e]&&(o++,a++):n[e]===void 0?r[e]!==void 0&&a++:o++;return{addedLines:a,removedLines:o}}var
|
|
4
|
-
`,1)[0].trim();return n.length>50?`${n.slice(0,47)}...`:n},variant:`simple`},"tool-WebFetch":{icon:xe,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Fetching`:`Fetched`,subtitle:e=>{let t=e.input?.url||``;try{return new URL(t).hostname.replace(`www.`,``)}catch{return t.slice(0,30)}},variant:`simple`},"tool-WebSearch":{icon:Te,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Searching web`:`Searched web`,subtitle:e=>{let t=e.input?.query||``;return t.length>40?`${t.slice(0,37)}...`:t},variant:`collapsible`},"tool-TodoWrite":{icon:b,title:e=>{let t=e.state!==`output-available`&&e.state!==`output-error`,n=e.input?.action||`update`;return t?n===`add`?`Adding todo`:`Updating todos`:n===`add`?`Added todo`:`Updated todos`},subtitle:e=>{let t=e.input?.todos||[];return t.length===0?``:`${t.length} ${t.length===1?`item`:`items`}`},variant:`simple`},"tool-PlanWrite":{icon:Se,title:e=>{let t=e.state!==`output-available`&&e.state!==`output-error`,n=e.input?.action||`create`;if(t)return n===`create`?`Creating plan`:n===`approve`?`Approving plan`:`Updating plan`;let r=e.input?.plan?.status;return r===`awaiting_approval`?`Plan ready for review`:r===`approved`?`Plan approved`:r===`completed`?`Plan completed`:n===`create`?`Created plan`:`Updated plan`},variant:`simple`},"tool-ExitPlanMode":{icon:k,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Finishing plan`:`Plan complete`,variant:`simple`},"tool-NotebookEdit":{icon:fe,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Editing notebook`:`Edited notebook`,subtitle:e=>{let t=e.input?.file_path||``;return t&&t.split(`/`).pop()||``},variant:`simple`},"tool-BashOutput":{icon:y,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Getting output`:`Command output`,subtitle:e=>{let t=e.output;if(typeof t==`string`&&t.trim())return t.trim();let n=e.input?.command||``;if(!n)return``;let r=n.replace(/\\\s*\n\s*/g,` `).trim();return r=r.replace(/\/(?:Users|home|root)\/[^\s"']+/g,e=>Ye(e)),r.length>50?`${r.slice(0,47)}...`:r},variant:`simple`},"tool-KillShell":{icon:ce,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Stopping shell`:`Shell stopped`,subtitle:e=>{let t=e.input?.pid;return typeof t==`number`?`pid ${t}`:``},variant:`simple`},"tool-cloning":{icon:ye,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Cloning repo`:`Repo cloned`,subtitle:e=>e.input?.repo??``,variant:`simple`},"tool-Thinking":{icon:Se,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Thinking...`:`Thought`,variant:`collapsible`}},Qe=`tool-mcp__`,$e={"tool-ListMcpResources":{serverName:`mcp`,toolName:`list_resources`,displayName:`List Resources`,category:`list`},"tool-ListMcpResourcesTool":{serverName:`mcp`,toolName:`list_resources`,displayName:`List Resources`,category:`list`},"tool-ReadMcpResource":{serverName:`mcp`,toolName:`read_resource`,displayName:`Read Resource`,category:`get`},"tool-ReadMcpResourceTool":{serverName:`mcp`,toolName:`read_resource`,displayName:`Read Resource`,category:`get`}};function et(e){let t=$e[e];if(t)return t;if(!e.startsWith(Qe))return null;let n=e.slice(10),r=n.indexOf(`__`);if(r===-1)return null;let i=n.slice(0,r),a=n.slice(r+2);return{serverName:i,toolName:a,displayName:a.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),category:`other`}}function tt({icon:e,shimmerLabel:t,completeLabel:n,isAnimating:r,detail:i,onDetailClick:a,trailingContent:o,expandable:s=!1,expanded:c,defaultOpen:l=!1,onToggleExpand:u,children:d}){let f=!r,m=c??!1,h=s&&(f||m||r),g=(0,F.jsxs)(`div`,{className:p(`flex max-w-full items-center gap-1 rounded-an-tool-border-radius select-none`,h?`cursor-pointer`:`cursor-default`),children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[e&&(0,F.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:e}),(0,F.jsx)(`span`,{className:`shrink-0 font-[450] whitespace-nowrap`,children:r&&t?(0,F.jsx)(me,{as:`span`,duration:1.2,className:`m-0 inline-flex h-4 items-center leading-none`,children:t}):n}),i&&(a?(0,F.jsx)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 truncate text-left font-normal text-an-foreground-muted/60 underline-offset-2 hover:text-an-foreground-muted hover:underline`,children:i}):(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-normal text-an-foreground-muted/60`,children:i})),o]}),s&&(f||m||r)&&(0,F.jsx)(`div`,{children:(0,F.jsx)(M,{className:p(`shrink-0 text-muted-foreground transition-transform duration-150 ease-out`,`size-3`,`rotate-0 group-data-panel-open:rotate-90`)})})]});return s?(0,F.jsxs)(de,{className:`flex w-full flex-col gap-2`,...c===void 0?{defaultOpen:l}:{open:c,onOpenChange:u},children:[(0,F.jsx)(oe,{className:`group flex`,disabled:!h,"aria-disabled":!h,children:g}),(0,F.jsx)(se,{className:p(`overflow-hidden`,`h-[var(--collapsible-panel-height)] transition-all duration-150 ease-out`,`data-ending-style:h-0 data-starting-style:h-0`,`[&[hidden]:not([hidden='until-found'])]:hidden`),children:d})]}):(0,F.jsx)(`div`,{className:`flex flex-col gap-1`,children:g})}var nt=(0,P.memo)(function({icon:e,title:t,subtitle:n,isPending:r,onSubtitleClick:i}){let a=e;return(0,F.jsx)(tt,{icon:a?(0,F.jsx)(a,{className:`h-full w-full shrink-0 text-muted-foreground`}):void 0,shimmerLabel:t,completeLabel:t,isAnimating:r,detail:n,onDetailClick:i})});function rt(e){return e.split(`|`).map(e=>e.trim().split(/\s+/)[0]??``).filter(Boolean).slice(0,4).join(`, `)}function it({step:e,state:t,onComplete:n,approval:r}){he(t===`animating`,e.duration,n);let i=t===`animating`,a=e.bashCommand??e.toolDetail,o=rt(a);return(0,F.jsxs)(`div`,{className:`overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,F.jsxs)(`div`,{className:`flex h-7 items-center justify-between pr-2 pl-2.5`,children:[(0,F.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:i?(0,F.jsxs)(me,{as:`span`,duration:1.2,className:`m-0 inline-flex h-full items-center truncate text-xs leading-none`,children:[`Running command: `,o]}):(0,F.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`Ran command: `,o]})}),i&&(0,F.jsx)(`svg`,{className:`h-3 w-3 shrink-0 animate-spin text-muted-foreground`,viewBox:`0 0 16 16`,fill:`none`,children:(0,F.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`28`,strokeDashoffset:`7`,strokeLinecap:`round`})})]}),(0,F.jsxs)(`div`,{className:`overflow-hidden border-t border-border bg-background px-2.5 py-1.5 font-mono text-[12px] leading-[16px]`,children:[(0,F.jsxs)(`div`,{className:`break-all`,children:[(0,F.jsxs)(`span`,{className:`text-amber-600 select-none dark:text-amber-400`,children:[`$`,` `]}),(0,F.jsx)(`span`,{className:`text-foreground`,children:a})]}),!i&&e.bashOutput&&(0,F.jsx)(`div`,{className:`mt-1 max-h-[80px] overflow-hidden whitespace-pre-line text-muted-foreground`,children:e.bashOutput})]}),r&&(0,F.jsx)(ge,{isPending:i,...r})]})}var at=(0,P.memo)(function({part:e}){let t=e.input?.approval??e.args?.approval,{step:n,stepState:r}=_e(e,`Bash`);return(0,F.jsx)(it,{step:n,state:r,onComplete:()=>{},approval:t})});function ot(e){let t=(0,P.useRef)(e);return(0,P.useInsertionEffect)(()=>void(t.current=e)),(0,P.useCallback)((...e)=>t.current(...e),[])}var st=(0,P.createContext)(void 0);function ct(){return(0,P.useContext)(st)}var lt={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},ut={display:`contents`};function dt(){return null}var ft=`diffs-container`,pt=/(?=^diff --git)/gm,mt=/(?<=\n)/,ht=/^(---|\+\+\+)\s+([^\t\r\n]+)/,gt=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,_t=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,vt=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,yt=`header-prefix`,bt=`header-filename-suffix`,xt=`header-metadata`,St=`header-custom`,R={dark:`pierre-dark`,light:`pierre-light`},Ct=`data-theme-css`,wt=`data-unsafe-css`,Tt=`data-diffs-scrollbar-measure`,Et=`--diffs-scrollbar-gutter-measured`,Dt=1e5,Ot={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...Ot});var kt=Object.freeze({fromStart:0,fromEnd:0}),At={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},jt={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0};function Mt(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function Nt({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function z(e,t){return e-(t===0?0:1)}function B(e,t){return z(e,t)+t}function Pt(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Ft(n,e.startContentIndex)}}function Ft(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function It({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d}){let f=n?.(e),p=r?.(e),m=i?.(e),h=a?.(e);return(0,F.jsxs)(F.Fragment,{children:[f==null?(0,F.jsxs)(F.Fragment,{children:[p!=null&&(0,F.jsx)(`div`,{slot:`header-prefix`,children:p}),m!=null&&(0,F.jsx)(`div`,{slot:`header-filename-suffix`,children:m}),h!=null&&(0,F.jsx)(`div`,{slot:`header-metadata`,children:h})]}):(0,F.jsx)(`div`,{slot:St,children:f}),o!=null&&l?.map((e,t)=>(0,F.jsx)(`div`,{slot:Mt(e),children:o(e)},t)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=Lt(t,e);return(0,F.jsx)(`div`,{slot:n,style:ut,children:c(t,d)},n)}),s!=null&&(0,F.jsx)(`div`,{slot:`gutter-utility-slot`,style:lt,children:s(u)})]})}function Lt(e,t){let n=Pt(e,t);return n==null?void 0:Nt({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function Rt(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function zt(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}var Bt=new Set;function Vt(e){let t=[],n=new Set;for(let r of Ht(e.themes)){let e=Gt(r)?r.getThemes():[r];for(let r of e){if(n.has(r.name))throw Error(`Theme collection already contains theme "${r.name}"`);n.add(r.name),t.push(r)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter(e=>e.colorScheme===`light`)),a=Object.freeze(r.filter(e=>e.colorScheme===`dark`)),o=new Map(r.map(e=>[e.name,e])),s=Object.freeze(r.map(e=>e.name)),c=Object.freeze(i.map(e=>e.name)),l=Object.freeze(a.map(e=>e.name));function u(e){if(e==null)return r;let{colorScheme:t,collection:n}=e;return n==null?t===`light`?i:t===`dark`?a:r:r.filter(e=>e.collection===n?t==null||e.colorScheme===t:!1)}return{getTheme(e){return o.get(e)},getThemes(e){return u(e)},getThemeNames(e){return e?.collection==null?e?.colorScheme===`light`?c:e?.colorScheme===`dark`?l:s:u(e).map(e=>e.name)},hasTheme(e){return o.has(e)},orderBy(e){return Vt({themes:r.map((e,t)=>({descriptor:e,index:t})).sort((t,n)=>{let r=e(t.descriptor,n.descriptor);return r===0?t.index-n.index:r}).map(e=>e.descriptor)})},pick(e){let t=[],n=new Set;for(let r of e){if(n.has(r))throw Error(`Theme collection pick already includes theme "${r}"`);n.add(r);let e=o.get(r);if(e==null)throw Error(`Theme collection does not contain theme "${r}"`);t.push(e)}return Vt({themes:t})},registerInto(e){for(let t of r)e.registerThemeIfAbsent(t.name,t.load)}}}function Ht(e){return Ut(e)?[e]:e}function Ut(e){return Gt(e)||Wt(e)}function Wt(e){return typeof e.name==`string`&&typeof e.load==`function`}function Gt(e){return typeof e.getThemes==`function`}function Kt(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var qt=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},Jt=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},Yt=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function Xt(){let e=new Map,t=new Map,n=new Map,r=0;function i(t,n){if(e.has(t))throw new qt(t);e.set(t,n)}function a(t,n){return!e.has(t)&&(e.set(t,n),!0)}function o(t){return e.has(t)}function s(i){let a=t.get(i);if(a!==void 0)return Promise.resolve(a);let o=n.get(i);if(o!==void 0)return o;let s=e.get(i);if(s===void 0)return Promise.reject(new Jt(i));let c=r,l=s().then(e=>{let a=Kt(e);return c===r&&t.set(i,a),n.get(i)===l&&n.delete(i),a}).catch(e=>{throw n.get(i)===l&&n.delete(i),e});return n.set(i,l),l}function c(e){return Promise.all(e.map(e=>s(e)))}function l(e,n){t.set(e,n)}function u(e){for(let[t,n]of e)l(t,n)}function d(e){return t.get(e)}function f(e){let n=[];for(let r of e){let e=t.get(r);if(e===void 0)throw new Yt(r);n.push(e)}return n}function p(e){return t.has(e)}function m(e){for(let n of e)if(!t.has(n))return!1;return!0}function h(e){let n=t.get(e);return n===void 0?s(e):n}function g(){r++,t.clear(),n.clear()}return{clearResolvedThemes:g,getResolvedOrResolveTheme:h,getResolvedTheme:d,getResolvedThemes:f,hasRegisteredTheme:o,hasResolvedTheme:p,hasResolvedThemes:m,registerTheme:i,registerThemeIfAbsent:a,resolveTheme:s,resolveThemes:c,seedResolvedTheme:l,seedResolvedThemes:u}}var V=Xt();function Zt(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let e;if(typeof n==`string`){if(e=V.getResolvedTheme(n),e==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else e=n,n=n.name,V.getResolvedTheme(n)??V.seedResolvedTheme(n,e);Bt.has(n)||(Bt.add(n),t.loadThemeSync(e))}}var Qt=new Map,$t=new Map,en=new Map,tn=new Set;function nn(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(tn.has(n.name))continue;let e=Qt.get(n.name);e??(e=n,Qt.set(n.name,e)),tn.add(e.name),t.loadLanguageSync(e.data)}}function rn(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}async function an(e){if(rn())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=$t.get(e);if(t!=null)return t;try{let t=en.get(e);if(t==null&&Object.prototype.hasOwnProperty.call(je,e)&&(t=je[e]),t==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n=t().then(({default:t})=>{let n={name:e,data:t};return Qt.has(e)||Qt.set(e,n),n});return $t.set(e,n),await n}finally{$t.delete(e)}}function on(e){return Qt.get(e)??an(e)}function sn({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:cn(t)}}function cn(e){return async()=>Ee(Kt(await e()))}var ln=`pierre`,un=[`pierre-dark`,`pierre-dark-soft`,`pierre-dark-vibrant`,`pierre-dark-protanopia-deuteranopia`,`pierre-dark-tritanopia`],dn=[`pierre-light`,`pierre-light-soft`,`pierre-light-vibrant`,`pierre-light-protanopia-deuteranopia`,`pierre-light-tritanopia`],fn=[...dn,...un],pn=new Set(dn);function mn(e){return pn.has(e)?`light`:`dark`}var hn={"pierre-dark":`Pierre Dark`,"pierre-dark-soft":`Pierre Dark Soft`,"pierre-dark-vibrant":`Pierre Dark Vibrant`,"pierre-dark-protanopia-deuteranopia":`Pierre Dark Protanopia & Deuteranopia`,"pierre-dark-tritanopia":`Pierre Dark Tritanopia`,"pierre-light":`Pierre Light`,"pierre-light-soft":`Pierre Light Soft`,"pierre-light-vibrant":`Pierre Light Vibrant`,"pierre-light-protanopia-deuteranopia":`Pierre Light Protanopia & Deuteranopia`,"pierre-light-tritanopia":`Pierre Light Tritanopia`},gn={"pierre-dark":()=>N(()=>import(`./pierre-dark-CpLgRqie.js`),[]),"pierre-dark-soft":()=>N(()=>import(`./pierre-dark-soft-kZQmAZld.js`),[]),"pierre-dark-vibrant":()=>N(()=>import(`./pierre-dark-vibrant-CpQYzh95.js`),[]),"pierre-dark-protanopia-deuteranopia":()=>N(()=>import(`./pierre-dark-protanopia-deuteranopia-B35FxJx-.js`),[]),"pierre-dark-tritanopia":()=>N(()=>import(`./pierre-dark-tritanopia-CpjhbsIL.js`),[]),"pierre-light":()=>N(()=>import(`./pierre-light-CoaEpmwp.js`),[]),"pierre-light-soft":()=>N(()=>import(`./pierre-light-soft-lWLdNTOI.js`),[]),"pierre-light-vibrant":()=>N(()=>import(`./pierre-light-vibrant-D80Fkn33.js`),[]),"pierre-light-protanopia-deuteranopia":()=>N(()=>import(`./pierre-light-protanopia-deuteranopia-0fSaH845.js`),[]),"pierre-light-tritanopia":()=>N(()=>import(`./pierre-light-tritanopia-CEbqgOJL.js`),[])};function _n(e){return sn({name:e,collection:ln,colorScheme:mn(e),displayName:hn[e],load:gn[e]})}var vn=Vt({themes:fn.map(e=>_n(e))}),yn=`shiki`,bn=[`ayu-light`,`catppuccin-latte`,`everforest-light`,`github-light`,`github-light-default`,`github-light-high-contrast`,`gruvbox-light-hard`,`gruvbox-light-medium`,`gruvbox-light-soft`,`horizon-bright`,`kanagawa-lotus`,`light-plus`,`material-theme-lighter`,`min-light`,`night-owl-light`,`one-light`,`rose-pine-dawn`,`slack-ochin`,`snazzy-light`,`solarized-light`,`vitesse-light`],xn=`andromeeda.aurora-x.ayu-dark.ayu-mirage.catppuccin-frappe.catppuccin-macchiato.catppuccin-mocha.dark-plus.dracula.dracula-soft.everforest-dark.github-dark.github-dark-default.github-dark-dimmed.github-dark-high-contrast.gruvbox-dark-hard.gruvbox-dark-medium.gruvbox-dark-soft.horizon.houston.kanagawa-dragon.kanagawa-wave.laserwave.material-theme.material-theme-darker.material-theme-ocean.material-theme-palenight.min-dark.monokai.night-owl.nord.one-dark-pro.plastic.poimandres.red.rose-pine.rose-pine-moon.slack-dark.solarized-dark.synthwave-84.tokyo-night.vesper.vitesse-black.vitesse-dark`.split(`.`),Sn=new Set(bn);function Cn(e){return Sn.has(e)?`light`:`dark`}var wn={andromeeda:()=>N(()=>import(`./andromeeda-vGVdxbeo.js`),[]),"aurora-x":()=>N(()=>import(`./aurora-x-CDeNXAV0.js`),[]),"ayu-dark":()=>N(()=>import(`./ayu-dark-DluEY0Gj.js`),[]),"ayu-light":()=>N(()=>import(`./ayu-light-C3h-C4tm.js`),[]),"ayu-mirage":()=>N(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[]),"catppuccin-frappe":()=>N(()=>import(`./catppuccin-frappe-C9Q5zVZY.js`),[]),"catppuccin-latte":()=>N(()=>import(`./catppuccin-latte-CtsyrtPq.js`),[]),"catppuccin-macchiato":()=>N(()=>import(`./catppuccin-macchiato-R8nAf1vR.js`),[]),"catppuccin-mocha":()=>N(()=>import(`./catppuccin-mocha-DjuaAJKi.js`),[]),"dark-plus":()=>N(()=>import(`./dark-plus-Cs2F2srj.js`),[]),dracula:()=>N(()=>import(`./dracula-BHWKrbxM.js`),[]),"dracula-soft":()=>N(()=>import(`./dracula-soft-5eyTD99u.js`),[]),"everforest-dark":()=>N(()=>import(`./everforest-dark-sB-x3p7T.js`),[]),"everforest-light":()=>N(()=>import(`./everforest-light-Df2xbC6M.js`),[]),"github-dark":()=>N(()=>import(`./github-dark-C-LZuMrd.js`),[]),"github-dark-default":()=>N(()=>import(`./github-dark-default-DXG-b-1a.js`),[]),"github-dark-dimmed":()=>N(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[]),"github-dark-high-contrast":()=>N(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[]),"github-light":()=>N(()=>import(`./github-light-EUqPIrTm.js`),[]),"github-light-default":()=>N(()=>import(`./github-light-default-BXViO-2h.js`),[]),"github-light-high-contrast":()=>N(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[]),"gruvbox-dark-hard":()=>N(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[]),"gruvbox-dark-medium":()=>N(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[]),"gruvbox-dark-soft":()=>N(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[]),"gruvbox-light-hard":()=>N(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[]),"gruvbox-light-medium":()=>N(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[]),"gruvbox-light-soft":()=>N(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[]),horizon:()=>N(()=>import(`./horizon-CE9ld1lL.js`),[]),"horizon-bright":()=>N(()=>import(`./horizon-bright-DSNQnXHK.js`),[]),houston:()=>N(()=>import(`./houston-CsvMBhTu.js`),[]),"kanagawa-dragon":()=>N(()=>import(`./kanagawa-dragon-Bozd7klA.js`),[]),"kanagawa-lotus":()=>N(()=>import(`./kanagawa-lotus-BmuOG9ZW.js`),[]),"kanagawa-wave":()=>N(()=>import(`./kanagawa-wave-BML5mF2J.js`),[]),laserwave:()=>N(()=>import(`./laserwave-C_8bwKvT.js`),[]),"light-plus":()=>N(()=>import(`./light-plus-DVQuIRkW.js`),[]),"material-theme":()=>N(()=>import(`./material-theme-Bm3Qr25_.js`),[]),"material-theme-darker":()=>N(()=>import(`./material-theme-darker-2IIEA8gg.js`),[]),"material-theme-lighter":()=>N(()=>import(`./material-theme-lighter-uhdI0v04.js`),[]),"material-theme-ocean":()=>N(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[]),"material-theme-palenight":()=>N(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[]),"min-dark":()=>N(()=>import(`./min-dark-BSWPekZh.js`),[]),"min-light":()=>N(()=>import(`./min-light-DDpmG2fV.js`),[]),monokai:()=>N(()=>import(`./monokai-B_bV9PQ9.js`),[]),"night-owl":()=>N(()=>import(`./night-owl-DhmEMT88.js`),[]),"night-owl-light":()=>N(()=>import(`./night-owl-light-eJ-hLW7d.js`),[]),nord:()=>N(()=>import(`./nord-Cb4Vim4T.js`),[]),"one-dark-pro":()=>N(()=>import(`./one-dark-pro-CLwyXe_n.js`),[]),"one-light":()=>N(()=>import(`./one-light-D7Lr4KcI.js`),[]),plastic:()=>N(()=>import(`./plastic-DQwYfKfQ.js`),[]),poimandres:()=>N(()=>import(`./poimandres-DRFjx7u4.js`),[]),red:()=>N(()=>import(`./red-DX1BQOs8.js`),[]),"rose-pine":()=>N(()=>import(`./rose-pine-aMsaMD1D.js`),[]),"rose-pine-dawn":()=>N(()=>import(`./rose-pine-dawn-8PwUyIlP.js`),[]),"rose-pine-moon":()=>N(()=>import(`./rose-pine-moon-DO-qXg-I.js`),[]),"slack-dark":()=>N(()=>import(`./slack-dark-DnToyrRv.js`),[]),"slack-ochin":()=>N(()=>import(`./slack-ochin-B2OO5cIa.js`),[]),"snazzy-light":()=>N(()=>import(`./snazzy-light-4G7pJPwS.js`),[]),"solarized-dark":()=>N(()=>import(`./solarized-dark-UdsmMDCL.js`),[]),"solarized-light":()=>N(()=>import(`./solarized-light-C1IUL_tW.js`),[]),"synthwave-84":()=>N(()=>import(`./synthwave-84-nFMaYfgc.js`),[]),"tokyo-night":()=>N(()=>import(`./tokyo-night-oM2G3aXe.js`),[]),vesper:()=>N(()=>import(`./vesper-DdrHHSXu.js`),[]),"vitesse-black":()=>N(()=>import(`./vitesse-black-fwtXNY1n.js`),[]),"vitesse-dark":()=>N(()=>import(`./vitesse-dark-BZCL-v6S.js`),[]),"vitesse-light":()=>N(()=>import(`./vitesse-light-VbXTXTou.js`),[])};function Tn(e){return sn({name:e,collection:yn,colorScheme:Cn(e),load:wn[e]})}var En=Vt({themes:Object.freeze([...bn.map(e=>Tn(e)),...xn.map(e=>Tn(e))])});function Dn(e){if(rn())throw Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(V.hasRegisteredTheme(e))return;let t=En.getTheme(e);if(t!=null){V.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function On(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function kn(e){Dn(e);let t=await V.resolveTheme(e);return On(e,t),t}function An(e){return V.getResolvedTheme(e)??kn(e)}var H;async function jn({themes:e,langs:t,preferredHighlighter:n=`shiki-js`}){H??=Ae({themes:[],langs:[`text`],engine:n===`shiki-wasm`?ke(N(()=>import(`./wasm-BnjxR4X6.js`),[])):Oe()});let r=Nn(H)?await H:H;H=r;let i=[];for(let e of t){if(e===`text`||e===`ansi`)continue;let t=on(e);`then`in t?i.push(t):nn(t,r)}let a=[];for(let t of e){let e=An(t);`then`in e?a.push(e):Zt(e,H)}return(i.length>0||a.length>0)&&await Promise.all([Promise.all(i).then(e=>{nn(e,r)}),Promise.all(a).then(e=>{Zt(e,r)})]),r}function Mn(){if(H!=null&&!(`then`in H))return H}function Nn(e=H){return e!=null&&`then`in e}for(let e of vn.getThemes())V.registerThemeIfAbsent(e.name,e.load);function Pn(e=R){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}var Fn=new Map,In={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function Ln(e){if(Fn.has(e))return Fn.get(e)??`text`;if(In[e]!=null)return In[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(Fn.has(t[1]))return Fn.get(t[1])??`text`;if(In[t[1]]!=null)return In[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return Fn.has(n)?Fn.get(n)??`text`:In[n]??`text`}function U(e){return{type:`text`,value:e}}function W({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function Rn({name:e,width:t=16,height:n=16,properties:r}){return W({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[W({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function zn(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function Bn(e){return W({tagName:`div`,properties:{"data-gutter":``},children:e})}function Vn(e,t,n,r={}){return W({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[W({tagName:`span`,properties:{"data-line-number-content":``},children:[U(`${t}`)]})]})}function G(e,t,n){return W({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Hn(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(U(`
|
|
5
|
-
`)),e}var Un=Symbol(`no-token`),Wn=Symbol(`multiple-tokens`);function Gn(e){let t=Kn(e);if(t!=null)return t;let n=Un,r=[],i=[],a,o=()=>{if(i.length===0||a==null){i=[],a=void 0;return}if(i.length===1){let e=i[0];if(e?.type===`element`){Jn(e,a);for(let t of e.children)qn(t)}else qn(e);r.push(e),i=[],a=void 0;return}for(let e of i)qn(e);r.push(W({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0},s=e=>{if(e!==Un){if(e===Wn){n=Wn;return}if(n===Un){n=e;return}n!==e&&(n=Wn)}};for(let t of e.children){let e=t.type===`element`?Gn(t):Un;if(s(e),typeof e!=`number`){o(),r.push(t);continue}a!=null&&a!==e&&o(),a??=e,i.push(t)}return o(),e.children=r,n}function Kn(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function qn(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)qn(t)}}function Jn(e,t){e.properties[`data-char`]=t}function Yn(e={}){let{classPrefix:t=`__shiki_`,classSuffix:n=``,classReplacer:r=e=>e}=e,i=new Map;function a(e){return Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function o(e){let o=typeof e==`string`?e:a(e),s=t+Xn(o)+n;return s=r(s),i.has(s)||i.set(s,typeof e==`string`?e:{...e}),s}return{name:`@shikijs/transformers:style-to-class`,pre(e){if(!e.properties.style)return;let t=o(e.properties.style);delete e.properties.style,this.addClassToHast(e,t)},tokens(e){for(let t of e)for(let e of t){if(!e.htmlStyle)continue;let t=o(e.htmlStyle);e.htmlStyle={},e.htmlAttrs||={},e.htmlAttrs.class?e.htmlAttrs.class+=` ${t}`:e.htmlAttrs.class=t}},getClassRegistry(){return i},getCSS(){let e=``;for(let[t,n]of i.entries())e+=`.${t}{${typeof n==`string`?n:a(n)}}`;return e},clearRegistry(){i.clear()}}}function Xn(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}function Zn(e=!1,t=!1){let n={lineInfo:[]},r=[{line(e){return delete e.properties.class,e},pre(t){let r=zn(t),i=[];if(r!=null){let t=1;for(let a of r.children)a.type===`element`&&(e&&Gn(a),i.push(Hn(a,t,n)),t++);r.children=i}return t},...e?{tokens(e){for(let t of e){let e=0;for(let n of t){let t=n;t.__lineChar??=e,e+=n.content.length}}},preprocess(e,t){t.mergeWhitespaces=`never`},span(e,t,n,r,i){if(i?.offset!=null&&i.content!=null){let t=i.__lineChar;return t!=null&&(e.properties[`data-char`]=t),e}return e}}:null}];return t&&r.push($n,Qn),e&&r.push({line:e=>(e.type===`element`&&e.children.length===0&&e.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),e)}),{state:n,transformers:r,toClass:Qn}}var Qn=Yn({classPrefix:`hl-`}),$n={name:`token-style-normalizer`,tokens(e){for(let t of e)for(let e of t){if(e.htmlStyle!=null)continue;let t={};e.color!=null&&(t.color=e.color),e.bgColor!=null&&(t[`background-color`]=e.bgColor),e.fontStyle!=null&&e.fontStyle!==0&&(e.fontStyle&1&&(t[`font-style`]=`italic`),e.fontStyle&2&&(t[`font-weight`]=`bold`),e.fontStyle&4&&(t[`text-decoration`]=`underline`)),Object.keys(t).length>0&&(e.htmlStyle=t)}}};function K(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var er=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,tr=/^0(?:\.0+)?%?$/;function nr(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function rr(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function ir(e){if(e==null)return null;let t=rr(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function ar(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||er.test(t))return!0;let n=nr(t);return n!=null&&tr.test(n)}function or(e,t,n){if(t==null||n==null)return!1;let r=ir(e),i=ir(t),a=ir(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var sr=new WeakMap;function cr(e){let t=sr.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;q(r,`editor.background`,i),q(r,`editor.foreground`,a),q(r,`sideBar.background`,o),q(r,`sideBar.foreground`,s),q(r,`input.background`,n[`input.background`]??o),q(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),q(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),q(r,`gitDecoration.addedResourceForeground`,lr(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),q(r,`gitDecoration.modifiedResourceForeground`,lr(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),q(r,`gitDecoration.deletedResourceForeground`,lr(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(ar(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(ar(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(ur(l,o)||or(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return sr.set(e,u),u}function q(e,t,n){n!=null&&n!==``&&(e[t]=n)}function lr(...e){for(let t of e)if(t!=null&&t!==``)return t}function ur(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function dr({theme:e=R,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=cr(i);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${K(`global`)}fg:${a.fg};`,r+=`${K(`global`)}bg:${a.bg};`,r+=fr(i,n)}else{let n=t.getTheme(e.dark),i=cr(n);r+=`${K(`global`)}dark:${i.fg};`,r+=`${K(`global`)}dark-bg:${i.bg};`,r+=fr(n,`dark`),n=t.getTheme(e.light),i=cr(n),r+=`${K(`global`)}light:${i.fg};`,r+=`${K(`global`)}light-bg:${i.bg};`,r+=fr(n,`light`)}return r}function fr(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${K(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${K(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${K(`global`)}${t}modified-color:${a};`),n}function pr(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t.children;t=`children`in t?t.children[0]:null}throw console.error(e),Error(`getLineNodes: Unable to find children`)}function mr(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function hr(e,t){return Rt(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function gr(e){let t=e.lang??Ln(e.name),n=e.lang??(e.prevName==null?`text`:Ln(e.prevName));return t===`text`&&n===`text`}function J(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function _r(e){return{...Ot,...e}}function vr(e,t){let n=yr(e,t);return t?n:e.diffHeaderHeight+n}function yr(e,t){return e.paddingTop??(t?e.spacing:0)}function br(e){return e.paddingBottom??e.spacing}function xr(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function Sr(e){return[z(e.additionStart,e.additionCount)+1,B(e.additionStart,e.additionCount)+1]}function Y({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function Cr(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-B(t.additionStart,t.additionCount),r=e.deletionLines.length-B(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function wr({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-B(n.additionStart,n.additionCount),i=e.deletionLines.length-B(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function X({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=wr({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function Tr({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=Sr(a);if(t<o){let s=Y({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=X({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=Sr(a);return t<o+i.fromStart||t>=o+i.rangeSize}function Er({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=Sr(n),l=Y({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=X({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function Dr({type:e,metrics:t}){return t.hunkSeparatorHeight??xr(e)}function Or({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function kr({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function Ar(e){return e!==`simple`&&e!==`metadata`}function jr({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!kr({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=Dr({type:e,metrics:t}),a=Or({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Mr({type:e,metrics:t}){if(!Ar(e))return;let n=Dr({type:e,metrics:t}),r=Or({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function Nr({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=Pr({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=z(r.deletionStart,r.deletionCount),s=z(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=Y({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?X({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(Lr(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,Lr(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,S=s+1,C=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===C;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(Lr(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:S+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,S+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=Rr(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(zr({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,S+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(Lr(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:S+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function Pr({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=Fr({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function Fr({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=Y({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?X({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function Ir(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function Lr(e,t,n,r,i,a){let[o,s]=Ir(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function Rr(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function zr({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var Br=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},Vr=new class extends Br{};function Hr(e,t,n){return Vr.diff(e,t,n)}function Ur(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Wr(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Gr(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Kr(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function qr(e,t){return Gr(e,t,``)}function Jr(e,t){return Kr(e,t,``)}function Yr(e,t){return t.slice(0,Xr(e,t))}function Xr(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Zr(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Qr(e,t){if(t)return ei(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function $r(e,t){if(t)return ei(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function ei(e,t){if(!t)return[$r(e),Qr(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Zr(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var ti=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,ni=RegExp(`[${ti}]+|\\s+|[^${ti}]`,`ug`);new class extends Br{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Zr(e,r)}else n=e.match(ni)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&ri(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&ri(n,i,r,null,t.intlSegmenter),e}};function ri(e,t,n,r,i){if(t&&n){let[a,o]=ei(t.value,i),[s,c]=ei(n.value,i);if(e){let r=Ur(a,s);e.value=Kr(e.value,s,r),t.value=qr(t.value,r),n.value=qr(n.value,r)}if(r){let e=Wr(o,c);r.value=Gr(r.value,c,e),t.value=Jr(t.value,e),n.value=Jr(n.value,e)}}else if(n){if(e){let e=$r(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=$r(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=$r(r.value,i),[a,o]=ei(t.value,i),s=Ur(n,a);t.value=qr(t.value,s);let c=Wr(qr(n,s),o);t.value=Jr(t.value,c),r.value=Gr(r.value,n,c),e.value=Kr(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=$r(r.value,i),n=Yr(Qr(t.value,i),e);t.value=Jr(t.value,n)}else if(e){let n=Yr(Qr(e.value,i),$r(t.value,i));t.value=qr(t.value,n)}}var ii=new class extends Br{tokenize(e){let t=RegExp(`(\\r?\\n)|[${ti}]+|[^\\S\\n\\r]+|[^${ti}]`,`ug`);return e.match(t)||[]}};function ai(e,t,n){return ii.diff(e,t,n)}var oi=new class extends Br{constructor(){super(...arguments),this.tokenize=ci}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
3
|
+
`),i=Math.max(n.length,r.length),a=0,o=0;for(let e=0;e<i;e++)n[e]!==void 0&&r[e]!==void 0?n[e]!==r[e]&&(o++,a++):n[e]===void 0?r[e]!==void 0&&a++:o++;return{addedLines:a,removedLines:o}}var Qe={"tool-Task":{icon:pe,title:e=>{let t=e.state!==`output-available`&&e.state!==`output-error`,n=e.input?.subagent_type||`Agent`;return t?`Running ${n}`:`${n} completed`},subtitle:e=>{let t=e.input?.description||``;return t.length>50?`${t.slice(0,47)}...`:t},variant:`simple`},"tool-Agent":{icon:pe,title:e=>{let t=e.state!==`output-available`&&e.state!==`output-error`,n=e.input?.subagent_type||`Agent`;return t?`Running ${n}`:`${n} completed`},subtitle:e=>{let t=e.input?.description||``;return t.length>50?`${t.slice(0,47)}...`:t},variant:`simple`},"tool-Skill":{icon:pe,title:()=>`Skill`,subtitle:e=>e.input?.skill||``,variant:`simple`},"tool-Grep":{icon:fe,title:e=>{if(e.state!==`output-available`&&e.state!==`output-error`)return`Grepping`;let t=e.output?.numFiles||0;return t>0?`Grepped ${t} files`:`No matches`},subtitle:e=>{let t=e.input?.pattern||``,n=e.input?.path||``;if(n){let e=`${t} in ${Xe(n)}`;return e.length>40?`${e.slice(0,37)}...`:e}return t.length>40?`${t.slice(0,37)}...`:t},variant:`simple`},"tool-Glob":{icon:Fe,title:e=>{if(e.state!==`output-available`&&e.state!==`output-error`)return`Exploring files`;let t=e.output?.numFiles||0;return t>0?`Found ${t} files`:`No files found`},subtitle:e=>{let t=e.input?.pattern||``;return t.length>40?`${t.slice(0,37)}...`:t},variant:`simple`},"tool-Read":{icon:le,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Reading`:`Read`,subtitle:e=>{let t=e.input?.file_path||``;return t&&t.split(`/`).pop()||``},variant:`simple`},"tool-Edit":{icon:ie,title:e=>{let t=e.input?.file_path||``;return t&&t.split(`/`).pop()||`Edit`},subtitle:e=>{if(e.state!==`output-available`&&e.state!==`output-error`)return``;let t=e.input?.old_string||``,n=e.input?.new_string||``;if(!t&&!n)return``;if(t!==n){let{addedLines:e,removedLines:r}=Ze(t,n);return`+${e} -${r}`}return``},variant:`simple`},"tool-Write":{icon:Pe,title:()=>`Create`,subtitle:e=>{let t=e.input?.file_path||``;return t&&t.split(`/`).pop()||``},variant:`simple`},"tool-Bash":{icon:me,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Running command`:`Ran command`,subtitle:e=>{let t=e.input?.command||``;if(!t)return``;let n=t.replace(/\\\s*\n\s*/g,` `).trim();return n=n.replace(/\/(?:Users|home|root)\/[^\s"']+/g,e=>Xe(e)),n.length>50?`${n.slice(0,47)}...`:n},variant:`simple`},"tool-IPython":{icon:ie,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Running cell`:`Ran cell`,subtitle:e=>{let t=e.input?.code||``;if(!t)return``;let n=t.split(`
|
|
4
|
+
`,1)[0].trim();return n.length>50?`${n.slice(0,47)}...`:n},variant:`simple`},"tool-WebFetch":{icon:oe,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Fetching`:`Fetched`,subtitle:e=>{let t=e.input?.url||``;try{return new URL(t).hostname.replace(`www.`,``)}catch{return t.slice(0,30)}},variant:`simple`},"tool-WebSearch":{icon:fe,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Searching web`:`Searched web`,subtitle:e=>{let t=e.input?.query||``;return t.length>40?`${t.slice(0,37)}...`:t},variant:`collapsible`},"tool-TodoWrite":{icon:x,title:e=>{let t=e.state!==`output-available`&&e.state!==`output-error`,n=e.input?.action||`update`;return t?n===`add`?`Adding todo`:`Updating todos`:n===`add`?`Added todo`:`Updated todos`},subtitle:e=>{let t=e.input?.todos||[];return t.length===0?``:`${t.length} ${t.length===1?`item`:`items`}`},variant:`simple`},"tool-PlanWrite":{icon:pe,title:e=>{let t=e.state!==`output-available`&&e.state!==`output-error`,n=e.input?.action||`create`;if(t)return n===`create`?`Creating plan`:n===`approve`?`Approving plan`:`Updating plan`;let r=e.input?.plan?.status;return r===`awaiting_approval`?`Plan ready for review`:r===`approved`?`Plan approved`:r===`completed`?`Plan completed`:n===`create`?`Created plan`:`Updated plan`},variant:`simple`},"tool-ExitPlanMode":{icon:y,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Finishing plan`:`Plan complete`,variant:`simple`},"tool-NotebookEdit":{icon:ie,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Editing notebook`:`Edited notebook`,subtitle:e=>{let t=e.input?.file_path||``;return t&&t.split(`/`).pop()||``},variant:`simple`},"tool-BashOutput":{icon:me,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Getting output`:`Command output`,subtitle:e=>{let t=e.output;if(typeof t==`string`&&t.trim())return t.trim();let n=e.input?.command||``;if(!n)return``;let r=n.replace(/\\\s*\n\s*/g,` `).trim();return r=r.replace(/\/(?:Users|home|root)\/[^\s"']+/g,e=>Xe(e)),r.length>50?`${r.slice(0,47)}...`:r},variant:`simple`},"tool-KillShell":{icon:M,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Stopping shell`:`Shell stopped`,subtitle:e=>{let t=e.input?.pid;return typeof t==`number`?`pid ${t}`:``},variant:`simple`},"tool-cloning":{icon:se,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Cloning repo`:`Repo cloned`,subtitle:e=>e.input?.repo??``,variant:`simple`},"tool-Thinking":{icon:pe,title:e=>e.state!==`output-available`&&e.state!==`output-error`?`Thinking...`:`Thought`,variant:`collapsible`}},$e=`tool-mcp__`,et={"tool-ListMcpResources":{serverName:`mcp`,toolName:`list_resources`,displayName:`List Resources`,category:`list`},"tool-ListMcpResourcesTool":{serverName:`mcp`,toolName:`list_resources`,displayName:`List Resources`,category:`list`},"tool-ReadMcpResource":{serverName:`mcp`,toolName:`read_resource`,displayName:`Read Resource`,category:`get`},"tool-ReadMcpResourceTool":{serverName:`mcp`,toolName:`read_resource`,displayName:`Read Resource`,category:`get`}};function tt(e){let t=et[e];if(t)return t;if(!e.startsWith($e))return null;let n=e.slice(10),r=n.indexOf(`__`);if(r===-1)return null;let i=n.slice(0,r),a=n.slice(r+2);return{serverName:i,toolName:a,displayName:a.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),category:`other`}}function nt({icon:e,shimmerLabel:t,completeLabel:n,isAnimating:r,detail:i,onDetailClick:a,trailingContent:o,expandable:s=!1,expanded:c,defaultOpen:l=!1,onToggleExpand:u,children:d}){let p=!r,m=c??!1,h=s&&(p||m||r),g=(0,I.jsxs)(`div`,{className:f(`flex max-w-full items-center gap-1 rounded-an-tool-border-radius select-none`,h?`cursor-pointer`:`cursor-default`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[e&&(0,I.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:e}),(0,I.jsx)(`span`,{className:`shrink-0 font-[450] whitespace-nowrap`,children:r&&t?(0,I.jsx)(N,{as:`span`,duration:1.2,className:`m-0 inline-flex h-4 items-center leading-none`,children:t}):n}),i&&(a?(0,I.jsx)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 truncate text-left font-normal text-an-foreground-muted/60 underline-offset-2 hover:text-an-foreground-muted hover:underline`,children:i}):(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-normal text-an-foreground-muted/60`,children:i})),o]}),s&&(p||m||r)&&(0,I.jsx)(`div`,{children:(0,I.jsx)(D,{className:f(`shrink-0 text-muted-foreground transition-transform duration-150 ease-out`,`size-3`,`rotate-0 group-data-panel-open:rotate-90`)})})]});return s?(0,I.jsxs)(Ee,{className:`flex w-full flex-col gap-2`,...c===void 0?{defaultOpen:l}:{open:c,onOpenChange:u},children:[(0,I.jsx)(Te,{className:`group flex`,disabled:!h,"aria-disabled":!h,children:g}),(0,I.jsx)(we,{className:f(`overflow-hidden`,`h-[var(--collapsible-panel-height)] transition-all duration-150 ease-out`,`data-ending-style:h-0 data-starting-style:h-0`,`[&[hidden]:not([hidden='until-found'])]:hidden`),children:d})]}):(0,I.jsx)(`div`,{className:`flex flex-col gap-1`,children:g})}var rt=(0,F.memo)(function({icon:e,title:t,subtitle:n,isPending:r,onSubtitleClick:i}){let a=e;return(0,I.jsx)(nt,{icon:a?(0,I.jsx)(a,{className:`h-full w-full shrink-0 text-muted-foreground`}):void 0,shimmerLabel:t,completeLabel:t,isAnimating:r,detail:n,onDetailClick:i})});function it(e){return e.split(`|`).map(e=>e.trim().split(/\s+/)[0]??``).filter(Boolean).slice(0,4).join(`, `)}function at({step:e,state:t,onComplete:n,approval:r}){ee(t===`animating`,e.duration,n);let i=t===`animating`,a=e.bashCommand??e.toolDetail,o=it(a);return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,I.jsxs)(`div`,{className:`flex h-7 items-center justify-between pr-2 pl-2.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:i?(0,I.jsxs)(N,{as:`span`,duration:1.2,className:`m-0 inline-flex h-full items-center truncate text-xs leading-none`,children:[`Running command: `,o]}):(0,I.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`Ran command: `,o]})}),i&&(0,I.jsx)(`svg`,{className:`h-3 w-3 shrink-0 animate-spin text-muted-foreground`,viewBox:`0 0 16 16`,fill:`none`,children:(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`28`,strokeDashoffset:`7`,strokeLinecap:`round`})})]}),(0,I.jsxs)(`div`,{className:`overflow-hidden border-t border-border bg-background px-2.5 py-1.5 font-mono text-[12px] leading-[16px]`,children:[(0,I.jsxs)(`div`,{className:`break-all`,children:[(0,I.jsxs)(`span`,{className:`text-amber-600 select-none dark:text-amber-400`,children:[`$`,` `]}),(0,I.jsx)(`span`,{className:`text-foreground`,children:a})]}),!i&&e.bashOutput&&(0,I.jsx)(`div`,{className:`mt-1 max-h-[80px] overflow-hidden whitespace-pre-line text-muted-foreground`,children:e.bashOutput})]}),r&&(0,I.jsx)(te,{isPending:i,...r})]})}var ot=(0,F.memo)(function({part:e}){let t=e.input?.approval??e.args?.approval,{step:n,stepState:r}=ne(e,`Bash`);return(0,I.jsx)(at,{step:n,state:r,onComplete:()=>{},approval:t})});function st(e){let t=(0,F.useRef)(e);return(0,F.useInsertionEffect)(()=>void(t.current=e)),(0,F.useCallback)((...e)=>t.current(...e),[])}var ct=(0,F.createContext)(void 0);function lt(){return(0,F.useContext)(ct)}var ut={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},dt={display:`contents`};function ft(){return null}var pt=`diffs-container`,mt=/(?=^diff --git)/gm,ht=/(?<=\n)/,gt=/^(---|\+\+\+)\s+([^\t\r\n]+)/,_t=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,vt=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,yt=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,bt=`header-prefix`,xt=`header-filename-suffix`,St=`header-metadata`,Ct=`header-custom`,L={dark:`pierre-dark`,light:`pierre-light`},wt=`data-theme-css`,Tt=`data-unsafe-css`,Et=`data-diffs-scrollbar-measure`,Dt=`--diffs-scrollbar-gutter-measured`,Ot=1e5,kt={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...kt});var At=Object.freeze({fromStart:0,fromEnd:0}),jt={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},Mt={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0};function Nt(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function Pt({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function R(e,t){return e-(t===0?0:1)}function z(e,t){return R(e,t)+t}function Ft(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:It(n,e.startContentIndex)}}function It(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function Lt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d}){let f=n?.(e),p=r?.(e),m=i?.(e),h=a?.(e);return(0,I.jsxs)(I.Fragment,{children:[f==null?(0,I.jsxs)(I.Fragment,{children:[p!=null&&(0,I.jsx)(`div`,{slot:`header-prefix`,children:p}),m!=null&&(0,I.jsx)(`div`,{slot:`header-filename-suffix`,children:m}),h!=null&&(0,I.jsx)(`div`,{slot:`header-metadata`,children:h})]}):(0,I.jsx)(`div`,{slot:Ct,children:f}),o!=null&&l?.map((e,t)=>(0,I.jsx)(`div`,{slot:Nt(e),children:o(e)},t)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=Rt(t,e);return(0,I.jsx)(`div`,{slot:n,style:dt,children:c(t,d)},n)}),s!=null&&(0,I.jsx)(`div`,{slot:`gutter-utility-slot`,style:ut,children:s(u)})]})}function Rt(e,t){let n=Ft(e,t);return n==null?void 0:Pt({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function zt(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function Bt(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}var Vt=new Set;function Ht(e){let t=[],n=new Set;for(let r of Ut(e.themes)){let e=Kt(r)?r.getThemes():[r];for(let r of e){if(n.has(r.name))throw Error(`Theme collection already contains theme "${r.name}"`);n.add(r.name),t.push(r)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter(e=>e.colorScheme===`light`)),a=Object.freeze(r.filter(e=>e.colorScheme===`dark`)),o=new Map(r.map(e=>[e.name,e])),s=Object.freeze(r.map(e=>e.name)),c=Object.freeze(i.map(e=>e.name)),l=Object.freeze(a.map(e=>e.name));function u(e){if(e==null)return r;let{colorScheme:t,collection:n}=e;return n==null?t===`light`?i:t===`dark`?a:r:r.filter(e=>e.collection===n?t==null||e.colorScheme===t:!1)}return{getTheme(e){return o.get(e)},getThemes(e){return u(e)},getThemeNames(e){return e?.collection==null?e?.colorScheme===`light`?c:e?.colorScheme===`dark`?l:s:u(e).map(e=>e.name)},hasTheme(e){return o.has(e)},orderBy(e){return Ht({themes:r.map((e,t)=>({descriptor:e,index:t})).sort((t,n)=>{let r=e(t.descriptor,n.descriptor);return r===0?t.index-n.index:r}).map(e=>e.descriptor)})},pick(e){let t=[],n=new Set;for(let r of e){if(n.has(r))throw Error(`Theme collection pick already includes theme "${r}"`);n.add(r);let e=o.get(r);if(e==null)throw Error(`Theme collection does not contain theme "${r}"`);t.push(e)}return Ht({themes:t})},registerInto(e){for(let t of r)e.registerThemeIfAbsent(t.name,t.load)}}}function Ut(e){return Wt(e)?[e]:e}function Wt(e){return Kt(e)||Gt(e)}function Gt(e){return typeof e.name==`string`&&typeof e.load==`function`}function Kt(e){return typeof e.getThemes==`function`}function qt(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var Jt=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},Yt=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},Xt=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function Zt(){let e=new Map,t=new Map,n=new Map,r=0;function i(t,n){if(e.has(t))throw new Jt(t);e.set(t,n)}function a(t,n){return!e.has(t)&&(e.set(t,n),!0)}function o(t){return e.has(t)}function s(i){let a=t.get(i);if(a!==void 0)return Promise.resolve(a);let o=n.get(i);if(o!==void 0)return o;let s=e.get(i);if(s===void 0)return Promise.reject(new Yt(i));let c=r,l=s().then(e=>{let a=qt(e);return c===r&&t.set(i,a),n.get(i)===l&&n.delete(i),a}).catch(e=>{throw n.get(i)===l&&n.delete(i),e});return n.set(i,l),l}function c(e){return Promise.all(e.map(e=>s(e)))}function l(e,n){t.set(e,n)}function u(e){for(let[t,n]of e)l(t,n)}function d(e){return t.get(e)}function f(e){let n=[];for(let r of e){let e=t.get(r);if(e===void 0)throw new Xt(r);n.push(e)}return n}function p(e){return t.has(e)}function m(e){for(let n of e)if(!t.has(n))return!1;return!0}function h(e){let n=t.get(e);return n===void 0?s(e):n}function g(){r++,t.clear(),n.clear()}return{clearResolvedThemes:g,getResolvedOrResolveTheme:h,getResolvedTheme:d,getResolvedThemes:f,hasRegisteredTheme:o,hasResolvedTheme:p,hasResolvedThemes:m,registerTheme:i,registerThemeIfAbsent:a,resolveTheme:s,resolveThemes:c,seedResolvedTheme:l,seedResolvedThemes:u}}var Qt=Zt();function $t(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let e;if(typeof n==`string`){if(e=Qt.getResolvedTheme(n),e==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else e=n,n=n.name,Qt.getResolvedTheme(n)??Qt.seedResolvedTheme(n,e);Vt.has(n)||(Vt.add(n),t.loadThemeSync(e))}}var en=new Map,tn=new Map,nn=new Map,rn=new Set;function an(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(rn.has(n.name))continue;let e=en.get(n.name);e??(e=n,en.set(n.name,e)),rn.add(e.name),t.loadLanguageSync(e.data)}}function on(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}async function sn(e){if(on())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=tn.get(e);if(t!=null)return t;try{let t=nn.get(e);if(t==null&&Object.prototype.hasOwnProperty.call(Se,e)&&(t=Se[e]),t==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n=t().then(({default:t})=>{let n={name:e,data:t};return en.has(e)||en.set(e,n),n});return tn.set(e,n),await n}finally{tn.delete(e)}}function cn(e){return en.get(e)??sn(e)}function ln({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:un(t)}}function un(e){return async()=>_e(qt(await e()))}var dn=`pierre`,fn=[`pierre-dark`,`pierre-dark-soft`,`pierre-dark-vibrant`,`pierre-dark-protanopia-deuteranopia`,`pierre-dark-tritanopia`],pn=[`pierre-light`,`pierre-light-soft`,`pierre-light-vibrant`,`pierre-light-protanopia-deuteranopia`,`pierre-light-tritanopia`],mn=[...pn,...fn],hn=new Set(pn);function gn(e){return hn.has(e)?`light`:`dark`}var _n={"pierre-dark":`Pierre Dark`,"pierre-dark-soft":`Pierre Dark Soft`,"pierre-dark-vibrant":`Pierre Dark Vibrant`,"pierre-dark-protanopia-deuteranopia":`Pierre Dark Protanopia & Deuteranopia`,"pierre-dark-tritanopia":`Pierre Dark Tritanopia`,"pierre-light":`Pierre Light`,"pierre-light-soft":`Pierre Light Soft`,"pierre-light-vibrant":`Pierre Light Vibrant`,"pierre-light-protanopia-deuteranopia":`Pierre Light Protanopia & Deuteranopia`,"pierre-light-tritanopia":`Pierre Light Tritanopia`},vn={"pierre-dark":()=>P(()=>import(`./pierre-dark-CpLgRqie.js`),[]),"pierre-dark-soft":()=>P(()=>import(`./pierre-dark-soft-kZQmAZld.js`),[]),"pierre-dark-vibrant":()=>P(()=>import(`./pierre-dark-vibrant-CpQYzh95.js`),[]),"pierre-dark-protanopia-deuteranopia":()=>P(()=>import(`./pierre-dark-protanopia-deuteranopia-B35FxJx-.js`),[]),"pierre-dark-tritanopia":()=>P(()=>import(`./pierre-dark-tritanopia-CpjhbsIL.js`),[]),"pierre-light":()=>P(()=>import(`./pierre-light-CoaEpmwp.js`),[]),"pierre-light-soft":()=>P(()=>import(`./pierre-light-soft-lWLdNTOI.js`),[]),"pierre-light-vibrant":()=>P(()=>import(`./pierre-light-vibrant-D80Fkn33.js`),[]),"pierre-light-protanopia-deuteranopia":()=>P(()=>import(`./pierre-light-protanopia-deuteranopia-0fSaH845.js`),[]),"pierre-light-tritanopia":()=>P(()=>import(`./pierre-light-tritanopia-CEbqgOJL.js`),[])};function yn(e){return ln({name:e,collection:dn,colorScheme:gn(e),displayName:_n[e],load:vn[e]})}var bn=Ht({themes:mn.map(e=>yn(e))}),xn=`shiki`,Sn=[`ayu-light`,`catppuccin-latte`,`everforest-light`,`github-light`,`github-light-default`,`github-light-high-contrast`,`gruvbox-light-hard`,`gruvbox-light-medium`,`gruvbox-light-soft`,`horizon-bright`,`kanagawa-lotus`,`light-plus`,`material-theme-lighter`,`min-light`,`night-owl-light`,`one-light`,`rose-pine-dawn`,`slack-ochin`,`snazzy-light`,`solarized-light`,`vitesse-light`],Cn=`andromeeda.aurora-x.ayu-dark.ayu-mirage.catppuccin-frappe.catppuccin-macchiato.catppuccin-mocha.dark-plus.dracula.dracula-soft.everforest-dark.github-dark.github-dark-default.github-dark-dimmed.github-dark-high-contrast.gruvbox-dark-hard.gruvbox-dark-medium.gruvbox-dark-soft.horizon.houston.kanagawa-dragon.kanagawa-wave.laserwave.material-theme.material-theme-darker.material-theme-ocean.material-theme-palenight.min-dark.monokai.night-owl.nord.one-dark-pro.plastic.poimandres.red.rose-pine.rose-pine-moon.slack-dark.solarized-dark.synthwave-84.tokyo-night.vesper.vitesse-black.vitesse-dark`.split(`.`),wn=new Set(Sn);function Tn(e){return wn.has(e)?`light`:`dark`}var En={andromeeda:()=>P(()=>import(`./andromeeda-vGVdxbeo.js`),[]),"aurora-x":()=>P(()=>import(`./aurora-x-CDeNXAV0.js`),[]),"ayu-dark":()=>P(()=>import(`./ayu-dark-DluEY0Gj.js`),[]),"ayu-light":()=>P(()=>import(`./ayu-light-C3h-C4tm.js`),[]),"ayu-mirage":()=>P(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[]),"catppuccin-frappe":()=>P(()=>import(`./catppuccin-frappe-C9Q5zVZY.js`),[]),"catppuccin-latte":()=>P(()=>import(`./catppuccin-latte-CtsyrtPq.js`),[]),"catppuccin-macchiato":()=>P(()=>import(`./catppuccin-macchiato-R8nAf1vR.js`),[]),"catppuccin-mocha":()=>P(()=>import(`./catppuccin-mocha-DjuaAJKi.js`),[]),"dark-plus":()=>P(()=>import(`./dark-plus-Cs2F2srj.js`),[]),dracula:()=>P(()=>import(`./dracula-BHWKrbxM.js`),[]),"dracula-soft":()=>P(()=>import(`./dracula-soft-5eyTD99u.js`),[]),"everforest-dark":()=>P(()=>import(`./everforest-dark-sB-x3p7T.js`),[]),"everforest-light":()=>P(()=>import(`./everforest-light-Df2xbC6M.js`),[]),"github-dark":()=>P(()=>import(`./github-dark-C-LZuMrd.js`),[]),"github-dark-default":()=>P(()=>import(`./github-dark-default-DXG-b-1a.js`),[]),"github-dark-dimmed":()=>P(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[]),"github-dark-high-contrast":()=>P(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[]),"github-light":()=>P(()=>import(`./github-light-EUqPIrTm.js`),[]),"github-light-default":()=>P(()=>import(`./github-light-default-BXViO-2h.js`),[]),"github-light-high-contrast":()=>P(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[]),"gruvbox-dark-hard":()=>P(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[]),"gruvbox-dark-medium":()=>P(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[]),"gruvbox-dark-soft":()=>P(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[]),"gruvbox-light-hard":()=>P(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[]),"gruvbox-light-medium":()=>P(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[]),"gruvbox-light-soft":()=>P(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[]),horizon:()=>P(()=>import(`./horizon-CE9ld1lL.js`),[]),"horizon-bright":()=>P(()=>import(`./horizon-bright-DSNQnXHK.js`),[]),houston:()=>P(()=>import(`./houston-CsvMBhTu.js`),[]),"kanagawa-dragon":()=>P(()=>import(`./kanagawa-dragon-Bozd7klA.js`),[]),"kanagawa-lotus":()=>P(()=>import(`./kanagawa-lotus-BmuOG9ZW.js`),[]),"kanagawa-wave":()=>P(()=>import(`./kanagawa-wave-BML5mF2J.js`),[]),laserwave:()=>P(()=>import(`./laserwave-C_8bwKvT.js`),[]),"light-plus":()=>P(()=>import(`./light-plus-DVQuIRkW.js`),[]),"material-theme":()=>P(()=>import(`./material-theme-Bm3Qr25_.js`),[]),"material-theme-darker":()=>P(()=>import(`./material-theme-darker-2IIEA8gg.js`),[]),"material-theme-lighter":()=>P(()=>import(`./material-theme-lighter-uhdI0v04.js`),[]),"material-theme-ocean":()=>P(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[]),"material-theme-palenight":()=>P(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[]),"min-dark":()=>P(()=>import(`./min-dark-BSWPekZh.js`),[]),"min-light":()=>P(()=>import(`./min-light-DDpmG2fV.js`),[]),monokai:()=>P(()=>import(`./monokai-B_bV9PQ9.js`),[]),"night-owl":()=>P(()=>import(`./night-owl-DhmEMT88.js`),[]),"night-owl-light":()=>P(()=>import(`./night-owl-light-eJ-hLW7d.js`),[]),nord:()=>P(()=>import(`./nord-Cb4Vim4T.js`),[]),"one-dark-pro":()=>P(()=>import(`./one-dark-pro-CLwyXe_n.js`),[]),"one-light":()=>P(()=>import(`./one-light-D7Lr4KcI.js`),[]),plastic:()=>P(()=>import(`./plastic-DQwYfKfQ.js`),[]),poimandres:()=>P(()=>import(`./poimandres-DRFjx7u4.js`),[]),red:()=>P(()=>import(`./red-DX1BQOs8.js`),[]),"rose-pine":()=>P(()=>import(`./rose-pine-aMsaMD1D.js`),[]),"rose-pine-dawn":()=>P(()=>import(`./rose-pine-dawn-8PwUyIlP.js`),[]),"rose-pine-moon":()=>P(()=>import(`./rose-pine-moon-DO-qXg-I.js`),[]),"slack-dark":()=>P(()=>import(`./slack-dark-DnToyrRv.js`),[]),"slack-ochin":()=>P(()=>import(`./slack-ochin-B2OO5cIa.js`),[]),"snazzy-light":()=>P(()=>import(`./snazzy-light-4G7pJPwS.js`),[]),"solarized-dark":()=>P(()=>import(`./solarized-dark-UdsmMDCL.js`),[]),"solarized-light":()=>P(()=>import(`./solarized-light-C1IUL_tW.js`),[]),"synthwave-84":()=>P(()=>import(`./synthwave-84-nFMaYfgc.js`),[]),"tokyo-night":()=>P(()=>import(`./tokyo-night-oM2G3aXe.js`),[]),vesper:()=>P(()=>import(`./vesper-DdrHHSXu.js`),[]),"vitesse-black":()=>P(()=>import(`./vitesse-black-fwtXNY1n.js`),[]),"vitesse-dark":()=>P(()=>import(`./vitesse-dark-BZCL-v6S.js`),[]),"vitesse-light":()=>P(()=>import(`./vitesse-light-VbXTXTou.js`),[])};function Dn(e){return ln({name:e,collection:xn,colorScheme:Tn(e),load:En[e]})}var On=Ht({themes:Object.freeze([...Sn.map(e=>Dn(e)),...Cn.map(e=>Dn(e))])});function kn(e){if(on())throw Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(Qt.hasRegisteredTheme(e))return;let t=On.getTheme(e);if(t!=null){Qt.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function An(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function jn(e){kn(e);let t=await Qt.resolveTheme(e);return An(e,t),t}function Mn(e){return Qt.getResolvedTheme(e)??jn(e)}var B;async function Nn({themes:e,langs:t,preferredHighlighter:n=`shiki-js`}){B??=xe({themes:[],langs:[`text`],engine:n===`shiki-wasm`?be(P(()=>import(`./wasm-BnjxR4X6.js`),[])):ye()});let r=Fn(B)?await B:B;B=r;let i=[];for(let e of t){if(e===`text`||e===`ansi`)continue;let t=cn(e);`then`in t?i.push(t):an(t,r)}let a=[];for(let t of e){let e=Mn(t);`then`in e?a.push(e):$t(e,B)}return(i.length>0||a.length>0)&&await Promise.all([Promise.all(i).then(e=>{an(e,r)}),Promise.all(a).then(e=>{$t(e,r)})]),r}function Pn(){if(B!=null&&!(`then`in B))return B}function Fn(e=B){return e!=null&&`then`in e}for(let e of bn.getThemes())Qt.registerThemeIfAbsent(e.name,e.load);function In(e=L){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}var Ln=new Map,Rn={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function zn(e){if(Ln.has(e))return Ln.get(e)??`text`;if(Rn[e]!=null)return Rn[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(Ln.has(t[1]))return Ln.get(t[1])??`text`;if(Rn[t[1]]!=null)return Rn[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return Ln.has(n)?Ln.get(n)??`text`:Rn[n]??`text`}function V(e){return{type:`text`,value:e}}function H({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function Bn({name:e,width:t=16,height:n=16,properties:r}){return H({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[H({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function Vn(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function Hn(e){return H({tagName:`div`,properties:{"data-gutter":``},children:e})}function Un(e,t,n,r={}){return H({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[H({tagName:`span`,properties:{"data-line-number-content":``},children:[V(`${t}`)]})]})}function U(e,t,n){return H({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Wn(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(V(`
|
|
5
|
+
`)),e}var Gn=Symbol(`no-token`),Kn=Symbol(`multiple-tokens`);function qn(e){let t=Jn(e);if(t!=null)return t;let n=Gn,r=[],i=[],a,o=()=>{if(i.length===0||a==null){i=[],a=void 0;return}if(i.length===1){let e=i[0];if(e?.type===`element`){Xn(e,a);for(let t of e.children)Yn(t)}else Yn(e);r.push(e),i=[],a=void 0;return}for(let e of i)Yn(e);r.push(H({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0},s=e=>{if(e!==Gn){if(e===Kn){n=Kn;return}if(n===Gn){n=e;return}n!==e&&(n=Kn)}};for(let t of e.children){let e=t.type===`element`?qn(t):Gn;if(s(e),typeof e!=`number`){o(),r.push(t);continue}a!=null&&a!==e&&o(),a??=e,i.push(t)}return o(),e.children=r,n}function Jn(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function Yn(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)Yn(t)}}function Xn(e,t){e.properties[`data-char`]=t}function Zn(e={}){let{classPrefix:t=`__shiki_`,classSuffix:n=``,classReplacer:r=e=>e}=e,i=new Map;function a(e){return Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function o(e){let o=typeof e==`string`?e:a(e),s=t+Qn(o)+n;return s=r(s),i.has(s)||i.set(s,typeof e==`string`?e:{...e}),s}return{name:`@shikijs/transformers:style-to-class`,pre(e){if(!e.properties.style)return;let t=o(e.properties.style);delete e.properties.style,this.addClassToHast(e,t)},tokens(e){for(let t of e)for(let e of t){if(!e.htmlStyle)continue;let t=o(e.htmlStyle);e.htmlStyle={},e.htmlAttrs||={},e.htmlAttrs.class?e.htmlAttrs.class+=` ${t}`:e.htmlAttrs.class=t}},getClassRegistry(){return i},getCSS(){let e=``;for(let[t,n]of i.entries())e+=`.${t}{${typeof n==`string`?n:a(n)}}`;return e},clearRegistry(){i.clear()}}}function Qn(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}function $n(e=!1,t=!1){let n={lineInfo:[]},r=[{line(e){return delete e.properties.class,e},pre(t){let r=Vn(t),i=[];if(r!=null){let t=1;for(let a of r.children)a.type===`element`&&(e&&qn(a),i.push(Wn(a,t,n)),t++);r.children=i}return t},...e?{tokens(e){for(let t of e){let e=0;for(let n of t){let t=n;t.__lineChar??=e,e+=n.content.length}}},preprocess(e,t){t.mergeWhitespaces=`never`},span(e,t,n,r,i){if(i?.offset!=null&&i.content!=null){let t=i.__lineChar;return t!=null&&(e.properties[`data-char`]=t),e}return e}}:null}];return t&&r.push(tr,er),e&&r.push({line:e=>(e.type===`element`&&e.children.length===0&&e.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),e)}),{state:n,transformers:r,toClass:er}}var er=Zn({classPrefix:`hl-`}),tr={name:`token-style-normalizer`,tokens(e){for(let t of e)for(let e of t){if(e.htmlStyle!=null)continue;let t={};e.color!=null&&(t.color=e.color),e.bgColor!=null&&(t[`background-color`]=e.bgColor),e.fontStyle!=null&&e.fontStyle!==0&&(e.fontStyle&1&&(t[`font-style`]=`italic`),e.fontStyle&2&&(t[`font-weight`]=`bold`),e.fontStyle&4&&(t[`text-decoration`]=`underline`)),Object.keys(t).length>0&&(e.htmlStyle=t)}}};function W(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var nr=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,rr=/^0(?:\.0+)?%?$/;function ir(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function ar(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function or(e){if(e==null)return null;let t=ar(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function sr(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||nr.test(t))return!0;let n=ir(t);return n!=null&&rr.test(n)}function cr(e,t,n){if(t==null||n==null)return!1;let r=or(e),i=or(t),a=or(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var lr=new WeakMap;function ur(e){let t=lr.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;G(r,`editor.background`,i),G(r,`editor.foreground`,a),G(r,`sideBar.background`,o),G(r,`sideBar.foreground`,s),G(r,`input.background`,n[`input.background`]??o),G(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),G(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),G(r,`gitDecoration.addedResourceForeground`,dr(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),G(r,`gitDecoration.modifiedResourceForeground`,dr(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),G(r,`gitDecoration.deletedResourceForeground`,dr(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(sr(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(sr(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(fr(l,o)||cr(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return lr.set(e,u),u}function G(e,t,n){n!=null&&n!==``&&(e[t]=n)}function dr(...e){for(let t of e)if(t!=null&&t!==``)return t}function fr(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function pr({theme:e=L,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=ur(i);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${W(`global`)}fg:${a.fg};`,r+=`${W(`global`)}bg:${a.bg};`,r+=mr(i,n)}else{let n=t.getTheme(e.dark),i=ur(n);r+=`${W(`global`)}dark:${i.fg};`,r+=`${W(`global`)}dark-bg:${i.bg};`,r+=mr(n,`dark`),n=t.getTheme(e.light),i=ur(n),r+=`${W(`global`)}light:${i.fg};`,r+=`${W(`global`)}light-bg:${i.bg};`,r+=mr(n,`light`)}return r}function mr(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${W(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${W(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${W(`global`)}${t}modified-color:${a};`),n}function hr(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t.children;t=`children`in t?t.children[0]:null}throw console.error(e),Error(`getLineNodes: Unable to find children`)}function gr(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function _r(e,t){return zt(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function vr(e){let t=e.lang??zn(e.name),n=e.lang??(e.prevName==null?`text`:zn(e.prevName));return t===`text`&&n===`text`}function K(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function yr(e){return{...kt,...e}}function br(e,t){let n=xr(e,t);return t?n:e.diffHeaderHeight+n}function xr(e,t){return e.paddingTop??(t?e.spacing:0)}function Sr(e){return e.paddingBottom??e.spacing}function Cr(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function wr(e){return[R(e.additionStart,e.additionCount)+1,z(e.additionStart,e.additionCount)+1]}function q({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function Tr(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-z(t.additionStart,t.additionCount),r=e.deletionLines.length-z(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function Er({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-z(n.additionStart,n.additionCount),i=e.deletionLines.length-z(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function J({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=Er({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function Dr({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=wr(a);if(t<o){let s=q({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=J({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=wr(a);return t<o+i.fromStart||t>=o+i.rangeSize}function Or({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=wr(n),l=q({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=J({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function kr({type:e,metrics:t}){return t.hunkSeparatorHeight??Cr(e)}function Ar({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function jr({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function Mr(e){return e!==`simple`&&e!==`metadata`}function Nr({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!jr({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=kr({type:e,metrics:t}),a=Ar({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Pr({type:e,metrics:t}){if(!Mr(e))return;let n=kr({type:e,metrics:t}),r=Ar({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function Fr({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=Ir({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=R(r.deletionStart,r.deletionCount),s=R(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=q({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?J({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(zr(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,zr(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,S=s+1,C=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===C;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(zr(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:S+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,S+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=Br(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(Vr({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,S+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(zr(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:S+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function Ir({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=Lr({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function Lr({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=q({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?J({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function Rr(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function zr(e,t,n,r,i,a){let[o,s]=Rr(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function Br(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function Vr({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var Y=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},Hr=new class extends Y{};function Ur(e,t,n){return Hr.diff(e,t,n)}function Wr(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Gr(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Kr(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function qr(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Jr(e,t){return Kr(e,t,``)}function Yr(e,t){return qr(e,t,``)}function Xr(e,t){return t.slice(0,Zr(e,t))}function Zr(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Qr(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function $r(e,t){if(t)return ti(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function ei(e,t){if(t)return ti(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function ti(e,t){if(!t)return[ei(e),$r(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Qr(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var ni=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,ri=RegExp(`[${ni}]+|\\s+|[^${ni}]`,`ug`);new class extends Y{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Qr(e,r)}else n=e.match(ri)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&ii(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&ii(n,i,r,null,t.intlSegmenter),e}};function ii(e,t,n,r,i){if(t&&n){let[a,o]=ti(t.value,i),[s,c]=ti(n.value,i);if(e){let r=Wr(a,s);e.value=qr(e.value,s,r),t.value=Jr(t.value,r),n.value=Jr(n.value,r)}if(r){let e=Gr(o,c);r.value=Kr(r.value,c,e),t.value=Yr(t.value,e),n.value=Yr(n.value,e)}}else if(n){if(e){let e=ei(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=ei(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=ei(r.value,i),[a,o]=ti(t.value,i),s=Wr(n,a);t.value=Jr(t.value,s);let c=Gr(Jr(n,s),o);t.value=Yr(t.value,c),r.value=Kr(r.value,n,c),e.value=qr(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=ei(r.value,i),n=Xr($r(t.value,i),e);t.value=Yr(t.value,n)}else if(e){let n=Xr($r(e.value,i),ei(t.value,i));t.value=Jr(t.value,n)}}var ai=new class extends Y{tokenize(e){let t=RegExp(`(\\r?\\n)|[${ni}]+|[^\\S\\n\\r]+|[^${ni}]`,`ug`);return e.match(t)||[]}};function oi(e,t,n){return ai.diff(e,t,n)}var si=new class extends Y{constructor(){super(...arguments),this.tokenize=li}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
6
6
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
7
7
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
8
8
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
9
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function
|
|
10
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
11
|
-
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function
|
|
12
|
-
`)}let n=[];if(e.isGit){if(t=
|
|
9
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function ci(e,t,n){return si.diff(e,t,n)}function li(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
10
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function ui(e){return e==`.`||e==`!`||e==`?`}new class extends Y{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(ui(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends Y{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends Y{constructor(){super(...arguments),this.tokenize=li}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(di(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function di(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=di(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=di(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends Y{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function fi(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function pi(e){if(!fi(e))return e;let t=`"`,n=new TextEncoder().encode(e),r=0;for(;r<n.length;){let e=n[r];t+=e===7?`\\a`:e===8?`\\b`:e===9?`\\t`:e===10?`\\n`:e===11?`\\v`:e===12?`\\f`:e===13?`\\r`:e===34?`\\"`:e===92?`\\\\`:e>=32&&e<=126?String.fromCharCode(e):`\\`+e.toString(8).padStart(3,`0`),r++}return t+=`"`,t}var mi={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function hi(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;ci(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(ci(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||vi(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s){if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
11
|
+
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function gi(e,t){if(t||=mi,Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(e=>e.isGit))throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>gi(e,t)).join(`
|
|
12
|
+
`)}let n=[];if(e.isGit){if(t=mi,!e.oldFileName)throw Error(`oldFileName must be specified for Git patches`);if(!e.newFileName)throw Error(`newFileName must be specified for Git patches`);let r=e.oldFileName,i=e.newFileName;e.isCreate&&r===`/dev/null`?r=i.replace(/^b\//,`a/`):e.isDelete&&i===`/dev/null`&&(i=r.replace(/^a\//,`b/`)),n.push(`diff --git `+pi(r)+` `+pi(i)),e.isDelete&&n.push(`deleted file mode `+(e.oldMode??`100644`)),e.isCreate&&n.push(`new file mode `+(e.newMode??`100644`)),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(n.push(`old mode `+e.oldMode),n.push(`new mode `+e.newMode)),e.isRename&&(n.push(`rename from `+pi((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+pi((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+pi((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+pi((e.newFileName??``).replace(/^b\//,``))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`);let r=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||r)&&(n.push(`--- `+pi(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+pi(e.newFileName)+(e.newHeader?` `+e.newHeader:``)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t],i=r.oldLines===0?r.oldStart-1:r.oldStart,a=r.newLines===0?r.newStart-1:r.newStart;n.push(`@@ -`+i+`,`+r.oldLines+` +`+a+`,`+r.newLines+` @@`);for(let e of r.lines)n.push(e)}return n.join(`
|
|
13
13
|
`)+`
|
|
14
|
-
`}function
|
|
14
|
+
`}function _i(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;hi(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?gi(e,o.headerOptions):void 0)}}))}else{let s=hi(e,t,n,r,i,a,o);return s?gi(s,o?.headerOptions):void 0}}function vi(e){let t=e.endsWith(`
|
|
15
15
|
`),n=e.split(`
|
|
16
16
|
`).map(e=>e+`
|
|
17
|
-
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function vi({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function yi({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}var bi={forcePlainText:!1};function xi(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=bi){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=dr({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??Ci();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}Nr({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&Si({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=wi({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function Si({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=J(e),t=J(t),e.length>s||t.length>s))return;let c=o===`char`?Hr(e,t):ai(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(yi({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),yi({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?yi({item:e,arr:l,enableJoin:d,isLastItem:t}):yi({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(vi({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(vi({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function Ci(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function wi({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=R,...l}}){let u=s??Ln(e.name),d=s??Ln(t.name),{state:f,transformers:p}=Zn(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:K(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:K(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,pr(i.codeToHast(J(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,pr(i.codeToHast(J(t.contents),m)))}}var Ti=(0,P.createContext)(void 0);function Ei(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function Di(e,t){let n=e?.theme??R,r=t?.theme??R,i=Oi(e),a=Oi(t);return Rt(n,r)&&Ei(e,t,[`theme`,`parseDiffOptions`])&&Ei(i,a)}function Oi(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}var ki=new Set,Ai=null;function ji(e){ki.add(e),Ai??=requestAnimationFrame(Ni)}function Mi(e){ki.delete(e)&&ki.size===0&&Ai!=null&&(cancelAnimationFrame(Ai),Ai=null)}function Ni(e){let t=new Set(ki);ki.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}Ai=ki.size>0?requestAnimationFrame(Ni):null}function Pi(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}var Fi=new TextEncoder,Ii=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Li=/[\uD800-\uDFFF]/,Ri=1024,zi=new Uint8Array(Ri);function Bi(){zi.length!==Ri&&(zi=new Uint8Array(Ri))}function Z(e){if(e.length===0)return e;if(Li.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;zi.length<t&&(zi=new Uint8Array(t));let{written:n}=Fi.encodeInto(e,zi);return Ii.decode(zi.subarray(0,n))}var Vi=4096,Hi=.5;function Ui(e){for(let t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!==`change`)continue;let i=Gi(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}Wi(t,e)}}function Wi(e,t){let{hunkContent:n}=e;for(let e=1;e<n.length;e++){let r=n[e],i=n[e-1];if(r.type!==`change`||r.additions>0&&r.deletions>0||i.type!==`context`)continue;let a=r.additions>0,o=a?t.additionLines:t.deletionLines,s=a?r.additionLineIndex:r.deletionLineIndex,c=a?r.additions:r.deletions,l=o[s]??``;if(l.trim()!==``)continue;let u=!0;for(let e=1;e<c;e++)if(o[s+e]!==l){u=!1;break}if(!u)continue;let d=0;for(;d<i.lines&&t.additionLines[i.additionLineIndex+i.lines-1-d]===l;)d++;if(d===0||e===1&&d===i.lines)continue;r.additionLineIndex-=d,r.deletionLineIndex-=d;let f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,m=n[e+1];m?.type===`context`?(m.lines+=d,m.additionLineIndex=f,m.deletionLineIndex=p):n.splice(e+1,0,{type:`context`,lines:d,additionLineIndex:f,deletionLineIndex:p}),i.lines-=d,i.lines===0&&(n.splice(e-1,1),e--)}}function Gi(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:a}=t,o=Math.min(n,r),s=Math.abs(r-n);if(o===0||s===0||o*(s+1)>Vi)return null;let c=[];for(let t=0;t<n;t++)c.push(qi(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(qi(e.additionLines[a+t]??``));let u=r>n,d=0,f=-1;for(let e=0;e<=s;e++){let t=0;for(let n=0;n<o;n++)t+=Ji(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*Hi:t>f&&(f=t,d=e)}if(d===0)return null;let p=[],m=(e,t,n,r)=>{(e>0||t>0)&&p.push({type:`change`,deletions:e,additions:t,deletionLineIndex:n,additionLineIndex:r})};return u?(m(0,d,i,a),m(o,o,i,a+d),m(0,r-o-d,i+o,a+d+o)):(m(d,0,i,a),m(o,o,i+d,a),m(n-o-d,0,i+d+o,a+o)),p}var Ki=/\s+/g;function qi(e){return e.replace(Ki,``)}function Ji(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return(i+a)/n}function Yi(e,t){try{return Xi(e,t)}finally{Bi()}}function Xi(e,{cacheKey:t,isGitDiff:n=pt.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=ia(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=Qi(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=ta(f),m=0,h=0;if(p==null||c==null){if(c!=null){if(a)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}c={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:l,additionLines:!l&&r!=null&&i!=null?Zi(i.contents):[],deletionLines:!l&&r!=null&&i!=null?Zi(r.contents):[],cacheKey:oa(t)},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0);for(let e of s){if(e.startsWith(`diff --git`)){let t=e.trim().match(_t),n=t?.[1]??t?.[2],r=t?.[3]??t?.[4];if(n==null||r==null){if(a)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}c.name=Z(r.trim()),n!==r&&(c.prevName=Z(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?gt:ht):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=Z(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=Z(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=Z(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=Z(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=Z(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=Z(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?c.type=`rename-pure`:c.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(vt)??[];t!=null&&(c.prevObjectId=Z(t)),n!=null&&(c.newObjectId=Z(n)),r!=null&&(c.mode=Z(r))}e.startsWith(`rename from `)&&(c.prevName=Z(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=Z(e.slice(10).trim()))}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
|
|
17
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function yi({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function bi({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}var xi={forcePlainText:!1};function Si(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=xi){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=pr({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??wi();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}Fr({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&Ci({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=Ti({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function Ci({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=K(e),t=K(t),e.length>s||t.length>s))return;let c=o===`char`?Ur(e,t):oi(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(bi({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),bi({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?bi({item:e,arr:l,enableJoin:d,isLastItem:t}):bi({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(yi({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(yi({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function wi(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Ti({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=L,...l}}){let u=s??zn(e.name),d=s??zn(t.name),{state:f,transformers:p}=$n(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:W(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:W(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,hr(i.codeToHast(K(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,hr(i.codeToHast(K(t.contents),m)))}}var Ei=(0,F.createContext)(void 0);function Di(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function Oi(e,t){let n=e?.theme??L,r=t?.theme??L,i=ki(e),a=ki(t);return zt(n,r)&&Di(e,t,[`theme`,`parseDiffOptions`])&&Di(i,a)}function ki(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}var Ai=new Set,ji=null;function Mi(e){Ai.add(e),ji??=requestAnimationFrame(Pi)}function Ni(e){Ai.delete(e)&&Ai.size===0&&ji!=null&&(cancelAnimationFrame(ji),ji=null)}function Pi(e){let t=new Set(Ai);Ai.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}ji=Ai.size>0?requestAnimationFrame(Pi):null}function Fi(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}var Ii=new TextEncoder,Li=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Ri=/[\uD800-\uDFFF]/,zi=1024,Bi=new Uint8Array(zi);function Vi(){Bi.length!==zi&&(Bi=new Uint8Array(zi))}function X(e){if(e.length===0)return e;if(Ri.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;Bi.length<t&&(Bi=new Uint8Array(t));let{written:n}=Ii.encodeInto(e,Bi);return Li.decode(Bi.subarray(0,n))}var Hi=4096,Ui=.5;function Wi(e){for(let t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!==`change`)continue;let i=Ki(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}Gi(t,e)}}function Gi(e,t){let{hunkContent:n}=e;for(let e=1;e<n.length;e++){let r=n[e],i=n[e-1];if(r.type!==`change`||r.additions>0&&r.deletions>0||i.type!==`context`)continue;let a=r.additions>0,o=a?t.additionLines:t.deletionLines,s=a?r.additionLineIndex:r.deletionLineIndex,c=a?r.additions:r.deletions,l=o[s]??``;if(l.trim()!==``)continue;let u=!0;for(let e=1;e<c;e++)if(o[s+e]!==l){u=!1;break}if(!u)continue;let d=0;for(;d<i.lines&&t.additionLines[i.additionLineIndex+i.lines-1-d]===l;)d++;if(d===0||e===1&&d===i.lines)continue;r.additionLineIndex-=d,r.deletionLineIndex-=d;let f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,m=n[e+1];m?.type===`context`?(m.lines+=d,m.additionLineIndex=f,m.deletionLineIndex=p):n.splice(e+1,0,{type:`context`,lines:d,additionLineIndex:f,deletionLineIndex:p}),i.lines-=d,i.lines===0&&(n.splice(e-1,1),e--)}}function Ki(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:a}=t,o=Math.min(n,r),s=Math.abs(r-n);if(o===0||s===0||o*(s+1)>Hi)return null;let c=[];for(let t=0;t<n;t++)c.push(Ji(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(Ji(e.additionLines[a+t]??``));let u=r>n,d=0,f=-1;for(let e=0;e<=s;e++){let t=0;for(let n=0;n<o;n++)t+=Yi(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*Ui:t>f&&(f=t,d=e)}if(d===0)return null;let p=[],m=(e,t,n,r)=>{(e>0||t>0)&&p.push({type:`change`,deletions:e,additions:t,deletionLineIndex:n,additionLineIndex:r})};return u?(m(0,d,i,a),m(o,o,i,a+d),m(0,r-o-d,i+o,a+d+o)):(m(d,0,i,a),m(o,o,i+d,a),m(n-o-d,0,i+d+o,a+o)),p}var qi=/\s+/g;function Ji(e){return e.replace(qi,``)}function Yi(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return(i+a)/n}function Xi(e,t){try{return Zi(e,t)}finally{Vi()}}function Zi(e,{cacheKey:t,isGitDiff:n=mt.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=aa(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=$i(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=na(f),m=0,h=0;if(p==null||c==null){if(c!=null){if(a)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}c={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:l,additionLines:!l&&r!=null&&i!=null?Qi(i.contents):[],deletionLines:!l&&r!=null&&i!=null?Qi(r.contents):[],cacheKey:sa(t)},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0);for(let e of s){if(e.startsWith(`diff --git`)){let t=e.trim().match(vt),n=t?.[1]??t?.[2],r=t?.[3]??t?.[4];if(n==null||r==null){if(a)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}c.name=X(r.trim()),n!==r&&(c.prevName=X(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?_t:gt):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=X(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=X(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=X(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=X(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=X(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=X(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?c.type=`rename-pure`:c.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(yt)??[];t!=null&&(c.prevObjectId=X(t)),n!=null&&(c.newObjectId=X(n)),r!=null&&(c.mode=X(r))}e.startsWith(`rename from `)&&(c.prevName=X(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=X(e.slice(10).trim()))}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
|
|
18
18
|
`||s[s.length-1]===`\r`||s[s.length-1]===`\r
|
|
19
|
-
`||s[s.length-1]===``);)s.pop();let{additionStart:v,deletionStart:y}=p;u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:
|
|
20
|
-
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function
|
|
21
|
-
`&&n!==`\r`)return!1}return!0}function
|
|
19
|
+
`||s[s.length-1]===``);)s.pop();let{additionStart:v,deletionStart:y}=p;u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:sa(p.hunkContext),hunkSpecs:X(f),noEOFCRAdditions:!1,noEOFCRDeletions:!1},x=0,S=0;for(let e=1;e<s.length;e++){let t=s[e];if(x>=b.additionCount&&S>=b.deletionCount&&!t.startsWith(`\\`)){if(a&&ea(t)&&!ta(t))throw Error(`parsePatchContent: hunk has more lines than expected`);break}let n=t[0];if(n!==`+`&&n!==`-`&&n!==` `&&n!==`\\`){if(a)throw Error(`parsePatchContent: invalid hunk line`);console.error(`parseLineType: Invalid firstChar: "${n}", full line: "${t}"`),console.error(`processFile: invalid rawLine:`,t);continue}let r=ca(n);if(r===`addition`){if(a&&x>=b.additionCount)throw Error(`parsePatchContent: hunk has too many addition lines`);let e=la(t);(g==null||g.type!==`change`)&&(g=ua(`change`,u,d),b.hunkContent.push(g)),d++,x++,l&&c.additionLines.push(e),g.additions++,m++,_=`addition`}else if(r===`deletion`){if(a&&S>=b.deletionCount)throw Error(`parsePatchContent: hunk has too many deletion lines`);let e=la(t);(g==null||g.type!==`change`)&&(g=ua(`change`,u,d),b.hunkContent.push(g)),u++,S++,l&&c.deletionLines.push(e),g.deletions++,h++,_=`deletion`}else if(r===`context`){if(a&&(S>=b.deletionCount||x>=b.additionCount))throw Error(`parsePatchContent: hunk has too many context lines`);let e=la(t);(g==null||g.type!==`context`)&&(g=ua(`context`,u,d),b.hunkContent.push(g)),d++,u++,x++,S++,l&&(c.deletionLines.push(e),c.additionLines.push(e)),g.lines++,_=`context`}else if(r===`metadata`&&g!=null){if(g.type===`context`?(b.noEOFCRAdditions=!0,b.noEOFCRDeletions=!0):_===`deletion`?b.noEOFCRDeletions=!0:_===`addition`&&(b.noEOFCRAdditions=!0),l&&(_===`addition`||_===`context`)){let e=c.additionLines.length-1;e>=0&&(c.additionLines[e]=K(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=K(c.deletionLines[e]))}}}if(a&&(x!==b.additionCount||S!==b.deletionCount))throw Error(`parsePatchContent: hunk line count mismatch`);b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(R(b.additionStart,b.additionCount)-o,0),c.hunks.push(b),o=z(b.additionStart,b.additionCount);for(let e of b.hunkContent)e.type===`context`?(b.splitLineCount+=e.lines,b.unifiedLineCount+=e.lines):(b.splitLineCount+=Math.max(e.additions,e.deletions),b.unifiedLineCount+=e.deletions+e.additions);b.splitLineStart=c.splitLineCount+b.collapsedBefore,b.unifiedLineStart=c.unifiedLineCount+b.collapsedBefore,c.splitLineCount+=b.collapsedBefore+b.splitLineCount,c.unifiedLineCount+=b.collapsedBefore+b.unifiedLineCount}if(c!=null){if(a&&l&&!n&&c.hunks.length===0)throw Error(`parsePatchContent: unified file has no hunks`);if(c.hunks.length>0&&!l&&c.additionLines.length>0&&c.deletionLines.length>0){let e=c.hunks[c.hunks.length-1],t=z(e.additionStart,e.additionCount),n=c.additionLines.length,r=Math.max(n-t,0);c.splitLineCount+=r,c.unifiedLineCount+=r}return n||(c.prevName!=null&&c.name!==c.prevName?c.hunks.length>0?c.type=`rename-changed`:c.type=`rename-pure`:(r==null||r.contents===``)&&i!=null&&i.contents!==``?c.type=`new`:r!=null&&r.contents!==``&&(i==null||i.contents===``)&&(c.type=`deleted`)),c.type!==`rename-pure`&&c.type!==`rename-changed`&&(c.prevName=void 0),Wi(c),c}}function Qi(e){let t=$i(e);for(let e=0;e<t.length;e++)t[e]=X(t[e]);return t}function $i(e){if(e.length===0)return[``];let t=[],n=0;for(;;){let r=e.indexOf(`
|
|
20
|
+
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function ea(e){let t=e[0];return t===`+`||t===`-`||t===` `}function ta(e){if(!e.startsWith(`--`))return!1;for(let t=2;t<e.length;t++){let n=e[t];if(n!==` `&&n!==` `&&n!==`
|
|
21
|
+
`&&n!==`\r`)return!1}return!0}function na(e){if(!e.startsWith(`@@ -`))return;let t=4,n=ra(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===`,`){let n=ra(e,t+1);if(n==null)return;i=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`+`)return;t+=2;let a=ra(e,t);if(a==null)return;let o=a.value;t=a.endIndex;let s=1;if(e[t]===`,`){let n=ra(e,t+1);if(n==null)return;s=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`@`||e[t+2]!==`@`)return;let c,l=t+3;return e[l]===` `&&(c=ia(e.slice(l+1))),{additionCount:s,additionStart:o,deletionCount:i,deletionStart:r,hunkContext:c}}function ra(e,t){let n=t,r=0;for(;n<e.length;n++){let t=e.charCodeAt(n)-48;if(t<0||t>9)break;r=r*10+t}if(n!==t)return{value:r,endIndex:n}}function ia(e){return e.endsWith(`\r
|
|
22
22
|
`)?e.slice(0,-2):e.endsWith(`
|
|
23
|
-
`)?e.slice(0,-1):e}function
|
|
24
|
-
`:t)}function
|
|
23
|
+
`)?e.slice(0,-1):e}function aa(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.startsWith(t)?0:oa(e,n,0);if(r===-1)return[e];let i=[];r>0&&i.push(e.slice(0,r));let a=r;for(;;){let t=oa(e,n,a+1);if(t===-1)break;i.push(e.slice(a,t)),a=t}return i.push(e.slice(a)),i}function oa(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function sa(e){return e==null?e:X(e)}function ca(e){return e===` `?`context`:e===`\\`?`metadata`:e===`+`?`addition`:`deletion`}function la(e){let t=e.slice(1);return X(t===``?`
|
|
24
|
+
`:t)}function ua(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}var da=`/dev/null`;function fa(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??pa(),a=t??pa(),o=Xi(_i(i.name,a.name,i.contents,a.contents,i.header,a.header,n),{cacheKey:(()=>{let n=e?.cacheKey??e?.name,r=t?.cacheKey??t?.name;return n!=null&&r!=null?n+`:`+r:n??r})(),oldFile:i,newFile:a,throwOnError:r});if(o==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(o.type=`new`,o.prevName=void 0):t===null&&(o.type=`deleted`,o.prevName=void 0);let s=t?.lang??(t===null?e?.lang:void 0);return s!=null&&(o.lang=s),o}function pa(){return{name:da,contents:``}}function ma(e,t){let n=fa({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function ha(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function ga(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function _a(e,t){return t.length>0&&t.length<e.deletionLines.length&&ga(t)}function va(e,t,n){let r=e.deletionLines.join(``),i=ha(t.length,r),a=fa({name:e.prevName??e.name,contents:r},{name:e.name,contents:i,lang:e.lang},n);return{hunks:a.hunks,splitLineCount:a.splitLineCount,unifiedLineCount:a.unifiedLineCount,additionLines:t,deletionLines:a.deletionLines,type:a.type}}function ya(e,t){return va(e,[``],t)}function ba(e,t){if(e.additionLines.length===0)return ya(e,t);if(_a(e,e.additionLines))return va(e,e.additionLines,t);let n=e.additionLines,r=ma(e,t);return Sa(r,n),r}function xa(e){return e.length>1&&e.at(-1)===``}function Sa(e,t){if(!xa(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&z(i.additionStart,i.additionCount)===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,Ma(e);return}}}function Ca(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return wa(e,ma(e,n));let r=Array.from(t);if(r.length===0)return wa(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||K(r)===K(i))return wa(e,ma(e,n))}let i=Ta(e,r);if(i.size===0)return wa(e,ma(e,n));for(let t of i)if(!Da(e,t,n))return wa(e,ma(e,n));return Ma(e),Tr(e)?wa(e,ma(e,n)):wa(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function wa(e,t){return Object.assign(e,t),t}function Ta(e,t){let n=new Set;for(let r of t){let t=Ea(e,r);if(t==null)return new Set;n.add(t)}return n}function Ea(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function Da(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=fa({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:(ka(r,s),Oa(e,t),!0)}function Oa(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
|
|
25
25
|
`),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
|
|
26
|
-
`)}function Oa(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>ka(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,Aa(e)}function ka(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function Aa(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function ja(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(z(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,Aa(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=B(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-B(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var Ma=new WeakMap;function Na(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function Pa(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function Fa(e,t){let n=e.hunks,r=e.additionLines,i=Na(r),a=i===r?e:{...e,additionLines:i},o=Ga(n,Wa(a,t),e.deletionLines.length),s=Ja(a,o);if(e.additionLines=i,e.hunks=s,e.editSessionDirty=!0,io(e),xa(e,r),Za(n,e.hunks))return{regions:o.map(e=>e.previousSpan)}}function Ia(e,t,n,r){let i=Array.from(new Set(t)).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(i.length===0)return;let{hunks:a}=e,o,s=0;for(let t of i){for(;s<a.length;){let e=a[s];if(t<eo(e)+e.additionCount)break;s++}let r=a[s],i=r==null?void 0:eo(r);if(i==null||t<i||o!=null&&o!==s)return Fa(e,n);o=s}if(o!=null){if(La(e,i,o,r,n)){e.editSessionDirty=!0;return}return Fa(e,n)}}function La(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=Ra(e),o=e.hunks[n];if(o.hunkContent.some(za))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function Ra(e){let t=Ma.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return Ma.set(e,{lines:e.deletionLines,set:n}),n}function za(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function Ba(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function Va(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=Y({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=to(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=X({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=to(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function Ha(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=to(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,to(i)+i.deletionCount,e.deletionLines.length),n}function Ua(e,t){return e.editSessionDirty===!0&&(e.editSessionDirty=void 0,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?pa(e,t):ya(e,t)),!0)}function Wa(e,t){if(Pa(e.deletionLines,e.additionLines)==null)return[];let n=da({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),r=[],i=0,a=0;for(let e of n.hunks){let t=e.additionCount>0?e.additionLineIndex-i:e.deletionLineIndex-a;i+=t,a+=t;for(let t of e.hunkContent){if(t.type===`context`){i+=t.lines,a+=t.lines;continue}let e=ka(t,0,0);e.additions===0&&(e.additionLineIndex=i),e.deletions===0&&(e.deletionLineIndex=a),r.push(e),i+=e.additions,a+=e.deletions}}return r}function Ga(e,t,n){let r=e.map((e,t)=>{let n=to(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&Ka(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=qa(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function Ka(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function qa(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function Ja(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);Xa(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);Xa(s,c,i,r),r+=c,i+=c,n.push(Ya(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function Ya(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:no(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:ro(t.additionStart,r),deletionStart:no(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:ro(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${no(t.deletionStart,i)},${i} +${no(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return Aa(s),s}function Xa(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function Za(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(to(r)!==to(i)||r.deletionCount!==i.deletionCount||eo(r)!==eo(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!Qa(r,i))return!0}return!1}function Qa(e,t){let n=$a(e),r=$a(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*$a(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function eo(e){return z(e.additionStart,e.additionCount)}function to(e){return z(e.deletionStart,e.deletionCount)}function no(e,t){return t===0?e:e+1}function ro(e,t){return t===0?e-1:e}function io(e){ja(e);for(let t=0;t<e.hunks.length;t++)Da(e,t)}function ao(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}var oo=`-1,-1`;function so(e){return e?.some(e=>e.lineNumber===0)??!1}function co(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function lo(e){return e.startingLine===0&&e.totalLines>0}function uo(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function fo(){return W({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[Rn({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function po(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var mo=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),Mi(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||Pi(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&po(e.composedPath())||(Q(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(Q(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(Q(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){Q(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();Q(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);Q(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=yo(i)&&this.hoveredLine?.lineElement===i.lineElement;vo(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),vo(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),yo(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(xo(i)&&p!=null){p(i);break}if(bo(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!yo(i))break;vo(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,Q(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),Q(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),Q(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();po(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(uo(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=De(fo());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);_o(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(wo(t));if(_o(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(_o(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(_o(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&po(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=wo(e);if(t&&po(n))return;let r=To(e);return r==null?this.pathFromAnnotationSlot(e):wo(r)}pathFromAnnotationSlot(e){let t=Do(Eo(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:wo(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=Oo(t)?t:Oo(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}Pi(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,ji(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{Mi(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!Ao(this.renderedSelectedLinesState,n),i=!Ao(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);So(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=Mo(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=Mo(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:Co(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:Co(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:jo(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:jo(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function ho({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:go({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function go({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function _o(e){return e!=null&&`kind`in e&&e.kind===`line`}function vo(e){return e!=null&&`kind`in e&&e.kind===`token`}function yo(e){return _o(e)||vo(e)}function bo(e){return`type`in e&&e.type===`line-info`}function xo(e){return`kind`in e&&e.kind===`merge-conflict-action`}function So(e){return e===`current`||e===`incoming`||e===`both`}function Co(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function wo(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function To(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function Eo(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function Do(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function Oo(e){return e!=null&&typeof e.elementFromPoint==`function`}function ko(e,t){return e===t||Pi(e??void 0,t??void 0)}function Ao(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&ko(e?.range??null,t.range)}function jo(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function Mo(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function Q(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var No=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),Io(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?zo(t):Bo(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:Po(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:Fo(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&Lo(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function Po(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function Fo(e){return Math.max(Math.ceil(e),0)}function Io(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?Lo(e,{codeWidthChanged:!0,numberWidthChanged:!0}):Ro(e))}function Lo(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function Ro(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function zo(e){e.codeElement.isConnected&&Ro(e)}function Bo(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}function Vo(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Ho(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!tn.has(t))return!1;return!0}function Uo(e){for(let t of Pn(e))if(!Bt.has(t))return!1;return!0}function Wo(e,t){return e.endsWith(`\r
|
|
26
|
+
`)}function ka(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>Aa(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,ja(e)}function Aa(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function ja(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function Ma(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(R(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,ja(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=z(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-z(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var Na=new WeakMap;function Pa(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function Fa(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function Ia(e,t){let n=e.hunks,r=e.additionLines,i=Pa(r),a=i===r?e:{...e,additionLines:i},o=Ka(n,Ga(a,t),e.deletionLines.length),s=Ya(a,o);if(e.additionLines=i,e.hunks=s,e.editSessionDirty=!0,ao(e),Sa(e,r),Qa(n,e.hunks))return{regions:o.map(e=>e.previousSpan)}}function La(e,t,n,r){let i=Array.from(new Set(t)).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(i.length===0)return;let{hunks:a}=e,o,s=0;for(let t of i){for(;s<a.length;){let e=a[s];if(t<to(e)+e.additionCount)break;s++}let r=a[s],i=r==null?void 0:to(r);if(i==null||t<i||o!=null&&o!==s)return Ia(e,n);o=s}if(o!=null){if(Ra(e,i,o,r,n)){e.editSessionDirty=!0;return}return Ia(e,n)}}function Ra(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=za(e),o=e.hunks[n];if(o.hunkContent.some(Ba))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function za(e){let t=Na.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return Na.set(e,{lines:e.deletionLines,set:n}),n}function Ba(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function Va(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function Ha(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=q({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=no(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=J({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=no(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function Ua(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=no(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,no(i)+i.deletionCount,e.deletionLines.length),n}function Wa(e,t){return e.editSessionDirty===!0&&(e.editSessionDirty=void 0,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?ma(e,t):ba(e,t)),!0)}function Ga(e,t){if(Fa(e.deletionLines,e.additionLines)==null)return[];let n=fa({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),r=[],i=0,a=0;for(let e of n.hunks){let t=e.additionCount>0?e.additionLineIndex-i:e.deletionLineIndex-a;i+=t,a+=t;for(let t of e.hunkContent){if(t.type===`context`){i+=t.lines,a+=t.lines;continue}let e=Aa(t,0,0);e.additions===0&&(e.additionLineIndex=i),e.deletions===0&&(e.deletionLineIndex=a),r.push(e),i+=e.additions,a+=e.deletions}}return r}function Ka(e,t,n){let r=e.map((e,t)=>{let n=no(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&qa(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=Ja(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function qa(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function Ja(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function Ya(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);Za(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);Za(s,c,i,r),r+=c,i+=c,n.push(Xa(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function Xa(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:ro(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:io(t.additionStart,r),deletionStart:ro(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:io(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${ro(t.deletionStart,i)},${i} +${ro(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return ja(s),s}function Za(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function Qa(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(no(r)!==no(i)||r.deletionCount!==i.deletionCount||to(r)!==to(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!$a(r,i))return!0}return!1}function $a(e,t){let n=eo(e),r=eo(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*eo(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function to(e){return R(e.additionStart,e.additionCount)}function no(e){return R(e.deletionStart,e.deletionCount)}function ro(e,t){return t===0?e:e+1}function io(e,t){return t===0?e-1:e}function ao(e){Ma(e);for(let t=0;t<e.hunks.length;t++)Oa(e,t)}function oo(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}var so=`-1,-1`;function co(e){return e?.some(e=>e.lineNumber===0)??!1}function lo(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function uo(e){return e.startingLine===0&&e.totalLines>0}function fo(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function po(){return H({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[Bn({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function mo(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var ho=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),Ni(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||Fi(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&mo(e.composedPath())||(Z(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(Z(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(Z(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){Z(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();Z(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);Z(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=bo(i)&&this.hoveredLine?.lineElement===i.lineElement;yo(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),yo(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),bo(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(So(i)&&p!=null){p(i);break}if(xo(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!bo(i))break;yo(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,Z(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),Z(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),Z(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();mo(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(fo(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=ve(po());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);vo(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(To(t));if(vo(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(vo(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(vo(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&mo(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=To(e);if(t&&mo(n))return;let r=Eo(e);return r==null?this.pathFromAnnotationSlot(e):To(r)}pathFromAnnotationSlot(e){let t=Oo(Do(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:To(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=ko(t)?t:ko(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}Fi(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,Mi(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{Ni(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!jo(this.renderedSelectedLinesState,n),i=!jo(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);Co(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=No(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=No(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:wo(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:wo(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:Mo(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:Mo(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function go({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:_o({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function _o({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function vo(e){return e!=null&&`kind`in e&&e.kind===`line`}function yo(e){return e!=null&&`kind`in e&&e.kind===`token`}function bo(e){return vo(e)||yo(e)}function xo(e){return`type`in e&&e.type===`line-info`}function So(e){return`kind`in e&&e.kind===`merge-conflict-action`}function Co(e){return e===`current`||e===`incoming`||e===`both`}function wo(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function To(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function Eo(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function Do(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function Oo(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function ko(e){return e!=null&&typeof e.elementFromPoint==`function`}function Ao(e,t){return e===t||Fi(e??void 0,t??void 0)}function jo(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&Ao(e?.range??null,t.range)}function Mo(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function No(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function Z(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var Po=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),Lo(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?Bo(t):Vo(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:Fo(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:Io(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&Ro(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function Fo(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function Io(e){return Math.max(Math.ceil(e),0)}function Lo(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?Ro(e,{codeWidthChanged:!0,numberWidthChanged:!0}):zo(e))}function Ro(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function zo(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function Bo(e){e.codeElement.isConnected&&zo(e)}function Vo(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}function Ho(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Uo(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!rn.has(t))return!1;return!0}function Wo(e){for(let t of In(e))if(!Vt.has(t))return!1;return!0}function Go(e,t){return e.endsWith(`\r
|
|
27
27
|
`)?t+`\r
|
|
28
28
|
`:e.endsWith(`\r`)?t+`\r`:e.endsWith(`
|
|
29
29
|
`)?t+`
|
|
30
|
-
`:t}function
|
|
30
|
+
`:t}function Ko(e){return H({tagName:`div`,children:[H({tagName:`div`,children:e.annotations?.map(e=>H({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function qo(e,t){return H({tagName:`div`,children:e,properties:{"data-content":``,style:`grid-row: span ${t}`}})}function Jo(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function Yo({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return H({tagName:`div`,children:[t===`custom`?H({tagName:`slot`,properties:{name:Ct}}):Xo({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[Zo(r)]],properties:i})}function Xo({name:e,prevName:t,iconType:n}){let r=[H({tagName:`slot`,properties:{name:bt}}),Bn({name:Jo(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(H({tagName:`div`,children:[H({tagName:`bdi`,children:[V(t)]})],properties:{"data-prev-name":``}})),r.push(Bn({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(H({tagName:`div`,children:[H({tagName:`bdi`,children:[V(e)]})],properties:{"data-title":``}})),r.push(H({tagName:`slot`,properties:{name:xt}})),H({tagName:`div`,children:r,properties:{"data-header-content":``}})}function Zo(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(H({tagName:`span`,children:[V(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(H({tagName:`span`,children:[V(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(H({tagName:`slot`,properties:{name:St}})),H({tagName:`div`,children:t,properties:{"data-metadata":``}})}function Qo(e){return H({tagName:`pre`,properties:$o(e)})}function $o({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}function es(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:In(t),preferredHighlighter:n}}var ts=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
31
31
|
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
32
32
|
<path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
|
|
33
33
|
</symbol>
|
|
@@ -79,7 +79,7 @@ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./b
|
|
|
79
79
|
<symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
|
|
80
80
|
<path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
|
|
81
81
|
</symbol>
|
|
82
|
-
</svg>`;function
|
|
82
|
+
</svg>`;function ns(e,t){return e==null||t==null?e===t:is(e.customProperties,t.customProperties)&&e.type===t.type&&e.diffIndicators===t.diffIndicators&&e.disableBackground===t.disableBackground&&e.disableLineNumbers===t.disableLineNumbers&&e.overflow===t.overflow&&e.split===t.split&&e.totalLines===t.totalLines}var rs={};function is(e=rs,t=rs){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function as(e){let t=document.createElement(`div`);return t.dataset.annotationSlot=``,t.slot=e,t.style.whiteSpace=`normal`,t}function os(){let e=document.createElement(`div`);return e.slot=`gutter-utility-slot`,e.style.position=`absolute`,e.style.top=`0`,e.style.bottom=`0`,e.style.textAlign=`center`,e.style.whiteSpace=`normal`,e.style.touchAction=`none`,e}function ss(){let e=document.createElement(`style`);return e.setAttribute(Tt,``),e}var cs;function ls(e){if(cs!=null)return cs;let t=e.host;if(typeof HTMLElement<`u`&&t instanceof HTMLElement&&!t.isConnected)return;let n=document.createElement(`div`);n.setAttribute(`data-code`,``),n.setAttribute(Et,`true`);let r=document.createElement(`div`);return r.style.position=`relative`,r.style.width=`200%`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n),cs=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),cs}function us(e){return`${Dt}: ${e==null?`var(--diffs-scrollbar-gutter-fallback)`:`${e}px`};`}var ds=`@layer base {
|
|
83
83
|
:host {
|
|
84
84
|
--diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
|
|
85
85
|
"Courier New", monospace;
|
|
@@ -1357,25 +1357,25 @@ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./b
|
|
|
1357
1357
|
}
|
|
1358
1358
|
|
|
1359
1359
|
@layer theme, rendered, unsafe;
|
|
1360
|
-
`,
|
|
1360
|
+
`,fs=`@layer base, theme, rendered, unsafe;`,ps=RegExp(`${_s(Dt)}\\s*:\\s*[^;]+;`);function ms(e){return`${fs}
|
|
1361
1361
|
@layer unsafe {
|
|
1362
1362
|
${e}
|
|
1363
|
-
}`}function
|
|
1363
|
+
}`}function hs(e,t=`system`,n){return`${fs}
|
|
1364
1364
|
@layer rendered {
|
|
1365
1365
|
:host {${t===`system`?``:`
|
|
1366
1366
|
color-scheme: ${t};`}
|
|
1367
|
-
${
|
|
1367
|
+
${us(n)}
|
|
1368
1368
|
${e}
|
|
1369
1369
|
}
|
|
1370
|
-
}`}function hs(e,t){let n=ls(t);return e.replace(fs,n)}function gs(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _s(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function vs({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function ys(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function bs({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=xs(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function xs(){let e=document.createElement(`style`);return e.setAttribute(Ct,``),e}var Ss=void 0;function Cs(){return Ss??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function ws(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Ts(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(us)),t.adoptedStyleSheets=[e]}connectedCallback(){cs(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(ft,t)}async function Es(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Ds({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=vr(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Y({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=jr({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=Os(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?X({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=Mr({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=Mr({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=br(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function Os(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return ks(e,t)}function ks(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function As({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function js(e){return{...e,hunks:e.hunks.map(e=>({...e,hunkContent:e.hunkContent.map(e=>({...e}))})),deletionLines:[...e.deletionLines],additionLines:[...e.additionLines]}}function Ms(e){return e===``?[]:e.split(mt)}function Ns(e,t,n){let r=e===`clone`?js(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return Ps(r,Is(r,n),Ls(r,n));case`rename-pure`:{let e=Ls(r,n);Rs(r,n);let t=Ms(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Bs(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function Ps(e,t,n){let r=Ms(t.contents),i=Ms(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Fs(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Bs(e,t,n),e}function Fs(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent){if(e.type===`context`){p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines;continue}p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions}let m=Math.max(z(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=B(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=B(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Is(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Ls(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Rs(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function zs(e,t,n){return e.cacheKey==null?Vs(t,n):`${e.cacheKey}:hydrated`}function Bs(e,t,n){let r=zs(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Vs(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?`${e.cacheKey}:${t.cacheKey}`:void 0:e?.cacheKey??t?.cacheKey}var Hs=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Us(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function Ws(e){return W({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Gs(e){return W({tagName:`div`,children:[W({tagName:`span`,children:[U(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function Ks(e){return W({tagName:`div`,children:[Rn({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function qs({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(W({tagName:`div`,children:[U(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(Ks(`up`)),s++),o||(e.push(Ks(`down`)),s++)):(e.push(Ks(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(W({tagName:`div`,children:[W({tagName:`span`,children:[U(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(W({tagName:`div`,children:[U(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(W({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(W({tagName:`slot`,properties:{name:i}})),W({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function Js(e,t){return`hunk-separator-${e}-${t}`}function Ys(e){let t=e.at(-1);return t==null?0:Math.max(B(t.additionStart,t.additionCount),B(t.deletionStart,t.deletionCount))}var Xs=-1,Zs=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Xs}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;editSessionActive=!1;constructor(e={theme:R},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Uo(e.theme??R)?Mn():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(){this.editSessionActive=!0;let e=this.diffCache;e!=null&&!e.isPartial&&e.additionLines.length===0&&(Object.assign(e,va(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache())}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{renderCache:e}=this;if(e==null||gr(e.diff)||fc(e.diff,this.getTokenizeMaxLength()))return Promise.resolve();let{diff:t}=e,{workerManager:n}=this;return!this.editSessionActive&&n?.isWorkingPool()===!0&&t.cacheKey!=null?(n.evictDiffFromCache(t.cacheKey),n.primeDiffHighlightCache(t).then(()=>{this.applyRefreshedResult(t,n.getDiffResultCache(t))}).catch(e=>this.onHighlightError(e))):this.asyncHighlight(t).then(e=>this.applyRefreshedResult(t,e)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){if(t==null||this.renderCache==null||this.renderCache.diff!==e||this.editSessionActive)return;let{options:n}=this.getRenderOptions(e);hr(n,t.options)&&(this.renderCache={diff:e,options:t.options,highlighted:!0,result:t.result,renderRange:void 0},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??kt}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1){if(this.renderCache==null)return!1;let{result:r,diff:i}=this.renderCache;if(r==null)return!1;if(i.isPartial)throw Error(`Could not update render cache for partial diff`);let a=r.code.additionLines,o=[],s=new Map;for(let[t,n]of e){let e=a[t]?.properties??{},r=n.map(e=>e[2]).join(``),c=t<i.additionLines.length,l=c?i.additionLines[t]??``:``,u=J(l);c&&(i.additionLines[t]=Wo(l,r),u!==r&&(o.push(t),s.set(t,l))),a[t]={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})}}let c=!1;if(o.length>0){if(this.editSessionActive&&!i.isPartial){if(!n){if(i.additionLines.length<=1&&i.additionLines.join(``)===``)Object.assign(i,va(i,this.options.parseDiffOptions)),this.markEditSessionPass(i),c=!0;else if(ga(i,i.additionLines))Object.assign(i,_a(i,i.additionLines,this.options.parseDiffOptions)),this.markEditSessionPass(i),c=!0;else{let e=Ia(i,o,this.options.parseDiffOptions,s);this.applyExpansionRemap(e),c=e!=null}}}else Object.assign(i,Sa(i,o,this.options.parseDiffOptions))}return r.baseThemeType=t,this.renderCache.isDirty=!0,c}applyExpansionRemap(e){e!=null&&(this.expandedHunks=Ba(this.expandedHunks,e))}applyDocumentChange(e){if(this.renderCache==null)return;let{diff:t,result:n}=this.renderCache;if(n==null)return;if(t.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:r}=t;t.additionLines=lc(e,r),n.code.additionLines=sc(r,t.additionLines,n.code.additionLines,e),t.additionLines.length<=1&&t.additionLines.join(``)===``?(Object.assign(t,va(t,this.options.parseDiffOptions)),n.code.additionLines[0]=cc(0,e.getLineText(0)),this.markEditSessionPass(t)):this.editSessionActive?this.applySessionDocumentChange(t):Object.assign(t,ya(t,this.options.parseDiffOptions)),this.renderCache.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if(ga(e,n)){Object.assign(e,_a(e,n,t)),this.markEditSessionPass(e);return}this.applyExpansionRemap(Fa(e,t))}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>Go(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=R,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=Dt,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await jn($o(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=fc(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!hr(t,r.options)&&(r=void 0),this.renderCache??={diff:e,highlighted:!n&&!gr(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLang=e.lang??Ln(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??R}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!mr(e,n.diff)||!hr(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=At){if(e==null)return;let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getMatchingWorkerResultCache(e,i);o!=null&&!this.hasHighlightedRenderCache(e,i)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||gr(e)||fc(e,this.getTokenizeMaxLength()),l=!mr(e,this.renderCache.diff),u=!Vo(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!l&&Us(t);o&&(this.renderCache.highlightPending=!0),!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Us(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLang=e.lang??Ln(e.name);let t=this.highlighter!=null&&Uo(i.theme),n=this.highlighter!=null&&Ho(this.computedLang),r=!c&&n;if(this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=At){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return Zo({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=fc(e,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??Ln(e.name);let n=this.highlighter!=null&&Uo(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&Ho(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),a=xi(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&a.code.additionLines[0]==null){let t;if(Nr({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);a.code.additionLines[0]=cc(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:a,options:r}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=this.renderCache.highlightPending===!0||!this.renderCache.highlighted||!hr(this.renderCache.options,n)||!mr(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!hr(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&mr(e,n.diff)&&hr(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1;this.diff=e;let f=a===`unified`,p=pc(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:Bn(),deletionsGutterAST:Bn(),additionsGutterAST:Bn(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=wr({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(x.pushToGutter(`additions`,G(void 0,`buffer`,this.size)),h?.push(Ws(this.size))):(x.pushToGutter(`deletions`,G(void 0,`buffer`,this.size)),g?.push(Ws(this.size))),this.size=0,this.side=void 0}}},w=(e,t,n,r,i)=>{x.pushToGutter(e,Vn(t,n,r,i))};function T(e){C.flush(),a===`unified`?ic(`unified`,e,x):(ic(`deletions`,e,x),ic(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),Nr({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,f=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let h=a===`unified`?f:l,g={type:c,hunkIndex:t,lineIndex:h,unifiedLineIndex:f,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(g);n?.before!=null&&tc(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${f},${l}`,u.gutterProperties),i==null?r!=null&&(r=ac(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${f},${l}`}:void 0)):i=ac(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${f},${l}`}:void 0),rc({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&tc(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(g);n?.before!=null&&nc(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,h);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=ac(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=ac(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}rc({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&nc(n.after,x,C)}let _=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,v=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:f===n.unifiedLineStart+n.unifiedLineCount-1),E=_?n.noEOFCRDeletions:!1,D=_?n.noEOFCRAdditions:!1,O=(s?.noEOFCR??!1)||E,k=(o?.noEOFCR??!1)||D;if(k||O){if(a===`split`&&C.flush(),O){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(Gs(e)),x.pushToGutter(`unified`,G(e,`metadata`,1))):(x.deletionsContentAST.push(Gs(e)),x.pushToGutter(`deletions`,G(e,`metadata`,1)),k||(x.pushToGutter(`additions`,G(void 0,`buffer`,1)),x.additionsContentAST.push(Ws(1))))}if(k){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(Gs(e)),x.pushToGutter(`unified`,G(e,`metadata`,1))):(x.additionsContentAST.push(Gs(e)),x.pushToGutter(`additions`,G(e,`metadata`,1)),O||(x.pushToGutter(`deletions`,G(void 0,`buffer`,1)),x.deletionsContentAST.push(Ws(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||v&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:v&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(Ys(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=Bn(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Ko(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(W({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(W({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(W({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return De(this.renderFullAST(e,t))}renderPartialHTML(e,t){return De(t==null?e:W({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!lo(n))return;let i=e.type===`new`?[]:Qs(co(this.deletionAnnotations)),a=e.type===`deleted`?[]:Qs(co(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;if(t===`unified`){rc({diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r});return}rc({diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(Mt(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(Mt(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(o.annotations.length!==0||a.annotations.length!==0)return{deletionSpan:a,additionSpan:o}}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Jo({fileOrDiff:e,mode:t,stickyHeader:n})}};function Qs(e){return e?.map(e=>Mt(e))??[]}var $s=new Intl.PluralRules(`en-US`);function ec(e){return`${e} unmodified line${$s.select(e)===`one`?``:`s`}`}function tc(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function nc(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function rc({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,G(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,G(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,G(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function ic(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,qs({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(qs({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,qs({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(qs({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Js(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?ec(n):`More unchanged context may be available`;c.pushToGutter(e,qs({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(qs({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function ac(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function oc(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function sc(e,t,n,r){let i=oc(e),a=oc(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let r=e.length;r<t.length;r++)l[r]??=n[r];for(let e=s;e<t.length;e++)l[e]??=cc(e,r.getLineText(e));return l}function cc(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function lc(e,t){let n=[],r=dc(t);for(let t=0;t<e.lineCount;t++){let i=e.getLineText(t,!0);n.push(t<e.lineCount-1&&!uc(i)?i+r:i)}return n}function uc(e){return e.endsWith(`
|
|
1371
|
-
`)||e.endsWith(`\r`)}function
|
|
1370
|
+
}`}function gs(e,t){let n=us(t);return e.replace(ps,n)}function _s(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function vs(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function ys({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function bs(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function xs({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=Ss(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function Ss(){let e=document.createElement(`style`);return e.setAttribute(wt,``),e}var Cs=void 0;function ws(){return Cs??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ts(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Es(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(ds)),t.adoptedStyleSheets=[e]}connectedCallback(){ls(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(pt,t)}async function Ds(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Os({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=br(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=q({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=Nr({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=ks(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?J({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=Pr({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=Pr({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=Sr(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function ks(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return As(e,t)}function As(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function js({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function Ms(e){return{...e,hunks:e.hunks.map(e=>({...e,hunkContent:e.hunkContent.map(e=>({...e}))})),deletionLines:[...e.deletionLines],additionLines:[...e.additionLines]}}function Ns(e){return e===``?[]:e.split(ht)}function Ps(e,t,n){let r=e===`clone`?Ms(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return Fs(r,Ls(r,n),Rs(r,n));case`rename-pure`:{let e=Rs(r,n);zs(r,n);let t=Ns(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Vs(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function Fs(e,t,n){let r=Ns(t.contents),i=Ns(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Is(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Vs(e,t,n),e}function Is(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent){if(e.type===`context`){p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines;continue}p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions}let m=Math.max(R(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=z(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=z(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Ls(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Rs(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function zs(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function Bs(e,t,n){return e.cacheKey==null?Hs(t,n):`${e.cacheKey}:hydrated`}function Vs(e,t,n){let r=Bs(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Hs(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?`${e.cacheKey}:${t.cacheKey}`:void 0:e?.cacheKey??t?.cacheKey}var Us=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Ws(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function Gs(e){return H({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Ks(e){return H({tagName:`div`,children:[H({tagName:`span`,children:[V(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function qs(e){return H({tagName:`div`,children:[Bn({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function Js({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(H({tagName:`div`,children:[V(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(qs(`up`)),s++),o||(e.push(qs(`down`)),s++)):(e.push(qs(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(H({tagName:`div`,children:[H({tagName:`span`,children:[V(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(H({tagName:`div`,children:[V(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(H({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(H({tagName:`slot`,properties:{name:i}})),H({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function Ys(e,t){return`hunk-separator-${e}-${t}`}function Xs(e){let t=e.at(-1);return t==null?0:Math.max(z(t.additionStart,t.additionCount),z(t.deletionStart,t.deletionCount))}var Zs=-1,Qs=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Zs}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;editSessionActive=!1;constructor(e={theme:L},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Wo(e.theme??L)?Pn():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(){this.editSessionActive=!0;let e=this.diffCache;e!=null&&!e.isPartial&&e.additionLines.length===0&&(Object.assign(e,ya(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache())}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{renderCache:e}=this;if(e==null||vr(e.diff)||pc(e.diff,this.getTokenizeMaxLength()))return Promise.resolve();let{diff:t}=e,{workerManager:n}=this;return!this.editSessionActive&&n?.isWorkingPool()===!0&&t.cacheKey!=null?(n.evictDiffFromCache(t.cacheKey),n.primeDiffHighlightCache(t).then(()=>{this.applyRefreshedResult(t,n.getDiffResultCache(t))}).catch(e=>this.onHighlightError(e))):this.asyncHighlight(t).then(e=>this.applyRefreshedResult(t,e)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){if(t==null||this.renderCache==null||this.renderCache.diff!==e||this.editSessionActive)return;let{options:n}=this.getRenderOptions(e);_r(n,t.options)&&(this.renderCache={diff:e,options:t.options,highlighted:!0,result:t.result,renderRange:void 0},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??At}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1){if(this.renderCache==null)return!1;let{result:r,diff:i}=this.renderCache;if(r==null)return!1;if(i.isPartial)throw Error(`Could not update render cache for partial diff`);let a=r.code.additionLines,o=[],s=new Map;for(let[t,n]of e){let e=a[t]?.properties??{},r=n.map(e=>e[2]).join(``),c=t<i.additionLines.length,l=c?i.additionLines[t]??``:``,u=K(l);c&&(i.additionLines[t]=Go(l,r),u!==r&&(o.push(t),s.set(t,l))),a[t]={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})}}let c=!1;if(o.length>0){if(this.editSessionActive&&!i.isPartial){if(!n){if(i.additionLines.length<=1&&i.additionLines.join(``)===``)Object.assign(i,ya(i,this.options.parseDiffOptions)),this.markEditSessionPass(i),c=!0;else if(_a(i,i.additionLines))Object.assign(i,va(i,i.additionLines,this.options.parseDiffOptions)),this.markEditSessionPass(i),c=!0;else{let e=La(i,o,this.options.parseDiffOptions,s);this.applyExpansionRemap(e),c=e!=null}}}else Object.assign(i,Ca(i,o,this.options.parseDiffOptions))}return r.baseThemeType=t,this.renderCache.isDirty=!0,c}applyExpansionRemap(e){e!=null&&(this.expandedHunks=Va(this.expandedHunks,e))}applyDocumentChange(e){if(this.renderCache==null)return;let{diff:t,result:n}=this.renderCache;if(n==null)return;if(t.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:r}=t;t.additionLines=uc(e,r),n.code.additionLines=cc(r,t.additionLines,n.code.additionLines,e),t.additionLines.length<=1&&t.additionLines.join(``)===``?(Object.assign(t,ya(t,this.options.parseDiffOptions)),n.code.additionLines[0]=lc(0,e.getLineText(0)),this.markEditSessionPass(t)):this.editSessionActive?this.applySessionDocumentChange(t):Object.assign(t,ba(t,this.options.parseDiffOptions)),this.renderCache.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if(_a(e,n)){Object.assign(e,va(e,n,t)),this.markEditSessionPass(e);return}this.applyExpansionRemap(Ia(e,t))}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>Ko(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=L,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=Ot,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await Nn(es(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=pc(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!_r(t,r.options)&&(r=void 0),this.renderCache??={diff:e,highlighted:!n&&!vr(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLang=e.lang??zn(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??L}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!gr(e,n.diff)||!_r(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=jt){if(e==null)return;let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getMatchingWorkerResultCache(e,i);o!=null&&!this.hasHighlightedRenderCache(e,i)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||vr(e)||pc(e,this.getTokenizeMaxLength()),l=!gr(e,this.renderCache.diff),u=!Ho(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!l&&Ws(t);o&&(this.renderCache.highlightPending=!0),!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Ws(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLang=e.lang??zn(e.name);let t=this.highlighter!=null&&Wo(i.theme),n=this.highlighter!=null&&Uo(this.computedLang),r=!c&&n;if(this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=jt){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return Qo({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=pc(e,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??zn(e.name);let n=this.highlighter!=null&&Wo(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&Uo(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),a=Si(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&a.code.additionLines[0]==null){let t;if(Fr({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);a.code.additionLines[0]=lc(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:a,options:r}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=this.renderCache.highlightPending===!0||!this.renderCache.highlighted||!_r(this.renderCache.options,n)||!gr(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!_r(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&gr(e,n.diff)&&_r(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1;this.diff=e;let f=a===`unified`,p=mc(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:Hn(),deletionsGutterAST:Hn(),additionsGutterAST:Hn(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=Er({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(x.pushToGutter(`additions`,U(void 0,`buffer`,this.size)),h?.push(Gs(this.size))):(x.pushToGutter(`deletions`,U(void 0,`buffer`,this.size)),g?.push(Gs(this.size))),this.size=0,this.side=void 0}}},w=(e,t,n,r,i)=>{x.pushToGutter(e,Un(t,n,r,i))};function T(e){C.flush(),a===`unified`?ac(`unified`,e,x):(ac(`deletions`,e,x),ac(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),Fr({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,f=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let h=a===`unified`?f:l,g={type:c,hunkIndex:t,lineIndex:h,unifiedLineIndex:f,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(g);n?.before!=null&&nc(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${f},${l}`,u.gutterProperties),i==null?r!=null&&(r=oc(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${f},${l}`}:void 0)):i=oc(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${f},${l}`}:void 0),ic({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&nc(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(g);n?.before!=null&&rc(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,h);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=oc(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=oc(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}ic({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&rc(n.after,x,C)}let _=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,v=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:f===n.unifiedLineStart+n.unifiedLineCount-1),E=_?n.noEOFCRDeletions:!1,D=_?n.noEOFCRAdditions:!1,O=(s?.noEOFCR??!1)||E,k=(o?.noEOFCR??!1)||D;if(k||O){if(a===`split`&&C.flush(),O){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(Ks(e)),x.pushToGutter(`unified`,U(e,`metadata`,1))):(x.deletionsContentAST.push(Ks(e)),x.pushToGutter(`deletions`,U(e,`metadata`,1)),k||(x.pushToGutter(`additions`,U(void 0,`buffer`,1)),x.additionsContentAST.push(Gs(1))))}if(k){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(Ks(e)),x.pushToGutter(`unified`,U(e,`metadata`,1))):(x.additionsContentAST.push(Ks(e)),x.pushToGutter(`additions`,U(e,`metadata`,1)),O||(x.pushToGutter(`deletions`,U(void 0,`buffer`,1)),x.deletionsContentAST.push(Gs(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||v&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:v&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(Xs(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=Hn(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,qo(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(H({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(H({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(H({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return ve(this.renderFullAST(e,t))}renderPartialHTML(e,t){return ve(t==null?e:H({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!uo(n))return;let i=e.type===`new`?[]:$s(lo(this.deletionAnnotations)),a=e.type===`deleted`?[]:$s(lo(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;if(t===`unified`){ic({diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r});return}ic({diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(Nt(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(Nt(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(o.annotations.length!==0||a.annotations.length!==0)return{deletionSpan:a,additionSpan:o}}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Yo({fileOrDiff:e,mode:t,stickyHeader:n})}};function $s(e){return e?.map(e=>Nt(e))??[]}var ec=new Intl.PluralRules(`en-US`);function tc(e){return`${e} unmodified line${ec.select(e)===`one`?``:`s`}`}function nc(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function rc(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function ic({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,U(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,U(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,U(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function ac(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Js({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Js({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Js({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Js({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Ys(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?tc(n):`More unchanged context may be available`;c.pushToGutter(e,Js({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Js({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function oc(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function sc(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function cc(e,t,n,r){let i=sc(e),a=sc(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let r=e.length;r<t.length;r++)l[r]??=n[r];for(let e=s;e<t.length;e++)l[e]??=lc(e,r.getLineText(e));return l}function lc(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function uc(e,t){let n=[],r=fc(t);for(let t=0;t<e.lineCount;t++){let i=e.getLineText(t,!0);n.push(t<e.lineCount-1&&!dc(i)?i+r:i)}return n}function dc(e){return e.endsWith(`
|
|
1371
|
+
`)||e.endsWith(`\r`)}function fc(e){for(let t of e){if(t.endsWith(`\r
|
|
1372
1372
|
`))return`\r
|
|
1373
1373
|
`;if(t.endsWith(`
|
|
1374
1374
|
`))return`
|
|
1375
1375
|
`;if(t.endsWith(`\r`))return`\r`}return`
|
|
1376
|
-
`}function fc(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function pc(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function mc(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function hc(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function gc(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:_s(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function _c(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}var vc=-1,yc=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++vc}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;pendingFiles;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:R},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new No,this.scrollSyncManager=new Hs,this.interactionManager=new mo(`diff`,ho(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return gc(e)}createHunksRenderer(e){return new Zs(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>{let n=this.fileDiffCache;if(n==null)return;let r=n.hunks.at(-1),i,a;hunkIterator:for(let o of n.hunks){let n=t===`deletions`?o.deletionStart:o.additionStart,s=t===`deletions`?o.deletionCount:o.additionCount,c=z(n,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(e<c){let t=c-e;i=Math.max(u-t,0),a=Math.max(l-t,0);break hunkIterator}if(e>=c+s){if(o===r){let t=e-(c+s);i=u+o.unifiedLineCount+t,a=l+o.splitLineCount+t;break hunkIterator}continue}for(let n of o.hunkContent)if(n.type===`context`){if(e<c+n.lines){let t=e-c;a=l+t,i=u+t;break hunkIterator}c+=n.lines,l+=n.lines,u+=n.lines}else{let r=t===`deletions`?n.deletions:n.additions;if(e<c+r){let r=e-c;i=u+(t===`additions`?n.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(n.deletions,n.additions),u+=n.deletions+n.additions}break hunkIterator}if(i!=null&&a!=null)return[i,a]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ho(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Rt(this.appliedThemeCSS.theme,this.options.theme??R)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){Mi(this.handleEditSessionRender),this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.pendingFiles=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=As(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t),Cc(this.pre,xc({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||wc(this.headerElement,Sc({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),ws(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)!(e instanceof HTMLElement)||e.tagName.toLowerCase()!==`code`||(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?da(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;e==null||t==null||!_c(e)||this.pendingFiles?.fileDiff===e||(this.pendingFiles={fileDiff:e,promise:this.loadFilesForDiff(e,t)})}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}finally{this.pendingFiles?.fileDiff===e&&(this.pendingFiles=void 0)}}async handleFilesLoaded(e,t){this.fileDiff!==e||!e.isPartial||(Ns(`merge`,e,t),this.setHydratedState(t),await Es(()=>this.primeHighlightCache(e)),!(!this.enabled||this.fileDiff!==e)&&this.rerender())}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){let l=As(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);e!=null&&e.cacheKey===void 0&&(e.cacheKey=e.prevName==null?e.name:e.prevName+`:`+e.name),this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,g=this.hasThemeChanged(),_=l!=null,v=_&&(!bc(u,this.deletionFile)||!bc(d,this.additionFile)),y=e!=null&&e!==this.fileDiff,b=i!=null&&(i.length>0||this.lineAnnotations.length>0)&&i!==this.lineAnnotations;if(!f&&Vo(h,this.renderRange)&&!n&&!b&&!g&&(e!=null&&e===this.fileDiff||e==null&&!v))return this.applyCachedThemeState(p);let x;e==null&&_&&(v||this.fileDiff==null)&&(x=da(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:S}=this;if(this.renderRange=h,_?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e==null?x!=null&&(y=!0,this.fileDiff=x):this.fileDiff=e,y&&(this.cachedHeaderHTML=void 0),i!=null&&this.setLineAnnotations(i),this.fileDiff==null)return!1;this.fileDiff.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(Ua(this.fileDiff,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:C=!1,disableFileHeader:w=!1}=this.options;if(w&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,jt);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(C)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,b,v||y||g)&&this.applyPartialRender({previousRenderRange:S,renderRange:h}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(C)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}get fileDiffCache(){return this.hunksRenderer.diffCache??this.fileDiff}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.fileDiffCache,r=this.lineAnnotations,i=this.computeEditorRenderRange(this.renderRange);e!=null&&t!=null&&n!=null&&!n.isPartial&&this.hunksRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.fileDiffCache!==n||e.__syncRenderView(a,t,n,r,i)})}computeEditorRenderRange(e){let t=this.fileDiffCache;if(e==null||t==null||Us(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return Nr({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.attachEditor: cannot attach an editor to a "${this.type}" diff`);return this.editor?.cleanUp(),this.editor=e,this.hunksRenderer.beginEditSession(),this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary(),this.hunksRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),e=>{this.editor=void 0,e!==!0&&this.finishEditSession()}}finishEditSession(){this.hunksRenderer.endEditSession(),this.completeEditSession()}completeEditSession(){let e=this.fileDiffCache;if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Va(e,this.hunksRenderer.getExpandedHunksMap(),t);return Ua(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Ha(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);let n=this.hunksRenderer.diffCache;if(n!=null){let e=this.fileDiff?.cacheKey;e!=null&&n.cacheKey==null&&(n.cacheKey=e),this.fileDiff=n}t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations()),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){let{shouldRefreshDiffsView:r,lineCountChangeInFlight:i}=n;if(this.hunksRenderer.updateRenderCache(e,t,i)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}r===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}isLineRenderable(e){let t=this.fileDiffCache;if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return Tr({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.fileDiffCache;if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Er({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.fileDiffCache,{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=Sr(o);if(e<s){let c=Y({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=X({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=Sr(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){ji(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||gr(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!hc(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${Mt(r)}`,a=this.annotationCache.get(i);if(a==null||!mc(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:is(Mt(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=as();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ao(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ao(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=es;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:n}=this,r=this.cachedHeaderHTML??De(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;let{renderCustomHeader:i,renderHeaderPrefix:a,renderHeaderFilenameSuffix:o,renderHeaderMetadata:s}=this.options;if(i!=null){let e=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,St,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let c=a?.(n)??void 0,l=o?.(n)??void 0,u=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,yt,c),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,bt,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,xt,u),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=os(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ps(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??R,s=typeof o==`string`?o:{...o},c=cs(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=bs({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:ms(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=hs(this.themeCSSStyle.textContent??``,cs(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&Cs()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?ys(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=Tc(t[0]),a=Tc(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=De(i),r.content.innerHTML=De(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=vs({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=vs({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=vs({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:a,options:{diffStyle:o=`split`}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(o,r,a,i);if(s==null)return!1;let c=e.startingLine,l=t.startingLine,u=c+e.totalLines,d=l+t.totalLines,f=Math.max(c,l),p=Math.min(u,d);if(p<=f)return!1;let m=Math.max(0,f-c),h=Math.max(0,u-p),g=this.trimColumns({columns:s,trimStart:m,trimEnd:h,previousStart:c,overlapStart:f,overlapEnd:p,diffStyle:o});if(g<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let _=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},y=v(l,Math.max(f-l,0));if(y==null&&l<f)return!1;let b=v(p,Math.max(d-p,0));if(b==null&&d>p)return!1;let x=(e,t)=>{if(e!=null){if(o===`unified`&&!Array.isArray(s))this.insertPartialHTML(o,s,e,t);else if(o===`split`&&Array.isArray(s))this.insertPartialHTML(o,s,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);_+=e.rowCount}};return this.cleanupErrorWrapper(),x(y,`afterbegin`),x(b,`beforeend`),this.lastRowCount!==_&&(this.applyRowSpan(o,s,_),this.lastRowCount=_),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){if(this.options.diffStyle!==`split`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;let n=(t,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(t,e),i=Tc(r?.[0]),a=Tc(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};n(`deletions`,t[0]),n(`additions`,t[1])}refreshUnifiedDiffView(){if(this.options.diffStyle!==`unified`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null||Array.isArray(t))return;let n=this.hunksRenderer.renderCodeAST(`unified`,e),r=Tc(n?.[0]),i=Tc(n?.[1]),a=()=>{for(let[e,n]of[[t.gutter,r],[t.content,i]])n!=null&&(e.innerHTML=De(n));e.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,t,e.rowCount),this.lastRowCount=e.rowCount)};this.shouldGuardRebuildScroll()?ys(this.pre,a):a(),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Tc(t[0]),i=Tc(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};ts(u,this.appliedPreAttributes)||(Ts(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function bc(e,t){return e==null||t==null?e==null&&t==null:zt(e,t)}function xc({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Sc({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function Cc(e,t,n=!1){return!n&&e==null&&t}function wc(e,t,n=!1){return e==null&&t&&!n}function Tc(e){if(e!=null&&e.type===`element`)return e.children??[]}var Ec=3e3,Dc=-1,Oc=class extends yc{__id=`little-virtualized-file-diff:${++Dc}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;currentExpandUnchanged;pendingHydratedDiff;pendingExpansions;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=_r(n)}setMetrics(e,t=!1){let n=_r(e);!t&&Ei(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!so(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Di(t,e),r=n&&Ic(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Lc(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}reconcileHeights(){let e=!1,{overflow:t=`scroll`}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;let n=this.getDiffStyle(),r=n===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],i=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&i&&lo(this.renderRange)){let t=kc(r)??0;this.setFileAnnotationHeight(t)&&(e=!0)}else!i&&this.setFileAnnotationHeight(0)&&(e=!0);for(let t of r){if(t==null)continue;let r=t.children[1];if(r instanceof HTMLElement)for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let i=Vc(r,n),a=t.getBoundingClientRect().height,o=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(o=!0),a+=t.nextElementSibling.getBoundingClientRect().height);let s=this.getEstimatedLineHeight(o),c=this.cache.heightDeltas.get(i)??0,l=a-s;l!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=l-c,l===0?this.cache.heightDeltas.delete(i):this.cache.heightDeltas.set(i,l))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}prepareCodeViewItem(e,t,n,r){let i=!mr(this.fileDiff,e),a=this.syncLineAnnotations(r),o=n?.resetDiffLayoutCache===!0||i||a,s=i||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=_r(n.metrics),o=!0,s=!0);let{collapsed:c=!1,expandUnchanged:l=!1}=this.options;return this.currentCollapsed!==c&&(this.currentCollapsed=c,o=!0),this.currentExpandUnchanged!==l&&(this.currentExpandUnchanged=l,o=!0,s=!0),o&&this.resetLayoutCache({includeEstimatedHeights:s}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t=`additions`){if(this.fileDiff==null||e<1)return;let n=this.getLineIndex(e,t);if(n==null)return;let{disableFileHeader:r=!1,expandUnchanged:i=!1,collapsed:a=!1,collapsedContextThreshold:o=1}=this.options,s=this.getDiffStyle(),c=this.getHunkSeparatorType(),l=s===`split`?n[1]:n[0];this.approximateLayoutCheckpoints();let u=vr(this.metrics,r),d=this.getLayoutCheckpointBeforeLineIndex(l),f=d?.top??u+this.cache.fileAnnotationHeight;if(a)return{top:u,height:0};let p;return Nr({diff:this.fileDiff,diffStyle:s,startingLine:d?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=s===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=jr({type:c,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(f+=r.gapBefore,l>=o-n&&l<o)return p={top:f,height:r.height},!0;f+=r.height+r.gapAfter}}let u=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===l)return p={top:f,height:u},!0;if(f+=u,r>0){let e=Mr({type:c,metrics:this.metrics});if(e!=null){if(l>o&&l<=o+r)return p={top:f+e.gapBefore,height:e.height},!0;f+=e.totalHeight}}return!1}}),p}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.fileDiff==null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1}=this.options;if(r)return;let a=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();let s=this.getLayoutCheckpointBeforeTop(e),c=s?.top??vr(this.metrics,t)+this.cache.fileAnnotationHeight,l;return Nr({diff:this.fileDiff,diffStyle:a,startingLine:s?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:s,additionLine:u})=>{let d=a===`split`?u?.splitLineIndex??s?.splitLineIndex:u?.unifiedLineIndex??s?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=jr({type:o,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(c+=e.totalHeight)}if(c>=e&&(s==null?u!=null&&(l={lineNumber:u.lineNumber,side:`additions`,top:c}):l={lineNumber:s.lineNumber,side:`deletions`,top:c},l!=null))return!0;let f=this.getLineHeight(d,(u?.noEOFCR??!1)||(s?.noEOFCR??!1));if(c+=f,i>0){let e=Mr({type:o,metrics:this.metrics});e!=null&&(c+=e.totalHeight)}return!1}}),l}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.fileDiff,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){let n=Ns(`clone`,e,t);if(await Es(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Ns(`merge`,e,t),this.setHydratedState(t),await Es(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}consumeCodeViewLayoutChanges(e){let t=!1,n,{pendingExpansions:r,pendingHydratedDiff:i}=this;if(r!=null){this.pendingExpansions=void 0;for(let e of r)this.hunksRenderer.expandHunk(e.hunkIndex,e.direction,e.expansionLineCountOverride),t=!0}return i!=null&&(this.pendingHydratedDiff=void 0,i.expectedDiff===e&&(this.setHydratedState(i.files),n=i.nextDiff)),n==null?t&&(this.forceRenderOverride=!0,this.invalidateDerivedLayoutCache(!0)):(this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0})),n}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.fileDiffCache;if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return Tr({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),!(!this.enabled||this.fileDiff==null)&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.fileDiff!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.fileDiff){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,o=vr(this.metrics,i);if(this.height+=o,a){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getActiveEstimatedHeight(e=this.fileDiff){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.fileDiff){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=Ds({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Rc(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.fileDiff){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=As(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Bc(s,this.deletionFile)||!Bc(c,this.additionFile)),u=t??this.fileDiff;t==null&&o&&(l||this.fileDiff==null)&&(u=da(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=this.syncLineAnnotations(r);p&&this.resetLayoutCache({includeEstimatedHeights:!1});let m=t!=null&&t!==this.fileDiff,h=u!=null&&!mr(this.fileDiff,u),g=m||l;if(h&&this.resetLayoutCache({includeEstimatedHeights:!0}),e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(f)this.top??=this.getVirtualizedTop(),h&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,u));else{this.computeApproximateSize(!1,u);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!g||!f))return this.fileDiff=u,a!=null&&(this.deletionFile=s,this.additionFile=c),h&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let _=this.virtualizer.getWindowSpecs(),v=this.top??0,y=this.computeRenderRangeFromWindow(u,v,_),b=super.render({fileDiff:u,fileContainer:e,renderRange:y,lineAnnotations:r,forceRender:(d??n)||p||h,...a,...i});return this.isSimpleMode()&&b&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),b}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return zc(this.options.hunkSeparators)}approximateLayoutCheckpoints(e=this.fileDiff){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e==null||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=Rc(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=Ac(this.cache.heightDeltas),u=vr(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Nc(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+Pc(i,e)*this.metrics.lineHeight+jc(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=Ec}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+jc(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=Y({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?jr({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?X({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?Mr({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Fc({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Y({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=X({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=Rc(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=vr(this.metrics,i),h=e.hunks.length>0?br(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,ee;if(Nr({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?jr({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),ee!=null)){if(ee<=0)return!0;ee--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),ee==null&&k>=r&&b&&(ee=T),A++,k+=S,c>0||v&&d){let e=Mr({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let te=Math.round(M-w/2),ne=Math.max(0,Math.ceil(p/s)-w),re=Math.max(0,Math.min(te,ne)),ie=re*s,ae=te<0?C+te*s:C,oe=E[re]??0,se=ie===0?0:g+oe,ce=re+ae/s,le=ce<E.length?v-E[ce]:v-(k-t-_);return{startingLine:ie,totalLines:ae,bufferBefore:se,bufferAfter:Math.max(0,le)}}};function kc(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===oo&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function Ac(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function jc({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Mc(e,n);return(t[Mc(e,r)]??0)-(t[i]??0)}function Mc(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Nc(e){return Math.ceil(e/Ec)*Ec}function Pc(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Fc({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Ic(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Lc(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Rc(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function zc(e){return typeof e==`function`?`custom`:e??`line-info`}function Bc(e,t){return e==null||t==null?e==null&&t==null:zt(e,t)}function Vc(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function Hc(e,t){return typeof window>`u`&&t!=null?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,F.jsx)(F.Fragment,{children:e})}var Uc=(0,P.createContext)(void 0);function Wc(){return(0,P.useContext)(Uc)}var Gc=typeof window>`u`?P.useEffect:P.useLayoutEffect;function Kc({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=Wc(),f=i!==void 0,p=(0,P.useContext)(Ti),m=ct(),h=(0,P.useRef)(null),g=ot(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new yc(qc({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new Oc(qc({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return Gc(()=>{let{current:n}=h;if(n==null)return;let a=qc({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!Di(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),Gc(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,P.useCallback)(()=>h.current?.getHoveredLine(),[])}}function qc({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?dt:e?.renderCustomHeader,renderGutterUtility:r?dt:e?.renderGutterUtility}:e}function Jc({oldFile:e,newFile:t,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1}){let v=(0,P.useMemo)(()=>da(e,t,n?.parseDiffOptions),[e,t,n?.parseDiffOptions]),{ref:y,getHoveredLine:b}=Kc({fileDiff:v,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_});return(0,F.jsx)(ft,{ref:y,className:s,style:c,children:Hc(It({fileDiff:v,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,lineAnnotations:a,renderGutterUtility:h,getHoveredLine:b}),l)})}function Yc({filename:e,className:t}){let n=e.split(`.`).pop()?.toLowerCase()??``,r=t??`w-2.5 h-2.5 shrink-0`;return n===`ts`||n===`tsx`?(0,F.jsx)(`svg`,{viewBox:`0 0 32 32`,className:r,children:(0,F.jsx)(`path`,{d:`M23.827,8.243A4.424,4.424,0,0,1,26.05,9.524a5.853,5.853,0,0,1,.852,1.143c.011.045-1.534,1.083-2.471,1.662-.034.023-.169-.124-.322-.35a2.014,2.014,0,0,0-1.67-1c-1.077-.074-1.771.49-1.766,1.433a1.3,1.3,0,0,0,.153.666c.237.49.677.784,2.059,1.383,2.544,1.095,3.636,1.817,4.31,2.843a5.158,5.158,0,0,1,.416,4.333,4.764,4.764,0,0,1-3.932,2.815,10.9,10.9,0,0,1-2.708-.028,6.531,6.531,0,0,1-3.616-1.884,6.278,6.278,0,0,1-.926-1.371,2.655,2.655,0,0,1,.327-.208c.158-.09.756-.434,1.32-.761L19.1,19.6l.214.312a4.771,4.771,0,0,0,1.35,1.292,3.3,3.3,0,0,0,3.458-.175,1.545,1.545,0,0,0,.2-1.974c-.276-.395-.84-.727-2.443-1.422a8.8,8.8,0,0,1-3.349-2.055,4.687,4.687,0,0,1-.976-1.777,7.116,7.116,0,0,1-.062-2.268,4.332,4.332,0,0,1,3.644-3.374A9,9,0,0,1,23.827,8.243ZM15.484,9.726l.011,1.454h-4.63V24.328H7.6V11.183H2.97V9.755A13.986,13.986,0,0,1,3.01,8.289c.017-.023,2.832-.034,6.245-.028l6.211.017Z`,fill:`#007acc`})}):n===`js`||n===`mjs`||n===`cjs`||n===`jsx`?(0,F.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:r,children:[(0,F.jsx)(`rect`,{x:`2`,y:`2`,width:`28`,height:`28`,rx:`1.312`,fill:`#f5de19`}),(0,F.jsx)(`path`,{d:`M20.809,23.875a2.866,2.866,0,0,0,2.6,1.6c1.09,0,1.787-.545,1.787-1.3,0-.9-.715-1.222-1.916-1.747l-.658-.282c-1.9-.809-3.16-1.822-3.16-3.964,0-1.973,1.5-3.476,3.853-3.476a3.889,3.889,0,0,1,3.742,2.107L25,18.128A1.789,1.789,0,0,0,23.311,17a1.145,1.145,0,0,0-1.259,1.128c0,.789.489,1.109,1.618,1.6l.658.282c2.236.959,3.5,1.936,3.5,4.133,0,2.369-1.861,3.667-4.36,3.667a5.055,5.055,0,0,1-4.795-2.691Zm-9.295.228c.413.733.789,1.353,1.693,1.353.864,0,1.41-.338,1.41-1.653V14.856h2.631v8.982c0,2.724-1.6,3.964-3.929,3.964a4.085,4.085,0,0,1-3.947-2.4Z`,fill:`#000`})]}):n===`json`||n===`jsonc`?(0,F.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:r,children:[(0,F.jsx)(`path`,{d:`M4.014,14.976a2.51,2.51,0,0,0,1.567-.518A2.377,2.377,0,0,0,6.386,13l.129-1.334A5.435,5.435,0,0,1,7.6,9.071,3.157,3.157,0,0,1,10.519,8h1.316v1.86H10.937a1.257,1.257,0,0,0-1.1.465,3.405,3.405,0,0,0-.357,1.585l-.127,1.244a3.283,3.283,0,0,1-.573,1.61A2.482,2.482,0,0,1,7.6,15.537a2.482,2.482,0,0,1,1.18.773A3.283,3.283,0,0,1,9.349,17.9l.127,1.244a3.405,3.405,0,0,0,.357,1.585,1.257,1.257,0,0,0,1.1.465h.9V23.06H10.519A3.157,3.157,0,0,1,7.6,21.981a5.435,5.435,0,0,1-1.082-2.595L6.386,18.05a2.377,2.377,0,0,0-.805-1.456A2.51,2.51,0,0,0,4.014,16.07Z`,fill:`#fbc02d`}),(0,F.jsx)(`path`,{d:`M27.986,16.07a2.51,2.51,0,0,0-1.567.518,2.377,2.377,0,0,0-.805,1.456l-.129,1.334a5.435,5.435,0,0,1-1.082,2.595A3.157,3.157,0,0,1,21.481,23.06H20.165V21.2h.9a1.257,1.257,0,0,0,1.1-.465,3.405,3.405,0,0,0,.357-1.585l.127-1.244a3.283,3.283,0,0,1,.573-1.61,2.482,2.482,0,0,1,1.18-.773,2.482,2.482,0,0,1-1.18-.773,3.283,3.283,0,0,1-.573-1.61L22.527,11.9a3.405,3.405,0,0,0-.357-1.585,1.257,1.257,0,0,0-1.1-.465h-.9V8h1.316a3.157,3.157,0,0,1,2.924,1.071,5.435,5.435,0,0,1,1.082,2.595l.129,1.334A2.377,2.377,0,0,0,26.419,14.458a2.51,2.51,0,0,0,1.567.518Z`,fill:`#fbc02d`})]}):null}function Xc({step:e,state:t,onComplete:n,input:r,output:i,isCollapsible:a=!1,approval:o,onFilePathClick:s}){he(t===`animating`,e.duration,n);let c=t===`animating`,l=e.filePath?.split(`/`).pop()??e.toolDetail,u=!!l,d=e.toolName===`Write`,[f,p]=P.useState(`light`),[m,h]=P.useState(!a);P.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=document.documentElement.classList.contains(`dark`);p(e?`dark`:`light`)};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{t.disconnect()}},[]),P.useEffect(()=>{h(!a)},[a]);let g=P.useMemo(()=>{let t=l||`file`,n=typeof i?.old_content==`string`?i.old_content:void 0,a=typeof i?.content==`string`?i.content:void 0,o=!n&&typeof r?.old_string==`string`?r.old_string:void 0,s=!a&&typeof r?.new_string==`string`?r.new_string:void 0,c=e.diffLines?.filter(e=>e.type!==`add`).map(e=>e.content).join(`
|
|
1376
|
+
`}function pc(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function mc(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function hc(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function gc(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function _c(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:vs(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function vc(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}var yc=-1,bc=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++yc}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;pendingFiles;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new Po,this.scrollSyncManager=new Us,this.interactionManager=new ho(`diff`,go(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return _c(e)}createHunksRenderer(e){return new Qs(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>{let n=this.fileDiffCache;if(n==null)return;let r=n.hunks.at(-1),i,a;hunkIterator:for(let o of n.hunks){let n=t===`deletions`?o.deletionStart:o.additionStart,s=t===`deletions`?o.deletionCount:o.additionCount,c=R(n,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(e<c){let t=c-e;i=Math.max(u-t,0),a=Math.max(l-t,0);break hunkIterator}if(e>=c+s){if(o===r){let t=e-(c+s);i=u+o.unifiedLineCount+t,a=l+o.splitLineCount+t;break hunkIterator}continue}for(let n of o.hunkContent)if(n.type===`context`){if(e<c+n.lines){let t=e-c;a=l+t,i=u+t;break hunkIterator}c+=n.lines,l+=n.lines,u+=n.lines}else{let r=t===`deletions`?n.deletions:n.additions;if(e<c+r){let r=e-c;i=u+(t===`additions`?n.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(n.deletions,n.additions),u+=n.deletions+n.additions}break hunkIterator}if(i!=null&&a!=null)return[i,a]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(go(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!zt(this.appliedThemeCSS.theme,this.options.theme??L)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){Ni(this.handleEditSessionRender),this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.pendingFiles=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=js(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t),wc(this.pre,Sc({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||Tc(this.headerElement,Cc({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ts(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)!(e instanceof HTMLElement)||e.tagName.toLowerCase()!==`code`||(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?fa(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;e==null||t==null||!vc(e)||this.pendingFiles?.fileDiff===e||(this.pendingFiles={fileDiff:e,promise:this.loadFilesForDiff(e,t)})}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}finally{this.pendingFiles?.fileDiff===e&&(this.pendingFiles=void 0)}}async handleFilesLoaded(e,t){this.fileDiff!==e||!e.isPartial||(Ps(`merge`,e,t),this.setHydratedState(t),await Ds(()=>this.primeHighlightCache(e)),!(!this.enabled||this.fileDiff!==e)&&this.rerender())}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){let l=js(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);e!=null&&e.cacheKey===void 0&&(e.cacheKey=e.prevName==null?e.name:e.prevName+`:`+e.name),this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,g=this.hasThemeChanged(),_=l!=null,v=_&&(!xc(u,this.deletionFile)||!xc(d,this.additionFile)),y=e!=null&&e!==this.fileDiff,b=i!=null&&(i.length>0||this.lineAnnotations.length>0)&&i!==this.lineAnnotations;if(!f&&Ho(h,this.renderRange)&&!n&&!b&&!g&&(e!=null&&e===this.fileDiff||e==null&&!v))return this.applyCachedThemeState(p);let x;e==null&&_&&(v||this.fileDiff==null)&&(x=fa(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:S}=this;if(this.renderRange=h,_?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e==null?x!=null&&(y=!0,this.fileDiff=x):this.fileDiff=e,y&&(this.cachedHeaderHTML=void 0),i!=null&&this.setLineAnnotations(i),this.fileDiff==null)return!1;this.fileDiff.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(Wa(this.fileDiff,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:C=!1,disableFileHeader:w=!1}=this.options;if(w&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,Mt);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(C)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,b,v||y||g)&&this.applyPartialRender({previousRenderRange:S,renderRange:h}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(C)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}get fileDiffCache(){return this.hunksRenderer.diffCache??this.fileDiff}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.fileDiffCache,r=this.lineAnnotations,i=this.computeEditorRenderRange(this.renderRange);e!=null&&t!=null&&n!=null&&!n.isPartial&&this.hunksRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.fileDiffCache!==n||e.__syncRenderView(a,t,n,r,i)})}computeEditorRenderRange(e){let t=this.fileDiffCache;if(e==null||t==null||Ws(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return Fr({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.attachEditor: cannot attach an editor to a "${this.type}" diff`);return this.editor?.cleanUp(),this.editor=e,this.hunksRenderer.beginEditSession(),this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary(),this.hunksRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),e=>{this.editor=void 0,e!==!0&&this.finishEditSession()}}finishEditSession(){this.hunksRenderer.endEditSession(),this.completeEditSession()}completeEditSession(){let e=this.fileDiffCache;if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Ha(e,this.hunksRenderer.getExpandedHunksMap(),t);return Wa(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Ua(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);let n=this.hunksRenderer.diffCache;if(n!=null){let e=this.fileDiff?.cacheKey;e!=null&&n.cacheKey==null&&(n.cacheKey=e),this.fileDiff=n}t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations()),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){let{shouldRefreshDiffsView:r,lineCountChangeInFlight:i}=n;if(this.hunksRenderer.updateRenderCache(e,t,i)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}r===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}isLineRenderable(e){let t=this.fileDiffCache;if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return Dr({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.fileDiffCache;if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Or({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.fileDiffCache,{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=wr(o);if(e<s){let c=q({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=J({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=wr(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){Mi(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||vr(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!gc(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${Nt(r)}`,a=this.annotationCache.get(i);if(a==null||!hc(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:as(Nt(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=os();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:oo(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):oo(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ts;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:n}=this,r=this.cachedHeaderHTML??ve(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;let{renderCustomHeader:i,renderHeaderPrefix:a,renderHeaderFilenameSuffix:o,renderHeaderMetadata:s}=this.options;if(i!=null){let e=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ct,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let c=a?.(n)??void 0,l=o?.(n)??void 0,u=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,bt,c),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,xt,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,St,u),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=ss(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ms(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=ls(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=xs({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:hs(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=gs(this.themeCSSStyle.textContent??``,ls(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&ws()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?bs(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=Ec(t[0]),a=Ec(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=ve(i),r.content.innerHTML=ve(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=ys({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=ys({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=ys({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:a,options:{diffStyle:o=`split`}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(o,r,a,i);if(s==null)return!1;let c=e.startingLine,l=t.startingLine,u=c+e.totalLines,d=l+t.totalLines,f=Math.max(c,l),p=Math.min(u,d);if(p<=f)return!1;let m=Math.max(0,f-c),h=Math.max(0,u-p),g=this.trimColumns({columns:s,trimStart:m,trimEnd:h,previousStart:c,overlapStart:f,overlapEnd:p,diffStyle:o});if(g<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let _=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},y=v(l,Math.max(f-l,0));if(y==null&&l<f)return!1;let b=v(p,Math.max(d-p,0));if(b==null&&d>p)return!1;let x=(e,t)=>{if(e!=null){if(o===`unified`&&!Array.isArray(s))this.insertPartialHTML(o,s,e,t);else if(o===`split`&&Array.isArray(s))this.insertPartialHTML(o,s,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);_+=e.rowCount}};return this.cleanupErrorWrapper(),x(y,`afterbegin`),x(b,`beforeend`),this.lastRowCount!==_&&(this.applyRowSpan(o,s,_),this.lastRowCount=_),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){if(this.options.diffStyle!==`split`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;let n=(t,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(t,e),i=Ec(r?.[0]),a=Ec(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};n(`deletions`,t[0]),n(`additions`,t[1])}refreshUnifiedDiffView(){if(this.options.diffStyle!==`unified`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null||Array.isArray(t))return;let n=this.hunksRenderer.renderCodeAST(`unified`,e),r=Ec(n?.[0]),i=Ec(n?.[1]),a=()=>{for(let[e,n]of[[t.gutter,r],[t.content,i]])n!=null&&(e.innerHTML=ve(n));e.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,t,e.rowCount),this.lastRowCount=e.rowCount)};this.shouldGuardRebuildScroll()?bs(this.pre,a):a(),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Ec(t[0]),i=Ec(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};ns(u,this.appliedPreAttributes)||(Es(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function xc(e,t){return e==null||t==null?e==null&&t==null:Bt(e,t)}function Sc({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Cc({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function wc(e,t,n=!1){return!n&&e==null&&t}function Tc(e,t,n=!1){return e==null&&t&&!n}function Ec(e){if(e!=null&&e.type===`element`)return e.children??[]}var Dc=3e3,Oc=-1,kc=class extends bc{__id=`little-virtualized-file-diff:${++Oc}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;currentExpandUnchanged;pendingHydratedDiff;pendingExpansions;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=yr(n)}setMetrics(e,t=!1){let n=yr(e);!t&&Di(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!co(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Oi(t,e),r=n&&Lc(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Rc(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}reconcileHeights(){let e=!1,{overflow:t=`scroll`}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;let n=this.getDiffStyle(),r=n===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],i=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&i&&uo(this.renderRange)){let t=Ac(r)??0;this.setFileAnnotationHeight(t)&&(e=!0)}else!i&&this.setFileAnnotationHeight(0)&&(e=!0);for(let t of r){if(t==null)continue;let r=t.children[1];if(r instanceof HTMLElement)for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let i=Hc(r,n),a=t.getBoundingClientRect().height,o=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(o=!0),a+=t.nextElementSibling.getBoundingClientRect().height);let s=this.getEstimatedLineHeight(o),c=this.cache.heightDeltas.get(i)??0,l=a-s;l!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=l-c,l===0?this.cache.heightDeltas.delete(i):this.cache.heightDeltas.set(i,l))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}prepareCodeViewItem(e,t,n,r){let i=!gr(this.fileDiff,e),a=this.syncLineAnnotations(r),o=n?.resetDiffLayoutCache===!0||i||a,s=i||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=yr(n.metrics),o=!0,s=!0);let{collapsed:c=!1,expandUnchanged:l=!1}=this.options;return this.currentCollapsed!==c&&(this.currentCollapsed=c,o=!0),this.currentExpandUnchanged!==l&&(this.currentExpandUnchanged=l,o=!0,s=!0),o&&this.resetLayoutCache({includeEstimatedHeights:s}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t=`additions`){if(this.fileDiff==null||e<1)return;let n=this.getLineIndex(e,t);if(n==null)return;let{disableFileHeader:r=!1,expandUnchanged:i=!1,collapsed:a=!1,collapsedContextThreshold:o=1}=this.options,s=this.getDiffStyle(),c=this.getHunkSeparatorType(),l=s===`split`?n[1]:n[0];this.approximateLayoutCheckpoints();let u=br(this.metrics,r),d=this.getLayoutCheckpointBeforeLineIndex(l),f=d?.top??u+this.cache.fileAnnotationHeight;if(a)return{top:u,height:0};let p;return Fr({diff:this.fileDiff,diffStyle:s,startingLine:d?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=s===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=Nr({type:c,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(f+=r.gapBefore,l>=o-n&&l<o)return p={top:f,height:r.height},!0;f+=r.height+r.gapAfter}}let u=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===l)return p={top:f,height:u},!0;if(f+=u,r>0){let e=Pr({type:c,metrics:this.metrics});if(e!=null){if(l>o&&l<=o+r)return p={top:f+e.gapBefore,height:e.height},!0;f+=e.totalHeight}}return!1}}),p}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.fileDiff==null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1}=this.options;if(r)return;let a=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();let s=this.getLayoutCheckpointBeforeTop(e),c=s?.top??br(this.metrics,t)+this.cache.fileAnnotationHeight,l;return Fr({diff:this.fileDiff,diffStyle:a,startingLine:s?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:s,additionLine:u})=>{let d=a===`split`?u?.splitLineIndex??s?.splitLineIndex:u?.unifiedLineIndex??s?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=Nr({type:o,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(c+=e.totalHeight)}if(c>=e&&(s==null?u!=null&&(l={lineNumber:u.lineNumber,side:`additions`,top:c}):l={lineNumber:s.lineNumber,side:`deletions`,top:c},l!=null))return!0;let f=this.getLineHeight(d,(u?.noEOFCR??!1)||(s?.noEOFCR??!1));if(c+=f,i>0){let e=Pr({type:o,metrics:this.metrics});e!=null&&(c+=e.totalHeight)}return!1}}),l}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.fileDiff,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){let n=Ps(`clone`,e,t);if(await Ds(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Ps(`merge`,e,t),this.setHydratedState(t),await Ds(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}consumeCodeViewLayoutChanges(e){let t=!1,n,{pendingExpansions:r,pendingHydratedDiff:i}=this;if(r!=null){this.pendingExpansions=void 0;for(let e of r)this.hunksRenderer.expandHunk(e.hunkIndex,e.direction,e.expansionLineCountOverride),t=!0}return i!=null&&(this.pendingHydratedDiff=void 0,i.expectedDiff===e&&(this.setHydratedState(i.files),n=i.nextDiff)),n==null?t&&(this.forceRenderOverride=!0,this.invalidateDerivedLayoutCache(!0)):(this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0})),n}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.fileDiffCache;if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return Dr({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),!(!this.enabled||this.fileDiff==null)&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.fileDiff!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.fileDiff){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,o=br(this.metrics,i);if(this.height+=o,a){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getActiveEstimatedHeight(e=this.fileDiff){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.fileDiff){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=Os({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:zc(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.fileDiff){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=js(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Vc(s,this.deletionFile)||!Vc(c,this.additionFile)),u=t??this.fileDiff;t==null&&o&&(l||this.fileDiff==null)&&(u=fa(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=this.syncLineAnnotations(r);p&&this.resetLayoutCache({includeEstimatedHeights:!1});let m=t!=null&&t!==this.fileDiff,h=u!=null&&!gr(this.fileDiff,u),g=m||l;if(h&&this.resetLayoutCache({includeEstimatedHeights:!0}),e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(f)this.top??=this.getVirtualizedTop(),h&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,u));else{this.computeApproximateSize(!1,u);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!g||!f))return this.fileDiff=u,a!=null&&(this.deletionFile=s,this.additionFile=c),h&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let _=this.virtualizer.getWindowSpecs(),v=this.top??0,y=this.computeRenderRangeFromWindow(u,v,_),b=super.render({fileDiff:u,fileContainer:e,renderRange:y,lineAnnotations:r,forceRender:(d??n)||p||h,...a,...i});return this.isSimpleMode()&&b&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),b}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Bc(this.options.hunkSeparators)}approximateLayoutCheckpoints(e=this.fileDiff){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e==null||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=zc(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=jc(this.cache.heightDeltas),u=br(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Pc(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+Fc(i,e)*this.metrics.lineHeight+Mc(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=Dc}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+Mc(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=q({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?Nr({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?J({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?Pr({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Ic({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=q({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=J({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=zc(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=br(this.metrics,i),h=e.hunks.length>0?Sr(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(Fr({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?Nr({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=Pr({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let ee=Math.round(M-w/2),te=Math.max(0,Math.ceil(p/s)-w),ne=Math.max(0,Math.min(ee,te)),re=ne*s,ie=ee<0?C+ee*s:C,ae=E[ne]??0,oe=re===0?0:g+ae,se=ne+ie/s,ce=se<E.length?v-E[se]:v-(k-t-_);return{startingLine:re,totalLines:ie,bufferBefore:oe,bufferAfter:Math.max(0,ce)}}};function Ac(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===so&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function jc(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function Mc({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Nc(e,n);return(t[Nc(e,r)]??0)-(t[i]??0)}function Nc(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Pc(e){return Math.ceil(e/Dc)*Dc}function Fc(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Ic({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Lc(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Rc(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function zc(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Bc(e){return typeof e==`function`?`custom`:e??`line-info`}function Vc(e,t){return e==null||t==null?e==null&&t==null:Bt(e,t)}function Hc(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function Uc(e,t){return typeof window>`u`&&t!=null?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,I.jsx)(I.Fragment,{children:e})}var Wc=(0,F.createContext)(void 0);function Gc(){return(0,F.useContext)(Wc)}var Kc=typeof window>`u`?F.useEffect:F.useLayoutEffect;function qc({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=Gc(),f=i!==void 0,p=(0,F.useContext)(Ei),m=lt(),h=(0,F.useRef)(null),g=st(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new bc(Jc({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new kc(Jc({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return Kc(()=>{let{current:n}=h;if(n==null)return;let a=Jc({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!Oi(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),Kc(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,F.useCallback)(()=>h.current?.getHoveredLine(),[])}}function Jc({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?ft:e?.renderCustomHeader,renderGutterUtility:r?ft:e?.renderGutterUtility}:e}function Yc({oldFile:e,newFile:t,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1}){let v=(0,F.useMemo)(()=>fa(e,t,n?.parseDiffOptions),[e,t,n?.parseDiffOptions]),{ref:y,getHoveredLine:b}=qc({fileDiff:v,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_});return(0,I.jsx)(pt,{ref:y,className:s,style:c,children:Uc(Lt({fileDiff:v,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,lineAnnotations:a,renderGutterUtility:h,getHoveredLine:b}),l)})}function Xc({filename:e,className:t}){let n=e.split(`.`).pop()?.toLowerCase()??``,r=t??`w-2.5 h-2.5 shrink-0`;return n===`ts`||n===`tsx`?(0,I.jsx)(`svg`,{viewBox:`0 0 32 32`,className:r,children:(0,I.jsx)(`path`,{d:`M23.827,8.243A4.424,4.424,0,0,1,26.05,9.524a5.853,5.853,0,0,1,.852,1.143c.011.045-1.534,1.083-2.471,1.662-.034.023-.169-.124-.322-.35a2.014,2.014,0,0,0-1.67-1c-1.077-.074-1.771.49-1.766,1.433a1.3,1.3,0,0,0,.153.666c.237.49.677.784,2.059,1.383,2.544,1.095,3.636,1.817,4.31,2.843a5.158,5.158,0,0,1,.416,4.333,4.764,4.764,0,0,1-3.932,2.815,10.9,10.9,0,0,1-2.708-.028,6.531,6.531,0,0,1-3.616-1.884,6.278,6.278,0,0,1-.926-1.371,2.655,2.655,0,0,1,.327-.208c.158-.09.756-.434,1.32-.761L19.1,19.6l.214.312a4.771,4.771,0,0,0,1.35,1.292,3.3,3.3,0,0,0,3.458-.175,1.545,1.545,0,0,0,.2-1.974c-.276-.395-.84-.727-2.443-1.422a8.8,8.8,0,0,1-3.349-2.055,4.687,4.687,0,0,1-.976-1.777,7.116,7.116,0,0,1-.062-2.268,4.332,4.332,0,0,1,3.644-3.374A9,9,0,0,1,23.827,8.243ZM15.484,9.726l.011,1.454h-4.63V24.328H7.6V11.183H2.97V9.755A13.986,13.986,0,0,1,3.01,8.289c.017-.023,2.832-.034,6.245-.028l6.211.017Z`,fill:`#007acc`})}):n===`js`||n===`mjs`||n===`cjs`||n===`jsx`?(0,I.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:r,children:[(0,I.jsx)(`rect`,{x:`2`,y:`2`,width:`28`,height:`28`,rx:`1.312`,fill:`#f5de19`}),(0,I.jsx)(`path`,{d:`M20.809,23.875a2.866,2.866,0,0,0,2.6,1.6c1.09,0,1.787-.545,1.787-1.3,0-.9-.715-1.222-1.916-1.747l-.658-.282c-1.9-.809-3.16-1.822-3.16-3.964,0-1.973,1.5-3.476,3.853-3.476a3.889,3.889,0,0,1,3.742,2.107L25,18.128A1.789,1.789,0,0,0,23.311,17a1.145,1.145,0,0,0-1.259,1.128c0,.789.489,1.109,1.618,1.6l.658.282c2.236.959,3.5,1.936,3.5,4.133,0,2.369-1.861,3.667-4.36,3.667a5.055,5.055,0,0,1-4.795-2.691Zm-9.295.228c.413.733.789,1.353,1.693,1.353.864,0,1.41-.338,1.41-1.653V14.856h2.631v8.982c0,2.724-1.6,3.964-3.929,3.964a4.085,4.085,0,0,1-3.947-2.4Z`,fill:`#000`})]}):n===`json`||n===`jsonc`?(0,I.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:r,children:[(0,I.jsx)(`path`,{d:`M4.014,14.976a2.51,2.51,0,0,0,1.567-.518A2.377,2.377,0,0,0,6.386,13l.129-1.334A5.435,5.435,0,0,1,7.6,9.071,3.157,3.157,0,0,1,10.519,8h1.316v1.86H10.937a1.257,1.257,0,0,0-1.1.465,3.405,3.405,0,0,0-.357,1.585l-.127,1.244a3.283,3.283,0,0,1-.573,1.61A2.482,2.482,0,0,1,7.6,15.537a2.482,2.482,0,0,1,1.18.773A3.283,3.283,0,0,1,9.349,17.9l.127,1.244a3.405,3.405,0,0,0,.357,1.585,1.257,1.257,0,0,0,1.1.465h.9V23.06H10.519A3.157,3.157,0,0,1,7.6,21.981a5.435,5.435,0,0,1-1.082-2.595L6.386,18.05a2.377,2.377,0,0,0-.805-1.456A2.51,2.51,0,0,0,4.014,16.07Z`,fill:`#fbc02d`}),(0,I.jsx)(`path`,{d:`M27.986,16.07a2.51,2.51,0,0,0-1.567.518,2.377,2.377,0,0,0-.805,1.456l-.129,1.334a5.435,5.435,0,0,1-1.082,2.595A3.157,3.157,0,0,1,21.481,23.06H20.165V21.2h.9a1.257,1.257,0,0,0,1.1-.465,3.405,3.405,0,0,0,.357-1.585l.127-1.244a3.283,3.283,0,0,1,.573-1.61,2.482,2.482,0,0,1,1.18-.773,2.482,2.482,0,0,1-1.18-.773,3.283,3.283,0,0,1-.573-1.61L22.527,11.9a3.405,3.405,0,0,0-.357-1.585,1.257,1.257,0,0,0-1.1-.465h-.9V8h1.316a3.157,3.157,0,0,1,2.924,1.071,5.435,5.435,0,0,1,1.082,2.595l.129,1.334A2.377,2.377,0,0,0,26.419,14.458a2.51,2.51,0,0,0,1.567.518Z`,fill:`#fbc02d`})]}):null}function Zc({step:e,state:t,onComplete:n,input:r,output:i,isCollapsible:a=!1,approval:o,onFilePathClick:s}){ee(t===`animating`,e.duration,n);let c=t===`animating`,l=e.filePath?.split(`/`).pop()??e.toolDetail,u=!!l,d=e.toolName===`Write`,[f,p]=F.useState(`light`),[m,h]=F.useState(!a);F.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=document.documentElement.classList.contains(`dark`);p(e?`dark`:`light`)};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{t.disconnect()}},[]),F.useEffect(()=>{h(!a)},[a]);let g=F.useMemo(()=>{let t=l||`file`,n=typeof i?.old_content==`string`?i.old_content:void 0,a=typeof i?.content==`string`?i.content:void 0,o=!n&&typeof r?.old_string==`string`?r.old_string:void 0,s=!a&&typeof r?.new_string==`string`?r.new_string:void 0,c=e.diffLines?.filter(e=>e.type!==`add`).map(e=>e.content).join(`
|
|
1377
1377
|
`),u=e.diffLines?.filter(e=>e.type!==`remove`).map(e=>e.content).join(`
|
|
1378
|
-
`),d=o??n??c??``,f=s??a??u??``;return!d&&!f?null:{oldFile:{name:t,contents:d},newFile:{name:t,contents:f}}},[l,r,i,e.diffLines]),_=
|
|
1378
|
+
`),d=o??n??c??``,f=s??a??u??``;return!d&&!f?null:{oldFile:{name:t,contents:d},newFile:{name:t,contents:f}}},[l,r,i,e.diffLines]),_=F.useMemo(()=>f===`dark`?{"--diffs-bg":`#000`,"--diffs-bg-buffer-override":`#000`,"--diffs-bg-context-override":`#000`,"--diffs-bg-hover-override":`#0a0a0a`,"--diffs-bg-separator-override":`#0f0f0f`}:void 0,[f]),v=F.useMemo(()=>f===`dark`?`
|
|
1379
1379
|
[data-diff],
|
|
1380
1380
|
[data-file],
|
|
1381
1381
|
[data-diffs-header],
|
|
@@ -1387,9 +1387,9 @@ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./b
|
|
|
1387
1387
|
--diffs-bg-hover-override: #0a0a0a;
|
|
1388
1388
|
--diffs-bg-separator-override: #0f0f0f;
|
|
1389
1389
|
}
|
|
1390
|
-
`:void 0,[f]),y=`an-edit-diff dark:bg-black dark:[--diffs-bg:#000] dark:[--diffs-bg-buffer-override:#000] dark:[--diffs-bg-context-override:#000] dark:[--diffs-bg-hover-override:#0a0a0a] dark:[--diffs-bg-separator-override:#0f0f0f]`;return(0,F.jsxs)(`div`,{className:`an-edit-tool-card overflow-hidden rounded-an-tool-border-radius border border-an-tool-border-color bg-an-tool-background dark:bg-black`,children:[(0,F.jsxs)(`div`,{className:`flex h-7 items-center justify-between bg-an-tool-background px-2.5 py-0 `+(c&&!g?``:`border-b border-an-tool-border-color`),children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[u&&(0,F.jsx)(Yc,{filename:l,className:`h-3 w-3 shrink-0`}),c&&!g?(0,F.jsx)(me,{as:`span`,duration:1.2,className:`text-xs`,children:`Generating...`}):c?(0,F.jsxs)(me,{as:`span`,duration:1.2,className:`text-xs`,children:[d?`Creating`:`Editing`,` `,l]}):(0,F.jsxs)(`span`,{className:`truncate text-xs text-an-tool-color-muted`,children:[d?`Created`:`Edited`,` `,e.filePath&&s?(0,F.jsx)(`button`,{type:`button`,onClick:()=>s(e.filePath??``),className:`truncate underline-offset-2 hover:text-an-tool-color hover:underline`,children:l}):l]})]}),e.diffStats&&!c&&(0,F.jsx)(`span`,{className:`inline-flex gap-2 font-mono text-[11px] text-an-tool-color-muted`,children:e.diffStats.split(` `).map(e=>(0,F.jsx)(`span`,{className:e.startsWith(`+`)?`text-an-diff-added-text`:e.startsWith(`-`)?`text-an-diff-removed-text`:void 0,children:e},e))})]}),g?(0,F.jsx)(`div`,{className:`${y} text-[12px]`,style:_,children:(0,F.jsxs)(`div`,{className:a?`group/edit-diff relative`:`relative`,children:[(0,F.jsx)(`div`,{className:a&&!m?`max-h-[260px] overflow-hidden`:void 0,children:(0,F.jsx)(Jc,{oldFile:g.oldFile,newFile:g.newFile,className:y,style:_,options:{theme:{dark:`github-dark`,light:`github-light`},themeType:f,unsafeCSS:v,diffStyle:`unified`,disableFileHeader:!0}},f)}),a&&(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-label":m?`Hide`:`Show more`,className:`group absolute inset-x-0 bottom-0 flex h-16 items-end justify-center pb-2 text-muted-foreground `+(m?`bg-transparent`:`bg-linear-to-b from-transparent to-background`),children:(0,F.jsx)(j,{className:`h-4 w-4 opacity-0 transition-opacity duration-150 group-hover:opacity-100 `+(m?`rotate-180`:`rotate-0`)})})})]})}):null,o&&(0,F.jsx)(ge,{isPending:c,...o})]})}var Zc=(0,P.memo)(function({part:e,isCollapsible:t=!1,onFilePathClick:n}){let r=e.input?.approval??e.args?.approval,i=e.type?.replace(`tool-`,``)||`Edit`,{step:a,stepState:o}=_e(e,i);return(0,F.jsx)(Xc,{step:a,state:o,onComplete:()=>{},input:e.input??e.args,output:e.output??e.result,isCollapsible:t,approval:r,onFilePathClick:n})});function Qc({className:e,...t}){return(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,className:e??`animate-spin text-muted-foreground will-change-transform`,...t,children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,fill:`none`,opacity:.2}),(0,F.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,fill:`none`})]})}function $c(e){return(0,F.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,F.jsx)(`path`,{d:`M5 12.75L10 19L19 5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function el(e){return(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,width:`24`,height:`24`,...e,children:[(0,F.jsx)(`path`,{d:`M14 6L20 12L14 18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,F.jsx)(`path`,{d:`M19 12H4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}function tl(e,t){if(!e||e.length===0)return{type:`creation`,items:t.map((e,t)=>({todo:e,newStatus:e.status,index:t}))};let n=[];return t.forEach((t,r)=>{let i=e[r];(!i||i.status!==t.status)&&n.push({todo:t,oldStatus:i?.status,newStatus:t.status,index:r})}),n.length===1?{type:`single`,items:n}:{type:`multiple`,items:n}}var nl=({status:e,isPending:t})=>{if(t&&e===`in_progress`)return(0,F.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/60`,children:(0,F.jsx)(el,{className:`h-2 w-2 text-an-foreground-muted/70`})});switch(e){case`completed`:return(0,F.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/40`,children:(0,F.jsx)($c,{className:`h-2 w-2 text-an-foreground-muted/70`})});case`in_progress`:return(0,F.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/60`,children:(0,F.jsx)(el,{className:`h-2 w-2 text-an-foreground-muted/70`})});default:return(0,F.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/60`})}},rl=(0,P.memo)(function({todo:e,isPending:t}){return(0,F.jsxs)(`div`,{className:p(`flex items-start gap-2`),children:[(0,F.jsx)(`div`,{className:`mt-[2px]`,children:(0,F.jsx)(nl,{status:e.status,isPending:t})}),(0,F.jsx)(`span`,{className:p(`text-sm`,e.status===`completed`&&`line-through`,t||e.status===`completed`||e.status===`pending`?`text-an-foreground/60`:`text-an-foreground/80`),children:e.content})]})}),il=(0,P.memo)(function({part:e,chatStatus:t}){let{isPending:n}=I(e,t),r=e.state===`input-streaming`,i=e.output?.oldTodos||[],a=e.input?.todos||e.output?.newTodos||[],o=i.length===0,s=(0,P.useMemo)(()=>tl(i,a),[i,a]);return r||a.length===0?(0,F.jsx)(`div`,{className:`flex flex-col gap-2 text-sm leading-relaxed text-an-foreground/80`,children:(0,F.jsx)(`div`,{className:`text-an-foreground/60`,children:(0,F.jsx)(me,{as:`span`,duration:1.2,className:`m-0 inline-flex h-4 items-center text-sm leading-none`,children:o?`Creating to-do list...`:`Updating to-dos...`})})}):(s.type===`single`||s.type,(0,F.jsx)(`div`,{className:`flex flex-col gap-2 text-sm leading-relaxed text-an-foreground/80`,children:a.map(e=>(0,F.jsx)(rl,{todo:e,isPending:n},e.content))}))},He);function al(e){let t=e.id?.trim();return t?t.endsWith(`.md`)?t:`plan-${t}.md`:`plan-working.md`}var ol=(0,P.memo)(function({part:e,chatStatus:t}){let{isPending:n}=I(e,t),r=e.input?.plan,[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(null),[u,d]=(0,P.useState)(!1),[f,m]=(0,P.useState)(``);if(!r)return null;let h=al(r),g=r.summary?.trim()??``,_=g.length>0,v=e.input?.completed??0,y=e.input?.total??r.todos?.length??0,b=!!e.input?.pendingDecision,x=b&&!n,C=e.input?.approved||o||r.status===`approved`||r.status===`completed`,w=async(e,t,n)=>{if(!(!t||c)){l(e);try{await t(n),e===`execute`&&s(!0),e===`refine`&&(m(``),d(!1))}finally{l(null)}}},T=y>0?`${v}/${y} complete`:b?`Awaiting review`:void 0;return(0,F.jsxs)(`div`,{className:`an-tool-plan overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,F.jsxs)(`div`,{className:`flex h-7 items-center justify-between pr-2.5 pl-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n?(0,F.jsx)(Qc,{className:`h-3 w-3 shrink-0 animate-spin text-an-tool-color-muted`}):(0,F.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 text-an-tool-color-muted`}),(0,F.jsx)(`span`,{className:`truncate text-xs text-an-tool-color-muted`,children:h})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-label":i?`Collapse plan`:`Expand plan`,className:`inline-flex size-5 items-center justify-center text-an-tool-color-muted`,children:i?(0,F.jsx)(Pe,{className:`h-3.5 w-3.5`}):(0,F.jsx)(Ne,{className:`h-3.5 w-3.5`})})]}),(0,F.jsxs)(`div`,{className:`border-t border-border bg-background pt-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3`,children:[(0,F.jsx)(`div`,{className:`text-sm text-an-tool-color`,children:r.title}),T?(0,F.jsx)(`div`,{className:`rounded-full border border-border px-2 py-0.5 text-[11px] text-an-tool-color-muted`,children:T}):null]}),_?(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`div`,{className:p(`px-3`,`text-sm text-an-tool-color-muted`,!i&&`max-h-[94px] overflow-hidden`),children:(0,F.jsx)(S,{content:g,className:`text-sm`})}),!i&&(0,F.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 h-16 pr-2 pb-2 pl-3.5`,children:[(0,F.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-full w-full bg-linear-to-b from-transparent from-0% to-background to-50%`}),(0,F.jsx)(`div`,{className:`relative flex h-full items-end justify-between`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`-mx-2 h-5 rounded-[4px] px-1.5 text-xs text-muted-foreground hover:text-an-tool-color`,children:`Read detailed plan`})})]})]}):(0,F.jsx)(`div`,{className:`text-xs text-an-tool-color-muted`,children:`No plan summary provided.`})]}),(i||!_)&&(0,F.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border bg-an-tool-background pt-1.5 pr-2 pb-2 pl-3.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`-mx-2 h-5 rounded-[4px] px-1.5 text-xs text-muted-foreground hover:text-an-tool-color`,children:i?`Hide detailed plan`:`Read detailed plan`}),x?(0,F.jsx)(`div`,{className:`text-[11px] text-an-tool-color-muted`,children:`Choose what to do with this plan.`}):C?(0,F.jsx)(`div`,{className:`text-[11px] text-an-tool-color-muted`,children:`Approved`}):null]}),x?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border bg-an-tool-background px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>w(`execute`,e.input?.onExecute),disabled:!!c,className:`h-7 rounded-[6px] bg-an-primary-color px-2.5 text-xs font-medium text-an-send-button-color disabled:opacity-60`,children:c===`execute`?`Executing...`:e.input?.executeLabel??`Execute`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>w(`stay`,e.input?.onStay),disabled:!!c,className:`h-7 rounded-[6px] border border-border px-2.5 text-xs text-an-tool-color disabled:opacity-60`,children:c===`stay`?`Saving...`:e.input?.stayLabel??`Stay`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),disabled:!!c,className:`h-7 rounded-[6px] border border-border px-2.5 text-xs text-an-tool-color disabled:opacity-60`,children:e.input?.refineLabel??`Refine`})]}),u?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,F.jsx)(`textarea`,{value:f,onChange:e=>m(e.target.value),rows:3,placeholder:`Describe what should change in the plan`,className:`w-full resize-y rounded-[8px] border border-border bg-background px-3 py-2 text-base text-an-tool-color outline-none focus:border-an-primary-color md:text-sm`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{d(!1),m(``)},disabled:!!c,className:`h-7 rounded-[6px] border border-border px-2.5 text-xs text-an-tool-color disabled:opacity-60`,children:`Cancel`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>w(`refine`,e.input?.onRefine,f),disabled:!!c,className:`h-7 rounded-[6px] bg-an-primary-color px-2.5 text-xs font-medium text-an-send-button-color disabled:opacity-60`,children:c===`refine`?`Submitting...`:`Submit refinement`})]})]}):null]}):null]})]})},He);function sl(e,t){let[n,r]=(0,P.useState)(0);return(0,P.useEffect)(()=>{if(t&&e){r(Date.now()-e);let t=setInterval(()=>{r(Date.now()-e)},1e3);return()=>clearInterval(t)}},[t,e]),n}function cl(e,t){return`${e} ${e===1?t:`${t}s`}`}function ll(e){if(e.length===0)return``;let t=new Set([`tool-Read`,`tool-Edit`,`tool-Write`]),n=new Set([`tool-Search`,`tool-Grep`,`tool-Glob`,`tool-WebSearch`]),r=new Set([`tool-Bash`]),i=0,a=0,o=0;for(let s of e)t.has(s.type)?i+=1:n.has(s.type)?a+=1:r.has(s.type)&&(o+=1);let s=[];return i>0&&s.push(cl(i,`file`)),a>0&&s.push(`${a} ${a===1?`search`:`searches`}`),o>0&&s.push(cl(o,`command`)),s.length===0?``:s.length===1?s[0]:s.length===2?`${s[0]} and ${s[1]}`:`${s.slice(0,-1).join(`, `)}, and ${s[s.length-1]}`}function ul(e){let t=new Set([`tool-Read`,`tool-Edit`,`tool-Write`]),n=new Set([`tool-Search`,`tool-Grep`,`tool-Glob`,`tool-WebSearch`]),r=0,i=0;for(let a of e)t.has(a.type)?r+=1:n.has(a.type)&&(i+=1);return{fileCount:r,searchCount:i}}function dl(e,t){let n=[];return e>0&&n.push(cl(e,`file`)),t>0&&n.push(`${t} ${t===1?`search`:`searches`}`),n.join(`, `)}var fl=(0,P.memo)(function({part:e,nestedTools:t=[],chatStatus:n,completeLabel:r,shimmerLabel:i,interruptedLabel:a,maxVisibleTools:o=5,defaultOpen:s,showElapsed:c=!0}){let{isPending:l,isInterrupted:u}=I(e,n),d=e.input?.description||``,[f,m]=(0,P.useState)(s??!1),[h,g]=(0,P.useState)(0),_=e.callProviderMetadata?.custom?.startedAt??e.startedAt,v=t.length>0,y=e.toolCallId??e.id??``,b=e.output?.totalDurationMs||e.output?.duration||e.output?.duration_ms,x=Math.max(1,o)*28,S=l?Math.max(h,0):t.length,C=(0,P.useRef)(l),w=(0,P.useRef)(!1),T=(0,P.useRef)(null),{fileCount:E,searchCount:D}=(0,P.useMemo)(()=>ul(l?t.slice(0,Math.max(h,0)):t),[l,t,h]),O=dl(E,D),k=(0,P.useRef)(null),A=sl(_,l);(0,P.useEffect)(()=>{let e=C.current;return T.current&&=(window.clearTimeout(T.current),null),l&&!e&&!w.current&&s!==!1&&(m(!1),T.current=window.setTimeout(()=>{m(!0)},60)),!l&&e&&(m(!1),w.current=!1),C.current=l,()=>{T.current&&=(window.clearTimeout(T.current),null)}},[s,l]),(0,P.useEffect)(()=>{if(!l||t.length===0){g(t.length);return}let e=1;g(Math.min(e,t.length));let n=setInterval(()=>{e+=1,g(Math.min(e,t.length)),e>=t.length&&clearInterval(n)},450);return()=>clearInterval(n)},[l,t.length,y]),(0,P.useEffect)(()=>{!l||!k.current||(k.current.scrollTop=k.current.scrollHeight)},[l,h]);let j=(()=>{if(l&&v)return O;if(!l&&v){let e=ll(t);if(e)return e}return d?d.length>60?`${d.slice(0,57)}...`:d:``})(),M=Ue(!l&&b?b:A);return u&&!e.output?(0,F.jsx)(tt,{completeLabel:a,isAnimating:!1}):(0,F.jsx)(tt,{completeLabel:r,shimmerLabel:i,isAnimating:l,detail:j,expandable:v,expanded:f,onToggleExpand:()=>{w.current=!0,m(e=>!e)},trailingContent:c&&M?(0,F.jsx)(`span`,{className:`shrink-0 font-normal text-an-foreground-muted/60 tabular-nums`,children:M}):void 0,children:(0,F.jsxs)(`div`,{className:`relative`,children:[l&&f&&S>4&&(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-10 bg-linear-to-b from-an-background to-transparent`}),(0,F.jsx)(`div`,{ref:k,className:p(t.length>1?`flex flex-col gap-2`:void 0,l&&f&&S>4&&`overflow-y-auto`),style:l&&f&&S>4?{height:`${x}px`}:void 0,children:(l?t.slice(0,Math.max(h,0)):t).map((e,t)=>{let r=l?{...e,state:t===h-1?`input-streaming`:`output-available`}:e,i=Ze[r.type];if(!i)return null;let{isPending:a,isError:o}=I(r,n);return(0,F.jsx)(nt,{icon:i.icon,title:i.title(r),subtitle:i.subtitle?.(r),isPending:a,isError:o},r.toolCallId??r.id??`${r.type}-${i.title(r)}`)})})]})})}),pl=[`query`,`question`,`email`,`name`,`id`,`customer`,`url`,`issue`,`body`,`summary`,`title`],ml={List:`Listing`,Get:`Getting`,Create:`Creating`,Update:`Updating`,Delete:`Deleting`,Search:`Searching`,Fetch:`Fetching`,Retrieve:`Retrieving`,Send:`Sending`,Generate:`Generating`,Add:`Adding`,Remove:`Removing`,Modify:`Modifying`,Draft:`Drafting`,Manage:`Managing`,Query:`Querying`,Start:`Starting`,Set:`Setting`,Check:`Checking`,Find:`Finding`},hl={List:`Listed`,Get:`Got`,Create:`Created`,Update:`Updated`,Delete:`Deleted`,Search:`Searched`,Fetch:`Fetched`,Retrieve:`Retrieved`,Send:`Sent`,Generate:`Generated`,Add:`Added`,Remove:`Removed`,Modify:`Modified`,Draft:`Drafted`,Manage:`Managed`,Query:`Queried`,Start:`Started`,Set:`Set`,Check:`Checked`,Find:`Found`};function gl(e){let t=e.displayName.split(` `),n=t[0],r=t.slice(1).join(` `),i=ml[n];return i?r?`${i} ${r}`:i:e.displayName}function _l(e){let t=e.displayName.split(` `),n=t[0],r=t.slice(1).join(` `),i=hl[n];return i?r?`${i} ${r}`:i:e.displayName}function vl(e){if(!e||typeof e!=`object`)return``;let t=Object.entries(e).filter(([,e])=>e!=null&&e!==``);if(t.length===0)return``;let n=[...t].sort(([e],[t])=>{let n=pl.indexOf(e),r=pl.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?0:1:-1}),r=[];for(let[e,t]of n){if(r.length>=2)break;let n=typeof t==`string`?t:JSON.stringify(t),i=n.length>30?n.slice(0,27)+`...`:n;r.push(`${e}: ${i}`)}return r.join(` `)}function yl(e){if(!e)return e;if(Array.isArray(e)){let t=[];for(let n of e)n?.type===`text`&&typeof n?.text==`string`&&t.push(n.text);if(t.length>0){let e=t.join(``);try{return JSON.parse(e)}catch{return e}}return e}if(e?.type===`text`&&typeof e?.text==`string`)try{return JSON.parse(e.text)}catch{return e.text}if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}function bl(e){let t=yl(e);if(typeof t==`string`)return t.length>3e3?t.slice(0,3e3)+`
|
|
1390
|
+
`:void 0,[f]),y=`an-edit-diff dark:bg-black dark:[--diffs-bg:#000] dark:[--diffs-bg-buffer-override:#000] dark:[--diffs-bg-context-override:#000] dark:[--diffs-bg-hover-override:#0a0a0a] dark:[--diffs-bg-separator-override:#0f0f0f]`;return(0,I.jsxs)(`div`,{className:`an-edit-tool-card overflow-hidden rounded-an-tool-border-radius border border-an-tool-border-color bg-an-tool-background dark:bg-black`,children:[(0,I.jsxs)(`div`,{className:`flex h-7 items-center justify-between bg-an-tool-background px-2.5 py-0 `+(c&&!g?``:`border-b border-an-tool-border-color`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[u&&(0,I.jsx)(Xc,{filename:l,className:`h-3 w-3 shrink-0`}),c&&!g?(0,I.jsx)(N,{as:`span`,duration:1.2,className:`text-xs`,children:`Generating...`}):c?(0,I.jsxs)(N,{as:`span`,duration:1.2,className:`text-xs`,children:[d?`Creating`:`Editing`,` `,l]}):(0,I.jsxs)(`span`,{className:`truncate text-xs text-an-tool-color-muted`,children:[d?`Created`:`Edited`,` `,e.filePath&&s?(0,I.jsx)(`button`,{type:`button`,onClick:()=>s(e.filePath??``),className:`truncate underline-offset-2 hover:text-an-tool-color hover:underline`,children:l}):l]})]}),e.diffStats&&!c&&(0,I.jsx)(`span`,{className:`inline-flex gap-2 font-mono text-[11px] text-an-tool-color-muted`,children:e.diffStats.split(` `).map(e=>(0,I.jsx)(`span`,{className:e.startsWith(`+`)?`text-an-diff-added-text`:e.startsWith(`-`)?`text-an-diff-removed-text`:void 0,children:e},e))})]}),g?(0,I.jsx)(`div`,{className:`${y} text-[12px]`,style:_,children:(0,I.jsxs)(`div`,{className:a?`group/edit-diff relative`:`relative`,children:[(0,I.jsx)(`div`,{className:a&&!m?`max-h-[260px] overflow-hidden`:void 0,children:(0,I.jsx)(Yc,{oldFile:g.oldFile,newFile:g.newFile,className:y,style:_,options:{theme:{dark:`github-dark`,light:`github-light`},themeType:f,unsafeCSS:v,diffStyle:`unified`,disableFileHeader:!0}},f)}),a&&(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-label":m?`Hide`:`Show more`,className:`group absolute inset-x-0 bottom-0 flex h-16 items-end justify-center pb-2 text-muted-foreground `+(m?`bg-transparent`:`bg-linear-to-b from-transparent to-background`),children:(0,I.jsx)(E,{className:`h-4 w-4 opacity-0 transition-opacity duration-150 group-hover:opacity-100 `+(m?`rotate-180`:`rotate-0`)})})})]})}):null,o&&(0,I.jsx)(te,{isPending:c,...o})]})}var Qc=(0,F.memo)(function({part:e,isCollapsible:t=!1,onFilePathClick:n}){let r=e.input?.approval??e.args?.approval,i=e.type?.replace(`tool-`,``)||`Edit`,{step:a,stepState:o}=ne(e,i);return(0,I.jsx)(Zc,{step:a,state:o,onComplete:()=>{},input:e.input??e.args,output:e.output??e.result,isCollapsible:t,approval:r,onFilePathClick:n})});function $c({className:e,...t}){return(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,className:e??`animate-spin text-muted-foreground will-change-transform`,...t,children:[(0,I.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,fill:`none`,opacity:.2}),(0,I.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,fill:`none`})]})}function el(e){return(0,I.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,I.jsx)(`path`,{d:`M5 12.75L10 19L19 5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function tl(e){return(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,width:`24`,height:`24`,...e,children:[(0,I.jsx)(`path`,{d:`M14 6L20 12L14 18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`M19 12H4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}function nl(e,t){if(!e||e.length===0)return{type:`creation`,items:t.map((e,t)=>({todo:e,newStatus:e.status,index:t}))};let n=[];return t.forEach((t,r)=>{let i=e[r];(!i||i.status!==t.status)&&n.push({todo:t,oldStatus:i?.status,newStatus:t.status,index:r})}),n.length===1?{type:`single`,items:n}:{type:`multiple`,items:n}}var rl=({status:e,isPending:t})=>{if(t&&e===`in_progress`)return(0,I.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/60`,children:(0,I.jsx)(tl,{className:`h-2 w-2 text-an-foreground-muted/70`})});switch(e){case`completed`:return(0,I.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/40`,children:(0,I.jsx)(el,{className:`h-2 w-2 text-an-foreground-muted/70`})});case`in_progress`:return(0,I.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/60`,children:(0,I.jsx)(tl,{className:`h-2 w-2 text-an-foreground-muted/70`})});default:return(0,I.jsx)(`div`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-an-foreground-muted/60`})}},il=(0,F.memo)(function({todo:e,isPending:t}){return(0,I.jsxs)(`div`,{className:f(`flex items-start gap-2`),children:[(0,I.jsx)(`div`,{className:`mt-[2px]`,children:(0,I.jsx)(rl,{status:e.status,isPending:t})}),(0,I.jsx)(`span`,{className:f(`text-sm`,e.status===`completed`&&`line-through`,t||e.status===`completed`||e.status===`pending`?`text-an-foreground/60`:`text-an-foreground/80`),children:e.content})]})}),al=(0,F.memo)(function({part:e,chatStatus:t}){let{isPending:n}=Ue(e,t),r=e.state===`input-streaming`,i=e.output?.oldTodos||[],a=e.input?.todos||e.output?.newTodos||[],o=i.length===0,s=(0,F.useMemo)(()=>nl(i,a),[i,a]);return r||a.length===0?(0,I.jsx)(`div`,{className:`flex flex-col gap-2 text-sm leading-relaxed text-an-foreground/80`,children:(0,I.jsx)(`div`,{className:`text-an-foreground/60`,children:(0,I.jsx)(N,{as:`span`,duration:1.2,className:`m-0 inline-flex h-4 items-center text-sm leading-none`,children:o?`Creating to-do list...`:`Updating to-dos...`})})}):(s.type===`single`||s.type,(0,I.jsx)(`div`,{className:`flex flex-col gap-2 text-sm leading-relaxed text-an-foreground/80`,children:a.map(e=>(0,I.jsx)(il,{todo:e,isPending:n},e.content))}))},Ve);function ol(e){let t=e.id?.trim();return t?t.endsWith(`.md`)?t:`plan-${t}.md`:`plan-working.md`}var sl=(0,F.memo)(function({part:e,chatStatus:t}){let{isPending:n}=Ue(e,t),r=e.input?.plan,[i,a]=(0,F.useState)(!1),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(!1),[p,m]=(0,F.useState)(``);if(!r)return null;let h=ol(r),g=r.summary?.trim()??``,_=g.length>0,y=e.input?.completed??0,b=e.input?.total??r.todos?.length??0,x=!!e.input?.pendingDecision,S=x&&!n,C=e.input?.approved||o||r.status===`approved`||r.status===`completed`,w=async(e,t,n)=>{if(!(!t||c)){l(e);try{await t(n),e===`execute`&&s(!0),e===`refine`&&(m(``),d(!1))}finally{l(null)}}},T=b>0?`${y}/${b} complete`:x?`Awaiting review`:void 0;return(0,I.jsxs)(`div`,{className:`an-tool-plan overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,I.jsxs)(`div`,{className:`flex h-7 items-center justify-between pr-2.5 pl-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n?(0,I.jsx)($c,{className:`h-3 w-3 shrink-0 animate-spin text-an-tool-color-muted`}):(0,I.jsx)(ue,{className:`h-3.5 w-3.5 shrink-0 text-an-tool-color-muted`}),(0,I.jsx)(`span`,{className:`truncate text-xs text-an-tool-color-muted`,children:h})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-label":i?`Collapse plan`:`Expand plan`,className:`inline-flex size-5 items-center justify-center text-an-tool-color-muted`,children:i?(0,I.jsx)(Ne,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Me,{className:`h-3.5 w-3.5`})})]}),(0,I.jsxs)(`div`,{className:`border-t border-border bg-background pt-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3`,children:[(0,I.jsx)(`div`,{className:`text-sm text-an-tool-color`,children:r.title}),T?(0,I.jsx)(`div`,{className:`rounded-full border border-border px-2 py-0.5 text-[11px] text-an-tool-color-muted`,children:T}):null]}),_?(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`div`,{className:f(`px-3`,`text-sm text-an-tool-color-muted`,!i&&`max-h-[94px] overflow-hidden`),children:(0,I.jsx)(v,{content:g,className:`text-sm`})}),!i&&(0,I.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 h-16 pr-2 pb-2 pl-3.5`,children:[(0,I.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-full w-full bg-linear-to-b from-transparent from-0% to-background to-50%`}),(0,I.jsx)(`div`,{className:`relative flex h-full items-end justify-between`,children:(0,I.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`-mx-2 h-5 rounded-[4px] px-1.5 text-xs text-muted-foreground hover:text-an-tool-color`,children:`Read detailed plan`})})]})]}):(0,I.jsx)(`div`,{className:`text-xs text-an-tool-color-muted`,children:`No plan summary provided.`})]}),(i||!_)&&(0,I.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border bg-an-tool-background pt-1.5 pr-2 pb-2 pl-3.5`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`-mx-2 h-5 rounded-[4px] px-1.5 text-xs text-muted-foreground hover:text-an-tool-color`,children:i?`Hide detailed plan`:`Read detailed plan`}),S?(0,I.jsx)(`div`,{className:`text-[11px] text-an-tool-color-muted`,children:`Choose what to do with this plan.`}):C?(0,I.jsx)(`div`,{className:`text-[11px] text-an-tool-color-muted`,children:`Approved`}):null]}),S?(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border bg-an-tool-background px-3 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>w(`execute`,e.input?.onExecute),disabled:!!c,className:`h-7 rounded-[6px] bg-an-primary-color px-2.5 text-xs font-medium text-an-send-button-color disabled:opacity-60`,children:c===`execute`?`Executing...`:e.input?.executeLabel??`Execute`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>w(`stay`,e.input?.onStay),disabled:!!c,className:`h-7 rounded-[6px] border border-border px-2.5 text-xs text-an-tool-color disabled:opacity-60`,children:c===`stay`?`Saving...`:e.input?.stayLabel??`Stay`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),disabled:!!c,className:`h-7 rounded-[6px] border border-border px-2.5 text-xs text-an-tool-color disabled:opacity-60`,children:e.input?.refineLabel??`Refine`})]}),u?(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:3,placeholder:`Describe what should change in the plan`,className:`w-full resize-y rounded-[8px] border border-border bg-background px-3 py-2 text-base text-an-tool-color outline-none focus:border-an-primary-color md:text-sm`}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>{d(!1),m(``)},disabled:!!c,className:`h-7 rounded-[6px] border border-border px-2.5 text-xs text-an-tool-color disabled:opacity-60`,children:`Cancel`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>w(`refine`,e.input?.onRefine,p),disabled:!!c,className:`h-7 rounded-[6px] bg-an-primary-color px-2.5 text-xs font-medium text-an-send-button-color disabled:opacity-60`,children:c===`refine`?`Submitting...`:`Submit refinement`})]})]}):null]}):null]})]})},Ve);function cl(e,t){let[n,r]=(0,F.useState)(0);return(0,F.useEffect)(()=>{if(t&&e){r(Date.now()-e);let t=setInterval(()=>{r(Date.now()-e)},1e3);return()=>clearInterval(t)}},[t,e]),n}function ll(e,t){return`${e} ${e===1?t:`${t}s`}`}function ul(e){if(e.length===0)return``;let t=new Set([`tool-Read`,`tool-Edit`,`tool-Write`]),n=new Set([`tool-Search`,`tool-Grep`,`tool-Glob`,`tool-WebSearch`]),r=new Set([`tool-Bash`]),i=0,a=0,o=0;for(let s of e)t.has(s.type)?i+=1:n.has(s.type)?a+=1:r.has(s.type)&&(o+=1);let s=[];return i>0&&s.push(ll(i,`file`)),a>0&&s.push(`${a} ${a===1?`search`:`searches`}`),o>0&&s.push(ll(o,`command`)),s.length===0?``:s.length===1?s[0]:s.length===2?`${s[0]} and ${s[1]}`:`${s.slice(0,-1).join(`, `)}, and ${s[s.length-1]}`}function dl(e){let t=new Set([`tool-Read`,`tool-Edit`,`tool-Write`]),n=new Set([`tool-Search`,`tool-Grep`,`tool-Glob`,`tool-WebSearch`]),r=0,i=0;for(let a of e)t.has(a.type)?r+=1:n.has(a.type)&&(i+=1);return{fileCount:r,searchCount:i}}function fl(e,t){let n=[];return e>0&&n.push(ll(e,`file`)),t>0&&n.push(`${t} ${t===1?`search`:`searches`}`),n.join(`, `)}var pl=(0,F.memo)(function({part:e,nestedTools:t=[],chatStatus:n,completeLabel:r,shimmerLabel:i,interruptedLabel:a,maxVisibleTools:o=5,defaultOpen:s,showElapsed:c=!0}){let{isPending:l,isInterrupted:u}=Ue(e,n),d=e.input?.description||``,[p,m]=(0,F.useState)(s??!1),[h,g]=(0,F.useState)(0),_=e.callProviderMetadata?.custom?.startedAt??e.startedAt,v=t.length>0,y=e.toolCallId??e.id??``,b=e.output?.totalDurationMs||e.output?.duration||e.output?.duration_ms,x=Math.max(1,o)*28,S=l?Math.max(h,0):t.length,C=(0,F.useRef)(l),w=(0,F.useRef)(!1),T=(0,F.useRef)(null),{fileCount:E,searchCount:D}=(0,F.useMemo)(()=>dl(l?t.slice(0,Math.max(h,0)):t),[l,t,h]),O=fl(E,D),k=(0,F.useRef)(null),A=cl(_,l);(0,F.useEffect)(()=>{let e=C.current;return T.current&&=(window.clearTimeout(T.current),null),l&&!e&&!w.current&&s!==!1&&(m(!1),T.current=window.setTimeout(()=>{m(!0)},60)),!l&&e&&(m(!1),w.current=!1),C.current=l,()=>{T.current&&=(window.clearTimeout(T.current),null)}},[s,l]),(0,F.useEffect)(()=>{if(!l||t.length===0){g(t.length);return}let e=1;g(Math.min(e,t.length));let n=setInterval(()=>{e+=1,g(Math.min(e,t.length)),e>=t.length&&clearInterval(n)},450);return()=>clearInterval(n)},[l,t.length,y]),(0,F.useEffect)(()=>{!l||!k.current||(k.current.scrollTop=k.current.scrollHeight)},[l,h]);let j=(()=>{if(l&&v)return O;if(!l&&v){let e=ul(t);if(e)return e}return d?d.length>60?`${d.slice(0,57)}...`:d:``})(),M=He(!l&&b?b:A);return u&&!e.output?(0,I.jsx)(nt,{completeLabel:a,isAnimating:!1}):(0,I.jsx)(nt,{completeLabel:r,shimmerLabel:i,isAnimating:l,detail:j,expandable:v,expanded:p,onToggleExpand:()=>{w.current=!0,m(e=>!e)},trailingContent:c&&M?(0,I.jsx)(`span`,{className:`shrink-0 font-normal text-an-foreground-muted/60 tabular-nums`,children:M}):void 0,children:(0,I.jsxs)(`div`,{className:`relative`,children:[l&&p&&S>4&&(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-10 bg-linear-to-b from-an-background to-transparent`}),(0,I.jsx)(`div`,{ref:k,className:f(t.length>1?`flex flex-col gap-2`:void 0,l&&p&&S>4&&`overflow-y-auto`),style:l&&p&&S>4?{height:`${x}px`}:void 0,children:(l?t.slice(0,Math.max(h,0)):t).map((e,t)=>{let r=l?{...e,state:t===h-1?`input-streaming`:`output-available`}:e,i=Qe[r.type];if(!i)return null;let{isPending:a,isError:o}=Ue(r,n);return(0,I.jsx)(rt,{icon:i.icon,title:i.title(r),subtitle:i.subtitle?.(r),isPending:a,isError:o},r.toolCallId??r.id??`${r.type}-${i.title(r)}`)})})]})})}),ml=[`query`,`question`,`email`,`name`,`id`,`customer`,`url`,`issue`,`body`,`summary`,`title`],hl={List:`Listing`,Get:`Getting`,Create:`Creating`,Update:`Updating`,Delete:`Deleting`,Search:`Searching`,Fetch:`Fetching`,Retrieve:`Retrieving`,Send:`Sending`,Generate:`Generating`,Add:`Adding`,Remove:`Removing`,Modify:`Modifying`,Draft:`Drafting`,Manage:`Managing`,Query:`Querying`,Start:`Starting`,Set:`Setting`,Check:`Checking`,Find:`Finding`},gl={List:`Listed`,Get:`Got`,Create:`Created`,Update:`Updated`,Delete:`Deleted`,Search:`Searched`,Fetch:`Fetched`,Retrieve:`Retrieved`,Send:`Sent`,Generate:`Generated`,Add:`Added`,Remove:`Removed`,Modify:`Modified`,Draft:`Drafted`,Manage:`Managed`,Query:`Queried`,Start:`Started`,Set:`Set`,Check:`Checked`,Find:`Found`};function _l(e){let t=e.displayName.split(` `),n=t[0],r=t.slice(1).join(` `),i=hl[n];return i?r?`${i} ${r}`:i:e.displayName}function vl(e){let t=e.displayName.split(` `),n=t[0],r=t.slice(1).join(` `),i=gl[n];return i?r?`${i} ${r}`:i:e.displayName}function yl(e){if(!e||typeof e!=`object`)return``;let t=Object.entries(e).filter(([,e])=>e!=null&&e!==``);if(t.length===0)return``;let n=[...t].sort(([e],[t])=>{let n=ml.indexOf(e),r=ml.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?0:1:-1}),r=[];for(let[e,t]of n){if(r.length>=2)break;let n=typeof t==`string`?t:JSON.stringify(t),i=n.length>30?n.slice(0,27)+`...`:n;r.push(`${e}: ${i}`)}return r.join(` `)}function bl(e){if(!e)return e;if(Array.isArray(e)){let t=[];for(let n of e)n?.type===`text`&&typeof n?.text==`string`&&t.push(n.text);if(t.length>0){let e=t.join(``);try{return JSON.parse(e)}catch{return e}}return e}if(e?.type===`text`&&typeof e?.text==`string`)try{return JSON.parse(e.text)}catch{return e.text}if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}function xl(e){let t=bl(e);if(typeof t==`string`)return t.length>3e3?t.slice(0,3e3)+`
|
|
1391
1391
|
...`:t;let n=JSON.stringify(t,null,2);return n.length>3e3?n.slice(0,3e3)+`
|
|
1392
|
-
...`:n}var xl=(0,P.memo)(function({part:e,mcpInfo:t,chatStatus:n,defaultOpen:r}){let{isPending:i,isInterrupted:a}=I(e,n),o=(0,P.useMemo)(()=>e.state===`input-streaming`?`Preparing ${t.displayName}`:i?gl(t):_l(t),[e.state,i,t]),s=(0,P.useMemo)(()=>e.state===`input-streaming`?``:vl(e.input),[e.input,e.state]),c=(0,P.useMemo)(()=>e.output?bl(e.output):null,[e.output]),l=(0,P.useMemo)(()=>{if(!c)return null;let e=c.trim();return e?`\`\`\`${e.startsWith(`{`)||e.startsWith(`[`)?`json`:`text`}\n${c}\n\`\`\``:null},[c]),u=!!l&&!i;return a&&!e.output?(0,F.jsxs)(`span`,{className:`text-sm text-an-tool-color-muted`,children:[t.displayName,` interrupted`]}):(0,F.jsx)(`div`,{className:`an-tool-mcp`,children:(0,F.jsx)(tt,{shimmerLabel:o,completeLabel:o,isAnimating:i,detail:s||void 0,trailingContent:void 0,expandable:u,defaultOpen:r,children:l&&(0,F.jsx)(S,{className:`text-[12px]`,codeControls:!1,content:l})})})},He);function Sl({step:e,state:t,onComplete:n,defaultOpen:r,expanded:i,onToggleExpand:a}){return he(t===`animating`,e.duration,n),(0,F.jsx)(tt,{shimmerLabel:`Thinking`,completeLabel:`Thought`,isAnimating:t===`animating`,expandable:!!e.thoughtContent,defaultOpen:r,expanded:i,onToggleExpand:a,children:(0,F.jsx)(`div`,{className:`max-h-[175px] overflow-y-auto`,children:(0,F.jsx)(`p`,{className:`text-sm whitespace-pre-wrap text-muted-foreground`,children:e.thoughtContent})})})}var Cl=(0,P.memo)(function({part:e,step:t,state:n,onComplete:r,defaultOpen:i,expanded:a,onToggleExpand:o}){let s,c,l;if(t&&n&&r)s=t,c=n,l=r;else if(e){let t=_e(e,`Thinking`);s=t.step,c=t.stepState,l=()=>{}}else return null;return(0,F.jsx)(Sl,{step:s,state:c,onComplete:l,defaultOpen:i,expanded:a,onToggleExpand:o})});function wl({toolSteps:e,stepStates:t,onStepComplete:n,results:r=[],defaultOpen:i}){let a=e.some(e=>t[e.id]===`animating`),o=e.find(e=>e.searchQuery)?.searchQuery??`searching...`,s=r.length,c=s>0;function l({step:e}){return he(t[e.id]===`animating`,e.duration,()=>n(e.id)),null}return(0,F.jsxs)(F.Fragment,{children:[e.map(e=>(0,F.jsx)(l,{step:e},e.id)),(0,F.jsx)(tt,{shimmerLabel:`Searching...`,completeLabel:`Found ${s} results`,isAnimating:a,expandable:c,defaultOpen:i,children:(0,F.jsxs)(`div`,{className:`overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,F.jsxs)(`div`,{className:`flex h-7 items-center gap-1 border-b border-an-tool-border-color px-2.5 py-0 text-xs`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`Searched for`}),` `,(0,F.jsxs)(`span`,{className:`truncate text-muted-foreground`,children:[`“`,o,`”`]})]}),(0,F.jsx)(`div`,{className:`max-h-[200px] overflow-y-auto bg-background`,children:(0,F.jsx)(`div`,{className:`flex flex-col gap-1 p-1`,children:r.map(e=>(0,F.jsxs)(`div`,{className:p(`flex cursor-default items-center gap-2 rounded-[calc(var(--an-tool-border-radius)-4px)] px-2 py-1`,`hover:bg-muted/50`),children:[(0,F.jsx)(`div`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground`,children:(0,F.jsx)(re,{className:`h-4 w-4`})}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground/90`,children:e.title}),(0,F.jsx)(`span`,{className:`shrink-0 text-xs whitespace-nowrap text-muted-foreground`,children:e.date||e.source})]},`${e.title}-${e.source}-${e.date}`))})})]})})]})}function Tl(e){if(!Array.isArray(e))return;let t=e.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.source,n=e.title,r=e.date;return typeof t!=`string`||typeof n!=`string`||typeof r!=`string`?null:{source:t,title:n,date:r}}).filter(e=>!!e);return t.length>0?t:void 0}var El=(0,P.memo)(function({part:e,results:t,defaultOpen:n}){let r=e.type?.replace(`tool-`,``)||`WebSearch`,{step:i,stepState:a}=_e(e,r),o={[i.id]:a};return(0,F.jsx)(wl,{toolSteps:[i],stepStates:o,onStepComplete:()=>{},results:t??Tl(e.output?.results)??Tl(e.result?.results),defaultOpen:n})});function Dl(e,t){if(e.state===`input-streaming`)return`streaming`;if(e.state===`output-available`)return`success`;if(e.state===`output-error`)return`error`;let{isPending:n}=I(e,t);return n?`pending`:`success`}var Ol=(0,P.memo)(function({part:e,nestedTools:t,chatStatus:n,toolRenderers:r}){let i=e.type;switch(i){case`tool-Bash`:return(0,F.jsx)(at,{part:e});case`tool-IPython`:return(0,F.jsx)(ve,{part:e});case`tool-Edit`:case`tool-Write`:return(0,F.jsx)(Zc,{part:e});case`tool-WebSearch`:case`tool-Grep`:case`tool-Glob`:return(0,F.jsx)(El,{part:e});case`tool-PlanWrite`:return(0,F.jsx)(ol,{part:e,chatStatus:n});case`tool-TodoWrite`:return(0,F.jsx)(il,{part:e,chatStatus:n});case`tool-Question`:return(0,F.jsx)(Je,{part:e,chatStatus:n});case`tool-Task`:case`tool-Agent`:{let r=e.type===`tool-Agent`?`Agent`:`Task`;return(0,F.jsx)(fl,{part:e,nestedTools:t,chatStatus:n,completeLabel:`${r} completed`,shimmerLabel:`Running ${r.toLowerCase()}`,interruptedLabel:`${r} interrupted`,defaultOpen:!1})}case`tool-Thinking`:return(0,F.jsx)(Cl,{part:e})}let a=et(i);if(a){if(r){let t=r[a.toolName];if(t)return(0,F.jsx)(t,{name:a.toolName,input:e.input??{},output:e.output?yl(e.output):void 0,status:Dl(e,n)})}return(0,F.jsx)(xl,{part:e,mcpInfo:a,chatStatus:n})}if(r&&i.startsWith(`tool-`)){let t=i.slice(5),a=r[t];if(a)return(0,F.jsx)(a,{name:t,input:e.input??{},output:e.output??e.result,status:Dl(e,n)})}let o=Ze[i];if(o){let{isPending:t,isError:r}=I(e,n);return(0,F.jsx)(nt,{title:o.title(e),subtitle:o.subtitle?.(e),isPending:t,isError:r})}let s=i.startsWith(`tool-`)?i.slice(5):i,{isPending:c,isError:l}=I(e,n);return(0,F.jsx)(nt,{title:c?`Running ${s}`:s,isPending:c,isError:l})}),kl={queued:`Waiting to generate`,generating:`Generating image`,refining:`Refining details`,complete:`Image ready`,error:`Generation failed`},Al={queued:{filter:`blur(4px) saturate(0.75)`,opacity:0,scale:1.02},generating:{filter:`blur(3px) saturate(0.85)`,opacity:0,scale:1.015},refining:{filter:`blur(1.5px) saturate(0.95)`,opacity:.62,scale:1.005},complete:{filter:`blur(0px) saturate(1)`,opacity:1,scale:1},error:{filter:`blur(2px) saturate(0.5)`,opacity:.28,scale:1}},jl={queued:1,generating:1,refining:.48,complete:0,error:0},Ml=10,Nl=Math.PI*2;function Pl({status:e,reduce:t}){return e===`complete`?(0,F.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`}):e===`error`?(0,F.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5`}):(0,F.jsxs)(i.span,{"aria-hidden":`true`,animate:t?void 0:{rotate:360},transition:{duration:2.4,ease:s,repeat:1/0},className:`grid size-3.5 grid-cols-2 place-items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current`}),(0,F.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current opacity-55`}),(0,F.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current opacity-55`}),(0,F.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current`})]})}function Fl({interactive:e,reduce:t,status:n}){let r=x(),a=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let n=a.current,i=n?.getContext(`2d`);if(!n||!i)return;let o=0,s=0,c=0,l=`currentColor`,u={x:0,y:0,targetX:0,targetY:0,inside:!1},d=e&&r&&!t,f=()=>{let e=n.getBoundingClientRect();s=e.width||n.clientWidth||208,c=e.height||n.clientHeight||208;let t=Math.min(window.devicePixelRatio||1,2);n.width=Math.round(s*t),n.height=Math.round(c*t),i.setTransform(t,0,0,t,0,0),l=window.getComputedStyle(n).color,u.x=s/2,u.y=c/2,u.targetX=u.x,u.targetY=u.y},p=e=>{i.clearRect(0,0,s,c),u.inside||(u.targetX=s/2+(t?0:Math.sin(e/1700)*s*.12),u.targetY=c/2+(t?0:Math.cos(e/2100)*c*.1));let n=t?1:u.inside?.16:.045;u.x+=(u.targetX-u.x)*n,u.y+=(u.targetY-u.y)*n;let r=Math.min(s,c)*.38,a=Math.ceil(s/Ml)+1,d=Math.ceil(c/Ml)+1,f=(s-(a-1)*Ml)/2,m=(c-(d-1)*Ml)/2;i.fillStyle=l;for(let e=0;e<d;e+=1)for(let t=0;t<a;t+=1){let n=f+t*Ml,a=m+e*Ml,o=n-u.x,s=a-u.y,c=Math.hypot(o,s),l=Math.max(0,1-c/r),d=l*l*(3-2*l),p=d*d*9,h=c>0?o/c:0,g=c>0?s/c:0,_=n+h*p,v=a+g*p,y=.65+d*.85;i.globalAlpha=.17+d*.72,i.beginPath(),i.arc(_,v,y,0,Nl),i.fill()}i.globalAlpha=1,t||(o=window.requestAnimationFrame(p))},m=e=>{if(!d)return;let t=n.getBoundingClientRect();u.inside=!0,u.targetX=e.clientX-t.left,u.targetY=e.clientY-t.top},h=()=>{u.inside=!1},g=typeof ResizeObserver>`u`?null:new ResizeObserver(f);return f(),g?.observe(n),n.addEventListener(`pointermove`,m,{passive:!0}),n.addEventListener(`pointerleave`,h),p(0),()=>{o&&window.cancelAnimationFrame(o),g?.disconnect(),n.removeEventListener(`pointermove`,m),n.removeEventListener(`pointerleave`,h)}},[r,e,t]),(0,F.jsx)(i.div,{"aria-hidden":`true`,initial:!1,animate:{opacity:jl[n]},transition:{duration:t?0:.4,ease:u},className:`absolute inset-0 overflow-hidden bg-muted`,children:(0,F.jsx)(`canvas`,{ref:a,className:`absolute inset-0 size-full text-foreground`})})}function Il({children:e,status:t=`generating`,label:n,prompt:r,resolution:s=`1024 × 1024`,aspectRatio:c=`1 / 1`,size:d=`compact`,interactive:f=!0,statusText:m,showStatus:h=!0,onRetry:g,className:_,mediaClassName:v,statusClassName:y}){let b=l()??!1,x=t===`queued`||t===`generating`||t===`refining`,S=Al[t],C=m??kl[t],w=n??(r?`${C}: ${r}`:C);return(0,F.jsx)(`div`,{"data-slot":`image-generation`,"data-state":t,"aria-busy":x,className:p(`w-full`,_),children:(0,F.jsxs)(`div`,{className:p(`w-full`,d===`compact`&&`mx-auto max-w-52`),children:[(0,F.jsxs)(`div`,{role:`img`,"aria-label":w,style:{aspectRatio:c},className:`relative isolate w-full overflow-hidden rounded-xl bg-muted`,children:[(0,F.jsx)(i.div,{"aria-hidden":!e||void 0,initial:!1,animate:b?{opacity:S.opacity}:{filter:S.filter,opacity:S.opacity,scale:S.scale},transition:b?{duration:0}:{duration:.4,ease:u},className:p(`absolute inset-0 [&>*]:size-full [&>*]:object-cover [&_img]:size-full [&_img]:object-cover`,v),children:e}),(0,F.jsx)(o,{initial:!1,children:x?(0,F.jsx)(i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:b?0:.25,ease:u},className:`absolute inset-0`,children:(0,F.jsx)(Fl,{interactive:f,reduce:b,status:t})},`dither-field`):null}),s?(0,F.jsx)(`span`,{className:`absolute top-2 right-2 z-10 rounded-full bg-background/75 px-2 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:s}):null]}),(0,F.jsx)(o,{initial:!1,children:h||r?(0,F.jsxs)(i.div,{initial:!1,className:`mt-3 text-left`,children:[(0,F.jsxs)(`div`,{"aria-live":`polite`,className:p(h?`flex min-h-5 items-center gap-2`:`contents`,`text-sm font-medium text-foreground`,t===`error`&&`text-destructive`,y),children:[h?(0,F.jsx)(Pl,{status:t,reduce:b}):null,(0,F.jsx)(o,{mode:`popLayout`,initial:!1,children:h?(0,F.jsx)(i.span,{initial:!b&&{opacity:0,y:4},animate:{opacity:1,y:0},exit:b?void 0:{opacity:0,y:-4},transition:{duration:b?0:.15,ease:u},children:C},C):null})]}),r?(0,F.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[`“`,r,`”`]}):null]},`status-block`):null}),t===`error`&&g?(0,F.jsxs)(i.button,{type:`button`,onClick:g,whileTap:b?void 0:{scale:.96},transition:a,className:`mt-3 inline-flex min-h-10 items-center gap-2 rounded-full px-3 text-sm font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,F.jsx)(we,{"aria-hidden":`true`,className:`size-4`}),`Try again`]}):null]})})}function Ll(e){return e===`in-progress`?`In progress`:e===`completed`?`Completed`:e===`cancelled`?`Cancelled`:`Pending`}function Rl({complete:e}){let t=l()??!1;return(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`relative grid size-6 shrink-0 place-items-center`,children:(0,F.jsx)(o,{initial:!1,mode:`popLayout`,children:e?(0,F.jsxs)(i.svg,{viewBox:`0 0 24 24`,initial:t?{opacity:1}:{opacity:0,scale:.72},animate:{opacity:1,scale:1},exit:{opacity:0},transition:t?{duration:0}:d,className:`absolute size-5.5 overflow-visible text-emerald-500`,children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,fill:`currentColor`}),(0,F.jsx)(i.path,{d:`M7.5 12.25 10.5 15.25 16.75 8.75`,fill:`none`,stroke:`white`,strokeWidth:`2.25`,strokeLinecap:`round`,strokeLinejoin:`round`,initial:t?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:t?{duration:0}:{duration:.24,ease:u}})]},`complete`):(0,F.jsx)(i.span,{initial:t?{opacity:1}:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:t?{opacity:0}:{opacity:0,scale:.72},transition:t?{duration:0}:d,className:`absolute grid place-items-center text-muted-foreground`,children:(0,F.jsx)(b,{className:`size-4`})},`todo`)})})}function zl({status:e,progress:t}){let n=l()??!1,r=t===void 0?.68:Math.min(100,Math.max(0,t))/100;return(0,F.jsxs)(i.svg,{"aria-hidden":`true`,viewBox:`0 0 24 24`,initial:!1,className:p(`mx-0.5 size-5 shrink-0 overflow-visible text-muted-foreground`,e===`in-progress`&&`text-foreground`,e===`cancelled`&&`text-rose-600 dark:text-rose-400`),children:[(0,F.jsx)(i.circle,{cx:`12`,cy:`12`,r:`9`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:e===`pending`?`2 3`:void 0,strokeLinecap:`round`,initial:!1,animate:{fillOpacity:e===`completed`?.06:0},transition:n?{duration:0}:{duration:.18,ease:u},className:p(e===`in-progress`&&`opacity-20`)}),(0,F.jsx)(i.circle,{cx:`12`,cy:`12`,r:`9`,pathLength:`1`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,initial:!1,animate:{pathLength:e===`in-progress`?r:0,opacity:+(e===`in-progress`),rotate:e===`in-progress`&&t===void 0&&!n?360:-90},transition:e===`in-progress`&&t===void 0&&!n?{rotate:{duration:1.1,repeat:1/0,ease:`linear`}}:n?{duration:0}:c,style:{transformOrigin:`12px 12px`}}),(0,F.jsx)(i.path,{d:`M7.5 12.25 10.5 15.25 16.75 8.75`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,initial:!1,animate:{pathLength:+(e===`completed`),opacity:+(e===`completed`)},transition:n?{duration:0}:{duration:.24,ease:u}}),(0,F.jsx)(i.path,{d:`M8.5 8.5 15.5 15.5M15.5 8.5 8.5 15.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,initial:!1,animate:{pathLength:+(e===`cancelled`),opacity:+(e===`cancelled`)},transition:n?{duration:0}:{duration:.2,ease:u}})]})}function Bl({items:e,title:t=`To-dos`,open:n,defaultOpen:r=!0,onOpenChange:a,collapseOnComplete:s=!0,maxHeight:f=248,className:m}){let h=l()??!1,g=(0,P.useId)(),_=`${g}-trigger`,v=`${g}-content`,y=(0,P.useRef)(null),b=(0,P.useRef)(!1),[x,S]=(0,P.useState)(r),C=n??x,w=e.filter(e=>e.status===`completed`).length,T=e.length>0&&w===e.length,E=e.length,D=(0,P.useCallback)(e=>{n===void 0&&S(e),a?.(e)},[a,n]);return(0,P.useEffect)(()=>{b.current&&!T&&D(!0),!b.current&&T&&s&&D(!1),b.current=T},[T,s,D]),(0,P.useLayoutEffect)(()=>{let e=y.current;if(!e||E===0)return;let t=requestAnimationFrame(()=>{e.scrollHeight<=e.clientHeight||(typeof e.scrollTo==`function`?e.scrollTo({top:e.scrollHeight,behavior:h?`auto`:`smooth`}):e.scrollTop=e.scrollHeight)});return()=>cancelAnimationFrame(t)},[E,h]),(0,F.jsxs)(`section`,{"aria-label":`Agent task list`,className:p(`w-full overflow-hidden rounded-2xl border border-border/70`,m),children:[(0,F.jsxs)(`button`,{id:_,type:`button`,"aria-expanded":C,"aria-controls":v,onClick:()=>D(!C),className:`group flex h-11 w-full items-center gap-2.5 rounded-2xl px-3.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,F.jsx)(Rl,{complete:T}),(0,F.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground/90`,children:t}),(0,F.jsxs)(`span`,{className:p(`shrink-0 text-xs font-medium tabular-nums text-muted-foreground`,T&&`text-emerald-600 dark:text-emerald-400`),children:[(0,F.jsxs)(`span`,{className:`sr-only`,children:[w,` of `,e.length,` tasks completed`]}),(0,F.jsxs)(`span`,{"aria-hidden":`true`,className:`inline-flex`,children:[(0,F.jsx)(pe,{value:String(w),children:w}),(0,F.jsx)(`span`,{children:`/`}),(0,F.jsx)(`span`,{children:e.length})]})]}),(0,F.jsx)(i.span,{"aria-hidden":`true`,animate:{rotate:C?180:0},transition:h?{duration:0}:d,className:`text-muted-foreground/50 transition-colors group-hover:text-muted-foreground`,children:(0,F.jsx)(j,{className:`size-3.5`})})]}),(0,F.jsx)(le,{id:v,role:`region`,"aria-labelledby":_,open:C,children:(0,F.jsxs)(`div`,{ref:y,className:`scrollbar-hide overflow-y-auto px-2 pb-2`,style:{maxHeight:f},children:[(0,F.jsx)(`ol`,{"aria-live":`polite`,className:`space-y-0`,children:(0,F.jsx)(o,{initial:!1,mode:`popLayout`,children:e.map(e=>{let t=e.status??`pending`;return(0,F.jsxs)(i.li,{layout:`position`,initial:h?{opacity:1}:{opacity:0,y:6},animate:{opacity:1,y:0},exit:h?{opacity:0}:{opacity:0,y:-3},transition:h?{duration:0}:{opacity:{duration:.18,ease:u},y:c,layout:c},className:`flex min-h-9 items-center gap-2.5 rounded-xl px-1.5 py-1`,children:[(0,F.jsx)(zl,{status:t,progress:e.progress}),(0,F.jsxs)(`span`,{className:`sr-only`,children:[Ll(t),`: `]}),(0,F.jsx)(`span`,{className:p(`min-w-0 flex-1 truncate text-sm leading-5`,t===`pending`&&`text-muted-foreground/65`,t===`in-progress`&&`text-foreground`,t===`completed`&&`text-muted-foreground/60`,t===`cancelled`&&`text-muted-foreground/55`),children:(0,F.jsxs)(`span`,{className:`relative inline-block max-w-full`,children:[e.title,(0,F.jsx)(i.span,{"aria-hidden":`true`,initial:!1,animate:{scaleX:+(t===`completed`),opacity:+(t===`completed`)},transition:h?{duration:0}:{duration:.28,ease:u,delay:.06},className:`absolute inset-x-0 top-1/2 h-px origin-left bg-current`})]})}),e.detail?(0,F.jsx)(`span`,{className:`shrink-0 text-sm text-muted-foreground/55`,children:e.detail}):null]},e.id)})})}),!e.length&&(0,F.jsx)(`p`,{className:`px-1.5 py-2 text-sm text-muted-foreground`,children:`No tasks yet`})]})})]})}function Vl({steps:e,activeIndex:t,className:n,...r}){let i=e.length,a=T(t,i),o=a>=i,s=D(a,i);return(0,F.jsxs)(`div`,{"data-slot":`agent-plan`,className:p(`flex w-full max-w-sm flex-col gap-3`,n),...r,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-[13.5px] font-medium`,children:`Plan`}),(0,F.jsxs)(`span`,{className:p(C,`text-foreground/35 tabular-nums`),children:[a,` of `,i]})]}),(0,F.jsx)(`div`,{className:`bg-foreground/[0.06] h-[3px] w-full overflow-hidden rounded-full`,children:(0,F.jsx)(`span`,{className:`bg-foreground/80 block h-full rounded-full transition-[width] duration-500`,style:{width:`${s}%`}})}),(0,F.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:e.map((e,t)=>{let n=o||t<a,r=!o&&t===a;return(0,F.jsxs)(`li`,{className:`flex items-center gap-2.5 text-[13.5px]`,children:[(0,F.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:n?(0,F.jsx)(A,{className:`text-foreground/35 size-3.5`}):r?(0,F.jsx)(ae,{className:`text-foreground/90 size-3.5 animate-spin motion-reduce:animate-none`}):(0,F.jsx)(`span`,{"aria-hidden":!0,className:`bg-foreground/15 size-1.5 rounded-full`})}),(0,F.jsx)(`span`,{className:p(n&&`text-foreground/40`,r&&`text-foreground/90`,!n&&!r&&`text-foreground/35`),children:e})]},e)})})]})}function Hl(e){if(e.length===0)return;let t=e.flatMap(e=>{let t=e.title.trim();return t?[t]:[]});if(t.length!==e.length)return;let n=0;for(;n<e.length&&e[n]?.status===`completed`;)n+=1;if(!e.slice(n+1).some(e=>e.status===`completed`))return{steps:t,activeIndex:n}}function Ul({presentation:e,className:t}){return(0,F.jsx)(Vl,{steps:e.steps,activeIndex:e.activeIndex,"aria-label":`Plan progress: ${Math.min(e.activeIndex,e.steps.length)} of ${e.steps.length} steps completed`,className:t})}function Wl(e){return e===`approving`?`Approving`:e===`approved`?`Approved`:e===`denied`?`Denied`:e===`running`?`Running`:e===`complete`?`Completed`:e===`error`?`Failed`:`Approval required`}function Gl(e){return e===`pending`?`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`:e===`approving`||e===`running`?`border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400`:e===`approved`||e===`complete`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`border-rose-500/30 bg-rose-500/10 text-rose-600 dark:text-rose-400`}function Kl({tool:e,title:t=`Allow this tool to run?`,description:n,parameters:r=[],status:s=`pending`,open:c,defaultOpen:m=!1,onOpenChange:h,onApprove:g,onAlwaysAllow:_,onDeny:v,className:y}){let b=l()??!1,x=`${(0,P.useId)()}-details`,S=(0,P.useRef)(s),[C,w]=(0,P.useState)(m),T=c??C,E=(0,P.useCallback)(e=>{c===void 0&&w(e),h?.(e)},[h,c]),D=s===`approving`||s===`running`,O=s===`pending`,k=s===`error`;return(0,P.useEffect)(()=>{S.current===`pending`&&s!==`pending`&&E(!1),S.current=s},[E,s]),(0,F.jsxs)(`div`,{"data-state":s,"aria-busy":D,className:p(`w-full overflow-hidden rounded-2xl border border-border/60 bg-muted/20 text-sm`,y),children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3 p-4`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,className:p(`mt-0.5 grid size-8 shrink-0 place-items-center rounded-xl border border-border/60 bg-background text-muted-foreground`,k&&`text-destructive`),children:D?(0,F.jsx)(ae,{className:p(`size-4`,!b&&`animate-spin`)}):k?(0,F.jsx)(ne,{className:`size-4`}):s===`denied`?(0,F.jsx)(f,{className:`size-4`}):s===`approved`||s===`complete`?(0,F.jsx)(A,{className:`size-4`}):(0,F.jsx)(be,{className:`size-4`})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`font-medium text-foreground`,children:t}),(0,F.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:e})]}),(0,F.jsx)(`span`,{className:p(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors`,Gl(s)),children:Wl(s)})]}),n?(0,F.jsx)(`p`,{className:`mt-2 leading-5 text-muted-foreground`,children:n}):null,r.length?(0,F.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":x,onClick:()=>E(!T),className:`mt-2 inline-flex items-center gap-1 rounded-md text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[`View details`,(0,F.jsx)(i.span,{"aria-hidden":`true`,animate:{rotate:T?180:0},transition:b?{duration:0}:d,children:(0,F.jsx)(j,{className:`size-3.5`})})]}):null]})]}),(0,F.jsx)(le,{id:x,open:T,children:(0,F.jsx)(`dl`,{className:`mx-4 mb-4 grid gap-2 rounded-xl border border-border/50 bg-background/70 p-3`,children:r.map(e=>(0,F.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)] items-center gap-3 text-xs`,children:[(0,F.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,F.jsx)(`dd`,{className:`min-w-0 break-words font-mono text-foreground/85`,children:e.value})]},e.id))})}),(0,F.jsx)(o,{initial:!1,children:O?(0,F.jsxs)(i.div,{initial:b?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:b?.12:.22,ease:u},className:`flex flex-wrap items-center gap-2 border-t border-border/60 px-4 py-3`,children:[(0,F.jsx)(i.button,{type:`button`,onClick:g,whileTap:b?void 0:{scale:.97},transition:a,className:`rounded-xl bg-foreground px-3 py-1.5 text-xs font-medium text-background outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:`Allow once`}),_?(0,F.jsx)(i.button,{type:`button`,onClick:_,whileTap:b?void 0:{scale:.97},transition:a,className:`rounded-xl border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:`Always allow`}):null,(0,F.jsx)(`button`,{type:`button`,onClick:v,className:`rounded-xl px-3 py-1.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:`Deny`})]}):null})]})}function ql(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Jl(e){let t=ql(e);if(t)return t;if(typeof e==`string`)try{return ql(JSON.parse(e))}catch{return}}function $(e,...t){for(let n of t){let t=e?.[n];if(typeof t==`string`&&t.trim())return t}}function Yl(e,...t){for(let n of t){let t=e?.[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e))return e}}}function Xl(e,...t){for(let n of t){let t=e?.[n];if(typeof t==`boolean`)return t}}function Zl(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ql(e){return e.output!==void 0&&e.output!==null?e.output:e.result}function $l(e){let t=Jl(e),n=Jl(t?.details),r={...t??{},...n??{}},i=r.result,a=$(r,`stdout`,`standardOutput`,`standard_output`),o=$(r,`stderr`,`standardError`,`standard_error`),s=r.error??r.errorMessage??r.evalue,c=s===void 0?void 0:Zl(s),l=Yl(r,`durationMs`,`duration_ms`,`duration`),u=Xl(r,`kernelRestarted`,`kernel_restarted`),d=new Set([`stdout`,`stderr`,`standardOutput`,`standard_output`,`standardError`,`standard_error`,`error`,`errorMessage`,`evalue`,`durationMs`,`duration_ms`,`duration`,`kernelRestarted`,`kernel_restarted`,`status`,`isError`]),f=Object.keys(r).some(e=>!d.has(e));return{record:t,details:n,stdout:a,stderr:o,result:i,error:c,durationMs:l,kernelRestarted:u,structured:!a&&!o&&!c&&(typeof i==`object`&&!!i||f)}}function eu(e,t){let n=[];if(e.stdout&&n.push({label:`stdout`,content:e.stdout,language:`text`}),e.stderr&&n.push({label:`stderr`,content:e.stderr,language:`text`}),e.result!==void 0&&n.push({label:`result`,content:Zl(e.result),language:typeof e.result==`object`&&e.result!==null?`json`:`text`}),e.error&&n.push({label:`error`,content:e.error,language:`text`}),n.length>0)return n;let r=e.details??e.record;if(r){let e={...r};if(delete e.details,delete e.isError,Object.keys(e).length>0)return[{label:`result`,content:Zl(e),language:`json`}]}let i=Zl(t);return i.trim()?[{label:`output`,content:i,language:`text`}]:[]}function tu(e,t){return eu(e,t).map(e=>`${e.label}\n${e.content}`).join(`
|
|
1392
|
+
...`:n}var Sl=(0,F.memo)(function({part:e,mcpInfo:t,chatStatus:n,defaultOpen:r}){let{isPending:i,isInterrupted:a}=Ue(e,n),o=(0,F.useMemo)(()=>e.state===`input-streaming`?`Preparing ${t.displayName}`:i?_l(t):vl(t),[e.state,i,t]),s=(0,F.useMemo)(()=>e.state===`input-streaming`?``:yl(e.input),[e.input,e.state]),c=(0,F.useMemo)(()=>e.output?xl(e.output):null,[e.output]),l=(0,F.useMemo)(()=>{if(!c)return null;let e=c.trim();return e?`\`\`\`${e.startsWith(`{`)||e.startsWith(`[`)?`json`:`text`}\n${c}\n\`\`\``:null},[c]),u=!!l&&!i;return a&&!e.output?(0,I.jsxs)(`span`,{className:`text-sm text-an-tool-color-muted`,children:[t.displayName,` interrupted`]}):(0,I.jsx)(`div`,{className:`an-tool-mcp`,children:(0,I.jsx)(nt,{shimmerLabel:o,completeLabel:o,isAnimating:i,detail:s||void 0,trailingContent:void 0,expandable:u,defaultOpen:r,children:l&&(0,I.jsx)(v,{className:`text-[12px]`,codeControls:!1,content:l})})})},Ve);function Cl({step:e,state:t,onComplete:n,defaultOpen:r,expanded:i,onToggleExpand:a}){return ee(t===`animating`,e.duration,n),(0,I.jsx)(nt,{shimmerLabel:`Thinking`,completeLabel:`Thought`,isAnimating:t===`animating`,expandable:!!e.thoughtContent,defaultOpen:r,expanded:i,onToggleExpand:a,children:(0,I.jsx)(`div`,{className:`max-h-[175px] overflow-y-auto`,children:(0,I.jsx)(`p`,{className:`text-sm whitespace-pre-wrap text-muted-foreground`,children:e.thoughtContent})})})}var wl=(0,F.memo)(function({part:e,step:t,state:n,onComplete:r,defaultOpen:i,expanded:a,onToggleExpand:o}){let s,c,l;if(t&&n&&r)s=t,c=n,l=r;else if(e){let t=ne(e,`Thinking`);s=t.step,c=t.stepState,l=()=>{}}else return null;return(0,I.jsx)(Cl,{step:s,state:c,onComplete:l,defaultOpen:i,expanded:a,onToggleExpand:o})});function Tl({toolSteps:e,stepStates:t,onStepComplete:n,results:r=[],defaultOpen:i}){let a=e.some(e=>t[e.id]===`animating`),o=e.find(e=>e.searchQuery)?.searchQuery??`searching...`,s=r.length,c=s>0;function l({step:e}){return ee(t[e.id]===`animating`,e.duration,()=>n(e.id)),null}return(0,I.jsxs)(I.Fragment,{children:[e.map(e=>(0,I.jsx)(l,{step:e},e.id)),(0,I.jsx)(nt,{shimmerLabel:`Searching...`,completeLabel:`Found ${s} results`,isAnimating:a,expandable:c,defaultOpen:i,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-an-tool-border-radius border border-border bg-an-tool-background`,children:[(0,I.jsxs)(`div`,{className:`flex h-7 items-center gap-1 border-b border-an-tool-border-color px-2.5 py-0 text-xs`,children:[(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:`Searched for`}),` `,(0,I.jsxs)(`span`,{className:`truncate text-muted-foreground`,children:[`“`,o,`”`]})]}),(0,I.jsx)(`div`,{className:`max-h-[200px] overflow-y-auto bg-background`,children:(0,I.jsx)(`div`,{className:`flex flex-col gap-1 p-1`,children:r.map(e=>(0,I.jsxs)(`div`,{className:f(`flex cursor-default items-center gap-2 rounded-[calc(var(--an-tool-border-radius)-4px)] px-2 py-1`,`hover:bg-muted/50`),children:[(0,I.jsx)(`div`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground`,children:(0,I.jsx)(ue,{className:`h-4 w-4`})}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground/90`,children:e.title}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs whitespace-nowrap text-muted-foreground`,children:e.date||e.source})]},`${e.title}-${e.source}-${e.date}`))})})]})})]})}function El(e){if(!Array.isArray(e))return;let t=e.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.source,n=e.title,r=e.date;return typeof t!=`string`||typeof n!=`string`||typeof r!=`string`?null:{source:t,title:n,date:r}}).filter(e=>!!e);return t.length>0?t:void 0}var Dl=(0,F.memo)(function({part:e,results:t,defaultOpen:n}){let r=e.type?.replace(`tool-`,``)||`WebSearch`,{step:i,stepState:a}=ne(e,r),o={[i.id]:a};return(0,I.jsx)(Tl,{toolSteps:[i],stepStates:o,onStepComplete:()=>{},results:t??El(e.output?.results)??El(e.result?.results),defaultOpen:n})});function Ol(e,t){if(e.state===`input-streaming`)return`streaming`;if(e.state===`output-available`)return`success`;if(e.state===`output-error`)return`error`;let{isPending:n}=Ue(e,t);return n?`pending`:`success`}var kl=(0,F.memo)(function({part:e,nestedTools:t,chatStatus:n,toolRenderers:r}){let i=e.type;switch(i){case`tool-Bash`:return(0,I.jsx)(ot,{part:e});case`tool-IPython`:return(0,I.jsx)(re,{part:e});case`tool-Edit`:case`tool-Write`:return(0,I.jsx)(Qc,{part:e});case`tool-WebSearch`:case`tool-Grep`:case`tool-Glob`:return(0,I.jsx)(Dl,{part:e});case`tool-PlanWrite`:return(0,I.jsx)(sl,{part:e,chatStatus:n});case`tool-TodoWrite`:return(0,I.jsx)(al,{part:e,chatStatus:n});case`tool-Question`:return(0,I.jsx)(Ye,{part:e,chatStatus:n});case`tool-Task`:case`tool-Agent`:{let r=e.type===`tool-Agent`?`Agent`:`Task`;return(0,I.jsx)(pl,{part:e,nestedTools:t,chatStatus:n,completeLabel:`${r} completed`,shimmerLabel:`Running ${r.toLowerCase()}`,interruptedLabel:`${r} interrupted`,defaultOpen:!1})}case`tool-Thinking`:return(0,I.jsx)(wl,{part:e})}let a=tt(i);if(a){if(r){let t=r[a.toolName];if(t)return(0,I.jsx)(t,{name:a.toolName,input:e.input??{},output:e.output?bl(e.output):void 0,status:Ol(e,n)})}return(0,I.jsx)(Sl,{part:e,mcpInfo:a,chatStatus:n})}if(r&&i.startsWith(`tool-`)){let t=i.slice(5),a=r[t];if(a)return(0,I.jsx)(a,{name:t,input:e.input??{},output:e.output??e.result,status:Ol(e,n)})}let o=Qe[i];if(o){let{isPending:t,isError:r}=Ue(e,n);return(0,I.jsx)(rt,{title:o.title(e),subtitle:o.subtitle?.(e),isPending:t,isError:r})}let s=i.startsWith(`tool-`)?i.slice(5):i,{isPending:c,isError:l}=Ue(e,n);return(0,I.jsx)(rt,{title:c?`Running ${s}`:s,isPending:c,isError:l})}),Al={queued:`Waiting to generate`,generating:`Generating image`,refining:`Refining details`,complete:`Image ready`,error:`Generation failed`},jl={queued:{filter:`blur(4px) saturate(0.75)`,opacity:0,scale:1.02},generating:{filter:`blur(3px) saturate(0.85)`,opacity:0,scale:1.015},refining:{filter:`blur(1.5px) saturate(0.95)`,opacity:.62,scale:1.005},complete:{filter:`blur(0px) saturate(1)`,opacity:1,scale:1},error:{filter:`blur(2px) saturate(0.5)`,opacity:.28,scale:1}},Ml={queued:1,generating:1,refining:.48,complete:0,error:0},Nl=10,Pl=Math.PI*2;function Fl({status:e,reduce:t}){return e===`complete`?(0,I.jsx)(T,{"aria-hidden":`true`,className:`size-3.5`}):e===`error`?(0,I.jsx)(k,{"aria-hidden":`true`,className:`size-3.5`}):(0,I.jsxs)(i.span,{"aria-hidden":`true`,animate:t?void 0:{rotate:360},transition:{duration:2.4,ease:o,repeat:1/0},className:`grid size-3.5 grid-cols-2 place-items-center gap-0.5`,children:[(0,I.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current`}),(0,I.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current opacity-55`}),(0,I.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current opacity-55`}),(0,I.jsx)(`span`,{className:`size-1 rounded-[1px] bg-current`})]})}function Il({interactive:e,reduce:t,status:n}){let r=S(),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>{let n=a.current,i=n?.getContext(`2d`);if(!n||!i)return;let o=0,s=0,c=0,l=`currentColor`,u={x:0,y:0,targetX:0,targetY:0,inside:!1},d=e&&r&&!t,f=()=>{let e=n.getBoundingClientRect();s=e.width||n.clientWidth||208,c=e.height||n.clientHeight||208;let t=Math.min(window.devicePixelRatio||1,2);n.width=Math.round(s*t),n.height=Math.round(c*t),i.setTransform(t,0,0,t,0,0),l=window.getComputedStyle(n).color,u.x=s/2,u.y=c/2,u.targetX=u.x,u.targetY=u.y},p=e=>{i.clearRect(0,0,s,c),u.inside||(u.targetX=s/2+(t?0:Math.sin(e/1700)*s*.12),u.targetY=c/2+(t?0:Math.cos(e/2100)*c*.1));let n=t?1:u.inside?.16:.045;u.x+=(u.targetX-u.x)*n,u.y+=(u.targetY-u.y)*n;let r=Math.min(s,c)*.38,a=Math.ceil(s/Nl)+1,d=Math.ceil(c/Nl)+1,f=(s-(a-1)*Nl)/2,m=(c-(d-1)*Nl)/2;i.fillStyle=l;for(let e=0;e<d;e+=1)for(let t=0;t<a;t+=1){let n=f+t*Nl,a=m+e*Nl,o=n-u.x,s=a-u.y,c=Math.hypot(o,s),l=Math.max(0,1-c/r),d=l*l*(3-2*l),p=d*d*9,h=c>0?o/c:0,g=c>0?s/c:0,_=n+h*p,v=a+g*p,y=.65+d*.85;i.globalAlpha=.17+d*.72,i.beginPath(),i.arc(_,v,y,0,Pl),i.fill()}i.globalAlpha=1,t||(o=window.requestAnimationFrame(p))},m=e=>{if(!d)return;let t=n.getBoundingClientRect();u.inside=!0,u.targetX=e.clientX-t.left,u.targetY=e.clientY-t.top},h=()=>{u.inside=!1},g=typeof ResizeObserver>`u`?null:new ResizeObserver(f);return f(),g?.observe(n),n.addEventListener(`pointermove`,m,{passive:!0}),n.addEventListener(`pointerleave`,h),p(0),()=>{o&&window.cancelAnimationFrame(o),g?.disconnect(),n.removeEventListener(`pointermove`,m),n.removeEventListener(`pointerleave`,h)}},[r,e,t]),(0,I.jsx)(i.div,{"aria-hidden":`true`,initial:!1,animate:{opacity:Ml[n]},transition:{duration:t?0:.4,ease:c},className:`absolute inset-0 overflow-hidden bg-muted`,children:(0,I.jsx)(`canvas`,{ref:a,className:`absolute inset-0 size-full text-foreground`})})}function Ll({children:e,status:t=`generating`,label:n,prompt:r,resolution:o=`1024 × 1024`,aspectRatio:s=`1 / 1`,size:l=`compact`,interactive:p=!0,statusText:m,showStatus:h=!0,onRetry:g,className:_,mediaClassName:v,statusClassName:y}){let b=d()??!1,x=t===`queued`||t===`generating`||t===`refining`,S=jl[t],C=m??Al[t],w=n??(r?`${C}: ${r}`:C);return(0,I.jsx)(`div`,{"data-slot":`image-generation`,"data-state":t,"aria-busy":x,className:f(`w-full`,_),children:(0,I.jsxs)(`div`,{className:f(`w-full`,l===`compact`&&`mx-auto max-w-52`),children:[(0,I.jsxs)(`div`,{role:`img`,"aria-label":w,style:{aspectRatio:s},className:`relative isolate w-full overflow-hidden rounded-xl bg-muted`,children:[(0,I.jsx)(i.div,{"aria-hidden":!e||void 0,initial:!1,animate:b?{opacity:S.opacity}:{filter:S.filter,opacity:S.opacity,scale:S.scale},transition:b?{duration:0}:{duration:.4,ease:c},className:f(`absolute inset-0 [&>*]:size-full [&>*]:object-cover [&_img]:size-full [&_img]:object-cover`,v),children:e}),(0,I.jsx)(u,{initial:!1,children:x?(0,I.jsx)(i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:b?0:.25,ease:c},className:`absolute inset-0`,children:(0,I.jsx)(Il,{interactive:p,reduce:b,status:t})},`dither-field`):null}),o?(0,I.jsx)(`span`,{className:`absolute top-2 right-2 z-10 rounded-full bg-background/75 px-2 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:o}):null]}),(0,I.jsx)(u,{initial:!1,children:h||r?(0,I.jsxs)(i.div,{initial:!1,className:`mt-3 text-left`,children:[(0,I.jsxs)(`div`,{"aria-live":`polite`,className:f(h?`flex min-h-5 items-center gap-2`:`contents`,`text-sm font-medium text-foreground`,t===`error`&&`text-destructive`,y),children:[h?(0,I.jsx)(Fl,{status:t,reduce:b}):null,(0,I.jsx)(u,{mode:`popLayout`,initial:!1,children:h?(0,I.jsx)(i.span,{initial:!b&&{opacity:0,y:4},animate:{opacity:1,y:0},exit:b?void 0:{opacity:0,y:-4},transition:{duration:b?0:.15,ease:c},children:C},C):null})]}),r?(0,I.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[`“`,r,`”`]}):null]},`status-block`):null}),t===`error`&&g?(0,I.jsxs)(i.button,{type:`button`,onClick:g,whileTap:b?void 0:{scale:.96},transition:a,className:`mt-3 inline-flex min-h-10 items-center gap-2 rounded-full px-3 text-sm font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,I.jsx)(de,{"aria-hidden":`true`,className:`size-4`}),`Try again`]}):null]})})}function Rl(e){return e===`in-progress`?`In progress`:e===`completed`?`Completed`:e===`cancelled`?`Cancelled`:`Pending`}function zl({complete:e}){let t=d()??!1;return(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`relative grid size-6 shrink-0 place-items-center`,children:(0,I.jsx)(u,{initial:!1,mode:`popLayout`,children:e?(0,I.jsxs)(i.svg,{viewBox:`0 0 24 24`,initial:t?{opacity:1}:{opacity:0,scale:.72},animate:{opacity:1,scale:1},exit:{opacity:0},transition:t?{duration:0}:l,className:`absolute size-5.5 overflow-visible text-emerald-500`,children:[(0,I.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,fill:`currentColor`}),(0,I.jsx)(i.path,{d:`M7.5 12.25 10.5 15.25 16.75 8.75`,fill:`none`,stroke:`white`,strokeWidth:`2.25`,strokeLinecap:`round`,strokeLinejoin:`round`,initial:t?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:t?{duration:0}:{duration:.24,ease:c}})]},`complete`):(0,I.jsx)(i.span,{initial:t?{opacity:1}:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:t?{opacity:0}:{opacity:0,scale:.72},transition:t?{duration:0}:l,className:`absolute grid place-items-center text-muted-foreground`,children:(0,I.jsx)(x,{className:`size-4`})},`todo`)})})}function Bl({status:e,progress:t}){let n=d()??!1,r=t===void 0?.68:Math.min(100,Math.max(0,t))/100;return(0,I.jsxs)(i.svg,{"aria-hidden":`true`,viewBox:`0 0 24 24`,initial:!1,className:f(`mx-0.5 size-5 shrink-0 overflow-visible text-muted-foreground`,e===`in-progress`&&`text-foreground`,e===`cancelled`&&`text-rose-600 dark:text-rose-400`),children:[(0,I.jsx)(i.circle,{cx:`12`,cy:`12`,r:`9`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:e===`pending`?`2 3`:void 0,strokeLinecap:`round`,initial:!1,animate:{fillOpacity:e===`completed`?.06:0},transition:n?{duration:0}:{duration:.18,ease:c},className:f(e===`in-progress`&&`opacity-20`)}),(0,I.jsx)(i.circle,{cx:`12`,cy:`12`,r:`9`,pathLength:`1`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,initial:!1,animate:{pathLength:e===`in-progress`?r:0,opacity:+(e===`in-progress`),rotate:e===`in-progress`&&t===void 0&&!n?360:-90},transition:e===`in-progress`&&t===void 0&&!n?{rotate:{duration:1.1,repeat:1/0,ease:`linear`}}:n?{duration:0}:s,style:{transformOrigin:`12px 12px`}}),(0,I.jsx)(i.path,{d:`M7.5 12.25 10.5 15.25 16.75 8.75`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,initial:!1,animate:{pathLength:+(e===`completed`),opacity:+(e===`completed`)},transition:n?{duration:0}:{duration:.24,ease:c}}),(0,I.jsx)(i.path,{d:`M8.5 8.5 15.5 15.5M15.5 8.5 8.5 15.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,initial:!1,animate:{pathLength:+(e===`cancelled`),opacity:+(e===`cancelled`)},transition:n?{duration:0}:{duration:.2,ease:c}})]})}function Vl({items:e,title:t=`To-dos`,open:n,defaultOpen:r=!0,onOpenChange:a,collapseOnComplete:o=!0,maxHeight:p=248,className:m}){let h=d()??!1,g=(0,F.useId)(),_=`${g}-trigger`,v=`${g}-content`,y=(0,F.useRef)(null),b=(0,F.useRef)(!1),[x,S]=(0,F.useState)(r),C=n??x,w=e.filter(e=>e.status===`completed`).length,T=e.length>0&&w===e.length,D=e.length,O=(0,F.useCallback)(e=>{n===void 0&&S(e),a?.(e)},[a,n]);return(0,F.useEffect)(()=>{b.current&&!T&&O(!0),!b.current&&T&&o&&O(!1),b.current=T},[T,o,O]),(0,F.useLayoutEffect)(()=>{let e=y.current;if(!e||D===0)return;let t=requestAnimationFrame(()=>{e.scrollHeight<=e.clientHeight||(typeof e.scrollTo==`function`?e.scrollTo({top:e.scrollHeight,behavior:h?`auto`:`smooth`}):e.scrollTop=e.scrollHeight)});return()=>cancelAnimationFrame(t)},[D,h]),(0,I.jsxs)(`section`,{"aria-label":`Agent task list`,className:f(`w-full overflow-hidden rounded-2xl border border-border/70`,m),children:[(0,I.jsxs)(`button`,{id:_,type:`button`,"aria-expanded":C,"aria-controls":v,onClick:()=>O(!C),className:`group flex h-11 w-full items-center gap-2.5 rounded-2xl px-3.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,I.jsx)(zl,{complete:T}),(0,I.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground/90`,children:t}),(0,I.jsxs)(`span`,{className:f(`shrink-0 text-xs font-medium tabular-nums text-muted-foreground`,T&&`text-emerald-600 dark:text-emerald-400`),children:[(0,I.jsxs)(`span`,{className:`sr-only`,children:[w,` of `,e.length,` tasks completed`]}),(0,I.jsxs)(`span`,{"aria-hidden":`true`,className:`inline-flex`,children:[(0,I.jsx)(ae,{value:String(w),children:w}),(0,I.jsx)(`span`,{children:`/`}),(0,I.jsx)(`span`,{children:e.length})]})]}),(0,I.jsx)(i.span,{"aria-hidden":`true`,animate:{rotate:C?180:0},transition:h?{duration:0}:l,className:`text-muted-foreground/50 transition-colors group-hover:text-muted-foreground`,children:(0,I.jsx)(E,{className:`size-3.5`})})]}),(0,I.jsx)(De,{id:v,role:`region`,"aria-labelledby":_,open:C,children:(0,I.jsxs)(`div`,{ref:y,className:`scrollbar-hide overflow-y-auto px-2 pb-2`,style:{maxHeight:p},children:[(0,I.jsx)(`ol`,{"aria-live":`polite`,className:`space-y-0`,children:(0,I.jsx)(u,{initial:!1,mode:`popLayout`,children:e.map(e=>{let t=e.status??`pending`;return(0,I.jsxs)(i.li,{layout:`position`,initial:h?{opacity:1}:{opacity:0,y:6},animate:{opacity:1,y:0},exit:h?{opacity:0}:{opacity:0,y:-3},transition:h?{duration:0}:{opacity:{duration:.18,ease:c},y:s,layout:s},className:`flex min-h-9 items-center gap-2.5 rounded-xl px-1.5 py-1`,children:[(0,I.jsx)(Bl,{status:t,progress:e.progress}),(0,I.jsxs)(`span`,{className:`sr-only`,children:[Rl(t),`: `]}),(0,I.jsx)(`span`,{className:f(`min-w-0 flex-1 truncate text-sm leading-5`,t===`pending`&&`text-muted-foreground/65`,t===`in-progress`&&`text-foreground`,t===`completed`&&`text-muted-foreground/60`,t===`cancelled`&&`text-muted-foreground/55`),children:(0,I.jsxs)(`span`,{className:`relative inline-block max-w-full`,children:[e.title,(0,I.jsx)(i.span,{"aria-hidden":`true`,initial:!1,animate:{scaleX:+(t===`completed`),opacity:+(t===`completed`)},transition:h?{duration:0}:{duration:.28,ease:c,delay:.06},className:`absolute inset-x-0 top-1/2 h-px origin-left bg-current`})]})}),e.detail?(0,I.jsx)(`span`,{className:`shrink-0 text-sm text-muted-foreground/55`,children:e.detail}):null]},e.id)})})}),!e.length&&(0,I.jsx)(`p`,{className:`px-1.5 py-2 text-sm text-muted-foreground`,children:`No tasks yet`})]})})]})}function Hl({steps:e,activeIndex:t,className:n,...r}){let i=e.length,a=Ae(t,i),o=a>=i,s=je(a,i);return(0,I.jsxs)(`div`,{"data-slot":`agent-plan`,className:f(`flex w-full max-w-sm flex-col gap-3`,n),...r,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`span`,{className:`text-[13.5px] font-medium`,children:`Plan`}),(0,I.jsxs)(`span`,{className:f(ke,`text-foreground/35 tabular-nums`),children:[a,` of `,i]})]}),(0,I.jsx)(`div`,{className:`bg-foreground/[0.06] h-[3px] w-full overflow-hidden rounded-full`,children:(0,I.jsx)(`span`,{className:`bg-foreground/80 block h-full rounded-full transition-[width] duration-500`,style:{width:`${s}%`}})}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:e.map((e,t)=>{let n=o||t<a,r=!o&&t===a;return(0,I.jsxs)(`li`,{className:`flex items-center gap-2.5 text-[13.5px]`,children:[(0,I.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:n?(0,I.jsx)(T,{className:`text-foreground/35 size-3.5`}):r?(0,I.jsx)(j,{className:`text-foreground/90 size-3.5 animate-spin motion-reduce:animate-none`}):(0,I.jsx)(`span`,{"aria-hidden":!0,className:`bg-foreground/15 size-1.5 rounded-full`})}),(0,I.jsx)(`span`,{className:f(n&&`text-foreground/40`,r&&`text-foreground/90`,!n&&!r&&`text-foreground/35`),children:e})]},e)})})]})}function Ul(e){if(e.length===0)return;let t=e.flatMap(e=>{let t=e.title.trim();return t?[t]:[]});if(t.length!==e.length)return;let n=0;for(;n<e.length&&e[n]?.status===`completed`;)n+=1;if(!e.slice(n+1).some(e=>e.status===`completed`))return{steps:t,activeIndex:n}}function Wl({presentation:e,className:t}){return(0,I.jsx)(Hl,{steps:e.steps,activeIndex:e.activeIndex,"aria-label":`Plan progress: ${Math.min(e.activeIndex,e.steps.length)} of ${e.steps.length} steps completed`,className:t})}function Gl(e){return e===`approving`?`Approving`:e===`approved`?`Approved`:e===`denied`?`Denied`:e===`running`?`Running`:e===`complete`?`Completed`:e===`error`?`Failed`:`Approval required`}function Kl(e){return e===`pending`?`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`:e===`approving`||e===`running`?`border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400`:e===`approved`||e===`complete`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`border-rose-500/30 bg-rose-500/10 text-rose-600 dark:text-rose-400`}function ql({tool:e,title:t=`Allow this tool to run?`,description:n,parameters:r=[],status:o=`pending`,open:s,defaultOpen:p=!1,onOpenChange:m,onApprove:h,onAlwaysAllow:g,onDeny:_,className:v}){let y=d()??!1,b=`${(0,F.useId)()}-details`,x=(0,F.useRef)(o),[S,C]=(0,F.useState)(p),w=s??S,D=(0,F.useCallback)(e=>{s===void 0&&C(e),m?.(e)},[m,s]),O=o===`approving`||o===`running`,A=o===`pending`,M=o===`error`;return(0,F.useEffect)(()=>{x.current===`pending`&&o!==`pending`&&D(!1),x.current=o},[D,o]),(0,I.jsxs)(`div`,{"data-state":o,"aria-busy":O,className:f(`w-full overflow-hidden rounded-2xl border border-border/60 bg-muted/20 text-sm`,v),children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3 p-4`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:f(`mt-0.5 grid size-8 shrink-0 place-items-center rounded-xl border border-border/60 bg-background text-muted-foreground`,M&&`text-destructive`),children:O?(0,I.jsx)(j,{className:f(`size-4`,!y&&`animate-spin`)}):M?(0,I.jsx)(k,{className:`size-4`}):o===`denied`?(0,I.jsx)(ge,{className:`size-4`}):o===`approved`||o===`complete`?(0,I.jsx)(T,{className:`size-4`}):(0,I.jsx)(ce,{className:`size-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium text-foreground`,children:t}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:e})]}),(0,I.jsx)(`span`,{className:f(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors`,Kl(o)),children:Gl(o)})]}),n?(0,I.jsx)(`p`,{className:`mt-2 leading-5 text-muted-foreground`,children:n}):null,r.length?(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":w,"aria-controls":b,onClick:()=>D(!w),className:`mt-2 inline-flex items-center gap-1 rounded-md text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[`View details`,(0,I.jsx)(i.span,{"aria-hidden":`true`,animate:{rotate:w?180:0},transition:y?{duration:0}:l,children:(0,I.jsx)(E,{className:`size-3.5`})})]}):null]})]}),(0,I.jsx)(De,{id:b,open:w,children:(0,I.jsx)(`dl`,{className:`mx-4 mb-4 grid gap-2 rounded-xl border border-border/50 bg-background/70 p-3`,children:r.map(e=>(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)] items-center gap-3 text-xs`,children:[(0,I.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,I.jsx)(`dd`,{className:`min-w-0 break-words font-mono text-foreground/85`,children:e.value})]},e.id))})}),(0,I.jsx)(u,{initial:!1,children:A?(0,I.jsxs)(i.div,{initial:y?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:y?.12:.22,ease:c},className:`flex flex-wrap items-center gap-2 border-t border-border/60 px-4 py-3`,children:[(0,I.jsx)(i.button,{type:`button`,onClick:h,whileTap:y?void 0:{scale:.97},transition:a,className:`rounded-xl bg-foreground px-3 py-1.5 text-xs font-medium text-background outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:`Allow once`}),g?(0,I.jsx)(i.button,{type:`button`,onClick:g,whileTap:y?void 0:{scale:.97},transition:a,className:`rounded-xl border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:`Always allow`}):null,(0,I.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-xl px-3 py-1.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:`Deny`})]}):null})]})}function Q(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Jl(e){let t=Q(e);if(t)return t;if(typeof e==`string`)try{return Q(JSON.parse(e))}catch{return}}function $(e,...t){for(let n of t){let t=e?.[n];if(typeof t==`string`&&t.trim())return t}}function Yl(e,...t){for(let n of t){let t=e?.[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e))return e}}}function Xl(e,...t){for(let n of t){let t=e?.[n];if(typeof t==`boolean`)return t}}function Zl(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ql(e){return e.output!==void 0&&e.output!==null?e.output:e.result}function $l(e){let t=Jl(e),n=Jl(t?.details),r={...t??{},...n??{}},i=r.result,a=$(r,`stdout`,`standardOutput`,`standard_output`),o=$(r,`stderr`,`standardError`,`standard_error`),s=r.error??r.errorMessage??r.evalue,c=s===void 0?void 0:Zl(s),l=Yl(r,`durationMs`,`duration_ms`,`duration`),u=Xl(r,`kernelRestarted`,`kernel_restarted`),d=new Set([`stdout`,`stderr`,`standardOutput`,`standard_output`,`standardError`,`standard_error`,`error`,`errorMessage`,`evalue`,`durationMs`,`duration_ms`,`duration`,`kernelRestarted`,`kernel_restarted`,`status`,`isError`]),f=Object.keys(r).some(e=>!d.has(e));return{record:t,details:n,stdout:a,stderr:o,result:i,error:c,durationMs:l,kernelRestarted:u,structured:!a&&!o&&!c&&(typeof i==`object`&&!!i||f)}}function eu(e,t){let n=[];if(e.stdout&&n.push({label:`stdout`,content:e.stdout,language:`text`}),e.stderr&&n.push({label:`stderr`,content:e.stderr,language:`text`}),e.result!==void 0&&n.push({label:`result`,content:Zl(e.result),language:typeof e.result==`object`&&e.result!==null?`json`:`text`}),e.error&&n.push({label:`error`,content:e.error,language:`text`}),n.length>0)return n;let r=e.details??e.record;if(r){let e={...r};if(delete e.details,delete e.isError,Object.keys(e).length>0)return[{label:`result`,content:Zl(e),language:`json`}]}let i=Zl(t);return i.trim()?[{label:`output`,content:i,language:`text`}]:[]}function tu(e,t){return eu(e,t).map(e=>`${e.label}\n${e.content}`).join(`
|
|
1393
1393
|
|
|
1394
1394
|
`)}function nu(e){return Jl(e.input)??Jl(e.args)}function ru(e,...t){for(let n of t){let t=e?.[n];if(Array.isArray(t))return t}}function iu(e,t){return $(t.details??t.record,`diff`,`patch`)??$(e,`diff`,`patch`)}function au(e,t){return $(e,`path`,`filePath`,`filename`,`file`)??$(t.details??t.record,`path`,`filePath`,`filename`,`file`)??`workspace file`}function ou(e){return e.split(`
|
|
1395
|
-
`).map((e,t)=>({id:`${t}-${e.slice(0,16)}`,type:e.startsWith(`+`)&&!e.startsWith(`+++`)?`added`:e.startsWith(`-`)&&!e.startsWith(`---`)?`removed`:`context`,content:e}))}function su(e,t){let n=t.details??t.record,r=Jl(e?.plan)??Jl(n?.plan),i=ru(e,`todos`)??ru(r,`todos`,`items`)??ru(n,`todos`,`newTodos`,`items`);return i?i.flatMap((e,t)=>{let n=
|
|
1395
|
+
`).map((e,t)=>({id:`${t}-${e.slice(0,16)}`,type:e.startsWith(`+`)&&!e.startsWith(`+++`)?`added`:e.startsWith(`-`)&&!e.startsWith(`---`)?`removed`:`context`,content:e}))}function su(e,t){let n=t.details??t.record,r=Jl(e?.plan)??Jl(n?.plan),i=ru(e,`todos`)??ru(r,`todos`,`items`)??ru(n,`todos`,`newTodos`,`items`);return i?i.flatMap((e,t)=>{let n=Q(e);if(!n)return[];let r=$(n,`content`,`title`,`text`,`label`);if(!r)return[];let i=$(n,`status`),a=i===`in_progress`?`in-progress`:i===`completed`?`completed`:i===`cancelled`?`cancelled`:`pending`;return[{id:`${t}-${r}`,title:r,status:a}]}):[]}function cu(e){let t=ru(e.details??e.record,`results`,`sources`,`citations`);return t?t.flatMap((e,t)=>{let n=Q(e);if(!n)return[];let r=$(n,`title`,`name`,`snippet`);if(!r)return[];let i=$(n,`url`,`link`),a=i&&Oe(i)?i:void 0;return[{id:`${t}-${r}`,title:r,url:a,domain:$(n,`domain`,`source`)}]}):[]}function lu(e){return $(e.details??e.record,`url`,`imageUrl`,`image_url`)}function uu(e,t){return Q(e?.approval)??Q(t.details?.approval)??Q(t.record?.approval)}function du(e){let t=typeof e.type==`string`?e.type:`Tool`;return t.startsWith(`tool-`)?t.slice(5):t}function fu(e,t){let n=typeof e.state==`string`?e.state:void 0;return n===`output-error`||n===`error`?`error`:n===`output-available`||n===`complete`||n===`success`?`success`:n===`cancelled`||n===`canceled`||n===`aborted`||n===`interrupted`?`cancelled`:e.error===void 0?n===`input-streaming`||n===`streaming`?t===`streaming`?`running`:`cancelled`:e.output!==void 0||e.result!==void 0?`success`:t===`streaming`?`running`:`cancelled`:`error`}function pu(e,t){return t||e.toLowerCase().includes(`json`)?`json`:e.toLowerCase().includes(`bash`)||e.toLowerCase().includes(`shell`)?`bash`:e.toLowerCase().includes(`python`)?`python`:`text`}function mu(e,t){if(!t)return;let n=e.toLowerCase();return n.includes(`bash`)||n.includes(`shell`)?`bash`:n.includes(`python`)?/^\s*%%bash(?:\s|$)/im.test(t)?`bash`:`python`:`text`}function hu(e,t){if(!t)return;let n=e.toLowerCase();return n.includes(`ipython`)?`IPython`:n.includes(`bash`)||n.includes(`shell`)?`Bash`:n.includes(`python`)?`Python`:t===`json`?`JSON`:t===`text`?`Text`:t.toUpperCase()}function gu(e,t){let n=Q(e);if(!n)return;let r=du(n),i=r.toLowerCase(),a=nu(n),o=Ql(n),s=$l(o),c=fu(n,t),l=$(a,`command`,`cmd`,`code`,`script`),u=mu(r,l),d=$(a,`thought`,`text`),f=[];s.durationMs!==void 0&&f.push(`${s.durationMs}ms`),s.kernelRestarted&&f.push(`kernel restarted`);let p=iu(a,s),m=i.includes(`todo`)||i.includes(`plan`)?su(a,s):[],h=i.includes(`search`)||i.includes(`web`)||i.includes(`source`)||i.includes(`citation`)?cu(s):[],g=i.includes(`image`)||i.includes(`generat`)?lu(s):void 0,_=uu(a,s),v=tu(s,o)||(i===`thinking`||i===`reasoning`?d??``:``),y=!!v.trim(),b=typeof n.toolCallId==`string`&&n.toolCallId?n.toolCallId:`${r}-${JSON.stringify(a??{})}`,x;return m.length>0?x={kind:`todo`,title:i.includes(`plan`)?`Plan`:`Todo list`,items:m}:h.length>0?x={kind:`citations`,citations:h}:g?x={kind:`image`,url:g}:p&&(i.includes(`edit`)||i.includes(`write`)||i.includes(`patch`))?x={kind:`diff`,file:au(a,s),lines:ou(p),copyText:p}:(l||y||_||f.length>0)&&(x={kind:`output`,content:v,language:pu(r,s.structured),structured:s.structured,sections:eu(s,o),sourceCode:l,sourceLanguage:u,sourceLabel:hu(r,u)}),{id:b,name:r,lowerName:i,status:c,input:a,output:o,outputSummary:s,command:l,metadata:f,approval:_,detail:x}}function _u(e){return e.map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:``,status:e.status===`in-progress`?`in_progress`:e.status===`completed`?`completed`:e.status===`cancelled`?`cancelled`:`pending`}))}function vu(e,t){return t.toLowerCase().includes(`bash`)||t.toLowerCase().includes(`shell`)?(0,I.jsx)(me,{"aria-hidden":`true`,className:`size-4`}):e===`success`?(0,I.jsx)(A,{"aria-hidden":`true`,className:`size-4`}):(0,I.jsx)(he,{"aria-hidden":`true`,className:`size-4`})}function yu({approval:e,name:t,status:n}){if(!e)return null;let r=n===`running`?`pending`:n===`error`?`error`:`complete`,i=Object.entries(e).flatMap(([e,t])=>typeof t==`object`||typeof t==`function`?[]:[{id:e,label:e,value:String(t)}]);return(0,I.jsx)(ql,{tool:t,title:`Fleet Prime permission`,description:`This tool reported a permission decision from Fleet Prime.`,parameters:i,status:r})}function bu({code:e,language:t,languageLabel:n,status:r}){return(0,I.jsx)(m,{code:e,language:t,languageLabel:n,status:r===`running`?`streaming`:`complete`,showStatus:!1,maxHeight:160,showLineNumbers:!1,wrap:!0})}var xu=(0,F.memo)(function({part:e,chatStatus:t,fallback:n}){let r=gu(e,t);if(!r||r.lowerName===`question`)return n??null;let{detail:i,status:a}=r;if(!i)return n??null;if(i.kind===`todo`){let t=_u(i.items),a=!!e.input?.pendingDecision;if(r.lowerName===`planwrite`&&a)return n??null;let o=r.lowerName===`planwrite`&&e.input?.executing?Ul(t):void 0;return o?(0,I.jsx)(Wl,{presentation:o,className:`mb-2`}):(0,I.jsx)(Vl,{items:i.items,title:i.title,defaultOpen:!0,collapseOnComplete:!1,maxHeight:240})}if(i.kind===`citations`)return(0,I.jsx)(C,{citations:i.citations,title:`Sources`,defaultOpen:!0});if(i.kind===`image`)return(0,I.jsx)(Ll,{status:a===`running`?`generating`:a===`error`?`error`:`complete`,children:(0,I.jsx)(`img`,{src:i.url,alt:`Generated result`,width:640,height:320,loading:`lazy`,decoding:`async`,className:`h-auto max-h-80 w-full object-contain`})});if(i.kind===`diff`)return(0,I.jsx)(g,{file:i.file,lines:i.lines,status:a===`running`?`streaming`:`complete`,language:`diff`,maxHeight:240,copyText:i.copyText,defaultOpen:a===`running`});let o=i.content||`No output.`;return(0,I.jsxs)(_,{tool:`Prime`,title:r.name,status:a,kind:r.lowerName.includes(`bash`)||r.lowerName.includes(`shell`)||r.lowerName.includes(`python`)?`terminal`:`custom`,meta:r.metadata.length>0?r.metadata.join(` · `):void 0,icon:vu(a,r.name),defaultOpen:a===`running`,collapseOnComplete:!1,maxHeight:240,copyText:o,children:[i.sourceCode?(0,I.jsx)(bu,{code:i.sourceCode,language:i.sourceLanguage??`text`,languageLabel:i.sourceLabel,status:a}):null,i.sections.map(e=>(0,I.jsx)(h,{language:e.language,label:e.label,children:e.content},e.label)),(0,I.jsx)(yu,{approval:r.approval,name:r.name,status:a})]})}),Su=e({FleetPiToolRenderer:()=>Cu}),Cu=(0,F.memo)(function(e){let t=e.part.type;if(t===`tool-Thinking`||t===`tool-FleetReasoning`)return null;let n=(0,I.jsx)(kl,{...e,toolRenderers:b});return t.startsWith(`tool-`)?(0,I.jsx)(xu,{...e,fallback:n}):n});export{Su as n,Cu as t};
|