@inkeep/open-knowledge 0.49.0-beta.7 → 0.49.0-beta.9
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/{acp-harness-probe-Pn0DeKiI.mjs → acp-harness-probe-DAvWLUO9.mjs} +2 -2
- package/dist/cli.mjs +50 -50
- package/dist/constants-Cs9yCGJ3.mjs +2 -0
- package/dist/{git-handle-DyGrpFVy.mjs → git-handle-CwKFBC31.mjs} +2 -2
- package/dist/git-handle-D2Z8RT5q.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/init-D97DTFnt.mjs +1 -0
- package/dist/{init-DdZA5rJi.mjs → init-DH-Px80S.mjs} +17 -17
- package/dist/{launch-json-removal-D7Iq84o3.mjs → launch-json-removal-D4FPrVjU.mjs} +2 -2
- package/dist/loader-CRMCRkRI.mjs +1 -0
- package/dist/{loader-DuHXT8ol.mjs → loader-ON7dLR96.mjs} +2 -2
- package/dist/md-manager-CApQ8lSb.mjs +2 -0
- package/dist/{open-browser-svTSfejY.mjs → open-browser-Dndi6WWX.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-B5fyX2N1.mjs +1 -0
- package/dist/{preview-CuHto4vn.mjs → preview-Ds5aM2R7.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-BNAxhpQj.js → ActivityModeContent-DlqRan97.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-D7Khwouf.js → AgentDiffPane-C_8fbRzc.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-daoer6rt.js → AgentThreadClientBinder-CAwKHBFH.js} +1 -1
- package/dist/public/assets/{ChangedOutsideBadge-CazpgqWA.js → ChangedOutsideBadge-EtTRyMst.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-Cc1LhUu6.js +3 -0
- package/dist/public/assets/DocumentContext-C21t23gR.js +38 -0
- package/dist/public/assets/{EditorModeToggle-BbMlOgkn.js → EditorModeToggle-C7CehDgV.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-CQetlwTb.js → EnableSyncConfirmDialog-DB9uLD_C.js} +1 -1
- package/dist/public/assets/FeedbackForm-Bxl-ARCE.js +1 -0
- package/dist/public/assets/{GraphPanel-BlKaOmvl.js → GraphPanel-CIK3uXtb.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BgrlE-MX.js → ImportSkillDialog-C0lAvukp.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-Cno_iGzp.js → LintConfigEditor-D-o_OWhj.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-2uKbG7zi.js +2 -0
- package/dist/public/assets/ManagedArtifactProperties-BUlDlZD7.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-NLB2A56E.js → McpConsentDialogBody-COj_KwlR.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-_Gx5VJXW.js → MermaidDocEditor-CiaKVZ6r.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-C9wKJMEr.js → ReportBugDialogBody-DexAqkb2.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-KkMUeDV5.js → SchemaConfigEditor-BM14WhF5.js} +1 -1
- package/dist/public/assets/{SessionsHost-CH5jffAG.js → SessionsHost-BMspzxaf.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody--nklwAG-.js → SettingsDialogBody-BwZ4EbH9.js} +4 -4
- package/dist/public/assets/{ShareBranchSwitchDialog-DWmVoqtB.js → ShareBranchSwitchDialog-BbDROBIa.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-Deigdttj.js → ShareReceiveDialog-CfU4m-WF.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-Bw2-qhvJ.js → ShareReceiveMissDialog-s_ig9ymF.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-B31-HMnN.js → SkillEditBanner-zxtA22QV.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-OqQA2gy_.js → SkillOriginInline-CHnC6xUF.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-U1QWzi0I.js → SkillToolbarControls-DlqLImDa.js} +1 -1
- package/dist/public/assets/{SourceEditor-DtuqTQRl.js → SourceEditor-C_2k6Civ.js} +1 -1
- package/dist/public/assets/{TerminalPanel-BElaeDzL.js → TerminalPanel-FZwnOTrU.js} +2 -2
- package/dist/public/assets/{TerminalWindowApp-C-uBdtmk.js → TerminalWindowApp-C8u0Fpbd.js} +1 -1
- package/dist/public/assets/{TextDocEditor-hb2f-OfN.js → TextDocEditor-CRK7lnOq.js} +1 -1
- package/dist/public/assets/{ThreadView-CQqlZmdN.js → ThreadView-CQyd4n73.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-BLLl6THu.js → TimelineDiffPane-CcgJFm6X.js} +1 -1
- package/dist/public/assets/{agent-diff-store-CLtKPNmI.js → agent-diff-store-B6KZTOv6.js} +1 -1
- package/dist/public/assets/{agent-visibility-Dz506quD.js → agent-visibility-DTb0lCVi.js} +1 -1
- package/dist/public/assets/auth-state-cache-BMNySofF.js +11 -0
- package/dist/public/assets/client-version-D7DMknC6.js +1 -0
- package/dist/public/assets/comment-chips-B9bT1JUw.js +5 -0
- package/dist/public/assets/{config-context-DyUEqnhn.js → config-context-CmQUJBcL.js} +1 -1
- package/dist/public/assets/{config-provider-NjnhDMPo.js → config-provider-xRIhjgw3.js} +2 -2
- package/dist/public/assets/{dist-DOPRKSzO2.js → dist-CW-WKphO2.js} +180 -179
- package/dist/public/assets/{doc-paths-Dr8av3tc.js → doc-paths-9WcZxMIM.js} +1 -1
- package/dist/public/assets/{documents-events-Cd-1x5Ed.js → documents-events-Dq_N3aGS.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-DbXLXHhN.js → file-tree-adapter-NUvHutlM.js} +1 -1
- package/dist/public/assets/{file-tree-utils-DfeUmuaf.js → file-tree-utils-Bifzlv6n.js} +1 -1
- package/dist/public/assets/{folder-config-api-C3YTmDwB.js → folder-config-api-M7RkoKuk.js} +1 -1
- package/dist/public/assets/{follow-file-Bi4vCCLt.js → follow-file-CRicwLk4.js} +1 -1
- package/dist/public/assets/{globals-DyXnUQBm.js → globals-BdT8IUNf.js} +1 -1
- package/dist/public/assets/{index-BuHmkuwS.js → index-BHlkZE7z.js} +14 -15
- package/dist/public/assets/{lint-config-client-CeUWUhyK.js → lint-config-client-DdmzNw30.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-DfPiRgim.js → markdownlint-rule-browser-DVOGLsiR.js} +1 -1
- package/dist/public/assets/navigation-targets-DdhmqoI-.js +1 -0
- package/dist/public/assets/{open-managed-artifact-tab-DN3NM6Ff.js → open-managed-artifact-tab-Dt-nEURF.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-B4JTMHp-.js → pending-receive-nav-store-B0J2CSDv.js} +1 -1
- package/dist/public/assets/{prop-types-BC9HEC35.js → prop-types-CVvMIZSF.js} +1 -1
- package/dist/public/assets/{receive-store-BCddK7iB.js → receive-store-2bhS8vt2.js} +1 -1
- package/dist/public/assets/{selection-context-CHSH5Ljn.js → selection-context-7jZla8LT.js} +1 -1
- package/dist/public/assets/{skill-actions-qtoCUe9u.js → skill-actions-l08GRiO6.js} +2 -2
- package/dist/public/assets/{skill-scope-CEtnfeg4.js → skill-scope-CBI04cxU.js} +1 -1
- package/dist/public/assets/{skills-api-Bt6QqZxu.js → skills-api-jQmbZiBx.js} +1 -1
- package/dist/public/assets/{src-BtmmehSp.js → src-Ab-J5Fjb.js} +1 -1
- package/dist/public/assets/{tag-pill-input-DFIdRT0e.js → tag-pill-input-DGyTCP4J.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-2M1YK6Wd.js → target-navigation-intent-CFlZwKM6.js} +1 -1
- package/dist/public/assets/{telemetry-impl-V8ZB0k7Y.js → telemetry-impl-DeQzH0Qy.js} +1 -1
- package/dist/public/assets/{telemetry-startup-Dww4VvEI.js → telemetry-startup-CF9C031W.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-C2Gz2G0L.js → terminal-launch-events-D6T-0OQp.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-CS_Zz_F-.js → terminal-telemetry-DIHFpeby.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DKVkQeXL.js → typing-burst-detector-o8zxjyyw.js} +3 -3
- package/dist/public/assets/{uninstall-iZnahGQ3.js → uninstall-DFBJKlqL.js} +1 -1
- package/dist/public/assets/{use-activity-panel-B0DFdV4C.js → use-activity-panel-CRG7InWx.js} +1 -1
- package/dist/public/assets/{use-collab-url-CMgoqd7H.js → use-collab-url-D2bQBB0t.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-KGb9fc_e.js → use-live-xterm-theme-CqKt6OLh.js} +1 -1
- package/dist/public/assets/{use-open-skill-DhpKvkHk.js → use-open-skill-CDmkCs_J.js} +1 -1
- package/dist/public/assets/{use-settings-route-ClTq87t7.js → use-settings-route-DBrH-P64.js} +1 -1
- package/dist/public/assets/{use-skill-directory-CLM2VHZh.js → use-skill-directory-DSeLowCq.js} +1 -1
- package/dist/public/assets/{use-skill-origin-DxVRIW_T.js → use-skill-origin-CdIbGanW.js} +1 -1
- package/dist/public/assets/{use-skills-CDcSIIym.js → use-skills-w-wrmauP.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DTsNSKJU.js → use-terminal-enabled-DvxUowUp.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-Cj4GIfcv.js → use-timeline-entry-diff-DQLimR9f.js} +4 -4
- package/dist/public/assets/{use-workspace-BNdbTGXU.js → use-workspace-C4drLo4u.js} +1 -1
- package/dist/public/index.html +44 -44
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-BDo065NP.mjs → repair-launch-json-qTKC25he.mjs} +2 -2
- package/dist/{repair-mcp-configs-BPJjzOY5.mjs → repair-mcp-configs-Ck9JhU-6.mjs} +2 -2
- package/dist/{repair-skills-QLgUXS7O.mjs → repair-skills-Dnr2Baut.mjs} +2 -2
- package/dist/repair-skills-e-0cKdGP.mjs +1 -0
- package/dist/server-lock-D_8go_hh.mjs +1 -0
- package/dist/{server-lock-DsDrc4RU.mjs → server-lock-GZh5XRQk.mjs} +2 -2
- package/dist/{skill-teardown-Cj1-Y6iS.mjs → skill-teardown-kmCtX6GY.mjs} +2 -2
- package/dist/src-BXetmbJ1.mjs +1 -0
- package/dist/{src-DOweCDXI.mjs → src-DLDOch6T.mjs} +7 -7
- package/dist/src-DUBkXvUa.mjs +2030 -0
- package/dist/{src-azBs1EPY.mjs → src-crfhwdu0.mjs} +126 -126
- package/dist/{start-Den_dWJK.mjs → start-AaOkShov.mjs} +3 -3
- package/dist/start-CSBiE0HL.mjs +1 -0
- package/dist/{write-project-skill-B77kdJNQ.mjs → write-project-skill-CbLmhWjs.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-D_NfRaX-.mjs +0 -2
- package/dist/git-handle-CtdWfsLv.mjs +0 -1
- package/dist/init-CeWy02sl.mjs +0 -1
- package/dist/loader-C4jmdmMw.mjs +0 -1
- package/dist/md-manager-C54e9m9K.mjs +0 -2
- package/dist/preview-Cs51czhG.mjs +0 -1
- package/dist/public/assets/CodeMirrorPropInput-B98kUaCj.js +0 -3
- package/dist/public/assets/DocumentContext-BeNSZPYG.js +0 -38
- package/dist/public/assets/FeedbackForm-09ORT6ec.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CM6O_XVV.js +0 -2
- package/dist/public/assets/ManagedArtifactProperties-DUFF_4AB.js +0 -1
- package/dist/public/assets/auth-state-cache-epurX430.js +0 -11
- package/dist/public/assets/client-version-C9zQ1Cba.js +0 -1
- package/dist/public/assets/comment-chips-Da14zLsr.js +0 -7
- package/dist/public/assets/navigation-targets-DxC4QM5f.js +0 -1
- package/dist/repair-skills-DHPneNpJ.mjs +0 -1
- package/dist/server-lock-BoNixvAi.mjs +0 -1
- package/dist/src-DIjYfcIb.mjs +0 -1
- package/dist/src-DoSxfvJP.mjs +0 -2030
- package/dist/start-CPvhLYfX.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./button-RQ5o7P7w.js";import{a as ee,c as te,i as ne,n as re,o as ie,s as ae,t as oe}from"./dialog-DwFomKjP.js";import{n as se,t as s}from"./git-branch-B0WeYwW-.js";import{t as c}from"./loader-circle-B0OUuKph.js";import{n as ce,t as le}from"./miss-dialog-store-B3cHkf8G.js";import{n as l}from"./dist-DmEZHXvB.js";import{t as u}from"./desktop-bridge-types-BwR5S9HF.js";import{r as d,t as f}from"./auth-prompt-store-DQ_HcDxh.js";import{a as p,n as m}from"./receive-store-BCddK7iB.js";import{t as ue}from"./share-metadata-rows-B1YjvGbL.js";var h=e(n(),1),de=a();function fe(e){let t=e.shareTargetExists,n=e.dirtyConflicts.conflicts,r=e.dirtyConflicts.files;return t&&!n?{kind:`A`,openCurrentEnabled:!0,switchEnabled:!0,conflictingFiles:r}:!t&&!n?{kind:`B`,openCurrentEnabled:!1,switchEnabled:!0,conflictingFiles:r}:t&&n?{kind:`C`,openCurrentEnabled:!0,switchEnabled:!1,conflictingFiles:r}:{kind:`D`,openCurrentEnabled:!1,switchEnabled:!1,conflictingFiles:r}}function pe(e){return e.detached?e.currentHeadSha:e.currentBranch??`HEAD`}function g(e){if(e.ok)return{action:`await-cc1`};switch(e.reason){case`dirty-conflict`:return{action:`rerender-conflict`,files:e.files??[]};case`branch-not-found`:return{action:`dismiss-with-toast`,reason:`branch-not-found`};case`fetch-failed`:case`checkout-failed`:return{action:`stay-with-toast`,reason:e.reason};case`branch-in-other-worktree`:{let t=e.otherWorktreePath;return t===void 0||t.length===0?{action:`stay-with-toast`,reason:`checkout-failed`}:{action:`pivot-to-other-worktree`,otherWorktreePath:t}}case`ff-diverged`:return{action:`branch-diverged`};default:{let t=e.reason;throw Error(`Unhandled CheckoutFailureReason: ${String(t)}`)}}}var me={phase:`loading`};function he(e,t){return e.phase===`loading`?t===null?{phase:`error`}:{phase:`ready`,info:t}:e}function ge(e,t){return e.phase!==`ready`&&e.phase!==`verdict`?e:{phase:`switching`,info:e.info,pendingDoc:t}}function _e(e){return e.phase===`ready`?{phase:`creating-worktree`,info:e.info}:e}function ve(e){return fe(e).kind===`B`&&e.shareTargetOnOriginBranch===!1}function ye(e){return e.phase===`ready`?{phase:`verdict-pending`,info:e.info}:e}function be(e,t){if(e.phase!==`verdict-pending`)return e;if(t===null||t.verdict===`unknown`||t.verdict===`changed-locally`)return{phase:`ready`,info:e.info};let n=t.verdict===`renamed`?{kind:`renamed`,renamedTo:t.renamedTo}:{kind:t.verdict};return{phase:`verdict`,info:e.info,resolution:n}}function xe(e,t){if(e.phase!==`switching`)return{state:e};if(t===null)return{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:`proxy-null`}};let n=g(t);return n.action===`await-cc1`?{state:{phase:`awaiting-cc1-recycle`,pendingDoc:e.pendingDoc}}:n.action===`rerender-conflict`?{state:{phase:`ready`,info:{...e.info,dirtyConflicts:{conflicts:!0,files:n.files.slice()}}}}:n.action===`pivot-to-other-worktree`?{state:{phase:`branch-in-other-worktree`,info:e.info,otherWorktreePath:n.otherWorktreePath,pendingDoc:e.pendingDoc}}:n.action===`dismiss-with-toast`?{state:{phase:`dismissed`,reason:n.reason},sideEffect:{kind:`toast`,reason:n.reason}}:n.action===`branch-diverged`?{state:{phase:`verdict`,info:e.info,resolution:{kind:`diverged`}}}:{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:n.reason}}}function Se(e,t){return e.phase===`creating-worktree`?t===null?{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:`proxy-null`}}:t.ok?{state:{phase:`opening-worktree`,path:t.path}}:t.reason===`branch-not-found`?{state:{phase:`dismissed`,reason:`branch-not-found`},sideEffect:{kind:`toast`,reason:`branch-not-found`}}:{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:t.reason,helper:t.helper,authFailed:t.reason===`fetch-failed`?t.authFailed:void 0}}:{state:e}}var _=t();function Ce(e){return e!==null&&e.kind===`project-branch-switch`}function v(e){let t=(0,de.c)(217),{bridge:n,store:a}=e,f=a===void 0?m:a,{_:g}=i(),v=(0,h.useSyncExternalStore)(f.subscribe,f.getSnapshot,je),[y,b]=(0,h.useState)(me),Me=(0,h.useRef)(!1),Ne=(0,h.useRef)(!1),Pe=(0,h.useRef)(!1),Fe=(0,h.useRef)(null),Ie;t[0]===v?Ie=t[1]:(Ie=Ce(v)?v:null,t[0]=v,t[1]=Ie);let x=Ie,Le;t[2]!==g||t[3]!==x?.share.target.kind?(Le=x?.share.target.kind===`folder`?g({id:`ugoTXs`}):g({id:`XH30C4`}),t[2]=g,t[3]=x?.share.target.kind,t[4]=Le):Le=t[4];let S=Le,Re;t[5]===x?Re=t[6]:(Re=()=>{b(me),Me.current=!1,Ne.current=!1,Pe.current=!1,Fe.current=x},t[5]=x,t[6]=Re);let ze;t[7]===v?ze=t[8]:(ze=[v],t[7]=v,t[8]=ze),(0,h.useEffect)(Re,ze);let Be;t[9]!==x||t[10]!==n?(Be=()=>{if(!x||Me.current)return;Me.current=!0;let e=!1;return n.project.fetchBranchInfo({projectPath:x.projectPath,branch:x.share.branch,kind:x.share.target.kind,path:u(x.share.target)}).then(t=>{e||b(e=>he(e,t))}).catch(t=>{e||(console.warn(`[receive] branch-info-fetch-failed`,t instanceof Error?t.message:t),b(Ae))}),()=>{e=!0}},t[9]=x,t[10]=n,t[11]=Be):Be=t[11];let Ve;t[12]===x?Ve=t[13]:(Ve=[x],t[12]=x,t[13]=Ve),(0,h.useEffect)(Be,Ve);let He;t[14]!==x||t[15]!==y.info||t[16]!==y.phase||t[17]!==n?(He=()=>{if(!x||y.phase!==`ready`||Pe.current||!ve(y.info))return;Pe.current=!0,b(ye);let e=x;n.project.fetchTargetStatus({projectPath:x.projectPath,branch:x.share.branch,kind:x.share.target.kind,path:u(x.share.target)}).then(t=>{Fe.current===e&&b(e=>be(e,t))}).catch(t=>{Fe.current===e&&(console.warn(`[receive] target-status-fetch-failed`,t instanceof Error?t.message:t),b(ke))})},t[14]=x,t[15]=y.info,t[16]=y.phase,t[17]=n,t[18]=He):He=t[18];let Ue;t[19]!==x||t[20]!==y.phase?(Ue=[y.phase,x],t[19]=x,t[20]=y.phase,t[21]=Ue):Ue=t[21],(0,h.useEffect)(He,Ue);let We;t[22]!==x||t[23]!==y.phase||t[24]!==y.resolution||t[25]!==f?(We=()=>{if(y.phase!==`verdict`)return;let{kind:e}=y.resolution;e!==`deleted`&&e!==`never-on-branch`||x&&(le.arm({kind:x.share.target.kind,path:u(x.share.target),branch:x.share.branch}),f.dismiss())},t[22]=x,t[23]=y.phase,t[24]=y.resolution,t[25]=f,t[26]=We):We=t[26];let Ge;t[27]!==x||t[28]!==y||t[29]!==f?(Ge=[y,x,f],t[27]=x,t[28]=y,t[29]=f,t[30]=Ge):Ge=t[30],(0,h.useEffect)(We,Ge);let Ke;t[31]!==y.phase||t[32]!==y.resolution?(Ke=()=>{y.phase===`verdict`&&console.log(p({verdict_cell:y.resolution.kind}))},t[31]=y.phase,t[32]=y.resolution,t[33]=Ke):Ke=t[33];let qe;t[34]===y?qe=t[35]:(qe=[y],t[34]=y,t[35]=qe),(0,h.useEffect)(Ke,qe);let Je;t[36]!==g||t[37]!==x||t[38]!==y.pendingDoc||t[39]!==y.phase||t[40]!==n||t[41]!==f||t[42]!==S?(Je=()=>{if(y.phase!==`awaiting-cc1-recycle`||!x)return;let e=x.share.branch,t=y.pendingDoc;if(!e){f.dismiss();return}if(Ne.current)return;Ne.current=!0;let r=!1;return n.project.awaitBranchSwitched({projectPath:x.projectPath,branch:e,timeoutMs:3e4}).then(i=>{if(!r){if(i.ok){console.log(p({branch_dialog_action:`branch-switch-complete`,branch:e})),n.project.open({path:x.projectPath,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:x.share.target.kind,path:t},pendingBranch:e}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=switch`,e instanceof Error?e.message:e),l.error(g({id:`gQV-9w`,values:{targetNoun:S}}))}),f.dismiss();return}console.log(p({branch_dialog_action:`branch-switch-timeout`,branch:e})),l.error(g({id:`LBwUR6`,values:{targetNoun:S}})),f.dismiss()}}).catch(e=>{r||(console.warn(`[receive] awaitBranchSwitched rejected`,e instanceof Error?e.message:e),l.error(g({id:`Jw6EC4`,values:{targetNoun:S}})),f.dismiss())}),()=>{r=!0}},t[36]=g,t[37]=x,t[38]=y.pendingDoc,t[39]=y.phase,t[40]=n,t[41]=f,t[42]=S,t[43]=Je):Je=t[43];let Ye;if(t[44]!==x||t[45]!==y.phase?(Ye=[y.phase,x],t[44]=x,t[45]=y.phase,t[46]=Ye):Ye=t[46],(0,h.useEffect)(Je,Ye),!x)return null;let{share:C,projectPath:w,currentBranch:Xe}=x,T=C.branch,Ze;t[47]!==g||t[48]!==n.project||t[49]!==w||t[50]!==T||t[51]!==f?(Ze=function(e,t,r){console.log(p({branch_dialog_action:`switch`,branch_action:`switch`,branch:T,verdict_cell:r})),b(t=>ge(t,e)),n.project.runCheckout(t?{projectPath:w,branch:T,fastForward:!0}:{projectPath:w,branch:T}).then(e=>{let t=null,n=!1;b(r=>{let{state:i,sideEffect:a}=xe(r,e);return a&&(t=a.reason,n=i.phase===`dismissed`),i}),t===`branch-not-found`?l.error(g({id:`NJyQi_`,values:{shareBranch:T}})):t===`fetch-failed`?l.error(g({id:`bWLmRK`})):(t===`checkout-failed`||t===`proxy-null`)&&l.error(g({id:`c863eW`,values:{shareBranch:T}})),n&&f.dismiss()}).catch(e=>{console.warn(`[receive] runCheckout rejected branch_action=switch`,e instanceof Error?e.message:e),b(Oe),l.error(g({id:`c863eW`,values:{shareBranch:T}}))})},t[47]=g,t[48]=n.project,t[49]=w,t[50]=T,t[51]=f,t[52]=Ze):Ze=t[52];let E=Ze,Qe;t[53]!==y.info||t[54]!==y.phase||t[55]!==E||t[56]!==C.target?(Qe=function(){y.phase===`ready`&&fe(y.info).switchEnabled&&E(u(C.target),!1)},t[53]=y.info,t[54]=y.phase,t[55]=E,t[56]=C.target,t[57]=Qe):Qe=t[57];let $e=Qe,et;t[58]!==y.phase||t[59]!==y.resolution||t[60]!==E||t[61]!==C.target?(et=function(){y.phase===`verdict`&&E(u(C.target),!0,y.resolution.kind)},t[58]=y.phase,t[59]=y.resolution,t[60]=E,t[61]=C.target,t[62]=et):et=t[62];let tt=et,nt;t[63]!==y.phase||t[64]!==y.resolution||t[65]!==E?(nt=function(){y.phase===`verdict`&&y.resolution.kind===`renamed`&&E(y.resolution.renamedTo,!0,y.resolution.kind)},t[63]=y.phase,t[64]=y.resolution,t[65]=E,t[66]=nt):nt=t[66];let rt=nt,it;t[67]!==y.phase||t[68]!==y.resolution||t[69]!==E||t[70]!==C.target?(it=function(){y.phase===`verdict`&&E(u(C.target),!1,y.resolution.kind)},t[67]=y.phase,t[68]=y.resolution,t[69]=E,t[70]=C.target,t[71]=it):it=t[71];let at=it,ot;t[72]!==g||t[73]!==n.project||t[74]!==w||t[75]!==C.target||t[76]!==T||t[77]!==f||t[78]!==S?(ot=function(){console.log(p({branch_dialog_action:`open-current`,branch:T})),n.project.open({path:w,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:C.target.kind,path:u(C.target)}}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=open-current`,e instanceof Error?e.message:e),l.error(g({id:`b5aNbi`,values:{targetNoun:S}}))}),f.dismiss()},t[72]=g,t[73]=n.project,t[74]=w,t[75]=C.target,t[76]=T,t[77]=f,t[78]=S,t[79]=ot):ot=t[79];let st=ot,ct;t[80]!==g||t[81]!==T?(ct=function(e,t,n){if(e===`fetch-failed`&&n){l.error(g({id:`gfb-CM`}),{action:{label:g({id:`5lWFkC`}),onClick:De}});return}switch(e){case`helper-not-found`:{let e=t??g({id:`cHhH3i`});l.error(g({id:`Z7x_Zh`,values:{tool:e}}));return}case`branch-not-found`:l.error(g({id:`NJyQi_`,values:{shareBranch:T}}));return;case`fetch-failed`:l.error(g({id:`bWLmRK`}));return;case`already-checked-out`:l.error(g({id:`ljHjfg`}));return;case`branch-exists`:l.error(g({id:`h3QZcB`,values:{shareBranch:T}}));return;case`path-exists`:l.error(g({id:`cN1Gcp`,values:{shareBranch:T}}));return;case`no-git`:l.error(g({id:`CFnavk`}));return;case`invalid-branch`:l.error(g({id:`JfPuv7`,values:{shareBranch:T}}));return;case`proxy-null`:case`error`:l.error(g({id:`e8zYa8`,values:{shareBranch:T}}));return;default:throw Error(`Unhandled worktree failure reason: ${String(e)}`)}},t[80]=g,t[81]=T,t[82]=ct):ct=t[82];let lt=ct,ut;t[83]!==g||t[84]!==n.project||t[85]!==C.target||t[86]!==T||t[87]!==lt||t[88]!==f?(ut=function(e){let t=null,r,i,a=!1,o=null;if(b(n=>{let{state:ee,sideEffect:te}=Se(n,e);return te&&(t=te.reason,r=te.helper,i=te.authFailed,a=ee.phase===`dismissed`),ee.phase===`opening-worktree`&&(o=ee.path),ee}),t!==null&&(console.log(p({branch_dialog_action:`open-worktree-failed:${t}`,branch:T})),lt(t,r,i)),o!==null){d();let e=o;n.project.open({path:e,target:`new-window`,entryPoint:`worktree`,pendingDeepLinkTarget:{kind:C.target.kind,path:u(C.target)},pendingBranch:T}).catch(t=>{console.warn(`[receive] worktree-open-failed branch_dialog_action=open-worktree`,t instanceof Error?t.message:t),l.error(g({id:`LdABLa`,values:{target:e}}))}),f.dismiss()}a&&f.dismiss()},t[83]=g,t[84]=n.project,t[85]=C.target,t[86]=T,t[87]=lt,t[88]=f,t[89]=ut):ut=t[89];let dt=ut,ft;t[90]!==dt||t[91]!==y.phase||t[92]!==n.worktree||t[93]!==T?(ft=function(){y.phase===`ready`&&(console.log(p({branch_dialog_action:`open-worktree`,branch:T})),b(_e),n.worktree.checkout({branch:T}).then(e=>{dt(e)}).catch(e=>{console.warn(`[receive] worktree-checkout rejected branch_dialog_action=open-worktree`,e instanceof Error?e.message:e),dt(null)}))},t[90]=dt,t[91]=y.phase,t[92]=n.worktree,t[93]=T,t[94]=ft):ft=t[94];let pt=ft,mt;t[95]!==g||t[96]!==y.otherWorktreePath||t[97]!==y.phase||t[98]!==n.project||t[99]!==C.target||t[100]!==T||t[101]!==f?(mt=function(){if(y.phase!==`branch-in-other-worktree`)return;let e=y.otherWorktreePath;console.log(p({branch_dialog_action:`pivot-to-other-worktree`,branch:T})),n.project.open({path:e,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:C.target.kind,path:u(C.target)},pendingBranch:T}).catch(t=>{console.warn(`[receive] pivot-open-failed branch_action=pivot-to-other-worktree`,t instanceof Error?t.message:t),l.error(g({id:`LdABLa`,values:{target:e}}))}),f.dismiss()},t[95]=g,t[96]=y.otherWorktreePath,t[97]=y.phase,t[98]=n.project,t[99]=C.target,t[100]=T,t[101]=f,t[102]=mt):mt=t[102];let ht=mt,gt;t[103]!==y.phase||t[104]!==y.resolution||t[105]!==f?(gt=function(){console.log(p({branch_dialog_action:`cancel`,verdict_cell:y.phase===`verdict`?y.resolution.kind:void 0})),f.dismiss()},t[103]=y.phase,t[104]=y.resolution,t[105]=f,t[106]=gt):gt=t[106];let D=gt,O,k,A,j,M,N,P,F,I,L,R,z,B,V,H,U,W,G,K;if(t[107]!==g||t[108]!==y.info||t[109]!==y.otherWorktreePath||t[110]!==y.phase||t[111]!==y.resolution||t[112]!==D||t[113]!==Xe||t[114]!==C.branch||t[115]!==C.owner||t[116]!==C.repo||t[117]!==C.target||t[118]!==T||t[119]!==S){G=y.phase===`ready`||y.phase===`switching`||y.phase===`creating-worktree`?fe(y.info):null;let e;t[139]!==y.info||t[140]!==y.phase||t[141]!==Xe?(e=y.phase===`ready`||y.phase===`switching`||y.phase===`creating-worktree`?pe(y.info):Xe??`HEAD`,t[139]=y.info,t[140]=y.phase,t[141]=Xe,t[142]=e):e=t[142];let n=e;P=y.phase===`switching`||y.phase===`awaiting-cc1-recycle`,j=y.phase===`creating-worktree`;let i;t[143]===g?i=t[144]:(i=g({id:`OuY8t9`}),t[143]=g,t[144]=i),M=i;let a;t[145]===g?a=t[146]:(a=g({id:`XZkdtg`}),t[145]=g,t[146]=a),N=a;let o;t[147]===g?o=t[148]:(o=g({id:`VTulZj`}),t[147]=g,t[148]=o),K=o;let ie=y.phase===`loading`,se=y.phase===`error`;A=oe,U=!0,t[149]===D?W=t[150]:(W=e=>{e||D()},t[149]=D,t[150]=W),k=ne,R=`sm:max-w-xl`,z=`share-branch-switch-dialog`,B=Ee,V=Te;let s;t[151]===S?s=t[152]:(s=(0,_.jsx)(te,{children:(0,_.jsx)(r,{id:`RY6Bq1`,values:{targetNoun:S}})}),t[151]=S,t[152]=s);let ce=C.owner,le=C.repo,l;t[153]===C.target?l=t[154]:(l=u(C.target),t[153]=C.target,t[154]=l);let d;t[155]!==C.owner||t[156]!==C.repo||t[157]!==l?(d=(0,_.jsx)(ee,{className:`sr-only`,children:(0,_.jsx)(r,{id:`f8jU-L`,values:{0:ce,1:le,2:l}})}),t[155]=C.owner,t[156]=C.repo,t[157]=l,t[158]=d):d=t[158],t[159]!==s||t[160]!==d?(H=(0,_.jsxs)(ae,{children:[s,d]}),t[159]=s,t[160]=d,t[161]=H):H=t[161],O=re;let f=C.owner,p=C.repo,m;t[162]===C.target?m=t[163]:(m=u(C.target),t[162]=C.target,t[163]=m),t[164]!==C.branch||t[165]!==C.owner||t[166]!==C.repo||t[167]!==C.target.kind||t[168]!==m?(F=(0,_.jsx)(`div`,{className:`mb-4`,children:(0,_.jsx)(ue,{owner:f,repo:p,path:m,kind:C.target.kind,branch:C.branch,testId:`share-branch-switch-metadata`,branchTestId:`share-branch-switch-metadata-branch`})}),t[164]=C.branch,t[165]=C.owner,t[166]=C.repo,t[167]=C.target.kind,t[168]=m,t[169]=F):F=t[169],I=y.phase===`branch-in-other-worktree`?(0,_.jsxs)(`div`,{className:`text-sm text-muted-foreground`,"data-testid":`share-branch-switch-in-other-worktree`,children:[(0,_.jsx)(`p`,{className:`leading-6`,children:(0,_.jsx)(r,{id:`yjExfe`,values:{shareBranch:T},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),(0,_.jsx)(`p`,{className:`mt-2 break-all rounded bg-muted px-2 py-1 font-mono text-xs text-foreground/80`,"data-testid":`share-branch-switch-in-other-worktree-path`,children:y.otherWorktreePath})]}):y.phase===`verdict-pending`?(0,_.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-verdict-pending`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`c8jBgX`})]}):y.phase===`verdict`?y.resolution.kind===`on-origin`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,"data-testid":`share-branch-switch-verdict-on-origin`,children:(0,_.jsx)(r,{id:`Uay5NL`,values:{targetNoun:S,shareBranch:T},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):y.resolution.kind===`renamed`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,"data-testid":`share-branch-switch-verdict-renamed`,children:(0,_.jsx)(r,{id:`P0HC30`,values:{0:y.resolution.renamedTo,targetNoun:S},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):y.resolution.kind===`diverged`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,"data-testid":`share-branch-switch-verdict-diverged`,children:(0,_.jsx)(r,{id:`kLv8d3`,values:{shareBranch:T,targetNoun:S},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):(0,_.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-verdict-handoff`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`c8jBgX`})]}):ie?(0,_.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-loading`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`jerqF0`})]}):se?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,_.jsx)(r,{id:`w4hMYl`})}):G?.kind===`D`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,_.jsx)(r,{id:`DTI-fp`,values:{targetNoun:S,shareBranch:T},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):G?.kind===`B`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,_.jsx)(r,{id:`sZ2IOu`,values:{targetNoun:S,shareBranch:T,currentLabel:n},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,_.jsx)(r,{id:`_902BE`,values:{targetNoun:S,shareBranch:T,currentLabel:n},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),L=G&&!G.switchEnabled&&G.conflictingFiles.length>0?(0,_.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/30 p-3 text-1sm`,"data-testid":`share-branch-switch-conflict`,children:[(0,_.jsx)(`p`,{className:`font-medium text-foreground/90`,children:(0,_.jsx)(r,{id:`n2lRue`})}),(0,_.jsx)(`ul`,{id:`share-receive-branch-conflict-files`,className:`mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground`,children:G.conflictingFiles.map(we)})]}):null,t[107]=g,t[108]=y.info,t[109]=y.otherWorktreePath,t[110]=y.phase,t[111]=y.resolution,t[112]=D,t[113]=Xe,t[114]=C.branch,t[115]=C.owner,t[116]=C.repo,t[117]=C.target,t[118]=T,t[119]=S,t[120]=O,t[121]=k,t[122]=A,t[123]=j,t[124]=M,t[125]=N,t[126]=P,t[127]=F,t[128]=I,t[129]=L,t[130]=R,t[131]=z,t[132]=B,t[133]=V,t[134]=H,t[135]=U,t[136]=W,t[137]=G,t[138]=K}else O=t[120],k=t[121],A=t[122],j=t[123],M=t[124],N=t[125],P=t[126],F=t[127],I=t[128],L=t[129],R=t[130],z=t[131],B=t[132],V=t[133],H=t[134],U=t[135],W=t[136],G=t[137],K=t[138];let q;t[170]===P?q=t[171]:(q=P?(0,_.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-switching`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`CU3AiE`})]}):null,t[170]=P,t[171]=q);let J;t[172]===j?J=t[173]:(J=j?(0,_.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-creating-worktree`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`PZtgO0`})]}):null,t[172]=j,t[173]=J);let Y;t[174]!==O||t[175]!==F||t[176]!==I||t[177]!==L||t[178]!==q||t[179]!==J?(Y=(0,_.jsxs)(O,{children:[F,I,L,q,J]}),t[174]=O,t[175]=F,t[176]=I,t[177]=L,t[178]=q,t[179]=J,t[180]=Y):Y=t[180];let _t;t[181]===Symbol.for(`react.memo_cache_sentinel`)?(_t=(0,_.jsx)(r,{id:`dEgA5A`}),t[181]=_t):_t=t[181];let X;t[182]===D?X=t[183]:(X=(0,_.jsx)(o,{variant:`ghost`,className:`font-mono uppercase`,onClick:D,"data-testid":`share-branch-switch-cancel`,children:_t}),t[182]=D,t[183]=X);let Z;t[184]!==y.phase||t[185]!==y.resolution||t[186]!==j||t[187]!==st||t[188]!==rt||t[189]!==pt||t[190]!==ht||t[191]!==at||t[192]!==$e||t[193]!==tt||t[194]!==M||t[195]!==N||t[196]!==P||t[197]!==G||t[198]!==K?(Z=y.phase===`branch-in-other-worktree`?(0,_.jsx)(o,{onClick:ht,"data-testid":`share-branch-switch-in-other-worktree-pivot`,children:(0,_.jsx)(r,{id:`hyCxJY`})}):y.phase===`verdict`?y.resolution.kind===`on-origin`?(0,_.jsxs)(o,{onClick:tt,"data-testid":`share-branch-switch-verdict-switch-update`,children:[(0,_.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),(0,_.jsx)(r,{id:`uA_jXp`})]}):y.resolution.kind===`renamed`?(0,_.jsxs)(o,{onClick:rt,"data-testid":`share-branch-switch-verdict-open-renamed`,children:[(0,_.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,_.jsx)(r,{id:`AItsE5`})]}):y.resolution.kind===`diverged`?(0,_.jsxs)(o,{onClick:at,"data-testid":`share-branch-switch-verdict-plain-switch`,children:[(0,_.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),N]}):null:(0,_.jsxs)(`div`,{className:`flex min-w-0 flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-end sm:gap-2`,children:[G?.openCurrentEnabled?(0,_.jsxs)(o,{variant:`outline`,className:`font-mono uppercase`,onClick:st,disabled:P||j,"data-testid":`share-branch-switch-open-current`,children:[(0,_.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),M]}):null,(0,_.jsx)(o,{variant:`outline`,onClick:$e,disabled:!G?.switchEnabled||P||j,"aria-disabled":!G?.switchEnabled||P||j,"aria-describedby":G&&!G.switchEnabled&&G.conflictingFiles.length>0?`share-receive-branch-conflict-files`:void 0,"data-testid":`share-branch-switch-switch`,children:P?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(c,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),N]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),N]})}),(0,_.jsx)(o,{onClick:pt,disabled:!G||P||j,"data-testid":`share-branch-switch-worktree`,children:j?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(c,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),K]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),K]})})]}),t[184]=y.phase,t[185]=y.resolution,t[186]=j,t[187]=st,t[188]=rt,t[189]=pt,t[190]=ht,t[191]=at,t[192]=$e,t[193]=tt,t[194]=M,t[195]=N,t[196]=P,t[197]=G,t[198]=K,t[199]=Z):Z=t[199];let Q;t[200]!==X||t[201]!==Z?(Q=(0,_.jsxs)(ie,{className:`sm:justify-between`,children:[X,Z]}),t[200]=X,t[201]=Z,t[202]=Q):Q=t[202];let $;t[203]!==k||t[204]!==R||t[205]!==z||t[206]!==B||t[207]!==V||t[208]!==H||t[209]!==Y||t[210]!==Q?($=(0,_.jsxs)(k,{className:R,"data-testid":z,onInteractOutside:B,onPointerDownOutside:V,children:[H,Y,Q]}),t[203]=k,t[204]=R,t[205]=z,t[206]=B,t[207]=V,t[208]=H,t[209]=Y,t[210]=Q,t[211]=$):$=t[211];let vt;return t[212]!==A||t[213]!==U||t[214]!==W||t[215]!==$?(vt=(0,_.jsx)(A,{open:U,onOpenChange:W,children:$}),t[212]=A,t[213]=U,t[214]=W,t[215]=$,t[216]=vt):vt=t[216],vt}function we(e){return(0,_.jsx)(`li`,{children:(0,_.jsx)(`code`,{className:`text-foreground/80`,children:e})},e)}function Te(e){e.preventDefault()}function Ee(e){e.preventDefault()}function De(){return f.request()}function Oe(e){return xe(e,null).state}function ke(e){return be(e,null)}function Ae(e){return he(e,null)}function je(){return null}export{v as ShareBranchSwitchDialog};
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./button-RQ5o7P7w.js";import{a as ee,c as te,i as ne,n as re,o as ie,s as ae,t as oe}from"./dialog-DwFomKjP.js";import{n as se,t as s}from"./git-branch-B0WeYwW-.js";import{t as c}from"./loader-circle-B0OUuKph.js";import{n as ce,t as le}from"./miss-dialog-store-B3cHkf8G.js";import{n as l}from"./dist-DmEZHXvB.js";import{t as u}from"./desktop-bridge-types-BwR5S9HF.js";import{r as d,t as f}from"./auth-prompt-store-DQ_HcDxh.js";import{a as p,n as m}from"./receive-store-2bhS8vt2.js";import{t as ue}from"./share-metadata-rows-B1YjvGbL.js";var h=e(n(),1),de=a();function fe(e){let t=e.shareTargetExists,n=e.dirtyConflicts.conflicts,r=e.dirtyConflicts.files;return t&&!n?{kind:`A`,openCurrentEnabled:!0,switchEnabled:!0,conflictingFiles:r}:!t&&!n?{kind:`B`,openCurrentEnabled:!1,switchEnabled:!0,conflictingFiles:r}:t&&n?{kind:`C`,openCurrentEnabled:!0,switchEnabled:!1,conflictingFiles:r}:{kind:`D`,openCurrentEnabled:!1,switchEnabled:!1,conflictingFiles:r}}function pe(e){return e.detached?e.currentHeadSha:e.currentBranch??`HEAD`}function g(e){if(e.ok)return{action:`await-cc1`};switch(e.reason){case`dirty-conflict`:return{action:`rerender-conflict`,files:e.files??[]};case`branch-not-found`:return{action:`dismiss-with-toast`,reason:`branch-not-found`};case`fetch-failed`:case`checkout-failed`:return{action:`stay-with-toast`,reason:e.reason};case`branch-in-other-worktree`:{let t=e.otherWorktreePath;return t===void 0||t.length===0?{action:`stay-with-toast`,reason:`checkout-failed`}:{action:`pivot-to-other-worktree`,otherWorktreePath:t}}case`ff-diverged`:return{action:`branch-diverged`};default:{let t=e.reason;throw Error(`Unhandled CheckoutFailureReason: ${String(t)}`)}}}var me={phase:`loading`};function he(e,t){return e.phase===`loading`?t===null?{phase:`error`}:{phase:`ready`,info:t}:e}function ge(e,t){return e.phase!==`ready`&&e.phase!==`verdict`?e:{phase:`switching`,info:e.info,pendingDoc:t}}function _e(e){return e.phase===`ready`?{phase:`creating-worktree`,info:e.info}:e}function ve(e){return fe(e).kind===`B`&&e.shareTargetOnOriginBranch===!1}function ye(e){return e.phase===`ready`?{phase:`verdict-pending`,info:e.info}:e}function be(e,t){if(e.phase!==`verdict-pending`)return e;if(t===null||t.verdict===`unknown`||t.verdict===`changed-locally`)return{phase:`ready`,info:e.info};let n=t.verdict===`renamed`?{kind:`renamed`,renamedTo:t.renamedTo}:{kind:t.verdict};return{phase:`verdict`,info:e.info,resolution:n}}function xe(e,t){if(e.phase!==`switching`)return{state:e};if(t===null)return{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:`proxy-null`}};let n=g(t);return n.action===`await-cc1`?{state:{phase:`awaiting-cc1-recycle`,pendingDoc:e.pendingDoc}}:n.action===`rerender-conflict`?{state:{phase:`ready`,info:{...e.info,dirtyConflicts:{conflicts:!0,files:n.files.slice()}}}}:n.action===`pivot-to-other-worktree`?{state:{phase:`branch-in-other-worktree`,info:e.info,otherWorktreePath:n.otherWorktreePath,pendingDoc:e.pendingDoc}}:n.action===`dismiss-with-toast`?{state:{phase:`dismissed`,reason:n.reason},sideEffect:{kind:`toast`,reason:n.reason}}:n.action===`branch-diverged`?{state:{phase:`verdict`,info:e.info,resolution:{kind:`diverged`}}}:{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:n.reason}}}function Se(e,t){return e.phase===`creating-worktree`?t===null?{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:`proxy-null`}}:t.ok?{state:{phase:`opening-worktree`,path:t.path}}:t.reason===`branch-not-found`?{state:{phase:`dismissed`,reason:`branch-not-found`},sideEffect:{kind:`toast`,reason:`branch-not-found`}}:{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:t.reason,helper:t.helper,authFailed:t.reason===`fetch-failed`?t.authFailed:void 0}}:{state:e}}var _=t();function Ce(e){return e!==null&&e.kind===`project-branch-switch`}function v(e){let t=(0,de.c)(217),{bridge:n,store:a}=e,f=a===void 0?m:a,{_:g}=i(),v=(0,h.useSyncExternalStore)(f.subscribe,f.getSnapshot,je),[y,b]=(0,h.useState)(me),Me=(0,h.useRef)(!1),Ne=(0,h.useRef)(!1),Pe=(0,h.useRef)(!1),Fe=(0,h.useRef)(null),Ie;t[0]===v?Ie=t[1]:(Ie=Ce(v)?v:null,t[0]=v,t[1]=Ie);let x=Ie,Le;t[2]!==g||t[3]!==x?.share.target.kind?(Le=x?.share.target.kind===`folder`?g({id:`ugoTXs`}):g({id:`XH30C4`}),t[2]=g,t[3]=x?.share.target.kind,t[4]=Le):Le=t[4];let S=Le,Re;t[5]===x?Re=t[6]:(Re=()=>{b(me),Me.current=!1,Ne.current=!1,Pe.current=!1,Fe.current=x},t[5]=x,t[6]=Re);let ze;t[7]===v?ze=t[8]:(ze=[v],t[7]=v,t[8]=ze),(0,h.useEffect)(Re,ze);let Be;t[9]!==x||t[10]!==n?(Be=()=>{if(!x||Me.current)return;Me.current=!0;let e=!1;return n.project.fetchBranchInfo({projectPath:x.projectPath,branch:x.share.branch,kind:x.share.target.kind,path:u(x.share.target)}).then(t=>{e||b(e=>he(e,t))}).catch(t=>{e||(console.warn(`[receive] branch-info-fetch-failed`,t instanceof Error?t.message:t),b(Ae))}),()=>{e=!0}},t[9]=x,t[10]=n,t[11]=Be):Be=t[11];let Ve;t[12]===x?Ve=t[13]:(Ve=[x],t[12]=x,t[13]=Ve),(0,h.useEffect)(Be,Ve);let He;t[14]!==x||t[15]!==y.info||t[16]!==y.phase||t[17]!==n?(He=()=>{if(!x||y.phase!==`ready`||Pe.current||!ve(y.info))return;Pe.current=!0,b(ye);let e=x;n.project.fetchTargetStatus({projectPath:x.projectPath,branch:x.share.branch,kind:x.share.target.kind,path:u(x.share.target)}).then(t=>{Fe.current===e&&b(e=>be(e,t))}).catch(t=>{Fe.current===e&&(console.warn(`[receive] target-status-fetch-failed`,t instanceof Error?t.message:t),b(ke))})},t[14]=x,t[15]=y.info,t[16]=y.phase,t[17]=n,t[18]=He):He=t[18];let Ue;t[19]!==x||t[20]!==y.phase?(Ue=[y.phase,x],t[19]=x,t[20]=y.phase,t[21]=Ue):Ue=t[21],(0,h.useEffect)(He,Ue);let We;t[22]!==x||t[23]!==y.phase||t[24]!==y.resolution||t[25]!==f?(We=()=>{if(y.phase!==`verdict`)return;let{kind:e}=y.resolution;e!==`deleted`&&e!==`never-on-branch`||x&&(le.arm({kind:x.share.target.kind,path:u(x.share.target),branch:x.share.branch}),f.dismiss())},t[22]=x,t[23]=y.phase,t[24]=y.resolution,t[25]=f,t[26]=We):We=t[26];let Ge;t[27]!==x||t[28]!==y||t[29]!==f?(Ge=[y,x,f],t[27]=x,t[28]=y,t[29]=f,t[30]=Ge):Ge=t[30],(0,h.useEffect)(We,Ge);let Ke;t[31]!==y.phase||t[32]!==y.resolution?(Ke=()=>{y.phase===`verdict`&&console.log(p({verdict_cell:y.resolution.kind}))},t[31]=y.phase,t[32]=y.resolution,t[33]=Ke):Ke=t[33];let qe;t[34]===y?qe=t[35]:(qe=[y],t[34]=y,t[35]=qe),(0,h.useEffect)(Ke,qe);let Je;t[36]!==g||t[37]!==x||t[38]!==y.pendingDoc||t[39]!==y.phase||t[40]!==n||t[41]!==f||t[42]!==S?(Je=()=>{if(y.phase!==`awaiting-cc1-recycle`||!x)return;let e=x.share.branch,t=y.pendingDoc;if(!e){f.dismiss();return}if(Ne.current)return;Ne.current=!0;let r=!1;return n.project.awaitBranchSwitched({projectPath:x.projectPath,branch:e,timeoutMs:3e4}).then(i=>{if(!r){if(i.ok){console.log(p({branch_dialog_action:`branch-switch-complete`,branch:e})),n.project.open({path:x.projectPath,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:x.share.target.kind,path:t},pendingBranch:e}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=switch`,e instanceof Error?e.message:e),l.error(g({id:`gQV-9w`,values:{targetNoun:S}}))}),f.dismiss();return}console.log(p({branch_dialog_action:`branch-switch-timeout`,branch:e})),l.error(g({id:`LBwUR6`,values:{targetNoun:S}})),f.dismiss()}}).catch(e=>{r||(console.warn(`[receive] awaitBranchSwitched rejected`,e instanceof Error?e.message:e),l.error(g({id:`Jw6EC4`,values:{targetNoun:S}})),f.dismiss())}),()=>{r=!0}},t[36]=g,t[37]=x,t[38]=y.pendingDoc,t[39]=y.phase,t[40]=n,t[41]=f,t[42]=S,t[43]=Je):Je=t[43];let Ye;if(t[44]!==x||t[45]!==y.phase?(Ye=[y.phase,x],t[44]=x,t[45]=y.phase,t[46]=Ye):Ye=t[46],(0,h.useEffect)(Je,Ye),!x)return null;let{share:C,projectPath:w,currentBranch:Xe}=x,T=C.branch,Ze;t[47]!==g||t[48]!==n.project||t[49]!==w||t[50]!==T||t[51]!==f?(Ze=function(e,t,r){console.log(p({branch_dialog_action:`switch`,branch_action:`switch`,branch:T,verdict_cell:r})),b(t=>ge(t,e)),n.project.runCheckout(t?{projectPath:w,branch:T,fastForward:!0}:{projectPath:w,branch:T}).then(e=>{let t=null,n=!1;b(r=>{let{state:i,sideEffect:a}=xe(r,e);return a&&(t=a.reason,n=i.phase===`dismissed`),i}),t===`branch-not-found`?l.error(g({id:`NJyQi_`,values:{shareBranch:T}})):t===`fetch-failed`?l.error(g({id:`bWLmRK`})):(t===`checkout-failed`||t===`proxy-null`)&&l.error(g({id:`c863eW`,values:{shareBranch:T}})),n&&f.dismiss()}).catch(e=>{console.warn(`[receive] runCheckout rejected branch_action=switch`,e instanceof Error?e.message:e),b(Oe),l.error(g({id:`c863eW`,values:{shareBranch:T}}))})},t[47]=g,t[48]=n.project,t[49]=w,t[50]=T,t[51]=f,t[52]=Ze):Ze=t[52];let E=Ze,Qe;t[53]!==y.info||t[54]!==y.phase||t[55]!==E||t[56]!==C.target?(Qe=function(){y.phase===`ready`&&fe(y.info).switchEnabled&&E(u(C.target),!1)},t[53]=y.info,t[54]=y.phase,t[55]=E,t[56]=C.target,t[57]=Qe):Qe=t[57];let $e=Qe,et;t[58]!==y.phase||t[59]!==y.resolution||t[60]!==E||t[61]!==C.target?(et=function(){y.phase===`verdict`&&E(u(C.target),!0,y.resolution.kind)},t[58]=y.phase,t[59]=y.resolution,t[60]=E,t[61]=C.target,t[62]=et):et=t[62];let tt=et,nt;t[63]!==y.phase||t[64]!==y.resolution||t[65]!==E?(nt=function(){y.phase===`verdict`&&y.resolution.kind===`renamed`&&E(y.resolution.renamedTo,!0,y.resolution.kind)},t[63]=y.phase,t[64]=y.resolution,t[65]=E,t[66]=nt):nt=t[66];let rt=nt,it;t[67]!==y.phase||t[68]!==y.resolution||t[69]!==E||t[70]!==C.target?(it=function(){y.phase===`verdict`&&E(u(C.target),!1,y.resolution.kind)},t[67]=y.phase,t[68]=y.resolution,t[69]=E,t[70]=C.target,t[71]=it):it=t[71];let at=it,ot;t[72]!==g||t[73]!==n.project||t[74]!==w||t[75]!==C.target||t[76]!==T||t[77]!==f||t[78]!==S?(ot=function(){console.log(p({branch_dialog_action:`open-current`,branch:T})),n.project.open({path:w,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:C.target.kind,path:u(C.target)}}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=open-current`,e instanceof Error?e.message:e),l.error(g({id:`b5aNbi`,values:{targetNoun:S}}))}),f.dismiss()},t[72]=g,t[73]=n.project,t[74]=w,t[75]=C.target,t[76]=T,t[77]=f,t[78]=S,t[79]=ot):ot=t[79];let st=ot,ct;t[80]!==g||t[81]!==T?(ct=function(e,t,n){if(e===`fetch-failed`&&n){l.error(g({id:`gfb-CM`}),{action:{label:g({id:`5lWFkC`}),onClick:De}});return}switch(e){case`helper-not-found`:{let e=t??g({id:`cHhH3i`});l.error(g({id:`Z7x_Zh`,values:{tool:e}}));return}case`branch-not-found`:l.error(g({id:`NJyQi_`,values:{shareBranch:T}}));return;case`fetch-failed`:l.error(g({id:`bWLmRK`}));return;case`already-checked-out`:l.error(g({id:`ljHjfg`}));return;case`branch-exists`:l.error(g({id:`h3QZcB`,values:{shareBranch:T}}));return;case`path-exists`:l.error(g({id:`cN1Gcp`,values:{shareBranch:T}}));return;case`no-git`:l.error(g({id:`CFnavk`}));return;case`invalid-branch`:l.error(g({id:`JfPuv7`,values:{shareBranch:T}}));return;case`proxy-null`:case`error`:l.error(g({id:`e8zYa8`,values:{shareBranch:T}}));return;default:throw Error(`Unhandled worktree failure reason: ${String(e)}`)}},t[80]=g,t[81]=T,t[82]=ct):ct=t[82];let lt=ct,ut;t[83]!==g||t[84]!==n.project||t[85]!==C.target||t[86]!==T||t[87]!==lt||t[88]!==f?(ut=function(e){let t=null,r,i,a=!1,o=null;if(b(n=>{let{state:ee,sideEffect:te}=Se(n,e);return te&&(t=te.reason,r=te.helper,i=te.authFailed,a=ee.phase===`dismissed`),ee.phase===`opening-worktree`&&(o=ee.path),ee}),t!==null&&(console.log(p({branch_dialog_action:`open-worktree-failed:${t}`,branch:T})),lt(t,r,i)),o!==null){d();let e=o;n.project.open({path:e,target:`new-window`,entryPoint:`worktree`,pendingDeepLinkTarget:{kind:C.target.kind,path:u(C.target)},pendingBranch:T}).catch(t=>{console.warn(`[receive] worktree-open-failed branch_dialog_action=open-worktree`,t instanceof Error?t.message:t),l.error(g({id:`LdABLa`,values:{target:e}}))}),f.dismiss()}a&&f.dismiss()},t[83]=g,t[84]=n.project,t[85]=C.target,t[86]=T,t[87]=lt,t[88]=f,t[89]=ut):ut=t[89];let dt=ut,ft;t[90]!==dt||t[91]!==y.phase||t[92]!==n.worktree||t[93]!==T?(ft=function(){y.phase===`ready`&&(console.log(p({branch_dialog_action:`open-worktree`,branch:T})),b(_e),n.worktree.checkout({branch:T}).then(e=>{dt(e)}).catch(e=>{console.warn(`[receive] worktree-checkout rejected branch_dialog_action=open-worktree`,e instanceof Error?e.message:e),dt(null)}))},t[90]=dt,t[91]=y.phase,t[92]=n.worktree,t[93]=T,t[94]=ft):ft=t[94];let pt=ft,mt;t[95]!==g||t[96]!==y.otherWorktreePath||t[97]!==y.phase||t[98]!==n.project||t[99]!==C.target||t[100]!==T||t[101]!==f?(mt=function(){if(y.phase!==`branch-in-other-worktree`)return;let e=y.otherWorktreePath;console.log(p({branch_dialog_action:`pivot-to-other-worktree`,branch:T})),n.project.open({path:e,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:C.target.kind,path:u(C.target)},pendingBranch:T}).catch(t=>{console.warn(`[receive] pivot-open-failed branch_action=pivot-to-other-worktree`,t instanceof Error?t.message:t),l.error(g({id:`LdABLa`,values:{target:e}}))}),f.dismiss()},t[95]=g,t[96]=y.otherWorktreePath,t[97]=y.phase,t[98]=n.project,t[99]=C.target,t[100]=T,t[101]=f,t[102]=mt):mt=t[102];let ht=mt,gt;t[103]!==y.phase||t[104]!==y.resolution||t[105]!==f?(gt=function(){console.log(p({branch_dialog_action:`cancel`,verdict_cell:y.phase===`verdict`?y.resolution.kind:void 0})),f.dismiss()},t[103]=y.phase,t[104]=y.resolution,t[105]=f,t[106]=gt):gt=t[106];let D=gt,O,k,A,j,M,N,P,F,I,L,R,z,B,V,H,U,W,G,K;if(t[107]!==g||t[108]!==y.info||t[109]!==y.otherWorktreePath||t[110]!==y.phase||t[111]!==y.resolution||t[112]!==D||t[113]!==Xe||t[114]!==C.branch||t[115]!==C.owner||t[116]!==C.repo||t[117]!==C.target||t[118]!==T||t[119]!==S){G=y.phase===`ready`||y.phase===`switching`||y.phase===`creating-worktree`?fe(y.info):null;let e;t[139]!==y.info||t[140]!==y.phase||t[141]!==Xe?(e=y.phase===`ready`||y.phase===`switching`||y.phase===`creating-worktree`?pe(y.info):Xe??`HEAD`,t[139]=y.info,t[140]=y.phase,t[141]=Xe,t[142]=e):e=t[142];let n=e;P=y.phase===`switching`||y.phase===`awaiting-cc1-recycle`,j=y.phase===`creating-worktree`;let i;t[143]===g?i=t[144]:(i=g({id:`OuY8t9`}),t[143]=g,t[144]=i),M=i;let a;t[145]===g?a=t[146]:(a=g({id:`XZkdtg`}),t[145]=g,t[146]=a),N=a;let o;t[147]===g?o=t[148]:(o=g({id:`VTulZj`}),t[147]=g,t[148]=o),K=o;let ie=y.phase===`loading`,se=y.phase===`error`;A=oe,U=!0,t[149]===D?W=t[150]:(W=e=>{e||D()},t[149]=D,t[150]=W),k=ne,R=`sm:max-w-xl`,z=`share-branch-switch-dialog`,B=Ee,V=Te;let s;t[151]===S?s=t[152]:(s=(0,_.jsx)(te,{children:(0,_.jsx)(r,{id:`RY6Bq1`,values:{targetNoun:S}})}),t[151]=S,t[152]=s);let ce=C.owner,le=C.repo,l;t[153]===C.target?l=t[154]:(l=u(C.target),t[153]=C.target,t[154]=l);let d;t[155]!==C.owner||t[156]!==C.repo||t[157]!==l?(d=(0,_.jsx)(ee,{className:`sr-only`,children:(0,_.jsx)(r,{id:`f8jU-L`,values:{0:ce,1:le,2:l}})}),t[155]=C.owner,t[156]=C.repo,t[157]=l,t[158]=d):d=t[158],t[159]!==s||t[160]!==d?(H=(0,_.jsxs)(ae,{children:[s,d]}),t[159]=s,t[160]=d,t[161]=H):H=t[161],O=re;let f=C.owner,p=C.repo,m;t[162]===C.target?m=t[163]:(m=u(C.target),t[162]=C.target,t[163]=m),t[164]!==C.branch||t[165]!==C.owner||t[166]!==C.repo||t[167]!==C.target.kind||t[168]!==m?(F=(0,_.jsx)(`div`,{className:`mb-4`,children:(0,_.jsx)(ue,{owner:f,repo:p,path:m,kind:C.target.kind,branch:C.branch,testId:`share-branch-switch-metadata`,branchTestId:`share-branch-switch-metadata-branch`})}),t[164]=C.branch,t[165]=C.owner,t[166]=C.repo,t[167]=C.target.kind,t[168]=m,t[169]=F):F=t[169],I=y.phase===`branch-in-other-worktree`?(0,_.jsxs)(`div`,{className:`text-sm text-muted-foreground`,"data-testid":`share-branch-switch-in-other-worktree`,children:[(0,_.jsx)(`p`,{className:`leading-6`,children:(0,_.jsx)(r,{id:`yjExfe`,values:{shareBranch:T},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),(0,_.jsx)(`p`,{className:`mt-2 break-all rounded bg-muted px-2 py-1 font-mono text-xs text-foreground/80`,"data-testid":`share-branch-switch-in-other-worktree-path`,children:y.otherWorktreePath})]}):y.phase===`verdict-pending`?(0,_.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-verdict-pending`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`c8jBgX`})]}):y.phase===`verdict`?y.resolution.kind===`on-origin`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,"data-testid":`share-branch-switch-verdict-on-origin`,children:(0,_.jsx)(r,{id:`Uay5NL`,values:{targetNoun:S,shareBranch:T},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):y.resolution.kind===`renamed`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,"data-testid":`share-branch-switch-verdict-renamed`,children:(0,_.jsx)(r,{id:`P0HC30`,values:{0:y.resolution.renamedTo,targetNoun:S},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):y.resolution.kind===`diverged`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,"data-testid":`share-branch-switch-verdict-diverged`,children:(0,_.jsx)(r,{id:`kLv8d3`,values:{shareBranch:T,targetNoun:S},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):(0,_.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-verdict-handoff`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`c8jBgX`})]}):ie?(0,_.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-loading`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`jerqF0`})]}):se?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,_.jsx)(r,{id:`w4hMYl`})}):G?.kind===`D`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,_.jsx)(r,{id:`DTI-fp`,values:{targetNoun:S,shareBranch:T},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):G?.kind===`B`?(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,_.jsx)(r,{id:`sZ2IOu`,values:{targetNoun:S,shareBranch:T,currentLabel:n},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):(0,_.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,_.jsx)(r,{id:`_902BE`,values:{targetNoun:S,shareBranch:T,currentLabel:n},components:{0:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,_.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),L=G&&!G.switchEnabled&&G.conflictingFiles.length>0?(0,_.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/30 p-3 text-1sm`,"data-testid":`share-branch-switch-conflict`,children:[(0,_.jsx)(`p`,{className:`font-medium text-foreground/90`,children:(0,_.jsx)(r,{id:`n2lRue`})}),(0,_.jsx)(`ul`,{id:`share-receive-branch-conflict-files`,className:`mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground`,children:G.conflictingFiles.map(we)})]}):null,t[107]=g,t[108]=y.info,t[109]=y.otherWorktreePath,t[110]=y.phase,t[111]=y.resolution,t[112]=D,t[113]=Xe,t[114]=C.branch,t[115]=C.owner,t[116]=C.repo,t[117]=C.target,t[118]=T,t[119]=S,t[120]=O,t[121]=k,t[122]=A,t[123]=j,t[124]=M,t[125]=N,t[126]=P,t[127]=F,t[128]=I,t[129]=L,t[130]=R,t[131]=z,t[132]=B,t[133]=V,t[134]=H,t[135]=U,t[136]=W,t[137]=G,t[138]=K}else O=t[120],k=t[121],A=t[122],j=t[123],M=t[124],N=t[125],P=t[126],F=t[127],I=t[128],L=t[129],R=t[130],z=t[131],B=t[132],V=t[133],H=t[134],U=t[135],W=t[136],G=t[137],K=t[138];let q;t[170]===P?q=t[171]:(q=P?(0,_.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-switching`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`CU3AiE`})]}):null,t[170]=P,t[171]=q);let J;t[172]===j?J=t[173]:(J=j?(0,_.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-creating-worktree`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,_.jsx)(r,{id:`PZtgO0`})]}):null,t[172]=j,t[173]=J);let Y;t[174]!==O||t[175]!==F||t[176]!==I||t[177]!==L||t[178]!==q||t[179]!==J?(Y=(0,_.jsxs)(O,{children:[F,I,L,q,J]}),t[174]=O,t[175]=F,t[176]=I,t[177]=L,t[178]=q,t[179]=J,t[180]=Y):Y=t[180];let _t;t[181]===Symbol.for(`react.memo_cache_sentinel`)?(_t=(0,_.jsx)(r,{id:`dEgA5A`}),t[181]=_t):_t=t[181];let X;t[182]===D?X=t[183]:(X=(0,_.jsx)(o,{variant:`ghost`,className:`font-mono uppercase`,onClick:D,"data-testid":`share-branch-switch-cancel`,children:_t}),t[182]=D,t[183]=X);let Z;t[184]!==y.phase||t[185]!==y.resolution||t[186]!==j||t[187]!==st||t[188]!==rt||t[189]!==pt||t[190]!==ht||t[191]!==at||t[192]!==$e||t[193]!==tt||t[194]!==M||t[195]!==N||t[196]!==P||t[197]!==G||t[198]!==K?(Z=y.phase===`branch-in-other-worktree`?(0,_.jsx)(o,{onClick:ht,"data-testid":`share-branch-switch-in-other-worktree-pivot`,children:(0,_.jsx)(r,{id:`hyCxJY`})}):y.phase===`verdict`?y.resolution.kind===`on-origin`?(0,_.jsxs)(o,{onClick:tt,"data-testid":`share-branch-switch-verdict-switch-update`,children:[(0,_.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),(0,_.jsx)(r,{id:`uA_jXp`})]}):y.resolution.kind===`renamed`?(0,_.jsxs)(o,{onClick:rt,"data-testid":`share-branch-switch-verdict-open-renamed`,children:[(0,_.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,_.jsx)(r,{id:`AItsE5`})]}):y.resolution.kind===`diverged`?(0,_.jsxs)(o,{onClick:at,"data-testid":`share-branch-switch-verdict-plain-switch`,children:[(0,_.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),N]}):null:(0,_.jsxs)(`div`,{className:`flex min-w-0 flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-end sm:gap-2`,children:[G?.openCurrentEnabled?(0,_.jsxs)(o,{variant:`outline`,className:`font-mono uppercase`,onClick:st,disabled:P||j,"data-testid":`share-branch-switch-open-current`,children:[(0,_.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),M]}):null,(0,_.jsx)(o,{variant:`outline`,onClick:$e,disabled:!G?.switchEnabled||P||j,"aria-disabled":!G?.switchEnabled||P||j,"aria-describedby":G&&!G.switchEnabled&&G.conflictingFiles.length>0?`share-receive-branch-conflict-files`:void 0,"data-testid":`share-branch-switch-switch`,children:P?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(c,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),N]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),N]})}),(0,_.jsx)(o,{onClick:pt,disabled:!G||P||j,"data-testid":`share-branch-switch-worktree`,children:j?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(c,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),K]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),K]})})]}),t[184]=y.phase,t[185]=y.resolution,t[186]=j,t[187]=st,t[188]=rt,t[189]=pt,t[190]=ht,t[191]=at,t[192]=$e,t[193]=tt,t[194]=M,t[195]=N,t[196]=P,t[197]=G,t[198]=K,t[199]=Z):Z=t[199];let Q;t[200]!==X||t[201]!==Z?(Q=(0,_.jsxs)(ie,{className:`sm:justify-between`,children:[X,Z]}),t[200]=X,t[201]=Z,t[202]=Q):Q=t[202];let $;t[203]!==k||t[204]!==R||t[205]!==z||t[206]!==B||t[207]!==V||t[208]!==H||t[209]!==Y||t[210]!==Q?($=(0,_.jsxs)(k,{className:R,"data-testid":z,onInteractOutside:B,onPointerDownOutside:V,children:[H,Y,Q]}),t[203]=k,t[204]=R,t[205]=z,t[206]=B,t[207]=V,t[208]=H,t[209]=Y,t[210]=Q,t[211]=$):$=t[211];let vt;return t[212]!==A||t[213]!==U||t[214]!==W||t[215]!==$?(vt=(0,_.jsx)(A,{open:U,onOpenChange:W,children:$}),t[212]=A,t[213]=U,t[214]=W,t[215]=$,t[216]=vt):vt=t[216],vt}function we(e){return(0,_.jsx)(`li`,{children:(0,_.jsx)(`code`,{className:`text-foreground/80`,children:e})},e)}function Te(e){e.preventDefault()}function Ee(e){e.preventDefault()}function De(){return f.request()}function Oe(e){return xe(e,null).state}function ke(e){return be(e,null)}function Ae(e){return he(e,null)}function je(){return null}export{v as ShareBranchSwitchDialog};
|
package/dist/public/assets/{ShareReceiveDialog-Deigdttj.js → ShareReceiveDialog-CfU4m-WF.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./button-RQ5o7P7w.js";import{a as ee,c as te,i as ne,n as re,o as s,s as c,t as l}from"./dialog-DwFomKjP.js";import{an as u,sn as d}from"./dist-DOPRKSzO2.js";import{t as ie}from"./loader-circle-B0OUuKph.js";import{n as f}from"./dist-DmEZHXvB.js";import{t as p}from"./desktop-bridge-types-BwR5S9HF.js";import{a as ae,i as m,n as h,o as g,r as oe,s as _}from"./receive-store-BCddK7iB.js";import{t as se}from"./share-metadata-rows-B1YjvGbL.js";var v=e(n(),1),y=a(),b=e=>({phase:`ready`,seed:e});function x(e){return e.phase===`ready`?{phase:`initializing`,seed:e.seed}:e}function S(e,t){return e.phase===`initializing`?t.ok?{phase:`opening`,seed:e.seed}:{phase:`error`,seed:e.seed,reason:t.reason,message:t.message}:e}function C(e,t){return e.phase===`opening`?t.ok?{phase:`done`,seed:e.seed}:{phase:`error`,seed:e.seed,reason:`network-error`,message:t.message}:e}function w(e){return e.phase===`done`||e.phase===`cancelled`||e.phase===`error`?e:{phase:`cancelled`,seed:e.seed}}var T=t();function E(e){return e!==null&&e.kind===`launcher-consent`}function D(e){return e!==null&&e.kind===`launcher-miss`}function O(e){let t=(0,y.c)(14),{bridge:n,cloneController:r,store:i}=e,a=i===void 0?h:i,o=(0,v.useSyncExternalStore)(a.subscribe,a.getSnapshot,A),[ee,te]=(0,v.useState)(0),[ne,re]=(0,v.useState)(o);o!==ne&&(re(o),te(k));let s,c;t[0]!==o||t[1]!==a?(s=()=>{if(!o)return;let e=_(o);e&&(f.error(e.message),a.dismiss())},c=[o,a],t[0]=o,t[1]=a,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,v.useEffect)(s,c);let l;t[4]===o?l=t[5]:(l=D(o)?o:null,t[4]=o,t[5]=l);let u=l,d;t[6]===o?d=t[7]:(d=E(o)?o:null,t[6]=o,t[7]=d);let ie=d??u;if(!ie)return null;let p;return t[8]!==ie||t[9]!==n||t[10]!==r||t[11]!==ee||t[12]!==a?(p=(0,T.jsx)(j,{payload:ie,bridge:n,cloneController:r,store:a},ee),t[8]=ie,t[9]=n,t[10]=r,t[11]=ee,t[12]=a,t[13]=p):p=t[13],p}function k(e){return e+1}function A(){return null}function j(e){let t=(0,y.c)(165),{payload:n,bridge:a,cloneController:h,store:_}=e,{_:x}=i(),[w,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,fe]=(0,v.useState)(!1),[N,pe]=(0,v.useState)(!1),[P,me]=(0,v.useState)(null),[F,I]=(0,v.useState)(null),he=(0,v.useRef)(!1),ge=(0,v.useRef)(null),_e,ve;t[0]===P?(_e=t[1],ve=t[2]):(_e=()=>{P&&ge.current?.focus()},ve=[P],t[0]=P,t[1]=_e,t[2]=ve),(0,v.useEffect)(_e,ve);let ye;t[3]!==F||t[4]!==n?(ye=()=>{E(n)&&F===null&&(console.warn(`[receive] q1_hit=true selection=branch_match_non_ok candidate=${n.candidatePath}`),I(b({candidatePath:n.candidatePath,branch:n.share.branch,targetPath:p(n.share.target),targetKind:n.share.target.kind,parentProjectName:n.parentProjectName})))},t[3]=F,t[4]=n,t[5]=ye):ye=t[5];let be;t[6]===n?be=t[7]:(be=[n],t[6]=n,t[7]=be),(0,v.useEffect)(ye,be);let xe;t[8]!==k||t[9]!==h||t[10]!==n?(xe=()=>{if(!h||!D(n)||k!==null||he.current)return;he.current=!0,fe(!0);let e=n.share.host;h.getAuthStatus(e).then(e=>{A(e)}).catch(t=>{console.warn(`[receive] auth pre-flight probe failed`,t instanceof Error?t.message:t),A({authenticated:!1,host:e})}).finally(()=>{fe(!1)})},t[8]=k,t[9]=h,t[10]=n,t[11]=xe):xe=t[11];let Se;t[12]!==k||t[13]!==n?(Se=[n,k],t[12]=k,t[13]=n,t[14]=Se):Se=t[14],(0,v.useEffect)(xe,Se);let L=D(n)?n:null,Ce=E(n)?n:null,R=L?.share??Ce?.share??null,z,B,V,H,U,we,W,G;if(t[15]!==x||t[16]!==j||t[17]!==a||t[18]!==h||t[19]!==N||t[20]!==F||t[21]!==L||t[22]!==w||t[23]!==R||t[24]!==_){W=Symbol.for(`react.early_return_sentinel`);bb0:{let e=R?{host:R.host,owner:R.owner,repo:R.repo}:null,n;t[33]!==x||t[34]!==R?.target.kind?(n=R?.target.kind===`folder`?x({id:`ugoTXs`}):x({id:`XH30C4`}),t[33]=x,t[34]=R?.target.kind,t[35]=n):n=t[35],G=n,V=async function(){if(!L||!e)return;if(console.log(ae({q2_path:`clone`})),!h){f.info(x({id:`27XW26`}),{action:{label:x({id:`B3NAZC`}),onClick:()=>{a.navigator.open()}},duration:8e3});return}if(N)return;me(null),pe(!0);let t=oe(e),n;try{n=await h.runClone({url:t,branch:L.share.branch})}catch(e){let t=e;console.warn(`[receive] runClone threw unexpectedly`,t),pe(!1),me({detail:t instanceof Error?t.message:String(t)});return}if(pe(!1),n.kind===`error`){me({detail:n.detail??null});return}if(n.kind===`ok`){try{await a.project.open({path:n.dir,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:L.share.target.kind,path:p(L.share.target)}}),_.dismiss()}catch(e){let t=e;console.warn(`[receive] project open after clone failed`,t instanceof Error?t.message:t),f.error(x({id:`438Fca`}))}return}};let i;t[36]!==x||t[37]!==j||t[38]!==h?(i=async function(){if(!(!h||j)){fe(!0);try{let e=await h.startSignIn();fe(!1),e!==null&&A(e)}catch(e){let t=e;fe(!1),console.warn(`[receive] startSignIn failed`,t instanceof Error?t.message:t),f.error(x({id:`lzwo7p`}))}}},t[36]=x,t[37]=j,t[38]=h,t[39]=i):i=t[39],U=i,H=async function(){if(!(!L||!e||w)){me(null),O(!0),console.log(ae({q2_path:`local`}));try{for(;;){let t=await a.dialog.openFolder();if(!t)break;let n=await a.share.validateLocalFolder({folderPath:t,host:e.host,owner:e.owner,repo:e.repo});if(console.log(ae({folder_validate:n.kind})),n.kind===`ok`){let e=L.share.branch,n={currentBranch:null,headSha:null,detached:!1};try{n=await a.project.readHeadBranch(t)}catch(e){let t=e;console.warn(`[receive] local-folder readHeadBranch failed`,t instanceof Error?t.message:t)}let r=d(e,n)!==`true`;try{await a.project.open({path:t,target:`new-window`,entryPoint:`share-receive`,...r?{pendingShareBranchSwitch:{share:L.share,projectPath:t,currentBranch:n.currentBranch}}:{pendingDeepLinkTarget:{kind:L.share.target.kind,path:p(L.share.target)}}}),_.dismiss()}catch(e){let t=e;console.warn(`[receive] local-folder-open failed`,t instanceof Error?t.message:t),f.error(x({id:`phM8Kh`}))}break}let r=g(n,e);r&&f.error(r)}}catch(e){let t=e;console.warn(`[receive] local-folder-validate failed`,t instanceof Error?t.message:t),f.error(x({id:`rlUzXK`}))}O(!1)}};let m;t[40]!==x||t[41]!==a||t[42]!==F||t[43]!==_?(m=function(){if(F===null||F.phase!==`ready`)return;let e=F.seed;console.warn(`[receive] consent_dialog action=initialize worktree=${e.candidatePath}`),I(de),a.project.okInit({projectPath:e.candidatePath}).then(async t=>{if(t.ok===!0){I(e=>e===null?e:S(e,{ok:!0,projectPath:t.projectPath}));try{await a.project.open({path:t.projectPath,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:e.targetKind,path:e.targetPath},pendingBranch:e.branch}),I(ue),_.dismiss()}catch(t){let n=t,r=n instanceof Error?n.message:String(n);I(e=>e===null?e:C(e,{ok:!1,message:r})),f.error(x({id:`nDT8qt`,values:{0:e.candidatePath}}))}return}let n=t.reason,r=t.message||`Initialization failed.`;I(e=>e===null?e:S(e,{ok:!1,reason:n,message:r})),f.error(r)}).catch(t=>{let n=t instanceof Error?t.message:String(t);I(e=>e===null?e:S(e,{ok:!1,reason:`network-error`,message:n})),f.error(x({id:`3Mwaly`,values:{0:e.candidatePath}}))})},t[40]=x,t[41]=a,t[42]=F,t[43]=_,t[44]=m):m=t[44];let v=m,y;t[45]!==F||t[46]!==_?(y=function(){F!==null&&console.warn(`[receive] consent_dialog action=cancel worktree=${F.seed.candidatePath}`),I(M),_.dismiss()},t[45]=F,t[46]=_,t[47]=y):y=t[47];let b=y;if(F!==null&&F.phase!==`cancelled`&&F.phase!==`done`&&R!==null){let e=F.seed,n=F.phase===`initializing`||F.phase===`opening`,i;t[48]===b?i=t[49]:(i=e=>{e||b()},t[48]=b,t[49]=i);let a;t[50]===G?a=t[51]:(a=(0,T.jsx)(te,{children:(0,T.jsx)(r,{id:`RY6Bq1`,values:{targetNoun:G}})}),t[50]=G,t[51]=a);let u;t[52]===R.target?u=t[53]:(u=p(R.target)?`— ${p(R.target)}`:``,t[52]=R.target,t[53]=u);let d;t[54]!==R.owner||t[55]!==R.repo||t[56]!==u?(d=(0,T.jsx)(ee,{className:`sr-only`,children:(0,T.jsx)(r,{id:`pgq_xf`,values:{0:R.owner,1:R.repo,2:u}})}),t[54]=R.owner,t[55]=R.repo,t[56]=u,t[57]=d):d=t[57];let f=R.owner,ae=R.repo,m;t[58]===R.target?m=t[59]:(m=p(R.target),t[58]=R.target,t[59]=m);let h;t[60]!==R.branch||t[61]!==R.owner||t[62]!==R.repo||t[63]!==R.target.kind||t[64]!==m?(h=(0,T.jsx)(se,{owner:f,repo:ae,path:m,kind:R.target.kind,branch:R.branch,testId:`share-receive-metadata`,branchTestId:`share-receive-metadata-branch`}),t[60]=R.branch,t[61]=R.owner,t[62]=R.repo,t[63]=R.target.kind,t[64]=m,t[65]=h):h=t[65];let g;t[66]!==a||t[67]!==d||t[68]!==h?(g=(0,T.jsxs)(c,{children:[a,d,h]}),t[66]=a,t[67]=d,t[68]=h,t[69]=g):g=t[69];let oe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`KsAPaB`})}),t[70]=oe):oe=t[70];let _;t[71]===e.candidatePath?_=t[72]:(_=(0,T.jsx)(`p`,{className:`mt-2 break-all rounded bg-muted px-2 py-1 font-mono text-xs text-foreground/80`,"data-testid":`share-receive-consent-path`,children:e.candidatePath}),t[71]=e.candidatePath,t[72]=_);let y;t[73]===e.parentProjectName?y=t[74]:(y=e.parentProjectName===null?null:(0,T.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,"data-testid":`share-receive-consent-parent`,children:(0,T.jsx)(r,{id:`JmfgFc`,values:{0:e.parentProjectName}})}),t[73]=e.parentProjectName,t[74]=y);let x;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,T.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`w7SsvI`})}),t[75]=x):x=t[75];let S;t[76]!==F.message||t[77]!==F.phase?(S=F.phase===`error`?(0,T.jsx)(`p`,{className:`mt-3 text-sm text-destructive`,"data-testid":`share-receive-consent-error`,role:`alert`,children:F.message}):null,t[76]=F.message,t[77]=F.phase,t[78]=S):S=t[78];let C;t[79]!==_||t[80]!==y||t[81]!==S?(C=(0,T.jsxs)(re,{children:[oe,_,y,x,S]}),t[79]=_,t[80]=y,t[81]=S,t[82]=C):C=t[82];let w;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,T.jsx)(r,{id:`dEgA5A`}),t[83]=w):w=t[83];let E;t[84]===b?E=t[85]:(E=(0,T.jsx)(o,{variant:`ghost`,onClick:b,"data-testid":`share-receive-consent-cancel`,children:w}),t[84]=b,t[85]=E);let D=n||F.phase===`error`,O=n||F.phase===`error`,k;t[86]===n?k=t[87]:(k=n?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ie,{className:`mr-2 h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,T.jsx)(r,{id:`NKkZXl`})]}):(0,T.jsx)(r,{id:`NKkZXl`}),t[86]=n,t[87]=k);let A;t[88]!==v||t[89]!==D||t[90]!==O||t[91]!==k?(A=(0,T.jsx)(o,{onClick:v,disabled:D,"aria-disabled":O,"data-testid":`share-receive-consent-initialize`,children:k}),t[88]=v,t[89]=D,t[90]=O,t[91]=k,t[92]=A):A=t[92];let j;t[93]!==E||t[94]!==A?(j=(0,T.jsxs)(s,{children:[E,A]}),t[93]=E,t[94]=A,t[95]=j):j=t[95];let M;t[96]!==g||t[97]!==C||t[98]!==j?(M=(0,T.jsxs)(ne,{className:`sm:max-w-xl`,"data-testid":`share-receive-consent-dialog`,onInteractOutside:le,onPointerDownOutside:ce,children:[g,C,j]}),t[96]=g,t[97]=C,t[98]=j,t[99]=M):M=t[99];let ue;t[100]!==i||t[101]!==M?(ue=(0,T.jsx)(l,{open:!0,onOpenChange:i,children:M}),t[100]=i,t[101]=M,t[102]=ue):ue=t[102],W=ue;break bb0}if(!L||!R||!e){W=null;break bb0}z=h!==void 0&&!N;let E;t[103]!==x||t[104]!==N?(E=x(N?{id:`YjhKI5`}:{id:`LE7t79`}),t[103]=x,t[104]=N,t[105]=E):E=t[105],B=E,we=u(e)}t[15]=x,t[16]=j,t[17]=a,t[18]=h,t[19]=N,t[20]=F,t[21]=L,t[22]=w,t[23]=R,t[24]=_,t[25]=z,t[26]=B,t[27]=V,t[28]=H,t[29]=U,t[30]=we,t[31]=W,t[32]=G}else z=t[25],B=t[26],V=t[27],H=t[28],U=t[29],we=t[30],W=t[31],G=t[32];if(W!==Symbol.for(`react.early_return_sentinel`))return W;let Te=we,Ee=k?.authenticated?k.login:void 0,De;t[106]===P?De=t[107]:(De=P?.detail?m(P.detail):``,t[106]=P,t[107]=De);let Oe=De,K;t[108]===_?K=t[109]:(K=e=>{e||_.dismiss()},t[108]=_,t[109]=K);let q;t[110]===G?q=t[111]:(q=(0,T.jsx)(te,{children:(0,T.jsx)(r,{id:`RY6Bq1`,values:{targetNoun:G}})}),t[110]=G,t[111]=q);let J;t[112]===R.target?J=t[113]:(J=p(R.target)?` — ${p(R.target)}`:null,t[112]=R.target,t[113]=J);let Y;t[114]!==R.owner||t[115]!==R.repo||t[116]!==J?(Y=(0,T.jsxs)(ee,{className:`sr-only`,children:[R.owner,`/`,R.repo,J]}),t[114]=R.owner,t[115]=R.repo,t[116]=J,t[117]=Y):Y=t[117];let ke=R.owner,Ae=R.repo,X;t[118]===R.target?X=t[119]:(X=p(R.target),t[118]=R.target,t[119]=X);let Z;t[120]!==R.branch||t[121]!==R.owner||t[122]!==R.repo||t[123]!==R.target.kind||t[124]!==X?(Z=(0,T.jsx)(se,{owner:ke,repo:Ae,path:X,kind:R.target.kind,branch:R.branch,testId:`share-receive-metadata`,branchTestId:`share-receive-metadata-branch`}),t[120]=R.branch,t[121]=R.owner,t[122]=R.repo,t[123]=R.target.kind,t[124]=X,t[125]=Z):Z=t[125];let Q;t[126]!==q||t[127]!==Y||t[128]!==Z?(Q=(0,T.jsxs)(c,{children:[q,Y,Z]}),t[126]=q,t[127]=Y,t[128]=Z,t[129]=Q):Q=t[129];let $;t[130]!==h||t[131]!==z||t[132]!==P||t[133]!==Oe||t[134]!==B||t[135]!==N||t[136]!==V||t[137]!==H||t[138]!==w?($=P?(0,T.jsxs)(`div`,{ref:ge,tabIndex:-1,className:`rounded-lg border border-destructive/40 bg-destructive/5 p-4 outline-none`,"data-testid":`share-receive-clone-error`,children:[(0,T.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,role:`alert`,children:(0,T.jsx)(r,{id:`aiArms`})}),Oe?(0,T.jsxs)(`p`,{className:`mt-2 break-words text-xs text-destructive`,"data-testid":`share-receive-clone-error-message`,children:[(0,T.jsx)(r,{id:`4BITzH`}),` `,(0,T.jsxs)(`span`,{className:`font-mono text-foreground/80`,children:[`"`,Oe,`"`]})]}):null,(0,T.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`Llyqvo`})}),(0,T.jsxs)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5 text-sm text-muted-foreground`,"data-testid":`share-receive-clone-error-reasons`,children:[(0,T.jsx)(`li`,{children:(0,T.jsx)(r,{id:`6LbUG7`})}),(0,T.jsx)(`li`,{children:(0,T.jsx)(r,{id:`_pY_Vq`})}),(0,T.jsx)(`li`,{children:(0,T.jsx)(r,{id:`J6mxC1`})})]}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,T.jsx)(o,{onClick:()=>{V()},"data-testid":`share-receive-clone-retry`,children:(0,T.jsx)(r,{id:`KDw4GX`})}),(0,T.jsx)(o,{variant:`outline`,onClick:()=>{H()},disabled:w||N,"data-testid":`share-receive-error-local`,children:(0,T.jsx)(r,{id:`xFQRu4`})})]})]}):(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,T.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-clone`,className:`flex flex-col items-start gap-2 rounded-lg border border-primary/50 bg-primary/5 p-4 text-left transition hover:border-primary hover:bg-primary/10 focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-primary/50 disabled:hover:bg-primary/5`,onClick:()=>{V()},disabled:h!==void 0&&!z,"aria-disabled":h!==void 0&&!z,children:[(0,T.jsx)(`span`,{className:`text-sm font-semibold`,children:B}),(0,T.jsx)(`span`,{className:`line-clamp-2 text-1sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`fj5YiP`})})]}),(0,T.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-local`,className:`flex flex-col items-start gap-2 rounded-lg border border-border bg-card p-4 text-left transition hover:border-foreground/50 hover:bg-accent focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,onClick:()=>{H()},disabled:w||N,children:[(0,T.jsx)(`span`,{className:`text-sm font-semibold`,children:(0,T.jsx)(r,{id:`HfI1dR`})}),(0,T.jsx)(`span`,{className:`line-clamp-2 text-1sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`_qD6mn`})})]})]}),t[130]=h,t[131]=z,t[132]=P,t[133]=Oe,t[134]=B,t[135]=N,t[136]=V,t[137]=H,t[138]=w,t[139]=$):$=t[139];let je;t[140]!==j||t[141]!==k||t[142]!==h||t[143]!==U||t[144]!==Ee?(je=h?(0,T.jsx)(`div`,{className:`mt-3 flex items-center justify-between rounded-md border border-border bg-muted/30 px-3 py-2 text-xs`,"data-testid":`share-receive-auth-banner`,role:`status`,"aria-live":`polite`,children:k===null?(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:(0,T.jsx)(r,{id:`UDFrWm`})}):k.authenticated?(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:(0,T.jsx)(r,{id:`VAHWL_`,values:{signedInLogin:Ee},components:{0:(0,T.jsx)(`span`,{className:`font-medium text-foreground/90`})}})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:(0,T.jsx)(r,{id:`SgKLfA`})}),(0,T.jsx)(`button`,{type:`button`,"data-testid":`share-receive-signin`,className:`font-medium text-primary underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,onClick:()=>{U()},disabled:j,children:j?(0,T.jsx)(r,{id:`PKLY-1`}):(0,T.jsx)(r,{id:`3jod3l`})})]})}):null,t[140]=j,t[141]=k,t[142]=h,t[143]=U,t[144]=Ee,t[145]=je):je=t[145];let Me;t[146]!==P||t[147]!==Te?(Me=P?null:(0,T.jsx)(`p`,{className:`mt-3 text-1sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`RJ3a8Z`,values:{lookingForUrl:Te},components:{0:(0,T.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),t[146]=P,t[147]=Te,t[148]=Me):Me=t[148];let Ne;t[149]!==$||t[150]!==je||t[151]!==Me?(Ne=(0,T.jsxs)(re,{children:[$,je,Me]}),t[149]=$,t[150]=je,t[151]=Me,t[152]=Ne):Ne=t[152];let Pe;t[153]===_?Pe=t[154]:(Pe=()=>_.dismiss(),t[153]=_,t[154]=Pe);let Fe;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,T.jsx)(r,{id:`dEgA5A`}),t[155]=Fe):Fe=t[155];let Ie;t[156]===Pe?Ie=t[157]:(Ie=(0,T.jsx)(s,{children:(0,T.jsx)(o,{variant:`outline`,className:`font-mono uppercase`,onClick:Pe,children:Fe})}),t[156]=Pe,t[157]=Ie);let Le;t[158]!==Q||t[159]!==Ne||t[160]!==Ie?(Le=(0,T.jsxs)(ne,{className:`sm:max-w-xl`,"data-testid":`share-receive-dialog`,children:[Q,Ne,Ie]}),t[158]=Q,t[159]=Ne,t[160]=Ie,t[161]=Le):Le=t[161];let Re;return t[162]!==K||t[163]!==Le?(Re=(0,T.jsx)(l,{open:!0,onOpenChange:K,children:Le}),t[162]=K,t[163]=Le,t[164]=Re):Re=t[164],Re}function ce(e){return e.preventDefault()}function le(e){return e.preventDefault()}function M(e){return e===null?e:w(e)}function ue(e){return e===null?e:C(e,{ok:!0})}function de(e){return e===null?e:x(e)}export{O as ShareReceiveDialog};
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./button-RQ5o7P7w.js";import{a as ee,c as te,i as ne,n as re,o as s,s as c,t as l}from"./dialog-DwFomKjP.js";import{an as u,sn as d}from"./dist-CW-WKphO2.js";import{t as ie}from"./loader-circle-B0OUuKph.js";import{n as f}from"./dist-DmEZHXvB.js";import{t as p}from"./desktop-bridge-types-BwR5S9HF.js";import{a as ae,i as m,n as h,o as g,r as oe,s as _}from"./receive-store-2bhS8vt2.js";import{t as se}from"./share-metadata-rows-B1YjvGbL.js";var v=e(n(),1),y=a(),b=e=>({phase:`ready`,seed:e});function x(e){return e.phase===`ready`?{phase:`initializing`,seed:e.seed}:e}function S(e,t){return e.phase===`initializing`?t.ok?{phase:`opening`,seed:e.seed}:{phase:`error`,seed:e.seed,reason:t.reason,message:t.message}:e}function C(e,t){return e.phase===`opening`?t.ok?{phase:`done`,seed:e.seed}:{phase:`error`,seed:e.seed,reason:`network-error`,message:t.message}:e}function w(e){return e.phase===`done`||e.phase===`cancelled`||e.phase===`error`?e:{phase:`cancelled`,seed:e.seed}}var T=t();function E(e){return e!==null&&e.kind===`launcher-consent`}function D(e){return e!==null&&e.kind===`launcher-miss`}function O(e){let t=(0,y.c)(14),{bridge:n,cloneController:r,store:i}=e,a=i===void 0?h:i,o=(0,v.useSyncExternalStore)(a.subscribe,a.getSnapshot,A),[ee,te]=(0,v.useState)(0),[ne,re]=(0,v.useState)(o);o!==ne&&(re(o),te(k));let s,c;t[0]!==o||t[1]!==a?(s=()=>{if(!o)return;let e=_(o);e&&(f.error(e.message),a.dismiss())},c=[o,a],t[0]=o,t[1]=a,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,v.useEffect)(s,c);let l;t[4]===o?l=t[5]:(l=D(o)?o:null,t[4]=o,t[5]=l);let u=l,d;t[6]===o?d=t[7]:(d=E(o)?o:null,t[6]=o,t[7]=d);let ie=d??u;if(!ie)return null;let p;return t[8]!==ie||t[9]!==n||t[10]!==r||t[11]!==ee||t[12]!==a?(p=(0,T.jsx)(j,{payload:ie,bridge:n,cloneController:r,store:a},ee),t[8]=ie,t[9]=n,t[10]=r,t[11]=ee,t[12]=a,t[13]=p):p=t[13],p}function k(e){return e+1}function A(){return null}function j(e){let t=(0,y.c)(165),{payload:n,bridge:a,cloneController:h,store:_}=e,{_:x}=i(),[w,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,fe]=(0,v.useState)(!1),[N,pe]=(0,v.useState)(!1),[P,me]=(0,v.useState)(null),[F,I]=(0,v.useState)(null),he=(0,v.useRef)(!1),ge=(0,v.useRef)(null),_e,ve;t[0]===P?(_e=t[1],ve=t[2]):(_e=()=>{P&&ge.current?.focus()},ve=[P],t[0]=P,t[1]=_e,t[2]=ve),(0,v.useEffect)(_e,ve);let ye;t[3]!==F||t[4]!==n?(ye=()=>{E(n)&&F===null&&(console.warn(`[receive] q1_hit=true selection=branch_match_non_ok candidate=${n.candidatePath}`),I(b({candidatePath:n.candidatePath,branch:n.share.branch,targetPath:p(n.share.target),targetKind:n.share.target.kind,parentProjectName:n.parentProjectName})))},t[3]=F,t[4]=n,t[5]=ye):ye=t[5];let be;t[6]===n?be=t[7]:(be=[n],t[6]=n,t[7]=be),(0,v.useEffect)(ye,be);let xe;t[8]!==k||t[9]!==h||t[10]!==n?(xe=()=>{if(!h||!D(n)||k!==null||he.current)return;he.current=!0,fe(!0);let e=n.share.host;h.getAuthStatus(e).then(e=>{A(e)}).catch(t=>{console.warn(`[receive] auth pre-flight probe failed`,t instanceof Error?t.message:t),A({authenticated:!1,host:e})}).finally(()=>{fe(!1)})},t[8]=k,t[9]=h,t[10]=n,t[11]=xe):xe=t[11];let Se;t[12]!==k||t[13]!==n?(Se=[n,k],t[12]=k,t[13]=n,t[14]=Se):Se=t[14],(0,v.useEffect)(xe,Se);let L=D(n)?n:null,Ce=E(n)?n:null,R=L?.share??Ce?.share??null,z,B,V,H,U,we,W,G;if(t[15]!==x||t[16]!==j||t[17]!==a||t[18]!==h||t[19]!==N||t[20]!==F||t[21]!==L||t[22]!==w||t[23]!==R||t[24]!==_){W=Symbol.for(`react.early_return_sentinel`);bb0:{let e=R?{host:R.host,owner:R.owner,repo:R.repo}:null,n;t[33]!==x||t[34]!==R?.target.kind?(n=R?.target.kind===`folder`?x({id:`ugoTXs`}):x({id:`XH30C4`}),t[33]=x,t[34]=R?.target.kind,t[35]=n):n=t[35],G=n,V=async function(){if(!L||!e)return;if(console.log(ae({q2_path:`clone`})),!h){f.info(x({id:`27XW26`}),{action:{label:x({id:`B3NAZC`}),onClick:()=>{a.navigator.open()}},duration:8e3});return}if(N)return;me(null),pe(!0);let t=oe(e),n;try{n=await h.runClone({url:t,branch:L.share.branch})}catch(e){let t=e;console.warn(`[receive] runClone threw unexpectedly`,t),pe(!1),me({detail:t instanceof Error?t.message:String(t)});return}if(pe(!1),n.kind===`error`){me({detail:n.detail??null});return}if(n.kind===`ok`){try{await a.project.open({path:n.dir,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:L.share.target.kind,path:p(L.share.target)}}),_.dismiss()}catch(e){let t=e;console.warn(`[receive] project open after clone failed`,t instanceof Error?t.message:t),f.error(x({id:`438Fca`}))}return}};let i;t[36]!==x||t[37]!==j||t[38]!==h?(i=async function(){if(!(!h||j)){fe(!0);try{let e=await h.startSignIn();fe(!1),e!==null&&A(e)}catch(e){let t=e;fe(!1),console.warn(`[receive] startSignIn failed`,t instanceof Error?t.message:t),f.error(x({id:`lzwo7p`}))}}},t[36]=x,t[37]=j,t[38]=h,t[39]=i):i=t[39],U=i,H=async function(){if(!(!L||!e||w)){me(null),O(!0),console.log(ae({q2_path:`local`}));try{for(;;){let t=await a.dialog.openFolder();if(!t)break;let n=await a.share.validateLocalFolder({folderPath:t,host:e.host,owner:e.owner,repo:e.repo});if(console.log(ae({folder_validate:n.kind})),n.kind===`ok`){let e=L.share.branch,n={currentBranch:null,headSha:null,detached:!1};try{n=await a.project.readHeadBranch(t)}catch(e){let t=e;console.warn(`[receive] local-folder readHeadBranch failed`,t instanceof Error?t.message:t)}let r=d(e,n)!==`true`;try{await a.project.open({path:t,target:`new-window`,entryPoint:`share-receive`,...r?{pendingShareBranchSwitch:{share:L.share,projectPath:t,currentBranch:n.currentBranch}}:{pendingDeepLinkTarget:{kind:L.share.target.kind,path:p(L.share.target)}}}),_.dismiss()}catch(e){let t=e;console.warn(`[receive] local-folder-open failed`,t instanceof Error?t.message:t),f.error(x({id:`phM8Kh`}))}break}let r=g(n,e);r&&f.error(r)}}catch(e){let t=e;console.warn(`[receive] local-folder-validate failed`,t instanceof Error?t.message:t),f.error(x({id:`rlUzXK`}))}O(!1)}};let m;t[40]!==x||t[41]!==a||t[42]!==F||t[43]!==_?(m=function(){if(F===null||F.phase!==`ready`)return;let e=F.seed;console.warn(`[receive] consent_dialog action=initialize worktree=${e.candidatePath}`),I(de),a.project.okInit({projectPath:e.candidatePath}).then(async t=>{if(t.ok===!0){I(e=>e===null?e:S(e,{ok:!0,projectPath:t.projectPath}));try{await a.project.open({path:t.projectPath,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:e.targetKind,path:e.targetPath},pendingBranch:e.branch}),I(ue),_.dismiss()}catch(t){let n=t,r=n instanceof Error?n.message:String(n);I(e=>e===null?e:C(e,{ok:!1,message:r})),f.error(x({id:`nDT8qt`,values:{0:e.candidatePath}}))}return}let n=t.reason,r=t.message||`Initialization failed.`;I(e=>e===null?e:S(e,{ok:!1,reason:n,message:r})),f.error(r)}).catch(t=>{let n=t instanceof Error?t.message:String(t);I(e=>e===null?e:S(e,{ok:!1,reason:`network-error`,message:n})),f.error(x({id:`3Mwaly`,values:{0:e.candidatePath}}))})},t[40]=x,t[41]=a,t[42]=F,t[43]=_,t[44]=m):m=t[44];let v=m,y;t[45]!==F||t[46]!==_?(y=function(){F!==null&&console.warn(`[receive] consent_dialog action=cancel worktree=${F.seed.candidatePath}`),I(M),_.dismiss()},t[45]=F,t[46]=_,t[47]=y):y=t[47];let b=y;if(F!==null&&F.phase!==`cancelled`&&F.phase!==`done`&&R!==null){let e=F.seed,n=F.phase===`initializing`||F.phase===`opening`,i;t[48]===b?i=t[49]:(i=e=>{e||b()},t[48]=b,t[49]=i);let a;t[50]===G?a=t[51]:(a=(0,T.jsx)(te,{children:(0,T.jsx)(r,{id:`RY6Bq1`,values:{targetNoun:G}})}),t[50]=G,t[51]=a);let u;t[52]===R.target?u=t[53]:(u=p(R.target)?`— ${p(R.target)}`:``,t[52]=R.target,t[53]=u);let d;t[54]!==R.owner||t[55]!==R.repo||t[56]!==u?(d=(0,T.jsx)(ee,{className:`sr-only`,children:(0,T.jsx)(r,{id:`pgq_xf`,values:{0:R.owner,1:R.repo,2:u}})}),t[54]=R.owner,t[55]=R.repo,t[56]=u,t[57]=d):d=t[57];let f=R.owner,ae=R.repo,m;t[58]===R.target?m=t[59]:(m=p(R.target),t[58]=R.target,t[59]=m);let h;t[60]!==R.branch||t[61]!==R.owner||t[62]!==R.repo||t[63]!==R.target.kind||t[64]!==m?(h=(0,T.jsx)(se,{owner:f,repo:ae,path:m,kind:R.target.kind,branch:R.branch,testId:`share-receive-metadata`,branchTestId:`share-receive-metadata-branch`}),t[60]=R.branch,t[61]=R.owner,t[62]=R.repo,t[63]=R.target.kind,t[64]=m,t[65]=h):h=t[65];let g;t[66]!==a||t[67]!==d||t[68]!==h?(g=(0,T.jsxs)(c,{children:[a,d,h]}),t[66]=a,t[67]=d,t[68]=h,t[69]=g):g=t[69];let oe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`KsAPaB`})}),t[70]=oe):oe=t[70];let _;t[71]===e.candidatePath?_=t[72]:(_=(0,T.jsx)(`p`,{className:`mt-2 break-all rounded bg-muted px-2 py-1 font-mono text-xs text-foreground/80`,"data-testid":`share-receive-consent-path`,children:e.candidatePath}),t[71]=e.candidatePath,t[72]=_);let y;t[73]===e.parentProjectName?y=t[74]:(y=e.parentProjectName===null?null:(0,T.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,"data-testid":`share-receive-consent-parent`,children:(0,T.jsx)(r,{id:`JmfgFc`,values:{0:e.parentProjectName}})}),t[73]=e.parentProjectName,t[74]=y);let x;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,T.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`w7SsvI`})}),t[75]=x):x=t[75];let S;t[76]!==F.message||t[77]!==F.phase?(S=F.phase===`error`?(0,T.jsx)(`p`,{className:`mt-3 text-sm text-destructive`,"data-testid":`share-receive-consent-error`,role:`alert`,children:F.message}):null,t[76]=F.message,t[77]=F.phase,t[78]=S):S=t[78];let C;t[79]!==_||t[80]!==y||t[81]!==S?(C=(0,T.jsxs)(re,{children:[oe,_,y,x,S]}),t[79]=_,t[80]=y,t[81]=S,t[82]=C):C=t[82];let w;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,T.jsx)(r,{id:`dEgA5A`}),t[83]=w):w=t[83];let E;t[84]===b?E=t[85]:(E=(0,T.jsx)(o,{variant:`ghost`,onClick:b,"data-testid":`share-receive-consent-cancel`,children:w}),t[84]=b,t[85]=E);let D=n||F.phase===`error`,O=n||F.phase===`error`,k;t[86]===n?k=t[87]:(k=n?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ie,{className:`mr-2 h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,T.jsx)(r,{id:`NKkZXl`})]}):(0,T.jsx)(r,{id:`NKkZXl`}),t[86]=n,t[87]=k);let A;t[88]!==v||t[89]!==D||t[90]!==O||t[91]!==k?(A=(0,T.jsx)(o,{onClick:v,disabled:D,"aria-disabled":O,"data-testid":`share-receive-consent-initialize`,children:k}),t[88]=v,t[89]=D,t[90]=O,t[91]=k,t[92]=A):A=t[92];let j;t[93]!==E||t[94]!==A?(j=(0,T.jsxs)(s,{children:[E,A]}),t[93]=E,t[94]=A,t[95]=j):j=t[95];let M;t[96]!==g||t[97]!==C||t[98]!==j?(M=(0,T.jsxs)(ne,{className:`sm:max-w-xl`,"data-testid":`share-receive-consent-dialog`,onInteractOutside:le,onPointerDownOutside:ce,children:[g,C,j]}),t[96]=g,t[97]=C,t[98]=j,t[99]=M):M=t[99];let ue;t[100]!==i||t[101]!==M?(ue=(0,T.jsx)(l,{open:!0,onOpenChange:i,children:M}),t[100]=i,t[101]=M,t[102]=ue):ue=t[102],W=ue;break bb0}if(!L||!R||!e){W=null;break bb0}z=h!==void 0&&!N;let E;t[103]!==x||t[104]!==N?(E=x(N?{id:`YjhKI5`}:{id:`LE7t79`}),t[103]=x,t[104]=N,t[105]=E):E=t[105],B=E,we=u(e)}t[15]=x,t[16]=j,t[17]=a,t[18]=h,t[19]=N,t[20]=F,t[21]=L,t[22]=w,t[23]=R,t[24]=_,t[25]=z,t[26]=B,t[27]=V,t[28]=H,t[29]=U,t[30]=we,t[31]=W,t[32]=G}else z=t[25],B=t[26],V=t[27],H=t[28],U=t[29],we=t[30],W=t[31],G=t[32];if(W!==Symbol.for(`react.early_return_sentinel`))return W;let Te=we,Ee=k?.authenticated?k.login:void 0,De;t[106]===P?De=t[107]:(De=P?.detail?m(P.detail):``,t[106]=P,t[107]=De);let Oe=De,K;t[108]===_?K=t[109]:(K=e=>{e||_.dismiss()},t[108]=_,t[109]=K);let q;t[110]===G?q=t[111]:(q=(0,T.jsx)(te,{children:(0,T.jsx)(r,{id:`RY6Bq1`,values:{targetNoun:G}})}),t[110]=G,t[111]=q);let J;t[112]===R.target?J=t[113]:(J=p(R.target)?` — ${p(R.target)}`:null,t[112]=R.target,t[113]=J);let Y;t[114]!==R.owner||t[115]!==R.repo||t[116]!==J?(Y=(0,T.jsxs)(ee,{className:`sr-only`,children:[R.owner,`/`,R.repo,J]}),t[114]=R.owner,t[115]=R.repo,t[116]=J,t[117]=Y):Y=t[117];let ke=R.owner,Ae=R.repo,X;t[118]===R.target?X=t[119]:(X=p(R.target),t[118]=R.target,t[119]=X);let Z;t[120]!==R.branch||t[121]!==R.owner||t[122]!==R.repo||t[123]!==R.target.kind||t[124]!==X?(Z=(0,T.jsx)(se,{owner:ke,repo:Ae,path:X,kind:R.target.kind,branch:R.branch,testId:`share-receive-metadata`,branchTestId:`share-receive-metadata-branch`}),t[120]=R.branch,t[121]=R.owner,t[122]=R.repo,t[123]=R.target.kind,t[124]=X,t[125]=Z):Z=t[125];let Q;t[126]!==q||t[127]!==Y||t[128]!==Z?(Q=(0,T.jsxs)(c,{children:[q,Y,Z]}),t[126]=q,t[127]=Y,t[128]=Z,t[129]=Q):Q=t[129];let $;t[130]!==h||t[131]!==z||t[132]!==P||t[133]!==Oe||t[134]!==B||t[135]!==N||t[136]!==V||t[137]!==H||t[138]!==w?($=P?(0,T.jsxs)(`div`,{ref:ge,tabIndex:-1,className:`rounded-lg border border-destructive/40 bg-destructive/5 p-4 outline-none`,"data-testid":`share-receive-clone-error`,children:[(0,T.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,role:`alert`,children:(0,T.jsx)(r,{id:`aiArms`})}),Oe?(0,T.jsxs)(`p`,{className:`mt-2 break-words text-xs text-destructive`,"data-testid":`share-receive-clone-error-message`,children:[(0,T.jsx)(r,{id:`4BITzH`}),` `,(0,T.jsxs)(`span`,{className:`font-mono text-foreground/80`,children:[`"`,Oe,`"`]})]}):null,(0,T.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`Llyqvo`})}),(0,T.jsxs)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5 text-sm text-muted-foreground`,"data-testid":`share-receive-clone-error-reasons`,children:[(0,T.jsx)(`li`,{children:(0,T.jsx)(r,{id:`6LbUG7`})}),(0,T.jsx)(`li`,{children:(0,T.jsx)(r,{id:`_pY_Vq`})}),(0,T.jsx)(`li`,{children:(0,T.jsx)(r,{id:`J6mxC1`})})]}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,T.jsx)(o,{onClick:()=>{V()},"data-testid":`share-receive-clone-retry`,children:(0,T.jsx)(r,{id:`KDw4GX`})}),(0,T.jsx)(o,{variant:`outline`,onClick:()=>{H()},disabled:w||N,"data-testid":`share-receive-error-local`,children:(0,T.jsx)(r,{id:`xFQRu4`})})]})]}):(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,T.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-clone`,className:`flex flex-col items-start gap-2 rounded-lg border border-primary/50 bg-primary/5 p-4 text-left transition hover:border-primary hover:bg-primary/10 focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-primary/50 disabled:hover:bg-primary/5`,onClick:()=>{V()},disabled:h!==void 0&&!z,"aria-disabled":h!==void 0&&!z,children:[(0,T.jsx)(`span`,{className:`text-sm font-semibold`,children:B}),(0,T.jsx)(`span`,{className:`line-clamp-2 text-1sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`fj5YiP`})})]}),(0,T.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-local`,className:`flex flex-col items-start gap-2 rounded-lg border border-border bg-card p-4 text-left transition hover:border-foreground/50 hover:bg-accent focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,onClick:()=>{H()},disabled:w||N,children:[(0,T.jsx)(`span`,{className:`text-sm font-semibold`,children:(0,T.jsx)(r,{id:`HfI1dR`})}),(0,T.jsx)(`span`,{className:`line-clamp-2 text-1sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`_qD6mn`})})]})]}),t[130]=h,t[131]=z,t[132]=P,t[133]=Oe,t[134]=B,t[135]=N,t[136]=V,t[137]=H,t[138]=w,t[139]=$):$=t[139];let je;t[140]!==j||t[141]!==k||t[142]!==h||t[143]!==U||t[144]!==Ee?(je=h?(0,T.jsx)(`div`,{className:`mt-3 flex items-center justify-between rounded-md border border-border bg-muted/30 px-3 py-2 text-xs`,"data-testid":`share-receive-auth-banner`,role:`status`,"aria-live":`polite`,children:k===null?(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:(0,T.jsx)(r,{id:`UDFrWm`})}):k.authenticated?(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:(0,T.jsx)(r,{id:`VAHWL_`,values:{signedInLogin:Ee},components:{0:(0,T.jsx)(`span`,{className:`font-medium text-foreground/90`})}})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:(0,T.jsx)(r,{id:`SgKLfA`})}),(0,T.jsx)(`button`,{type:`button`,"data-testid":`share-receive-signin`,className:`font-medium text-primary underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,onClick:()=>{U()},disabled:j,children:j?(0,T.jsx)(r,{id:`PKLY-1`}):(0,T.jsx)(r,{id:`3jod3l`})})]})}):null,t[140]=j,t[141]=k,t[142]=h,t[143]=U,t[144]=Ee,t[145]=je):je=t[145];let Me;t[146]!==P||t[147]!==Te?(Me=P?null:(0,T.jsx)(`p`,{className:`mt-3 text-1sm text-muted-foreground`,children:(0,T.jsx)(r,{id:`RJ3a8Z`,values:{lookingForUrl:Te},components:{0:(0,T.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),t[146]=P,t[147]=Te,t[148]=Me):Me=t[148];let Ne;t[149]!==$||t[150]!==je||t[151]!==Me?(Ne=(0,T.jsxs)(re,{children:[$,je,Me]}),t[149]=$,t[150]=je,t[151]=Me,t[152]=Ne):Ne=t[152];let Pe;t[153]===_?Pe=t[154]:(Pe=()=>_.dismiss(),t[153]=_,t[154]=Pe);let Fe;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,T.jsx)(r,{id:`dEgA5A`}),t[155]=Fe):Fe=t[155];let Ie;t[156]===Pe?Ie=t[157]:(Ie=(0,T.jsx)(s,{children:(0,T.jsx)(o,{variant:`outline`,className:`font-mono uppercase`,onClick:Pe,children:Fe})}),t[156]=Pe,t[157]=Ie);let Le;t[158]!==Q||t[159]!==Ne||t[160]!==Ie?(Le=(0,T.jsxs)(ne,{className:`sm:max-w-xl`,"data-testid":`share-receive-dialog`,children:[Q,Ne,Ie]}),t[158]=Q,t[159]=Ne,t[160]=Ie,t[161]=Le):Le=t[161];let Re;return t[162]!==K||t[163]!==Le?(Re=(0,T.jsx)(l,{open:!0,onOpenChange:K,children:Le}),t[162]=K,t[163]=Le,t[164]=Re):Re=t[164],Re}function ce(e){return e.preventDefault()}function le(e){return e.preventDefault()}function M(e){return e===null?e:w(e)}function ue(e){return e===null?e:C(e,{ok:!0})}function de(e){return e===null?e:x(e)}export{O as ShareReceiveDialog};
|
package/dist/public/assets/{ShareReceiveMissDialog-Bw2-qhvJ.js → ShareReceiveMissDialog-s_ig9ymF.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{t as r}from"./compiler-runtime-BfE3aGVn.js";import{c as i,i as a,n as o,s,t as c}from"./dialog-DwFomKjP.js";import{a as l,i as u,n as d,r as f}from"./pending-receive-nav-store-
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{t as r}from"./compiler-runtime-BfE3aGVn.js";import{c as i,i as a,n as o,s,t as c}from"./dialog-DwFomKjP.js";import{a as l,i as u,n as d,r as f}from"./pending-receive-nav-store-B0J2CSDv.js";import{t as p}from"./miss-dialog-store-B3cHkf8G.js";import{f as m,p as h}from"./doc-paths-9WcZxMIM.js";var g=r(),_=e(n(),1),v=t();function y(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function b(){let e=(0,g.c)(2),t=(0,_.useSyncExternalStore)(p.subscribe,p.getSnapshot,x);if(t===null)return null;let n;return e[0]===t?n=e[1]:(n=(0,v.jsx)(S,{nav:t},t.path),e[0]=t,e[1]=n),n}function x(){return null}function S(e){let t=(0,g.c)(29),{nav:n}=e,{state:r,refetch:_}=l(n),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(){p.dismiss()},t[0]=b):b=t[0];let x=b,S;t[1]===n.path?S=t[2]:(S=function(){window.location.hash=h(u(n.path)),x()},t[1]=n.path,t[2]=S);let C=S,w;t[3]!==n.branch||t[4]!==n.kind?(w=function(e){d.arm({kind:n.kind,path:e,branch:n.branch}),window.location.hash=n.kind===`folder`?h(e):m(e),x()},t[3]=n.branch,t[4]=n.kind,t[5]=w):w=t[5];let T=w,E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{e||x()},t[6]=E):E=t[6];let D=r.phase,O=r.phase===`resolved`?r.resolution.verdict:void 0,k;t[7]===n.path?k=t[8]:(k=y(n.path),t[7]=n.path,t[8]=k);let A;t[9]===k?A=t[10]:(A=(0,v.jsx)(s,{children:(0,v.jsx)(i,{className:`truncate`,children:k})}),t[9]=k,t[10]=A);let j=r.phase===`pending`?`flex flex-col items-center justify-center gap-3 py-6 text-center text-sm text-muted-foreground`:`flex flex-col items-center justify-center gap-6 py-2 text-center`,M;t[11]!==n.path||t[12]!==T?(M=()=>T(n.path),t[11]=n.path,t[12]=T,t[13]=M):M=t[13];let N;t[14]!==C||t[15]!==n||t[16]!==T||t[17]!==_||t[18]!==r||t[19]!==M?(N=(0,v.jsx)(f,{nav:n,state:r,onBrowseFolder:C,onOpenRenamed:T,onEnableAutoSync:x,onSyncCompleted:_,onPullApplied:M}),t[14]=C,t[15]=n,t[16]=T,t[17]=_,t[18]=r,t[19]=M,t[20]=N):N=t[20];let P;t[21]!==N||t[22]!==j?(P=(0,v.jsx)(o,{className:j,children:N}),t[21]=N,t[22]=j,t[23]=P):P=t[23];let F;return t[24]!==r.phase||t[25]!==P||t[26]!==O||t[27]!==A?(F=(0,v.jsx)(c,{open:!0,onOpenChange:E,children:(0,v.jsxs)(a,{className:`sm:max-w-md`,"data-testid":`share-receive-miss-dialog`,"data-phase":D,"data-verdict":O,children:[A,P]})}),t[24]=r.phase,t[25]=P,t[26]=O,t[27]=A,t[28]=F):F=t[28],F}export{b as ShareReceiveMissDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BUgB2tll.js";import{n as t}from"./dist-Nvb76hAm.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import{t as r}from"./square-pen-CEIus1aL.js";import{o as i}from"./skill-scope-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BUgB2tll.js";import{n as t}from"./dist-Nvb76hAm.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import{t as r}from"./square-pen-CEIus1aL.js";import{o as i}from"./skill-scope-CBI04cxU.js";import{t as a}from"./SkillModeBanner-DFgrdWyf.js";var o=n(),s=e();function c(e){let n=(0,o.c)(7),{name:c}=e,l;n[0]===c?l=n[1]:(l=i(c),n[0]=c,n[1]=l);let u;n[2]===l?u=n[3]:(u=(0,s.jsx)(`strong`,{className:`font-medium text-foreground`,children:l}),n[2]=l,n[3]=u);let d=u,f;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,s.jsx)(r,{className:`size-4`,"aria-hidden":!0}),n[4]=f):f=n[4];let p;return n[5]===d?p=n[6]:(p=(0,s.jsx)(a,{icon:f,children:(0,s.jsx)(t,{id:`i-wHEp`,values:{boldName:d}})}),n[5]=d,n[6]=p),p}export{c as SkillEditBanner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{t as s}from"./button-RQ5o7P7w.js";import{i as c,n as l,t as u}from"./tooltip-x7BNUa3s.js";import{a as d,c as f,i as p,n as m,o as h,s as g,t as _}from"./dialog-DwFomKjP.js";import{t as v}from"./switch-0kSGDL9E.js";import{t as y}from"./arrow-up-right-Gp4MuO-g.js";import{t as b}from"./refresh-cw-DGLnzhho.js";import{t as x}from"./undo-2-bYFSgQwb.js";import{t as S}from"./use-skill-origin-
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{t as s}from"./button-RQ5o7P7w.js";import{i as c,n as l,t as u}from"./tooltip-x7BNUa3s.js";import{a as d,c as f,i as p,n as m,o as h,s as g,t as _}from"./dialog-DwFomKjP.js";import{t as v}from"./switch-0kSGDL9E.js";import{t as y}from"./arrow-up-right-Gp4MuO-g.js";import{t as b}from"./refresh-cw-DGLnzhho.js";import{t as x}from"./undo-2-bYFSgQwb.js";import{t as S}from"./use-skill-origin-CdIbGanW.js";import{t as C}from"./DiffView-Bc5gwnAV.js";var w=e(n(),1),T=a(),E=t();function D(e){let t=(0,T.c)(31),{open:n,onOpenChange:i,skillName:a,localBody:o,upstreamBody:c,applying:l,onTakeUpstream:u}=e,v;t[0]===a?v=t[1]:(v=(0,E.jsx)(f,{children:(0,E.jsx)(r,{id:`EPKVES`,values:{skillName:a}})}),t[0]=a,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,E.jsx)(d,{children:(0,E.jsx)(r,{id:`kKw0H3`})}),t[2]=y):y=t[2];let b;t[3]===v?b=t[4]:(b=(0,E.jsxs)(g,{children:[v,y]}),t[3]=v,t[4]=b);let x;t[5]!==o||t[6]!==c?(x=(0,E.jsx)(m,{className:`min-h-0 flex-1 overflow-auto`,children:(0,E.jsx)(C,{oldContent:o,newContent:c,layout:`unified`})}),t[5]=o,t[6]=c,t[7]=x):x=t[7];let S;t[8]===i?S=t[9]:(S=()=>i(!1),t[8]=i,t[9]=S);let w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,E.jsx)(r,{id:`Tq3pcs`}),t[10]=w):w=t[10];let D;t[11]!==l||t[12]!==S?(D=(0,E.jsx)(s,{variant:`outline`,onClick:S,disabled:l,children:w}),t[11]=l,t[12]=S,t[13]=D):D=t[13];let O;t[14]===l?O=t[15]:(O=l?(0,E.jsx)(r,{id:`JL3si7`}):(0,E.jsx)(r,{id:`qkqG0b`}),t[14]=l,t[15]=O);let k;t[16]!==l||t[17]!==u||t[18]!==O?(k=(0,E.jsx)(s,{onClick:u,disabled:l,children:O}),t[16]=l,t[17]=u,t[18]=O,t[19]=k):k=t[19];let A;t[20]!==D||t[21]!==k?(A=(0,E.jsxs)(h,{children:[D,k]}),t[20]=D,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==A||t[24]!==b||t[25]!==x?(j=(0,E.jsxs)(p,{className:`flex max-h-[85vh] max-w-3xl flex-col`,children:[b,x,A]}),t[23]=A,t[24]=b,t[25]=x,t[26]=j):j=t[26];let M;return t[27]!==i||t[28]!==n||t[29]!==j?(M=(0,E.jsx)(_,{open:n,onOpenChange:i,children:j}),t[27]=i,t[28]=n,t[29]=j,t[30]=M):M=t[30],M}function O(e){let t=(0,T.c)(48),{scope:n,name:a}=e,{_:d}=i(),f;t[0]!==a||t[1]!==n?(f={scope:n,name:a},t[0]=a,t[1]=n,t[2]=f):f=t[2];let{origin:p,github:m,displaySource:h,importedTitle:g,canReimport:_,updateAvailable:C,modified:O,autoUpdate:k,gitTracked:A,setAutoUpdate:j,revertable:M,reimport:N,reimporting:P,previewUpdate:F,revert:I,reverting:L}=S(f),[R,z]=(0,w.useState)(null),B;t[3]!==O||t[4]!==F||t[5]!==N?(B=async function(){if(O){let e=await F();e&&z(e);return}await N()},t[3]=O,t[4]=F,t[5]=N,t[6]=B):B=t[6];let V=B,H;t[7]===N?H=t[8]:(H=async function(){await N(),z(null)},t[7]=N,t[8]=H);let U=H;if(!p)return null;let W;t[9]!==h||t[10]!==m||t[11]!==g?(W=m?(0,E.jsxs)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,title:g??void 0,className:`hidden min-w-0 max-w-48 items-center gap-1 hover:text-foreground @xl/toolbar:flex`,children:[(0,E.jsx)(`span`,{className:`truncate`,children:h}),(0,E.jsx)(y,{className:`size-3 shrink-0`,"aria-hidden":!0})]}):(0,E.jsx)(`span`,{title:g??void 0,className:`hidden min-w-0 max-w-48 truncate @xl/toolbar:inline`,children:h}),t[9]=h,t[10]=m,t[11]=g,t[12]=W):W=t[12];let G;t[13]!==d||t[14]!==k||t[15]!==_||t[16]!==A||t[17]!==j?(G=_?(0,E.jsxs)(u,{children:[(0,E.jsx)(c,{asChild:!0,children:(0,E.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,E.jsx)(`label`,{htmlFor:`skill-auto-update-switch`,className:`hidden cursor-pointer @xl/toolbar:inline`,children:(0,E.jsx)(r,{id:`2M0JF6`})}),(0,E.jsx)(v,{id:`skill-auto-update-switch`,checked:k&&!A,disabled:A,onCheckedChange:e=>void j(e===!0),"aria-label":d({id:`o9fPtM`}),className:`scale-75`})]})}),(0,E.jsx)(l,{side:`bottom`,children:A?(0,E.jsx)(r,{id:`vy_VIN`}):k?(0,E.jsx)(r,{id:`vGQxBT`}):(0,E.jsx)(r,{id:`9p_QBN`})})]}):null,t[13]=d,t[14]=k,t[15]=_,t[16]=A,t[17]=j,t[18]=G):G=t[18];let K;t[19]===O?K=t[20]:(K=O?(0,E.jsxs)(u,{children:[(0,E.jsx)(c,{asChild:!0,children:(0,E.jsx)(`span`,{className:`shrink-0 rounded-sm bg-amber-500/15 px-1.5 py-0.5 font-medium text-[11px] text-amber-700 dark:text-amber-400`,children:(0,E.jsx)(r,{id:`tgWuMB`})})}),(0,E.jsx)(l,{side:`bottom`,children:(0,E.jsx)(r,{id:`s0Iold`})})]}):null,t[19]=O,t[20]=K);let q;t[21]!==d||t[22]!==_||t[23]!==O||t[24]!==P||t[25]!==I||t[26]!==M||t[27]!==L?(q=O&&_&&M?(0,E.jsxs)(u,{children:[(0,E.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void I(),disabled:L||P,"aria-label":d({id:`VxLvKE`}),className:`shrink-0 gap-1 text-muted-foreground px-2 text-xs hover:text-foreground`,asChild:!0,children:(0,E.jsxs)(c,{children:[(0,E.jsx)(x,{className:o(`size-3`,L&&`animate-spin`),"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden @xl/toolbar:inline`,children:L?(0,E.jsx)(r,{id:`fIJtam`}):(0,E.jsx)(r,{id:`jJdwCB`})})]})}),(0,E.jsx)(l,{side:`bottom`,children:(0,E.jsx)(r,{id:`XSb9HS`})})]}):null,t[21]=d,t[22]=_,t[23]=O,t[24]=P,t[25]=I,t[26]=M,t[27]=L,t[28]=q):q=t[28];let J;t[29]!==d||t[30]!==_||t[31]!==V||t[32]!==P||t[33]!==L||t[34]!==C?(J=_&&C?(0,E.jsxs)(u,{children:[(0,E.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void V(),disabled:P||L,"aria-label":d({id:`GidGkh`}),className:`shrink-0 gap-1 text-muted-foreground px-2 text-xs hover:text-foreground`,asChild:!0,children:(0,E.jsxs)(c,{children:[(0,E.jsx)(b,{className:o(`size-3`,P&&`animate-spin`),"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden @xl/toolbar:inline`,children:P?(0,E.jsx)(r,{id:`JL3si7`}):(0,E.jsx)(r,{id:`EkH9pt`})})]})}),(0,E.jsx)(l,{side:`bottom`,children:(0,E.jsx)(r,{id:`GidGkh`})})]}):null,t[29]=d,t[30]=_,t[31]=V,t[32]=P,t[33]=L,t[34]=C,t[35]=J):J=t[35];let Y;t[36]!==R||t[37]!==a||t[38]!==U||t[39]!==P?(Y=R?(0,E.jsx)(D,{open:!0,onOpenChange:e=>{e||z(null)},skillName:a,localBody:R.localBody,upstreamBody:R.upstreamBody,applying:P,onTakeUpstream:()=>void U()}):null,t[36]=R,t[37]=a,t[38]=U,t[39]=P,t[40]=Y):Y=t[40];let X;return t[41]!==W||t[42]!==G||t[43]!==K||t[44]!==q||t[45]!==J||t[46]!==Y?(X=(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground text-xs`,children:[W,G,K,q,J,Y]}),t[41]=W,t[42]=G,t[43]=K,t[44]=q,t[45]=J,t[46]=Y,t[47]=X):X=t[47],X}export{O as SkillOriginInline};
|
package/dist/public/assets/{SkillToolbarControls-U1QWzi0I.js → SkillToolbarControls-DlqLImDa.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{c as s,l as c,r as l}from"./ChangedOutsideBadge-
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{c as s,l as c,r as l}from"./ChangedOutsideBadge-EtTRyMst.js";import{t as u}from"./button-RQ5o7P7w.js";import{R as d,d as f,f as p,i as m,l as h,p as g,r as _}from"./skill-actions-l08GRiO6.js";import{a as v,c as y,l as b,m as ee,o as x,r as S,t as C,u as w}from"./dropdown-menu-DRytYgB4.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./select-BU4xT6VN.js";import{t as M}from"./chevron-down-CRb8csep.js";import{f as N,i as P,t as F}from"./skill-scope-CBI04cxU.js";import{t as I}from"./use-skills-w-wrmauP.js";var L=a(),R=e(n(),1),z=t();function B(e){let t=(0,L.c)(52),{scope:n,name:a}=e,{_:c}=i(),d=I(),m=_(),h;t[0]!==a||t[1]!==n||t[2]!==d.data||t[3]!==d.status?(h=d.status===`ready`?d.data.find(e=>e.scope===n&&e.name===a):void 0,t[0]=a,t[1]=n,t[2]=d.data,t[3]=d.status,t[4]=h):h=t[4];let v=h,y;t[5]!==v||t[6]!==a||t[7]!==n?(y=v??{scope:n,name:a,path:a,description:``,installed:!1,hosts:[]},t[5]=v,t[6]=a,t[7]=n,t[8]=y):y=t[8];let b=y,[x,w]=(0,R.useState)(!1),T=g(b,m),{installed:E,installing:D,hostSet:O}=T,k=v===void 0&&!E,A;t[9]!==v||t[10]!==O?(A=v?P(v,[...O]):[],t[9]=v,t[10]=O,t[11]=A):A=t[11];let j=A,N;t[12]!==m||t[13]!==b?(N=()=>m.requestFileCreate(b),t[12]=m,t[13]=b,t[14]=N):N=t[14];let F;t[15]===c?F=t[16]:(F=c({id:`leF0i_`}),t[15]=c,t[16]=F);let B;t[17]===c?B=t[18]:(B=c({id:`leF0i_`}),t[17]=c,t[18]=B);let V;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[19]=V):V=t[19];let H;t[20]!==N||t[21]!==F||t[22]!==B?(H=(0,z.jsx)(u,{variant:`outline`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,onClick:N,title:F,"aria-label":B,"data-testid":`skill-editor-new-file`,children:V}),t[20]=N,t[21]=F,t[22]=B,t[23]=H):H=t[23];let U=k?`resolving`:`installed`,W=k?`border-border bg-muted/50 text-muted-foreground`:`border-primary/50 bg-primary/5 text-primary hover:bg-primary/10 hover:text-primary aria-expanded:bg-primary/10 aria-expanded:text-primary`,G;t[24]===W?G=t[25]:(G=o(`h-7 shrink-0 gap-1 rounded-lg border px-2 font-normal text-xs shadow-xs font-mono uppercase`,W),t[24]=W,t[25]=G);let K;t[26]!==j||t[27]!==D||t[28]!==k?(K=D?(0,z.jsx)(r,{id:`b4itZn`}):k?(0,z.jsx)(r,{id:`iKvAeG`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(r,{id:`eQkgKV`}),(0,z.jsx)(l,{hosts:j,className:`text-muted-foreground`})]}),t[26]=j,t[27]=D,t[28]=k,t[29]=K):K=t[29];let q;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,z.jsx)(M,{className:`size-4 shrink-0 opacity-50`,"aria-hidden":!0}),t[30]=q):q=t[30];let J;t[31]!==D||t[32]!==G||t[33]!==K||t[34]!==U?(J=(0,z.jsx)(ee,{asChild:!0,children:(0,z.jsxs)(u,{variant:`outline`,size:`sm`,disabled:D,"data-testid":`skill-install-menu-trigger`,"data-state":U,className:G,children:[K,q]})}),t[31]=D,t[32]=G,t[33]=K,t[34]=U,t[35]=J):J=t[35];let Y;t[36]!==m||t[37]!==b?(Y=e=>m.requestForkResolve(b,e),t[36]=m,t[37]=b,t[38]=Y):Y=t[38];let X;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>w(!1),t[39]=X):X=t[39];let Z;t[40]!==b||t[41]!==Y||t[42]!==T?(Z=(0,z.jsx)(S,{align:`end`,className:f,children:(0,z.jsx)(p,{toggles:T,skill:b,onResolveFork:Y,onRunStart:X})}),t[40]=b,t[41]=Y,t[42]=T,t[43]=Z):Z=t[43];let Q;t[44]!==x||t[45]!==J||t[46]!==Z?(Q=(0,z.jsxs)(C,{open:x,onOpenChange:w,children:[J,Z]}),t[44]=x,t[45]=J,t[46]=Z,t[47]=Q):Q=t[47];let $;return t[48]!==m.dialogs||t[49]!==Q||t[50]!==H?($=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[H,Q,m.dialogs]}),t[48]=m.dialogs,t[49]=Q,t[50]=H,t[51]=$):$=t[51],$}function V(e){let t=(0,L.c)(21),{value:n,onRequestMove:a,disabled:s,triggerClassName:c}=e,{_:l}=i(),u=N(),d;t[0]===a?d=t[1]:(d=e=>a(e),t[0]=a,t[1]=d);let f;t[2]===l?f=t[3]:(f=l({id:`oCHfGC`}),t[2]=l,t[3]=f);let p;t[4]===c?p=t[5]:(p=o(`w-auto gap-1 text-xs font-mono uppercase`,c),t[4]=c,t[5]=p);let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(A,{}),t[6]=m):m=t[6];let h;t[7]!==f||t[8]!==p?(h=(0,z.jsx)(O,{size:`sm`,"aria-label":f,"data-testid":`skill-level-select`,className:p,children:m}),t[7]=f,t[8]=p,t[9]=h):h=t[9];let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,z.jsx)(T,{children:(0,z.jsx)(r,{id:`oCHfGC`})}),t[10]=g):g=t[10];let _;t[11]===u?_=t[12]:(_=F.map(e=>(0,z.jsx)(E,{value:e,children:u[e]},e)),t[11]=u,t[12]=_);let v;t[13]===_?v=t[14]:(v=(0,z.jsx)(D,{align:`end`,children:(0,z.jsxs)(k,{children:[g,_]})}),t[13]=_,t[14]=v);let y;return t[15]!==s||t[16]!==d||t[17]!==h||t[18]!==v||t[19]!==n?(y=(0,z.jsxs)(j,{value:n,onValueChange:d,disabled:s,children:[h,v]}),t[15]=s,t[16]=d,t[17]=h,t[18]=v,t[19]=n,t[20]=y):y=t[20],y}function H(e){let t=(0,L.c)(12),{scope:n,name:r}=e,[i,a]=(0,R.useState)(null),o;t[0]===n?o=t[1]:(o=e=>{e!==n&&a(e)},t[0]=n,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==n?(s=i?{scope:n,name:r,toScope:i}:null,t[2]=r,t[3]=i,t[4]=n,t[5]=s):s=t[5];let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>!e&&a(null),t[6]=c):c=t[6];let l;t[7]===s?l=t[8]:(l=(0,z.jsx)(m,{target:s,onOpenChange:c}),t[7]=s,t[8]=l);let u;return t[9]!==o||t[10]!==l?(u={requestMove:o,dialog:l},t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function U(e){let t=(0,L.c)(45),{scope:n,name:a,showAddPropertyButton:o,onAddProperty:s,problemCount:l,problemMessages:f}=e,{_:p}=i(),m=N(),g;t[0]!==a||t[1]!==n?(g={scope:n,name:a},t[0]=a,t[1]=n,t[2]=g):g=t[2];let _=H(g),T;t[3]!==_.requestMove||t[4]!==n?(T=(0,z.jsx)(V,{value:n,onRequestMove:_.requestMove,triggerClassName:`hidden @xl/toolbar:flex`}),t[3]=_.requestMove,t[4]=n,t[5]=T):T=t[5];let E;t[6]!==a||t[7]!==n?(E=(0,z.jsx)(B,{scope:n,name:a}),t[6]=a,t[7]=n,t[8]=E):E=t[8];let D;t[9]!==T||t[10]!==E?(D=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,E]}),t[9]=T,t[10]=E,t[11]=D):D=t[11];let O;t[12]!==s||t[13]!==l||t[14]!==f||t[15]!==o?(O=o?(0,z.jsx)(h,{onAddProperty:s,problemCount:l,problemMessages:f,className:`hidden @xl/toolbar:inline-flex`}):null,t[12]=s,t[13]=l,t[14]=f,t[15]=o,t[16]=O):O=t[16];let k;t[17]===p?k=t[18]:(k=p({id:`Yzs3QX`}),t[17]=p,t[18]=k);let A;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t[19]=A):A=t[19];let j;t[20]===k?j=t[21]:(j=(0,z.jsx)(ee,{asChild:!0,children:(0,z.jsx)(u,{variant:`ghost`,size:`icon`,"aria-label":k,"data-testid":`skill-toolbar-overflow`,className:`@xl/toolbar:hidden`,children:A})}),t[20]=k,t[21]=j);let M;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,z.jsx)(x,{children:(0,z.jsx)(r,{id:`oCHfGC`})}),t[22]=M):M=t[22];let P;t[23]===_?P=t[24]:(P=e=>_.requestMove(e),t[23]=_,t[24]=P);let I;t[25]===m?I=t[26]:(I=F.map(e=>(0,z.jsx)(b,{value:e,children:m[e]},e)),t[25]=m,t[26]=I);let R;t[27]!==n||t[28]!==P||t[29]!==I?(R=(0,z.jsx)(y,{value:n,onValueChange:P,children:I}),t[27]=n,t[28]=P,t[29]=I,t[30]=R):R=t[30];let U;t[31]!==s||t[32]!==o?(U=o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(w,{}),(0,z.jsxs)(v,{onSelect:s,children:[(0,z.jsx)(d,{}),(0,z.jsx)(r,{id:`81H_23`})]})]}):null,t[31]=s,t[32]=o,t[33]=U):U=t[33];let W;t[34]!==R||t[35]!==U?(W=(0,z.jsxs)(S,{align:`end`,className:`min-w-44`,children:[M,R,U]}),t[34]=R,t[35]=U,t[36]=W):W=t[36];let G;t[37]!==W||t[38]!==j?(G=(0,z.jsxs)(C,{children:[j,W]}),t[37]=W,t[38]=j,t[39]=G):G=t[39];let K;return t[40]!==_.dialog||t[41]!==G||t[42]!==D||t[43]!==O?(K=(0,z.jsxs)(z.Fragment,{children:[D,O,G,_.dialog]}),t[40]=_.dialog,t[41]=G,t[42]=D,t[43]=O,t[44]=K):K=t[44],K}export{U as SkillToolbarControls};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Gt as n,Lt as r,Rt as i,Xt as a,_t as o,bt as s,gn as c,k as l,mn as u,xt as d,yt as f}from"./DocumentContext-BeNSZPYG.js";import{t as p}from"./react-f2sANaYj.js";import{n as m}from"./dist-PQ5KMVDh.js";import{t as h}from"./compiler-runtime-BfE3aGVn.js";import{E as g,a as ee,i as te,o as ne}from"./CodeMirrorPropInput-B98kUaCj.js";import{Ea as _,Ia as v,Li as re,T as ie,Tr as y,ba as b,ti as ae}from"./dist-DOPRKSzO2.js";import{A as oe,C as x,D as se,I as ce,N as le,a as ue,i as de,j as fe,t as pe,u as me,x as he}from"./typing-burst-detector-DKVkQeXL.js";import{f as S,g as C}from"./doc-paths-Dr8av3tc.js";import{v as ge}from"./use-settings-route-ClTq87t7.js";import{J as w}from"./navigation-targets-DxC4QM5f.js";import"./config-provider-NjnhDMPo.js";import{n as _e}from"./config-context-DyUEqnhn.js";import{Dt as T,E,Et as D,Ft as O,It as k,J as A,Ot as ve,P as j,Q as M,X as N,_ as P,ct as F,dt as I,ft as L,ht as R,l as z,lt as B,mt as ye,nt as V,rt as H,st as U,tt as W,y as G}from"./dist-zYQJXuRH.js";import{a as be,n as K}from"./cm-theme-CUwlOcHl.js";import{i as q,n as J,o as Y,r as X}from"./dist-DgD72kci.js";import{o as xe,r as Se}from"./selection-context-CHSH5Ljn.js";import{l as Ce}from"./lint-config-client-CeUWUhyK.js";import{a as we,i as Z,n as Te,o as Ee,r as De,t as Oe}from"./dist-BX-8uxZE.js";import{n as ke,t as Ae}from"./src-BtmmehSp.js";var Q=e(p(),1),je=h();function Me(){let e=d();return e===null?null:new Set(e.keys())}function Ne(e,t,n){let r=[],i=j(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);_.lastIndex=0;for(let e=_.exec(t);e!==null;e=_.exec(t)){let t=e[2];if(!v(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(A.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:a,to:s}of t)i.iterate({from:a,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),a=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(a,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&v(l)&&n!=null)return r.push(A.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+a,t.to-s)),!1;let u=o.exec(c);if(u)return r.push(A.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+a,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(r)}function Pe(e){let t=s(e);return t===null?[]:[M.fromClass(class{decorations;constructor(e){this.decorations=Ne(e.state,e.visibleRanges,Me())}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Ne(e.view.state,e.view.visibleRanges,Me()))}},{decorations:e=>e.decorations}),N.domEventHandlers({mousedown(n){let r=n.target?.closest?.(`[data-skill-ref]`),i=r instanceof HTMLElement?r.dataset.skillRef:void 0;if(i!==void 0){n.preventDefault();let e=d()?.get(i);return window.location.hash=e===void 0?C():S(w({scope:e.scope,name:i,path:e.path})),!0}let a=n.target?.closest?.(`.cm-skill-path-link`),o=a instanceof HTMLElement?a.dataset.skillPath:void 0;return o===void 0?!1:(n.preventDefault(),window.location.hash=f(t,e,o),!0)}})]}function Fe(e,t){return e.enabled?[Oe(),De(async n=>Ie(n.state.doc,await y(n.state.doc.toString(),e,t)),{delay:600})]:[]}function $(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function Ie(e,t){let n=[];for(let r of t){let t=$(e,r.range.start),i=$(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=Le(r);o&&(a.actions=[o]),n.push(a)}return n}function Le(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:$(n,e.range.start),to:$(n,e.range.end),insert:e.newText}))})}}}var Re=[L(),F(),B(),P(),V(),H(),ve.allowMultipleSelections.of(!0),E(),z(),X(),J(),R(),W(),U(),Z(),I.of([...q,...K,...Ee,...G,...Y,...Te])],ze=A.mark({class:`cm-link-ref-broken`}),Be=/^\s{0,3}\[([^\]]+)\]:\s/,Ve=/\[([^\]]*)\]\[([^\]]*)\]/g,He=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Ue(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function We(e){let t=[];return j(e).iterate({enter(e){if(He.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ge(e){let t=new Set,n=[],r=e.doc,i=We(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Ue(n.from,i))continue;let a=Be.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Ue(t.from,i)&&!Be.test(t.text))for(Ve.lastIndex=0;;){let e=Ve.exec(t.text);if(!e)break;let r=t.from+e.index;if(Ue(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(ze.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),A.set(a)}var Ke=k.define({create(e){return Ge(e)},update(e,t){return t.docChanged?Ge(t.state):e},provide:e=>N.decorations.from(e)}),qe=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Je=A.mark({class:`cm-del`}),Ye=A.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Xe=A.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ze(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Qe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!b.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(b.test(r.text))return{from:t.from,to:r.to}}return null}function $e(e,t){let n=[],r=j(e),i=Qe(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(Je.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=qe.exec(r.text),a=i?i[1].length:2,o=A.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=Ze(r.text),a=A.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(Ye.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(n)}var et=class{decorations;constructor(e){this.decorations=$e(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=$e(e.view.state,e.view.visibleRanges))}},tt=M.fromClass(et,{decorations:e=>e.decorations});function nt(){return[tt,Ke]}var rt=t(),it=56,at=O.define();function ot(e,t,n){let r=x(e.state.doc)[t.index];r&&a(n,()=>{e.dispatch({selection:T.cursor(r.from),effects:N.scrollIntoView(r.from,{y:`start`})}),e.focus()})}function st(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,o=Math.min(t.offset,i.length);a(r,()=>{e.dispatch({selection:T.cursor(o),effects:N.scrollIntoView(o,{y:`center`})}),e.focus()})})}function ct(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),o=r.line(i),s=Math.min(o.from+Math.max(0,t.column-1),o.to);a(n,()=>{e.dispatch({selection:T.cursor(s),effects:N.scrollIntoView(s,{y:`start`})}),e.focus()})}function lt(e){let t=(0,je.c)(50),{docName:a,ytext:o,provider:s,placeholder:d,isSourceModeActive:f}=e,p=(0,Q.useRef)(null),h=(0,Q.useRef)(null),[g,_]=(0,Q.useState)(null);if(g)throw g;let{resolvedTheme:v}=m(),{merged:y}=_e(),b=(0,Q.useRef)(f),x=y?.editor?.wordWrap??!0,{data:S}=Ce(a),C;t[0]!==S?.effective||t[1]!==y?(C=S?.effective??(y?.contentRules?ae(y.contentRules):ie),t[0]=S?.effective,t[1]=y,t[2]=C):C=t[2];let w=C,T;t[3]===w?T=t[4]:(T=JSON.stringify(w),t[3]=w,t[4]=T);let E=T,O,k;t[5]===f?(O=t[6],k=t[7]):(O=()=>{b.current=f},k=[f],t[5]=f,t[6]=O,t[7]=k),(0,Q.useEffect)(O,k);let A=(0,Q.useRef)(null),j;t[8]!==a||t[9]!==w||t[10]!==d||t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==o?(j=()=>{let e=p.current;if(!e)return;let t=s.configuration.name??``,f,m=dt;try{f=r({docName:t,container:e,sizeStats:{viewCount:0,bytes:o.length},factory:e=>{let r=null,i=l({ydoc:s.document,ytext:o}),c=new D,u=new D,f=new D,p=new D,h=new N({state:ve.create({doc:o.toString(),extensions:[Re,we({scrollToMatch:e=>n(t)?N.scrollIntoView(e,{y:`start`}):at.of(null)}),I.of([be]),Ae(o,s.awareness),I.of(ke),...te({themeCompartment:c,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:u,wordWrap:x,currentDocName:t}),nt(),Pe(t),ce(),p.of(Fe(w,a)),i,N.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,de(t,`source`,ue(e.view)),Se(t,`source`,xe(e.view,t))},120))}),N.domEventHandlers({keydown:(e,t)=>!b.current||!re()||!ge(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pe(),!0)}),f.of(ye(d??``)),N.theme({"&":{height:`100%`}}),N.scrollMargins.of(ut)]}),parent:e});de(t,`source`,ue(h)),Se(t,`source`,xe(h,t));let g=h.contentDOM;return g.addEventListener(`keydown`,m),g.addEventListener(`paste`,m),g.addEventListener(`drop`,m),g.addEventListener(`cut`,m),{view:h,ydoc:s.document,ytext:o,provider:s,themeCompartment:c,wordWrapCompartment:u,placeholderCompartment:f,lintCompartment:p}}}),A.current=f,h.current=f.view,u(a,f.view)}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),A.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=A.current;e&&(i(e),c(a,e.view)),A.current=null,h.current=null}},t[8]=a,t[9]=w,t[10]=d,t[11]=s,t[12]=v,t[13]=x,t[14]=o,t[15]=j):j=t[15];let M;t[16]!==s||t[17]!==o?(M=[o,s],t[16]=s,t[17]=o,t[18]=M):M=t[18],(0,Q.useEffect)(j,M);let P,F;t[19]===a?(P=t[20],F=t[21]):(P=()=>{},F=[a],t[19]=a,t[20]=P,t[21]=F),(0,Q.useEffect)(P,F);let L,R;t[22]===v?(L=t[23],R=t[24]):(R=()=>{let e=A.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?ee:ne)})},L=[v],t[22]=v,t[23]=L,t[24]=R),(0,Q.useEffect)(R,L);let z,B;t[25]===x?(z=t[26],B=t[27]):(z=()=>{let e=A.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(x?N.lineWrapping:[])})},B=[x],t[25]=x,t[26]=z,t[27]=B),(0,Q.useEffect)(z,B);let V,H;t[28]===d?(V=t[29],H=t[30]):(V=()=>{let e=A.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(ye(d??``))})},H=[d],t[28]=d,t[29]=V,t[30]=H),(0,Q.useEffect)(V,H);let U;t[31]!==a||t[32]!==w?(U=()=>{let e=A.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(Fe(w,a))})},t[31]=a,t[32]=w,t[33]=U):U=t[33];let W;t[34]===E?W=t[35]:(W=[E],t[34]=E,t[35]=W),(0,Q.useEffect)(U,W);let G,K;t[36]!==a||t[37]!==f?(G=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||t.mode!==`source`||!f)return;let n=h.current;n&&(ot(n,t,a),oe(a))};return window.addEventListener(he,e),()=>window.removeEventListener(he,e)},K=[a,f],t[36]=a,t[37]=f,t[38]=G,t[39]=K):(G=t[38],K=t[39]),(0,Q.useEffect)(G,K);let q,J;t[40]!==a||t[41]!==f?(q=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||!f)return;let n=h.current;n&&(ct(n,t,a),oe(a))};return window.addEventListener(me,e),()=>window.removeEventListener(me,e)},J=[a,f],t[40]=a,t[41]=f,t[42]=q,t[43]=J):(q=t[42],J=t[43]),(0,Q.useEffect)(q,J);let Y,X;t[44]!==a||t[45]!==f||t[46]!==s?(Y=()=>{if(!f)return;let e=h.current;if(!e)return;let t=le(a);if(!t)return;if(t.kind!==`selection-offset`){fe(a),t.kind===`outline`?ot(e,t.detail,a):t.kind===`lint`?ct(e,t.detail,a):t.kind===`raw-mdx`&&st(e,t.detail,()=>b.current,a);return}let n=!1,r=null;return queueMicrotask(()=>{if(n)return;let t=le(a);t?.kind===`selection-offset`&&(r=se({view:e,docName:a,navigation:t,ydoc:s.document,transition:{from:`wysiwyg`,to:`source`}}),r&&fe(a))}),()=>{n=!0,r?.cancel(`mode-flip`)}},X=[a,f,s],t[44]=a,t[45]=f,t[46]=s,t[47]=Y,t[48]=X):(Y=t[47],X=t[48]),(0,Q.useEffect)(Y,X);let Z;return t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,rt.jsx)(`div`,{ref:p,className:`source-editor h-full pb-3`}),t[49]=Z):Z=t[49],Z}function ut(){return{top:it}}function dt(){return g()}export{lt as SourceEditor,st as applyRawMdxNavigation};
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Gt as n,Lt as r,Rt as i,Xt as a,_t as o,bt as s,gn as c,k as l,mn as u,xt as d,yt as f}from"./DocumentContext-C21t23gR.js";import{t as p}from"./react-f2sANaYj.js";import{n as m}from"./dist-PQ5KMVDh.js";import{t as h}from"./compiler-runtime-BfE3aGVn.js";import{E as g,a as ee,i as te,o as ne}from"./CodeMirrorPropInput-Cc1LhUu6.js";import{Aa as _,Ba as v,Or as y,T as re,Vi as ie,ai as ae,wa as b}from"./dist-CW-WKphO2.js";import{A as oe,C as x,D as se,I as ce,N as le,a as ue,i as de,j as fe,t as pe,u as me,x as he}from"./typing-burst-detector-o8zxjyyw.js";import{f as S,g as C}from"./doc-paths-9WcZxMIM.js";import{v as ge}from"./use-settings-route-DBrH-P64.js";import{J as w}from"./navigation-targets-DdhmqoI-.js";import"./config-provider-xRIhjgw3.js";import{n as _e}from"./config-context-CmQUJBcL.js";import{Dt as T,E,Et as D,Ft as O,It as k,J as A,Ot as ve,P as j,Q as M,X as N,_ as P,ct as F,dt as I,ft as L,ht as R,l as z,lt as B,mt as ye,nt as V,rt as H,st as U,tt as W,y as G}from"./dist-zYQJXuRH.js";import{a as be,n as K}from"./cm-theme-CUwlOcHl.js";import{i as q,n as J,o as Y,r as X}from"./dist-DgD72kci.js";import{o as xe,r as Se}from"./selection-context-7jZla8LT.js";import{l as Ce}from"./lint-config-client-DdmzNw30.js";import{a as we,i as Z,n as Te,o as Ee,r as De,t as Oe}from"./dist-BX-8uxZE.js";import{n as ke,t as Ae}from"./src-Ab-J5Fjb.js";var Q=e(p(),1),je=h();function Me(){let e=d();return e===null?null:new Set(e.keys())}function Ne(e,t,n){let r=[],i=j(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);_.lastIndex=0;for(let e=_.exec(t);e!==null;e=_.exec(t)){let t=e[2];if(!v(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(A.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:a,to:s}of t)i.iterate({from:a,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),a=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(a,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&v(l)&&n!=null)return r.push(A.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+a,t.to-s)),!1;let u=o.exec(c);if(u)return r.push(A.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+a,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(r)}function Pe(e){let t=s(e);return t===null?[]:[M.fromClass(class{decorations;constructor(e){this.decorations=Ne(e.state,e.visibleRanges,Me())}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Ne(e.view.state,e.view.visibleRanges,Me()))}},{decorations:e=>e.decorations}),N.domEventHandlers({mousedown(n){let r=n.target?.closest?.(`[data-skill-ref]`),i=r instanceof HTMLElement?r.dataset.skillRef:void 0;if(i!==void 0){n.preventDefault();let e=d()?.get(i);return window.location.hash=e===void 0?C():S(w({scope:e.scope,name:i,path:e.path})),!0}let a=n.target?.closest?.(`.cm-skill-path-link`),o=a instanceof HTMLElement?a.dataset.skillPath:void 0;return o===void 0?!1:(n.preventDefault(),window.location.hash=f(t,e,o),!0)}})]}function Fe(e,t){return e.enabled?[Oe(),De(async n=>Ie(n.state.doc,await y(n.state.doc.toString(),e,t)),{delay:600})]:[]}function $(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function Ie(e,t){let n=[];for(let r of t){let t=$(e,r.range.start),i=$(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=Le(r);o&&(a.actions=[o]),n.push(a)}return n}function Le(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:$(n,e.range.start),to:$(n,e.range.end),insert:e.newText}))})}}}var Re=[L(),F(),B(),P(),V(),H(),ve.allowMultipleSelections.of(!0),E(),z(),X(),J(),R(),W(),U(),Z(),I.of([...q,...K,...Ee,...G,...Y,...Te])],ze=A.mark({class:`cm-link-ref-broken`}),Be=/^\s{0,3}\[([^\]]+)\]:\s/,Ve=/\[([^\]]*)\]\[([^\]]*)\]/g,He=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Ue(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function We(e){let t=[];return j(e).iterate({enter(e){if(He.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ge(e){let t=new Set,n=[],r=e.doc,i=We(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Ue(n.from,i))continue;let a=Be.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Ue(t.from,i)&&!Be.test(t.text))for(Ve.lastIndex=0;;){let e=Ve.exec(t.text);if(!e)break;let r=t.from+e.index;if(Ue(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(ze.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),A.set(a)}var Ke=k.define({create(e){return Ge(e)},update(e,t){return t.docChanged?Ge(t.state):e},provide:e=>N.decorations.from(e)}),qe=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Je=A.mark({class:`cm-del`}),Ye=A.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Xe=A.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ze(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Qe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!b.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(b.test(r.text))return{from:t.from,to:r.to}}return null}function $e(e,t){let n=[],r=j(e),i=Qe(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(Je.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=qe.exec(r.text),a=i?i[1].length:2,o=A.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=Ze(r.text),a=A.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(Ye.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(n)}var et=class{decorations;constructor(e){this.decorations=$e(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=$e(e.view.state,e.view.visibleRanges))}},tt=M.fromClass(et,{decorations:e=>e.decorations});function nt(){return[tt,Ke]}var rt=t(),it=56,at=O.define();function ot(e,t,n){let r=x(e.state.doc)[t.index];r&&a(n,()=>{e.dispatch({selection:T.cursor(r.from),effects:N.scrollIntoView(r.from,{y:`start`})}),e.focus()})}function st(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,o=Math.min(t.offset,i.length);a(r,()=>{e.dispatch({selection:T.cursor(o),effects:N.scrollIntoView(o,{y:`center`})}),e.focus()})})}function ct(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),o=r.line(i),s=Math.min(o.from+Math.max(0,t.column-1),o.to);a(n,()=>{e.dispatch({selection:T.cursor(s),effects:N.scrollIntoView(s,{y:`start`})}),e.focus()})}function lt(e){let t=(0,je.c)(50),{docName:a,ytext:o,provider:s,placeholder:d,isSourceModeActive:f}=e,p=(0,Q.useRef)(null),h=(0,Q.useRef)(null),[g,_]=(0,Q.useState)(null);if(g)throw g;let{resolvedTheme:v}=m(),{merged:y}=_e(),b=(0,Q.useRef)(f),x=y?.editor?.wordWrap??!0,{data:S}=Ce(a),C;t[0]!==S?.effective||t[1]!==y?(C=S?.effective??(y?.contentRules?ae(y.contentRules):re),t[0]=S?.effective,t[1]=y,t[2]=C):C=t[2];let w=C,T;t[3]===w?T=t[4]:(T=JSON.stringify(w),t[3]=w,t[4]=T);let E=T,O,k;t[5]===f?(O=t[6],k=t[7]):(O=()=>{b.current=f},k=[f],t[5]=f,t[6]=O,t[7]=k),(0,Q.useEffect)(O,k);let A=(0,Q.useRef)(null),j;t[8]!==a||t[9]!==w||t[10]!==d||t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==o?(j=()=>{let e=p.current;if(!e)return;let t=s.configuration.name??``,f,m=dt;try{f=r({docName:t,container:e,sizeStats:{viewCount:0,bytes:o.length},factory:e=>{let r=null,i=l({ydoc:s.document,ytext:o}),c=new D,u=new D,f=new D,p=new D,h=new N({state:ve.create({doc:o.toString(),extensions:[Re,we({scrollToMatch:e=>n(t)?N.scrollIntoView(e,{y:`start`}):at.of(null)}),I.of([be]),Ae(o,s.awareness),I.of(ke),...te({themeCompartment:c,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:u,wordWrap:x,currentDocName:t}),nt(),Pe(t),ce(),p.of(Fe(w,a)),i,N.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,de(t,`source`,ue(e.view)),Se(t,`source`,xe(e.view,t))},120))}),N.domEventHandlers({keydown:(e,t)=>!b.current||!ie()||!ge(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pe(),!0)}),f.of(ye(d??``)),N.theme({"&":{height:`100%`}}),N.scrollMargins.of(ut)]}),parent:e});de(t,`source`,ue(h)),Se(t,`source`,xe(h,t));let g=h.contentDOM;return g.addEventListener(`keydown`,m),g.addEventListener(`paste`,m),g.addEventListener(`drop`,m),g.addEventListener(`cut`,m),{view:h,ydoc:s.document,ytext:o,provider:s,themeCompartment:c,wordWrapCompartment:u,placeholderCompartment:f,lintCompartment:p}}}),A.current=f,h.current=f.view,u(a,f.view)}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),A.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=A.current;e&&(i(e),c(a,e.view)),A.current=null,h.current=null}},t[8]=a,t[9]=w,t[10]=d,t[11]=s,t[12]=v,t[13]=x,t[14]=o,t[15]=j):j=t[15];let M;t[16]!==s||t[17]!==o?(M=[o,s],t[16]=s,t[17]=o,t[18]=M):M=t[18],(0,Q.useEffect)(j,M);let P,F;t[19]===a?(P=t[20],F=t[21]):(P=()=>{},F=[a],t[19]=a,t[20]=P,t[21]=F),(0,Q.useEffect)(P,F);let L,R;t[22]===v?(L=t[23],R=t[24]):(R=()=>{let e=A.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?ee:ne)})},L=[v],t[22]=v,t[23]=L,t[24]=R),(0,Q.useEffect)(R,L);let z,B;t[25]===x?(z=t[26],B=t[27]):(z=()=>{let e=A.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(x?N.lineWrapping:[])})},B=[x],t[25]=x,t[26]=z,t[27]=B),(0,Q.useEffect)(z,B);let V,H;t[28]===d?(V=t[29],H=t[30]):(V=()=>{let e=A.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(ye(d??``))})},H=[d],t[28]=d,t[29]=V,t[30]=H),(0,Q.useEffect)(V,H);let U;t[31]!==a||t[32]!==w?(U=()=>{let e=A.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(Fe(w,a))})},t[31]=a,t[32]=w,t[33]=U):U=t[33];let W;t[34]===E?W=t[35]:(W=[E],t[34]=E,t[35]=W),(0,Q.useEffect)(U,W);let G,K;t[36]!==a||t[37]!==f?(G=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||t.mode!==`source`||!f)return;let n=h.current;n&&(ot(n,t,a),oe(a))};return window.addEventListener(he,e),()=>window.removeEventListener(he,e)},K=[a,f],t[36]=a,t[37]=f,t[38]=G,t[39]=K):(G=t[38],K=t[39]),(0,Q.useEffect)(G,K);let q,J;t[40]!==a||t[41]!==f?(q=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||!f)return;let n=h.current;n&&(ct(n,t,a),oe(a))};return window.addEventListener(me,e),()=>window.removeEventListener(me,e)},J=[a,f],t[40]=a,t[41]=f,t[42]=q,t[43]=J):(q=t[42],J=t[43]),(0,Q.useEffect)(q,J);let Y,X;t[44]!==a||t[45]!==f||t[46]!==s?(Y=()=>{if(!f)return;let e=h.current;if(!e)return;let t=le(a);if(!t)return;if(t.kind!==`selection-offset`){fe(a),t.kind===`outline`?ot(e,t.detail,a):t.kind===`lint`?ct(e,t.detail,a):t.kind===`raw-mdx`&&st(e,t.detail,()=>b.current,a);return}let n=!1,r=null;return queueMicrotask(()=>{if(n)return;let t=le(a);t?.kind===`selection-offset`&&(r=se({view:e,docName:a,navigation:t,ydoc:s.document,transition:{from:`wysiwyg`,to:`source`}}),r&&fe(a))}),()=>{n=!0,r?.cancel(`mode-flip`)}},X=[a,f,s],t[44]=a,t[45]=f,t[46]=s,t[47]=Y,t[48]=X):(Y=t[47],X=t[48]),(0,Q.useEffect)(Y,X);let Z;return t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,rt.jsx)(`div`,{ref:p,className:`source-editor h-full pb-3`}),t[49]=Z):Z=t[49],Z}function ut(){return{top:it}}function dt(){return g()}export{lt as SourceEditor,st as applyRawMdxNavigation};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{r}from"./dist-Nvb76hAm.js";import{n as i}from"./dist-PQ5KMVDh.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{t as s}from"./button-RQ5o7P7w.js";import{Nt as c,
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{r}from"./dist-Nvb76hAm.js";import{n as i}from"./dist-PQ5KMVDh.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{t as s}from"./button-RQ5o7P7w.js";import{Nt as c,ei as l,en as u,in as d,ti as f}from"./dist-CW-WKphO2.js";import{t as p}from"./x-B3zGPHCO.js";import{n as m}from"./dist-DmEZHXvB.js";import{f as h,p as g,u as _}from"./doc-paths-9WcZxMIM.js";import{$ as v}from"./navigation-targets-DdhmqoI-.js";import{t as y}from"./config-context-CmQUJBcL.js";import{f as b,h as x}from"./file-tree-adapter-NUvHutlM.js";import{t as ee}from"./use-live-xterm-theme-CqKt6OLh.js";var S=a(),C=2,w=1,te=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(C,Math.floor(u/e.css.cell.width)),rows:Math.max(w,Math.floor(l/e.css.cell.height))}}},T=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],ne=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],E;function re(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var ie=class{constructor(){if(this.version=`6`,!E){E=new Uint8Array(65536),E.fill(1),E[0]=0,E.fill(0,1,32),E.fill(0,127,160),E.fill(2,4352,4448),E[9001]=2,E[9002]=2,E.fill(2,11904,42192),E[12351]=1,E.fill(2,44032,55204),E.fill(2,63744,64256),E.fill(2,65040,65050),E.fill(2,65072,65136),E.fill(2,65280,65377),E.fill(2,65504,65511);for(let e=0;e<T.length;++e)E.fill(0,T[e][0],T[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?E[e]:re(e,ne)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=$e.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return $e.createPropertyValue(0,n,r)}},ae=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?se.isErrorNoTelemetry(e)?new se(e.message+`
|
|
2
2
|
|
|
3
3
|
`+e.stack):Error(e.message+`
|
|
4
4
|
|
|
@@ -143,4 +143,4 @@ ${s.join(`
|
|
|
143
143
|
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(H(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(R(()=>{Yp?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<Jp+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
144
144
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Jp+1&&(this._liveRegion.textContent+=io.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Xp=I([L(1,Mo),L(2,Vo),L(3,Uo)],Xp);var Zp=class extends z{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new V),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new V),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(R(()=>{Ss(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(H(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(H(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(H(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(H(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Qp(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ss(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Zp=I([L(1,Ho),L(2,Uo),L(3,Oo),L(4,qo)],Zp);function Qp(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var $p=class extends Rp{constructor(e={}){super(e),this._linkifier=this._register(new Es),this.browser=md,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Es),this._onCursorMove=this._register(new V),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new V),this.onKey=this._onKey.event,this._onRender=this._register(new V),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new V),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new V),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new V),this.onBell=this._onBell.event,this._onFocus=this._register(new V),this._onBlur=this._register(new V),this._onA11yCharEmitter=this._register(new V),this._onA11yTabEmitter=this._register(new V),this._onWillOpen=this._register(new V),this._setup(),this._decorationService=this._instantiationService.createInstance(Wp),this._instantiationService.setService(Lo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ld),this._instantiationService.setService(qo,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ro)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Fs.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Fs.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Fs.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Fs.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(R(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=K.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${U.ESC}]${n};${Sp(r)}${Du.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=G.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=G.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Xp,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(H(this.element,`copy`,e=>{this.hasSelection()&&so(e,this._selectionService)}));let e=e=>co(e,this.textarea,this.coreService,this.optionsService);this._register(H(this.textarea,`paste`,e)),this._register(H(this.element,`paste`,e)),vd?this._register(H(this.element,`mousedown`,e=>{e.button===2&&fo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(H(this.element,`contextmenu`,e=>{fo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ed&&this._register(H(this.element,`auxclick`,e=>{e.button===1&&uo(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(H(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(H(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(H(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(H(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(H(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(H(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(H(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(H(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,no.get()),Dd||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sd,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Vo,this._coreBrowserService),this._register(H(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(H(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(rd,this._document,this._helperContainer),this._instantiationService.setService(Bo,this._charSizeService),this._themeService=this._instantiationService.createInstance(df),this._instantiationService.setService(Ko,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ru),this._instantiationService.setService(Go,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Nd,this.rows,this.screenElement)),this._instantiationService.setService(Uo,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Ou,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(fd),this._instantiationService.setService(Ho,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Zp,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(yu,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(tf,this.element,this.screenElement,r)),this._instantiationService.setService(Wo,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(Fs.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(bu,this.screenElement)),this._register(H(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Xp,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Tu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Tu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(nd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(H(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(H(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=U.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){lo(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=Bp(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===U.ETX||n.key===U.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(em(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Z));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(U.ESC+`[I`):this.coreService.triggerDataEvent(U.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${U.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${U.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function em(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var tm=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},nm=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new xo)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},rm=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new nm(t)}getNullCell(){return new xo}},im=class extends z{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new V),this.onBufferChange=this._onBufferChange.event,this._normal=new rm(this._core.buffers.normal,`normal`),this._alternate=new rm(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},am=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},om=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},sm=[`cols`,`rows`],cm=0,lm=class extends z{constructor(e){super(),this._core=this._register(new $p(e)),this._addonManager=this._register(new tm),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(sm.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new am(this._core),this._parser}get unicode(){return this._checkProposedApi(),new om(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new im(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
145
145
|
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return no.get()},set promptLabel(e){no.set(e)},get tooMuchOutput(){return io.get()},set tooMuchOutput(e){io.set(e)}}}_verifyIntegers(...e){for(cm of e)if(cm===1/0||isNaN(cm)||cm%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(cm of e)if(cm&&(cm===1/0||isNaN(cm)||cm%1!=0||cm<0))throw Error(`This API only accepts positive integers`)}},um=e(n(),1),$=t(),dm=`https://docs.claude.com/en/docs/claude-code`;function fm(e){return e.claude===`not-found`?`claude-missing`:e.claude===`present`&&e.mcp===`needs-rewire`?`mcp-needs-rewire`:null}function pm(e){let t=(0,S.c)(29),{readiness:n,bridge:i,onDismiss:a}=e,{_:o}=r(),c;t[0]===n?c=t[1]:(c=fm(n),t[0]=n,t[1]=c);let l=c;if(l===null)return null;let u=l===`claude-missing`,d;t[2]!==o||t[3]!==u?(d=o(u?{id:`dNM58w`}:{id:`_bth6g`}),t[2]=o,t[3]=u,t[4]=d):d=t[4];let f=d,h;t[5]!==o||t[6]!==u?(h=o(u?{id:`E1tG2u`}:{id:`gfohmY`}),t[5]=o,t[6]=u,t[7]=h):h=t[7];let g=h,_;t[8]!==o||t[9]!==i.shell||t[10]!==i.terminal||t[11]!==u||t[12]!==a?(_=function(){if(u){i.shell.openExternal(dm);return}i.terminal.rewireClaudeMcp().then(e=>{if(e.rewireError!=null){m.error(o({id:`cn1sLi`}));return}a()}).catch(e=>{console.warn(`[terminal] rewireClaudeMcp failed:`,e),m.error(o({id:`cn1sLi`}))})},t[8]=o,t[9]=i.shell,t[10]=i.terminal,t[11]=u,t[12]=a,t[13]=_):_=t[13];let v=_,y;t[14]===f?y=t[15]:(y=(0,$.jsx)(`p`,{className:`min-w-0 flex-1`,children:f}),t[14]=f,t[15]=y);let b;t[16]!==g||t[17]!==v?(b=(0,$.jsx)(s,{size:`sm`,variant:`secondary`,className:`shrink-0`,onClick:v,children:g}),t[16]=g,t[17]=v,t[18]=b):b=t[18];let x;t[19]===o?x=t[20]:(x=o({id:`1QfxQT`}),t[19]=o,t[20]=x);let ee;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(p,{"aria-hidden":`true`,className:`size-4`}),t[21]=ee):ee=t[21];let C;t[22]!==a||t[23]!==x?(C=(0,$.jsx)(s,{size:`icon`,variant:`ghost`,"aria-label":x,className:`size-6 shrink-0`,onClick:a,children:ee}),t[22]=a,t[23]=x,t[24]=C):C=t[24];let w;return t[25]!==y||t[26]!==b||t[27]!==C?(w=(0,$.jsxs)(`div`,{role:`status`,"data-testid":`terminal-readiness-banner`,className:`flex shrink-0 items-center gap-3 border-border border-b bg-muted px-3 py-2 text-foreground text-xs`,children:[y,b,C]}),t[25]=y,t[26]=b,t[27]=C,t[28]=w):w=t[28],w}function mm(e){let t=(0,S.c)(25),{cli:n,bridge:i,onDismiss:a}=e,{_:o}=r(),{bin:l,displayName:u,docsUrl:d}=c[n],f;t[0]!==o||t[1]!==l||t[2]!==u?(f=o({id:`rSoi6g`,values:{displayName:u,bin:l}}),t[0]=o,t[1]=l,t[2]=u,t[3]=f):f=t[3];let m;t[4]===f?m=t[5]:(m=(0,$.jsx)(`p`,{className:`min-w-0 flex-1`,children:f}),t[4]=f,t[5]=m);let h;t[6]!==i.shell||t[7]!==d?(h=()=>void i.shell.openExternal(d),t[6]=i.shell,t[7]=d,t[8]=h):h=t[8];let g;t[9]!==o||t[10]!==u?(g=o({id:`F0OA00`,values:{displayName:u}}),t[9]=o,t[10]=u,t[11]=g):g=t[11];let _;t[12]!==h||t[13]!==g?(_=(0,$.jsx)(s,{size:`sm`,variant:`secondary`,className:`shrink-0`,onClick:h,children:g}),t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]===o?v=t[16]:(v=o({id:`1QfxQT`}),t[15]=o,t[16]=v);let y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(p,{"aria-hidden":`true`,className:`size-4`}),t[17]=y):y=t[17];let b;t[18]!==a||t[19]!==v?(b=(0,$.jsx)(s,{size:`icon`,variant:`ghost`,"aria-label":v,className:`size-6 shrink-0`,onClick:a,children:y}),t[18]=a,t[19]=v,t[20]=b):b=t[20];let x;return t[21]!==m||t[22]!==_||t[23]!==b?(x=(0,$.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-center gap-3 border-border border-b bg-muted px-3 py-2 text-foreground text-xs`,children:[m,_,b]}),t[21]=m,t[22]=_,t[23]=b,t[24]=x):x=t[24],x}function hm(e){let t=(0,S.c)(20),{info:n,onRestart:i}=e,{_:a}=r(),o;if(n.error!=null){let e;t[0]===a?e=t[1]:(e=a({id:`uL_Wx8`}),t[0]=a,t[1]=e),o=e}else if(n.signal!=null&&n.signal!==0){let e;t[2]!==a||t[3]!==n.signal?(e=a({id:`ubMwcO`,values:{0:n.signal}}),t[2]=a,t[3]=n.signal,t[4]=e):e=t[4],o=e}else if(n.exitCode!==0){let e;t[5]!==a||t[6]!==n.exitCode?(e=a({id:`q4YJl_`,values:{0:n.exitCode}}),t[5]=a,t[6]=n.exitCode,t[7]=e):e=t[7],o=e}else{let e;t[8]===a?e=t[9]:(e=a({id:`AE7BY3`}),t[8]=a,t[9]=e),o=e}let c;t[10]===o?c=t[11]:(c=(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:o}),t[10]=o,t[11]=c);let l;t[12]===a?l=t[13]:(l=a({id:`BQKHuL`}),t[12]=a,t[13]=l);let u;t[14]!==i||t[15]!==l?(u=(0,$.jsx)(s,{size:`sm`,variant:`outline`,className:`uppercase font-mono`,onClick:i,children:l}),t[14]=i,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==c||t[18]!==u?(d=(0,$.jsxs)(`div`,{role:`alert`,className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/90 dark:bg-transparent p-6 text-center`,children:[c,u]}),t[17]=c,t[18]=u,t[19]=d):d=t[19],d}function gm(e){let t=(0,S.c)(11),{reason:n,onClose:i}=e,{_:a}=r(),o;t[0]!==a||t[1]!==n?(o=a(n===`not-consented`?{id:`Khxcyu`}:{id:`fBHvBn`}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let c=o,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`p`,{className:`max-w-sm text-sm`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==a||t[6]!==i?(u=i?(0,$.jsx)(s,{size:`sm`,variant:`secondary`,onClick:i,children:a({id:`Iq8zdU`})}):null,t[5]=a,t[6]=i,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`div`,{role:`alert`,className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/90 p-6 text-center text-foreground`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d}function _m(e,t){let n=Om(e,t);return n===null?e.startsWith(`/`)?e===vm(t)?null:{kind:`external`,absPath:e}:null:{kind:`in-project`,relPath:n}}function vm(e){return e.replace(/\/+$/,``)}var ym=2e3,bm=/[^\s<>"'`|(){}[\]\0]+/g,xm=/:\d+(?::\d+)?$/,Sm=/^[a-z][a-z0-9+.-]*:\/\//i,Cm=/\.[A-Za-z0-9]+$/;function wm(e){return Cm.test(e)}function Tm(e,t=10){if(e.length===0||e.length>ym)return[];let n=[];for(let r of e.matchAll(bm)){if(n.length>=t)break;let e=r[0],i=r.index;if(Sm.test(e))continue;let a=e.replace(/[.,;:!?]+$/,``),o=a.match(xm);o&&(a=a.slice(0,o.index));let s=a.endsWith(`/`),c=s?a.slice(0,-1):a;if(!Dm(c))continue;let l=i+c.length;n.push({path:c,startIndex:i,endIndex:l,trailingSlash:s})}return n}function Em(e,t,n,r){let i=r>0?r:2**53-1,a=Math.max(e,t-1),o=e=>({x:e%i+1,y:n+Math.floor(e/i)});return{start:o(e),end:o(a)}}function Dm(e){return e.length<2||e.startsWith(`~`)?!1:e.includes(`/`)?!0:Cm.test(e)}function Om(e,t){if(!e||!t)return null;let n=vm(t),r;if(e.startsWith(`/`)){if(e===n)return null;let t=`${n}/`;if(!e.startsWith(t))return null;r=e.slice(t.length)}else r=e.startsWith(`./`)?e.slice(2):e;let i=[];for(let e of r.split(`/`))if(!(e===``||e===`.`)){if(e===`..`)return null;i.push(e)}return i.length===0?null:i.join(`/`)}function km(e,t,n){return t||n?.folderPaths.has(e)?`folder`:e.endsWith(`.md`)||e.endsWith(`.mdx`)||n?.pages.has(_(e))?`doc`:`asset`}function Am(e=300){let t=null;return(n,r)=>t!==null&&t.uri===n&&r-t.at<e?!0:(t={uri:n,at:r},!1)}function jm(e,t,n){return n?t?n.folderPaths.has(e):n.pages.has(_(e))||n.assetPaths?.has(e)||n.filePaths?.has(e)?!0:n.folderPaths.has(e):!1}var Mm=1e3;function Nm(e){let t=e.maxLinksPerLine??10,n=new Map,r=!1,i=!1;async function a(t,i){let a=`${t}:${i}`,o=n.get(a);if(o!==void 0)return o;let s=!1;try{s=await e.checkTargetExists(t,i)===`exists`}catch(e){s=!1,r||(r=!0,console.warn(`[terminal] checkTargetExists probe failed; file-path links suppressed:`,e))}return n.size>=Mm&&n.clear(),n.set(a,s),s}async function o(e,t,n){let r=km(e,t,n);return jm(e,t,n)?{kind:r,relPath:e}:r===`folder`?await a(`folder`,e)?{kind:r,relPath:e}:null:await a(`doc`,e)?{kind:r,relPath:e}:!wm(e)&&await a(`folder`,e)?{kind:`folder`,relPath:e}:null}return{provideLinks(n,r){let a=e.readLogicalLine(n);if(!a||a.text.length===0){r(void 0);return}let{text:s,startLine:c,cols:l}=a,u=Tm(s,t);if(u.length===0){r(void 0);return}let d=e.getSnapshot();Promise.all(u.map(async t=>{let n=_m(t.path,e.projectPath);if(n===null)return null;let r;if(n.kind===`external`)r={kind:`external`,absPath:n.absPath};else{let e=await o(n.relPath,t.trailingSlash,d);if(e===null)return null;r=e}return{text:t.path,range:Em(t.startIndex,t.endIndex,c,l),activate:()=>e.onActivate(r)}})).then(e=>{let t=e.filter(e=>e!==null);r(t.length>0?t:void 0)}).catch(e=>{i||(i=!0,console.warn(`[terminal] link provider failed to compute links:`,e)),r(void 0)})}}}function Pm(e,t=console.warn){let n=!1;return()=>{e.refresh(0,e.rows-1);let r=e._core?._renderService?._renderDebouncer;typeof r?._innerRefresh==`function`?r._innerRefresh():n||(n=!0,t(`[terminal] xterm render-debouncer internal not found; resize repaint deferring to the next frame. An xterm upgrade may have moved _core._renderService._renderDebouncer.`))}}var Fm={setTimer:(e,t)=>setTimeout(e,t),clearTimer:e=>clearTimeout(e)};function Im(e,t,n=Fm){let r=null,i=!1;function a(){r=n.setTimer(()=>{r=null,i&&(i=!1,e(),a())},t)}return{request(){if(r!==null){i=!0;return}e(),a()},cancel(){r!==null&&(n.clearTimer(r),r=null),i=!1}}}var Lm=1,Rm=2;function zm(e,t,n,r){let i=n+(t===Lm?e:t===Rm?e*r.viewportRows:e/r.cellHeight)*r.sensitivity,a=Math.trunc(i);return a===0?{count:0,button:65,accumulator:i}:{count:Math.min(Math.abs(a),r.maxRowsPerEvent),button:a<0?64:65,accumulator:i-a}}var Bm=9;function Vm(e,t,n){let r=n.cellWidth!==void 0&&n.cellWidth>0?n.cellWidth:void 0,i=(e,t)=>Math.min(Math.max(e,1),t);if(n.pixels){let a=Math.round((r??Bm)*n.cols),o=Math.round(n.cellHeight*n.rows);return{x:Hm(e)?i(Math.floor(e)+1,a):Math.ceil(a/2),y:Hm(t)?i(Math.floor(t)+1,o):Math.ceil(o/2)}}return{x:Hm(e)&&r!==void 0?i(Math.floor(e/r)+1,n.cols):Math.ceil(n.cols/2),y:Hm(t)?i(Math.floor(t/n.cellHeight)+1,n.rows):Math.ceil(n.rows/2)}}function Hm(e){return e!==void 0&&Number.isFinite(e)}function Um(e,t){return`\x1b[<${e};${t.x};${t.y}M`}var Wm=100;function Gm(e){let t=(0,S.c)(21),{bridge:n,className:a,onClose:s,onExit:c,onTitleChange:l,launch:u,adoptPtyId:d,onPtyId:f}=e,p=u===void 0?null:u,m=d===void 0?null:d,{_:h}=r(),{resolvedTheme:g}=i(),_=ee(g),[v,y]=(0,um.useState)(0),b=v===0?m:null,x;t[0]===h?x=t[1]:(x=h({id:`ALhMYW`}),t[0]=h,t[1]=x);let C;t[2]===_.background?C=t[3]:(C={backgroundColor:_.background},t[2]=_.background,t[3]=C);let w;t[4]===a?w=t[5]:(w=o(`relative flex h-full w-full flex-col overflow-hidden`,a),t[4]=a,t[5]=w);let te;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>y(Km),t[6]=te):te=t[6];let T;t[7]!==b||t[8]!==n||t[9]!==p||t[10]!==s||t[11]!==c||t[12]!==f||t[13]!==l||t[14]!==v?(T=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1`,children:(0,$.jsx)(qm,{bridge:n,onClose:s,onExit:c,onTitleChange:l,onRestart:te,launch:p,adoptPtyId:b,onPtyId:f},v)}),t[7]=b,t[8]=n,t[9]=p,t[10]=s,t[11]=c,t[12]=f,t[13]=l,t[14]=v,t[15]=T):T=t[15];let ne;return t[16]!==x||t[17]!==C||t[18]!==w||t[19]!==T?(ne=(0,$.jsx)(`section`,{"aria-label":x,style:C,className:w,children:T}),t[16]=x,t[17]=C,t[18]=w,t[19]=T,t[20]=ne):ne=t[20],ne}function Km(e){return e+1}function qm(e){let t=(0,S.c)(51),{bridge:n,onClose:r,onExit:a,onTitleChange:o,onRestart:s,launch:c,adoptPtyId:p,onPtyId:m}=e,C=c===void 0?null:c,w=p===void 0?null:p,T=(0,um.useRef)(null),ne=(0,um.useRef)(a),E=(0,um.useRef)(o),re=(0,um.useRef)(m),{resolvedTheme:ie}=i(),ae=ee(ie),D=(0,um.useRef)(null),O=(0,um.useRef)(ae),[k,oe]=(0,um.useState)(`starting`),[se,ce]=(0,um.useState)(null),[le,ue]=(0,um.useState)(null),A=(0,um.useRef)(null),[de,fe]=(0,um.useState)(null),pe=(0,um.use)(y),me=(0,um.useRef)(pe?.userConfig?.agents?.autoApproveOkTools??!0),he;t[0]!==pe?.userConfig?.agents?.autoApproveOkTools||t[1]!==a||t[2]!==m||t[3]!==o?(he=()=>{ne.current=a,E.current=o,re.current=m,me.current=pe?.userConfig?.agents?.autoApproveOkTools??!0},t[0]=pe?.userConfig?.agents?.autoApproveOkTools,t[1]=a,t[2]=m,t[3]=o,t[4]=he):he=t[4],(0,um.useEffect)(he);let ge;t[5]!==w||t[6]!==n.accessibility||t[7]!==n.config||t[8]!==n.project||t[9]!==n.shell||t[10]!==n.terminal||t[11]!==C?(ge=()=>{let e=T.current;if(!e)return;let t=!1,r=null,i,a,o,s,c,l,p,m,y,b=n.config.e2eSmoke===!0||(n.accessibility?.isScreenReaderActive()??!0),x=Am(),ee=e=>{D.current?.modes.mouseTrackingMode===`none`&&(x(e,Date.now())||n.shell.openExternal(e))},S=new lm({screenReaderMode:b,minimumContrastRatio:4.5,allowProposedApi:!0,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, monospace`,fontSize:13,scrollback:1e4,smoothScrollDuration:125,scrollSensitivity:3,linkHandler:{activate:(e,t)=>ee(t)},theme:O.current});D.current=S;let ie=new te;if(S.loadAddon(ie),S.loadAddon(new st),S.unicode.activeVersion=`11`,S.loadAddon(new pt((e,t)=>ee(t))),S.open(e),l=S.registerLinkProvider(Nm({projectPath:n.config.projectPath,readLogicalLine:e=>{let t=S.buffer.active,n=e-1;if(!t.getLine(n))return;let r=n;for(;r>0&&t.getLine(r)?.isWrapped;)r--;let i=n;for(;t.getLine(i+1)?.isWrapped;)i++;let a=``;for(let e=r;e<=i;e++)a+=t.getLine(e)?.translateToString(!1)??``;return{text:a,startLine:r+1,cols:S.cols}},getSnapshot:v,checkTargetExists:(e,t)=>n.project.checkTargetExists({projectPath:n.config.projectPath,kind:e,path:t}),onActivate:e=>{switch(e.kind){case`doc`:window.location.hash=h(_(e.relPath));return;case`folder`:window.location.hash=g(e.relPath);return;case`external`:n.shell.revealExternal(e.absPath).catch(th);return;case`asset`:n.shell.openAsset(e.relPath).then(t=>{if(!t.ok){if(t.reason===`extension-blocked`){n.shell.revealAsset(e.relPath).catch(eh);return}console.warn(`[terminal] openAsset refused:`,t.reason)}}).catch($m);return;default:return e}}})),n.config.e2eSmoke!==!0)try{let e=new Za;e.onContextLoss(()=>{console.warn(`[terminal] WebGL context lost, falling back to DOM renderer`),e.dispose()}),S.loadAddon(e)}catch(e){let t=e;(t instanceof Error&&/webgl2?|context/i.test(t.message)?console.warn:console.error)(`[terminal] WebGL addon failed, using DOM renderer:`,t)}ie.fit();let ae=Pm(S),k=e.querySelector(`.xterm-screen canvas`);if(k!==null){m=new ResizeObserver(()=>ae());try{m.observe(k,{box:`device-pixel-content-box`})}catch(e){console.warn(`[terminal] device-pixel canvas observe failed:`,e),m.disconnect(),m=void 0}}c=S.onTitleChange(e=>{t||E.current?.(e)}),S.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`||!e.shiftKey)return!0;if(e.key===`Tab`)return e.preventDefault(),!0;if(e.key===`Enter`){let t=A.current;return t===null?!0:(e.preventDefault(),n.terminal.input(t,`
|
|
146
|
-
`),!1)}return!0});let se=0,le=!1;S.attachCustomWheelEventHandler(e=>{let t=S._core,r=t?.coreMouseService?.activeEncoding;if(!(S.modes.mouseTrackingMode!==`none`&&(r===`SGR`||r===`SGR_PIXELS`)))return se=0,!0;let i=A.current;if(i===null||e.deltaY===0)return!0;let a=t?._renderService?.dimensions?.css?.cell?.height;a===void 0&&!le&&(le=!0,console.warn(`[terminal] xterm cell-height internal not found; wheel scroll using fallback. An xterm upgrade may have moved _core._renderService.dimensions.css.cell.height.`));let o=a??17,{count:s,button:c,accumulator:l}=zm(e.deltaY,e.deltaMode,se,{cellHeight:o,sensitivity:1.5,maxRowsPerEvent:20,viewportRows:S.rows});if(se=l,s>0){let a=(S.element?.querySelector(`.xterm-screen`)??S.element)?.getBoundingClientRect(),l=Vm(a===void 0?void 0:e.clientX-a.left,a===void 0?void 0:e.clientY-a.top,{cellWidth:t?._renderService?.dimensions?.css?.cell?.width,cellHeight:o,cols:S.cols,rows:S.rows,pixels:r===`SGR_PIXELS`});n.terminal.input(i,Um(c,l).repeat(s))}return!1});let de=s=>{r=s,A.current=s,re.current?.(s),oe(`running`),S.onData(e=>{r&&n.terminal.input(r,e)}),i=n.terminal.onData(e=>{e.ptyId===r&&(S.write(e.data,()=>n.terminal.drain(e.ptyId,e.data.length)),o?.(e.data))}),a=n.terminal.onExit(e=>{e.ptyId===r&&(ue({exitCode:e.exitCode,signal:e.signal,error:e.error}),oe(`exited`),ne.current?.({exitCode:e.exitCode,signal:e.signal}))}),y=Im(()=>{r&&n.terminal.resize(r,S.cols,S.rows)},Wm),p=new ResizeObserver(()=>{let e=S.cols,t=S.rows;ie.fit(),(S.cols!==e||S.rows!==t)&&ae(),y?.request()}),p.observe(e),S.focus(),C!==null&&w===null||n.terminal.claudePreflight().then(e=>{t||ce(e)}).catch(Qm)},pe=async e=>{if(e.cli===`claude`){try{let r=await n.terminal.claudePreflight();if(r.claude===`present`)return t||ce(r),
|
|
146
|
+
`),!1)}return!0});let se=0,le=!1;S.attachCustomWheelEventHandler(e=>{let t=S._core,r=t?.coreMouseService?.activeEncoding;if(!(S.modes.mouseTrackingMode!==`none`&&(r===`SGR`||r===`SGR_PIXELS`)))return se=0,!0;let i=A.current;if(i===null||e.deltaY===0)return!0;let a=t?._renderService?.dimensions?.css?.cell?.height;a===void 0&&!le&&(le=!0,console.warn(`[terminal] xterm cell-height internal not found; wheel scroll using fallback. An xterm upgrade may have moved _core._renderService.dimensions.css.cell.height.`));let o=a??17,{count:s,button:c,accumulator:l}=zm(e.deltaY,e.deltaMode,se,{cellHeight:o,sensitivity:1.5,maxRowsPerEvent:20,viewportRows:S.rows});if(se=l,s>0){let a=(S.element?.querySelector(`.xterm-screen`)??S.element)?.getBoundingClientRect(),l=Vm(a===void 0?void 0:e.clientX-a.left,a===void 0?void 0:e.clientY-a.top,{cellWidth:t?._renderService?.dimensions?.css?.cell?.width,cellHeight:o,cols:S.cols,rows:S.rows,pixels:r===`SGR_PIXELS`});n.terminal.input(i,Um(c,l).repeat(s))}return!1});let de=s=>{r=s,A.current=s,re.current?.(s),oe(`running`),S.onData(e=>{r&&n.terminal.input(r,e)}),i=n.terminal.onData(e=>{e.ptyId===r&&(S.write(e.data,()=>n.terminal.drain(e.ptyId,e.data.length)),o?.(e.data))}),a=n.terminal.onExit(e=>{e.ptyId===r&&(ue({exitCode:e.exitCode,signal:e.signal,error:e.error}),oe(`exited`),ne.current?.({exitCode:e.exitCode,signal:e.signal}))}),y=Im(()=>{r&&n.terminal.resize(r,S.cols,S.rows)},Wm),p=new ResizeObserver(()=>{let e=S.cols,t=S.rows;ie.fit(),(S.cols!==e||S.rows!==t)&&ae(),y?.request()}),p.observe(e),S.focus(),C!==null&&w===null||n.terminal.claudePreflight().then(e=>{t||ce(e)}).catch(Qm)},pe=async e=>{if(e.cli===`claude`){try{let r=await n.terminal.claudePreflight();if(r.claude===`present`)return t||ce(r),u(`claude`,e.prompt,{mcpPreApprove:r.mcpPreApprovable===!0,autoApproveOkTools:me.current&&r.mcpPreApprovable===!0});t||ce(r.claude===`not-found`?r:{claude:`not-found`,mcp:r.mcp,mcpPreApprovable:!1})}catch(e){console.warn(`[terminal] claude launch preflight failed`,e),t||ce({claude:`not-found`,mcp:`needs-rewire`,mcpPreApprovable:!1})}return}try{let r=await n.terminal.cliPreflight(e.cli);if(r.onPath===`unknown`){if(t)return;r=await n.terminal.cliPreflight(e.cli)}if(r.onPath===`present`)return u(e.cli,e.prompt,{autoApproveOkTools:e.cli===`codex`&&r.okServerConfigured===!0&&me.current})}catch(t){let n=t;console.warn(`[terminal] cliPreflight failed`,{cli:e.cli,err:n})}t||fe(e.cli)},he;return(async()=>{if(w!==null){let e;try{e=await n.terminal.adopt(w)}catch(t){console.error(`[terminal] adopt() failed:`,t),e={ok:!1,reason:`unknown-session`}}if(t)return;if(e.ok){e.replay&&S.write(e.replay),de(w),n.terminal.resize(w,S.cols,S.rows);return}}let e;if(C!==null&&w===null&&(e=await pe(C),t))return;let r;try{r=await n.terminal.create({cols:S.cols,rows:S.rows,launchCommand:e})}catch(e){let n=e;if(console.error(`[terminal] create() failed:`,n),t)return;ue({exitCode:1,signal:null,error:n instanceof Error?n.message:String(n)}),oe(`exited`);return}if(t){r.ok&&n.terminal.kill(r.ptyId).catch(Zm);return}if(!r.ok){oe(r.reason===`not-consented`?`not-consented`:`no-project`);return}de(r.ptyId);let i=C?.stagePaste,a=C!=null&&e!==void 0&&C.prompt!=null?d(C.cli,C.prompt):null;if(a!=null&&C!=null){let e=f(C.cli),r=e?.settleMs??500,i=e?.readyMarker,c=a,l=!1,u=()=>{l||(l=!0,o=void 0,he!==void 0&&clearTimeout(he),s!==void 0&&clearTimeout(s),!(t||A.current===null)&&(n.terminal.input(A.current,c),S.focus()))};if(s=setTimeout(u,e?.capMs??r),i!=null){let e=``;o=t=>{if(!(l||he!==void 0)){if(e+=t,e.includes(i)){o=void 0,he=setTimeout(u,r);return}e.length>i.length+256&&(e=e.slice(-(i.length+256)))}}}else he=setTimeout(u,r)}else C!=null&&C.prompt!=null&&i!=null?console.warn(`[terminal] TerminalLaunchIntent carried both prompt and stagePaste; dropping stagePaste`):e!==void 0&&i!=null&&i!==``&&(he=setTimeout(()=>{t||A.current===null||(n.terminal.input(A.current,i),S.focus())},500))})(),()=>{t=!0,he!==void 0&&clearTimeout(he),s!==void 0&&clearTimeout(s),o=void 0,A.current=null,re.current?.(null),D.current=null,p?.disconnect(),m?.disconnect(),y?.cancel(),i?.(),a?.(),c?.dispose(),l?.dispose(),S.dispose(),r&&n.terminal.kill(r).catch(Xm)}},t[5]=w,t[6]=n.accessibility,t[7]=n.config,t[8]=n.project,t[9]=n.shell,t[10]=n.terminal,t[11]=C,t[12]=ge):ge=t[12];let _e;t[13]!==w||t[14]!==n||t[15]!==C?(_e=[n,w,C],t[13]=w,t[14]=n,t[15]=C,t[16]=_e):_e=t[16],(0,um.useEffect)(ge,_e);let ve,ye;t[17]===ae?(ve=t[18],ye=t[19]):(ve=()=>{let e=D.current;e!==null&&(e.options.theme=ae)},ye=[ae],t[17]=ae,t[18]=ve,t[19]=ye),(0,um.useEffect)(ve,ye);let be;t[20]!==n.accessibility||t[21]!==n.config?(be=()=>{let e=n.accessibility;if(!(e==null||n.config.e2eSmoke===!0))return e.onScreenReaderChanged(e=>{let t=D.current;t!==null&&(t.options.screenReaderMode=e)})},t[20]=n.accessibility,t[21]=n.config,t[22]=be):be=t[22];let xe;t[23]===n?xe=t[24]:(xe=[n],t[23]=n,t[24]=xe),(0,um.useEffect)(be,xe);let Se,Ce;t[25]===n?(Se=t[26],Ce=t[27]):(Se=()=>{let e=T.current;if(e===null)return;let t=function(e){x(e)&&e.preventDefault()},r=function(e){if(!x(e))return;e.preventDefault();let t=A.current;if(t===null)return;let r=b(e).map(e=>n.getPathForFile(e)).filter(Jm);r.length!==0&&n.terminal.input(t,`${r.map(l).join(` `)} `)};return e.addEventListener(`dragover`,t,{capture:!0}),e.addEventListener(`drop`,r,{capture:!0}),()=>{e.removeEventListener(`dragover`,t,{capture:!0}),e.removeEventListener(`drop`,r,{capture:!0})}},Ce=[n],t[25]=n,t[26]=Se,t[27]=Ce),(0,um.useEffect)(Se,Ce);let we;t[28]!==n||t[29]!==se||t[30]!==k?(we=k===`running`&&se?(0,$.jsx)(pm,{readiness:se,bridge:n,onDismiss:()=>ce(null)}):null,t[28]=n,t[29]=se,t[30]=k,t[31]=we):we=t[31];let Te;t[32]!==n||t[33]!==de||t[34]!==k?(Te=k===`running`&&de?(0,$.jsx)(mm,{cli:de,bridge:n,onDismiss:()=>fe(null)}):null,t[32]=n,t[33]=de,t[34]=k,t[35]=Te):Te=t[35];let Ee;t[36]===k?Ee=t[37]:(Ee=(0,$.jsx)(`div`,{ref:T,"data-terminal-status":k,className:`min-h-0 flex-1 px-1.5`}),t[36]=k,t[37]=Ee);let De;t[38]!==le||t[39]!==s||t[40]!==k?(De=k===`exited`&&le?(0,$.jsx)(hm,{info:le,onRestart:s}):null,t[38]=le,t[39]=s,t[40]=k,t[41]=De):De=t[41];let Oe;t[42]!==r||t[43]!==k?(Oe=k===`no-project`||k===`not-consented`?(0,$.jsx)(gm,{reason:k,onClose:r}):null,t[42]=r,t[43]=k,t[44]=Oe):Oe=t[44];let ke;return t[45]!==we||t[46]!==Te||t[47]!==Ee||t[48]!==De||t[49]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[we,Te,Ee,De,Oe]}),t[45]=we,t[46]=Te,t[47]=Ee,t[48]=De,t[49]=Oe,t[50]=ke):ke=t[50],ke}function Jm(e){return e!==null&&e!==``&&!Array.from(e).some(Ym)}function Ym(e){return e.charCodeAt(0)<32}function Xm(e){return console.warn(`[terminal] kill on unmount failed:`,e)}function Zm(e){return console.warn(`[terminal] kill after cancelled mount failed:`,e)}function Qm(e){console.warn(`[terminal] claude readiness preflight failed`,e)}function $m(e){return console.warn(`[terminal] openAsset failed:`,e)}function eh(e){return console.warn(`[terminal] revealAsset failed:`,e)}function th(e){return console.warn(`[terminal] revealExternal failed:`,e)}export{Gm as TerminalPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{t as a}from"./config-provider-
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{t as a}from"./config-provider-xRIhjgw3.js";import{t as o}from"./use-installed-clis-B7_xP0xS.js";import{t as s}from"./use-live-xterm-theme-CqKt6OLh.js";import{SessionsHost as c}from"./SessionsHost-BMspzxaf.js";var l=i(),u=e(n(),1),d=t();function f(e){let t=(0,l.c)(5),{bridge:n}=e,r=n.config.collabUrl?n.config.collabUrl:null,i;t[0]===n?i=t[1]:(i=(0,d.jsx)(p,{bridge:n}),t[0]=n,t[1]=i);let o;return t[2]!==r||t[3]!==i?(o=(0,d.jsx)(a,{collabUrl:r,children:i}),t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function p(e){let t=(0,l.c)(9),{bridge:n}=e,{resolvedTheme:i}=r(),a=s(i),f=o(),[p,g]=(0,u.useState)(null),_;t[0]===a.background?_=t[1]:(_=(0,d.jsx)(`div`,{ref:g,className:`flex h-screen min-h-0 flex-col`,style:{backgroundColor:a.background}}),t[0]=a.background,t[1]=_);let v;t[2]!==n||t[3]!==p||t[4]!==f?(v=(0,d.jsx)(c,{bridge:n,surface:`terminal-window`,terminalCapable:!0,visible:!0,onVisibleChange:h,installedClis:f,container:p,isShowing:!0,onRequestEditorFocus:m}),t[2]=n,t[3]=p,t[4]=f,t[5]=v):v=t[5];let y;return t[6]!==_||t[7]!==v?(y=(0,d.jsxs)(d.Fragment,{children:[_,v]}),t[6]=_,t[7]=v,t[8]=y):y=t[8],y}function m(){}function h(e){e||window.close()}export{f as TerminalWindowApp};
|