texlite 0.8.4 → 0.9.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 (65) hide show
  1. package/DESIGN.md +75 -8
  2. package/OPERATIONS.md +19 -2
  3. package/dist/client/assets/{AdminUsers-CqOmV9rq.js → AdminUsers-3CHb5012.js} +1 -1
  4. package/dist/client/assets/{CitationLibraryDialog-BmWFXTW2.js → CitationLibraryDialog-zPpsUhWJ.js} +1 -1
  5. package/dist/client/assets/Dashboard-CWfSLzD3.js +2 -0
  6. package/dist/client/assets/{GitDialog-BCfSHuMB.js → GitDialog-BUU2U_LV.js} +2 -2
  7. package/dist/client/assets/HistoryDialog-B6aopsrw.js +7 -0
  8. package/dist/client/assets/{LatexEditor-DSopAHbC.js → LatexEditor-CM445Tk0.js} +1 -1
  9. package/dist/client/assets/{PdfPreview-BDkU20jP.js → PdfPreview-BFVNczSk.js} +1 -1
  10. package/dist/client/assets/{ProjectIconPickerDialog-GAd8HGOx.js → ProjectIconPickerDialog-Cf0zBf8u.js} +1 -1
  11. package/dist/client/assets/{ProjectNavigationDialogs-BTLcRY7i.js → ProjectNavigationDialogs-TPbe11iR.js} +1 -1
  12. package/dist/client/assets/{ProjectSettings-BJWTkoZq.js → ProjectSettings-CDQvIlQ4.js} +1 -1
  13. package/dist/client/assets/ProjectWorkspace-C6GrvKN6.js +27 -0
  14. package/dist/client/assets/SelectionHistoryDialog-CyE0_YDs.js +3 -0
  15. package/dist/client/assets/{SystemMetricsDialog-C9P4TSQl.js → SystemMetricsDialog-CuqHPUnn.js} +1 -1
  16. package/dist/client/assets/{TagManagementDialog-LYbib36_.js → TagManagementDialog-gRLM3lLx.js} +1 -1
  17. package/dist/client/assets/{WordCountDialog-BFg0GeJy.js → WordCountDialog-B4PI0vEk.js} +1 -1
  18. package/dist/client/assets/check-BXvzrdoz.js +1 -0
  19. package/dist/client/assets/chevron-left-BB5MYb7g.js +1 -0
  20. package/dist/client/assets/hard-drive-6uYFyezl.js +1 -0
  21. package/dist/client/assets/index-BRT5O-Hg.js +5 -0
  22. package/dist/client/assets/index-C0t11tlT.js +14 -0
  23. package/dist/client/assets/index-DXWp2bzM.css +1 -0
  24. package/dist/client/assets/{key-round-BaIj7Jch.js → key-round-DOAxDSfz.js} +1 -1
  25. package/dist/client/assets/minimize-2-BWtbag2I.js +1 -0
  26. package/dist/client/assets/{minus-Beso_n-6.js → minus-9eVJnugf.js} +1 -1
  27. package/dist/client/assets/{plus-BfEC7mzf.js → plus-BGXipRoG.js} +1 -1
  28. package/dist/client/assets/{refresh-cw-FZs9MtoA.js → refresh-cw-Dvp3O90f.js} +1 -1
  29. package/dist/client/assets/{search-DL2UGvdj.js → search-b1ORp1k8.js} +1 -1
  30. package/dist/client/assets/{sigma-CSRwPPkk.js → sigma-Bk0_MzWi.js} +1 -1
  31. package/dist/client/assets/{spellCheck-L9gD2d1M.js → spellCheck-BJjWgnef.js} +1 -1
  32. package/dist/client/assets/{tags-CjkWzXqX.js → tags-JAkbmWns.js} +1 -1
  33. package/dist/client/assets/{type-D1mmDdLM.js → type-CE2DYkPH.js} +1 -1
  34. package/dist/client/assets/{user-plus-YJ3ftuL5.js → user-plus-CKalKSsw.js} +1 -1
  35. package/dist/client/assets/x-Bq29njHL.js +1 -0
  36. package/dist/client/index.html +2 -2
  37. package/dist/server/app.js +45 -4
  38. package/dist/server/cli.js +4 -0
  39. package/dist/server/collaboration.js +219 -7
  40. package/dist/server/commentMentions.js +139 -0
  41. package/dist/server/config.js +9 -2
  42. package/dist/server/db.js +59 -0
  43. package/dist/server/editHistory.js +411 -0
  44. package/dist/server/editHistoryRetry.js +90 -0
  45. package/dist/server/history.js +136 -20
  46. package/dist/server/historyRetention.js +37 -0
  47. package/dist/server/i18n.js +4 -0
  48. package/dist/server/index.js +6 -0
  49. package/dist/server/logRotation.js +82 -0
  50. package/dist/server/pm2.js +7 -0
  51. package/dist/server/routes/comments.js +107 -16
  52. package/dist/server/routes/projectHistory.js +93 -7
  53. package/dist/server/routes/projectShared.js +2 -1
  54. package/dist/server/routes/projects.js +3 -1
  55. package/package.json +1 -1
  56. package/texlite.config.example.json +4 -1
  57. package/dist/client/assets/Dashboard-BfN2bCgZ.js +0 -2
  58. package/dist/client/assets/HistoryDialog-BtQhyTr9.js +0 -5
  59. package/dist/client/assets/ProjectWorkspace-WLYA7BSv.js +0 -27
  60. package/dist/client/assets/check-bnimQPun.js +0 -1
  61. package/dist/client/assets/chevron-left-DNM7mhNi.js +0 -1
  62. package/dist/client/assets/hard-drive-CF3WDfkG.js +0 -1
  63. package/dist/client/assets/index-CzVDvC5h.js +0 -14
  64. package/dist/client/assets/index-RjUuWk8F.css +0 -1
  65. package/dist/client/assets/x-BDSEosRE.js +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,b as p,f as l}from"./index-CzVDvC5h.js";import{G as q,C as ie,T as ke}from"./x-BDSEosRE.js";import{K as be}from"./key-round-BaIj7Jch.js";import{C as ne,R as ve}from"./ProjectWorkspace-WLYA7BSv.js";import{M as Ce,a as Ne}from"./minus-Beso_n-6.js";import{P as we}from"./plus-BfEC7mzf.js";import"./check-bnimQPun.js";import"./search-DL2UGvdj.js";import"./user-plus-YJ3ftuL5.js";import"./refresh-cw-FZs9MtoA.js";const ze=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 Se=u("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);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 qe({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(ze,{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(Se,{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 be,r as n,j as e}from"./react-BVUjbTTn.js";import{c as p,M as H,b as x,f as l}from"./index-C0t11tlT.js";import{G as q,C as ie,T as ke}from"./x-Bq29njHL.js";import{K as ye}from"./key-round-DOAxDSfz.js";import{C as ne,R as ve}from"./ProjectWorkspace-C6GrvKN6.js";import{G as ae,M as Ce}from"./minimize-2-BWtbag2I.js";import{M as Ne,a as we}from"./minus-9eVJnugf.js";import{P as ze}from"./plus-BGXipRoG.js";import"./check-BXvzrdoz.js";import"./search-b1ORp1k8.js";import"./user-plus-CKalKSsw.js";import"./refresh-cw-Dvp3O90f.js";const Se=p("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 oe=p("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=p("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 W=p("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=p("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=p("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:b,onBeforeMutation:r}){const{t:s,i18n:E}=be(),[i,u]=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(""),[y,M]=n.useState(null),[m,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,f]=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(u(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(()=>{}),f(!1),k("");return}N(""),B(""),M(null),f(!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=()=>f(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&&f(!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})});u(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"});u(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:_})});u(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})});u(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"});u(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(()=>{}),f(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}f(!0)},xe=()=>{const t=m;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:b,footer:e.jsx("button",{onClick:()=>b(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(x,{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(ye,{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(oe,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(x,{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(oe,{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(x,{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(ae,{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(x,{className:"spin",size:14}):e.jsx(ae,{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(x,{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(x,{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")]})]})]}),y&&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:[y.title,y.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(Ne,{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(ze,{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(Ce,{size:15}):e.jsx(we,{size:15})})]})]}),e.jsx(Fe,{content:y.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:!!m,title:s(m==="branch"?"git.returnTitle":"git.checkoutTitle"),description:m==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:m?.shortSha??"",message:m?.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:b}){return h.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${b}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
- `]},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{qe as GitDialog};
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};
@@ -0,0 +1,7 @@
1
+ import{u as Se,r as o,j as e}from"./react-BVUjbTTn.js";import{c as Te,f as A,M as Le,b as ee,C as fe}from"./index-C0t11tlT.js";import{d as Fe,C as me}from"./index-BRT5O-Hg.js";import{H as ze,F as De}from"./hard-drive-6uYFyezl.js";import{T as ge,d as Ee}from"./x-Bq29njHL.js";import{F as re,R as pe,S as ke,i as Me}from"./ProjectWorkspace-C6GrvKN6.js";import{G as Pe,M as Ae}from"./minimize-2-BWtbag2I.js";import{M as Be,a as Re}from"./minus-9eVJnugf.js";import{P as Ve}from"./plus-BGXipRoG.js";import"./check-BXvzrdoz.js";import"./search-b1ORp1k8.js";import"./user-plus-CKalKSsw.js";import"./refresh-cw-Dvp3O90f.js";const _e=Te("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 xe(n,l,j,p="历史版本",s="当前版本",m=3){const L=l.replace(/\r\n/g,`
2
+ `),M=j.replace(/\r\n/g,`
3
+ `);if(L===M)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const c=new Fe,z=c.diff_linesToChars_(L,M),S=c.diff_main(z.chars1,z.chars2,!1);c.diff_charsToLines_(S,z.lineArray);const N=[];let r=1,D=1,g=0,P=0;for(const[h,y]of S){if(!y)continue;const d=y.split(`
4
+ `);d[d.length-1]===""&&d.pop();for(const C of d)h===0?N.push({op:0,text:C,oldNum:r++,newNum:D++}):h===-1?(P++,N.push({op:-1,text:C,oldNum:r++,newNum:D})):h===1&&(g++,N.push({op:1,text:C,oldNum:r,newNum:D++}))}if(g===0&&P===0)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const x=[];let b=-1,u=-1;for(let h=0;h<N.length;h++)if(N[h].op!==0){const y=Math.max(0,h-m),d=Math.min(N.length-1,h+m);b===-1?(b=y,u=d):y<=u+1?u=Math.max(u,d):(x.push({start:b,end:u}),b=y,u=d)}b!==-1&&x.push({start:b,end:u});const V=[`--- a/${n} (${p})`,`+++ b/${n} (${s})`];for(const h of x){const y=N.slice(h.start,h.end+1),d=y.filter($=>$.op<=0).length,C=y.filter($=>$.op>=0).length,_=y[0],J=d===0?0:_.oldNum,B=C===0?0:_.newNum;V.push(`@@ -${J},${d} +${B},${C} @@`);for(const $ of y){const T=$.op===-1?"-":$.op===1?"+":" ";V.push(`${T}${$.text}`)}}return{diffText:V.join(`
5
+ `),additions:g,deletions:P,hasChanges:!0}}function oe(n,l){try{const j=new Date(n);if(Number.isNaN(j.getTime()))return n;const p=new Date;return j.getFullYear()===p.getFullYear()&&j.getMonth()===p.getMonth()&&j.getDate()===p.getDate()?j.toLocaleTimeString(l,{hour:"2-digit",minute:"2-digit"}):j.toLocaleString(l,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return n}}function ae(n,l,j){if(n.label)return n.label;const p=oe(n.createdAt,j);if(n.changedPaths.length===1)return`${n.changedPaths[0].split("/").pop()||n.changedPaths[0]} (${p})`;if(n.changedPaths.length===2){const m=n.changedPaths[0].split("/").pop()||n.changedPaths[0],L=n.changedPaths[1].split("/").pop()||n.changedPaths[1];return`${m}, ${L} (${p})`}if(n.changedPaths.length>2)return`${n.changedPaths[0].split("/").pop()||n.changedPaths[0]} +${n.changedPaths.length-1} (${p})`;const s=n.author?.name||n.author?.username;return s?`${s} @ ${p}`:`${l} (${p})`}const ye=100;function et({open:n,project:l,onOpenChange:j,onBeforeMutation:p}){const{t:s,i18n:m}=Se(),[L,M]=o.useState([]),[c,z]=o.useState(null),[S,N]=o.useState(""),[r,D]=o.useState(null),[g,P]=o.useState(""),[x,b]=o.useState(null),[u,V]=o.useState("commit"),[h,y]=o.useState(11),[d,C]=o.useState(!1),[_,J]=o.useState(""),[B,$]=o.useState(null),[T,K]=o.useState(null),[U,w]=o.useState(""),[le,Z]=o.useState(null),[W,Q]=o.useState(!1),[ce,v]=o.useState(""),se=o.useRef(null),F=o.useRef(null),E=o.useRef(null),ie=l.permission!=="read",de=l.permission==="owner",H=!!U||W;o.useEffect(()=>{if(!n){E.current!==null&&window.clearTimeout(E.current),E.current=null,F.current?.abort(),F.current=null,Q(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),C(!1);return}F.current?.abort(),F.current=null;const t=new AbortController;return w("load"),v(""),b(null),Z(null),Q(!1),A(`/api/projects/${l.id}/history?limit=${ye}`,{signal:t.signal}).then(i=>{M(i.versions),z(i.stats),Z(i.nextCursor),N(a=>i.versions.some(f=>f.id===a)?a:i.versions[0]?.id??"")}).catch(i=>{te(i)||v(R(i))}).finally(()=>{t.signal.aborted||w("")}),()=>t.abort()},[n,l.id]),o.useEffect(()=>()=>{F.current?.abort(),F.current=null,E.current!==null&&window.clearTimeout(E.current)},[l.id]);const je=async()=>{const t=le;if(!t||W||U)return;F.current?.abort();const i=new AbortController;F.current=i,Q(!0),v("");try{const a=new URLSearchParams({limit:String(ye),before:t}),f=await A(`/api/projects/${l.id}/history?${a.toString()}`,{signal:i.signal});if(i.signal.aborted)return;M(O=>{const we=new Set(O.map(ne=>ne.id));return[...O,...f.versions.filter(ne=>!we.has(ne.id))]}),z(f.stats),Z(f.nextCursor)}catch(a){te(a)||v(R(a))}finally{F.current===i&&(F.current=null,Q(!1))}};o.useEffect(()=>{const t=()=>C(document.fullscreenElement===se.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),o.useEffect(()=>{if(!d)return;const t=i=>{i.key==="Escape"&&!document.fullscreenElement&&C(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[d]),o.useEffect(()=>{if(!n||!S){D(null);return}const t=new AbortController;return w("detail"),b(null),A(`/api/projects/${l.id}/history/${S}`,{signal:t.signal}).then(i=>{D(i),J(i.version.label??"");const a=i.version.changedPaths.find(f=>i.files.some(O=>O.path===f))??"";P(a)}).catch(i=>{te(i)||v(R(i))}).finally(()=>{t.signal.aborted||w("")}),()=>t.abort()},[n,l.id,S]);const I=x?.previousVersion??null;o.useEffect(()=>{if(!n||!S||!g){b(null);return}const t=new AbortController;w("compare"),v("");const i=u==="commit"?"&against=__previous__":"";return A(`/api/projects/${l.id}/history/${S}/file?path=${encodeURIComponent(g)}${i}`,{signal:t.signal}).then(a=>{b(a)}).catch(a=>{te(a)||v(R(a))}).finally(()=>{t.signal.aborted||w(a=>a==="compare"?"":a)}),()=>t.abort()},[n,l.id,S,g,u]);const k=o.useMemo(()=>{if(!r)return[];const t=new Set(r.version.changedPaths);return r.files.filter(i=>t.has(i.path))},[r]);o.useEffect(()=>{k.length>0&&!k.some(t=>t.path===g)?P(k[0].path):k.length===0&&g&&P("")},[k,g]);const be=async()=>{if(d){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),C(!1);return}const t=se.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}C(!0)},ve=async()=>{if(r){w("label"),v("");try{const t=await A(`/api/projects/${l.id}/history/${r.version.id}`,{method:"PATCH",body:JSON.stringify({label:_.trim()||null})});D(i=>i&&{...i,version:t.version}),M(i=>i.map(a=>a.id===t.version.id?t.version:a)),z(t.stats),t.retentionScheduled&&(E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{E.current=null,A(`/api/projects/${l.id}/history?limit=1`).then(i=>{z(i.stats)}).catch(()=>{})},t.retentionRefreshAfterMs))}catch(t){v(R(t))}finally{w("")}}},Ne=async()=>{const t=T;if(t){K(null),w("delete"),v("");try{if(!await p())throw new Error(s("errors.collaborationUnavailable"));const i=t==="all"?`/api/projects/${l.id}/history`:`/api/projects/${l.id}/history/${t.id}`,a=await A(i,{method:"DELETE"});if(z(a.stats),t==="all")M([]),N(""),D(null),b(null),Z(null);else{const f=L.filter(O=>O.id!==t.id);M(f),S===t.id&&(N(f[0]?.id??""),D(null),b(null))}}catch(i){v(R(i))}finally{w("")}}},Ce=async()=>{const t=B;if(!(!t||!r)){$(null),w("restore"),v("");try{if(!await p())throw new Error(s("errors.collaborationUnavailable"));await A(`/api/projects/${l.id}/history/${r.version.id}/restore`,{method:"POST",body:JSON.stringify(t==="project"?{}:{path:t})}),window.location.reload()}catch(i){v(R(i)),w("")}}},X=r?.version.author?.name||r?.version.author?.username||(r?.version.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser")),q=r?oe(r.version.createdAt,m.resolvedLanguage):"",G=o.useMemo(()=>{if(!x||!r)return{diffText:"",additions:0,deletions:0,hasChanges:!1};if(u==="commit"){const t=x.comparison,i=x.historical,a=I?`${I.label||s(`history.reasons.${I.reason}`)} (${oe(I.createdAt,m.resolvedLanguage)})`:"/dev/null",f=`${X} @ ${q}`;return xe(x.path,t,i,a,f)}else{const t=x.historical,i=x.comparison,a=`${r.version.label||s(`history.reasons.${r.version.reason}`)} (${q})`,f=s("history.currentVersion");return xe(x.path,t,i,a,f)}},[x,r,u,I,X,q,s,m.resolvedLanguage]),he=r?s(`history.reasons.${r.version.reason}`):"",ue=r?ae(r.version,he,m.resolvedLanguage):"",$e=T&&T!=="all"?ae(T,s(`history.reasons.${T.reason}`),m.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(Le,{open:n,extraWide:!0,draggable:!0,className:"history-dialog-modal",title:s("history.projectSnapshots"),description:s("history.description"),onOpenChange:j,footer:e.jsx("button",{onClick:()=>j(!1),children:s("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[ce&&e.jsx("p",{className:"error history-message",children:ce}),U==="load"&&L.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(ee,{className:"spin",size:22}),s("common.loading")]}):e.jsxs("div",{className:"history-dialog-layout",children:[e.jsxs("aside",{className:"history-timeline",children:[de&&c&&e.jsxs("div",{className:`history-stats${c.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(ze,{size:14}),s("history.storage")]}),e.jsx("button",{type:"button",disabled:H||L.length===0,title:s("history.clearAll"),"aria-label":s("history.clearAll"),onClick:()=>K("all"),children:e.jsx(ge,{size:13})})]}),e.jsx("strong",{children:s("history.storageUsage",{used:Y(c.totalBytes),limit:Y(c.maxStorageBytes)})}),e.jsx("progress",{max:c.maxStorageBytes,value:Math.min(c.totalBytes,c.maxStorageBytes)}),e.jsx("small",{children:s("history.storageBreakdown",{objects:Y(c.objectBytes),metadata:Y(c.metadataBytes),protected:Y(c.protectedBytes)})}),e.jsxs("small",{children:[s("history.versionUsage",{count:c.ordinaryVersionCount,limit:c.maxVersions>0?c.maxVersions:"∞"}),c.labeledVersionCount>0?` · ${s("history.protectedVersions",{count:c.labeledVersionCount})}`:""]}),c.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:s("history.storageExceeded")})]}),L.map(t=>{const i=s(`history.reasons.${t.reason}`),a=ae(t,i,m.resolvedLanguage),f=t.author?.name||t.author?.username||(t.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser"));return e.jsxs("button",{className:t.id===S?"active":"",onClick:()=>N(t.id),children:[e.jsx(re,{size:15}),e.jsxs("span",{children:[e.jsxs("div",{className:"history-item-heading",children:[e.jsx("strong",{title:a,children:a}),e.jsx("span",{className:`history-reason-badge reason-${t.reason}`,children:i})]}),e.jsx("small",{children:new Date(t.createdAt).toLocaleString(m.resolvedLanguage)}),e.jsxs("small",{children:[f," · ",s("history.changedCount",{count:t.changedPaths.length})]})]})]},t.id)}),le&&e.jsx("div",{className:"history-load-more",children:e.jsxs("button",{type:"button",disabled:H,"aria-busy":W,onClick:()=>{je()},children:[W?e.jsx(ee,{className:"spin",size:13}):e.jsx(me,{size:13}),s(W?"common.loading":"history.loadOlder")]})}),L.length===0&&e.jsx("p",{className:"muted padded",children:s("history.empty")})]}),e.jsx("section",{className:"history-detail",children:r&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"history-detail-header",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"history-detail-title-row",children:[e.jsx("strong",{title:ue,children:ue}),e.jsx("span",{className:`history-reason-badge reason-${r.version.reason}`,children:he})]}),e.jsxs("small",{children:[e.jsx(me,{size:12}),new Date(r.version.createdAt).toLocaleString(m.resolvedLanguage)," · ",X," · ",s("history.fileCount",{count:r.version.fileCount})]})]}),e.jsxs("span",{className:"history-detail-actions",children:[de&&e.jsxs("button",{className:"danger-text",disabled:H,onClick:()=>K(r.version),children:[e.jsx(ge,{size:14}),s("history.deleteVersion")]}),ie&&e.jsxs("button",{className:"danger-text",disabled:H,onClick:()=>$("project"),children:[e.jsx(pe,{size:14}),s("history.restoreProject")]})]})]}),ie&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(_e,{size:14}),e.jsx("input",{value:_,maxLength:80,placeholder:s("history.labelPlaceholder"),onChange:t=>J(t.target.value)})]}),e.jsxs("button",{disabled:H||_.trim()===(r.version.label??""),onClick:()=>{ve()},children:[U==="label"?e.jsx(ee,{className:"spin",size:13}):e.jsx(ke,{size:13}),s("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsxs("div",{className:"history-files-toolbar",children:[e.jsxs("div",{className:"history-files-heading",children:[e.jsx(De,{size:13}),e.jsx("span",{children:s("history.changedFilesHeading",{count:k.length})})]}),e.jsx("div",{className:"history-file-actions",children:ie&&e.jsxs("button",{disabled:!g||H,onClick:()=>$(g),children:[e.jsx(pe,{size:13}),s("history.restoreFile")]})})]}),k.length>0?e.jsx("div",{className:"history-file-list",children:k.map(t=>e.jsxs("button",{type:"button",className:t.path===g?"active":"",title:t.path,onClick:()=>P(t.path),children:[e.jsx(Ee,{size:13}),e.jsx("span",{children:t.path})]},t.path))}):e.jsx("p",{className:"muted padded-small",children:s("history.noChangedFiles")})]}),e.jsx("div",{ref:se,className:`history-comparison${d?" is-fullscreen":""}`,children:g?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsxs("div",{className:"history-comparison-meta",children:[e.jsx("strong",{children:g}),e.jsxs("small",{className:"history-commit-summary",children:[u==="commit"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"history-commit-author",children:X}),e.jsx("span",{children:I?s("history.changedAt",{time:q}):s("history.createdAt",{time:q})})]}):e.jsx("span",{children:s("history.comparingCurrent")}),G.hasChanges&&e.jsxs("span",{className:"history-diff-stats",children:[e.jsxs("span",{className:"addition",children:["+",G.additions]})," ",e.jsxs("span",{className:"deletion",children:["-",G.deletions]})]})]})]}),e.jsxs("div",{className:"history-diff-controls",children:[e.jsxs("div",{className:"history-mode-toggle",role:"group","aria-label":s("history.diffMode"),children:[e.jsxs("button",{type:"button",className:u==="commit"?"active":"",onClick:()=>V("commit"),title:s("history.diffModeCommitHint"),children:[e.jsx(Pe,{size:13}),e.jsx("span",{children:s("history.diffModeCommit")})]}),e.jsxs("button",{type:"button",className:u==="current"?"active":"",onClick:()=>V("current"),title:s("history.diffModeCurrentHint"),children:[e.jsx(re,{size:13}),e.jsx("span",{children:s("history.diffModeCurrent")})]})]}),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:h<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>y(t=>Math.max(8,t-1)),children:e.jsx(Be,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[h,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:h>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>y(t=>Math.min(24,t+1)),children:e.jsx(Ve,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(d?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(d?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{be()},children:d?e.jsx(Ae,{size:15}):e.jsx(Re,{size:15})})]})]}),U==="compare"&&!x?e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(ee,{className:"spin",size:24}),e.jsx("span",{children:s("common.loading")})]}):G.hasChanges?e.jsx("pre",{className:"git-diff history-git-diff",style:{fontSize:`${h}px`},children:G.diffText.split(`
6
+ `).map((t,i)=>{const a=t.startsWith("+")&&!t.startsWith("+++")?"addition":t.startsWith("-")&&!t.startsWith("---")?"deletion":t.startsWith("@@")?"hunk":t.startsWith("diff ")||t.startsWith("---")||t.startsWith("+++")?"header":"";return e.jsxs("span",{className:a,children:[t,`
7
+ `]},i)})}):e.jsxs("div",{className:"git-diff-empty history-diff-empty",children:[e.jsx(Me,{size:24}),e.jsx("span",{children:s(u==="commit"?"history.noDifferencesInCommit":"history.noDifferences")})]})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(re,{size:25}),e.jsx("span",{children:k.length===0?s("history.noChangedFiles"):s("history.chooseFile")})]})})]})})]})]})}),e.jsx(fe,{open:!!B,title:s(B==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:B==="project"?s("history.restoreProjectDescription"):s("history.restoreFileDescription",{path:B??""}),confirmLabel:s("history.restore"),danger:!0,onCancel:()=>$(null),onConfirm:()=>{Ce()}}),e.jsx(fe,{open:!!T,title:s(T==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:T==="all"?s("history.clearAllDescription"):s("history.deleteVersionDescription",{name:$e}),confirmLabel:s(T==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>K(null),onConfirm:()=>{Ne()}})]})}function Y(n){return n<1024?`${n} B`:n<1024*1024?`${Math.round(n/102.4)/10} KB`:n<1024*1024*1024?`${Math.round(n/(1024*1024)*10)/10} MB`:`${Math.round(n/(1024*1024*1024)*10)/10} GB`}function R(n){return n instanceof Error?n.message:String(n)}function te(n){return n instanceof Error&&n.name==="AbortError"}export{et as HistoryDialog};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/katex-CEK31ho9.css"])))=>i.map(i=>d[i]);
2
- import{u as ki,r as Y,j as $e}from"./react-BVUjbTTn.js";import{s as rr,E as se,V as dt,D as te,a as Ht,R as wi,P as ir,S as xt,b as Me,f as xi,M as or,m as Bn,i as Si,c as bi,d as Mi,e as Li,g as Ai,h as Ei,j as Dn,k as ar,l as St,n as Oi,o as Ri,p as Ti,q as Ii,r as Ni,t as Pi,u as Bi,v as Di,w as _i,x as Ki,y as it,F as Yt,A as Xt,z as $i,W as sr,B as lr,C as _n,G as Fi,H as _t,I as Kt,J as Hi,K as Vi,L as ji,N as Wi,O as Ui,Q as zi,T as Qi,U as qi,X as Ji,Y as Zi,Z as Yi,_ as Xi,$ as Gi,a0 as eo,a1 as to,a2 as no,a3 as ro,a4 as io,a5 as oo,a6 as Gt,a7 as ao,a8 as so,a9 as lo,aa as co,ab as be,ac as uo,ad as fo}from"./editor-CiK7TK0p.js";import{r as Kn,c as ht,U as cr,a as Vt,b as jt,d as $n,m as ho,e as po,f as $t,t as Ct,g as kt,h as go}from"./ProjectWorkspace-WLYA7BSv.js";import{_ as Fn}from"./index-CzVDvC5h.js";import"./check-bnimQPun.js";import"./x-BDSEosRE.js";import"./search-DL2UGvdj.js";import"./user-plus-YJ3ftuL5.js";import"./refresh-cw-FZs9MtoA.js";function vo(a){var i=a.Pos;function l(e,t,n){if(t.line===n.line&&t.ch>=n.ch-1){var r=e.getLine(t.line),o=r.charCodeAt(t.ch);55296<=o&&o<=55551&&(n.ch+=1)}return{start:t,end:n}}var c=[{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"}],f=Object.create(null),v=c.length,C=[{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"}],x=nn("");function S(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),a.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",On),Ee(e),a.on(e.getInputField(),"paste",R(e))}function T(e){e.setOption("disableInput",!1),e.off("cursorActivity",On),a.off(e.getInputField(),"paste",R(e)),e.state.vim=null,ut&&clearTimeout(ut)}function R(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(ie(e.getCursor(),0,1)),Ze.enterInsertMode(e,{},t))}),t.onPasteFn}var L=/[\d]/,A=[a.isWordChar,function(e){return e&&!a.isWordChar(e)&&!/\s/.test(e)}],D=[function(e){return/\S/.test(e)}],_=["<",">"],j=["-",'"',".",":","_","/","+"],z=/^\w$/,q=/^[A-Z]$/;try{q=new RegExp("^[\\p{Lu}]$","u")}catch{}function W(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function ae(e){return/^[a-z]$/.test(e)}function le(e){return"()[]{}".indexOf(e)!=-1}function J(e){return L.test(e)}function ye(e){return q.test(e)}function re(e){return/^\s*$/.test(e)}function He(e){return".?!".indexOf(e)!=-1}function et(e,t){for(var n=0;n<t.length;n++)if(t[n]==e)return!0;return!1}var Ae={};function Ve(e,t,n,r,o){if(t===void 0&&!o)throw Error("defaultValue is required unless callback is provided");if(n||(n="string"),Ae[e]={type:n,defaultValue:t,callback:o},r)for(var s=0;s<r.length;s++)Ae[r[s]]=Ae[e];t&&Qe(e,t)}function Qe(e,t,n,r){var o=Ae[e];r=r||{};var s=r.scope;if(!o)return new Error("Unknown option: "+e);if(o.type=="boolean"){if(t&&t!==!0)return new Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}o.callback?(s!=="local"&&o.callback(t,void 0),s!=="global"&&n&&o.callback(t,n)):(s!=="local"&&(o.value=o.type=="boolean"?!!t:t),s!=="global"&&n&&(n.state.vim.options[e]={value:t}))}function de(e,t,n){var r=Ae[e];n=n||{};var o=n.scope;if(!r)return new Error("Unknown option: "+e);if(r.callback){let s=t&&r.callback(void 0,t);return o!=="global"&&s!==void 0?s:o!=="local"?r.callback():void 0}else return(o!=="global"&&t&&t.state.vim.options[e]||o!=="local"&&r||{}).value}Ve("filetype",void 0,"string",["ft"],function(e,t){if(t!==void 0)if(e===void 0){let n=t.getOption("mode");return n=="null"?"":n}else{let n=e==""?"null":e;t.setOption("mode",n)}}),Ve("textwidth",80,"number",["tw"],function(e,t){if(t!==void 0)if(e===void 0){var n=t.getOption("textwidth");return n}else{var r=Math.round(e);r>1&&t.setOption("textwidth",r)}});var pt=function(){var e=100,t=-1,n=0,r=0,o=new Array(e);function s(d,p,g){var y=t%e,k=o[y];function w(b){var M=++t%e,P=o[M];P&&P.clear(),o[M]=d.setBookmark(b)}if(k){var m=k.find();m&&!Re(m,p)&&w(p)}else w(p);w(g),n=t,r=t-e+1,r<0&&(r=0)}function u(d,p){t+=p,t>n?t=n:t<r&&(t=r);var g=o[(e+t)%e];if(g&&!g.find()){var y=p>0?1:-1,k,w=d.getCursor();do if(t+=y,g=o[(e+t)%e],g&&(k=g.find())&&!Re(w,k))break;while(t<n&&t>r)}return g}function h(d,p){var g=t,y=u(d,p);return t=g,y&&y.find()}return{cachedCursor:void 0,add:s,find:h,move:u}},at=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class gt{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=at()}exitMacroRecordMode(){var t=E.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,n){var r=E.registerController.getRegister(n);if(r){if(r.clear(),this.latestRegister=n,t.openDialog){var o=Ne("span",{class:"cm-vim-message"},"recording @"+n);this.onRecordingDone=t.openDialog(o,function(){},{bottom:!0})}this.isRecording=!0}}}function Ee(e){return e.state.vim||(e.state.vim={inputState:new rn,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 i(0,0),head:new i(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var E;function tt(){E={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:pt(),macroModeState:new gt,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Rr({}),searchHistoryController:new on,exCommandHistoryController:new on};for(var e in Ae){var t=Ae[e];t.value=t.defaultValue}}class we{constructor(t,n){this.keyName=t,this.key=n.key,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.metaKey=n.metaKey,this.shiftKey=n.shiftKey}}var xe,pe={enterVimMode:S,leaveVimMode:T,buildKeyMap:function(){},getRegisterController:function(){return E.registerController},resetVimGlobalState_:tt,getVimGlobalState_:function(){return E},maybeInitVimState_:Ee,suppressErrorLogging:!1,InsertModeKey:we,map:function(e,t,n){Ce.map(e,t,n)},unmap:function(e,t){return Ce.unmap(e,t)},noremap:function(e,t,n){Ce.map(e,t,n,!0)},mapclear:function(e){var t=c.length,n=v,r=c.slice(0,t-n);if(c=c.slice(t-n),e)for(var o=r.length-1;o>=0;o--){var s=r[o];if(e!==s.context)if(s.context)this._mapCommand(s);else{var u=["normal","insert","visual"];for(var h in u)if(u[h]!==e){var d=Object.assign({},s);d.context=u[h],this._mapCommand(d)}}}},langmap:lt,vimKeyFromEvent:qe,setOption:Qe,getOption:de,defineOption:Ve,defineEx:function(e,t,n){if(!t)t=e;else if(e.indexOf(t)!==0)throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered');An[e]=n,Ce.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,n){var r=this.findKey(e,t,n);if(typeof r=="function")return r()},multiSelectHandleKey:Ci,findKey:function(e,t,n){var r=Ee(e),o=e;function s(){var g=E.macroModeState;if(g.isRecording){if(t=="q")return g.exitMacroRecordMode(),ce(o),!0;n!="mapping"&&vi(g,t)}}function u(){if(t=="<Esc>"){if(r.visualMode)_e(o);else if(r.insertMode)ze(o);else return;return ce(o),!0}}function h(){if(u())return!0;r.inputState.keyBuffer.push(t);var g=r.inputState.keyBuffer.join(""),y=t.length==1,k=Je.matchCommand(g,c,r.inputState,"insert"),w=r.inputState.changeQueue;if(k.type=="none")return ce(o),!1;if(k.type=="partial"){if(k.expectLiteralNext&&(r.expectLiteralNext=!0),xe&&window.clearTimeout(xe),xe=y&&window.setTimeout(function(){r.insertMode&&r.inputState.keyBuffer.length&&ce(o)},de("insertModeEscKeysTimeout")),y){var m=o.listSelections();(!w||w.removed.length!=m.length)&&(w=r.inputState.changeQueue=new Er),w.inserted+=t;for(var b=0;b<m.length;b++){var M=me(m[b].anchor,m[b].head),P=Ue(m[b].anchor,m[b].head),I=o.getRange(M,o.state.overwrite?ie(P,0,1):P);w.removed[b]=(w.removed[b]||"")+I}}return!y}else k.type=="full"&&(r.inputState.keyBuffer.length=0);if(r.expectLiteralNext=!1,xe&&window.clearTimeout(xe),k.command&&w){for(var m=o.listSelections(),b=0;b<m.length;b++){var N=m[b].head;o.replaceRange(w.removed[b]||"",ie(N,0,-w.inserted.length),N,"+input")}E.macroModeState.lastInsertModeChanges.changes.pop()}return k.command||ce(o),k.command}function d(){if(s()||u())return!0;r.inputState.keyBuffer.push(t);var g=r.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(g))return!0;var y=/^(\d*)(.*)$/.exec(g);if(!y)return ce(o),!1;var k=r.visualMode?"visual":"normal",w=y[2]||y[1];r.inputState.operatorShortcut&&r.inputState.operatorShortcut.slice(-1)==w&&(w=r.inputState.operatorShortcut);var m=Je.matchCommand(w,c,r.inputState,k);return m.type=="none"?(ce(o),!1):m.type=="partial"?(m.expectLiteralNext&&(r.expectLiteralNext=!0),!0):m.type=="clear"?(ce(o),!0):(r.expectLiteralNext=!1,r.inputState.keyBuffer.length=0,y=/^(\d*)(.*)$/.exec(g),y&&y[1]&&y[1]!="0"&&r.inputState.pushRepeatDigit(y[1]),m.command)}var p=r.insertMode?h():d();if(p===!1)return!r.insertMode&&(t.length===1||a.isMac&&/<A-.>/.test(t))?function(){return!0}:void 0;if(p===!0)return function(){return!0};if(p)return function(){return o.operation(function(){o.curOp.isVimOp=!0;try{if(typeof p!="object")return;p.type=="keyToKey"?U(o,p.toKeys,p):Je.processCommand(o,r,p)}catch(g){throw o.state.vim=void 0,Ee(o),pe.suppressErrorLogging||console.log(g),g}return!0})}},handleEx:function(e,t){Ce.processCommand(e,t)},defineMotion:Tr,defineAction:Nr,defineOperator:Ir,mapCommand:pi,_mapCommand:Nt,defineRegister:Or,exitVisualMode:_e,exitInsertMode:ze},B=[],X=!1,O;function Z(e){if(!O)throw new Error("No prompt to send key to");if(e[0]=="<"){var t=e.toLowerCase().slice(1,-1),n=t.split("-");if(t=n.pop()||"",t=="lt")e="<";else if(t=="space")e=" ";else if(t=="cr")e=`
2
+ import{u as ki,r as Y,j as $e}from"./react-BVUjbTTn.js";import{s as rr,E as se,V as dt,D as te,a as Ht,R as wi,P as ir,S as xt,b as Me,f as xi,M as or,m as Bn,i as Si,c as bi,d as Mi,e as Li,g as Ai,h as Ei,j as Dn,k as ar,l as St,n as Oi,o as Ri,p as Ti,q as Ii,r as Ni,t as Pi,u as Bi,v as Di,w as _i,x as Ki,y as it,F as Yt,A as Xt,z as $i,W as sr,B as lr,C as _n,G as Fi,H as _t,I as Kt,J as Hi,K as Vi,L as ji,N as Wi,O as Ui,Q as zi,T as Qi,U as qi,X as Ji,Y as Zi,Z as Yi,_ as Xi,$ as Gi,a0 as eo,a1 as to,a2 as no,a3 as ro,a4 as io,a5 as oo,a6 as Gt,a7 as ao,a8 as so,a9 as lo,aa as co,ab as be,ac as uo,ad as fo}from"./editor-CiK7TK0p.js";import{r as Kn,c as ht,U as cr,a as Vt,b as jt,d as $n,m as ho,e as po,f as $t,t as Ct,g as kt,h as go}from"./ProjectWorkspace-C6GrvKN6.js";import{_ as Fn}from"./index-C0t11tlT.js";import"./check-BXvzrdoz.js";import"./x-Bq29njHL.js";import"./search-b1ORp1k8.js";import"./user-plus-CKalKSsw.js";import"./refresh-cw-Dvp3O90f.js";function vo(a){var i=a.Pos;function l(e,t,n){if(t.line===n.line&&t.ch>=n.ch-1){var r=e.getLine(t.line),o=r.charCodeAt(t.ch);55296<=o&&o<=55551&&(n.ch+=1)}return{start:t,end:n}}var c=[{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"}],f=Object.create(null),v=c.length,C=[{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"}],x=nn("");function S(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),a.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",On),Ee(e),a.on(e.getInputField(),"paste",R(e))}function T(e){e.setOption("disableInput",!1),e.off("cursorActivity",On),a.off(e.getInputField(),"paste",R(e)),e.state.vim=null,ut&&clearTimeout(ut)}function R(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(ie(e.getCursor(),0,1)),Ze.enterInsertMode(e,{},t))}),t.onPasteFn}var L=/[\d]/,A=[a.isWordChar,function(e){return e&&!a.isWordChar(e)&&!/\s/.test(e)}],D=[function(e){return/\S/.test(e)}],_=["<",">"],j=["-",'"',".",":","_","/","+"],z=/^\w$/,q=/^[A-Z]$/;try{q=new RegExp("^[\\p{Lu}]$","u")}catch{}function W(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function ae(e){return/^[a-z]$/.test(e)}function le(e){return"()[]{}".indexOf(e)!=-1}function J(e){return L.test(e)}function ye(e){return q.test(e)}function re(e){return/^\s*$/.test(e)}function He(e){return".?!".indexOf(e)!=-1}function et(e,t){for(var n=0;n<t.length;n++)if(t[n]==e)return!0;return!1}var Ae={};function Ve(e,t,n,r,o){if(t===void 0&&!o)throw Error("defaultValue is required unless callback is provided");if(n||(n="string"),Ae[e]={type:n,defaultValue:t,callback:o},r)for(var s=0;s<r.length;s++)Ae[r[s]]=Ae[e];t&&Qe(e,t)}function Qe(e,t,n,r){var o=Ae[e];r=r||{};var s=r.scope;if(!o)return new Error("Unknown option: "+e);if(o.type=="boolean"){if(t&&t!==!0)return new Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}o.callback?(s!=="local"&&o.callback(t,void 0),s!=="global"&&n&&o.callback(t,n)):(s!=="local"&&(o.value=o.type=="boolean"?!!t:t),s!=="global"&&n&&(n.state.vim.options[e]={value:t}))}function de(e,t,n){var r=Ae[e];n=n||{};var o=n.scope;if(!r)return new Error("Unknown option: "+e);if(r.callback){let s=t&&r.callback(void 0,t);return o!=="global"&&s!==void 0?s:o!=="local"?r.callback():void 0}else return(o!=="global"&&t&&t.state.vim.options[e]||o!=="local"&&r||{}).value}Ve("filetype",void 0,"string",["ft"],function(e,t){if(t!==void 0)if(e===void 0){let n=t.getOption("mode");return n=="null"?"":n}else{let n=e==""?"null":e;t.setOption("mode",n)}}),Ve("textwidth",80,"number",["tw"],function(e,t){if(t!==void 0)if(e===void 0){var n=t.getOption("textwidth");return n}else{var r=Math.round(e);r>1&&t.setOption("textwidth",r)}});var pt=function(){var e=100,t=-1,n=0,r=0,o=new Array(e);function s(d,p,g){var y=t%e,k=o[y];function w(b){var M=++t%e,P=o[M];P&&P.clear(),o[M]=d.setBookmark(b)}if(k){var m=k.find();m&&!Re(m,p)&&w(p)}else w(p);w(g),n=t,r=t-e+1,r<0&&(r=0)}function u(d,p){t+=p,t>n?t=n:t<r&&(t=r);var g=o[(e+t)%e];if(g&&!g.find()){var y=p>0?1:-1,k,w=d.getCursor();do if(t+=y,g=o[(e+t)%e],g&&(k=g.find())&&!Re(w,k))break;while(t<n&&t>r)}return g}function h(d,p){var g=t,y=u(d,p);return t=g,y&&y.find()}return{cachedCursor:void 0,add:s,find:h,move:u}},at=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class gt{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=at()}exitMacroRecordMode(){var t=E.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,n){var r=E.registerController.getRegister(n);if(r){if(r.clear(),this.latestRegister=n,t.openDialog){var o=Ne("span",{class:"cm-vim-message"},"recording @"+n);this.onRecordingDone=t.openDialog(o,function(){},{bottom:!0})}this.isRecording=!0}}}function Ee(e){return e.state.vim||(e.state.vim={inputState:new rn,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 i(0,0),head:new i(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var E;function tt(){E={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:pt(),macroModeState:new gt,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Rr({}),searchHistoryController:new on,exCommandHistoryController:new on};for(var e in Ae){var t=Ae[e];t.value=t.defaultValue}}class we{constructor(t,n){this.keyName=t,this.key=n.key,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.metaKey=n.metaKey,this.shiftKey=n.shiftKey}}var xe,pe={enterVimMode:S,leaveVimMode:T,buildKeyMap:function(){},getRegisterController:function(){return E.registerController},resetVimGlobalState_:tt,getVimGlobalState_:function(){return E},maybeInitVimState_:Ee,suppressErrorLogging:!1,InsertModeKey:we,map:function(e,t,n){Ce.map(e,t,n)},unmap:function(e,t){return Ce.unmap(e,t)},noremap:function(e,t,n){Ce.map(e,t,n,!0)},mapclear:function(e){var t=c.length,n=v,r=c.slice(0,t-n);if(c=c.slice(t-n),e)for(var o=r.length-1;o>=0;o--){var s=r[o];if(e!==s.context)if(s.context)this._mapCommand(s);else{var u=["normal","insert","visual"];for(var h in u)if(u[h]!==e){var d=Object.assign({},s);d.context=u[h],this._mapCommand(d)}}}},langmap:lt,vimKeyFromEvent:qe,setOption:Qe,getOption:de,defineOption:Ve,defineEx:function(e,t,n){if(!t)t=e;else if(e.indexOf(t)!==0)throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered');An[e]=n,Ce.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,n){var r=this.findKey(e,t,n);if(typeof r=="function")return r()},multiSelectHandleKey:Ci,findKey:function(e,t,n){var r=Ee(e),o=e;function s(){var g=E.macroModeState;if(g.isRecording){if(t=="q")return g.exitMacroRecordMode(),ce(o),!0;n!="mapping"&&vi(g,t)}}function u(){if(t=="<Esc>"){if(r.visualMode)_e(o);else if(r.insertMode)ze(o);else return;return ce(o),!0}}function h(){if(u())return!0;r.inputState.keyBuffer.push(t);var g=r.inputState.keyBuffer.join(""),y=t.length==1,k=Je.matchCommand(g,c,r.inputState,"insert"),w=r.inputState.changeQueue;if(k.type=="none")return ce(o),!1;if(k.type=="partial"){if(k.expectLiteralNext&&(r.expectLiteralNext=!0),xe&&window.clearTimeout(xe),xe=y&&window.setTimeout(function(){r.insertMode&&r.inputState.keyBuffer.length&&ce(o)},de("insertModeEscKeysTimeout")),y){var m=o.listSelections();(!w||w.removed.length!=m.length)&&(w=r.inputState.changeQueue=new Er),w.inserted+=t;for(var b=0;b<m.length;b++){var M=me(m[b].anchor,m[b].head),P=Ue(m[b].anchor,m[b].head),I=o.getRange(M,o.state.overwrite?ie(P,0,1):P);w.removed[b]=(w.removed[b]||"")+I}}return!y}else k.type=="full"&&(r.inputState.keyBuffer.length=0);if(r.expectLiteralNext=!1,xe&&window.clearTimeout(xe),k.command&&w){for(var m=o.listSelections(),b=0;b<m.length;b++){var N=m[b].head;o.replaceRange(w.removed[b]||"",ie(N,0,-w.inserted.length),N,"+input")}E.macroModeState.lastInsertModeChanges.changes.pop()}return k.command||ce(o),k.command}function d(){if(s()||u())return!0;r.inputState.keyBuffer.push(t);var g=r.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(g))return!0;var y=/^(\d*)(.*)$/.exec(g);if(!y)return ce(o),!1;var k=r.visualMode?"visual":"normal",w=y[2]||y[1];r.inputState.operatorShortcut&&r.inputState.operatorShortcut.slice(-1)==w&&(w=r.inputState.operatorShortcut);var m=Je.matchCommand(w,c,r.inputState,k);return m.type=="none"?(ce(o),!1):m.type=="partial"?(m.expectLiteralNext&&(r.expectLiteralNext=!0),!0):m.type=="clear"?(ce(o),!0):(r.expectLiteralNext=!1,r.inputState.keyBuffer.length=0,y=/^(\d*)(.*)$/.exec(g),y&&y[1]&&y[1]!="0"&&r.inputState.pushRepeatDigit(y[1]),m.command)}var p=r.insertMode?h():d();if(p===!1)return!r.insertMode&&(t.length===1||a.isMac&&/<A-.>/.test(t))?function(){return!0}:void 0;if(p===!0)return function(){return!0};if(p)return function(){return o.operation(function(){o.curOp.isVimOp=!0;try{if(typeof p!="object")return;p.type=="keyToKey"?U(o,p.toKeys,p):Je.processCommand(o,r,p)}catch(g){throw o.state.vim=void 0,Ee(o),pe.suppressErrorLogging||console.log(g),g}return!0})}},handleEx:function(e,t){Ce.processCommand(e,t)},defineMotion:Tr,defineAction:Nr,defineOperator:Ir,mapCommand:pi,_mapCommand:Nt,defineRegister:Or,exitVisualMode:_e,exitInsertMode:ze},B=[],X=!1,O;function Z(e){if(!O)throw new Error("No prompt to send key to");if(e[0]=="<"){var t=e.toLowerCase().slice(1,-1),n=t.split("-");if(t=n.pop()||"",t=="lt")e="<";else if(t=="space")e=" ";else if(t=="cr")e=`
3
3
  `;else if(We[t]){var r=O.value||"",o={key:We[t],target:{value:r,selectionEnd:r.length,selectionStart:r.length}};O.onKeyDown&&O.onKeyDown(o,O.value,u),O&&O.onKeyUp&&O.onKeyUp(o,O.value,u);return}}if(e==`
4
4
  `){var s=O;O=null,s.onClose&&s.onClose(s.value)}else O.value=(O.value||"")+e;function u(h){O&&(typeof h=="string"?O.value=h:O=null)}}function U(e,t,n){var r=X;if(n){if(B.indexOf(n)!=-1)return;B.push(n),X=n.noremap!=!1}try{for(var o=Ee(e),s=/<(?:[CSMA]-)*\w+>|./gi,u;u=s.exec(t);){var h=u[0],d=o.insertMode;if(O){Z(h);continue}var p=pe.handleKey(e,h,"mapping");if(!p&&d&&o.insertMode){if(h[0]=="<"){var g=h.toLowerCase().slice(1,-1),y=g.split("-");if(g=y.pop()||"",g=="lt")h="<";else if(g=="space")h=" ";else if(g=="cr")h=`
5
5
  `;else if(We.hasOwnProperty(g)){h=We[g],Nn(e,h);continue}else h=h[0],s.lastIndex=u.index+1}e.replaceSelection(h)}}}finally{if(B.pop(),X=B.length?r:!1,!B.length&&O){var k=O;O=null,mt(e,k)}}}var Oe={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},st={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},We={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(Oe)).forEach(function(e){We[(Oe[e]||"").toLowerCase()]=We[e.toLowerCase()]=e});function qe(e,t){var n=e.key;if(!st[n]){n.length>1&&n[0]=="n"&&(n=n.replace("Numpad","")),n=Oe[n]||n;var r="";if(e.ctrlKey&&(r+="C-"),e.altKey&&(r+="A-"),e.metaKey&&(r+="M-"),a.isMac&&r=="A-"&&n.length==1&&(r=r.slice(2)),(r||n.length>1)&&e.shiftKey&&(r+="S-"),t&&!t.expectLiteralNext&&n.length==1){if(x.keymap&&n in x.keymap)(x.remapCtrl!=!1||!r)&&(n=x.keymap[n]);else if(n.charCodeAt(0)>128&&!f[n]){var o=e.code?.slice(-1)||"";e.shiftKey||(o=o.toLowerCase()),o&&(n=o,!r&&e.altKey&&(r="A-"))}}return r+=n,r.length>1&&(r="<"+r+">"),r}}function lt(e,t){x.string!==e&&(x=nn(e)),x.remapCtrl=t}function nn(e){let t={};if(!e)return{keymap:t,string:""};function n(r){return r.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(r=>{if(!r)return;const o=r.split(/((?:[^\\;]|\\.)+);/);if(o.length==3){const s=n(o[1]),u=n(o[2]);if(s.length!==u.length)return;for(let h=0;h<s.length;++h)t[s[h]]=u[h]}else if(o.length==1){const s=n(r);if(s.length%2!==0)return;for(let u=0;u<s.length;u+=2)t[s[u]]=s[u+1]}}),{keymap:t,string:e}}Ve("langmap",void 0,"string",["lmap"],function(e,t){if(e===void 0)return x.string;lt(e)});class rn{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(t){this.operator?this.motionRepeat=this.motionRepeat.concat(t):this.prefixRepeat=this.prefixRepeat.concat(t)}getRepeat(){var t=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(t=1,this.prefixRepeat.length>0&&(t*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(t*=parseInt(this.motionRepeat.join(""),10))),t}}function ce(e,t){e.state.vim.inputState=new rn,e.state.vim.expectLiteralNext=!1,a.signal(e,"vim-command-done",t)}function Er(){this.removed=[],this.inserted=""}class Be{constructor(t,n,r){this.clear(),this.keyBuffer=[t||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!n,this.blockwise=!!r}setText(t,n,r){this.keyBuffer=[t||""],this.linewise=!!n,this.blockwise=!!r}pushText(t,n){n&&(this.linewise||this.keyBuffer.push(`
@@ -1 +1 @@
1
- import{u as X,r as s,j as i}from"./react-BVUjbTTn.js";import{P as K,g as J,w as Q,G as ee}from"./pdf-BB1XvBIF.js";import{M as te,a as ne}from"./minus-Beso_n-6.js";import{P as re}from"./plus-BfEC7mzf.js";import{b as V}from"./index-CzVDvC5h.js";ee.workerSrc=Q;const Y=new K,O=2,R=new Map;async function fe(){await Y.promise}function _(a,r){const o=`${r}:${a}`,f=R.get(o);if(f)return f.lastUsed=Date.now(),f;const u=J({url:a,worker:Y,disableRange:r==="full"}),c={task:u,promise:u.promise,consumers:0,settled:!1,lastUsed:Date.now()};return R.set(o,c),c.promise.then(()=>{c.settled=!0,q()},()=>{c.settled=!0,R.get(o)===c&&R.delete(o)}),c}function q(){if(R.size<=O)return;const a=[...R.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,o)=>r[1].lastUsed-o[1].lastUsed);for(;R.size>O&&a.length;){const[r,o]=a.shift();R.get(r)===o&&(R.delete(r),o.task.destroy())}}function he(a,r){if(!a)return;_(a,r).promise.catch(()=>{})}function se(a,r){const o=_(a,r);o.consumers+=1,o.lastUsed=Date.now();let f=!1;return{promise:o.promise,release:()=>{f||(f=!0,o.consumers=Math.max(0,o.consumers-1),o.lastUsed=Date.now(),q())}}}function me({url:a,loadingMode:r,target:o,compiling:f=!1,onViewportLocation:u,onDoubleClickLocation:c}){const{t:h}=X(),x=s.useRef(null),[m,D]=s.useState(null),[g,p]=s.useState(0),[d,E]=s.useState(100),[v,N]=s.useState(""),b=s.useRef(new Map),w=s.useRef(null),k=s.useRef(u);k.current=u;const M=s.useCallback((t,e)=>{e?b.current.set(t,e):b.current.delete(t)},[]),C=async t=>{if(!m||t==null)return;let e=t;if(typeof t=="string"&&(e=await m.getDestination(t).catch(()=>null)),!Array.isArray(e)||e.length===0)return;const l=e[0];let n=null;if(typeof l=="number"&&Number.isInteger(l))n=l;else if(l!=null)try{n=await m.getPageIndex(l)}catch{return}n==null||n<0||n>=m.numPages||b.current.get(n+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},y=s.useCallback(()=>{w.current=null;const t=x.current;if(!t)return;const e=t.getBoundingClientRect(),l=e.left+e.width/2,n=e.top+e.height/2,P=[...t.querySelectorAll(".pdf-page")],S=P.find(F=>{const I=F.getBoundingClientRect();return n>=I.top&&n<=I.bottom})??P.reduce((F,I)=>{if(!F)return I;const H=Math.abs(I.getBoundingClientRect().top-n),G=Math.abs(F.getBoundingClientRect().top-n);return H<G?I:F},null);if(!S)return;const j=S.getBoundingClientRect(),U=Number(S.dataset.scale)||1,T=Number(S.dataset.page),$=Math.max(0,Math.min(j.width,l-j.left))/U,B=Math.max(0,Math.min(j.height,n-j.top))/U;T&&k.current(T,$,B)},[]),A=s.useCallback(()=>{w.current===null&&(w.current=window.requestAnimationFrame(y))},[y]);s.useEffect(()=>()=>{w.current!==null&&window.cancelAnimationFrame(w.current),w.current=null},[]),s.useEffect(()=>{const t=x.current;if(!t)return;const e=()=>p(t.clientWidth);e();const l=new ResizeObserver(e);return l.observe(t),()=>l.disconnect()},[]),s.useEffect(()=>{let t=!1;D(null),N("");const e=se(a,r);return e.promise.then(l=>{t||D(l)}).catch(()=>{t||N(h("editor.pdfLoadFailed"))}),()=>{t=!0,e.release()}},[a,r]),s.useEffect(()=>{d>100||!x.current||(x.current.scrollLeft=0)},[d,g,m]);const z=t=>E(e=>Math.min(200,Math.max(50,e+t))),W=()=>{x.current&&(x.current.scrollLeft=0),E(100)},L=t=>{!t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||(t.preventDefault(),t.currentTarget.scrollLeft+=t.deltaY,A())};return i.jsxs("div",{className:"pdf-viewer",children:[i.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":h("editor.pdfZoomControls"),children:[i.jsx("button",{disabled:d<=50,title:h("editor.pdfZoomOut"),"aria-label":h("editor.pdfZoomOut"),onClick:()=>z(-10),children:i.jsx(te,{size:14})}),i.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[d,"%"]}),i.jsx("button",{disabled:d>=200,title:h("editor.pdfZoomIn"),"aria-label":h("editor.pdfZoomIn"),onClick:()=>z(10),children:i.jsx(re,{size:14})}),i.jsxs("button",{className:"pdf-fit-width",title:h("editor.pdfFitWidth"),onClick:W,children:[i.jsx(ne,{size:13}),h("editor.pdfFitWidth")]})]}),f&&i.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:20}),i.jsx("span",{children:h("editor.compiling")})]}),i.jsx("div",{className:"pdf-document",ref:x,onScroll:A,onWheel:L,children:i.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,g-28)*Math.max(1,d/100)}px`},children:[!m&&!v&&i.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:24}),i.jsx("span",{children:h("editor.loadingPdf")})]}),v&&i.jsx("div",{className:"preview-empty",children:i.jsx("strong",{children:v})}),m&&g>0&&Array.from({length:m.numPages},(t,e)=>i.jsx(ie,{document:m,pageNumber:e+1,availableWidth:g-28,zoom:d/100,target:o?.page===e+1?o:null,onReady:A,onPageElement:M,onInternalLink:C,onDoubleClickLocation:c},e+1))]})})]})}function ie({document:a,pageNumber:r,availableWidth:o,zoom:f,target:u,onReady:c,onPageElement:h,onInternalLink:x,onDoubleClickLocation:m}){const D=s.useRef(null),g=s.useRef(null),p=s.useRef(null),[d,E]=s.useState(1),[v,N]=s.useState({width:0,height:0}),[b,w]=s.useState(r===1),[k,M]=s.useState(!1),[C,y]=s.useState(null),[A,z]=s.useState([]);s.useEffect(()=>{const e=D.current;if(!e||b)return;if(!("IntersectionObserver"in window)){w(!0);return}const l=new IntersectionObserver(n=>{n.some(P=>P.isIntersecting)&&(w(!0),l.disconnect())},{rootMargin:"900px 0px"});return l.observe(e),()=>l.disconnect()},[b]),s.useEffect(()=>{u&&w(!0)},[u?.nonce]),s.useEffect(()=>{if(!b)return;let e=!1,l=null;return M(!1),y(null),z([]),a.getPage(r).then(n=>{if(e)return;const P=n.getViewport({scale:1}),S=o/P.width,j=Math.min(3.3,Math.max(.175,S*f)),U=n.getViewport({scale:j});if(E(j),N({width:U.width,height:U.height}),y(U),n.getAnnotations({intent:"display"}).then(B=>{e||z(B)}).catch(()=>{e||z([])}),!g.current)return;const T=Math.max(1,window.devicePixelRatio||1),$=n.getViewport({scale:j*T});return g.current.width=Math.floor($.width),g.current.height=Math.floor($.height),l=n.render({canvas:g.current,viewport:$}),l.promise.then(()=>{e||(M(!0),window.requestAnimationFrame(c))})}).catch(()=>{}),()=>{e=!0,l?.cancel()}},[a,r,o,f,b]),s.useEffect(()=>{!u||!p.current||p.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[u?.nonce,d]);const W=e=>{if(!m||!k||e.target instanceof HTMLElement&&e.target.closest("a"))return;const l=g.current;if(!l)return;const n=l.getBoundingClientRect();if(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom)return;const P=d||1,S=Math.max(0,Math.min(n.width,e.clientX-n.left))/P,j=Math.max(0,Math.min(n.height,e.clientY-n.top))/P;m(r,S,j)},L=Math.max(1,o*f),t=L*(792/612);return i.jsxs("figure",{ref:e=>{D.current=e,h(r,e)},onDoubleClick:W,className:`pdf-page${k?" rendered":" loading"}`,"data-page":r,"data-scale":d,style:{width:`${v.width||L}px`,minHeight:`${v.height||t}px`},children:[i.jsx("canvas",{ref:g,style:{width:`${v.width||L}px`,height:`${v.height||t}px`}}),k&&C&&i.jsx(oe,{annotations:A,viewport:C,onInternalLink:x}),u&&i.jsx("span",{ref:p,className:"pdf-sync-marker",style:{left:u.x*d,top:u.y*d}}),i.jsx("figcaption",{children:r})]})}function oe({annotations:a,viewport:r,onInternalLink:o}){const{t:f}=X(),u=f("editor.pdfLink");return i.jsx("div",{className:"pdf-annotation-layer","aria-label":f("editor.pdfLinks"),children:a.filter(c=>c.subtype==="Link"&&Array.isArray(c.rect)&&c.rect.length>=4).map((c,h)=>{const[x,m]=r.convertToViewportPoint(c.rect[0],c.rect[1]),[D,g]=r.convertToViewportPoint(c.rect[2],c.rect[3]),p=[x,m,D,g],d=Math.min(p[0],p[2]),E=Math.min(p[1],p[3]),v=Math.abs(p[2]-p[0]),N=Math.abs(p[3]-p[1]),b=typeof c.title=="string"?c.title.trim():"",w=typeof c.unsafeUrl=="string"?c.unsafeUrl.trim():"",k=typeof c.url=="string"?c.url.trim():"",M=Z(k)?k:Z(w)?w:"",C=c.dest;if(!M&&C==null)return null;const y=!!M;return i.jsx("a",{className:"pdf-annotation-link",href:M||"#",target:y?"_blank":void 0,rel:y?"noreferrer":void 0,title:b||(y?M:u),"aria-label":b||(y?M:u),style:{left:d,top:E,width:v,height:N},onClick:y?void 0:A=>{A.preventDefault(),o(C)}},`${h}-${d}-${E}`)})})}function Z(a){return/^(?:https?|mailto|ftp):/i.test(a)}export{me as PdfPreview,he as preloadPdf,fe as preloadPdfRuntime};
1
+ import{u as X,r as s,j as i}from"./react-BVUjbTTn.js";import{P as K,g as J,w as Q,G as ee}from"./pdf-BB1XvBIF.js";import{M as te,a as ne}from"./minus-9eVJnugf.js";import{P as re}from"./plus-BGXipRoG.js";import{b as V}from"./index-C0t11tlT.js";ee.workerSrc=Q;const Y=new K,O=2,R=new Map;async function fe(){await Y.promise}function _(a,r){const o=`${r}:${a}`,f=R.get(o);if(f)return f.lastUsed=Date.now(),f;const u=J({url:a,worker:Y,disableRange:r==="full"}),c={task:u,promise:u.promise,consumers:0,settled:!1,lastUsed:Date.now()};return R.set(o,c),c.promise.then(()=>{c.settled=!0,q()},()=>{c.settled=!0,R.get(o)===c&&R.delete(o)}),c}function q(){if(R.size<=O)return;const a=[...R.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,o)=>r[1].lastUsed-o[1].lastUsed);for(;R.size>O&&a.length;){const[r,o]=a.shift();R.get(r)===o&&(R.delete(r),o.task.destroy())}}function he(a,r){if(!a)return;_(a,r).promise.catch(()=>{})}function se(a,r){const o=_(a,r);o.consumers+=1,o.lastUsed=Date.now();let f=!1;return{promise:o.promise,release:()=>{f||(f=!0,o.consumers=Math.max(0,o.consumers-1),o.lastUsed=Date.now(),q())}}}function me({url:a,loadingMode:r,target:o,compiling:f=!1,onViewportLocation:u,onDoubleClickLocation:c}){const{t:h}=X(),x=s.useRef(null),[m,D]=s.useState(null),[g,p]=s.useState(0),[d,E]=s.useState(100),[v,N]=s.useState(""),b=s.useRef(new Map),w=s.useRef(null),k=s.useRef(u);k.current=u;const M=s.useCallback((t,e)=>{e?b.current.set(t,e):b.current.delete(t)},[]),C=async t=>{if(!m||t==null)return;let e=t;if(typeof t=="string"&&(e=await m.getDestination(t).catch(()=>null)),!Array.isArray(e)||e.length===0)return;const l=e[0];let n=null;if(typeof l=="number"&&Number.isInteger(l))n=l;else if(l!=null)try{n=await m.getPageIndex(l)}catch{return}n==null||n<0||n>=m.numPages||b.current.get(n+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},y=s.useCallback(()=>{w.current=null;const t=x.current;if(!t)return;const e=t.getBoundingClientRect(),l=e.left+e.width/2,n=e.top+e.height/2,P=[...t.querySelectorAll(".pdf-page")],S=P.find(F=>{const I=F.getBoundingClientRect();return n>=I.top&&n<=I.bottom})??P.reduce((F,I)=>{if(!F)return I;const H=Math.abs(I.getBoundingClientRect().top-n),G=Math.abs(F.getBoundingClientRect().top-n);return H<G?I:F},null);if(!S)return;const j=S.getBoundingClientRect(),U=Number(S.dataset.scale)||1,T=Number(S.dataset.page),$=Math.max(0,Math.min(j.width,l-j.left))/U,B=Math.max(0,Math.min(j.height,n-j.top))/U;T&&k.current(T,$,B)},[]),A=s.useCallback(()=>{w.current===null&&(w.current=window.requestAnimationFrame(y))},[y]);s.useEffect(()=>()=>{w.current!==null&&window.cancelAnimationFrame(w.current),w.current=null},[]),s.useEffect(()=>{const t=x.current;if(!t)return;const e=()=>p(t.clientWidth);e();const l=new ResizeObserver(e);return l.observe(t),()=>l.disconnect()},[]),s.useEffect(()=>{let t=!1;D(null),N("");const e=se(a,r);return e.promise.then(l=>{t||D(l)}).catch(()=>{t||N(h("editor.pdfLoadFailed"))}),()=>{t=!0,e.release()}},[a,r]),s.useEffect(()=>{d>100||!x.current||(x.current.scrollLeft=0)},[d,g,m]);const z=t=>E(e=>Math.min(200,Math.max(50,e+t))),W=()=>{x.current&&(x.current.scrollLeft=0),E(100)},L=t=>{!t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||(t.preventDefault(),t.currentTarget.scrollLeft+=t.deltaY,A())};return i.jsxs("div",{className:"pdf-viewer",children:[i.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":h("editor.pdfZoomControls"),children:[i.jsx("button",{disabled:d<=50,title:h("editor.pdfZoomOut"),"aria-label":h("editor.pdfZoomOut"),onClick:()=>z(-10),children:i.jsx(te,{size:14})}),i.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[d,"%"]}),i.jsx("button",{disabled:d>=200,title:h("editor.pdfZoomIn"),"aria-label":h("editor.pdfZoomIn"),onClick:()=>z(10),children:i.jsx(re,{size:14})}),i.jsxs("button",{className:"pdf-fit-width",title:h("editor.pdfFitWidth"),onClick:W,children:[i.jsx(ne,{size:13}),h("editor.pdfFitWidth")]})]}),f&&i.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:20}),i.jsx("span",{children:h("editor.compiling")})]}),i.jsx("div",{className:"pdf-document",ref:x,onScroll:A,onWheel:L,children:i.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,g-28)*Math.max(1,d/100)}px`},children:[!m&&!v&&i.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:24}),i.jsx("span",{children:h("editor.loadingPdf")})]}),v&&i.jsx("div",{className:"preview-empty",children:i.jsx("strong",{children:v})}),m&&g>0&&Array.from({length:m.numPages},(t,e)=>i.jsx(ie,{document:m,pageNumber:e+1,availableWidth:g-28,zoom:d/100,target:o?.page===e+1?o:null,onReady:A,onPageElement:M,onInternalLink:C,onDoubleClickLocation:c},e+1))]})})]})}function ie({document:a,pageNumber:r,availableWidth:o,zoom:f,target:u,onReady:c,onPageElement:h,onInternalLink:x,onDoubleClickLocation:m}){const D=s.useRef(null),g=s.useRef(null),p=s.useRef(null),[d,E]=s.useState(1),[v,N]=s.useState({width:0,height:0}),[b,w]=s.useState(r===1),[k,M]=s.useState(!1),[C,y]=s.useState(null),[A,z]=s.useState([]);s.useEffect(()=>{const e=D.current;if(!e||b)return;if(!("IntersectionObserver"in window)){w(!0);return}const l=new IntersectionObserver(n=>{n.some(P=>P.isIntersecting)&&(w(!0),l.disconnect())},{rootMargin:"900px 0px"});return l.observe(e),()=>l.disconnect()},[b]),s.useEffect(()=>{u&&w(!0)},[u?.nonce]),s.useEffect(()=>{if(!b)return;let e=!1,l=null;return M(!1),y(null),z([]),a.getPage(r).then(n=>{if(e)return;const P=n.getViewport({scale:1}),S=o/P.width,j=Math.min(3.3,Math.max(.175,S*f)),U=n.getViewport({scale:j});if(E(j),N({width:U.width,height:U.height}),y(U),n.getAnnotations({intent:"display"}).then(B=>{e||z(B)}).catch(()=>{e||z([])}),!g.current)return;const T=Math.max(1,window.devicePixelRatio||1),$=n.getViewport({scale:j*T});return g.current.width=Math.floor($.width),g.current.height=Math.floor($.height),l=n.render({canvas:g.current,viewport:$}),l.promise.then(()=>{e||(M(!0),window.requestAnimationFrame(c))})}).catch(()=>{}),()=>{e=!0,l?.cancel()}},[a,r,o,f,b]),s.useEffect(()=>{!u||!p.current||p.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[u?.nonce,d]);const W=e=>{if(!m||!k||e.target instanceof HTMLElement&&e.target.closest("a"))return;const l=g.current;if(!l)return;const n=l.getBoundingClientRect();if(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom)return;const P=d||1,S=Math.max(0,Math.min(n.width,e.clientX-n.left))/P,j=Math.max(0,Math.min(n.height,e.clientY-n.top))/P;m(r,S,j)},L=Math.max(1,o*f),t=L*(792/612);return i.jsxs("figure",{ref:e=>{D.current=e,h(r,e)},onDoubleClick:W,className:`pdf-page${k?" rendered":" loading"}`,"data-page":r,"data-scale":d,style:{width:`${v.width||L}px`,minHeight:`${v.height||t}px`},children:[i.jsx("canvas",{ref:g,style:{width:`${v.width||L}px`,height:`${v.height||t}px`}}),k&&C&&i.jsx(oe,{annotations:A,viewport:C,onInternalLink:x}),u&&i.jsx("span",{ref:p,className:"pdf-sync-marker",style:{left:u.x*d,top:u.y*d}}),i.jsx("figcaption",{children:r})]})}function oe({annotations:a,viewport:r,onInternalLink:o}){const{t:f}=X(),u=f("editor.pdfLink");return i.jsx("div",{className:"pdf-annotation-layer","aria-label":f("editor.pdfLinks"),children:a.filter(c=>c.subtype==="Link"&&Array.isArray(c.rect)&&c.rect.length>=4).map((c,h)=>{const[x,m]=r.convertToViewportPoint(c.rect[0],c.rect[1]),[D,g]=r.convertToViewportPoint(c.rect[2],c.rect[3]),p=[x,m,D,g],d=Math.min(p[0],p[2]),E=Math.min(p[1],p[3]),v=Math.abs(p[2]-p[0]),N=Math.abs(p[3]-p[1]),b=typeof c.title=="string"?c.title.trim():"",w=typeof c.unsafeUrl=="string"?c.unsafeUrl.trim():"",k=typeof c.url=="string"?c.url.trim():"",M=Z(k)?k:Z(w)?w:"",C=c.dest;if(!M&&C==null)return null;const y=!!M;return i.jsx("a",{className:"pdf-annotation-link",href:M||"#",target:y?"_blank":void 0,rel:y?"noreferrer":void 0,title:b||(y?M:u),"aria-label":b||(y?M:u),style:{left:d,top:E,width:v,height:N},onClick:y?void 0:A=>{A.preventDefault(),o(C)}},`${h}-${d}-${E}`)})})}function Z(a){return/^(?:https?|mailto|ftp):/i.test(a)}export{me as PdfPreview,he as preloadPdf,fe as preloadPdfRuntime};
@@ -1 +1 @@
1
- import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,g as M}from"./index-CzVDvC5h.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-BfN2bCgZ.js";import{S as q}from"./search-DL2UGvdj.js";import"./hard-drive-CF3WDfkG.js";import"./x-BDSEosRE.js";import"./sigma-CSRwPPkk.js";import"./tags-CjkWzXqX.js";import"./chevron-left-DNM7mhNi.js";function g(o){return o.trim().toLocaleLowerCase()}function J({project:o,open:l,onOpenChange:d,onSave:y}){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=g(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>g(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await y(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{J as ProjectIconPickerDialog};
1
+ import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,g as M}from"./index-C0t11tlT.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-CWfSLzD3.js";import{S as q}from"./search-b1ORp1k8.js";import"./hard-drive-6uYFyezl.js";import"./x-Bq29njHL.js";import"./sigma-Bk0_MzWi.js";import"./tags-JAkbmWns.js";import"./chevron-left-BB5MYb7g.js";function g(o){return o.trim().toLocaleLowerCase()}function J({project:o,open:l,onOpenChange:d,onSave:y}){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=g(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>g(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await y(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{J as ProjectIconPickerDialog};
@@ -1 +1 @@
1
- import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,f as q,M as F,b as V,C as B}from"./index-CzVDvC5h.js";import{S as $}from"./search-DL2UGvdj.js";import{F as J,d as K}from"./x-BDSEosRE.js";import{C as G}from"./check-bnimQPun.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,f as q,M as F,b as V,C as B}from"./index-C0t11tlT.js";import{S as $}from"./search-b1ORp1k8.js";import{F as J,d as K}from"./x-Bq29njHL.js";import{C as G}from"./check-BXvzrdoz.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 +1 @@
1
- import{u as le,r,j as e}from"./react-BVUjbTTn.js";import{c as j,f as x,g as S,b as oe}from"./index-CzVDvC5h.js";import{i as f,p as pe,S as O,j as V,k as de,A as he,l as me,n as xe}from"./ProjectWorkspace-WLYA7BSv.js";import{X as B,C as je,c as ge}from"./x-BDSEosRE.js";import{T as K}from"./type-D1mmDdLM.js";import{S as ue}from"./sigma-CSRwPPkk.js";import{C as be}from"./chevron-left-DNM7mhNi.js";import{R as X}from"./refresh-cw-FZs9MtoA.js";import"./check-bnimQPun.js";import"./search-DL2UGvdj.js";import"./user-plus-YJ3ftuL5.js";const ve=j("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Se=j("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const fe=j("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 ye=j("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 ke=j("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 Ne=j("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 Ce({name:y,state:n,label:c,reloadLabel:d,onReload:k,compact:N=!1}){const g=n.status==="loading"?e.jsx(oe,{className:"spin",size:14}):n.status==="working"?e.jsx(me,{size:14}):e.jsx(fe,{size:14}),u=e.jsxs(e.Fragment,{children:[g,e.jsx("strong",{children:y}),e.jsx("span",{children:c}),n.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:[e.jsx(X,{size:12}),d]})]});return N?e.jsxs("span",{className:`browser-tool-status compact ${n.status}`,role:"status","aria-live":"polite","aria-label":`${y}: ${c}`,title:n.error||void 0,children:[g,e.jsx("span",{children:c}),n.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:e.jsx(X,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${n.status}`,title:n.error||void 0,children:u})}function He({onClose:y,project:n,projectId:c,site:d,files:k,dictionaryWords:N,onDictionaryChange:g,editorPreferences:u,onEditorPreferences:G,spellCheckCount:o,spellCheckUniqueCount:Q,spellCheckIndex:h,onSpellCheckNavigate:C,onProject:Y}){const{t:s}=le(),[M,Z]=r.useState(n.engine),[F,T]=r.useState(""),[$,I]=r.useState(n.name),[b,ee]=r.useState(n.mainFile),[v,D]=r.useState(null),[P,z]=r.useState(""),[E,A]=r.useState(""),[H,w]=r.useState(""),[p,L]=r.useState("appearance"),[i,l]=r.useState(u),R=r.useSyncExternalStore(f.subscribe,f.getSnapshot,f.getSnapshot),m=n.permission==="owner",W=n.permission!=="read",q=n.permission!=="read";r.useEffect(()=>l(u),[u]),r.useEffect(()=>{pe().catch(f.failed)},[c]);const te=()=>{xe().catch(f.failed)};r.useEffect(()=>{if(!n.latexmkrc)return T("");x(`/api/projects/${c}/file?path=${encodeURIComponent(n.latexmkrc)}`).then(({content:t})=>T(t)).catch(t=>z(S(t)))},[n.latexmkrc]),r.useEffect(()=>{if(p!=="compiler")return;const t=new AbortController;return D(null),x(`/api/projects/${c}/main-files`,{signal:t.signal}).then(a=>D(a.mainFiles)).catch(a=>{a instanceof Error&&a.name==="AbortError"||z(S(a))}),()=>t.abort()},[c,k,p]);const se=v??[n.mainFile],ie=v!==null&&!v.includes(b),_=async()=>{try{const t=F.trim()&&d.allowProjectLatexmkrc!==!1?".latexmkrc":null;t&&await x(`/api/projects/${c}/file`,{method:"PUT",body:JSON.stringify({path:t,content:F})});const a=await x(`/api/projects/${c}`,{method:"PATCH",body:JSON.stringify({name:$,mainFile:b,engine:M,latexmkrc:t})});Y(a.project)}catch(t){z(S(t))}},J=()=>G(i),ne=()=>{if(p==="appearance")return J();m&&_()},ae=s(p==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),re=p==="appearance"||m,U=async()=>{const t=E.trim();if(t)try{const a=await x(`/api/projects/${c}/dictionary`,{method:"POST",body:JSON.stringify({word:t})});g(a.words),A(""),w("")}catch(a){w(S(a))}},ce=async t=>{try{const a=await x(`/api/projects/${c}/dictionary/${encodeURIComponent(t)}`,{method:"DELETE"});g(a.words),w("")}catch(a){w(S(a))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:s("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[re&&e.jsxs("button",{type:"button",className:"drawer-settings-save",onClick:ne,children:[e.jsx(O,{size:14}),e.jsx("span",{children:ae})]}),e.jsx("button",{type:"button","aria-label":s("common.close"),onClick:y,children:e.jsx(B,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[P&&e.jsx("p",{className:"error",children:P}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":s("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":p==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${p==="appearance"?" active":""}`,onClick:()=>L("appearance"),children:[e.jsx(K,{size:15}),s("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":p==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${p==="compiler"?" active":""}`,onClick:()=>L("compiler"),children:[e.jsx(V,{size:15}),s("projectSettings.compilerTab")]})]}),p==="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(K,{size:15}),e.jsx("strong",{children:s("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:s("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[s("projectSettings.fontFamily"),e.jsx("select",{value:i.font,onChange:t=>l({...i,font:t.target.value}),children:de.map(t=>e.jsx("option",{value:t.id,children:s(t.labelKey)},t.id))})]}),e.jsxs("label",{children:[s("projectSettings.fontSize"),e.jsx("select",{value:i.fontSize,onChange:t=>l({...i,fontSize:Number(t.target.value)}),children:[12,13,14,15,16,18,20].map(t=>e.jsxs("option",{value:t,children:[t," px"]},t))})]}),e.jsxs("label",{children:[s("projectSettings.lineHeight"),e.jsxs("select",{value:i.lineHeight,onChange:t=>l({...i,lineHeight:Number(t.target.value)}),children:[e.jsx("option",{value:1.45,children:s("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:s("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:s("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.lineWrapping,onChange:t=>l({...i,lineWrapping:t.target.checked})}),e.jsx(Ne,{size:15}),e.jsx("span",{children:s("projectSettings.lineWrapping")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.mathPreviewOnHover,onChange:t=>l({...i,mathPreviewOnHover:t.target.checked})}),e.jsx(ue,{size:15}),e.jsx("span",{children:s("projectSettings.mathPreviewOnHover")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.mathPreviewOnHoverDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.spellCheck,onChange:t=>l({...i,spellCheck:t.target.checked})}),e.jsx("span",{children:s("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[s("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:i.vimMode,onChange:t=>l({...i,vimMode:t.target.checked})}),e.jsx("span",{children:s("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:s("projectSettings.vimHelp")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.openFilesInTabs,onChange:t=>l({...i,openFilesInTabs:t.target.checked})}),e.jsx(ye,{size:15}),e.jsx("span",{children:s("projectSettings.openFilesInTabs")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.openFilesInTabsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!W,checked:i.formatOnCompile,onChange:t=>l({...i,formatOnCompile:t.target.checked})}),e.jsx(he,{size:15}),e.jsx("span",{children:s("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[s(W?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",s("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:s("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:s("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:s("projectSettings.texFmtOptions")}),e.jsx(Ce,{compact:!0,name:"tex-fmt",state:R,label:s(`projectSettings.toolStatus.${R.status}`),reloadLabel:s("projectSettings.reloadTool"),onReload:te})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:i.texFmtConfig,placeholder:s("projectSettings.texFmtOptionsPlaceholder"),onChange:t=>l({...i,texFmtConfig:t.target.value})})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.texFmtOptionsDescription")})]}),o!==null&&e.jsxs("div",{className:`spell-check-result${o?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(ke,{size:14}),e.jsx("span",{children:o?s("projectSettings.writingIssues",{count:o,uniqueCount:Q??0}):s("projectSettings.noWritingIssues")}),o>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:s("projectSettings.spellCheckFirst"),"aria-label":s("projectSettings.spellCheckFirst"),disabled:h<=0,onClick:()=>C(0),children:e.jsx(ve,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckPrevious"),"aria-label":s("projectSettings.spellCheckPrevious"),disabled:h<=0,onClick:()=>C(h-1),children:e.jsx(be,{size:14})}),e.jsx("span",{className:"spell-check-position",children:s("projectSettings.spellCheckPosition",{current:Math.min(h+1,o),total:o})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckNext"),"aria-label":s("projectSettings.spellCheckNext"),disabled:h>=o-1,onClick:()=>C(h+1),children:e.jsx(je,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckLast"),"aria-label":s("projectSettings.spellCheckLast"),disabled:h>=o-1,onClick:()=>C(o-1),children:e.jsx(Se,{size:14})})]})]}),e.jsxs("div",{className:"settings-section-title",children:[e.jsx(ge,{size:15}),e.jsx("strong",{children:s("projectSettings.dictionary")})]}),e.jsx("p",{className:"settings-description",children:s("projectSettings.dictionaryDescription")}),H&&e.jsx("p",{className:"error dictionary-error",children:H}),q&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:E,placeholder:s("projectSettings.dictionaryPlaceholder"),onChange:t=>A(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),U())}}),e.jsx("button",{type:"button",disabled:!E.trim(),onClick:()=>{U()},children:s("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[N.map(t=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:t}),q&&e.jsx("button",{type:"button",title:s("common.delete"),"aria-label":`${s("common.delete")} ${t}`,onClick:()=>{ce(t)},children:e.jsx(B,{size:13})})]},t)),N.length===0&&e.jsx("span",{className:"dictionary-empty",children:s("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:J,children:[e.jsx(O,{size:15}),s("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(V,{size:15}),e.jsx("strong",{children:s("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:s("projectSettings.compilerDescription")}),e.jsxs("label",{children:[s("projects.name"),e.jsx("input",{disabled:!m,value:$,onChange:t=>I(t.target.value)})]}),e.jsxs("label",{children:[s("projectSettings.mainFile"),e.jsxs("select",{disabled:!m||v===null||v.length===0,value:b,onChange:t=>ee(t.target.value),children:[ie&&e.jsx("option",{value:b,disabled:!0,children:s("projectSettings.invalidMainFileOption",{path:b})}),se.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{children:[s("projectSettings.engine"),e.jsx("select",{disabled:!m,value:M,onChange:t=>Z(t.target.value),children:(d.allowedEngines??["pdflatex","xelatex","lualatex"]).map(t=>e.jsx("option",{children:t},t))})]}),e.jsxs("label",{children:[s("projectSettings.latexmkrc"),e.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!m||d.allowProjectLatexmkrc===!1,value:F,placeholder:s("projectSettings.latexmkrcPlaceholder"),onChange:t=>T(t.target.value)})]}),e.jsx("div",{className:"settings-actions",children:m&&e.jsxs("button",{className:"settings-save",onClick:()=>{_()},children:[e.jsx(O,{size:15}),s("projectSettings.saveCompiler")]})})]})]})]})}export{He as ProjectSettings};
1
+ import{u as le,r,j as e}from"./react-BVUjbTTn.js";import{c as j,f as x,g as S,b as oe}from"./index-C0t11tlT.js";import{k as f,p as pe,S as O,l as V,n as de,A as he,i as me,o as xe}from"./ProjectWorkspace-C6GrvKN6.js";import{X as B,C as je,c as ge}from"./x-Bq29njHL.js";import{T as K}from"./type-CE2DYkPH.js";import{S as ue}from"./sigma-Bk0_MzWi.js";import{C as be}from"./chevron-left-BB5MYb7g.js";import{R as X}from"./refresh-cw-Dvp3O90f.js";import"./check-BXvzrdoz.js";import"./search-b1ORp1k8.js";import"./user-plus-CKalKSsw.js";const ve=j("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Se=j("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const fe=j("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 ye=j("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 ke=j("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 Ne=j("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 Ce({name:y,state:n,label:c,reloadLabel:d,onReload:k,compact:N=!1}){const g=n.status==="loading"?e.jsx(oe,{className:"spin",size:14}):n.status==="working"?e.jsx(me,{size:14}):e.jsx(fe,{size:14}),u=e.jsxs(e.Fragment,{children:[g,e.jsx("strong",{children:y}),e.jsx("span",{children:c}),n.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:[e.jsx(X,{size:12}),d]})]});return N?e.jsxs("span",{className:`browser-tool-status compact ${n.status}`,role:"status","aria-live":"polite","aria-label":`${y}: ${c}`,title:n.error||void 0,children:[g,e.jsx("span",{children:c}),n.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:e.jsx(X,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${n.status}`,title:n.error||void 0,children:u})}function He({onClose:y,project:n,projectId:c,site:d,files:k,dictionaryWords:N,onDictionaryChange:g,editorPreferences:u,onEditorPreferences:G,spellCheckCount:o,spellCheckUniqueCount:Q,spellCheckIndex:h,onSpellCheckNavigate:C,onProject:Y}){const{t:s}=le(),[M,Z]=r.useState(n.engine),[F,T]=r.useState(""),[$,I]=r.useState(n.name),[b,ee]=r.useState(n.mainFile),[v,D]=r.useState(null),[P,z]=r.useState(""),[E,A]=r.useState(""),[H,w]=r.useState(""),[p,L]=r.useState("appearance"),[i,l]=r.useState(u),R=r.useSyncExternalStore(f.subscribe,f.getSnapshot,f.getSnapshot),m=n.permission==="owner",W=n.permission!=="read",q=n.permission!=="read";r.useEffect(()=>l(u),[u]),r.useEffect(()=>{pe().catch(f.failed)},[c]);const te=()=>{xe().catch(f.failed)};r.useEffect(()=>{if(!n.latexmkrc)return T("");x(`/api/projects/${c}/file?path=${encodeURIComponent(n.latexmkrc)}`).then(({content:t})=>T(t)).catch(t=>z(S(t)))},[n.latexmkrc]),r.useEffect(()=>{if(p!=="compiler")return;const t=new AbortController;return D(null),x(`/api/projects/${c}/main-files`,{signal:t.signal}).then(a=>D(a.mainFiles)).catch(a=>{a instanceof Error&&a.name==="AbortError"||z(S(a))}),()=>t.abort()},[c,k,p]);const se=v??[n.mainFile],ie=v!==null&&!v.includes(b),_=async()=>{try{const t=F.trim()&&d.allowProjectLatexmkrc!==!1?".latexmkrc":null;t&&await x(`/api/projects/${c}/file`,{method:"PUT",body:JSON.stringify({path:t,content:F})});const a=await x(`/api/projects/${c}`,{method:"PATCH",body:JSON.stringify({name:$,mainFile:b,engine:M,latexmkrc:t})});Y(a.project)}catch(t){z(S(t))}},J=()=>G(i),ne=()=>{if(p==="appearance")return J();m&&_()},ae=s(p==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),re=p==="appearance"||m,U=async()=>{const t=E.trim();if(t)try{const a=await x(`/api/projects/${c}/dictionary`,{method:"POST",body:JSON.stringify({word:t})});g(a.words),A(""),w("")}catch(a){w(S(a))}},ce=async t=>{try{const a=await x(`/api/projects/${c}/dictionary/${encodeURIComponent(t)}`,{method:"DELETE"});g(a.words),w("")}catch(a){w(S(a))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:s("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[re&&e.jsxs("button",{type:"button",className:"drawer-settings-save",onClick:ne,children:[e.jsx(O,{size:14}),e.jsx("span",{children:ae})]}),e.jsx("button",{type:"button","aria-label":s("common.close"),onClick:y,children:e.jsx(B,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[P&&e.jsx("p",{className:"error",children:P}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":s("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":p==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${p==="appearance"?" active":""}`,onClick:()=>L("appearance"),children:[e.jsx(K,{size:15}),s("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":p==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${p==="compiler"?" active":""}`,onClick:()=>L("compiler"),children:[e.jsx(V,{size:15}),s("projectSettings.compilerTab")]})]}),p==="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(K,{size:15}),e.jsx("strong",{children:s("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:s("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[s("projectSettings.fontFamily"),e.jsx("select",{value:i.font,onChange:t=>l({...i,font:t.target.value}),children:de.map(t=>e.jsx("option",{value:t.id,children:s(t.labelKey)},t.id))})]}),e.jsxs("label",{children:[s("projectSettings.fontSize"),e.jsx("select",{value:i.fontSize,onChange:t=>l({...i,fontSize:Number(t.target.value)}),children:[12,13,14,15,16,18,20].map(t=>e.jsxs("option",{value:t,children:[t," px"]},t))})]}),e.jsxs("label",{children:[s("projectSettings.lineHeight"),e.jsxs("select",{value:i.lineHeight,onChange:t=>l({...i,lineHeight:Number(t.target.value)}),children:[e.jsx("option",{value:1.45,children:s("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:s("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:s("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.lineWrapping,onChange:t=>l({...i,lineWrapping:t.target.checked})}),e.jsx(Ne,{size:15}),e.jsx("span",{children:s("projectSettings.lineWrapping")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.mathPreviewOnHover,onChange:t=>l({...i,mathPreviewOnHover:t.target.checked})}),e.jsx(ue,{size:15}),e.jsx("span",{children:s("projectSettings.mathPreviewOnHover")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.mathPreviewOnHoverDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.spellCheck,onChange:t=>l({...i,spellCheck:t.target.checked})}),e.jsx("span",{children:s("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[s("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:i.vimMode,onChange:t=>l({...i,vimMode:t.target.checked})}),e.jsx("span",{children:s("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:s("projectSettings.vimHelp")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.openFilesInTabs,onChange:t=>l({...i,openFilesInTabs:t.target.checked})}),e.jsx(ye,{size:15}),e.jsx("span",{children:s("projectSettings.openFilesInTabs")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.openFilesInTabsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!W,checked:i.formatOnCompile,onChange:t=>l({...i,formatOnCompile:t.target.checked})}),e.jsx(he,{size:15}),e.jsx("span",{children:s("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[s(W?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",s("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:s("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:s("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:s("projectSettings.texFmtOptions")}),e.jsx(Ce,{compact:!0,name:"tex-fmt",state:R,label:s(`projectSettings.toolStatus.${R.status}`),reloadLabel:s("projectSettings.reloadTool"),onReload:te})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:i.texFmtConfig,placeholder:s("projectSettings.texFmtOptionsPlaceholder"),onChange:t=>l({...i,texFmtConfig:t.target.value})})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.texFmtOptionsDescription")})]}),o!==null&&e.jsxs("div",{className:`spell-check-result${o?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(ke,{size:14}),e.jsx("span",{children:o?s("projectSettings.writingIssues",{count:o,uniqueCount:Q??0}):s("projectSettings.noWritingIssues")}),o>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:s("projectSettings.spellCheckFirst"),"aria-label":s("projectSettings.spellCheckFirst"),disabled:h<=0,onClick:()=>C(0),children:e.jsx(ve,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckPrevious"),"aria-label":s("projectSettings.spellCheckPrevious"),disabled:h<=0,onClick:()=>C(h-1),children:e.jsx(be,{size:14})}),e.jsx("span",{className:"spell-check-position",children:s("projectSettings.spellCheckPosition",{current:Math.min(h+1,o),total:o})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckNext"),"aria-label":s("projectSettings.spellCheckNext"),disabled:h>=o-1,onClick:()=>C(h+1),children:e.jsx(je,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckLast"),"aria-label":s("projectSettings.spellCheckLast"),disabled:h>=o-1,onClick:()=>C(o-1),children:e.jsx(Se,{size:14})})]})]}),e.jsxs("div",{className:"settings-section-title",children:[e.jsx(ge,{size:15}),e.jsx("strong",{children:s("projectSettings.dictionary")})]}),e.jsx("p",{className:"settings-description",children:s("projectSettings.dictionaryDescription")}),H&&e.jsx("p",{className:"error dictionary-error",children:H}),q&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:E,placeholder:s("projectSettings.dictionaryPlaceholder"),onChange:t=>A(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),U())}}),e.jsx("button",{type:"button",disabled:!E.trim(),onClick:()=>{U()},children:s("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[N.map(t=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:t}),q&&e.jsx("button",{type:"button",title:s("common.delete"),"aria-label":`${s("common.delete")} ${t}`,onClick:()=>{ce(t)},children:e.jsx(B,{size:13})})]},t)),N.length===0&&e.jsx("span",{className:"dictionary-empty",children:s("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:J,children:[e.jsx(O,{size:15}),s("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(V,{size:15}),e.jsx("strong",{children:s("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:s("projectSettings.compilerDescription")}),e.jsxs("label",{children:[s("projects.name"),e.jsx("input",{disabled:!m,value:$,onChange:t=>I(t.target.value)})]}),e.jsxs("label",{children:[s("projectSettings.mainFile"),e.jsxs("select",{disabled:!m||v===null||v.length===0,value:b,onChange:t=>ee(t.target.value),children:[ie&&e.jsx("option",{value:b,disabled:!0,children:s("projectSettings.invalidMainFileOption",{path:b})}),se.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{children:[s("projectSettings.engine"),e.jsx("select",{disabled:!m,value:M,onChange:t=>Z(t.target.value),children:(d.allowedEngines??["pdflatex","xelatex","lualatex"]).map(t=>e.jsx("option",{children:t},t))})]}),e.jsxs("label",{children:[s("projectSettings.latexmkrc"),e.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!m||d.allowProjectLatexmkrc===!1,value:F,placeholder:s("projectSettings.latexmkrcPlaceholder"),onChange:t=>T(t.target.value)})]}),e.jsx("div",{className:"settings-actions",children:m&&e.jsxs("button",{className:"settings-save",onClick:()=>{_()},children:[e.jsx(O,{size:15}),s("projectSettings.saveCompiler")]})})]})]})]})}export{He as ProjectSettings};