@scolladon/tsgit 2.0.0 → 3.0.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 (152) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/adapters/browser/index.cjs +1 -1
  3. package/dist/cjs/adapters/browser/index.cjs.map +1 -1
  4. package/dist/cjs/adapters/memory/index.cjs +1 -1
  5. package/dist/cjs/adapters/memory/index.cjs.map +1 -1
  6. package/dist/cjs/adapters/node/index.cjs +1 -1
  7. package/dist/cjs/adapters/node/index.cjs.map +1 -1
  8. package/dist/cjs/chunks/adapter-detect-D7DFJtuk.cjs +2 -0
  9. package/dist/cjs/chunks/adapter-detect-D7DFJtuk.cjs.map +1 -0
  10. package/dist/cjs/chunks/adler32-CrRRuL2P.cjs +2 -0
  11. package/dist/cjs/chunks/adler32-CrRRuL2P.cjs.map +1 -0
  12. package/dist/cjs/chunks/browser-http-transport-nGm6alox.cjs +2 -0
  13. package/dist/cjs/chunks/browser-http-transport-nGm6alox.cjs.map +1 -0
  14. package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
  15. package/dist/cjs/chunks/error-CA80UqXF.cjs +2 -0
  16. package/dist/cjs/chunks/error-CA80UqXF.cjs.map +1 -0
  17. package/dist/cjs/chunks/index-01WCH0eg.cjs +2 -0
  18. package/dist/cjs/chunks/index-01WCH0eg.cjs.map +1 -0
  19. package/dist/cjs/chunks/memory-http-transport-7hpDW8o3.cjs +2 -0
  20. package/dist/cjs/chunks/memory-http-transport-7hpDW8o3.cjs.map +1 -0
  21. package/dist/cjs/chunks/node-http-transport-CoqnAvIL.cjs +2 -0
  22. package/dist/cjs/chunks/node-http-transport-CoqnAvIL.cjs.map +1 -0
  23. package/dist/cjs/chunks/{progress-CxU62NC1.cjs → progress-CjhUeyxd.cjs} +2 -2
  24. package/dist/cjs/chunks/{progress-CxU62NC1.cjs.map → progress-CjhUeyxd.cjs.map} +1 -1
  25. package/dist/cjs/chunks/repository-DJNNrfQr.cjs +2 -0
  26. package/dist/cjs/chunks/repository-DJNNrfQr.cjs.map +1 -0
  27. package/dist/cjs/chunks/write-sparse-checkout-DzVubBcI.cjs +2 -0
  28. package/dist/cjs/chunks/write-sparse-checkout-DzVubBcI.cjs.map +1 -0
  29. package/dist/cjs/commands/index.cjs +1 -1
  30. package/dist/cjs/index.browser.cjs +1 -1
  31. package/dist/cjs/index.browser.cjs.map +1 -1
  32. package/dist/cjs/index.cjs +1 -1
  33. package/dist/cjs/index.cjs.map +1 -1
  34. package/dist/cjs/index.default.cjs +1 -1
  35. package/dist/cjs/index.default.cjs.map +1 -1
  36. package/dist/cjs/index.node.cjs +1 -1
  37. package/dist/cjs/index.node.cjs.map +1 -1
  38. package/dist/cjs/primitives/index.cjs +1 -1
  39. package/dist/cjs/primitives/index.cjs.map +1 -1
  40. package/dist/esm/adapters/browser/index.js +1 -1
  41. package/dist/esm/adapters/browser/index.js.map +1 -1
  42. package/dist/esm/adapters/memory/index.js +1 -1
  43. package/dist/esm/adapters/memory/index.js.map +1 -1
  44. package/dist/esm/adapters/node/index.js +1 -1
  45. package/dist/esm/adapters/node/index.js.map +1 -1
  46. package/dist/esm/chunks/adapter-detect-CTTG6hpk.js +2 -0
  47. package/dist/esm/chunks/adapter-detect-CTTG6hpk.js.map +1 -0
  48. package/dist/esm/chunks/adler32-BfvKJOAO.js +2 -0
  49. package/dist/esm/chunks/adler32-BfvKJOAO.js.map +1 -0
  50. package/dist/esm/chunks/browser-http-transport-DD0YKmIW.js +2 -0
  51. package/dist/esm/chunks/browser-http-transport-DD0YKmIW.js.map +1 -0
  52. package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
  53. package/dist/esm/chunks/error-BD0nFV6t.js +2 -0
  54. package/dist/esm/chunks/error-BD0nFV6t.js.map +1 -0
  55. package/dist/esm/chunks/index-BEI7XKaV.js +2 -0
  56. package/dist/esm/chunks/index-BEI7XKaV.js.map +1 -0
  57. package/dist/esm/chunks/memory-http-transport-D13LBPvu.js +2 -0
  58. package/dist/esm/chunks/memory-http-transport-D13LBPvu.js.map +1 -0
  59. package/dist/esm/chunks/node-http-transport-doU9Y8WN.js +2 -0
  60. package/dist/esm/chunks/node-http-transport-doU9Y8WN.js.map +1 -0
  61. package/dist/esm/chunks/{progress-BZobfl7p.js → progress-CLPpgZJ6.js} +2 -2
  62. package/dist/esm/chunks/{progress-BZobfl7p.js.map → progress-CLPpgZJ6.js.map} +1 -1
  63. package/dist/esm/chunks/repository-dCH3DdLQ.js +2 -0
  64. package/dist/esm/chunks/repository-dCH3DdLQ.js.map +1 -0
  65. package/dist/esm/chunks/write-sparse-checkout-D4tNUXOp.js +2 -0
  66. package/dist/esm/chunks/write-sparse-checkout-D4tNUXOp.js.map +1 -0
  67. package/dist/esm/commands/index.js +1 -1
  68. package/dist/esm/index.browser.js +1 -1
  69. package/dist/esm/index.browser.js.map +1 -1
  70. package/dist/esm/index.default.js +1 -1
  71. package/dist/esm/index.default.js.map +1 -1
  72. package/dist/esm/index.js +1 -1
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/index.node.js +1 -1
  75. package/dist/esm/index.node.js.map +1 -1
  76. package/dist/esm/primitives/index.js +1 -1
  77. package/dist/esm/primitives/index.js.map +1 -1
  78. package/dist/types/adapters/browser/index.d.cts +5 -3
  79. package/dist/types/adapters/browser/index.d.ts +5 -3
  80. package/dist/types/adapters/memory/index.d.cts +31 -4
  81. package/dist/types/adapters/memory/index.d.ts +31 -4
  82. package/dist/types/adapters/node/index.d.cts +53 -5
  83. package/dist/types/adapters/node/index.d.ts +53 -5
  84. package/dist/types/chunks/{context-CCL0_F8R.d.ts → context-CNtbFlwI.d.ts} +119 -6
  85. package/dist/types/chunks/{context-YDw6qicq.d.cts → context-D_A7-uau.d.cts} +119 -6
  86. package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
  87. package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
  88. package/dist/types/chunks/index-BJDekgCP.d.ts +1122 -0
  89. package/dist/types/chunks/index-CMLLVz9B.d.cts +1122 -0
  90. package/dist/types/chunks/index-E_KapqW9.d.ts +2439 -0
  91. package/dist/types/chunks/index-wwZiot4c.d.cts +2439 -0
  92. package/dist/types/chunks/progress-Cp-huK45.d.cts +1171 -0
  93. package/dist/types/chunks/progress-hcn9r2H3.d.ts +1171 -0
  94. package/dist/types/chunks/reflog-entry-BGJr9VfU.d.cts +688 -0
  95. package/dist/types/chunks/reflog-entry-DecZqJna.d.ts +688 -0
  96. package/dist/types/chunks/{repository-BeifCqp0.d.cts → repository-DASBgOb9.d.cts} +58 -20
  97. package/dist/types/chunks/{repository-FoS_Laoy.d.ts → repository-Dxhwpzd6.d.ts} +58 -20
  98. package/dist/types/commands/index.d.cts +4 -1259
  99. package/dist/types/commands/index.d.ts +4 -1259
  100. package/dist/types/index.browser.d.cts +7 -8
  101. package/dist/types/index.browser.d.ts +7 -8
  102. package/dist/types/index.d.cts +61 -124
  103. package/dist/types/index.d.ts +61 -124
  104. package/dist/types/index.default.d.cts +7 -8
  105. package/dist/types/index.default.d.ts +7 -8
  106. package/dist/types/index.node.d.cts +7 -8
  107. package/dist/types/index.node.d.ts +7 -8
  108. package/dist/types/primitives/index.d.cts +4 -692
  109. package/dist/types/primitives/index.d.ts +4 -692
  110. package/dist/types/transport/index.d.cts +1 -1
  111. package/dist/types/transport/index.d.ts +1 -1
  112. package/package.json +21 -21
  113. package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs +0 -2
  114. package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs.map +0 -1
  115. package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs +0 -2
  116. package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs.map +0 -1
  117. package/dist/cjs/chunks/error-CfjFO3x_.cjs +0 -2
  118. package/dist/cjs/chunks/error-CfjFO3x_.cjs.map +0 -1
  119. package/dist/cjs/chunks/index-BWCq_5BJ.cjs +0 -2
  120. package/dist/cjs/chunks/index-BWCq_5BJ.cjs.map +0 -1
  121. package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs +0 -2
  122. package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs.map +0 -1
  123. package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs +0 -2
  124. package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs.map +0 -1
  125. package/dist/cjs/chunks/repository-BEg2zNtx.cjs +0 -2
  126. package/dist/cjs/chunks/repository-BEg2zNtx.cjs.map +0 -1
  127. package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs +0 -2
  128. package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs.map +0 -1
  129. package/dist/esm/chunks/adapter-detect-DkZhhUhd.js +0 -2
  130. package/dist/esm/chunks/adapter-detect-DkZhhUhd.js.map +0 -1
  131. package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js +0 -2
  132. package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js.map +0 -1
  133. package/dist/esm/chunks/error-Dc-SRSJK.js +0 -2
  134. package/dist/esm/chunks/error-Dc-SRSJK.js.map +0 -1
  135. package/dist/esm/chunks/index-jH0UMhh-.js +0 -2
  136. package/dist/esm/chunks/index-jH0UMhh-.js.map +0 -1
  137. package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js +0 -2
  138. package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js.map +0 -1
  139. package/dist/esm/chunks/node-http-transport-DPa2lK3T.js +0 -2
  140. package/dist/esm/chunks/node-http-transport-DPa2lK3T.js.map +0 -1
  141. package/dist/esm/chunks/repository-DF6ePd1x.js +0 -2
  142. package/dist/esm/chunks/repository-DF6ePd1x.js.map +0 -1
  143. package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js +0 -2
  144. package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js.map +0 -1
  145. package/dist/types/chunks/index-entry-DtEbVpOG.d.cts +0 -47
  146. package/dist/types/chunks/index-entry-UD4dvtKh.d.ts +0 -47
  147. package/dist/types/chunks/progress-7KKiXXfX.d.ts +0 -405
  148. package/dist/types/chunks/progress-By8yFaUE.d.cts +0 -405
  149. package/dist/types/chunks/reflog-entry-BbNnXCTC.d.cts +0 -368
  150. package/dist/types/chunks/reflog-entry-CSzjnZd4.d.ts +0 -368
  151. package/dist/types/chunks/write-tree-C3oNxOlX.d.cts +0 -196
  152. package/dist/types/chunks/write-tree-DRI-LzSr.d.ts +0 -196
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-Dc-SRSJK.js","sources":["../../../src/domain/error.ts","../../../src/domain/commands/error.ts"],"sourcesContent":[null,null],"names":["TsgitError","Error","data","name","constructor","super","code","value","reason","basename","path","operation","statusCode","id","expected","actual","depth","count","limit","actualSize","chain","join","remaining","line","channel","message","resource","objectCount","paths","length","pattern","host","scheme","ref","local","remote","expression","candidates","branch","raw","option","runtime","size","requested","available","hook","exitCode","spec","observed","mtimeMs","current","previous","undefined","position","key","scope","source","destination","child","parent","index","stackSize","prefix","commit","String","extractDetail","this","segments","split","i","segment","dirname","slash","lastIndexOf","slice","fileNotFound","fileExists","notADirectory","directoryNotEmpty","permissionDenied","unsupportedOperation","hashFailed","compressFailed","decompressFailed","httpError","networkError","invalidWalkInput","operationAborted","snapshotRequired","workdirRace","orderInvariantViolation","sanitizeForDisplay","s","out","charCodeAt","toString","toUpperCase","padStart","sanitize","workingTreeDirty","pathspecNoMatch","pathspecOutsideRepo","nothingToCommit","emptyCommitMessage","authorUnconfigured","branchExists","branchNotFound","tagExists","tagNotFound","cannotDeleteCheckedOutBranch","invalidUrl","blockedHost","unsupportedScheme","targetDirectoryNotEmpty","remoteAdvertisesNoRefs","noPromisorRemote","nonFastForward","pushRejected","reportStatus","mergeHasConflicts","truncated","cappedPaths","checkoutOverwriteDirty","revparseUnresolved","emptyPathspec","operationInProgress","noOperationInProgress","remoteNotConfigured","noUpstreamConfigured","remoteExists","remoteNameInvalid","invalidOption","repositoryDisposed","adapterUnavailable","workingTreeFileTooLarge","gitignoreFileTooLarge","sparsePatternFileTooLarge","hookFailed","stderr","configKeyInvalid","configValueInvalid","configMultipleValues","configSectionNotFound","configScopeNotAvailable","configSystemPathUnresolved","mvSourceNotTracked","mvBadSource","mvDestinationExists","mvIntoSelf","mvDestinationNotDirectory","mvDestinationDirectoryMissing","mvMultipleSourcesSameTarget","mvOverlappingSources","rmStagedChanges","rmLocalModifications","rmStagedAndLocalChanges","noInitialCommit","stashNotFound","stashApplyWouldOverwrite","ambiguousOidPrefix","invalidSequencerTodo","cherryPickMergeNoMainline","revertMergeNoMainline"],"mappings":"AAuEM,MAAOA,UAAmBC,MAGTC,KAFHC,KAAO,aAEzB,WAAAC,CAAqBF,GACnBG,MAAM,GAAGH,EAAKI,SAgFlB,SAAuBJ,GACrB,OAAQA,EAAKI,MACX,IAAK,oBACL,IAAK,oBACH,OAAOJ,EAAKK,MACd,IAAK,wBACL,IAAK,qBACL,IAAK,iBACL,IAAK,cACL,IAAK,mBACL,IAAK,sBACL,IAAK,qBACL,IAAK,qBACL,IAAK,gBACL,IAAK,cACL,IAAK,sBACL,IAAK,uBACL,IAAK,sBACH,OAAOL,EAAKM,OACd,IAAK,iBACH,MAAO,mBAAmBC,EAASP,EAAKQ,QAC1C,IAAK,cACH,MAAO,wBAAwBD,EAASP,EAAKQ,QAC/C,IAAK,kBACH,MAAO,oBAAoBD,EAASP,EAAKQ,QAC3C,IAAK,sBACH,MAAO,wBAAwBD,EAASP,EAAKQ,QAC/C,IAAK,oBACH,MAAO,sBAAsBD,EAASP,EAAKQ,QAC7C,IAAK,wBACH,MAAO,0BAA0BR,EAAKS,cAAcT,EAAKM,SAC3D,IAAK,cACH,MAAO,4BAA4BN,EAAKM,SAC1C,IAAK,kBACH,MAAO,uBAAuBN,EAAKM,SACrC,IAAK,oBACH,MAAO,yBAAyBN,EAAKM,SACvC,IAAK,aACH,MAAO,QAAQN,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IAAIrC,EAAW,CAAEM,KAAM,uBAAwBwD,SAAQzB,eAI3D2H,GAAwBxJ,GACnC,IAAIR,EAAW,CAAEM,KAAM,yBAA0BE,OAAQmF,EAAmBnF,KAIjEyJ,GAA6BlG,GACxC,IAAI/D,EAAW,CAAEM,KAAM,gCAAiCyD,WAI7CmG,GAAyBnG,GACpC,IAAI/D,EAAW,CAAEM,KAAM,2BAA4ByD"}
@@ -1,2 +0,0 @@
1
- import{T as t,H as e,u as a,t as n,I as i,J as r,k as o,K as s,G as c,o as d,L as f,M as u,N as l,O as w,P as h,Q as m,R as p,S as g,U as y,V as v,W as k,X as b,z as $,Y as x,Z as E,_ as I,$ as D,a0 as T,a1 as M,C as S,a2 as H,a3 as A,a4 as N,a5 as O,a6 as L,a7 as U,a8 as P,a9 as C,aa as _,ab as R,ac as F,ad as W,ae as j,af as q,ag as B,ah as z,ai as V,aj as G,ak as X,al as Y,am as K,s as Z,an as J,ao as Q,ap as tt}from"./error-Dc-SRSJK.js";import{z as et,S as at,A as nt,B as it,C as rt,M as ot,D as st,F as ct,E as dt,G as ft,H as ut,I as lt,O as wt,J as ht,b as mt,u as pt,K as gt,f as yt,L as vt,N as kt,P as bt,Q as $t,m as xt,R as Et,T as It,U as Dt,e as Tt,V as Mt,j as St,W as Ht,X as At,c as Nt,a as Ot,Y as Lt,h as Ut,Z as Pt,y as Ct,p as _t,o as Rt,w as Ft,_ as Wt,$ as jt,a0 as qt,r as Bt,a1 as zt,a2 as Vt,a3 as Gt,a4 as Xt,a5 as Yt,a6 as Kt,a7 as Zt,a8 as Jt,a9 as Qt,aa as te,x as ee,l as ae,ab as ne,ac as ie,ad as re,ae as oe,af as se,ag as ce,ah as de,ai as fe,aj as ue,ak as le,n as we,g as he,al as me,am as pe,an as ge,ao as ye,ap as ve,aq as ke,ar as be,as as $e,at as xe,v as Ee,au as Ie,av as De,aw as Te,ax as Me,ay as Se,az as He,q as Ae,aA as Ne,aB as Oe,aC as Le,aD as Ue,aE as Pe,aF as Ce,aG as _e,aH as Re,aI as Fe,aJ as We,aK as je,aL as qe,aM as Be,aN as ze,aO as Ve,aP as Ge,aQ as Xe,aR as Ye,aS as Ke,aT as Ze,s as Je,aU as Qe,aV as ta,aW as ea,aX as aa,aY as na,aZ as ia,a_ as ra,a$ as oa,b0 as sa,b1 as ca,k as da,b2 as fa}from"./walk-submodules-Dq9oGwP8.js";import{withRetry as ua,withAuth as la,withLogging as wa}from"../transport/index.js";import{r as ha}from"./readable-stream-CGuf8k1J.js";const ma=e=>new t({code:"INVALID_DIFF_INPUT",reason:e}),pa=/[ \t\v\f\r]+$/,ga=t=>{const e=t.indexOf("\n");return-1===e?t:t.slice(0,e)};function ya(t){const e=[];return void 0!==t.baseId&&void 0!==t.baseMode&&e.push({id:t.baseId,mode:t.baseMode,stage:1}),void 0!==t.ourId&&void 0!==t.ourMode&&e.push({id:t.ourId,mode:t.ourMode,stage:2}),void 0!==t.theirId&&void 0!==t.theirMode&&e.push({id:t.theirId,mode:t.theirMode,stage:3}),e}function va(t,e,a){const n=a(e.mode);return{ctimeSeconds:n.ctimeSeconds,ctimeNanoseconds:n.ctimeNanoseconds,mtimeSeconds:n.mtimeSeconds,mtimeNanoseconds:n.mtimeNanoseconds,dev:n.dev,ino:n.ino,mode:e.mode,uid:n.uid,gid:n.gid,fileSize:n.fileSize,id:e.id,flags:{...at,stage:e.stage},path:t}}function ka(t,e){const a=new Set;for(const e of t){if(a.has(e.path))throw ma("duplicate conflict path");a.add(e.path)}const n=[];for(const a of t)for(const t of ya(a))n.push(va(a.path,t,e));return n.sort((t,e)=>{const a=et(t.path,e.path);return 0!==a?a:t.flags.stage-e.flags.stage}),n}const ba=1e5;function $a(t){const e=[];let a=0;for(let n=0;n<t.length;n++)10===t[n]&&(e.push(t.subarray(a,n+1)),a=n+1);return a<t.length&&e.push(t.subarray(a)),e}function xa(t){return function(t){const e=Math.min(t.length,8e3);for(let a=0;a<e;a++)if(0===t[a])return!0;return!1}(t)||function(t){let e=0,a=0;for(let n=0;n<t.length;n++){if(e++,e>=65536)return!0;if(10===t[n]){if(a++,a>=ba)return!0;e=0}}return e>0&&(a++,a>=ba)}(t)}function Ea(t,e){if(t.length!==e.length)return!1;for(let a=0;a<t.length;a++)if(t[a]!==e[a])return!1;return!0}function Ia(t,e,a,n){return n===-a||t[n-1+e]<t[n+1+e]}function Da(t,e,a,n,i,r){let o=Ia(a,n,i,r)?a[r+1+n]:a[r-1+n]+1,s=o-r;for(;o<t.length&&s<e.length&&Ea(t[o],e[s]);)o++,s++;return{x:o,y:s}}function Ta(t){const e=[];let a=0,n=0,i=0;for(;i<t.length;){const r=t[i],o=a,s=n;for(;t[i]===r;)"equal"===r?(a++,n++):"delete"===r?a++:n++,i++;e.push({kind:"equal"===r?"common":"delete"===r?"ours-only":"theirs-only",oursStart:o,oursEnd:a,theirsStart:s,theirsEnd:n})}return e}function Ma(t,e){const a=$a(t),n=$a(e),i=a.length,r=n.length;if(0===i&&0===r)return{hunks:[{kind:"common",oursStart:0,oursEnd:0,theirsStart:0,theirsEnd:0}],oursLines:a,theirsLines:n,degraded:!1};const o=function(t,e){const a=t.length,n=e.length;if(a+n>5e4)return;const i=a+n,r=i,o=new Array(2*i+1).fill(0),s=[],c=1e3*i;let d=0;for(let i=0;;i++){const f=2*i+1,u=new Array(f);for(let t=0;t<f;t++)u[t]=o[r-i+t];s.push(u);for(let f=-i;f<=i;f+=2){if(d++,d>c)return;const u=Da(t,e,o,r,i,f);if(o[f+r]=u.x,u.x>=a&&u.y>=n)return{trace:s,totalD:i}}}}(a,n);return void 0===o?function(t,e){const a=[];return t.length>0&&a.push({kind:"ours-only",oursStart:0,oursEnd:t.length,theirsStart:0,theirsEnd:0}),e.length>0&&a.push({kind:"theirs-only",oursStart:t.length,oursEnd:t.length,theirsStart:0,theirsEnd:e.length}),{hunks:a,oursLines:t,theirsLines:e,degraded:!0}}(a,n):{hunks:Ta(function(t,e,a){const n=[];let i=t,r=e;for(let t=a.length-1;t>0;t--){const e=a[t],o=t,s=i-r,c=Ia(e,o,t,s)?s+1:s-1,d=e[c+o],f=d-c;for(;i>d&&r>f;)n.push("equal"),i--,r--;n.push(i===d?"insert":"delete"),i===d?r--:i--}for(;i>0;)n.push("equal"),i--;return n.reverse(),n}(i,r,o.trace)),oursLines:a,theirsLines:n,degraded:!1}}const Sa="0000000",Ha={old:"a/",new:"b/"},Aa="\",Na=new TextDecoder("utf-8",{fatal:!1});function Oa(t,e){for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);if(10===n||13===n||0===n)throw ma(`${t} contains control character (code ${n}) at index ${a}`)}}function La(t,e){if(Oa("pathPrefix.old",e.old),Oa("pathPrefix.new",e.new),"rename"===t.type)return Oa("oldPath",t.oldPath),void Oa("newPath",t.newPath);"add"!==t.type?"delete"!==t.type?Oa("path",t.path):Oa("oldPath",t.oldPath):Oa("newPath",t.newPath)}function Ua(t){return void 0===t||0===t.length?{lines:[],hasTrailingNewline:!0}:{lines:$a(t).map(Pa),hasTrailingNewline:10===t[t.length-1]}}function Pa(t){return Na.decode(t.subarray(0,t.length>0&&10===t[t.length-1]?t.length-1:t.length))}function Ca(t){return t.slice(0,7)}function _a(t,e,a){return`diff --git ${a.old}${t} ${a.new}${e}`}function Ra(t,e,a,n){return`@@ -${1===e?`${t}`:`${t},${e}`} +${1===n?`${a}`:`${a},${n}`} @@`}function Fa(t,e,a){return"common"===t.kind?function(t,e){const a=[];for(let n=t.oursStart;n<t.oursEnd;n++)a.push({kind:"context",oldIndex:n,newIndex:t.theirsStart+(n-t.oursStart),text:e[n]});return a}(t,e):"ours-only"===t.kind?function(t,e){const a=[];for(let n=t.oursStart;n<t.oursEnd;n++)a.push({kind:"delete",oldIndex:n,newIndex:t.theirsStart,text:e[n]});return a}(t,e):function(t,e){const a=[];for(let n=t.theirsStart;n<t.theirsEnd;n++)a.push({kind:"insert",oldIndex:t.oursEnd,newIndex:n,text:e[n]});return a}(t,a)}function Wa(t,e){const a="insert"!==t.kind&&t.oldIndex===e.lastOldIdx&&e.lastOldIdx===e.oldTotal-1,n="delete"!==t.kind&&t.newIndex===e.lastNewIdx&&e.lastNewIdx===e.newTotal-1;return"context"===t.kind?a&&!e.oldHasTrailingNewline||n&&!e.newHasTrailingNewline:"delete"===t.kind?a&&!e.oldHasTrailingNewline:n&&!e.newHasTrailingNewline}function ja(t){return"context"===t?" ":"delete"===t?"-":"+"}function qa(t){const e=[];for(const a of t)e.push(`${ja(a.kind)}${a.text}`),a.trailingNoNewline&&e.push(Aa);return e}function Ba(t,e,a,n,i){const r=Ua(a),o=Ua(n),s=function(t,e,a,n){const i=Ma(a,n),r=[];for(const a of i.hunks)for(const n of Fa(a,t,e))r.push(n);return r}(r.lines,o.lines,a,n),c=function(t,e,a){if(0===t.length)return[];const n=function(t,e){const a=[];return t.forEach((t,n)=>{if("context"===t.kind)return;const i=a[a.length-1];void 0!==i&&n-i.last<=e?a[a.length-1]={first:i.first,last:n}:a.push({first:n,last:n})}),a}(t,2*e+1);return 0===n.length?[]:n.map(n=>function(t,e,a,n){const i=Math.max(0,t.first-a),r=Math.min(e.length,t.last+a+1),o=e.slice(i,r),s=function(t){let e=0,a=0,n=0,i=0,r=!1,o=!1,s=-1,c=-1;for(const d of t)"insert"!==d.kind&&(r||(e=d.oldIndex+1,r=!0),n++,s=d.oldIndex),"delete"!==d.kind&&(o||(a=d.newIndex+1,o=!0),i++,c=d.newIndex);return 0===n&&(e=t[0].oldIndex),0===i&&(a=t[0].newIndex),{oldStart:e,oldLen:n,newStart:a,newLen:i,lastOldIdx:s,lastNewIdx:c}}(o),c={...n,lastOldIdx:s.lastOldIdx,lastNewIdx:s.lastNewIdx},d=o.map(t=>({kind:t.kind,text:t.text,trailingNoNewline:Wa(t,c)}));return{oldStart:s.oldStart,oldLen:s.oldLen,newStart:s.newStart,newLen:s.newLen,body:d}}(n,t,e,a))}(s,i,{oldTotal:r.lines.length,newTotal:o.lines.length,oldHasTrailingNewline:r.hasTrailingNewline,newHasTrailingNewline:o.hasTrailingNewline}),d=[];d.push(`--- ${e.old}${t.path}`),d.push(`+++ ${e.new}${t.path}`);for(const t of c){d.push(Ra(t.oldStart,t.oldLen,t.newStart,t.newLen));for(const e of qa(t.body))d.push(e)}return d}function za(t,e,a){const n=t.change;return"add"===n.type?xa(t.newContent??new Uint8Array(0))?function(t,e){return[_a(t.newPath,t.newPath,e),`new file mode ${t.newMode}`,`index ${Sa}..${Ca(t.newId)}`,`Binary files /dev/null and ${e.new}${t.newPath} differ`]}(n,e):function(t,e,a){const n=Ua(e),i=[];if(i.push(_a(t.newPath,t.newPath,a)),i.push(`new file mode ${t.newMode}`),i.push(`index ${Sa}..${Ca(t.newId)}`),i.push("--- /dev/null"),i.push(`+++ ${a.new}${t.newPath}`),0===n.lines.length)return i;i.push(Ra(0,0,1,n.lines.length));for(const t of n.lines)i.push(`+${t}`);return n.hasTrailingNewline||i.push(Aa),i}(n,t.newContent,e):"delete"===n.type?xa(t.oldContent??new Uint8Array(0))?function(t,e){return[_a(t.oldPath,t.oldPath,e),`deleted file mode ${t.oldMode}`,`index ${Ca(t.oldId)}..${Sa}`,`Binary files ${e.old}${t.oldPath} and /dev/null differ`]}(n,e):function(t,e,a){const n=Ua(e),i=[];if(i.push(_a(t.oldPath,t.oldPath,a)),i.push(`deleted file mode ${t.oldMode}`),i.push(`index ${Ca(t.oldId)}..${Sa}`),i.push(`--- ${a.old}${t.oldPath}`),i.push("+++ /dev/null"),0===n.lines.length)return i;i.push(Ra(1,n.lines.length,0,0));for(const t of n.lines)i.push(`-${t}`);return n.hasTrailingNewline||i.push(Aa),i}(n,t.oldContent,e):"rename"===n.type?function(t,e){return[_a(t.oldPath,t.newPath,e),"similarity index 100%",`rename from ${t.oldPath}`,`rename to ${t.newPath}`]}(n,e):function(t,e,a,n,i){return function(t,e,a,n,i){const r=[];r.push(_a(t.path,t.path,e));for(const e of function(t){return t.oldMode===t.newMode?[`index ${Ca(t.oldId)}..${Ca(t.newId)} ${t.newMode}`]:[`old mode ${t.oldMode}`,`new mode ${t.newMode}`,`index ${Ca(t.oldId)}..${Ca(t.newId)}`]}(t))r.push(e);if(t.oldId===t.newId)return r;if(xa(a)||xa(n)){for(const i of function(t,e,a,n){return[`Binary files ${0===a.length?"/dev/null":`${e.old}${t.path}`} and ${0===n.length?"/dev/null":`${e.new}${t.path}`} differ`]}(t,e,a,n))r.push(i);return r}for(const o of Ba(t,e,a,n,i))r.push(o);return r}(function(t){return{path:t.path,oldId:t.oldId,newId:t.newId,oldMode:t.oldMode,newMode:t.newMode}}(t),n,e,a,i)}(n,t.oldContent??new Uint8Array(0),t.newContent??new Uint8Array(0),e,a)}function Va(t,e){const a=function(t){if(void 0===t)return 3;if(!Number.isInteger(t)||t<0)throw ma(`contextLines must be a non-negative integer; got ${t}`);return t}(e?.contextLines);if(0===t.length)return"";const n=e?.pathPrefix??Ha;for(const e of t)La(e.change,n);const i=[];for(const e of t){const t=za(e,n,a);for(const e of t)i.push(e)}return i.push(""),i.join("\n")}const Ga=t=>{const e=t.startsWith("!"),a=e?t.slice(1):t;return nt(a)?{pattern:t,body:a,negated:e,isLiteral:!1,compiled:it(a,{anchored:a.includes("/")})}:{pattern:t,body:a,negated:e,isLiteral:!0,compiled:it(a,{anchored:!0,withDirSuffix:!0})}},Xa=(t,e)=>{let a=!1;for(const n of t)n.compiled.test(e)&&(a=!n.negated);return a},Ya=e=>new t({code:"INVALID_MERGE_TREE",reason:e}),Ka=e=>new t({code:"INVALID_MERGE_INPUT",reason:e}),Za=268435456,Ja=["<<<<<<<","=======",">>>>>>>","|||||||"],Qa=new TextEncoder;function tn(t){return t<=31||t>=127&&t<=159}function en(t){return t>=8234&&t<=8238||t>=8294&&t<=8297||8203===t||8204===t||8205===t||8288===t||65279===t}function an(t,e){if(t.length>255)throw Ka(`conflict marker ${e} label exceeds maximum length`);if(""===t.trim())throw Ka(`conflict marker ${e} label is empty or whitespace-only`);if(function(t){for(let e=0;e<t.length;e++){const a=t.charCodeAt(e);if(tn(a)||en(a))return!0}return!1}(t))throw Ka(`conflict marker ${e} label contains forbidden control character`);if(function(t){for(const e of Ja)if(t.includes(e))return!0;return!1}(t))throw Ka(`conflict marker ${e} label contains forbidden marker substring`)}function nn(t){let e=0;for(const a of t)e+=a.length;return e}function rn(t){if(0===t.length)return new Uint8Array(0);const e=nn(t),a=t[t.length-1],n=0===a.length||10!==a[a.length-1],i=new Uint8Array(e+(n?1:0));let r=0;for(const e of t)i.set(e,r),r+=e.length;return n&&(i[r]=10),i}function on(t,e,a={}){if("diff3"===a.conflictStyle)throw Ka("diff3 conflict style requires base lines — not supported in v1");const n=a.labels?.ours??"ours",i=a.labels?.theirs??"theirs";if(an(n,"ours"),an(i,"theirs"),void 0!==a.labels?.base&&an(a.labels.base,"base"),nn(t)+nn(e)>Za)throw Ka("conflict output exceeds MAX_CONFLICT_OUTPUT_BYTES");const r=Qa.encode(`<<<<<<< ${n}\n`),o=Qa.encode("=======\n"),s=Qa.encode(`>>>>>>> ${i}\n`),c=rn(t),d=rn(e),f=new Uint8Array(r.length+c.length+o.length+d.length+s.length);let u=0;return f.set(r,u),u+=r.length,f.set(c,u),u+=c.length,f.set(o,u),u+=o.length,f.set(d,u),u+=d.length,f.set(s,u),f}function sn(t,e){if(t.length!==e.length)return!1;for(let a=0;a<t.length;a++)if(t[a]!==e[a])return!1;return!0}function cn(t,e){if(t.length!==e.length)return!1;for(let a=0;a<t.length;a++)if(!sn(t[a],e[a]))return!1;return!0}function dn(t){let e=0;for(const a of t)e+=a.length;const a=new Uint8Array(e);let n=0;for(const e of t)a.set(e,n),n+=e.length;return a}function fn(t,e){const a=[];let n;const i=()=>{void 0!==n&&(a.push({baseStart:n.baseStart,baseEnd:n.baseEnd,replacement:n.replacement}),n=void 0)};for(const a of t)if("common"!==a.kind)if(void 0===n&&(n={baseStart:a.oursStart,baseEnd:a.oursStart,replacement:[]}),"ours-only"===a.kind)n.baseEnd=Math.max(n.baseEnd,a.oursEnd);else for(let t=a.theirsStart;t<a.theirsEnd;t++)n.replacement.push(e[t]);else i();return i(),a}function un(t,e){return t.baseStart===t.baseEnd?e.baseStart===e.baseEnd?t.baseStart===e.baseStart:t.baseStart>=e.baseStart&&t.baseStart<e.baseEnd:e.baseStart===e.baseEnd?e.baseStart>=t.baseStart&&e.baseStart<t.baseEnd:t.baseStart<e.baseEnd&&e.baseStart<t.baseEnd}function ln(t,e){for(const a of e)if(a.baseStart===t.baseStart&&a.baseEnd===t.baseEnd&&cn(a.replacement,t.replacement))return a}function wn(t,e){for(const a of e)if(un(t,a))return!0;return!1}function hn(t,e,a){return{status:"conflict",conflictType:"content",markedBytes:on(t,e,a)}}function mn(t,e,a,n={}){if(xa(e)||xa(a)||void 0!==t&&xa(t))return{status:"conflict",conflictType:"binary",markedBytes:e};if(void 0===t)return sn(e,a)?{status:"clean",bytes:e}:hn($a(e),$a(a),n);if(sn(e,t))return{status:"clean",bytes:a};if(sn(a,t))return{status:"clean",bytes:e};if(sn(e,a))return{status:"clean",bytes:e};const i=Ma(t,e),r=Ma(t,a);if(i.degraded||r.degraded)return hn($a(e),$a(a),n);const o=function(t,e){const a=[],n=new Set;for(const i of t){const t=ln(i,e);if(void 0===t){if(wn(i,e))return;a.push(i)}else n.add(t),a.push(i)}for(const t of e)n.has(t)||a.push(t);return a.sort((t,e)=>t.baseStart-e.baseStart),{changes:a}}(fn(i.hunks,i.theirsLines),fn(r.hunks,r.theirsLines));if(void 0===o)return hn($a(e),$a(a),n);const s=function(t,e){const a=[];let n=0;for(const i of e.changes){for(let e=n;e<i.baseStart;e++)a.push(t[e]);for(const t of i.replacement)a.push(t);n=i.baseEnd}for(let e=n;e<t.length;e++)a.push(t[e]);return a}(i.oursLines,o);return{status:"clean",bytes:dn(s)}}function pn(t,e){return t.id===e.id&&t.mode===e.mode}function gn(t,e){if(void 0!==t&&t.entries.size>ot)throw Ya(`${e} FlatTree exceeds MAX_FLAT_TREE_ENTRIES`)}function yn(t){return{status:"conflict",conflict:t}}function vn(t,e,a,n){return yn({type:"modify-delete",path:t,baseId:e.id,baseMode:e.mode,...void 0===a?{}:{ourId:a.id,ourMode:a.mode},...void 0===n?{}:{theirId:n.id,theirMode:n.mode}})}function kn(t,e,a,n){return void 0===e?{status:"resolved-known",path:t,id:a.id,mode:a.mode}:pn(e,a)?{status:"resolved-deleted",path:t}:"our"===n?vn(t,e,a,void 0):vn(t,e,void 0,a)}function bn(t,e,a,n,i){return void 0===a&&void 0===n?{status:"resolved-deleted",path:t}:void 0===a?kn(t,e,n,"their"):void 0===n?kn(t,e,a,"our"):void 0===e?function(t,e,a){return pn(e,a)?{status:"resolved-known",path:t,id:e.id,mode:e.mode}:function(t,e,a){return yn({type:"add-add",path:t,ourId:e.id,theirId:a.id,ourMode:e.mode,theirMode:a.mode})}(t,e,a)}(t,a,n):async function(t,e,a,n,i){const r=pn(e,a),o=pn(e,n);if(r&&o)return{status:"unchanged",path:t,id:e.id,mode:e.mode};if(r)return{status:"resolved-known",path:t,id:n.id,mode:n.mode};if(o)return{status:"resolved-known",path:t,id:a.id,mode:a.mode};if(pn(a,n))return{status:"resolved-known",path:t,id:a.id,mode:a.mode};if(!st(a.mode,n.mode)||!st(e.mode,a.mode))return function(t,e,a,n){return yn({type:"type-change",path:t,baseId:e.id,ourId:a.id,theirId:n.id,baseMode:e.mode,ourMode:a.mode,theirMode:n.mode})}(t,e,a,n);const s=function(t,e,a){return e.mode===a.mode?e.mode:e.mode===t.mode?a.mode:e.mode}(e,a,n);return function(t){return t===ct.GITLINK}(s)?function(t,e,a,n){return yn({type:"gitlink",path:t,baseId:e.id,ourId:a.id,theirId:n.id,baseMode:e.mode,ourMode:a.mode,theirMode:n.mode})}(t,e,a,n):async function(t,e,a,n,i,r){const o={path:t,baseId:e.id,ourId:a.id,theirId:n.id,baseMode:e.mode,ourMode:a.mode,theirMode:n.mode},s=await r(o,void 0,new Uint8Array(0),new Uint8Array(0));if("clean"===s.status){if(s.bytes.length>Za)throw Ka("contentMerger returned oversize clean bytes");return void 0!==s.id?{status:"resolved-known",path:t,id:s.id,mode:i}:{status:"resolved-merged",path:t,bytes:s.bytes,mode:i}}if(s.markedBytes.length>Za)throw Ka("contentMerger returned oversize marked bytes");return yn({type:s.conflictType,path:t,baseId:e.id,ourId:a.id,theirId:n.id,baseMode:e.mode,ourMode:a.mode,theirMode:n.mode,conflictContent:s.markedBytes})}(t,e,a,n,s,i)}(t,e,a,n,i)}async function $n(t,e,a,n){gn(t,"base"),gn(e,"ours"),gn(a,"theirs");const i=function(t,e,a){const n=new Set;for(const i of[t,e,a])if(void 0!==i)for(const t of i.entries.keys())n.add(t);if(n.size>ot)throw Ya("union FlatTree exceeds MAX_FLAT_TREE_ENTRIES");return n}(t,e,a),r=rt([...i],t=>t),o=[];for(const i of r){const r=bn(i,t?.entries.get(i),e?.entries.get(i),a?.entries.get(i),n),s=r instanceof Promise?await r:r;o.push(s)}const s=function(t){const e=[];for(const a of t)"conflict"===a.status&&e.push(a.conflict);return e}(o);return{outcomes:o,conflicts:s,cleanMerge:0===s.length}}const xn="blob:limit=",En="tree:",In=/^(\d+)([kmg])?$/i,Dn=/^\d+$/,Tn=t=>{if(""===t)throw dt(t,"empty");if("blob:none"===t)return{kind:"blob-none"};if(t.startsWith(xn))return(t=>{const e=t.slice(11).match(In);if(null===e)throw dt(t,"bad-blob-limit");const a=Number(e[1])*(t=>{switch(t?.toLowerCase()){case"k":return 1024;case"m":return 1048576;case"g":return 1073741824;default:return 1}})(e[2]);if(!Number.isSafeInteger(a))throw dt(t,"bad-blob-limit");return{kind:"blob-limit",bytes:a}})(t);if(t.startsWith(En))return(t=>{const e=t.slice(5);if(!Dn.test(e))throw dt(t,"bad-tree-depth");const a=Number(e);if(!Number.isSafeInteger(a))throw dt(t,"bad-tree-depth");return{kind:"tree-depth",depth:a}})(t);throw dt(t,"unknown-kind")},Mn=t=>{switch(t.kind){case"blob-none":return"blob:none";case"blob-limit":return`${xn}${t.bytes}`;case"tree-depth":return`${En}${t.depth}`}},Sn=new TextDecoder("utf-8",{fatal:!1}),Hn=new TextEncoder,An=t=>t.endsWith("\n")?t.slice(0,-1):t,Nn=t=>{if(t.startsWith("ok "))return{name:t.slice(3),accepted:!0};if(t.startsWith("ng ")){const e=t.slice(3),a=e.indexOf(" ");if(a<0)throw lt(t);return{name:e.slice(0,a),accepted:!1,reason:e.slice(a+1)}}throw lt(t)},On=async t=>{const e=await(async t=>{const e=[];for await(const a of t){if("data"!==a.kind)return e;e.push(An(Sn.decode(a.payload)))}return e})(t);if(0===e.length)throw lt("");const[a,...n]=e,i=(t=>{if("unpack ok"===t)return{ok:!0};if(t.startsWith("unpack "))return{ok:!1,error:t.slice(7)};throw lt(t)})(a);return i.ok?{unpackOk:!0,refUpdates:n.map(Nn)}:{unpackOk:!1,unpackError:i.error,refUpdates:[]}},Ln={second:1,minute:60,hour:3600,day:86400,week:604800,month:2592e3,year:31536e3},Un=/^(\d{4})-(\d{2})-(\d{2})(?: (\d{2}):(\d{2}):(\d{2}))?$/,Pn=/^(\d+)[ .]([a-z]+?)s?(?:[ .]ago)?$/;function Cn(t,e){const a=t.trim().toLowerCase();return"now"===a?e:"yesterday"===a?e-86400:function(t){const e=Un.exec(t);if(null===e)return;const[,a,n,i,r,o,s]=e,c=Number(a),d=Number(n),f=Number(i),u=void 0===r?0:Number(r),l=void 0===o?0:Number(o),w=void 0===s?0:Number(s);if(d<1||d>12)return;if(f<1||f>function(t,e){return 2===e&&function(t){return t%4==0&&t%100!=0||t%400==0}(t)?29:_n[e-1]}(c,d))return;if(u>23)return;if(l>59)return;if(w>59)return;const h=new Date(c,d-1,f,u,l,w);return h.setFullYear(c),Math.floor(h.getTime()/1e3)}(a)??function(t,e){const a=Pn.exec(t);if(null===a)return;const[,n,i]=a,r=Ln[i];return void 0===r?void 0:e-Number(n)*r}(a,e)}const _n=[31,28,31,30,31,30,31,31,30,31,30,31],Rn=t=>[t,`refs/${t}`,`refs/tags/${t}`,`refs/heads/${t}`,`refs/remotes/${t}`,`refs/remotes/${t}/HEAD`],Fn=t=>`${t.layout.gitDir}/MERGE_HEAD`,Wn=t=>`${t.layout.gitDir}/MERGE_MSG`,jn=t=>`${t.layout.gitDir}/ORIG_HEAD`,qn=async(t,e)=>{await t.fs.writeUtf8(Wn(t),e)},Bn=async(t,e)=>{await t.fs.writeUtf8(jn(t),`${e}\n`)},zn=async t=>{const e=Fn(t);if(!await t.fs.exists(e))return;const a=(await t.fs.readUtf8(e)).trim();return 0!==a.length?wt.from(a):void 0},Vn=async t=>{const e=Wn(t);if(await t.fs.exists(e))return t.fs.readUtf8(e)},Gn=async t=>{for(const e of[Fn(t),Wn(t)])await t.fs.exists(e)&&await t.fs.rm(e)},Xn=async t=>{const e=Wn(t);await t.fs.exists(e)&&await t.fs.rm(e)},Yn=async(t,e)=>{const a=await ht(t),n=await mt(t,e);if("commit"!==n.type)throw pt("commit",n.type,e);const i=await gt(t);try{const e=await yt(t),r=await vt(t,{targetTree:n.data.tree,currentIndex:e,force:!0,forceRewriteAll:!0,...void 0!==a?{sparse:a}:{}});await i.commit(r.newIndexEntries)}finally{await i.release()}},Kn=async t=>{if(await kt(t),await bt(t,"merge --abort"),void 0===await zn(t))throw e("merge");const n=await(async t=>{const e=jn(t);if(!await t.fs.exists(e))return;const a=(await t.fs.readUtf8(e)).trim();return 0!==a.length?wt.from(a):void 0})(t);if(void 0===n)throw e("merge");const i=await $t(t);if("symbolic"!==i.kind)throw a("merge --abort","cannot abort with detached HEAD");return await Yn(t,n),await xt(t,i.target,n,{reflogMessage:"reset: moving to HEAD"}),await Gn(t),{origHead:n,branch:i.target}},Zn=Et,Jn=(t,e)=>`${t.layout.workDir}/${e}`,Qn=async(t,e)=>{const a=Zn(e),i=Jn(t,a);let r;try{r=await t.fs.lstat(i)}catch{throw n([a])}if(!r.isFile&&!r.isSymbolicLink)throw n([a]);await t.fs.rm(i)},ti=async(t,e,a)=>{const n=Zn(e),i=Zn(a);await ei(t,Jn(t,n),Jn(t,i))},ei=async(t,e,a)=>{const n=await t.fs.lstat(e);if(!n.isDirectory||n.isSymbolicLink)await t.fs.mkdir(i(a)),await t.fs.rename(e,a);else{for(const n of await t.fs.readdir(e))await ei(t,`${e}/${n.name}`,`${a}/${n.name}`);await t.fs.rmRecursive(e)}},ai=new TextEncoder,ni=t=>{for(const e of t){const t=e.startsWith("!")?e.slice(1):e;Zn(t),ii(e)}const e=(t=>t.map(Ga))(t),a=e.filter(si).map(t=>di(t)),n=e.some(ci);return{matcher:e,literalMustMatch:a,hasGlob:n}},ii=t=>{if(ai.encode(t).byteLength>256)throw o("paths","pattern exceeds max length 256 bytes");if(ri(t)>4)throw o("paths","pattern exceeds max **-token count 4")},ri=t=>{let e=0,a=0;for(;a<t.length;)"*"!==t[a]||"*"!==t[a+1]?a+=1:(e+=1,a+=2);return e},oi=(t,e)=>{if(0===t.length)return;const a=new Set(e);for(const n of t)if(!a.has(n)&&!e.some(t=>t.startsWith(`${n}/`)))throw r(n)},si=t=>!t.negated&&t.isLiteral,ci=t=>!t.negated&&!t.isLiteral,di=t=>t.body,fi=new Set(["FILE_NOT_FOUND","INVALID_INDEX_HEADER","INVALID_INDEX_ENTRY"]),ui=async(t,e,a={})=>{if(await kt(t),await bt(t,"add"),await It(t,{except:["merge","cherry-pick","revert","rebase"]}),!0===a.all){if(0!==e.length)throw o("all","pathspec must be empty when all=true");return pi(t,a)}if(0===e.length)throw s();return li(t,e,a)},li=async(t,e,a)=>{const{matcher:n,literalMustMatch:i,hasGlob:r}=ni(e);return!r&&await hi(t,i)?wi(t,i,a):mi(t,n,i,a)},wi=async(t,e,a)=>{const n=await gt(t,void 0!==a.breakStaleLockMs?{breakStaleLockMs:a.breakStaleLockMs}:{});try{const a=await ki(t),i=new Map(a),o=[],s=[];for(const n of e){const e=await bi(t,n);if("missing"===e)throw r(n);const c=a.get(n);i.set(n,e),void 0===c?o.push(n):c.id===e.id&&c.mode===e.mode||s.push(n)}return await n.commit(Array.from(i.values())),{added:o,modified:s,removed:[]}}finally{await n.release()}},hi=async(t,e)=>{if(0===e.length)return!1;for(const a of e){const e=await t.fs.lstat(`${t.layout.workDir}/${a}`).catch(()=>{});if(void 0===e)return!1;if(e.isDirectory&&!e.isSymbolicLink)return!1}return!0},mi=async(t,e,a,n)=>{const i=await Dt(t),r=async(t,a)=>!!await i(t,a)||!a&&!Xa(e,t),o=await gt(t,void 0!==n.breakStaleLockMs?{breakStaleLockMs:n.breakStaleLockMs}:{});try{const e=await ki(t),n=new Map(e),i=[],s=[],c=[],d=new Set;for await(const a of Tt(t,{ignore:r})){const r=await vi(t,a,e,d);void 0!==r&&(i.push(r.path),n.set(r.path,r.entry),"added"===r.kind?s.push(r.path):"modified"===r.kind&&c.push(r.path))}return oi(a,i),s.sort(),c.sort(),await o.commit(Array.from(n.values())),{added:s,modified:c,removed:[]}}finally{await o.release()}},pi=async(t,e,a)=>{const n=await Dt(t),i=await gt(t,void 0!==e.breakStaleLockMs?{breakStaleLockMs:e.breakStaleLockMs}:{});try{const e=await ki(t),a=new Map(e),r=new Set,o=[],s=[];for await(const i of Tt(t,{ignore:n})){const n=await vi(t,i,e,r);void 0!==n&&(a.set(n.path,n.entry),"added"===n.kind?o.push(n.path):"modified"===n.kind&&s.push(n.path))}const c=await gi(e,r,n);for(const t of c)a.delete(t);return o.sort(),s.sort(),c.sort(),await i.commit(Array.from(a.values())),{added:o,modified:s,removed:c}}finally{await i.release()}},gi=async(t,e,a)=>{const n=[];for(const[i,r]of t)e.has(i)||r.flags.skipWorktree||await yi(i,a)||n.push(i);return n},yi=async(t,e)=>{if(await e(t,!1))return!0;const a=t.split("/");for(let t=1;t<a.length;t+=1){const n=a.slice(0,t).join("/");if(await e(n,!0))return!0}return!1},vi=async(t,e,a,n)=>{const{path:i,stat:r}=e;if(n.add(i),r.size>Mt)throw c(i,r.size,Mt);const o=await $i(t,i,r),s=a.get(i);return void 0===s?{kind:"added",path:i,entry:o}:s.id!==o.id||s.mode!==o.mode?{kind:"modified",path:i,entry:o}:{kind:"unchanged",path:i,entry:o}},ki=async e=>{try{const t=await yt(e),a=new Map;for(const e of t.entries)a.set(e.path,e);return a}catch(e){if(e instanceof t&&fi.has(e.data.code))return new Map;throw e}},bi=async(t,e)=>{const a=await t.fs.lstat(`${t.layout.workDir}/${e}`).catch(()=>{});return void 0===a?"missing":$i(t,e,a)},$i=async(t,e,a)=>{const n=await t.fs.lstat(`${t.layout.workDir}/${e}`);if(n.isSymbolicLink!==a.isSymbolicLink||n.isDirectory!==a.isDirectory||n.isFile!==a.isFile)throw d();if(n.size>Mt)throw c(e,n.size,Mt);const i=Ht(n),r=await xi(t,e,n),o=await St(t,{type:"blob",id:"",content:r});return Ei(n,i,o,e)},xi=async(t,e,a)=>{if(a.isSymbolicLink){const a=(new TextEncoder).encode(await t.fs.readlink(`${t.layout.workDir}/${e}`));if(a.byteLength>Mt)throw c(e,a.byteLength,Mt);return a}return(async(t,e)=>{const a=Zn(e);return t.fs.read(Jn(t,a))})(t,e)},Ei=(t,e,a,n)=>({ctimeSeconds:Math.floor(t.ctimeMs/1e3),ctimeNanoseconds:0,mtimeSeconds:Math.floor(t.mtimeMs/1e3),mtimeNanoseconds:0,dev:t.dev,ino:t.ino,mode:e,uid:t.uid,gid:t.gid,fileSize:t.size,id:a,flags:at,path:n}),Ii="refs/heads/",Di=async t=>{await kt(t);const e=`${t.layout.gitDir}/refs/heads`;if(!await t.fs.exists(e))return{branches:[]};const a=await $t(t),n="symbolic"===a.kind&&a.target.startsWith(Ii)?a.target:void 0,i=await t.fs.readdir(e),r=[];for(const e of i){if(!e.isFile)continue;const a=`${Ii}${e.name}`,i=await Nt(t,a);r.push({name:a,id:i,current:a===n})}return r.sort((t,e)=>Ti(t.name,e.name)),{branches:r}},Ti=(t,e)=>t<e?-1:t>e?1:0,Mi=async(e,a)=>{await kt(e);const n=At(`${Ii}${a.name}`),i=a.startPoint??"HEAD",r=await Ai(e,i),o=`branch: Created from ${i}`;try{await xt(e,n,r,!0===a.force?{reflogMessage:o}:{expected:"absent",reflogMessage:o})}catch(e){if(e instanceof t&&"REF_UPDATE_CONFLICT"===e.data.code)throw f(n);throw e}return{name:n,id:r}},Si=async(t,e)=>{await kt(t);const a=At(`${Ii}${e.name}`),n=await $t(t);if("symbolic"===n.kind&&n.target===a)throw u(a);if(!await t.fs.exists(`${t.layout.gitDir}/${a}`))throw l(a);return await xt(t,a,Pt,{delete:!0}),{name:a}},Hi=async(e,a)=>{await kt(e);const n=At(`${Ii}${a.from}`),i=At(`${Ii}${a.to}`),r=await Nt(e,n),o=`branch: renamed ${n} to ${i}`,s=await Ot(e,n);try{await xt(e,i,r,!0===a.force?{reflogMessage:o}:{expected:"absent",reflogMessage:o})}catch(e){if(e instanceof t&&"REF_UPDATE_CONFLICT"===e.data.code)throw f(i);throw e}s.length>0&&await Lt(e,i,[...s,...await Ot(e,i)]),await xt(e,n,Pt,{delete:!0});const c=await $t(e);return"symbolic"===c.kind&&c.target===n&&await Ut(e,"HEAD",i),{from:n,to:i}},Ai=async(t,e)=>{if(/^[0-9a-f]{40}$/.test(e))return e;const a="HEAD"===e?["HEAD"]:[`${Ii}${e}`,e];for(const e of a)try{return await Nt(t,e)}catch{}throw l(e)},Ni=t=>"string"==typeof t?wt.from(t):t,Oi=async(t,e)=>{await kt(t);const a=e.ids.map(Ni),n=void 0===e.maxBytes?void 0:{maxBytes:e.maxBytes},i=[];for await(const e of Ct(t,a,n))i.push(e);return{kind:"batch",entries:i}},Li="refs/heads/",Ui="checkout:materialize",Pi=async(t,e)=>{if("HEAD"===e){const e=await Nt(t,"HEAD");return(await _t(t,e)).id}return(await _t(t,e)).id},Ci=async(t,e)=>{await kt(t),await bt(t,"checkout"),await It(t);const a=(t=>"target"in t&&void 0!==t.target)(e),n=(t=>"paths"in t&&void 0!==t.paths)(e);if(a&&n)throw o("paths","cannot be combined with target");if(!a&&!n)throw o("target","either target or paths must be provided");t.progress.start(Ui);try{return n?await(async(t,e)=>{if(0===e.paths.length)throw o("paths","must not be empty");const a=e.source??"index",{matcher:n,literalMustMatch:i}=ni(e.paths),r=(await(async(t,e)=>{if("index"===e)return(await yt(t)).entries.map(t=>t.path);const a=await Pi(t,e),n=[];for await(const e of Ft(t,a))e.mode!==ct.DIRECTORY&&n.push(e.path);return n})(t,a)).filter(t=>Xa(n,t));oi(i,r);const s=new Set(r);if(0===s.size)return{branch:void 0,id:await Nt(t,"HEAD"),detached:!1,changedPaths:0};const c="index"===a?await(async(t,e)=>{const a=await yt(t),n=await Wt(t,a.entries);return vt(t,{targetTree:n,currentIndex:a,force:!0,forceRewriteAll:!0,paths:e})})(t,s):await(async(t,e,a)=>{const n=await gt(t);try{const i=await yt(t),r=await vt(t,{targetTree:e,currentIndex:i,force:!0,forceRewriteAll:!0,paths:a});return await n.commit(r.newIndexEntries),r}finally{await n.release()}})(t,await Pi(t,a),s);return{branch:void 0,id:await Nt(t,"HEAD"),detached:!1,changedPaths:c.written+c.deleted}})(t,e):await(async(t,e)=>{const a=!0===e.detach||/^[0-9a-f]{40}$/.test(e.target),n=await $t(t),i=await Nt(t,"HEAD");let r,o;if(a)o=await(async(t,e)=>/^[0-9a-f]{40}$/.test(e)?e:Nt(t,e))(t,e.target);else{if(r=At(`${Li}${e.target}`),!await t.fs.exists(`${t.layout.gitDir}/${r}`))throw l(r);o=await Nt(t,r)}const s=await _t(t,o),c=await ht(t),d=await gt(t);let f;try{const a=await yt(t);f=await vt(t,{targetTree:s.id,currentIndex:a,force:e.force??!1,...void 0!==c?{sparse:c}:{}}),await d.commit(f.newIndexEntries)}finally{await d.release()}const u=(t=>{if("symbolic"!==t.kind)return t.id.slice(0,7);if(t.target.startsWith(Li))return t.target.slice(11);const e=t.target.lastIndexOf("/");return-1===e?t.target:t.target.slice(e+1)})(n);return a?(await t.fs.writeUtf8(`${t.layout.gitDir}/HEAD`,`${o}\n`),await Rt(t,"HEAD",i,o,`checkout: moving from ${u} to ${o.slice(0,7)}`),{branch:void 0,id:o,detached:!0,changedPaths:f.written+f.deleted}):(await Ut(t,"HEAD",r),await Rt(t,"HEAD",i,o,`checkout: moving from ${u} to ${e.target}`),{branch:r,id:o,detached:!1,changedPaths:f.written+f.deleted})})(t,e)}finally{t.progress.end(Ui)}},_i=t=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:t,uid:0,gid:0,fileSize:0}),Ri=(t,e,a)=>({..._i(a),id:e,flags:at,path:t}),Fi=async(t,e,a)=>{const n=`${t.layout.workDir}/${e}`,i=(t=>{const e=t.lastIndexOf("/");if(!(e<=0))return t.slice(0,e)})(n);void 0!==i&&await t.fs.mkdir(i),await t.fs.write(n,a)},Wi=async(t,e)=>{const a=`${t.layout.workDir}/${e}`;await t.fs.exists(a)&&await t.fs.rm(a)},ji=new Set(["rename-rename","gitlink"]),qi=t=>async e=>{const[a,n,i]=await Promise.all([Bt(t,e.ourId,{maxBytes:Za}),Bt(t,e.theirId,{maxBytes:Za}),void 0!==e.baseId?Bt(t,e.baseId,{maxBytes:Za}):Promise.resolve(void 0)]);return mn(i?.content,a.content,n.content)},Bi=(t,e)=>{if("unchanged"===t.status)return!1;if("resolved-known"===t.status){const a=e.get(t.path);return void 0===a||a.id!==t.id||a.mode!==t.mode}return"resolved-merged"===t.status||"resolved-deleted"===t.status&&e.has(t.path)},zi=async(t,e)=>{const a=[];for(const n of e)if("resolved-deleted"!==n.status&&"conflict"!==n.status){if("resolved-merged"===n.status){const e=await St(t,{type:"blob",content:n.bytes,id:""});a.push(Ri(n.path,e,n.mode));continue}a.push(Ri(n.path,n.id,n.mode))}return Wt(t,a)},Vi=async(t,e)=>{if("content"===e.type&&void 0!==e.conflictContent)return e.conflictContent;if("modify-delete"===e.type){const a=e.ourId??e.theirId;return void 0!==a?(await Bt(t,a,{maxBytes:Za})).content:void 0}return void 0!==e.ourId?(await Bt(t,e.ourId,{maxBytes:Za})).content:void 0},Gi=(t,e)=>{const a=[];for(const e of t)"unchanged"!==e.status&&"resolved-known"!==e.status||a.push(Ri(e.path,e.id,e.mode));const n=[...a,...ka(e,_i)];return n.sort((t,e)=>t.path<e.path?-1:t.path>e.path?1:t.flags.stage-e.flags.stage),n},Xi=async(t,e)=>{const[n,i,r]=await Promise.all([void 0!==e.baseTree?jt(t,e.baseTree):Promise.resolve(void 0),jt(t,e.oursTree),jt(t,e.theirsTree)]),o=await $n(n,i,r,qi(t));o.cleanMerge||(t=>{for(const e of t)if(ji.has(e.type))throw a("apply-merge",`conflict type '${e.type}' not supported (path=${e.path})`)})(o.conflicts);const s=((t,e,a)=>{const n=new Set;for(const e of t)"conflict"!==e.status&&Bi(e,a)&&n.add(e.path);for(const t of e)n.add(t.path);return n})(o.outcomes,o.conflicts,i.entries),c=await(async(t,e,a)=>{const n=new Map;for(const t of a.entries)0===t.flags.stage&&n.set(t.path,t);const i=[];for(const a of e){const e=n.get(a);void 0!==e?"modified"===await qt(t,e)&&i.push(a):await t.fs.exists(`${t.layout.workDir}/${a}`)&&i.push(a)}return i})(t,s,e.currentIndex);if(c.length>0)return{kind:"would-overwrite",paths:c};if(o.cleanMerge){const a=await zi(t,o.outcomes);return{kind:"clean",mergedTree:a,result:await vt(t,{targetTree:a,currentIndex:e.currentIndex,force:!0})}}return await(async(t,e,a,n)=>{for(const a of e)if("conflict"!==a.status&&n.has(a.path))if("resolved-deleted"!==a.status)if("resolved-merged"!==a.status){if("resolved-known"===a.status){const e=await Bt(t,a.id,{maxBytes:Za});await Fi(t,a.path,e.content)}}else await Fi(t,a.path,a.bytes);else await Wi(t,a.path);for(const e of a){const a=await Vi(t,e);void 0!==a&&await Fi(t,e.path,a)}})(t,o.outcomes,o.conflicts,s),{kind:"conflict",conflicts:o.conflicts,indexEntries:Gi(o.outcomes,o.conflicts)}},Yi=/^(pick|revert) (\S+) (.*)$/,Ki=/^[0-9a-f]{40}$/,Zi=/^[0-9a-f]{4,39}$/,Ji=/^[0-9a-f]{38}$/,Qi=async(t,e)=>{const a=zt(t.layout.gitDir,e.slice(0,2));if(!await t.fs.exists(a))return[];const n=e.slice(2),i=[];for(const r of await t.fs.readdir(a))r.isFile&&Ji.test(r.name)&&r.name.startsWith(n)&&i.push(e.slice(0,2)+r.name);return i},tr=async(t,e)=>{const a=await Vt(t).all(),n=[];for(const t of a)for(const a of Gt(t.index,e))n.push(a);return n},er=async(t,e)=>{if(Ki.test(e))return e;if(!Zi.test(e))return;const[a,n]=await Promise.all([Qi(t,e),tr(t,e)]),i=[...new Set([...a,...n])];if(0!==i.length){if(1===i.length)return i[0];throw h(e,i.slice(0,16))}},ar=async(t,e)=>{if(!await t.fs.exists(e))return;const a=(await t.fs.readUtf8(e)).trim();return 0!==a.length?wt.from(a):void 0},nr=t=>`${t.layout.gitDir}/sequencer`,ir=t=>`${nr(t)}/head`,rr=t=>`${nr(t)}/todo`,or=t=>`${nr(t)}/opts`,sr=(t,e)=>t.fs.writeUtf8(ir(t),`${e}\n`),cr=t=>ar(t,ir(t)),dr=(t,e)=>t.fs.writeUtf8((t=>`${nr(t)}/abort-safety`)(t),`${e}\n`),fr=(t,e)=>t.fs.writeUtf8(rr(t),(t=>t.map(t=>`${t.command} ${t.oid} ${t.subject}\n`).join(""))(e)),ur=async t=>{const e=rr(t);if(!await t.fs.exists(e))return;const a=(t=>{const e=[];for(const a of t.split("\n")){if(""===a||a.startsWith("#"))continue;const t=Yi.exec(a);if(null===t)throw w(a);e.push({command:t[1],oid:t[2],subject:t[3]})}return e})(await t.fs.readUtf8(e)),n=[];for(const e of a){const a=await er(t,e.oid);if(void 0===a)throw w(`cannot resolve commit ${e.oid}`);n.push({command:e.command,oid:a,subject:e.subject})}return n},lr=async(t,e)=>{(e.noCommit||e.recordOrigin||e.allowEmpty)&&await t.fs.writeUtf8(or(t),(t=>{let e="[options]\n";return t.noCommit&&(e+="\tno-commit = true\n"),t.recordOrigin&&(e+="\trecord-origin = true\n"),t.allowEmpty&&(e+="\tallow-empty = true\n"),e})(e))},wr=(t,e)=>t.some(t=>"options"===t.section.toLowerCase()&&t.entries.some(t=>t.key.toLowerCase()===e&&"true"===t.value.toLowerCase())),hr=async t=>{const e=nr(t);await t.fs.exists(e)&&await t.fs.rmRecursive(e)},mr=async(t,e)=>{await Yn(t,e.target),await xt(t,e.branch,e.target,{reflogMessage:`reset: moving to ${e.target}`}),await e.clearHead(t),await Xn(t),await hr(t)},pr=t=>`${t.layout.gitDir}/CHERRY_PICK_HEAD`,gr=t=>ar(t,pr(t)),yr=async t=>{const e=pr(t);await t.fs.exists(e)&&await t.fs.rm(e)},vr=(t,e)=>`${t.replace(/\s+$/,"")}\n\n# Conflicts:\n${e.map(t=>`#\t${t}\n`).join("")}`,kr=async(t,e,a)=>{const n=await jt(t,a),i=new Set(e.map(t=>t.path)),r=[];for(const t of e){const e=n.entries.get(t.path);void 0!==e&&e.id===t.id&&e.mode===t.mode||r.push(t.path)}for(const t of n.entries.keys())i.has(t)||r.push(t);return r},br=async(t,e)=>{const a=[];for(const n of e)n.flags.skipWorktree||"unchanged"!==await qt(t,n)&&a.push(n.path);return a},$r=async(t,e)=>{const{stage0:a,unmerged:n}=(t=>{const e=[],a=[];for(const n of t)0===n.flags.stage?e.push(n):a.push(n.path);return{stage0:e,unmerged:a}})((await yt(t)).entries),i=new Set([...n,...await kr(t,a,e),...await br(t,a)]);if(i.size>0)throw m([...i])},xr=async(t,e)=>{if(/^[0-9a-f]{40}$/.test(e))return e;for(const a of Rn(e))try{return await Nt(t,a,{peel:!0})}catch{}const a=await er(t,e);if(void 0!==a)return a;throw Yt(e)},Er=t=>{if(void 0!==t.explicit)return t.explicit;if(void 0!==t.configUser)return t.configUser;throw p()},Ir=t=>{if(void 0!==t.explicit)return t.explicit;if(void 0!==t.author)return t.author;if(void 0!==t.configUser)return t.configUser;throw p()},Dr=(t,e)=>{const a=(t=>{const e=[];for(const a of t.split("\n")){const t=a.replace(pa,"");(""!==t||0!==e.length&&""!==e[e.length-1])&&e.push(t)}return""===e[e.length-1]&&e.pop(),0===e.length?"":`${e.join("\n")}\n`})(t);if(""===a&&!e.allowEmpty)throw g();return a},Tr=t=>t.split("\n").filter(t=>!t.startsWith("#")).join("\n"),Mr=async t=>{const e=(await Kt(t)).user,a=void 0!==e?{name:e.name,email:e.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}:void 0;return Ir(void 0!==a?{configUser:a}:{})},Sr=async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);return a.data},Hr=async(t,e)=>(await Sr(t,e)).tree,Ar=async(t,e)=>{const n=await $t(t);if("symbolic"!==n.kind)throw a(e,"cannot run with detached HEAD");return n.target},Nr=new Set(["commit","tree","blob","tag"]),Or=/^:(\d):(.+)$/,Lr=/^[0-9a-f]{1,3}$/,Ur=t=>{throw y(t)},Pr=/^\d+$/,Cr=t=>{for(let e=0;e<t.length;e+=1){const a=t[e];if("~"===a||"^"===a)return e}return-1},_r=(t,e)=>{const a=[];let n=e;for(;n<t.length;){const e=t[n];if("~"===e){const e=Rr(t,n);a.push(e.op),n=e.next}else if("^"===e){const e=Fr(t,n);a.push(e.op),n=e.next}else Ur(t)}return a},Rr=(t,e)=>{let a=e+1;for(;a<t.length&&Wr(t.charCodeAt(a));)a+=1;return a===e+1&&Ur(t),{op:{kind:"ancestor",n:Number(t.slice(e+1,a))},next:a}},Fr=(t,e)=>{if("{"===t[e+1]){const a=t.indexOf("}",e+2);-1===a&&Ur(t);const n=t.slice(e+2,a);return Nr.has(n)||Ur(t),{op:{kind:"peel",target:n},next:a+1}}let a=e+1;for(;a<t.length&&Wr(t.charCodeAt(a));)a+=1;const n=t.slice(e+1,a);return{op:{kind:"parent",n:""===n?1:Number(n)},next:a}},Wr=t=>t>=48&&t<=57,jr=async(t,e)=>{await kt(t);const a=(""===(n=e)&&Ur(n),n.startsWith(":")?(t=>{const e=Or.exec(t);null===e&&Ur(t);const a=e[2],n=Number(e[1]);return n>3&&Ur(t),{kind:"index-stage",stage:n,path:a}})(n):n.includes("@{")?(t=>{const e=t.indexOf("@{"),a=t.indexOf("}",e+2),n=t.slice(0,e),i=t.slice(e+2,a);return""===i&&Ur(t),{kind:"ref-or-hex",base:n,reflog:Pr.test(i)?{kind:"index",n:Number(i)}:{kind:"date",raw:i},operations:_r(t.slice(a+1),0)}})(n):(t=>{const e=Cr(t),a=-1===e?t:t.slice(0,e);return""===a&&Ur(t),Lr.test(a)&&-1===e&&Ur(t),{kind:"ref-or-hex",base:a,operations:-1===e?[]:_r(t,e)}})(n));var n;return qr(t,a,e)},qr=async(t,e,a)=>{if("index-stage"===e.kind)return eo(t,e);const n=Math.floor(Date.now()/1e3);let i=void 0!==e.reflog?await zr(t,e.base,e.reflog,n,a):await Br(t,e.base);for(const a of e.operations)i=await Jr(t,i,a);return i},Br=async(t,e)=>{if(/^[0-9a-f]{40}$/.test(e))return wt.from(e);for(const a of Rn(e))try{return await Nt(t,a)}catch{}const a=await er(t,e);if(void 0!==a)return a;throw Zt(e)},zr=async(t,e,a,n,i)=>{const r=""===e?await Vr(t):await Gr(t,e),o=await Ot(t,r);if(0===o.length)throw y(i);return"index"===a.kind?Kr(o,a.n,r):Zr(o,a.raw,n,i)},Vr=async t=>{const e=await Jt(t).resolveDirect("HEAD");return"symbolic"===e.kind?e.target:"HEAD"},Gr=async(t,e)=>{const a=Xr(e),n=Rn(a);for(const e of n)if(await Qt(t,e))return e;for(const e of n)if(await Yr(t,e))return e;return a},Xr=t=>{try{return At(t)}catch{throw y(t)}},Yr=async(t,e)=>{try{return await Nt(t,e),!0}catch{return!1}},Kr=(t,e,a)=>{const n=t[t.length-1-e];if(void 0===n)throw te(a,e,t.length);return n.newId},Zr=(t,e,a,n)=>{const i=Cn(e,a);if(void 0===i)throw y(n);for(let e=t.length-1;e>=0;e-=1){const a=t[e];if(a.identity.timestamp<=i)return a.newId}return t[0].oldId},Jr=async(t,e,a)=>{if("parent"===a.kind)return Qr(t,e,a.n);if("ancestor"===a.kind){let n=e;for(let e=0;e<a.n;e+=1)n=await Qr(t,n,1);return n}return to(t,e,a.target)},Qr=async(t,e,a)=>{const n=await mt(t,e);if("commit"!==n.type)throw Zt(e);const i=n.data.parents[a-1];if(void 0===i)throw Zt(e);return i},to=async(t,e,a)=>{let n=e;for(let e=0;e<5;e+=1){const e=await mt(t,n);if(e.type===a)return n;if("tag"!==e.type){if("tree"===a&&"commit"===e.type)return e.data.tree;throw Zt(n)}n=e.data.object}throw Zt(n)},eo=async(t,e)=>{const a=await yt(t);for(const t of a.entries)if(t.path===e.path&&t.flags.stage===e.stage)return t.id;throw Zt(`${e.stage}:${e.path}`)},ao=t=>t.parents.length>=2,no=t=>t.map(t=>({path:t.path,type:t.type})),io=/^(.+)\.\.(.+)$/,ro=async(t,e,a)=>{const n=new Set;for await(const a of ae(t,{from:[e]}))n.add(a.id);const i=[];for await(const e of ae(t,{from:[a],until:[...n]}))i.push(e.id);return i.reverse()},oo=async(t,e,a,n,i)=>{await sr(t,e.sequenceHead),await fr(t,await(async(t,e)=>{const a=[];for(const n of e){const e=await Sr(t,n);a.push({command:"pick",oid:n,subject:ga(e.message)})}return a})(t,a)),await dr(t,n),await lr(t,{recordOrigin:i.recordOrigin,allowEmpty:i.allowEmpty,noCommit:!1})},so=async(t,e,a,n,i,r)=>{let o=n;const s=[];for(let n=0;n<e.length;n+=1){const c=e[n],d=await Sr(t,c);if(ao(d))throw r.multiPick&&await oo(t,r,e.slice(n),o,i),v(c);const f=await fo(t,c,d,a,o,i);if("committed"===f.kind){s.push({source:c,created:f.id}),o=f.id;continue}await uo(t,c,d,"conflict"===f.kind?f.conflicts:void 0,i),r.multiPick&&await oo(t,r,e.slice(n),o,i);const u=e.length-(n+1);return"conflict"===f.kind?{kind:"conflict",commit:c,conflicts:no(f.conflicts),remaining:u}:{kind:"empty",commit:c,remaining:u}}return await hr(t),{kind:"picked",commits:s}},co=(t,e,a)=>a?((t,e)=>`${t.replace(/\s+$/,"")}\n\n(cherry picked from commit ${e})`)(t,e):t,fo=async(t,e,a,n,i,r)=>{const o=a.parents[0],s=void 0!==o?await Hr(t,o):void 0,c=await Hr(t,i),d=await gt(t);try{const o=await yt(t),f=await Xi(t,{baseTree:s,oursTree:c,theirsTree:a.tree,currentIndex:o});if("would-overwrite"===f.kind)throw m(f.paths);if("conflict"===f.kind)return await d.commit(f.indexEntries),{kind:"conflict",conflicts:f.conflicts};if(f.mergedTree===c&&!r.allowEmpty)return{kind:"empty"};await d.commit(f.result.newIndexEntries);const u=await(async(t,e,a,n,i,r)=>{const o=await Mr(t);return ee(t,{tree:i,parents:[n],author:a.author,committer:o,message:Dr(co(a.message,e,r.recordOrigin),{allowEmpty:!1}),extraHeaders:[]})})(t,e,a,i,f.mergedTree,r);return await xt(t,n,u,{expected:i,reflogMessage:`cherry-pick: ${ga(a.message)}`}),{kind:"committed",id:u}}finally{await d.release()}},uo=async(t,e,a,n,i)=>{await(async(t,e)=>{await t.fs.writeUtf8(pr(t),`${e}\n`)})(t,e);const r=co(a.message,e,i.recordOrigin),o=void 0!==n&&n.length>0?vr(r,n.map(t=>t.path)):r;await qn(t,o)},lo=async(e,n)=>{await kt(e),await bt(e,"cherry-pick"),await It(e);const i=await $t(e);if("symbolic"!==i.kind)throw a("cherry-pick","cannot cherry-pick with detached HEAD");const r=await(async(e,a)=>{try{return await Nt(e,a)}catch(e){if(e instanceof t&&"REF_NOT_FOUND"===e.data.code)throw k();throw e}})(e,i.target),s=await(async(t,e)=>{const a=[];for(const n of e){if(n.includes("...")||n.includes("^"))throw o("commits",`unsupported revision form '${n}' (use a commit-ish or A..B)`);const e=io.exec(n);if(null===e){a.push(await xr(t,n));continue}const i=await jr(t,e[1]),r=await jr(t,e[2]);a.push(...await ro(t,i,r))}return a})(e,n.commits);return await $r(e,await Hr(e,r)),!0===n.noCommit?(async(t,e)=>{const a=await gt(t);try{let n=await yt(t);for(let i=0;i<e.length;i+=1){const r=e[i],o=await Sr(t,r);if(ao(o))throw v(r);const s=o.parents[0],c=void 0!==s?await Hr(t,s):void 0,d=await Wt(t,n.entries),f=await Xi(t,{baseTree:c,oursTree:d,theirsTree:o.tree,currentIndex:n});if("would-overwrite"===f.kind)throw m(f.paths);if("conflict"===f.kind)return await a.commit(f.indexEntries),{kind:"conflict",commit:r,conflicts:no(f.conflicts),remaining:e.length-(i+1)};n={...n,entries:f.result.newIndexEntries}}return await a.commit(n.entries),{kind:"no-commit",sources:e}}finally{await a.release()}})(e,s):so(e,s,i.target,r,{recordOrigin:n.recordOrigin??!1,allowEmpty:n.allowEmpty??!1},{multiPick:s.length>1,sequenceHead:r})},wo=async(t,e)=>{if(void 0!==await cr(t)){const e=await(async t=>{const e=or(t);if(!await t.fs.exists(e))return{recordOrigin:!1,allowEmpty:!1,noCommit:!1};const a=Xt(await t.fs.readUtf8(e));return{noCommit:wr(a,"no-commit"),recordOrigin:wr(a,"record-origin"),allowEmpty:wr(a,"allow-empty")}})(t);return{recordOrigin:e.recordOrigin,allowEmpty:e.allowEmpty}}return{recordOrigin:!1,allowEmpty:e.allowEmpty??!1}},ho=async(t,n={})=>{await kt(t),await bt(t,"cherry-pick --continue");const i=await gr(t),r=await ur(t);if(void 0===i&&(void 0===r||0===r.length))throw e("cherry-pick");const o=await $t(t);if("symbolic"!==o.kind)throw a("cherry-pick --continue","cannot continue with detached HEAD");const s=await wo(t,n);let c=await Nt(t,o.target);const d=[];if(void 0!==i){const e=void 0!==r?r.length-1:0,a=await(async(t,e,a,n,i)=>{const r=await yt(t);(t=>{const e=new Set;for(const a of t)0!==a.flags.stage&&e.add(a.path);if(e.size>0)throw b(e.size,[...e])})(r.entries);const o=await Wt(t,r.entries);if(o===await Hr(t,n)&&!i.allowEmpty)return{empty:!0};const s=await(async(t,e,a,n,i)=>{const r=await Sr(t,e),o=await Mr(t),s=Dr(Tr(await Vn(t)??""),{allowEmpty:!1}),c=await ee(t,{tree:i,parents:[a],author:r.author,committer:o,message:s,extraHeaders:[]});return await xt(t,n,c,{expected:a,reflogMessage:`commit (cherry-pick): ${ga(s)}`}),c})(t,e,n,a,o);return await yr(t),await Xn(t),{created:s}})(t,i,o.target,c,s);if("empty"in a)return{kind:"empty",commit:i,remaining:e};d.push({source:i,created:a.created}),c=a.created}const f=(r??[]).slice(void 0!==i?1:0).map(t=>t.oid);if(0===f.length)return await hr(t),{kind:"picked",commits:d};const u=await cr(t)??c,l=await so(t,f,o.target,c,s,{multiPick:!0,sequenceHead:u});return"picked"===l.kind?{kind:"picked",commits:[...d,...l.commits]}:l},mo=async(t,a={})=>{await kt(t),await bt(t,"cherry-pick --skip");const n=await gr(t),i=await ur(t);if(void 0===n&&(void 0===i||0===i.length))throw e("cherry-pick");const r=await Ar(t,"cherry-pick --skip"),o=await Nt(t,r),s=await wo(t,a);await Yn(t,o),await yr(t),await Xn(t);const c=(i??[]).slice(1).map(t=>t.oid);if(0===c.length)return await hr(t),{kind:"picked",commits:[]};const d=await cr(t)??o;return so(t,c,r,o,s,{multiPick:!0,sequenceHead:d})},po=async t=>{await kt(t),await bt(t,"cherry-pick --abort");const a=await gr(t),n=await cr(t);if(void 0===a&&void 0===n)throw e("cherry-pick");const i=await Ar(t,"cherry-pick --abort"),r=n??await Nt(t,i);return await mr(t,{branch:i,target:r,clearHead:yr}),{head:r,branch:i}},go=async(t,e)=>{const a=At(e.initialBranch),n=t.layout.gitDir;try{await t.fs.mkdir(n),await t.fs.writeUtf8(`${n}/HEAD`,`ref: refs/heads/${a}\n`),await t.fs.writeUtf8(`${n}/config`,(i=e.bare,`[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = ${i?"true":"false"}\n`)),await t.fs.mkdir(`${n}/refs/heads`),await t.fs.mkdir(`${n}/refs/tags`),await t.fs.mkdir(`${n}/objects/info`),await t.fs.mkdir(`${n}/objects/pack`),await t.fs.writeUtf8(`${n}/info/exclude`,"# git ls-files --others --exclude-from=.git/info/exclude\n# Lines that start with '#' are comments.\n# For a project mostly in C, the following would be a good set of\n# exclude patterns (uncomment them if you want to use them):\n# *.[oa]\n# *~\n"),await t.fs.writeUtf8(`${n}/description`,"Unnamed repository; edit this file 'description' to name the repository.\n")}catch(e){throw await t.fs.rmRecursive(n).catch(()=>{}),e}var i;return{gitDir:n,initialBranch:a,bare:e.bare}},yo={attempts:3,backoff:"exponential",baseMs:250,maxDelayMs:5e3},vo=(t,e={})=>{const a=void 0!==e.logger?ko(e.logger):void 0;let n=t.transport;return n=ua(e.retry??yo)(n),void 0!==e.auth&&(n=la(e.auth)(n)),void 0!==a&&(n=wa({logger:a})(n)),n},ko=t=>({log:e=>t.log(bo(e))}),bo=t=>"request"===t.kind||"response"===t.kind?{...t,url:xo(t.url),headers:$o(t.headers)}:{...t,url:xo(t.url),errorMessage:xo(t.errorMessage)},$o=t=>{const e={};for(const[a,n]of Object.entries(t))e[a]=xo(n);return e},xo=t=>{let e="";for(let a=0;a<t.length;a+=1){const n=t.charCodeAt(a);e+=9===n||10===n?t[a]:n<32||n>126?`\\x${n.toString(16).padStart(2,"0").toUpperCase()}`:t[a]}return e},Eo={"git-upload-pack":"application/x-git-upload-pack-advertisement","git-receive-pack":"application/x-git-receive-pack-advertisement"},Io=async(t,e,a,n)=>{const i=ne(a,n),r=await e.request({url:i,method:"GET",headers:{accept:Eo[n]},...void 0!==t.signal?{signal:t.signal}:{}});if(200!==r.statusCode)throw $(r.statusCode,`${n} discovery returned ${r.statusCode}`);const o=re(ha(r.body));return ie(o,n)},Do=async(t,e,a)=>Io(t,e,a,"git-upload-pack"),To=t=>{const e=ce.filter(t=>"multi_ack_detailed"!==t&&"thin-pack"!==t&&"no-progress"!==t&&t!==se);return[...oe(t,e),se]},Mo=t=>{const e=new Set,a=[];for(const n of t)e.has(n.id)||(e.add(n.id),a.push(n.id));return a},So=t=>t.includes("filter"),Ho=async(t,e)=>{Ao(t);const a=No(t);Oo(a,e.allowInsecure??!1),Lo(a);const n=await e.resolver(a.hostname);return{url:t,pinnedAddress:Uo(n,e.allowPrivateNetworks??!1)}},Ao=t=>{for(let e=0;e<t.length;e+=1){const a=t.charCodeAt(e);if(10===a||13===a)throw x("contains forbidden control character")}},No=t=>{try{return new URL(t)}catch{throw x("not a valid URL")}},Oo=(t,e)=>{const a=t.protocol;if("https:"!==a&&("http:"!==a||!e))throw E(a.replace(":",""))},Lo=t=>{if(""!==t.hash)throw x("URL fragment is not allowed")},Uo=(t,e)=>{for(const a of t)if(e||!Po(a))return a;if(0===t.length)throw I("<unresolved>","no DNS records returned");throw I(t[0],"all resolved addresses are in a blocked range")},Po=t=>t.includes(":")?_o(t):Co(t),Co=t=>{const e=(t=>{const e=t.split(".");if(4!==e.length)return;const a=[];for(const t of e){if(!/^\d{1,3}$/.test(t))return;const e=Number(t);if(e>255)return;a.push(e)}return a})(t);if(void 0===e)return!1;const[a,n]=e;return 0===a||10===a||100===a&&n>=64&&n<=127||127===a||169===a&&254===n||172===a&&n>=16&&n<=31||192===a&&168===n||a>=224},_o=t=>{const e=t.toLowerCase(),a=e.match(/::ffff:(?:0:)?(\d+\.\d+\.\d+\.\d+)$/);if(void 0!==a?.[1])return Co(a[1]);const n=e.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);if(void 0!==n?.[1]&&void 0!==n[2]){const t=parseInt(n[1],16),e=parseInt(n[2],16);return Co(`${t>>8}.${255&t}.${e>>8}.${255&e}`)}return!!("::1"===e||"::"===e||e.startsWith("fe80:")||e.startsWith("fe80::")||e.startsWith("ff")||e.startsWith("fc")||e.startsWith("fd"))},Ro="clone:discover",Fo=async(t,e)=>{if(await t.fs.exists(`${t.layout.gitDir}/HEAD`))throw D(t.layout.workDir);if(""===e.url)throw T();const a=void 0!==e.filter?Mn(Tn(e.filter)):void 0;t.progress.start(Ro);try{void 0!==e.resolver&&await Ho(e.url,{resolver:e.resolver,...void 0!==e.allowInsecure?{allowInsecure:e.allowInsecure}:{},...void 0!==e.allowPrivateNetworks?{allowPrivateNetworks:e.allowPrivateNetworks}:{}});const n=await go(t,{initialBranch:e.initialBranch??"main",bare:e.bare??!1});try{return await Wo(t,e,n.gitDir,a)}catch(e){throw await t.fs.rmRecursive(t.layout.gitDir).catch(()=>{}),e}}finally{t.progress.end(Ro)}},Wo=async(t,e,a,n)=>{const i=vo(t,{...void 0!==t.config?.auth?{auth:t.config.auth}:{}}),r=await Do(t,i,e.url);if(0===r.refs.length)throw T();if(void 0!==n&&!So(r.capabilities))throw de();const o=To(r.capabilities),s=Mo(r.refs),c=await fe(t,i,{wants:s,haves:[],capabilities:o,url:e.url,progressOp:"clone:write-objects",...void 0!==e.depth?{depth:e.depth}:{},...void 0!==n?{filter:n,promisor:!0}:{}});c.shallow.length>0&&await ue(t,{shallow:c.shallow,unshallow:c.unshallow});const d=await qo(t,r,e.url),f=await Vo(t,r,e.url);return await jo(t,e.url,zo(r),n),{path:a,head:f,fetchedRefs:d}},jo=async(t,e,a,n)=>{await le(t,[{section:"remote",subsection:"origin",key:"url",value:e},{section:"remote",subsection:"origin",key:"fetch",value:"+refs/heads/*:refs/remotes/origin/*"},...void 0!==a?[{section:"branch",subsection:a,key:"remote",value:"origin"},{section:"branch",subsection:a,key:"merge",value:`refs/heads/${a}`}]:[],...void 0!==n?[{section:"core",key:"repositoryformatversion",value:"1"},{section:"remote",subsection:"origin",key:"promisor",value:"true"},{section:"remote",subsection:"origin",key:"partialclonefilter",value:n},{section:"extensions",key:"partialClone",value:"origin"}]:[]])},qo=async(t,e,a)=>{const n=zo(e),i=[];for(const r of e.refs)if("HEAD"!==r.name){if(r.name.startsWith("refs/heads/")){const e=r.name.slice(11),o=`refs/remotes/origin/${e}`;if(await Bo(t,o,r.id,a),i.push({name:o,id:r.id}),void 0!==n&&e===n){const e=r.name;await Bo(t,e,r.id,a),i.push({name:e,id:r.id})}continue}if(r.name.startsWith("refs/tags/")){const e=r.name;await Bo(t,e,r.id,a),i.push({name:e,id:r.id});continue}t.logger?.debug?.("clone: skipping unsupported ref namespace",{name:r.name})}return i},Bo=async(t,e,a,n)=>{const i=`${t.layout.gitDir}/${e}`;await t.fs.writeUtf8(i,`${a}\n`),await Rt(t,e,Pt,a,`clone: from ${n}`)},zo=t=>{const e=t.capabilities.find(t=>t.startsWith("symref=HEAD:refs/heads/"));if(void 0!==e)return e.slice(23)},Vo=async(t,e,a)=>{const n=zo(e),i=e.head?.id;if(void 0!==n){const e=`refs/heads/${n}`;return await t.fs.writeUtf8(`${t.layout.gitDir}/HEAD`,`ref: ${e}\n`),await Go(t,i,a),e}if(void 0!==e.head)return await t.fs.writeUtf8(`${t.layout.gitDir}/HEAD`,`${e.head.id}\n`),void await Go(t,i,a)},Go=async(t,e,a)=>{void 0!==e&&await Rt(t,"HEAD",Pt,e,`clone: from ${a}`)},Xo=t=>`${t.layout.gitDir}/REVERT_HEAD`,Yo=t=>ar(t,Xo(t)),Ko=async t=>{const e=Xo(t);await t.fs.exists(e)&&await t.fs.rm(e)},Zo=(t,e)=>{return`Revert ${a=ga(t.message),`"${a.replace(/([\\"])/g,"\\$1")}"`}\n\nThis reverts commit ${e}.\n`;var a},Jo=async(t,e)=>{await kt(t),await bt(t,"commit");const a=await Qo(t),{mergeHead:n,cherryPickHead:i,revertHead:r}=a,o=ts(a);await It(t,void 0!==o?{except:o}:{});const s=e.noVerify??!1;await(async(t,e)=>{e||await we(t,"pre-commit")})(t,s);const c=await as(t,e,void 0!==n||void 0!==i||void 0!==r),d=await Kt(t),f=os(d.user),u=Er(ss(e.author,f)),l=Ir(cs(e.committer,u,f)),w=await yt(t);rs(w.entries);const h=await us(t,w.entries),m=await $t(t),p="symbolic"===m.kind?await ds(t,m.target):m.id,g=is(p,n);if(!e.allowEmpty&&void 0!==p&&void 0===n&&await fs(t,p)===h)throw M();const y=await(async(t,e,a)=>{if(a.noVerify||void 0===t.hooks)return e;const n=`${t.layout.gitDir}/COMMIT_EDITMSG`;await t.fs.writeUtf8(n,e),await we(t,"commit-msg",{args:[n]});const i=await t.fs.readUtf8(n);return Dr(i,{allowEmpty:a.allowEmptyMessage})})(t,c,{noVerify:s,allowEmptyMessage:e.allowEmptyMessage??!1}),v={tree:h,parents:g,author:u,committer:l,message:y,extraHeaders:[]},k=await ee(t,v),b="symbolic"===m.kind?m.target:void 0,$=ns(y,p,n,i);return void 0!==b?await xt(t,b,k,void 0!==p?{expected:p,reflogMessage:$}:{reflogMessage:$}):(await t.fs.writeUtf8(`${t.layout.gitDir}/HEAD`,`${k}\n`),await Rt(t,"HEAD",p??Pt,k,$)),await es(t,a),{id:k,tree:h,branch:b,parents:g}},Qo=async t=>({mergeHead:await zn(t),cherryPickHead:await gr(t),revertHead:await Yo(t)}),ts=t=>void 0!==t.mergeHead?"merge":void 0!==t.cherryPickHead?"cherry-pick":void 0!==t.revertHead?"revert":void 0,es=async(t,e)=>{if(void 0===e.mergeHead)return void 0!==e.cherryPickHead?(await yr(t),void await Xn(t)):void(void 0!==e.revertHead&&(await Ko(t),await Xn(t)));await Gn(t)},as=async(t,e,a)=>{if(e.message.length>0||!a)return Dr(e.message,{allowEmpty:e.allowEmptyMessage??!1});const n=await Vn(t);return Dr(Tr(n??""),{allowEmpty:e.allowEmptyMessage??!1})},ns=(t,e,a,n)=>{const i=ga(t);return void 0===e?`commit (initial): ${i}`:void 0!==a?`commit (merge): ${i}`:void 0!==n?`commit (cherry-pick): ${i}`:`commit: ${i}`},is=(t,e)=>{const a=[];return void 0!==t&&a.push(t),void 0!==e&&a.push(e),a},rs=t=>{const e=new Set;for(const a of t)0!==a.flags.stage&&e.add(a.path);if(e.size>0)throw b(e.size,[...e])},os=t=>{if(void 0!==t)return{name:t.name,email:t.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}},ss=(t,e)=>{const a={};return void 0!==t&&(a.explicit=t),void 0!==e&&(a.configUser=e),a},cs=(t,e,a)=>{const n={};return void 0!==t&&(n.explicit=t),void 0!==e&&(n.author=e),void 0!==a&&(n.configUser=a),n},ds=async(t,e)=>{try{return await Nt(t,e)}catch{return}},fs=async(t,e)=>{const a=await mt(t,e);return"commit"!==a.type?Pt:a.data.tree},us=async(t,e)=>{const a={files:new Map,subdirs:new Map};for(const t of e)ls(a,t.path.split("/"),t);return ws(t,a)},ls=(t,e,a)=>{if(1===e.length)return void t.files.set(e[0],{id:a.id,mode:a.mode});const[n,...i]=e,r=n;let o=t.subdirs.get(r);void 0===o&&(o={files:new Map,subdirs:new Map},t.subdirs.set(r,o)),ls(o,i,a)},ws=async(t,e)=>{const a=[];for(const[t,n]of e.files)a.push({mode:n.mode,name:t,id:n.id});const n=await Promise.all(Array.from(e.subdirs).map(async([e,a])=>({name:e,id:await ws(t,a)})));for(const{name:t,id:e}of n)a.push({mode:"40000",name:t,id:e});return he(t,a)},hs=t=>t,ms=async(t,e)=>(await kt(t),void 0===e.scope?await me({ctx:t,key:e.key}):await me({ctx:t,key:e.key,scope:e.scope})),ps=async(t,e)=>(await kt(t),void 0===e.scope?await pe({ctx:t,key:e.key}):await pe({ctx:t,key:e.key,scope:e.scope})),gs=async(t,e)=>{await kt(t);const a=void 0===e.scope?await ge({ctx:t}):await ge({ctx:t,scope:e.scope}),n=[];for(const{scope:t,section:i}of a)for(const a of i.entries){const r=ye(i,a.key);e.keyPattern.test(r)&&(void 0===e.valuePattern||e.valuePattern.test(a.value))&&n.push({key:hs(r),value:a.value,scope:t})}return{entries:n}},ys=async(t,e)=>{await kt(t);const a=void 0===e?.scope?await ge({ctx:t}):await ge({ctx:t,scope:e.scope}),n=[];for(const{scope:t,section:e}of a)for(const a of e.entries){const i=ye(e,a.key);n.push({key:hs(i),value:a.value,scope:t})}return{entries:n}},vs=async(t,e)=>{await kt(t);const a=e.scope??"local",n=await pe({ctx:t,key:e.key,scope:a});if(n.values.length>1)throw S(e.key,n.values.length,"overwrite",a);return await be({ctx:t,key:e.key,value:e.value,scope:a}),{key:e.key,value:e.value,scope:a}},ks=async(t,e)=>{await kt(t);const a=e.scope??"local",n=await pe({ctx:t,key:e.key,scope:a});if(0===n.values.length)return{key:e.key,scope:a,removed:!1};if(n.values.length>1)throw S(e.key,n.values.length,"remove",a);const[i]=n.values;return await $e({ctx:t,key:e.key,scope:a}),{key:e.key,scope:a,removed:!0,previousValue:i.value}},bs=async(t,e)=>{await kt(t);const a=e.scope??"local",n=await pe({ctx:t,key:e.key,scope:a});return 0===n.values.length?{key:e.key,scope:a,removed:0}:(await xe({ctx:t,key:e.key,scope:a}),{key:e.key,scope:a,removed:n.values.length})},$s=async(t,e)=>{await kt(t);const a=e.scope??"local";return await ke({ctx:t,oldName:e.oldName,newName:e.newName,scope:a}),{oldName:e.oldName,newName:e.newName,scope:a}},xs=async(t,e)=>{await kt(t);const a=e.scope??"local";return await ve({ctx:t,sectionName:e.name,scope:a}),{name:e.name,scope:a}},Es=async(t,a={})=>{if(await kt(t),await bt(t,"merge --continue"),void 0===await zn(t))throw e("merge");return Jo(t,Is(a))},Is=t=>({message:t.message??"",...void 0!==t.author&&{author:t.author},...void 0!==t.committer&&{committer:t.committer},...void 0!==t.noVerify&&{noVerify:t.noVerify}});async function Ds(t,e){const a=new Array(e.length);let n=0;const i=async()=>{for(;n<e.length;){const i=n++,r=e[i];a[i]=await Ts(t,r)}},r=Math.min(32,e.length),o=[];for(let t=0;t<r;t++)o.push(i());return await Promise.all(o),a.map(t=>t)}async function Ts(t,e){if("add"===e.type)return{change:e,newContent:(await Bt(t,e.newId)).content};if("delete"===e.type)return{change:e,oldContent:(await Bt(t,e.oldId)).content};if("rename"===e.type)return{change:e};if(e.oldId===e.newId){const a=await Bt(t,e.oldId);return{change:e,oldContent:a.content,newContent:a.content}}const[a,n]=await Promise.all([Bt(t,e.oldId),Bt(t,e.newId)]);return{change:e,oldContent:a.content,newContent:n.content}}async function Ms(t,e={}){await kt(t);const a=await Ss(t,e.from??"HEAD"),n=void 0!==e.to?await Ss(t,e.to):void 0,i=await Ee(t,a,n,!0===e.detectRenames?{detectRenames:!0}:{});if("patch"!==e.format)return i;const r=Va(await Ds(t,i.changes),function(t){const e={};return void 0!==t.contextLines&&(e.contextLines=t.contextLines),void 0!==t.pathPrefix&&(e.pathPrefix=t.pathPrefix),e}(e));return{format:"patch",text:r,diff:i}}const Ss=async(t,e)=>{const a=/^[0-9a-f]{40}$/.test(e)?e:await Nt(t,At(e)),n=await mt(t,a);return"commit"===n.type?n.data.tree:a},Hs="fetch:negotiate",As=async(t,e={})=>{await kt(t);const a=e.remote??"origin",{url:n,filter:i}=await Ns(t,a);t.progress.start(Hs);try{const r=vo(t,void 0!==t.config?.auth?{auth:t.config.auth}:{}),o=await Do(t,r,n);if(0===o.refs.length)throw T();if(void 0!==i&&!So(o.capabilities))throw de();const s=To(o.capabilities),c=Mo(o.refs),d=await Os(t,a),f=await fe(t,r,{wants:c,haves:d,capabilities:s,url:n,progressOp:"fetch:write-objects",...void 0!==e.depth?{depth:e.depth}:{},...void 0!==i?{filter:i,promisor:!0}:{}});(f.shallow.length>0||f.unshallow.length>0)&&await ue(t,{shallow:f.shallow,unshallow:f.unshallow});return{remote:a,url:n,updatedRefs:await _s(t,a,o),prunedRefs:!0===e.prune?await js(t,a,o):[],shallow:f.shallow,unshallow:f.unshallow}}finally{t.progress.end(Hs)}},Ns=async(t,e)=>{const a=await Kt(t),n=a.remote?.get(e);if(void 0===n?.url||""===n.url)throw H(e);const i=void 0!==n.partialCloneFilter?Mn(Tn(n.partialCloneFilter)):void 0;return{url:n.url,filter:i}},Os=async(t,e)=>{const a=await Ls(t,e);if(0===a.length)return[];const n=new Set,i=[];for(const t of a)if(!n.has(t)&&(n.add(t),i.push(t),i.length>=Ie))return i;const r=a.slice(0,De);for await(const e of ae(t,{from:r,ignoreMissing:!0,verifyHash:!1}))if(!n.has(e.id)&&(n.add(e.id),i.push(e.id),i.length>=Ie))break;return i},Ls=async(t,e)=>{const a=[],n=[`refs/remotes/${e}`,"refs/tags"];for(const e of n){const n=`${t.layout.gitDir}/${e}`;await t.fs.exists(n)&&await Us(t,n,a)}const i=`refs/remotes/${e}/`,r=await Jt(t).getPackedRefs();for(const t of r.entries)(t.name.startsWith(i)||t.name.startsWith("refs/tags/"))&&a.push(t.id);return a},Us=async(t,e,a)=>{const n=await t.fs.readdir(e);for(const i of n){const n=`${e}/${i.name}`;if(i.isDirectory){await Us(t,n,a);continue}const r=(await t.fs.readUtf8(n)).trim();Cs(r)&&a.push(r)}},Ps=/^[0-9a-f]{40}([0-9a-f]{24})?$/i,Cs=t=>Ps.test(t),_s=async(t,e,a)=>{const n=[];for(const i of a.refs){const a=Rs(e,i);if(void 0===a)continue;const r=await Ws(t,a);r!==i.id?(await xt(t,a,i.id,{reflogMessage:`fetch ${e}: storing head`}),n.push({name:a,oldId:r,newId:i.id})):n.push({name:a,oldId:r,newId:i.id})}return n},Rs=(t,e)=>{if("HEAD"!==e.name&&Fs(e.name)){if(e.name.startsWith("refs/heads/")){const a=`refs/remotes/${t}/${e.name.slice(11)}`;if(!Fs(a))return;return a}return e.name.startsWith("refs/tags/")?e.name:void 0}},Fs=t=>{try{return At(t),!0}catch{return!1}},Ws=async(t,e)=>{At(e);const a=`${t.layout.gitDir}/${e}`;if(!await t.fs.exists(a))return;const n=(await t.fs.readUtf8(a)).trim();return Cs(n)?n:void 0},js=async(t,e,a)=>{const n=new Set(a.refs.filter(t=>t.name.startsWith("refs/heads/")).map(t=>t.name.slice(11))),i=`${t.layout.gitDir}/refs/remotes/${e}`;if(!await t.fs.exists(i))return[];const r=[];return await qs(t,i,"",n,e,r),r},qs=async(t,e,a,n,i,r)=>{const o=await t.fs.readdir(e);for(const s of o){const o=`${e}/${s.name}`,c=""===a?s.name:`${a}/${s.name}`;if(s.isDirectory){await qs(t,o,c,n,i,r);continue}if(n.has(c))continue;const d=`refs/remotes/${i}/${c}`;if(!Fs(d)){t.logger?.warn?.("fetch.prune: skipping unsafe ref name",{name:d});continue}const f=d;try{await xt(t,f,Pt,{delete:!0})}catch(e){if(Bs(e)){t.logger?.warn?.("fetch.prune: skipping packed-only ref",{name:f});continue}throw e}r.push(f)}},Bs=e=>e instanceof t&&"UNSUPPORTED_OPERATION"===e.data.code&&"delete-packed-ref"===e.data.operation,zs=async(t,e,a)=>!!await t.fs.exists(Te(t.layout.gitDir,a))||void 0!==await e.lookup(a),Vs=async(e,a)=>{await kt(e);const n=await Kt(e),i=n.extensions?.partialClone;if(void 0===i)return{kind:"no-promisor"};const r=n.remote?.get(i)?.url;if(void 0===r||""===r)throw H(i);const o=await(async(t,e)=>{const a=Me(t),n=new Set,i=[];for(const r of e)n.has(r)||(n.add(r),await zs(t,a,r)||i.push(r));return i})(e,a);if(0===o.length)return{kind:"fetched",remote:i,requested:a.length,fetched:0};const s=vo(e,void 0!==e.config?.auth?{auth:e.config.auth}:{}),c=await Do(e,s,r),d=To(c.capabilities);try{await fe(e,s,{wants:o,haves:[],capabilities:d,url:r,progressOp:"fetch-missing:write-objects",promisor:!0})}catch(e){if(!(e=>e instanceof t&&"FILE_EXISTS"===e.data.code)(e))throw e}return{kind:"fetched",remote:i,requested:a.length,fetched:o.length}},Gs=async(t,e)=>{const a=await Vs(t,e.oids);if("no-promisor"===a.kind)throw A();return{remote:a.remote,requested:a.requested,fetched:a.fetched}},Xs=t=>({fetch:async e=>{const a=await Vs(t,e);return"no-promisor"===a.kind?{attempted:!1,requested:e.length,fetched:0}:{attempted:!0,requested:a.requested,fetched:a.fetched}}}),Ys=async(t,e={})=>{const a=e.initialBranch??"main",n=e.bare??!1;if(await t.fs.exists(`${t.layout.gitDir}/HEAD`))throw Se(t.layout.gitDir);const i=await go(t,{initialBranch:a,bare:n});return{path:i.gitDir,initialBranch:i.initialBranch,bare:i.bare}},Ks=(t,e)=>Object.freeze({list:()=>(e(),Di(t)),create:a=>(e(),Mi(t,a)),delete:a=>(e(),Si(t,a)),rename:a=>(e(),Hi(t,a))}),Zs=(t,e)=>Object.freeze({run:a=>(e(),lo(t,a)),continue:a=>(e(),ho(t,a)),skip:a=>(e(),mo(t,a)),abort:()=>(e(),po(t))}),Js=(t,e)=>Object.freeze({get:a=>(e(),ms(t,a)),getAll:a=>(e(),ps(t,a)),getRegexp:a=>(e(),gs(t,a)),list:a=>(e(),ys(t,a)),set:a=>(e(),vs(t,a)),unset:a=>(e(),ks(t,a)),unsetAll:a=>(e(),bs(t,a)),renameSection:a=>(e(),$s(t,a)),removeSection:a=>(e(),xs(t,a))}),Qs=t=>`'${t.replaceAll("'","'\\''")}'`,tc=(t,e)=>{const a=`${e}=`,n=t.find(t=>t.startsWith(a));if(void 0===n)throw He(e,"missing author-script key");const i=n.slice(a.length);if(i.length<2||!i.startsWith("'")||!i.endsWith("'"))throw He(n,"author-script value is not single-quoted");return(t=>t.slice(1,-1).replaceAll("'\\''","'"))(i)},ec=t=>t.replace(/\n+$/,""),ac=(t,e)=>{return 0===e?`# This is the 1st commit message:\n\n${ec(t.message)}\n`:!0===t.skip?`\n# The commit message #${e+1} will be skipped:\n\n${a=t.message,ec(a).split("\n").map(t=>""===t?"#":`# ${t}`).join("\n")}\n`:`\n# This is the commit message #${e+1}:\n\n${ec(t.message)}\n`;var a},nc=t=>{const e=t.length;let a=`# This is a combination of ${e} ${1===e?"commit":"commits"}.\n`;for(let n=0;n<e;n+=1)a+=ac(t[n],n);return a},ic=/^(pick|reword|edit|squash|fixup|drop) (\S+) # (.*)$/,rc=t=>t.map(t=>`${t.action} ${t.oid} # ${t.subject}\n`).join(""),oc=t=>{const e=[];for(const a of t.split("\n")){if(""===a||a.startsWith("#"))continue;const t=ic.exec(a);if(null===t)throw w(a);e.push({action:t[1],oid:t[2],subject:t[3]})}return e},sc=new TextEncoder,cc=new Uint8Array,dc=async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);return a.data},fc=async(t,e)=>{const a=await dc(t,e),n=a.parents[0],i=void 0!==n?(await dc(t,n)).tree:void 0,r=await Ee(t,i,a.tree),o=await Ds(t,r.changes),s=Va(o,{contextLines:3,pathPrefix:{old:"a/",new:"b/"}}),c=o.filter(t=>xa(t.oldContent??cc)||xa(t.newContent??cc)).map(t=>{return`${"oldId"in(e=t.change)?e.oldId:""}${"newId"in e&&void 0!==e.newId?e.newId:""}`;var e}).join("");return t.hash.hashHex(sc.encode(s.split("\n").filter(t=>!t.startsWith("@@ ")&&!t.startsWith("index ")).map(t=>t.replace(/\s/g,"")).join("")+c))},uc=t=>`${t.layout.gitDir}/rebase-merge`,lc=(t,e)=>`${uc(t)}/${e}`,wc=t=>`${t.layout.gitDir}/REBASE_HEAD`,hc=async(t,e)=>{const a=[...e.done,...e.remaining],n=(e,a)=>t.fs.writeUtf8(lc(t,e),a);var i,r;await n("head-name",`${e.headName}\n`),await n("onto",`${e.onto}\n`),await n("orig-head",`${e.origHead}\n`),await n("git-rebase-todo",rc(e.remaining)),void 0!==e.backupHeader&&await n("git-rebase-todo.backup",((t,e)=>{const a=t.length,n=`# Rebase ${e.shortUpstream}..${e.shortOrigHead} onto ${e.shortOnto} (${a} ${1===a?"command":"commands"})\n`;return`${rc(t)}\n${n}#\n# Commands:\n# p, pick <commit> = use commit\n# r, reword <commit> = use commit, but edit the commit message\n# e, edit <commit> = use commit, but stop for amending\n# s, squash <commit> = use commit, but meld into previous commit\n# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous\n# commit's log message, unless -C is used, in which case\n# keep only this commit's message; -c is same as -C but\n# opens the editor\n# x, exec <command> = run command (the rest of the line) using shell\n# b, break = stop here (continue rebase later with 'git rebase --continue')\n# d, drop <commit> = remove commit\n# l, label <label> = label current HEAD with a name\n# t, reset <label> = reset HEAD to a label\n# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n# create a merge commit using the original merge commit's\n# message (or the oneline, if no original merge commit was\n# specified); use -c <commit> to reword the commit message\n# u, update-ref <ref> = track a placeholder for the <ref> to be updated\n# to this position in the new commits. The <ref> is\n# updated at the end of the rebase\n#\n# These lines can be re-ordered; they are executed from top to bottom.\n#\n# If you remove a line here THAT COMMIT WILL BE LOST.\n#\n# However, if you remove everything, the rebase will be aborted.\n#\n`})(a,e.backupHeader)),await n("done",rc(e.done)),await n("message",e.message),await n("author-script",(i=e.stoppedAuthor,`GIT_AUTHOR_NAME=${Qs(i.name)}\nGIT_AUTHOR_EMAIL=${Qs(i.email)}\nGIT_AUTHOR_DATE=${Qs(`@${i.timestamp} ${i.timezoneOffset}`)}\n`)),await n("end",`${a.length}\n`),await n("msgnum",`${e.done.length}\n`),await n("interactive",""),await n("rewritten-list",(r=e.rewritten,r.map(([t,e])=>`${t} ${e}\n`).join(""))),await n("patch",e.patch),await n("drop_redundant_commits",""),await n("no-reschedule-failed-exec",""),await n("stopped-sha",`${e.stoppedSha}\n`),void 0!==e.amend&&await n("amend",`${e.amend}\n`),void 0!==e.currentFixups&&await n("current-fixups",e.currentFixups.map(t=>`${t.action} ${t.oid}\n`).join("")),void 0!==e.rewrittenPending&&await n("rewritten-pending",e.rewrittenPending.map(t=>`${t}\n`).join("")),void 0!==e.messageSquash&&await n("message-squash",e.messageSquash),await t.fs.writeUtf8(wc(t),`${e.stoppedSha}\n`)},mc=t=>ar(t,wc(t)),pc=async(t,e)=>{const a=[];for(const n of e){const e=await er(t,n.oid);if(void 0===e)throw w(`cannot resolve commit ${n.oid}`);a.push({action:n.action,oid:e,subject:n.subject})}return a},gc=async t=>{if(!await(t=>t.fs.exists(uc(t)))(t))return;const e=(await t.fs.readUtf8(lc(t,"head-name"))).trimEnd(),a=await ar(t,lc(t,"onto")),n=await ar(t,lc(t,"orig-head")),i=await pc(t,oc(await t.fs.readUtf8(lc(t,"done")))),r=await pc(t,oc(await t.fs.readUtf8(lc(t,"git-rebase-todo")))),o=(t=>{const e=t.split("\n"),a=tc(e,"GIT_AUTHOR_NAME"),n=tc(e,"GIT_AUTHOR_EMAIL"),i=tc(e,"GIT_AUTHOR_DATE");if(!i.startsWith("@"))throw He(i,"author-script date lacks the `@` prefix");const[r,o]=i.slice(1).split(" "),s=Number(r);if(!Number.isSafeInteger(s))throw He(i,"invalid author-script timestamp");if(void 0===o||!/^[+-]\d{4}$/.test(o))throw He(i,"invalid author-script timezone offset");return{name:a,email:n,timestamp:s,timezoneOffset:o}})(await t.fs.readUtf8(lc(t,"author-script"))),s=await t.fs.readUtf8(lc(t,"message")),c=await ar(t,lc(t,"amend")),d=await yc(t),f=await vc(t);return{headName:e,onto:a,origHead:n,done:i,remaining:r,stoppedSha:await mc(t),author:o,message:s,...void 0!==c?{amend:c}:{},...void 0!==d?{currentFixups:d}:{},...void 0!==f?{rewrittenPending:f}:{}}},yc=async t=>{const e=lc(t,"current-fixups");if(!await t.fs.exists(e))return;const a=[];for(const n of(await t.fs.readUtf8(e)).split("\n")){const[t,e]=n.split(" ");"squash"!==t&&"fixup"!==t||void 0===e||a.push({action:t,oid:e})}return a},vc=async t=>{const e=lc(t,"rewritten-pending");if(!await t.fs.exists(e))return;const a=[];for(const n of(await t.fs.readUtf8(e)).split("\n"))""!==n&&a.push(n);return a},kc=async t=>{const e=lc(t,"rewritten-list");if(!await t.fs.exists(e))return[];const a=[];for(const n of(await t.fs.readUtf8(e)).split("\n")){if(""===n)continue;const[t,e]=n.split(" ");void 0!==t&&void 0!==e&&a.push([t,e])}return a},bc=async t=>{await t.fs.exists(uc(t))&&await t.fs.rmRecursive(uc(t)),await t.fs.exists(wc(t))&&await t.fs.rm(wc(t))},$c="HEAD",xc=t=>t.slice(0,7),Ec=async(t,e,a)=>{const n=new Set;if(void 0!==e)for await(const a of ae(t,{from:[e]}))n.add(a.id);const i=[];for await(const e of ae(t,{from:[a],until:[...n]}))i.push(e.id);return i.reverse()},Ic=async(t,e,a)=>{const n=e.parents[0],i=void 0!==n?await Hr(t,n):void 0,r=await Hr(t,a),o=await gt(t);try{const a=await yt(t),n=await Xi(t,{baseTree:i,oursTree:r,theirsTree:e.tree,currentIndex:a});if("would-overwrite"===n.kind)throw m(n.paths);return"conflict"===n.kind?(await o.commit(n.indexEntries),{kind:"conflict",conflicts:n.conflicts}):(await o.commit(n.result.newIndexEntries),{kind:"clean",mergedTree:n.mergedTree,oursTree:r})}finally{await o.release()}},Dc=async(t,e,a)=>{const n=await Ic(t,e,a);if("conflict"===n.kind)return{kind:"conflict",conflicts:n.conflicts};if(n.mergedTree===n.oursTree)return{kind:"empty"};const i=await Mr(t),r=await ee(t,{tree:n.mergedTree,parents:[a],author:e.author,committer:i,message:e.message,extraHeaders:[]});return await xt(t,$c,r,{expected:a,reflogMessage:`rebase (pick): ${ga(e.message)}`}),{kind:"committed",id:r}},Tc=async(t,e)=>{const a=e.parents[0],n=void 0!==a?await Hr(t,a):void 0,i=await Ee(t,n,e.tree);return Va(await Ds(t,i.changes),{contextLines:3,pathPrefix:{old:"a/",new:"b/"}})},Mc=async(t,e,a,n,i,r)=>{const o={headName:e.branch??"detached HEAD",onto:e.onto,origHead:e.origHead,done:[...e.doneBefore,...e.todo.slice(0,a+1)],remaining:e.todo.slice(a+1),stoppedSha:e.todo[a].oid,stoppedAuthor:n.author,message:vr(n.message,i.map(t=>t.path)),rewritten:r,patch:await Tc(t,n),...void 0!==e.backupHeader?{backupHeader:e.backupHeader}:{}};await hc(t,o)},Sc=async(t,e,a,n,i)=>{void 0!==e&&(await xt(t,e,n,{expected:a,reflogMessage:`rebase (finish): ${e} onto ${i}`}),await Ut(t,$c,e),await Rt(t,$c,n,n,`rebase (finish): returning to ${e}`))},Hc=async(t,e,a,n)=>{let i=a;const r=[...n.applied],o=[...n.rewritten];for(let a=0;a<e.todo.length;a+=1){const n=e.todo[a].oid,s=await Sr(t,n),c=await Dc(t,s,i);if("committed"!==c.kind){if("empty"!==c.kind)return await Mc(t,e,a,s,c.conflicts,o),{kind:"conflict",commit:n,conflicts:c.conflicts.map(t=>({path:t.path,type:t.type})),remaining:e.todo.length-(a+1)}}else r.push({source:n,created:c.id}),o.push([n,c.id]),i=c.id}return await Sc(t,e.branch,e.origHead,i,e.onto),await bc(t),{kind:"rebased",commits:r}},Ac=async(e,a)=>{await kt(e),await bt(e,"rebase"),await It(e);const n=await $t(e),i="symbolic"===n.kind?await(async(e,a)=>{try{return await Nt(e,a)}catch(e){if(e instanceof t&&"REF_NOT_FOUND"===e.data.code)throw k();throw e}})(e,n.target):n.id,r="symbolic"===n.kind?n.target:void 0,o=await xr(e,a.upstream),s=void 0!==a.onto?await xr(e,a.onto):o,c=a.onto??a.upstream;await $r(e,await Hr(e,i));const[d]=await Ae(e,[o,i]);if(void 0!==a.interactive)return zc(e,{instructions:a.interactive,branch:r,headCommit:i,upstream:o,onto:s,ontoName:c,base:d});if(s===d)return{kind:"up-to-date"};const f=await Ec(e,d,i),u=await(async(t,e,a,n)=>{const i=await Ec(t,a,n),r=new Set;for(const e of i)r.add(await fc(t,e));const o=[];for(const a of e)r.has(await fc(t,a))||o.push(a);return o})(e,f,d,o),l=await(async(t,e)=>{const a=[];for(const n of e)a.push({action:"pick",oid:n,subject:ga((await Sr(t,n)).message)});return a})(e,u);await Bn(e,i),await(async(t,e,a,n)=>{await Jt(t).writeLoose($c,a),await Rt(t,$c,e,a,`rebase (start): checkout ${n}`),await Yn(t,a)})(e,i,s,c);const w={branch:r,onto:s,origHead:i,doneBefore:[],todo:l,backupHeader:{shortUpstream:xc(o),shortOrigHead:xc(i),shortOnto:xc(s)}};return Hc(e,w,s,{applied:[],rewritten:[]})},Nc=t=>"detached HEAD"===t?void 0:t,Oc=t=>{const e=new Set;for(const a of t)0!==a.flags.stage&&e.add(a.path);if(e.size>0)throw b(e.size,[...e])},Lc=async t=>{await kt(t),await bt(t,"rebase --continue");const a=await gc(t);if(void 0===a)throw e("rebase");if(Vc(a))return Gc(t,a);const n=await yt(t);Oc(n.entries);const i=a.done[a.done.length-1],r=await Nt(t,$c),o=await Wt(t,n.entries),s=await Mr(t),c=Dr(Tr(a.message),{allowEmpty:!1}),d=await ee(t,{tree:o,parents:[r],author:a.author,committer:s,message:c,extraHeaders:[]});await xt(t,$c,d,{expected:r,reflogMessage:`rebase (continue): ${ga(c)}`});const f=[...await kc(t),[i.oid,d]],u={branch:Nc(a.headName),onto:a.onto,origHead:a.origHead,doneBefore:a.done,todo:a.remaining};return Hc(t,u,d,{applied:[{source:i.oid,created:d}],rewritten:f})},Uc=async t=>{await kt(t),await bt(t,"rebase --skip");const a=await gc(t);if(void 0===a)throw e("rebase");if(Vc(a))return Xc(t,a);const n=await Nt(t,$c);await Yn(t,n);const i={branch:Nc(a.headName),onto:a.onto,origHead:a.origHead,doneBefore:a.done,todo:a.remaining};return Hc(t,i,n,{applied:[],rewritten:await kc(t)})},Pc=async t=>{await kt(t),await bt(t,"rebase --abort");const a=await gc(t);if(void 0===a)throw e("rebase");const n=Nc(a.headName),i=await Nt(t,$c);return await Yn(t,a.origHead),void 0!==n?(await Ut(t,$c,n),await Rt(t,$c,i,a.origHead,`rebase (abort): returning to ${n}`)):(await Jt(t).writeLoose($c,a.origHead),await Rt(t,$c,i,a.origHead,`rebase (abort): returning to ${a.origHead}`)),await bc(t),{head:a.origHead,headName:a.headName}},Cc=async(t,e)=>{const a=await Mr(t),n=await ee(t,{tree:e.tree,parents:[e.parent],author:e.author,committer:a,message:e.message,extraHeaders:[]});return await xt(t,$c,n,{expected:e.expected,reflogMessage:e.reflog}),n},_c=async(t,e,a,n,i)=>{if(a.parents[0]===n)return await(async(t,e)=>{const a=await Nt(t,$c);await Jt(t).writeLoose($c,e),await Rt(t,$c,a,e,"rebase: fast-forward"),await Yn(t,e)})(t,e.oid),{kind:"committed",created:e.oid};const r=await Ic(t,a,n);return"conflict"===r.kind?{kind:"conflict",conflicts:r.conflicts}:{kind:"committed",created:await Cc(t,{tree:r.mergedTree,parent:n,expected:n,author:a.author,message:a.message,reflog:i})}},Rc=(t,e,a,n)=>"reword"===e.action?(async(t,e,a,n)=>{const i=Dr(e.message??a.message,{allowEmpty:!1}),r=await _c(t,e,a,n,`rebase (reword): ${ga(a.message)}`);if("conflict"===r.kind)return{kind:"conflict",conflicts:r.conflicts};const o=await Sr(t,r.created);return{kind:"advanced",created:await Cc(t,{tree:o.tree,parent:o.parents[0],expected:r.created,author:o.author,message:i,reflog:`rebase (reword): ${ga(i)}`})}})(t,e,a,n):"edit"===e.action?(async(t,e,a,n)=>{const i=await _c(t,e,a,n,`rebase (edit): ${ga(a.message)}`);return"conflict"===i.kind?{kind:"conflict",conflicts:i.conflicts}:{kind:"edit-stop",created:i.created}})(t,e,a,n):(async(t,e,a,n)=>{const i=await _c(t,e,a,n,`rebase (pick): ${ga(a.message)}`);return"conflict"===i.kind?{kind:"conflict",conflicts:i.conflicts}:{kind:"advanced",created:i.created}})(t,e,a,n),Fc=async(t,e,a,n)=>{await hc(t,{headName:e.branch??"detached HEAD",onto:e.onto,origHead:e.origHead,done:[...e.doneBefore,...e.todo.slice(0,a+1)],remaining:e.todo.slice(a+1),stoppedSha:n.stoppedSha,stoppedAuthor:n.author,message:n.message,rewritten:n.rewritten,patch:n.patch,...void 0!==e.backupHeader?{backupHeader:e.backupHeader}:{},...void 0!==n.amend?{amend:n.amend}:{},...void 0!==n.currentFixups?{currentFixups:n.currentFixups}:{},...void 0!==n.rewrittenPending?{rewrittenPending:n.rewrittenPending}:{},...void 0!==n.messageSquash?{messageSquash:n.messageSquash}:{}})},Wc=(t,e)=>{const a=t[e+1];return void 0!==a&&("squash"===a.action||"fixup"===a.action)},jc=(t,e,a)=>({kind:"conflict",commit:t,conflicts:e.map(t=>({path:t.path,type:t.type})),remaining:a}),qc=async(t,e,a,n,i,r)=>{const o=await Sr(t,n),s=await Ic(t,a,n);if("conflict"===s.kind)return{kind:"conflict",conflicts:s.conflicts};i.members.push({message:a.message,skip:"fixup"===e.action}),i.fixups.push({action:e.action,oid:e.oid}),i.pending.push(e.oid),"squash"===e.action&&void 0!==e.message&&(i.inline=e.message);const c=nc([{message:i.baseMessage},...i.members]),d=r?Dr(i.inline??Tr(c),{allowEmpty:!1}):c;return{kind:"committed",created:await Cc(t,{tree:s.mergedTree,parent:o.parents[0],expected:n,author:o.author,message:d,reflog:`rebase (${e.action}): ${ga(d)}`}),message:d}},Bc=async(t,e,a,n)=>{let i=a;const r=[...n.applied],o=[...n.rewritten],s={baseMessage:(await Sr(t,a)).message,members:[],fixups:[],pending:[a],inline:void 0};for(let a=0;a<e.todo.length;a+=1){const n=e.todo[a];if("drop"===n.action)continue;const c=await Sr(t,n.oid),d=await Tc(t,c);if("squash"===n.action||"fixup"===n.action){const f=await qc(t,n,c,i,s,!Wc(e.todo,a));if("conflict"===f.kind){const i=nc([{message:s.baseMessage},...s.members,{message:c.message,skip:"fixup"===n.action}]);return await Fc(t,e,a,{stoppedSha:n.oid,author:c.author,message:vr(i,f.conflicts.map(t=>t.path)),patch:d,rewritten:o,currentFixups:[...s.fixups,{action:n.action,oid:n.oid}],rewrittenPending:[...s.pending],messageSquash:i}),jc(n.oid,f.conflicts,e.todo.length-(a+1))}r.push({source:n.oid,created:f.created}),o.push([n.oid,f.created]),i=f.created;continue}const f=await Rc(t,n,c,i);if("conflict"===f.kind)return await Fc(t,e,a,{stoppedSha:n.oid,author:c.author,message:vr(c.message,f.conflicts.map(t=>t.path)),patch:d,rewritten:o}),jc(n.oid,f.conflicts,e.todo.length-(a+1));if("edit-stop"===f.kind)return await Fc(t,e,a,{stoppedSha:f.created,author:c.author,message:c.message,patch:d,rewritten:o,amend:f.created}),{kind:"stopped",commit:n.oid,remaining:e.todo.length-(a+1)};r.push({source:n.oid,created:f.created}),o.push([n.oid,f.created]),i=f.created,s.baseMessage=(await Sr(t,f.created)).message,s.members=[],s.fixups=[],s.pending=[f.created],s.inline=void 0}return await Sc(t,e.branch,e.origHead,i,e.onto),await bc(t),{kind:"rebased",commits:r}},zc=async(t,e)=>{const a=await(async(t,e,a,n)=>{if(e.every(t=>"drop"===t.action))throw o("interactive","nothing to do (every instruction drops a commit)");const i=e.find(t=>"drop"!==t.action);if("squash"===i?.action||"fixup"===i?.action)throw o("interactive",`cannot '${i.action}' without a previous commit`);const r=new Set(await Ec(t,a,n)),s=[];for(const a of e){if("reword"===a.action&&void 0===a.message)throw o("interactive","reword requires a message (no editor in a library)");if(("reword"===a.action||"squash"===a.action)&&void 0!==a.message&&""===Dr(a.message,{allowEmpty:!0}))throw o("interactive",`${a.action} message must not be empty`);const e=await xr(t,a.oid);if(!r.has(e))throw o("interactive",`commit ${e} is not in the list of commits to be rebased`);const n=ga((await Sr(t,e)).message);s.push({action:a.action,oid:e,subject:n,...void 0!==a.message?{message:a.message}:{}})}return s})(t,e.instructions,e.base,e.headCommit),n=await(async(t,e,a)=>{let n=a,i=0;for(;i<e.length&&"pick"===e[i].action&&(await Sr(t,e[i].oid)).parents[0]===n;)n=e[i].oid,i+=1;return i})(t,a,e.onto),i=n>0?a[n-1].oid:e.onto;await Bn(t,e.headCommit),await(async(t,e,a,n)=>{await Jt(t).writeLoose($c,n),await Rt(t,$c,e,n,`rebase (start): checkout ${a}`),await Yn(t,n)})(t,e.headCommit,e.ontoName,i);const r=a.slice(0,n),s={branch:e.branch,onto:e.onto,origHead:e.headCommit,doneBefore:r,todo:a.slice(n),backupHeader:{shortUpstream:xc(e.upstream),shortOrigHead:xc(e.headCommit),shortOnto:xc(e.onto)}},c={applied:r.map(t=>({source:t.oid,created:t.oid})),rewritten:[]};return Bc(t,s,i,c)},Vc=t=>[...t.done,...t.remaining].some(t=>"pick"!==t.action),Gc=async(t,e)=>{const a={branch:Nc(e.headName),onto:e.onto,origHead:e.origHead,doneBefore:e.done,todo:e.remaining},n=[...await kc(t)],i=await yt(t);Oc(i.entries);const r=await Wt(t,i.entries),o=await Nt(t,$c),s=e.done[e.done.length-1].oid;let c;if(void 0!==e.currentFixups){const a=await Sr(t,o),i=Dr(Tr(e.message),{allowEmpty:!1});c=await Cc(t,{tree:r,parent:a.parents[0],expected:o,author:a.author,message:i,reflog:`rebase (continue): ${ga(i)}`}),n.push([s,c])}else if(void 0!==e.amend){const a=await Sr(t,e.amend);r===a.tree?c=o:(c=await Cc(t,{tree:r,parent:a.parents[0],expected:o,author:e.author,message:a.message,reflog:`rebase (continue): ${ga(a.message)}`}),n.push([s,c]))}else{const a=Dr(Tr(e.message),{allowEmpty:!1});c=await Cc(t,{tree:r,parent:o,expected:o,author:e.author,message:a,reflog:`rebase (continue): ${ga(a)}`}),n.push([s,c])}return Bc(t,a,c,{applied:[],rewritten:n})},Xc=async(t,e)=>{const a=await Nt(t,$c),n=void 0!==e.amend?(await Sr(t,e.amend)).parents[0]:a;await Jt(t).writeLoose($c,n),await Yn(t,n);const i={branch:Nc(e.headName),onto:e.onto,origHead:e.origHead,doneBefore:e.done,todo:e.remaining};return Bc(t,i,n,{applied:[],rewritten:await kc(t)})},Yc=(t,e)=>Object.freeze({run:a=>(e(),Ac(t,a)),continue:()=>(e(),Lc(t)),skip:()=>(e(),Uc(t)),abort:()=>(e(),Pc(t))}),Kc=t=>"HEAD"===t||t.includes("/")?t:`refs/heads/${t}`,Zc=t=>{if(""===t)throw Ne(t,"refspec must not be empty");let e=t,a="normal";if(e.startsWith("+")&&(a="force",e=e.slice(1)),""===e)throw Ne(t,"refspec must not be empty after force prefix");const n=Jc(e,":");if(n>1)throw Ne(t,"refspec must contain at most one colon");if(0===n){const t=Kc(e);return{force:a,src:t,dst:t,isDelete:!1}}const i=e.indexOf(":"),r=e.slice(0,i),o=e.slice(i+1);if(""===o)throw Ne(t,"destination must not be empty");const s=Kc(o);if("HEAD"===s)throw Ne(t,"destination must not be HEAD");return""===r?{force:a,src:"",dst:s,isDelete:!0}:{force:a,src:Kc(r),dst:s,isDelete:!1}},Jc=(t,e)=>{let a=0;for(let n=0;n<t.length;n+=1)t[n]===e&&(a+=1);return a},Qc=/[\n\r\t\0"\\\]/]/,td=t=>{if(""===t)throw N(t,"name must not be empty");if(Qc.test(t))throw N(t,"name must not contain a newline, tab, NUL, slash, bracket, quote, or backslash");return t},ed=(t,e)=>{if(void 0===t.branch)return[];const a=[];for(const[n,i]of t.branch)i.remote===e&&a.push({branch:n,ref:`refs/heads/${n}`,merge:i.merge});return a},ad=/[\n\r\0]/,nd=t=>{if(ad.test(t))throw o("remote.url","url must not contain a newline or NUL")},id=(t,e)=>({name:t,url:e?.url??"",pushUrl:e?.pushUrl,fetchRefspecs:e?.fetch??[]}),rd=async t=>{await kt(t);const e=await Kt(t);if(void 0===e.remote)return{remotes:[]};const a=[];for(const[t,n]of e.remote)a.push(id(t,n));return a.sort((t,e)=>t.name<e.name?-1:1),{remotes:a}},od=async(t,e)=>{await kt(t),td(e.name),nd(e.url);const a=await Kt(t);if(!0===a.remote?.has(e.name))throw O(e.name);const n=e.fetch??`+refs/heads/*:refs/remotes/${e.name}/*`;Zc(n);const i=[{kind:"set",section:"remote",subsection:e.name,key:"url",value:e.url},{kind:"set",section:"remote",subsection:e.name,key:"fetch",value:n}];return await Oe(t,i),{remote:{name:e.name,url:e.url,pushUrl:void 0,fetchRefspecs:[n]}}},sd=async(t,e)=>{const a=`refs/remotes/${e}/`;return(await Le(t)).filter(t=>t.startsWith(a))},cd=async(t,e)=>{await kt(t),td(e.name);const a=await Kt(t);if(!0!==a.remote?.has(e.name))throw H(e.name);const n=await sd(t,e.name),i=ed(a,e.name);for(const e of n)await xt(t,e,Pt,{delete:!0});const r=[{kind:"removeSection",section:"remote",subsection:e.name}];for(const t of i)r.push({kind:"removeEntry",section:"branch",subsection:t.branch,key:"remote"},{kind:"removeEntry",section:"branch",subsection:t.branch,key:"merge"});return await Oe(t,r),{name:e.name,removedTrackingRefs:n,clearedBranches:i.map(t=>t.ref)}},dd=async(t,e,n,i)=>{const r=Jt(t),o=await r.resolveDirect(e);if("direct"===o.kind){if(!await r.isLoose(e))throw a("rename-packed-tracking-ref",`cannot rename packed-only ref ${e} — run \`git pack-refs --unpack\` and retry`);await xt(t,n,o.id,{expected:"absent",reflogMessage:i}),await xt(t,e,Pt,{delete:!0})}},fd=async(t,e)=>{if(await kt(t),td(e.from),td(e.to),e.from===e.to)throw o("remote.rename","from and to must differ");const a=await Kt(t),n=a.remote?.get(e.from);if(void 0===n)throw H(e.from);if(!0===a.remote?.has(e.to))throw O(e.to);const i=await sd(t,e.from),r=ed(a,e.from),s=`remote: renamed ${e.from} to ${e.to}`,c=[];for(const a of i){const n=a.slice(`refs/remotes/${e.from}/`.length),i=`refs/remotes/${e.to}/${n}`;await dd(t,a,i,s),c.push(i)}const d=((t,e,a)=>{const n=`+refs/heads/*:refs/remotes/${e}/*`,i=`+refs/heads/*:refs/remotes/${a}/*`;return t.map(t=>t===n?i:t)})(n.fetch??[],e.from,e.to),f=[{kind:"renameSection",section:"remote",from:e.from,to:e.to}];if(d.length>0){f.push({kind:"removeEntry",section:"remote",subsection:e.to,key:"fetch"});for(const t of d)f.push({kind:"appendEntry",section:"remote",subsection:e.to,key:"fetch",value:t})}for(const t of r)f.push({kind:"set",section:"branch",subsection:t.branch,key:"remote",value:e.to});return await Oe(t,f),{from:e.from,to:e.to,movedTrackingRefs:c,rewrittenBranches:r.map(t=>t.ref)}},ud=async(t,e)=>{await kt(t),td(e.name),nd(e.url);const a=await Kt(t);if(!0!==a.remote?.has(e.name))throw H(e.name);const n=!0===e.push?"pushurl":"url";await Oe(t,[{kind:"set",section:"remote",subsection:e.name,key:n,value:e.url}]);const i=(await Kt(t)).remote?.get(e.name);return{remote:id(e.name,i)}},ld=async(t,e)=>{await kt(t),td(e.name);const a=await Kt(t),n=a.remote?.get(e.name);if(void 0===n)throw H(e.name);const i=await sd(t,e.name),r=Jt(t),o=new Map;for(const t of i){const e=await r.resolveDirect(t);"direct"===e.kind&&o.set(t,e.id)}const s=ed(a,e.name);return{remote:{...id(e.name,n),trackingRefs:o,trackedBy:s.map(t=>({branch:t.ref,merge:t.merge}))}}},wd=(t,e)=>Object.freeze({list:()=>(e(),rd(t)),add:a=>(e(),od(t,a)),remove:a=>(e(),cd(t,a)),rename:a=>(e(),fd(t,a)),setUrl:a=>(e(),ud(t,a)),show:a=>(e(),ld(t,a))}),hd=t=>t.parents.length>=2,md=t=>t.map(t=>({path:t.path,type:t.type})),pd=t=>he(t,[]),gd=async(t,e,a,n,i)=>{const r=a.parents[0],o=void 0!==r?await Hr(t,r):await pd(t),s=await Hr(t,i),c=await gt(t);try{const r=await yt(t),d=await Xi(t,{baseTree:a.tree,oursTree:s,theirsTree:o,currentIndex:r});if("would-overwrite"===d.kind)throw m(d.paths);if("conflict"===d.kind)return await c.commit(d.indexEntries),{kind:"conflict",conflicts:d.conflicts};if(d.mergedTree===s)return{kind:"empty"};await c.commit(d.result.newIndexEntries);const{id:f,subject:u}=await(async(t,e,a,n,i)=>{const r=await Mr(t),o=Dr(Zo(a,e),{allowEmpty:!1});return{id:await ee(t,{tree:i,parents:[n],author:r,committer:r,message:o,extraHeaders:[]}),subject:ga(o)}})(t,e,a,i,d.mergedTree);return await xt(t,n,f,{expected:i,reflogMessage:`revert: ${u}`}),{kind:"committed",id:f}}finally{await c.release()}},yd=async(t,e,a,n)=>{await sr(t,e.sequenceHead),await fr(t,await(async(t,e)=>{const a=[];for(const n of e){const e=await Sr(t,n);a.push({command:"revert",oid:n,subject:ga(e.message)})}return a})(t,a)),await dr(t,n),await lr(t,{recordOrigin:!1,allowEmpty:!1,noCommit:!1})},vd=async(t,e,a)=>{"conflict"===e.kind&&await(async(t,e,a,n)=>{await(async(t,e)=>{await t.fs.writeUtf8(Xo(t),`${e}\n`)})(t,e),await qn(t,vr(Zo(a,e),n.map(t=>t.path)))})(t,a.source,a.cData,e.conflicts),a.seq.multiPick&&await yd(t,a.seq,a.remaining,a.currentHead);const n=a.remaining.length-1;return"conflict"===e.kind?{kind:"conflict",commit:a.source,conflicts:md(e.conflicts),remaining:n}:{kind:"empty",commit:a.source,remaining:n}},kd=async(t,e,a,n,i)=>{let r=n;const o=[];for(let n=0;n<e.length;n+=1){const s=e[n],c=await Sr(t,s);if(hd(c))throw i.multiPick&&await yd(t,i,e.slice(n),r),L(s);const d=await gd(t,s,c,a,r);if("committed"!==d.kind){if("empty"!==d.kind||"drop"!==i.onEmpty||0!==n)return vd(t,d,{seq:i,source:s,cData:c,remaining:e.slice(n),currentHead:r})}else o.push({source:s,created:d.id}),r=d.id}return await hr(t),{kind:"reverted",commits:o}},bd=/^(.+)\.\.(.+)$/,$d=async(t,e,a)=>{const n=new Set;for await(const a of ae(t,{from:[e]}))n.add(a.id);const i=[];for await(const e of ae(t,{from:[a],until:[...n]}))i.push(e.id);return i},xd=async(e,n)=>{await kt(e),await bt(e,"revert"),await It(e);const i=await $t(e);if("symbolic"!==i.kind)throw a("revert","cannot revert with detached HEAD");const r=await(async(e,a)=>{try{return await Nt(e,a)}catch(e){if(e instanceof t&&"REF_NOT_FOUND"===e.data.code)throw k();throw e}})(e,i.target),s=await(async(t,e)=>{const a=[];for(const n of e){if(n.includes("...")||n.includes("^"))throw o("commits",`unsupported revision form '${n}' (use a commit-ish or A..B)`);const e=bd.exec(n);if(null===e){a.push(await xr(t,n));continue}const i=await jr(t,e[1]),r=await jr(t,e[2]);a.push(...await $d(t,i,r))}return a})(e,n.commits);return await $r(e,await Hr(e,r)),!0===n.noCommit?(async(t,e)=>{const a=await gt(t);try{let n=await yt(t);for(let i=0;i<e.length;i+=1){const r=e[i],o=await Sr(t,r);if(hd(o))throw L(r);const s=o.parents[0],c=void 0!==s?await Hr(t,s):await pd(t),d=await Wt(t,n.entries),f=await Xi(t,{baseTree:o.tree,oursTree:d,theirsTree:c,currentIndex:n});if("would-overwrite"===f.kind)throw m(f.paths);if("conflict"===f.kind)return await a.commit(f.indexEntries),{kind:"conflict",commit:r,conflicts:md(f.conflicts),remaining:e.length-(i+1)};n={...n,entries:f.result.newIndexEntries}}return await a.commit(n.entries),{kind:"no-commit",sources:e}}finally{await a.release()}})(e,s):kd(e,s,i.target,r,{multiPick:s.length>1,sequenceHead:r,onEmpty:"stop"})},Ed=async t=>{await kt(t),await bt(t,"revert --continue");const n=await Yo(t),i=await ur(t);if(void 0===n&&(void 0===i||0===i.length))throw e("revert");const r=await $t(t);if("symbolic"!==r.kind)throw a("revert --continue","cannot continue with detached HEAD");let o=await Nt(t,r.target);const s=[];if(void 0!==n){const e=void 0!==i?i.length-1:0,a=await(async(t,e,a)=>{const n=await yt(t);(t=>{const e=new Set;for(const a of t)0!==a.flags.stage&&e.add(a.path);if(e.size>0)throw b(e.size,[...e])})(n.entries);const i=await Wt(t,n.entries);if(i===await Hr(t,a))return{empty:!0};const r=await(async(t,e,a,n)=>{const i=await Mr(t),r=Dr(Tr(await Vn(t)??""),{allowEmpty:!1}),o=await ee(t,{tree:n,parents:[e],author:i,committer:i,message:r,extraHeaders:[]});return await xt(t,a,o,{expected:e,reflogMessage:`commit: ${ga(r)}`}),o})(t,a,e,i);return await Ko(t),await Xn(t),{created:r}})(t,r.target,o);if("empty"in a)return{kind:"empty",commit:n,remaining:e};s.push({source:n,created:a.created}),o=a.created}const c=(i??[]).slice(void 0!==n?1:0).map(t=>t.oid),d=await cr(t)??o,f=void 0===n?"drop":"stop",u=await kd(t,c,r.target,o,{multiPick:!0,sequenceHead:d,onEmpty:f});return"reverted"===u.kind?{kind:"reverted",commits:[...s,...u.commits]}:u},Id=async t=>{await kt(t),await bt(t,"revert --skip");const a=await Yo(t),n=await ur(t);if(void 0===a&&(void 0===n||0===n.length))throw e("revert");const i=await Ar(t,"revert --skip"),r=await Nt(t,i);await Yn(t,r),await Ko(t),await Xn(t);const o=(n??[]).slice(1).map(t=>t.oid),s=await cr(t)??r;return kd(t,o,i,r,{multiPick:!0,sequenceHead:s,onEmpty:"stop"})},Dd=async t=>{await kt(t),await bt(t,"revert --abort");const a=await Yo(t),n=await cr(t);if(void 0===a&&void 0===n)throw e("revert");const i=await Ar(t,"revert --abort"),r=n??await Nt(t,i);return await mr(t,{branch:i,target:r,clearHead:Ko}),{head:r,branch:i}},Td=(t,e)=>Object.freeze({run:a=>(e(),xd(t,a)),continue:()=>(e(),Ed(t)),skip:()=>(e(),Id(t)),abort:()=>(e(),Dd(t))}),Md=(t,e)=>`${t}/${e}`,Sd=(t,e)=>void 0===t||t(e),Hd=t=>({kind:"delete",path:t.path,mode:t.mode,id:void 0,previousId:t.id,previousMode:t.mode}),Ad=t=>({kind:"add",path:t.path,mode:t.mode,id:t.id,previousId:void 0,previousMode:void 0}),Nd=t=>({kind:"noop",path:t.path,mode:t.mode,id:t.id,previousId:t.id,previousMode:t.mode}),Od={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,fileSize:0},Ld=t=>({...Od,mode:t.mode,id:t.id,flags:{...at,skipWorktree:!0},path:t.path}),Ud=t=>t.flags.skipWorktree?{...t,flags:{...t.flags,skipWorktree:!1}}:t,Pd=async(t,e)=>{const a=t.layout.workDir,n=await gt(t);try{const i=(await yt(t)).entries.filter(t=>0===t.flags.stage),r=await(async(t,e,a,n)=>{const i=[],r=[],o=[];for(const s of a){if(Sd(n.matcher,s.path)){i.push(s);continue}const a=Md(e,s.path),c=await t.fs.exists(a);c&&await Pe(t,a,s.id)&&!0!==n.force?o.push(s):r.push({entry:s,present:c})}return{included:i,removable:r,retained:o}})(t,a,i,e),o=await(async(t,e,a)=>{const n=[];for(const{entry:t,present:e}of a.removable)n.push(e?Hd(t):Nd(t));for(const i of a.included){const a=await t.fs.exists(Md(e,i.path));n.push(a?Nd(i):Ad(i))}const i={add:0,update:0,delete:0,noop:0};for(const t of n)i[t.kind]+=1;return{entries:n,stats:i}})(t,a,r),s=await Ue(t,{changeset:o,force:!0,workdir:a}),c=((t,e)=>{const a=new Map;for(const t of e)a.set(t.path,t);const n=[];for(const e of t.included)n.push(a.get(e.path)??Ud(e));for(const{entry:e}of t.removable)n.push(Ld(e));for(const e of t.retained)n.push(Ud(e));return n})(r,s.writtenEntries);return await n.commit(c),{materialized:s.written,removed:s.deleted,retained:r.retained.map(t=>t.path)}}finally{await n.release()}},Cd=async t=>{await kt(t),await bt(t,"sparse-checkout"),await It(t)},_d=async t=>{await Cd(t);const e=await Kt(t);if(!0!==e.core?.sparseCheckout)return{cone:!1,patterns:[]};const a=!0===e.core.sparseCheckoutCone,n=await Ce(t)??"";return"cone"===(i=Re(n,a).spec).mode?{cone:!0,patterns:[...i.recursive].sort()}:{cone:!1,patterns:i.rules.map(t=>t.source)};var i},Rd=(t,e)=>void 0===e?{matcher:t}:{matcher:t,force:e},Fd=async(t,e,a,n)=>{const i=await Pd(t,Rd(qe(e),n));return await je(t,a),await _e(t,{sparseCheckout:"true",sparseCheckoutCone:"cone"===e.mode?"true":"false"}),Gd("cone"===e.mode,i)},Wd=async(t,e)=>{if(await Cd(t),0===e.patterns.length)throw o("patterns","set requires at least one pattern");const a=await Kt(t),n=e.cone??a.core?.sparseCheckoutCone??!0,{spec:i,text:r}=zd(n,e.patterns);return Fd(t,i,r,e.force)},jd=async(t,e)=>{if(await Cd(t),0===e.patterns.length)throw o("patterns","add requires at least one pattern");const a=await Kt(t);if(!0!==a.core?.sparseCheckout)throw o("action","add requires sparse checkout to be enabled");const n=!0===a.core.sparseCheckoutCone,i=await Ce(t)??"",{spec:r,text:s}=Vd(n,i,e.patterns);return Fd(t,r,s,e.force)},qd=async(t,e)=>{await Cd(t);const a=await ht(t);if(void 0===a)throw o("action","reapply requires sparse checkout to be enabled");const n=await Kt(t),i=await Pd(t,Rd(a,e?.force));return Gd(!0===n.core?.sparseCheckoutCone,i)},Bd=async(t,e)=>{await Cd(t);const a=await Pd(t,Rd(void 0,e?.force));return await _e(t,{sparseCheckout:"false"}),Gd(!1,a)},zd=(t,e)=>{if(t){const t=Fe(e);return{spec:t,text:We(t)}}const a=e.join("\n");return{spec:Re(a,!1).spec,text:a}},Vd=(t,e,a)=>{if(t){const t=Re(e,!0).spec,n="cone"===t.mode?[...t.recursive,...a]:a,i=Fe(n);return{spec:i,text:We(i)}}const n=(""===e?a:[e,...a]).join("\n");return{spec:Re(n,!1).spec,text:n}},Gd=(t,e)=>({cone:t,materialized:e.materialized,removed:e.removed,retained:e.retained}),Xd=(t,e)=>Object.freeze({list:()=>(e(),_d(t)),set:a=>(e(),Wd(t,a)),add:a=>(e(),jd(t,a)),reapply:a=>(e(),qd(t,a)),disable:a=>(e(),Bd(t,a))}),Yd="refs/stash",Kd=new TextEncoder,Zd=(t,e)=>Xe(t,Yd,Ye(t.layout.gitDir,Yd),Kd.encode(`${e}\n`)),Jd=async t=>{const e=await Ot(t,Yd),a=e.length-1;return e.map((t,n)=>{const i=e[a-n];return{index:n,selector:`stash@{${n}}`,stash:i.newId,message:i.message}})},Qd=async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);return a.data.tree},tf=async(t,e,a)=>{const n=`${t.layout.workDir}/${e}`,i=a.isSymbolicLink?(new TextEncoder).encode(await t.fs.readlink(n)):await t.fs.read(n);return{id:await Je(t,i,{write:!0}),mode:Ht(a)}},ef=async(e,a={})=>{await kt(e),await bt(e,"stash"),await It(e);const n=await $t(e),i=await(async(e,a)=>{const n=await(async(e,a)=>{if("direct"===a.kind)return a.id;try{return await Nt(e,a.target)}catch(e){if(e instanceof t&&"REF_NOT_FOUND"===e.data.code)throw k();throw e}})(e,a),i=await mt(e,n);if("commit"!==i.type)throw pt("commit",i.type,n);return{b:n,bTree:i.data.tree,branchRef:"symbolic"===a.kind?a.target:void 0,subject:ga(i.data.message)}})(e,n),r=await gt(e);try{const t=await yt(e),n=await Wt(e,t.entries),o=await(async(t,e)=>{const a=[];let n=!1;for(const i of e.entries){if(0!==i.flags.stage)continue;if(i.flags.skipWorktree){a.push(i);continue}const e=await qt(t,i);if("absent"===e){n=!0;continue}if("unchanged"===e){a.push(i);continue}n=!0;const r=await t.fs.lstat(`${t.layout.workDir}/${i.path}`),{id:o,mode:s}=await tf(t,i.path,r);a.push(Ri(i.path,o,s))}return{entries:a,dirty:n}})(e,t),s=a.includeUntracked?await(async(t,e)=>{const a=new Set(e.entries.map(t=>t.path)),n=await Dt(t),i=[],r=[];for await(const{path:e,stat:o}of Tt(t,{ignore:n})){if(a.has(e))continue;const{id:n,mode:s}=await tf(t,e,o);r.push(Ri(e,n,s)),i.push(e)}return{paths:i,entries:r}})(e,t):{paths:[],entries:[]};if(!(n!==i.bTree||o.dirty||s.paths.length>0))return{kind:"no-local-changes"};const c=await af(e,{base:i,iTree:n,working:o,untracked:s,opts:a});return await(async(t,e,a)=>{const n=await(async t=>{const e=await Jt(t).resolveDirect(Yd);return"direct"===e.kind?e.id:Pt})(t);await Zd(t,e);const i=await ze(t);await Ve(t,Yd,{oldId:n,newId:e,identity:i,message:Ge(a)})})(e,c.stash,c.message),await of(e,r,{base:i,iTree:n,untracked:s,opts:a}),{kind:"saved",stash:c.stash,message:c.message}}finally{await r.release()}},af=async(t,e)=>{const{base:a,iTree:n,working:i,untracked:r,opts:o}=e,s=await ze(t),c=void 0!==(d=a.branchRef)&&d.startsWith("refs/heads/")?d.slice(11):"(no branch)";var d;const f=a.b.slice(0,7),u=a.subject,l=void 0!==o.message?((t,e)=>`On ${t}: ${e}`)(c,o.message):((t,e,a)=>`WIP on ${t}: ${e} ${a}`)(c,f,u),w=(e,a,n)=>ee(t,{tree:e,parents:a,author:s,committer:s,message:n,extraHeaders:[]}),h=await w(n,[a.b],((t,e,a)=>`index on ${t}: ${e} ${a}`)(c,f,u)),m=await Wt(t,i.entries);if(0===r.paths.length)return{stash:await w(m,[a.b,h],l),message:l};const p=await Wt(t,r.entries),g=await w(p,[],((t,e,a)=>`untracked files on ${t}: ${e} ${a}`)(c,f,u));return{stash:await w(m,[a.b,h,g],l),message:l}},nf=async t=>(await kt(t),{entries:await Jd(t)}),rf=async(t,e={})=>(await kt(t),await bt(t,"stash drop"),(async(t,e)=>{const a=await Ot(t,Yd),n=a.length-1-e,i=a[n];if(void 0===i)throw U(e,a.length);const r=a[n+1],o=a.filter((t,e)=>e!==n).map(t=>t===r?{...t,oldId:i.oldId}:t);if(0===o.length)return await Jt(t).removeLoose(Yd),await Be(t,Yd),{dropped:i.newId,remaining:0};const s=o[o.length-1];return await Zd(t,s.newId),await Lt(t,Yd,o),{dropped:i.newId,remaining:o.length}})(t,e.index??0)),of=async(t,e,a)=>{const{base:n,iTree:i,untracked:r,opts:o}=a,s=await yt(t),c=!0===o.keepIndex?i:n.bTree,d=await vt(t,{targetTree:c,currentIndex:s,force:!0,forceRewriteAll:!0});if(await e.commit(d.newIndexEntries),!0===o.includeUntracked)for(const e of r.paths)await Wi(t,e)},sf=async(t,e={})=>{await kt(t),await bt(t,"stash apply"),await It(t);const a=await(async(t,e)=>{const a=await Ot(t,Yd),n=a[a.length-1-e];if(void 0===n)throw U(e,a.length);return n.newId})(t,e.index??0),n=await(async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);const[n,i,r]=a.data.parents;if(void 0===n||void 0===i)throw Ke("ref does not point at a stash commit");return{base:n,indexParent:i,untrackedParent:r,wTree:a.data.tree}})(t,a),i=await Qd(t,n.base),r=void 0!==n.untrackedParent?await Qd(t,n.untrackedParent):void 0,o=await gt(t);try{const s=await yt(t),c=await Wt(t,s.entries);if(void 0!==r){const e=await(async(t,e)=>{const a=await jt(t,e),n=[];for(const e of a.entries.keys())await t.fs.exists(`${t.layout.workDir}/${e}`)&&n.push(e);return n})(t,r);if(e.length>0)throw P(e)}const d=await Xi(t,{baseTree:i,oursTree:c,theirsTree:n.wTree,currentIndex:s});if("would-overwrite"===d.kind)throw P(d.paths);return"conflict"===d.kind?(await o.commit(d.indexEntries),{kind:"conflict",conflicts:d.conflicts.map(t=>({path:t.path,type:t.type}))}):(!0===e.restoreIndex&&await(async(t,e,a)=>{const n=await Qd(t,a.indexParent),i=await(async(t,e)=>{const[a,n,i]=await Promise.all([void 0!==e.baseTree?jt(t,e.baseTree):Promise.resolve(void 0),jt(t,e.oursTree),jt(t,e.theirsTree)]),r=await $n(a,n,i,qi(t));return r.cleanMerge?{kind:"clean",mergedTree:await zi(t,r.outcomes)}:{kind:"conflict",conflicts:r.conflicts}})(t,{baseTree:a.bTree,oursTree:a.cTree,theirsTree:n});if("clean"!==i.kind)return;const r=await Ze(t,{targetTree:i.mergedTree,currentIndex:a.currentIndex});await e.commit(r)})(t,o,{bTree:i,cTree:c,indexParent:n.indexParent,currentIndex:s}),void 0!==r&&await(async(t,e)=>{const a=await jt(t,e);for(const[e,n]of a.entries){const a=await Bt(t,n.id,{maxBytes:Mt});await Fi(t,e,a.content)}})(t,r),{kind:"applied",stash:a})}finally{await o.release()}},cf=async(t,e={})=>{const a=await sf(t,e);if("conflict"===a.kind)return a;const n=await rf(t,{index:e.index??0});return{kind:"applied",stash:a.stash,dropped:n.dropped}},df=(t,e)=>Object.freeze({push:a=>(e(),ef(t,a)),list:()=>(e(),nf(t)),apply:a=>(e(),sf(t,a)),pop:a=>(e(),cf(t,a)),drop:a=>(e(),rf(t,a))}),ff="refs/tags/",uf=async t=>{await kt(t);const e=`${t.layout.gitDir}/refs/tags`;if(!await t.fs.exists(e))return{tags:[]};const a=await t.fs.readdir(e),n=[];for(const e of a){if(!e.isFile)continue;const a=`${ff}${e.name}`,i=await Nt(t,a);n.push({name:a,id:i})}return n.sort((t,e)=>t.name<e.name?-1:1),{tags:n}},lf=async(e,a)=>{await kt(e);const n=At(`${ff}${a.name}`),i=void 0!==a.target?a.target:await hf(e),r=/^[0-9a-f]{40}$/.test(i)?i:await Nt(e,i),o=`tag: ${a.name}`;try{await xt(e,n,r,!0===a.force?{reflogMessage:o}:{expected:"absent",reflogMessage:o})}catch(e){if(e instanceof t&&"REF_UPDATE_CONFLICT"===e.data.code)throw C(n);throw e}return{name:n,id:r}},wf=async(t,e)=>{await kt(t);const a=At(`${ff}${e.name}`);if(!await t.fs.exists(`${t.layout.gitDir}/${a}`))throw _(a);return await xt(t,a,Pt,{delete:!0}),{name:a}},hf=async t=>{const e=await $t(t);return"direct"===e.kind?e.id:Nt(t,e.target)},mf=(t,e)=>Object.freeze({list:()=>(e(),uf(t)),create:a=>(e(),lf(t,a)),delete:a=>(e(),wf(t,a))}),pf=async(t,e={})=>{await kt(t);const a=await gf(t,e.from??"HEAD"),n=await yf(t,e.excluding??[]),i=e.before,r=[];let o=0;for await(const s of ae(t,{from:[a],until:n,order:"first-parent"}))if(!(void 0!==i&&s.data.committer.timestamp>=i.getTime()/1e3)&&(r.push({id:s.id,tree:s.data.tree,parents:s.data.parents,author:s.data.author,committer:s.data.committer,message:s.data.message}),o+=1,void 0!==e.limit&&o>=e.limit))break;return r},gf=async(t,e)=>{if(/^[0-9a-f]{40}$/.test(e))return e;const a=[e,`refs/heads/${e}`,`refs/tags/${e}`];for(const e of a)try{return await Nt(t,At(e))}catch{}return Nt(t,At(e))},yf=async(t,e)=>{const a=[];for(const n of e)if(/^[0-9a-f]{40}$/.test(n))a.push(n);else try{a.push(await Nt(t,At(n)))}catch{}return a},vf=async(t,e)=>{await kt(t),await bt(t,"merge"),await It(t);const n=await $t(t);if("symbolic"!==n.kind)throw a("merge","cannot merge with detached HEAD");const i=await Nt(t,n.target),r=await xr(t,e.target);if(i===r)return{kind:"up-to-date",id:i};const[o]=await Ae(t,[i,r]);if(o===r)return{kind:"up-to-date",id:i};if(o===i&&!0!==e.noFastForward)return await xt(t,n.target,r,{expected:i,reflogMessage:`${e.reflogLabel??`merge ${e.target}`}: Fast-forward`}),{kind:"fast-forward",id:r,branch:n.target};if(!0===e.fastForwardOnly)throw R(n.target,i,r);return $f(t,e,n.target,i,r,o)},kf="merge:write-files",bf=new Set(["rename-rename","gitlink"]),$f=async(t,e,a,n,i,r)=>{t.progress.start(kf);try{const o=await Ef(t,n,i,r);return"conflict"===o.kind?Mf(t,e,o,n,i):xf(t,e,a,n,i,o.tree)}finally{t.progress.end(kf)}},xf=async(t,e,a,n,i,r)=>{const o=await Wf(t,e),s={tree:r,parents:[n,i],author:o,committer:jf(e,o),message:Dr(e.message??`Merge ${e.target}`,{allowEmpty:!1}),extraHeaders:[]},c=await ee(t,s);return await xt(t,a,c,{expected:n,reflogMessage:`${e.reflogLabel??`merge ${e.target}`}: Merge made by the 'tsgit' strategy.`}),{kind:"merge",id:c,branch:a,parents:[n,i]}},Ef=async(t,e,a,n)=>{const i=await qf(t,e),r=await qf(t,a),o=void 0!==n?await qf(t,n):void 0,[s,c,d]=await Promise.all([jt(t,i),jt(t,r),void 0!==o?jt(t,o):Promise.resolve(void 0)]),f=If(t),u=await $n(d,s,c,f);return u.cleanMerge?{kind:"clean",tree:await Df(t,u.outcomes)}:{kind:"conflict",outcomes:u.outcomes,conflicts:u.conflicts}},If=t=>async(e,a,n,i)=>{const[r,o,s]=await Promise.all([Bt(t,e.ourId,{maxBytes:Za}),Bt(t,e.theirId,{maxBytes:Za}),void 0!==e.baseId?Bt(t,e.baseId,{maxBytes:Za}):Promise.resolve(void 0)]);return mn(s?.content,r.content,o.content)},Df=async(t,e)=>{const a=await(async(t,e)=>{const a=[];for(const n of e)if("resolved-deleted"!==n.status&&"conflict"!==n.status){if("resolved-merged"===n.status){const e=await St(t,{type:"blob",content:n.bytes,id:""});a.push({path:n.path,id:e,mode:n.mode});continue}a.push({path:n.path,id:n.id,mode:n.mode})}return a})(t,e);return Tf(t,a)},Tf=async(t,e,a=0)=>{if(a>4096)throw ta(a);const{files:n,subdirs:i}=(t=>{const e=[],a=new Map;for(const n of t){const t=n.path.indexOf("/");if(-1===t){e.push(n);continue}const i=n.path.slice(0,t),r={path:n.path.slice(t+1),id:n.id,mode:n.mode},o=a.get(i);void 0===o?a.set(i,[r]):o.push(r)}return{files:e,subdirs:a}})(e),r=await Promise.all(Array.from(i,async([e,n])=>({name:e,id:await Tf(t,n,a+1),mode:ct.DIRECTORY}))),o=n.map(t=>({name:t.path,id:t.id,mode:t.mode}));return he(t,[...o,...r])},Mf=async(t,e,a,n,i)=>{Sf(a.conflicts);const r=await ht(t),o=await gt(t);try{await Af(t,a.outcomes,a.conflicts,r),await Bn(t,n),await(async(t,e)=>{await t.fs.writeUtf8(Fn(t),`${e}\n`)})(t,i);const s=Dr(e.message??`Merge ${e.target}`,{allowEmpty:!1});await qn(t,s);const c=Ff(a.outcomes,a.conflicts,r);await o.commit(c)}finally{await o.release()}return{kind:"conflict",conflicts:a.conflicts.map(t=>({path:t.path,type:t.type})),mergeHead:i,origHead:n}},Sf=t=>{for(const e of t)if(bf.has(e.type))throw a("merge",`conflict type '${e.type}' not supported in v1 (path=${e.path})`)},Hf=(t,e)=>void 0!==t&&!t(e),Af=async(t,e,a,n)=>{await Nf(e,32,e=>Of(t,e,n)),await Nf(a,32,e=>Lf(t,e))},Nf=async(t,e,a)=>{let n=0;const i=[],r=async()=>{for(;n<t.length;){const e=t[n++];if(void 0===e)break;await a(e)}},o=Math.min(e,t.length);for(let t=0;t<o;t++)i.push(r());await Promise.all(i)},Of=async(t,e,a)=>{if("unchanged"===e.status||"resolved-known"===e.status){if(Hf(a,e.path))return;const n=await Bt(t,e.id,{maxBytes:Za});return void await Pf(t,e.path,n.content)}"resolved-merged"!==e.status?"resolved-deleted"===e.status&&await Cf(t,e.path):await Pf(t,e.path,e.bytes)},Lf=async(t,e)=>{const a=await Uf(t,e);void 0!==a&&await Pf(t,e.path,a)},Uf=async(t,e)=>{if("content"===e.type&&void 0!==e.conflictContent)return e.conflictContent;if("binary"===e.type&&void 0!==e.ourId)return(await Bt(t,e.ourId,{maxBytes:Za})).content;if(("add-add"===e.type||"type-change"===e.type)&&void 0!==e.ourId)return(await Bt(t,e.ourId,{maxBytes:Za})).content;if("modify-delete"===e.type){const a=e.ourId??e.theirId;if(void 0!==a)return(await Bt(t,a,{maxBytes:Za})).content}if("content"===e.type&&void 0!==e.ourId&&void 0!==e.theirId){const[a,n]=await Promise.all([Bt(t,e.ourId,{maxBytes:Za}),Bt(t,e.theirId,{maxBytes:Za})]);return on([a.content],[n.content])}},Pf=async(t,e,a)=>{const n=`${t.layout.workDir}/${e}`,i=_f(n);void 0!==i&&await t.fs.mkdir(i),await t.fs.write(n,a)},Cf=async(t,e)=>{const a=`${t.layout.workDir}/${e}`;await t.fs.exists(a)&&await t.fs.rm(a)},_f=t=>{const e=t.lastIndexOf("/");if(!(e<=0))return t.slice(0,e)},Rf=t=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:t,uid:0,gid:0,fileSize:0}),Ff=(t,e,a)=>{const n=[];for(const e of t)"unchanged"!==e.status&&"resolved-known"!==e.status||n.push(Hf(a,e.path)?Qe({path:e.path,id:e.id,mode:e.mode}):{...Rf(e.mode),id:e.id,flags:at,path:e.path});const i=ka(e,Rf),r=[...n,...i];return r.sort((t,e)=>t.path<e.path?-1:t.path>e.path?1:t.flags.stage-e.flags.stage),r},Wf=async(t,e)=>{const a=await Kt(t),n=a.user?{name:a.user.name,email:a.user.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}:void 0,i={};return void 0!==e.author&&(i.explicit=e.author),void 0!==n&&(i.configUser=n),Er(i)},jf=(t,e)=>{const a={author:e};return void 0!==t.committer&&(a.explicit=t.committer),Ir(a)},qf=async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);return a.data.tree},Bf=async(t,e,a,n={})=>{await kt(t),await bt(t,"mv"),await It(t);const i=e.map(t=>Zn(t)),[r]=i;if(void 0===r)throw s();Jf(i);const o=Zn(ru(a)),c=await gt(t,void 0!==n.breakStaleLockMs?{breakStaleLockMs:n.breakStaleLockMs}:{});try{const e=await zf(t),s=await Vf(t,r,a,o);if("rename"===s.kind&&i.length>1)throw F(r,s.target);const{planned:d,skipped:f}=await Gf(t,e,i,s,n);Qf(d);const u=tu(d);if(!0===n.dryRun)return{moved:u,skipped:f};eu(e,d);for(const e of d)await ti(t,e.source,e.target);return await c.commit(Array.from(e.values())),{moved:u,skipped:f}}finally{await c.release()}},zf=async e=>{const a=await yt(e).catch(e=>{if(e instanceof t&&("FILE_NOT_FOUND"===(a=e.data.code)||"INVALID_INDEX_HEADER"===a||"INVALID_INDEX_ENTRY"===a))return{entries:[]};var a;throw e}),n=new Map;for(const t of a.entries)n.set(t.path,t);return n},Vf=async(t,e,a,n)=>{const i=await ou(t,n);if(!0===i?.isDirectory&&!0!==i.isSymbolicLink)return{kind:"into-dir",destDir:n};if(a.endsWith("/"))throw j(e,a);return{kind:"rename",target:n}},Gf=async(t,e,a,n,i)=>{const r=[],o=[];for(const s of a){const a="rename"===n.kind?n.target:iu(n.destDir,q(s)),c=await Xf(t,e,s,a,i);if("skip"in c){if(!0===i.skipErrors){o.push({source:s,reason:c.skip});continue}throw nu(c.skip,s,a)}r.push({source:s,target:a,entries:c.entries})}return{planned:r,skipped:o}},Xf=async(t,e,a,n,r)=>{const o=Yf(e,a);if("untracked"===o.kind)return{skip:"source-not-tracked"};if(!await Kf(t,a,o.kind))return{skip:"bad-source"};if(n===a||n.startsWith(`${a}/`))return{skip:"into-self"};const s=i(n);if(""!==s&&!await su(t,s))throw j(a,n);return await Zf(t,e,n,o.kind,!0===r.force)?{kind:o.kind,entries:o.entries}:{skip:"destination-exists"}},Yf=(t,e)=>{const a=t.get(e);if(void 0!==a)return{kind:"file",entries:[a]};const n=`${e}/`,i=Array.from(t.values()).filter(t=>t.path.startsWith(n));return i.length>0?{kind:"directory",entries:i}:{kind:"untracked"}},Kf=async(t,e,a)=>{const n=await ou(t,e);return void 0!==n&&("directory"===a?n.isDirectory&&!n.isSymbolicLink:n.isFile||n.isSymbolicLink)},Zf=async(t,e,a,n,i)=>!(e.has(a)||void 0!==await ou(t,a))||"file"===n&&i,Jf=t=>{for(const e of t)for(const a of t)if(a!==e&&a.startsWith(`${e}/`))throw W(a,e)},Qf=t=>{const e=new Set;for(const a of t){if(e.has(a.target))throw B(a.source,a.target);e.add(a.target)}},tu=t=>{const e=[];for(const a of t)for(const t of a.entries)e.push({from:t.path,to:au(t,a.source,a.target)});return e.sort((t,e)=>t.from<e.from?-1:t.from>e.from?1:0)},eu=(t,e)=>{for(const a of e)for(const e of a.entries){const n=au(e,a.source,a.target);t.delete(e.path),t.set(n,{...e,path:n})}},au=(t,e,a)=>`${a}${t.path.slice(e.length)}`,nu=(t,e,a)=>{switch(t){case"source-not-tracked":return X(e,a);case"bad-source":return G(e,a);case"destination-exists":return V(e,a);case"into-self":return z(e,a)}},iu=(t,e)=>`${t}/${e}`,ru=t=>t.endsWith("/")?t.slice(0,-1):t,ou=async(t,e)=>t.fs.lstat(((t,e)=>`${t.layout.workDir}/${e}`)(t,e)).catch(()=>{}),su=async(t,e)=>{const a=await ou(t,e);return!0===a?.isDirectory&&!0!==a.isSymbolicLink},cu="refs/heads/",du=async(t,e={})=>{await kt(t),await bt(t,"pull"),await It(t);const a=await $t(t),n="symbolic"===a.kind?(i=a.target).startsWith(cu)?i.slice(11):i:void 0;var i;const r="symbolic"===a.kind?a.target:ea.from("HEAD"),{remote:o,branch:s}=await(async(t,e,a,n)=>{const i=await Kt(t),r=void 0!==e?i.branch?.get(e):void 0,o=a.remote??r?.remote??"origin",s=a.branch??(t=>{if(void 0!==t)return t.startsWith(cu)?t.slice(11):t})(r?.merge);if(void 0===s)throw Y(n);return{remote:o,branch:s}})(t,n,e,r),c=await As(t,{remote:o,...void 0!==e.prune?{prune:e.prune}:{},...void 0!==e.depth?{depth:e.depth}:{}}),d=await Nt(t,`refs/remotes/${o}/${s}`);return{fetch:c,merge:await vf(t,{target:d,message:e.message??`Merge branch '${s}' of ${c.url}`,reflogLabel:"pull",...void 0!==e.fastForwardOnly?{fastForwardOnly:e.fastForwardOnly}:{},...void 0!==e.noFastForward?{noFastForward:e.noFastForward}:{},...void 0!==e.author?{author:e.author}:{},...void 0!==e.committer?{committer:e.committer}:{}})}},fu="push:enumerate-objects",uu="push:upload",lu=wt.from("0".repeat(40)),wu="refs/heads/",hu=new Set(["side-band-64k","side-band"]),mu=async(t,e={})=>{await kt(t),t.progress.start(fu);try{const a=e.remote??"origin",n=await vu(t,a),i=await ku(t,e.refspecs),r=vo(t,void 0!==t.config?.auth?{auth:t.config.auth}:{}),o=await(async(t,e,a)=>Io(t,e,a,"git-receive-pack"))(t,r,n),s=(await bu(t,i,o,a,e)).filter(t=>t.localOid!==t.remoteOid);return 0===s.length?{remote:a,url:n,pushedRefs:[]}:(await pu(t,e.noVerify??!1,a,n,s),{remote:a,url:n,pushedRefs:await Mu(t,r,n,o,s,a)})}finally{t.progress.end(fu)}},pu=async(t,e,a,n,i)=>{if(e)return;const r=i.map(gu).join("");await we(t,"pre-push",{args:[a,n],stdin:r})},gu=t=>`${t.parsed.isDelete?"(delete)":t.parsed.src} ${t.localOid} ${t.parsed.dst} ${t.remoteOid}\n`,yu=/^[A-Za-z0-9._-]+$/,vu=async(t,e)=>{if(!yu.test(e))throw o("remote",`invalid remote name: ${e}`);const a=await Kt(t),n=a.remote?.get(e),i=n?.pushUrl??n?.url;if(void 0===i)throw H(e);return i},ku=async(t,e)=>{if(void 0!==e&&e.length>0)return e.map(Zc);const a=await $t(t);if("symbolic"!==a.kind)throw o("refspecs","no-default-refspec (HEAD is detached)");const n=a.target;return[Zc(`${n}:${n}`)]},bu=async(t,e,a,n,i)=>{const r=$u(a.refs),o=[];for(const a of e)o.push(await xu(t,a,r,n,i));return o},$u=t=>{const e=new Map;for(const a of t)e.set(a.name,a.id);return e},xu=async(t,e,a,n,i)=>{const r=a.get(e.dst)??lu;if(e.isDelete){if(r===lu)throw o("refspecs",`delete target ${e.dst} is not advertised`);return{parsed:e,localOid:lu,remoteOid:r}}const s=await Nt(t,e.src);return await Eu(t,e,s,r,n,i),{parsed:e,localOid:s,remoteOid:r}},Eu=async(t,e,a,n,i,r)=>{const o=await Iu(t,e,i,r);if(void 0===o){if("force"!==e.force&&!0!==r.force&&n!==lu&&!await Du(t,n,a))throw R(e.dst,a,n)}else if(o!==n)throw K(e.dst,"lease-mismatch",Tu())},Iu=async(t,e,a,n)=>{if(void 0===n.forceWithLease)return;if("auto"!==n.forceWithLease)return n.forceWithLease;if(!e.dst.startsWith(wu))throw o("forceWithLease","lease-on-non-branch");const i=e.dst.slice(11);return Nt(t,`refs/remotes/${a}/${i}`)},Du=async(t,e,a)=>{for await(const n of ae(t,{from:[a],ignoreMissing:!0}))if(n.id===e)return!0;return!1},Tu=()=>({unpackOk:!0,refUpdates:[]}),Mu=async(t,e,a,n,i,r)=>{const o=i.filter(t=>!t.parsed.isDelete).map(t=>t.localOid),s=n.refs.map(t=>t.id),c=await Su(t,o,s),d=await na(t,{oids:c}),f=(t=>{const e=aa.filter(t=>t!==se);return[...oe(t,e),se]})(n.capabilities),u=(t=>{if(0===t.updates.length)throw ft();const e=t.updates.map((e,a)=>((t,e)=>{const a=0===e.length?"":`\0${e.join(" ")}`;return Hn.encode(`${t.oldId} ${t.newId} ${t.name}${a}\n`)})(e,0===a?t.capabilities:[])),a=ut(e),n=new Uint8Array(a.byteLength+t.packfile.byteLength);return n.set(a,0),n.set(t.packfile,a.byteLength),n})({updates:i.map(Hu),capabilities:f,packfile:d.bytes}),l=await Au(t,e,a,u),w=await Ou(t,l,f);if(!w.unpackOk)throw K(i[0]?.parsed.dst,w.unpackError??"unpack failed",w);return await Uu(t,i,w.refUpdates,r)},Su=async(t,e,a)=>{if(0===e.length)return[];const n=[];for await(const i of ia(t,{wants:e,haves:a}))n.push(i);return n},Hu=t=>({name:t.parsed.dst,oldId:t.remoteOid,newId:t.localOid}),Au=async(t,e,a,n)=>{t.progress.start(uu);try{const i=Nu(a),r=await e.request({url:i,method:"POST",headers:{"content-type":"application/x-git-receive-pack-request",accept:"application/x-git-receive-pack-result"},body:n,...void 0!==t.signal?{signal:t.signal}:{}});if(200!==r.statusCode)throw $(r.statusCode,`git-receive-pack returned ${r.statusCode}`);return r}finally{t.progress.end(uu)}},Nu=t=>{let e;try{e=new URL(t)}catch{throw ra("invalid URL")}if(""!==e.hash)throw ra("fragment must not be set");const a=e.pathname.endsWith("/")?e.pathname.slice(0,-1):e.pathname;return`${e.protocol}//${e.host}${a}/git-receive-pack${e.search}`},Ou=async(t,e,a)=>{const n=ha(e.body),i=re(n);if(Lu(a)){const e=oa(i,{onProgress:e=>t.progress.update(uu,0,void 0,Z(e))});return On(re(e))}return On(i)},Lu=t=>t.some(t=>hu.has(t)),Uu=async(t,e,a,n)=>{const i=new Map;for(const t of a)i.set(t.name,t);const r=[];for(const a of e){const e=i.get(a.parsed.dst),o=!0===e?.accepted;o&&await Pu(t,a,n),r.push({name:a.parsed.dst,oldId:a.remoteOid,newId:a.localOid,status:o?"ok":"rejected",...void 0!==e?.reason?{reason:e.reason}:{}})}return r},Pu=async(t,e,a)=>{if(!e.parsed.dst.startsWith(wu))return;if(e.parsed.isDelete)return;const n=`refs/remotes/${a}/${e.parsed.dst.slice(11)}`;Cu(n)&&await xt(t,n,e.localOid,{reflogMessage:"update by push"})},Cu=t=>{try{return At(t),!0}catch{return!1}},_u=t=>At(t),Ru=async(t,e={})=>(await kt(t),"exists"===e.action?Wu(t,e.ref):"delete"===e.action?ju(t,e):"expire"===e.action?Bu(t,e):Fu(t,e.ref??"HEAD")),Fu=async(t,e)=>{const a=_u(e),n=await Ot(t,a),i=n.length-1,r=n.map((t,e)=>({index:e,selector:`${a}@{${e}}`,entry:n[i-e]}));return{kind:"show",ref:a,entries:r}},Wu=async(t,e)=>({kind:"exists",exists:await Qt(t,_u(e))}),ju=async(t,e)=>{const a=_u(e.ref);if(!await Qt(t,a))throw sa(a);const n=await Ot(t,a);if(!Number.isInteger(e.index)||e.index<0)throw te(a,e.index,n.length);const i=n.length-1-e.index;if(i<0)throw te(a,e.index,n.length);const r=n[i],o=qu(n,i,!0===e.rewrite);return await Lt(t,a,o),{kind:"delete",removed:r}},qu=(t,e,a)=>{const n=t[e],i=t[e+1];return t.filter((t,a)=>a!==e).map(t=>a&&t===i?{...t,oldId:n.oldId}:t)},Bu=async(t,e)=>{const a=Math.floor(Date.now()/1e3),n=zu(e.expire??"90.days.ago",a),i=zu(e.expireUnreachable??"30.days.ago",a),r=await Gu(t),o=!0===e.all?await ca(t):[_u(e.ref??"HEAD")];let s=0,c=0;for(const e of o){const a=await Ot(t,e),o=a.filter(t=>Vu(t,r,n,i));s+=a.length-o.length,c+=o.length,o.length!==a.length&&await Lt(t,e,o)}return{kind:"expire",removed:s,kept:c}},zu=(t,e)=>{const a=Cn(t,e);if(void 0===a)throw y(t);return a},Vu=(t,e,a,n)=>{const i=e.has(t.newId)?a:n;return t.identity.timestamp>=i},Gu=async t=>{const e=await Xu(t),a=new Set;if(0===e.length)return a;for await(const n of ae(t,{from:e,ignoreMissing:!0}))a.add(n.id);return a},Xu=async t=>{const e=new Set;for(const a of await Le(t)){const n=await Yu(t,a);void 0!==n&&e.add(n)}return[...e]},Yu=async(e,a)=>{try{return await Nt(e,a)}catch(e){if(e instanceof t)return;throw e}},Ku=async(t,e)=>{await kt(t),"hard"===e.mode&&await bt(t,"reset --hard"),await It(t);const a=await Qu(t,e.target);"mixed"===e.mode?await Zu(t,a):"hard"===e.mode&&await Ju(t,a);const n=await $t(t),i="symbolic"===n.kind?n.target:void 0;return await xt(t,i??"HEAD",a,{reflogMessage:`reset: moving to ${e.target}`}),{mode:e.mode,id:a,branch:i}},Zu=async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);const n=await ht(t),i=await gt(t);try{const e=await yt(t),r=await Ze(t,{targetTree:a.data.tree,currentIndex:e,...void 0!==n?{sparse:n}:{}});await i.commit(r)}finally{await i.release()}},Ju=async(t,e)=>{const a=await mt(t,e);if("commit"!==a.type)throw pt("commit",a.type,e);const n=await ht(t),i=await gt(t);try{const e=await yt(t),r=await vt(t,{targetTree:a.data.tree,currentIndex:e,force:!0,forceRewriteAll:!0,...void 0!==n?{sparse:n}:{}});(r.written>0||r.deleted>0||void 0!==n)&&await i.commit(r.newIndexEntries)}finally{await i.release()}},Qu=async(t,e)=>{if(/^[0-9a-f]{40}$/.test(e))return e;const a="HEAD"===e?["HEAD"]:[e,`refs/heads/${e}`,`refs/tags/${e}`];for(const e of a)try{return await Nt(t,e)}catch{}throw y(e)},tl=async(e,a,n={})=>{if(await kt(e),await bt(e,"rm"),await It(e),0===a.length)throw s();const{matcher:i,literalMustMatch:r}=ni(a),o=await gt(e,void 0!==n.breakStaleLockMs?{breakStaleLockMs:n.breakStaleLockMs}:{});try{const a=await yt(e).catch(e=>{if(e instanceof t&&("FILE_NOT_FOUND"===(a=e.data.code)||"INVALID_INDEX_HEADER"===a||"INVALID_INDEX_ENTRY"===a))return{entries:[]};var a;throw e}),s=new Map;for(const t of a.entries)s.set(t.path,t);const c=[],d=[];for(const[t,e]of s)Xa(i,t)&&(c.push(t),d.push(e));oi(r,c),!0!==n.force&&await el(e,d,!0===n.cached);for(const t of c)s.delete(t);if(!n.cached)for(const a of c)await Qn(e,a).catch(e=>{if(!(e instanceof t&&"FILE_NOT_FOUND"===e.data.code))throw e});return await o.commit(Array.from(s.values())),{removed:c}}finally{await o.release()}},el=async(t,e,a)=>{const n=await nl(t),i=[],r=[],o=[];for(const s of e){const e=await qt(t,s);if("absent"===e)continue;const c="modified"===e,d=al(n,s);d&&c?i.push(s.path):d&&!a?r.push(s.path):c&&!a&&o.push(s.path)}if(i.length>0)throw J(i);if(r.length>0)throw Q(r);if(o.length>0)throw tt(o)},al=(t,e)=>{const a=t.get(e.path);return void 0===a||a.id!==e.id||a.mode!==e.mode},nl=async e=>{const a=await Nt(e,"HEAD").catch(e=>{if(!(e instanceof t&&"REF_NOT_FOUND"===e.data.code))throw e});if(void 0===a)return new Map;const n=await mt(e,a);if("commit"!==n.type)throw pt("commit",n.type,a);return(await jt(e,n.data.tree)).entries},il="status:scan",rl=async t=>{await kt(t);const e=await $t(t),a="symbolic"===e.kind?e.target:void 0,n="direct"===e.kind,i=await yt(t).catch(()=>({entries:[]})),r=new Map;for(const t of i.entries)r.set(t.path,t);t.progress.start(il);try{const e=((t,e)=>{let a=0,n=0;return{tick:()=>{a+=1;const i=Math.floor(a/100);i>n&&(n=i,t.update(e,a))}}})(t.progress,il),i=(await Promise.all(Array.from(r.values()).map(async a=>{const n=await sl(t,a);return e.tick(),n}))).filter(t=>void 0!==t),o=await Dt(t),s=[];for await(const{path:e}of Tt(t,{ignore:o}))r.has(e)||s.push({kind:"untracked",path:e});s.sort(ol);const c=[...i,...s];return{branch:a,detached:n,indexChanges:[],workingTreeChanges:c,clean:0===c.length}}finally{t.progress.end(il)}},ol=(t,e)=>t.path<e.path?-1:1,sl=async(t,e)=>{if(e.flags.skipWorktree)return;const a=await qt(t,e);return"absent"===a?{kind:"deleted",path:e.path}:"modified"===a?{kind:"modified",path:e.path}:void 0},cl=async(t,e={})=>{await kt(t);const a=(t=>fa(t)?wt.from(t):At(t))(e.ref??"HEAD"),n=!0===e.recursive,i=[];for await(const r of da(t,{ref:a,recursive:n,...void 0!==e.maxDepth?{maxDepth:e.maxDepth}:{}}))i.push(r);return{kind:"list",entries:i}};export{ld as $,ys as A,xs as B,$s as C,vs as D,ks as E,bs as F,Es as G,Xs as H,Ms as I,As as J,Gs as K,Ys as L,pf as M,vf as N,Bf as O,du as P,mu as Q,Pc as R,Lc as S,Ac as T,Uc as U,Ru as V,od as W,rd as X,cd as Y,fd as Z,ud as _,Kn as a,Ku as a0,jr as a1,Dd as a2,Ed as a3,xd as a4,Id as a5,tl as a6,jd as a7,Bd as a8,_d as a9,qd as aa,Wd as ab,sf as ac,rf as ad,nf as ae,cf as af,ef as ag,rl as ah,cl as ai,lf as aj,wf as ak,uf as al,Xa as am,Ho as an,ui as b,Ks as c,Zs as d,Js as e,Yc as f,wd as g,Td as h,Xd as i,df as j,mf as k,Mi as l,Si as m,Di as n,Hi as o,Oi as p,Ci as q,po as r,ho as s,lo as t,mo as u,Fo as v,Jo as w,ms as x,ps as y,gs as z};
2
- //# sourceMappingURL=index-jH0UMhh-.js.map