decocms 4.20.1 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-DMGExMxY.js → AlertCircle-BAqebLND.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-BYUnq8gY.js → ArrowUpRight-BejkutVa.js} +1 -1
- package/dist/client/assets/Check-CC3ah2EP.js +1 -0
- package/dist/client/assets/{CheckCircle-C5ITwmFz.js → CheckCircle-C_Aedf-I.js} +1 -1
- package/dist/client/assets/{ChevronDown-BDi4pzpg.js → ChevronDown-ChsImHZJ.js} +1 -1
- package/dist/client/assets/{ChevronRight-CkirMRmz.js → ChevronRight-DKpM0qdo.js} +1 -1
- package/dist/client/assets/ChevronUp-CJ6cOnxb.js +1 -0
- package/dist/client/assets/Circle-Blw66dbf.js +1 -0
- package/dist/client/assets/Copy01-B9fTK-Gv.js +1 -0
- package/dist/client/assets/DotsVertical-CmhOyP1I.js +1 -0
- package/dist/client/assets/Eye-CFP70kHf.js +1 -0
- package/dist/client/assets/{FilterLines-DCrHo_W-.js → FilterLines-BCJIlwsH.js} +1 -1
- package/dist/client/assets/{Globe01-CHueNlXT.js → Globe01-CdKa67VI.js} +1 -1
- package/dist/client/assets/{Globe04-D1Ia72FD.js → Globe04-BwB-L-v7.js} +1 -1
- package/dist/client/assets/{HardDrive-C5pxB0xX.js → HardDrive-Cvln_XgB.js} +1 -1
- package/dist/client/assets/{Key01-D_Aswhqq.js → Key01-Dq3fyqt5.js} +1 -1
- package/dist/client/assets/{LayoutLeft-BIAH0kog.js → LayoutLeft-D7T3E-u6.js} +1 -1
- package/dist/client/assets/{LinkExternal01-vG76nXPe.js → LinkExternal01-Cohlmmy1.js} +1 -1
- package/dist/client/assets/List-BX1Dxe3c.js +1 -0
- package/dist/client/assets/Loading02-DutOxXF8.js +1 -0
- package/dist/client/assets/{Monitor01-BEHd5v9A.js → Monitor01-Do0cCBdt.js} +1 -1
- package/dist/client/assets/{Palette-CUxSqgEM.js → Palette-BmgCpHFj.js} +1 -1
- package/dist/client/assets/{Play-B6SMfN5e.js → Play-BBHolMYa.js} +1 -1
- package/dist/client/assets/{Plus-B3W-zU0m.js → Plus-Cpa6DE3F.js} +1 -1
- package/dist/client/assets/{SearchLg-CwA3o7Kq.js → SearchLg-D1sKIH4t.js} +1 -1
- package/dist/client/assets/{SearchMd-CG-ZdWyV.js → SearchMd-CafLz5-k.js} +1 -1
- package/dist/client/assets/{Settings02-BXQlyl72.js → Settings02-Qe5DtIFk.js} +1 -1
- package/dist/client/assets/{Shield01-C5cTYwHG.js → Shield01-CmqQX7z4.js} +1 -1
- package/dist/client/assets/{Star01-CaO0nMo9.js → Star01-Dx3yxBV5.js} +1 -1
- package/dist/client/assets/{Stars01-DjfTA0U2.js → Stars01-Cjj351UH.js} +1 -1
- package/dist/client/assets/{Stars02-oR68jXM_.js → Stars02-DVjaFNiu.js} +1 -1
- package/dist/client/assets/{Sun-gt9ujltE.js → Sun-9KvJTXMD.js} +1 -1
- package/dist/client/assets/SwitchHorizontal01-C2AiHI6d.js +1 -0
- package/dist/client/assets/{Tool01-CPfgYpSb.js → Tool01-CMdJij71.js} +1 -1
- package/dist/client/assets/{Trash01-De9U-JcA.js → Trash01-Bk68wFhO.js} +1 -1
- package/dist/client/assets/{Upload01-XVwkIKd6.js → Upload01-DfieuDNH.js} +1 -1
- package/dist/client/assets/{User01--wnyNy2g.js → User01-BiwKrQu6.js} +1 -1
- package/dist/client/assets/{Users01-DQSxkCun.js → Users01-rcBZnIdC.js} +1 -1
- package/dist/client/assets/{Users03-DEShSeP4.js → Users03-C2FdBaet.js} +1 -1
- package/dist/client/assets/{X-DchRughI.js → X-Dfoip5yB.js} +1 -1
- package/dist/client/assets/{XCircle-BMPeQmo7.js → XCircle-C9R5bCeP.js} +1 -1
- package/dist/client/assets/{XClose-BlQxiRFv.js → XClose-CPqc0UtD.js} +1 -1
- package/dist/client/assets/{Zap-gCfOy-ns.js → Zap-CRPirG1P.js} +1 -1
- package/dist/client/assets/{ZapSquare-DRmIxSdp.js → ZapSquare-CGsw7HnP.js} +1 -1
- package/dist/client/assets/{ZoomOut-VZDZQqnX.js → ZoomOut-Cq_jwvnh.js} +1 -1
- package/dist/client/assets/{access-gate-Cqrbc3BU.js → access-gate-7q5PI6kF.js} +1 -1
- package/dist/client/assets/{add-section-modal-DgQQFrd8.js → add-section-modal-BVhFBSux.js} +1 -1
- package/dist/client/assets/agent-capabilities-BGx_yFvg.js +1 -0
- package/dist/client/assets/agent-icon-DAuEpvjN.js +1 -0
- package/dist/client/assets/agents-list-DEbqbve9.js +1 -0
- package/dist/client/assets/ai-providers-jW9pV5wT.js +1 -0
- package/dist/client/assets/{alert-CWiQ4BOG.js → alert-Chi9L6Lo.js} +1 -1
- package/dist/client/assets/{alert-dialog-Buxux4Jv.js → alert-dialog-DNV8OhbX.js} +1 -1
- package/dist/client/assets/app-editor-B90O76NW.js +1 -0
- package/dist/client/assets/{auth-catchall-BM5rYO-b.js → auth-catchall-BeENOKgo.js} +1 -1
- package/dist/client/assets/{auth-entry-Cvl9qiXx.js → auth-entry-Banhr0Dj.js} +1 -1
- package/dist/client/assets/{auth-BZgEN2RD.js → auth-k2I4x92r.js} +1 -1
- package/dist/client/assets/{auth-split-layout-Dfe6g0QY.js → auth-split-layout-BpIandE_.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-cJNik8J_.js → authenticate-and-persist-oauth-DiKNvlD_.js} +1 -1
- package/dist/client/assets/{automation-list-row-BUhdfpZz.js → automation-list-row-pGg9Lluh.js} +1 -1
- package/dist/client/assets/automation-runs-8IQ_r9WW.js +1 -0
- package/dist/client/assets/automations-DYcjcF3S.js +1 -0
- package/dist/client/assets/{avatar-B8STW9mD.js → avatar-BD1bv4j8.js} +1 -1
- package/dist/client/assets/{badge-D5WiG5D4.js → badge-Dz2OFDxQ.js} +1 -1
- package/dist/client/assets/{block-document-CyegCur0.js → block-document-MEJKfSm3.js} +1 -1
- package/dist/client/assets/{brand-context-BclDTNfv.js → brand-context-C-0cx-zk.js} +1 -1
- package/dist/client/assets/{breadcrumb-CrhSDATC.js → breadcrumb-DDrlJm3F.js} +1 -1
- package/dist/client/assets/buckets-K1kG3QiU.js +1 -0
- package/dist/client/assets/bulk-category-panel-Cpe8cv7-.js +1 -0
- package/dist/client/assets/{capability-load-error-DB0r6fSo.js → capability-load-error-CV7OdywL.js} +1 -1
- package/dist/client/assets/{card-BWrHlXPo.js → card-DT6z8UIy.js} +1 -1
- package/dist/client/assets/category-editor-97EZw1QP.js +1 -0
- package/dist/client/assets/{chat-context-D6mGbi6m.js → chat-context-CcZXAHlF.js} +5 -5
- package/dist/client/assets/checkbox-CGiCIR_t.js +1 -0
- package/dist/client/assets/{cli-auth-success-DYZ43GUt.js → cli-auth-success-C0sOgmEb.js} +1 -1
- package/dist/client/assets/collection-detail-Clwh-BUk.js +1 -0
- package/dist/client/assets/collection-display-button-S0ZgQk6P.js +1 -0
- package/dist/client/assets/{collection-search-C_fvYmsw.js → collection-search-eFRNtpdt.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-Cv1VGTD3.js → collection-table-wrapper-DQSn1GJT.js} +1 -1
- package/dist/client/assets/{collection-tabs-Bj8UeBuP.js → collection-tabs-CYD2CpTe.js} +1 -1
- package/dist/client/assets/{command-DeIgAPPz.js → command-DWilEO1e.js} +1 -1
- package/dist/client/assets/commerce-onboarding-Dmxkngyz.js +1 -0
- package/dist/client/assets/connect-desktop-dialog-C8fqunJ_.js +1 -0
- package/dist/client/assets/connection-card-De6SHWCH.js +1 -0
- package/dist/client/assets/connection-detail-BUV19nAJ.js +1 -0
- package/dist/client/assets/{connection-form-helpers-DYr5JaDw.js → connection-form-helpers-DsTip61C.js} +1 -1
- package/dist/client/assets/connections-DHz382Nc.js +1 -0
- package/dist/client/assets/constants-C8_Swa4x.js +1 -0
- package/dist/client/assets/{decopilot-BEN2dFqJ.js → decopilot-DA6E6MgD.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-D-yGYu6w.js → decopilot-sse-pool-B-Li8vIf.js} +1 -1
- package/dist/client/assets/{dialog-Bw0pp5yj.js → dialog-Bx9_D2-i.js} +1 -1
- package/dist/client/assets/{domain-settings-ClPu3y3V.js → domain-settings-CmBMcneA.js} +1 -1
- package/dist/client/assets/{drawer-Bqwp_rDk.js → drawer-DUrVpGtt.js} +1 -1
- package/dist/client/assets/dropdown-menu-BXlOZYEj.js +1 -0
- package/dist/client/assets/{empty-state-DEvtcbTs.js → empty-state-DrOUH3OQ.js} +1 -1
- package/dist/client/assets/extract-connection-data-AeQK1qls.js +1 -0
- package/dist/client/assets/file-explorer-cazCHuV9.js +2 -0
- package/dist/client/assets/{file-type-icon-CeDR5FDE.js → file-type-icon-DHWkW0ug.js} +1 -1
- package/dist/client/assets/{files-BhVyoXap.js → files-CHpi2r2q.js} +1 -1
- package/dist/client/assets/{form-BvyPfbLQ.js → form-C6xzxaKT.js} +1 -1
- package/dist/client/assets/format-time-Cy7tTmZp.js +1 -0
- package/dist/client/assets/general-CBqmiHQR.js +1 -0
- package/dist/client/assets/github-repo-picker-BFPwF92l.js +1 -0
- package/dist/client/assets/{hooks-BPEh0QmD.js → hooks-DPy92pzv.js} +4 -4
- package/dist/client/assets/{index-BLK_ychv.js → index-C8i8F2aZ.js} +12 -12
- package/dist/client/assets/index-CARq6YCN.js +1 -0
- package/dist/client/assets/{index-DSmc84cq.js → index-CO9SnRbg.js} +4 -4
- package/dist/client/assets/{index-DBQeQBu7.js → index-CYLzTU3h.js} +6 -6
- package/dist/client/assets/{index-Bi8gy8BM.js → index-ChSXukaC.js} +1 -1
- package/dist/client/assets/index-CveMeMql.css +1 -0
- package/dist/client/assets/{index-C0UjMZmb.js → index-DD6weYxO.js} +1 -1
- package/dist/client/assets/{index-CuLYHmz6.js → index-DU_SD-rb.js} +1 -1
- package/dist/client/assets/{index-C4E5A5_g.js → index-DWzm9A1x.js} +1 -1
- package/dist/client/assets/{index-WiwoxaKL.js → index-Dx-JuX8X.js} +2 -2
- package/dist/client/assets/{index-BAAVzGGp.js → index-LGROg_hz.js} +1 -1
- package/dist/client/assets/index-Mlqi33Qh.js +1 -0
- package/dist/client/assets/{index-OF548fxc.js → index-S0Q7YlOD.js} +25 -25
- package/dist/client/assets/index-r-ZTThxt.js +1 -0
- package/dist/client/assets/{index-redirect-Ckad27gh.js → index-redirect-BDcT3T7b.js} +1 -1
- package/dist/client/assets/{index-C3UHIWhR.js → index-zDHcoqw4.js} +1 -1
- package/dist/client/assets/{input-C6fESize.js → input-Dmp_t77f.js} +1 -1
- package/dist/client/assets/{integration-icon-B3836mZm.js → integration-icon-D1vivc8T.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-BuboFMvI.js → invite-member-dialog-B52NxzkC.js} +2 -2
- package/dist/client/assets/{label-Cpj2tcAv.js → label-D3ajqQqF.js} +1 -1
- package/dist/client/assets/{library-tab-BBjWEEvH.js → library-tab-D0-rbhqe.js} +3 -3
- package/dist/client/assets/{login-BGIn53vR.js → login-B5g56FG8.js} +1 -1
- package/dist/client/assets/{mcp-oauth-DXbhYp2n.js → mcp-oauth-jAFObzAH.js} +1 -1
- package/dist/client/assets/members-C3EfSHkY.js +1 -0
- package/dist/client/assets/{monaco-editor-Dg_OXRF1.js → monaco-editor-DMzl3sdg.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-ty05snCg.js → monitoring-stats-row-Cn7CUK3V.js} +1 -1
- package/dist/client/assets/{oauth-callback-DmDYtprU.js → oauth-callback-Bs1-J2uC.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-nV9ol-kz.js → oauth-callback-ai-provider-1jknSd8R.js} +1 -1
- package/dist/client/assets/{onboarding-DFxThqB8.js → onboarding-DvEuy0D_.js} +1 -1
- package/dist/client/assets/{org-install-C6-_thTM.js → org-install-CJ7F5mZU.js} +1 -1
- package/dist/client/assets/{org-layout-rq33k6_9.js → org-layout-CQsIu6xu.js} +1 -1
- package/dist/client/assets/{organization-choice-LqtmycnE.js → organization-choice-UHSo9CAk.js} +1 -1
- package/dist/client/assets/{page-seo-form-SfmOLumQ.js → page-seo-form-BY-XtFIF.js} +1 -1
- package/dist/client/assets/page-seo-sheet-C-o48EMg.js +1 -0
- package/dist/client/assets/{popover-CPAEPhwT.js → popover-DbclufIS.js} +1 -1
- package/dist/client/assets/post-editor-o5fS997b.js +1 -0
- package/dist/client/assets/{primitives-TAuh4FGx.js → primitives-PoyK9-WR.js} +1 -1
- package/dist/client/assets/profile-DXLRzqRR.js +1 -0
- package/dist/client/assets/project-app-view-sebr-y53.js +1 -0
- package/dist/client/assets/record-editor-BGPyrMO7.js +1 -0
- package/dist/client/assets/registry-GJh_dUyE.js +2 -0
- package/dist/client/assets/{registry-layout-D8trut1f.js → registry-layout-DaPQiP8-.js} +4 -4
- package/dist/client/assets/{require-capability-Dh5JJLWW.js → require-capability-D_bY_XS6.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BFKAd6mb.js → required-auth-layout-CUJtlw7e.js} +1 -1
- package/dist/client/assets/{reset-password-BVwK480T.js → reset-password-Boo6v3a2.js} +1 -1
- package/dist/client/assets/roles-CP5n6DBo.js +1 -0
- package/dist/client/assets/{scroll-area-DVylVd8s.js → scroll-area-C9lD0DG9.js} +11 -11
- package/dist/client/assets/{search-input-DsIBo_sc.js → search-input-CDcgzOxB.js} +1 -1
- package/dist/client/assets/secrets-BXbhAnGl.js +1 -0
- package/dist/client/assets/{sections-editor-BexUuo8y.js → sections-editor-DHI42whV.js} +2 -2
- package/dist/client/assets/select-CsaBdTgI.js +1 -0
- package/dist/client/assets/{select-model-BEsDOV7S.js → select-model-DflkFrTV.js} +1 -1
- package/dist/client/assets/seo-editor-CaMUQOw8.js +1 -0
- package/dist/client/assets/{settings-layout-CP6mrAe7.js → settings-layout-B_-ExZeb.js} +1 -1
- package/dist/client/assets/{settings-section-Cd3zmde3.js → settings-section-URYHyOYi.js} +1 -1
- package/dist/client/assets/{sheet-S1l6W00L.js → sheet-BGhHsN5F.js} +1 -1
- package/dist/client/assets/{shell-controls-CgJrLQ34.js → shell-controls-6cosW1pP.js} +1 -1
- package/dist/client/assets/shell-layout-DdBCXSg-.js +1 -0
- package/dist/client/assets/{sidebar-DKxDx7lC.js → sidebar-BAsFQ-MT.js} +1 -1
- package/dist/client/assets/{skeleton-wLHgTqVy.js → skeleton-BUBk-3xi.js} +1 -1
- package/dist/client/assets/sso-D_2b6Fc8.js +1 -0
- package/dist/client/assets/store-ievF1htD.js +1 -0
- package/dist/client/assets/store-registry-B3gzmTlr.js +2 -0
- package/dist/client/assets/{studio-tools-DkATXRgK.js → studio-tools-DgAshZ-_.js} +1 -1
- package/dist/client/assets/{switch-C4FKiTgP.js → switch-BonZrdli.js} +1 -1
- package/dist/client/assets/{table-BV3Hd7cI.js → table-DEH4uiQe.js} +1 -1
- package/dist/client/assets/{tabs-B9iGaa-Z.js → tabs-CRj6AkcW.js} +1 -1
- package/dist/client/assets/task-row-ChWV-nAj.js +1 -0
- package/dist/client/assets/task-status-Dh1x9gPU.js +1 -0
- package/dist/client/assets/{textarea-CiUwXw-w.js → textarea-BNlJNx-b.js} +1 -1
- package/dist/client/assets/{toggle-group-CN_l4byE.js → toggle-group-QkV1Q0_i.js} +1 -1
- package/dist/client/assets/{toolbar-ekp7NSbq.js → toolbar-CCAeF5A-.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-CBlJ6I0o.js → toolbar-icon-button-D7VY-9VN.js} +1 -1
- package/dist/client/assets/{tools-list-D_VeN0IP.js → tools-list-M23BH1hq.js} +1 -1
- package/dist/client/assets/{tooltip-CKk6MyBG.js → tooltip-FlCInimM.js} +1 -1
- package/dist/client/assets/{types-CeLnpp7L.js → types-kWY4145T.js} +1 -1
- package/dist/client/assets/{use-ai-providers-DhQCSBc1.js → use-ai-providers-Bc5pT284.js} +1 -1
- package/dist/client/assets/use-automations-CF2YS293.js +1 -0
- package/dist/client/assets/{use-capability-HK8_0h49.js → use-capability-BY1ZsP4P.js} +1 -1
- package/dist/client/assets/use-clock-tick-DiVstnVw.js +1 -0
- package/dist/client/assets/{use-collections-CdbL-rX2.js → use-collections-BwIgjkkY.js} +1 -1
- package/dist/client/assets/use-connection-BuLrAfYP.js +1 -0
- package/dist/client/assets/{use-copy-Ba_RrSds.js → use-copy-ue2G1-hn.js} +1 -1
- package/dist/client/assets/use-create-virtual-mcp-CwTiuOpk.js +1 -0
- package/dist/client/assets/{use-debounced-autosave-B6gDjRvo.js → use-debounced-autosave-DPoL6EyR.js} +1 -1
- package/dist/client/assets/{use-debounced-value-CyOmB5fJ.js → use-debounced-value-BaMggBf4.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-DwY1rJO2.js → use-decopilot-events-CqBKeCC-.js} +1 -1
- package/dist/client/assets/{use-delete-connection-CPWy2xmw.js → use-delete-connection-Dz7PGuLT.js} +1 -1
- package/dist/client/assets/{use-file-configs-SlXV4SMn.js → use-file-configs-DG9Mhiyd.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-DHUYU_kG.js → use-infinite-scroll-3Uj2RNwo.js} +1 -1
- package/dist/client/assets/{use-join-requests-f9qAAjhC.js → use-join-requests-S43CfCdf.js} +1 -1
- package/dist/client/assets/use-mcp-client-CnRSGieI.js +10 -0
- package/dist/client/assets/{use-mcp-prompts-UzvitU_e.js → use-mcp-prompts-BHkYncis.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-zFZxfr6-.js → use-mcp-tools-CDyeZmTp.js} +1 -1
- package/dist/client/assets/{use-members-DTTAqnQj.js → use-members-DSSi_h3c.js} +1 -1
- package/dist/client/assets/{use-mobile-71FrMeIQ.js → use-mobile-FUxUqTQv.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-DIwK9fdW.js → use-navigate-to-agent-DqOg0uVZ.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-CfqWFlO5.js → use-org-auth-client-DOD7ccpR.js} +1 -1
- package/dist/client/assets/{use-org-sso-DnPy8IJo.js → use-org-sso-DU73DmAG.js} +1 -1
- package/dist/client/assets/{use-organization-roles-DLiC1YgM.js → use-organization-roles-Dcz2MjMd.js} +1 -1
- package/dist/client/assets/use-organization-settings-C8EmnI93.js +1 -0
- package/dist/client/assets/use-registry-connections-Ctaa0JQV.js +1 -0
- package/dist/client/assets/{use-secrets-CJb3Q-KQ.js → use-secrets-B5E8bF7h.js} +1 -1
- package/dist/client/assets/{use-status-sounds-C23loojF.js → use-status-sounds-BH3nLka8.js} +1 -1
- package/dist/client/assets/{use-view-mode-DtQqfjJM.js → use-view-mode-DHvPeuX3.js} +1 -1
- package/dist/client/assets/use-virtual-mcp-iU8WqU_q.js +1 -0
- package/dist/client/assets/useInfiniteQuery-MSYpmccr.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-Wt188HkA.js +1 -0
- package/dist/client/assets/{useSuspenseQueries-f54Kg_lq.js → useSuspenseQueries-Cy-j8ofE.js} +1 -1
- package/dist/client/assets/variant-calendar-BWM8PQLC.js +1 -0
- package/dist/client/assets/{view-mode-toggle-xMIlyXz_.js → view-mode-toggle-td--5Ihh.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +521 -507
- package/dist/server/migrate.js +83 -83
- package/dist/server/server.js +314 -314
- package/package.json +1 -1
- package/dist/client/assets/ChevronUp-BgfgTfJo.js +0 -1
- package/dist/client/assets/DotsVertical-wFUaTKIr.js +0 -1
- package/dist/client/assets/Eye-BPtPfNj_.js +0 -1
- package/dist/client/assets/SwitchHorizontal01-DKfBMAMt.js +0 -1
- package/dist/client/assets/agent-capabilities-Bxs0ILD3.js +0 -1
- package/dist/client/assets/agent-icon-Bw-pYaqu.js +0 -1
- package/dist/client/assets/agents-list-BaYiXH15.js +0 -1
- package/dist/client/assets/ai-providers-C4e06NrJ.js +0 -1
- package/dist/client/assets/app-editor-DtV9KQKR.js +0 -1
- package/dist/client/assets/automation-runs-D52rO4m5.js +0 -1
- package/dist/client/assets/automations-Cc50qZvh.js +0 -1
- package/dist/client/assets/buckets--3cPd2W_.js +0 -1
- package/dist/client/assets/bulk-category-panel-DsOXc5WN.js +0 -1
- package/dist/client/assets/category-editor-EHZdd7WQ.js +0 -1
- package/dist/client/assets/checkbox-B0iPK-Vx.js +0 -1
- package/dist/client/assets/collection-detail-pr_0VNQT.js +0 -1
- package/dist/client/assets/collection-display-button-BdyEgFyg.js +0 -1
- package/dist/client/assets/commerce-onboarding-CHMkWtbP.js +0 -1
- package/dist/client/assets/connect-desktop-dialog-DU7oJbU_.js +0 -1
- package/dist/client/assets/connection-card-CIIT6a-B.js +0 -1
- package/dist/client/assets/connection-detail-DW7R20rk.js +0 -1
- package/dist/client/assets/connections-BXo316Yj.js +0 -1
- package/dist/client/assets/dropdown-menu-DBdT-R6w.js +0 -1
- package/dist/client/assets/extract-connection-data-DB2mp1s-.js +0 -1
- package/dist/client/assets/file-explorer-CCDyOatC.js +0 -2
- package/dist/client/assets/general-Cppvys0u.js +0 -1
- package/dist/client/assets/github-repo-picker-D7QB7NBL.js +0 -1
- package/dist/client/assets/index-B1I1Oi0g.css +0 -1
- package/dist/client/assets/index-BASamdWA.js +0 -1
- package/dist/client/assets/index-CgS6ZFaA.js +0 -1
- package/dist/client/assets/members-BJuT40Uf.js +0 -1
- package/dist/client/assets/page-seo-sheet-rEaKbGL4.js +0 -1
- package/dist/client/assets/post-editor-DNSrY2g5.js +0 -1
- package/dist/client/assets/profile-BJUc-WPJ.js +0 -1
- package/dist/client/assets/project-app-view-vdCIDY4V.js +0 -1
- package/dist/client/assets/record-editor-ChG8xfNH.js +0 -1
- package/dist/client/assets/registry-BDvYq0sF.js +0 -2
- package/dist/client/assets/roles-BVmBg8nQ.js +0 -1
- package/dist/client/assets/secrets-okf3dR05.js +0 -1
- package/dist/client/assets/select-CYLZmEqL.js +0 -1
- package/dist/client/assets/seo-editor-lx2p6Zbz.js +0 -1
- package/dist/client/assets/shell-layout-D3aCzUD1.js +0 -1
- package/dist/client/assets/sso-CsR0QPxD.js +0 -1
- package/dist/client/assets/store-Dmf6IFoE.js +0 -1
- package/dist/client/assets/store-registry-Ci8hLaqa.js +0 -2
- package/dist/client/assets/task-row-Dq6a6p3f.js +0 -1
- package/dist/client/assets/task-status-vCNfacyn.js +0 -1
- package/dist/client/assets/use-automations-DH-tTWJO.js +0 -1
- package/dist/client/assets/use-clock-tick-7xgXM9p8.js +0 -1
- package/dist/client/assets/use-connection-BoEeMU65.js +0 -1
- package/dist/client/assets/use-create-virtual-mcp-DCJ_9oKR.js +0 -1
- package/dist/client/assets/use-mcp-client-PdP6F3TE.js +0 -10
- package/dist/client/assets/use-organization-settings-BZHnFHzb.js +0 -1
- package/dist/client/assets/use-registry-connections-BItKY-Xq.js +0 -1
- package/dist/client/assets/use-virtual-mcp-D3Xj1Zyr.js +0 -1
- package/dist/client/assets/useInfiniteQuery-CdROm-U7.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-DtKEQU_S.js +0 -1
- package/dist/client/assets/variant-calendar-BSvOsjHM.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as M,c as D,o as wc,n as fh,p as hh,j as p,B as ir,s as Dl,bG as Cc,bH as ph,ae as mh,a3 as en,bI as gh,l as X,v as yh,a7 as xh,a4 as Pt,ab as bh,aa as Mt,b6 as br,a8 as un,bJ as Tc,a6 as Nc,G as Lt,m as kh,d as Sh,K as Wt,t as Vo,k as Mi,b as Pn,E as vh,a0 as Mc,bK as Ei,a9 as wh,bL as Ht}from"./index-OF548fxc.js";import{f as Ch,L as Th,h as Nh,as as Mh,a0 as Eh,a8 as Ah,a7 as Oh,ap as Ec,at as Ih,au as Rh,A as Ac,av as tt,aw as jh,ax as Dh,ay as Ph,k as Lh}from"./agent-icon-Bw-pYaqu.js";import{t as Bs}from"./Stars01-DjfTA0U2.js";import{i as Oc,t as _h,d as Ic,b as Mr}from"./XCircle-BMPeQmo7.js";import{i as Ai}from"./ChevronUp-BgfgTfJo.js";import{i as Pl}from"./ChevronRight-CkirMRmz.js";import{a as Rc,s as $h}from"./Eye-BPtPfNj_.js";import{a as Rt,t as Oi,u as jc,c as Ll}from"./use-clock-tick-7xgXM9p8.js";import{u as Dc}from"./use-copy-Ba_RrSds.js";import{a as tn,b as nn,T as rn}from"./tooltip-CKk6MyBG.js";import{M as Ii,I as Pc,F as zh}from"./file-type-icon-CeDR5FDE.js";import{c as Bh}from"./content-blocks-o63cs2vh.js";import{g as Lc,M as Fh}from"./types-CeLnpp7L.js";import{S as Hh,j as Ln,m as Vh,c as Ri,a as Wh,u as Uh}from"./chat-context-D6mGbi6m.js";import{c as qh,r as Kh,R as Jh}from"./hooks-BPEh0QmD.js";import{u as Gh}from"./studio-tools-DkATXRgK.js";import{f as Xh,n as Yh,o as Qh}from"./tab-id-CLpu897Q.js";import{e as Zh,u as _c,l as ep}from"./use-mcp-client-PdP6F3TE.js";import{i as $c}from"./AlertCircle-DMGExMxY.js";import{s as Kr,t as zc}from"./Star01-CaO0nMo9.js";import{s as tp}from"./XClose-BlQxiRFv.js";import{n as Wo}from"./ZapSquare-DRmIxSdp.js";import{n as Bc,i as np}from"./Globe01-CHueNlXT.js";import{c as rp,b as sp,a as Er}from"./Tool01-CPfgYpSb.js";import{i as _l,a as op}from"./ZoomOut-VZDZQqnX.js";import{i as Jn}from"./Monitor01-BEHd5v9A.js";import{i as ip}from"./SearchMd-CG-ZdWyV.js";import{i as lp}from"./Upload01-XVwkIKd6.js";import{b as ap,c as cp}from"./shell-layout-D3aCzUD1.js";import{n as Fc}from"./LinkExternal01-vG76nXPe.js";import{b as up,S as dp,c as fp,d as hp}from"./sheet-S1l6W00L.js";import{I as kr}from"./integration-icon-B3836mZm.js";import{u as pp}from"./use-virtual-mcp-D3Xj1Zyr.js";import{i as mp}from"./ArrowUpRight-BYUnq8gY.js";import{a as ji}from"./Users03-DEShSeP4.js";import{a as nt}from"./Palette-CUxSqgEM.js";import{c as Hc}from"./use-navigate-to-agent-DIwK9fdW.js";import{a as gp}from"./use-connection-BoEeMU65.js";import{a as yp}from"./Stars02-oR68jXM_.js";import{g as xp}from"./use-mcp-prompts-UzvitU_e.js";import{a as bp,c as kp,D as Sp,d as vp,e as wp}from"./dialog-Bw0pp5yj.js";import{a as Cp,F as Tp,b as Np,c as Mp,d as Ep,e as Ap}from"./form-BvyPfbLQ.js";import{I as Op}from"./input-C6fESize.js";import{t as Ip}from"./ChevronDown-BDi4pzpg.js";import{e as Rp}from"./select-CYLZmEqL.js";const jp={openrouter:n=>{const e=n?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Vc(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(jp)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function Wc(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function Uc(n,e){if(!e)return n;const t=e.inputTokenDetails?.cacheReadTokens??e.cachedInputTokens??0,r=e.inputTokenDetails?.cacheWriteTokens??0;return{inputTokens:n.inputTokens+(e.inputTokens??0),outputTokens:n.outputTokens+(e.outputTokens??0),reasoningTokens:n.reasoningTokens+(e.reasoningTokens??0),totalTokens:n.totalTokens+(e.totalTokens??0),cost:n.cost+Vc(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function C2(n){return n.reduce((e,t)=>Uc(e,t.metadata?.usage),Wc())}const Dp={damping:.7,stiffness:.05,mass:1.25},Pp=70,Lp=1e3/60,_p=350;let Fs=!1;globalThis.document?.addEventListener("mousedown",()=>{Fs=!0});globalThis.document?.addEventListener("mouseup",()=>{Fs=!1});globalThis.document?.addEventListener("click",()=>{Fs=!1});const $p=(n={})=>{const[e,t]=M.useState(!1),[r,s]=M.useState(n.initial!==!1),[o,i]=M.useState(!1),l=M.useRef(null);l.current=n;const a=M.useCallback(()=>{if(!Fs)return!1;const b=window.getSelection();if(!b||!b.rangeCount)return!1;const k=b.getRangeAt(0);return k.commonAncestorContainer.contains(y.current)||y.current?.contains(k.commonAncestorContainer)},[]),c=M.useCallback(b=>{d.isAtBottom=b,s(b)},[]),u=M.useCallback(b=>{d.escapedFromLock=b,t(b)},[]),d=M.useMemo(()=>{let b;return{escapedFromLock:e,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return y.current?.scrollTop??0},set scrollTop(k){if(y.current){const{scrollBehavior:v}=getComputedStyle(y.current);v!=="auto"&&(y.current.style.scrollBehavior="auto"),y.current.scrollTop=k,d.ignoreScrollToTop=y.current.scrollTop,v!=="auto"&&(y.current.style.scrollBehavior=v)}},get targetScrollTop(){return!y.current||!x.current?0:y.current.scrollHeight-1-y.current.clientHeight},get calculatedTargetScrollTop(){if(!y.current||!x.current)return 0;const{targetScrollTop:k}=this;if(!n.targetScrollTop)return k;if(b?.targetScrollTop===k)return b.calculatedScrollTop;const v=Math.max(Math.min(n.targetScrollTop(k,{scrollElement:y.current,contentElement:x.current}),k),0);return b={targetScrollTop:k,calculatedScrollTop:v},requestAnimationFrame(()=>{b=void 0}),v},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Pp}}},[]),f=M.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),v=fo(l.current,b.animation),{ignoreEscapes:S=!1}=b;let w,C=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{w=Date.now()}):w=k+(b.duration??0);const T=async()=>{const N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;const{scrollTop:E}=d,j=performance.now(),L=(j-(d.lastTick??j))/Lp;if(d.animation||(d.animation={behavior:v,promise:N,ignoreEscapes:S}),d.animation.behavior===v&&(d.lastTick=j),a()||k>Date.now())return T();if(E<Math.min(C,d.calculatedTargetScrollTop)){if(d.animation?.behavior===v){if(v==="instant")return d.scrollTop=d.calculatedTargetScrollTop,T();d.velocity=(v.damping*d.velocity+v.stiffness*d.scrollDifference)/v.mass,d.accumulated+=d.velocity*L,d.scrollTop+=d.accumulated,d.scrollTop!==E&&(d.accumulated=0)}return T()}return w>Date.now()?(C=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:fo(l.current,l.current.resize),ignoreEscapes:S,duration:Math.max(0,w-Date.now())||void 0}):d.isAtBottom)});return N.then(E=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),E))};return b.wait!==!0&&(d.animation=void 0),d.animation?.behavior===v?d.animation.promise:T()},[c,a,d]),h=M.useCallback(()=>{u(!0),c(!1)},[u,c]),m=M.useCallback(({target:b})=>{if(b!==y.current)return;const{scrollTop:k,ignoreScrollToTop:v}=d;let{lastScrollTop:S=k}=d;d.lastScrollTop=k,d.ignoreScrollToTop=void 0,v&&v>k&&(S=v),i(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===v)return;if(a()){u(!0),c(!1);return}const w=k>S,C=k<S;if(d.animation?.ignoreEscapes){d.scrollTop=S;return}C&&(u(!0),c(!1)),w&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,a,d]),g=M.useCallback(({target:b,deltaY:k})=>{let v=b;for(;!["scroll","auto"].includes(getComputedStyle(v).overflow);){if(!v.parentElement)return;v=v.parentElement}v===y.current&&k<0&&y.current.scrollHeight>y.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),y=$l(b=>{y.current?.removeEventListener("scroll",m),y.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),x=$l(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([v])=>{const{height:S}=v.contentRect,w=S-(k??S);if(d.resizeDifference=w,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),i(d.isNearBottom),w>=0){const C=fo(l.current,k?l.current.resize:l.current.initial);f({animation:C,wait:!0,preserveScrollPosition:!0,duration:C==="instant"?void 0:_p})}else d.isNearBottom&&(u(!1),c(!0));k=S,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===w&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:x,scrollRef:y,scrollToBottom:f,stopScroll:h,isAtBottom:r||o,isNearBottom:o,escapedFromLock:e,state:d}};function $l(n,e){const t=M.useCallback(r=>(t.current=r,n(r)),e);return t}const uo=new Map;function fo(...n){const e={...Dp};let t=!1;for(const s of n){if(s==="instant"){t=!0;continue}typeof s=="object"&&(t=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const r=JSON.stringify(e);return uo.has(r)||uo.set(r,Object.freeze(e)),t?"instant":uo.get(r)}function zp(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Di(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function Pi(n,e){if(!e)return n;const t=`${zp(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function Bp(n,e){return Pi(n,e).replace(/[_-]/g," ").toLowerCase()}function Fp(n){const e={};for(const t of n.arguments??[])e[t.name]=t.required?Dl().min(1,"Required"):Dl();return wc(e)}function Hp(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Vp(n){const e=D.c(66),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:o}=n,i=M.useId();let l;if(e[0]!==t){const $=t?Fp(t):wc({});l=fh($),e[0]=t,e[1]=l}else l=e[1];const c=l;let u;e[2]!==o||e[3]!==t?(u=t?Hp(t,o):{},e[2]=o,e[3]=t,e[4]=u):u=e[4];let d;e[5]!==c||e[6]!==u?(d={resolver:c,defaultValues:u,mode:"onChange"},e[5]=c,e[6]=u,e[7]=d):d=e[7];const f=hh(d);let h;e[8]!==t?.arguments?(h=t?.arguments??[],e[8]=t?.arguments,e[9]=h):h=e[9];const m=h;let g;e[10]!==f||e[11]!==s||e[12]!==r?(g=async $=>{await s($),r(null),f.reset()},e[10]=f,e[11]=s,e[12]=r,e[13]=g):g=e[13];const y=g;let x;e[14]!==f||e[15]!==r?(x=$=>{$||(f.reset(),r(null))},e[14]=f,e[15]=r,e[16]=x):x=e[16];const b=x;if(!t)return null;let k;e[17]!==t._meta||e[18]!==t.name||e[19]!==t.title?(k=t.title||Bp(t.name,Di(t._meta)),e[17]=t._meta,e[18]=t.name,e[19]=t.title,e[20]=k):k=e[20];let v;e[21]!==k?(v=p.jsx(bp,{children:p.jsx("span",{className:"capitalize",children:k})}),e[21]=k,e[22]=v):v=e[22];let S;e[23]!==t.description?(S=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[23]=t.description,e[24]=S):S=e[24];let w;e[25]!==S||e[26]!==v?(w=p.jsxs(kp,{children:[v,S]}),e[25]=S,e[26]=v,e[27]=w):w=e[27];let C;e[28]!==f||e[29]!==y?(C=$=>{$.stopPropagation(),f.handleSubmit(y)($)},e[28]=f,e[29]=y,e[30]=C):C=e[30];let T;if(e[31]!==m||e[32]!==f.control||e[33]!==f.formState.isSubmitting){let $;e[35]!==f.control||e[36]!==f.formState.isSubmitting?($=F=>p.jsx(Tp,{control:f.control,name:F.name,render:G=>{const{field:Q}=G;return p.jsxs(Np,{children:[p.jsxs(Mp,{className:"text-xs",children:[F.name,F.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(Ep,{children:p.jsx(Op,{...Q,value:Q.value??"",required:F.required,placeholder:F.description??"",className:"h-9",disabled:f.formState.isSubmitting})}),p.jsx(Ap,{})]})}},F.name),e[35]=f.control,e[36]=f.formState.isSubmitting,e[37]=$):$=e[37],T=m.map($),e[31]=m,e[32]=f.control,e[33]=f.formState.isSubmitting,e[34]=T}else T=e[34];let N;e[38]!==b?(N=()=>b(!1),e[38]=b,e[39]=N):N=e[39];let E;e[40]!==f.formState.isSubmitting||e[41]!==N?(E=p.jsx(ir,{type:"button",variant:"ghost",onClick:N,disabled:f.formState.isSubmitting,children:"Cancel"}),e[40]=f.formState.isSubmitting,e[41]=N,e[42]=E):E=e[42];let j;e[43]!==f.formState.isSubmitting?(j=f.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(Hh,{size:"xs"}),"Loading..."]}):"Use prompt",e[43]=f.formState.isSubmitting,e[44]=j):j=e[44];let L;e[45]!==f.formState.isSubmitting||e[46]!==i||e[47]!==j?(L=p.jsx(ir,{type:"submit",form:i,disabled:f.formState.isSubmitting,children:j}),e[45]=f.formState.isSubmitting,e[46]=i,e[47]=j,e[48]=L):L=e[48];let I;e[49]!==E||e[50]!==L?(I=p.jsxs(Sp,{children:[E,L]}),e[49]=E,e[50]=L,e[51]=I):I=e[51];let P;e[52]!==i||e[53]!==C||e[54]!==T||e[55]!==I?(P=p.jsxs("form",{id:i,className:"space-y-4 py-4",autoComplete:"off",onSubmit:C,children:[T,I]}),e[52]=i,e[53]=C,e[54]=T,e[55]=I,e[56]=P):P=e[56];let R;e[57]!==f||e[58]!==P?(R=p.jsx(Cp,{...f,children:P}),e[57]=f,e[58]=P,e[59]=R):R=e[59];let z;e[60]!==w||e[61]!==R?(z=p.jsxs(vp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[w,R]}),e[60]=w,e[61]=R,e[62]=z):z=e[62];let B;return e[63]!==b||e[64]!==z?(B=p.jsx(wp,{open:!0,onOpenChange:b,children:z}),e[63]=b,e[64]=z,e[65]=B):B=e[65],B}function qc(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function Ye(n,e){return n==="output-error"||n==="output-denied"?"error":n==="approval-requested"?"approval":n==="input-streaming"||n==="input-available"||n==="output-available"&&e===!0?"loading":"idle"}function _n(n){if(n==null||typeof n!="object")return;const e=n;if(e.structuredContent&&typeof e.structuredContent=="object")return e.structuredContent;if(Array.isArray(e.content)){const t=e.content[0];if(t?.type==="text"&&typeof t.text=="string")try{return JSON.parse(t.text)}catch{return}return}return n}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function Kc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Kc(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Jc(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=Jc(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class A{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new A(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new A(r,s)}cutByIndex(e,t){return e==t?A.empty:e==0&&t==this.content.length?this:new A(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new A(s,o)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Kc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Jc(this,e,t,r)}findIndex(e){if(e==0)return Ar(0,e);if(e==this.size)return Ar(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Ar(t+1,o):Ar(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return A.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new A(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new A(t||e,r)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const ho={index:0,offset:0};function Ar(n,e){return ho.index=n,ho.offset=e,ho}function Jr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Jr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Jr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ee=class Uo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Jr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Uo.none;if(e instanceof Uo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};ee.none=[];class Gr extends Error{}class _{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Xc(this.content,e+this.openStart,t);return r&&new _(r,this.openStart,this.openEnd)}removeBetween(e,t){return new _(Gc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return _.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _(A.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new _(e,r,s)}}_.empty=new _(A.empty,0,0);function Gc(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Gc(o.content,e-s-1,t-s-1)))}function Xc(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Xc(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function Wp(n,e,t){if(t.openStart>n.depth)throw new Gr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Gr("Inconsistent open depths");return Yc(n,e,t,0)}function Yc(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=Yc(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Xt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Up(t,n);return Xt(o,Zc(n,i,l,e,r))}else return Xt(o,Xr(n,e,r))}function Qc(n,e){if(!e.type.compatibleContent(n.type))throw new Gr("Cannot join "+e.type.name+" onto "+n.type.name)}function qo(n,e,t){let r=n.node(t);return Qc(r,e.node(t)),r}function Gt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Gn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Gt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Gt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Gt(e.nodeBefore,r)}function Xt(n,e){return n.type.checkContent(e),n.copy(e)}function Zc(n,e,t,r,s){let o=n.depth>s&&qo(n,e,s+1),i=r.depth>s&&qo(t,r,s+1),l=[];return Gn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(Qc(o,i),Gt(Xt(o,Zc(n,e,t,r,s+1)),l)):(o&&Gt(Xt(o,Xr(n,e,s+1)),l),Gn(e,t,s,l),i&&Gt(Xt(i,Xr(t,r,s+1)),l)),Gn(r,null,s,l),new A(l)}function Xr(n,e,t){let r=[];if(Gn(null,n,t,r),n.depth>t){let s=qo(n,e,t+1);Gt(Xt(s,Xr(n,e,t+1)),r)}return Gn(e,null,t,r),new A(r)}function Up(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(A.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class lr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ee.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Yr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new lr(t,r,o)}static resolveCached(e,t){let r=zl.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else zl.set(e,r=new qp);let s=r.elts[r.i]=lr.resolve(e,t);return r.i=(r.i+1)%Kp,s}}class qp{constructor(){this.elts=[],this.i=0}}const Kp=12,zl=new WeakMap;class Yr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Jp=Object.create(null);class Xe{constructor(e,t,r,s=ee.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Jr(this.attrs,t||e.defaultAttrs||Jp)&&ee.sameSet(this.marks,r||ee.none)}copy(e=null){return e==this.content?this:new Xe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Xe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return _.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new _(c,s.depth-i,o.depth-i)}replace(e,t,r){return Wp(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return lr.resolveCached(this,e)}resolveNoCache(e){return lr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),eu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=A.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ee.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ee.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=A.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}Xe.prototype.text=void 0;class Qr extends Xe{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):eu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function eu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class sn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Gp(e,t);if(r.next==null)return sn.empty;let s=tu(r);r.next&&r.err("Unexpected trailing text");let o=nm(tm(s));return rm(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
|
|
1
|
+
import{r as M,c as D,o as wc,n as fh,p as hh,j as p,B as ir,s as Dl,bG as Cc,bH as ph,ae as mh,a3 as en,bI as gh,l as X,v as yh,a7 as xh,a4 as Pt,ab as bh,aa as Mt,b6 as br,a8 as un,bJ as Tc,a6 as Nc,D as Lt,m as kh,d as Sh,K as Wt,t as Vo,k as Mi,b as Pn,E as vh,a0 as Mc,bK as Ei,a9 as wh,bL as Ht}from"./index-S0Q7YlOD.js";import{f as Ch,L as Th,h as Nh,as as Mh,a0 as Eh,a8 as Ah,a7 as Oh,ap as Ec,at as Ih,au as Rh,A as Ac,av as tt,aw as jh,ax as Dh,ay as Ph,k as Lh}from"./agent-icon-DAuEpvjN.js";import{t as Bs}from"./Stars01-Cjj351UH.js";import{i as Oc,t as _h,d as Ic,b as Mr}from"./XCircle-C9R5bCeP.js";import{i as Ai}from"./Check-CC3ah2EP.js";import{i as Pl}from"./ChevronRight-DKpM0qdo.js";import{a as Rc}from"./Copy01-B9fTK-Gv.js";import{a as Rt,t as Oi,c as Ll}from"./format-time-Cy7tTmZp.js";import{u as jc}from"./use-copy-ue2G1-hn.js";import{a as tn,b as nn,T as rn}from"./tooltip-FlCInimM.js";import{M as Ii,I as Dc,F as $h}from"./file-type-icon-DHWkW0ug.js";import{c as zh}from"./content-blocks-o63cs2vh.js";import{g as Pc,M as Bh}from"./types-kWY4145T.js";import{S as Fh,j as Ln,m as Hh,c as Ri,a as Vh,u as Wh}from"./chat-context-CcZXAHlF.js";import{c as Uh,r as qh,R as Kh}from"./hooks-DPy92pzv.js";import{u as Jh}from"./studio-tools-DgAshZ-_.js";import{f as Gh,n as Xh,o as Yh}from"./tab-id-CLpu897Q.js";import{c as Qh,u as Lc}from"./use-mcp-client-CnRSGieI.js";import{i as _c}from"./AlertCircle-BAqebLND.js";import{s as Zh}from"./Eye-CFP70kHf.js";import{s as Kr,t as $c}from"./Star01-Dx3yxBV5.js";import{s as ep}from"./XClose-CPqc0UtD.js";import{n as Wo}from"./ZapSquare-CGsw7HnP.js";import{n as zc,i as tp}from"./Globe01-CdKa67VI.js";import{c as np,b as rp,a as Er}from"./Tool01-CMdJij71.js";import{i as _l,a as sp}from"./ZoomOut-Cq_jwvnh.js";import{i as Jn}from"./Monitor01-Do0cCBdt.js";import{i as op}from"./SearchMd-CafLz5-k.js";import{i as ip}from"./Upload01-DfieuDNH.js";import{u as Bc}from"./use-clock-tick-DiVstnVw.js";import{b as lp,c as ap}from"./shell-layout-DdBCXSg-.js";import{n as Fc}from"./LinkExternal01-Cohlmmy1.js";import{b as cp,S as up,c as dp,d as fp}from"./sheet-BGhHsN5F.js";import{I as kr}from"./integration-icon-D1vivc8T.js";import{a as hp}from"./use-virtual-mcp-iU8WqU_q.js";import{i as pp}from"./ArrowUpRight-BejkutVa.js";import{a as ji}from"./Users03-C2FdBaet.js";import{a as nt}from"./Palette-BmgCpHFj.js";import{u as Hc}from"./use-navigate-to-agent-DqOg0uVZ.js";import{a as mp}from"./use-connection-BuLrAfYP.js";import{a as gp}from"./Stars02-DVjaFNiu.js";import{d as yp}from"./constants-C8_Swa4x.js";import{g as xp}from"./use-mcp-prompts-BHkYncis.js";import{a as bp,c as kp,D as Sp,d as vp,e as wp}from"./dialog-Bx9_D2-i.js";import{a as Cp,F as Tp,b as Np,c as Mp,d as Ep,e as Ap}from"./form-C6xzxaKT.js";import{I as Op}from"./input-Dmp_t77f.js";import{t as Ip}from"./ChevronDown-ChsImHZJ.js";import{e as Rp}from"./select-CsaBdTgI.js";const jp={openrouter:n=>{const e=n?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Vc(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(jp)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function Wc(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function Uc(n,e){if(!e)return n;const t=e.inputTokenDetails?.cacheReadTokens??e.cachedInputTokens??0,r=e.inputTokenDetails?.cacheWriteTokens??0;return{inputTokens:n.inputTokens+(e.inputTokens??0),outputTokens:n.outputTokens+(e.outputTokens??0),reasoningTokens:n.reasoningTokens+(e.reasoningTokens??0),totalTokens:n.totalTokens+(e.totalTokens??0),cost:n.cost+Vc(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function M2(n){return n.reduce((e,t)=>Uc(e,t.metadata?.usage),Wc())}const Dp={damping:.7,stiffness:.05,mass:1.25},Pp=70,Lp=1e3/60,_p=350;let Fs=!1;globalThis.document?.addEventListener("mousedown",()=>{Fs=!0});globalThis.document?.addEventListener("mouseup",()=>{Fs=!1});globalThis.document?.addEventListener("click",()=>{Fs=!1});const $p=(n={})=>{const[e,t]=M.useState(!1),[r,s]=M.useState(n.initial!==!1),[o,i]=M.useState(!1),l=M.useRef(null);l.current=n;const a=M.useCallback(()=>{if(!Fs)return!1;const b=window.getSelection();if(!b||!b.rangeCount)return!1;const k=b.getRangeAt(0);return k.commonAncestorContainer.contains(y.current)||y.current?.contains(k.commonAncestorContainer)},[]),c=M.useCallback(b=>{d.isAtBottom=b,s(b)},[]),u=M.useCallback(b=>{d.escapedFromLock=b,t(b)},[]),d=M.useMemo(()=>{let b;return{escapedFromLock:e,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return y.current?.scrollTop??0},set scrollTop(k){if(y.current){const{scrollBehavior:v}=getComputedStyle(y.current);v!=="auto"&&(y.current.style.scrollBehavior="auto"),y.current.scrollTop=k,d.ignoreScrollToTop=y.current.scrollTop,v!=="auto"&&(y.current.style.scrollBehavior=v)}},get targetScrollTop(){return!y.current||!x.current?0:y.current.scrollHeight-1-y.current.clientHeight},get calculatedTargetScrollTop(){if(!y.current||!x.current)return 0;const{targetScrollTop:k}=this;if(!n.targetScrollTop)return k;if(b?.targetScrollTop===k)return b.calculatedScrollTop;const v=Math.max(Math.min(n.targetScrollTop(k,{scrollElement:y.current,contentElement:x.current}),k),0);return b={targetScrollTop:k,calculatedScrollTop:v},requestAnimationFrame(()=>{b=void 0}),v},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Pp}}},[]),f=M.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),v=fo(l.current,b.animation),{ignoreEscapes:S=!1}=b;let w,C=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{w=Date.now()}):w=k+(b.duration??0);const T=async()=>{const N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;const{scrollTop:E}=d,j=performance.now(),L=(j-(d.lastTick??j))/Lp;if(d.animation||(d.animation={behavior:v,promise:N,ignoreEscapes:S}),d.animation.behavior===v&&(d.lastTick=j),a()||k>Date.now())return T();if(E<Math.min(C,d.calculatedTargetScrollTop)){if(d.animation?.behavior===v){if(v==="instant")return d.scrollTop=d.calculatedTargetScrollTop,T();d.velocity=(v.damping*d.velocity+v.stiffness*d.scrollDifference)/v.mass,d.accumulated+=d.velocity*L,d.scrollTop+=d.accumulated,d.scrollTop!==E&&(d.accumulated=0)}return T()}return w>Date.now()?(C=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:fo(l.current,l.current.resize),ignoreEscapes:S,duration:Math.max(0,w-Date.now())||void 0}):d.isAtBottom)});return N.then(E=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),E))};return b.wait!==!0&&(d.animation=void 0),d.animation?.behavior===v?d.animation.promise:T()},[c,a,d]),h=M.useCallback(()=>{u(!0),c(!1)},[u,c]),m=M.useCallback(({target:b})=>{if(b!==y.current)return;const{scrollTop:k,ignoreScrollToTop:v}=d;let{lastScrollTop:S=k}=d;d.lastScrollTop=k,d.ignoreScrollToTop=void 0,v&&v>k&&(S=v),i(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===v)return;if(a()){u(!0),c(!1);return}const w=k>S,C=k<S;if(d.animation?.ignoreEscapes){d.scrollTop=S;return}C&&(u(!0),c(!1)),w&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,a,d]),g=M.useCallback(({target:b,deltaY:k})=>{let v=b;for(;!["scroll","auto"].includes(getComputedStyle(v).overflow);){if(!v.parentElement)return;v=v.parentElement}v===y.current&&k<0&&y.current.scrollHeight>y.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),y=$l(b=>{y.current?.removeEventListener("scroll",m),y.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),x=$l(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([v])=>{const{height:S}=v.contentRect,w=S-(k??S);if(d.resizeDifference=w,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),i(d.isNearBottom),w>=0){const C=fo(l.current,k?l.current.resize:l.current.initial);f({animation:C,wait:!0,preserveScrollPosition:!0,duration:C==="instant"?void 0:_p})}else d.isNearBottom&&(u(!1),c(!0));k=S,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===w&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:x,scrollRef:y,scrollToBottom:f,stopScroll:h,isAtBottom:r||o,isNearBottom:o,escapedFromLock:e,state:d}};function $l(n,e){const t=M.useCallback(r=>(t.current=r,n(r)),e);return t}const uo=new Map;function fo(...n){const e={...Dp};let t=!1;for(const s of n){if(s==="instant"){t=!0;continue}typeof s=="object"&&(t=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const r=JSON.stringify(e);return uo.has(r)||uo.set(r,Object.freeze(e)),t?"instant":uo.get(r)}function zp(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Di(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function Pi(n,e){if(!e)return n;const t=`${zp(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function Bp(n,e){return Pi(n,e).replace(/[_-]/g," ").toLowerCase()}function Fp(n){const e={};for(const t of n.arguments??[])e[t.name]=t.required?Dl().min(1,"Required"):Dl();return wc(e)}function Hp(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Vp(n){const e=D.c(66),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:o}=n,i=M.useId();let l;if(e[0]!==t){const $=t?Fp(t):wc({});l=fh($),e[0]=t,e[1]=l}else l=e[1];const c=l;let u;e[2]!==o||e[3]!==t?(u=t?Hp(t,o):{},e[2]=o,e[3]=t,e[4]=u):u=e[4];let d;e[5]!==c||e[6]!==u?(d={resolver:c,defaultValues:u,mode:"onChange"},e[5]=c,e[6]=u,e[7]=d):d=e[7];const f=hh(d);let h;e[8]!==t?.arguments?(h=t?.arguments??[],e[8]=t?.arguments,e[9]=h):h=e[9];const m=h;let g;e[10]!==f||e[11]!==s||e[12]!==r?(g=async $=>{await s($),r(null),f.reset()},e[10]=f,e[11]=s,e[12]=r,e[13]=g):g=e[13];const y=g;let x;e[14]!==f||e[15]!==r?(x=$=>{$||(f.reset(),r(null))},e[14]=f,e[15]=r,e[16]=x):x=e[16];const b=x;if(!t)return null;let k;e[17]!==t._meta||e[18]!==t.name||e[19]!==t.title?(k=t.title||Bp(t.name,Di(t._meta)),e[17]=t._meta,e[18]=t.name,e[19]=t.title,e[20]=k):k=e[20];let v;e[21]!==k?(v=p.jsx(bp,{children:p.jsx("span",{className:"capitalize",children:k})}),e[21]=k,e[22]=v):v=e[22];let S;e[23]!==t.description?(S=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[23]=t.description,e[24]=S):S=e[24];let w;e[25]!==S||e[26]!==v?(w=p.jsxs(kp,{children:[v,S]}),e[25]=S,e[26]=v,e[27]=w):w=e[27];let C;e[28]!==f||e[29]!==y?(C=$=>{$.stopPropagation(),f.handleSubmit(y)($)},e[28]=f,e[29]=y,e[30]=C):C=e[30];let T;if(e[31]!==m||e[32]!==f.control||e[33]!==f.formState.isSubmitting){let $;e[35]!==f.control||e[36]!==f.formState.isSubmitting?($=F=>p.jsx(Tp,{control:f.control,name:F.name,render:G=>{const{field:Q}=G;return p.jsxs(Np,{children:[p.jsxs(Mp,{className:"text-xs",children:[F.name,F.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(Ep,{children:p.jsx(Op,{...Q,value:Q.value??"",required:F.required,placeholder:F.description??"",className:"h-9",disabled:f.formState.isSubmitting})}),p.jsx(Ap,{})]})}},F.name),e[35]=f.control,e[36]=f.formState.isSubmitting,e[37]=$):$=e[37],T=m.map($),e[31]=m,e[32]=f.control,e[33]=f.formState.isSubmitting,e[34]=T}else T=e[34];let N;e[38]!==b?(N=()=>b(!1),e[38]=b,e[39]=N):N=e[39];let E;e[40]!==f.formState.isSubmitting||e[41]!==N?(E=p.jsx(ir,{type:"button",variant:"ghost",onClick:N,disabled:f.formState.isSubmitting,children:"Cancel"}),e[40]=f.formState.isSubmitting,e[41]=N,e[42]=E):E=e[42];let j;e[43]!==f.formState.isSubmitting?(j=f.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(Fh,{size:"xs"}),"Loading..."]}):"Use prompt",e[43]=f.formState.isSubmitting,e[44]=j):j=e[44];let L;e[45]!==f.formState.isSubmitting||e[46]!==i||e[47]!==j?(L=p.jsx(ir,{type:"submit",form:i,disabled:f.formState.isSubmitting,children:j}),e[45]=f.formState.isSubmitting,e[46]=i,e[47]=j,e[48]=L):L=e[48];let I;e[49]!==E||e[50]!==L?(I=p.jsxs(Sp,{children:[E,L]}),e[49]=E,e[50]=L,e[51]=I):I=e[51];let P;e[52]!==i||e[53]!==C||e[54]!==T||e[55]!==I?(P=p.jsxs("form",{id:i,className:"space-y-4 py-4",autoComplete:"off",onSubmit:C,children:[T,I]}),e[52]=i,e[53]=C,e[54]=T,e[55]=I,e[56]=P):P=e[56];let R;e[57]!==f||e[58]!==P?(R=p.jsx(Cp,{...f,children:P}),e[57]=f,e[58]=P,e[59]=R):R=e[59];let z;e[60]!==w||e[61]!==R?(z=p.jsxs(vp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[w,R]}),e[60]=w,e[61]=R,e[62]=z):z=e[62];let B;return e[63]!==b||e[64]!==z?(B=p.jsx(wp,{open:!0,onOpenChange:b,children:z}),e[63]=b,e[64]=z,e[65]=B):B=e[65],B}function qc(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function Ye(n,e){return n==="output-error"||n==="output-denied"?"error":n==="approval-requested"?"approval":n==="input-streaming"||n==="input-available"||n==="output-available"&&e===!0?"loading":"idle"}function _n(n){if(n==null||typeof n!="object")return;const e=n;if(e.structuredContent&&typeof e.structuredContent=="object")return e.structuredContent;if(Array.isArray(e.content)){const t=e.content[0];if(t?.type==="text"&&typeof t.text=="string")try{return JSON.parse(t.text)}catch{return}return}return n}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function Kc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Kc(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Jc(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=Jc(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class A{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new A(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new A(r,s)}cutByIndex(e,t){return e==t?A.empty:e==0&&t==this.content.length?this:new A(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new A(s,o)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Kc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Jc(this,e,t,r)}findIndex(e){if(e==0)return Ar(0,e);if(e==this.size)return Ar(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Ar(t+1,o):Ar(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return A.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new A(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new A(t||e,r)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const ho={index:0,offset:0};function Ar(n,e){return ho.index=n,ho.offset=e,ho}function Jr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Jr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Jr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ee=class Uo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Jr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Uo.none;if(e instanceof Uo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};ee.none=[];class Gr extends Error{}class _{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Xc(this.content,e+this.openStart,t);return r&&new _(r,this.openStart,this.openEnd)}removeBetween(e,t){return new _(Gc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return _.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _(A.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new _(e,r,s)}}_.empty=new _(A.empty,0,0);function Gc(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Gc(o.content,e-s-1,t-s-1)))}function Xc(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Xc(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function Wp(n,e,t){if(t.openStart>n.depth)throw new Gr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Gr("Inconsistent open depths");return Yc(n,e,t,0)}function Yc(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=Yc(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Xt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Up(t,n);return Xt(o,Zc(n,i,l,e,r))}else return Xt(o,Xr(n,e,r))}function Qc(n,e){if(!e.type.compatibleContent(n.type))throw new Gr("Cannot join "+e.type.name+" onto "+n.type.name)}function qo(n,e,t){let r=n.node(t);return Qc(r,e.node(t)),r}function Gt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Gn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Gt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Gt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Gt(e.nodeBefore,r)}function Xt(n,e){return n.type.checkContent(e),n.copy(e)}function Zc(n,e,t,r,s){let o=n.depth>s&&qo(n,e,s+1),i=r.depth>s&&qo(t,r,s+1),l=[];return Gn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(Qc(o,i),Gt(Xt(o,Zc(n,e,t,r,s+1)),l)):(o&&Gt(Xt(o,Xr(n,e,s+1)),l),Gn(e,t,s,l),i&&Gt(Xt(i,Xr(t,r,s+1)),l)),Gn(r,null,s,l),new A(l)}function Xr(n,e,t){let r=[];if(Gn(null,n,t,r),n.depth>t){let s=qo(n,e,t+1);Gt(Xt(s,Xr(n,e,t+1)),r)}return Gn(e,null,t,r),new A(r)}function Up(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(A.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class lr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ee.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Yr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new lr(t,r,o)}static resolveCached(e,t){let r=zl.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else zl.set(e,r=new qp);let s=r.elts[r.i]=lr.resolve(e,t);return r.i=(r.i+1)%Kp,s}}class qp{constructor(){this.elts=[],this.i=0}}const Kp=12,zl=new WeakMap;class Yr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Jp=Object.create(null);class Xe{constructor(e,t,r,s=ee.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Jr(this.attrs,t||e.defaultAttrs||Jp)&&ee.sameSet(this.marks,r||ee.none)}copy(e=null){return e==this.content?this:new Xe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Xe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return _.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new _(c,s.depth-i,o.depth-i)}replace(e,t,r){return Wp(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return lr.resolveCached(this,e)}resolveNoCache(e){return lr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),eu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=A.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ee.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ee.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=A.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}Xe.prototype.text=void 0;class Qr extends Xe{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):eu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function eu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class sn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Gp(e,t);if(r.next==null)return sn.empty;let s=tu(r);r.next&&r.err("Unexpected trailing text");let o=nm(tm(s));return rm(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
|
|
2
2
|
`)}}sn.empty=new sn(!0);class Gp{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function tu(n){let e=[];do e.push(Xp(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xp(n){let e=[];do e.push(Yp(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Yp(n){let e=em(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Qp(n,e);else break;return e}function Bl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Qp(n,e){let t=Bl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Bl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Zp(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function em(n){if(n.eat("(")){let e=tu(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Zp(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function tm(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),s(o(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function nu(n,e){return e-n}function Fl(n,e){let t=[];return r(e),t.sort(nu);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function nm(n){let e=Object.create(null);return t(Fl(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Fl(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new sn(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(nu);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function rm(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ru(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function su(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function ou(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function iu(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new om(n,r,e[r]);return t}let Hl=class lu{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=iu(e,r.attrs),this.defaultAttrs=ru(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==sn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:su(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xe(this,this.computeAttrs(e),A.from(t),ee.setFrom(r))}createChecked(e=null,t,r){return t=A.from(t),this.checkContent(t),new Xe(this,this.computeAttrs(e),t,ee.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=A.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(A.empty,!0);return o?new Xe(this,e,t.append(o),ee.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ou(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:ee.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new lu(o,t,i));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function sm(n,e,t){let r=t.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class om{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?sm(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Hs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=iu(e,s.attrs),this.excluded=null;let o=ru(this.attrs);this.instance=o?new ee(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ee(this,su(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Hs(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){ou(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class au{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=xe.from(e.nodes),t.marks=xe.from(e.marks||{}),this.nodes=Hl.compile(this.spec.nodes,this),this.marks=Hs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=sn.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?Vl(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:Vl(this,i.split(" "))}this.nodeFromJSON=s=>Xe.fromJSON(this,s),this.markFromJSON=s=>ee.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Hl){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new Qr(r,r.defaultAttrs,e,ee.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Vl(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function im(n){return n.tag!=null}function lm(n){return n.style!=null}class Et{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(im(s))this.tags.push(s);else if(lm(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new Ul(this,t,!1);return r.addAll(e,ee.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ul(this,t,!0);return r.addAll(e,ee.none,t.from,t.to),_.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(um(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ql(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ql(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Et(e,Et.schemaRules(e)))}}const cu={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},am={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},uu={ol:!0,ul:!0},ar=1,Ko=2,Xn=4;function Wl(n,e,t){return e!=null?(e?ar:0)|(e==="full"?Ko:0):n&&n.whitespace=="pre"?ar|Ko:t&~Xn}class Or{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=ee.none,this.match=o||(i&Xn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(A.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ar)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=A.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!cu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ul{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=Wl(null,t.preserveWhitespace,0)|(r?Xn:0);s?o=new Or(s.type,s.attrs,ee.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new Or(null,null,ee.none,!0,null,i):o=new Or(e.schema.topNodeType,null,ee.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&Ko?"full":this.localPreserveWS||(s.options&ar)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;uu.hasOwnProperty(i)&&this.parser.normalizeLists&&cm(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:am.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(cu.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=ee.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Kl(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Wl(e,o,i.options);i.options&Xn&&i.content.length==0&&(l|=Xn);let a=ee.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Kl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Or(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=ar)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function cm(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&uu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function um(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ql(n){let e={};for(let t in n)e[t]=n[t];return e}function Kl(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class dn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=po(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Hr(po(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Hr(po(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Hr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new dn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jl(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Jl(e.marks)}}function Jl(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function po(n){return n.document||window.document}const Gl=new WeakMap;function dm(n){let e=Gl.get(n);return e===void 0&&Gl.set(n,e=fm(n)),e}function fm(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Hr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=dm(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:m}=Hr(n,f,t,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const du=65535,fu=Math.pow(2,16);function hm(n,e){return n+e*fu}function Xl(n){return n&du}function pm(n){return(n-(n&du))/fu}const hu=1,pu=2,Vr=4,mu=8;class Jo{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&mu)>0}get deletedBefore(){return(this.delInfo&(hu|Vr))>0}get deletedAfter(){return(this.delInfo&(pu|Vr))>0}get deletedAcross(){return(this.delInfo&Vr)>0}}class _e{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&_e.empty)return _e.empty}recover(e){let t=0,r=Xl(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+pm(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(r)return h;let m=e==(t<0?a:d)?null:hm(l/3,e-a),g=e==a?pu:e==d?hu:Vr;return(t<0?e!=a:e!=d)&&(g|=mu),new Jo(h,g,m)}s+=u-c}return r?e+s:new Jo(e+s,0,null)}touches(e,t){let r=0,s=Xl(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new _e(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?_e.empty:new _e(e<0?[0,-e,0]:[0,0,e])}}_e.empty=new _e([]);class cr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new cr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new cr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Jo(e,s,null)}}const mo=Object.create(null);class Me{getMap(){return _e.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=mo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in mo)throw new RangeError("Duplicate use of step JSON ID "+e);return mo[e]=t,t.prototype.jsonID=e,t}}class ue{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ue(e,null)}static fail(e){return new ue(null,e)}static fromReplace(e,t,r,s){try{return ue.ok(e.replace(t,r,s))}catch(o){if(o instanceof Gr)return ue.fail(o.message);throw o}}}function Li(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Li(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return A.fromArray(r)}class Ct extends Me{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new _(Li(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,o)}invert(){return new Ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ct(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ct&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ct(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ct(t.from,t.to,e.markFromJSON(t.mark))}}Me.jsonID("addMark",Ct);class Ge extends Me{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new _(Li(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return ue.fromReplace(e,this.from,this.to,r)}invert(){return new Ct(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ge(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ge(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ge(t.from,t.to,e.markFromJSON(t.mark))}}Me.jsonID("removeMark",Ge);class Tt extends Me{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new _(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new Tt(this.pos,t.marks[s]);return new Tt(this.pos,this.mark)}}return new on(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Tt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Tt(t.pos,e.markFromJSON(t.mark))}}Me.jsonID("addNodeMark",Tt);class on extends Me{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ue.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ue.fromReplace(e,this.pos,this.pos+1,new _(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Tt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new on(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new on(t.pos,e.markFromJSON(t.mark))}}Me.jsonID("removeNodeMark",on);class ce extends Me{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Go(e,this.from,this.to)?ue.fail("Structure replace would overwrite content"):ue.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new _e([this.from,this.to-this.from,this.slice.size])}invert(e){return new ce(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&ce.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new ce(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ce)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?_.empty:new _(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ce(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?_.empty:new _(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ce(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ce(t.from,t.to,_.fromJSON(e,t.slice),!!t.structure)}}ce.MAP_BIAS=1;Me.jsonID("replace",ce);class ge extends Me{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Go(e,this.from,this.gapFrom)||Go(e,this.gapTo,this.to)))return ue.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ue.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ue.fromReplace(e,this.from,this.to,r):ue.fail("Content does not fit in gap")}getMap(){return new _e([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ge(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new ge(t.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ge(t.from,t.to,t.gapFrom,t.gapTo,_.fromJSON(e,t.slice),t.insert,!!t.structure)}}Me.jsonID("replaceAround",ge);function Go(n,e,t){let r=n.resolve(e),s=t-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function mm(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=h:s.push(i=new Ge(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new Ct(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function gm(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof Hs){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==o-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new Ge(i.from,i.to,i.style)))}function _i(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new ce(l,u,_.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Ge(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new _(A.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new ce(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(A.empty,!0);n.replace(l,l,new _(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function ym(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function $n(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!ym(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function xm(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,u=A.empty,d=0;for(let m=o,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=A.from(r.node(m).copy(u)),d++):a--;let f=A.empty,h=0;for(let m=o,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=A.from(s.node(m).copy(f)),h++):c++;n.step(new ge(a,c,i,l,new _(u.append(f),d,h),u.size-d,!0))}function $i(n,e,t=null,r=n){let s=bm(n,e),o=s&&km(r,e);return o?s.map(Yl).concat({type:e,attrs:t}).concat(o.map(Yl)):null}function Yl(n){return{type:n,attrs:null}}function bm(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function km(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Sm(n,e,t){let r=A.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=A.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new ge(s,o,s,o,new _(r,0,0),t.length,!0))}function vm(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&wm(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&yu(n,i,l,o),_i(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return n.step(new ge(d,f,d+1,f-1,new _(A.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&gu(n,i,l,o),!1}})}function gu(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function yu(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
@@ -82,7 +82,7 @@ img.ProseMirror-separator {
|
|
|
82
82
|
display: block;
|
|
83
83
|
}`;function zy(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var By=class extends Ny{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:ry,createMappablePosition:sy},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:o})=>this.options.onDrop(r,s,o)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=Cd(e,this.options.autofocus);this.editorState=wn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=zy($y,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=Ad(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;t=t.filter(i=>!i.key.startsWith(o))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[qd,Hd.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Vd,Jd,Gd,Yd,Ud,Xd,Wd,Qd.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s?.type));this.extensionManager=new to(r,this)}createCommandManager(){this.commandManager=new Xs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=li(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=li(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=t?this.extensionManager.dispatchTransaction(r):r,o=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(o);this.editorView=new bd(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Dd(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return ey(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sl(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
|
|
84
84
|
|
|
85
|
-
`,textSerializers:t={}}=n||{};return J0(this.state.doc,{blockSeparator:e,textSerializers:{...jd(this.schema),...t}})}get isEmpty(){return Zs(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new _y(e,this)}get $doc(){return this.$pos(0)}};function Rn(n){return new eo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=Y(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(ol(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&o.delete(u,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Fy(n){return new eo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=Y(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function ci(n){return new eo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=Y(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function jn(n){return new eo({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=Y(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&$i(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(y=>h.includes(y.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&_t(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)},undoable:n.undoable})}function Hy(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof V){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function
|
|
85
|
+
`,textSerializers:t={}}=n||{};return J0(this.state.doc,{blockSeparator:e,textSerializers:{...jd(this.schema),...t}})}get isEmpty(){return Zs(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new _y(e,this)}get $doc(){return this.$pos(0)}};function Rn(n){return new eo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=Y(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(ol(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&o.delete(u,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Fy(n){return new eo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=Y(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function ci(n){return new eo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=Y(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function jn(n){return new eo({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=Y(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&$i(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(y=>h.includes(y.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&_t(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)},undoable:n.undoable})}function Hy(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof V){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function E2(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Vy={};el(Vy,{createAtomBlockMarkdownSpec:()=>Wy,createBlockMarkdownSpec:()=>Uy,createInlineMarkdownSpec:()=>Jy,parseAttributes:()=>ll,parseIndentedBlocks:()=>ui,renderNestedMarkdownContent:()=>cl,serializeAttributes:()=>al});function ll(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function al(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function Wy(n){const{nodeName:e,name:t,parseAttributes:r=ll,serializeAttributes:s=al,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...o,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",y=r(g);if(!i.find(b=>!(b in y)))return{type:e,raw:m[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Uy(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=ll,serializeAttributes:o=al,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,u=d=>{if(!a)return d;const f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const g=r(d);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const m={...i,...d.attributes};return f.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),m=(f=d.match(h))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,h){var m;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=d.match(g);if(!y)return;const[x,b=""]=y,k=s(b);let v=1;const S=x.length;let w="";const C=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(S);for(C.lastIndex=0;;){const N=C.exec(T);if(N===null)break;const E=N.index,j=N[1];if(!((m=N[2])!=null&&m.endsWith(":::"))){if(j)v+=1;else if(v-=1,v===0){const L=T.slice(0,E);w=L.trim();const I=d.slice(0,S+E+N[0].length);let P=[];if(w)if(l==="block")for(P=h.blockTokens(L),P.forEach(R=>{R.text&&(!R.tokens||R.tokens.length===0)&&(R.tokens=h.inlineTokens(R.text))});P.length>0;){const R=P[P.length-1];if(R.type==="paragraph"&&(!R.text||R.text.trim()===""))P.pop();else break}else P=h.inlineTokens(w);return{type:e,raw:I,attributes:k,content:w,tokens:P}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=o(h),g=m?` {${m}}`:"",y=f.renderChildren(d.content||[],`
|
|
86
86
|
|
|
87
87
|
`);return`:::${c}${g}
|
|
88
88
|
|
|
@@ -99,7 +99,7 @@ ${y}
|
|
|
99
99
|
`);a+=c.type==="paragraph"?`
|
|
100
100
|
|
|
101
101
|
${m}`:`
|
|
102
|
-
${m}`}}),a}function Gy(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,u,n.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var Ie=class Zd extends il{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Zd(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Xy=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),v=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,S=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+v,f=k.y-b.y+S}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=V.create(a.state.doc,g),x=a.state.tr.setSelection(y);a.dispatch(x)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=V.isSelectable(this.node),d=n.type==="copy",f=n.type==="paste",h=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(pr()||ii())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function cn(n){return new Iy({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=Y(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(ol(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Yy,getOwnPropertySymbols:Qy}=Object,{hasOwnProperty:Zy}=Object.prototype;function Oo(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function Lr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function ex(n){return n?.[Symbol.toStringTag]}function Ka(n){return Yy(n).concat(Qy(n))}const tx=Object.hasOwn||((n,e)=>Zy.call(n,e));function hn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const nx="__v",rx="__o",sx="_owner",{getOwnPropertyDescriptor:Ja,keys:Ga}=Object;function ox(n,e){return n.byteLength===e.byteLength&&ls(new Uint8Array(n),new Uint8Array(e))}function ix(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function lx(n,e){return n.byteLength===e.byteLength&&ls(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function ax(n,e){return hn(n.getTime(),e.getTime())}function cx(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function ux(n,e){return n===e}function Xa(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,d,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const dx=hn;function fx(n,e,t){const r=Ga(n);let s=r.length;if(Ga(e).length!==s)return!1;for(;s-- >0;)if(!ef(n,e,t,r[s]))return!1;return!0}function Fn(n,e,t){const r=Ka(n);let s=r.length;if(Ka(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!ef(n,e,t,o)||(i=Ja(n,o),l=Ja(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function hx(n,e){return hn(n.valueOf(),e.valueOf())}function px(n,e){return n.source===e.source&&n.flags===e.flags}function Ya(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ls(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function mx(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function ef(n,e,t,r){return(r===sx||r===rx||r===nx)&&(n.$$typeof||e.$$typeof)?!0:tx(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const gx="[object ArrayBuffer]",yx="[object Arguments]",xx="[object Boolean]",bx="[object DataView]",kx="[object Date]",Sx="[object Error]",vx="[object Map]",wx="[object Number]",Cx="[object Object]",Tx="[object RegExp]",Nx="[object Set]",Mx="[object String]",Ex={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Ax="[object URL]",Ox=Object.prototype.toString;function Ix({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(y,x,b){if(y===x)return!0;if(y==null||x==null)return!1;const k=typeof y;if(k!==typeof x)return!1;if(k!=="object")return k==="number"?l(y,x,b):k==="function"?o(y,x,b):!1;const v=y.constructor;if(v!==x.constructor)return!1;if(v===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(v===Date)return r(y,x,b);if(v===RegExp)return u(y,x,b);if(v===Map)return i(y,x,b);if(v===Set)return d(y,x,b);const S=Ox.call(y);if(S===kx)return r(y,x,b);if(S===Tx)return u(y,x,b);if(S===vx)return i(y,x,b);if(S===Nx)return d(y,x,b);if(S===Cx)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(S===Ax)return h(y,x,b);if(S===Sx)return s(y,x,b);if(S===yx)return a(y,x,b);if(Ex[S])return f(y,x,b);if(S===gx)return n(y,x,b);if(S===bx)return t(y,x,b);if(S===xx||S===wx||S===Mx)return c(y,x,b);if(m){let w=m[S];if(!w){const C=ex(y);C&&(w=m[C])}if(w)return w(y,x,b)}return!1}}function Rx({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:ox,areArraysEqual:t?Fn:ix,areDataViewsEqual:lx,areDatesEqual:ax,areErrorsEqual:cx,areFunctionsEqual:ux,areMapsEqual:t?Oo(Xa,Fn):Xa,areNumbersEqual:dx,areObjectsEqual:t?Fn:fx,arePrimitiveWrappersEqual:hx,areRegExpsEqual:px,areSetsEqual:t?Oo(Ya,Fn):Ya,areTypedArraysEqual:t?Oo(ls,Fn):ls,areUrlsEqual:mx,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Lr(r.areArraysEqual),o=Lr(r.areMapsEqual),i=Lr(r.areObjectsEqual),l=Lr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function jx(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function Dx({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:u}=t();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const Px=zt();zt({strict:!0});zt({circular:!0});zt({circular:!0,strict:!0});zt({createInternalComparator:()=>hn});zt({strict:!0,createInternalComparator:()=>hn});zt({circular:!0,createInternalComparator:()=>hn});zt({circular:!0,createInternalComparator:()=>hn,strict:!0});function zt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=Rx(n),i=Ix(o),l=t?t(i):jx(i);return Dx({circular:e,comparator:i,createState:r,equals:l,strict:s})}var Lx=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},_x=({contentComponent:n})=>{const e=Cc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function $x(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:gh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var zx=class extends en.Component{constructor(n){var e;super(n),this.editorContentRef=en.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=$x(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:Lx(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(_x,{contentComponent:n.contentComponent})]})}},Bx=M.forwardRef((n,e)=>{const t=en.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return en.createElement(zx,{key:t,innerRef:e,...n})}),tf=en.memo(Bx),Fx=typeof window<"u"?M.useLayoutEffect:M.useEffect,Hx=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Vx(n){var e;const[t]=M.useState(()=>new Hx(n.editor)),r=ph.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:Px);return Fx(()=>t.watch(n.editor),[n.editor,t]),M.useDebugValue(r),r}var Wx=!1,di=typeof window>"u",Ux=di||!!(typeof window<"u"&&window.next),qx=class nf{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?di||Ux?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new By(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?nf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Kx(n={},e=[]){const t=M.useRef(n);t.current=n;const[r]=M.useState(()=>new qx(t)),s=Cc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(s),M.useEffect(r.onRender(e)),Vx({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var ul=M.createContext({editor:null});ul.Consumer;var N2=()=>M.useContext(ul),rf=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Jx=()=>M.useContext(rf),sf=en.forwardRef((n,e)=>{const{onDragStart:t}=Jx(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Qa(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function Za(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Gx(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Xx(n){if(Qa(n)||Za(n))return!0;if(Gx(n)){const e=n.type;if(e)return Qa(e)||Za(e)}return!1}function Yx(){try{if(M.version)return parseInt(M.version.split(".")[0],10)>=19}catch{}return!1}var Qx=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?mh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=Yx(),o=Xx(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};en.createContext({markViewContentRef:()=>{}});var Zx=class extends Xy{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const n=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(t,r,s){var o;return r==="storage"?(o=n.storage[e.name])!=null?o:{}:Reflect.get(t,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:M.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=M.memo(a=>p.jsx(rf.Provider,{value:r,children:M.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Qx(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=In(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function of(n,e){return t=>t.editor.contentComponent?new Zx(n,t,e):{}}var dl=M.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});dl.displayName="TiptapContext";var eb=()=>M.useContext(dl);function lf({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=M.useMemo(()=>({editor:r}),[r]),o=M.useMemo(()=>({editor:r}),[r]);return p.jsx(ul.Provider,{value:o,children:p.jsx(dl.Provider,{value:s,children:t})})}lf.displayName="Tiptap";function af({...n}){const{editor:e}=eb();return p.jsx(tf,{editor:e,...n})}af.displayName="Tiptap.Content";Object.assign(lf,{Content:af});function tb(n){return n.storage.mention}function M2(n,e,t){n.chain().focus().insertContentAt(e,[cf(t),{type:"text",text:" "}]).run()}function cf(n){return{type:"mention",attrs:n}}function nb(n){const e=D.c(19),{node:t,selected:r,view:s,editor:o,getPos:i}=n,{name:l,char:a,kind:c,id:u,args:d}=t.attrs,f=r&&s.editable,h=a==="@",m=s.editable&&a==="/"&&(c==="prompt"||c==null);let g;e[0]!==d||e[1]!==o||e[2]!==i||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const E=tb(o)?.onEditChip;if(!E||typeof i!="function")return;const j=i();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),E({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=o,e[2]=i,e[3]=u,e[4]=m,e[5]=l,e[6]=g):g=e[6];const y=g,x=m?"cursor-pointer":"cursor-default",b=h?"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",k=f&&"outline-2 outline-blue-300 outline-offset-0",v=m&&"hover:brightness-95";let S;e[7]!==x||e[8]!==b||e[9]!==k||e[10]!==v?(S=X("px-1 py-1 rounded","inline-flex items-center gap-1",x,"select-none","text-xs font-light",b,k,v,"capitalize"),e[7]=x,e[8]=b,e[9]=k,e[10]=v,e[11]=S):S=e[11];let w;e[12]!==l?(w=l?qc(l):"",e[12]=l,e[13]=w):w=e[13];let C;return e[14]!==a||e[15]!==y||e[16]!==S||e[17]!==w?(C=p.jsxs(sf,{onClick:y,className:S,children:[a,w]}),e[14]=a,e[15]=y,e[16]=S,e[17]=w,e[18]=C):C=e[18],C}const rb=Ie.create({name:"mention",group:"inline",inline:!0,atom:!0,addStorage(){return{onEditChip:null}},addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},char:{default:"/",parseHTML:n=>n.getAttribute("data-char")||"/",renderHTML:n=>n.char?{"data-char":n.char}:{}},metadata:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:n=>n.metadata?{"data-metadata":JSON.stringify(n.metadata)}:{}},kind:{default:null,parseHTML:n=>n.getAttribute("data-kind")||null,renderHTML:n=>n.kind?{"data-kind":n.kind}:{}},args:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-args")||"null")}catch{return null}},renderHTML:n=>n.args?{"data-args":JSON.stringify(n.args)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"mention"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.char&&(t["data-char"]=n.attrs.char),n.attrs.metadata&&(t["data-metadata"]=JSON.stringify(n.attrs.metadata)),n.attrs.kind&&(t["data-kind"]=n.attrs.kind),n.attrs.args&&(t["data-args"]=JSON.stringify(n.attrs.args)),["span",{...e,...t}]},renderText({node:n}){const e=n.attrs.char??"@",t=n.attrs.name??"";return`${e}${t}`},addNodeView(){return of(nb)}}),sb=/^mcp__[a-zA-Z0-9_-]+__/;function uf(n){return n.replace(sb,"")}function no(n){const e=D.c(18),{id:t,part:r,copyable:s,extraActions:o,alwaysShowActions:i,animate:l}=n,a=s===void 0?!1:s,c=i===void 0?!1:i,u=l===void 0?!1:l,{handleCopy:d}=Dc(),[f,h]=M.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{yh("chat_message_copied",{message_id:t,chars:r.text.length}),await d(r.text),h(!0),setTimeout(()=>h(!1),2e3)},e[0]=d,e[1]=t,e[2]=r.text,e[3]=m):m=e[3];const g=m,y=a&&o,x=y||o;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Ii,{id:t,text:r.text,animate:u}),e[4]=u,e[5]=t,e[6]=r.text,e[7]=b):b=e[7];let k;e[8]!==c||e[9]!==o||e[10]!==g||e[11]!==f||e[12]!==x||e[13]!==y?(k=x&&p.jsxs("div",{className:X("flex w-full items-center gap-2 text-sm text-muted-foreground transition-all duration-200 mt-1 py-1",c?"opacity-100":"opacity-0 pointer-events-none group-hover/part:opacity-100 group-hover/part:pointer-events-auto"),children:[o,y&&o&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),y&&p.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground [@media(hover:hover)]:hover:text-foreground transition-colors active:scale-[0.97]","aria-label":"Copy message",children:f?p.jsx(Ai,{className:"size-4"}):p.jsx(Rc,{className:"size-4"})})]}),e[8]=c,e[9]=o,e[10]=g,e[11]=f,e[12]=x,e[13]=y,e[14]=k):k=e[14];let v;return e[15]!==b||e[16]!==k?(v=p.jsxs("div",{className:"group/part relative",children:[b,k]}),e[15]=b,e[16]=k,e[17]=v):v=e[17],v}function E2(n,e,t){n.chain().focus().insertContentAt(e,[ob(t),{type:"text",text:" "}]).run()}function ob(n){return{type:"file",attrs:n}}function ib(n){const e=D.c(17),{node:t,selected:r,view:s}=n,{name:o,mimeType:i,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==i?(c=i.startsWith("image/"),e[0]=i,e[1]=c):c=e[1];const u=c,d=a&&"outline-2 outline-blue-300 outline-offset-0";let f;e[2]!==d?(f=X("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-muted text-muted-foreground",d),e[2]=d,e[3]=f):f=e[3];let h;e[4]!==o?(h=p.jsx(tn,{asChild:!0,children:p.jsx("span",{children:o})}),e[4]=o,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==i||e[9]!==o?(m=p.jsx(nn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${i};base64,${l}`,alt:o,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:o}),p.jsx("div",{className:"text-muted-foreground mt-1",children:i})]})}),e[6]=l,e[7]=u,e[8]=i,e[9]=o,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(rn,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13];let y;return e[14]!==f||e[15]!==g?(y=p.jsx(sf,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=y):y=e[16],y}const lb=Ie.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},mimeType:{default:null,parseHTML:n=>n.getAttribute("data-mime-type")||null,renderHTML:n=>n.mimeType?{"data-mime-type":n.mimeType}:{}},size:{default:0,parseHTML:n=>{const e=n.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:n=>n.size?{"data-size":String(n.size)}:{}},data:{default:null,parseHTML:n=>n.getAttribute("data-data")||null,renderHTML:n=>n.data?{"data-data":n.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"file"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.mimeType&&(t["data-mime-type"]=n.attrs.mimeType),n.attrs.size&&(t["data-size"]=String(n.attrs.size)),n.attrs.data&&(t["data-data"]=n.attrs.data),["span",{...e,...t}]},renderText({node:n}){return`[${n.attrs.name??""}]`},addNodeView(){return of(ib)}});function ab(n={}){return new re({view(e){return new cb(e,n)}})}class cb{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=bu(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class le extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return le.valid(r)?new le(r):q.near(r)}content(){return _.empty}eq(e){return e instanceof le&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new le(e.resolve(t.pos))}getBookmark(){return new fl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ub(e)||!db(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&le.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(le.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(le.valid(l))return l}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;q.jsonID("gapcursor",le);class fl{constructor(e){this.pos=e}map(e){return new fl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return le.valid(t)?new le(t):q.near(t)}}function df(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function ub(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||df(s.type))return!0;if(s.inlineContent)return!1}}return!0}function db(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||df(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fb(){return new re({props:{decorations:gb,createSelectionBetween(n,e,t){return e.pos==t.pos&&le.valid(t)?new le(t):null},handleClick:pb,handleKeyDown:hb,handleDOMEvents:{beforeinput:mb}}})}const hb=kd({ArrowLeft:_r("horiz",-1),ArrowRight:_r("horiz",1),ArrowUp:_r("vert",-1),ArrowDown:_r("vert",1)});function _r(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof W){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=le.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new le(c))),!0):!1}}function pb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!le.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&V.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new le(r))),!0)}function mb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof le))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=A.empty;for(let i=r.length-1;i>=0;i--)s=A.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new _(s,0,0));return o.setSelection(W.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function gb(n){if(!(n.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ne.create(n.doc,[Ee.widget(n.selection.head,e,{key:"gapcursor"})])}var as=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<as&&this.leafAppend(e)||this.length<as&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new yb(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new ff(e):ye.empty};var ff=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=as)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=as)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new ff([]);var yb=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ye);const xb=500;class Je{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new Qe(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new Qe(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new Je(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Qe(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>kb&&(l=bb(l,c),i-=c),new Je(l.append(o),i)}remapping(e,t){let r=new cr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Je(this.items.append(e.map(t=>new Qe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,r.push(new Qe(m,g,y))}else r.push(new Qe(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new Qe(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new Je(u,l);return d.emptyItemCount()>xb&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new Qe(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new Je(ye.from(s.reverse()),o)}}Je.empty=new Je(ye.empty,0);function bb(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class Qe{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Qe(t.getMap().invert(),t,this.selection)}}}class kt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const kb=20;function Sb(n,e,t,r){let s=t.getMeta(Zt),o;if(s)return s.historyState;t.getMeta(Cb)&&(n=new kt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Zt))return i.getMeta(Zt).redo?new kt(n.done.addTransform(t,void 0,r,Ur(e)),n.undone,ec(t.mapping.maps),n.prevTime,n.prevComposition):new kt(n.done,n.undone.addTransform(t,void 0,r,Ur(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!vb(t,n.prevRanges)),c=i?Io(n.prevRanges,t.mapping):ec(t.mapping.maps);return new kt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ur(e)),Je.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new kt(n.done.rebased(t,o),n.undone.rebased(t,o),Io(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new kt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Io(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function vb(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function ec(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function Io(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function wb(n,e,t){let r=Ur(e),s=Zt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new kt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Zt,{redo:t,historyState:a})}let Ro=!1,tc=null;function Ur(n){let e=n.plugins;if(tc!=e){Ro=!1,tc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ro=!0;break}}return Ro}const Zt=new me("history"),Cb=new me("closeHistory");function Tb(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Zt,state:{init(){return new kt(Je.empty,Je.empty,null,0,-1)},apply(e,t,r){return Sb(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?pf:r=="historyRedo"?mf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function hf(n,e){return(t,r)=>{let s=Zt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=wb(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const pf=hf(!1,!0),mf=hf(!0,!0);ae.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new me("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Nb=ae.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ab(this.options)]}});ae.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return ne.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(Ee.node(c,c+a.nodeSize,{class:this.options.className}))}),ne.create(n,o)}}})]}});var Mb=ae.create({name:"gapCursor",addProseMirrorPlugins(){return[fb()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Y(H(n,"allowGapCursor",t)))!=null?e:null}}}),nc="placeholder";function Eb(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var A2=ae.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:nc,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${Eb(this.options.dataAttribute)}`:`data-${nc}`;return[new re({key:new me("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,o=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&Zs(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const f=Ee.node(a,a+l.nodeSize,{class:d.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});o.push(f)}return this.options.includeChildren}),ne.create(e,o)}}})]}});ae.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new me("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Ld(t.selection)||n.view.dragging?null:ne.create(t.doc,[Ee.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function rc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Ab=ae.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new me(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!rc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!rc({node:i,types:r})}}})]}}),Ob=ae.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>pf(n,e),redo:()=>({state:n,dispatch:e})=>mf(n,e)}},addProseMirrorPlugins(){return[Tb(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),cs=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Ib=/^\s*>\s$/,Rb=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return cs("blockquote",{...fe(this.options.HTMLAttributes,n),children:cs("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((s,o)=>{var i,l;const u=((l=(i=e.renderChild)==null?void 0:i.call(e,s,o))!=null?l:e.renderChildren([s])).split(`
|
|
102
|
+
${m}`}}),a}function Gy(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,u,n.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var Ie=class Zd extends il{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Zd(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Xy=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),v=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,S=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+v,f=k.y-b.y+S}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=V.create(a.state.doc,g),x=a.state.tr.setSelection(y);a.dispatch(x)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=V.isSelectable(this.node),d=n.type==="copy",f=n.type==="paste",h=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(pr()||ii())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function cn(n){return new Iy({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=Y(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(ol(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Yy,getOwnPropertySymbols:Qy}=Object,{hasOwnProperty:Zy}=Object.prototype;function Oo(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function Lr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function ex(n){return n?.[Symbol.toStringTag]}function Ka(n){return Yy(n).concat(Qy(n))}const tx=Object.hasOwn||((n,e)=>Zy.call(n,e));function hn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const nx="__v",rx="__o",sx="_owner",{getOwnPropertyDescriptor:Ja,keys:Ga}=Object;function ox(n,e){return n.byteLength===e.byteLength&&ls(new Uint8Array(n),new Uint8Array(e))}function ix(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function lx(n,e){return n.byteLength===e.byteLength&&ls(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function ax(n,e){return hn(n.getTime(),e.getTime())}function cx(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function ux(n,e){return n===e}function Xa(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,d,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const dx=hn;function fx(n,e,t){const r=Ga(n);let s=r.length;if(Ga(e).length!==s)return!1;for(;s-- >0;)if(!ef(n,e,t,r[s]))return!1;return!0}function Fn(n,e,t){const r=Ka(n);let s=r.length;if(Ka(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!ef(n,e,t,o)||(i=Ja(n,o),l=Ja(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function hx(n,e){return hn(n.valueOf(),e.valueOf())}function px(n,e){return n.source===e.source&&n.flags===e.flags}function Ya(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ls(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function mx(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function ef(n,e,t,r){return(r===sx||r===rx||r===nx)&&(n.$$typeof||e.$$typeof)?!0:tx(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const gx="[object ArrayBuffer]",yx="[object Arguments]",xx="[object Boolean]",bx="[object DataView]",kx="[object Date]",Sx="[object Error]",vx="[object Map]",wx="[object Number]",Cx="[object Object]",Tx="[object RegExp]",Nx="[object Set]",Mx="[object String]",Ex={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Ax="[object URL]",Ox=Object.prototype.toString;function Ix({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(y,x,b){if(y===x)return!0;if(y==null||x==null)return!1;const k=typeof y;if(k!==typeof x)return!1;if(k!=="object")return k==="number"?l(y,x,b):k==="function"?o(y,x,b):!1;const v=y.constructor;if(v!==x.constructor)return!1;if(v===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(v===Date)return r(y,x,b);if(v===RegExp)return u(y,x,b);if(v===Map)return i(y,x,b);if(v===Set)return d(y,x,b);const S=Ox.call(y);if(S===kx)return r(y,x,b);if(S===Tx)return u(y,x,b);if(S===vx)return i(y,x,b);if(S===Nx)return d(y,x,b);if(S===Cx)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(S===Ax)return h(y,x,b);if(S===Sx)return s(y,x,b);if(S===yx)return a(y,x,b);if(Ex[S])return f(y,x,b);if(S===gx)return n(y,x,b);if(S===bx)return t(y,x,b);if(S===xx||S===wx||S===Mx)return c(y,x,b);if(m){let w=m[S];if(!w){const C=ex(y);C&&(w=m[C])}if(w)return w(y,x,b)}return!1}}function Rx({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:ox,areArraysEqual:t?Fn:ix,areDataViewsEqual:lx,areDatesEqual:ax,areErrorsEqual:cx,areFunctionsEqual:ux,areMapsEqual:t?Oo(Xa,Fn):Xa,areNumbersEqual:dx,areObjectsEqual:t?Fn:fx,arePrimitiveWrappersEqual:hx,areRegExpsEqual:px,areSetsEqual:t?Oo(Ya,Fn):Ya,areTypedArraysEqual:t?Oo(ls,Fn):ls,areUrlsEqual:mx,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Lr(r.areArraysEqual),o=Lr(r.areMapsEqual),i=Lr(r.areObjectsEqual),l=Lr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function jx(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function Dx({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:u}=t();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const Px=zt();zt({strict:!0});zt({circular:!0});zt({circular:!0,strict:!0});zt({createInternalComparator:()=>hn});zt({strict:!0,createInternalComparator:()=>hn});zt({circular:!0,createInternalComparator:()=>hn});zt({circular:!0,createInternalComparator:()=>hn,strict:!0});function zt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=Rx(n),i=Ix(o),l=t?t(i):jx(i);return Dx({circular:e,comparator:i,createState:r,equals:l,strict:s})}var Lx=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},_x=({contentComponent:n})=>{const e=Cc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function $x(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:gh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var zx=class extends en.Component{constructor(n){var e;super(n),this.editorContentRef=en.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=$x(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:Lx(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(_x,{contentComponent:n.contentComponent})]})}},Bx=M.forwardRef((n,e)=>{const t=en.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return en.createElement(zx,{key:t,innerRef:e,...n})}),tf=en.memo(Bx),Fx=typeof window<"u"?M.useLayoutEffect:M.useEffect,Hx=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Vx(n){var e;const[t]=M.useState(()=>new Hx(n.editor)),r=ph.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:Px);return Fx(()=>t.watch(n.editor),[n.editor,t]),M.useDebugValue(r),r}var Wx=!1,di=typeof window>"u",Ux=di||!!(typeof window<"u"&&window.next),qx=class nf{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?di||Ux?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new By(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?nf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Kx(n={},e=[]){const t=M.useRef(n);t.current=n;const[r]=M.useState(()=>new qx(t)),s=Cc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(s),M.useEffect(r.onRender(e)),Vx({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var ul=M.createContext({editor:null});ul.Consumer;var A2=()=>M.useContext(ul),rf=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Jx=()=>M.useContext(rf),sf=en.forwardRef((n,e)=>{const{onDragStart:t}=Jx(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Qa(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function Za(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Gx(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Xx(n){if(Qa(n)||Za(n))return!0;if(Gx(n)){const e=n.type;if(e)return Qa(e)||Za(e)}return!1}function Yx(){try{if(M.version)return parseInt(M.version.split(".")[0],10)>=19}catch{}return!1}var Qx=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?mh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=Yx(),o=Xx(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};en.createContext({markViewContentRef:()=>{}});var Zx=class extends Xy{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const n=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(t,r,s){var o;return r==="storage"?(o=n.storage[e.name])!=null?o:{}:Reflect.get(t,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:M.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=M.memo(a=>p.jsx(rf.Provider,{value:r,children:M.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Qx(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=In(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function of(n,e){return t=>t.editor.contentComponent?new Zx(n,t,e):{}}var dl=M.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});dl.displayName="TiptapContext";var eb=()=>M.useContext(dl);function lf({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=M.useMemo(()=>({editor:r}),[r]),o=M.useMemo(()=>({editor:r}),[r]);return p.jsx(ul.Provider,{value:o,children:p.jsx(dl.Provider,{value:s,children:t})})}lf.displayName="Tiptap";function af({...n}){const{editor:e}=eb();return p.jsx(tf,{editor:e,...n})}af.displayName="Tiptap.Content";Object.assign(lf,{Content:af});function tb(n){return n.storage.mention}function O2(n,e,t){n.chain().focus().insertContentAt(e,[cf(t),{type:"text",text:" "}]).run()}function cf(n){return{type:"mention",attrs:n}}function nb(n){const e=D.c(19),{node:t,selected:r,view:s,editor:o,getPos:i}=n,{name:l,char:a,kind:c,id:u,args:d}=t.attrs,f=r&&s.editable,h=a==="@",m=s.editable&&a==="/"&&(c==="prompt"||c==null);let g;e[0]!==d||e[1]!==o||e[2]!==i||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const E=tb(o)?.onEditChip;if(!E||typeof i!="function")return;const j=i();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),E({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=o,e[2]=i,e[3]=u,e[4]=m,e[5]=l,e[6]=g):g=e[6];const y=g,x=m?"cursor-pointer":"cursor-default",b=h?"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",k=f&&"outline-2 outline-blue-300 outline-offset-0",v=m&&"hover:brightness-95";let S;e[7]!==x||e[8]!==b||e[9]!==k||e[10]!==v?(S=X("px-1 py-1 rounded","inline-flex items-center gap-1",x,"select-none","text-xs font-light",b,k,v,"capitalize"),e[7]=x,e[8]=b,e[9]=k,e[10]=v,e[11]=S):S=e[11];let w;e[12]!==l?(w=l?qc(l):"",e[12]=l,e[13]=w):w=e[13];let C;return e[14]!==a||e[15]!==y||e[16]!==S||e[17]!==w?(C=p.jsxs(sf,{onClick:y,className:S,children:[a,w]}),e[14]=a,e[15]=y,e[16]=S,e[17]=w,e[18]=C):C=e[18],C}const rb=Ie.create({name:"mention",group:"inline",inline:!0,atom:!0,addStorage(){return{onEditChip:null}},addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},char:{default:"/",parseHTML:n=>n.getAttribute("data-char")||"/",renderHTML:n=>n.char?{"data-char":n.char}:{}},metadata:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:n=>n.metadata?{"data-metadata":JSON.stringify(n.metadata)}:{}},kind:{default:null,parseHTML:n=>n.getAttribute("data-kind")||null,renderHTML:n=>n.kind?{"data-kind":n.kind}:{}},args:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-args")||"null")}catch{return null}},renderHTML:n=>n.args?{"data-args":JSON.stringify(n.args)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"mention"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.char&&(t["data-char"]=n.attrs.char),n.attrs.metadata&&(t["data-metadata"]=JSON.stringify(n.attrs.metadata)),n.attrs.kind&&(t["data-kind"]=n.attrs.kind),n.attrs.args&&(t["data-args"]=JSON.stringify(n.attrs.args)),["span",{...e,...t}]},renderText({node:n}){const e=n.attrs.char??"@",t=n.attrs.name??"";return`${e}${t}`},addNodeView(){return of(nb)}}),sb=/^mcp__[a-zA-Z0-9_-]+__/;function uf(n){return n.replace(sb,"")}function no(n){const e=D.c(18),{id:t,part:r,copyable:s,extraActions:o,alwaysShowActions:i,animate:l}=n,a=s===void 0?!1:s,c=i===void 0?!1:i,u=l===void 0?!1:l,{handleCopy:d}=jc(),[f,h]=M.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{yh("chat_message_copied",{message_id:t,chars:r.text.length}),await d(r.text),h(!0),setTimeout(()=>h(!1),2e3)},e[0]=d,e[1]=t,e[2]=r.text,e[3]=m):m=e[3];const g=m,y=a&&o,x=y||o;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Ii,{id:t,text:r.text,animate:u}),e[4]=u,e[5]=t,e[6]=r.text,e[7]=b):b=e[7];let k;e[8]!==c||e[9]!==o||e[10]!==g||e[11]!==f||e[12]!==x||e[13]!==y?(k=x&&p.jsxs("div",{className:X("flex w-full items-center gap-2 text-sm text-muted-foreground transition-all duration-200 mt-1 py-1",c?"opacity-100":"opacity-0 pointer-events-none group-hover/part:opacity-100 group-hover/part:pointer-events-auto"),children:[o,y&&o&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),y&&p.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground [@media(hover:hover)]:hover:text-foreground transition-colors active:scale-[0.97]","aria-label":"Copy message",children:f?p.jsx(Ai,{className:"size-4"}):p.jsx(Rc,{className:"size-4"})})]}),e[8]=c,e[9]=o,e[10]=g,e[11]=f,e[12]=x,e[13]=y,e[14]=k):k=e[14];let v;return e[15]!==b||e[16]!==k?(v=p.jsxs("div",{className:"group/part relative",children:[b,k]}),e[15]=b,e[16]=k,e[17]=v):v=e[17],v}function I2(n,e,t){n.chain().focus().insertContentAt(e,[ob(t),{type:"text",text:" "}]).run()}function ob(n){return{type:"file",attrs:n}}function ib(n){const e=D.c(17),{node:t,selected:r,view:s}=n,{name:o,mimeType:i,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==i?(c=i.startsWith("image/"),e[0]=i,e[1]=c):c=e[1];const u=c,d=a&&"outline-2 outline-blue-300 outline-offset-0";let f;e[2]!==d?(f=X("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-muted text-muted-foreground",d),e[2]=d,e[3]=f):f=e[3];let h;e[4]!==o?(h=p.jsx(tn,{asChild:!0,children:p.jsx("span",{children:o})}),e[4]=o,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==i||e[9]!==o?(m=p.jsx(nn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${i};base64,${l}`,alt:o,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:o}),p.jsx("div",{className:"text-muted-foreground mt-1",children:i})]})}),e[6]=l,e[7]=u,e[8]=i,e[9]=o,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(rn,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13];let y;return e[14]!==f||e[15]!==g?(y=p.jsx(sf,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=y):y=e[16],y}const lb=Ie.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},mimeType:{default:null,parseHTML:n=>n.getAttribute("data-mime-type")||null,renderHTML:n=>n.mimeType?{"data-mime-type":n.mimeType}:{}},size:{default:0,parseHTML:n=>{const e=n.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:n=>n.size?{"data-size":String(n.size)}:{}},data:{default:null,parseHTML:n=>n.getAttribute("data-data")||null,renderHTML:n=>n.data?{"data-data":n.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"file"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.mimeType&&(t["data-mime-type"]=n.attrs.mimeType),n.attrs.size&&(t["data-size"]=String(n.attrs.size)),n.attrs.data&&(t["data-data"]=n.attrs.data),["span",{...e,...t}]},renderText({node:n}){return`[${n.attrs.name??""}]`},addNodeView(){return of(ib)}});function ab(n={}){return new re({view(e){return new cb(e,n)}})}class cb{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=bu(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class le extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return le.valid(r)?new le(r):q.near(r)}content(){return _.empty}eq(e){return e instanceof le&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new le(e.resolve(t.pos))}getBookmark(){return new fl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ub(e)||!db(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&le.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(le.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(le.valid(l))return l}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;q.jsonID("gapcursor",le);class fl{constructor(e){this.pos=e}map(e){return new fl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return le.valid(t)?new le(t):q.near(t)}}function df(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function ub(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||df(s.type))return!0;if(s.inlineContent)return!1}}return!0}function db(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||df(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fb(){return new re({props:{decorations:gb,createSelectionBetween(n,e,t){return e.pos==t.pos&&le.valid(t)?new le(t):null},handleClick:pb,handleKeyDown:hb,handleDOMEvents:{beforeinput:mb}}})}const hb=kd({ArrowLeft:_r("horiz",-1),ArrowRight:_r("horiz",1),ArrowUp:_r("vert",-1),ArrowDown:_r("vert",1)});function _r(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof W){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=le.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new le(c))),!0):!1}}function pb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!le.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&V.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new le(r))),!0)}function mb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof le))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=A.empty;for(let i=r.length-1;i>=0;i--)s=A.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new _(s,0,0));return o.setSelection(W.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function gb(n){if(!(n.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ne.create(n.doc,[Ee.widget(n.selection.head,e,{key:"gapcursor"})])}var as=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<as&&this.leafAppend(e)||this.length<as&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new yb(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new ff(e):ye.empty};var ff=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=as)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=as)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new ff([]);var yb=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ye);const xb=500;class Je{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new Qe(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new Qe(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new Je(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Qe(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>kb&&(l=bb(l,c),i-=c),new Je(l.append(o),i)}remapping(e,t){let r=new cr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Je(this.items.append(e.map(t=>new Qe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,r.push(new Qe(m,g,y))}else r.push(new Qe(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new Qe(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new Je(u,l);return d.emptyItemCount()>xb&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new Qe(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new Je(ye.from(s.reverse()),o)}}Je.empty=new Je(ye.empty,0);function bb(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class Qe{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Qe(t.getMap().invert(),t,this.selection)}}}class kt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const kb=20;function Sb(n,e,t,r){let s=t.getMeta(Zt),o;if(s)return s.historyState;t.getMeta(Cb)&&(n=new kt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Zt))return i.getMeta(Zt).redo?new kt(n.done.addTransform(t,void 0,r,Ur(e)),n.undone,ec(t.mapping.maps),n.prevTime,n.prevComposition):new kt(n.done,n.undone.addTransform(t,void 0,r,Ur(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!vb(t,n.prevRanges)),c=i?Io(n.prevRanges,t.mapping):ec(t.mapping.maps);return new kt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ur(e)),Je.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new kt(n.done.rebased(t,o),n.undone.rebased(t,o),Io(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new kt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Io(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function vb(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function ec(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function Io(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function wb(n,e,t){let r=Ur(e),s=Zt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new kt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Zt,{redo:t,historyState:a})}let Ro=!1,tc=null;function Ur(n){let e=n.plugins;if(tc!=e){Ro=!1,tc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ro=!0;break}}return Ro}const Zt=new me("history"),Cb=new me("closeHistory");function Tb(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Zt,state:{init(){return new kt(Je.empty,Je.empty,null,0,-1)},apply(e,t,r){return Sb(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?pf:r=="historyRedo"?mf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function hf(n,e){return(t,r)=>{let s=Zt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=wb(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const pf=hf(!1,!0),mf=hf(!0,!0);ae.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new me("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Nb=ae.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ab(this.options)]}});ae.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return ne.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(Ee.node(c,c+a.nodeSize,{class:this.options.className}))}),ne.create(n,o)}}})]}});var Mb=ae.create({name:"gapCursor",addProseMirrorPlugins(){return[fb()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Y(H(n,"allowGapCursor",t)))!=null?e:null}}}),nc="placeholder";function Eb(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var R2=ae.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:nc,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${Eb(this.options.dataAttribute)}`:`data-${nc}`;return[new re({key:new me("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,o=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&Zs(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const f=Ee.node(a,a+l.nodeSize,{class:d.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});o.push(f)}return this.options.includeChildren}),ne.create(e,o)}}})]}});ae.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new me("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Ld(t.selection)||n.view.dragging?null:ne.create(t.doc,[Ee.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function rc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Ab=ae.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new me(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!rc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!rc({node:i,types:r})}}})]}}),Ob=ae.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>pf(n,e),redo:()=>({state:n,dispatch:e})=>mf(n,e)}},addProseMirrorPlugins(){return[Tb(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),cs=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Ib=/^\s*>\s$/,Rb=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return cs("blockquote",{...fe(this.options.HTMLAttributes,n),children:cs("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((s,o)=>{var i,l;const u=((l=(i=e.renderChild)==null?void 0:i.call(e,s,o))!=null?l:e.renderChildren([s])).split(`
|
|
103
103
|
`).map(d=>d.trim()===""?t:`${t} ${d}`);r.push(u.join(`
|
|
104
104
|
`))}),r.join(`
|
|
105
105
|
${t}
|
|
@@ -139,7 +139,7 @@ ${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:
|
|
|
139
139
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(`
|
|
140
140
|
`),[o,i]=Ok(s);if(o.length===0)return;const l=jf(o,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,i).join(`
|
|
141
141
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rk,this.editor.getAttributes(pc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=jn({find:mc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jn({find:mc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(pc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),jk=/^\s*(\[([( |x])?\])\s$/,Dk=Ie.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",fe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return cl(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const m=t();if(typeof m!="number")return!1;const g=h.doc.nodeAt(m);return h.setNodeMarkup(m,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,h=In(d,f),m=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(y=>{m.has(y)||(y in g?s.setAttribute(y,g[y]):s.removeAttribute(y))}),Object.entries(h).forEach(([y,x])=>{x==null?y in g?s.setAttribute(y,g[y]):s.removeAttribute(y):s.setAttribute(y,x)}),u=m,!0}}}},addInputRules(){return[jn({find:jk,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),Pk=Ie.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",fe(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
142
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=ui(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=ui(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ae.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Tf.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Nf.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Rf.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(Df.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Dk.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(Pk.configure(this.options.taskList)),n}});var gc=" ",Lk=" ",_k=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",fe(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return r.length===1&&r[0].type==="text"&&(r[0].text===gc||r[0].text===Lk)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const o=Array.isArray(n.content)?n.content:[];if(o.length===0){const i=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&i.length===0?gc:""}return e.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),$k=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,zk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Bk=fn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Rn({find:$k,type:this.type})]},addPasteRules(){return[cn({find:zk,type:this.type})]}}),Fk=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Hk=fn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",fe(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Vk=ae.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(_b.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Rb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Tf.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Bb.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Vb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Wb.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Nb.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Mb.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Ub.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(qb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Ob.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(Kb.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Qb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Nf.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Rf.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(wk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Df.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(_k.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Bk.configure(this.options.strike)),this.options.text!==!1&&s.push(Fk.configure(this.options.text)),this.options.underline!==!1&&s.push(Hk.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(Ab.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),Wk=Vk;const Ft=16,vi=2.5,wi=(Ft-vi)/2,Bo=2*Math.PI*wi;function Pf(n){const e=D.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:o,cost:i}=t;if(!r&&!s&&!o)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(Ch,{size:12}),e[0]=l):l=e[0];let a;e[1]!==i||e[2]!==r?(a=i>0?`$${i.toFixed(4)}`:r.toLocaleString(),e[1]=i,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(tn,{asChild:!0,children:p.jsxs("span",{className:"inline-flex items-center text-muted-foreground [@media(hover:hover)]:hover:text-foreground pl-1 h-6 gap-1 whitespace-nowrap shrink-0 cursor-default",children:[l,p.jsx("span",{className:"text-sm font-mono tabular-nums",children:a})]})}),e[4]=a,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("p",{className:"text-muted text-[10px] mb-1",children:"tokens"}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("span",{className:"text-muted",children:"in"}),e[7]=d):d=e[7];let f;e[8]!==s?(f=s.toLocaleString(),e[8]=s,e[9]=f):f=e[9];let h;e[10]!==f?(h=p.jsx("span",{className:"text-right tabular-nums",children:f}),e[10]=f,e[11]=h):h=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("span",{className:"text-muted",children:"out"}),e[12]=m):m=e[12];const g=o-(t.reasoningTokens??0);let y;e[13]!==g?(y=g.toLocaleString(),e[13]=g,e[14]=y):y=e[14];let x;e[15]!==y?(x=p.jsx("span",{className:"text-right tabular-nums",children:y}),e[15]=y,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==t.cacheReadTokens||e[19]!==t.cacheWriteTokens?(b=(t.cacheReadTokens>0||t.cacheWriteTokens>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:s>0?`${(t.cacheReadTokens/s*100).toFixed(0)}%`:"0%"})]}),e[17]=s,e[18]=t.cacheReadTokens,e[19]=t.cacheWriteTokens,e[20]=b):b=e[20];let k;e[21]!==i?(k=i>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",i.toFixed(4)]})]}),e[21]=i,e[22]=k):k=e[22];let v;e[23]!==x||e[24]!==b||e[25]!==k||e[26]!==h?(v=p.jsxs(nn,{side:"top",className:"font-mono text-[11px]",children:[u,p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[d,h,m,x,b,k]})]}),e[23]=x,e[24]=b,e[25]=k,e[26]=h,e[27]=v):v=e[27];let S;return e[28]!==v||e[29]!==c?(S=p.jsxs(rn,{children:[c,v]}),e[28]=v,e[29]=c,e[30]=S):S=e[30],S}function Uk(n){const e=D.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,o=t!=null&&(t.cost??0)>0,i=t!=null&&(t.totalTokens??0)>0;if(!s&&!o&&!i)return null;let l;e[0]!==r||e[1]!==s?(l=s?Rt(r/1e3):null,e[0]=r,e[1]=s,e[2]=l):l=e[2];const a=l;let c;e[3]!==r||e[4]!==a||e[5]!==t?(c=a&&p.jsxs(rn,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:a})}),p.jsxs(nn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"thinking"}),p.jsx("span",{className:"tabular-nums",children:Rt(r/1e3)}),(t?.reasoningTokens??0)>0&&p.jsxs("span",{className:"ml-2 opacity-50",children:[t.reasoningTokens.toLocaleString()," tok"]})]})]}),e[3]=r,e[4]=a,e[5]=t,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==s||e[9]!==i?(u=s&&(o||i)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=o,e[8]=s,e[9]=i,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==i||e[13]!==t?(d=(o||i)&&p.jsxs(rn,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:o?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(nn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"tokens"}),p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[p.jsx("span",{className:"opacity-60",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:(t.inputTokens??0).toLocaleString()}),p.jsx("span",{className:"opacity-60",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:((t.outputTokens??0)-(t?.reasoningTokens??0)).toLocaleString()}),(t?.reasoningTokens??0)>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"think"}),p.jsx("span",{className:"text-right tabular-nums",children:t.reasoningTokens.toLocaleString()})]}),((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:(t?.inputTokens??0)>0?`${((t?.cacheReadTokens??0)/t.inputTokens*100).toFixed(0)}%`:"0%"})]})]})]})]}),e[11]=o,e[12]=i,e[13]=t,e[14]=d):d=e[14];let f;return e[15]!==c||e[16]!==u||e[17]!==d?(f=p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c,u,d]}),e[15]=c,e[16]=u,e[17]=d,e[18]=f):f=e[18],f}function O2(n){const e=D.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:o}=n,i=Math.min(r/s*100,100),l=Bo-i/100*Bo,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==i?(d=i.toFixed(0),e[0]=i,e[1]=d):d=e[1];let f;e[2]!==a?(f=a>0?`, $${a.toFixed(2)}`:"",e[2]=a,e[3]=f):f=e[3];const h=`Context usage: ${d}%${f}`,m=o?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=X("flex items-center gap-1.5 text-muted-foreground hover:text-foreground h-6 px-1 shrink-0",m),e[4]=m,e[5]=g):g=e[5];let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx("circle",{cx:Ft/2,cy:Ft/2,r:wi,fill:"none",stroke:"currentColor",strokeWidth:vi,className:"opacity-15"}),e[6]=y):y=e[6];const x=i>90?"text-destructive":i>70?"text-warning":"text-muted-foreground";let b;e[7]!==x?(b=X(x),e[7]=x,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:Ft,height:Ft,className:"-rotate-90",children:[y,p.jsx("circle",{cx:Ft/2,cy:Ft/2,r:wi,fill:"none",stroke:"currentColor",strokeWidth:vi,strokeDasharray:Bo,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let v;e[12]!==i?(v=i.toFixed(0),e[12]=i,e[13]=v):v=e[13];let S;e[14]!==a?(S=a>0?` · $${a.toFixed(2)}`:"",e[14]=a,e[15]=S):S=e[15];let w;e[16]!==v||e[17]!==S?(w=p.jsxs("span",{className:"inline-block overflow-hidden whitespace-nowrap max-w-0 opacity-0 transition-[max-width,opacity] duration-200 ease-out @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100 text-[11px] font-mono tabular-nums",children:[v,"%",S]}),e[16]=v,e[17]=S,e[18]=w):w=e[18];let C;e[19]!==o||e[20]!==w||e[21]!==h||e[22]!==g||e[23]!==k?(C=p.jsx(tn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:o,"aria-label":h,className:g,children:[k,w]})}),e[19]=o,e[20]=w,e[21]=h,e[22]=g,e[23]=k,e[24]=C):C=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx("span",{className:"text-muted",children:"context"}),e[25]=T):T=e[25];let N;e[26]!==r?(N=r.toLocaleString(),e[26]=r,e[27]=N):N=e[27];let E;e[28]!==s?(E=s.toLocaleString(),e[28]=s,e[29]=E):E=e[29];let j;e[30]!==i?(j=i.toFixed(1),e[30]=i,e[31]=j):j=e[31];let L;e[32]!==N||e[33]!==E||e[34]!==j?(L=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",E," (",j,"%)"]}),e[32]=N,e[33]=E,e[34]=j,e[35]=L):L=e[35];let I;e[36]!==a||e[37]!==c||e[38]!==u?(I=a>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",a.toFixed(4)]}),p.jsx("span",{className:"text-muted",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:c.toLocaleString()}),p.jsx("span",{className:"text-muted",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:u.toLocaleString()})]}),e[36]=a,e[37]=c,e[38]=u,e[39]=I):I=e[39];let P;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(P=((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:c>0?`${((t?.cacheReadTokens??0)/c*100).toFixed(0)}%`:"0%"})]}),e[40]=c,e[41]=t?.cacheReadTokens,e[42]=t?.cacheWriteTokens,e[43]=P):P=e[43];let R;e[44]!==L||e[45]!==I||e[46]!==P?(R=p.jsx(nn,{side:"top",className:"font-mono text-[11px]",children:p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[T,L,I,P]})}),e[44]=L,e[45]=I,e[46]=P,e[47]=R):R=e[47];let z;return e[48]!==C||e[49]!==R?(z=p.jsxs(rn,{children:[C,R]}),e[48]=C,e[49]=R,e[50]=z):z=e[50],z}var so="Collapsible",[qk,I2]=Nc(so),[Kk,wl]=qk(so),Lf=M.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=xh({prop:r,defaultProp:s??!1,onChange:i,caller:so});return p.jsx(Kk,{scope:t,disabled:o,contentId:bh(),open:a,onOpenToggle:M.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Pt.div,{"data-state":Ml(a),"data-disabled":o?"":void 0,...l,ref:e})})});Lf.displayName=so;var _f="CollapsibleTrigger",Cl=M.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=wl(_f,t);return p.jsx(Pt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Ml(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Mt(n.onClick,s.onOpenToggle)})});Cl.displayName=_f;var Tl="CollapsibleContent",Nl=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=wl(Tl,n.__scopeCollapsible);return p.jsx(br,{present:t||s.open,children:({present:o})=>p.jsx(Jk,{...r,ref:e,present:o})})});Nl.displayName=Tl;var Jk=M.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=wl(Tl,t),[l,a]=M.useState(r),c=M.useRef(null),u=un(e,c),d=M.useRef(0),f=d.current,h=M.useRef(0),m=h.current,g=i.open||l,y=M.useRef(g),x=M.useRef(void 0);return M.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),Tc(()=>{const b=c.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,y.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),a(r)}},[i.open,r]),p.jsx(Pt.div,{"data-state":Ml(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:g&&s})});function Ml(n){return n?"open":"closed"}var Gk=Lf,R2=Cl,j2=Nl;function Xk(n){const e=D.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Gk,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function Yk(n){const e=D.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Cl,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function Qk(n){const e=D.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Nl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function J({icon:n,title:e,usage:t,latency:r,summary:s,state:o,detail:i,detailVariant:l="code",forceOpen:a,variant:c="default",trailing:u,iconDestructive:d,alwaysChevron:f,defaultOpen:h,children:m}){const[g,y]=M.useState(h??!1),{handleCopy:x,copied:b}=Dc(),k=o==="loading",v=o==="error",w=!!(i&&i.trim())||!!m,C=c==="subtask",T=(a??!1)||g,N=$p({initial:k?"instant":!1}),E=p.jsxs(Xk,{open:T,onOpenChange:a?void 0:y,className:"min-w-0",children:[p.jsxs(Yk,{disabled:!w,className:X("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",w&&"[@media(hover:hover)]:hover:bg-accent/30",!w&&"cursor-default",k&&"shimmer"),"aria-disabled":!w,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(Pl,{className:X("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:X("absolute inset-0 flex items-center justify-center [&>svg]:size-4 transition-opacity duration-150",d?"[&>svg]:text-destructive/70":v?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75",w&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),w&&p.jsx("div",{className:X("absolute inset-0 flex items-center justify-center transition-opacity duration-150",T?"opacity-100":"opacity-0 [@media(hover:hover)]:group-hover/tool:opacity-100"),children:p.jsx(Pl,{className:X("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:X("shrink-0 text-[14px] font-normal",v?"text-warning/80":"text-foreground"),children:e}),s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),u&&p.jsx("div",{className:"shrink-0 flex items-center gap-1 [&_svg]:size-3.5 [&_svg]:text-muted-foreground/50",children:u}),p.jsx(Pf,{usage:t})]}),w&&p.jsx(Qk,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:m||(l==="prose"?p.jsx("div",{className:"mt-1 mb-1",children:p.jsx("div",{ref:N.scrollRef,className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:p.jsx("p",{ref:N.contentRef,className:"text-xs text-muted-foreground/70 whitespace-pre-wrap leading-relaxed wrap-break-word",children:i})})}):p.jsx("div",{className:"ml-[20px] pl-3 border-l border-border/30 mt-0.5 pb-1",children:p.jsx("div",{ref:N.scrollRef,className:"flex flex-col max-h-48 overflow-y-auto",children:p.jsxs("div",{ref:N.contentRef,className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:i})}),p.jsx("button",{type:"button",onClick:()=>x(i),className:"shrink-0 p-1.5 rounded-md text-muted-foreground/50 [@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/50 transition-colors active:scale-[0.97]","aria-label":"Copy",children:b?p.jsx(Ai,{className:"size-3.5"}):p.jsx(Rc,{className:"size-3.5"})})]})})}))})]});return C?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:E}):E}function Te(n){const e=D.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Rt(t),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r?(s=p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground",children:r}),e[2]=r,e[3]=s):s=e[3],s}const $f=4;function zf(n){const e=D.c(5),{count:t,noun:r,onClick:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(Oc,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==r||e[3]!==s?(i=p.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:["See all ",t," ",r,o]}),e[1]=t,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function Bf(n){const e=D.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let o,i,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Oi(s);if(u===null){a=null;break e}const d=new Date(u);o=d.toLocaleString(),e[6]!==r?(i=X("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=i):i=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=l,e[5]=a}else o=e[2],i=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==o||e[9]!==i||e[10]!==l?(c=p.jsx("span",{title:o,className:i,children:l}),e[8]=o,e[9]=i,e[10]=l,e[11]=c):c=e[11],c}function Zk(n){const e=D.c(24),{org:t}=Lt(),r=kh(),s=qh(),o=Gh();let i;e[0]!==o||e[1]!==n?(i=async g=>{if(!n)throw new Error("useTaskExpandedTools: no task in context");const x=(await o.call("COLLECTION_THREADS_GET",{id:n})).item?.metadata??{},k=(x.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const v={...x,expanded_tools:k};return await o.call("COLLECTION_THREADS_UPDATE",{id:n,data:{metadata:v}}),k},e[0]=o,e[1]=n,e[2]=i):i=e[2];let l,a,c;e[3]!==t||e[4]!==r||e[5]!==n?(l=async g=>{const y=Wt.ensureTask(t.id,n??"");await r.cancelQueries({queryKey:y});const x=r.getQueryData(y),k=(x?.metadata?.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);return k.push({...g,expandedAt:new Date().toISOString()}),r.setQueryData(y,v=>v&&{...v,metadata:{...v.metadata??{},expanded_tools:k}}),{previous:x}},a=()=>{r.invalidateQueries({queryKey:Wt.ensureTask(t.id,n??"")})},c=(g,y,x)=>{const b=Wt.ensureTask(t.id,n??"");x?.previous===void 0?r.removeQueries({queryKey:b,exact:!0}):r.setQueryData(b,x.previous),Vo.error(g instanceof Error?g.message:"Failed to expand tool")},e[3]=t,e[4]=r,e[5]=n,e[6]=l,e[7]=a,e[8]=c):(l=e[6],a=e[7],c=e[8]);let u;e[9]!==i||e[10]!==l||e[11]!==a||e[12]!==c?(u={mutationFn:i,onMutate:l,onSuccess:a,onError:c},e[9]=i,e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13];const d=Sh(u);let f;e[14]!==s||e[15]!==d||e[16]!==t||e[17]!==r||e[18]!==n?(f=g=>{if(!n||!s)return;const y=Wt.ensureTask(t.id,n),x=r.getQueryData(y),k=(x?.metadata?.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const v={...x?.metadata??{},expanded_tools:k};r.setQueryData(y,S=>S&&{...S,metadata:v}),s.patchThread({id:n,metadata:v}),d.mutate(g)},e[14]=s,e[15]=d,e[16]=t,e[17]=r,e[18]=n,e[19]=f):f=e[19];const h=f;let m;return e[20]!==h||e[21]!==d.isPending||e[22]!==d.mutate?(m={addOrReplace:d.mutate,addOrReplaceEager:h,isPending:d.isPending},e[20]=h,e[21]=d.isPending,e[22]=d.mutate,e[23]=m):m=e[23],m}function eS(n){if(n<1024)return`${n} B`;if(n<1024*1024){const t=n/1024;return t<10?`${t.toFixed(1)} KB`:`${Math.round(t)} KB`}const e=n/(1024*1024);return e<10?`${e.toFixed(1)} MB`:`${Math.round(e)} MB`}function tS(n,e,t,r){const{data:s,isLoading:o}=Mi({queryKey:Wt.toolDefinitionLookup(e,t,n),queryFn:async()=>{if(!n||!e)return null;const i=await Zh({connectionId:e,orgId:t,orgSlug:r});try{const{tools:l}=await i.listTools(),a=uf(n);return l.find(c=>c.name===a)??null}finally{await i.close().catch(()=>{})}},enabled:!!n&&!!e,staleTime:6e4,gcTime:3e5,retry:!1});return{toolDef:s??void 0,isLoading:o}}const nS={read:{icon:_l,label:"Read File"},write:{icon:sp,label:"Write File"},edit:{icon:Oh,label:"Edit File"},grep:{icon:ip,label:"Search Content"},glob:{icon:op,label:"Find Files"},bash:{icon:Ah,label:"Run Command"},read_tool_output:{icon:_l,label:"Read Tool Output"},read_resource:{icon:Eh,label:"Read Resource"},read_prompt:{icon:Wo,label:"Read Prompt"},skill:{icon:Wo,label:"Load Skill"},enable_tool:{icon:rp,label:"Enable Tool"},open_in_agent:{icon:Mh,label:"Open in Agent"},sandbox:{icon:Nh,label:"Run Code"},copy_to_sandbox:{icon:Bc,label:"Load File"},share_with_user:{icon:lp,label:"Share with User"},take_screenshot:{icon:Jn,label:"Take Screenshot"},scrape_url:{icon:Kr,label:"Scrape URL"},inspect_page:{icon:Th,label:"Inspect Page"}},rS="bash-sleep-start:";function sS(n){const e=rS+n;try{const t=sessionStorage.getItem(e);if(t!==null){const s=Number.parseInt(t,10);if(Number.isFinite(s))return s}const r=Date.now();return sessionStorage.setItem(e,String(r)),r}catch{return Date.now()}}function oS(n,e){const t=D.c(2);let r;t[0]!==n?(r=()=>sS(n),t[0]=n,t[1]=r):r=t[1];const s=M.useState(r)[0];return e??s}function iS(n){const e=Math.ceil(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),r=e%60;return r?`${t}m ${r}s`:`${t}m`}function lS(n){const e=D.c(4),{toolCallId:t,durationMs:r,anchorMs:s}=n;jc(1e3);const i=oS(t,s)+r-Date.now();let l;e[0]!==i?(l=i>0?`Waiting ${iS(i)}`:"Wrapping up…",e[0]=i,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.jsx("span",{className:"tabular-nums",children:l}),e[2]=l,e[3]=a):a=e[3],a}const aS={s:1e3,m:6e4,h:36e5,d:864e5};function cS(n){const e=/(?:^|[\s;&|(])sleep((?:\s+[\d.]+[smhd]?)+)/g;let t=0,r=!1;for(const s of n.matchAll(e))for(const o of s[1].trim().split(/\s+/)){const i=/^([\d.]+)([smhd]?)$/.exec(o);if(!i)continue;const l=Number.parseFloat(i[1]);Number.isFinite(l)&&(t+=l*(aS[i[2]||"s"]??1e3),r=!0)}return r?t:null}function oo(n,e="An unknown error occurred"){return"errorText"in n&&typeof n.errorText=="string"?n.errorText:e}function vn(n){if(n==null)return"";try{return JSON.stringify(n)}catch{return"[Non-serializable value]"}}function _s(n){const e=vn(n);if(e===""||e==="[Non-serializable value]")return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const uS=n=>n.type==="dynamic-tool"||n.type.startsWith("tool-");function dS(n){if(!n||typeof n!="object")return null;const e=n;if(!Array.isArray(e.parts))return null;const t=[];for(const r of e.parts)if(r.type==="text"&&typeof r.text=="string")t.push(r.text);else if(r.type==="reasoning")t.push(`## Reasoning
|
|
142
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=ui(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=ui(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ae.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Tf.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Nf.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Rf.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(Df.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Dk.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(Pk.configure(this.options.taskList)),n}});var gc=" ",Lk=" ",_k=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",fe(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return r.length===1&&r[0].type==="text"&&(r[0].text===gc||r[0].text===Lk)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const o=Array.isArray(n.content)?n.content:[];if(o.length===0){const i=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&i.length===0?gc:""}return e.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),$k=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,zk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Bk=fn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Rn({find:$k,type:this.type})]},addPasteRules(){return[cn({find:zk,type:this.type})]}}),Fk=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Hk=fn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",fe(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Vk=ae.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(_b.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Rb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Tf.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Bb.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Vb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Wb.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Nb.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Mb.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Ub.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(qb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Ob.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(Kb.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Qb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Nf.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Rf.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(wk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Df.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(_k.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Bk.configure(this.options.strike)),this.options.text!==!1&&s.push(Fk.configure(this.options.text)),this.options.underline!==!1&&s.push(Hk.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(Ab.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),Wk=Vk;const Ft=16,vi=2.5,wi=(Ft-vi)/2,Bo=2*Math.PI*wi;function Pf(n){const e=D.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:o,cost:i}=t;if(!r&&!s&&!o)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(Ch,{size:12}),e[0]=l):l=e[0];let a;e[1]!==i||e[2]!==r?(a=i>0?`$${i.toFixed(4)}`:r.toLocaleString(),e[1]=i,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(tn,{asChild:!0,children:p.jsxs("span",{className:"inline-flex items-center text-muted-foreground [@media(hover:hover)]:hover:text-foreground pl-1 h-6 gap-1 whitespace-nowrap shrink-0 cursor-default",children:[l,p.jsx("span",{className:"text-sm font-mono tabular-nums",children:a})]})}),e[4]=a,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("p",{className:"text-muted text-[10px] mb-1",children:"tokens"}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("span",{className:"text-muted",children:"in"}),e[7]=d):d=e[7];let f;e[8]!==s?(f=s.toLocaleString(),e[8]=s,e[9]=f):f=e[9];let h;e[10]!==f?(h=p.jsx("span",{className:"text-right tabular-nums",children:f}),e[10]=f,e[11]=h):h=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("span",{className:"text-muted",children:"out"}),e[12]=m):m=e[12];const g=o-(t.reasoningTokens??0);let y;e[13]!==g?(y=g.toLocaleString(),e[13]=g,e[14]=y):y=e[14];let x;e[15]!==y?(x=p.jsx("span",{className:"text-right tabular-nums",children:y}),e[15]=y,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==t.cacheReadTokens||e[19]!==t.cacheWriteTokens?(b=(t.cacheReadTokens>0||t.cacheWriteTokens>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:s>0?`${(t.cacheReadTokens/s*100).toFixed(0)}%`:"0%"})]}),e[17]=s,e[18]=t.cacheReadTokens,e[19]=t.cacheWriteTokens,e[20]=b):b=e[20];let k;e[21]!==i?(k=i>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",i.toFixed(4)]})]}),e[21]=i,e[22]=k):k=e[22];let v;e[23]!==x||e[24]!==b||e[25]!==k||e[26]!==h?(v=p.jsxs(nn,{side:"top",className:"font-mono text-[11px]",children:[u,p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[d,h,m,x,b,k]})]}),e[23]=x,e[24]=b,e[25]=k,e[26]=h,e[27]=v):v=e[27];let S;return e[28]!==v||e[29]!==c?(S=p.jsxs(rn,{children:[c,v]}),e[28]=v,e[29]=c,e[30]=S):S=e[30],S}function Uk(n){const e=D.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,o=t!=null&&(t.cost??0)>0,i=t!=null&&(t.totalTokens??0)>0;if(!s&&!o&&!i)return null;let l;e[0]!==r||e[1]!==s?(l=s?Rt(r/1e3):null,e[0]=r,e[1]=s,e[2]=l):l=e[2];const a=l;let c;e[3]!==r||e[4]!==a||e[5]!==t?(c=a&&p.jsxs(rn,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:a})}),p.jsxs(nn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"thinking"}),p.jsx("span",{className:"tabular-nums",children:Rt(r/1e3)}),(t?.reasoningTokens??0)>0&&p.jsxs("span",{className:"ml-2 opacity-50",children:[t.reasoningTokens.toLocaleString()," tok"]})]})]}),e[3]=r,e[4]=a,e[5]=t,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==s||e[9]!==i?(u=s&&(o||i)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=o,e[8]=s,e[9]=i,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==i||e[13]!==t?(d=(o||i)&&p.jsxs(rn,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:o?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(nn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"tokens"}),p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[p.jsx("span",{className:"opacity-60",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:(t.inputTokens??0).toLocaleString()}),p.jsx("span",{className:"opacity-60",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:((t.outputTokens??0)-(t?.reasoningTokens??0)).toLocaleString()}),(t?.reasoningTokens??0)>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"think"}),p.jsx("span",{className:"text-right tabular-nums",children:t.reasoningTokens.toLocaleString()})]}),((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:(t?.inputTokens??0)>0?`${((t?.cacheReadTokens??0)/t.inputTokens*100).toFixed(0)}%`:"0%"})]})]})]})]}),e[11]=o,e[12]=i,e[13]=t,e[14]=d):d=e[14];let f;return e[15]!==c||e[16]!==u||e[17]!==d?(f=p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c,u,d]}),e[15]=c,e[16]=u,e[17]=d,e[18]=f):f=e[18],f}function j2(n){const e=D.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:o}=n,i=Math.min(r/s*100,100),l=Bo-i/100*Bo,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==i?(d=i.toFixed(0),e[0]=i,e[1]=d):d=e[1];let f;e[2]!==a?(f=a>0?`, $${a.toFixed(2)}`:"",e[2]=a,e[3]=f):f=e[3];const h=`Context usage: ${d}%${f}`,m=o?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=X("flex items-center gap-1.5 text-muted-foreground hover:text-foreground h-6 px-1 shrink-0",m),e[4]=m,e[5]=g):g=e[5];let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx("circle",{cx:Ft/2,cy:Ft/2,r:wi,fill:"none",stroke:"currentColor",strokeWidth:vi,className:"opacity-15"}),e[6]=y):y=e[6];const x=i>90?"text-destructive":i>70?"text-warning":"text-muted-foreground";let b;e[7]!==x?(b=X(x),e[7]=x,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:Ft,height:Ft,className:"-rotate-90",children:[y,p.jsx("circle",{cx:Ft/2,cy:Ft/2,r:wi,fill:"none",stroke:"currentColor",strokeWidth:vi,strokeDasharray:Bo,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let v;e[12]!==i?(v=i.toFixed(0),e[12]=i,e[13]=v):v=e[13];let S;e[14]!==a?(S=a>0?` · $${a.toFixed(2)}`:"",e[14]=a,e[15]=S):S=e[15];let w;e[16]!==v||e[17]!==S?(w=p.jsxs("span",{className:"inline-block overflow-hidden whitespace-nowrap max-w-0 opacity-0 transition-[max-width,opacity] duration-200 ease-out @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100 text-[11px] font-mono tabular-nums",children:[v,"%",S]}),e[16]=v,e[17]=S,e[18]=w):w=e[18];let C;e[19]!==o||e[20]!==w||e[21]!==h||e[22]!==g||e[23]!==k?(C=p.jsx(tn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:o,"aria-label":h,className:g,children:[k,w]})}),e[19]=o,e[20]=w,e[21]=h,e[22]=g,e[23]=k,e[24]=C):C=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx("span",{className:"text-muted",children:"context"}),e[25]=T):T=e[25];let N;e[26]!==r?(N=r.toLocaleString(),e[26]=r,e[27]=N):N=e[27];let E;e[28]!==s?(E=s.toLocaleString(),e[28]=s,e[29]=E):E=e[29];let j;e[30]!==i?(j=i.toFixed(1),e[30]=i,e[31]=j):j=e[31];let L;e[32]!==N||e[33]!==E||e[34]!==j?(L=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",E," (",j,"%)"]}),e[32]=N,e[33]=E,e[34]=j,e[35]=L):L=e[35];let I;e[36]!==a||e[37]!==c||e[38]!==u?(I=a>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",a.toFixed(4)]}),p.jsx("span",{className:"text-muted",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:c.toLocaleString()}),p.jsx("span",{className:"text-muted",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:u.toLocaleString()})]}),e[36]=a,e[37]=c,e[38]=u,e[39]=I):I=e[39];let P;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(P=((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:c>0?`${((t?.cacheReadTokens??0)/c*100).toFixed(0)}%`:"0%"})]}),e[40]=c,e[41]=t?.cacheReadTokens,e[42]=t?.cacheWriteTokens,e[43]=P):P=e[43];let R;e[44]!==L||e[45]!==I||e[46]!==P?(R=p.jsx(nn,{side:"top",className:"font-mono text-[11px]",children:p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[T,L,I,P]})}),e[44]=L,e[45]=I,e[46]=P,e[47]=R):R=e[47];let z;return e[48]!==C||e[49]!==R?(z=p.jsxs(rn,{children:[C,R]}),e[48]=C,e[49]=R,e[50]=z):z=e[50],z}var so="Collapsible",[qk,D2]=Nc(so),[Kk,wl]=qk(so),Lf=M.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=xh({prop:r,defaultProp:s??!1,onChange:i,caller:so});return p.jsx(Kk,{scope:t,disabled:o,contentId:bh(),open:a,onOpenToggle:M.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Pt.div,{"data-state":Ml(a),"data-disabled":o?"":void 0,...l,ref:e})})});Lf.displayName=so;var _f="CollapsibleTrigger",Cl=M.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=wl(_f,t);return p.jsx(Pt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Ml(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Mt(n.onClick,s.onOpenToggle)})});Cl.displayName=_f;var Tl="CollapsibleContent",Nl=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=wl(Tl,n.__scopeCollapsible);return p.jsx(br,{present:t||s.open,children:({present:o})=>p.jsx(Jk,{...r,ref:e,present:o})})});Nl.displayName=Tl;var Jk=M.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=wl(Tl,t),[l,a]=M.useState(r),c=M.useRef(null),u=un(e,c),d=M.useRef(0),f=d.current,h=M.useRef(0),m=h.current,g=i.open||l,y=M.useRef(g),x=M.useRef(void 0);return M.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),Tc(()=>{const b=c.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,y.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),a(r)}},[i.open,r]),p.jsx(Pt.div,{"data-state":Ml(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:g&&s})});function Ml(n){return n?"open":"closed"}var Gk=Lf,P2=Cl,L2=Nl;function Xk(n){const e=D.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Gk,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function Yk(n){const e=D.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Cl,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function Qk(n){const e=D.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Nl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function J({icon:n,title:e,usage:t,latency:r,summary:s,state:o,detail:i,detailVariant:l="code",forceOpen:a,variant:c="default",trailing:u,iconDestructive:d,alwaysChevron:f,defaultOpen:h,children:m}){const[g,y]=M.useState(h??!1),{handleCopy:x,copied:b}=jc(),k=o==="loading",v=o==="error",w=!!(i&&i.trim())||!!m,C=c==="subtask",T=(a??!1)||g,N=$p({initial:k?"instant":!1}),E=p.jsxs(Xk,{open:T,onOpenChange:a?void 0:y,className:"min-w-0",children:[p.jsxs(Yk,{disabled:!w,className:X("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",w&&"[@media(hover:hover)]:hover:bg-accent/30",!w&&"cursor-default",k&&"shimmer"),"aria-disabled":!w,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(Pl,{className:X("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:X("absolute inset-0 flex items-center justify-center [&>svg]:size-4 transition-opacity duration-150",d?"[&>svg]:text-destructive/70":v?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75",w&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),w&&p.jsx("div",{className:X("absolute inset-0 flex items-center justify-center transition-opacity duration-150",T?"opacity-100":"opacity-0 [@media(hover:hover)]:group-hover/tool:opacity-100"),children:p.jsx(Pl,{className:X("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:X("shrink-0 text-[14px] font-normal",v?"text-warning/80":"text-foreground"),children:e}),s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),u&&p.jsx("div",{className:"shrink-0 flex items-center gap-1 [&_svg]:size-3.5 [&_svg]:text-muted-foreground/50",children:u}),p.jsx(Pf,{usage:t})]}),w&&p.jsx(Qk,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:m||(l==="prose"?p.jsx("div",{className:"mt-1 mb-1",children:p.jsx("div",{ref:N.scrollRef,className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:p.jsx("p",{ref:N.contentRef,className:"text-xs text-muted-foreground/70 whitespace-pre-wrap leading-relaxed wrap-break-word",children:i})})}):p.jsx("div",{className:"ml-[20px] pl-3 border-l border-border/30 mt-0.5 pb-1",children:p.jsx("div",{ref:N.scrollRef,className:"flex flex-col max-h-48 overflow-y-auto",children:p.jsxs("div",{ref:N.contentRef,className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:i})}),p.jsx("button",{type:"button",onClick:()=>x(i),className:"shrink-0 p-1.5 rounded-md text-muted-foreground/50 [@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/50 transition-colors active:scale-[0.97]","aria-label":"Copy",children:b?p.jsx(Ai,{className:"size-3.5"}):p.jsx(Rc,{className:"size-3.5"})})]})})}))})]});return C?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:E}):E}function Te(n){const e=D.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Rt(t),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r?(s=p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground",children:r}),e[2]=r,e[3]=s):s=e[3],s}const $f=4;function zf(n){const e=D.c(5),{count:t,noun:r,onClick:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(Oc,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==r||e[3]!==s?(i=p.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:["See all ",t," ",r,o]}),e[1]=t,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function Bf(n){const e=D.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let o,i,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Oi(s);if(u===null){a=null;break e}const d=new Date(u);o=d.toLocaleString(),e[6]!==r?(i=X("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=i):i=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=l,e[5]=a}else o=e[2],i=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==o||e[9]!==i||e[10]!==l?(c=p.jsx("span",{title:o,className:i,children:l}),e[8]=o,e[9]=i,e[10]=l,e[11]=c):c=e[11],c}function Zk(n){const e=D.c(24),{org:t}=Lt(),r=kh(),s=Uh(),o=Jh();let i;e[0]!==o||e[1]!==n?(i=async g=>{if(!n)throw new Error("useTaskExpandedTools: no task in context");const x=(await o.call("COLLECTION_THREADS_GET",{id:n})).item?.metadata??{},k=(x.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const v={...x,expanded_tools:k};return await o.call("COLLECTION_THREADS_UPDATE",{id:n,data:{metadata:v}}),k},e[0]=o,e[1]=n,e[2]=i):i=e[2];let l,a,c;e[3]!==t||e[4]!==r||e[5]!==n?(l=async g=>{const y=Wt.ensureTask(t.id,n??"");await r.cancelQueries({queryKey:y});const x=r.getQueryData(y),k=(x?.metadata?.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);return k.push({...g,expandedAt:new Date().toISOString()}),r.setQueryData(y,v=>v&&{...v,metadata:{...v.metadata??{},expanded_tools:k}}),{previous:x}},a=()=>{r.invalidateQueries({queryKey:Wt.ensureTask(t.id,n??"")})},c=(g,y,x)=>{const b=Wt.ensureTask(t.id,n??"");x?.previous===void 0?r.removeQueries({queryKey:b,exact:!0}):r.setQueryData(b,x.previous),Vo.error(g instanceof Error?g.message:"Failed to expand tool")},e[3]=t,e[4]=r,e[5]=n,e[6]=l,e[7]=a,e[8]=c):(l=e[6],a=e[7],c=e[8]);let u;e[9]!==i||e[10]!==l||e[11]!==a||e[12]!==c?(u={mutationFn:i,onMutate:l,onSuccess:a,onError:c},e[9]=i,e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13];const d=Sh(u);let f;e[14]!==s||e[15]!==d||e[16]!==t||e[17]!==r||e[18]!==n?(f=g=>{if(!n||!s)return;const y=Wt.ensureTask(t.id,n),x=r.getQueryData(y),k=(x?.metadata?.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const v={...x?.metadata??{},expanded_tools:k};r.setQueryData(y,S=>S&&{...S,metadata:v}),s.patchThread({id:n,metadata:v}),d.mutate(g)},e[14]=s,e[15]=d,e[16]=t,e[17]=r,e[18]=n,e[19]=f):f=e[19];const h=f;let m;return e[20]!==h||e[21]!==d.isPending||e[22]!==d.mutate?(m={addOrReplace:d.mutate,addOrReplaceEager:h,isPending:d.isPending},e[20]=h,e[21]=d.isPending,e[22]=d.mutate,e[23]=m):m=e[23],m}function eS(n){if(n<1024)return`${n} B`;if(n<1024*1024){const t=n/1024;return t<10?`${t.toFixed(1)} KB`:`${Math.round(t)} KB`}const e=n/(1024*1024);return e<10?`${e.toFixed(1)} MB`:`${Math.round(e)} MB`}function tS(n,e,t,r){const{data:s,isLoading:o}=Mi({queryKey:Wt.toolDefinitionLookup(e,t,n),queryFn:async()=>{if(!n||!e)return null;const i=await Qh({connectionId:e,orgId:t,orgSlug:r});try{const{tools:l}=await i.listTools(),a=uf(n);return l.find(c=>c.name===a)??null}finally{await i.close().catch(()=>{})}},enabled:!!n&&!!e,staleTime:6e4,gcTime:3e5,retry:!1});return{toolDef:s??void 0,isLoading:o}}const nS={read:{icon:_l,label:"Read File"},write:{icon:rp,label:"Write File"},edit:{icon:Oh,label:"Edit File"},grep:{icon:op,label:"Search Content"},glob:{icon:sp,label:"Find Files"},bash:{icon:Ah,label:"Run Command"},read_tool_output:{icon:_l,label:"Read Tool Output"},read_resource:{icon:Eh,label:"Read Resource"},read_prompt:{icon:Wo,label:"Read Prompt"},skill:{icon:Wo,label:"Load Skill"},enable_tool:{icon:np,label:"Enable Tool"},open_in_agent:{icon:Mh,label:"Open in Agent"},sandbox:{icon:Nh,label:"Run Code"},copy_to_sandbox:{icon:zc,label:"Load File"},share_with_user:{icon:ip,label:"Share with User"},take_screenshot:{icon:Jn,label:"Take Screenshot"},scrape_url:{icon:Kr,label:"Scrape URL"},inspect_page:{icon:Th,label:"Inspect Page"}},rS="bash-sleep-start:";function sS(n){const e=rS+n;try{const t=sessionStorage.getItem(e);if(t!==null){const s=Number.parseInt(t,10);if(Number.isFinite(s))return s}const r=Date.now();return sessionStorage.setItem(e,String(r)),r}catch{return Date.now()}}function oS(n,e){const t=D.c(2);let r;t[0]!==n?(r=()=>sS(n),t[0]=n,t[1]=r):r=t[1];const s=M.useState(r)[0];return e??s}function iS(n){const e=Math.ceil(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),r=e%60;return r?`${t}m ${r}s`:`${t}m`}function lS(n){const e=D.c(4),{toolCallId:t,durationMs:r,anchorMs:s}=n;Bc(1e3);const i=oS(t,s)+r-Date.now();let l;e[0]!==i?(l=i>0?`Waiting ${iS(i)}`:"Wrapping up…",e[0]=i,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.jsx("span",{className:"tabular-nums",children:l}),e[2]=l,e[3]=a):a=e[3],a}const aS={s:1e3,m:6e4,h:36e5,d:864e5};function cS(n){const e=/(?:^|[\s;&|(])sleep((?:\s+[\d.]+[smhd]?)+)/g;let t=0,r=!1;for(const s of n.matchAll(e))for(const o of s[1].trim().split(/\s+/)){const i=/^([\d.]+)([smhd]?)$/.exec(o);if(!i)continue;const l=Number.parseFloat(i[1]);Number.isFinite(l)&&(t+=l*(aS[i[2]||"s"]??1e3),r=!0)}return r?t:null}function oo(n,e="An unknown error occurred"){return"errorText"in n&&typeof n.errorText=="string"?n.errorText:e}function vn(n){if(n==null)return"";try{return JSON.stringify(n)}catch{return"[Non-serializable value]"}}function _s(n){const e=vn(n);if(e===""||e==="[Non-serializable value]")return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const uS=n=>n.type==="dynamic-tool"||n.type.startsWith("tool-");function dS(n){if(!n||typeof n!="object")return null;const e=n;if(!Array.isArray(e.parts))return null;const t=[];for(const r of e.parts)if(r.type==="text"&&typeof r.text=="string")t.push(r.text);else if(r.type==="reasoning")t.push(`## Reasoning
|
|
143
143
|
${r.text}`);else if(r.type==="source-url")t.push(`## Source URL
|
|
144
144
|
${r.url}`);else if(r.type==="source-document")t.push(`## Source Document
|
|
145
145
|
${r.title}`);else if(r.type==="file")t.push(`## File
|
|
@@ -160,29 +160,29 @@ Error: Tool responded with an error`)}else if(r.state==="output-denied"){const o
|
|
|
160
160
|
Input: ${o||"[No input]"}...
|
|
161
161
|
Output: Tool execution was denied`)}}}return t.length>0?t.join(`
|
|
162
162
|
|
|
163
|
-
`):null}function fS(n){const e=n&&typeof n=="object"&&"created_at"in n?n.created_at:void 0;return typeof e=="string"||e instanceof Date?Oi(e):null}function hS(n){const e=n&&typeof n=="object"&&"timeout"in n?n.timeout:void 0;return Math.min(typeof e=="number"?e:3e4,12e4)}function Fr(n){const e=D.c(7),{icon:t,label:r}=n;let s;e[0]!==t?(s=p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"flex items-center",children:t})}),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx(nn,{side:"top",children:r}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsxs(rn,{children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function pS(n){const e=D.c(15),{annotations:t,toolMeta:r}=n;let s;e[0]!==r?(s=
|
|
163
|
+
`):null}function fS(n){const e=n&&typeof n=="object"&&"created_at"in n?n.created_at:void 0;return typeof e=="string"||e instanceof Date?Oi(e):null}function hS(n){const e=n&&typeof n=="object"&&"timeout"in n?n.timeout:void 0;return Math.min(typeof e=="number"?e:3e4,12e4)}function Fr(n){const e=D.c(7),{icon:t,label:r}=n;let s;e[0]!==t?(s=p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"flex items-center",children:t})}),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx(nn,{side:"top",children:r}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsxs(rn,{children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function pS(n){const e=D.c(15),{annotations:t,toolMeta:r}=n;let s;e[0]!==r?(s=Pc(r),e[0]=r,e[1]=s):s=e[1];const o=!!s;if(!t&&!o)return null;let i;e[2]!==o?(i=o&&p.jsx(Fr,{icon:p.jsx(Ec,{}),label:"Interactive"}),e[2]=o,e[3]=i):i=e[3];let l;e[4]!==t?.readOnlyHint?(l=t?.readOnlyHint&&p.jsx(Fr,{icon:p.jsx(Zh,{}),label:"Read-only — no side effects"}),e[4]=t?.readOnlyHint,e[5]=l):l=e[5];let a;e[6]!==t?.destructiveHint?(a=t?.destructiveHint&&p.jsx(Fr,{icon:p.jsx(_c,{}),label:"May modify or delete data"}),e[6]=t?.destructiveHint,e[7]=a):a=e[7];let c;e[8]!==t?.openWorldHint?(c=t?.openWorldHint&&p.jsx(Fr,{icon:p.jsx(Kr,{}),label:"Reaches outside this system"}),e[8]=t?.openWorldHint,e[9]=c):c=e[9];let u;return e[10]!==i||e[11]!==l||e[12]!==a||e[13]!==c?(u=p.jsxs(p.Fragment,{children:[i,l,a,c]}),e[10]=i,e[11]=l,e[12]=a,e[13]=c,e[14]=u):u=e[14],u}function mS(n){return n<1?`${Math.round(n*1e3)}ms`:n<10?`${n.toFixed(1)}s`:`${Math.round(n)}s`}function gS(n){const e=D.c(13),{latency:t,outputBytes:r}=n,s=typeof t=="number"&&t>0,o=typeof r=="number"&&r>=0;if(!s&&!o)return null;let i;e[0]!==s||e[1]!==t?(i=s&&p.jsx("span",{children:mS(t)}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]!==o||e[4]!==s?(l=s&&o&&p.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[3]=o,e[4]=s,e[5]=l):l=e[5];let a;e[6]!==o||e[7]!==r?(a=o&&p.jsx("span",{children:eS(r)}),e[6]=o,e[7]=r,e[8]=a):a=e[8];let c;return e[9]!==i||e[10]!==l||e[11]!==a?(c=p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-mono tabular-nums text-muted-foreground/60 px-1 leading-none",children:[i,l,a]}),e[9]=i,e[10]=l,e[11]=a,e[12]=c):c=e[12],c}function yS(n,e,t){switch(n){case"input-streaming":case"input-available":return"Preparing...";case"approval-requested":return"Waiting for your approval";case"output-denied":return"Cancelled";case"output-error":return t??"Failed";case"output-available":{if(e==null)return"Done";if(typeof e=="string"){const r=e.trim();return r.length>100?r.slice(0,100)+"…":r}if(typeof e=="object"){for(const r of Object.keys(e)){const s=e[r];if(typeof s=="string"&&s.trim()){const o=s.trim();return o.length>100?o.slice(0,100)+"…":o}}return""}return String(e).slice(0,100)}default:return""}}function yc(n){const e=D.c(74),{part:t,annotations:r,latency:s,outputBytes:o,isLastMessage:i,toolMeta:l}=n,a="toolName"in t&&typeof t.toolName=="string"?t.toolName:t.type==="dynamic-tool"?"Dynamic Tool":t.type.replace("tool-","")||"Tool",c=uf(a),u=Ln(),d=Hh(),{org:f}=Lt(),{setChatOpen:h}=lp(),m=Ri()?.taskId??null,{addOrReplaceEager:g}=Zk(m),y=Pn(),x=l&&typeof l=="object"&&l!==null&&"connectionId"in l&&l.connectionId!=null&&l.connectionId!==""?String(l.connectionId):d?.selectedVirtualMcp?.id??null,{toolDef:b}=tS(x?a:null,x,f.id,f.slug),k=b?._meta??l,v=Di(k),S=Pi(c,v),w=nS[S],C=b?.title??w?.label??qc(S);let T;e[0]!==k?(T=Pc(k),e[0]=k,e[1]=T):T=e[1];const N=T,E=!!N&&t.state==="output-available",j=x?`${x}:${a}`:null,L=!!r?.destructiveHint,I=E&&!!x&&!L&&!!m;let P;e[2]!==g||e[3]!==x||e[4]!==y||e[5]!==t||e[6]!==a?(P=()=>{if(!x)return;const he="input"in t&&t.input&&typeof t.input=="object"?t.input:{};g({toolName:a,appId:x,args:he}),y({to:".",search:we=>({...we,main:Gh(x,a)}),replace:!0})},e[2]=g,e[3]=x,e[4]=y,e[5]=t,e[6]=a,e[7]=P):P=e[7];const R=P;let z;e[8]!==I||e[9]!==R?(z=he=>he==="fullscreen"&&I?(R(),"fullscreen"):"inline",e[8]=I,e[9]=R,e[10]=z):z=e[10];const B=z;let $;e[11]!==u||e[12]!==h?($=he=>{const we=zh(he.content);we.content.length>0&&(h?.(!0),u?.sendMessage(we))},e[11]=u,e[12]=h,e[13]=$):$=e[13];const F=$,G=t.state==="approval-requested"&&i===!1,Q=t.state==="output-denied"||G,Z=t.state==="output-available"&&typeof t.output=="object"&&t.output!=null&&"isError"in t.output&&t.output.isError===!0;let se;e[14]!==t.state?(se=Ye(t.state),e[14]=t.state,e[15]=se):se=e[15];const Pe=se,Le=G||Pe==="approval"?"idle":Z?"error":Pe;let ze,Ke;if(e[16]!==Le||e[17]!==Z||e[18]!==G||e[19]!==t||e[20]!==S){ze=t.state==="output-error"?oo(t):void 0;const he=S==="bash"&&Le==="loading"&&t.input&&typeof t.input=="object"&&typeof t.input.command=="string"?t.input.command:null;let we;e[23]!==he?(we=he!==null?cS(he):null,e[23]=he,e[24]=we):we=e[24];const pe=we;let Nr;e[25]!==t.input||e[26]!==pe?(Nr=pe!==null?Math.min(pe,hS(t.input)):null,e[25]=t.input,e[26]=pe,e[27]=Nr):Nr=e[27];const jl=Nr,dh="toolCallId"in t?t.toolCallId:"";Ke=jl!==null?p.jsx(lS,{toolCallId:dh,durationMs:jl,anchorMs:fS(t)}):G?"Cancelled":Z?"Failed":yS(t.state,t.output,ze),e[16]=Le,e[17]=Z,e[18]=G,e[19]=t,e[20]=S,e[21]=ze,e[22]=Ke}else ze=e[21],Ke=e[22];const gt=Ke;let K="";t.input!==void 0&&(K=`# Input
|
|
164
164
|
`+_s(t.input)),t.state==="output-error"?(K&&(K=K+`
|
|
165
165
|
|
|
166
166
|
`),K=K+(`# Error
|
|
167
167
|
`+(ze??""))):t.output!==void 0&&!E&&(K&&(K=K+`
|
|
168
168
|
|
|
169
169
|
`),K=K+(`# Output
|
|
170
|
-
`+_s(t.output)));let oe;e:{if(Q){let pe;e[28]===Symbol.for("react.memo_cache_sentinel")?(pe=p.jsx(
|
|
170
|
+
`+_s(t.output)));let oe;e:{if(Q){let pe;e[28]===Symbol.for("react.memo_cache_sentinel")?(pe=p.jsx(ep,{}),e[28]=pe):pe=e[28],oe=pe;break e}if(E){let pe;e[29]===Symbol.for("react.memo_cache_sentinel")?(pe=p.jsx(Ec,{className:"size-4 text-muted-foreground"}),e[29]=pe):pe=e[29],oe=pe;break e}const he=w?.icon;if(he){let pe;e[30]!==he?(pe=p.jsx(he,{className:"size-4 text-muted-foreground"}),e[30]=he,e[31]=pe):pe=e[31],oe=pe;break e}let we;e[32]===Symbol.for("react.memo_cache_sentinel")?(we=p.jsx(Ih,{className:"size-4 text-muted-foreground"}),e[32]=we):we=e[32],oe=we}let ve;e[33]!==r||e[34]!==l?(ve=p.jsx(pS,{annotations:r,toolMeta:l}),e[33]=r,e[34]=l,e[35]=ve):ve=e[35];let Re;e[36]!==s||e[37]!==o?(Re=p.jsx(gS,{latency:s,outputBytes:o}),e[36]=s,e[37]=o,e[38]=Re):Re=e[38];let it;e[39]!==ve||e[40]!==Re?(it=p.jsxs(p.Fragment,{children:[ve,Re]}),e[39]=ve,e[40]=Re,e[41]=it):it=e[41];const co=K||null;let pn;e[42]!==Le||e[43]!==C||e[44]!==Q||e[45]!==s||e[46]!==gt||e[47]!==it||e[48]!==co||e[49]!==oe?(pn=p.jsx(J,{icon:oe,iconDestructive:Q,trailing:it,title:C,latency:s,summary:gt,state:Le,detail:co}),e[42]=Le,e[43]=C,e[44]=Q,e[45]=s,e[46]=gt,e[47]=it,e[48]=co,e[49]=oe,e[50]=pn):pn=e[50];let mn;e[51]!==I||e[52]!==R?(mn=I&&p.jsx("div",{className:"flex justify-end mt-1.5 mb-1",children:p.jsxs("button",{type:"button",onClick:R,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground rounded-md [@media(hover:hover)]:hover:bg-accent/50 [@media(hover:hover)]:hover:text-foreground transition-colors",children:[p.jsx(Rh,{className:"size-3.5"}),"Open in panel"]})}),e[51]=I,e[52]=R,e[53]=mn):mn=e[53];let gn;e[54]!==I||e[55]!==d||e[56]!==x||e[57]!==C||e[58]!==F||e[59]!==B||e[60]!==E||e[61]!==k||e[62]!==f.id||e[63]!==f.slug||e[64]!==t.input||e[65]!==t.output||e[66]!==j||e[67]!==S||e[68]!==N?(gn=E&&N&&x&&f?.id&&p.jsx(p.Fragment,{children:p.jsx(vh,{fallback:he=>{const{resetError:we}=he;return p.jsxs("div",{className:"mt-2 flex items-center gap-2 px-3 py-2.5 border border-dashed border-destructive/30 bg-destructive/5 rounded-lg",children:[p.jsx(_c,{size:16,className:"shrink-0 text-destructive"}),p.jsxs("span",{className:"flex-1 text-xs text-destructive font-medium",children:["Failed to load"," ",p.jsx("span",{className:"font-mono",children:C})," app"]}),p.jsxs(ir,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1.5 shrink-0",onClick:we,children:[p.jsx(Mc,{className:"size-3.5"}),"Retry"]})]})},children:p.jsx(M.Suspense,{fallback:p.jsx("div",{className:"mt-2 flex items-center justify-center h-12 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[p.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),p.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),children:p.jsx(kS,{uiResourceUri:N,connectionId:x,orgId:f.id,orgSlug:f.slug,toolName:S,toolInput:t.input,toolResult:t.output,toolMeta:k,onMessage:F,onUpdateModelContext:j&&d?he=>d.setAppContext(j,he):void 0,onTeardown:j&&d?()=>d.clearAppContext(j):void 0,onRequestDisplayMode:I?B:void 0})})})}),e[54]=I,e[55]=d,e[56]=x,e[57]=C,e[58]=F,e[59]=B,e[60]=E,e[61]=k,e[62]=f.id,e[63]=f.slug,e[64]=t.input,e[65]=t.output,e[66]=j,e[67]=S,e[68]=N,e[69]=gn):gn=e[69];let Tr;return e[70]!==pn||e[71]!==mn||e[72]!==gn?(Tr=p.jsxs("div",{children:[pn,mn,gn]}),e[70]=pn,e[71]=mn,e[72]=gn,e[73]=Tr):Tr=e[73],Tr}function Ff(n){return typeof n=="object"&&n!=null&&"type"in n&&n.type==="mcpToolCall"}function xS(n){if(n!=null)return Ff(n)?n.arguments??void 0:n}function bS(n){if(n==null)return;if(Ff(n)&&n.result!=null)return n.result;if(typeof n=="object"&&"content"in n&&Array.isArray(n.content)){const t=n.content;if(t.length>0&&typeof t[0]=="object"&&t[0]!=null&&"type"in t[0])return n}const e=typeof n=="string"?n:JSON.stringify(n);return{structuredContent:typeof n=="object"&&!Array.isArray(n)?n:void 0,content:[{type:"text",text:e}]}}function kS(n){const e=D.c(27),{uiResourceUri:t,connectionId:r,orgId:s,orgSlug:o,toolName:i,toolInput:l,toolResult:a,toolMeta:c,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h}=n;let m;e[0]!==r||e[1]!==s||e[2]!==o?(m={connectionId:r,orgId:s,orgSlug:o},e[0]=r,e[1]=s,e[2]=o,e[3]=m):m=e[3];const g=Lc(m);let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y={type:"object"},e[4]=y):y=e[4];let x;e[5]!==c?(x=c!=null&&{_meta:c},e[5]=c,e[6]=x):x=e[6];let b;e[7]!==x||e[8]!==i?(b={name:i,inputSchema:y,...x},e[7]=x,e[8]=i,e[9]=b):b=e[9];const k=b;let v;e[10]!==k?(v={tool:k},e[10]=k,e[11]=v):v=e[11];let S;e[12]!==l?(S=xS(l),e[12]=l,e[13]=S):S=e[13];let w;e[14]!==a?(w=bS(a),e[14]=a,e[15]=w):w=e[15];let C;return e[16]!==g||e[17]!==u||e[18]!==h||e[19]!==f||e[20]!==d||e[21]!==s||e[22]!==v||e[23]!==S||e[24]!==w||e[25]!==t?(C=p.jsx("div",{className:"mt-2 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsx(Bh,{resourceURI:t,orgId:s,toolInfo:v,toolInput:S,toolResult:w,client:g,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h})}),e[16]=g,e[17]=u,e[18]=h,e[19]=f,e[20]=d,e[21]=s,e[22]=v,e[23]=S,e[24]=w,e[25]=t,e[26]=C):C=e[26],C}const xc="mesh-storage://";function io(n){return n.startsWith(xc)?n.slice(xc.length):null}function Hf(n,e){const t=io(n);return t!==null?`/api/${e}/files/${t}`:n}function SS(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;return r?{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:0,cacheReadTokens:0,cacheWriteTokens:0}:null}function vS(n){const e=D.c(13),{uri:t,orgSlug:r}=n;let s;e[0]!==r||e[1]!==t?(s=Hf(t,r),e[0]=r,e[1]=t,e[2]=s):s=e[2];const o=s;let i;e[3]!==t?(i=io(t)!==null?t.slice(t.lastIndexOf("/")+1):"reference",e[3]=t,e[4]=i):i=e[4];const l=i;let a;e[5]!==l?(a=p.jsx(tn,{asChild:!0,children:p.jsx("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 rounded bg-muted text-muted-foreground text-xs cursor-default select-none",children:l})}),e[5]=l,e[6]=a):a=e[6];let c;e[7]!==l||e[8]!==o?(c=p.jsx(nn,{side:"top",className:"max-w-sm p-1.5",children:p.jsx("img",{src:o,alt:l,className:"max-w-full max-h-64 object-contain rounded"})}),e[7]=l,e[8]=o,e[9]=c):c=e[9];let u;return e[10]!==a||e[11]!==c?(u=p.jsxs(rn,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=u):u=e[12],u}function wS(n){const e=D.c(76),{part:t,latency:r}=n,s=Ei();let o;e[0]!==t.state?(o=Ye(t.state),e[0]=t.state,e[1]=o):o=e[1];const i=o,l=t.input,a=t.output,c=a?.images;let u;e[2]!==a?(u=SS(a),e[2]=a,e[3]=u):u=e[3];const d=u,f=a?.model;let h,m,g,y,x,b,k,v,S,w,C,T;if(e[4]!==c||e[5]!==l||e[6]!==r||e[7]!==f||e[8]!==s||e[9]!==t||e[10]!==a||e[11]!==i||e[12]!==d){x=Symbol.for("react.early_return_sentinel");e:{const P=Array.isArray(l?.referenceImages)?l.referenceImages.filter(CS):void 0;let R;e[25]!==r?(R=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Rt(r)}):null,e[25]=r,e[26]=R):R=e[26];const z=R;if(i==="loading"){let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=p.jsx(Er,{size:14}),e[27]=B):B=e[27];let $;e[28]!==l?($=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[28]=l,e[29]=$):$=e[29];let F;e[30]!==$?(F=p.jsx(J,{icon:B,title:"Generating image",summary:$,state:"loading"}),e[30]=$,e[31]=F):F=e[31],x=F;break e}if(a?.background){let B;e[32]===Symbol.for("react.memo_cache_sentinel")?(B=p.jsx(Er,{size:14}),e[32]=B):B=e[32];let $;e[33]!==l?($=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[33]=l,e[34]=$):$=e[34];let F;e[35]!==$?(F=p.jsx(J,{icon:B,title:"Image queued — generating in the background",summary:$,state:"idle"}),e[35]=$,e[36]=F):F=e[36],x=F;break e}if(i==="error"||!c||c.length===0){let B;e[37]!==t||e[38]!==i?(B=i==="error"?oo(t):void 0,e[37]=t,e[38]=i,e[39]=B):B=e[39];const $=B;let F="";l!==void 0&&(F=`# Input
|
|
171
171
|
`+_s(l)),$?(F&&(F=F+`
|
|
172
172
|
|
|
173
173
|
`),F=F+(`# Error
|
|
174
174
|
`+$)):a!==void 0&&(F&&(F=F+`
|
|
175
175
|
|
|
176
176
|
`),F=F+(`# Output
|
|
177
|
-
`+_s(a)));let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=p.jsx(Er,{size:14}),e[40]=G):G=e[40];const Q=i==="error"?"Failed":"No images generated",Z=i==="error"?"error":"idle",se=F||null;let Pe;e[41]!==z||e[42]!==Q||e[43]!==Z||e[44]!==se||e[45]!==d?(Pe=p.jsx(J,{icon:G,title:"Image generation",summary:Q,state:Z,usage:d,trailing:z,detail:se}),e[41]=z,e[42]=Q,e[43]=Z,e[44]=se,e[45]=d,e[46]=Pe):Pe=e[46],x=Pe;break e}y="flex flex-col gap-2",h=J,e[47]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Er,{size:14,className:"text-pink-500"}),e[47]=S):S=e[47],w="Generated image",C=f,T="idle",m=d,g=z,b="flex flex-col gap-1 pb-2 pl-6",e[48]!==l?(k=l?.prompt&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:l.prompt}),e[48]=l,e[49]=k):k=e[49],v=P&&P.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"references:"}),P.map((B,$)=>{const F=B.uri??B.url;return p.jsx(vS,{uri:F,orgSlug:s.slug},$)})]})}e[4]=c,e[5]=l,e[6]=r,e[7]=f,e[8]=s,e[9]=t,e[10]=a,e[11]=i,e[12]=d,e[13]=h,e[14]=m,e[15]=g,e[16]=y,e[17]=x,e[18]=b,e[19]=k,e[20]=v,e[21]=S,e[22]=w,e[23]=C,e[24]=T}else h=e[13],m=e[14],g=e[15],y=e[16],x=e[17],b=e[18],k=e[19],v=e[20],S=e[21],w=e[22],C=e[23],T=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let N;e[50]!==b||e[51]!==k||e[52]!==v?(N=p.jsxs("div",{className:b,children:[k,v]}),e[50]=b,e[51]=k,e[52]=v,e[53]=N):N=e[53];let E;e[54]!==h||e[55]!==m||e[56]!==g||e[57]!==N||e[58]!==S||e[59]!==w||e[60]!==C||e[61]!==T?(E=p.jsx(h,{icon:S,title:w,summary:C,state:T,usage:m,trailing:g,children:N}),e[54]=h,e[55]=m,e[56]=g,e[57]=N,e[58]=S,e[59]=w,e[60]=C,e[61]=T,e[62]=E):E=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let P;e[67]!==l?.prompt||e[68]!==s?(P=(R,z)=>{const B=R.uri??R.url;if(!B)return null;const $=Hf(B,s.slug);return p.jsx(Pc,{src:$,alt:l?.prompt??"Generated image",children:p.jsx("img",{src:$,alt:l?.prompt??"Generated image",className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"})},z)},e[67]=l?.prompt,e[68]=s,e[69]=P):P=e[69],j=c.map(P),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let L;e[70]!==j?(L=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=L):L=e[71];let I;return e[72]!==y||e[73]!==E||e[74]!==L?(I=p.jsxs("div",{className:y,children:[E,L]}),e[72]=y,e[73]=E,e[74]=L,e[75]=I):I=e[75],I}function CS(n){return n.uri??n.url}function TS(n,e){const t=io(n);return t!==null?`/api/${e}/files/${t}`:n}function NS(n){const e=D.c(26),{part:t,latency:r}=n,s=Ei(),o=Ye(t.state),i=t.input,l=t.output,a=l?.image?.uri,c=l?.url??i?.url;let u;e[0]!==r?(u=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Rt(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(o==="loading"){let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Jn,{size:14}),e[2]=S):S=e[2];let w;return e[3]!==c?(w=p.jsx(J,{icon:S,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=w):w=e[4],w}if(o==="error"||l?.success===!1||!a){let S;e[5]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Jn,{size:14}),e[5]=S):S=e[5];const w=l?.error??"Failed";let C;return e[6]!==d||e[7]!==w?(C=p.jsx(J,{icon:S,title:"Take screenshot",summary:w,state:"error",trailing:d}),e[6]=d,e[7]=w,e[8]=C):C=e[8],C}let f;e[9]!==s.slug||e[10]!==a?(f=TS(a,s.slug),e[9]=s.slug,e[10]=a,e[11]=f):f=e[11];const h=f;let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(Jn,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(J,{icon:m,title:"Screenshot",summary:c,state:"idle",trailing:d}),e[13]=d,e[14]=c,e[15]=g):g=e[15];const y=c??"Screenshot",x=c??"Screenshot";let b;e[16]!==h||e[17]!==x?(b=p.jsx("img",{src:h,alt:x,className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"}),e[16]=h,e[17]=x,e[18]=b):b=e[18];let k;e[19]!==h||e[20]!==y||e[21]!==b?(k=p.jsx("div",{className:"flex flex-wrap gap-2",children:p.jsx(Pc,{src:h,alt:y,children:b})}),e[19]=h,e[20]=y,e[21]=b,e[22]=k):k=e[22];let v;return e[23]!==g||e[24]!==k?(v=p.jsxs("div",{className:"flex flex-col gap-2",children:[g,k]}),e[23]=g,e[24]=k,e[25]=v):v=e[25],v}function MS(n,e){const t=io(n);return t!==null?`/api/${e}/files/${t}`:n}function ES(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;if(!r)return null;const s={providerMetadata:n.usage.providerMetadata};return{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:Vc(s),cacheReadTokens:0,cacheWriteTokens:0}}function AS(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function OS(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function IS(n){const e=D.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=AS(t.url),e[0]=t.url,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.url?(i=OS(t.url),e[2]=t.url,e[3]=i):i=e[3];const l=i,a=t.title||o;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:RS}),e[4]=l,e[5]=c):c=e[5];let u;e[6]!==a?(u=p.jsx("span",{className:"truncate max-w-[180px]",children:a}),e[6]=a,e[7]=u):u=e[7];const d=r+1;let f;e[8]!==d?(f=p.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0",children:["[",d,"]"]}),e[8]=d,e[9]=f):f=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Fc,{size:10,className:"shrink-0 opacity-0 group-hover/src:opacity-100 transition-opacity"}),e[10]=h):h=e[10];let m;return e[11]!==t.url||e[12]!==c||e[13]!==u||e[14]!==f?(m=p.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"group/src inline-flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:[c,u,f,h]}),e[11]=t.url,e[12]=c,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function RS(n){n.target.style.display="none"}function jS(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,o=e[s];return o?`[\\[${r}\\]](${o.url})`:t})}const Fo=5;function DS(n){const e=D.c(12),{citations:t}=n,[r,s]=M.useState(!1),o=t.length>Fo;let i;e[0]!==t||e[1]!==r?(i=r?t:t.slice(0,Fo),e[0]=t,e[1]=r,e[2]=i):i=e[2];const l=i;let a;e[3]!==l?(a=l.map(LS),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==o?(c=o&&p.jsx("button",{type:"button",onClick:()=>s(PS),className:"inline-flex items-center rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:r?"show less":`+${t.length-Fo} more`}),e[5]=t.length,e[6]=r,e[7]=o,e[8]=c):c=e[8];let u;return e[9]!==a||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a,c]}),e[9]=a,e[10]=c,e[11]=u):u=e[11],u}function PS(n){return!n}function LS(n,e){return p.jsx(IS,{citation:n,index:e},n.url)}function _S(n){const e=D.c(51),{part:t,latency:r,streamingText:s}=n,o=Ei();let i;e[0]!==t.state?(i=Ye(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i,a=t.input,c=t.output;let u,d,f;e[2]!==o||e[3]!==c?(u=c?.uri?MS(c.uri,o.slug):void 0,f=Mi,d=Wt.webSearchBlob(u??""),e[2]=o,e[3]=c,e[4]=u,e[5]=d,e[6]=f):(u=e[4],d=e[5],f=e[6]);let h;e[7]!==u?(h=async()=>{const Z=await fetch(u);if(!Z.ok)throw new Error(`Failed to fetch: ${Z.status}`);return Z.text()},e[7]=u,e[8]=h):h=e[8];const m=!!u;let g;e[9]!==d||e[10]!==h||e[11]!==m?(g={queryKey:d,queryFn:h,enabled:m,staleTime:1/0},e[9]=d,e[10]=h,e[11]=m,e[12]=g):g=e[12];const{data:y}=f(g),x=l==="loading",b=l!=="loading"&&l!=="error",k=c?.citations;let v;e[13]!==c?(v=ES(c),e[13]=c,e[14]=v):v=e[14];const S=v,w=c?.content??y??s;let C;e[15]!==k||e[16]!==w?(C=w&&k?.length?jS(w,k):w,e[15]=k,e[16]=w,e[17]=C):C=e[17];const T=C;let N;e[18]!==r?(N=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Rt(r)}):null,e[18]=r,e[19]=N):N=e[19];const E=N;if(l==="error"){let Z;e[20]===Symbol.for("react.memo_cache_sentinel")?(Z=p.jsx(Kr,{size:14}),e[20]=Z):Z=e[20];let se;return e[21]!==E||e[22]!==S?(se=p.jsx(J,{icon:Z,title:"Web search",summary:"Failed",state:"error",usage:S,trailing:E}),e[21]=E,e[22]=S,e[23]=se):se=e[23],se}const j=x?"animate-pulse":"text-blue-500";let L;e[24]!==j?(L=X(j),e[24]=j,e[25]=L):L=e[25];let I;e[26]!==L?(I=p.jsx(Kr,{size:14,className:L}),e[26]=L,e[27]=I):I=e[27];const P=x?"Researching...":"Web search";let R;e[28]!==a||e[29]!==b||e[30]!==c?.model?(R=b?c?.model??a?.query?.slice(0,60):a?.query?`"${a.query.slice(0,80)}"`:void 0,e[28]=a,e[29]=b,e[30]=c?.model,e[31]=R):R=e[31];const z=x?"loading":"idle";let B;e[32]!==a?(B=a?.query&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:a.query}),e[32]=a,e[33]=B):B=e[33];let $;e[34]!==T||e[35]!==t.toolCallId?($=T?p.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-hidden rounded-lg border border-border/40 bg-muted/20 px-4 py-3 min-w-0",children:p.jsx("div",{className:"prose prose-sm prose-neutral dark:prose-invert max-w-none text-[13px] leading-relaxed break-words",children:p.jsx(Ii,{id:t.toolCallId,text:T})})}):p.jsx("div",{className:"rounded-lg border border-border/40 bg-muted/20 px-4 py-3",children:p.jsxs("div",{className:"space-y-2 animate-pulse",children:[p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-3/4"}),p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-1/2"})]})}),e[34]=T,e[35]=t.toolCallId,e[36]=$):$=e[36];let F;e[37]!==k?(F=k&&k.length>0&&p.jsx(DS,{citations:k}),e[37]=k,e[38]=F):F=e[38];let G;e[39]!==B||e[40]!==$||e[41]!==F?(G=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[B,$,F]}),e[39]=B,e[40]=$,e[41]=F,e[42]=G):G=e[42];let Q;return e[43]!==E||e[44]!==I||e[45]!==P||e[46]!==R||e[47]!==z||e[48]!==G||e[49]!==S?(Q=p.jsx(J,{icon:I,title:P,summary:R,state:z,usage:S,trailing:E,defaultOpen:!0,children:G}),e[43]=E,e[44]=I,e[45]=P,e[46]=R,e[47]=z,e[48]=G,e[49]=S,e[50]=Q):Q=e[50],Q}function $S(n){const e=D.c(14),{part:t}=n;if(!t.state.startsWith("output-"))return null;let r;e[0]!==t.input?.prompt?(r=t.input?.prompt?.trim()||"Question",e[0]=t.input?.prompt,e[1]=r):r=e[1];const s=r,o=t.state==="output-error"||t.state==="output-denied",i=t.state==="output-denied";let l;e[2]!==i||e[3]!==t?(l=i?"Skipped":t.state==="output-error"?oo(t)??"Error":t.output?.response??"",e[2]=i,e[3]=t,e[4]=l):l=e[4];const a=l;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(_h,{className:"size-4 text-muted-foreground/50 shrink-0 mt-0.5"}),e[5]=c):c=e[5];let u;e[6]!==s?(u=p.jsxs("div",{className:"flex items-start gap-2",children:[c,p.jsx("span",{className:"text-[14px] text-muted-foreground leading-snug",children:s})]}),e[6]=s,e[7]=u):u=e[7];let d;e[8]!==a||e[9]!==o?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:X("text-[14px] leading-snug",o?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13],f}const Vf=M.createContext(new Map);function D2(n){const e=D.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const i of t){const l=i.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(i):s.set(l,[i])}e[0]=t,e[1]=s}else s=e[1];let o;return e[2]!==s||e[3]!==r?(o=p.jsx(Vf.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function zS(n){const e=D.c(3),t=M.useContext(Vf);let r;return e[0]!==n||e[1]!==t?(r=n?t.get(n)??[]:[],e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function BS(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:o,value:i}=await t.read();if(o)break;s+=r.decode(i,{stream:!0});let l;for(;(l=s.indexOf(`
|
|
177
|
+
`+_s(a)));let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=p.jsx(Er,{size:14}),e[40]=G):G=e[40];const Q=i==="error"?"Failed":"No images generated",Z=i==="error"?"error":"idle",se=F||null;let Pe;e[41]!==z||e[42]!==Q||e[43]!==Z||e[44]!==se||e[45]!==d?(Pe=p.jsx(J,{icon:G,title:"Image generation",summary:Q,state:Z,usage:d,trailing:z,detail:se}),e[41]=z,e[42]=Q,e[43]=Z,e[44]=se,e[45]=d,e[46]=Pe):Pe=e[46],x=Pe;break e}y="flex flex-col gap-2",h=J,e[47]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Er,{size:14,className:"text-pink-500"}),e[47]=S):S=e[47],w="Generated image",C=f,T="idle",m=d,g=z,b="flex flex-col gap-1 pb-2 pl-6",e[48]!==l?(k=l?.prompt&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:l.prompt}),e[48]=l,e[49]=k):k=e[49],v=P&&P.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"references:"}),P.map((B,$)=>{const F=B.uri??B.url;return p.jsx(vS,{uri:F,orgSlug:s.slug},$)})]})}e[4]=c,e[5]=l,e[6]=r,e[7]=f,e[8]=s,e[9]=t,e[10]=a,e[11]=i,e[12]=d,e[13]=h,e[14]=m,e[15]=g,e[16]=y,e[17]=x,e[18]=b,e[19]=k,e[20]=v,e[21]=S,e[22]=w,e[23]=C,e[24]=T}else h=e[13],m=e[14],g=e[15],y=e[16],x=e[17],b=e[18],k=e[19],v=e[20],S=e[21],w=e[22],C=e[23],T=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let N;e[50]!==b||e[51]!==k||e[52]!==v?(N=p.jsxs("div",{className:b,children:[k,v]}),e[50]=b,e[51]=k,e[52]=v,e[53]=N):N=e[53];let E;e[54]!==h||e[55]!==m||e[56]!==g||e[57]!==N||e[58]!==S||e[59]!==w||e[60]!==C||e[61]!==T?(E=p.jsx(h,{icon:S,title:w,summary:C,state:T,usage:m,trailing:g,children:N}),e[54]=h,e[55]=m,e[56]=g,e[57]=N,e[58]=S,e[59]=w,e[60]=C,e[61]=T,e[62]=E):E=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let P;e[67]!==l?.prompt||e[68]!==s?(P=(R,z)=>{const B=R.uri??R.url;if(!B)return null;const $=Hf(B,s.slug);return p.jsx(Dc,{src:$,alt:l?.prompt??"Generated image",children:p.jsx("img",{src:$,alt:l?.prompt??"Generated image",className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"})},z)},e[67]=l?.prompt,e[68]=s,e[69]=P):P=e[69],j=c.map(P),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let L;e[70]!==j?(L=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=L):L=e[71];let I;return e[72]!==y||e[73]!==E||e[74]!==L?(I=p.jsxs("div",{className:y,children:[E,L]}),e[72]=y,e[73]=E,e[74]=L,e[75]=I):I=e[75],I}function CS(n){return n.uri??n.url}function TS(n,e){const t=io(n);return t!==null?`/api/${e}/files/${t}`:n}function NS(n){const e=D.c(26),{part:t,latency:r}=n,s=Ei(),o=Ye(t.state),i=t.input,l=t.output,a=l?.image?.uri,c=l?.url??i?.url;let u;e[0]!==r?(u=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Rt(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(o==="loading"){let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Jn,{size:14}),e[2]=S):S=e[2];let w;return e[3]!==c?(w=p.jsx(J,{icon:S,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=w):w=e[4],w}if(o==="error"||l?.success===!1||!a){let S;e[5]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Jn,{size:14}),e[5]=S):S=e[5];const w=l?.error??"Failed";let C;return e[6]!==d||e[7]!==w?(C=p.jsx(J,{icon:S,title:"Take screenshot",summary:w,state:"error",trailing:d}),e[6]=d,e[7]=w,e[8]=C):C=e[8],C}let f;e[9]!==s.slug||e[10]!==a?(f=TS(a,s.slug),e[9]=s.slug,e[10]=a,e[11]=f):f=e[11];const h=f;let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(Jn,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(J,{icon:m,title:"Screenshot",summary:c,state:"idle",trailing:d}),e[13]=d,e[14]=c,e[15]=g):g=e[15];const y=c??"Screenshot",x=c??"Screenshot";let b;e[16]!==h||e[17]!==x?(b=p.jsx("img",{src:h,alt:x,className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"}),e[16]=h,e[17]=x,e[18]=b):b=e[18];let k;e[19]!==h||e[20]!==y||e[21]!==b?(k=p.jsx("div",{className:"flex flex-wrap gap-2",children:p.jsx(Dc,{src:h,alt:y,children:b})}),e[19]=h,e[20]=y,e[21]=b,e[22]=k):k=e[22];let v;return e[23]!==g||e[24]!==k?(v=p.jsxs("div",{className:"flex flex-col gap-2",children:[g,k]}),e[23]=g,e[24]=k,e[25]=v):v=e[25],v}function MS(n,e){const t=io(n);return t!==null?`/api/${e}/files/${t}`:n}function ES(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;if(!r)return null;const s={providerMetadata:n.usage.providerMetadata};return{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:Vc(s),cacheReadTokens:0,cacheWriteTokens:0}}function AS(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function OS(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function IS(n){const e=D.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=AS(t.url),e[0]=t.url,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.url?(i=OS(t.url),e[2]=t.url,e[3]=i):i=e[3];const l=i,a=t.title||o;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:RS}),e[4]=l,e[5]=c):c=e[5];let u;e[6]!==a?(u=p.jsx("span",{className:"truncate max-w-[180px]",children:a}),e[6]=a,e[7]=u):u=e[7];const d=r+1;let f;e[8]!==d?(f=p.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0",children:["[",d,"]"]}),e[8]=d,e[9]=f):f=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Fc,{size:10,className:"shrink-0 opacity-0 group-hover/src:opacity-100 transition-opacity"}),e[10]=h):h=e[10];let m;return e[11]!==t.url||e[12]!==c||e[13]!==u||e[14]!==f?(m=p.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"group/src inline-flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:[c,u,f,h]}),e[11]=t.url,e[12]=c,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function RS(n){n.target.style.display="none"}function jS(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,o=e[s];return o?`[\\[${r}\\]](${o.url})`:t})}const Fo=5;function DS(n){const e=D.c(12),{citations:t}=n,[r,s]=M.useState(!1),o=t.length>Fo;let i;e[0]!==t||e[1]!==r?(i=r?t:t.slice(0,Fo),e[0]=t,e[1]=r,e[2]=i):i=e[2];const l=i;let a;e[3]!==l?(a=l.map(LS),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==o?(c=o&&p.jsx("button",{type:"button",onClick:()=>s(PS),className:"inline-flex items-center rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:r?"show less":`+${t.length-Fo} more`}),e[5]=t.length,e[6]=r,e[7]=o,e[8]=c):c=e[8];let u;return e[9]!==a||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a,c]}),e[9]=a,e[10]=c,e[11]=u):u=e[11],u}function PS(n){return!n}function LS(n,e){return p.jsx(IS,{citation:n,index:e},n.url)}function _S(n){const e=D.c(51),{part:t,latency:r,streamingText:s}=n,o=Ei();let i;e[0]!==t.state?(i=Ye(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i,a=t.input,c=t.output;let u,d,f;e[2]!==o||e[3]!==c?(u=c?.uri?MS(c.uri,o.slug):void 0,f=Mi,d=Wt.webSearchBlob(u??""),e[2]=o,e[3]=c,e[4]=u,e[5]=d,e[6]=f):(u=e[4],d=e[5],f=e[6]);let h;e[7]!==u?(h=async()=>{const Z=await fetch(u);if(!Z.ok)throw new Error(`Failed to fetch: ${Z.status}`);return Z.text()},e[7]=u,e[8]=h):h=e[8];const m=!!u;let g;e[9]!==d||e[10]!==h||e[11]!==m?(g={queryKey:d,queryFn:h,enabled:m,staleTime:1/0},e[9]=d,e[10]=h,e[11]=m,e[12]=g):g=e[12];const{data:y}=f(g),x=l==="loading",b=l!=="loading"&&l!=="error",k=c?.citations;let v;e[13]!==c?(v=ES(c),e[13]=c,e[14]=v):v=e[14];const S=v,w=c?.content??y??s;let C;e[15]!==k||e[16]!==w?(C=w&&k?.length?jS(w,k):w,e[15]=k,e[16]=w,e[17]=C):C=e[17];const T=C;let N;e[18]!==r?(N=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Rt(r)}):null,e[18]=r,e[19]=N):N=e[19];const E=N;if(l==="error"){let Z;e[20]===Symbol.for("react.memo_cache_sentinel")?(Z=p.jsx(Kr,{size:14}),e[20]=Z):Z=e[20];let se;return e[21]!==E||e[22]!==S?(se=p.jsx(J,{icon:Z,title:"Web search",summary:"Failed",state:"error",usage:S,trailing:E}),e[21]=E,e[22]=S,e[23]=se):se=e[23],se}const j=x?"animate-pulse":"text-blue-500";let L;e[24]!==j?(L=X(j),e[24]=j,e[25]=L):L=e[25];let I;e[26]!==L?(I=p.jsx(Kr,{size:14,className:L}),e[26]=L,e[27]=I):I=e[27];const P=x?"Researching...":"Web search";let R;e[28]!==a||e[29]!==b||e[30]!==c?.model?(R=b?c?.model??a?.query?.slice(0,60):a?.query?`"${a.query.slice(0,80)}"`:void 0,e[28]=a,e[29]=b,e[30]=c?.model,e[31]=R):R=e[31];const z=x?"loading":"idle";let B;e[32]!==a?(B=a?.query&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:a.query}),e[32]=a,e[33]=B):B=e[33];let $;e[34]!==T||e[35]!==t.toolCallId?($=T?p.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-hidden rounded-lg border border-border/40 bg-muted/20 px-4 py-3 min-w-0",children:p.jsx("div",{className:"prose prose-sm prose-neutral dark:prose-invert max-w-none text-[13px] leading-relaxed break-words",children:p.jsx(Ii,{id:t.toolCallId,text:T})})}):p.jsx("div",{className:"rounded-lg border border-border/40 bg-muted/20 px-4 py-3",children:p.jsxs("div",{className:"space-y-2 animate-pulse",children:[p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-3/4"}),p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-1/2"})]})}),e[34]=T,e[35]=t.toolCallId,e[36]=$):$=e[36];let F;e[37]!==k?(F=k&&k.length>0&&p.jsx(DS,{citations:k}),e[37]=k,e[38]=F):F=e[38];let G;e[39]!==B||e[40]!==$||e[41]!==F?(G=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[B,$,F]}),e[39]=B,e[40]=$,e[41]=F,e[42]=G):G=e[42];let Q;return e[43]!==E||e[44]!==I||e[45]!==P||e[46]!==R||e[47]!==z||e[48]!==G||e[49]!==S?(Q=p.jsx(J,{icon:I,title:P,summary:R,state:z,usage:S,trailing:E,defaultOpen:!0,children:G}),e[43]=E,e[44]=I,e[45]=P,e[46]=R,e[47]=z,e[48]=G,e[49]=S,e[50]=Q):Q=e[50],Q}function $S(n){const e=D.c(14),{part:t}=n;if(!t.state.startsWith("output-"))return null;let r;e[0]!==t.input?.prompt?(r=t.input?.prompt?.trim()||"Question",e[0]=t.input?.prompt,e[1]=r):r=e[1];const s=r,o=t.state==="output-error"||t.state==="output-denied",i=t.state==="output-denied";let l;e[2]!==i||e[3]!==t?(l=i?"Skipped":t.state==="output-error"?oo(t)??"Error":t.output?.response??"",e[2]=i,e[3]=t,e[4]=l):l=e[4];const a=l;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(_h,{className:"size-4 text-muted-foreground/50 shrink-0 mt-0.5"}),e[5]=c):c=e[5];let u;e[6]!==s?(u=p.jsxs("div",{className:"flex items-start gap-2",children:[c,p.jsx("span",{className:"text-[14px] text-muted-foreground leading-snug",children:s})]}),e[6]=s,e[7]=u):u=e[7];let d;e[8]!==a||e[9]!==o?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:X("text-[14px] leading-snug",o?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13],f}const Vf=M.createContext(new Map);function _2(n){const e=D.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const i of t){const l=i.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(i):s.set(l,[i])}e[0]=t,e[1]=s}else s=e[1];let o;return e[2]!==s||e[3]!==r?(o=p.jsx(Vf.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function zS(n){const e=D.c(3),t=M.useContext(Vf);let r;return e[0]!==n||e[1]!==t?(r=n?t.get(n)??[]:[],e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function BS(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:o,value:i}=await t.read();if(o)break;s+=r.decode(i,{stream:!0});let l;for(;(l=s.indexOf(`
|
|
178
178
|
|
|
179
179
|
`))!==-1;){const a=s.slice(0,l);s=s.slice(l+2);const c=a.split(`
|
|
180
180
|
`).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trim()).join(`
|
|
181
|
-
`);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{t.releaseLock(),e.close()}}})}function FS(n){const{orgSlug:e,threadId:t,jobId:r,enabled:s}=n,[o,i]=M.useState([]),[l,a]=M.useState(!1);return M.useEffect(()=>{if(!s||!r)return;const c=new AbortController;return i([]),a(!0),(async()=>{try{const u=await fetch(`/api/${encodeURIComponent(e)}/decopilot/threads/${encodeURIComponent(t)}/jobs/${encodeURIComponent(r)}/stream`,{headers:{accept:"text/event-stream"},credentials:"include",signal:c.signal});if(!u.ok||!u.body)return;for await(const d of
|
|
181
|
+
`);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{t.releaseLock(),e.close()}}})}function FS(n){const{orgSlug:e,threadId:t,jobId:r,enabled:s}=n,[o,i]=M.useState([]),[l,a]=M.useState(!1);return M.useEffect(()=>{if(!s||!r)return;const c=new AbortController;return i([]),a(!0),(async()=>{try{const u=await fetch(`/api/${encodeURIComponent(e)}/decopilot/threads/${encodeURIComponent(t)}/jobs/${encodeURIComponent(r)}/stream`,{headers:{accept:"text/event-stream"},credentials:"include",signal:c.signal});if(!u.ok||!u.body)return;for await(const d of qh({stream:BS(u.body)})){if(c.signal.aborted)return;i([d])}}catch{}finally{c.signal.aborted||a(!1)}})(),()=>c.abort()},[s,r,t,e]),{messages:o,streaming:l}}function HS(n){if(n&&typeof n=="object"&&!Array.isArray(n)){const e=n;if(typeof e.text=="string"||typeof e.error=="string"||typeof e.finishReason=="string"){if(typeof e.error=="string"&&e.error.length>0)return`Subtask failed: ${e.error}`;const r=typeof e.text=="string"?e.text.trim():"",s=e.finishReason==="length";return r?(s?`[Subtask hit step limit — partial result below; consider narrowing the task.]
|
|
182
182
|
|
|
183
|
-
`:"")+r:s?"[Subtask hit step limit before producing a final report. The subagent did work but ran out of steps. Narrow the task or increase the budget.]":"Subtask completed (no output)."}}return dS(n)}function Wf(n){return!!n&&typeof n=="object"&&n.background===!0}function Uf({part:n,subtaskMeta:e}){const t=n.state==="input-streaming"||n.state==="input-available",r=n.state==="output-available"&&n.preliminary===!0,s=n.state==="output-available"&&!n.preliminary,o=n.state==="output-error",i=Ye(n.state,"preliminary"in n?n.preliminary:!1),l=i==="approval"?"idle":i,a=t?"Starting subtask...":r?"Subtask running...":s?"Subtask completed":o?"Subtask failed":"Subtask",c=n.input?.prompt??"",u=n.state==="approval-requested"?"Awaiting approval...":c.length>120?c.slice(0,120)+"…":c;return{fallbackTitle:a,summary:u,usage:e?.usage,state:l}}function El(n){const e=D.c(45),{icon:t,title:r,summary:s,state:o,usage:i,onOpenChange:l,children:a}=n,[c,u]=M.useState(!1);let d;e[0]!==l?(d=$=>{u($),l?.($)},e[0]=l,e[1]=d):d=e[1];const f=d,h=o==="loading",m=o==="error";let g;e[2]!==f?(g=()=>f(!0),e[2]=f,e[3]=g):g=e[3];const y=h&&"shimmer";let x;e[4]!==y?(x=X("group/tool flex items-center gap-2 w-full py-2.5 text-left rounded-md transition-colors","[@media(hover:hover)]:hover:bg-accent/30",y),e[4]=y,e[5]=x):x=e[5];const b=m?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75";let k;e[6]!==b?(k=X("relative shrink-0 size-4 flex items-center justify-center [&>svg]:size-4",b),e[6]=b,e[7]=k):k=e[7];let v;e[8]!==t||e[9]!==k?(v=p.jsx("div",{className:k,children:t}),e[8]=t,e[9]=k,e[10]=v):v=e[10];const S=m?"text-warning/80":"text-foreground";let w;e[11]!==S?(w=X("shrink-0 text-[14px] font-normal",S),e[11]=S,e[12]=w):w=e[12];let C;e[13]!==w||e[14]!==r?(C=p.jsx("span",{className:w,children:r}),e[13]=w,e[14]=r,e[15]=C):C=e[15];let T;e[16]!==s?(T=s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),e[16]=s,e[17]=T):T=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx(
|
|
184
|
-
… (${f.length-Ho} more characters)`:f,e[5]=t.input,e[6]=a}else a=e[6];const c=a;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Ic,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==o||e[10]!==l?(d=p.jsx(J,{icon:u,title:o,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=o,e[10]=l,e[11]=d):d=e[11],d}function WS(n){const e=D.c(12),{jobId:t,prompt:r,items:s,streaming:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=i):i=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[i,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:r})]}),e[1]=r,e[2]=l):l=e[2];let a;e[3]!==s||e[4]!==t||e[5]!==o?(a=s.length===0?p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic py-1",children:"Running in the background…"}):s.map((d,f)=>{const h=d,m=h.type??"";return m==="text"?h.text?.trim()?p.jsx(no,{id:`${t}-sub-${f}`,part:d,animate:o},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx(VS,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=o,e[6]=a):a=e[6];let c;e[7]!==a?(c=p.jsx("section",{className:"flex flex-col gap-3 sm:gap-2",children:a}),e[7]=a,e[8]=c):c=e[8];let u;return e[9]!==l||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-col gap-4",children:[l,c]}),e[9]=l,e[10]=c,e[11]=u):u=e[11],u}function Kf(n){const e=D.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=Wh(),{org:o}=Lt(),[i,l]=M.useState(!1),a=zS(r);let c;e[0]!==r||e[1]!==i||e[2]!==o.slug||e[3]!==s?(c={orgSlug:o.slug,threadId:s,jobId:r,enabled:i},e[0]=r,e[1]=i,e[2]=o.slug,e[3]=s,e[4]=c):c=e[4];const u=FS(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(qS),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(US),e[7]=a,e[8]=h):h=e[8];const m=h,g=f.length>0?f:m,y=t.input?.prompt??"No prompt provided";let x;e[9]!==y?(x=y.length>120?`${y.slice(0,120)}…`:y,e[9]=y,e[10]=x):x=e[10];const b=x,k=a.length===0;let v;e[11]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(kr,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(ji,{})}),e[11]=v):v=e[11];const S=k?"loading":"idle",w=u.streaming||k;let C;e[12]!==g||e[13]!==r||e[14]!==y||e[15]!==w?(C=p.jsx(WS,{jobId:r,prompt:y,items:g,streaming:w}),e[12]=g,e[13]=r,e[14]=y,e[15]=w,e[16]=C):C=e[16];let T;return e[17]!==b||e[18]!==S||e[19]!==C?(T=p.jsx(El,{icon:v,title:"Subtask",summary:b,state:S,onOpenChange:l,children:C}),e[17]=b,e[18]=S,e[19]=C,e[20]=T):T=e[20],T}function US(n){return n.parts??[]}function qS(n){return n.parts??[]}function KS(n){const e=D.c(13);if(Wf(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Kf,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=Uf(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:o,state:i}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(kr,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(ji,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(qf,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==i||e[9]!==s||e[10]!==a||e[11]!==o?(c=p.jsx(El,{icon:l,title:r,summary:s,state:i,usage:o,children:a}),e[7]=r,e[8]=i,e[9]=s,e[10]=a,e[11]=o,e[12]=c):c=e[12],c}function JS(n){const e=D.c(17),t=pp(n.part.input?.agent_id);if(Wf(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Kf,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=Uf(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:o,usage:i,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(ji,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(kr,{icon:a,name:c,size:"2xs",className:"rounded-xs",fallbackIcon:u}),e[5]=a,e[6]=c,e[7]=d):d=e[7];const f=t?.title??s;let h;e[8]!==n.part?(h=p.jsx(qf,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==o||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==i?(m=p.jsx(El,{icon:d,title:f,summary:o,state:l,usage:i,children:h}),e[10]=l,e[11]=o,e[12]=d,e[13]=f,e[14]=h,e[15]=i,e[16]=m):m=e[16],m}function GS(n){const e=D.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",o=t.output?.approved===!0;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(Wo,{className:"size-4 text-purple-500 shrink-0"}),l=p.jsx("span",{className:"text-[14px] font-medium text-foreground/80",children:"Implementation Plan"}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let a;e[2]!==o?(a=o&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 bg-green-500/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(Ai,{size:12}),"Approved"]}),e[2]=o,e[3]=a):a=e[3];let c;e[4]!==o||e[5]!==t.state?(c=!o&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=o,e[5]=t.state,e[6]=c):c=e[6];let u;e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[i,l,a,c]}),e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"View plan"}),e[10]=d):d=e[10];let f;e[11]!==r?(f=p.jsxs("details",{className:"ml-6",children:[d,p.jsx("div",{className:"mt-1 pl-2 border-l-2 border-purple-500/30 prose prose-sm max-w-none text-sm",children:p.jsx(no,{id:"plan-content",part:{type:"text",text:r}})})]}),e[11]=r,e[12]=f):f=e[12];let h;return e[13]!==u||e[14]!==f?(h=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,f]}),e[13]=u,e[14]=f,e[15]=h):h=e[15],h}const Al={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function XS(n){return n.startsWith("http")?n:`https://${n}`}function bc(n){const e=D.c(2),{children:t}=n;let r;return e[0]!==t?(r=p.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[0]=t,e[1]=r):r=e[1],r}function YS(n){const e=D.c(12),{name:t,value:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"size-7 shrink-0 rounded-md border border-border",style:{backgroundColor:r},"aria-hidden":!0}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==o||e[7]!==i?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8];let a;return e[9]!==s||e[10]!==l?(a=p.jsxs("div",{className:"flex items-center gap-2.5",children:[s,l]}),e[9]=s,e[10]=l,e[11]=a):a=e[11],a}function QS(n){const e=D.c(15),{role:t,family:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"text-2xl font-medium leading-none text-foreground shrink-0",style:{fontFamily:r},"aria-hidden":!0,children:"Aa"}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i={fontFamily:r},e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r||e[7]!==i?(l=p.jsx("span",{className:"text-sm text-foreground",style:i,children:r}),e[6]=r,e[7]=i,e[8]=l):l=e[8];let a;e[9]!==o||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[o,l]}),e[9]=o,e[10]=l,e[11]=a):a=e[11];let c;return e[12]!==s||e[13]!==a?(c=p.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted px-4 py-3",children:[s,a]}),e[12]=s,e[13]=a,e[14]=c):c=e[14],c}function ZS(n){const e=D.c(3),{logo:t,favicon:r,name:s}=n,o=t??r;if(!o)return null;const i=s?`${s} logo`:"";let l;return e[0]!==o||e[1]!==i?(l=p.jsx("img",{src:o,alt:i,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:ev}),e[0]=o,e[1]=i,e[2]=l):l=e[2],l}function ev(n){n.target.style.display="none"}function Jf(n){const e=D.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(nv),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let o;return e[2]!==s?(o=p.jsx("div",{className:"flex h-1.5",children:s.map(tv)}),e[2]=s,e[3]=o):o=e[3],o}function tv(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${Al[e]}: ${t}`,"aria-hidden":!0},e)}function nv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Gf(n){const e=D.c(36),{logo:t,favicon:r,name:s,domain:o,overview:i,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(iv):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(ov):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(Jf,{colors:l}),e[4]=l,e[5]=g):g=e[5];let y;e[6]!==r||e[7]!==t||e[8]!==s?(y=p.jsx(ZS,{logo:t,favicon:r,name:s}),e[6]=r,e[7]=t,e[8]=s,e[9]=y):y=e[9];let x;e[10]!==u||e[11]!==s||e[12]!==c?(x=s&&p.jsxs("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-foreground truncate",children:[s,c&&u&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[p.jsx(zc,{className:"size-3 text-amber-500"}),"default"]})]}),e[10]=u,e[11]=s,e[12]=c,e[13]=x):x=e[13];let b;e[14]!==o?(b=o&&p.jsxs("a",{href:XS(o),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[o,p.jsx(Fc,{className:"size-3 shrink-0"})]}),e[14]=o,e[15]=b):b=e[15];let k;e[16]!==x||e[17]!==b?(k=p.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[x,b]}),e[16]=x,e[17]=b,e[18]=k):k=e[18];let v;e[19]!==y||e[20]!==k?(v=p.jsxs("div",{className:"flex items-center gap-4",children:[y,k]}),e[19]=y,e[20]=k,e[21]=v):v=e[21];let S;e[22]!==i?(S=i&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:i}),e[22]=i,e[23]=S):S=e[23];let w;e[24]!==f?(w=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(bc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(sv)})]}),e[24]=f,e[25]=w):w=e[25];let C;e[26]!==m?(C=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(bc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(rv)})]}),e[26]=m,e[27]=C):C=e[27];let T;e[28]!==w||e[29]!==C||e[30]!==v||e[31]!==S?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[v,S,w,C]}),e[28]=w,e[29]=C,e[30]=v,e[31]=S,e[32]=T):T=e[32];let N;return e[33]!==T||e[34]!==g?(N=p.jsxs("div",{className:"mt-2 rounded-lg overflow-hidden border border-border",children:[g,T]}),e[33]=T,e[34]=g,e[35]=N):N=e[35],N}function rv(n){const[e,t]=n;return p.jsx(QS,{role:e,family:t},e)}function sv(n){const[e,t]=n;return p.jsx(YS,{name:Al[e],value:t},e)}function ov(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function iv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function lv(n){const e=D.c(29),{part:t,latency:r}=n,s=Ye(t.state);let o;e[0]!==t.output?(o=_n(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){const C=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(nt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=C?.domain?`from ${C.domain}`:void 0;let E;return e[3]!==N?(E=p.jsx(J,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=E):E=e[4],E}if(a){let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(nt,{}),e[5]=C):C=e[5];const T=i?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[6]=r,e[7]=N):N=e[7];let E;return e[8]!==T||e[9]!==N?(E=p.jsx(J,{icon:C,title:"Brand extraction failed",summary:T,state:"error",trailing:N}),e[8]=T,e[9]=N,e[10]=E):E=e[10],E}let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(nt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=i?.name?`Brand set: ${i.name}`:"Brand context set",d=i?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[12]=r,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==d||e[16]!==f?(h=p.jsx(J,{icon:c,title:u,summary:d,state:"idle",trailing:f}),e[14]=u,e[15]=d,e[16]=f,e[17]=h):h=e[17];const m=i?.logo,g=i?.favicon,y=i?.name,x=i?.domain,b=i?.overview,k=i?.colors,v=i?.fonts;let S;e[18]!==x||e[19]!==b||e[20]!==k||e[21]!==v||e[22]!==m||e[23]!==g||e[24]!==y?(S=p.jsx(Gf,{logo:m,favicon:g,name:y,domain:x,overview:b,colors:k,fonts:v}),e[18]=x,e[19]=b,e[20]=k,e[21]=v,e[22]=m,e[23]=g,e[24]=y,e[25]=S):S=e[25];let w;return e[26]!==S||e[27]!==h?(w=p.jsxs(p.Fragment,{children:[h,S]}),e[26]=S,e[27]=h,e[28]=w):w=e[28],w}function av(n){const e=D.c(27),{part:t,latency:r}=n,s=Ye(t.state);let o;e[0]!==t.output?(o=_n(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(J,{icon:p.jsx(nt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!i){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(nt,{}),e[3]=g):g=e[3];let y;e[4]!==r?(y=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[4]=r,e[5]=y):y=e[5];let x;return e[6]!==y?(x=p.jsx(J,{icon:g,title:"Couldn't load brand",state:"error",trailing:y}),e[6]=y,e[7]=x):x=e[7],x}let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(nt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=i.name?`Brand · ${i.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==i.domain||e[12]!==u||e[13]!==d?(f=p.jsx(J,{icon:c,title:u,summary:i.domain,state:"idle",trailing:d}),e[11]=i.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==i.colors||e[16]!==i.domain||e[17]!==i.favicon||e[18]!==i.fonts||e[19]!==i.isDefault||e[20]!==i.logo||e[21]!==i.name||e[22]!==i.overview?(h=p.jsx(Gf,{logo:i.logo,favicon:i.favicon,name:i.name,domain:i.domain,overview:i.overview,colors:i.colors,fonts:i.fonts,showDefaultBadge:!0,isDefault:i.isDefault}),e[15]=i.colors,e[16]=i.domain,e[17]=i.favicon,e[18]=i.fonts,e[19]=i.isDefault,e[20]=i.logo,e[21]=i.name,e[22]=i.overview,e[23]=h):h=e[23];let m;return e[24]!==f||e[25]!==h?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[24]=f,e[25]=h,e[26]=m):m=e[26],m}function cv(n){const e=D.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=Ye(t.state),e[0]=t.state,e[1]=s):s=e[1];const o=s;let i,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==o){c=Symbol.for("react.early_return_sentinel");e:{const f=_n(t.output),h=Array.isArray(f?.items)?f.items:[],m=o==="loading",g=o==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(J,{icon:p.jsx(nt,{className:"animate-pulse"}),title:"Loading brands",state:"loading"}),e[9]=k):k=e[9],c=k;break e}if(g){let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(nt,{}),e[10]=k):k=e[10];let v;e[11]!==r?(v=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[11]=r,e[12]=v):v=e[12];let S;e[13]!==v?(S=p.jsx(J,{icon:k,title:"Couldn't load brands",state:"error",trailing:v}),e[13]=v,e[14]=S):S=e[14],c=S;break e}if(h.length===0){let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(nt,{}),e[15]=k):k=e[15];let v;e[16]!==r?(v=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[16]=r,e[17]=v):v=e[17];let S;e[18]!==v?(S=p.jsx(J,{icon:k,title:"No brands yet",summary:"The organization hasn't set up any brand context.",state:"idle",trailing:v}),e[18]=v,e[19]=S):S=e[19],c=S;break e}let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx(nt,{className:"text-fuchsia-500"}),e[20]=y):y=e[20];const x=h.length===1?"1 brand":`${h.length} brands`;let b;e[21]!==r?(b=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==x||e[24]!==b?(a=p.jsx(J,{icon:y,title:x,state:"idle",trailing:b}),e[23]=x,e[24]=b,e[25]=a):a=e[25],i="mt-2 flex flex-col gap-1.5",l=h.map(uv)}e[2]=r,e[3]=t.output,e[4]=o,e[5]=i,e[6]=l,e[7]=a,e[8]=c}else i=e[5],l=e[6],a=e[7],c=e[8];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;e[26]!==i||e[27]!==l?(u=p.jsx("div",{className:i,children:l}),e[26]=i,e[27]=l,e[28]=u):u=e[28];let d;return e[29]!==a||e[30]!==u?(d=p.jsxs(p.Fragment,{children:[a,u]}),e[29]=a,e[30]=u,e[31]=d):d=e[31],d}function uv(n){const e=n.colors?Object.entries(n.colors).filter(hv):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(Jf,{colors:n.colors}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(n.logo||n.favicon)&&p.jsx("img",{src:n.logo??n.favicon??void 0,alt:"",className:"size-8 shrink-0 rounded-md border border-border bg-background object-contain p-0.5",onError:fv}),p.jsxs("div",{className:"flex flex-col leading-tight min-w-0 flex-1",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-foreground truncate",children:[n.name??"Untitled",n.isDefault&&p.jsx(zc,{className:"size-3 text-amber-500 shrink-0"})]}),n.domain&&p.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:n.domain})]}),e.length>0&&p.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:e.slice(0,5).map(dv)})]})]},n.id??`${n.name}-${n.domain}`)}function dv(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${Al[e]}: ${t}`,"aria-hidden":!0},e)}function fv(n){n.target.style.display="none"}function hv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Ci(n){const e=D.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,o=gp(t);if(!o)return null;let i;return e[0]!==o.icon||e[1]!==o.title||e[2]!==s?(i=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(kr,{icon:o.icon,name:o.title,size:s})}),e[0]=o.icon,e[1]=o.title,e[2]=s,e[3]=i):i=e[3],i}Ci.Fallback=function({iconSize:e="xs"}){const t=e==="sm"?"size-6":"size-5";return p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:X(t,"rounded bg-muted animate-pulse")})})};function xr(n){const e=D.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:o}=n,i=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==o||e[1]!==t||e[2]!==l||e[3]!==i){const h=t.slice(0,i);a=t.length-i,e[7]!==o?(c=X("flex items-center justify-end -space-x-2",o),e[7]=o,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(M.Suspense,{fallback:p.jsx(Ci.Fallback,{iconSize:l}),children:p.jsx(Ci,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=o,e[1]=t,e[2]=l,e[3]=i,e[4]=a,e[5]=c,e[6]=u}else a=e[4],c=e[5],u=e[6];let d;e[11]!==l||e[12]!==a?(d=a>0&&p.jsx("div",{className:X("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",l==="sm"?"size-8":"size-6"),children:p.jsxs("span",{className:X(l==="sm"?"text-sm":"text-xs","font-medium text-muted-foreground"),"aria-label":`and ${a} more`,children:["+",a]})}),e[11]=l,e[12]=a,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==u||e[16]!==d?(f=p.jsxs("div",{className:c,children:[u,d]}),e[14]=c,e[15]=u,e[16]=d,e[17]=f):f=e[17],f}xr.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",o=r==="sm"?"size-8":"size-6",i=t!==void 0&&t>e;return p.jsxs("div",{className:"flex items-center -space-x-2",children:[Array.from({length:e}).map((l,a)=>p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:X(s,"rounded bg-muted animate-pulse")})},a)),i&&p.jsx("div",{className:X("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",o),children:p.jsx("div",{className:X(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const pv="This document certifies that the bearer agent has been granted authorized access to the tools and capabilities described herein. The agent is permitted to operate within the scope defined by its instructions and shall act in accordance with the constraints set forth by the issuing organization. This credential remains valid for the duration of the agent's active status. Unauthorized modification of this agent's permissions or scope is prohibited. The issuing authority reserves the right to revoke access at any time. All actions performed by this agent are subject to audit and review by the organization administrator. ",kc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function mv(n){const e=D.c(64),{part:t,latency:r}=n,s=Hc(),o=Ye(t.state),i=M.useRef(null),l=M.useRef(null),a=M.useRef(null),c=M.useRef(null),u=M.useRef(null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{kc?.matches||(u.current=i.current?.getBoundingClientRect()??null,i.current&&(i.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=K=>{if(kc?.matches)return;const oe=u.current,ve=i.current;if(!oe||!ve)return;const Re=(K.clientX-oe.left)/oe.width*100,it=(K.clientY-oe.top)/oe.height*100;ve.style.transform=`perspective(800px) rotateY(${(Re-50)*.05}deg) rotateX(${(it-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(Re-50)*.15}px, ${(it-50)*.15}px)`),a.current&&(a.current.style.opacity="0.45"),c.current&&(c.current.style.opacity="0.45")},e[1]=h):h=e[1];const m=h;let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const K=i.current;K&&(K.style.transform="none",K.style.willChange="auto"),l.current&&(l.current.style.opacity="0.4",l.current.style.transform="translate(0, 0)"),a.current&&(a.current.style.opacity="0.3"),c.current&&(c.current.style.opacity="0.3"),u.current=null},e[2]=g):g=e[2];const y=g;if(o==="loading"){let K;return e[3]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(J,{icon:p.jsx(tt,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=K):K=e[3],K}if(o==="approval"){let K;return e[4]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(J,{icon:p.jsx(tt,{}),title:"Create agent",state:"idle"}),e[4]=K):K=e[4],K}if(o==="error"){let K;e[5]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(tt,{}),e[5]=K):K=e[5];const oe=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let ve;e[6]!==r?(ve=p.jsx(Te,{latency:r}),e[6]=r,e[7]=ve):ve=e[7];let Re;return e[8]!==oe||e[9]!==ve?(Re=p.jsx(J,{icon:K,title:oe,state:"error",trailing:ve}),e[8]=oe,e[9]=ve,e[10]=Re):Re=e[10],Re}let x,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(x=_n(t.output)?.item,!x?.id||!x?.title){let K;e[16]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(tt,{}),e[16]=K):K=e[16];let oe;e[17]!==r?(oe=p.jsx(J,{icon:K,title:"Agent created",state:"idle",trailing:p.jsx(Te,{latency:r})}),e[17]=r,e[18]=oe):oe=e[18],k=oe;break e}b=(x.connections??[]).map(gv)}e[11]=r,e[12]=t.output,e[13]=x,e[14]=b,e[15]=k}else x=e[13],b=e[14],k=e[15];if(k!==Symbol.for("react.early_return_sentinel"))return k;const v=b;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(tt,{className:"text-emerald-500"}),e[19]=S):S=e[19];const w=`Agent created: ${x.title}`;let C;e[20]!==r?(C=p.jsx(Te,{latency:r}),e[20]=r,e[21]=C):C=e[21];let T;e[22]!==w||e[23]!==C?(T=p.jsx(J,{icon:S,title:w,state:"idle",trailing:C}),e[22]=w,e[23]=C,e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N={transition:"transform 0.3s ease-out"},e[25]=N):N=e[25];let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=p.jsx("div",{ref:l,className:"pointer-events-none absolute inset-[-20%] z-[1] select-none rounded-lg",style:{background:"linear-gradient(135deg, hsla(280, 60%, 80%, 0.35) 0%, transparent 35%), linear-gradient(315deg, hsla(190, 70%, 80%, 0.35) 0%, transparent 35%), linear-gradient(225deg, hsla(140, 55%, 80%, 0.3) 0%, transparent 30%), linear-gradient(45deg, hsla(320, 55%, 82%, 0.3) 0%, transparent 30%)",opacity:.4,transition:"opacity 0.3s ease, transform 0.3s ease-out"},"aria-hidden":"true"}),e[26]=E):E=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j={textAlign:"justify",wordBreak:"break-all"},e[27]=j):j=e[27];let L,I;e[28]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx("p",{className:"pointer-events-none absolute inset-0 z-[1] select-none overflow-hidden text-[6px] font-light leading-[1.5] tracking-[0.06px] text-background opacity-50 mix-blend-overlay",style:j,"aria-hidden":"true",children:pv.repeat(6)}),I=p.jsx("img",{src:"/stamp.svg",alt:"",className:"pointer-events-none absolute -right-10 -top-10 size-[140px] opacity-50 select-none","aria-hidden":"true"}),e[28]=L,e[29]=I):(L=e[28],I=e[29]);let P;e[30]===Symbol.for("react.memo_cache_sentinel")?(P=p.jsx("img",{ref:a,src:"/left-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 left-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[30]=P):P=e[30];let R;e[31]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx("img",{ref:c,src:"/right-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 right-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[31]=R):R=e[31];let z;e[32]!==x.icon||e[33]!==x.title?(z=p.jsx(Ac,{icon:x.icon,name:x.title,size:"md"}),e[32]=x.icon,e[33]=x.title,e[34]=z):z=e[34];let B;e[35]!==x.title?(B=p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:x.title})}),e[35]=x.title,e[36]=B):B=e[36];let $;e[37]!==z||e[38]!==B?($=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[z,B]}),e[37]=z,e[38]=B,e[39]=$):$=e[39];let F;e[40]!==x.description?(F=x.description&&p.jsx("div",{className:"px-2 pt-1 pr-16",children:p.jsx("p",{className:"text-sm leading-snug text-muted-foreground line-clamp-2",children:x.description})}),e[40]=x.description,e[41]=F):F=e[41];let G;e[42]!==$||e[43]!==F?(G=p.jsxs("div",{className:"relative",children:[$,F]}),e[42]=$,e[43]=F,e[44]=G):G=e[44];let Q;e[45]!==v?(Q=v.length>0&&p.jsx(M.Suspense,{fallback:p.jsx(xr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:v.length}),children:p.jsx(xr,{connectionIds:v,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=v,e[46]=Q):Q=e[46];let Z;e[47]!==Q?(Z=p.jsx("div",{className:"flex-1 min-w-0",children:Q}),e[47]=Q,e[48]=Z):Z=e[48];let se;e[49]!==x.id||e[50]!==s?(se=()=>s(x.id),e[49]=x.id,e[50]=s,e[51]=se):se=e[51];const Pe=`See agent: ${x.title}`;let Le;e[52]!==se||e[53]!==Pe?(Le=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(ir,{size:"sm",className:"h-7",onClick:se,"aria-label":Pe,children:"See agent"})}),e[52]=se,e[53]=Pe,e[54]=Le):Le=e[54];let ze;e[55]!==Z||e[56]!==Le?(ze=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[Z,Le]}),e[55]=Z,e[56]=Le,e[57]=ze):ze=e[57];let Ke;e[58]!==G||e[59]!==ze?(Ke=p.jsx("div",{className:"mt-2 overflow-hidden rounded-xl border-[0.5px] border-border bg-card p-2.5",children:p.jsxs("div",{ref:i,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:y,children:[E,L,I,P,R,G,ze]})}),e[58]=G,e[59]=ze,e[60]=Ke):Ke=e[60];let gt;return e[61]!==Ke||e[62]!==T?(gt=p.jsxs(p.Fragment,{children:[T,Ke]}),e[61]=Ke,e[62]=T,e[63]=gt):gt=e[63],gt}function gv(n){return n.connection_id}function yv(n){const e=D.c(24),{agent:t}=n,r=Hc();if(!t.id)return null;let s;e[0]!==t.connections?(s=t.connections??[],e[0]=t.connections,e[1]=s):s=e[1];let o;e[2]!==s?(o=s.map(xv),e[2]=s,e[3]=o):o=e[3];const i=o;let l;e[4]!==t.id||e[5]!==r?(l=()=>r(t.id),e[4]=t.id,e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t.icon||e[8]!==t.title?(a=p.jsx(Ac,{icon:t.icon,name:t.title,size:"sm"}),e[7]=t.icon,e[8]=t.title,e[9]=a):a=e[9];let c;e[10]!==t.title?(c=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[10]=t.title,e[11]=c):c=e[11];let u;e[12]!==t.description?(u=t.description&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.description}),e[12]=t.description,e[13]=u):u=e[13];let d;e[14]!==c||e[15]!==u?(d=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16];let f;e[17]!==i?(f=i.length>0&&p.jsx(M.Suspense,{fallback:p.jsx(xr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:i.length}),children:p.jsx(xr,{connectionIds:i,iconSize:"xs",maxVisibleIcons:3})}),e[17]=i,e[18]=f):f=e[18];let h;return e[19]!==l||e[20]!==a||e[21]!==d||e[22]!==f?(h=p.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[a,d,f]}),e[19]=l,e[20]=a,e[21]=d,e[22]=f,e[23]=h):h=e[23],h}function xv(n){return n.connection_id}function bv(n){const e=D.c(41),{part:t,latency:r}=n,s=Pn(),{org:o}=Lt();let i;e[0]!==t.state?(i=Ye(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const x=_n(t.output);if(c=Array.isArray(x?.items)?x.items:[],l==="loading"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(J,{icon:p.jsx(tt,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="approval"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(J,{icon:p.jsx(tt,{}),title:"List agents",state:"idle"}),e[13]=w):w=e[13],h=w;break e}if(l==="error"){let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(tt,{}),e[14]=w):w=e[14];const C=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx(Te,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==C||e[18]!==T?(N=p.jsx(J,{icon:w,title:C,state:"error",trailing:T}),e[17]=C,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(tt,{}),e[20]=w):w=e[20];let C;e[21]!==r?(C=p.jsx(J,{icon:w,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx(Te,{latency:r})}),e[21]=r,e[22]=C):C=e[22],h=C;break e}const b=c.slice(0,$f);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(tt,{className:"text-emerald-500"}),e[23]=k):k=e[23];const v=c.length===1?"1 agent":`${c.length} agents`;let S;e[24]!==r?(S=p.jsx(Te,{latency:r}),e[24]=r,e[25]=S):S=e[25],e[26]!==v||e[27]!==S?(f=p.jsx(J,{icon:k,title:v,state:"idle",trailing:S}),e[26]=v,e[27]=S,e[28]=f):f=e[28],u="mt-2 flex flex-col gap-1.5",d=b.map(kv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[29]!==a||e[30]!==c||e[31]!==s||e[32]!==o?(m=a>0&&p.jsx(zf,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:o.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=o,e[33]=m):m=e[33];let g;e[34]!==u||e[35]!==d||e[36]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[34]=u,e[35]=d,e[36]=m,e[37]=g):g=e[37];let y;return e[38]!==f||e[39]!==g?(y=p.jsxs(p.Fragment,{children:[f,g]}),e[38]=f,e[39]=g,e[40]=y):y=e[40],y}function kv(n){return p.jsx(yv,{agent:n},n.id)}const Sv={active:"bg-emerald-500",inactive:"bg-muted-foreground",error:"bg-destructive"};function vv(n){const e=D.c(27),{connection:t}=n,r=Pn(),{org:s}=Lt(),o=t.slug,i=t.description||t.app_name,l=!o||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==o?(a=()=>o&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:o}}),e[0]=r,e[1]=s,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(kr,{icon:t.icon,name:t.title,size:"sm"}),e[4]=t.icon,e[5]=t.title,e[6]=c):c=e[6];let u;e[7]!==t.title?(u=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[7]=t.title,e[8]=u):u=e[8];let d;e[9]!==i?(d=i&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=d):d=e[10];let f;e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13];const h=Sv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=X("size-2 shrink-0 rounded-full",h),e[14]=h,e[15]=m):m=e[15];let g;e[16]!==m?(g=p.jsx("span",{className:m,"aria-hidden":"true"}),e[16]=m,e[17]=g):g=e[17];let y;e[18]!==t.status?(y=p.jsx("span",{className:"sr-only",children:t.status}),e[18]=t.status,e[19]=y):y=e[19];let x;return e[20]!==l||e[21]!==y||e[22]!==a||e[23]!==c||e[24]!==f||e[25]!==g?(x=p.jsxs("button",{type:"button","aria-disabled":l,onClick:a,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer aria-disabled:cursor-default aria-disabled:hover:bg-card",children:[c,f,g,y]}),e[20]=l,e[21]=y,e[22]=a,e[23]=c,e[24]=f,e[25]=g,e[26]=x):x=e[26],x}function wv(n){const e=D.c(40),{part:t,latency:r}=n,s=Pn(),{org:o}=Lt();let i;e[0]!==t.state?(i=Ye(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const x=_n(t.output);if(c=(Array.isArray(x?.items)?x.items:[]).filter(Tv),l==="loading"||l==="approval"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(J,{icon:p.jsx(Mr,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="error"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Mr,{}),e[13]=w):w=e[13];const C=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx(Te,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==C||e[17]!==T?(N=p.jsx(J,{icon:w,title:C,state:"error",trailing:T}),e[16]=C,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Mr,{}),e[19]=w):w=e[19];let C;e[20]!==r?(C=p.jsx(J,{icon:w,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx(Te,{latency:r})}),e[20]=r,e[21]=C):C=e[21],h=C;break e}const b=c.slice(0,$f);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Mr,{className:"text-emerald-500"}),e[22]=k):k=e[22];const v=c.length===1?"1 connection":`${c.length} connections`;let S;e[23]!==r?(S=p.jsx(Te,{latency:r}),e[23]=r,e[24]=S):S=e[24],e[25]!==v||e[26]!==S?(f=p.jsx(J,{icon:k,title:v,state:"idle",trailing:S}),e[25]=v,e[26]=S,e[27]=f):f=e[27],u="mt-2 flex flex-col gap-1.5",d=b.map(Cv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[28]!==a||e[29]!==c||e[30]!==s||e[31]!==o?(m=a>0&&p.jsx(zf,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:o.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=o,e[32]=m):m=e[32];let g;e[33]!==u||e[34]!==d||e[35]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[33]=u,e[34]=d,e[35]=m,e[36]=g):g=e[36];let y;return e[37]!==f||e[38]!==g?(y=p.jsxs(p.Fragment,{children:[f,g]}),e[37]=f,e[38]=g,e[39]=y):y=e[39],y}function Cv(n){return p.jsx(vv,{connection:n},n.id)}function Tv(n){return n.connection_type!=="VIRTUAL"}function Nv(){const n=D.c(37),e=Ri(),{sendMessage:t,isStreaming:r,messages:s}=Uh(),{org:o}=Lt(),i=e?.virtualMcpId,{prompts:l}=cp(o.slug),a=i??null;let c;n[0]!==o.id||n[1]!==o.slug||n[2]!==a?(c={connectionId:a,orgId:o.id,orgSlug:o.slug},n[0]=o.id,n[1]=o.slug,n[2]=a,n[3]=c):c=n[3];const u=_c(c),[d,f]=M.useState(null);if(!i||r||!ep(i)||!s.some(Mv))return null;let m;if(n[4]!==l||n[5]!==i){let I;n[7]!==i?(I=P=>P.agentId===i&&P.promptName,n[7]=i,n[8]=I):I=n[8],m=l.find(I),n[4]=l,n[5]=i,n[6]=m}else m=n[6];const g=m;if(!g)return null;let y;n[9]!==u||n[10]!==t?(y=async(I,P)=>{if(!u){Vo.error("MCP client not available");return}try{const R=await xp(u,I.name,P);await t({type:"doc",content:[{type:"paragraph",content:[cf({id:I.name,name:Pi(I.name,Di(I._meta)),metadata:R.messages,char:"/",kind:"prompt",args:P}),{type:"text",text:" "}]}]})}catch(R){console.error("[next-action-chip] failed",R),Vo.error("Failed to load prompt. Please try again.")}},n[9]=u,n[10]=t,n[11]=y):y=n[11];const x=y;let b;n[12]!==g._meta||n[13]!==g.arguments||n[14]!==g.description||n[15]!==g.promptName||n[16]!==g.title||n[17]!==x?(b=()=>{const I={name:g.promptName,title:g.title,description:g.description,arguments:g.arguments,_meta:g._meta};if(I.arguments&&I.arguments.length>0){f(I);return}x(I)},n[12]=g._meta,n[13]=g.arguments,n[14]=g.description,n[15]=g.promptName,n[16]=g.title,n[17]=x,n[18]=b):b=n[18];const k=b;let v,S;n[19]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(yp,{size:12,className:"shrink-0 text-purple-500"}),S=p.jsx("span",{className:"font-medium text-foreground/80",children:"Next:"}),n[19]=v,n[20]=S):(v=n[19],S=n[20]);let w;n[21]!==g.title?(w=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=w):w=n[22];let C;n[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Oc,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=C):C=n[23];let T;n[24]!==k||n[25]!==w?(T=p.jsxs("button",{type:"button",onClick:k,className:"group mt-3 flex items-center gap-2 self-start rounded-full border border-border bg-background px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-border hover:bg-accent/40 hover:text-foreground",children:[v,S,w,C]}),n[24]=k,n[25]=w,n[26]=T):T=n[26];let N;n[27]===Symbol.for("react.memo_cache_sentinel")?(N=I=>f(I),n[27]=N):N=n[27];let E;n[28]!==d||n[29]!==x?(E=async I=>{const P=d;f(null),P&&await x(P,I)},n[28]=d,n[29]=x,n[30]=E):E=n[30];let j;n[31]!==d||n[32]!==E?(j=p.jsx(Vp,{prompt:d,setPrompt:N,onSubmit:E}),n[31]=d,n[32]=E,n[33]=j):j=n[33];let L;return n[34]!==j||n[35]!==T?(L=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=L):L=n[36],L}function Mv(n){return n.role==="user"||n.parts.some(Ev)}function Ev(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function Av(n){const e=new Map;for(let t=n.length-1;t>=0;t--){const r=n[t]?.parts;if(r)for(const s of r){const o=s;if(o.type!=="data-deck-updated")continue;const i=o.data;if(!i?.path)continue;const l=`deck:${i.path}`;e.has(l)||e.set(l,{tabId:Yh(i.path),label:i.name||i.path,kind:i.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function Ov(){const n=D.c(9),e=Pn(),t=Ln()?.messages??[],r=Av(t);if(r.length===0)return null;const s=r.some(Rv),o=r.some(Iv),i=s?o?"Slides & pages in this chat":"Slides in this chat":"Pages in this chat",l="flex flex-col gap-1.5 py-2";let a;n[0]!==i?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:i}),n[0]=i,n[1]=a):a=n[1];const c="flex flex-wrap gap-2";let u;n[2]!==e?(u=m=>p.jsxs("button",{type:"button",onClick:()=>e({to:".",search:g=>({...g,main:m.tabId}),replace:!0}),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/30 hover:bg-muted/60 text-[13px] transition-colors",children:[m.kind==="deck"?p.jsx(Jn,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(np,{className:"size-3.5 shrink-0 text-muted-foreground"}),p.jsx("span",{className:"font-medium text-foreground",children:m.label})]},m.tabId),n[2]=e,n[3]=u):u=n[3];const d=r.map(u);let f;n[4]!==d?(f=p.jsx("div",{className:c,children:d}),n[4]=d,n[5]=f):f=n[5];let h;return n[6]!==a||n[7]!==f?(h=p.jsxs("div",{className:l,children:[a,f]}),n[6]=a,n[7]=f,n[8]=h):h=n[8],h}function Iv(n){return n.kind==="page"}function Rv(n){return n.kind==="deck"}async function jv(n,e){const t=await fetch(`/api/${e}/threads/${encodeURIComponent(n)}/outputs`,{credentials:"include"});if(!t.ok)throw new Error(`Failed to fetch thread outputs: ${t.status}`);return(await t.json()).objects??[]}function P2(){const n=D.c(2),e=Ln()?.messages??[];let t;return n[0]!==e?(t=e.some(Dv),n[0]=e,n[1]=t):t=n[1],t}function Dv(n){return n.parts?.some(Pv)}function Pv(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function Lv(n,e){const t=D.c(9),{org:r}=Lt();let s;t[0]!==n?(s=Wt.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let o;t[2]!==r||t[3]!==n?(o=()=>jv(n??"",r.slug),t[2]=r,t[3]=n,t[4]=o):o=t[4];const i=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==o||t[7]!==i?(l={queryKey:s,queryFn:o,enabled:i,staleTime:0},t[5]=s,t[6]=o,t[7]=i,t[8]=l):l=t[8],Mi(l)}function _v(n){const e=D.c(20),{file:t}=n,r=Pn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:Qh(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const o=s;let i;e[3]!==t.filename?(i=p.jsx(zh,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=i):i=e[4];let l;e[5]!==t.filename||e[6]!==o?(l=p.jsx("button",{type:"button",onClick:o,className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-foreground hover:underline",title:t.filename,children:t.filename}),e[5]=t.filename,e[6]=o,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Bc,{className:"size-3.5"}),e[8]=c):c=e[8];let u;e[9]!==t.downloadUrl||e[10]!==t.filename||e[11]!==a?(u=p.jsx("a",{href:t.downloadUrl,download:t.filename,className:"hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:block",title:"Download","aria-label":a,children:c}),e[9]=t.downloadUrl,e[10]=t.filename,e[11]=a,e[12]=u):u=e[12];let d;e[13]!==o?(d=p.jsx(ir,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:o,children:"Open"}),e[13]=o,e[14]=d):d=e[14];let f;return e[15]!==i||e[16]!==l||e[17]!==u||e[18]!==d?(f=p.jsxs("div",{className:"group flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[i,l,u,d]}),e[15]=i,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Sc(n){return n.split("/").pop()??n}const $v=/(^|\/)output\//;function zv(n){const e=new Set;for(const t of n.parts??[]){const r=t;if(r.state==="output-available"){if(r.type==="tool-share_with_user"){const s=r.output?.filename??r.input?.name??(r.input?.source?Sc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&$v.test(s)&&e.add(Sc(s))}}}return e}function Bv(n){const e=D.c(4),{threadId:t,message:r}=n,s=zv(r),o=s.size>0;let i;e[0]!==o?(i={enabled:o},e[0]=o,e[1]=i):i=e[1];const{data:l}=Lv(t,i);if(s.size===0)return null;const a=(l??[]).filter(f=>s.has(f.filename));if(a.length===0)return null;const c="flex flex-col gap-1.5 py-2",u=a.map(Fv);let d;return e[2]!==u?(d=p.jsx("div",{className:c,children:u}),e[2]=u,e[3]=d):d=e[3],d}function Fv(n){return p.jsx(_v,{file:n},n.key)}function Hv(n){return n.type==="reasoning"}function Vv(n){const e=[],t=new Set,r=new Map,s=new Map,o=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(Hv(c)){l||(l={parts:[],startIndex:a},e.push(l)),l.parts.push(c),t.add(a);continue}if(l=null,c.type==="data-tool-metadata"&&"id"in c&&"data"in c){const u=c.data,d={};u.annotations&&(d.annotations=u.annotations),typeof u.latencyMs=="number"&&Number.isFinite(u.latencyMs)&&(d.latencySeconds=u.latencyMs/1e3),typeof u.outputBytes=="number"&&Number.isFinite(u.outputBytes)&&u.outputBytes>=0&&(d.outputBytes=u.outputBytes),u._meta&&typeof u._meta=="object"&&(d._meta=u._meta),r.set(c.id,d);continue}if(c.type==="data-tool-subtask-metadata"&&"id"in c){s.set(c.id,c.data);continue}if(c.type==="data-web-search"&&"id"in c&&"data"in c){const u=c.id,d=c.data;o.set(u,d.text??"");continue}}}const i=[];if(n)for(let l=0;l<n.parts.length;l++){const a=n.parts[l];if(a.type!=="step-start"){if(t.has(l)){const c=e.find(u=>u.startIndex===l);c&&i.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||i.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:i,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:o}}}function Ti(n){const e=D.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>Ll(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,o]=M.useState(r);let i,l;e[2]!==t?(i=()=>{const d=setInterval(()=>o(Ll(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=i,e[4]=l):(i=e[3],l=e[4]),M.useEffect(i,l);const a=s/1e3;let c;e[5]!==a?(c=Rt(a),e[5]=a,e[6]=c):c=e[6];let u;return e[7]!==c?(u=p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground/50",children:c}),e[7]=c,e[8]=u):u=e[8],u}const Xf=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function Wv(){const n=D.c(5),[e]=M.useState(Uv);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={gridTemplateColumns:"repeat(3, 3px)",gap:"1.5px",width:"fit-content"},n[0]=t):t=n[0];let r;n[1]!==e?(r=Xf.map((o,i)=>{const{delay:l}=o;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[i],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},i)}),n[1]=e,n[2]=r):r=n[2];let s;return n[3]!==r?(s=p.jsx("div",{className:"grid",style:t,children:r}),n[3]=r,n[4]=s):s=n[4],s}function Uv(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return Xf.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const qv={planning:{icon:p.jsx(Dh,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves",detail:"Deciding how to approach the request"},thinking:{icon:p.jsx(Bs,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},Kv=1200;function Ni(n){const e=D.c(9),{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==o||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(J,{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:u,latency:a,trailing:c}),e[0]=o,e[1]=u,e[2]=t,e[3]=a,e[4]=i,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function Jv(n){const e=D.c(17),{startedAt:t}=n,r=Ln()?.runStatusStage??null,[s,o]=M.useState("planning");let i,l;if(e[0]!==r?(i=()=>{if(r!==null)return;const f=setTimeout(()=>{o("thinking")},Kv);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=i,e[2]=l):(i=e[1],l=e[2]),M.useEffect(i,l),r!==null){const f=Jh[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Bs,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(Ti,{since:t}),e[4]=t,e[5]=g):g=e[5];let y;return e[6]!==f.detail||e[7]!==m||e[8]!==g?(y=p.jsx(Ni,{icon:h,title:m,summary:f.detail,state:"loading",trailing:g}),e[6]=f.detail,e[7]=m,e[8]=g,e[9]=y):y=e[9],y}const a=qv[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(Ti,{since:t}),e[10]=t,e[11]=u):u=e[11];let d;return e[12]!==a.detail||e[13]!==a.icon||e[14]!==c||e[15]!==u?(d=p.jsx(Ni,{icon:a.icon,title:c,summary:a.detail,state:"loading",trailing:u}),e[12]=a.detail,e[13]=a.icon,e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function Gv(n){const e=D.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(Wv,{}),e[0]=r):r=e[0];let s;return e[1]!==t?(s=p.jsxs("div",{className:"flex items-center gap-2.5 mt-1 pb-1 text-muted-foreground/40 select-none",children:[r,p.jsx(Ti,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const Xv=2e4;function Yv(n){const e=D.c(8),{startedAt:t}=n;jc(1e3);const r=Ln(),o=(t!==null?Date.now()-t:0)>=Xv;let i;e[0]!==t?(i=p.jsx(Jv,{startedAt:t}),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==o||e[3]!==r?(l=o&&r?.stop&&p.jsxs("div",{className:"flex items-center gap-2 pb-1 text-[13px] text-muted-foreground/60",children:[p.jsx("span",{children:"This is taking longer than usual."}),p.jsx("button",{type:"button",onClick:()=>r.stop(),className:"text-muted-foreground hover:text-foreground underline underline-offset-2",children:"Cancel"})]}),e[2]=o,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==i||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[i,l]}),e[5]=i,e[6]=l,e[7]=a):a=e[7],a}function Qv(n){const e=D.c(20),{duration:t,parts:r,isStreaming:s}=n;let o;e[0]!==r?(o=r.every(tw),e[0]=r,e[1]=o):o=e[1];const i=o;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Rt(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==i||e[5]!==s||e[6]!==r){const k=r.map(ew).join(`
|
|
183
|
+
`:"")+r:s?"[Subtask hit step limit before producing a final report. The subagent did work but ran out of steps. Narrow the task or increase the budget.]":"Subtask completed (no output)."}}return dS(n)}function Wf(n){return!!n&&typeof n=="object"&&n.background===!0}function Uf({part:n,subtaskMeta:e}){const t=n.state==="input-streaming"||n.state==="input-available",r=n.state==="output-available"&&n.preliminary===!0,s=n.state==="output-available"&&!n.preliminary,o=n.state==="output-error",i=Ye(n.state,"preliminary"in n?n.preliminary:!1),l=i==="approval"?"idle":i,a=t?"Starting subtask...":r?"Subtask running...":s?"Subtask completed":o?"Subtask failed":"Subtask",c=n.input?.prompt??"",u=n.state==="approval-requested"?"Awaiting approval...":c.length>120?c.slice(0,120)+"…":c;return{fallbackTitle:a,summary:u,usage:e?.usage,state:l}}function El(n){const e=D.c(45),{icon:t,title:r,summary:s,state:o,usage:i,onOpenChange:l,children:a}=n,[c,u]=M.useState(!1);let d;e[0]!==l?(d=$=>{u($),l?.($)},e[0]=l,e[1]=d):d=e[1];const f=d,h=o==="loading",m=o==="error";let g;e[2]!==f?(g=()=>f(!0),e[2]=f,e[3]=g):g=e[3];const y=h&&"shimmer";let x;e[4]!==y?(x=X("group/tool flex items-center gap-2 w-full py-2.5 text-left rounded-md transition-colors","[@media(hover:hover)]:hover:bg-accent/30",y),e[4]=y,e[5]=x):x=e[5];const b=m?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75";let k;e[6]!==b?(k=X("relative shrink-0 size-4 flex items-center justify-center [&>svg]:size-4",b),e[6]=b,e[7]=k):k=e[7];let v;e[8]!==t||e[9]!==k?(v=p.jsx("div",{className:k,children:t}),e[8]=t,e[9]=k,e[10]=v):v=e[10];const S=m?"text-warning/80":"text-foreground";let w;e[11]!==S?(w=X("shrink-0 text-[14px] font-normal",S),e[11]=S,e[12]=w):w=e[12];let C;e[13]!==w||e[14]!==r?(C=p.jsx("span",{className:w,children:r}),e[13]=w,e[14]=r,e[15]=C):C=e[15];let T;e[16]!==s?(T=s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),e[16]=s,e[17]=T):T=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx(pp,{className:"size-3.5 shrink-0 text-muted-foreground/40 opacity-0 transition-opacity [@media(hover:hover)]:group-hover/tool:opacity-100"}),e[18]=N):N=e[18];let E;e[19]!==i?(E=p.jsx(Pf,{usage:i}),e[19]=i,e[20]=E):E=e[20];let j;e[21]!==C||e[22]!==T||e[23]!==E||e[24]!==g||e[25]!==x||e[26]!==v?(j=p.jsxs("button",{type:"button",onClick:g,className:x,children:[v,C,T,N,E]}),e[21]=C,e[22]=T,e[23]=E,e[24]=g,e[25]=x,e[26]=v,e[27]=j):j=e[27];let L;e[28]!==t?(L=p.jsx("span",{className:"flex items-center [&>svg]:size-4 [&>svg]:text-muted-foreground/75",children:t}),e[28]=t,e[29]=L):L=e[29];let I;e[30]!==L||e[31]!==r?(I=p.jsx(cp,{className:"px-4 py-3 border-b border-border shrink-0",children:p.jsxs(up,{className:"flex items-center gap-2 text-sm font-medium",children:[L,r]})}),e[30]=L,e[31]=r,e[32]=I):I=e[32];let P;e[33]!==a?(P=p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4",children:a}),e[33]=a,e[34]=P):P=e[34];let R;e[35]!==I||e[36]!==P?(R=p.jsxs(dp,{side:"right",className:"w-full sm:max-w-2xl flex flex-col p-0 gap-0",children:[I,P]}),e[35]=I,e[36]=P,e[37]=R):R=e[37];let z;e[38]!==c||e[39]!==f||e[40]!==R?(z=p.jsx(fp,{open:c,onOpenChange:f,children:R}),e[38]=c,e[39]=f,e[40]=R,e[41]=z):z=e[41];let B;return e[42]!==j||e[43]!==z?(B=p.jsxs(p.Fragment,{children:[j,z]}),e[42]=j,e[43]=z,e[44]=B):B=e[44],B}function qf(n){const e=D.c(9),{part:t}=n,r=t.state==="output-error",s=t.input?.prompt??"No prompt provided";let o;if(e[0]!==r||e[1]!==t||e[2]!==s){const i=r?oo(t):HS(t.output)??"";let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[4]=l):l=e[4];let a;e[5]!==s?(a=p.jsxs("section",{children:[l,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:s})]}),e[5]=s,e[6]=a):a=e[6];const c=r?"Error":"Result";let u;e[7]!==c?(u=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:c}),e[7]=c,e[8]=u):u=e[8],o=p.jsxs("div",{className:"flex flex-col gap-4",children:[a,p.jsxs("section",{children:[u,i.trim()?p.jsx(Ii,{id:`${t.toolCallId}-result`,text:i}):p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic",children:"Running…"})]})]}),e[0]=r,e[1]=t,e[2]=s,e[3]=o}else o=e[3];return o}const Ho=600;function VS(n){const e=D.c(12),{part:t}=n,r=t.type??"";let s;e[0]!==t.toolName||e[1]!==r?(s=r==="dynamic-tool"?t.toolName??"tool":r.slice(5),e[0]=t.toolName,e[1]=r,e[2]=s):s=e[2];const o=s;let i;if(e[3]!==t.input){const f=t.input!=null?JSON.stringify(t.input):"";i=f.length>80?`${f.slice(0,80)}…`:f||void 0,e[3]=t.input,e[4]=i}else i=e[4];const l=i;let a;if(e[5]!==t.input){const f=t.input!=null?JSON.stringify(t.input,null,2):null;a=f&&f.length>Ho?`${f.slice(0,Ho)}
|
|
184
|
+
… (${f.length-Ho} more characters)`:f,e[5]=t.input,e[6]=a}else a=e[6];const c=a;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Ic,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==o||e[10]!==l?(d=p.jsx(J,{icon:u,title:o,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=o,e[10]=l,e[11]=d):d=e[11],d}function WS(n){const e=D.c(12),{jobId:t,prompt:r,items:s,streaming:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=i):i=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[i,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:r})]}),e[1]=r,e[2]=l):l=e[2];let a;e[3]!==s||e[4]!==t||e[5]!==o?(a=s.length===0?p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic py-1",children:"Running in the background…"}):s.map((d,f)=>{const h=d,m=h.type??"";return m==="text"?h.text?.trim()?p.jsx(no,{id:`${t}-sub-${f}`,part:d,animate:o},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx(VS,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=o,e[6]=a):a=e[6];let c;e[7]!==a?(c=p.jsx("section",{className:"flex flex-col gap-3 sm:gap-2",children:a}),e[7]=a,e[8]=c):c=e[8];let u;return e[9]!==l||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-col gap-4",children:[l,c]}),e[9]=l,e[10]=c,e[11]=u):u=e[11],u}function Kf(n){const e=D.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=Vh(),{org:o}=Lt(),[i,l]=M.useState(!1),a=zS(r);let c;e[0]!==r||e[1]!==i||e[2]!==o.slug||e[3]!==s?(c={orgSlug:o.slug,threadId:s,jobId:r,enabled:i},e[0]=r,e[1]=i,e[2]=o.slug,e[3]=s,e[4]=c):c=e[4];const u=FS(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(qS),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(US),e[7]=a,e[8]=h):h=e[8];const m=h,g=f.length>0?f:m,y=t.input?.prompt??"No prompt provided";let x;e[9]!==y?(x=y.length>120?`${y.slice(0,120)}…`:y,e[9]=y,e[10]=x):x=e[10];const b=x,k=a.length===0;let v;e[11]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(kr,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(ji,{})}),e[11]=v):v=e[11];const S=k?"loading":"idle",w=u.streaming||k;let C;e[12]!==g||e[13]!==r||e[14]!==y||e[15]!==w?(C=p.jsx(WS,{jobId:r,prompt:y,items:g,streaming:w}),e[12]=g,e[13]=r,e[14]=y,e[15]=w,e[16]=C):C=e[16];let T;return e[17]!==b||e[18]!==S||e[19]!==C?(T=p.jsx(El,{icon:v,title:"Subtask",summary:b,state:S,onOpenChange:l,children:C}),e[17]=b,e[18]=S,e[19]=C,e[20]=T):T=e[20],T}function US(n){return n.parts??[]}function qS(n){return n.parts??[]}function KS(n){const e=D.c(13);if(Wf(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Kf,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=Uf(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:o,state:i}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(kr,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(ji,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(qf,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==i||e[9]!==s||e[10]!==a||e[11]!==o?(c=p.jsx(El,{icon:l,title:r,summary:s,state:i,usage:o,children:a}),e[7]=r,e[8]=i,e[9]=s,e[10]=a,e[11]=o,e[12]=c):c=e[12],c}function JS(n){const e=D.c(17),t=hp(n.part.input?.agent_id);if(Wf(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Kf,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=Uf(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:o,usage:i,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(ji,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(kr,{icon:a,name:c,size:"2xs",className:"rounded-xs",fallbackIcon:u}),e[5]=a,e[6]=c,e[7]=d):d=e[7];const f=t?.title??s;let h;e[8]!==n.part?(h=p.jsx(qf,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==o||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==i?(m=p.jsx(El,{icon:d,title:f,summary:o,state:l,usage:i,children:h}),e[10]=l,e[11]=o,e[12]=d,e[13]=f,e[14]=h,e[15]=i,e[16]=m):m=e[16],m}function GS(n){const e=D.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",o=t.output?.approved===!0;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(Wo,{className:"size-4 text-purple-500 shrink-0"}),l=p.jsx("span",{className:"text-[14px] font-medium text-foreground/80",children:"Implementation Plan"}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let a;e[2]!==o?(a=o&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 bg-green-500/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(Ai,{size:12}),"Approved"]}),e[2]=o,e[3]=a):a=e[3];let c;e[4]!==o||e[5]!==t.state?(c=!o&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=o,e[5]=t.state,e[6]=c):c=e[6];let u;e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[i,l,a,c]}),e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"View plan"}),e[10]=d):d=e[10];let f;e[11]!==r?(f=p.jsxs("details",{className:"ml-6",children:[d,p.jsx("div",{className:"mt-1 pl-2 border-l-2 border-purple-500/30 prose prose-sm max-w-none text-sm",children:p.jsx(no,{id:"plan-content",part:{type:"text",text:r}})})]}),e[11]=r,e[12]=f):f=e[12];let h;return e[13]!==u||e[14]!==f?(h=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,f]}),e[13]=u,e[14]=f,e[15]=h):h=e[15],h}const Al={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function XS(n){return n.startsWith("http")?n:`https://${n}`}function bc(n){const e=D.c(2),{children:t}=n;let r;return e[0]!==t?(r=p.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[0]=t,e[1]=r):r=e[1],r}function YS(n){const e=D.c(12),{name:t,value:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"size-7 shrink-0 rounded-md border border-border",style:{backgroundColor:r},"aria-hidden":!0}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==o||e[7]!==i?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8];let a;return e[9]!==s||e[10]!==l?(a=p.jsxs("div",{className:"flex items-center gap-2.5",children:[s,l]}),e[9]=s,e[10]=l,e[11]=a):a=e[11],a}function QS(n){const e=D.c(15),{role:t,family:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"text-2xl font-medium leading-none text-foreground shrink-0",style:{fontFamily:r},"aria-hidden":!0,children:"Aa"}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i={fontFamily:r},e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r||e[7]!==i?(l=p.jsx("span",{className:"text-sm text-foreground",style:i,children:r}),e[6]=r,e[7]=i,e[8]=l):l=e[8];let a;e[9]!==o||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[o,l]}),e[9]=o,e[10]=l,e[11]=a):a=e[11];let c;return e[12]!==s||e[13]!==a?(c=p.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted px-4 py-3",children:[s,a]}),e[12]=s,e[13]=a,e[14]=c):c=e[14],c}function ZS(n){const e=D.c(3),{logo:t,favicon:r,name:s}=n,o=t??r;if(!o)return null;const i=s?`${s} logo`:"";let l;return e[0]!==o||e[1]!==i?(l=p.jsx("img",{src:o,alt:i,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:ev}),e[0]=o,e[1]=i,e[2]=l):l=e[2],l}function ev(n){n.target.style.display="none"}function Jf(n){const e=D.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(nv),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let o;return e[2]!==s?(o=p.jsx("div",{className:"flex h-1.5",children:s.map(tv)}),e[2]=s,e[3]=o):o=e[3],o}function tv(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${Al[e]}: ${t}`,"aria-hidden":!0},e)}function nv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Gf(n){const e=D.c(36),{logo:t,favicon:r,name:s,domain:o,overview:i,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(iv):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(ov):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(Jf,{colors:l}),e[4]=l,e[5]=g):g=e[5];let y;e[6]!==r||e[7]!==t||e[8]!==s?(y=p.jsx(ZS,{logo:t,favicon:r,name:s}),e[6]=r,e[7]=t,e[8]=s,e[9]=y):y=e[9];let x;e[10]!==u||e[11]!==s||e[12]!==c?(x=s&&p.jsxs("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-foreground truncate",children:[s,c&&u&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[p.jsx($c,{className:"size-3 text-amber-500"}),"default"]})]}),e[10]=u,e[11]=s,e[12]=c,e[13]=x):x=e[13];let b;e[14]!==o?(b=o&&p.jsxs("a",{href:XS(o),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[o,p.jsx(Fc,{className:"size-3 shrink-0"})]}),e[14]=o,e[15]=b):b=e[15];let k;e[16]!==x||e[17]!==b?(k=p.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[x,b]}),e[16]=x,e[17]=b,e[18]=k):k=e[18];let v;e[19]!==y||e[20]!==k?(v=p.jsxs("div",{className:"flex items-center gap-4",children:[y,k]}),e[19]=y,e[20]=k,e[21]=v):v=e[21];let S;e[22]!==i?(S=i&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:i}),e[22]=i,e[23]=S):S=e[23];let w;e[24]!==f?(w=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(bc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(sv)})]}),e[24]=f,e[25]=w):w=e[25];let C;e[26]!==m?(C=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(bc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(rv)})]}),e[26]=m,e[27]=C):C=e[27];let T;e[28]!==w||e[29]!==C||e[30]!==v||e[31]!==S?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[v,S,w,C]}),e[28]=w,e[29]=C,e[30]=v,e[31]=S,e[32]=T):T=e[32];let N;return e[33]!==T||e[34]!==g?(N=p.jsxs("div",{className:"mt-2 rounded-lg overflow-hidden border border-border",children:[g,T]}),e[33]=T,e[34]=g,e[35]=N):N=e[35],N}function rv(n){const[e,t]=n;return p.jsx(QS,{role:e,family:t},e)}function sv(n){const[e,t]=n;return p.jsx(YS,{name:Al[e],value:t},e)}function ov(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function iv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function lv(n){const e=D.c(29),{part:t,latency:r}=n,s=Ye(t.state);let o;e[0]!==t.output?(o=_n(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){const C=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(nt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=C?.domain?`from ${C.domain}`:void 0;let E;return e[3]!==N?(E=p.jsx(J,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=E):E=e[4],E}if(a){let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(nt,{}),e[5]=C):C=e[5];const T=i?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[6]=r,e[7]=N):N=e[7];let E;return e[8]!==T||e[9]!==N?(E=p.jsx(J,{icon:C,title:"Brand extraction failed",summary:T,state:"error",trailing:N}),e[8]=T,e[9]=N,e[10]=E):E=e[10],E}let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(nt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=i?.name?`Brand set: ${i.name}`:"Brand context set",d=i?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[12]=r,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==d||e[16]!==f?(h=p.jsx(J,{icon:c,title:u,summary:d,state:"idle",trailing:f}),e[14]=u,e[15]=d,e[16]=f,e[17]=h):h=e[17];const m=i?.logo,g=i?.favicon,y=i?.name,x=i?.domain,b=i?.overview,k=i?.colors,v=i?.fonts;let S;e[18]!==x||e[19]!==b||e[20]!==k||e[21]!==v||e[22]!==m||e[23]!==g||e[24]!==y?(S=p.jsx(Gf,{logo:m,favicon:g,name:y,domain:x,overview:b,colors:k,fonts:v}),e[18]=x,e[19]=b,e[20]=k,e[21]=v,e[22]=m,e[23]=g,e[24]=y,e[25]=S):S=e[25];let w;return e[26]!==S||e[27]!==h?(w=p.jsxs(p.Fragment,{children:[h,S]}),e[26]=S,e[27]=h,e[28]=w):w=e[28],w}function av(n){const e=D.c(27),{part:t,latency:r}=n,s=Ye(t.state);let o;e[0]!==t.output?(o=_n(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(J,{icon:p.jsx(nt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!i){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(nt,{}),e[3]=g):g=e[3];let y;e[4]!==r?(y=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[4]=r,e[5]=y):y=e[5];let x;return e[6]!==y?(x=p.jsx(J,{icon:g,title:"Couldn't load brand",state:"error",trailing:y}),e[6]=y,e[7]=x):x=e[7],x}let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(nt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=i.name?`Brand · ${i.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==i.domain||e[12]!==u||e[13]!==d?(f=p.jsx(J,{icon:c,title:u,summary:i.domain,state:"idle",trailing:d}),e[11]=i.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==i.colors||e[16]!==i.domain||e[17]!==i.favicon||e[18]!==i.fonts||e[19]!==i.isDefault||e[20]!==i.logo||e[21]!==i.name||e[22]!==i.overview?(h=p.jsx(Gf,{logo:i.logo,favicon:i.favicon,name:i.name,domain:i.domain,overview:i.overview,colors:i.colors,fonts:i.fonts,showDefaultBadge:!0,isDefault:i.isDefault}),e[15]=i.colors,e[16]=i.domain,e[17]=i.favicon,e[18]=i.fonts,e[19]=i.isDefault,e[20]=i.logo,e[21]=i.name,e[22]=i.overview,e[23]=h):h=e[23];let m;return e[24]!==f||e[25]!==h?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[24]=f,e[25]=h,e[26]=m):m=e[26],m}function cv(n){const e=D.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=Ye(t.state),e[0]=t.state,e[1]=s):s=e[1];const o=s;let i,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==o){c=Symbol.for("react.early_return_sentinel");e:{const f=_n(t.output),h=Array.isArray(f?.items)?f.items:[],m=o==="loading",g=o==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(J,{icon:p.jsx(nt,{className:"animate-pulse"}),title:"Loading brands",state:"loading"}),e[9]=k):k=e[9],c=k;break e}if(g){let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(nt,{}),e[10]=k):k=e[10];let v;e[11]!==r?(v=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[11]=r,e[12]=v):v=e[12];let S;e[13]!==v?(S=p.jsx(J,{icon:k,title:"Couldn't load brands",state:"error",trailing:v}),e[13]=v,e[14]=S):S=e[14],c=S;break e}if(h.length===0){let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(nt,{}),e[15]=k):k=e[15];let v;e[16]!==r?(v=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[16]=r,e[17]=v):v=e[17];let S;e[18]!==v?(S=p.jsx(J,{icon:k,title:"No brands yet",summary:"The organization hasn't set up any brand context.",state:"idle",trailing:v}),e[18]=v,e[19]=S):S=e[19],c=S;break e}let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx(nt,{className:"text-fuchsia-500"}),e[20]=y):y=e[20];const x=h.length===1?"1 brand":`${h.length} brands`;let b;e[21]!==r?(b=r!=null&&r>0?p.jsx(Te,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==x||e[24]!==b?(a=p.jsx(J,{icon:y,title:x,state:"idle",trailing:b}),e[23]=x,e[24]=b,e[25]=a):a=e[25],i="mt-2 flex flex-col gap-1.5",l=h.map(uv)}e[2]=r,e[3]=t.output,e[4]=o,e[5]=i,e[6]=l,e[7]=a,e[8]=c}else i=e[5],l=e[6],a=e[7],c=e[8];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;e[26]!==i||e[27]!==l?(u=p.jsx("div",{className:i,children:l}),e[26]=i,e[27]=l,e[28]=u):u=e[28];let d;return e[29]!==a||e[30]!==u?(d=p.jsxs(p.Fragment,{children:[a,u]}),e[29]=a,e[30]=u,e[31]=d):d=e[31],d}function uv(n){const e=n.colors?Object.entries(n.colors).filter(hv):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(Jf,{colors:n.colors}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(n.logo||n.favicon)&&p.jsx("img",{src:n.logo??n.favicon??void 0,alt:"",className:"size-8 shrink-0 rounded-md border border-border bg-background object-contain p-0.5",onError:fv}),p.jsxs("div",{className:"flex flex-col leading-tight min-w-0 flex-1",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-foreground truncate",children:[n.name??"Untitled",n.isDefault&&p.jsx($c,{className:"size-3 text-amber-500 shrink-0"})]}),n.domain&&p.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:n.domain})]}),e.length>0&&p.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:e.slice(0,5).map(dv)})]})]},n.id??`${n.name}-${n.domain}`)}function dv(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${Al[e]}: ${t}`,"aria-hidden":!0},e)}function fv(n){n.target.style.display="none"}function hv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Ci(n){const e=D.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,o=mp(t);if(!o)return null;let i;return e[0]!==o.icon||e[1]!==o.title||e[2]!==s?(i=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(kr,{icon:o.icon,name:o.title,size:s})}),e[0]=o.icon,e[1]=o.title,e[2]=s,e[3]=i):i=e[3],i}Ci.Fallback=function({iconSize:e="xs"}){const t=e==="sm"?"size-6":"size-5";return p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:X(t,"rounded bg-muted animate-pulse")})})};function xr(n){const e=D.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:o}=n,i=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==o||e[1]!==t||e[2]!==l||e[3]!==i){const h=t.slice(0,i);a=t.length-i,e[7]!==o?(c=X("flex items-center justify-end -space-x-2",o),e[7]=o,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(M.Suspense,{fallback:p.jsx(Ci.Fallback,{iconSize:l}),children:p.jsx(Ci,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=o,e[1]=t,e[2]=l,e[3]=i,e[4]=a,e[5]=c,e[6]=u}else a=e[4],c=e[5],u=e[6];let d;e[11]!==l||e[12]!==a?(d=a>0&&p.jsx("div",{className:X("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",l==="sm"?"size-8":"size-6"),children:p.jsxs("span",{className:X(l==="sm"?"text-sm":"text-xs","font-medium text-muted-foreground"),"aria-label":`and ${a} more`,children:["+",a]})}),e[11]=l,e[12]=a,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==u||e[16]!==d?(f=p.jsxs("div",{className:c,children:[u,d]}),e[14]=c,e[15]=u,e[16]=d,e[17]=f):f=e[17],f}xr.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",o=r==="sm"?"size-8":"size-6",i=t!==void 0&&t>e;return p.jsxs("div",{className:"flex items-center -space-x-2",children:[Array.from({length:e}).map((l,a)=>p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:X(s,"rounded bg-muted animate-pulse")})},a)),i&&p.jsx("div",{className:X("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",o),children:p.jsx("div",{className:X(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const pv="This document certifies that the bearer agent has been granted authorized access to the tools and capabilities described herein. The agent is permitted to operate within the scope defined by its instructions and shall act in accordance with the constraints set forth by the issuing organization. This credential remains valid for the duration of the agent's active status. Unauthorized modification of this agent's permissions or scope is prohibited. The issuing authority reserves the right to revoke access at any time. All actions performed by this agent are subject to audit and review by the organization administrator. ",kc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function mv(n){const e=D.c(64),{part:t,latency:r}=n,s=Hc(),o=Ye(t.state),i=M.useRef(null),l=M.useRef(null),a=M.useRef(null),c=M.useRef(null),u=M.useRef(null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{kc?.matches||(u.current=i.current?.getBoundingClientRect()??null,i.current&&(i.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=K=>{if(kc?.matches)return;const oe=u.current,ve=i.current;if(!oe||!ve)return;const Re=(K.clientX-oe.left)/oe.width*100,it=(K.clientY-oe.top)/oe.height*100;ve.style.transform=`perspective(800px) rotateY(${(Re-50)*.05}deg) rotateX(${(it-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(Re-50)*.15}px, ${(it-50)*.15}px)`),a.current&&(a.current.style.opacity="0.45"),c.current&&(c.current.style.opacity="0.45")},e[1]=h):h=e[1];const m=h;let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const K=i.current;K&&(K.style.transform="none",K.style.willChange="auto"),l.current&&(l.current.style.opacity="0.4",l.current.style.transform="translate(0, 0)"),a.current&&(a.current.style.opacity="0.3"),c.current&&(c.current.style.opacity="0.3"),u.current=null},e[2]=g):g=e[2];const y=g;if(o==="loading"){let K;return e[3]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(J,{icon:p.jsx(tt,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=K):K=e[3],K}if(o==="approval"){let K;return e[4]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(J,{icon:p.jsx(tt,{}),title:"Create agent",state:"idle"}),e[4]=K):K=e[4],K}if(o==="error"){let K;e[5]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(tt,{}),e[5]=K):K=e[5];const oe=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let ve;e[6]!==r?(ve=p.jsx(Te,{latency:r}),e[6]=r,e[7]=ve):ve=e[7];let Re;return e[8]!==oe||e[9]!==ve?(Re=p.jsx(J,{icon:K,title:oe,state:"error",trailing:ve}),e[8]=oe,e[9]=ve,e[10]=Re):Re=e[10],Re}let x,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(x=_n(t.output)?.item,!x?.id||!x?.title){let K;e[16]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(tt,{}),e[16]=K):K=e[16];let oe;e[17]!==r?(oe=p.jsx(J,{icon:K,title:"Agent created",state:"idle",trailing:p.jsx(Te,{latency:r})}),e[17]=r,e[18]=oe):oe=e[18],k=oe;break e}b=(x.connections??[]).map(gv)}e[11]=r,e[12]=t.output,e[13]=x,e[14]=b,e[15]=k}else x=e[13],b=e[14],k=e[15];if(k!==Symbol.for("react.early_return_sentinel"))return k;const v=b;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(tt,{className:"text-emerald-500"}),e[19]=S):S=e[19];const w=`Agent created: ${x.title}`;let C;e[20]!==r?(C=p.jsx(Te,{latency:r}),e[20]=r,e[21]=C):C=e[21];let T;e[22]!==w||e[23]!==C?(T=p.jsx(J,{icon:S,title:w,state:"idle",trailing:C}),e[22]=w,e[23]=C,e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N={transition:"transform 0.3s ease-out"},e[25]=N):N=e[25];let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=p.jsx("div",{ref:l,className:"pointer-events-none absolute inset-[-20%] z-[1] select-none rounded-lg",style:{background:"linear-gradient(135deg, hsla(280, 60%, 80%, 0.35) 0%, transparent 35%), linear-gradient(315deg, hsla(190, 70%, 80%, 0.35) 0%, transparent 35%), linear-gradient(225deg, hsla(140, 55%, 80%, 0.3) 0%, transparent 30%), linear-gradient(45deg, hsla(320, 55%, 82%, 0.3) 0%, transparent 30%)",opacity:.4,transition:"opacity 0.3s ease, transform 0.3s ease-out"},"aria-hidden":"true"}),e[26]=E):E=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j={textAlign:"justify",wordBreak:"break-all"},e[27]=j):j=e[27];let L,I;e[28]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx("p",{className:"pointer-events-none absolute inset-0 z-[1] select-none overflow-hidden text-[6px] font-light leading-[1.5] tracking-[0.06px] text-background opacity-50 mix-blend-overlay",style:j,"aria-hidden":"true",children:pv.repeat(6)}),I=p.jsx("img",{src:"/stamp.svg",alt:"",className:"pointer-events-none absolute -right-10 -top-10 size-[140px] opacity-50 select-none","aria-hidden":"true"}),e[28]=L,e[29]=I):(L=e[28],I=e[29]);let P;e[30]===Symbol.for("react.memo_cache_sentinel")?(P=p.jsx("img",{ref:a,src:"/left-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 left-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[30]=P):P=e[30];let R;e[31]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx("img",{ref:c,src:"/right-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 right-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[31]=R):R=e[31];let z;e[32]!==x.icon||e[33]!==x.title?(z=p.jsx(Ac,{icon:x.icon,name:x.title,size:"md"}),e[32]=x.icon,e[33]=x.title,e[34]=z):z=e[34];let B;e[35]!==x.title?(B=p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:x.title})}),e[35]=x.title,e[36]=B):B=e[36];let $;e[37]!==z||e[38]!==B?($=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[z,B]}),e[37]=z,e[38]=B,e[39]=$):$=e[39];let F;e[40]!==x.description?(F=x.description&&p.jsx("div",{className:"px-2 pt-1 pr-16",children:p.jsx("p",{className:"text-sm leading-snug text-muted-foreground line-clamp-2",children:x.description})}),e[40]=x.description,e[41]=F):F=e[41];let G;e[42]!==$||e[43]!==F?(G=p.jsxs("div",{className:"relative",children:[$,F]}),e[42]=$,e[43]=F,e[44]=G):G=e[44];let Q;e[45]!==v?(Q=v.length>0&&p.jsx(M.Suspense,{fallback:p.jsx(xr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:v.length}),children:p.jsx(xr,{connectionIds:v,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=v,e[46]=Q):Q=e[46];let Z;e[47]!==Q?(Z=p.jsx("div",{className:"flex-1 min-w-0",children:Q}),e[47]=Q,e[48]=Z):Z=e[48];let se;e[49]!==x.id||e[50]!==s?(se=()=>s(x.id),e[49]=x.id,e[50]=s,e[51]=se):se=e[51];const Pe=`See agent: ${x.title}`;let Le;e[52]!==se||e[53]!==Pe?(Le=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(ir,{size:"sm",className:"h-7",onClick:se,"aria-label":Pe,children:"See agent"})}),e[52]=se,e[53]=Pe,e[54]=Le):Le=e[54];let ze;e[55]!==Z||e[56]!==Le?(ze=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[Z,Le]}),e[55]=Z,e[56]=Le,e[57]=ze):ze=e[57];let Ke;e[58]!==G||e[59]!==ze?(Ke=p.jsx("div",{className:"mt-2 overflow-hidden rounded-xl border-[0.5px] border-border bg-card p-2.5",children:p.jsxs("div",{ref:i,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:y,children:[E,L,I,P,R,G,ze]})}),e[58]=G,e[59]=ze,e[60]=Ke):Ke=e[60];let gt;return e[61]!==Ke||e[62]!==T?(gt=p.jsxs(p.Fragment,{children:[T,Ke]}),e[61]=Ke,e[62]=T,e[63]=gt):gt=e[63],gt}function gv(n){return n.connection_id}function yv(n){const e=D.c(24),{agent:t}=n,r=Hc();if(!t.id)return null;let s;e[0]!==t.connections?(s=t.connections??[],e[0]=t.connections,e[1]=s):s=e[1];let o;e[2]!==s?(o=s.map(xv),e[2]=s,e[3]=o):o=e[3];const i=o;let l;e[4]!==t.id||e[5]!==r?(l=()=>r(t.id),e[4]=t.id,e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t.icon||e[8]!==t.title?(a=p.jsx(Ac,{icon:t.icon,name:t.title,size:"sm"}),e[7]=t.icon,e[8]=t.title,e[9]=a):a=e[9];let c;e[10]!==t.title?(c=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[10]=t.title,e[11]=c):c=e[11];let u;e[12]!==t.description?(u=t.description&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.description}),e[12]=t.description,e[13]=u):u=e[13];let d;e[14]!==c||e[15]!==u?(d=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16];let f;e[17]!==i?(f=i.length>0&&p.jsx(M.Suspense,{fallback:p.jsx(xr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:i.length}),children:p.jsx(xr,{connectionIds:i,iconSize:"xs",maxVisibleIcons:3})}),e[17]=i,e[18]=f):f=e[18];let h;return e[19]!==l||e[20]!==a||e[21]!==d||e[22]!==f?(h=p.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[a,d,f]}),e[19]=l,e[20]=a,e[21]=d,e[22]=f,e[23]=h):h=e[23],h}function xv(n){return n.connection_id}function bv(n){const e=D.c(41),{part:t,latency:r}=n,s=Pn(),{org:o}=Lt();let i;e[0]!==t.state?(i=Ye(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const x=_n(t.output);if(c=Array.isArray(x?.items)?x.items:[],l==="loading"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(J,{icon:p.jsx(tt,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="approval"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(J,{icon:p.jsx(tt,{}),title:"List agents",state:"idle"}),e[13]=w):w=e[13],h=w;break e}if(l==="error"){let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(tt,{}),e[14]=w):w=e[14];const C=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx(Te,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==C||e[18]!==T?(N=p.jsx(J,{icon:w,title:C,state:"error",trailing:T}),e[17]=C,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(tt,{}),e[20]=w):w=e[20];let C;e[21]!==r?(C=p.jsx(J,{icon:w,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx(Te,{latency:r})}),e[21]=r,e[22]=C):C=e[22],h=C;break e}const b=c.slice(0,$f);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(tt,{className:"text-emerald-500"}),e[23]=k):k=e[23];const v=c.length===1?"1 agent":`${c.length} agents`;let S;e[24]!==r?(S=p.jsx(Te,{latency:r}),e[24]=r,e[25]=S):S=e[25],e[26]!==v||e[27]!==S?(f=p.jsx(J,{icon:k,title:v,state:"idle",trailing:S}),e[26]=v,e[27]=S,e[28]=f):f=e[28],u="mt-2 flex flex-col gap-1.5",d=b.map(kv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[29]!==a||e[30]!==c||e[31]!==s||e[32]!==o?(m=a>0&&p.jsx(zf,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:o.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=o,e[33]=m):m=e[33];let g;e[34]!==u||e[35]!==d||e[36]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[34]=u,e[35]=d,e[36]=m,e[37]=g):g=e[37];let y;return e[38]!==f||e[39]!==g?(y=p.jsxs(p.Fragment,{children:[f,g]}),e[38]=f,e[39]=g,e[40]=y):y=e[40],y}function kv(n){return p.jsx(yv,{agent:n},n.id)}const Sv={active:"bg-emerald-500",inactive:"bg-muted-foreground",error:"bg-destructive"};function vv(n){const e=D.c(27),{connection:t}=n,r=Pn(),{org:s}=Lt(),o=t.slug,i=t.description||t.app_name,l=!o||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==o?(a=()=>o&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:o}}),e[0]=r,e[1]=s,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(kr,{icon:t.icon,name:t.title,size:"sm"}),e[4]=t.icon,e[5]=t.title,e[6]=c):c=e[6];let u;e[7]!==t.title?(u=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[7]=t.title,e[8]=u):u=e[8];let d;e[9]!==i?(d=i&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=d):d=e[10];let f;e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13];const h=Sv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=X("size-2 shrink-0 rounded-full",h),e[14]=h,e[15]=m):m=e[15];let g;e[16]!==m?(g=p.jsx("span",{className:m,"aria-hidden":"true"}),e[16]=m,e[17]=g):g=e[17];let y;e[18]!==t.status?(y=p.jsx("span",{className:"sr-only",children:t.status}),e[18]=t.status,e[19]=y):y=e[19];let x;return e[20]!==l||e[21]!==y||e[22]!==a||e[23]!==c||e[24]!==f||e[25]!==g?(x=p.jsxs("button",{type:"button","aria-disabled":l,onClick:a,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer aria-disabled:cursor-default aria-disabled:hover:bg-card",children:[c,f,g,y]}),e[20]=l,e[21]=y,e[22]=a,e[23]=c,e[24]=f,e[25]=g,e[26]=x):x=e[26],x}function wv(n){const e=D.c(40),{part:t,latency:r}=n,s=Pn(),{org:o}=Lt();let i;e[0]!==t.state?(i=Ye(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const x=_n(t.output);if(c=(Array.isArray(x?.items)?x.items:[]).filter(Tv),l==="loading"||l==="approval"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(J,{icon:p.jsx(Mr,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="error"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Mr,{}),e[13]=w):w=e[13];const C=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx(Te,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==C||e[17]!==T?(N=p.jsx(J,{icon:w,title:C,state:"error",trailing:T}),e[16]=C,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Mr,{}),e[19]=w):w=e[19];let C;e[20]!==r?(C=p.jsx(J,{icon:w,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx(Te,{latency:r})}),e[20]=r,e[21]=C):C=e[21],h=C;break e}const b=c.slice(0,$f);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Mr,{className:"text-emerald-500"}),e[22]=k):k=e[22];const v=c.length===1?"1 connection":`${c.length} connections`;let S;e[23]!==r?(S=p.jsx(Te,{latency:r}),e[23]=r,e[24]=S):S=e[24],e[25]!==v||e[26]!==S?(f=p.jsx(J,{icon:k,title:v,state:"idle",trailing:S}),e[25]=v,e[26]=S,e[27]=f):f=e[27],u="mt-2 flex flex-col gap-1.5",d=b.map(Cv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[28]!==a||e[29]!==c||e[30]!==s||e[31]!==o?(m=a>0&&p.jsx(zf,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:o.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=o,e[32]=m):m=e[32];let g;e[33]!==u||e[34]!==d||e[35]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[33]=u,e[34]=d,e[35]=m,e[36]=g):g=e[36];let y;return e[37]!==f||e[38]!==g?(y=p.jsxs(p.Fragment,{children:[f,g]}),e[37]=f,e[38]=g,e[39]=y):y=e[39],y}function Cv(n){return p.jsx(vv,{connection:n},n.id)}function Tv(n){return n.connection_type!=="VIRTUAL"}function Nv(){const n=D.c(37),e=Ri(),{sendMessage:t,isStreaming:r,messages:s}=Wh(),{org:o}=Lt(),i=e?.virtualMcpId,{prompts:l}=ap(o.slug),a=i??null;let c;n[0]!==o.id||n[1]!==o.slug||n[2]!==a?(c={connectionId:a,orgId:o.id,orgSlug:o.slug},n[0]=o.id,n[1]=o.slug,n[2]=a,n[3]=c):c=n[3];const u=Lc(c),[d,f]=M.useState(null);if(!i||r||!yp(i)||!s.some(Mv))return null;let m;if(n[4]!==l||n[5]!==i){let I;n[7]!==i?(I=P=>P.agentId===i&&P.promptName,n[7]=i,n[8]=I):I=n[8],m=l.find(I),n[4]=l,n[5]=i,n[6]=m}else m=n[6];const g=m;if(!g)return null;let y;n[9]!==u||n[10]!==t?(y=async(I,P)=>{if(!u){Vo.error("MCP client not available");return}try{const R=await xp(u,I.name,P);await t({type:"doc",content:[{type:"paragraph",content:[cf({id:I.name,name:Pi(I.name,Di(I._meta)),metadata:R.messages,char:"/",kind:"prompt",args:P}),{type:"text",text:" "}]}]})}catch(R){console.error("[next-action-chip] failed",R),Vo.error("Failed to load prompt. Please try again.")}},n[9]=u,n[10]=t,n[11]=y):y=n[11];const x=y;let b;n[12]!==g._meta||n[13]!==g.arguments||n[14]!==g.description||n[15]!==g.promptName||n[16]!==g.title||n[17]!==x?(b=()=>{const I={name:g.promptName,title:g.title,description:g.description,arguments:g.arguments,_meta:g._meta};if(I.arguments&&I.arguments.length>0){f(I);return}x(I)},n[12]=g._meta,n[13]=g.arguments,n[14]=g.description,n[15]=g.promptName,n[16]=g.title,n[17]=x,n[18]=b):b=n[18];const k=b;let v,S;n[19]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(gp,{size:12,className:"shrink-0 text-purple-500"}),S=p.jsx("span",{className:"font-medium text-foreground/80",children:"Next:"}),n[19]=v,n[20]=S):(v=n[19],S=n[20]);let w;n[21]!==g.title?(w=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=w):w=n[22];let C;n[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Oc,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=C):C=n[23];let T;n[24]!==k||n[25]!==w?(T=p.jsxs("button",{type:"button",onClick:k,className:"group mt-3 flex items-center gap-2 self-start rounded-full border border-border bg-background px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-border hover:bg-accent/40 hover:text-foreground",children:[v,S,w,C]}),n[24]=k,n[25]=w,n[26]=T):T=n[26];let N;n[27]===Symbol.for("react.memo_cache_sentinel")?(N=I=>f(I),n[27]=N):N=n[27];let E;n[28]!==d||n[29]!==x?(E=async I=>{const P=d;f(null),P&&await x(P,I)},n[28]=d,n[29]=x,n[30]=E):E=n[30];let j;n[31]!==d||n[32]!==E?(j=p.jsx(Vp,{prompt:d,setPrompt:N,onSubmit:E}),n[31]=d,n[32]=E,n[33]=j):j=n[33];let L;return n[34]!==j||n[35]!==T?(L=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=L):L=n[36],L}function Mv(n){return n.role==="user"||n.parts.some(Ev)}function Ev(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function Av(n){const e=new Map;for(let t=n.length-1;t>=0;t--){const r=n[t]?.parts;if(r)for(const s of r){const o=s;if(o.type!=="data-deck-updated")continue;const i=o.data;if(!i?.path)continue;const l=`deck:${i.path}`;e.has(l)||e.set(l,{tabId:Xh(i.path),label:i.name||i.path,kind:i.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function Ov(){const n=D.c(9),e=Pn(),t=Ln()?.messages??[],r=Av(t);if(r.length===0)return null;const s=r.some(Rv),o=r.some(Iv),i=s?o?"Slides & pages in this chat":"Slides in this chat":"Pages in this chat",l="flex flex-col gap-1.5 py-2";let a;n[0]!==i?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:i}),n[0]=i,n[1]=a):a=n[1];const c="flex flex-wrap gap-2";let u;n[2]!==e?(u=m=>p.jsxs("button",{type:"button",onClick:()=>e({to:".",search:g=>({...g,main:m.tabId}),replace:!0}),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/30 hover:bg-muted/60 text-[13px] transition-colors",children:[m.kind==="deck"?p.jsx(Jn,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(tp,{className:"size-3.5 shrink-0 text-muted-foreground"}),p.jsx("span",{className:"font-medium text-foreground",children:m.label})]},m.tabId),n[2]=e,n[3]=u):u=n[3];const d=r.map(u);let f;n[4]!==d?(f=p.jsx("div",{className:c,children:d}),n[4]=d,n[5]=f):f=n[5];let h;return n[6]!==a||n[7]!==f?(h=p.jsxs("div",{className:l,children:[a,f]}),n[6]=a,n[7]=f,n[8]=h):h=n[8],h}function Iv(n){return n.kind==="page"}function Rv(n){return n.kind==="deck"}async function jv(n,e){const t=await fetch(`/api/${e}/threads/${encodeURIComponent(n)}/outputs`,{credentials:"include"});if(!t.ok)throw new Error(`Failed to fetch thread outputs: ${t.status}`);return(await t.json()).objects??[]}function $2(){const n=D.c(2),e=Ln()?.messages??[];let t;return n[0]!==e?(t=e.some(Dv),n[0]=e,n[1]=t):t=n[1],t}function Dv(n){return n.parts?.some(Pv)}function Pv(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function Lv(n,e){const t=D.c(9),{org:r}=Lt();let s;t[0]!==n?(s=Wt.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let o;t[2]!==r||t[3]!==n?(o=()=>jv(n??"",r.slug),t[2]=r,t[3]=n,t[4]=o):o=t[4];const i=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==o||t[7]!==i?(l={queryKey:s,queryFn:o,enabled:i,staleTime:0},t[5]=s,t[6]=o,t[7]=i,t[8]=l):l=t[8],Mi(l)}function _v(n){const e=D.c(20),{file:t}=n,r=Pn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:Yh(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const o=s;let i;e[3]!==t.filename?(i=p.jsx($h,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=i):i=e[4];let l;e[5]!==t.filename||e[6]!==o?(l=p.jsx("button",{type:"button",onClick:o,className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-foreground hover:underline",title:t.filename,children:t.filename}),e[5]=t.filename,e[6]=o,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(zc,{className:"size-3.5"}),e[8]=c):c=e[8];let u;e[9]!==t.downloadUrl||e[10]!==t.filename||e[11]!==a?(u=p.jsx("a",{href:t.downloadUrl,download:t.filename,className:"hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:block",title:"Download","aria-label":a,children:c}),e[9]=t.downloadUrl,e[10]=t.filename,e[11]=a,e[12]=u):u=e[12];let d;e[13]!==o?(d=p.jsx(ir,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:o,children:"Open"}),e[13]=o,e[14]=d):d=e[14];let f;return e[15]!==i||e[16]!==l||e[17]!==u||e[18]!==d?(f=p.jsxs("div",{className:"group flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[i,l,u,d]}),e[15]=i,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Sc(n){return n.split("/").pop()??n}const $v=/(^|\/)output\//;function zv(n){const e=new Set;for(const t of n.parts??[]){const r=t;if(r.state==="output-available"){if(r.type==="tool-share_with_user"){const s=r.output?.filename??r.input?.name??(r.input?.source?Sc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&$v.test(s)&&e.add(Sc(s))}}}return e}function Bv(n){const e=D.c(4),{threadId:t,message:r}=n,s=zv(r),o=s.size>0;let i;e[0]!==o?(i={enabled:o},e[0]=o,e[1]=i):i=e[1];const{data:l}=Lv(t,i);if(s.size===0)return null;const a=(l??[]).filter(f=>s.has(f.filename));if(a.length===0)return null;const c="flex flex-col gap-1.5 py-2",u=a.map(Fv);let d;return e[2]!==u?(d=p.jsx("div",{className:c,children:u}),e[2]=u,e[3]=d):d=e[3],d}function Fv(n){return p.jsx(_v,{file:n},n.key)}function Hv(n){return n.type==="reasoning"}function Vv(n){const e=[],t=new Set,r=new Map,s=new Map,o=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(Hv(c)){l||(l={parts:[],startIndex:a},e.push(l)),l.parts.push(c),t.add(a);continue}if(l=null,c.type==="data-tool-metadata"&&"id"in c&&"data"in c){const u=c.data,d={};u.annotations&&(d.annotations=u.annotations),typeof u.latencyMs=="number"&&Number.isFinite(u.latencyMs)&&(d.latencySeconds=u.latencyMs/1e3),typeof u.outputBytes=="number"&&Number.isFinite(u.outputBytes)&&u.outputBytes>=0&&(d.outputBytes=u.outputBytes),u._meta&&typeof u._meta=="object"&&(d._meta=u._meta),r.set(c.id,d);continue}if(c.type==="data-tool-subtask-metadata"&&"id"in c){s.set(c.id,c.data);continue}if(c.type==="data-web-search"&&"id"in c&&"data"in c){const u=c.id,d=c.data;o.set(u,d.text??"");continue}}}const i=[];if(n)for(let l=0;l<n.parts.length;l++){const a=n.parts[l];if(a.type!=="step-start"){if(t.has(l)){const c=e.find(u=>u.startIndex===l);c&&i.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||i.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:i,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:o}}}function Ti(n){const e=D.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>Ll(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,o]=M.useState(r);let i,l;e[2]!==t?(i=()=>{const d=setInterval(()=>o(Ll(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=i,e[4]=l):(i=e[3],l=e[4]),M.useEffect(i,l);const a=s/1e3;let c;e[5]!==a?(c=Rt(a),e[5]=a,e[6]=c):c=e[6];let u;return e[7]!==c?(u=p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground/50",children:c}),e[7]=c,e[8]=u):u=e[8],u}const Xf=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function Wv(){const n=D.c(5),[e]=M.useState(Uv);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={gridTemplateColumns:"repeat(3, 3px)",gap:"1.5px",width:"fit-content"},n[0]=t):t=n[0];let r;n[1]!==e?(r=Xf.map((o,i)=>{const{delay:l}=o;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[i],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},i)}),n[1]=e,n[2]=r):r=n[2];let s;return n[3]!==r?(s=p.jsx("div",{className:"grid",style:t,children:r}),n[3]=r,n[4]=s):s=n[4],s}function Uv(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return Xf.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const qv={planning:{icon:p.jsx(Dh,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves",detail:"Deciding how to approach the request"},thinking:{icon:p.jsx(Bs,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},Kv=1200;function Ni(n){const e=D.c(9),{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==o||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(J,{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:u,latency:a,trailing:c}),e[0]=o,e[1]=u,e[2]=t,e[3]=a,e[4]=i,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function Jv(n){const e=D.c(17),{startedAt:t}=n,r=Ln()?.runStatusStage??null,[s,o]=M.useState("planning");let i,l;if(e[0]!==r?(i=()=>{if(r!==null)return;const f=setTimeout(()=>{o("thinking")},Kv);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=i,e[2]=l):(i=e[1],l=e[2]),M.useEffect(i,l),r!==null){const f=Kh[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Bs,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(Ti,{since:t}),e[4]=t,e[5]=g):g=e[5];let y;return e[6]!==f.detail||e[7]!==m||e[8]!==g?(y=p.jsx(Ni,{icon:h,title:m,summary:f.detail,state:"loading",trailing:g}),e[6]=f.detail,e[7]=m,e[8]=g,e[9]=y):y=e[9],y}const a=qv[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(Ti,{since:t}),e[10]=t,e[11]=u):u=e[11];let d;return e[12]!==a.detail||e[13]!==a.icon||e[14]!==c||e[15]!==u?(d=p.jsx(Ni,{icon:a.icon,title:c,summary:a.detail,state:"loading",trailing:u}),e[12]=a.detail,e[13]=a.icon,e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function Gv(n){const e=D.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(Wv,{}),e[0]=r):r=e[0];let s;return e[1]!==t?(s=p.jsxs("div",{className:"flex items-center gap-2.5 mt-1 pb-1 text-muted-foreground/40 select-none",children:[r,p.jsx(Ti,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const Xv=2e4;function Yv(n){const e=D.c(8),{startedAt:t}=n;Bc(1e3);const r=Ln(),o=(t!==null?Date.now()-t:0)>=Xv;let i;e[0]!==t?(i=p.jsx(Jv,{startedAt:t}),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==o||e[3]!==r?(l=o&&r?.stop&&p.jsxs("div",{className:"flex items-center gap-2 pb-1 text-[13px] text-muted-foreground/60",children:[p.jsx("span",{children:"This is taking longer than usual."}),p.jsx("button",{type:"button",onClick:()=>r.stop(),className:"text-muted-foreground hover:text-foreground underline underline-offset-2",children:"Cancel"})]}),e[2]=o,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==i||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[i,l]}),e[5]=i,e[6]=l,e[7]=a):a=e[7],a}function Qv(n){const e=D.c(20),{duration:t,parts:r,isStreaming:s}=n;let o;e[0]!==r?(o=r.every(tw),e[0]=r,e[1]=o):o=e[1];const i=o;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Rt(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==i||e[5]!==s||e[6]!==r){const k=r.map(ew).join(`
|
|
185
185
|
`).trim().split(`
|
|
186
186
|
`).filter(Boolean),v=s?k[k.length-1]??"":k[0]??"";c=!i&&v?v.length>100?v.slice(0,100)+"…":v:void 0,e[4]=i,e[5]=s,e[6]=r,e[7]=c}else c=e[7];const u=c;let d;if(e[8]!==i||e[9]!==r){const b=r.map(Zv).join(`
|
|
187
187
|
|
|
188
|
-
`);d=!i&&b.trim()?b:null,e[8]=i,e[9]=r,e[10]=d}else d=e[10];const f=d,h=!s&&t!=null?t/1e3:void 0;let m;e[11]!==s?(m=s?p.jsx(Bs,{className:"size-4"}):p.jsx(jh,{className:"size-4"}),e[11]=s,e[12]=m):m=e[12];const g=s?"Thinking...":a,y=s?"loading":"idle";let x;return e[13]!==f||e[14]!==h||e[15]!==u||e[16]!==m||e[17]!==g||e[18]!==y?(x=p.jsx(Ni,{icon:m,title:g,summary:u,detail:f,state:y,detailVariant:"prose",latency:h}),e[13]=f,e[14]=h,e[15]=u,e[16]=m,e[17]=g,e[18]=y,e[19]=x):x=e[19],x}function Zv(n){return n.text??""}function ew(n){return n.text??""}function tw(n){return n.text?.includes("REDACTED")}const nw=3;function rw(n,e){let t=-1;for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.kind==="part"&&e[s.index]?.type==="text"){t=r;break}}return t===-1?{collapsed:[],tail:n}:{collapsed:n.slice(0,t),tail:n.slice(t)}}function sw(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const o=e[s.index]?.type;o==="text"?r++:(o==="dynamic-tool"||o?.startsWith("tool-"))&&o!=="tool-todo_write"&&o!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function ow(n){const e=D.c(8),{toolCalls:t,messages:r}=n;let s;e[0]!==r||e[1]!==t?(s=t>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ic,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[t," tool call",t===1?"":"s",r>0?",":""]})]}),e[0]=r,e[1]=t,e[2]=s):s=e[2];let o;e[3]!==r?(o=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ph,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,o]}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function iw(n){const e=D.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=sw(t,r.parts),e[0]=t,e[1]=r.parts,e[2]=u):u=e[2];const{toolCalls:d,messages:f}=u;if(d===0&&f===0)return null;let h;e[3]!==f||e[4]!==d?(h=p.jsx(ow,{toolCalls:d,messages:f}),e[3]=f,e[4]=d,e[5]=h):h=e[5];let m;if(e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==i){let x;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==r||e[20]!==s||e[21]!==i?(x=(b,k)=>Yf({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=o,e[19]=r,e[20]=s,e[21]=i,e[22]=x):x=e[22],m=t.map(x),e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=t,e[11]=r,e[12]=s,e[13]=i,e[14]=m}else m=e[14];let g;e[23]!==m?(g=p.jsx("div",{className:"flex flex-col gap-3 sm:gap-2 pt-1",children:m}),e[23]=m,e[24]=g):g=e[24];let y;return e[25]!==h||e[26]!==g?(y=p.jsx(J,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=y):y=e[27],y}function Yf({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:o,dataParts:i,isLoading:l,isLast:a,isLastVisiblePart:c,renderOrder:u}){if(n.kind==="reasoning-group"){const{group:m}=n,g=m===r[r.length-1],y=s&&g;if(!m.parts.some(k=>k.text?.trim())&&!y)return null;const b=r.length===1?o:null;return p.jsx(Qv,{duration:b,parts:m.parts,isStreaming:y},`${t.id}-reasoning-${m.startIndex}`)}const d=t.parts[n.index],f=c||(u?u.findLastIndex(m=>m.kind==="part")===e:!1),h=f?Uc(Wc(),t.metadata?.usage):null;return p.jsx(lw,{part:d,id:t.id,usageStats:f&&p.jsx(Uk,{usage:h,duration:o}),dataParts:i,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function lw(n){const e=D.c(121),{part:t,id:r,usageStats:s,dataParts:o,isLoading:i,isLastMessage:l}=n;let a;e[0]!==o.toolMetadata?(a=f=>o.toolMetadata.get(f),e[0]=o.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==o.toolSubtaskMetadata?(u=f=>o.toolSubtaskMetadata.get(f),e[2]=o.toolSubtaskMetadata,e[3]=u):u=e[3];const d=u;switch(t.type){case"dynamic-tool":{let f;e[4]!==c||e[5]!==t.toolCallId?(f=c(t.toolCallId)?.annotations,e[4]=c,e[5]=t.toolCallId,e[6]=f):f=e[6];let h;e[7]!==c||e[8]!==t.toolCallId?(h=c(t.toolCallId)?.latencySeconds,e[7]=c,e[8]=t.toolCallId,e[9]=h):h=e[9];let m;e[10]!==c||e[11]!==t.toolCallId?(m=c(t.toolCallId)?.outputBytes,e[10]=c,e[11]=t.toolCallId,e[12]=m):m=e[12];let g;e[13]!==c||e[14]!==t.toolCallId?(g=c(t.toolCallId)?._meta,e[13]=c,e[14]=t.toolCallId,e[15]=g):g=e[15];let y;return e[16]!==l||e[17]!==t||e[18]!==f||e[19]!==h||e[20]!==m||e[21]!==g?(y=p.jsx(yc,{part:t,annotations:f,latency:h,outputBytes:m,isLastMessage:l,toolMeta:g}),e[16]=l,e[17]=t,e[18]=f,e[19]=h,e[20]=m,e[21]=g,e[22]=y):y=e[22],y}case"tool-todo_write":return null;case"tool-update_interests":return null;case"tool-user_ask":{let f;e[23]!==c||e[24]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[23]=c,e[24]=t.toolCallId,e[25]=f):f=e[25];let h;return e[26]!==t||e[27]!==f?(h=p.jsx($S,{part:t,latency:f}),e[26]=t,e[27]=f,e[28]=h):h=e[28],h}case"tool-propose_plan":{let f;return e[29]!==t?(f=p.jsx(GS,{part:t}),e[29]=t,e[30]=f):f=e[30],f}case"tool-generate_image":{let f;e[31]!==c||e[32]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[31]=c,e[32]=t.toolCallId,e[33]=f):f=e[33];let h;return e[34]!==t||e[35]!==f?(h=p.jsx(wS,{part:t,latency:f}),e[34]=t,e[35]=f,e[36]=h):h=e[36],h}case"tool-take_screenshot":{let f;e[37]!==c||e[38]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[37]=c,e[38]=t.toolCallId,e[39]=f):f=e[39];let h;return e[40]!==t||e[41]!==f?(h=p.jsx(NS,{part:t,latency:f}),e[40]=t,e[41]=f,e[42]=h):h=e[42],h}case"tool-web_search":case"tool-deep_research":{let f;e[43]!==c||e[44]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[43]=c,e[44]=t.toolCallId,e[45]=f):f=e[45];let h;e[46]!==o.webSearchStreaming||e[47]!==t.toolCallId?(h=o.webSearchStreaming.get(t.toolCallId),e[46]=o.webSearchStreaming,e[47]=t.toolCallId,e[48]=h):h=e[48];let m;return e[49]!==t||e[50]!==f||e[51]!==h?(m=p.jsx(_S,{part:t,latency:f,streamingText:h}),e[49]=t,e[50]=f,e[51]=h,e[52]=m):m=e[52],m}case"tool-subtask":{let f;e[53]!==d||e[54]!==t.toolCallId?(f=d(t.toolCallId),e[53]=d,e[54]=t.toolCallId,e[55]=f):f=e[55];let h;e[56]!==c||e[57]!==t.toolCallId?(h=c(t.toolCallId)?.annotations,e[56]=c,e[57]=t.toolCallId,e[58]=h):h=e[58];let m;e[59]!==c||e[60]!==t.toolCallId?(m=c(t.toolCallId)?.latencySeconds,e[59]=c,e[60]=t.toolCallId,e[61]=m):m=e[61];let g;e[62]!==t||e[63]!==f||e[64]!==h||e[65]!==m?(g={part:t,subtaskMeta:f,annotations:h,latency:m},e[62]=t,e[63]=f,e[64]=h,e[65]=m,e[66]=g):g=e[66];const y=g;let x;return e[67]!==y?(x=p.jsx(M.Suspense,{fallback:p.jsx(KS,{...y}),children:p.jsx(JS,{...y})}),e[67]=y,e[68]=x):x=e[68],x}case"text":{const f=!!s&&!i,h=i&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(no,{id:r,part:t,extraActions:s,copyable:!0,alwaysShowActions:f,animate:h}),e[69]=r,e[70]=t,e[71]=f,e[72]=h,e[73]=s,e[74]=m):m=e[74],m}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;case"data-tool-metadata":case"data-tool-subtask-metadata":case"data-generate-image":case"data-web-search":return null;default:{const f=t;if(f.type==="tool-brand_context_setup"||f.type==="tool-BRAND_CONTEXT_EXTRACT"){let h;e[75]!==f.toolCallId||e[76]!==c?(h=c(f.toolCallId)?.latencySeconds,e[75]=f.toolCallId,e[76]=c,e[77]=h):h=e[77];let m;return e[78]!==f||e[79]!==h?(m=p.jsx(lv,{part:f,latency:h}),e[78]=f,e[79]=h,e[80]=m):m=e[80],m}if(f.type==="tool-BRAND_CONTEXT_GET"){let h;e[81]!==f.toolCallId||e[82]!==c?(h=c(f.toolCallId)?.latencySeconds,e[81]=f.toolCallId,e[82]=c,e[83]=h):h=e[83];let m;return e[84]!==f||e[85]!==h?(m=p.jsx(av,{part:f,latency:h}),e[84]=f,e[85]=h,e[86]=m):m=e[86],m}if(f.type==="tool-BRAND_CONTEXT_LIST"){let h;e[87]!==f.toolCallId||e[88]!==c?(h=c(f.toolCallId)?.latencySeconds,e[87]=f.toolCallId,e[88]=c,e[89]=h):h=e[89];let m;return e[90]!==f||e[91]!==h?(m=p.jsx(cv,{part:f,latency:h}),e[90]=f,e[91]=h,e[92]=m):m=e[92],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_CREATE"){let h;e[93]!==f.toolCallId||e[94]!==c?(h=c(f.toolCallId)?.latencySeconds,e[93]=f.toolCallId,e[94]=c,e[95]=h):h=e[95];let m;return e[96]!==f||e[97]!==h?(m=p.jsx(mv,{part:f,latency:h}),e[96]=f,e[97]=h,e[98]=m):m=e[98],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_LIST"){let h;e[99]!==f.toolCallId||e[100]!==c?(h=c(f.toolCallId)?.latencySeconds,e[99]=f.toolCallId,e[100]=c,e[101]=h):h=e[101];let m;return e[102]!==f||e[103]!==h?(m=p.jsx(bv,{part:f,latency:h}),e[102]=f,e[103]=h,e[104]=m):m=e[104],m}if(f.type==="tool-COLLECTION_CONNECTIONS_LIST"){let h;e[105]!==f.toolCallId||e[106]!==c?(h=c(f.toolCallId)?.latencySeconds,e[105]=f.toolCallId,e[106]=c,e[107]=h):h=e[107];let m;return e[108]!==f||e[109]!==h?(m=p.jsx(wv,{part:f,latency:h}),e[108]=f,e[109]=h,e[110]=m):m=e[110],m}if(f.type.startsWith("tool-")){const h=f.toolCallId;let m;e[111]!==o.toolMetadata||e[112]!==h?(m=o.toolMetadata.get(h),e[111]=o.toolMetadata,e[112]=h,e[113]=m):m=e[113];const g=m,y=g?.annotations,x=g?.latencySeconds,b=g?.outputBytes,k=g?._meta;let v;return e[114]!==f||e[115]!==l||e[116]!==y||e[117]!==x||e[118]!==b||e[119]!==k?(v=p.jsx(yc,{part:f,annotations:y,latency:x,outputBytes:b,isLastMessage:l,toolMeta:k}),e[114]=f,e[115]=l,e[116]=y,e[117]=x,e[118]=b,e[119]=k,e[120]=v):v=e[120],v}if(f.type.startsWith("data-"))return null;throw new Error(`Unknown part type: ${f.type}`)}}}function aw(n){const e=D.c(2),{isRunInProgress:t}=n;if(t){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Bs,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),p.jsx("span",{className:"text-[14px] text-muted-foreground shimmer",children:"Resuming task..."})]})}),e[0]=s):s=e[0],s}let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-[14px] text-muted-foreground/60 py-2",children:"No response was generated"}),e[1]=r):r=e[1],r}function cw(n){const e=D.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=X("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",t),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:p.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[14px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function uw(n){const e=D.c(31),{message:t,turnStartedAt:r,status:s,className:o,isLast:i}=n,l=i===void 0?!1:i,{isRunInProgress:a}=Ln()??{},c=a===void 0?!1:a,u=Ri()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Oi(r),e[0]=r,e[1]=m):m=e[1];const g=m;let y;e[2]!==h?(y=()=>h?Date.now():null,e[2]=h,e[3]=y):y=e[3];const[x,b]=M.useState(y),[k,v]=M.useState(h);k!==h&&(v(h),b(h?Date.now():null));const S=g??x,{reasoningGroups:w,renderOrder:C,dataParts:T}=Vv(t),N=t!==null&&C.length>0,E=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&E?.type==="reasoning";let L;if(e[4]!==t){const F=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,G=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;L=F!==null?G.getTime()-F.getTime():null,e[4]=t,e[5]=L}else L=e[5];const I=L;let P;e[6]!==l||e[7]!==t?(P=!l||!t||!t.parts.some(fw),e[6]=l,e[7]=t,e[8]=P):P=e[8];const R=P;let z;e[9]!==N||e[10]!==h||e[11]!==R||e[12]!==t||e[13]!==C?(z=!h&&N&&R&&(()=>{let F=0;for(const G of C)if(G.kind==="part"){const Q=t.parts[G.index]?.type;(Q==="dynamic-tool"||Q?.startsWith("tool-"))&&F++}return F>=nw})(),e[9]=N,e[10]=h,e[11]=R,e[12]=t,e[13]=C,e[14]=z):z=e[14];const B=z;let $;if(e[15]!==o||e[16]!==T||e[17]!==N||e[18]!==l||e[19]!==h||e[20]!==j||e[21]!==c||e[22]!==R||e[23]!==t||e[24]!==w||e[25]!==C||e[26]!==B||e[27]!==S||e[28]!==u||e[29]!==I){const{collapsed:F,tail:G}=B?rw(C,t.parts):{collapsed:[],tail:C};$=p.jsx(cw,{className:o,children:N?p.jsxs("div",{className:"flex flex-col gap-3 sm:gap-2",children:[t.metadata?.resumedFromBackground&&p.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground/60 select-none",children:[p.jsx(Mc,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),F.length>0&&p.jsx(iw,{items:F,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:I,dataParts:T,isLoading:h,isLast:l}),G.map((Q,Z)=>{const se=F.length+Z,Pe=G.findLastIndex(dw)===Z;return Yf({item:Q,renderIndex:se,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:I,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:Pe,renderOrder:C})}),u&&p.jsx(Bv,{threadId:u,message:t}),l&&h&&S!==null&&p.jsx(Gv,{startedAt:S}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(Ov,{}),R&&p.jsx(Nv,{})]}),!h&&p.jsx(Bf,{message:t})]}):h?p.jsx(Yv,{startedAt:S}):p.jsx(aw,{isRunInProgress:l&&c})}),e[15]=o,e[16]=T,e[17]=N,e[18]=l,e[19]=h,e[20]=j,e[21]=c,e[22]=R,e[23]=t,e[24]=w,e[25]=C,e[26]=B,e[27]=S,e[28]=u,e[29]=I,e[30]=$}else $=e[30];return $}function dw(n){return n.kind==="part"}function fw(n){const e=n.type;if(e!=="dynamic-tool"&&!e?.startsWith("tool-"))return!1;const t=n.state;return t==="input-streaming"||t==="input-available"||t==="approval-requested"}function hw(n){const e=D.c(21),{event:t}=n,[r,s]=M.useState(!1);let o;e[0]!==t.data?(o=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(pw),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(Lh,{className:"size-4 shrink-0 text-muted-foreground"}),c=p.jsx("span",{className:"font-medium",children:"Triggered by event"}),e[3]=a,e[4]=c):(a=e[3],c=e[4]);let u;e[5]!==t.type?(u=p.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t.type}),e[5]=t.type,e[6]=u):u=e[6];const d=r&&"rotate-180";let f;e[7]!==d?(f=X("ml-auto size-4 shrink-0 text-muted-foreground transition-transform",d),e[7]=d,e[8]=f):f=e[8];let h;e[9]!==f?(h=p.jsx(Ip,{className:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=p.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 px-3 py-2 text-sm cursor-pointer",children:[a,c,u,h]}),e[11]=u,e[12]=h,e[13]=m):m=e[13];let g;e[14]!==t.source||e[15]!==r||e[16]!==i?(g=r&&p.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[p.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:t.source}),p.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words text-xs text-foreground",children:i})]}),e[14]=t.source,e[15]=r,e[16]=i,e[17]=g):g=e[17];let y;return e[18]!==g||e[19]!==m?(y=p.jsxs("div",{className:"rounded-lg border border-border/60 bg-background overflow-hidden text-left",children:[m,g]}),e[18]=g,e[19]=m,e[20]=y):y=e[20],y}function pw(n){return!n}const mw=[Wk.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),rb,lb];function gw(n){const e=D.c(5),{tiptapDoc:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let s;e[1]!==t?(s={extensions:mw,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const o=Kx(s);if(!o)return null;let i;return e[3]!==o?(i=p.jsx(tf,{editor:o,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=o,e[4]=i):i=e[4],i}function yw(n){const e=D.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:o,parts:i,metadata:l}=t,[a,c]=M.useState(!1),[u,d]=M.useState(!1),f=M.useRef(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=R=>{R&&!f.current&&(f.current=!0,d(R.scrollHeight>R.clientHeight))},e[0]=h):h=e[0];const m=h;if(!i||i.length===0)return null;let g;e[1]!==s?(g=()=>{c(!0),s?.()},e[1]=s,e[2]=g):g=e[2];const y=g,x=l?.tiptapDoc;let b;e[3]!==r?(b=X("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=b):b=e[4];let k,v;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=()=>c(!0),v=()=>c(!1),e[5]=k,e[6]=v):(k=e[5],v=e[6]);let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx("div",{className:"absolute inset-0 bg-muted/75 rounded-lg pointer-events-none"}),e[7]=S):S=e[7];let w;e[8]!==a||e[9]!==u?(w=X("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":X("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=w):w=e[10];let C;if(e[11]!==o||e[12]!==i){let R;e[14]!==o?(R=(z,B)=>z.type==="data-trigger-event"?p.jsx(hw,{event:z.data},`${o}-${B}`):null,e[14]=o,e[15]=R):R=e[15],C=i.map(R),e[11]=o,e[12]=i,e[13]=C}else C=e[13];let T;e[16]!==x||e[17]!==o||e[18]!==l||e[19]!==i?(T=x?p.jsx(gw,{tiptapDoc:l.tiptapDoc}):i.map((R,z)=>R.type==="text"?i[z-1]?.type==="data-trigger-event"?null:p.jsx(no,{id:o,part:R},`${o}-${z}`):null),e[16]=x,e[17]=o,e[18]=l,e[19]=i,e[20]=T):T=e[20];let N;e[21]!==C||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[C,T]}),e[21]=C,e[22]=T,e[23]=N):N=e[23];let E;e[24]!==N||e[25]!==w?(E=p.jsx("div",{ref:m,className:w,children:N}),e[24]=N,e[25]=w,e[26]=E):E=e[26];let j;e[27]!==y||e[28]!==E?(j=p.jsxs("div",{tabIndex:0,onClick:y,onFocus:k,onBlur:v,className:"w-full border border-border/60 min-w-0 shadow-xs rounded-lg text-[14px] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[S,E]}),e[27]=y,e[28]=E,e[29]=j):j=e[29];let L;e[30]!==t?(L=p.jsx(Bf,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=L):L=e[31];let I;e[32]!==j||e[33]!==L?(I=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,L]}),e[32]=j,e[33]=L,e[34]=I):I=e[34];let P;return e[35]!==I||e[36]!==b?(P=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:I})}),e[35]=I,e[36]=b,e[37]=P):P=e[37],P}function L2(n){const e=[],t=n.filter(r=>r.role!=="system"&&!r.metadata?.internal&&!r.metadata?.subtaskJobId);for(let r=0;r<t.length;r++){const s=t[r];if(s)if(s.role==="user"){const o=t[r+1];o&&o.role==="assistant"?(e.push({user:s,assistant:o}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function _2(n){const e=D.c(19),{pair:t,isLastPair:r,status:s}=n,o=M.useRef(null),i=M.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o.current&&o.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=l):l=e[0];const a=l;let c;e[1]!==r||e[2]!==t.assistant?.metadata?.resumedFromBackground||e[3]!==s?(c=x=>{if(o.current=x,!r||!x||i.current||(i.current=!0,t.assistant?.metadata?.resumedFromBackground))return;if(s==="submitted"||s==="streaming"){x.scrollIntoView({behavior:"smooth",block:"start"});return}const b=x.closest("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:x.scrollIntoView({behavior:"instant",block:"start"})},e[1]=r,e[2]=t.assistant?.metadata?.resumedFromBackground,e[3]=s,e[4]=c):c=e[4];const u=c,d=!t.user&&"pt-8 sm:pt-6";let f;e[5]!==d?(f=X("flex flex-col pb-2 sm:pb-2",d),e[5]=d,e[6]=f):f=e[6];let h;e[7]!==t.user?(h=t.user&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"sticky top-0 z-50 w-full h-4 bg-background"}),p.jsx("div",{className:"sticky mb-8 sm:mb-6 top-4 z-50",children:p.jsx(yw,{message:t.user,onScrollToPair:a})})]}),e[7]=t.user,e[8]=h):h=e[8];const m=t.user?.created_at??null;let g;e[9]!==r||e[10]!==t.assistant||e[11]!==s||e[12]!==m?(g=p.jsx(uw,{message:t.assistant,turnStartedAt:m,status:s,isLast:r}),e[9]=r,e[10]=t.assistant,e[11]=s,e[12]=m,e[13]=g):g=e[13];let y;return e[14]!==u||e[15]!==f||e[16]!==h||e[17]!==g?(y=p.jsxs("div",{ref:u,className:f,children:[h,g]}),e[14]=u,e[15]=f,e[16]=h,e[17]=g,e[18]=y):y=e[18],y}function xw(n,e){return M.useReducer((t,r)=>e[t][r]??t,n)}var Ol="ScrollArea",[Qf]=Nc(Ol),[bw,qe]=Qf(Ol),Zf=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:o=600,...i}=n,[l,a]=M.useState(null),[c,u]=M.useState(null),[d,f]=M.useState(null),[h,m]=M.useState(null),[g,y]=M.useState(null),[x,b]=M.useState(0),[k,v]=M.useState(0),[S,w]=M.useState(!1),[C,T]=M.useState(!1),N=un(e,j=>a(j)),E=wh(s);return p.jsx(bw,{scope:t,type:r,dir:E,scrollHideDelay:o,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:w,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:C,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:v,children:p.jsx(Pt.div,{dir:E,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Zf.displayName=Ol;var eh="ScrollAreaViewport",th=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...o}=n,i=qe(eh,t),l=M.useRef(null),a=un(e,l,i.onViewportChange);return p.jsxs(p.Fragment,{children:[p.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),p.jsx(Pt.div,{"data-radix-scroll-area-viewport":"",...o,ref:a,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});th.displayName=eh;var ot="ScrollAreaScrollbar",nh=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=qe(ot,n.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,l=n.orientation==="horizontal";return M.useEffect(()=>(l?o(!0):i(!0),()=>{l?o(!1):i(!1)}),[l,o,i]),s.type==="hover"?p.jsx(kw,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(Sw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(rh,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Il,{...r,ref:e}):null});nh.displayName=ot;var kw=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=qe(ot,n.__scopeScrollArea),[o,i]=M.useState(!1);return M.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),i(!0)},u=()=>{a=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",c),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(a),l.removeEventListener("pointerenter",c),l.removeEventListener("pointerleave",u)}}},[s.scrollArea,s.scrollHideDelay]),p.jsx(br,{present:t||o,children:p.jsx(rh,{"data-state":o?"visible":"hidden",...r,ref:e})})}),Sw=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=qe(ot,n.__scopeScrollArea),o=n.orientation==="horizontal",i=ao(()=>a("SCROLL_END"),100),[l,a]=xw("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return M.useEffect(()=>{if(l==="idle"){const c=window.setTimeout(()=>a("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(c)}},[l,s.scrollHideDelay,a]),M.useEffect(()=>{const c=s.viewport,u=o?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),i()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,o,a,i]),p.jsx(br,{present:t||l!=="hidden",children:p.jsx(Il,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:Mt(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:Mt(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),rh=M.forwardRef((n,e)=>{const t=qe(ot,n.__scopeScrollArea),{forceMount:r,...s}=n,[o,i]=M.useState(!1),l=n.orientation==="horizontal",a=ao(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;i(l?c:u)}},10);return Dn(t.viewport,a),Dn(t.content,a),p.jsx(br,{present:r||o,children:p.jsx(Il,{"data-state":o?"visible":"hidden",...s,ref:e})})}),Il=M.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=qe(ot,n.__scopeScrollArea),o=M.useRef(null),i=M.useRef(0),[l,a]=M.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=ah(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function d(f,h){return Mw(f,i.current,l,h)}return t==="horizontal"?p.jsx(vw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,h=vc(f,l,s.dir);o.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=d(f,s.dir))}}):t==="vertical"?p.jsx(ww,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,h=vc(f,l);o.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=d(f))}}):null}),vw=M.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=qe(ot,n.__scopeScrollArea),[i,l]=M.useState(),a=M.useRef(null),c=un(e,a,o.onScrollbarXChange);return M.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(oh,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":lo(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),uh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),ww=M.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=qe(ot,n.__scopeScrollArea),[i,l]=M.useState(),a=M.useRef(null),c=un(e,a,o.onScrollbarYChange);return M.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(oh,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":lo(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),uh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[Cw,sh]=Qf(ot),oh=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=qe(ot,t),[m,g]=M.useState(null),y=un(e,N=>g(N)),x=M.useRef(null),b=M.useRef(""),k=h.viewport,v=r.content-r.viewport,S=Ht(u),w=Ht(a),C=ao(d,10);function T(N){if(x.current){const E=N.clientX-x.current.left,j=N.clientY-x.current.top;c({x:E,y:j})}}return M.useEffect(()=>{const N=E=>{const j=E.target;m?.contains(j)&&S(E,v)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[k,m,v,S]),M.useEffect(w,[r,w]),Dn(m,C),Dn(h.content,C),p.jsx(Cw,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:Ht(o),onThumbPointerUp:Ht(i),onThumbPositionChange:w,onThumbPointerDown:Ht(l),children:p.jsx(Pt.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Mt(n.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),x.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),T(N))}),onPointerMove:Mt(n.onPointerMove,T),onPointerUp:Mt(n.onPointerUp,N=>{const E=N.target;E.hasPointerCapture(N.pointerId)&&E.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),x.current=null})})})}),$s="ScrollAreaThumb",ih=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=sh($s,n.__scopeScrollArea);return p.jsx(br,{present:t||s.hasThumb,children:p.jsx(Tw,{ref:e,...r})})}),Tw=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,o=qe($s,t),i=sh($s,t),{onThumbPositionChange:l}=i,a=un(e,d=>i.onThumbChange(d)),c=M.useRef(void 0),u=ao(()=>{c.current&&(c.current(),c.current=void 0)},100);return M.useEffect(()=>{const d=o.viewport;if(d){const f=()=>{if(u(),!c.current){const h=Ew(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[o.viewport,u,l]),p.jsx(Pt.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Mt(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:Mt(n.onPointerUp,i.onThumbPointerUp)})});ih.displayName=$s;var Rl="ScrollAreaCorner",lh=M.forwardRef((n,e)=>{const t=qe(Rl,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(Nw,{...n,ref:e}):null});lh.displayName=Rl;var Nw=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=qe(Rl,t),[o,i]=M.useState(0),[l,a]=M.useState(0),c=!!(o&&l);return Dn(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Dn(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),i(u)}),c?p.jsx(Pt.div,{...r,ref:e,style:{width:o,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function zs(n){return n?parseInt(n,10):0}function ah(n,e){const t=n/e;return isNaN(t)?0:t}function lo(n){const e=ah(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function Mw(n,e,t,r="ltr"){const s=lo(t),o=s/2,i=e||o,l=s-i,a=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return ch([a,c],d)(n)}function vc(n,e,t="ltr"){const r=lo(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,l=o-r,a=t==="ltr"?[0,i]:[i*-1,0],c=Rp(n,a);return ch([0,i],[0,l])(c)}function ch(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function uh(n,e){return n>0&&n<e}var Ew=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const o={left:n.scrollLeft,top:n.scrollTop},i=t.left!==o.left,l=t.top!==o.top;(i||l)&&e(),t=o,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function ao(n,e){const t=Ht(n),r=M.useRef(0);return M.useEffect(()=>()=>window.clearTimeout(r.current),[]),M.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(t,e)},[t,e])}function Dn(n,e){const t=Ht(e);Tc(()=>{let r=0;if(n){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return s.observe(n),()=>{window.cancelAnimationFrame(r),s.unobserve(n)}}},[n,t])}var Aw=Zf,Ow=th,Iw=lh;function $2(n){const e=D.c(17);let t,r,s,o;e[0]!==n?({className:r,children:t,hideScrollbar:o,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=o===void 0?!1:o;let l;e[5]!==r?(l=X("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(Ow,{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-auto rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-[2px] focus-visible:ring-ring/20",children:p.jsx("div",{className:"flex min-w-0 flex-col",children:t})}),e[7]=t,e[8]=a):a=e[8];let c;e[9]!==i?(c=p.jsx(Rw,{hideScrollbar:i}),e[9]=i,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Iw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(Aw,{"data-slot":"scroll-area",className:l,...s,children:[a,c,u]}),e[12]=s,e[13]=l,e[14]=a,e[15]=c,e[16]=d):d=e[16],d}function Rw(n){const e=D.c(15);let t,r,s,o;e[0]!==n?({className:t,orientation:s,hideScrollbar:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"vertical":s,l=o===void 0?!1:o,a=i==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",u=l&&"hidden";let d;e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==u?(d=X("select-none touch-none p-px transition-colors",a,c,u,t),e[5]=t,e[6]=a,e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx(ih,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==i||e[12]!==r||e[13]!==d?(h=p.jsx(nh,{"data-slot":"scroll-area-scrollbar",orientation:i,className:d,...r,children:f}),e[11]=i,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}export{O2 as A,L2 as B,j2 as C,ne as D,tf as E,lb as F,Wv as G,$p as H,D2 as I,_2 as J,eS as K,no as M,_v as O,Vp as P,Gk as R,$2 as S,R2 as T,Lv as a,I2 as b,C2 as c,Kx as d,Xk as e,Yk as f,Di as g,Qk as h,Wk as i,cf as j,Bp as k,uf as l,E2 as m,me as n,re as o,A2 as p,Ee as q,T2 as r,Pi as s,qc as t,P2 as u,M2 as v,tb as w,ul as x,N2 as y,rb as z};
|
|
188
|
+
`);d=!i&&b.trim()?b:null,e[8]=i,e[9]=r,e[10]=d}else d=e[10];const f=d,h=!s&&t!=null?t/1e3:void 0;let m;e[11]!==s?(m=s?p.jsx(Bs,{className:"size-4"}):p.jsx(jh,{className:"size-4"}),e[11]=s,e[12]=m):m=e[12];const g=s?"Thinking...":a,y=s?"loading":"idle";let x;return e[13]!==f||e[14]!==h||e[15]!==u||e[16]!==m||e[17]!==g||e[18]!==y?(x=p.jsx(Ni,{icon:m,title:g,summary:u,detail:f,state:y,detailVariant:"prose",latency:h}),e[13]=f,e[14]=h,e[15]=u,e[16]=m,e[17]=g,e[18]=y,e[19]=x):x=e[19],x}function Zv(n){return n.text??""}function ew(n){return n.text??""}function tw(n){return n.text?.includes("REDACTED")}const nw=3;function rw(n,e){let t=-1;for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.kind==="part"&&e[s.index]?.type==="text"){t=r;break}}return t===-1?{collapsed:[],tail:n}:{collapsed:n.slice(0,t),tail:n.slice(t)}}function sw(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const o=e[s.index]?.type;o==="text"?r++:(o==="dynamic-tool"||o?.startsWith("tool-"))&&o!=="tool-todo_write"&&o!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function ow(n){const e=D.c(8),{toolCalls:t,messages:r}=n;let s;e[0]!==r||e[1]!==t?(s=t>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ic,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[t," tool call",t===1?"":"s",r>0?",":""]})]}),e[0]=r,e[1]=t,e[2]=s):s=e[2];let o;e[3]!==r?(o=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ph,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,o]}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function iw(n){const e=D.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=sw(t,r.parts),e[0]=t,e[1]=r.parts,e[2]=u):u=e[2];const{toolCalls:d,messages:f}=u;if(d===0&&f===0)return null;let h;e[3]!==f||e[4]!==d?(h=p.jsx(ow,{toolCalls:d,messages:f}),e[3]=f,e[4]=d,e[5]=h):h=e[5];let m;if(e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==i){let x;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==r||e[20]!==s||e[21]!==i?(x=(b,k)=>Yf({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=o,e[19]=r,e[20]=s,e[21]=i,e[22]=x):x=e[22],m=t.map(x),e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=t,e[11]=r,e[12]=s,e[13]=i,e[14]=m}else m=e[14];let g;e[23]!==m?(g=p.jsx("div",{className:"flex flex-col gap-3 sm:gap-2 pt-1",children:m}),e[23]=m,e[24]=g):g=e[24];let y;return e[25]!==h||e[26]!==g?(y=p.jsx(J,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=y):y=e[27],y}function Yf({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:o,dataParts:i,isLoading:l,isLast:a,isLastVisiblePart:c,renderOrder:u}){if(n.kind==="reasoning-group"){const{group:m}=n,g=m===r[r.length-1],y=s&&g;if(!m.parts.some(k=>k.text?.trim())&&!y)return null;const b=r.length===1?o:null;return p.jsx(Qv,{duration:b,parts:m.parts,isStreaming:y},`${t.id}-reasoning-${m.startIndex}`)}const d=t.parts[n.index],f=c||(u?u.findLastIndex(m=>m.kind==="part")===e:!1),h=f?Uc(Wc(),t.metadata?.usage):null;return p.jsx(lw,{part:d,id:t.id,usageStats:f&&p.jsx(Uk,{usage:h,duration:o}),dataParts:i,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function lw(n){const e=D.c(121),{part:t,id:r,usageStats:s,dataParts:o,isLoading:i,isLastMessage:l}=n;let a;e[0]!==o.toolMetadata?(a=f=>o.toolMetadata.get(f),e[0]=o.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==o.toolSubtaskMetadata?(u=f=>o.toolSubtaskMetadata.get(f),e[2]=o.toolSubtaskMetadata,e[3]=u):u=e[3];const d=u;switch(t.type){case"dynamic-tool":{let f;e[4]!==c||e[5]!==t.toolCallId?(f=c(t.toolCallId)?.annotations,e[4]=c,e[5]=t.toolCallId,e[6]=f):f=e[6];let h;e[7]!==c||e[8]!==t.toolCallId?(h=c(t.toolCallId)?.latencySeconds,e[7]=c,e[8]=t.toolCallId,e[9]=h):h=e[9];let m;e[10]!==c||e[11]!==t.toolCallId?(m=c(t.toolCallId)?.outputBytes,e[10]=c,e[11]=t.toolCallId,e[12]=m):m=e[12];let g;e[13]!==c||e[14]!==t.toolCallId?(g=c(t.toolCallId)?._meta,e[13]=c,e[14]=t.toolCallId,e[15]=g):g=e[15];let y;return e[16]!==l||e[17]!==t||e[18]!==f||e[19]!==h||e[20]!==m||e[21]!==g?(y=p.jsx(yc,{part:t,annotations:f,latency:h,outputBytes:m,isLastMessage:l,toolMeta:g}),e[16]=l,e[17]=t,e[18]=f,e[19]=h,e[20]=m,e[21]=g,e[22]=y):y=e[22],y}case"tool-todo_write":return null;case"tool-update_interests":return null;case"tool-user_ask":{let f;e[23]!==c||e[24]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[23]=c,e[24]=t.toolCallId,e[25]=f):f=e[25];let h;return e[26]!==t||e[27]!==f?(h=p.jsx($S,{part:t,latency:f}),e[26]=t,e[27]=f,e[28]=h):h=e[28],h}case"tool-propose_plan":{let f;return e[29]!==t?(f=p.jsx(GS,{part:t}),e[29]=t,e[30]=f):f=e[30],f}case"tool-generate_image":{let f;e[31]!==c||e[32]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[31]=c,e[32]=t.toolCallId,e[33]=f):f=e[33];let h;return e[34]!==t||e[35]!==f?(h=p.jsx(wS,{part:t,latency:f}),e[34]=t,e[35]=f,e[36]=h):h=e[36],h}case"tool-take_screenshot":{let f;e[37]!==c||e[38]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[37]=c,e[38]=t.toolCallId,e[39]=f):f=e[39];let h;return e[40]!==t||e[41]!==f?(h=p.jsx(NS,{part:t,latency:f}),e[40]=t,e[41]=f,e[42]=h):h=e[42],h}case"tool-web_search":case"tool-deep_research":{let f;e[43]!==c||e[44]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[43]=c,e[44]=t.toolCallId,e[45]=f):f=e[45];let h;e[46]!==o.webSearchStreaming||e[47]!==t.toolCallId?(h=o.webSearchStreaming.get(t.toolCallId),e[46]=o.webSearchStreaming,e[47]=t.toolCallId,e[48]=h):h=e[48];let m;return e[49]!==t||e[50]!==f||e[51]!==h?(m=p.jsx(_S,{part:t,latency:f,streamingText:h}),e[49]=t,e[50]=f,e[51]=h,e[52]=m):m=e[52],m}case"tool-subtask":{let f;e[53]!==d||e[54]!==t.toolCallId?(f=d(t.toolCallId),e[53]=d,e[54]=t.toolCallId,e[55]=f):f=e[55];let h;e[56]!==c||e[57]!==t.toolCallId?(h=c(t.toolCallId)?.annotations,e[56]=c,e[57]=t.toolCallId,e[58]=h):h=e[58];let m;e[59]!==c||e[60]!==t.toolCallId?(m=c(t.toolCallId)?.latencySeconds,e[59]=c,e[60]=t.toolCallId,e[61]=m):m=e[61];let g;e[62]!==t||e[63]!==f||e[64]!==h||e[65]!==m?(g={part:t,subtaskMeta:f,annotations:h,latency:m},e[62]=t,e[63]=f,e[64]=h,e[65]=m,e[66]=g):g=e[66];const y=g;let x;return e[67]!==y?(x=p.jsx(M.Suspense,{fallback:p.jsx(KS,{...y}),children:p.jsx(JS,{...y})}),e[67]=y,e[68]=x):x=e[68],x}case"text":{const f=!!s&&!i,h=i&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(no,{id:r,part:t,extraActions:s,copyable:!0,alwaysShowActions:f,animate:h}),e[69]=r,e[70]=t,e[71]=f,e[72]=h,e[73]=s,e[74]=m):m=e[74],m}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;case"data-tool-metadata":case"data-tool-subtask-metadata":case"data-generate-image":case"data-web-search":return null;default:{const f=t;if(f.type==="tool-brand_context_setup"||f.type==="tool-BRAND_CONTEXT_EXTRACT"){let h;e[75]!==f.toolCallId||e[76]!==c?(h=c(f.toolCallId)?.latencySeconds,e[75]=f.toolCallId,e[76]=c,e[77]=h):h=e[77];let m;return e[78]!==f||e[79]!==h?(m=p.jsx(lv,{part:f,latency:h}),e[78]=f,e[79]=h,e[80]=m):m=e[80],m}if(f.type==="tool-BRAND_CONTEXT_GET"){let h;e[81]!==f.toolCallId||e[82]!==c?(h=c(f.toolCallId)?.latencySeconds,e[81]=f.toolCallId,e[82]=c,e[83]=h):h=e[83];let m;return e[84]!==f||e[85]!==h?(m=p.jsx(av,{part:f,latency:h}),e[84]=f,e[85]=h,e[86]=m):m=e[86],m}if(f.type==="tool-BRAND_CONTEXT_LIST"){let h;e[87]!==f.toolCallId||e[88]!==c?(h=c(f.toolCallId)?.latencySeconds,e[87]=f.toolCallId,e[88]=c,e[89]=h):h=e[89];let m;return e[90]!==f||e[91]!==h?(m=p.jsx(cv,{part:f,latency:h}),e[90]=f,e[91]=h,e[92]=m):m=e[92],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_CREATE"){let h;e[93]!==f.toolCallId||e[94]!==c?(h=c(f.toolCallId)?.latencySeconds,e[93]=f.toolCallId,e[94]=c,e[95]=h):h=e[95];let m;return e[96]!==f||e[97]!==h?(m=p.jsx(mv,{part:f,latency:h}),e[96]=f,e[97]=h,e[98]=m):m=e[98],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_LIST"){let h;e[99]!==f.toolCallId||e[100]!==c?(h=c(f.toolCallId)?.latencySeconds,e[99]=f.toolCallId,e[100]=c,e[101]=h):h=e[101];let m;return e[102]!==f||e[103]!==h?(m=p.jsx(bv,{part:f,latency:h}),e[102]=f,e[103]=h,e[104]=m):m=e[104],m}if(f.type==="tool-COLLECTION_CONNECTIONS_LIST"){let h;e[105]!==f.toolCallId||e[106]!==c?(h=c(f.toolCallId)?.latencySeconds,e[105]=f.toolCallId,e[106]=c,e[107]=h):h=e[107];let m;return e[108]!==f||e[109]!==h?(m=p.jsx(wv,{part:f,latency:h}),e[108]=f,e[109]=h,e[110]=m):m=e[110],m}if(f.type.startsWith("tool-")){const h=f.toolCallId;let m;e[111]!==o.toolMetadata||e[112]!==h?(m=o.toolMetadata.get(h),e[111]=o.toolMetadata,e[112]=h,e[113]=m):m=e[113];const g=m,y=g?.annotations,x=g?.latencySeconds,b=g?.outputBytes,k=g?._meta;let v;return e[114]!==f||e[115]!==l||e[116]!==y||e[117]!==x||e[118]!==b||e[119]!==k?(v=p.jsx(yc,{part:f,annotations:y,latency:x,outputBytes:b,isLastMessage:l,toolMeta:k}),e[114]=f,e[115]=l,e[116]=y,e[117]=x,e[118]=b,e[119]=k,e[120]=v):v=e[120],v}if(f.type.startsWith("data-"))return null;throw new Error(`Unknown part type: ${f.type}`)}}}function aw(n){const e=D.c(2),{isRunInProgress:t}=n;if(t){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Bs,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),p.jsx("span",{className:"text-[14px] text-muted-foreground shimmer",children:"Resuming task..."})]})}),e[0]=s):s=e[0],s}let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-[14px] text-muted-foreground/60 py-2",children:"No response was generated"}),e[1]=r):r=e[1],r}function cw(n){const e=D.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=X("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",t),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:p.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[14px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function uw(n){const e=D.c(31),{message:t,turnStartedAt:r,status:s,className:o,isLast:i}=n,l=i===void 0?!1:i,{isRunInProgress:a}=Ln()??{},c=a===void 0?!1:a,u=Ri()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Oi(r),e[0]=r,e[1]=m):m=e[1];const g=m;let y;e[2]!==h?(y=()=>h?Date.now():null,e[2]=h,e[3]=y):y=e[3];const[x,b]=M.useState(y),[k,v]=M.useState(h);k!==h&&(v(h),b(h?Date.now():null));const S=g??x,{reasoningGroups:w,renderOrder:C,dataParts:T}=Vv(t),N=t!==null&&C.length>0,E=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&E?.type==="reasoning";let L;if(e[4]!==t){const F=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,G=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;L=F!==null?G.getTime()-F.getTime():null,e[4]=t,e[5]=L}else L=e[5];const I=L;let P;e[6]!==l||e[7]!==t?(P=!l||!t||!t.parts.some(fw),e[6]=l,e[7]=t,e[8]=P):P=e[8];const R=P;let z;e[9]!==N||e[10]!==h||e[11]!==R||e[12]!==t||e[13]!==C?(z=!h&&N&&R&&(()=>{let F=0;for(const G of C)if(G.kind==="part"){const Q=t.parts[G.index]?.type;(Q==="dynamic-tool"||Q?.startsWith("tool-"))&&F++}return F>=nw})(),e[9]=N,e[10]=h,e[11]=R,e[12]=t,e[13]=C,e[14]=z):z=e[14];const B=z;let $;if(e[15]!==o||e[16]!==T||e[17]!==N||e[18]!==l||e[19]!==h||e[20]!==j||e[21]!==c||e[22]!==R||e[23]!==t||e[24]!==w||e[25]!==C||e[26]!==B||e[27]!==S||e[28]!==u||e[29]!==I){const{collapsed:F,tail:G}=B?rw(C,t.parts):{collapsed:[],tail:C};$=p.jsx(cw,{className:o,children:N?p.jsxs("div",{className:"flex flex-col gap-3 sm:gap-2",children:[t.metadata?.resumedFromBackground&&p.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground/60 select-none",children:[p.jsx(Mc,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),F.length>0&&p.jsx(iw,{items:F,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:I,dataParts:T,isLoading:h,isLast:l}),G.map((Q,Z)=>{const se=F.length+Z,Pe=G.findLastIndex(dw)===Z;return Yf({item:Q,renderIndex:se,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:I,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:Pe,renderOrder:C})}),u&&p.jsx(Bv,{threadId:u,message:t}),l&&h&&S!==null&&p.jsx(Gv,{startedAt:S}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(Ov,{}),R&&p.jsx(Nv,{})]}),!h&&p.jsx(Bf,{message:t})]}):h?p.jsx(Yv,{startedAt:S}):p.jsx(aw,{isRunInProgress:l&&c})}),e[15]=o,e[16]=T,e[17]=N,e[18]=l,e[19]=h,e[20]=j,e[21]=c,e[22]=R,e[23]=t,e[24]=w,e[25]=C,e[26]=B,e[27]=S,e[28]=u,e[29]=I,e[30]=$}else $=e[30];return $}function dw(n){return n.kind==="part"}function fw(n){const e=n.type;if(e!=="dynamic-tool"&&!e?.startsWith("tool-"))return!1;const t=n.state;return t==="input-streaming"||t==="input-available"||t==="approval-requested"}function hw(n){const e=D.c(21),{event:t}=n,[r,s]=M.useState(!1);let o;e[0]!==t.data?(o=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(pw),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(Lh,{className:"size-4 shrink-0 text-muted-foreground"}),c=p.jsx("span",{className:"font-medium",children:"Triggered by event"}),e[3]=a,e[4]=c):(a=e[3],c=e[4]);let u;e[5]!==t.type?(u=p.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t.type}),e[5]=t.type,e[6]=u):u=e[6];const d=r&&"rotate-180";let f;e[7]!==d?(f=X("ml-auto size-4 shrink-0 text-muted-foreground transition-transform",d),e[7]=d,e[8]=f):f=e[8];let h;e[9]!==f?(h=p.jsx(Ip,{className:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=p.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 px-3 py-2 text-sm cursor-pointer",children:[a,c,u,h]}),e[11]=u,e[12]=h,e[13]=m):m=e[13];let g;e[14]!==t.source||e[15]!==r||e[16]!==i?(g=r&&p.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[p.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:t.source}),p.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words text-xs text-foreground",children:i})]}),e[14]=t.source,e[15]=r,e[16]=i,e[17]=g):g=e[17];let y;return e[18]!==g||e[19]!==m?(y=p.jsxs("div",{className:"rounded-lg border border-border/60 bg-background overflow-hidden text-left",children:[m,g]}),e[18]=g,e[19]=m,e[20]=y):y=e[20],y}function pw(n){return!n}const mw=[Wk.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),rb,lb];function gw(n){const e=D.c(5),{tiptapDoc:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let s;e[1]!==t?(s={extensions:mw,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const o=Kx(s);if(!o)return null;let i;return e[3]!==o?(i=p.jsx(tf,{editor:o,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=o,e[4]=i):i=e[4],i}function yw(n){const e=D.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:o,parts:i,metadata:l}=t,[a,c]=M.useState(!1),[u,d]=M.useState(!1),f=M.useRef(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=R=>{R&&!f.current&&(f.current=!0,d(R.scrollHeight>R.clientHeight))},e[0]=h):h=e[0];const m=h;if(!i||i.length===0)return null;let g;e[1]!==s?(g=()=>{c(!0),s?.()},e[1]=s,e[2]=g):g=e[2];const y=g,x=l?.tiptapDoc;let b;e[3]!==r?(b=X("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=b):b=e[4];let k,v;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=()=>c(!0),v=()=>c(!1),e[5]=k,e[6]=v):(k=e[5],v=e[6]);let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx("div",{className:"absolute inset-0 bg-muted/75 rounded-lg pointer-events-none"}),e[7]=S):S=e[7];let w;e[8]!==a||e[9]!==u?(w=X("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":X("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=w):w=e[10];let C;if(e[11]!==o||e[12]!==i){let R;e[14]!==o?(R=(z,B)=>z.type==="data-trigger-event"?p.jsx(hw,{event:z.data},`${o}-${B}`):null,e[14]=o,e[15]=R):R=e[15],C=i.map(R),e[11]=o,e[12]=i,e[13]=C}else C=e[13];let T;e[16]!==x||e[17]!==o||e[18]!==l||e[19]!==i?(T=x?p.jsx(gw,{tiptapDoc:l.tiptapDoc}):i.map((R,z)=>R.type==="text"?i[z-1]?.type==="data-trigger-event"?null:p.jsx(no,{id:o,part:R},`${o}-${z}`):null),e[16]=x,e[17]=o,e[18]=l,e[19]=i,e[20]=T):T=e[20];let N;e[21]!==C||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[C,T]}),e[21]=C,e[22]=T,e[23]=N):N=e[23];let E;e[24]!==N||e[25]!==w?(E=p.jsx("div",{ref:m,className:w,children:N}),e[24]=N,e[25]=w,e[26]=E):E=e[26];let j;e[27]!==y||e[28]!==E?(j=p.jsxs("div",{tabIndex:0,onClick:y,onFocus:k,onBlur:v,className:"w-full border border-border/60 min-w-0 shadow-xs rounded-lg text-[14px] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[S,E]}),e[27]=y,e[28]=E,e[29]=j):j=e[29];let L;e[30]!==t?(L=p.jsx(Bf,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=L):L=e[31];let I;e[32]!==j||e[33]!==L?(I=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,L]}),e[32]=j,e[33]=L,e[34]=I):I=e[34];let P;return e[35]!==I||e[36]!==b?(P=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:I})}),e[35]=I,e[36]=b,e[37]=P):P=e[37],P}function z2(n){const e=[],t=n.filter(r=>r.role!=="system"&&!r.metadata?.internal&&!r.metadata?.subtaskJobId);for(let r=0;r<t.length;r++){const s=t[r];if(s)if(s.role==="user"){const o=t[r+1];o&&o.role==="assistant"?(e.push({user:s,assistant:o}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function B2(n){const e=D.c(19),{pair:t,isLastPair:r,status:s}=n,o=M.useRef(null),i=M.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o.current&&o.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=l):l=e[0];const a=l;let c;e[1]!==r||e[2]!==t.assistant?.metadata?.resumedFromBackground||e[3]!==s?(c=x=>{if(o.current=x,!r||!x||i.current||(i.current=!0,t.assistant?.metadata?.resumedFromBackground))return;if(s==="submitted"||s==="streaming"){x.scrollIntoView({behavior:"smooth",block:"start"});return}const b=x.closest("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:x.scrollIntoView({behavior:"instant",block:"start"})},e[1]=r,e[2]=t.assistant?.metadata?.resumedFromBackground,e[3]=s,e[4]=c):c=e[4];const u=c,d=!t.user&&"pt-8 sm:pt-6";let f;e[5]!==d?(f=X("flex flex-col pb-2 sm:pb-2",d),e[5]=d,e[6]=f):f=e[6];let h;e[7]!==t.user?(h=t.user&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"sticky top-0 z-50 w-full h-4 bg-background"}),p.jsx("div",{className:"sticky mb-8 sm:mb-6 top-4 z-50",children:p.jsx(yw,{message:t.user,onScrollToPair:a})})]}),e[7]=t.user,e[8]=h):h=e[8];const m=t.user?.created_at??null;let g;e[9]!==r||e[10]!==t.assistant||e[11]!==s||e[12]!==m?(g=p.jsx(uw,{message:t.assistant,turnStartedAt:m,status:s,isLast:r}),e[9]=r,e[10]=t.assistant,e[11]=s,e[12]=m,e[13]=g):g=e[13];let y;return e[14]!==u||e[15]!==f||e[16]!==h||e[17]!==g?(y=p.jsxs("div",{ref:u,className:f,children:[h,g]}),e[14]=u,e[15]=f,e[16]=h,e[17]=g,e[18]=y):y=e[18],y}function xw(n,e){return M.useReducer((t,r)=>e[t][r]??t,n)}var Ol="ScrollArea",[Qf]=Nc(Ol),[bw,qe]=Qf(Ol),Zf=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:o=600,...i}=n,[l,a]=M.useState(null),[c,u]=M.useState(null),[d,f]=M.useState(null),[h,m]=M.useState(null),[g,y]=M.useState(null),[x,b]=M.useState(0),[k,v]=M.useState(0),[S,w]=M.useState(!1),[C,T]=M.useState(!1),N=un(e,j=>a(j)),E=wh(s);return p.jsx(bw,{scope:t,type:r,dir:E,scrollHideDelay:o,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:w,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:C,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:v,children:p.jsx(Pt.div,{dir:E,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Zf.displayName=Ol;var eh="ScrollAreaViewport",th=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...o}=n,i=qe(eh,t),l=M.useRef(null),a=un(e,l,i.onViewportChange);return p.jsxs(p.Fragment,{children:[p.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),p.jsx(Pt.div,{"data-radix-scroll-area-viewport":"",...o,ref:a,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});th.displayName=eh;var ot="ScrollAreaScrollbar",nh=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=qe(ot,n.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,l=n.orientation==="horizontal";return M.useEffect(()=>(l?o(!0):i(!0),()=>{l?o(!1):i(!1)}),[l,o,i]),s.type==="hover"?p.jsx(kw,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(Sw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(rh,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Il,{...r,ref:e}):null});nh.displayName=ot;var kw=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=qe(ot,n.__scopeScrollArea),[o,i]=M.useState(!1);return M.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),i(!0)},u=()=>{a=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",c),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(a),l.removeEventListener("pointerenter",c),l.removeEventListener("pointerleave",u)}}},[s.scrollArea,s.scrollHideDelay]),p.jsx(br,{present:t||o,children:p.jsx(rh,{"data-state":o?"visible":"hidden",...r,ref:e})})}),Sw=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=qe(ot,n.__scopeScrollArea),o=n.orientation==="horizontal",i=ao(()=>a("SCROLL_END"),100),[l,a]=xw("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return M.useEffect(()=>{if(l==="idle"){const c=window.setTimeout(()=>a("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(c)}},[l,s.scrollHideDelay,a]),M.useEffect(()=>{const c=s.viewport,u=o?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),i()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,o,a,i]),p.jsx(br,{present:t||l!=="hidden",children:p.jsx(Il,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:Mt(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:Mt(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),rh=M.forwardRef((n,e)=>{const t=qe(ot,n.__scopeScrollArea),{forceMount:r,...s}=n,[o,i]=M.useState(!1),l=n.orientation==="horizontal",a=ao(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;i(l?c:u)}},10);return Dn(t.viewport,a),Dn(t.content,a),p.jsx(br,{present:r||o,children:p.jsx(Il,{"data-state":o?"visible":"hidden",...s,ref:e})})}),Il=M.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=qe(ot,n.__scopeScrollArea),o=M.useRef(null),i=M.useRef(0),[l,a]=M.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=ah(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function d(f,h){return Mw(f,i.current,l,h)}return t==="horizontal"?p.jsx(vw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,h=vc(f,l,s.dir);o.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=d(f,s.dir))}}):t==="vertical"?p.jsx(ww,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,h=vc(f,l);o.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=d(f))}}):null}),vw=M.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=qe(ot,n.__scopeScrollArea),[i,l]=M.useState(),a=M.useRef(null),c=un(e,a,o.onScrollbarXChange);return M.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(oh,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":lo(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),uh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),ww=M.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=qe(ot,n.__scopeScrollArea),[i,l]=M.useState(),a=M.useRef(null),c=un(e,a,o.onScrollbarYChange);return M.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(oh,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":lo(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),uh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[Cw,sh]=Qf(ot),oh=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=qe(ot,t),[m,g]=M.useState(null),y=un(e,N=>g(N)),x=M.useRef(null),b=M.useRef(""),k=h.viewport,v=r.content-r.viewport,S=Ht(u),w=Ht(a),C=ao(d,10);function T(N){if(x.current){const E=N.clientX-x.current.left,j=N.clientY-x.current.top;c({x:E,y:j})}}return M.useEffect(()=>{const N=E=>{const j=E.target;m?.contains(j)&&S(E,v)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[k,m,v,S]),M.useEffect(w,[r,w]),Dn(m,C),Dn(h.content,C),p.jsx(Cw,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:Ht(o),onThumbPointerUp:Ht(i),onThumbPositionChange:w,onThumbPointerDown:Ht(l),children:p.jsx(Pt.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Mt(n.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),x.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),T(N))}),onPointerMove:Mt(n.onPointerMove,T),onPointerUp:Mt(n.onPointerUp,N=>{const E=N.target;E.hasPointerCapture(N.pointerId)&&E.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),x.current=null})})})}),$s="ScrollAreaThumb",ih=M.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=sh($s,n.__scopeScrollArea);return p.jsx(br,{present:t||s.hasThumb,children:p.jsx(Tw,{ref:e,...r})})}),Tw=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,o=qe($s,t),i=sh($s,t),{onThumbPositionChange:l}=i,a=un(e,d=>i.onThumbChange(d)),c=M.useRef(void 0),u=ao(()=>{c.current&&(c.current(),c.current=void 0)},100);return M.useEffect(()=>{const d=o.viewport;if(d){const f=()=>{if(u(),!c.current){const h=Ew(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[o.viewport,u,l]),p.jsx(Pt.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Mt(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:Mt(n.onPointerUp,i.onThumbPointerUp)})});ih.displayName=$s;var Rl="ScrollAreaCorner",lh=M.forwardRef((n,e)=>{const t=qe(Rl,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(Nw,{...n,ref:e}):null});lh.displayName=Rl;var Nw=M.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=qe(Rl,t),[o,i]=M.useState(0),[l,a]=M.useState(0),c=!!(o&&l);return Dn(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Dn(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),i(u)}),c?p.jsx(Pt.div,{...r,ref:e,style:{width:o,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function zs(n){return n?parseInt(n,10):0}function ah(n,e){const t=n/e;return isNaN(t)?0:t}function lo(n){const e=ah(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function Mw(n,e,t,r="ltr"){const s=lo(t),o=s/2,i=e||o,l=s-i,a=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return ch([a,c],d)(n)}function vc(n,e,t="ltr"){const r=lo(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,l=o-r,a=t==="ltr"?[0,i]:[i*-1,0],c=Rp(n,a);return ch([0,i],[0,l])(c)}function ch(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function uh(n,e){return n>0&&n<e}var Ew=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const o={left:n.scrollLeft,top:n.scrollTop},i=t.left!==o.left,l=t.top!==o.top;(i||l)&&e(),t=o,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function ao(n,e){const t=Ht(n),r=M.useRef(0);return M.useEffect(()=>()=>window.clearTimeout(r.current),[]),M.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(t,e)},[t,e])}function Dn(n,e){const t=Ht(e);Tc(()=>{let r=0;if(n){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return s.observe(n),()=>{window.cancelAnimationFrame(r),s.unobserve(n)}}},[n,t])}var Aw=Zf,Ow=th,Iw=lh;function F2(n){const e=D.c(17);let t,r,s,o;e[0]!==n?({className:r,children:t,hideScrollbar:o,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=o===void 0?!1:o;let l;e[5]!==r?(l=X("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(Ow,{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-auto rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-[2px] focus-visible:ring-ring/20",children:p.jsx("div",{className:"flex min-w-0 flex-col",children:t})}),e[7]=t,e[8]=a):a=e[8];let c;e[9]!==i?(c=p.jsx(Rw,{hideScrollbar:i}),e[9]=i,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Iw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(Aw,{"data-slot":"scroll-area",className:l,...s,children:[a,c,u]}),e[12]=s,e[13]=l,e[14]=a,e[15]=c,e[16]=d):d=e[16],d}function Rw(n){const e=D.c(15);let t,r,s,o;e[0]!==n?({className:t,orientation:s,hideScrollbar:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"vertical":s,l=o===void 0?!1:o,a=i==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",u=l&&"hidden";let d;e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==u?(d=X("select-none touch-none p-px transition-colors",a,c,u,t),e[5]=t,e[6]=a,e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx(ih,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==i||e[12]!==r||e[13]!==d?(h=p.jsx(nh,{"data-slot":"scroll-area-scrollbar",orientation:i,className:d,...r,children:f}),e[11]=i,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}export{j2 as A,z2 as B,L2 as C,ne as D,tf as E,lb as F,Wv as G,$p as H,_2 as I,B2 as J,eS as K,no as M,_v as O,Vp as P,Gk as R,F2 as S,P2 as T,Lv as a,D2 as b,M2 as c,Kx as d,Xk as e,Yk as f,Di as g,Qk as h,Wk as i,cf as j,Bp as k,uf as l,I2 as m,me as n,re as o,R2 as p,Ee as q,E2 as r,Pi as s,qc as t,$2 as u,O2 as v,tb as w,ul as x,A2 as y,rb as z};
|