texlite 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/DESIGN.md +12 -14
  2. package/OPERATIONS.md +12 -6
  3. package/README.md +9 -4
  4. package/README.zh-CN.md +7 -4
  5. package/dist/client/assets/{AdminUsers-C7oU_1Y_.js → AdminUsers-BExOMZsW.js} +1 -1
  6. package/dist/client/assets/{CitationLibraryDialog-CU2b0xtm.js → CitationLibraryDialog-tVD3i2gg.js} +1 -1
  7. package/dist/client/assets/Dashboard-DRt4rjKP.js +2 -0
  8. package/dist/client/assets/{GitDialog-C2Np1i8v.js → GitDialog-CjDCi1uh.js} +1 -1
  9. package/dist/client/assets/{HistoryDialog-CdoYeLyX.js → HistoryDialog-Pa9mK3Ky.js} +1 -1
  10. package/dist/client/assets/{LatexEditor-Dmy6_gqt.js → LatexEditor-8r486VeG.js} +2 -2
  11. package/dist/client/assets/PdfPreview-CMkO72I5.js +1 -0
  12. package/dist/client/assets/{ProjectIconPickerDialog-CsjMKq7h.js → ProjectIconPickerDialog-B52xbSyr.js} +1 -1
  13. package/dist/client/assets/{ProjectNavigationDialogs-_JY0yVob.js → ProjectNavigationDialogs-isGMXCfG.js} +1 -1
  14. package/dist/client/assets/ProjectSettings-Br_kJ113.js +1 -0
  15. package/dist/client/assets/ProjectWorkspace-CcbrdCy8.js +32 -0
  16. package/dist/client/assets/{SelectionHistoryDialog-D8CeqjLD.js → SelectionHistoryDialog-ZvAhIJMy.js} +2 -2
  17. package/dist/client/assets/{SystemMetricsDialog-BZx7ZMQt.js → SystemMetricsDialog-D4ouU4HI.js} +1 -1
  18. package/dist/client/assets/{TagManagementDialog-4R1Gs43j.js → TagManagementDialog-qhZfHgTr.js} +1 -1
  19. package/dist/client/assets/{WordCountDialog-C-MCscAu.js → WordCountDialog-tFhMCGyn.js} +1 -1
  20. package/dist/client/assets/check-DKIW1zpR.js +1 -0
  21. package/dist/client/assets/chktex-tM1XXPk2.js +3 -0
  22. package/dist/client/assets/{hard-drive-Bsk-RETn.js → hard-drive-CkIPwUSV.js} +1 -1
  23. package/dist/client/assets/index-90X2GUd_.css +1 -0
  24. package/dist/client/assets/index-CqBmQAzW.js +10 -0
  25. package/dist/client/assets/{index-Csp5J5aI.js → index-DTYEGzB7.js} +1 -1
  26. package/dist/client/assets/{key-round-DqptHHKC.js → key-round-BEnQo7IM.js} +1 -1
  27. package/dist/client/assets/{minimize-2-92UqFWI9.js → minimize-2-CLuDohEf.js} +1 -1
  28. package/dist/client/assets/{minus-bx4ZLZnb.js → minus-BpuvzV2m.js} +1 -1
  29. package/dist/client/assets/{plus-DQg_bV50.js → plus-BFr75l91.js} +1 -1
  30. package/dist/client/assets/{refresh-cw-BoMEkk5J.js → refresh-cw-DyA4NKh7.js} +1 -1
  31. package/dist/client/assets/{search-UZspmceH.js → search-Nu4OcY_n.js} +1 -1
  32. package/dist/client/assets/{sigma-C0IvFdKV.js → sigma-B-wjepsY.js} +1 -1
  33. package/dist/client/assets/{spellCheck-DyKIHf5C.js → spellCheck-C-bNJsIU.js} +1 -1
  34. package/dist/client/assets/{tags-BTUtvaAc.js → tags-BSA08jK3.js} +1 -1
  35. package/dist/client/assets/{type-XvvfEJRs.js → type-BCdIbDmF.js} +1 -1
  36. package/dist/client/assets/{user-plus-Chr9T97G.js → user-plus-gFwY-NA3.js} +1 -1
  37. package/dist/client/assets/{x-DlFXD9Vl.js → x-Cspw_pa4.js} +1 -1
  38. package/dist/client/index.html +2 -2
  39. package/dist/server/app.js +8 -0
  40. package/dist/server/chktex.js +377 -0
  41. package/dist/server/collaboration.js +6 -0
  42. package/dist/server/db.js +6 -1
  43. package/dist/server/environment.js +1 -0
  44. package/dist/server/history.js +4 -4
  45. package/dist/server/i18n.js +12 -2
  46. package/dist/server/projectImportUploads.js +133 -0
  47. package/dist/server/routes/projectFiles.js +3 -0
  48. package/dist/server/routes/projectShared.js +1 -0
  49. package/dist/server/routes/projects.js +87 -15
  50. package/dist/shared/writingChecks.js +4 -0
  51. package/package.json +1 -1
  52. package/dist/client/assets/Dashboard-BB4RO4x2.js +0 -2
  53. package/dist/client/assets/PdfPreview-fDxKh6hP.js +0 -1
  54. package/dist/client/assets/ProjectSettings-DXGA-lmB.js +0 -1
  55. package/dist/client/assets/ProjectWorkspace-mCYjyc6e.js +0 -32
  56. package/dist/client/assets/check-Jf8WBxDX.js +0 -1
  57. package/dist/client/assets/index-B6rP7QsM.js +0 -12
  58. package/dist/client/assets/index-DGZNAyxW.css +0 -1
@@ -1,3 +1,3 @@
1
- import{u as ye,r as n,j as e}from"./react-BVUjbTTn.js";import{c as u,M as H,d as p,g as l}from"./index-B6rP7QsM.js";import{G as q,C as ie,T as ke}from"./x-DlFXD9Vl.js";import{K as be}from"./key-round-DqptHHKC.js";import{C as ne,R as ve}from"./ProjectWorkspace-mCYjyc6e.js";import{M as Ce,a as Ne}from"./minus-bx4ZLZnb.js";import{P as we}from"./plus-DQg_bV50.js";import{M as ze}from"./minimize-2-92UqFWI9.js";import"./check-Jf8WBxDX.js";import"./search-UZspmceH.js";import"./user-plus-Chr9T97G.js";import"./refresh-cw-BoMEkk5J.js";const Se=u("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);const ae=u("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const G=u("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const oe=u("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);const W=u("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const Ee=u("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);const Te=u("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function Ge({open:h,project:o,onOpenChange:y,onBeforeMutation:r}){const{t:s,i18n:E}=ye(),[i,m]=n.useState(null),[J,K]=n.useState([]),[T,k]=n.useState(""),[F,V]=n.useState(()=>re(o.name)),[_,ce]=n.useState(!0),[D,Z]=n.useState(""),[b,M]=n.useState(null),[f,j]=n.useState(null),[U,R]=n.useState(!1),[le,v]=n.useState(!1),[$,L]=n.useState(!0),[P,A]=n.useState(!0),[a,C]=n.useState(""),[Q,N]=n.useState(""),[X,B]=n.useState(""),[g,x]=n.useState(!1),[w,Y]=n.useState(10),O=n.useRef(null),z=async(t=!1)=>{const c=await l(`/api/projects/${o.id}/git`);if(m(c.status),t&&(L(!c.status.tokenConfigured),A(!c.status.remoteUrl)),c.status.initialized&&c.status.latestCommit){const S=await l(`/api/projects/${o.id}/git/history`);K(S.commits)}else K([])};n.useEffect(()=>{if(!h){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),x(!1),k("");return}N(""),B(""),M(null),x(!1),V(re(o.name)),C("load"),r().then(()=>z(!0)).catch(t=>N(t instanceof Error?t.message:s("errors.generic"))).finally(()=>C(""))},[h,o.id]),n.useEffect(()=>{const t=()=>x(document.fullscreenElement===O.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),n.useEffect(()=>{if(!g)return;const t=c=>{c.key==="Escape"&&!document.fullscreenElement&&x(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[g]);const d=async(t,c,S,ee)=>{C(t),N(""),B("");try{await c(),S&&B(S)}catch(se){const te=se instanceof Error?se.message:s("errors.generic");N(ee?`${ee}: ${te}`:te)}finally{C("")}},de=()=>d("token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"PUT",body:JSON.stringify({token:T})});m(t.status),k(""),L(!1)},s("git.tokenSaved")),he=()=>d("remove-token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"DELETE"});m(t.status),k("")},s("git.tokenRemoved")),ge=()=>d("repository",async()=>{const t=await l(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:_})});m(t.status),A(!1)},s("git.repositoryCreated")),ue=()=>d("commit",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});m(t.status),Z(""),M(null),await z()},s("git.committed")),me=()=>d("push",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/push`,{method:"POST"});m(t.status),await z()},s("git.pushed"),s("git.pushFailed")),I=t=>d("diff",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const c=t?`?revision=${encodeURIComponent(t)}`:"";M(await l(`/api/projects/${o.id}/git/diff${c}`))}),fe=async()=>{if(g){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),x(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}x(!0)},xe=()=>{const t=f;t&&(j(null),d("checkout",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:t==="branch"?null:t.sha,force:U})}),window.location.reload()}))},pe=()=>{v(!1),d("discard",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},je=a==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:h,extraWide:!0,className:g?"git-dialog-modal-fullscreen":void 0,title:s("git.title"),description:s("git.description"),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(p,{className:"spin",size:22}),s("common.loading")]}),Q&&e.jsx("p",{className:"git-message error",children:Q}),X&&e.jsxs("p",{className:"git-message success",children:[e.jsx(q,{size:14}),X]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>L(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(be,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?s("git.connectedAs",{login:i.githubLogin}):s("git.authenticationHint")})]})]}),$?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),$&&e.jsxs("div",{className:"git-section-content",children:[e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:s("git.recommendedAccessTitle")}),e.jsx("span",{children:s("git.recommendedAccess")})]}),i.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(W,{size:17}),e.jsx("span",{children:s("git.connectedAs",{login:i.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:he,children:[e.jsx(ke,{size:14}),s("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[i.tokenConfigured?s("git.replaceToken"):s("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:T,placeholder:s("git.tokenPlaceholder"),onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"git-inline-actions",children:[e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[s("git.createToken"),e.jsx(ae,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(p,{className:"spin",size:13}),s("git.saveToken")]})]})]})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,onClick:()=>A(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?s("git.localReady"):s("git.localPending")})]})]}),P?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),P&&e.jsx("div",{className:"git-section-content",children:i.remoteUrl?e.jsxs("div",{className:"git-repository-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.repositoryName??s("git.origin")}),e.jsxs("small",{children:[i.branch??s("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?s("git.changedFiles",{count:i.changedFiles}):s("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(ae,{size:14}),s("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[s("git.repositoryName"),e.jsx("input",{value:F,onChange:t=>V(t.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ce(t.target.checked)}),s("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!a||!i.tokenConfigured||!F.trim(),onClick:ge,children:[a==="repository"?e.jsx(p,{className:"spin",size:14}):e.jsx(W,{size:14}),s("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(oe,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.commitAndPush")}),e.jsx("small",{children:i.branch?s("git.identity",{username:o.ownerUsername}):s("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[s("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:s("git.commitPlaceholder"),onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:s("git.noChangesToCommit"),disabled:!!a||!i.branch||!i.dirty||!D.trim(),onClick:ue,children:[a==="commit"?e.jsx(p,{className:"spin",size:14}):e.jsx(oe,{size:14}),s("git.commit")]}),e.jsxs("button",{disabled:!!a||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit,onClick:me,children:[a==="push"?e.jsx(p,{className:"spin",size:14}):e.jsx(Se,{size:14}),s("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!a||!i.latestCommit,onClick:()=>{I()},children:[a==="diff"?e.jsx(p,{className:"spin",size:14}):e.jsx(G,{size:14}),s("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?s("git.discardChanges"):s("git.noChangesToDiscard"),disabled:!!a||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(ve,{size:14}),s("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!a,onClick:()=>{R(!1),j("branch")},children:[e.jsx(q,{size:14}),s("git.returnToBranch",{branch:i.defaultBranch})]}),e.jsxs("button",{disabled:!!a,onClick:()=>{d("refresh",z)},children:[e.jsx(Ee,{className:a==="refresh"?"spin":"",size:14}),s("git.refresh")]})]})]}),b&&e.jsxs("section",{ref:O,className:`git-section git-diff-section${g?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.diffTitle")}),e.jsxs("small",{children:[b.title,b.truncated?` · ${s("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",children:[e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":s("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>Y(t=>Math.max(8,t-1)),children:e.jsx(Ce,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[w,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>Y(t=>Math.min(24,t+1)),children:e.jsx(we,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{fe()},children:g?e.jsx(ze,{size:15}):e.jsx(Ne,{size:15})})]})]}),e.jsx(Fe,{content:b.diff,empty:s("git.noChanges"),fontSize:w})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(q,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.history")}),e.jsx("small",{children:s("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[J.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:t.message}),e.jsxs("small",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleString(E.resolvedLanguage)]})]}),e.jsxs("span",{children:[e.jsx("button",{title:s("git.viewCommitDiff"),disabled:!!a,onClick:()=>{I(t.sha)},children:e.jsx(G,{size:14})}),e.jsx("button",{title:s("git.checkoutVersion"),disabled:!!a,onClick:()=>{R(!1),j(t)},children:e.jsx(Te,{size:14})})]})]},t.sha)),J.length===0&&e.jsx("p",{className:"muted",children:s("git.noCommits")})]})]})]})]})}),e.jsx(H,{open:!!f,title:s(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:t=>{t||j(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j(null),children:s("common.cancel")}),e.jsx("button",{className:U?"danger":"primary",onClick:xe,children:s("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:t=>R(t.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.forceCheckout")}),e.jsx("small",{children:s("git.forceCheckoutDescription")})]})]})}),e.jsx(H,{open:le,title:s("git.discardTitle"),description:s("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:s("common.cancel")}),e.jsx("button",{className:"danger",onClick:pe,children:s("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function Fe({content:h,empty:o,fontSize:y}){return h.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${y}px`},children:h.split(`
1
+ import{u as ye,r as n,j as e}from"./react-BVUjbTTn.js";import{c as u,M as H,d as p,g as l}from"./index-CqBmQAzW.js";import{G as q,C as ie,T as ke}from"./x-Cspw_pa4.js";import{K as be}from"./key-round-BEnQo7IM.js";import{C as ne,R as ve}from"./ProjectWorkspace-CcbrdCy8.js";import{M as Ce,a as Ne}from"./minus-BpuvzV2m.js";import{P as we}from"./plus-BFr75l91.js";import{M as ze}from"./minimize-2-CLuDohEf.js";import"./check-DKIW1zpR.js";import"./search-Nu4OcY_n.js";import"./user-plus-gFwY-NA3.js";import"./refresh-cw-DyA4NKh7.js";const Se=u("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);const ae=u("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const G=u("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const oe=u("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);const W=u("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const Ee=u("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);const Te=u("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function Ge({open:h,project:o,onOpenChange:y,onBeforeMutation:r}){const{t:s,i18n:E}=ye(),[i,m]=n.useState(null),[J,K]=n.useState([]),[T,k]=n.useState(""),[F,V]=n.useState(()=>re(o.name)),[_,ce]=n.useState(!0),[D,Z]=n.useState(""),[b,M]=n.useState(null),[f,j]=n.useState(null),[U,R]=n.useState(!1),[le,v]=n.useState(!1),[$,L]=n.useState(!0),[P,A]=n.useState(!0),[a,C]=n.useState(""),[Q,N]=n.useState(""),[X,B]=n.useState(""),[g,x]=n.useState(!1),[w,Y]=n.useState(10),O=n.useRef(null),z=async(t=!1)=>{const c=await l(`/api/projects/${o.id}/git`);if(m(c.status),t&&(L(!c.status.tokenConfigured),A(!c.status.remoteUrl)),c.status.initialized&&c.status.latestCommit){const S=await l(`/api/projects/${o.id}/git/history`);K(S.commits)}else K([])};n.useEffect(()=>{if(!h){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),x(!1),k("");return}N(""),B(""),M(null),x(!1),V(re(o.name)),C("load"),r().then(()=>z(!0)).catch(t=>N(t instanceof Error?t.message:s("errors.generic"))).finally(()=>C(""))},[h,o.id]),n.useEffect(()=>{const t=()=>x(document.fullscreenElement===O.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),n.useEffect(()=>{if(!g)return;const t=c=>{c.key==="Escape"&&!document.fullscreenElement&&x(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[g]);const d=async(t,c,S,ee)=>{C(t),N(""),B("");try{await c(),S&&B(S)}catch(se){const te=se instanceof Error?se.message:s("errors.generic");N(ee?`${ee}: ${te}`:te)}finally{C("")}},de=()=>d("token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"PUT",body:JSON.stringify({token:T})});m(t.status),k(""),L(!1)},s("git.tokenSaved")),he=()=>d("remove-token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"DELETE"});m(t.status),k("")},s("git.tokenRemoved")),ge=()=>d("repository",async()=>{const t=await l(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:_})});m(t.status),A(!1)},s("git.repositoryCreated")),ue=()=>d("commit",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});m(t.status),Z(""),M(null),await z()},s("git.committed")),me=()=>d("push",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/push`,{method:"POST"});m(t.status),await z()},s("git.pushed"),s("git.pushFailed")),I=t=>d("diff",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const c=t?`?revision=${encodeURIComponent(t)}`:"";M(await l(`/api/projects/${o.id}/git/diff${c}`))}),fe=async()=>{if(g){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),x(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}x(!0)},xe=()=>{const t=f;t&&(j(null),d("checkout",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:t==="branch"?null:t.sha,force:U})}),window.location.reload()}))},pe=()=>{v(!1),d("discard",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},je=a==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:h,extraWide:!0,className:g?"git-dialog-modal-fullscreen":void 0,title:s("git.title"),description:s("git.description"),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(p,{className:"spin",size:22}),s("common.loading")]}),Q&&e.jsx("p",{className:"git-message error",children:Q}),X&&e.jsxs("p",{className:"git-message success",children:[e.jsx(q,{size:14}),X]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>L(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(be,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?s("git.connectedAs",{login:i.githubLogin}):s("git.authenticationHint")})]})]}),$?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),$&&e.jsxs("div",{className:"git-section-content",children:[e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:s("git.recommendedAccessTitle")}),e.jsx("span",{children:s("git.recommendedAccess")})]}),i.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(W,{size:17}),e.jsx("span",{children:s("git.connectedAs",{login:i.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:he,children:[e.jsx(ke,{size:14}),s("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[i.tokenConfigured?s("git.replaceToken"):s("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:T,placeholder:s("git.tokenPlaceholder"),onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"git-inline-actions",children:[e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[s("git.createToken"),e.jsx(ae,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(p,{className:"spin",size:13}),s("git.saveToken")]})]})]})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,onClick:()=>A(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?s("git.localReady"):s("git.localPending")})]})]}),P?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),P&&e.jsx("div",{className:"git-section-content",children:i.remoteUrl?e.jsxs("div",{className:"git-repository-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.repositoryName??s("git.origin")}),e.jsxs("small",{children:[i.branch??s("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?s("git.changedFiles",{count:i.changedFiles}):s("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(ae,{size:14}),s("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[s("git.repositoryName"),e.jsx("input",{value:F,onChange:t=>V(t.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ce(t.target.checked)}),s("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!a||!i.tokenConfigured||!F.trim(),onClick:ge,children:[a==="repository"?e.jsx(p,{className:"spin",size:14}):e.jsx(W,{size:14}),s("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(oe,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.commitAndPush")}),e.jsx("small",{children:i.branch?s("git.identity",{username:o.ownerUsername}):s("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[s("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:s("git.commitPlaceholder"),onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:s("git.noChangesToCommit"),disabled:!!a||!i.branch||!i.dirty||!D.trim(),onClick:ue,children:[a==="commit"?e.jsx(p,{className:"spin",size:14}):e.jsx(oe,{size:14}),s("git.commit")]}),e.jsxs("button",{disabled:!!a||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit,onClick:me,children:[a==="push"?e.jsx(p,{className:"spin",size:14}):e.jsx(Se,{size:14}),s("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!a||!i.latestCommit,onClick:()=>{I()},children:[a==="diff"?e.jsx(p,{className:"spin",size:14}):e.jsx(G,{size:14}),s("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?s("git.discardChanges"):s("git.noChangesToDiscard"),disabled:!!a||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(ve,{size:14}),s("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!a,onClick:()=>{R(!1),j("branch")},children:[e.jsx(q,{size:14}),s("git.returnToBranch",{branch:i.defaultBranch})]}),e.jsxs("button",{disabled:!!a,onClick:()=>{d("refresh",z)},children:[e.jsx(Ee,{className:a==="refresh"?"spin":"",size:14}),s("git.refresh")]})]})]}),b&&e.jsxs("section",{ref:O,className:`git-section git-diff-section${g?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.diffTitle")}),e.jsxs("small",{children:[b.title,b.truncated?` · ${s("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",children:[e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":s("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>Y(t=>Math.max(8,t-1)),children:e.jsx(Ce,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[w,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>Y(t=>Math.min(24,t+1)),children:e.jsx(we,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{fe()},children:g?e.jsx(ze,{size:15}):e.jsx(Ne,{size:15})})]})]}),e.jsx(Fe,{content:b.diff,empty:s("git.noChanges"),fontSize:w})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(q,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.history")}),e.jsx("small",{children:s("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[J.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:t.message}),e.jsxs("small",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleString(E.resolvedLanguage)]})]}),e.jsxs("span",{children:[e.jsx("button",{title:s("git.viewCommitDiff"),disabled:!!a,onClick:()=>{I(t.sha)},children:e.jsx(G,{size:14})}),e.jsx("button",{title:s("git.checkoutVersion"),disabled:!!a,onClick:()=>{R(!1),j(t)},children:e.jsx(Te,{size:14})})]})]},t.sha)),J.length===0&&e.jsx("p",{className:"muted",children:s("git.noCommits")})]})]})]})]})}),e.jsx(H,{open:!!f,title:s(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:t=>{t||j(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j(null),children:s("common.cancel")}),e.jsx("button",{className:U?"danger":"primary",onClick:xe,children:s("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:t=>R(t.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.forceCheckout")}),e.jsx("small",{children:s("git.forceCheckoutDescription")})]})]})}),e.jsx(H,{open:le,title:s("git.discardTitle"),description:s("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:s("common.cancel")}),e.jsx("button",{className:"danger",onClick:pe,children:s("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function Fe({content:h,empty:o,fontSize:y}){return h.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${y}px`},children:h.split(`
2
2
  `).map((r,s)=>{const E=r.startsWith("+")&&!r.startsWith("+++")?"addition":r.startsWith("-")&&!r.startsWith("---")?"deletion":r.startsWith("@@")?"hunk":r.startsWith("diff ")?"header":"";return e.jsxs("span",{className:E,children:[r,`
3
3
  `]},s)})}):e.jsx("div",{className:"git-diff-empty",children:o})}function re(h){return h.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,100)||"texlite-project"}export{Ge as GitDialog};
@@ -1,4 +1,4 @@
1
- import{u as Ae,r as o,j as e}from"./react-BVUjbTTn.js";import{c as Pe,g as _,M as Me,d as le,C as be,A as ve}from"./index-B6rP7QsM.js";import{d as He,C as Ne}from"./index-Csp5J5aI.js";import{H as Be}from"./hard-drive-Bsk-RETn.js";import{T as Ce,c as Ve,e as _e}from"./x-DlFXD9Vl.js";import{F as we,R as $e,S as Ie,A as Oe}from"./ProjectWorkspace-mCYjyc6e.js";import{M as Ue,a as We}from"./minus-bx4ZLZnb.js";import{P as Ye}from"./plus-DQg_bV50.js";import{M as qe}from"./minimize-2-92UqFWI9.js";import"./check-Jf8WBxDX.js";import"./search-UZspmceH.js";import"./user-plus-Chr9T97G.js";import"./refresh-cw-BoMEkk5J.js";const Ge=Pe("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function Se(i,c,C,y="历史版本",s="当前版本",f=3){const S=c.replace(/\r\n/g,`
1
+ import{u as Ae,r as o,j as e}from"./react-BVUjbTTn.js";import{c as Pe,g as _,M as Me,d as le,C as be,A as ve}from"./index-CqBmQAzW.js";import{d as He,C as Ne}from"./index-DTYEGzB7.js";import{H as Be}from"./hard-drive-CkIPwUSV.js";import{T as Ce,c as Ve,e as _e}from"./x-Cspw_pa4.js";import{F as we,R as $e,S as Ie,B as Oe}from"./ProjectWorkspace-CcbrdCy8.js";import{M as Ue,a as We}from"./minus-BpuvzV2m.js";import{P as Ye}from"./plus-BFr75l91.js";import{M as qe}from"./minimize-2-CLuDohEf.js";import"./check-DKIW1zpR.js";import"./search-Nu4OcY_n.js";import"./user-plus-gFwY-NA3.js";import"./refresh-cw-DyA4NKh7.js";const Ge=Pe("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function Se(i,c,C,y="历史版本",s="当前版本",f=3){const S=c.replace(/\r\n/g,`
2
2
  `),R=C.replace(/\r\n/g,`
3
3
  `);if(S===R)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const h=new He,k=h.diff_linesToChars_(S,R),x=h.diff_main(k.chars1,k.chars2,!1);h.diff_charsToLines_(x,k.lineArray);const w=[];let n=1,T=1,m=0,z=0;for(const[d,v]of x){if(!v)continue;const u=v.split(`
4
4
  `);u[u.length-1]===""&&u.pop();for(const P of u)d===0?w.push({op:0,text:P,oldNum:n++,newNum:T++}):d===-1?(z++,w.push({op:-1,text:P,oldNum:n++,newNum:T})):d===1&&(m++,w.push({op:1,text:P,oldNum:n,newNum:T++}))}if(m===0&&z===0)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const j=[];let b=-1,A=-1;for(let d=0;d<w.length;d++)if(w[d].op!==0){const v=Math.max(0,d-f),u=Math.min(w.length-1,d+f);b===-1?(b=v,A=u):v<=A+1?A=Math.max(A,u):(j.push({start:b,end:A}),b=v,A=u)}b!==-1&&j.push({start:b,end:A});const G=[`--- a/${i} (${y})`,`+++ b/${i} (${s})`];for(const d of j){const v=w.slice(d.start,d.end+1),u=v.filter($=>$.op<=0).length,P=v.filter($=>$.op>=0).length,E=v[0],O=u===0?0:E.oldNum,J=P===0?0:E.newNum;G.push(`@@ -${O},${u} +${J},${P} @@`);for(const $ of v){const U=$.op===-1?"-":$.op===1?"+":" ";G.push(`${U}${$.text}`)}}return{diffText:G.join(`
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./katex-D9PXdmFF.css"])))=>i.map(i=>d[i]);
2
- import{u as To,r as Y,j as Ve}from"./react-BVUjbTTn.js";import{s as Hr,E as pe,V as dt,D as J,a as ln,R as Ro,P as Wr,S as Ct,b as Le,f as Ao,M as Zr,m as ur,i as Po,c as No,d as Do,e as Bo,g as Fo,h as Io,j as fr,k as wn,l as It,n as $o,o as Vo,p as _o,q as Qo,r as jo,t as Ko,u as qo,v as zo,w as Uo,x as Xo,y as ut,F as $t,A as Sn,z as cn,W as Yr,B as Gr,L as Ho,C as Wo,G as Zo,H as Yo,I as ft,J as Go,K as ae,N as Jo,O as Vt,Q as Jr,T as ie,U as ea,X as ei,Y as Xe,Z as ta,_ as Bt,$ as ti,a0 as na,a1 as ra,a2 as At,a3 as ia,a4 as oa,a5 as aa,a6 as sa,a7 as la,a8 as dr,a9 as ca,aa as ua,ab as fa,ac as da,ad as ha,ae as pa,af as ma,ag as ga,ah as va,ai as ya,aj as ba,ak as ka,al as Oa,am as Ca,an as wa,ao as Sa,ap as xa,aq as Ma}from"./editor-B9HNwtsd.js";import{r as hr,a as bt,U as ni,b as un,d as fn,e as pr,m as Ea,f as La,g as tn,t as Pt,h as Nt,i as xn,l as Mn,j as _t,k as En,n as ri,o as ii,p as Ft,q as Ln,u as Ta,v as dn,w as oi,x as nn,y as Ra,z as Aa}from"./ProjectWorkspace-mCYjyc6e.js";import{_ as mr}from"./index-B6rP7QsM.js";import"./check-Jf8WBxDX.js";import"./x-DlFXD9Vl.js";import"./search-UZspmceH.js";import"./user-plus-Chr9T97G.js";import"./refresh-cw-BoMEkk5J.js";function Pa(t){var n=t.Pos;function o(e,r,i){if(r.line===i.line&&r.ch>=i.ch-1){var a=e.getLine(r.line),l=a.charCodeAt(r.ch);55296<=l&&l<=55551&&(i.ch+=1)}return{start:r,end:i}}var s=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],c=Object.create(null),f=s.length,m=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],g=ue("");function b(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),t.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",ir),qe(e),t.on(e.getInputField(),"paste",M(e))}function S(e){e.setOption("disableInput",!1),e.off("cursorActivity",ir),t.off(e.getInputField(),"paste",M(e)),e.state.vim=null,vt&&clearTimeout(vt)}function M(e){var r=e.state.vim;return r.onPasteFn||(r.onPasteFn=function(){r.insertMode||(e.setCursor(de(e.getCursor(),0,1)),rt.enterInsertMode(e,{},r))}),r.onPasteFn}var A=/[\d]/,P=[t.isWordChar,function(e){return e&&!t.isWordChar(e)&&!/\s/.test(e)}],E=[function(e){return/\S/.test(e)}],T=["<",">"],R=["-",'"',".",":","_","/","+"],_=/^\w$/,U=/^[A-Z]$/;try{U=new RegExp("^[\\p{Lu}]$","u")}catch{}function ee(e,r){return r>=e.firstLine()&&r<=e.lastLine()}function te(e){return/^[a-z]$/.test(e)}function q(e){return"()[]{}".indexOf(e)!=-1}function le(e){return A.test(e)}function Oe(e){return U.test(e)}function H(e){return/^\s*$/.test(e)}function je(e){return".?!".indexOf(e)!=-1}function et(e,r){for(var i=0;i<r.length;i++)if(r[i]==e)return!0;return!1}var Te={};function Ke(e,r,i,a,l){if(r===void 0&&!l)throw Error("defaultValue is required unless callback is provided");if(i||(i="string"),Te[e]={type:i,defaultValue:r,callback:l},a)for(var u=0;u<a.length;u++)Te[a[u]]=Te[e];r&&tt(e,r)}function tt(e,r,i,a){var l=Te[e];a=a||{};var u=a.scope;if(!l)return new Error("Unknown option: "+e);if(l.type=="boolean"){if(r&&r!==!0)return new Error("Invalid argument: "+e+"="+r);r!==!1&&(r=!0)}l.callback?(u!=="local"&&l.callback(r,void 0),u!=="global"&&i&&l.callback(r,i)):(u!=="local"&&(l.value=l.type=="boolean"?!!r:r),u!=="global"&&i&&(i.state.vim.options[e]={value:r}))}function be(e,r,i){var a=Te[e];i=i||{};var l=i.scope;if(!a)return new Error("Unknown option: "+e);if(a.callback){let u=r&&a.callback(void 0,r);return l!=="global"&&u!==void 0?u:l!=="local"?a.callback():void 0}else return(l!=="global"&&r&&r.state.vim.options[e]||l!=="local"&&a||{}).value}Ke("filetype",void 0,"string",["ft"],function(e,r){if(r!==void 0)if(e===void 0){let i=r.getOption("mode");return i=="null"?"":i}else{let i=e==""?"null":e;r.setOption("mode",i)}}),Ke("textwidth",80,"number",["tw"],function(e,r){if(r!==void 0)if(e===void 0){var i=r.getOption("textwidth");return i}else{var a=Math.round(e);a>1&&r.setOption("textwidth",a)}});var xt=function(){var e=100,r=-1,i=0,a=0,l=new Array(e);function u(p,v,y){var O=r%e,C=l[O];function w(x){var L=++r%e,F=l[L];F&&F.clear(),l[L]=p.setBookmark(x)}if(C){var k=C.find();k&&!Ae(k,v)&&w(v)}else w(v);w(y),i=r,a=r-e+1,a<0&&(a=0)}function d(p,v){r+=v,r>i?r=i:r<a&&(r=a);var y=l[(e+r)%e];if(y&&!y.find()){var O=v>0?1:-1,C,w=p.getCursor();do if(r+=O,y=l[(e+r)%e],y&&(C=y.find())&&!Ae(w,C))break;while(r<i&&r>a)}return y}function h(p,v){var y=r,O=d(p,v);return r=y,O&&O.find()}return{cachedCursor:void 0,add:u,find:h,move:d}},ht=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Mt{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ht()}exitMacroRecordMode(){var r=N.macroModeState;r.onRecordingDone&&r.onRecordingDone(),r.onRecordingDone=void 0,r.isRecording=!1}enterMacroRecordMode(r,i){var a=N.registerController.getRegister(i);if(a){if(a.clear(),this.latestRegister=i,r.openDialog){var l=De("span",{class:"cm-vim-message"},"recording @"+i);this.onRecordingDone=r.openDialog(l,function(){},{bottom:!0})}this.isRecording=!0}}}function qe(e){return e.state.vim||(e.state.vim={inputState:new fe,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new n(0,0),head:new n(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var N;function pt(){N={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:xt(),macroModeState:new Mt,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Et({}),searchHistoryController:new Dn,exCommandHistoryController:new Dn};for(var e in Te){var r=Te[e];r.value=r.defaultValue}}class st{constructor(r,i){this.keyName=r,this.key=i.key,this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.shiftKey=i.shiftKey}}var He,me={enterVimMode:b,leaveVimMode:S,buildKeyMap:function(){},getRegisterController:function(){return N.registerController},resetVimGlobalState_:pt,getVimGlobalState_:function(){return N},maybeInitVimState_:qe,suppressErrorLogging:!1,InsertModeKey:st,map:function(e,r,i){Se.map(e,r,i)},unmap:function(e,r){return Se.unmap(e,r)},noremap:function(e,r,i){Se.map(e,r,i,!0)},mapclear:function(e){var r=s.length,i=f,a=s.slice(0,r-i);if(s=s.slice(r-i),e)for(var l=a.length-1;l>=0;l--){var u=a[l];if(e!==u.context)if(u.context)this._mapCommand(u);else{var d=["normal","insert","visual"];for(var h in d)if(d[h]!==e){var p=Object.assign({},u);p.context=d[h],this._mapCommand(p)}}}},langmap:Q,vimKeyFromEvent:ce,setOption:tt,getOption:be,defineOption:Ke,defineEx:function(e,r,i){if(!r)r=e;else if(e.indexOf(r)!==0)throw new Error('(Vim.defineEx) "'+r+'" is not a prefix of "'+e+'", command not registered');nr[e]=i,Se.commandMap_[r]={name:e,shortName:r,type:"api"}},handleKey:function(e,r,i){var a=this.findKey(e,r,i);if(typeof a=="function")return a()},multiSelectHandleKey:Lo,findKey:function(e,r,i){var a=qe(e),l=e;function u(){var y=N.macroModeState;if(y.isRecording){if(r=="q")return y.exitMacroRecordMode(),oe(l),!0;i!="mapping"&&xo(y,r)}}function d(){if(r=="<Esc>"){if(a.visualMode)Ie(l);else if(a.insertMode)Je(l);else return;return oe(l),!0}}function h(){if(d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join(""),O=r.length==1,C=nt.matchCommand(y,s,a.inputState,"insert"),w=a.inputState.changeQueue;if(C.type=="none")return oe(l),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(a.expectLiteralNext=!0),He&&window.clearTimeout(He),He=O&&window.setTimeout(function(){a.insertMode&&a.inputState.keyBuffer.length&&oe(l)},be("insertModeEscKeysTimeout")),O){var k=l.listSelections();(!w||w.removed.length!=k.length)&&(w=a.inputState.changeQueue=new mt),w.inserted+=r;for(var x=0;x<k.length;x++){var L=we(k[x].anchor,k[x].head),F=Ge(k[x].anchor,k[x].head),D=l.getRange(L,l.state.overwrite?de(F,0,1):F);w.removed[x]=(w.removed[x]||"")+D}}return!O}else C.type=="full"&&(a.inputState.keyBuffer.length=0);if(a.expectLiteralNext=!1,He&&window.clearTimeout(He),C.command&&w){for(var k=l.listSelections(),x=0;x<k.length;x++){var B=k[x].head;l.replaceRange(w.removed[x]||"",de(B,0,-w.inserted.length),B,"+input")}N.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||oe(l),C.command}function p(){if(u()||d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(y))return!0;var O=/^(\d*)(.*)$/.exec(y);if(!O)return oe(l),!1;var C=a.visualMode?"visual":"normal",w=O[2]||O[1];a.inputState.operatorShortcut&&a.inputState.operatorShortcut.slice(-1)==w&&(w=a.inputState.operatorShortcut);var k=nt.matchCommand(w,s,a.inputState,C);return k.type=="none"?(oe(l),!1):k.type=="partial"?(k.expectLiteralNext&&(a.expectLiteralNext=!0),!0):k.type=="clear"?(oe(l),!0):(a.expectLiteralNext=!1,a.inputState.keyBuffer.length=0,O=/^(\d*)(.*)$/.exec(y),O&&O[1]&&O[1]!="0"&&a.inputState.pushRepeatDigit(O[1]),k.command)}var v=a.insertMode?h():p();if(v===!1)return!a.insertMode&&(r.length===1||t.isMac&&/<A-.>/.test(r))?function(){return!0}:void 0;if(v===!0)return function(){return!0};if(v)return function(){return l.operation(function(){l.curOp.isVimOp=!0;try{if(typeof v!="object")return;v.type=="keyToKey"?Ye(l,v.toKeys,v):nt.processCommand(l,a,v)}catch(y){throw l.state.vim=void 0,qe(l),me.suppressErrorLogging||console.log(y),y}return!0})}},handleEx:function(e,r){Se.processCommand(e,r)},defineMotion:Vi,defineAction:Qi,defineOperator:_i,mapCommand:wo,_mapCommand:Yt,defineRegister:Kt,exitVisualMode:Ie,exitInsertMode:Je},We=[],Ze=!1,W;function ze(e){if(!W)throw new Error("No prompt to send key to");if(e[0]=="<"){var r=e.toLowerCase().slice(1,-1),i=r.split("-");if(r=i.pop()||"",r=="lt")e="<";else if(r=="space")e=" ";else if(r=="cr")e=`
2
+ import{u as To,r as Y,j as Ve}from"./react-BVUjbTTn.js";import{s as Hr,E as pe,V as dt,D as J,a as ln,R as Ro,P as Wr,S as Ct,b as Le,f as Ao,M as Zr,m as ur,i as Po,c as No,d as Do,e as Bo,g as Fo,h as Io,j as fr,k as wn,l as It,n as $o,o as Vo,p as _o,q as Qo,r as jo,t as Ko,u as qo,v as zo,w as Uo,x as Xo,y as ut,F as $t,A as Sn,z as cn,W as Yr,B as Gr,L as Ho,C as Wo,G as Zo,H as Yo,I as ft,J as Go,K as ae,N as Jo,O as Vt,Q as Jr,T as ie,U as ea,X as ei,Y as Xe,Z as ta,_ as Bt,$ as ti,a0 as na,a1 as ra,a2 as At,a3 as ia,a4 as oa,a5 as aa,a6 as sa,a7 as la,a8 as dr,a9 as ca,aa as ua,ab as fa,ac as da,ad as ha,ae as pa,af as ma,ag as ga,ah as va,ai as ya,aj as ba,ak as ka,al as Oa,am as Ca,an as wa,ao as Sa,ap as xa,aq as Ma}from"./editor-B9HNwtsd.js";import{r as hr,b as bt,U as ni,d as un,e as fn,f as pr,m as Ea,g as La,h as tn,t as Pt,i as Nt,j as xn,l as Mn,k as _t,n as En,o as ri,p as ii,q as Ft,u as Ln,v as Ta,w as dn,x as oi,y as nn,z as Ra,A as Aa}from"./ProjectWorkspace-CcbrdCy8.js";import{_ as mr}from"./index-CqBmQAzW.js";import"./check-DKIW1zpR.js";import"./x-Cspw_pa4.js";import"./search-Nu4OcY_n.js";import"./user-plus-gFwY-NA3.js";import"./refresh-cw-DyA4NKh7.js";function Pa(t){var n=t.Pos;function o(e,r,i){if(r.line===i.line&&r.ch>=i.ch-1){var a=e.getLine(r.line),l=a.charCodeAt(r.ch);55296<=l&&l<=55551&&(i.ch+=1)}return{start:r,end:i}}var s=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],c=Object.create(null),f=s.length,m=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],g=ue("");function b(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),t.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",ir),qe(e),t.on(e.getInputField(),"paste",M(e))}function S(e){e.setOption("disableInput",!1),e.off("cursorActivity",ir),t.off(e.getInputField(),"paste",M(e)),e.state.vim=null,vt&&clearTimeout(vt)}function M(e){var r=e.state.vim;return r.onPasteFn||(r.onPasteFn=function(){r.insertMode||(e.setCursor(de(e.getCursor(),0,1)),rt.enterInsertMode(e,{},r))}),r.onPasteFn}var A=/[\d]/,P=[t.isWordChar,function(e){return e&&!t.isWordChar(e)&&!/\s/.test(e)}],E=[function(e){return/\S/.test(e)}],T=["<",">"],R=["-",'"',".",":","_","/","+"],_=/^\w$/,U=/^[A-Z]$/;try{U=new RegExp("^[\\p{Lu}]$","u")}catch{}function ee(e,r){return r>=e.firstLine()&&r<=e.lastLine()}function te(e){return/^[a-z]$/.test(e)}function q(e){return"()[]{}".indexOf(e)!=-1}function le(e){return A.test(e)}function Oe(e){return U.test(e)}function H(e){return/^\s*$/.test(e)}function je(e){return".?!".indexOf(e)!=-1}function et(e,r){for(var i=0;i<r.length;i++)if(r[i]==e)return!0;return!1}var Te={};function Ke(e,r,i,a,l){if(r===void 0&&!l)throw Error("defaultValue is required unless callback is provided");if(i||(i="string"),Te[e]={type:i,defaultValue:r,callback:l},a)for(var u=0;u<a.length;u++)Te[a[u]]=Te[e];r&&tt(e,r)}function tt(e,r,i,a){var l=Te[e];a=a||{};var u=a.scope;if(!l)return new Error("Unknown option: "+e);if(l.type=="boolean"){if(r&&r!==!0)return new Error("Invalid argument: "+e+"="+r);r!==!1&&(r=!0)}l.callback?(u!=="local"&&l.callback(r,void 0),u!=="global"&&i&&l.callback(r,i)):(u!=="local"&&(l.value=l.type=="boolean"?!!r:r),u!=="global"&&i&&(i.state.vim.options[e]={value:r}))}function be(e,r,i){var a=Te[e];i=i||{};var l=i.scope;if(!a)return new Error("Unknown option: "+e);if(a.callback){let u=r&&a.callback(void 0,r);return l!=="global"&&u!==void 0?u:l!=="local"?a.callback():void 0}else return(l!=="global"&&r&&r.state.vim.options[e]||l!=="local"&&a||{}).value}Ke("filetype",void 0,"string",["ft"],function(e,r){if(r!==void 0)if(e===void 0){let i=r.getOption("mode");return i=="null"?"":i}else{let i=e==""?"null":e;r.setOption("mode",i)}}),Ke("textwidth",80,"number",["tw"],function(e,r){if(r!==void 0)if(e===void 0){var i=r.getOption("textwidth");return i}else{var a=Math.round(e);a>1&&r.setOption("textwidth",a)}});var xt=function(){var e=100,r=-1,i=0,a=0,l=new Array(e);function u(p,v,y){var O=r%e,C=l[O];function w(x){var L=++r%e,F=l[L];F&&F.clear(),l[L]=p.setBookmark(x)}if(C){var k=C.find();k&&!Ae(k,v)&&w(v)}else w(v);w(y),i=r,a=r-e+1,a<0&&(a=0)}function d(p,v){r+=v,r>i?r=i:r<a&&(r=a);var y=l[(e+r)%e];if(y&&!y.find()){var O=v>0?1:-1,C,w=p.getCursor();do if(r+=O,y=l[(e+r)%e],y&&(C=y.find())&&!Ae(w,C))break;while(r<i&&r>a)}return y}function h(p,v){var y=r,O=d(p,v);return r=y,O&&O.find()}return{cachedCursor:void 0,add:u,find:h,move:d}},ht=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Mt{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ht()}exitMacroRecordMode(){var r=N.macroModeState;r.onRecordingDone&&r.onRecordingDone(),r.onRecordingDone=void 0,r.isRecording=!1}enterMacroRecordMode(r,i){var a=N.registerController.getRegister(i);if(a){if(a.clear(),this.latestRegister=i,r.openDialog){var l=De("span",{class:"cm-vim-message"},"recording @"+i);this.onRecordingDone=r.openDialog(l,function(){},{bottom:!0})}this.isRecording=!0}}}function qe(e){return e.state.vim||(e.state.vim={inputState:new fe,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new n(0,0),head:new n(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var N;function pt(){N={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:xt(),macroModeState:new Mt,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Et({}),searchHistoryController:new Dn,exCommandHistoryController:new Dn};for(var e in Te){var r=Te[e];r.value=r.defaultValue}}class st{constructor(r,i){this.keyName=r,this.key=i.key,this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.shiftKey=i.shiftKey}}var He,me={enterVimMode:b,leaveVimMode:S,buildKeyMap:function(){},getRegisterController:function(){return N.registerController},resetVimGlobalState_:pt,getVimGlobalState_:function(){return N},maybeInitVimState_:qe,suppressErrorLogging:!1,InsertModeKey:st,map:function(e,r,i){Se.map(e,r,i)},unmap:function(e,r){return Se.unmap(e,r)},noremap:function(e,r,i){Se.map(e,r,i,!0)},mapclear:function(e){var r=s.length,i=f,a=s.slice(0,r-i);if(s=s.slice(r-i),e)for(var l=a.length-1;l>=0;l--){var u=a[l];if(e!==u.context)if(u.context)this._mapCommand(u);else{var d=["normal","insert","visual"];for(var h in d)if(d[h]!==e){var p=Object.assign({},u);p.context=d[h],this._mapCommand(p)}}}},langmap:Q,vimKeyFromEvent:ce,setOption:tt,getOption:be,defineOption:Ke,defineEx:function(e,r,i){if(!r)r=e;else if(e.indexOf(r)!==0)throw new Error('(Vim.defineEx) "'+r+'" is not a prefix of "'+e+'", command not registered');nr[e]=i,Se.commandMap_[r]={name:e,shortName:r,type:"api"}},handleKey:function(e,r,i){var a=this.findKey(e,r,i);if(typeof a=="function")return a()},multiSelectHandleKey:Lo,findKey:function(e,r,i){var a=qe(e),l=e;function u(){var y=N.macroModeState;if(y.isRecording){if(r=="q")return y.exitMacroRecordMode(),oe(l),!0;i!="mapping"&&xo(y,r)}}function d(){if(r=="<Esc>"){if(a.visualMode)Ie(l);else if(a.insertMode)Je(l);else return;return oe(l),!0}}function h(){if(d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join(""),O=r.length==1,C=nt.matchCommand(y,s,a.inputState,"insert"),w=a.inputState.changeQueue;if(C.type=="none")return oe(l),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(a.expectLiteralNext=!0),He&&window.clearTimeout(He),He=O&&window.setTimeout(function(){a.insertMode&&a.inputState.keyBuffer.length&&oe(l)},be("insertModeEscKeysTimeout")),O){var k=l.listSelections();(!w||w.removed.length!=k.length)&&(w=a.inputState.changeQueue=new mt),w.inserted+=r;for(var x=0;x<k.length;x++){var L=we(k[x].anchor,k[x].head),F=Ge(k[x].anchor,k[x].head),D=l.getRange(L,l.state.overwrite?de(F,0,1):F);w.removed[x]=(w.removed[x]||"")+D}}return!O}else C.type=="full"&&(a.inputState.keyBuffer.length=0);if(a.expectLiteralNext=!1,He&&window.clearTimeout(He),C.command&&w){for(var k=l.listSelections(),x=0;x<k.length;x++){var B=k[x].head;l.replaceRange(w.removed[x]||"",de(B,0,-w.inserted.length),B,"+input")}N.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||oe(l),C.command}function p(){if(u()||d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(y))return!0;var O=/^(\d*)(.*)$/.exec(y);if(!O)return oe(l),!1;var C=a.visualMode?"visual":"normal",w=O[2]||O[1];a.inputState.operatorShortcut&&a.inputState.operatorShortcut.slice(-1)==w&&(w=a.inputState.operatorShortcut);var k=nt.matchCommand(w,s,a.inputState,C);return k.type=="none"?(oe(l),!1):k.type=="partial"?(k.expectLiteralNext&&(a.expectLiteralNext=!0),!0):k.type=="clear"?(oe(l),!0):(a.expectLiteralNext=!1,a.inputState.keyBuffer.length=0,O=/^(\d*)(.*)$/.exec(y),O&&O[1]&&O[1]!="0"&&a.inputState.pushRepeatDigit(O[1]),k.command)}var v=a.insertMode?h():p();if(v===!1)return!a.insertMode&&(r.length===1||t.isMac&&/<A-.>/.test(r))?function(){return!0}:void 0;if(v===!0)return function(){return!0};if(v)return function(){return l.operation(function(){l.curOp.isVimOp=!0;try{if(typeof v!="object")return;v.type=="keyToKey"?Ye(l,v.toKeys,v):nt.processCommand(l,a,v)}catch(y){throw l.state.vim=void 0,qe(l),me.suppressErrorLogging||console.log(y),y}return!0})}},handleEx:function(e,r){Se.processCommand(e,r)},defineMotion:Vi,defineAction:Qi,defineOperator:_i,mapCommand:wo,_mapCommand:Yt,defineRegister:Kt,exitVisualMode:Ie,exitInsertMode:Je},We=[],Ze=!1,W;function ze(e){if(!W)throw new Error("No prompt to send key to");if(e[0]=="<"){var r=e.toLowerCase().slice(1,-1),i=r.split("-");if(r=i.pop()||"",r=="lt")e="<";else if(r=="space")e=" ";else if(r=="cr")e=`
3
3
  `;else if(Z[r]){var a=W.value||"",l={key:Z[r],target:{value:a,selectionEnd:a.length,selectionStart:a.length}};W.onKeyDown&&W.onKeyDown(l,W.value,d),W&&W.onKeyUp&&W.onKeyUp(l,W.value,d);return}}if(e==`
4
4
  `){var u=W;W=null,u.onClose&&u.onClose(u.value)}else W.value=(W.value||"")+e;function d(h){W&&(typeof h=="string"?W.value=h:W=null)}}function Ye(e,r,i){var a=Ze;if(i){if(We.indexOf(i)!=-1)return;We.push(i),Ze=i.noremap!=!1}try{for(var l=qe(e),u=/<(?:[CSMA]-)*\w+>|./gi,d;d=u.exec(r);){var h=d[0],p=l.insertMode;if(W){ze(h);continue}var v=me.handleKey(e,h,"mapping");if(!v&&p&&l.insertMode){if(h[0]=="<"){var y=h.toLowerCase().slice(1,-1),O=y.split("-");if(y=O.pop()||"",y=="lt")h="<";else if(y=="space")h=" ";else if(y=="cr")h=`
5
5
  `;else if(Z.hasOwnProperty(y)){h=Z[y],lr(e,h);continue}else h=h[0],u.lastIndex=d.index+1}e.replaceSelection(h)}}}finally{if(We.pop(),Ze=We.length?a:!1,!We.length&&W){var C=W;W=null,Tt(e,C)}}}var I={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},G={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},Z={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(I)).forEach(function(e){Z[(I[e]||"").toLowerCase()]=Z[e.toLowerCase()]=e});function ce(e,r){var i=e.key;if(!G[i]){i.length>1&&i[0]=="n"&&(i=i.replace("Numpad","")),i=I[i]||i;var a="";if(e.ctrlKey&&(a+="C-"),e.altKey&&(a+="A-"),e.metaKey&&(a+="M-"),t.isMac&&a=="A-"&&i.length==1&&(a=a.slice(2)),(a||i.length>1)&&e.shiftKey&&(a+="S-"),r&&!r.expectLiteralNext&&i.length==1){if(g.keymap&&i in g.keymap)(g.remapCtrl!=!1||!a)&&(i=g.keymap[i]);else if(i.charCodeAt(0)>128&&!c[i]){var l=e.code?.slice(-1)||"";e.shiftKey||(l=l.toLowerCase()),l&&(i=l,!a&&e.altKey&&(a="A-"))}}return a+=i,a.length>1&&(a="<"+a+">"),a}}function Q(e,r){g.string!==e&&(g=ue(e)),g.remapCtrl=r}function ue(e){let r={};if(!e)return{keymap:r,string:""};function i(a){return a.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(a=>{if(!a)return;const l=a.split(/((?:[^\\;]|\\.)+);/);if(l.length==3){const u=i(l[1]),d=i(l[2]);if(u.length!==d.length)return;for(let h=0;h<u.length;++h)r[u[h]]=d[h]}else if(l.length==1){const u=i(a);if(u.length%2!==0)return;for(let d=0;d<u.length;d+=2)r[u[d]]=u[d+1]}}),{keymap:r,string:e}}Ke("langmap",void 0,"string",["lmap"],function(e,r){if(e===void 0)return g.string;Q(e)});class fe{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(r){this.operator?this.motionRepeat=this.motionRepeat.concat(r):this.prefixRepeat=this.prefixRepeat.concat(r)}getRepeat(){var r=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(r=1,this.prefixRepeat.length>0&&(r*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(r*=parseInt(this.motionRepeat.join(""),10))),r}}function oe(e,r){e.state.vim.inputState=new fe,e.state.vim.expectLiteralNext=!1,t.signal(e,"vim-command-done",r)}function mt(){this.removed=[],this.inserted=""}class Re{constructor(r,i,a){this.clear(),this.keyBuffer=[r||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!i,this.blockwise=!!a}setText(r,i,a){this.keyBuffer=[r||""],this.linewise=!!i,this.blockwise=!!a}pushText(r,i){i&&(this.linewise||this.keyBuffer.push(`
@@ -135,4 +135,4 @@ ${M}\\end{${s}}`,cursor:n+m.length+1+M.length+1,reusesExistingEnd:!1}}function a
135
135
  \${content}
136
136
  \\caption{\${caption}}
137
137
  \\label{fig:\${label}}
138
- \\end{figure}`,{label:"\\begin{figure}"})]}function dc(t){const n=[],o=[],s=[],c=[],f=[],m=[],g=oi(Ra(t)),b=(S,M,A,P,E)=>{M&&!S.some(T=>T.label===M)&&S.push({label:M,detail:A,kind:P,source:"Current file",...E?{apply:E}:{}})};for(const S of g.matchAll(/\\(?:newcommand|renewcommand|providecommand|DeclareRobustCommand)\s*\*?\s*(?:\{\s*)?\\([A-Za-z@][A-Za-z@0-9:_]*)\s*(?:\})?\s*(?:\[(\d+)\])?(?:\s*(\[[^\]]*\]))?/g)){const M=Fr(Number.parseInt(S[2]??"0",10),!!S[3]);b(n,`\\${S[1]}`,"Project command","function",an(`\\${S[1]}`,M))}for(const S of cc(g)){const M=sc(S.specification);b(n,`\\${S.name}`,"Project command","function",M?an(`\\${S.name}`,M):void 0)}for(const S of g.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)){const M=[...(S[2]??"").matchAll(/#\d+/g)].length;b(n,`\\${S[1]}`,"Project macro","function",an(`\\${S[1]}`,Fr(M,!1)))}for(const S of g.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))b(n,`\\${S[1]}`,"Project math delimiter","function");for(const S of g.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))b(n,`\\${S[1]}`,"Expl3 project command","function");for(const S of g.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g))b(o,S[1].trim(),"Project environment","keyword");for(const S of Dr(t,"label"))S.source==="label"&&b(s,S.key,"Label","constant");for(const S of g.matchAll(/\\(?:usepackage|RequirePackage)\s*(?:\[[^\]]*\])?\s*\{([^}]+)\}/g))for(const M of S[1].split(","))b(f,M.trim(),"Package","text");for(const S of g.matchAll(/\\(?:input|include|subfile)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g))b(m,(S[1]??S[2]??"").trim(),"Project file","text");for(const S of Dr(t,"citation"))S.source==="bibitem"&&b(c,S.key,"Bibliography key","constant");return{commands:n,environments:o,labels:s,citations:c,packages:f,classes:[],files:m}}function hc(t){return(t?.citations??[]).filter(n=>/\.bib$/i.test(n.source??""))}const Ir=new WeakMap;function pc(t){const n=t.state.doc,o=Ir.get(n);if(o)return o;const s=dc(t.state.doc.toString());return Ir.set(n,s),s}const $r={"Project command":"projectCommand","Project macro":"projectMacro","Expl3 project command":"expl3Command","Project math operator":"mathOperator","Project math delimiter":"mathDelimiter","Project environment":"projectEnvironment","Project file":"projectFile",Package:"package","Document class":"documentClass","Current file":"currentFile",Project:"project",LaTeX:"latex"};function mc(t,n,o=!0){const s=$r[t.detail],c=t.source?$r[t.source]:void 0,f=t.detail.match(/^Project command \((\d+) arguments?\)$/),m=t.source==="LaTeX"?"":f?n("completions.projectCommandArgs",{count:Number(f[1])}):s?n(`completions.${s}`):t.source==="LaTeX"?n("completions.standard"):t.detail,g=t.source==="LaTeX"?"":c?n(`completions.${c}`):t.source,b=g&&m?`${m} · ${g}`:m||g||void 0,S={label:t.label,type:t.kind,...b?{detail:b}:{},...t.info?{info:t.info}:{}};return o&&t.apply?ie(t.apply,S):S}function ot(t,...n){const o=[],s=new Set;for(const c of n)for(const f of c){const m="kind"in f?mc(f,t):f;s.has(m.label)||(s.add(m.label),o.push(m))}return o}function Vr(t){return t.map(({detail:n,...o})=>o)}function _r(t){return t.map(({apply:n,...o})=>o)}function gc(t,n){return{...t,apply(o,s,c,f){const m=s.label,g=oc(o.state.doc,c,f,m,n);o.dispatch({changes:{from:c,to:g.to,insert:g.insert},selection:{anchor:g.cursor},annotations:[ra.of(s),ti.userEvent.of("input.complete")]})}}}function vc(t,n,o){const s=()=>pc(t),c=()=>En(ec(t),t.pos)!==null,f=tc(t);if(f){if(c())return null;const P=ot(n,_r(s().environments),_r(o?.environments??[]));return{from:f.from,options:Vr(P.map(E=>gc(E,f.command))),validFor:/^[A-Za-z0-9*:_-]*$/}}const m=rc(t);if(m&&c())return null;if(m)return{from:m.from,options:ot(n,s().labels,o?.labels??[]),validFor:/^[^,{}\s]*$/};const g=nc(t);if(g&&c())return null;if(g)return{from:g.from,options:ot(n,s().citations,hc(o)),validFor:/^[^,{}\s]*$/};const b=on(t,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(b&&c())return null;if(b)return{from:b.from,options:ot(n,s().files,o?.files??[]),validFor:/^[^{}]*$/};const S=on(t,/\\(?:usepackage|RequirePackage)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/,!0);if(S&&c())return null;if(S)return{from:S.from,options:ot(n,s().packages,o?.packages??[]),validFor:/^[^,{}\s]*$/};const M=on(t,/\\documentclass(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(M&&c())return null;if(M)return{from:M.from,options:ot(n,o?.classes??[]),validFor:/^[^{}]*$/};const A=t.matchBefore(/\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/);return(A||t.explicit)&&c()?null:A||t.explicit?{from:A?.from??t.pos,options:Vr(ot(n,s().commands,o?.commands??[],fc())),validFor:/^\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/}:null}class yc{constructor(n=Fi){this.scan=n}scan;document=null;references=[];referencesFor(n){return n!==this.document&&(this.document=n,this.references=this.scan(n.toString())),this.references}referencesIn(n,o){return Ii(this.referencesFor(n),o)}clear(){this.document=null,this.references=[]}}function bc(t,n,o=1024){if(t.length===0)return[];const s=(n.length?n:[{from:0,to:t.length}]).map(f=>{const m=Math.max(0,f.from-o),g=Math.min(t.length,f.to+o),b=t.lineAt(m).from,S=Math.max(m,Math.max(0,g-1)),M=t.lineAt(S).to;return{from:b,to:M}}).sort((f,m)=>f.from-m.from),c=[];for(const f of s){const m=c.at(-1);m&&f.from<=m.to?m.to=Math.max(m.to,f.to):c.push(f)}return c}function Ii(t,n){if(t.length===0||n.length===0)return[];const o=[];for(const s of n)for(let c=kc(t,s.from);c<t.length;c+=1){const f=t[c];if(f.from>=s.to)break;f.to<=s.to&&o.push(f)}return o}function kc(t,n){let o=0,s=t.length;for(;o<s;){const c=o+Math.floor((s-o)/2);t[c].from<n?o=c+1:s=c}return o}const On=It.define(),Qr=Sn.define();class Oc extends xa{constructor(n){super(),this.label=n}label;toDOM(){const n=document.createElement("button");n.type="button",n.tabIndex=-1,n.className="cm-comment-add-button",n.dataset.commentAdd="true",n.dataset.texliteTooltipAlways="true",n.title=this.label,n.setAttribute("aria-label",this.label);const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d","M20 3H4a2 2 0 0 0-2 2v14l4-4h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Zm-3 7h-4v4h-2v-4H7V8h4V4h2v4h4v2Z"),o.append(s),n.append(o),n}}function jr(t,n){const o=t.selection.main;return o.empty?cn.empty:cn.of([n.range(t.doc.lineAt(o.from).from)])}function Cc(t,n){const o=new Oc(t);return[Ct.define({create:c=>jr(c,o),update:(c,f)=>f.selection||f.docChanged?jr(f.state,o):c,provide:c=>Oa.from(c)}),Ca({domEventHandlers:{mousedown(c,f,m){const g=m.target;if(!(g instanceof Element)||!g.closest("[data-comment-add]"))return!1;const b=c.state.selection.main;return b.empty?!1:(n(c.state.sliceDoc(b.from,b.to),b.from,b.to,c.state.doc.toString()),!0)}}})]}const wc={undo:()=>!1,redo:()=>!1},Nn=$t.define({combine:t=>t.at(-1)??wc});Be.defineAction("texliteUndo",t=>{t.cm6.state.facet(Nn).undo()||t.execCommand("undo")});Be.defineAction("texliteRedo",t=>{t.cm6.state.facet(Nn).redo()||t.execCommand("redo")});Be.mapCommand("u","action","texliteUndo",{},{context:"normal"});Be.mapCommand("<C-r>","action","texliteRedo",{},{context:"normal"});const Sc=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);for(const s of n.effects)s.is(On)&&(o=Nc(s.value,n.state.doc.length));return o},provide:t=>pe.decorations.from(t)}),$i=It.define(),xc=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=J.none);for(const s of n.effects)s.is($i)&&(o=Pc(s.value,n.state.doc.length));return o},provide:t=>pe.decorations.from(t)}),Cn=It.define(),Mc=J.mark({class:"cm-spell-error-active"}),Ec=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=J.none);for(const s of n.effects){if(!s.is(Cn))continue;const c=s.value;o=c&&c.to>c.from?J.set([Mc.range(c.from,c.to)]):J.none}return o},provide:t=>pe.decorations.from(t)}),Lc={enabled:!1,title:()=>""},Ot=$t.define({combine:t=>t.at(-1)??Lc}),Tc=dt.fromClass(class{constructor(t){this.view=t,this.scrollTop=t.scrollDOM.scrollTop,this.scrollLeft=t.scrollDOM.scrollLeft,this.decorations=sn(t,null)}view;decorations;cache=null;viewportDocument=null;viewportChanges=0;scrollTop;scrollLeft;update(t){const n=t.startState.facet(Ot)!==t.state.facet(Ot);if(!t.docChanged&&!t.viewportChanged&&!n)return;const o=t.viewportChanged&&(this.view.scrollDOM.scrollTop!==this.scrollTop||this.view.scrollDOM.scrollLeft!==this.scrollLeft);if(this.scrollTop=this.view.scrollDOM.scrollTop,this.scrollLeft=this.view.scrollDOM.scrollLeft,t.docChanged){this.cache?.clear(),this.cache=null,this.viewportDocument=null,this.viewportChanges=0,this.decorations=sn(this.view,null);return}o&&(this.viewportDocument!==t.state.doc&&(this.viewportDocument=t.state.doc,this.viewportChanges=0),this.viewportChanges+=1,this.viewportChanges>=2&&(this.cache??=new yc)),this.decorations=sn(this.view,this.cache)}},{decorations:t=>t.decorations});function sn(t,n){const o=t.state.facet(Ot);if(!o.enabled||t.state.doc.length===0)return J.none;const s=bc(t.state.doc,t.visibleRanges),c=n?n.referencesIn(t.state.doc,s):Ii(Fi(t.state.sliceDoc(0,s.reduce((g,b)=>Math.max(g,b.to),0))),s),f=[],m=new Set;for(const g of c){const b=g.from,S=g.to,M=[g.kind,g.key,String(b),String(S)].join(":");m.has(M)||S<=b||(m.add(M),f.push(J.mark({class:g.kind==="citation"?"cm-latex-citation-key":"cm-latex-label-key",attributes:{title:o.title(g),spellcheck:"false","data-latex-reference-kind":g.kind,"data-latex-reference-key":g.key,"data-latex-reference-from":String(b),"data-latex-reference-to":String(S),"data-latex-reference-command":g.command}}).range(b,S)))}return f.length?J.set(f,!0):J.none}function Kr(t){if(!(t instanceof HTMLElement))return null;const n=t.closest("[data-latex-reference-kind][data-latex-reference-key]"),o=n?.dataset.latexReferenceKind,s=n?.dataset.latexReferenceKey;return o!=="citation"&&o!=="label"||!s?null:{kind:o,key:s,from:Number(n.dataset.latexReferenceFrom)||0,to:Number(n.dataset.latexReferenceTo)||0,command:n.dataset.latexReferenceCommand??""}}function Kc({value:t,filePath:n,readOnly:o,comments:s,focusComment:c,preferences:f,completionIndex:m,jumpTo:g,searchRequest:b,nativeSpellCheck:S,spellCheckIssues:M,spellCheckJump:A,collaboration:P,onChange:E,onSelection:T,onAddComment:R,onCommentClick:_,onSpellCheckReplace:U,onReferenceNavigate:ee,onCursor:te}){const{t:q,i18n:le}=To(),Oe=Y.useRef(null),H=Y.useRef(null),je=Y.useRef(E),et=Y.useRef(T),Te=Y.useRef(R),Ke=Y.useRef(_),tt=Y.useRef(U),be=Y.useRef(ee),xt=Y.useRef(te),ht=Y.useRef(M),Mt=Y.useRef(b),qe=Y.useRef(m),N=Y.useRef(new At),pt=Y.useRef(new At),st=Y.useRef(new At),He=Y.useRef(new At),me=Y.useRef(null),[We,Ze]=Y.useState(f.vimMode?"NORMAL":""),[W,ze]=Y.useState(null);je.current=E,et.current=T,Te.current=R,Ke.current=_,tt.current=U,be.current=ee,xt.current=te,ht.current=M,qe.current=m;const Ye=(I,G)=>{if(me.current?.(),me.current=null,!G){Ze("");return}const Z=pi(I);if(!Z){Ze("NORMAL");return}const ce=()=>{const Q=Z.state.vim?.mode??(Z.state.vim?.insertMode?"insert":"normal");Ze(Q.toUpperCase())};ce(),Z.on("vim-mode-change",ce),me.current=()=>Z.off("vim-mode-change",ce)};return Y.useEffect(()=>{if(!Oe.current)return;const I=/\.bib$/i.test(n),G=/\.bst$/i.test(n),Z=P&&!o?P.undoManager??null:null,ce=Bt.create({doc:P?.text.toString()??t,extensions:[Cc(q("editor.addComment"),(...Q)=>Te.current(...Q)),ia(),...P?[]:[oa()],aa(),sa(),la(),I?[hl,...Ci(dl(q))]:G?xs:Cl,dr(Sa),...I?[dr(As)]:[],...I?[]:[ei(),...G?[]:[Wr.high(pe.inputHandler.of($l)),Vl,Bl]],ca(),ua(),Sc,xc,Ec,pt.current.of(G?[]:Ot.of(zr(n,q))),...G?[]:[Tc],st.current.of(f.mathPreviewOnHover&&Lr(n)?Tr({loading:q("editor.mathPreviewLoading"),unavailable:q("editor.mathPreviewUnavailable"),preview:q("editor.mathPreview")}):[]),fa({top:!1}),Ac(q),Bt.phrases.of(Rc(q)),da({override:I?[fl]:G?[]:[Q=>vc(Q,q,qe.current)],activateOnTyping:!0}),...Z?[Nn.of({undo:()=>Z.undo()!==null,redo:()=>Z.redo()!==null})]:[],He.current.of(f.vimMode?br():[]),ha.of([...pa,...ma,...ga,...va,...P&&!o?vs:[],...ya,...P?[]:ba]),...P?[ys(P.text,P.awareness,{undoManager:Z??!1})]:[],Bt.readOnly.of(o),N.current.of(qr(f,S)),pe.domEventHandlers({mousedown(Q){const ue=Kr(Q.target);return!ue||!(Q.ctrlKey||Q.metaKey)?!1:(Q.preventDefault(),be.current(ue),!0)},mousemove(Q,ue){const fe=Kr(Q.target);return ue.dom.classList.toggle("cm-reference-navigation-active",!!(fe&&(Q.ctrlKey||Q.metaKey))),!1},mouseleave(Q,ue){return ue.dom.classList.remove("cm-reference-navigation-active"),!1},click(Q){const ue=Q.target.closest("[data-comment-id]");return ue?.dataset.commentId&&Ke.current(ue.dataset.commentId),!1},contextmenu(Q){const ue=Q.target.closest("[data-spell-error]");if(!ue)return!1;const fe=Number(ue.dataset.spellFrom),oe=Number(ue.dataset.spellTo),mt=ht.current.find(Et=>Et.from===fe&&Et.to===oe);if(!mt)return!1;Q.preventDefault();const Re=250,Kt=Math.min(300,100+mt.suggestions.length*34);return ze({issue:mt,left:Math.max(8,Math.min(Q.clientX,window.innerWidth-Re-8)),top:Math.max(8,Math.min(Q.clientY,window.innerHeight-Kt-8))}),!0},blur(Q,ue){const fe=ue.state.selection.main;return et.current(ue.state.sliceDoc(fe.from,fe.to),fe.from,fe.to),P?.awareness.setLocalStateField("cursor",null),!1}}),pe.updateListener.of(Q=>{const ue=Q.transactions.some(fe=>fe.annotation(Qr));if(Q.docChanged&&!ue&&!P&&je.current(Q.state.doc.toString()),Q.docChanged&&ze(null),Q.selectionSet||Q.docChanged){const fe=Q.state.selection.main;et.current(Q.state.sliceDoc(fe.from,fe.to),fe.from,fe.to);const oe=Q.state.doc.lineAt(fe.head);xt.current(oe.number,fe.head-oe.from+1,fe.head)}})]});return H.current=new pe({state:ce,parent:Oe.current}),Ye(H.current,f.vimMode),H.current.dispatch({effects:On.of(Ur(s,n))}),()=>{me.current?.(),me.current=null,H.current?.destroy(),H.current=null}},[n,o,le.resolvedLanguage,P?.text]),Y.useEffect(()=>{const I=H.current;I&&(I.dispatch({effects:[N.current.reconfigure(qr(f,S)),pt.current.reconfigure(/\.bst$/i.test(n)?[]:Ot.of(zr(n,q))),st.current.reconfigure(f.mathPreviewOnHover&&Lr(n)?Tr({loading:q("editor.mathPreviewLoading"),unavailable:q("editor.mathPreviewUnavailable"),preview:q("editor.mathPreview")}):[]),He.current.reconfigure(f.vimMode?br():[])]}),Ye(I,f.vimMode))},[f,S,n,le.resolvedLanguage]),Y.useEffect(()=>{const I=H.current;if(!I)return;const G=I.state.doc.toString(),Z=M.filter(ce=>ce.from>=0&&ce.to<=G.length&&ce.to>ce.from);I.dispatch({effects:[$i.of(Z),Cn.of(null)]})},[M]),Y.useEffect(()=>{ze(null)},[M]),Y.useEffect(()=>{if(!W)return;const I=H.current,G=Q=>{Q.target instanceof Element&&Q.target.closest(".spell-suggestions-menu")||ze(null)},Z=Q=>{Q.key==="Escape"&&ze(null)},ce=()=>ze(null);return document.addEventListener("mousedown",G,!0),document.addEventListener("keydown",Z,!0),I?.scrollDOM.addEventListener("scroll",ce,{passive:!0}),()=>{document.removeEventListener("mousedown",G,!0),document.removeEventListener("keydown",Z,!0),I?.scrollDOM.removeEventListener("scroll",ce)}},[W,n]),Y.useEffect(()=>{const I=H.current;P||!I||I.state.doc.toString()===t||I.dispatch({changes:{from:0,to:I.state.doc.length,insert:t},annotations:Qr.of(!0)})},[t,P]),Y.useEffect(()=>{H.current?.dispatch({effects:On.of(Ur(s,n))})},[s,n]),Y.useEffect(()=>{const I=H.current;if(!I||!c||c.filePath!==n||c.orphaned)return;const G=Math.min(c.startOffset,I.state.doc.length),Z=Math.min(Math.max(G,c.endOffset),I.state.doc.length);I.dispatch({selection:{anchor:G,head:Z},effects:pe.scrollIntoView(G,{y:"center"})}),I.focus()},[n,c]),Y.useEffect(()=>{const I=H.current;if(!I||!g)return;const G=Math.max(1,Math.min(I.state.doc.lines,g.line)),Z=I.state.doc.line(G),ce=Math.min(Z.to,Z.from+Math.max(0,g.column-1));I.dispatch({selection:{anchor:Z.from,head:Z.to},effects:pe.scrollIntoView(ce,{y:"center",yMargin:60})}),I.focus()},[g?.nonce]),Y.useEffect(()=>{const I=H.current;if(!I||!A)return;const G=Math.max(0,Math.min(A.from,I.state.doc.length)),Z=Math.max(G,Math.min(A.to,I.state.doc.length));I.dispatch({selection:{anchor:G},effects:[Cn.of({from:G,to:Z}),pe.scrollIntoView(G,{y:"center",yMargin:60})]}),I.focus()},[A?.nonce]),Y.useEffect(()=>{const I=H.current;!I||b===0||b===Mt.current||(Mt.current=b,ka(I))},[b]),Ve.jsxs("div",{className:"editor-shell",style:{fontFamily:Aa(f.font),fontSize:`${f.fontSize}px`,lineHeight:f.lineHeight},children:[Ve.jsx("div",{className:"editor-host",ref:Oe}),W&&Ve.jsxs("div",{className:"spell-suggestions-menu",role:"menu","aria-label":q("editor.writingSuggestions"),onMouseDown:I=>I.stopPropagation(),children:[Ve.jsx("div",{className:"spell-suggestions-title",children:q("editor.writingSuggestions")}),W.issue.message&&Ve.jsx("div",{className:"spell-suggestions-message",children:W.issue.message}),W.issue.suggestions.map((I,G)=>Ve.jsx("button",{type:"button",role:"menuitem",disabled:o,title:o?q("editor.spellCheckReadOnly"):q("editor.replaceWith",{word:I||q("editor.removeText")}),onClick:()=>{tt.current(W.issue,I),ze(null)},children:I||q("editor.removeText")},`${I}-${G}`)),W.issue.suggestions.length===0&&Ve.jsx("span",{className:"spell-suggestions-empty",children:q("editor.noWritingSuggestions")}),o&&W.issue.suggestions.length>0&&Ve.jsx("span",{className:"spell-suggestions-readonly",children:q("editor.spellCheckReadOnly")})]}),f.vimMode&&Ve.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:Ve.jsxs("span",{children:["--",We||"NORMAL","--"]})})]})}function Rc(t){return{Find:t("editor.search.find"),Replace:t("editor.search.replace"),next:t("editor.search.next"),previous:t("editor.search.previous"),all:t("editor.search.all"),"match case":t("editor.search.matchCase"),regexp:t("editor.search.regexp"),"by word":t("editor.search.wholeWord"),replace:t("editor.search.replaceNext"),"replace all":t("editor.search.replaceAll"),close:t("common.close"),"current match":t("editor.search.currentMatch"),"on line":t("editor.search.onLine"),"replaced match on line $":t("editor.search.replacedMatchOnLine"),"replaced $ matches":t("editor.search.replacedMatches"),"Go to line":t("editor.search.goToLine"),go:t("editor.search.go")}}function Ac(t){return dt.fromClass(class{constructor(n){this.view=n,this.document=n.state.doc,this.schedule()}view;frame=null;document;signature="";count=0;update(){this.schedule()}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame)}schedule(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()})}render(){if(!wa(this.view.state))return;const n=this.view.dom.querySelector(".cm-panel.cm-search");if(!n)return;let o=n.querySelector(".cm-search-count");if(!o){o=document.createElement("span"),o.className="cm-search-count",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const f=n.querySelector("[name=close]");n.insertBefore(o,f)}const s=Ma(this.view.state),c=ks(s);(this.document!==this.view.state.doc||this.signature!==c)&&(this.document=this.view.state.doc,this.signature=c,this.count=bs(this.view.state,s)),o.textContent=s.search?s.valid?this.count===0?t("editor.search.noMatches"):t("editor.search.matchCount",{count:this.count}):t("editor.search.invalidQuery"):""}})}function qr(t,n){return[pe.contentAttributes.of({spellcheck:n?"true":"false",autocorrect:"off",autocapitalize:"off",autocomplete:"off",lang:"en-US"}),pe.theme({"&":{fontSize:`${t.fontSize}px`},".cm-scroller":{fontFamily:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit"},".cm-gutters":{fontFamily:"inherit",fontSize:"inherit"}}),t.lineWrapping?pe.lineWrapping:[]]}function zr(t,n){return{enabled:/\.(?:tex|sty|cls)$/i.test(t),title:s=>s.kind==="citation"?n("editor.citationJumpHint",{key:s.key}):n("editor.labelJumpHint",{key:s.key})}}function Pc(t,n){const o=t.map(s=>({from:Math.max(0,Math.min(n,s.from)),to:Math.max(0,Math.min(n,s.to)),word:s.word,kind:s.kind,message:s.message})).filter(s=>s.to>s.from).sort((s,c)=>s.from-c.from||s.to-c.to);return J.set(o.map(s=>J.mark({class:s.kind==="spelling"?"cm-spell-error":"cm-grammar-warning",attributes:{title:s.message||s.word,"data-spell-error":"true","data-spell-kind":s.kind,"data-spell-from":String(s.from),"data-spell-to":String(s.to)}}).range(s.from,s.to)),!0)}function Ur(t,n){return t.filter(o=>o.filePath===n).map(o=>({id:o.id,from:o.startOffset,to:o.endOffset,resolved:o.resolved,orphaned:o.orphaned}))}function Nc(t,n){const o=t.filter(s=>!s.orphaned&&!s.resolved).flatMap(s=>{const c=Math.max(0,Math.min(n,s.from)),f=Math.max(c,Math.min(n,s.to)),m="cm-source-comment";return c===f?[J.widget({widget:new Xr(s.id,m),side:1}).range(c)]:[J.mark({class:m}).range(c,f),J.widget({widget:new Xr(s.id,m),side:1}).range(f)]});return J.set(o,!0)}class Xr extends Yr{constructor(n,o){super(),this.id=n,this.className=o}id;className;toDOM(){const n=document.createElement("span");return n.className=`${this.className} cm-comment-pin`,n.dataset.commentId=this.id,n.textContent="●",n}}export{Kc as LatexEditor};
138
+ \\end{figure}`,{label:"\\begin{figure}"})]}function dc(t){const n=[],o=[],s=[],c=[],f=[],m=[],g=oi(Ra(t)),b=(S,M,A,P,E)=>{M&&!S.some(T=>T.label===M)&&S.push({label:M,detail:A,kind:P,source:"Current file",...E?{apply:E}:{}})};for(const S of g.matchAll(/\\(?:newcommand|renewcommand|providecommand|DeclareRobustCommand)\s*\*?\s*(?:\{\s*)?\\([A-Za-z@][A-Za-z@0-9:_]*)\s*(?:\})?\s*(?:\[(\d+)\])?(?:\s*(\[[^\]]*\]))?/g)){const M=Fr(Number.parseInt(S[2]??"0",10),!!S[3]);b(n,`\\${S[1]}`,"Project command","function",an(`\\${S[1]}`,M))}for(const S of cc(g)){const M=sc(S.specification);b(n,`\\${S.name}`,"Project command","function",M?an(`\\${S.name}`,M):void 0)}for(const S of g.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)){const M=[...(S[2]??"").matchAll(/#\d+/g)].length;b(n,`\\${S[1]}`,"Project macro","function",an(`\\${S[1]}`,Fr(M,!1)))}for(const S of g.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))b(n,`\\${S[1]}`,"Project math delimiter","function");for(const S of g.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))b(n,`\\${S[1]}`,"Expl3 project command","function");for(const S of g.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g))b(o,S[1].trim(),"Project environment","keyword");for(const S of Dr(t,"label"))S.source==="label"&&b(s,S.key,"Label","constant");for(const S of g.matchAll(/\\(?:usepackage|RequirePackage)\s*(?:\[[^\]]*\])?\s*\{([^}]+)\}/g))for(const M of S[1].split(","))b(f,M.trim(),"Package","text");for(const S of g.matchAll(/\\(?:input|include|subfile)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g))b(m,(S[1]??S[2]??"").trim(),"Project file","text");for(const S of Dr(t,"citation"))S.source==="bibitem"&&b(c,S.key,"Bibliography key","constant");return{commands:n,environments:o,labels:s,citations:c,packages:f,classes:[],files:m}}function hc(t){return(t?.citations??[]).filter(n=>/\.bib$/i.test(n.source??""))}const Ir=new WeakMap;function pc(t){const n=t.state.doc,o=Ir.get(n);if(o)return o;const s=dc(t.state.doc.toString());return Ir.set(n,s),s}const $r={"Project command":"projectCommand","Project macro":"projectMacro","Expl3 project command":"expl3Command","Project math operator":"mathOperator","Project math delimiter":"mathDelimiter","Project environment":"projectEnvironment","Project file":"projectFile",Package:"package","Document class":"documentClass","Current file":"currentFile",Project:"project",LaTeX:"latex"};function mc(t,n,o=!0){const s=$r[t.detail],c=t.source?$r[t.source]:void 0,f=t.detail.match(/^Project command \((\d+) arguments?\)$/),m=t.source==="LaTeX"?"":f?n("completions.projectCommandArgs",{count:Number(f[1])}):s?n(`completions.${s}`):t.source==="LaTeX"?n("completions.standard"):t.detail,g=t.source==="LaTeX"?"":c?n(`completions.${c}`):t.source,b=g&&m?`${m} · ${g}`:m||g||void 0,S={label:t.label,type:t.kind,...b?{detail:b}:{},...t.info?{info:t.info}:{}};return o&&t.apply?ie(t.apply,S):S}function ot(t,...n){const o=[],s=new Set;for(const c of n)for(const f of c){const m="kind"in f?mc(f,t):f;s.has(m.label)||(s.add(m.label),o.push(m))}return o}function Vr(t){return t.map(({detail:n,...o})=>o)}function _r(t){return t.map(({apply:n,...o})=>o)}function gc(t,n){return{...t,apply(o,s,c,f){const m=s.label,g=oc(o.state.doc,c,f,m,n);o.dispatch({changes:{from:c,to:g.to,insert:g.insert},selection:{anchor:g.cursor},annotations:[ra.of(s),ti.userEvent.of("input.complete")]})}}}function vc(t,n,o){const s=()=>pc(t),c=()=>En(ec(t),t.pos)!==null,f=tc(t);if(f){if(c())return null;const P=ot(n,_r(s().environments),_r(o?.environments??[]));return{from:f.from,options:Vr(P.map(E=>gc(E,f.command))),validFor:/^[A-Za-z0-9*:_-]*$/}}const m=rc(t);if(m&&c())return null;if(m)return{from:m.from,options:ot(n,s().labels,o?.labels??[]),validFor:/^[^,{}\s]*$/};const g=nc(t);if(g&&c())return null;if(g)return{from:g.from,options:ot(n,s().citations,hc(o)),validFor:/^[^,{}\s]*$/};const b=on(t,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(b&&c())return null;if(b)return{from:b.from,options:ot(n,s().files,o?.files??[]),validFor:/^[^{}]*$/};const S=on(t,/\\(?:usepackage|RequirePackage)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/,!0);if(S&&c())return null;if(S)return{from:S.from,options:ot(n,s().packages,o?.packages??[]),validFor:/^[^,{}\s]*$/};const M=on(t,/\\documentclass(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(M&&c())return null;if(M)return{from:M.from,options:ot(n,o?.classes??[]),validFor:/^[^{}]*$/};const A=t.matchBefore(/\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/);return(A||t.explicit)&&c()?null:A||t.explicit?{from:A?.from??t.pos,options:Vr(ot(n,s().commands,o?.commands??[],fc())),validFor:/^\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/}:null}class yc{constructor(n=Fi){this.scan=n}scan;document=null;references=[];referencesFor(n){return n!==this.document&&(this.document=n,this.references=this.scan(n.toString())),this.references}referencesIn(n,o){return Ii(this.referencesFor(n),o)}clear(){this.document=null,this.references=[]}}function bc(t,n,o=1024){if(t.length===0)return[];const s=(n.length?n:[{from:0,to:t.length}]).map(f=>{const m=Math.max(0,f.from-o),g=Math.min(t.length,f.to+o),b=t.lineAt(m).from,S=Math.max(m,Math.max(0,g-1)),M=t.lineAt(S).to;return{from:b,to:M}}).sort((f,m)=>f.from-m.from),c=[];for(const f of s){const m=c.at(-1);m&&f.from<=m.to?m.to=Math.max(m.to,f.to):c.push(f)}return c}function Ii(t,n){if(t.length===0||n.length===0)return[];const o=[];for(const s of n)for(let c=kc(t,s.from);c<t.length;c+=1){const f=t[c];if(f.from>=s.to)break;f.to<=s.to&&o.push(f)}return o}function kc(t,n){let o=0,s=t.length;for(;o<s;){const c=o+Math.floor((s-o)/2);t[c].from<n?o=c+1:s=c}return o}const On=It.define(),Qr=Sn.define();class Oc extends xa{constructor(n){super(),this.label=n}label;toDOM(){const n=document.createElement("button");n.type="button",n.tabIndex=-1,n.className="cm-comment-add-button",n.dataset.commentAdd="true",n.dataset.texliteTooltipAlways="true",n.title=this.label,n.setAttribute("aria-label",this.label);const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d","M20 3H4a2 2 0 0 0-2 2v14l4-4h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Zm-3 7h-4v4h-2v-4H7V8h4V4h2v4h4v2Z"),o.append(s),n.append(o),n}}function jr(t,n){const o=t.selection.main;return o.empty?cn.empty:cn.of([n.range(t.doc.lineAt(o.from).from)])}function Cc(t,n){const o=new Oc(t);return[Ct.define({create:c=>jr(c,o),update:(c,f)=>f.selection||f.docChanged?jr(f.state,o):c,provide:c=>Oa.from(c)}),Ca({domEventHandlers:{mousedown(c,f,m){const g=m.target;if(!(g instanceof Element)||!g.closest("[data-comment-add]"))return!1;const b=c.state.selection.main;return b.empty?!1:(n(c.state.sliceDoc(b.from,b.to),b.from,b.to,c.state.doc.toString()),!0)}}})]}const wc={undo:()=>!1,redo:()=>!1},Nn=$t.define({combine:t=>t.at(-1)??wc});Be.defineAction("texliteUndo",t=>{t.cm6.state.facet(Nn).undo()||t.execCommand("undo")});Be.defineAction("texliteRedo",t=>{t.cm6.state.facet(Nn).redo()||t.execCommand("redo")});Be.mapCommand("u","action","texliteUndo",{},{context:"normal"});Be.mapCommand("<C-r>","action","texliteRedo",{},{context:"normal"});const Sc=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);for(const s of n.effects)s.is(On)&&(o=Nc(s.value,n.state.doc.length));return o},provide:t=>pe.decorations.from(t)}),$i=It.define(),xc=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=J.none);for(const s of n.effects)s.is($i)&&(o=Pc(s.value,n.state.doc.length));return o},provide:t=>pe.decorations.from(t)}),Cn=It.define(),Mc=J.mark({class:"cm-spell-error-active"}),Ec=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=J.none);for(const s of n.effects){if(!s.is(Cn))continue;const c=s.value;o=c&&c.to>c.from?J.set([Mc.range(c.from,c.to)]):J.none}return o},provide:t=>pe.decorations.from(t)}),Lc={enabled:!1,title:()=>""},Ot=$t.define({combine:t=>t.at(-1)??Lc}),Tc=dt.fromClass(class{constructor(t){this.view=t,this.scrollTop=t.scrollDOM.scrollTop,this.scrollLeft=t.scrollDOM.scrollLeft,this.decorations=sn(t,null)}view;decorations;cache=null;viewportDocument=null;viewportChanges=0;scrollTop;scrollLeft;update(t){const n=t.startState.facet(Ot)!==t.state.facet(Ot);if(!t.docChanged&&!t.viewportChanged&&!n)return;const o=t.viewportChanged&&(this.view.scrollDOM.scrollTop!==this.scrollTop||this.view.scrollDOM.scrollLeft!==this.scrollLeft);if(this.scrollTop=this.view.scrollDOM.scrollTop,this.scrollLeft=this.view.scrollDOM.scrollLeft,t.docChanged){this.cache?.clear(),this.cache=null,this.viewportDocument=null,this.viewportChanges=0,this.decorations=sn(this.view,null);return}o&&(this.viewportDocument!==t.state.doc&&(this.viewportDocument=t.state.doc,this.viewportChanges=0),this.viewportChanges+=1,this.viewportChanges>=2&&(this.cache??=new yc)),this.decorations=sn(this.view,this.cache)}},{decorations:t=>t.decorations});function sn(t,n){const o=t.state.facet(Ot);if(!o.enabled||t.state.doc.length===0)return J.none;const s=bc(t.state.doc,t.visibleRanges),c=n?n.referencesIn(t.state.doc,s):Ii(Fi(t.state.sliceDoc(0,s.reduce((g,b)=>Math.max(g,b.to),0))),s),f=[],m=new Set;for(const g of c){const b=g.from,S=g.to,M=[g.kind,g.key,String(b),String(S)].join(":");m.has(M)||S<=b||(m.add(M),f.push(J.mark({class:g.kind==="citation"?"cm-latex-citation-key":"cm-latex-label-key",attributes:{title:o.title(g),spellcheck:"false","data-latex-reference-kind":g.kind,"data-latex-reference-key":g.key,"data-latex-reference-from":String(b),"data-latex-reference-to":String(S),"data-latex-reference-command":g.command}}).range(b,S)))}return f.length?J.set(f,!0):J.none}function Kr(t){if(!(t instanceof HTMLElement))return null;const n=t.closest("[data-latex-reference-kind][data-latex-reference-key]"),o=n?.dataset.latexReferenceKind,s=n?.dataset.latexReferenceKey;return o!=="citation"&&o!=="label"||!s?null:{kind:o,key:s,from:Number(n.dataset.latexReferenceFrom)||0,to:Number(n.dataset.latexReferenceTo)||0,command:n.dataset.latexReferenceCommand??""}}function Kc({value:t,filePath:n,readOnly:o,comments:s,focusComment:c,preferences:f,completionIndex:m,jumpTo:g,searchRequest:b,nativeSpellCheck:S,spellCheckIssues:M,spellCheckJump:A,collaboration:P,onChange:E,onSelection:T,onAddComment:R,onCommentClick:_,onSpellCheckReplace:U,onReferenceNavigate:ee,onCursor:te}){const{t:q,i18n:le}=To(),Oe=Y.useRef(null),H=Y.useRef(null),je=Y.useRef(E),et=Y.useRef(T),Te=Y.useRef(R),Ke=Y.useRef(_),tt=Y.useRef(U),be=Y.useRef(ee),xt=Y.useRef(te),ht=Y.useRef(M),Mt=Y.useRef(b),qe=Y.useRef(m),N=Y.useRef(new At),pt=Y.useRef(new At),st=Y.useRef(new At),He=Y.useRef(new At),me=Y.useRef(null),[We,Ze]=Y.useState(f.vimMode?"NORMAL":""),[W,ze]=Y.useState(null);je.current=E,et.current=T,Te.current=R,Ke.current=_,tt.current=U,be.current=ee,xt.current=te,ht.current=M,qe.current=m;const Ye=(I,G)=>{if(me.current?.(),me.current=null,!G){Ze("");return}const Z=pi(I);if(!Z){Ze("NORMAL");return}const ce=()=>{const Q=Z.state.vim?.mode??(Z.state.vim?.insertMode?"insert":"normal");Ze(Q.toUpperCase())};ce(),Z.on("vim-mode-change",ce),me.current=()=>Z.off("vim-mode-change",ce)};return Y.useEffect(()=>{if(!Oe.current)return;const I=/\.bib$/i.test(n),G=/\.bst$/i.test(n),Z=P&&!o?P.undoManager??null:null,ce=Bt.create({doc:P?.text.toString()??t,extensions:[Cc(q("editor.addComment"),(...Q)=>Te.current(...Q)),ia(),...P?[]:[oa()],aa(),sa(),la(),I?[hl,...Ci(dl(q))]:G?xs:Cl,dr(Sa),...I?[dr(As)]:[],...I?[]:[ei(),...G?[]:[Wr.high(pe.inputHandler.of($l)),Vl,Bl]],ca(),ua(),Sc,xc,Ec,pt.current.of(G?[]:Ot.of(zr(n,q))),...G?[]:[Tc],st.current.of(f.mathPreviewOnHover&&Lr(n)?Tr({loading:q("editor.mathPreviewLoading"),unavailable:q("editor.mathPreviewUnavailable"),preview:q("editor.mathPreview")}):[]),fa({top:!1}),Ac(q),Bt.phrases.of(Rc(q)),da({override:I?[fl]:G?[]:[Q=>vc(Q,q,qe.current)],activateOnTyping:!0}),...Z?[Nn.of({undo:()=>Z.undo()!==null,redo:()=>Z.redo()!==null})]:[],He.current.of(f.vimMode?br():[]),ha.of([...pa,...ma,...ga,...va,...P&&!o?vs:[],...ya,...P?[]:ba]),...P?[ys(P.text,P.awareness,{undoManager:Z??!1})]:[],Bt.readOnly.of(o),N.current.of(qr(f,S)),pe.domEventHandlers({mousedown(Q){const ue=Kr(Q.target);return!ue||!(Q.ctrlKey||Q.metaKey)?!1:(Q.preventDefault(),be.current(ue),!0)},mousemove(Q,ue){const fe=Kr(Q.target);return ue.dom.classList.toggle("cm-reference-navigation-active",!!(fe&&(Q.ctrlKey||Q.metaKey))),!1},mouseleave(Q,ue){return ue.dom.classList.remove("cm-reference-navigation-active"),!1},click(Q){const ue=Q.target.closest("[data-comment-id]");return ue?.dataset.commentId&&Ke.current(ue.dataset.commentId),!1},contextmenu(Q){const ue=Q.target.closest("[data-spell-error]");if(!ue)return!1;const fe=Number(ue.dataset.spellFrom),oe=Number(ue.dataset.spellTo),mt=ht.current.find(Et=>Et.from===fe&&Et.to===oe);if(!mt)return!1;Q.preventDefault();const Re=250,Kt=Math.min(300,100+mt.suggestions.length*34);return ze({issue:mt,left:Math.max(8,Math.min(Q.clientX,window.innerWidth-Re-8)),top:Math.max(8,Math.min(Q.clientY,window.innerHeight-Kt-8))}),!0},blur(Q,ue){const fe=ue.state.selection.main;return et.current(ue.state.sliceDoc(fe.from,fe.to),fe.from,fe.to),P?.awareness.setLocalStateField("cursor",null),!1}}),pe.updateListener.of(Q=>{const ue=Q.transactions.some(fe=>fe.annotation(Qr));if(Q.docChanged&&!ue&&!P&&je.current(Q.state.doc.toString()),Q.docChanged&&ze(null),Q.selectionSet||Q.docChanged){const fe=Q.state.selection.main;et.current(Q.state.sliceDoc(fe.from,fe.to),fe.from,fe.to);const oe=Q.state.doc.lineAt(fe.head);xt.current(oe.number,fe.head-oe.from+1,fe.head)}})]});return H.current=new pe({state:ce,parent:Oe.current}),Ye(H.current,f.vimMode),H.current.dispatch({effects:On.of(Ur(s,n))}),()=>{me.current?.(),me.current=null,H.current?.destroy(),H.current=null}},[n,o,le.resolvedLanguage,P?.text]),Y.useEffect(()=>{const I=H.current;I&&(I.dispatch({effects:[N.current.reconfigure(qr(f,S)),pt.current.reconfigure(/\.bst$/i.test(n)?[]:Ot.of(zr(n,q))),st.current.reconfigure(f.mathPreviewOnHover&&Lr(n)?Tr({loading:q("editor.mathPreviewLoading"),unavailable:q("editor.mathPreviewUnavailable"),preview:q("editor.mathPreview")}):[]),He.current.reconfigure(f.vimMode?br():[])]}),Ye(I,f.vimMode))},[f,S,n,le.resolvedLanguage]),Y.useEffect(()=>{const I=H.current;if(!I)return;const G=I.state.doc.toString(),Z=M.filter(ce=>ce.from>=0&&ce.to<=G.length&&ce.to>ce.from);I.dispatch({effects:[$i.of(Z),Cn.of(null)]})},[M]),Y.useEffect(()=>{ze(null)},[M]),Y.useEffect(()=>{if(!W)return;const I=H.current,G=Q=>{Q.target instanceof Element&&Q.target.closest(".spell-suggestions-menu")||ze(null)},Z=Q=>{Q.key==="Escape"&&ze(null)},ce=()=>ze(null);return document.addEventListener("mousedown",G,!0),document.addEventListener("keydown",Z,!0),I?.scrollDOM.addEventListener("scroll",ce,{passive:!0}),()=>{document.removeEventListener("mousedown",G,!0),document.removeEventListener("keydown",Z,!0),I?.scrollDOM.removeEventListener("scroll",ce)}},[W,n]),Y.useEffect(()=>{const I=H.current;P||!I||I.state.doc.toString()===t||I.dispatch({changes:{from:0,to:I.state.doc.length,insert:t},annotations:Qr.of(!0)})},[t,P]),Y.useEffect(()=>{H.current?.dispatch({effects:On.of(Ur(s,n))})},[s,n]),Y.useEffect(()=>{const I=H.current;if(!I||!c||c.filePath!==n||c.orphaned)return;const G=Math.min(c.startOffset,I.state.doc.length),Z=Math.min(Math.max(G,c.endOffset),I.state.doc.length);I.dispatch({selection:{anchor:G,head:Z},effects:pe.scrollIntoView(G,{y:"center"})}),I.focus()},[n,c]),Y.useEffect(()=>{const I=H.current;if(!I||!g)return;const G=Math.max(1,Math.min(I.state.doc.lines,g.line)),Z=I.state.doc.line(G),ce=Math.min(Z.to,Z.from+Math.max(0,g.column-1));I.dispatch({selection:{anchor:Z.from,head:Z.to},effects:pe.scrollIntoView(ce,{y:"center",yMargin:60})}),I.focus()},[g?.nonce]),Y.useEffect(()=>{const I=H.current;if(!I||!A)return;const G=Math.max(0,Math.min(A.from,I.state.doc.length)),Z=Math.max(G,Math.min(A.to,I.state.doc.length));I.dispatch({selection:{anchor:G},effects:[Cn.of({from:G,to:Z}),pe.scrollIntoView(G,{y:"center",yMargin:60})]}),I.focus()},[A?.nonce]),Y.useEffect(()=>{const I=H.current;!I||b===0||b===Mt.current||(Mt.current=b,ka(I))},[b]),Ve.jsxs("div",{className:"editor-shell",style:{fontFamily:Aa(f.font),fontSize:`${f.fontSize}px`,lineHeight:f.lineHeight},children:[Ve.jsx("div",{className:"editor-host",ref:Oe}),W&&Ve.jsxs("div",{className:"spell-suggestions-menu",role:"menu","aria-label":q("editor.writingSuggestions"),onMouseDown:I=>I.stopPropagation(),children:[Ve.jsx("div",{className:"spell-suggestions-title",children:q("editor.writingSuggestions")}),W.issue.message&&Ve.jsx("div",{className:"spell-suggestions-message",children:W.issue.message}),W.issue.suggestions.map((I,G)=>Ve.jsx("button",{type:"button",role:"menuitem",disabled:o,title:o?q("editor.spellCheckReadOnly"):q("editor.replaceWith",{word:I||q("editor.removeText")}),onClick:()=>{tt.current(W.issue,I),ze(null)},children:I||q("editor.removeText")},`${I}-${G}`)),W.issue.suggestions.length===0&&Ve.jsx("span",{className:"spell-suggestions-empty",children:q("editor.noWritingSuggestions")}),o&&W.issue.suggestions.length>0&&Ve.jsx("span",{className:"spell-suggestions-readonly",children:q("editor.spellCheckReadOnly")})]}),f.vimMode&&Ve.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:Ve.jsxs("span",{children:["--",We||"NORMAL","--"]})})]})}function Rc(t){return{Find:t("editor.search.find"),Replace:t("editor.search.replace"),next:t("editor.search.next"),previous:t("editor.search.previous"),all:t("editor.search.all"),"match case":t("editor.search.matchCase"),regexp:t("editor.search.regexp"),"by word":t("editor.search.wholeWord"),replace:t("editor.search.replaceNext"),"replace all":t("editor.search.replaceAll"),close:t("common.close"),"current match":t("editor.search.currentMatch"),"on line":t("editor.search.onLine"),"replaced match on line $":t("editor.search.replacedMatchOnLine"),"replaced $ matches":t("editor.search.replacedMatches"),"Go to line":t("editor.search.goToLine"),go:t("editor.search.go")}}function Ac(t){return dt.fromClass(class{constructor(n){this.view=n,this.document=n.state.doc,this.schedule()}view;frame=null;document;signature="";count=0;update(){this.schedule()}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame)}schedule(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()})}render(){if(!wa(this.view.state))return;const n=this.view.dom.querySelector(".cm-panel.cm-search");if(!n)return;let o=n.querySelector(".cm-search-count");if(!o){o=document.createElement("span"),o.className="cm-search-count",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const f=n.querySelector("[name=close]");n.insertBefore(o,f)}const s=Ma(this.view.state),c=ks(s);(this.document!==this.view.state.doc||this.signature!==c)&&(this.document=this.view.state.doc,this.signature=c,this.count=bs(this.view.state,s)),o.textContent=s.search?s.valid?this.count===0?t("editor.search.noMatches"):t("editor.search.matchCount",{count:this.count}):t("editor.search.invalidQuery"):""}})}function qr(t,n){return[pe.contentAttributes.of({spellcheck:n?"true":"false",autocorrect:"off",autocapitalize:"off",autocomplete:"off",lang:"en-US"}),pe.theme({"&":{fontSize:`${t.fontSize}px`},".cm-scroller":{fontFamily:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit"},".cm-gutters":{fontFamily:"inherit",fontSize:"inherit"}}),t.lineWrapping?pe.lineWrapping:[]]}function zr(t,n){return{enabled:/\.(?:tex|sty|cls)$/i.test(t),title:s=>s.kind==="citation"?n("editor.citationJumpHint",{key:s.key}):n("editor.labelJumpHint",{key:s.key})}}function Pc(t,n){const o=t.map(s=>({from:Math.max(0,Math.min(n,s.from)),to:Math.max(0,Math.min(n,s.to)),word:s.word,kind:s.kind,message:s.message})).filter(s=>s.to>s.from).sort((s,c)=>s.from-c.from||s.to-c.to);return J.set(o.map(s=>J.mark({class:s.kind==="spelling"?"cm-spell-error":s.kind==="latex"?"cm-latex-writing-issue":"cm-grammar-warning",attributes:{title:s.message||s.word,"data-spell-error":"true","data-spell-kind":s.kind,"data-spell-from":String(s.from),"data-spell-to":String(s.to)}}).range(s.from,s.to)),!0)}function Ur(t,n){return t.filter(o=>o.filePath===n).map(o=>({id:o.id,from:o.startOffset,to:o.endOffset,resolved:o.resolved,orphaned:o.orphaned}))}function Nc(t,n){const o=t.filter(s=>!s.orphaned&&!s.resolved).flatMap(s=>{const c=Math.max(0,Math.min(n,s.from)),f=Math.max(c,Math.min(n,s.to)),m="cm-source-comment";return c===f?[J.widget({widget:new Xr(s.id,m),side:1}).range(c)]:[J.mark({class:m}).range(c,f),J.widget({widget:new Xr(s.id,m),side:1}).range(f)]});return J.set(o,!0)}class Xr extends Yr{constructor(n,o){super(),this.id=n,this.className=o}id;className;toDOM(){const n=document.createElement("span");return n.className=`${this.className} cm-comment-pin`,n.dataset.commentId=this.id,n.textContent="●",n}}export{Kc as LatexEditor};
@@ -0,0 +1 @@
1
+ import{u as Q,r as t,j as e}from"./react-BVUjbTTn.js";import{P as de,g as fe,w as he,G as me}from"./pdf-DUYcbPMK.js";import{M as pe,a as ge}from"./minus-BpuvzV2m.js";import{P as xe}from"./plus-BFr75l91.js";import{d as G}from"./index-CqBmQAzW.js";import{R as J}from"./refresh-cw-DyA4NKh7.js";me.workerSrc=he;const se=new de,re=2,S=new Map;async function Ee(){await se.promise}function ie(i,r){const n=`${r}:${i}`,a=S.get(n);if(a)return a.lastUsed=Date.now(),a;const m=fe({url:i,worker:se,disableRange:r==="full"}),o={task:m,promise:m.promise,consumers:0,settled:!1,retired:!1,lastUsed:Date.now()};return S.set(n,o),o.promise.then(()=>{o.settled=!0,oe()},()=>{o.settled=!0,S.get(n)===o&&S.delete(n),o.retired||(o.retired=!0,o.consumers===0&&o.task.destroy())}),o}function we(i,r){const n=`${r}:${i}`,a=S.get(n);a&&(S.delete(n),a.retired=!0,a.consumers===0&&a.task.destroy())}function oe(){if(S.size<=re)return;const i=[...S.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,n)=>r[1].lastUsed-n[1].lastUsed);for(;S.size>re&&i.length;){const[r,n]=i.shift();S.get(r)===n&&(S.delete(r),n.retired=!0,n.task.destroy())}}function Se(i,r){if(!i)return;ie(i,r).promise.catch(()=>{})}function ye(i,r){const n=ie(i,r);n.consumers+=1,n.lastUsed=Date.now();let a=!1;return{promise:n.promise,release:()=>{a||(a=!0,n.consumers=Math.max(0,n.consumers-1),n.lastUsed=Date.now(),n.retired&&n.consumers===0&&n.task.destroy(),oe())}}}function Ce({url:i,loadingMode:r,target:n,compiling:a=!1,onViewportLocation:m,onDoubleClickLocation:o,onDisplayedUrlChange:U}){const{t:d}=Q(),v=t.useRef(null),[p,$]=t.useState(null),[f,R]=t.useState(""),[k,N]=t.useState(0),[M,C]=t.useState(100),[P,b]=t.useState(""),[y,z]=t.useState(0),j=t.useRef(new Map),D=t.useRef(null),A=t.useRef(null),E=t.useRef(null),L=t.useRef(m);L.current=m;const F=t.useRef(U);F.current=U;const T=t.useRef(0),B=()=>{we(i,r),F.current?.(""),b(""),z(s=>s+1)},W=t.useCallback((s,c)=>{c?j.current.set(s,c):j.current.delete(s)},[]),_=async s=>{if(!p||s==null)return;let c=s;if(typeof s=="string"&&(c=await p.getDestination(s).catch(()=>null)),!Array.isArray(c)||c.length===0)return;const u=c[0];let w=null;if(typeof u=="number"&&Number.isInteger(u))w=u;else if(u!=null)try{w=await p.getPageIndex(u)}catch{return}w==null||w<0||w>=p.numPages||j.current.get(w+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},l=t.useCallback(()=>{D.current=null;const s=v.current;if(!s)return;const c=s.getBoundingClientRect(),u=c.left+c.width/2,w=c.top+c.height/2,q=[...s.querySelectorAll(".pdf-page")],H=q.find(Y=>{const V=Y.getBoundingClientRect();return w>=V.top&&w<=V.bottom})??q.reduce((Y,V)=>{if(!Y)return V;const ae=Math.abs(V.getBoundingClientRect().top-w),ue=Math.abs(Y.getBoundingClientRect().top-w);return ae<ue?V:Y},null);if(!H)return;const K=H.getBoundingClientRect(),ee=Number(H.dataset.scale)||1,te=Number(H.dataset.page),ce=Math.max(0,Math.min(K.width,u-K.left))/ee,le=Math.max(0,Math.min(K.height,w-K.top))/ee;te&&L.current(te,ce,le)},[]),x=t.useCallback(()=>{D.current===null&&(D.current=window.requestAnimationFrame(l))},[l]);t.useEffect(()=>()=>{D.current!==null&&window.cancelAnimationFrame(D.current),D.current=null},[]),t.useEffect(()=>{const s=v.current;if(!s)return;const c=()=>N(s.clientWidth);c();const u=new ResizeObserver(c);return u.observe(s),()=>u.disconnect()},[]),t.useEffect(()=>{const s=A.current;if(s?.url===i&&s.loadingMode===r&&T.current===y){b("");return}let c=!1;b("");const u=ye(i,r);return E.current=u,u.promise.then(w=>{if(c)return;const q=A.current;A.current={...u,url:i,loadingMode:r},T.current=y,E.current===u&&(E.current=null),$(w),R(i),q?.release()}).catch(()=>{c||(E.current===u&&(E.current=null),u.release(),b(d("editor.pdfLoadFailed")))}),()=>{c=!0,E.current===u&&(E.current=null,u.release())}},[i,r,y,d]),t.useEffect(()=>()=>{F.current?.(""),E.current?.release(),E.current=null,A.current?.release(),A.current=null},[]),t.useEffect(()=>{M>100||!v.current||(v.current.scrollLeft=0)},[M,k,p]);const h=s=>C(c=>Math.min(200,Math.max(50,c+s))),g=()=>{v.current&&(v.current.scrollLeft=0),C(100)},O=s=>{!s.shiftKey||Math.abs(s.deltaX)>Math.abs(s.deltaY)||(s.preventDefault(),s.currentTarget.scrollLeft+=s.deltaY,x())},Z=!!(p&&f!==i&&!P),I=f===i?n:null,X=()=>{f===i&&F.current?.(i),x()};return e.jsxs("div",{className:"pdf-viewer",children:[e.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":d("editor.pdfZoomControls"),children:[e.jsx("button",{disabled:M<=50,title:d("editor.pdfZoomOut"),"aria-label":d("editor.pdfZoomOut"),onClick:()=>h(-10),children:e.jsx(pe,{size:14})}),e.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[M,"%"]}),e.jsx("button",{disabled:M>=200,title:d("editor.pdfZoomIn"),"aria-label":d("editor.pdfZoomIn"),onClick:()=>h(10),children:e.jsx(xe,{size:14})}),e.jsxs("button",{className:"pdf-fit-width",title:d("editor.pdfFitWidth"),onClick:g,children:[e.jsx(ge,{size:13}),d("editor.pdfFitWidth")]})]}),a&&e.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.compiling")})]}),Z&&!a&&e.jsxs("div",{className:"pdf-loading-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.loadingPdf")})]}),p&&P&&e.jsxs("div",{className:"pdf-load-error-overlay",role:"status","aria-live":"polite",children:[e.jsx("span",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:13}),d("common.retry")]})]}),e.jsx("div",{className:"pdf-document",ref:v,onScroll:x,onWheel:O,children:e.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,k-28)*Math.max(1,M/100)}px`},children:[!p&&!P&&e.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:24}),e.jsx("span",{children:d("editor.loadingPdf")})]}),P&&!p&&e.jsxs("div",{className:"preview-empty",children:[e.jsx("strong",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:14}),d("common.retry")]})]}),p&&k>0&&Array.from({length:p.numPages},(s,c)=>e.jsx(ve,{document:p,pageNumber:c+1,availableWidth:k-28,zoom:M/100,target:I?.page===c+1?I:null,onReady:X,onPageElement:W,onInternalLink:_,onDoubleClickLocation:f===i?o:void 0,onRetryDocument:B},`${f}:${c+1}`))]})})]})}function ve({document:i,pageNumber:r,availableWidth:n,zoom:a,target:m,onReady:o,onPageElement:U,onInternalLink:d,onDoubleClickLocation:v,onRetryDocument:p}){const{t:$}=Q(),f=t.useRef(null),R=t.useRef(null),k=t.useRef(null),[N,M]=t.useState(1),[C,P]=t.useState({width:0,height:0}),[b,y]=t.useState(r===1),[z,j]=t.useState(!1),[D,A]=t.useState(null),[E,L]=t.useState([]),[F,T]=t.useState(!1);t.useEffect(()=>{const l=f.current;if(!l||b)return;if(!("IntersectionObserver"in window)){y(!0);return}const x=new IntersectionObserver(h=>{h.some(g=>g.isIntersecting)&&(y(!0),x.disconnect())},{rootMargin:"900px 0px"});return x.observe(l),()=>x.disconnect()},[b]),t.useEffect(()=>{m&&y(!0)},[m?.nonce]),t.useEffect(()=>{if(!b)return;let l=!1,x=null,h=null;return j(!1),A(null),L([]),T(!1),i.getPage(r).then(g=>{if(l)return;const O=g.getViewport({scale:1}),Z=n/O.width,I=Math.min(3.3,Math.max(.175,Z*a)),X=g.getViewport({scale:I});if(M(I),P({width:X.width,height:X.height}),A(X),g.getAnnotations({intent:"display"}).then(u=>{l||L(u)}).catch(()=>{l||L([])}),!R.current)return;const s=Math.max(1,window.devicePixelRatio||1),c=g.getViewport({scale:I*s});return R.current.width=Math.floor(c.width),R.current.height=Math.floor(c.height),x=g.render({canvas:R.current,viewport:c}),x.promise.then(()=>{l||(j(!0),h=window.requestAnimationFrame(()=>{l||o()}))})}).catch(g=>{!l&&!(g instanceof Error&&g.name==="RenderingCancelledException")&&T(!0)}),()=>{l=!0,h!==null&&window.cancelAnimationFrame(h),x?.cancel()}},[i,r,n,a,b]),t.useEffect(()=>{!m||!k.current||k.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[m?.nonce,N]);const B=l=>{if(!v||!z||l.target instanceof HTMLElement&&l.target.closest("a"))return;const x=R.current;if(!x)return;const h=x.getBoundingClientRect();if(l.clientX<h.left||l.clientX>h.right||l.clientY<h.top||l.clientY>h.bottom)return;const g=N||1,O=Math.max(0,Math.min(h.width,l.clientX-h.left))/g,Z=Math.max(0,Math.min(h.height,l.clientY-h.top))/g;v(r,O,Z)},W=Math.max(1,n*a),_=W*(792/612);return e.jsxs("figure",{ref:l=>{f.current=l,U(r,l)},onDoubleClick:B,className:`pdf-page${z?" rendered":" loading"}`,"data-page":r,"data-scale":N,style:{width:`${C.width||W}px`,minHeight:`${C.height||_}px`},children:[e.jsx("canvas",{ref:R,style:{width:`${C.width||W}px`,height:`${C.height||_}px`}}),F&&e.jsxs("div",{className:"pdf-page-error",role:"alert",children:[e.jsx("span",{children:$("editor.pdfPageLoadFailed",{page:r})}),e.jsxs("button",{type:"button",onClick:p,children:[e.jsx(J,{size:14}),$("common.retry")]})]}),z&&D&&e.jsx(be,{annotations:E,viewport:D,onInternalLink:d}),m&&e.jsx("span",{ref:k,className:"pdf-sync-marker",style:{left:m.x*N,top:m.y*N}}),e.jsx("figcaption",{children:r})]})}function be({annotations:i,viewport:r,onInternalLink:n}){const{t:a}=Q(),m=a("editor.pdfLink");return e.jsx("div",{className:"pdf-annotation-layer","aria-label":a("editor.pdfLinks"),children:i.filter(o=>o.subtype==="Link"&&Array.isArray(o.rect)&&o.rect.length>=4).map((o,U)=>{const[d,v]=r.convertToViewportPoint(o.rect[0],o.rect[1]),[p,$]=r.convertToViewportPoint(o.rect[2],o.rect[3]),f=[d,v,p,$],R=Math.min(f[0],f[2]),k=Math.min(f[1],f[3]),N=Math.abs(f[2]-f[0]),M=Math.abs(f[3]-f[1]),C=typeof o.title=="string"?o.title.trim():"",P=typeof o.unsafeUrl=="string"?o.unsafeUrl.trim():"",b=typeof o.url=="string"?o.url.trim():"",y=ne(b)?b:ne(P)?P:"",z=o.dest;if(!y&&z==null)return null;const j=!!y;return e.jsx("a",{className:"pdf-annotation-link",href:y||"#",target:j?"_blank":void 0,rel:j?"noreferrer":void 0,title:C||(j?y:m),"aria-label":C||(j?y:m),style:{left:R,top:k,width:N,height:M},onClick:j?void 0:D=>{D.preventDefault(),n(z)}},`${U}-${R}-${k}`)})})}function ne(i){return/^(?:https?|mailto|ftp):/i.test(i)}export{Ce as PdfPreview,Se as preloadPdf,Ee as preloadPdfRuntime};
@@ -1 +1 @@
1
- import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,h as M}from"./index-B6rP7QsM.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-BB4RO4x2.js";import{S as q}from"./search-UZspmceH.js";import"./hard-drive-Bsk-RETn.js";import"./x-DlFXD9Vl.js";import"./sigma-C0IvFdKV.js";import"./tags-BTUtvaAc.js";function y(o){return o.trim().toLocaleLowerCase()}function H({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{H as ProjectIconPickerDialog};
1
+ import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,h as M}from"./index-CqBmQAzW.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-DRt4rjKP.js";import{S as q}from"./search-Nu4OcY_n.js";import"./hard-drive-CkIPwUSV.js";import"./x-Cspw_pa4.js";import"./sigma-B-wjepsY.js";import"./tags-BSA08jK3.js";function y(o){return o.trim().toLocaleLowerCase()}function H({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{H as ProjectIconPickerDialog};
@@ -1 +1 @@
1
- import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-B6rP7QsM.js";import{S as $}from"./search-UZspmceH.js";import{F as J,e as K}from"./x-DlFXD9Vl.js";import{C as G}from"./check-Jf8WBxDX.js";const T=U("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(0),m=r.useRef(null),y=r.useRef(null),l=r.useMemo(()=>h.filter(s=>s.type==="file").map(s=>({entry:s,score:H(s.path,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:u,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:m,value:n,placeholder:a("navigation.filePlaceholder"),onChange:s=>{f(s.target.value),o(0)},onKeyDown:s=>{s.key==="ArrowDown"&&(s.preventDefault(),o(i=>Math.min(l.length-1,i+1))),s.key==="ArrowUp"&&(s.preventDefault(),o(i=>Math.max(0,i-1))),s.key==="Enter"&&l[d]&&(s.preventDefault(),S(l[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[l.map(({entry:s},i)=>e.jsxs("button",{ref:i===d?y:void 0,className:i===d?"active":"",onMouseEnter:()=>o(i),onClick:()=>S(s.path),children:[e.jsx(K,{size:14}),e.jsx("span",{children:s.path}),i===d&&e.jsx(G,{size:13})]},s.path)),l.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(""),[m,y]=r.useState(!1),[l,S]=r.useState(!1),[s,i]=r.useState([]),[g,C]=r.useState(0),[P,D]=r.useState(!1),[b,k]=r.useState(!1),[W,N]=r.useState(!1),[R,M]=r.useState(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.trim()){i([]),C(0),D(!1);return}const t=window.setTimeout(()=>{v.current?.abort();const x=new AbortController;v.current=x,k(!0);const E=new URLSearchParams({q:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/api/projects/${h.id}/search?${E}`,{signal:x.signal}).then(j=>{i(j.matches),C(j.total),D(j.truncated)}).catch(j=>{j instanceof DOMException&&j.name==="AbortError"||w(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:m,wholeWord:l})});M(a("navigation.replaced",{count:t.replacements,files:t.files.length})),i([]),C(0),Q(x=>x+1)}catch(t){w(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:u,footer:e.jsx("button",{onClick:()=>u(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[z&&e.jsx("p",{className:"error",children:z}),R&&e.jsx("p",{className:"success",children:R}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:t=>o(t.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:m,onChange:t=>y(t.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:l,onChange:t=>S(t.target.checked)}),a("editor.search.wholeWord")]}),h.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{size:13}),a("navigation.replaceAll",{count:g})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:g})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:s.length})})]}),e.jsxs("div",{className:"project-search-results",children:[s.map((t,x)=>e.jsxs("button",{onClick:()=>{p(t.path,t.line,t.column),u(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[t.path,e.jsxs("small",{children:[":",t.line,":",t.column]})]}),e.jsxs("code",{children:[t.preview.slice(0,t.matchStart),e.jsx("mark",{children:t.preview.slice(t.matchStart,t.matchEnd)}),t.preview.slice(t.matchEnd)]})]})]},`${t.path}-${t.line}-${t.column}-${x}`)),!b&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:g}),confirmLabel:a("navigation.replaceAll",{count:g}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{I()}})]})}function H(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
1
+ import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-CqBmQAzW.js";import{S as $}from"./search-Nu4OcY_n.js";import{F as J,e as K}from"./x-Cspw_pa4.js";import{C as G}from"./check-DKIW1zpR.js";const T=U("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(0),m=r.useRef(null),y=r.useRef(null),l=r.useMemo(()=>h.filter(s=>s.type==="file").map(s=>({entry:s,score:H(s.path,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:u,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:m,value:n,placeholder:a("navigation.filePlaceholder"),onChange:s=>{f(s.target.value),o(0)},onKeyDown:s=>{s.key==="ArrowDown"&&(s.preventDefault(),o(i=>Math.min(l.length-1,i+1))),s.key==="ArrowUp"&&(s.preventDefault(),o(i=>Math.max(0,i-1))),s.key==="Enter"&&l[d]&&(s.preventDefault(),S(l[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[l.map(({entry:s},i)=>e.jsxs("button",{ref:i===d?y:void 0,className:i===d?"active":"",onMouseEnter:()=>o(i),onClick:()=>S(s.path),children:[e.jsx(K,{size:14}),e.jsx("span",{children:s.path}),i===d&&e.jsx(G,{size:13})]},s.path)),l.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(""),[m,y]=r.useState(!1),[l,S]=r.useState(!1),[s,i]=r.useState([]),[g,C]=r.useState(0),[P,D]=r.useState(!1),[b,k]=r.useState(!1),[W,N]=r.useState(!1),[R,M]=r.useState(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.trim()){i([]),C(0),D(!1);return}const t=window.setTimeout(()=>{v.current?.abort();const x=new AbortController;v.current=x,k(!0);const E=new URLSearchParams({q:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/api/projects/${h.id}/search?${E}`,{signal:x.signal}).then(j=>{i(j.matches),C(j.total),D(j.truncated)}).catch(j=>{j instanceof DOMException&&j.name==="AbortError"||w(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:m,wholeWord:l})});M(a("navigation.replaced",{count:t.replacements,files:t.files.length})),i([]),C(0),Q(x=>x+1)}catch(t){w(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:u,footer:e.jsx("button",{onClick:()=>u(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[z&&e.jsx("p",{className:"error",children:z}),R&&e.jsx("p",{className:"success",children:R}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:t=>o(t.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:m,onChange:t=>y(t.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:l,onChange:t=>S(t.target.checked)}),a("editor.search.wholeWord")]}),h.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{size:13}),a("navigation.replaceAll",{count:g})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:g})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:s.length})})]}),e.jsxs("div",{className:"project-search-results",children:[s.map((t,x)=>e.jsxs("button",{onClick:()=>{p(t.path,t.line,t.column),u(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[t.path,e.jsxs("small",{children:[":",t.line,":",t.column]})]}),e.jsxs("code",{children:[t.preview.slice(0,t.matchStart),e.jsx("mark",{children:t.preview.slice(t.matchStart,t.matchEnd)}),t.preview.slice(t.matchEnd)]})]})]},`${t.path}-${t.line}-${t.column}-${x}`)),!b&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:g}),confirmLabel:a("navigation.replaceAll",{count:g}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{I()}})]})}function H(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
@@ -0,0 +1 @@
1
+ import{u as Se,r,j as e}from"./react-BVUjbTTn.js";import{c as u,g as M,h as O,d as B}from"./index-CqBmQAzW.js";import{E as F,G as Ne,S as q,I as oe,J as Ce,K as we,B as Fe,L as Ee}from"./ProjectWorkspace-CcbrdCy8.js";import{X as pe,i as Te,C as ze,d as Me,k as Oe}from"./x-Cspw_pa4.js";import{T as de}from"./type-BCdIbDmF.js";import{S as Le}from"./sigma-B-wjepsY.js";import{R as he}from"./refresh-cw-DyA4NKh7.js";import"./check-DKIW1zpR.js";import"./search-Nu4OcY_n.js";import"./user-plus-gFwY-NA3.js";const De=u("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Re=u("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const Ae=u("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Pe=u("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);const $e=u("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const He=u("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const We=u("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);const qe=u("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);function Be(b,i){const p=b.filter(a=>a.type==="file"&&["latexmkrc",".latexmkrc"].includes(a.path.split("/").at(-1)??"")).map(a=>a.path);i&&b.some(a=>a.type==="file"&&a.path===i)&&!p.includes(i)&&p.push(i);const o=a=>a==="latexmkrc"?0:a===".latexmkrc"?1:a.includes("/")?3:2;return p.sort((a,k)=>o(a)-o(k)||a.localeCompare(k))}function _e({name:b,state:i,label:p,reloadLabel:o,onReload:a,compact:k=!1}){const y=i.status==="loading"?e.jsx(B,{className:"spin",size:14}):i.status==="working"?e.jsx(Fe,{size:14}):e.jsx(Ae,{size:14}),S=e.jsxs(e.Fragment,{children:[y,e.jsx("strong",{children:b}),e.jsx("span",{children:p}),i.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:o,"aria-label":o,onClick:a,children:[e.jsx(he,{size:12}),o]})]});return k?e.jsxs("span",{className:`browser-tool-status compact ${i.status}`,role:"status","aria-live":"polite","aria-label":`${b}: ${p}`,title:i.error||void 0,children:[y,e.jsx("span",{children:p}),i.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:o,"aria-label":o,onClick:a,children:e.jsx(he,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${i.status}`,title:i.error||void 0,children:S})}function et({onClose:b,project:i,projectId:p,site:o,files:a,dictionaryWords:k,onDictionaryChange:y,editorPreferences:S,onEditorPreferences:xe,spellCheckCount:m,spellCheckUniqueCount:me,spellCheckIndex:f,onSpellCheckNavigate:E,onProject:_}){const{t}=Se(),[L,V]=r.useState(i.engine),[D,R]=r.useState(!!i.latexmkrc),[A,J]=r.useState(i.name),[v,K]=r.useState(i.mainFile),[P,Q]=r.useState(i.chktexEnabled),[x,U]=r.useState(!1),T=r.useRef(null),N=r.useRef(!0),X=r.useRef({name:i.name,mainFile:i.mainFile,engine:i.engine,latexmkrc:i.latexmkrc,chktexEnabled:i.chktexEnabled}),[C,G]=r.useState(null),[Z,$]=r.useState(""),[H,I]=r.useState(""),[Y,z]=r.useState(""),[d,ee]=r.useState("appearance"),[n,h]=r.useState(S),te=r.useSyncExternalStore(F.subscribe,F.getSnapshot,F.getSnapshot),j=i.permission==="owner",se=i.permission!=="read",ie=i.permission!=="read";r.useEffect(()=>h(S),[S]),r.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]),r.useEffect(()=>{Ne().catch(F.failed)},[p]);const je=()=>{Ee().catch(F.failed)},w=Be(a,i.latexmkrc),ne=i.latexmkrc&&w.includes(i.latexmkrc)?i.latexmkrc:w[0]??"",ae=a.length>0&&i.latexmkrc!==null&&!w.includes(i.latexmkrc);r.useEffect(()=>{ae&&R(!1)},[ae]),r.useEffect(()=>{if(d!=="compiler")return;const s=new AbortController;return G(null),M(`/api/projects/${p}/main-files`,{signal:s.signal}).then(c=>G(c.mainFiles)).catch(c=>{c instanceof Error&&c.name==="AbortError"||$(O(c))}),()=>s.abort()},[p,a,d]);const ge=C??[i.mainFile],ue=C!==null&&!C.includes(v),re=async()=>{if(T.current)return;const s=a.length===0&&i.latexmkrc&&o.allowProjectLatexmkrc!==!1?i.latexmkrc:D&&o.allowProjectLatexmkrc!==!1&&ne||null,c=X.current,g={};if(A!==c.name&&(g.name=A),v!==c.mainFile&&(g.mainFile=v),L!==c.engine&&(g.engine=L),s!==c.latexmkrc&&(g.latexmkrc=s),P!==c.chktexEnabled&&(g.chktexEnabled=P),Object.keys(g).length===0)return;const ye=Object.fromEntries(Object.keys(g).map(l=>[l,c[l]])),W=new AbortController;T.current=W,U(!0);try{$("");const l=await M(`/api/projects/${p}`,{method:"PATCH",signal:W.signal,body:JSON.stringify({...g,expectedSettings:ye})});if(!N.current){_(l.project);return}X.current={name:l.project.name,mainFile:l.project.mainFile,engine:l.project.engine,latexmkrc:l.project.latexmkrc,chktexEnabled:l.project.chktexEnabled},J(l.project.name),K(l.project.mainFile),V(l.project.engine),Q(l.project.chktexEnabled),R(!!l.project.latexmkrc),_(l.project)}catch(l){N.current&&$(O(l))}finally{T.current===W&&(T.current=null,N.current&&U(!1))}},ce=()=>xe(n),be=()=>{if(d==="appearance")return ce();j&&re()},ke=t(d==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),fe=d==="appearance"||j,le=async()=>{const s=H.trim();if(s)try{const c=await M(`/api/projects/${p}/dictionary`,{method:"POST",body:JSON.stringify({word:s})});y(c.words),I(""),z("")}catch(c){z(O(c))}},ve=async s=>{try{const c=await M(`/api/projects/${p}/dictionary/${encodeURIComponent(s)}`,{method:"DELETE"});y(c.words),z("")}catch(c){z(O(c))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:t("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[fe&&e.jsxs("button",{type:"button",className:"drawer-settings-save",disabled:d==="compiler"&&x,"aria-busy":d==="compiler"&&x,onClick:be,children:[d==="compiler"&&x?e.jsx(B,{className:"spin",size:14}):e.jsx(q,{size:14}),e.jsx("span",{children:ke})]}),e.jsx("button",{type:"button","aria-label":t("common.close"),onClick:b,children:e.jsx(pe,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[Z&&e.jsx("p",{className:"error",children:Z}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":t("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":d==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${d==="appearance"?" active":""}`,onClick:()=>ee("appearance"),children:[e.jsx(de,{size:15}),t("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":d==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${d==="compiler"?" active":""}`,onClick:()=>ee("compiler"),children:[e.jsx(oe,{size:15}),t("projectSettings.compilerTab")]})]}),d==="appearance"?e.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(de,{size:15}),e.jsx("strong",{children:t("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:t("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[t("projectSettings.fontFamily"),e.jsx("select",{value:n.font,onChange:s=>h({...n,font:s.target.value}),children:Ce.map(s=>e.jsx("option",{value:s.id,children:t(s.labelKey)},s.id))})]}),e.jsxs("label",{children:[t("projectSettings.fontSize"),e.jsx("select",{value:n.fontSize,onChange:s=>h({...n,fontSize:Number(s.target.value)}),children:[12,13,14,15,16,18,20].map(s=>e.jsxs("option",{value:s,children:[s," px"]},s))})]}),e.jsxs("label",{children:[t("projectSettings.lineHeight"),e.jsxs("select",{value:n.lineHeight,onChange:s=>h({...n,lineHeight:Number(s.target.value)}),children:[e.jsx("option",{value:1.45,children:t("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:t("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:t("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.lineWrapping,onChange:s=>h({...n,lineWrapping:s.target.checked})}),e.jsx(qe,{size:15}),e.jsx("span",{children:t("projectSettings.lineWrapping")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.showTooltips,onChange:s=>h({...n,showTooltips:s.target.checked})}),e.jsx($e,{size:15}),e.jsx("span",{children:t("projectSettings.showTooltips")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.showTooltipsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.mathPreviewOnHover,onChange:s=>h({...n,mathPreviewOnHover:s.target.checked})}),e.jsx(Le,{size:15}),e.jsx("span",{children:t("projectSettings.mathPreviewOnHover")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.mathPreviewOnHoverDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.spellCheck,onChange:s=>h({...n,spellCheck:s.target.checked})}),e.jsx("span",{children:t("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[t("projectSettings.writingCheckDescription")," ",e.jsx("a",{href:"https://writewithharper.com/docs/integrations/language-server",target:"_blank",rel:"noreferrer",children:"Harper"})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.vimMode,onChange:s=>h({...n,vimMode:s.target.checked})}),e.jsx("span",{children:t("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[t("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:t("projectSettings.vimHelp")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.openFilesInTabs,onChange:s=>h({...n,openFilesInTabs:s.target.checked})}),e.jsx(He,{size:15}),e.jsx("span",{children:t("projectSettings.openFilesInTabs")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.openFilesInTabsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!se,checked:n.formatOnCompile,onChange:s=>h({...n,formatOnCompile:s.target.checked})}),e.jsx(we,{size:15}),e.jsx("span",{children:t("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[t(se?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",t("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:t("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:t("projectSettings.bibtexTidyInstall")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"tex-fmt-options-field",children:[e.jsxs("span",{className:"tex-fmt-options-heading",children:[e.jsx("span",{children:t("projectSettings.texFmtOptions")}),e.jsx(_e,{compact:!0,name:"tex-fmt",state:te,label:t(`projectSettings.toolStatus.${te.status}`),reloadLabel:t("projectSettings.reloadTool"),onReload:je})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:n.texFmtConfig,placeholder:t("projectSettings.texFmtOptionsPlaceholder"),onChange:s=>h({...n,texFmtConfig:s.target.value})})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.texFmtOptionsDescription")})]}),m!==null&&e.jsxs("div",{className:`spell-check-result${m?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(We,{size:14}),e.jsx("span",{children:m?t("projectSettings.writingIssues",{count:m,uniqueCount:me??0}):t("chktex.noIssues")}),m>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:t("projectSettings.spellCheckFirst"),"aria-label":t("projectSettings.spellCheckFirst"),disabled:f<=0,onClick:()=>E(0),children:e.jsx(De,{size:14})}),e.jsx("button",{type:"button",title:t("projectSettings.spellCheckPrevious"),"aria-label":t("projectSettings.spellCheckPrevious"),disabled:f<=0,onClick:()=>E(f-1),children:e.jsx(Te,{size:14})}),e.jsx("span",{className:"spell-check-position",children:t("projectSettings.spellCheckPosition",{current:Math.min(f+1,m),total:m})}),e.jsx("button",{type:"button",title:t("projectSettings.spellCheckNext"),"aria-label":t("projectSettings.spellCheckNext"),disabled:f>=m-1,onClick:()=>E(f+1),children:e.jsx(ze,{size:14})}),e.jsx("button",{type:"button",title:t("projectSettings.spellCheckLast"),"aria-label":t("projectSettings.spellCheckLast"),disabled:f>=m-1,onClick:()=>E(m-1),children:e.jsx(Re,{size:14})})]})]}),e.jsxs("div",{className:"settings-section-title",children:[e.jsx(Me,{size:15}),e.jsx("strong",{children:t("projectSettings.dictionary")})]}),e.jsx("p",{className:"settings-description",children:t("projectSettings.dictionaryDescription")}),Y&&e.jsx("p",{className:"error dictionary-error",children:Y}),ie&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:H,placeholder:t("projectSettings.dictionaryPlaceholder"),onChange:s=>I(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),le())}}),e.jsx("button",{type:"button",disabled:!H.trim(),onClick:()=>{le()},children:t("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[k.map(s=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:s}),ie&&e.jsx("button",{type:"button",title:t("common.delete"),"aria-label":`${t("common.delete")} ${s}`,onClick:()=>{ve(s)},children:e.jsx(pe,{size:13})})]},s)),k.length===0&&e.jsx("span",{className:"dictionary-empty",children:t("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:ce,children:[e.jsx(q,{size:15}),t("projectSettings.saveAppearance")]})})]}):e.jsxs("section",{id:"settings-panel-compiler",role:"tabpanel","aria-labelledby":"settings-tab-compiler",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(oe,{size:15}),e.jsx("strong",{children:t("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:t("projectSettings.compilerDescription")}),e.jsxs("label",{children:[t("projects.name"),e.jsx("input",{disabled:!j||x,value:A,onChange:s=>J(s.target.value)})]}),e.jsxs("label",{children:[t("projectSettings.mainFile"),e.jsxs("select",{disabled:!j||x||C===null||C.length===0,value:v,onChange:s=>K(s.target.value),children:[ue&&e.jsx("option",{value:v,disabled:!0,children:t("projectSettings.invalidMainFileOption",{path:v})}),ge.map(s=>e.jsx("option",{value:s,children:s},s))]})]}),e.jsxs("label",{children:[t(D&&w.length>0&&o.allowProjectLatexmkrc!==!1?"projectSettings.defaultEngine":"projectSettings.engine"),e.jsx("select",{disabled:!j||x,value:L,onChange:s=>V(s.target.value),children:(o.allowedEngines??["pdflatex","xelatex","lualatex"]).map(s=>e.jsx("option",{children:s},s))})]}),e.jsxs("div",{className:"editor-preference compiler-check-option",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!j||x,checked:P,onChange:s=>Q(s.target.checked)}),e.jsx(Pe,{size:15}),e.jsx("span",{children:t("chktex.enabled")})]}),e.jsxs("p",{className:"field-hint",children:[t("chktex.description")," ",e.jsx("a",{href:"https://www.nongnu.org/chktex/",target:"_blank",rel:"noreferrer",children:"ChkTeX"})]})]}),w.length>0&&e.jsxs("div",{className:"editor-preference latexmkrc-setting",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!j||x||o.allowProjectLatexmkrc===!1,checked:D&&o.allowProjectLatexmkrc!==!1,onChange:s=>R(s.target.checked)}),e.jsx("span",{children:t("projectSettings.enableLatexmkrc")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.latexmkrcSource",{path:ne})}),o.allowProjectLatexmkrc===!1?e.jsx("p",{className:"field-hint",children:t("projectSettings.latexmkrcUnavailable")}):e.jsxs("p",{className:"field-hint latexmkrc-warning",children:[e.jsx(Oe,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:t("projectSettings.latexmkrcWarning")})]})]}),e.jsx("div",{className:"settings-actions",children:j&&e.jsxs("button",{className:"settings-save",disabled:x,"aria-busy":x,onClick:()=>{re()},children:[x?e.jsx(B,{className:"spin",size:15}):e.jsx(q,{size:15}),t("projectSettings.saveCompiler")]})})]})]})]})}export{et as ProjectSettings};