sliccy 6.256.22 → 6.256.23

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 (132) hide show
  1. package/dist/ui/.vite/manifest.json +181 -181
  2. package/dist/ui/assets/{account-store-d2P7Bb4k.js → account-store-BzR7PGCb.js} +1 -1
  3. package/dist/ui/assets/{account-store-C5_5VBg8.js → account-store-DQ2HCyLY.js} +1 -1
  4. package/dist/ui/assets/{adobe-BCjOpmDj.js → adobe-CN2vwjPa.js} +1 -1
  5. package/dist/ui/assets/{adobe-Dwy9Dm_F.js → adobe-Dax9StmD.js} +1 -1
  6. package/dist/ui/assets/{agent-panels-DiyAY39t.js → agent-panels-Ddnawg5n.js} +1 -1
  7. package/dist/ui/assets/{almost-bash-shell-headless-CiYtCme3.js → almost-bash-shell-headless-B5ev19bo.js} +12 -12
  8. package/dist/ui/assets/{apply-layout-VjTxAKVy.js → apply-layout-JkK-T1FF.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-BBIm9qmq.js → azure-openai-A-9oEpXX.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-Cs1GrykH.js → azure-openai-qop0qO5X.js} +1 -1
  11. package/dist/ui/assets/{cdp-HnPqc-bE.js → cdp-rEcG4j2o.js} +3 -3
  12. package/dist/ui/assets/{cerebras-CgUStZkj.js → cerebras-BkrlqYfH.js} +1 -1
  13. package/dist/ui/assets/{cerebras-DPH4vBR1.js → cerebras-Dmm7-CBN.js} +1 -1
  14. package/dist/ui/assets/{composer-speech-BkThrhp7.js → composer-speech-BceLaD00.js} +1 -1
  15. package/dist/ui/assets/{connect-surface-D3q0j5nz.js → connect-surface-C2Ofmzq0.js} +1 -1
  16. package/dist/ui/assets/{directed-approval-BcyFVMQh.js → directed-approval-wTf5_JnY.js} +1 -1
  17. package/dist/ui/assets/{emscripten-vfs-hook-DfxaPPTH.js → emscripten-vfs-hook-IkAuOJNz.js} +1 -1
  18. package/dist/ui/assets/{frozen-archive-writer-D62qyqlR.js → frozen-archive-writer-cKZjhhAy.js} +1 -1
  19. package/dist/ui/assets/{frozen-session-delete-DR7Cm1pU.js → frozen-session-delete-Cebeq5Bq.js} +1 -1
  20. package/dist/ui/assets/{frozen-session-identity-BiMSkG1d.js → frozen-session-identity-Carmm9Vs.js} +1 -1
  21. package/dist/ui/assets/{gelatiere-unit-BHXhp7VV.js → gelatiere-unit-DMNC7nR9.js} +1 -1
  22. package/dist/ui/assets/{github-DUjy16Zd.js → github-CXDjhtb5.js} +1 -1
  23. package/dist/ui/assets/{github-BSsvyrNp.js → github-_kC84FAr.js} +1 -1
  24. package/dist/ui/assets/{github-copilot-BdsOV6PD.js → github-copilot-BiGies73.js} +1 -1
  25. package/dist/ui/assets/{github-copilot-BFGUR2X2.js → github-copilot-DGpdLtXu.js} +1 -1
  26. package/dist/ui/assets/{hear-D1gFYqta.js → hear-DDGk3LG8.js} +1 -1
  27. package/dist/ui/assets/{hidden-page-input-CqgW21NQ.js → hidden-page-input-D4_JWrxu.js} +1 -1
  28. package/dist/ui/assets/{hidden-page-input-smOjBrfl.js → hidden-page-input-D8G2fX4h.js} +1 -1
  29. package/dist/ui/assets/{isomorphic-git-CRgEMe-7.js → isomorphic-git-CNj2MdIg.js} +32 -30
  30. package/dist/ui/assets/{isomorphic-git-BuOEK1OD.js → isomorphic-git-g3FQf8MI.js} +33 -31
  31. package/dist/ui/assets/{js-realm-worker-MR_DMX91.js → js-realm-worker-D5qrX-D2.js} +2 -2
  32. package/dist/ui/assets/{jsh-executor-CT-8LkHe.js → jsh-executor-BgvhpcRB.js} +3 -3
  33. package/dist/ui/assets/{kernel-worker-CLw69eCa.js → kernel-worker-DaPQ9vMZ.js} +9 -9
  34. package/dist/ui/assets/{lick-ws-bridge-BWtLseTn.js → lick-ws-bridge-CdtvLd_R.js} +1 -1
  35. package/dist/ui/assets/{lick-ws-bridge-vUOREZbX.js → lick-ws-bridge-Rl-p_lGN.js} +1 -1
  36. package/dist/ui/assets/{live-session-curation-C5_RUMgT.js → live-session-curation-C7vpvELn.js} +1 -1
  37. package/dist/ui/assets/{live-session-curation-EcFbjm8p.js → live-session-curation-CXg3ncHX.js} +1 -1
  38. package/dist/ui/assets/{live-session-snapshot-BKvm99c9.js → live-session-snapshot-CA8Z5gkw.js} +1 -1
  39. package/dist/ui/assets/{local-llm-DLlOCk8X.js → local-llm-Cq6QM-K_.js} +1 -1
  40. package/dist/ui/assets/{local-llm-DnslcUNG.js → local-llm-DAO48sWK.js} +1 -1
  41. package/dist/ui/assets/{main-DE35aQoM.js → main-ClCme0jT.js} +3 -3
  42. package/dist/ui/assets/{main-cherry-C1MYVjUn.js → main-cherry-AKGhMpSH.js} +1 -1
  43. package/dist/ui/assets/{mcp-command-CG4OdUCr.js → mcp-command-DtcTnwPM.js} +10 -10
  44. package/dist/ui/assets/{memory-curation-seam-CBnDM-UC.js → memory-curation-seam-DJ6fd-Wg.js} +1 -1
  45. package/dist/ui/assets/{memory-write-execute-ofbwtJ36.js → memory-write-execute-B8fnq-Te.js} +1 -1
  46. package/dist/ui/assets/{merge-folded-cost-into-frozen-BmCFn7S0.js → merge-folded-cost-into-frozen-NLKuGd4J.js} +1 -1
  47. package/dist/ui/assets/{mv-DjjjmXOU.js → mv-DeUDSLZ6.js} +1 -1
  48. package/dist/ui/assets/{new-session-CDre0g2p.js → new-session-DXffXZUE.js} +2 -2
  49. package/dist/ui/assets/{oauth-bootstrap-CCSibxzq.js → oauth-bootstrap-DbVugils.js} +2 -2
  50. package/dist/ui/assets/{onboarding-orchestrator-CS5mdqi8.js → onboarding-orchestrator-ZohNmt5J.js} +1 -1
  51. package/dist/ui/assets/{openai-codex-_sC4F4TM.js → openai-codex-BCtpXhOx.js} +1 -1
  52. package/dist/ui/assets/{openai-codex-CqL_thlC.js → openai-codex-Djwv_nC8.js} +1 -1
  53. package/dist/ui/assets/{openrouter-DQqmKSZV.js → openrouter-BvXS2X0g.js} +1 -1
  54. package/dist/ui/assets/{openrouter-CWzu5BKb.js → openrouter-CxKhHB69.js} +1 -1
  55. package/dist/ui/assets/{openrouter-free-Cz7F58Cj.js → openrouter-free-C0_jU6Av.js} +1 -1
  56. package/dist/ui/assets/{openrouter-free-PvTy_oTg.js → openrouter-free-CziNwktQ.js} +1 -1
  57. package/dist/ui/assets/{openrouter-oauth-Dyk7HDZK.js → openrouter-oauth-CnkjjEOJ.js} +1 -1
  58. package/dist/ui/assets/{openrouter-oauth-C-k4Ad3g.js → openrouter-oauth-qcDQl2S9.js} +1 -1
  59. package/dist/ui/assets/{panel-rpc-handlers-DXmd833I.js → panel-rpc-handlers-bfq16OWF.js} +2 -2
  60. package/dist/ui/assets/{panelize-shell-CgAAzCzt.js → panelize-shell-CfXJ9hLk.js} +1 -1
  61. package/dist/ui/assets/{pi-edit-execution-DUA8Gi6C.js → pi-edit-execution-DhVeEKVU.js} +1 -1
  62. package/dist/ui/assets/{provider-BHslCnFk.js → provider-7iaRiL0M.js} +1 -1
  63. package/dist/ui/assets/{provider-BKqZN4v_.js → provider-BgzlN1WS.js} +1 -1
  64. package/dist/ui/assets/{provider-settings-MAjahjMG.js → provider-settings-AbyCEHMB.js} +1 -1
  65. package/dist/ui/assets/provider-store-access-BioC052q.js +1 -0
  66. package/dist/ui/assets/{provider-store-access-CDdXd2U6.js → provider-store-access-BsfOPIM2.js} +1 -1
  67. package/dist/ui/assets/{providers-c4PMCqwx.js → providers-DwBNCnGG.js} +2 -2
  68. package/dist/ui/assets/{providers-26Cwby8h.js → providers-I7x_90Mf.js} +1 -1
  69. package/dist/ui/assets/{quick-llm-EceM7Mk9.js → quick-llm-DSKL4wjG.js} +1 -1
  70. package/dist/ui/assets/{realm-inprocess-Dv-cSNy9.js → realm-inprocess-DZTWGN69.js} +2 -2
  71. package/dist/ui/assets/{realm-unhandled-rejections-CpfKxnnX.js → realm-unhandled-rejections-B4zxQTRI.js} +1 -1
  72. package/dist/ui/assets/{realm-unhandled-rejections-Dnh7SEPb.js → realm-unhandled-rejections-VyRiGrVq.js} +1 -1
  73. package/dist/ui/assets/{remote-terminal-view-DJduJSob.js → remote-terminal-view-B-O1A8wW.js} +2 -2
  74. package/dist/ui/assets/{restore-DDPPcWws.js → restore-Ydxq7AVh.js} +1 -1
  75. package/dist/ui/assets/{run-hxAWIEca.js → run-BSqBVLPL.js} +1 -1
  76. package/dist/ui/assets/{run-BoMDMZZE.js → run-CYX3yrh2.js} +2 -2
  77. package/dist/ui/assets/{run-Dv0r7Fw_.js → run-DMc3IK9c.js} +2 -2
  78. package/dist/ui/assets/{serve-command-C9aiiVPO.js → serve-command-rCm9w3xp.js} +2 -2
  79. package/dist/ui/assets/{serve-runtime-B3KUChwY.js → serve-runtime-ddwluARV.js} +1 -1
  80. package/dist/ui/assets/{session-command-memory-TiKlxKms.js → session-command-memory-Bu46cxn1.js} +2 -2
  81. package/dist/ui/assets/{session-jsonl-D_lE7B3J.js → session-jsonl-BlXBagTy.js} +1 -1
  82. package/dist/ui/assets/{session-search-index-BO8HWuUf.js → session-search-index-CwyThSJF.js} +1 -1
  83. package/dist/ui/assets/{setup-feature-flags-remote-CedaafnH.js → setup-feature-flags-remote-C1ydLN84.js} +1 -1
  84. package/dist/ui/assets/{setup-model-catalog-CFy2J5Fv.js → setup-model-catalog-BHiyjq3b.js} +1 -1
  85. package/dist/ui/assets/{silent-renew-backoff-B0iE1rRp.js → silent-renew-backoff-Ckc3jul-.js} +1 -1
  86. package/dist/ui/assets/slicc-version-DsiylrIX.js +1 -0
  87. package/dist/ui/assets/{soundscape-CkSuX5Qr.js → soundscape-BOqBDWZw.js} +1 -1
  88. package/dist/ui/assets/{speak-zyniiAYa.js → speak-BEhhS9tZ.js} +1 -1
  89. package/dist/ui/assets/{sprinkle-manager-BZly_kDG.js → sprinkle-manager-B8EKfaW5.js} +1 -1
  90. package/dist/ui/assets/{sprinkle-renderer-Cg5iqZhn.js → sprinkle-renderer-CKwvddVe.js} +1 -1
  91. package/dist/ui/assets/{sudo-ByRi6WDD.js → sudo-_pZ701G_.js} +1 -1
  92. package/dist/ui/assets/{supervisor-DFQcqCqY.js → supervisor-D8xSloho.js} +1 -1
  93. package/dist/ui/assets/{sync-dialog-cjENvtdi.js → sync-dialog-CKcqjzwa.js} +1 -1
  94. package/dist/ui/assets/{transformers-env-8DePnTVc.js → transformers-env-n_MOyyO1.js} +1 -1
  95. package/dist/ui/assets/{tray-leader-CLPQGf9k.js → tray-leader-LDnlhrpQ.js} +1 -1
  96. package/dist/ui/assets/{tray-leave-runtime-DiEG7LYX.js → tray-leave-runtime-Dyx865wW.js} +1 -1
  97. package/dist/ui/assets/{tray-sidecar-BhyX43Us.js → tray-sidecar-gH-N-Ns7.js} +1 -1
  98. package/dist/ui/assets/{upgrade-detection-COVPG3cm.js → upgrade-detection-CBASjkA_.js} +1 -1
  99. package/dist/ui/assets/{upgrade-to-seven-CCg3iFUe.js → upgrade-to-seven-CZ1w3Hmr.js} +1 -1
  100. package/dist/ui/assets/{voice-reply-9UGA88Bi.js → voice-reply-uh2WRq1k.js} +1 -1
  101. package/dist/ui/assets/{wc-attach-FrDT_eLm.js → wc-attach-BnWhEkYA.js} +2 -2
  102. package/dist/ui/assets/{wc-browser-jTY_5BgQ.js → wc-browser-CS1ekMXX.js} +1 -1
  103. package/dist/ui/assets/{wc-computers-DoKdI_oA.js → wc-computers-Dct4bfvZ.js} +1 -1
  104. package/dist/ui/assets/{wc-detached-DOAhbR_j.js → wc-detached-DDSyS2KP.js} +1 -1
  105. package/dist/ui/assets/{wc-extension-CCmapnoE.js → wc-extension-CfYBgAP_.js} +2 -2
  106. package/dist/ui/assets/{wc-follower-Cx-kQSeD.js → wc-follower-CVqbfYwF.js} +3 -3
  107. package/dist/ui/assets/{wc-follower-oauth-CRODhTlO.js → wc-follower-oauth-21rynIVe.js} +1 -1
  108. package/dist/ui/assets/{wc-gelatiere-Xm0c-W_I.js → wc-gelatiere-CClRoq9I.js} +1 -1
  109. package/dist/ui/assets/{wc-live-BpRnDusq.js → wc-live-7pMjMGp_.js} +5 -5
  110. package/dist/ui/assets/{wc-nav-C8MNcYkG.js → wc-nav-CD6SGeGk.js} +2 -2
  111. package/dist/ui/assets/{wc-onboarding-BnqC5JNq.js → wc-onboarding-CEVinhTC.js} +2 -2
  112. package/dist/ui/assets/{wc-permissions-w6MzYo-I.js → wc-permissions-CX9g_q_g.js} +2 -2
  113. package/dist/ui/assets/{wc-placeholder-9ExeY58f.js → wc-placeholder-BTubgzHQ.js} +2 -2
  114. package/dist/ui/assets/{wc-profile-export-TfGoKm8m.js → wc-profile-export-CLrVoBUb.js} +3 -3
  115. package/dist/ui/assets/{wc-secret-request-Bw2Z-odI.js → wc-secret-request-C6de01ym.js} +1 -1
  116. package/dist/ui/assets/{wc-settings--En-Ge_6.js → wc-settings-UMB6kSyi.js} +3 -3
  117. package/dist/ui/assets/{wc-shell-NkYoeVsC.js → wc-shell-S8qOdNtE.js} +4 -4
  118. package/dist/ui/assets/{wc-shortcut-config-CIe9QmAl.js → wc-shortcut-config-qEhVO-Uc.js} +1 -1
  119. package/dist/ui/assets/{wc-sprinkles-xlpNp57J.js → wc-sprinkles-DkHcbspL.js} +2 -2
  120. package/dist/ui/assets/{wc-transcript-export-CxI9PghJ.js → wc-transcript-export-P96ecgEm.js} +2 -2
  121. package/dist/ui/assets/{wc-tray-PnX5ReG6.js → wc-tray-nC9rEjN1.js} +4 -4
  122. package/dist/ui/assets/{welcome-detection-CoLpHf7U.js → welcome-detection-nx6R970e.js} +1 -1
  123. package/dist/ui/assets/{whisper-session-_9vBA8B7.js → whisper-session-JVxon6RK.js} +2 -2
  124. package/dist/ui/assets/{xai-grok-BsD0QBRK.js → xai-grok-Ch8m_qvv.js} +1 -1
  125. package/dist/ui/assets/{xai-grok-DveHVQUG.js → xai-grok-OozQ0aFH.js} +1 -1
  126. package/dist/ui/index.html +3 -3
  127. package/dist/ui/packages/webapp/index.html +3 -3
  128. package/dist/ui/packages/webapp/upgrade-to-seven.html +1 -1
  129. package/dist/ui/upgrade-to-seven.html +1 -1
  130. package/package.json +2 -2
  131. package/dist/ui/assets/provider-store-access-KJ4vm_gE.js +0 -1
  132. package/dist/ui/assets/slicc-version-kgSeNa1K.js +0 -1
@@ -5,14 +5,16 @@ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{t as n}from"./buffer
5
5
  `),this.code=this.name=e.code,this.data={remote:t}}};Ot.code=`NoRefspecError`;var kt=class e{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let t=null;this.parsedConfig=e.trim().split(`
6
6
  `).map(e=>{if(/^\s*#/.test(e))return{line:e,comment:!0};let n=e.indexOf(` `);if(e.startsWith(`^`)){let n=e.slice(1);return this.refs.set(t+`^{}`,n),{line:e,ref:t,peeled:n}}{let r=e.slice(0,n);return t=e.slice(n+1),this.refs.set(t,r),{line:e,ref:t,oid:r}}})}return this}static from(t){return new e(t)}delete(e){this.parsedConfig=this.parsedConfig.filter(t=>t.ref!==e),this.refs.delete(e)}toString(){return this.parsedConfig.map(({line:e})=>e).join(`
7
7
  `)+`
8
- `}},At=class e{constructor({remotePath:e,localPath:t,force:n,matchPrefix:r}){Object.assign(this,{remotePath:e,localPath:t,force:n,matchPrefix:r})}static from(t){let[n,r,i,a,o]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s=n===`+`,c=i===`*`;if(c!==(o===`*`))throw new q(`Invalid refspec`);return new e({remotePath:r,localPath:a,force:s,matchPrefix:c})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,``)}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,``)}else if(e===this.localPath)return this.remotePath;return null}},jt=class e{constructor(e=[]){this.rules=e}static from(t){let n=[];for(let e of t)n.push(At.from(e));return new e(n)}add(e){let t=At.from(e);this.rules.push(t)}translate(e){let t=[];for(let n of this.rules)for(let r of e){let e=n.translate(r);e&&t.push([r,e])}return t}translateOne(e){let t=null;for(let n of this.rules){let r=n.translate(e);r&&(t=r)}return t}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,``))}};function Mt(e,t){let n=e.replace(/\^\{\}$/,``),r=t.replace(/\^\{\}$/,``),i=-(n<r)||+(n>r);return i===0?e.endsWith(`^{}`)?1:-1:i}var Nt=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function Pt(e,t){if(typeof e!=`string`)throw TypeError(`Reference name must be a string`);return!Nt.test(e)&&(!!t||e.includes(`/`))}function Ft(e,t){let n=``,r=0,i=-1,a=0,o=`\0`;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(i!==s-1&&a!==1){if(a===2){if(n.length<2||r!==2||n.at(-1)!==`.`||n.at(-2)!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length!==0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1}i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}function It(e){return e.length>=2&&/^[a-zA-Z]:/.test(e)?e.slice(0,2):null}function Lt(e){if(!e.length)return`.`;e=e.replace(/\\/g,`/`);let t=It(e),n=e[0]===`/`||t!==null&&e[2]===`/`,r=e.at(-1)===`/`,i=Ft(t?e.slice(2):e,!n);if(!i.length){let e=t?n?t+`/`:t:n?`/`:`.`;return r&&!n?e+`/`:e}return r&&(i+=`/`),t?n?`${t}/${i}`:`${t}${i}`:n?`/${i}`:i}function Y(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n].replace(/\\/g,`/`);r.length!==0&&(/^[a-zA-Z]:\//.test(r)||t===void 0?t=r:t+=`/`+r)}return t===void 0?`.`:Lt(t)}var Rt=e=>{if(typeof e==`number`)return e;e=e.toLowerCase();let t=parseInt(e);return e.endsWith(`k`)&&(t*=1024),e.endsWith(`m`)&&(t*=1048576),e.endsWith(`g`)&&(t*=1073741824),t},zt=e=>{if(typeof e==`boolean`)return e;if(e=e.trim().toLowerCase(),e===`true`||e===`yes`||e===`on`)return!0;if(e===`false`||e===`no`||e===`off`)return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${e}`)},Bt={core:{filemode:zt,bare:zt,logallrefupdates:zt,symlinks:zt,ignorecase:zt,bigFileThreshold:Rt}},Vt=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,Ht=/^[A-Za-z0-9-.]+$/,Ut=/^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/,Wt=/^[A-Za-z][A-Za-z0-9-]*$/,Gt=/^(.*?)( *[#;].*)$/,Kt=e=>{let t=Vt.exec(e);if(t!=null){let[e,n]=t.slice(1);return[e,n]}return null},qt=e=>{let t=Ut.exec(e);if(t!=null){let[e,n=`true`]=t.slice(1);return[e,Xt(Jt(n))]}return null},Jt=e=>{let t=Gt.exec(e);if(t==null)return e;let[n,r]=t.slice(1);return Yt(n)&&Yt(r)?`${n}${r}`:n},Yt=e=>(e.match(/(?:^|[^\\])"/g)||[]).length%2!=0,Xt=e=>e.split(``).reduce((e,t,n,r)=>{let i=t===`"`&&r[n-1]!==`\\`,a=t===`\\`&&r[n+1]===`"`;return i||a?e:e+t},``),Zt=e=>e==null?null:e.toLowerCase(),Qt=(e,t,n)=>[Zt(e),t,Zt(n)].filter(e=>e!=null).join(`.`),$t=e=>{let t=e.split(`.`),n=t.shift(),r=t.pop(),i=t.length?t.join(`.`):void 0;return{section:n,subsection:i,name:r,path:Qt(n,i,r),sectionPath:Qt(n,i,null),isSection:!!n}},en=(e,t)=>e.reduce((e,n,r)=>t(n)?r:e,-1),tn=class e{constructor(e){let t=null,n=null;this.parsedConfig=e?e.split(`
9
- `).map(e=>{let r=null,i=null,a=e.trim(),o=Kt(a),s=o!=null;if(s)[t,n]=o;else{let e=qt(a);e!=null&&([r,i]=e)}let c=Qt(t,n,r);return{line:e,isSection:s,section:t,subsection:n,name:r,value:i,path:c}}):[]}static from(t){return new e(t)}async get(e,t=!1){let n=$t(e).path,r=this.parsedConfig.filter(e=>e.path===n).map(({section:e,name:t,value:n})=>{let r=Bt[e]&&Bt[e][t];return r?r(n):n});return t?r:r.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(t=>t.isSection&&t.section===e).map(e=>e.subsection)}async deleteSection(e,t){this.parsedConfig=this.parsedConfig.filter(n=>n.section!==e||n.subsection!==t)}async append(e,t){return this.set(e,t,!0)}async set(e,t,n=!1){let{section:r,subsection:i,name:a,path:o,sectionPath:s,isSection:c}=$t(e),l=en(this.parsedConfig,e=>e.path===o);if(t==null)l!==-1&&this.parsedConfig.splice(l,1);else if(l!==-1){let e=this.parsedConfig[l],r=Object.assign({},e,{name:a,value:t,modified:!0});n?this.parsedConfig.splice(l+1,0,r):this.parsedConfig[l]=r}else{let e=this.parsedConfig.findIndex(e=>e.path===s),n={section:r,subsection:i,name:a,value:t,modified:!0,path:o};if(Ht.test(r)&&Wt.test(a)){if(e>=0)this.parsedConfig.splice(e+1,0,n);else{let e={isSection:c,section:r,subsection:i,modified:!0,path:s};this.parsedConfig.push(e,n)}}}}toString(){return this.parsedConfig.map(({line:e,section:t,subsection:n,name:r,value:i,modified:a=!1})=>a?r!=null&&i!=null?typeof i==`string`&&/[#;]/.test(i)?`\t${r} = "${i}"`:`\t${r} = ${i}`:n==null?`[${t}]`:`[${t} "${n}"]`:e).join(`
10
- `)}},nn=class{static async get({fs:e,gitdir:t}){let n=await e.read(`${t}/config`,{encoding:`utf8`});return tn.from(n)}static async save({fs:e,gitdir:t,config:n}){await e.write(`${t}/config`,n.toString(),{encoding:`utf8`})}},rn=e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],an=[`config`,`description`,`index`,`shallow`,`commondir`];function on(e){if(an.includes(e))throw new Dt(e,`refs/heads/${e}`);if(!Pt(e,!0))throw new Dt(e,Le.default.clean(e))}var X=class e{static async updateRemoteRefs({fs:t,gitdir:n,remote:r,refs:i,symrefs:a,tags:o,refspecs:s=void 0,prune:c=!1,pruneTags:l=!1}){for(let e of i.values())if(!e.match(/[0-9a-f]{40}/))throw new Et(e);let u=await nn.get({fs:t,gitdir:n});if(!s){if(s=await u.getall(`remote.${r}.fetch`),s.length===0)throw new Ot(r);s.unshift(`+HEAD:refs/remotes/${r}/HEAD`)}let d=jt.from(s),f=new Map,p=d.translate([...i.keys()]),m=[];for(let[e,t]of d.translate([...a.keys()])){let n=d.translateOne(a.get(e));n&&(on(n),m.push([t,`ref: ${n}`]))}let h=o?[...i.keys()].filter(e=>e.startsWith(`refs/tags`)&&!e.endsWith(`^{}`)):[];for(let[,e]of p)on(e);for(let[e]of m)on(e);if(h.forEach(on),l){let r=await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`});await e.deleteRefs({fs:t,gitdir:n,refs:r.map(e=>`refs/tags/${e}`)})}for(let r of h)if(!await e.exists({fs:t,gitdir:n,ref:r})){let e=i.get(r);f.set(r,e)}for(let[e,t]of p){let n=i.get(e);f.set(t,n)}for(let[e,t]of m)f.set(e,t);let g=[];if(c){for(let r of d.localNamespaces()){let i=(await e.listRefs({fs:t,gitdir:n,filepath:r})).map(e=>`${r}/${e}`);for(let e of i)f.has(e)||g.push(e)}g.length>0&&await e.deleteRefs({fs:t,gitdir:n,refs:g})}for(let[e,r]of f)await ft(e,async()=>t.write(Y(n,e),`${r.trim()}\n`,`utf8`));return{pruned:g}}static async writeRef({fs:e,gitdir:t,ref:n,value:r}){if(on(n),!r.match(/[0-9a-f]{40}/))throw new Et(r);await ft(n,async()=>e.write(Y(t,n),`${r.trim()}\n`,`utf8`))}static async writeSymbolicRef({fs:e,gitdir:t,ref:n,value:r}){on(n),await ft(n,async()=>e.write(Y(t,n),`ref: ${r.trim()}\n`,`utf8`))}static async deleteRef({fs:t,gitdir:n,ref:r}){return e.deleteRefs({fs:t,gitdir:n,refs:[r]})}static async deleteRefs({fs:e,gitdir:t,refs:n}){n.forEach(on),await Promise.all(n.map(n=>e.rm(Y(t,n))));let r=await ft(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`})),i=kt.from(r),a=i.refs.size;for(let e of n)i.refs.has(e)&&i.delete(e);i.refs.size<a&&(r=i.toString(),await ft(`packed-refs`,async()=>e.write(`${t}/packed-refs`,r,{encoding:`utf8`})))}static async resolve({fs:t,gitdir:n,ref:r,depth:i=void 0,visited:a=new Set}){if(i!==void 0&&(i--,i===-1))return r;if(r.startsWith(`ref: `))return r=r.slice(5),e.resolve({fs:t,gitdir:n,ref:r,depth:i,visited:a});if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let o=await e.packedRefs({fs:t,gitdir:n}),s=rn(r).filter(e=>!an.includes(e));for(let r of s){let s=await ft(r,async()=>await t.read(`${n}/${r}`,{encoding:`utf8`})||o.get(r));if(s){if(a.has(r))throw new q(`Circular reference detected while resolving ref "${r}"`);return a.add(r),e.resolve({fs:t,gitdir:n,ref:s.trim(),depth:i,visited:a})}}throw new J(r)}static async isUnbornBranch({fs:t,gitdir:n,ref:r}){let i;try{i=await e.resolve({fs:t,gitdir:n,ref:`HEAD`,depth:2})}catch(e){if(e instanceof J)return!1;throw e}return i.startsWith(`refs/heads/`)?r===`HEAD`||rn(r).includes(i):!1}static async exists({fs:t,gitdir:n,ref:r}){try{return await e.expand({fs:t,gitdir:n,ref:r}),!0}catch(e){if(e instanceof J)return!1;throw e}}static async expand({fs:t,gitdir:n,ref:r}){if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let i=await e.packedRefs({fs:t,gitdir:n}),a=rn(r).filter(e=>!an.includes(e));for(let e of a)if(await ft(e,async()=>t.exists(`${n}/${e}`))||i.has(e))return e;throw new J(r)}static async expandAgainstMap({ref:e,map:t}){let n=rn(e);for(let e of n)if(await t.has(e))return e;throw new J(e)}static resolveAgainstMap({ref:t,fullref:n=t,depth:r=void 0,map:i}){if(r!==void 0&&(r--,r===-1))return{fullref:n,oid:t};if(t.startsWith(`ref: `))return t=t.slice(5),e.resolveAgainstMap({ref:t,fullref:n,depth:r,map:i});if(t.length===40&&/[0-9a-f]{40}/.test(t))return{fullref:n,oid:t};let a=rn(t);for(let t of a){let n=i.get(t);if(n)return e.resolveAgainstMap({ref:n.trim(),fullref:t,depth:r,map:i})}throw new J(t)}static async packedRefs({fs:e,gitdir:t}){let n=await ft(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`}));return kt.from(n).refs}static async listRefs({fs:t,gitdir:n,filepath:r}){let i=await e.packedRefs({fs:t,gitdir:n}),a=null;try{a=await t.readdirDeep(`${n}/${r}`),a=a.map(e=>e.replace(`${n}/${r}/`,``))}catch{a=[]}for(let e of i.keys())e.startsWith(r)&&(e=e.replace(r+`/`,``),a.includes(e)||a.push(e));return a.sort(Mt),a}static async listBranches({fs:t,gitdir:n,remote:r}){return r?e.listRefs({fs:t,gitdir:n,filepath:`refs/remotes/${r}`}):e.listRefs({fs:t,gitdir:n,filepath:`refs/heads`})}static async listTags({fs:t,gitdir:n}){return(await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`})).filter(e=>!e.endsWith(`^{}`))}};function sn(e,t){return Je(cn(e),cn(t))}function cn(e){return e.mode===`040000`?e.path+`/`:e.path}function ln(e){switch(e){case`040000`:return`tree`;case`100644`:return`blob`;case`100755`:return`blob`;case`120000`:return`blob`;case`160000`:return`commit`}throw new q(`Unexpected GitTree entry mode: ${e}`)}function un(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(32,n);if(r===-1)throw new q(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next space character.`);let i=e.indexOf(0,n);if(i===-1)throw new q(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next null character.`);let a=e.slice(n,r).toString(`utf8`);a===`40000`&&(a=`040000`);let o=ln(a),s=e.slice(r+1,i).toString(`utf8`),c=s.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,``),l=c.split(`:`)[0].toLowerCase().replace(/[. ]+$/,``);if(s.includes(`\\`)||s.includes(`/`)||c===`.`||c===`..`||l===`.git`||/^\.?git~[1-9]$/.test(l))throw new We(s);let u=e.slice(i+1,i+21).toString(`hex`);n=i+21,t.push({mode:a,path:s,oid:u,type:o})}return t}function dn(e){if(typeof e==`number`&&(e=e.toString(8)),e.match(/^0?4.*/))return`040000`;if(e.match(/^1006.*/))return`100644`;if(e.match(/^1007.*/))return`100755`;if(e.match(/^120.*/))return`120000`;if(e.match(/^160.*/))return`160000`;throw new q(`Could not understand file mode: ${e}`)}function fn(e){return!e.oid&&e.sha&&(e.oid=e.sha),e.mode=dn(e.mode),e.type||=ln(e.mode),e}var pn=class e{constructor(e){if(Buffer.isBuffer(e))this._entries=un(e);else if(Array.isArray(e))this._entries=e.map(fn);else throw new q(`invalid type passed to GitTree constructor`);this._entries.sort(Ye)}static from(t){return new e(t)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
11
- `)}toObject(){let e=[...this._entries];return e.sort(sn),Buffer.concat(e.map(e=>{let t=Buffer.from(e.mode.replace(/^0/,``)),n=Buffer.from(` `),r=Buffer.from(e.path,`utf8`),i=Buffer.from([0]),a=Buffer.from(e.oid,`hex`);return Buffer.concat([t,n,r,i,a])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},mn=class{static wrap({type:e,object:t}){let n=`${e} ${t.length}\x00`,r=n.length,i=r+t.length,a=new Uint8Array(i);for(let e=0;e<r;e++)a[e]=n.charCodeAt(e);return a.set(t,r),a}static unwrap(e){let t=e.indexOf(32),n=e.indexOf(0),r=e.slice(0,t).toString(`utf8`),i=e.slice(t+1,n).toString(`utf8`),a=e.length-(n+1);if(parseInt(i)!==a)throw new q(`Length mismatch: expected ${i} bytes but got ${a} instead.`);return{type:r,object:Buffer.from(e.slice(n+1))}}};async function hn({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`,i=await e.read(`${t}/${r}`);return i?{object:i,format:`deflated`,source:r}:null}function gn(e,t){let n=new Ge(e),r=_n(n);if(r!==t.byteLength)throw new q(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${t.length} bytes`);let i=_n(n),a,o=yn(n,t);if(o.byteLength===i)a=o;else{let e=[o],r=o.byteLength;for(;!n.eof();){let i=yn(n,t);e.push(i),r+=i.byteLength}if(i!==r)throw new q(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${r} bytes`);a=Buffer.concat(e,i)}return a}function _n(e){let t=0,n=0,r=null;do r=e.readUInt8(),t|=(r&127)<<n,n+=7;while(r&128);return t}function vn(e,t,n){let r=0,i=0;for(;n--;)t&1&&(r|=e.readUInt8()<<i),t>>=1,i+=8;return r}function yn(e,t){let n=e.readUInt8();if(n&128){let r=vn(e,n&15,4),i=vn(e,(n&112)>>4,3);return i===0&&(i=65536),t.slice(r,r+i)}return e.slice(n)}function bn(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function xn(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:bn(e)}var Sn=class{constructor(e){if(typeof Buffer>`u`)throw Error(`Missing Buffer dependency`);this.stream=xn(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:t}=await this.stream.next();return e&&(this._ended=!0,!t)?Buffer.alloc(0):(t&&=Buffer.from(t),t)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let t=[this.buffer];for(;this.cursor+e>Cn(t);){let e=await this._next();if(this._ended)break;t.push(e)}this.buffer=Buffer.concat(t)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function Cn(e){return e.reduce((e,t)=>e+t.length,0)}async function wn(e,t){let n=new Sn(e),r=await n.read(4);if(r=r.toString(`utf8`),r!==`PACK`)throw new q(`Invalid PACK header '${r}'`);let i=await n.read(4);if(i=i.readUInt32BE(0),i!==2)throw new q(`Invalid packfile version: ${i}`);let a=await n.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!n.eof()&&a--;){let e=n.tell(),{type:r,length:i,ofs:o,reference:s}=await Tn(n),c=new ze.default.Inflate;for(;!c.result;){let l=await n.chunk();if(!l)break;if(c.push(l,!1),c.err)throw new q(`Pako error: ${c.msg}`);if(c.result){if(c.result.length!==i)throw new q(`Inflated object size is different from that stated in packfile.`);await n.undo(),await n.read(l.length-c.strm.avail_in);let u=n.tell();await t({data:c.result,type:r,num:a,offset:e,end:u,reference:s,ofs:o})}}}}async function Tn(e){let t=await e.byte(),n=t>>4&7,r=t&15;if(t&128){let n=4;do t=await e.byte(),r|=(t&127)<<n,n+=7;while(t&128)}let i,a;if(n===6){let n=0;i=0;let r=[];do t=await e.byte(),i|=(t&127)<<n,n+=7,r.push(t);while(t&128);a=Buffer.from(r)}return n===7&&(a=await e.read(20)),{type:n,length:r,ofs:i,reference:a}}var En=class e extends K{constructor(t){super(`Invalid compressed buffer: ${t}`),this.code=this.name=e.code,this.data={message:t}}};En.code=`DecompressionError`;async function Dn(e){let t=new DecompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);try{return new Uint8Array(await new Response(n).arrayBuffer())}catch(e){throw e&&e.name===`TypeError`&&e.message===``?new En(`decompression failed`):e}}var On=!1;async function kn(e){On===null&&(On=An());try{return On?await Dn(e):ze.default.inflate(e)}catch(e){throw typeof e==`string`?new En(e):e}}function An(){try{if(new DecompressionStream(`deflate`))return!0}catch{}return!1}function jn(e){let t=[],n=0,r=0;do{n=e.readUInt8();let i=n&127;t.push(i),r=n&128}while(r);return t.reduce((e,t)=>e+1<<7|t,-1)}function Mn(e,t){let n=t,r=4,i=null;do i=e.readUInt8(),n|=(i&127)<<r,r+=7;while(i&128);return n}var Nn=class e{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:n}){let r=new Ge(t);if(r.slice(4).toString(`hex`)!==`ff744f63`)return;let i=r.readUInt32BE();if(i!==2)throw new q(`Unable to read version ${i} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2147483648)throw new q(`To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.`);r.seek(r.tell()+1020);let a=r.readUInt32BE(),o=[];for(let e=0;e<a;e++){let t=r.slice(20).toString(`hex`);o[e]=t}r.seek(r.tell()+4*a);let s=new Map;for(let e=0;e<a;e++)s.set(o[e],r.readUInt32BE());let c=r.slice(20).toString(`hex`);return new e({hashes:o,crcs:{},offsets:s,packfileSha:c,getExternalRefDelta:n})}static async fromPack({pack:t,getExternalRefDelta:n,onProgress:r}){let i={1:`commit`,2:`tree`,3:`blob`,4:`tag`,6:`ofs-delta`,7:`ref-delta`},a={},o=t.slice(-20).toString(`hex`),s=[],c={},l=new Map,u=null,d=null;await wn([t],async({data:e,type:t,reference:n,offset:o,num:s})=>{u===null&&(u=s);let c=Math.floor((u-s)*100/u);c!==d&&r&&await r({phase:`Receiving objects`,loaded:u-s,total:u}),d=c,t=i[t],([`commit`,`tree`,`blob`,`tag`].includes(t)||t===`ofs-delta`||t===`ref-delta`)&&(a[o]={type:t,offset:o})});let f=Object.keys(a).map(Number);for(let[e,n]of f.entries()){let r=e+1===f.length?t.byteLength-20:f[e+1],i=a[n],o=Re.default.buf(t.slice(n,r))>>>0;i.end=r,i.crc=o}let p=new e({pack:Promise.resolve(t),packfileSha:o,crcs:c,hashes:s,offsets:l,getExternalRefDelta:n});d=null;let m=0,h=[0,0,0,0,0,0,0,0,0,0,0,0];for(let e in a){e=Number(e);let t=Math.floor(m*100/u);t!==d&&r&&await r({phase:`Resolving deltas`,loaded:m,total:u}),m++,d=t;let n=a[e];if(!n.oid)try{p.readDepth=0,p.externalReadDepth=0;let{type:t,object:r}=await p.readSlice({start:e});h[p.readDepth]+=1;let i=await nt(mn.wrap({type:t,object:r}));n.oid=i,s.push(i),l.set(i,e),c[i]=n.crc}catch{continue}}return s.sort(),p}async toBuffer(){let e=[],t=(t,n)=>{e.push(Buffer.from(t,n))};t(`ff744f63`,`hex`),t(`00000002`,`hex`);let n=new Ge(Buffer.alloc(1024));for(let e=0;e<256;e++){let t=0;for(let n of this.hashes)parseInt(n.slice(0,2),16)<=e&&t++;n.writeUInt32BE(t)}e.push(n.buffer);for(let e of this.hashes)t(e,`hex`);let r=new Ge(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)r.writeUInt32BE(this.crcs[e]);e.push(r.buffer);let i=new Ge(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)i.writeUInt32BE(this.offsets.get(e));e.push(i.buffer),t(this.packfileSha,`hex`);let a=Buffer.concat(e),o=await nt(a),s=Buffer.alloc(20);return s.write(o,`hex`),Buffer.concat([a,s])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new q(`Could not read object ${e} from packfile`)}let t=this.offsets.get(e);return this.readSlice({start:t})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let t={16:`commit`,32:`tree`,48:`blob`,64:`tag`,96:`ofs_delta`,112:`ref_delta`},n=await this.pack;if(!n)throw new q(`Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.`);let r=n.slice(e),i=new Ge(r),a=i.readUInt8(),o=a&112,s=t[o];if(s===void 0)throw new q(`Unrecognized type: 0b`+o.toString(2));let c=a&15,l=c;a&128&&(l=Mn(i,c));let u=null,d=null;if(s===`ofs_delta`){let t=e-jn(i);({object:u,type:s}=await this.readSlice({start:t}))}if(s===`ref_delta`){let e=i.slice(20).toString(`hex`);({object:u,type:s}=await this.read({oid:e}))}let f=r.slice(i.tell());if(d=Buffer.from(await kn(f)),d.byteLength!==l)throw new q(`Packfile told us object would have length ${l} but it had length ${d.byteLength}`);return u&&(d=Buffer.from(gn(d,u))),this.readDepth>3&&(this.offsetCache[e]={type:s,object:d}),{type:s,format:`content`,object:d}}},Pn=Symbol(`PackfileCache`);async function Fn({fs:e,filename:t,getExternalRefDelta:n,emitter:r,emitterPrefix:i}){let a=await e.read(t);return Nn.fromIdx({idx:a,getExternalRefDelta:n})}function In({fs:e,cache:t,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}){t[Pn]||(t[Pn]=new Map);let o=t[Pn].get(n);return o||(o=Fn({fs:e,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}),t[Pn].set(n,o),o.catch(()=>{t[Pn].get(n)===o&&t[Pn].delete(n)})),o}async function Ln(e,{start:t=0,end:n=e.length}={}){return nt(e.subarray(t,n))}async function Rn({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`,getExternalRefDelta:a}){let o=await e.readdir(Y(n,`objects/pack`));o=o.filter(e=>e.endsWith(`.idx`));for(let i of o){let o=`${n}/objects/pack/${i}`,s=await In({fs:e,cache:t,filename:o,getExternalRefDelta:a});if(s.error)throw new q(s.error);if(s.offsets.has(r)){let n=o.replace(/idx$/,`pack`);if(!s.pack){let t=e.read(n);s.pack=t,t.catch(()=>{s.pack===t&&(s.pack=null)})}let c=await s.pack;if(!c)throw s.pack=null,new q(`Could not read packfile at ${n}. The file may be missing, corrupted, or too large to read into memory.`);let l=!(t&&t.skipDeepPackVerification);(!s._checksumVerification||l&&!s._deepVerified)&&(s._deepVerified=l,s._checksumVerification=Bn(c,s.packfileSha,l)),await s._checksumVerification,s._lastUsedAt=++zn;let u=await s.read({oid:r,getExternalRefDelta:a});return u.format=`content`,u.source=`objects/pack/${i.replace(/idx$/,`pack`)}`,u}}return null}var zn=0;async function Bn(e,t,n=!0){let r=e.subarray(-20),i=Array.from(r).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(i!==t)throw new q(`Packfile trailer mismatch: expected ${t}, got ${i}. The packfile may be corrupted.`);if(n){let n=await Ln(e,{start:0,end:e.length-20});if(n!==t)throw new q(`Packfile payload corrupted: calculated ${n} but expected ${t}. The packfile may have been tampered with.`)}}async function Vn({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){if(![`deflated`,`wrapped`,`content`].includes(i))throw new q(`invalid requested format "${i}"`);let a=r=>Vn({fs:e,cache:t,gitdir:n,oid:r}),o;if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`&&(o={format:`wrapped`,object:Buffer.from(`tree 0\0`)}),o||=await hn({fs:e,gitdir:n,oid:r}),!o){if(o=await Rn({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),!o)throw new J(r);return o}if(i===`deflated`||(o.format===`deflated`&&(o.object=Buffer.from(await kn(o.object)),o.format=`wrapped`),i===`wrapped`))return o;let s=await nt(o.object);if(s!==r)throw new q(`SHA check failed! Expected ${r}, computed ${s}`);let{object:c,type:l}=mn.unwrap(o.object);return o.type=l,o.object=c,o.format=`content`,o}var Hn=class e extends K{constructor(t,n,r=!0){super(`Failed to create ${t} at ${n} because it already exists.${r?` (Hint: use 'force: true' parameter to overwrite existing ${t}.)`:``}`),this.code=this.name=e.code,this.data={noun:t,where:n,canForce:r}}};Hn.code=`AlreadyExistsError`;var Un=class e extends K{constructor(t,n,r){super(`Found multiple ${t} matching "${n}" (${r.join(`, `)}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=e.code,this.data={nouns:t,short:n,matches:r}}};Un.code=`AmbiguousError`;var Wn=class e extends K{constructor(t){super(`Your local changes to the following files would be overwritten by checkout: ${t.join(`, `)}`),this.code=this.name=e.code,this.data={filepaths:t}}};Wn.code=`CheckoutConflictError`;var Gn=class e extends K{constructor(t){super(`Your local changes to the following files would be overwritten by cherry-pick: ${t.join(`, `)}`),this.code=this.name=e.code,this.data={filepaths:t}}};Gn.code=`CherryPickLocalChangesError`;var Kn=class e extends K{constructor(t,n){super(`Cannot cherry-pick merge commit ${t}. Merge commits have ${n} parents and require specifying which parent to use as the base.`),this.code=this.name=e.code,this.data={oid:t,parentCount:n}}};Kn.code=`CherryPickMergeCommitError`;var qn=class e extends K{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=e.code,this.data={oid:t}}};qn.code=`CherryPickRootCommitError`;var Jn=class e extends K{constructor(t,n){super(`Failed to checkout "${t}" because commit ${n} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=e.code,this.data={ref:t,oid:n}}};Jn.code=`CommitNotFetchedError`;var Yn=class e extends K{constructor(){super(`Cannot create an empty commit when disallowEmpty is true.`),this.code=this.name=e.code,this.data={}}};Yn.code=`EmptyCommitError`;var Xn=class e extends K{constructor(){super(`Empty response from git server.`),this.code=this.name=e.code,this.data={}}};Xn.code=`EmptyServerResponseError`;var Zn=class e extends K{constructor(){super(`A simple fast-forward merge was not possible.`),this.code=this.name=e.code,this.data={}}};Zn.code=`FastForwardError`;var Qn=class e extends K{constructor(t,n){super(`One or more branches were not updated: ${t}`),this.code=this.name=e.code,this.data={prettyDetails:t,result:n}}};Qn.code=`GitPushError`;var $n=class e extends K{constructor(t,n,r){super(`HTTP Error: ${t} ${n}`),this.code=this.name=e.code,this.data={statusCode:t,statusMessage:n,response:r}}};$n.code=`HttpError`;var er=class e extends K{constructor(t){let n=`invalid filepath`;t===`leading-slash`||t===`trailing-slash`?n=`"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`:t===`directory`&&(n=`"filepath" should not be a directory.`),super(n),this.code=this.name=e.code,this.data={reason:t}}};er.code=`InvalidFilepathError`;var tr=class e extends K{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=e.code,this.data={depth:t}}};tr.code=`MaxDepthError`;var nr=class e extends K{constructor(){super(`Merges with conflicts are not supported yet.`),this.code=this.name=e.code,this.data={}}};nr.code=`MergeNotSupportedError`;var rr=class e extends K{constructor(t,n,r,i){super(`Automatic merge failed with one or more merge conflicts in the following files: ${t.toString()}. Fix conflicts then commit the result.`),this.code=this.name=e.code,this.data={filepaths:t,bothModified:n,deleteByUs:r,deleteByTheirs:i}}};rr.code=`MergeConflictError`;var ir=class e extends K{constructor(t){super(`No name was provided for ${t} in the argument or in the .git/config file.`),this.code=this.name=e.code,this.data={role:t}}};ir.code=`MissingNameError`;var ar=class e extends K{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=e.code,this.data={parameter:t}}};ar.code=`MissingParameterError`;var or=class e extends K{constructor(t){super(`There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more`),this.code=this.name=e.code,this.data={errors:t},this.errors=t}};or.code=`MultipleGitError`;var sr=class e extends K{constructor(t,n){super(`Expected "${t}" but received "${n}".`),this.code=this.name=e.code,this.data={expected:t,actual:n}}};sr.code=`ParseError`;var cr=class e extends K{constructor(t){let n=``;t===`not-fast-forward`?n=` because it was not a simple fast-forward`:t===`tag-exists`&&(n=` because tag already exists`),super(`Push rejected${n}. Use "force: true" to override.`),this.code=this.name=e.code,this.data={reason:t}}};cr.code=`PushRejectedError`;var lr=class e extends K{constructor(t,n){super(`Remote does not support the "${t}" so the "${n}" parameter cannot be used.`),this.code=this.name=e.code,this.data={capability:t,parameter:n}}};lr.code=`RemoteCapabilityError`;var ur=class e extends K{constructor(t,n){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${t}`),this.code=this.name=e.code,this.data={preview:t,response:n}}};ur.code=`SmartHttpError`;var dr=class e extends K{constructor(t,n,r){super(`Git remote "${t}" uses an unrecognized transport protocol: "${n}"`),this.code=this.name=e.code,this.data={url:t,transport:n,suggestion:r}}};dr.code=`UnknownTransportError`;var fr=class e extends K{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=e.code,this.data={url:t}}};fr.code=`UrlParseError`;var pr=class e extends K{constructor(){super(`The operation was canceled.`),this.code=this.name=e.code,this.data={}}};pr.code=`UserCanceledError`;var mr=class e extends K{constructor(t){super(`Could not merge index: Entry for '${t}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=e.code,this.data={filepath:t}}};mr.code=`IndexResetError`;var hr=class e extends K{constructor(t){super(`"${t}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=e.code,this.data={ref:t}}};hr.code=`NoCommitError`;var gr=Object.freeze({__proto__:null,AlreadyExistsError:Hn,AmbiguousError:Un,CheckoutConflictError:Wn,CherryPickLocalChangesError:Gn,CherryPickMergeCommitError:Kn,CherryPickRootCommitError:qn,CommitNotFetchedError:Jn,DecompressionError:En,EmptyCommitError:Yn,EmptyServerResponseError:Xn,FastForwardError:Zn,GitPushError:Qn,HttpError:$n,InternalError:q,InvalidFilepathError:er,InvalidOidError:Et,InvalidRefNameError:Dt,MaxDepthError:tr,MergeNotSupportedError:nr,MergeConflictError:rr,MissingNameError:ir,MissingParameterError:ar,MultipleGitError:or,NoRefspecError:Ot,NotFoundError:J,ObjectTypeError:Tt,ParseError:sr,PushRejectedError:cr,RemoteCapabilityError:lr,SmartHttpError:ur,UnknownTransportError:dr,UnsafeFilepathError:We,UrlParseError:fr,UserCanceledError:pr,UnmergedPathsError:Ue,IndexResetError:mr,NoCommitError:hr});function _r({name:e,email:t,timestamp:n,timezoneOffset:r}){return r=vr(r),`${e} <${t}> ${n} ${r}`}function vr(e){let t=yr(br(e));e=Math.abs(e);let n=Math.floor(e/60);e-=n*60;let r=String(n),i=String(e);return r.length<2&&(r=`0`+r),i.length<2&&(i=`0`+i),(t===-1?`-`:`+`)+r+i}function yr(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}function br(e){return e===0?e:-e}function xr(e){return e=e.replace(/\r/g,``),e=e.replace(/^\n+/,``),e=e.replace(/\n+$/,``)+`
12
- `,e}function Sr(e){let[,t,n,r,i]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(r),timezoneOffset:Cr(i)}}function Cr(e){let[,t,n,r]=e.match(/(\+|-)(\d\d)(\d\d)/);return r=(t===`+`?1:-1)*(Number(n)*60+Number(r)),wr(r)}function wr(e){return e===0?e:-e}var Tr=class e{constructor(t){if(typeof t==`string`)this._tag=t;else if(Buffer.isBuffer(t))this._tag=t.toString(`utf8`);else if(typeof t==`object`)this._tag=e.render(t);else throw new q(`invalid type passed to GitAnnotatedTag constructor`)}static from(t){return new e(t)}static render(e){return`object ${e.object}
8
+ `}},At=class e{constructor({remotePath:e,localPath:t,force:n,matchPrefix:r}){Object.assign(this,{remotePath:e,localPath:t,force:n,matchPrefix:r})}static from(t){let[n,r,i,a,o]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s=n===`+`,c=i===`*`;if(c!==(o===`*`))throw new q(`Invalid refspec`);return new e({remotePath:r,localPath:a,force:s,matchPrefix:c})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,``)}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,``)}else if(e===this.localPath)return this.remotePath;return null}},jt=class e{constructor(e=[]){this.rules=e}static from(t){let n=[];for(let e of t)n.push(At.from(e));return new e(n)}add(e){let t=At.from(e);this.rules.push(t)}translate(e){let t=[];for(let n of this.rules)for(let r of e){let e=n.translate(r);e&&t.push([r,e])}return t}translateOne(e){let t=null;for(let n of this.rules){let r=n.translate(e);r&&(t=r)}return t}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,``))}};function Mt(e,t){let n=e.replace(/\^\{\}$/,``),r=t.replace(/\^\{\}$/,``),i=-(n<r)||+(n>r);return i===0?e.endsWith(`^{}`)?1:-1:i}var Nt=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function Pt(e,t){if(typeof e!=`string`)throw TypeError(`Reference name must be a string`);return!Nt.test(e)&&(!!t||e.includes(`/`))}function Ft(e,t){let n=``,r=0,i=-1,a=0,o=`\0`;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(i!==s-1&&a!==1){if(a===2){if(n.length<2||r!==2||n.at(-1)!==`.`||n.at(-2)!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length!==0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1}i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}function It(e){return e.length>=2&&/^[a-zA-Z]:/.test(e)?e.slice(0,2):null}function Lt(e){if(!e.length)return`.`;e=e.replace(/\\/g,`/`);let t=It(e),n=e[0]===`/`||t!==null&&e[2]===`/`,r=e.at(-1)===`/`,i=Ft(t?e.slice(2):e,!n);if(!i.length){let e=t?n?t+`/`:t:n?`/`:`.`;return r&&!n?e+`/`:e}return r&&(i+=`/`),t?n?`${t}/${i}`:`${t}${i}`:n?`/${i}`:i}function Y(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n].replace(/\\/g,`/`);r.length!==0&&(/^[a-zA-Z]:\//.test(r)||t===void 0?t=r:t+=`/`+r)}return t===void 0?`.`:Lt(t)}var Rt=e=>{if(typeof e==`number`)return e;e=e.toLowerCase();let t=parseInt(e);return e.endsWith(`k`)&&(t*=1024),e.endsWith(`m`)&&(t*=1048576),e.endsWith(`g`)&&(t*=1073741824),t},zt=e=>{if(typeof e==`boolean`)return e;if(e=e.trim().toLowerCase(),e===`true`||e===`yes`||e===`on`)return!0;if(e===`false`||e===`no`||e===`off`)return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${e}`)},Bt={core:{filemode:zt,bare:zt,logallrefupdates:zt,symlinks:zt,ignorecase:zt,bigFileThreshold:Rt}},Vt=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,Ht=/^[A-Za-z0-9-.]+$/,Ut=/^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/,Wt=/^[A-Za-z][A-Za-z0-9-]*$/,Gt=e=>{let t=Vt.exec(e);if(t!=null){let[e,n]=t.slice(1);return[e,n]}return null},Kt=e=>{let t=Ut.exec(e);if(t!=null){let[e,n=`true`]=t.slice(1);return[e,Jt(n)]}return null},qt=new Map([[`t`,` `],[`b`,`\b`],[`n`,`
9
+ `],[`\\`,`\\`],[`"`,`"`]]),Jt=e=>{let t=``,n=``,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(!r&&/[ \t\r\v\f]/.test(a))t!==``&&(n+=a);else{if(!r&&(a===`#`||a===`;`))break;t+=n,n=``,a===`\\`&&qt.has(e[i+1])?t+=qt.get(e[++i]):a===`"`?r=!r:t+=a}}return t},Yt=e=>{if(typeof e!=`string`)return e;let t=e.startsWith(` `)||e.endsWith(` `)||/[#;]/.test(e)?`"`:``;return`${t}${e.replace(/[\\"\n\t]/g,e=>e===`
10
+ `?`\\n`:e===` `?`\\t`:`\\${e}`)}${t}`},Xt=e=>e==null?null:e.toLowerCase(),Zt=(e,t,n)=>[Xt(e),t,Xt(n)].filter(e=>e!=null).join(`.`),Qt=e=>{let t=e.split(`.`),n=t.shift(),r=t.pop(),i=t.length?t.join(`.`):void 0;return{section:n,subsection:i,name:r,path:Zt(n,i,r),sectionPath:Zt(n,i,null),isSection:!!n}},$t=(e,t)=>e.reduce((e,n,r)=>t(n)?r:e,-1),en=class e{constructor(e){let t=null,n=null;this.parsedConfig=e?e.split(`
11
+ `).map(e=>{let r=null,i=null,a=e.trim(),o=Gt(a),s=o!=null;if(s)[t,n]=o;else{let e=Kt(a);e!=null&&([r,i]=e)}let c=Zt(t,n,r);return{line:e,isSection:s,section:t,subsection:n,name:r,value:i,path:c}}):[]}static from(t){return new e(t)}async get(e,t=!1){let n=Qt(e).path,r=this.parsedConfig.filter(e=>e.path===n).map(({section:e,name:t,value:n})=>{let r=Bt[e]&&Bt[e][t];return r?r(n):n});return t?r:r.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(t=>t.isSection&&t.section===e).map(e=>e.subsection)}async deleteSection(e,t){this.parsedConfig=this.parsedConfig.filter(n=>n.section!==e||n.subsection!==t)}async append(e,t){return this.set(e,t,!0)}async set(e,t,n=!1){let{section:r,subsection:i,name:a,path:o,sectionPath:s,isSection:c}=Qt(e),l=$t(this.parsedConfig,e=>e.path===o);if(t==null)l!==-1&&this.parsedConfig.splice(l,1);else if(l!==-1){let e=this.parsedConfig[l],r=Object.assign({},e,{name:a,value:t,modified:!0});n?this.parsedConfig.splice(l+1,0,r):this.parsedConfig[l]=r}else{let e=this.parsedConfig.findIndex(e=>e.path===s),n={section:r,subsection:i,name:a,value:t,modified:!0,path:o};if(Ht.test(r)&&Wt.test(a)){if(e>=0)this.parsedConfig.splice(e+1,0,n);else{let e={isSection:c,section:r,subsection:i,modified:!0,path:s};this.parsedConfig.push(e,n)}}}}toString(){return this.parsedConfig.map(({line:e,section:t,subsection:n,name:r,value:i,modified:a=!1})=>a?r!=null&&i!=null?`\t${r} = ${Yt(i)}`:n==null?`[${t}]`:`[${t} "${n}"]`:e).join(`
12
+ `)}},tn=class{static async get({fs:e,gitdir:t}){let n=await e.read(`${t}/config`,{encoding:`utf8`});return en.from(n)}static async save({fs:e,gitdir:t,config:n}){await e.write(`${t}/config`,n.toString(),{encoding:`utf8`})}},nn=e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],rn=[`config`,`description`,`index`,`shallow`,`commondir`];function an(e){if(rn.includes(e))throw new Dt(e,`refs/heads/${e}`);if(!Pt(e,!0))throw new Dt(e,Le.default.clean(e))}var X=class e{static async updateRemoteRefs({fs:t,gitdir:n,remote:r,refs:i,symrefs:a,tags:o,refspecs:s=void 0,prune:c=!1,pruneTags:l=!1}){for(let e of i.values())if(!e.match(/[0-9a-f]{40}/))throw new Et(e);let u=await tn.get({fs:t,gitdir:n});if(!s){if(s=await u.getall(`remote.${r}.fetch`),s.length===0)throw new Ot(r);s.unshift(`+HEAD:refs/remotes/${r}/HEAD`)}let d=jt.from(s),f=new Map,p=d.translate([...i.keys()]),m=[];for(let[e,t]of d.translate([...a.keys()])){let n=d.translateOne(a.get(e));n&&(an(n),m.push([t,`ref: ${n}`]))}let h=o?[...i.keys()].filter(e=>e.startsWith(`refs/tags`)&&!e.endsWith(`^{}`)):[];for(let[,e]of p)an(e);for(let[e]of m)an(e);if(h.forEach(an),l){let r=await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`});await e.deleteRefs({fs:t,gitdir:n,refs:r.map(e=>`refs/tags/${e}`)})}for(let r of h)if(!await e.exists({fs:t,gitdir:n,ref:r})){let e=i.get(r);f.set(r,e)}for(let[e,t]of p){let n=i.get(e);f.set(t,n)}for(let[e,t]of m)f.set(e,t);let g=[];if(c){for(let r of d.localNamespaces()){let i=(await e.listRefs({fs:t,gitdir:n,filepath:r})).map(e=>`${r}/${e}`);for(let e of i)f.has(e)||g.push(e)}g.length>0&&await e.deleteRefs({fs:t,gitdir:n,refs:g})}for(let[e,r]of f)await ft(e,async()=>t.write(Y(n,e),`${r.trim()}\n`,`utf8`));return{pruned:g}}static async writeRef({fs:e,gitdir:t,ref:n,value:r}){if(an(n),!r.match(/[0-9a-f]{40}/))throw new Et(r);await ft(n,async()=>e.write(Y(t,n),`${r.trim()}\n`,`utf8`))}static async writeSymbolicRef({fs:e,gitdir:t,ref:n,value:r}){an(n),await ft(n,async()=>e.write(Y(t,n),`ref: ${r.trim()}\n`,`utf8`))}static async deleteRef({fs:t,gitdir:n,ref:r}){return e.deleteRefs({fs:t,gitdir:n,refs:[r]})}static async deleteRefs({fs:e,gitdir:t,refs:n}){n.forEach(an),await Promise.all(n.map(n=>e.rm(Y(t,n))));let r=await ft(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`})),i=kt.from(r),a=i.refs.size;for(let e of n)i.refs.has(e)&&i.delete(e);i.refs.size<a&&(r=i.toString(),await ft(`packed-refs`,async()=>e.write(`${t}/packed-refs`,r,{encoding:`utf8`})))}static async resolve({fs:t,gitdir:n,ref:r,depth:i=void 0,visited:a=new Set}){if(i!==void 0&&(i--,i===-1))return r;if(r.startsWith(`ref: `))return r=r.slice(5),e.resolve({fs:t,gitdir:n,ref:r,depth:i,visited:a});if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let o=await e.packedRefs({fs:t,gitdir:n}),s=nn(r).filter(e=>!rn.includes(e));for(let r of s){let s=await ft(r,async()=>await t.read(`${n}/${r}`,{encoding:`utf8`})||o.get(r));if(s){if(a.has(r))throw new q(`Circular reference detected while resolving ref "${r}"`);return a.add(r),e.resolve({fs:t,gitdir:n,ref:s.trim(),depth:i,visited:a})}}throw new J(r)}static async isUnbornBranch({fs:t,gitdir:n,ref:r}){let i;try{i=await e.resolve({fs:t,gitdir:n,ref:`HEAD`,depth:2})}catch(e){if(e instanceof J)return!1;throw e}return i.startsWith(`refs/heads/`)?r===`HEAD`||nn(r).includes(i):!1}static async exists({fs:t,gitdir:n,ref:r}){try{return await e.expand({fs:t,gitdir:n,ref:r}),!0}catch(e){if(e instanceof J)return!1;throw e}}static async expand({fs:t,gitdir:n,ref:r}){if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let i=await e.packedRefs({fs:t,gitdir:n}),a=nn(r).filter(e=>!rn.includes(e));for(let e of a)if(await ft(e,async()=>t.exists(`${n}/${e}`))||i.has(e))return e;throw new J(r)}static async expandAgainstMap({ref:e,map:t}){let n=nn(e);for(let e of n)if(await t.has(e))return e;throw new J(e)}static resolveAgainstMap({ref:t,fullref:n=t,depth:r=void 0,map:i}){if(r!==void 0&&(r--,r===-1))return{fullref:n,oid:t};if(t.startsWith(`ref: `))return t=t.slice(5),e.resolveAgainstMap({ref:t,fullref:n,depth:r,map:i});if(t.length===40&&/[0-9a-f]{40}/.test(t))return{fullref:n,oid:t};let a=nn(t);for(let t of a){let n=i.get(t);if(n)return e.resolveAgainstMap({ref:n.trim(),fullref:t,depth:r,map:i})}throw new J(t)}static async packedRefs({fs:e,gitdir:t}){let n=await ft(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`}));return kt.from(n).refs}static async listRefs({fs:t,gitdir:n,filepath:r}){let i=await e.packedRefs({fs:t,gitdir:n}),a=null;try{a=await t.readdirDeep(`${n}/${r}`),a=a.map(e=>e.replace(`${n}/${r}/`,``))}catch{a=[]}for(let e of i.keys())e.startsWith(r)&&(e=e.replace(r+`/`,``),a.includes(e)||a.push(e));return a.sort(Mt),a}static async listBranches({fs:t,gitdir:n,remote:r}){return r?e.listRefs({fs:t,gitdir:n,filepath:`refs/remotes/${r}`}):e.listRefs({fs:t,gitdir:n,filepath:`refs/heads`})}static async listTags({fs:t,gitdir:n}){return(await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`})).filter(e=>!e.endsWith(`^{}`))}};function on(e,t){return Je(sn(e),sn(t))}function sn(e){return e.mode===`040000`?e.path+`/`:e.path}function cn(e){switch(e){case`040000`:return`tree`;case`100644`:return`blob`;case`100755`:return`blob`;case`120000`:return`blob`;case`160000`:return`commit`}throw new q(`Unexpected GitTree entry mode: ${e}`)}function ln(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(32,n);if(r===-1)throw new q(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next space character.`);let i=e.indexOf(0,n);if(i===-1)throw new q(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next null character.`);let a=e.slice(n,r).toString(`utf8`);a===`40000`&&(a=`040000`);let o=cn(a),s=e.slice(r+1,i).toString(`utf8`),c=s.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,``),l=c.split(`:`)[0].toLowerCase().replace(/[. ]+$/,``);if(s.includes(`\\`)||s.includes(`/`)||c===`.`||c===`..`||l===`.git`||/^\.?git~[1-9]$/.test(l))throw new We(s);let u=e.slice(i+1,i+21).toString(`hex`);n=i+21,t.push({mode:a,path:s,oid:u,type:o})}return t}function un(e){if(typeof e==`number`&&(e=e.toString(8)),e.match(/^0?4.*/))return`040000`;if(e.match(/^1006.*/))return`100644`;if(e.match(/^1007.*/))return`100755`;if(e.match(/^120.*/))return`120000`;if(e.match(/^160.*/))return`160000`;throw new q(`Could not understand file mode: ${e}`)}function dn(e){return!e.oid&&e.sha&&(e.oid=e.sha),e.mode=un(e.mode),e.type||=cn(e.mode),e}var fn=class e{constructor(e){if(Buffer.isBuffer(e))this._entries=ln(e);else if(Array.isArray(e))this._entries=e.map(dn);else throw new q(`invalid type passed to GitTree constructor`);this._entries.sort(Ye)}static from(t){return new e(t)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
13
+ `)}toObject(){let e=[...this._entries];return e.sort(on),Buffer.concat(e.map(e=>{let t=Buffer.from(e.mode.replace(/^0/,``)),n=Buffer.from(` `),r=Buffer.from(e.path,`utf8`),i=Buffer.from([0]),a=Buffer.from(e.oid,`hex`);return Buffer.concat([t,n,r,i,a])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},pn=class{static wrap({type:e,object:t}){let n=`${e} ${t.length}\x00`,r=n.length,i=r+t.length,a=new Uint8Array(i);for(let e=0;e<r;e++)a[e]=n.charCodeAt(e);return a.set(t,r),a}static unwrap(e){let t=e.indexOf(32),n=e.indexOf(0),r=e.slice(0,t).toString(`utf8`),i=e.slice(t+1,n).toString(`utf8`),a=e.length-(n+1);if(parseInt(i)!==a)throw new q(`Length mismatch: expected ${i} bytes but got ${a} instead.`);return{type:r,object:Buffer.from(e.slice(n+1))}}};async function mn({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`,i=await e.read(`${t}/${r}`);return i?{object:i,format:`deflated`,source:r}:null}function hn(e,t){let n=new Ge(e),r=gn(n);if(r!==t.byteLength)throw new q(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${t.length} bytes`);let i=gn(n),a,o=vn(n,t);if(o.byteLength===i)a=o;else{let e=[o],r=o.byteLength;for(;!n.eof();){let i=vn(n,t);e.push(i),r+=i.byteLength}if(i!==r)throw new q(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${r} bytes`);a=Buffer.concat(e,i)}return a}function gn(e){let t=0,n=0,r=null;do r=e.readUInt8(),t|=(r&127)<<n,n+=7;while(r&128);return t}function _n(e,t,n){let r=0,i=0;for(;n--;)t&1&&(r|=e.readUInt8()<<i),t>>=1,i+=8;return r}function vn(e,t){let n=e.readUInt8();if(n&128){let r=_n(e,n&15,4),i=_n(e,(n&112)>>4,3);return i===0&&(i=65536),t.slice(r,r+i)}return e.slice(n)}function yn(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function bn(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:yn(e)}var xn=class{constructor(e){if(typeof Buffer>`u`)throw Error(`Missing Buffer dependency`);this.stream=bn(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:t}=await this.stream.next();return e&&(this._ended=!0,!t)?Buffer.alloc(0):(t&&=Buffer.from(t),t)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let t=[this.buffer];for(;this.cursor+e>Sn(t);){let e=await this._next();if(this._ended)break;t.push(e)}this.buffer=Buffer.concat(t)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function Sn(e){return e.reduce((e,t)=>e+t.length,0)}async function Cn(e,t){let n=new xn(e),r=await n.read(4);if(r=r.toString(`utf8`),r!==`PACK`)throw new q(`Invalid PACK header '${r}'`);let i=await n.read(4);if(i=i.readUInt32BE(0),i!==2)throw new q(`Invalid packfile version: ${i}`);let a=await n.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!n.eof()&&a--;){let e=n.tell(),{type:r,length:i,ofs:o,reference:s}=await wn(n),c=new ze.default.Inflate;for(;!c.result;){let l=await n.chunk();if(!l)break;if(c.push(l,!1),c.err)throw new q(`Pako error: ${c.msg}`);if(c.result){if(c.result.length!==i)throw new q(`Inflated object size is different from that stated in packfile.`);await n.undo(),await n.read(l.length-c.strm.avail_in);let u=n.tell();await t({data:c.result,type:r,num:a,offset:e,end:u,reference:s,ofs:o})}}}}async function wn(e){let t=await e.byte(),n=t>>4&7,r=t&15;if(t&128){let n=4;do t=await e.byte(),r|=(t&127)<<n,n+=7;while(t&128)}let i,a;if(n===6){let n=0;i=0;let r=[];do t=await e.byte(),i|=(t&127)<<n,n+=7,r.push(t);while(t&128);a=Buffer.from(r)}return n===7&&(a=await e.read(20)),{type:n,length:r,ofs:i,reference:a}}var Tn=class e extends K{constructor(t){super(`Invalid compressed buffer: ${t}`),this.code=this.name=e.code,this.data={message:t}}};Tn.code=`DecompressionError`;async function En(e){let t=new DecompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);try{return new Uint8Array(await new Response(n).arrayBuffer())}catch(e){throw e&&e.name===`TypeError`&&e.message===``?new Tn(`decompression failed`):e}}var Dn=!1;async function On(e){Dn===null&&(Dn=kn());try{return Dn?await En(e):ze.default.inflate(e)}catch(e){throw typeof e==`string`?new Tn(e):e}}function kn(){try{if(new DecompressionStream(`deflate`))return!0}catch{}return!1}function An(e){let t=[],n=0,r=0;do{n=e.readUInt8();let i=n&127;t.push(i),r=n&128}while(r);return t.reduce((e,t)=>e+1<<7|t,-1)}function jn(e,t){let n=t,r=4,i=null;do i=e.readUInt8(),n|=(i&127)<<r,r+=7;while(i&128);return n}var Mn=class e{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:n}){let r=new Ge(t);if(r.slice(4).toString(`hex`)!==`ff744f63`)return;let i=r.readUInt32BE();if(i!==2)throw new q(`Unable to read version ${i} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2147483648)throw new q(`To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.`);r.seek(r.tell()+1020);let a=r.readUInt32BE(),o=[];for(let e=0;e<a;e++){let t=r.slice(20).toString(`hex`);o[e]=t}r.seek(r.tell()+4*a);let s=new Map;for(let e=0;e<a;e++)s.set(o[e],r.readUInt32BE());let c=r.slice(20).toString(`hex`);return new e({hashes:o,crcs:{},offsets:s,packfileSha:c,getExternalRefDelta:n})}static async fromPack({pack:t,getExternalRefDelta:n,onProgress:r}){let i={1:`commit`,2:`tree`,3:`blob`,4:`tag`,6:`ofs-delta`,7:`ref-delta`},a={},o=t.slice(-20).toString(`hex`),s=[],c={},l=new Map,u=null,d=null;await Cn([t],async({data:e,type:t,reference:n,offset:o,num:s})=>{u===null&&(u=s);let c=Math.floor((u-s)*100/u);c!==d&&r&&await r({phase:`Receiving objects`,loaded:u-s,total:u}),d=c,t=i[t],([`commit`,`tree`,`blob`,`tag`].includes(t)||t===`ofs-delta`||t===`ref-delta`)&&(a[o]={type:t,offset:o})});let f=Object.keys(a).map(Number);for(let[e,n]of f.entries()){let r=e+1===f.length?t.byteLength-20:f[e+1],i=a[n],o=Re.default.buf(t.slice(n,r))>>>0;i.end=r,i.crc=o}let p=new e({pack:Promise.resolve(t),packfileSha:o,crcs:c,hashes:s,offsets:l,getExternalRefDelta:n});d=null;let m=0,h=[0,0,0,0,0,0,0,0,0,0,0,0];for(let e in a){e=Number(e);let t=Math.floor(m*100/u);t!==d&&r&&await r({phase:`Resolving deltas`,loaded:m,total:u}),m++,d=t;let n=a[e];if(!n.oid)try{p.readDepth=0,p.externalReadDepth=0;let{type:t,object:r}=await p.readSlice({start:e});h[p.readDepth]+=1;let i=await nt(pn.wrap({type:t,object:r}));n.oid=i,s.push(i),l.set(i,e),c[i]=n.crc}catch{continue}}return s.sort(),p}async toBuffer(){let e=[],t=(t,n)=>{e.push(Buffer.from(t,n))};t(`ff744f63`,`hex`),t(`00000002`,`hex`);let n=new Ge(Buffer.alloc(1024));for(let e=0;e<256;e++){let t=0;for(let n of this.hashes)parseInt(n.slice(0,2),16)<=e&&t++;n.writeUInt32BE(t)}e.push(n.buffer);for(let e of this.hashes)t(e,`hex`);let r=new Ge(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)r.writeUInt32BE(this.crcs[e]);e.push(r.buffer);let i=new Ge(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)i.writeUInt32BE(this.offsets.get(e));e.push(i.buffer),t(this.packfileSha,`hex`);let a=Buffer.concat(e),o=await nt(a),s=Buffer.alloc(20);return s.write(o,`hex`),Buffer.concat([a,s])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new q(`Could not read object ${e} from packfile`)}let t=this.offsets.get(e);return this.readSlice({start:t})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let t={16:`commit`,32:`tree`,48:`blob`,64:`tag`,96:`ofs_delta`,112:`ref_delta`},n=await this.pack;if(!n)throw new q(`Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.`);let r=n.slice(e),i=new Ge(r),a=i.readUInt8(),o=a&112,s=t[o];if(s===void 0)throw new q(`Unrecognized type: 0b`+o.toString(2));let c=a&15,l=c;a&128&&(l=jn(i,c));let u=null,d=null;if(s===`ofs_delta`){let t=e-An(i);({object:u,type:s}=await this.readSlice({start:t}))}if(s===`ref_delta`){let e=i.slice(20).toString(`hex`);({object:u,type:s}=await this.read({oid:e}))}let f=r.slice(i.tell());if(d=Buffer.from(await On(f)),d.byteLength!==l)throw new q(`Packfile told us object would have length ${l} but it had length ${d.byteLength}`);return u&&(d=Buffer.from(hn(d,u))),this.readDepth>3&&(this.offsetCache[e]={type:s,object:d}),{type:s,format:`content`,object:d}}},Nn=Symbol(`PackfileCache`);async function Pn({fs:e,filename:t,getExternalRefDelta:n,emitter:r,emitterPrefix:i}){let a=await e.read(t);return Mn.fromIdx({idx:a,getExternalRefDelta:n})}function Fn({fs:e,cache:t,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}){t[Nn]||(t[Nn]=new Map);let o=t[Nn].get(n);return o||(o=Pn({fs:e,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}),t[Nn].set(n,o),o.catch(()=>{t[Nn].get(n)===o&&t[Nn].delete(n)})),o}async function In(e,{start:t=0,end:n=e.length}={}){return nt(e.subarray(t,n))}async function Ln({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`,getExternalRefDelta:a}){let o=await e.readdir(Y(n,`objects/pack`));o=o.filter(e=>e.endsWith(`.idx`));for(let i of o){let o=`${n}/objects/pack/${i}`,s=await Fn({fs:e,cache:t,filename:o,getExternalRefDelta:a});if(s.error)throw new q(s.error);if(s.offsets.has(r)){let n=o.replace(/idx$/,`pack`);if(!s.pack){let t=e.read(n);s.pack=t,t.catch(()=>{s.pack===t&&(s.pack=null)})}let c=await s.pack;if(!c)throw s.pack=null,new q(`Could not read packfile at ${n}. The file may be missing, corrupted, or too large to read into memory.`);let l=!(t&&t.skipDeepPackVerification);(!s._checksumVerification||l&&!s._deepVerified)&&(s._deepVerified=l,s._checksumVerification=zn(c,s.packfileSha,l)),await s._checksumVerification,s._lastUsedAt=++Rn;let u=await s.read({oid:r,getExternalRefDelta:a});return u.format=`content`,u.source=`objects/pack/${i.replace(/idx$/,`pack`)}`,u}}return null}var Rn=0;async function zn(e,t,n=!0){let r=e.subarray(-20),i=Array.from(r).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(i!==t)throw new q(`Packfile trailer mismatch: expected ${t}, got ${i}. The packfile may be corrupted.`);if(n){let n=await In(e,{start:0,end:e.length-20});if(n!==t)throw new q(`Packfile payload corrupted: calculated ${n} but expected ${t}. The packfile may have been tampered with.`)}}async function Bn({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){if(![`deflated`,`wrapped`,`content`].includes(i))throw new q(`invalid requested format "${i}"`);let a=r=>Bn({fs:e,cache:t,gitdir:n,oid:r}),o;if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`&&(o={format:`wrapped`,object:Buffer.from(`tree 0\0`)}),o||=await mn({fs:e,gitdir:n,oid:r}),!o){if(o=await Ln({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),!o)throw new J(r);return o}if(i===`deflated`||(o.format===`deflated`&&(o.object=Buffer.from(await On(o.object)),o.format=`wrapped`),i===`wrapped`))return o;let s=await nt(o.object);if(s!==r)throw new q(`SHA check failed! Expected ${r}, computed ${s}`);let{object:c,type:l}=pn.unwrap(o.object);return o.type=l,o.object=c,o.format=`content`,o}var Vn=class e extends K{constructor(t,n,r=!0){super(`Failed to create ${t} at ${n} because it already exists.${r?` (Hint: use 'force: true' parameter to overwrite existing ${t}.)`:``}`),this.code=this.name=e.code,this.data={noun:t,where:n,canForce:r}}};Vn.code=`AlreadyExistsError`;var Hn=class e extends K{constructor(t,n,r){super(`Found multiple ${t} matching "${n}" (${r.join(`, `)}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=e.code,this.data={nouns:t,short:n,matches:r}}};Hn.code=`AmbiguousError`;var Un=class e extends K{constructor(t){super(`Your local changes to the following files would be overwritten by checkout: ${t.join(`, `)}`),this.code=this.name=e.code,this.data={filepaths:t}}};Un.code=`CheckoutConflictError`;var Wn=class e extends K{constructor(t){super(`Your local changes to the following files would be overwritten by cherry-pick: ${t.join(`, `)}`),this.code=this.name=e.code,this.data={filepaths:t}}};Wn.code=`CherryPickLocalChangesError`;var Gn=class e extends K{constructor(t,n){super(`Cannot cherry-pick merge commit ${t}. Merge commits have ${n} parents and require specifying which parent to use as the base.`),this.code=this.name=e.code,this.data={oid:t,parentCount:n}}};Gn.code=`CherryPickMergeCommitError`;var Kn=class e extends K{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=e.code,this.data={oid:t}}};Kn.code=`CherryPickRootCommitError`;var qn=class e extends K{constructor(t,n){super(`Failed to checkout "${t}" because commit ${n} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=e.code,this.data={ref:t,oid:n}}};qn.code=`CommitNotFetchedError`;var Jn=class e extends K{constructor(){super(`Cannot create an empty commit when disallowEmpty is true.`),this.code=this.name=e.code,this.data={}}};Jn.code=`EmptyCommitError`;var Yn=class e extends K{constructor(){super(`Empty response from git server.`),this.code=this.name=e.code,this.data={}}};Yn.code=`EmptyServerResponseError`;var Xn=class e extends K{constructor(){super(`A simple fast-forward merge was not possible.`),this.code=this.name=e.code,this.data={}}};Xn.code=`FastForwardError`;var Zn=class e extends K{constructor(t,n){super(`One or more branches were not updated: ${t}`),this.code=this.name=e.code,this.data={prettyDetails:t,result:n}}};Zn.code=`GitPushError`;var Qn=class e extends K{constructor(t,n,r){super(`HTTP Error: ${t} ${n}`),this.code=this.name=e.code,this.data={statusCode:t,statusMessage:n,response:r}}};Qn.code=`HttpError`;var $n=class e extends K{constructor(t){let n=`invalid filepath`;t===`leading-slash`||t===`trailing-slash`?n=`"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`:t===`directory`&&(n=`"filepath" should not be a directory.`),super(n),this.code=this.name=e.code,this.data={reason:t}}};$n.code=`InvalidFilepathError`;var er=class e extends K{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=e.code,this.data={depth:t}}};er.code=`MaxDepthError`;var tr=class e extends K{constructor(){super(`Merges with conflicts are not supported yet.`),this.code=this.name=e.code,this.data={}}};tr.code=`MergeNotSupportedError`;var nr=class e extends K{constructor(t,n,r,i){super(`Automatic merge failed with one or more merge conflicts in the following files: ${t.toString()}. Fix conflicts then commit the result.`),this.code=this.name=e.code,this.data={filepaths:t,bothModified:n,deleteByUs:r,deleteByTheirs:i}}};nr.code=`MergeConflictError`;var rr=class e extends K{constructor(t){super(`No name was provided for ${t} in the argument or in the .git/config file.`),this.code=this.name=e.code,this.data={role:t}}};rr.code=`MissingNameError`;var ir=class e extends K{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=e.code,this.data={parameter:t}}};ir.code=`MissingParameterError`;var ar=class e extends K{constructor(t){super(`There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more`),this.code=this.name=e.code,this.data={errors:t},this.errors=t}};ar.code=`MultipleGitError`;var or=class e extends K{constructor(t,n){super(`Expected "${t}" but received "${n}".`),this.code=this.name=e.code,this.data={expected:t,actual:n}}};or.code=`ParseError`;var sr=class e extends K{constructor(t){let n=``;t===`not-fast-forward`?n=` because it was not a simple fast-forward`:t===`tag-exists`&&(n=` because tag already exists`),super(`Push rejected${n}. Use "force: true" to override.`),this.code=this.name=e.code,this.data={reason:t}}};sr.code=`PushRejectedError`;var cr=class e extends K{constructor(t,n){super(`Remote does not support the "${t}" so the "${n}" parameter cannot be used.`),this.code=this.name=e.code,this.data={capability:t,parameter:n}}};cr.code=`RemoteCapabilityError`;var lr=class e extends K{constructor(t,n){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${t}`),this.code=this.name=e.code,this.data={preview:t,response:n}}};lr.code=`SmartHttpError`;var ur=class e extends K{constructor(t,n,r){super(`Git remote "${t}" uses an unrecognized transport protocol: "${n}"`),this.code=this.name=e.code,this.data={url:t,transport:n,suggestion:r}}};ur.code=`UnknownTransportError`;var dr=class e extends K{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=e.code,this.data={url:t}}};dr.code=`UrlParseError`;var fr=class e extends K{constructor(){super(`The operation was canceled.`),this.code=this.name=e.code,this.data={}}};fr.code=`UserCanceledError`;var pr=class e extends K{constructor(t){super(`Could not merge index: Entry for '${t}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=e.code,this.data={filepath:t}}};pr.code=`IndexResetError`;var mr=class e extends K{constructor(t){super(`"${t}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=e.code,this.data={ref:t}}};mr.code=`NoCommitError`;var hr=Object.freeze({__proto__:null,AlreadyExistsError:Vn,AmbiguousError:Hn,CheckoutConflictError:Un,CherryPickLocalChangesError:Wn,CherryPickMergeCommitError:Gn,CherryPickRootCommitError:Kn,CommitNotFetchedError:qn,DecompressionError:Tn,EmptyCommitError:Jn,EmptyServerResponseError:Yn,FastForwardError:Xn,GitPushError:Zn,HttpError:Qn,InternalError:q,InvalidFilepathError:$n,InvalidOidError:Et,InvalidRefNameError:Dt,MaxDepthError:er,MergeNotSupportedError:tr,MergeConflictError:nr,MissingNameError:rr,MissingParameterError:ir,MultipleGitError:ar,NoRefspecError:Ot,NotFoundError:J,ObjectTypeError:Tt,ParseError:or,PushRejectedError:sr,RemoteCapabilityError:cr,SmartHttpError:lr,UnknownTransportError:ur,UnsafeFilepathError:We,UrlParseError:dr,UserCanceledError:fr,UnmergedPathsError:Ue,IndexResetError:pr,NoCommitError:mr});function gr({name:e,email:t,timestamp:n,timezoneOffset:r}){return r=_r(r),`${e} <${t}> ${n} ${r}`}function _r(e){let t=vr(yr(e));e=Math.abs(e);let n=Math.floor(e/60);e-=n*60;let r=String(n),i=String(e);return r.length<2&&(r=`0`+r),i.length<2&&(i=`0`+i),(t===-1?`-`:`+`)+r+i}function vr(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}function yr(e){return e===0?e:-e}function br(e){return e=e.replace(/\r/g,``),e=e.replace(/^\n+/,``),e=e.replace(/\n+$/,``)+`
14
+ `,e}function xr(e){let[,t,n,r,i]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(r),timezoneOffset:Sr(i)}}function Sr(e){let[,t,n,r]=e.match(/(\+|-)(\d\d)(\d\d)/);return r=(t===`+`?1:-1)*(Number(n)*60+Number(r)),Cr(r)}function Cr(e){return e===0?e:-e}var wr=class e{constructor(t){if(typeof t==`string`)this._tag=t;else if(Buffer.isBuffer(t))this._tag=t.toString(`utf8`);else if(typeof t==`object`)this._tag=e.render(t);else throw new q(`invalid type passed to GitAnnotatedTag constructor`)}static from(t){return new e(t)}static render(e){return`object ${e.object}
13
15
  type ${e.type}
14
16
  tag ${e.tag}
15
- tagger ${_r(e.tagger)}
17
+ tagger ${gr(e.tagger)}
16
18
 
17
19
  ${e.message}
18
20
  ${e.gpgsig?e.gpgsig:``}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
@@ -21,49 +23,49 @@ ${e.gpgsig?e.gpgsig:``}`}justHeaders(){return this._tag.slice(0,this._tag.indexO
21
23
 
22
24
  `)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let e=this.justHeaders().split(`
23
25
  `),t=[];for(let n of e)n[0]===` `?t[t.length-1]+=`
24
- `+n.slice(1):t.push(n);let n={};for(let e of t){let t=e.slice(0,e.indexOf(` `)),r=e.slice(e.indexOf(` `)+1);Array.isArray(n[t])?n[t].push(r):n[t]=r}return n.tagger&&=Sr(n.tagger),n.committer&&=Sr(n.committer),n}withoutSignature(){let e=xr(this._tag);return e.indexOf(`
26
+ `+n.slice(1):t.push(n);let n={};for(let e of t){let t=e.slice(0,e.indexOf(` `)),r=e.slice(e.indexOf(` `)+1);Array.isArray(n[t])?n[t].push(r):n[t]=r}return n.tagger&&=xr(n.tagger),n.committer&&=xr(n.committer),n}withoutSignature(){let e=br(this._tag);return e.indexOf(`
25
27
  -----BEGIN PGP SIGNATURE-----`)===-1?e:e.slice(0,e.lastIndexOf(`
26
28
  -----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
27
- -----BEGIN PGP SIGNATURE-----`)!==-1)return xr(this._tag.slice(this._tag.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._tag.indexOf(`-----END PGP SIGNATURE-----`)+27))}payload(){return this.withoutSignature()+`
28
- `}toObject(){return Buffer.from(this._tag,`utf8`)}static async sign(t,n,r){let i=t.payload(),{signature:a}=await n({payload:i,secretKey:r});a=xr(a);let o=i+a;return e.from(o)}};function Er(e){return e.trim().split(`
29
+ -----BEGIN PGP SIGNATURE-----`)!==-1)return br(this._tag.slice(this._tag.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._tag.indexOf(`-----END PGP SIGNATURE-----`)+27))}payload(){return this.withoutSignature()+`
30
+ `}toObject(){return Buffer.from(this._tag,`utf8`)}static async sign(t,n,r){let i=t.payload(),{signature:a}=await n({payload:i,secretKey:r});a=br(a);let o=i+a;return e.from(o)}};function Tr(e){return e.trim().split(`
29
31
  `).map(e=>` `+e).join(`
30
32
  `)+`
31
- `}function Dr(e){return e.split(`
33
+ `}function Er(e){return e.split(`
32
34
  `).map(e=>e.replace(/^ /,``)).join(`
33
- `)}var Or=class e{constructor(t){if(typeof t==`string`)this._commit=t;else if(Buffer.isBuffer(t))this._commit=t.toString(`utf8`);else if(typeof t==`object`)this._commit=e.render(t);else throw new q(`invalid type passed to GitCommit constructor`)}static fromPayloadSignature({payload:t,signature:n}){let r=e.justHeaders(t),i=e.justMessage(t),a=xr(r+`
34
- gpgsig`+Er(n)+`
35
- `+i);return new e(a)}static from(t){return new e(t)}toObject(){return Buffer.from(this._commit,`utf8`)}headers(){return this.parseHeaders()}message(){return e.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(e){return xr(e.slice(e.indexOf(`
35
+ `)}var Dr=class e{constructor(t){if(typeof t==`string`)this._commit=t;else if(Buffer.isBuffer(t))this._commit=t.toString(`utf8`);else if(typeof t==`object`)this._commit=e.render(t);else throw new q(`invalid type passed to GitCommit constructor`)}static fromPayloadSignature({payload:t,signature:n}){let r=e.justHeaders(t),i=e.justMessage(t),a=br(r+`
36
+ gpgsig`+Tr(n)+`
37
+ `+i);return new e(a)}static from(t){return new e(t)}toObject(){return Buffer.from(this._commit,`utf8`)}headers(){return this.parseHeaders()}message(){return e.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(e){return br(e.slice(e.indexOf(`
36
38
 
37
39
  `)+2))}static justHeaders(e){return e.slice(0,e.indexOf(`
38
40
 
39
41
  `))}parseHeaders(){let t=e.justHeaders(this._commit).split(`
40
42
  `),n=[];for(let e of t)e[0]===` `?n[n.length-1]+=`
41
- `+e.slice(1):n.push(e);let r={parent:[]};for(let e of n){let t=e.slice(0,e.indexOf(` `)),n=e.slice(e.indexOf(` `)+1);Array.isArray(r[t])?r[t].push(n):r[t]=n}return r.author&&=Sr(r.author),r.committer&&=Sr(r.committer),r}static renderHeaders(e){let t=``;if(e.tree?t+=`tree ${e.tree}\n`:t+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
42
- `,e.parent){if(e.parent.length===void 0)throw new q(`commit 'parent' property should be an array`);for(let n of e.parent)t+=`parent ${n}\n`}let n=e.author;t+=`author ${_r(n)}\n`;let r=e.committer||e.author;return t+=`committer ${_r(r)}\n`,e.gpgsig&&(t+=`gpgsig`+Er(e.gpgsig)),t}static render(t){return e.renderHeaders(t)+`
43
- `+xr(t.message)}render(){return this._commit}withoutSignature(){let e=xr(this._commit);if(e.indexOf(`
43
+ `+e.slice(1):n.push(e);let r={parent:[]};for(let e of n){let t=e.slice(0,e.indexOf(` `)),n=e.slice(e.indexOf(` `)+1);Array.isArray(r[t])?r[t].push(n):r[t]=n}return r.author&&=xr(r.author),r.committer&&=xr(r.committer),r}static renderHeaders(e){let t=``;if(e.tree?t+=`tree ${e.tree}\n`:t+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
44
+ `,e.parent){if(e.parent.length===void 0)throw new q(`commit 'parent' property should be an array`);for(let n of e.parent)t+=`parent ${n}\n`}let n=e.author;t+=`author ${gr(n)}\n`;let r=e.committer||e.author;return t+=`committer ${gr(r)}\n`,e.gpgsig&&(t+=`gpgsig`+Tr(e.gpgsig)),t}static render(t){return e.renderHeaders(t)+`
45
+ `+br(t.message)}render(){return this._commit}withoutSignature(){let e=br(this._commit);if(e.indexOf(`
44
46
  gpgsig`)===-1)return e;let t=e.slice(0,e.indexOf(`
45
47
  gpgsig`)),n=e.slice(e.indexOf(`-----END PGP SIGNATURE-----
46
- `)+28);return xr(t+`
47
- `+n)}isolateSignature(){return Dr(this._commit.slice(this._commit.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._commit.indexOf(`-----END PGP SIGNATURE-----`)+27))}static async sign(t,n,r){let i=t.withoutSignature(),a=e.justMessage(t._commit),{signature:o}=await n({payload:i,secretKey:r});o=xr(o);let s=e.justHeaders(t._commit)+`
48
- gpgsig`+Er(o)+`
49
- `+a;return e.from(s)}};async function kr({fs:e,cache:t,gitdir:n,oid:r}){if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`)return{tree:pn.from([]),oid:r};let{type:i,object:a}=await Vn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=Tr.from(a).parse().object,kr({fs:e,cache:t,gitdir:n,oid:r});if(i===`commit`)return r=Or.from(a).parse().tree,kr({fs:e,cache:t,gitdir:n,oid:r});if(i!==`tree`)throw new Tt(r,i,`tree`);return{tree:pn.from(a),oid:r}}var Ar=class{constructor({fs:e,gitdir:t,ref:n,cache:r}){this.fs=e,this.cache=r,this.gitdir=t,this.mapPromise=(async()=>{let r=new Map,i;try{i=await X.resolve({fs:e,gitdir:t,ref:n})}catch(r){if(r instanceof J&&await X.isUnbornBranch({fs:e,gitdir:t,ref:n}))i=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`;else throw r}let a=await kr({fs:e,cache:this.cache,gitdir:t,oid:i});return a.type=`tree`,a.mode=`40000`,r.set(`.`,a),r})();let i=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return i.type(this)}async mode(){return i.mode(this)}async stat(){return i.stat(this)}async content(){return i.content(this)}async oid(){return i.oid(this)}}}async readdir(e){let t=e._fullpath,{fs:n,cache:r,gitdir:i}=this,a=await this.mapPromise,o=a.get(t);if(!o)throw Error(`No obj for ${t}`);let s=o.oid;if(!s)throw Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!==`tree`)return null;let{type:c,object:l}=await Vn({fs:n,cache:r,gitdir:i,oid:s});if(c!==o.type)throw new Tt(s,c,o.type);let u=pn.from(l);for(let e of u)a.set(Y(t,e.path),e);return u.entries().map(e=>Y(t,e.path))}async type(e){if(e._type===!1){let{type:t}=(await this.mapPromise).get(e._fullpath);e._type=t}return e._type}async mode(e){if(e._mode===!1){let{mode:t}=(await this.mapPromise).get(e._fullpath);e._mode=Xe(parseInt(t,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let t=await this.mapPromise,{fs:n,cache:r,gitdir:i}=this,a=t.get(e._fullpath).oid,{type:o,object:s}=await Vn({fs:n,cache:r,gitdir:i,oid:a});e._content=o===`blob`?new Uint8Array(s):void 0}return e._content}async oid(e){return e._oid===!1&&(e._oid=(await this.mapPromise).get(e._fullpath).oid),e._oid}};function jr({ref:e=`HEAD`}={}){let t=Object.create(null);return Object.defineProperty(t,Ct,{value:function({fs:t,gitdir:n,cache:r}){return new Ar({fs:t,gitdir:n,ref:e,cache:r})}}),Object.freeze(t),t}var Mr=class{constructor({fs:e,dir:t,gitdir:n,cache:r,refresh:i=!0}){this.fs=e,this.cache=r,this.dir=t,this.gitdir=n,this.refresh=i,this.refreshQueue=[],this.flushed=!1,this.config=null;let a=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(e){if(await e.type()!==`tree`)return null;let t=e._fullpath,{fs:n,dir:r}=this,i=await n.readdir(Y(r,t));return i===null?null:i.map(e=>Y(t,e))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let{fs:t,dir:n}=this,r=await t.lstat(`${n}/${e._fullpath}`);if(!r)throw Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let i=r.isDirectory()?`tree`:`blob`;i===`blob`&&!r.isFile()&&!r.isSymbolicLink()&&(i=`special`),e._type=i,r=$e(r),e._mode=r.mode,r.size===-1&&e._actualSize&&(r.size=e._actualSize),e._stat=r}return e._stat}async content(e){if(e._content===!1){let{fs:t,dir:n,gitdir:r}=this;if(await e.type()===`tree`)e._content=void 0;else{let i;if(await e.mode()>>12==10)i=await t.readlink(`${n}/${e._fullpath}`);else{let a=await(await this._getGitConfig(t,r)).get(`core.autocrlf`);i=await t.read(`${n}/${e._fullpath}`,{autocrlf:a})}e._actualSize=i.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(i)}}return e._content}async oid(e){if(e._oid===!1){let t=this,{fs:n,gitdir:r,cache:i}=this,a;await _t.acquire({fs:n,gitdir:r,cache:i},async function(i){let o=i.entriesMap.get(e._fullpath),s=await e.stat(),c=await(await t._getGitConfig(n,r)).get(`core.filemode`),l=typeof process<`u`?process.platform!==`win32`:!0;if(!o||lt(s,o,c,l)){let n=await e.content();n===void 0?a=void 0:(a=await nt(mn.wrap({type:`blob`,object:n})),t.refresh&&o&&a===o.oid&&(!c||s.mode===o.mode)&&lt(s,o,c,l)&&(t.flushed?i.insert({filepath:e._fullpath,stats:s,oid:a}):t.refreshQueue.push({filepath:e._fullpath,stage:o,stats:s,oid:a})))}else a=o.oid}),e._oid=a}return e._oid}async flush(){let{fs:e,gitdir:t,cache:n,refreshQueue:r}=this;this.refreshQueue=[],this.flushed=!0,r.length!==0&&await _t.acquire({fs:e,gitdir:t,cache:n},async e=>{for(let{filepath:t,stage:n,stats:i,oid:a}of r)e.entriesMap.get(t)===n&&e.insert({filepath:t,stats:i,oid:a})})}async _getGitConfig(e,t){return this.config||=await nn.get({fs:e,gitdir:t}),this.config}};function Nr({refresh:e=!0}={}){let t=Object.create(null);return Object.defineProperty(t,Ct,{value:function({fs:t,dir:n,gitdir:r,cache:i}){return new Mr({fs:t,dir:n,gitdir:r,cache:i,refresh:e})}}),Object.freeze(t),t}function Pr(e,t){let n=t-e;return Array.from({length:n},(t,n)=>e+n)}var Fr=Array.prototype.flat===void 0?e=>e.reduce((e,t)=>e.concat(t),[]):e=>e.flat(),Ir=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null||e<this.value)&&(this.value=e)}reset(){this.value=null}};function*Lr(e){let t=new Ir,n,r=[],i=e.length;for(let n=0;n<i;n++)r[n]=e[n].next().value,r[n]!==void 0&&t.consider(r[n]);if(t.value!==null)for(;;){let a=[];n=t.value,t.reset();for(let o=0;o<i;o++)r[o]!==void 0&&r[o]===n?(a[o]=r[o],r[o]=e[o].next().value):a[o]=null,r[o]!==void 0&&t.consider(r[o]);if(yield a,t.value===null)return}}async function Rr({fs:e,cache:t,dir:n,gitdir:r,trees:i,map:a=async(e,t)=>t,reduce:o=async(e,t)=>{let n=Fr(t);return e!==void 0&&n.unshift(e),n},iterate:s=(e,t)=>Promise.all([...t].map(e))}){let c=i.map(i=>i[Ct]({fs:e,dir:n,gitdir:r,cache:t})),l=Array(c.length).fill(`.`),u=Pr(0,c.length),d=async e=>(u.forEach(t=>{let n=e[t];e[t]=n&&new c[t].ConstructEntry(n)}),{entries:e,children:Lr((await Promise.all(u.map(t=>{let n=e[t];return n?c[t].readdir(n):[]}))).map(e=>(e===null?[]:e)[Symbol.iterator]()))}),f=async e=>{let{entries:t,children:n}=await d(e),r=t.find(e=>e&&e._fullpath)._fullpath,i=await a(r,t);if(i!==null){let e=await s(f,n);return e=e.filter(e=>e!==void 0),o(i,e)}},p=await f(l);for(let e of c)e.flush&&await e.flush();return p}async function zr(e,t,n=10){try{await e(t)}catch(r){if(r===null||r.code===`EEXIST`)return;if(r.code!==`ENOENT`)throw r;let i=yt(t);if(i===`.`||i===`/`||i===t)throw r;await zr(e,i,n);for(let r=0;;r++)try{await e(t);return}catch(e){if(e===null||e.code===`EEXIST`)return;if(e.code===`ENOENT`&&r<n){await new Promise(e=>setTimeout(e,0));continue}throw e}}}async function Br(e,t){let n=await e.readdir(t);n==null?await e.rm(t):n.length?await Promise.all(n.map(n=>{let r=Y(t,n);return e.lstat(r).then(t=>{if(t)return t.isDirectory()?Br(e,r):e.rm(r)})})).then(()=>e.rmdir(t)):await e.rmdir(t)}function Vr(e){return Hr(e)&&Ur(e.then)&&Ur(e.catch)}function Hr(e){return e&&typeof e==`object`}function Ur(e){return typeof e==`function`}function Wr(e){let t=e.code;return typeof t==`string`?t===`ENOENT`||t===`ENOTDIR`||t.includes(`ENS`):!1}function Gr(e){return Vr((e=>{try{return e.readFile().catch(e=>e)}catch(e){return e}})(e))}var Kr=[`readFile`,`writeFile`,`mkdir`,`rmdir`,`unlink`,`stat`,`lstat`,`readdir`,`readlink`,`symlink`];function qr(e,t){if(Gr(t))for(let n of Kr)e[`_${n}`]=t[n].bind(t);else for(let n of Kr)e[`_${n}`]=(0,Be.default)(t[n].bind(t));Gr(t)?(t.cp&&(e._cp=t.cp.bind(t)),e._rm=t.rm?t.rm.bind(t):t.rmdir.length>1?t.rmdir.bind(t):Br.bind(null,e)):(t.cp&&(e._cp=(0,Be.default)(t.cp.bind(t))),e._rm=t.rm?(0,Be.default)(t.rm.bind(t)):t.rmdir.length>2?(0,Be.default)(t.rmdir.bind(t)):Br.bind(null,e))}var Z=class{constructor(e){if(e._original_unwrapped_fs!==void 0)return e;let t=Object.getOwnPropertyDescriptor(e,`promises`);t&&t.enumerable?qr(this,e.promises):qr(this,e),this._original_unwrapped_fs=e}async exists(e,t={}){try{return await this._stat(e),!0}catch(e){if(Wr(e))return!1;throw console.log(`Unhandled error in "FileSystem.exists()" function`,e),e}}async read(e,t={}){let n;try{n=await this._readFile(e,t)}catch(e){if(Wr(e)||e.code===`EISDIR`)return null;throw e}if(n==null)return null;if(t.autocrlf===`true`)try{n=new TextDecoder(`utf8`,{fatal:!0}).decode(n),n=n.replace(/\r\n/g,`
50
- `),n=new TextEncoder().encode(n)}catch{}return typeof n!=`string`&&(n=Buffer.from(n)),n}async write(e,t,n={}){try{await this._writeFile(e,t,n)}catch{await this.mkdir(yt(e)),await this._writeFile(e,t,n)}}async mkdir(e){await zr(this._mkdir,e)}async rm(e){try{await this._unlink(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async rmdir(e,t){try{t&&t.recursive?await this._rm(e,t):await this._rmdir(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async readdir(e){let t;try{t=await this._readdir(e)}catch(e){if(e.code===`ENOTDIR`)return null;if(Wr(e))return[];throw e}return t.sort(Je),t}async readdirDeep(e){let t=await this._readdir(e);return(await Promise.all(t.map(async t=>{let n=e+`/`+t;return(await this._stat(n)).isDirectory()?this.readdirDeep(n):n}))).reduce((e,t)=>e.concat(t),[])}async lstat(e){try{return await this._lstat(e)}catch(e){if(Wr(e))return null;throw e}}async readlink(e,t={encoding:`buffer`}){try{let n=await this._readlink(e,t);return Buffer.isBuffer(n)?n:Buffer.from(n)}catch(e){if(Wr(e))return null;throw e}}async writelink(e,t){return this._symlink(t.toString(`utf8`),e)}};function Q(e,t){if(t===void 0)throw new ar(e)}function Jr(e){return e.startsWith(`/`)||/^[a-zA-Z]:[\\/]/.test(e)}async function $({fsp:e,dotgit:t}){Q(`fsp`,e),Q(`dotgit`,t);let n=await e._stat(t).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return n.isDirectory()?t:n.isFile()?e._readFile(t,`utf8`).then(e=>e.trimRight().substr(8)).then(e=>Jr(e)?e:Y(yt(t),e)):t}async function Yr(e,t){return!e&&!t?!1:e&&!t||!e&&t?!0:!(await e.type()===`tree`&&await t.type()===`tree`||await e.type()===await t.type()&&await e.mode()===await t.mode()&&await e.oid()===await t.oid())}async function Xr({fs:e,dir:t,gitdir:n=Y(t,`.git`),commit:r=`HEAD`,cache:i={}}){try{Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n);let a=new Z(e),o=[jr({ref:r}),Nr(),wt()],s=[],c=await $({fsp:a,dotgit:n});await _t.acquire({fs:a,gitdir:c,cache:i},async function(e){s=e.unmergedPaths});let l=await Rr({fs:a,cache:i,dir:t,gitdir:c,trees:o,map:async function(e,[t,n,r]){let i=!await Yr(n,r),a=s.includes(e),o=!await Yr(r,t);if(i||a)return t?{path:e,mode:await t.mode(),oid:await t.oid(),type:await t.type(),content:await t.content()}:void 0;if(o)return!1;throw new mr(e)}});await _t.acquire({fs:a,gitdir:c,cache:i},async function(e){for(let n of l)if(n!==!1){if(!n)await a.rmdir(`${t}/${n.path}`,{recursive:!0}),e.delete({filepath:n.path});else if(n.type===`blob`){let r=new TextDecoder().decode(n.content);await a.write(`${t}/${n.path}`,r,{mode:n.mode}),e.insert({filepath:n.path,oid:n.oid,stage:0})}}})}catch(e){throw e.caller=`git.abortMerge`,e}}var Zr=class{static async isIgnored({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r}){if(vt(r)===`.git`)return!0;if(r===`.`)return!1;let i=``,a=Y(n,`info`,`exclude`);await e.exists(a)&&(i=await e.read(a,`utf8`));let o=[{gitignore:Y(t,`.gitignore`),filepath:r}],s=r.split(`/`).filter(Boolean);for(let e=1;e<s.length;e++){let n=s.slice(0,e).join(`/`),r=s.slice(e).join(`/`);o.push({gitignore:Y(t,n,`.gitignore`),filepath:r})}let c=!1;for(let[t,n]of o.entries()){let r=await e.read(n.gitignore,`utf8`),a=(0,Ve.default)();t===0&&a.add(i),a.add(r);let o=yt(n.filepath);if(o!==`.`&&a.ignores(o))return!0;c=c?!a.test(n.filepath).unignored:a.test(n.filepath).ignored}return c}};async function Qr({fs:e,gitdir:t,object:n,format:r,oid:i}){if(r!==`deflated`)throw new q(`GitObjectStoreLoose expects objects to write to be in deflated format`);let a=`${t}/${`objects/${i.slice(0,2)}/${i.slice(2)}`}`;await e.exists(a)||await e.write(a,n)}var $r=null;async function ei(e){return $r===null&&($r=ni()),$r?ti(e):ze.default.deflate(e)}async function ti(e){let t=new CompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function ni(){try{return new CompressionStream(`deflate`).writable.close(),new Blob([]).stream().cancel(),!0}catch{return!1}}async function ri({fs:e,gitdir:t,type:n,object:r,format:i=`content`,oid:a=void 0,dryRun:o=!1}){return i!==`deflated`&&(i!==`wrapped`&&(r=mn.wrap({type:n,object:r})),a=await nt(r),r=Buffer.from(await ei(r))),o||await Qr({fs:e,gitdir:t,object:r,format:`deflated`,oid:a}),a}function ii(e){let t;for(;~(t=e.indexOf(92));)e[t]=47;return e}async function ai({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,cache:i={},force:a=!1,parallel:o=!0}){try{Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n),Q(`filepath`,r);let s=new Z(e),c=await $({fsp:s,dotgit:n});await _t.acquire({fs:s,gitdir:c,cache:i},async e=>{let n=await(await nn.get({fs:s,gitdir:c})).get(`core.autocrlf`);return si({dir:t,gitdir:c,fs:s,filepath:r,index:e,force:a,parallel:o,autocrlf:n})})}catch(e){throw e.caller=`git.add`,e}}function oi(e,t){if(e.has({filepath:t}))return!0;let n=`${t}/`;for(let t of e.entriesMap.keys())if(t.startsWith(n))return!0;return!1}async function si({dir:e,gitdir:t,fs:n,filepath:r,index:i,force:a,parallel:o,autocrlf:s}){r=Array.isArray(r)?r:[r];let c=r.map(async r=>{if(!a&&!oi(i,r)&&await Zr.isIgnored({fs:n,dir:e,gitdir:t,filepath:r}))return;let c=await n.lstat(Y(e,r));if(!c)throw new J(r);if(c.isDirectory()){let c=await n.readdir(Y(e,r));if(o){let l=c.map(c=>si({dir:e,gitdir:t,fs:n,filepath:[Y(r,c)],index:i,force:a,parallel:o,autocrlf:s}));await Promise.all(l)}else for(let l of c)await si({dir:e,gitdir:t,fs:n,filepath:[Y(r,l)],index:i,force:a,parallel:o,autocrlf:s})}else{let a=c.isSymbolicLink()?await n.readlink(Y(e,r)).then(ii):await n.read(Y(e,r),{autocrlf:s});if(a===null)throw new J(r);let o=await ri({fs:n,gitdir:t,type:`blob`,object:a});i.insert({filepath:r,stats:c,oid:o})}}),l=await Promise.allSettled(c),u=l.filter(e=>e.status===`rejected`).map(e=>e.reason);if(u.length>1)throw new or(u);if(u.length===1)throw u[0];return l.filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}async function ci({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`;return e.exists(`${t}/${r}`)}async function li({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=await e.readdir(Y(n,`objects/pack`));a=a.filter(e=>e.endsWith(`.idx`));for(let o of a){let a=await In({fs:e,cache:t,filename:`${n}/objects/pack/${o}`,getExternalRefDelta:i});if(a.error)throw new q(a.error);if(a.offsets.has(r))return!0}return!1}async function ui({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>Vn({fs:e,cache:t,gitdir:n,oid:r}),o=await ci({fs:e,gitdir:n,oid:r});return o||=await li({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),o}async function di({fs:e,gitdir:t,path:n}){return(await nn.get({fs:e,gitdir:t})).get(n)}function fi(e,...t){for(let n of t)if(n)for(let t of Object.keys(n)){let r=n[t];r!==void 0&&(e[t]=r)}return e}async function pi({fs:e,gitdir:t,author:n,commit:r}){let i=Math.floor(Date.now()/1e3),a=fi({},{name:await di({fs:e,gitdir:t,path:`user.name`}),email:await di({fs:e,gitdir:t,path:`user.email`})||``,timestamp:i,timezoneOffset:new Date(i*1e3).getTimezoneOffset()},r?r.author:void 0,n);if(a.name!==void 0)return a}async function mi({fs:e,gitdir:t,author:n,committer:r,commit:i}){let a=Math.floor(Date.now()/1e3),o=fi({},{name:await di({fs:e,gitdir:t,path:`user.name`}),email:await di({fs:e,gitdir:t,path:`user.email`})||``,timestamp:a,timezoneOffset:new Date(a*1e3).getTimezoneOffset()},i?i.committer:void 0,n,r);if(o.name!==void 0)return o}async function hi({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Vn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=Tr.from(a).parse().object,hi({fs:e,cache:t,gitdir:n,oid:r});if(i!==`commit`)throw new Tt(r,i,`commit`);return{commit:Or.from(a),oid:r}}async function gi({fs:e,cache:t,gitdir:n,oid:r}){let{commit:i,oid:a}=await hi({fs:e,cache:t,gitdir:n,oid:r});return{oid:a,commit:i.parse(),payload:i.withoutSignature()}}var _i=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`;async function vi({fs:e,cache:t,onSign:n,gitdir:r,message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,disallowEmpty:d=!1,ref:f,parent:p,tree:m}){let h=!1,g=!1;f||=(g=!(await e.read(`${r}/HEAD`,{encoding:`utf8`})).startsWith(`ref:`),await X.resolve({fs:e,gitdir:r,ref:`HEAD`,depth:2}));let _,v;try{_=await X.resolve({fs:e,gitdir:r,ref:f})}catch(e){if(!(e instanceof J))throw e;h=!0}if(!h&&(c||d)&&(v=await gi({fs:e,gitdir:r,oid:_,cache:t})),c&&h)throw new hr(f);let y=c?await pi({fs:e,gitdir:r,author:a,commit:v.commit}):await pi({fs:e,gitdir:r,author:a});if(!y)throw new ir(`author`);let b=c?await mi({fs:e,gitdir:r,author:y,committer:o,commit:v.commit}):await mi({fs:e,gitdir:r,author:y,committer:o});if(!b)throw new ir(`committer`);return _t.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async function(a){let o=bt(a.entries).get(`.`);if(m||=await yi({fs:e,gitdir:r,inode:o,dryRun:l}),p=p?await Promise.all(p.map(async n=>{let i=await X.resolve({fs:e,gitdir:r,ref:n});for(;await ui({fs:e,cache:t,gitdir:r,oid:i});){let{type:n,object:a}=await Vn({fs:e,cache:t,gitdir:r,oid:i});if(n===`commit`)break;if(n!==`tag`)throw new Tt(i,n,`commit`);i=Tr.from(a).parse().object}return i})):c?v.commit.parent:_?[_]:[],d&&!c&&(h&&m===_i||!h&&m===v.commit.tree))throw new Yn;if(!i){if(c)i=v.commit.message;else throw new ar(`message`)}let x=Or.from({tree:m,parent:p,author:y,committer:b,message:i});s&&(x=await Or.sign(x,n,s));let S=await ri({fs:e,gitdir:r,type:`commit`,object:x.toObject(),dryRun:l});return!u&&!l&&await X.writeRef({fs:e,gitdir:r,ref:g?`HEAD`:f,value:S}),S})}async function yi({fs:e,gitdir:t,inode:n,dryRun:r}){let i=n.children;for(let n of i)n.type===`tree`&&(n.metadata.mode=`040000`,n.metadata.oid=await yi({fs:e,gitdir:t,inode:n,dryRun:r}));let a=i.map(e=>({mode:e.metadata.mode,path:e.basename,oid:e.metadata.oid,type:e.type}));return await ri({fs:e,gitdir:t,type:`tree`,object:pn.from(a).toObject(),dryRun:r})}async function bi({fs:e,cache:t,gitdir:n,oid:r,filepath:i}){return(await xi({fs:e,cache:t,gitdir:n,oid:r,filepath:i})).oid}async function xi({fs:e,cache:t,gitdir:n,oid:r,filepath:i}){if(i.startsWith(`/`))throw new er(`leading-slash`);if(i.endsWith(`/`))throw new er(`trailing-slash`);let a=r,o=await kr({fs:e,cache:t,gitdir:n,oid:r}),s=o.tree;return i===``?{mode:`040000`,oid:o.oid,path:``,type:`tree`}:Si({fs:e,cache:t,gitdir:n,tree:s,pathArray:i.split(`/`),oid:a,filepath:i})}async function Si({fs:e,cache:t,gitdir:n,tree:r,pathArray:i,oid:a,filepath:o}){let s=i.shift();for(let c of r)if(c.path===s){if(i.length===0)return c;{let{type:s,object:l}=await Vn({fs:e,cache:t,gitdir:n,oid:c.oid});if(s!==`tree`)throw new Tt(a,s,`tree`,o);return r=pn.from(l),Si({fs:e,cache:t,gitdir:n,tree:r,pathArray:i,oid:a,filepath:o})}}throw new J(`file or directory found at "${a}:${o}"`)}async function Ci({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){i!==void 0&&(r=await bi({fs:e,cache:t,gitdir:n,oid:r,filepath:i}));let{tree:a,oid:o}=await kr({fs:e,cache:t,gitdir:n,oid:r});return{oid:o,tree:a.entries()}}async function wi({fs:e,gitdir:t,tree:n}){return await ri({fs:e,gitdir:t,type:`tree`,object:pn.from(n).toObject(),format:`content`})}async function Ti({fs:e,cache:t,onSign:n,gitdir:r,ref:i,oid:a,note:o,force:s,author:c,committer:l,signingKey:u}){let d;try{d=await X.resolve({gitdir:r,fs:e,ref:i})}catch(e){if(!(e instanceof J))throw e}let f=(await Ci({fs:e,cache:t,gitdir:r,oid:d||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;if(s)f=f.filter(e=>e.path!==a);else for(let e of f)if(e.path===a)throw new Hn(`note`,a);typeof o==`string`&&(o=Buffer.from(o,`utf8`));let p=await ri({fs:e,gitdir:r,type:`blob`,object:o,format:`content`});return f.push({mode:`100644`,path:a,oid:p,type:`blob`}),await vi({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:await wi({fs:e,gitdir:r,tree:f}),parent:d&&[d],message:`Note added by 'isomorphic-git addNote'
51
- `,author:c,committer:l,signingKey:u})}async function Ei({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ref:i=`refs/notes/commits`,oid:a,note:o,force:s,author:c,committer:l,signingKey:u,cache:d={}}){try{Q(`fs`,e),Q(`gitdir`,r),Q(`oid`,a),Q(`note`,o),u&&Q(`onSign`,t);let n=new Z(e),f=await pi({fs:n,gitdir:r,author:c});if(!f)throw new ir(`author`);let p=await mi({fs:n,gitdir:r,author:f,committer:l});if(!p)throw new ir(`committer`);return await Ti({fs:n,cache:d,onSign:t,gitdir:await $({fsp:n,dotgit:r}),ref:i,oid:a,note:o,force:s,author:f,committer:p,signingKey:u})}catch(e){throw e.caller=`git.addNote`,e}}async function Di({fs:e,gitdir:t,remote:n,url:r,force:i}){if(!Pt(n,!0))throw new Dt(n,Le.default.clean(n));let a=await nn.get({fs:e,gitdir:t});if(!i&&(await a.getSubsections(`remote`)).includes(n)&&r!==await a.get(`remote.${n}.url`))throw new Hn(`remote`,n);await a.set(`remote.${n}.url`,r),await a.set(`remote.${n}.fetch`,`+refs/heads/*:refs/remotes/${n}/*`),await nn.save({fs:e,gitdir:t,config:a})}async function Oi({fs:e,dir:t,gitdir:n=Y(t,`.git`),remote:r,url:i,force:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`remote`,r),Q(`url`,i);let t=new Z(e);return await Di({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r,url:i,force:a})}catch(e){throw e.caller=`git.addRemote`,e}}async function ki({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tagger:a,message:o=i,gpgsig:s,object:c,signingKey:l,force:u=!1}){if(i=i.startsWith(`refs/tags/`)?i:`refs/tags/${i}`,!u&&await X.exists({fs:e,gitdir:r,ref:i}))throw new Hn(`tag`,i);let d=await X.resolve({fs:e,gitdir:r,ref:c||`HEAD`}),{type:f}=await Vn({fs:e,cache:t,gitdir:r,oid:d}),p=Tr.from({object:d,type:f,tag:i.replace(`refs/tags/`,``),tagger:a,message:o,gpgsig:s});l&&(p=await Tr.sign(p,n,l));let m=await ri({fs:e,gitdir:r,type:`tag`,object:p.toObject()});await X.writeRef({fs:e,gitdir:r,ref:i,value:m})}async function Ai({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ref:i,tagger:a,message:o=i,gpgsig:s,object:c,signingKey:l,force:u=!1,cache:d={}}){try{Q(`fs`,e),Q(`gitdir`,r),Q(`ref`,i),l&&Q(`onSign`,t);let n=new Z(e),f=await $({fsp:n,dotgit:r}),p=await pi({fs:n,gitdir:f,author:a});if(!p)throw new ir(`tagger`);return await ki({fs:n,cache:d,onSign:t,gitdir:f,ref:i,tagger:p,message:o,gpgsig:s,object:c,signingKey:l,force:u})}catch(e){throw e.caller=`git.annotatedTag`,e}}async function ji({fs:e,gitdir:t,ref:n,object:r,checkout:i=!1,force:a=!1}){if(!Pt(n,!0))throw new Dt(n,Le.default.clean(n));let o=`refs/heads/${n}`;if(!a&&await X.exists({fs:e,gitdir:t,ref:o}))throw new Hn(`branch`,n,!1);let s;try{s=await X.resolve({fs:e,gitdir:t,ref:r||`HEAD`})}catch(e){if(!(e instanceof J))throw e}s&&(s=(await hi({fs:e,cache:{},gitdir:t,oid:s})).oid,await X.writeRef({fs:e,gitdir:t,ref:o,value:s})),i&&await X.writeSymbolicRef({fs:e,gitdir:t,ref:`HEAD`,value:o})}async function Mi({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,object:i,checkout:a=!1,force:o=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e);return await ji({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r,object:i,checkout:a,force:o})}catch(e){throw e.caller=`git.branch`,e}}async function Ni(e,t,n){let r=n.split(`/`);r.pop();let i=t;for(let t of r){if(t===``||t===`.`)continue;i=`${i}/${t}`;let r=await e.lstat(i);if(r&&r.isSymbolicLink())throw new We(n)}}var Pi=(e,t)=>{if(e===`.`||t==null||t.length===0||t===`.`)return!0;let n=t.endsWith(`/`)?t.slice(0,-1):t;return n===`.`?!0:n.length>=e.length?n===e||n.startsWith(`${e}/`):e.startsWith(`${n}/`)};async function Fi({fs:e,cache:t,onProgress:n,onPostCheckout:r,dir:i,gitdir:a,remote:o,ref:s,filepaths:c,noCheckout:l,noUpdateHead:u,dryRun:d,force:f,track:p=!0,restoreFromIndex:m=!1,nonBlocking:h=!1,batchSize:g=100}){let _;if(r)try{_=await X.resolve({fs:e,gitdir:a,ref:`HEAD`})}catch{_=`0000000000000000000000000000000000000000`}let v;try{v=await X.resolve({fs:e,gitdir:a,ref:s})}catch(t){if(s===`HEAD`||!(t instanceof J))throw t;let n=`${o}/${s}`;if(v=await X.resolve({fs:e,gitdir:a,ref:n}),p){let t=await nn.get({fs:e,gitdir:a});await t.set(`branch.${s}.remote`,o),await t.set(`branch.${s}.merge`,`refs/heads/${s}`),await nn.save({fs:e,gitdir:a,config:t})}await X.writeRef({fs:e,gitdir:a,ref:`refs/heads/${s}`,value:v})}if(!u)try{v=(await hi({fs:e,cache:t,gitdir:a,oid:v})).oid}catch(e){throw e instanceof J?new Jn(s,e.data.what):e}if(!l){let o;try{o=await Ii({fs:e,cache:t,onProgress:n,dir:i,gitdir:a,ref:s,force:f,filepaths:c,restoreFromIndex:m})}catch(e){throw e instanceof J&&e.data.what===v?new Jn(s,v):e}let l=o.filter(([e])=>e===`conflict`).map(([e,t])=>t);if(l.length>0)throw new Wn(l);let u=o.filter(([e])=>e===`error`).map(([e,t])=>t);if(u.length>0)throw new q(u.join(`, `));if(d){r&&await r({previousHead:_,newHead:v,type:c!=null&&c.length>0?`file`:`branch`});return}let p=0,y=o.length;if(await _t.acquire({fs:e,gitdir:a,cache:t},async function(t){await Promise.all(o.filter(([e])=>e===`delete`||e===`delete-index`).map(async function([r,a]){let o=`${i}/${a}`;r===`delete`&&await e.rm(o),t.delete({filepath:a}),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})}))}),await _t.acquire({fs:e,gitdir:a,cache:t},async function(t){for(let[r,a]of o)if(r===`rmdir`||r===`rmdir-index`){let o=`${i}/${a}`;try{r===`rmdir`&&await e.rmdir(o),t.delete({filepath:a}),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})}catch(e){if(e.code===`ENOTEMPTY`)console.log(`Did not delete ${a} because directory is not empty`);else throw e}}}),await Promise.all(o.filter(([e])=>e===`mkdir`||e===`mkdir-index`).map(async function([t,r]){let a=`${i}/${r}`;await Ni(e,i,r),await e.mkdir(a),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})})),h){let r=await zi(`Update Working Dir`,o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(([n,r,o,s,c])=>()=>Ri({fs:e,cache:t,gitdir:a,dir:i},[n,r,o,s,c])),n,g);await _t.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(e){await zi(`Update Index`,r.map(([t,n,r])=>()=>Li({index:e,fullpath:t,oid:n,stats:r})),n,g)})}else await _t.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(r){let s=await Promise.allSettled(o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(async function([o,s,c,l,u]){let d=`${i}/${s}`;if(o!==`create-index`&&o!==`mkdir-index`){await Ni(e,i,s);let{object:n}=await Vn({fs:e,cache:t,gitdir:a,oid:c});if(u&&await e.rm(d),l===33188)await e.write(d,n);else if(l===33261)await e.write(d,n,{mode:511});else if(l===40960)await e.writelink(d,n);else throw new q(`Invalid mode 0o${l.toString(8)} detected in blob ${c}`)}let f=await e.lstat(d);l===33261&&(f.mode=493),o===`mkdir-index`&&(f.mode=57344),r.insert({filepath:s,stats:f,oid:c}),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})})),c=[];for(let e of s)e.status===`rejected`&&(c.push(e.reason),console.error(`[isomorphic-git checkout] task rejected:`,e.reason?.stack??e.reason));if(c.length>0)throw new or(c)});r&&await r({previousHead:_,newHead:v,type:c!=null&&c.length>0?`file`:`branch`})}if(!u){let t=await X.expand({fs:e,gitdir:a,ref:s});t.startsWith(`refs/heads`)?await X.writeSymbolicRef({fs:e,gitdir:a,ref:`HEAD`,value:t}):await X.writeRef({fs:e,gitdir:a,ref:`HEAD`,value:v})}}async function Ii({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,ref:a,force:o,filepaths:s,restoreFromIndex:c}){let l=0;return Rr({fs:e,cache:t,dir:r,gitdir:i,trees:[c?wt():jr({ref:a}),Nr(),wt()],map:async function(e,[t,r,i]){if(e!==`.`){if(s&&!s.some(t=>Pi(e,t)))return null;switch(n&&await n({phase:`Analyzing workdir`,loaded:++l}),[!!i,!!t,!!r].map(Number).join(``)){case`000`:return;case`001`:return!c&&o&&s&&s.includes(e)?[`delete`,e]:void 0;case`010`:switch(await t.type()){case`tree`:return[`mkdir`,e];case`blob`:return[`create`,e,await t.oid(),await t.mode()];case`commit`:return[`mkdir-index`,e,await t.oid(),await t.mode()];default:return[`error`,`new entry Unhandled type ${await t.type()}`]}case`011`:switch(`${await t.type()}-${await r.type()}`){case`tree-tree`:return;case`tree-blob`:case`blob-tree`:return[`conflict`,e];case`blob-blob`:return await t.oid()===await r.oid()?await t.mode()===await r.mode()?[`create-index`,e,await t.oid(),await t.mode()]:o?[`update`,e,await t.oid(),await t.mode(),!0]:[`conflict`,e]:o?[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await r.mode()]:[`conflict`,e];case`commit-tree`:return;case`commit-blob`:return[`conflict`,e];default:return[`error`,`new entry Unhandled type ${t.type}`]}case`100`:return[`delete-index`,e];case`101`:switch(await i.type()){case`tree`:return[`rmdir-index`,e];case`blob`:return await i.oid()===await r.oid()||o?[`delete`,e]:[`conflict`,e];case`commit`:return[`rmdir-index`,e];default:return[`error`,`delete entry Unhandled type ${await i.type()}`]}case`110`:case`111`:switch(`${await i.type()}-${await t.type()}`){case`tree-tree`:return;case`blob-blob`:if(await i.oid()===await t.oid()&&await i.mode()===await t.mode()&&!o)return;if(r){if(await r.oid()!==await i.oid()&&await r.oid()!==await t.oid())return o?[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await r.mode()]:[`conflict`,e]}else if(o)return[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await i.mode()];return await t.mode()===await i.mode()?await t.oid()===await i.oid()?void 0:[`update`,e,await t.oid(),await t.mode(),!1]:[`update`,e,await t.oid(),await t.mode(),!0];case`tree-blob`:return[`update-dir-to-blob`,e,await t.oid()];case`blob-tree`:return[`update-blob-to-tree`,e];case`commit-commit`:return[`mkdir-index`,e,await t.oid(),await t.mode()];default:return[`error`,`update entry Unhandled type ${await i.type()}-${await t.type()}`]}}}},reduce:async function(e,t){return t=Fr(t),e?e&&e[0]===`rmdir`?(t.push(e),t):(t.unshift(e),t):t}})}async function Li({index:e,fullpath:t,stats:n,oid:r}){try{e.insert({filepath:t,stats:n,oid:r})}catch(e){console.warn(`Error inserting ${t} into index:`,e)}}async function Ri({fs:e,cache:t,gitdir:n,dir:r},[i,a,o,s,c]){let l=`${r}/${a}`;if(i!==`create-index`&&i!==`mkdir-index`){await Ni(e,r,a);let{object:i}=await Vn({fs:e,cache:t,gitdir:n,oid:o});if(c&&await e.rm(l),s===33188)await e.write(l,i);else if(s===33261)await e.write(l,i,{mode:511});else if(s===40960)await e.writelink(l,i);else throw new q(`Invalid mode 0o${s.toString(8)} detected in blob ${o}`)}let u=await e.lstat(l);return s===33261&&(u.mode=493),i===`mkdir-index`&&(u.mode=57344),[a,o,u]}async function zi(e,t,n,r){let i=[],a=[];for(let o=0;o<t.length;o+=r){let s=t.slice(o,o+r).map(e=>e());(await Promise.allSettled(s)).forEach(t=>{t.status===`fulfilled`?i.push(t.value):(a.push(t.reason),console.error(`[isomorphic-git ${e}] task rejected:`,t.reason?.stack??t.reason))}),n&&await n({phase:`Updating workdir`,loaded:o+s.length,total:t.length})}if(a.length>0)throw new or(a);return i}async function Bi({fs:e,onProgress:t,onPostCheckout:n,dir:r,gitdir:i=Y(r,`.git`),remote:a=`origin`,ref:o,filepaths:s,noCheckout:c=!1,noUpdateHead:l=o===void 0,dryRun:u=!1,force:d=!1,track:f=!0,cache:p={},nonBlocking:m=!1,batchSize:h=100}){try{Q(`fs`,e),Q(`dir`,r),Q(`gitdir`,i);let g=o||`HEAD`,_=o===void 0&&s!=null&&s.length>0,v=new Z(e);return await Fi({fs:v,cache:p,onProgress:t,onPostCheckout:n,dir:r,gitdir:await $({fsp:v,dotgit:i}),remote:a,ref:g,filepaths:s,noCheckout:c,noUpdateHead:l,dryRun:u,force:d,track:f,restoreFromIndex:_,nonBlocking:m,batchSize:h})}catch(e){throw e.caller=`git.checkout`,e}}var Vi=/^.*(\r?\n|$)/gm;function Hi({branches:e,contents:t}){let n=e[1],r=e[2],i=t[0],a=t[1],o=t[2],s=a.match(Vi),c=i.match(Vi),l=o.match(Vi),u=(0,He.default)(s,c,l),d=``,f=!0;for(let e of u)e.ok&&(d+=e.ok.join(``)),e.conflict&&(f=!1,d+=`${`<`.repeat(7)} ${n}\n`,d+=e.conflict.a.join(``),d+=`${`=`.repeat(7)}\n`,d+=e.conflict.b.join(``),d+=`${`>`.repeat(7)} ${r}\n`);return{cleanMerge:f,mergedText:d}}async function Ui({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),index:i,ourOid:a,baseOid:o,theirOid:s,ourName:c=`ours`,baseName:l=`base`,theirName:u=`theirs`,dryRun:d=!1,abortOnConflict:f=!0,mergeDriver:p}){let m=jr({ref:a}),h=jr({ref:o}),g=jr({ref:s}),_=[],v=[],y=[],b=[],x=await Rr({fs:e,cache:t,dir:n,gitdir:r,trees:[m,h,g],map:async function(t,[n,a,o]){let s=vt(t);switch(`${await Yr(n,a)}-${await Yr(o,a)}`){case`false-false`:return{mode:await a.mode(),path:s,oid:await a.oid(),type:await a.type()};case`false-true`:return!o&&await n.type()===`tree`?{mode:await n.mode(),path:s,oid:await n.oid(),type:await n.type()}:o?{mode:await o.mode(),path:s,oid:await o.oid(),type:await o.type()}:void 0;case`true-false`:return!n&&await o.type()===`tree`?{mode:await o.mode(),path:s,oid:await o.oid(),type:await o.type()}:n?{mode:await n.mode(),path:s,oid:await n.oid(),type:await n.type()}:void 0;case`true-true`:if(n&&o&&await n.type()===`tree`&&await o.type()===`tree`)return{mode:await n.mode(),path:s,oid:await n.oid(),type:`tree`};if(n&&o&&await n.type()===`blob`&&await o.type()===`blob`)return Wi({fs:e,gitdir:r,path:s,ours:n,base:a,theirs:o,ourName:c,baseName:l,theirName:u,mergeDriver:p}).then(async e=>{if(e.cleanMerge)f||i.insert({filepath:t,oid:e.mergeResult.oid,stage:0});else if(_.push(t),v.push(t),!f){let e=``;a&&await a.type()===`blob`&&(e=await a.oid());let r=await n.oid(),s=await o.oid();i.delete({filepath:t}),e&&i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:r,stage:2}),i.insert({filepath:t,oid:s,stage:3})}return e.mergeResult});if(a&&!n&&o&&await a.type()===`blob`&&await o.type()===`blob`){if(_.push(t),y.push(t),!f){let e=await a.oid(),n=await o.oid();i.delete({filepath:t}),i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:n,stage:3})}return{mode:await o.mode(),oid:await o.oid(),type:`blob`,path:s}}if(a&&n&&!o&&await a.type()===`blob`&&await n.type()===`blob`){if(_.push(t),b.push(t),!f){let e=await a.oid(),r=await n.oid();i.delete({filepath:t}),i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:r,stage:2})}return{mode:await n.mode(),oid:await n.oid(),type:`blob`,path:s}}if(a&&!n&&!o&&(await a.type()===`blob`||await a.type()===`tree`))return;throw new nr}},reduce:_.length!==0&&(!n||f)?void 0:async(t,n)=>{let i=n.filter(Boolean);if(t&&!(t&&t.type===`tree`&&i.length===0&&t.path!==`.`))return(i.length>0||t.path===`.`&&i.length===0)&&(t.oid=await ri({fs:e,gitdir:r,type:`tree`,object:new pn(i).toObject(),dryRun:d})),t}});return _.length===0?x.oid:(n&&!f&&await Rr({fs:e,cache:t,dir:n,gitdir:r,trees:[jr({ref:x.oid})],map:async function(t,[r]){let i=`${n}/${t}`;if(await r.type()===`blob`){let t=await r.mode(),n=await r.content();await e.write(i,n,{mode:t})}return!0}}),new rr(_,v,y,b))}async function Wi({fs:e,gitdir:t,path:n,ours:r,base:i,theirs:a,ourName:o,theirName:s,baseName:c,dryRun:l,mergeDriver:u=Hi}){let d=`blob`,f=`100755`,p=``,m=``;i&&await i.type()===`blob`&&(f=await i.mode(),p=await i.oid(),m=Buffer.from(await i.content()).toString(`utf8`));let h=f===await r.mode()?await a.mode():await r.mode();if(await r.oid()===await a.oid())return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await r.oid(),type:d}};if(await r.oid()===p)return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await a.oid(),type:d}};if(await a.oid()===p)return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await r.oid(),type:d}};let g=Buffer.from(await r.content()).toString(`utf8`),_=Buffer.from(await a.content()).toString(`utf8`),{mergedText:v,cleanMerge:y}=await u({branches:[c,o,s],contents:[m,g,_],path:n});return{cleanMerge:y,mergeResult:{mode:h,path:n,oid:await ri({fs:e,gitdir:t,type:`blob`,object:Buffer.from(v,`utf8`),dryRun:l}),type:d}}}var Gi={stage:wt,workdir:Nr};async function Ki(e,t,n,r,i=null){let a=Y(n,r),o=await e.lstat(a);if(!o)throw new J(a);if(o.isDirectory())throw new q(`${a}: file expected, but found directory`);let s=i?await hn({fs:e,gitdir:t,oid:i}):void 0,c=s?i:void 0;return s||await ft(a,async()=>{let n=o.isSymbolicLink()?await e.readlink(a).then(ii):await e.read(a);if(n===null)throw new J(a);c=await ri({fs:e,gitdir:t,type:`blob`,object:n})}),c}async function qi({fs:e,dir:t,gitdir:n,entries:r}){async function i(r){return r.type===`tree`?r.oid||(r.oid=await wi({fs:e,gitdir:n,tree:await Promise.all(r.children.map(i))}),r.mode=16384):r.type===`blob`&&(r.oid=await Ki(e,n,t,r.path,r.oid),r.mode=33188),r.path=r.path.split(`/`).pop(),r}return Promise.all(r.map(i))}async function Ji({fs:e,dir:t,gitdir:n,treePair:r}){let i=r[1]===`stage`,a=r.map(e=>typeof e==`string`?Gi[e]():e),o=[],s=await Rr({fs:e,cache:{},dir:t,gitdir:n,trees:a,map:async(r,[i,a])=>{if(!(r===`.`||await Zr.isIgnored({fs:e,dir:t,gitdir:n,filepath:r}))&&a)return(!i||await i.oid()!==await a.oid()&&await a.oid()!==void 0)&&o.push([i,a]),{mode:await a.mode(),path:r,oid:await a.oid(),type:await a.type()}},reduce:async(e,t)=>(t=t.filter(Boolean),e?(e.children=t,e):t.length>0?t:void 0),iterate:async(n,r)=>{let a=[];for(let n of r){let[r,s]=n;i?s&&(await e.exists(`${t}/${s.toString()}`)?a.push(n):o.push([null,s])):r&&(s?a.push(n):o.push([r,null]))}return a.length?Promise.all(a.map(n)):[]}});return o.length===0||s.length===0?null:wi({fs:e,gitdir:n,tree:(await qi({fs:e,dir:t,gitdir:n,entries:s})).filter(Boolean).map(e=>({mode:e.mode,path:e.path,oid:e.oid,type:e.type}))})}async function Yi({fs:e,dir:t,gitdir:n,stashCommit:r,parentCommit:i,wasStaged:a}){let o=[],s=[],c=await Rr({fs:e,cache:{},dir:t,gitdir:n,trees:[jr({ref:i}),jr({ref:r})],map:async(r,[i,c])=>{if(r===`.`||await Zr.isIgnored({fs:e,dir:t,gitdir:n,filepath:r}))return;let l=c?await c.type():await i.type();if(l!==`tree`&&l!==`blob`)return;if(!c&&i){let e=l===`tree`?`rmdir`:`rm`;return l===`tree`&&o.push(r),l===`blob`&&a&&s.push({filepath:r,oid:await i.oid()}),{method:e,filepath:r}}let u=await c.oid();if(!i||await i.oid()!==u)return l===`tree`?{method:`mkdir`,filepath:r}:(a&&s.push({filepath:r,oid:u,stats:await e.lstat(Y(t,r))}),{method:`write`,filepath:r,oid:u})}});await ft(n,async()=>{for(let r of c){let i=Y(t,r.filepath);switch(r.method){case`rmdir`:await e.rmdir(i);break;case`mkdir`:await Ni(e,t,r.filepath),await e.mkdir(i);break;case`rm`:await e.rm(i);break;case`write`:if(!o.some(e=>i.startsWith(e))){await Ni(e,t,r.filepath);let{object:a}=await Vn({fs:e,cache:{},gitdir:n,oid:r.oid});await e.exists(i)&&await e.rm(i),await e.write(i,a)}}}}),await _t.acquire({fs:e,gitdir:n,cache:{}},async e=>{s.forEach(({filepath:t,stats:n,oid:r})=>{e.insert({filepath:t,stats:n,oid:r})})})}async function Xi({fs:e,cache:t,dir:n,gitdir:r,oid:i,dryRun:a=!1,noUpdateBranch:o=!1,abortOnConflict:s=!0,committer:c,mergeDriver:l}){let{commit:u,oid:d}=await gi({fs:e,cache:t,gitdir:r,oid:i});if(u.parent.length>1)throw new Kn(d,u.parent.length);if(u.parent.length===0)throw new qn(d);let f=await X.resolve({fs:e,gitdir:r,ref:`HEAD`}),{commit:p}=await gi({fs:e,cache:t,gitdir:r,oid:f}),m=u.parent[0],{commit:h}=await gi({fs:e,cache:t,gitdir:r,oid:m});if(n&&(!a&&!o||!s)){let i=await Zi({fs:e,cache:t,dir:n,gitdir:r,headTree:p.tree,baseTree:h.tree,theirTree:u.tree,allTracked:!s});if(i.length>0)throw new Gn(i)}let g=await _t.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async i=>Ui({fs:e,cache:t,dir:n,gitdir:r,index:i,ourOid:p.tree,baseOid:h.tree,theirOid:u.tree,ourName:`HEAD`,baseName:`parent of ${d.slice(0,7)}`,theirName:d.slice(0,7),dryRun:a,abortOnConflict:s,mergeDriver:l}));if(g instanceof rr)throw g;let _=await vi({fs:e,cache:t,gitdir:r,message:u.message,tree:g,parent:[f],author:u.author,committer:c,dryRun:a,noUpdateBranch:o});return n&&!a&&!o&&await Yi({fs:e,dir:n,gitdir:r,stashCommit:_,parentCommit:f,wasStaged:!0}),_}async function Zi({fs:e,cache:t,dir:n,gitdir:r,headTree:i,baseTree:a,theirTree:o,allTracked:s}){let c=await Rr({fs:e,cache:t,dir:n,gitdir:r,trees:[jr({ref:a}),jr({ref:o})],map:async(e,[t,n])=>{if(e!==`.`){if(t&&n&&await t.oid()===await n.oid())return null;if([t?await t.type():void 0,n?await n.type():void 0].includes(`blob`))return e}}});return c.length===0&&!s?[]:Rr({fs:e,cache:t,dir:n,gitdir:r,trees:[jr({ref:i}),wt(),Nr()],map:async(e,[t,n,r])=>{if(e===`.`)return;if(!s&&!c.some(t=>Pi(e,t)))return null;let i=t&&await t.type()===`blob`?await t.oid():void 0;if((c.includes(e)||s&&i)&&((n?await n.oid():void 0)!==i||r&&(!i||await r.type()!==`blob`||await r.oid()!==i)))return e}})}async function Qi({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={},committer:a,dryRun:o=!1,noUpdateBranch:s=!1,abortOnConflict:c=!0,mergeDriver:l}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let u=new Z(e),d=await $({fsp:u,dotgit:n}),{commit:f}=await gi({fs:u,cache:i,gitdir:d,oid:r});if(f.parent&&f.parent.length>1)return await Xi({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:void 0,mergeDriver:l});let p=await mi({fs:u,gitdir:d,committer:a});if(!p)throw new ir(`committer`);return await Xi({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:p,mergeDriver:l})}catch(e){throw e.caller=`git.cherryPick`,e}}var $i=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function ea(e){let t=$i.exec(e);return t?t[1]===`remotes/`&&e.endsWith(`/HEAD`)?t[2].slice(0,-5):t[2]:e}async function ta({fs:e,gitdir:t,fullname:n=!1,test:r=!1}){let i=await X.resolve({fs:e,gitdir:t,ref:`HEAD`,depth:2});if(r)try{await X.resolve({fs:e,gitdir:t,ref:i})}catch(e){if(e instanceof J)return;throw e}if(i.startsWith(`refs/`))return n?i:ea(i)}function na(e){return e=e.replace(/^[^/@:]+@([^/@:]+):/,`https://$1/`),e=e.replace(/^ssh:\/\//,`https://`),e}function ra({username:e=``,password:t=``}){return`Basic ${Buffer.from(`${e}:${t}`).toString(`base64`)}`}async function ia(e,t){let n=xn(e);for(;;){let{value:e,done:r}=await n.next();if(e&&await t(e),r)break}n.return&&n.return()}async function aa(e){let t=0,n=[];await ia(e,e=>{n.push(e),t+=e.byteLength});let r=new Uint8Array(t),i=0;for(let e of n)r.set(e,i),i+=e.byteLength;return r}var oa=/^(https?:\/\/)([^/?#]+)@/i;function sa(e){let t=e.match(oa);return t==null?{url:e,auth:{}}:{url:e.replace(oa,`$1`),auth:ca(e,t[2])}}function ca(e,t){let n=la(e),r=t.indexOf(`:`)!==-1;if(n!==null)return{username:ua(n.username),password:r?ua(n.password):void 0};let i=t.indexOf(`:`);return{username:r?t.slice(0,i):t,password:r?t.slice(i+1):void 0}}function la(e){if(typeof URL!=`function`)return null;try{return new URL(e)}catch{return null}}function ua(e){try{return decodeURIComponent(e)}catch{return e}}function da(e,t){let n=t.toString(16);return`0`.repeat(e-n.length)+n}var fa=class{static flush(){return Buffer.from(`0000`,`utf8`)}static delim(){return Buffer.from(`0001`,`utf8`)}static encode(e){typeof e==`string`&&(e=Buffer.from(e));let t=da(4,e.length+4);return Buffer.concat([Buffer.from(t,`utf8`),e])}static streamReader(e){let t=new Sn(e);return async function(){try{let e=await t.read(4);return e==null||(e=parseInt(e.toString(`utf8`),16),e===0||e===1?null:await t.read(e-4)??!0)}catch(t){return e.error=t,!0}}}};async function pa(e){let t={},n;for(;n=await e(),n!==!0;){if(n===null)continue;n=n.toString(`utf8`).replace(/\n$/,``);let e=n.indexOf(`=`);if(e>-1){let r=n.slice(0,e);t[r]=n.slice(e+1)}else t[n]=!0}return{protocolVersion:2,capabilities2:t}}async function ma(e,{service:t}){let n=new Set,r=new Map,i=new Map,a=fa.streamReader(e),o=await a();for(;o===null;)o=await a();if(o===!0)throw new Xn;if(o.includes(`version 2`))return pa(a);if(o.toString(`utf8`).replace(/\n$/,``)!==`# service=${t}`)throw new sr(`# service=${t}\\n`,o.toString(`utf8`));let s=await a();for(;s===null;)s=await a();if(s===!0)return{capabilities:n,refs:r,symrefs:i};if(s=s.toString(`utf8`),s.includes(`version 2`))return pa(a);let[c,l]=ha(s,`\0`,`\\x00`);if(l.split(` `).map(e=>n.add(e)),c!==`0000000000000000000000000000000000000000 capabilities^{}`){let[e,t]=ha(c,` `,` `);for(r.set(t,e);;){let e=await a();if(e===!0)break;if(e!==null){let[t,n]=ha(e.toString(`utf8`),` `,` `);r.set(n,t)}}}for(let e of n)if(e.startsWith(`symref=`)){let t=e.match(/symref=([^:]+):(.*)/);t.length===3&&i.set(t[1],t[2])}return{protocolVersion:1,capabilities:n,refs:r,symrefs:i}}function ha(e,t,n){let r=e.trim().split(t);if(r.length!==2)throw new sr(`Two strings separated by '${n}'`,e.toString(`utf8`));return r}var ga=(e,t)=>e.endsWith(`?`)?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,``)}`,_a=(e,t)=>{(t.username||t.password)&&(e.Authorization=ra(t)),t.headers&&Object.assign(e,t.headers)},va=async e=>{try{let t=Buffer.from(await aa(e.body)),n=t.toString(`utf8`);return{preview:n.length<256?n:n.slice(0,256)+`...`,response:n,data:t}}catch{return{}}},ya=class{static async capabilities(){return[`discover`,`connect`]}static async discover({http:e,onProgress:t,onAuth:n,onAuthSuccess:r,onAuthFailure:i,corsProxy:a,service:o,url:s,headers:c,signal:l,protocolVersion:u}){let{url:d,auth:f}=sa(s),p=a?ga(a,d):d;(f.username||f.password)&&(c.Authorization=ra(f)),u===2&&(c[`Git-Protocol`]=`version=2`);let m,h,g=!1;do if(m=await e.request({onProgress:t,method:`GET`,url:`${p}/info/refs?service=${o}`,headers:c,signal:l}),h=!1,m.statusCode===401||m.statusCode===203){let e=g?i:n;if(e){if(f=await e(d,{...f,headers:{...c}}),f&&f.cancel)throw new pr;f&&(_a(c,f),g=!0,h=!0)}}else m.statusCode===200&&g&&r&&await r(d,f);while(h);if(m.statusCode!==200){let{response:e}=await va(m);throw new $n(m.statusCode,m.statusMessage,e)}if(m.headers[`content-type`]===`application/x-${o}-advertisement`){let e=await ma(m.body,{service:o});return e.auth=f,e}{let{preview:e,response:t,data:n}=await va(m);try{let e=await ma([n],{service:o});return e.auth=f,e}catch{throw new ur(e,t)}}}static async connect({http:e,onProgress:t,corsProxy:n,service:r,url:i,auth:a,body:o,headers:s,signal:c}){let l=sa(i);l&&(i=l.url),n&&(i=ga(n,i)),s[`content-type`]=`application/x-${r}-request`,s.accept=`application/x-${r}-result`,_a(s,a);let u=await e.request({onProgress:t,method:`POST`,url:`${i}/${r}`,body:o,headers:s,signal:c});if(u.statusCode!==200){let{response:e}=va(u);throw new $n(u.statusCode,u.statusMessage,e)}return u}},ba=class{static getRemoteHelperFor({url:e}){let t=new Map;t.set(`http`,ya),t.set(`https`,ya);let n=Sa({url:e});if(!n)throw new fr(e);if(t.has(n.transport))return t.get(n.transport);throw new dr(e,n.transport,n.transport===`ssh`?na(e):void 0)}},xa=/^[^/@:]+@[^/@:]+:/;function Sa({url:e}){if(xa.test(e))return{transport:`ssh`,address:e};let t=e.match(/(\w+)(:\/\/|::)(.*)/);if(t!==null){if(t[2]===`://`)return{transport:t[1],address:t[0]};if(t[2]===`::`)return{transport:t[1],address:t[3]}}}var Ca=class{static async read({fs:e,gitdir:t}){let n=Y(t,`shallow`),r=new Set;return await ft(n,async function(){let t=await e.read(n,{encoding:`utf8`});if(t===null||t.trim()===``)return r;t.trim().split(`
48
+ `)+28);return br(t+`
49
+ `+n)}isolateSignature(){return Er(this._commit.slice(this._commit.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._commit.indexOf(`-----END PGP SIGNATURE-----`)+27))}static async sign(t,n,r){let i=t.withoutSignature(),a=e.justMessage(t._commit),{signature:o}=await n({payload:i,secretKey:r});o=br(o);let s=e.justHeaders(t._commit)+`
50
+ gpgsig`+Tr(o)+`
51
+ `+a;return e.from(s)}};async function Or({fs:e,cache:t,gitdir:n,oid:r}){if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`)return{tree:fn.from([]),oid:r};let{type:i,object:a}=await Bn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=wr.from(a).parse().object,Or({fs:e,cache:t,gitdir:n,oid:r});if(i===`commit`)return r=Dr.from(a).parse().tree,Or({fs:e,cache:t,gitdir:n,oid:r});if(i!==`tree`)throw new Tt(r,i,`tree`);return{tree:fn.from(a),oid:r}}var kr=class{constructor({fs:e,gitdir:t,ref:n,cache:r}){this.fs=e,this.cache=r,this.gitdir=t,this.mapPromise=(async()=>{let r=new Map,i;try{i=await X.resolve({fs:e,gitdir:t,ref:n})}catch(r){if(r instanceof J&&await X.isUnbornBranch({fs:e,gitdir:t,ref:n}))i=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`;else throw r}let a=await Or({fs:e,cache:this.cache,gitdir:t,oid:i});return a.type=`tree`,a.mode=`40000`,r.set(`.`,a),r})();let i=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return i.type(this)}async mode(){return i.mode(this)}async stat(){return i.stat(this)}async content(){return i.content(this)}async oid(){return i.oid(this)}}}async readdir(e){let t=e._fullpath,{fs:n,cache:r,gitdir:i}=this,a=await this.mapPromise,o=a.get(t);if(!o)throw Error(`No obj for ${t}`);let s=o.oid;if(!s)throw Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!==`tree`)return null;let{type:c,object:l}=await Bn({fs:n,cache:r,gitdir:i,oid:s});if(c!==o.type)throw new Tt(s,c,o.type);let u=fn.from(l);for(let e of u)a.set(Y(t,e.path),e);return u.entries().map(e=>Y(t,e.path))}async type(e){if(e._type===!1){let{type:t}=(await this.mapPromise).get(e._fullpath);e._type=t}return e._type}async mode(e){if(e._mode===!1){let{mode:t}=(await this.mapPromise).get(e._fullpath);e._mode=Xe(parseInt(t,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let t=await this.mapPromise,{fs:n,cache:r,gitdir:i}=this,a=t.get(e._fullpath).oid,{type:o,object:s}=await Bn({fs:n,cache:r,gitdir:i,oid:a});e._content=o===`blob`?new Uint8Array(s):void 0}return e._content}async oid(e){return e._oid===!1&&(e._oid=(await this.mapPromise).get(e._fullpath).oid),e._oid}};function Ar({ref:e=`HEAD`}={}){let t=Object.create(null);return Object.defineProperty(t,Ct,{value:function({fs:t,gitdir:n,cache:r}){return new kr({fs:t,gitdir:n,ref:e,cache:r})}}),Object.freeze(t),t}var jr=class{constructor({fs:e,dir:t,gitdir:n,cache:r,refresh:i=!0}){this.fs=e,this.cache=r,this.dir=t,this.gitdir=n,this.refresh=i,this.refreshQueue=[],this.flushed=!1,this.config=null;let a=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(e){if(await e.type()!==`tree`)return null;let t=e._fullpath,{fs:n,dir:r}=this,i=await n.readdir(Y(r,t));return i===null?null:i.map(e=>Y(t,e))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let{fs:t,dir:n}=this,r=await t.lstat(`${n}/${e._fullpath}`);if(!r)throw Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let i=r.isDirectory()?`tree`:`blob`;i===`blob`&&!r.isFile()&&!r.isSymbolicLink()&&(i=`special`),e._type=i,r=$e(r),e._mode=r.mode,r.size===-1&&e._actualSize&&(r.size=e._actualSize),e._stat=r}return e._stat}async content(e){if(e._content===!1){let{fs:t,dir:n,gitdir:r}=this;if(await e.type()===`tree`)e._content=void 0;else{let i;if(await e.mode()>>12==10)i=await t.readlink(`${n}/${e._fullpath}`);else{let a=await(await this._getGitConfig(t,r)).get(`core.autocrlf`);i=await t.read(`${n}/${e._fullpath}`,{autocrlf:a})}e._actualSize=i.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(i)}}return e._content}async oid(e){if(e._oid===!1){let t=this,{fs:n,gitdir:r,cache:i}=this,a;await _t.acquire({fs:n,gitdir:r,cache:i},async function(i){let o=i.entriesMap.get(e._fullpath),s=await e.stat(),c=await(await t._getGitConfig(n,r)).get(`core.filemode`),l=typeof process<`u`?process.platform!==`win32`:!0;if(!o||lt(s,o,c,l)){let n=await e.content();n===void 0?a=void 0:(a=await nt(pn.wrap({type:`blob`,object:n})),t.refresh&&o&&a===o.oid&&(!c||s.mode===o.mode)&&lt(s,o,c,l)&&(t.flushed?i.insert({filepath:e._fullpath,stats:s,oid:a}):t.refreshQueue.push({filepath:e._fullpath,stage:o,stats:s,oid:a})))}else a=o.oid}),e._oid=a}return e._oid}async flush(){let{fs:e,gitdir:t,cache:n,refreshQueue:r}=this;this.refreshQueue=[],this.flushed=!0,r.length!==0&&await _t.acquire({fs:e,gitdir:t,cache:n},async e=>{for(let{filepath:t,stage:n,stats:i,oid:a}of r)e.entriesMap.get(t)===n&&e.insert({filepath:t,stats:i,oid:a})})}async _getGitConfig(e,t){return this.config||=await tn.get({fs:e,gitdir:t}),this.config}};function Mr({refresh:e=!0}={}){let t=Object.create(null);return Object.defineProperty(t,Ct,{value:function({fs:t,dir:n,gitdir:r,cache:i}){return new jr({fs:t,dir:n,gitdir:r,cache:i,refresh:e})}}),Object.freeze(t),t}function Nr(e,t){let n=t-e;return Array.from({length:n},(t,n)=>e+n)}var Pr=Array.prototype.flat===void 0?e=>e.reduce((e,t)=>e.concat(t),[]):e=>e.flat(),Fr=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null||e<this.value)&&(this.value=e)}reset(){this.value=null}};function*Ir(e){let t=new Fr,n,r=[],i=e.length;for(let n=0;n<i;n++)r[n]=e[n].next().value,r[n]!==void 0&&t.consider(r[n]);if(t.value!==null)for(;;){let a=[];n=t.value,t.reset();for(let o=0;o<i;o++)r[o]!==void 0&&r[o]===n?(a[o]=r[o],r[o]=e[o].next().value):a[o]=null,r[o]!==void 0&&t.consider(r[o]);if(yield a,t.value===null)return}}async function Lr({fs:e,cache:t,dir:n,gitdir:r,trees:i,map:a=async(e,t)=>t,reduce:o=async(e,t)=>{let n=Pr(t);return e!==void 0&&n.unshift(e),n},iterate:s=(e,t)=>Promise.all([...t].map(e))}){let c=i.map(i=>i[Ct]({fs:e,dir:n,gitdir:r,cache:t})),l=Array(c.length).fill(`.`),u=Nr(0,c.length),d=async e=>(u.forEach(t=>{let n=e[t];e[t]=n&&new c[t].ConstructEntry(n)}),{entries:e,children:Ir((await Promise.all(u.map(t=>{let n=e[t];return n?c[t].readdir(n):[]}))).map(e=>(e===null?[]:e)[Symbol.iterator]()))}),f=async e=>{let{entries:t,children:n}=await d(e),r=t.find(e=>e&&e._fullpath)._fullpath,i=await a(r,t);if(i!==null){let e=await s(f,n);return e=e.filter(e=>e!==void 0),o(i,e)}},p=await f(l);for(let e of c)e.flush&&await e.flush();return p}async function Rr(e,t,n=10){try{await e(t)}catch(r){if(r===null||r.code===`EEXIST`)return;if(r.code!==`ENOENT`)throw r;let i=yt(t);if(i===`.`||i===`/`||i===t)throw r;await Rr(e,i,n);for(let r=0;;r++)try{await e(t);return}catch(e){if(e===null||e.code===`EEXIST`)return;if(e.code===`ENOENT`&&r<n){await new Promise(e=>setTimeout(e,0));continue}throw e}}}async function zr(e,t){let n=await e.readdir(t);n==null?await e.rm(t):n.length?await Promise.all(n.map(n=>{let r=Y(t,n);return e.lstat(r).then(t=>{if(t)return t.isDirectory()?zr(e,r):e.rm(r)})})).then(()=>e.rmdir(t)):await e.rmdir(t)}function Br(e){return Vr(e)&&Hr(e.then)&&Hr(e.catch)}function Vr(e){return e&&typeof e==`object`}function Hr(e){return typeof e==`function`}function Ur(e){let t=e.code;return typeof t==`string`?t===`ENOENT`||t===`ENOTDIR`||t.includes(`ENS`):!1}function Wr(e){return Br((e=>{try{return e.readFile().catch(e=>e)}catch(e){return e}})(e))}var Gr=[`readFile`,`writeFile`,`mkdir`,`rmdir`,`unlink`,`stat`,`lstat`,`readdir`,`readlink`,`symlink`];function Kr(e,t){if(Wr(t))for(let n of Gr)e[`_${n}`]=t[n].bind(t);else for(let n of Gr)e[`_${n}`]=(0,Be.default)(t[n].bind(t));Wr(t)?(t.cp&&(e._cp=t.cp.bind(t)),e._rm=t.rm?t.rm.bind(t):t.rmdir.length>1?t.rmdir.bind(t):zr.bind(null,e)):(t.cp&&(e._cp=(0,Be.default)(t.cp.bind(t))),e._rm=t.rm?(0,Be.default)(t.rm.bind(t)):t.rmdir.length>2?(0,Be.default)(t.rmdir.bind(t)):zr.bind(null,e))}var Z=class{constructor(e){if(e._original_unwrapped_fs!==void 0)return e;let t=Object.getOwnPropertyDescriptor(e,`promises`);t&&t.enumerable?Kr(this,e.promises):Kr(this,e),this._original_unwrapped_fs=e}async exists(e,t={}){try{return await this._stat(e),!0}catch(e){if(Ur(e))return!1;throw console.log(`Unhandled error in "FileSystem.exists()" function`,e),e}}async read(e,t={}){let n;try{n=await this._readFile(e,t)}catch(e){if(Ur(e)||e.code===`EISDIR`)return null;throw e}if(n==null)return null;if(t.autocrlf===`true`)try{n=new TextDecoder(`utf8`,{fatal:!0}).decode(n),n=n.replace(/\r\n/g,`
52
+ `),n=new TextEncoder().encode(n)}catch{}return typeof n!=`string`&&(n=Buffer.from(n)),n}async write(e,t,n={}){try{await this._writeFile(e,t,n)}catch{await this.mkdir(yt(e)),await this._writeFile(e,t,n)}}async mkdir(e){await Rr(this._mkdir,e)}async rm(e){try{await this._unlink(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async rmdir(e,t){try{t&&t.recursive?await this._rm(e,t):await this._rmdir(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async readdir(e){let t;try{t=await this._readdir(e)}catch(e){if(e.code===`ENOTDIR`)return null;if(Ur(e))return[];throw e}return t.sort(Je),t}async readdirDeep(e){let t=await this._readdir(e);return(await Promise.all(t.map(async t=>{let n=e+`/`+t;return(await this._stat(n)).isDirectory()?this.readdirDeep(n):n}))).reduce((e,t)=>e.concat(t),[])}async lstat(e){try{return await this._lstat(e)}catch(e){if(Ur(e))return null;throw e}}async readlink(e,t={encoding:`buffer`}){try{let n=await this._readlink(e,t);return Buffer.isBuffer(n)?n:Buffer.from(n)}catch(e){if(Ur(e))return null;throw e}}async writelink(e,t){return this._symlink(t.toString(`utf8`),e)}};function Q(e,t){if(t===void 0)throw new ir(e)}function qr(e){return e.startsWith(`/`)||/^[a-zA-Z]:[\\/]/.test(e)}async function $({fsp:e,dotgit:t}){Q(`fsp`,e),Q(`dotgit`,t);let n=await e._stat(t).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return n.isDirectory()?t:n.isFile()?e._readFile(t,`utf8`).then(e=>e.trimRight().substr(8)).then(e=>qr(e)?e:Y(yt(t),e)):t}async function Jr(e,t){return!e&&!t?!1:e&&!t||!e&&t?!0:!(await e.type()===`tree`&&await t.type()===`tree`||await e.type()===await t.type()&&await e.mode()===await t.mode()&&await e.oid()===await t.oid())}async function Yr({fs:e,dir:t,gitdir:n=Y(t,`.git`),commit:r=`HEAD`,cache:i={}}){try{Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n);let a=new Z(e),o=[Ar({ref:r}),Mr(),wt()],s=[],c=await $({fsp:a,dotgit:n});await _t.acquire({fs:a,gitdir:c,cache:i},async function(e){s=e.unmergedPaths});let l=await Lr({fs:a,cache:i,dir:t,gitdir:c,trees:o,map:async function(e,[t,n,r]){let i=!await Jr(n,r),a=s.includes(e),o=!await Jr(r,t);if(i||a)return t?{path:e,mode:await t.mode(),oid:await t.oid(),type:await t.type(),content:await t.content()}:void 0;if(o)return!1;throw new pr(e)}});await _t.acquire({fs:a,gitdir:c,cache:i},async function(e){for(let n of l)if(n!==!1){if(!n)await a.rmdir(`${t}/${n.path}`,{recursive:!0}),e.delete({filepath:n.path});else if(n.type===`blob`){let r=new TextDecoder().decode(n.content);await a.write(`${t}/${n.path}`,r,{mode:n.mode}),e.insert({filepath:n.path,oid:n.oid,stage:0})}}})}catch(e){throw e.caller=`git.abortMerge`,e}}var Xr=class{static async isIgnored({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r}){if(vt(r)===`.git`)return!0;if(r===`.`)return!1;let i=``,a=Y(n,`info`,`exclude`);await e.exists(a)&&(i=await e.read(a,`utf8`));let o=[{gitignore:Y(t,`.gitignore`),filepath:r}],s=r.split(`/`).filter(Boolean);for(let e=1;e<s.length;e++){let n=s.slice(0,e).join(`/`),r=s.slice(e).join(`/`);o.push({gitignore:Y(t,n,`.gitignore`),filepath:r})}let c=!1;for(let[t,n]of o.entries()){let r=await e.read(n.gitignore,`utf8`),a=(0,Ve.default)();t===0&&a.add(i),a.add(r);let o=yt(n.filepath);if(o!==`.`&&a.ignores(o))return!0;c=c?!a.test(n.filepath).unignored:a.test(n.filepath).ignored}return c}};async function Zr({fs:e,gitdir:t,object:n,format:r,oid:i}){if(r!==`deflated`)throw new q(`GitObjectStoreLoose expects objects to write to be in deflated format`);let a=`${t}/${`objects/${i.slice(0,2)}/${i.slice(2)}`}`;await e.exists(a)||await e.write(a,n)}var Qr=null;async function $r(e){return Qr===null&&(Qr=ti()),Qr?ei(e):ze.default.deflate(e)}async function ei(e){let t=new CompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function ti(){try{return new CompressionStream(`deflate`).writable.close(),new Blob([]).stream().cancel(),!0}catch{return!1}}async function ni({fs:e,gitdir:t,type:n,object:r,format:i=`content`,oid:a=void 0,dryRun:o=!1}){return i!==`deflated`&&(i!==`wrapped`&&(r=pn.wrap({type:n,object:r})),a=await nt(r),r=Buffer.from(await $r(r))),o||await Zr({fs:e,gitdir:t,object:r,format:`deflated`,oid:a}),a}function ri(e){let t;for(;~(t=e.indexOf(92));)e[t]=47;return e}async function ii({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,cache:i={},force:a=!1,parallel:o=!0}){try{Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n),Q(`filepath`,r);let s=new Z(e),c=await $({fsp:s,dotgit:n});await _t.acquire({fs:s,gitdir:c,cache:i},async e=>{let n=await(await tn.get({fs:s,gitdir:c})).get(`core.autocrlf`);return oi({dir:t,gitdir:c,fs:s,filepath:r,index:e,force:a,parallel:o,autocrlf:n})})}catch(e){throw e.caller=`git.add`,e}}function ai(e,t){if(e.has({filepath:t}))return!0;let n=`${t}/`;for(let t of e.entriesMap.keys())if(t.startsWith(n))return!0;return!1}async function oi({dir:e,gitdir:t,fs:n,filepath:r,index:i,force:a,parallel:o,autocrlf:s}){r=Array.isArray(r)?r:[r];let c=r.map(async r=>{if(!a&&!ai(i,r)&&await Xr.isIgnored({fs:n,dir:e,gitdir:t,filepath:r}))return;let c=await n.lstat(Y(e,r));if(!c)throw new J(r);if(c.isDirectory()){let c=await n.readdir(Y(e,r));if(o){let l=c.map(c=>oi({dir:e,gitdir:t,fs:n,filepath:[Y(r,c)],index:i,force:a,parallel:o,autocrlf:s}));await Promise.all(l)}else for(let l of c)await oi({dir:e,gitdir:t,fs:n,filepath:[Y(r,l)],index:i,force:a,parallel:o,autocrlf:s})}else{let a=c.isSymbolicLink()?await n.readlink(Y(e,r)).then(ri):await n.read(Y(e,r),{autocrlf:s});if(a===null)throw new J(r);let o=await ni({fs:n,gitdir:t,type:`blob`,object:a});i.insert({filepath:r,stats:c,oid:o})}}),l=await Promise.allSettled(c),u=l.filter(e=>e.status===`rejected`).map(e=>e.reason);if(u.length>1)throw new ar(u);if(u.length===1)throw u[0];return l.filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}async function si({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`;return e.exists(`${t}/${r}`)}async function ci({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=await e.readdir(Y(n,`objects/pack`));a=a.filter(e=>e.endsWith(`.idx`));for(let o of a){let a=await Fn({fs:e,cache:t,filename:`${n}/objects/pack/${o}`,getExternalRefDelta:i});if(a.error)throw new q(a.error);if(a.offsets.has(r))return!0}return!1}async function li({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>Bn({fs:e,cache:t,gitdir:n,oid:r}),o=await si({fs:e,gitdir:n,oid:r});return o||=await ci({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),o}async function ui({fs:e,gitdir:t,path:n}){return(await tn.get({fs:e,gitdir:t})).get(n)}function di(e,...t){for(let n of t)if(n)for(let t of Object.keys(n)){let r=n[t];r!==void 0&&(e[t]=r)}return e}async function fi({fs:e,gitdir:t,author:n,commit:r}){let i=Math.floor(Date.now()/1e3),a=di({},{name:await ui({fs:e,gitdir:t,path:`user.name`}),email:await ui({fs:e,gitdir:t,path:`user.email`})||``,timestamp:i,timezoneOffset:new Date(i*1e3).getTimezoneOffset()},r?r.author:void 0,n);if(a.name!==void 0)return a}async function pi({fs:e,gitdir:t,author:n,committer:r,commit:i}){let a=Math.floor(Date.now()/1e3),o=di({},{name:await ui({fs:e,gitdir:t,path:`user.name`}),email:await ui({fs:e,gitdir:t,path:`user.email`})||``,timestamp:a,timezoneOffset:new Date(a*1e3).getTimezoneOffset()},i?i.committer:void 0,n,r);if(o.name!==void 0)return o}async function mi({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Bn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=wr.from(a).parse().object,mi({fs:e,cache:t,gitdir:n,oid:r});if(i!==`commit`)throw new Tt(r,i,`commit`);return{commit:Dr.from(a),oid:r}}async function hi({fs:e,cache:t,gitdir:n,oid:r}){let{commit:i,oid:a}=await mi({fs:e,cache:t,gitdir:n,oid:r});return{oid:a,commit:i.parse(),payload:i.withoutSignature()}}var gi=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`;async function _i({fs:e,cache:t,onSign:n,gitdir:r,message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,disallowEmpty:d=!1,ref:f,parent:p,tree:m}){let h=!1,g=!1;f||=(g=!(await e.read(`${r}/HEAD`,{encoding:`utf8`})).startsWith(`ref:`),await X.resolve({fs:e,gitdir:r,ref:`HEAD`,depth:2}));let _,v;try{_=await X.resolve({fs:e,gitdir:r,ref:f})}catch(e){if(!(e instanceof J))throw e;h=!0}if(!h&&(c||d)&&(v=await hi({fs:e,gitdir:r,oid:_,cache:t})),c&&h)throw new mr(f);let y=c?await fi({fs:e,gitdir:r,author:a,commit:v.commit}):await fi({fs:e,gitdir:r,author:a});if(!y)throw new rr(`author`);let b=c?await pi({fs:e,gitdir:r,author:y,committer:o,commit:v.commit}):await pi({fs:e,gitdir:r,author:y,committer:o});if(!b)throw new rr(`committer`);return _t.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async function(a){let o=bt(a.entries).get(`.`);if(m||=await vi({fs:e,gitdir:r,inode:o,dryRun:l}),p=p?await Promise.all(p.map(async n=>{let i=await X.resolve({fs:e,gitdir:r,ref:n});for(;await li({fs:e,cache:t,gitdir:r,oid:i});){let{type:n,object:a}=await Bn({fs:e,cache:t,gitdir:r,oid:i});if(n===`commit`)break;if(n!==`tag`)throw new Tt(i,n,`commit`);i=wr.from(a).parse().object}return i})):c?v.commit.parent:_?[_]:[],d&&!c&&(h&&m===gi||!h&&m===v.commit.tree))throw new Jn;if(!i){if(c)i=v.commit.message;else throw new ir(`message`)}let x=Dr.from({tree:m,parent:p,author:y,committer:b,message:i});s&&(x=await Dr.sign(x,n,s));let S=await ni({fs:e,gitdir:r,type:`commit`,object:x.toObject(),dryRun:l});return!u&&!l&&await X.writeRef({fs:e,gitdir:r,ref:g?`HEAD`:f,value:S}),S})}async function vi({fs:e,gitdir:t,inode:n,dryRun:r}){let i=n.children;for(let n of i)n.type===`tree`&&(n.metadata.mode=`040000`,n.metadata.oid=await vi({fs:e,gitdir:t,inode:n,dryRun:r}));let a=i.map(e=>({mode:e.metadata.mode,path:e.basename,oid:e.metadata.oid,type:e.type}));return await ni({fs:e,gitdir:t,type:`tree`,object:fn.from(a).toObject(),dryRun:r})}async function yi({fs:e,cache:t,gitdir:n,oid:r,filepath:i}){return(await bi({fs:e,cache:t,gitdir:n,oid:r,filepath:i})).oid}async function bi({fs:e,cache:t,gitdir:n,oid:r,filepath:i}){if(i.startsWith(`/`))throw new $n(`leading-slash`);if(i.endsWith(`/`))throw new $n(`trailing-slash`);let a=r,o=await Or({fs:e,cache:t,gitdir:n,oid:r}),s=o.tree;return i===``?{mode:`040000`,oid:o.oid,path:``,type:`tree`}:xi({fs:e,cache:t,gitdir:n,tree:s,pathArray:i.split(`/`),oid:a,filepath:i})}async function xi({fs:e,cache:t,gitdir:n,tree:r,pathArray:i,oid:a,filepath:o}){let s=i.shift();for(let c of r)if(c.path===s){if(i.length===0)return c;{let{type:s,object:l}=await Bn({fs:e,cache:t,gitdir:n,oid:c.oid});if(s!==`tree`)throw new Tt(a,s,`tree`,o);return r=fn.from(l),xi({fs:e,cache:t,gitdir:n,tree:r,pathArray:i,oid:a,filepath:o})}}throw new J(`file or directory found at "${a}:${o}"`)}async function Si({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){i!==void 0&&(r=await yi({fs:e,cache:t,gitdir:n,oid:r,filepath:i}));let{tree:a,oid:o}=await Or({fs:e,cache:t,gitdir:n,oid:r});return{oid:o,tree:a.entries()}}async function Ci({fs:e,gitdir:t,tree:n}){return await ni({fs:e,gitdir:t,type:`tree`,object:fn.from(n).toObject(),format:`content`})}async function wi({fs:e,cache:t,onSign:n,gitdir:r,ref:i,oid:a,note:o,force:s,author:c,committer:l,signingKey:u}){let d;try{d=await X.resolve({gitdir:r,fs:e,ref:i})}catch(e){if(!(e instanceof J))throw e}let f=(await Si({fs:e,cache:t,gitdir:r,oid:d||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;if(s)f=f.filter(e=>e.path!==a);else for(let e of f)if(e.path===a)throw new Vn(`note`,a);typeof o==`string`&&(o=Buffer.from(o,`utf8`));let p=await ni({fs:e,gitdir:r,type:`blob`,object:o,format:`content`});return f.push({mode:`100644`,path:a,oid:p,type:`blob`}),await _i({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:await Ci({fs:e,gitdir:r,tree:f}),parent:d&&[d],message:`Note added by 'isomorphic-git addNote'
53
+ `,author:c,committer:l,signingKey:u})}async function Ti({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ref:i=`refs/notes/commits`,oid:a,note:o,force:s,author:c,committer:l,signingKey:u,cache:d={}}){try{Q(`fs`,e),Q(`gitdir`,r),Q(`oid`,a),Q(`note`,o),u&&Q(`onSign`,t);let n=new Z(e),f=await fi({fs:n,gitdir:r,author:c});if(!f)throw new rr(`author`);let p=await pi({fs:n,gitdir:r,author:f,committer:l});if(!p)throw new rr(`committer`);return await wi({fs:n,cache:d,onSign:t,gitdir:await $({fsp:n,dotgit:r}),ref:i,oid:a,note:o,force:s,author:f,committer:p,signingKey:u})}catch(e){throw e.caller=`git.addNote`,e}}async function Ei({fs:e,gitdir:t,remote:n,url:r,force:i}){if(!Pt(n,!0))throw new Dt(n,Le.default.clean(n));let a=await tn.get({fs:e,gitdir:t});if(!i&&(await a.getSubsections(`remote`)).includes(n)&&r!==await a.get(`remote.${n}.url`))throw new Vn(`remote`,n);await a.set(`remote.${n}.url`,r),await a.set(`remote.${n}.fetch`,`+refs/heads/*:refs/remotes/${n}/*`),await tn.save({fs:e,gitdir:t,config:a})}async function Di({fs:e,dir:t,gitdir:n=Y(t,`.git`),remote:r,url:i,force:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`remote`,r),Q(`url`,i);let t=new Z(e);return await Ei({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r,url:i,force:a})}catch(e){throw e.caller=`git.addRemote`,e}}async function Oi({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tagger:a,message:o=i,gpgsig:s,object:c,signingKey:l,force:u=!1}){if(i=i.startsWith(`refs/tags/`)?i:`refs/tags/${i}`,!u&&await X.exists({fs:e,gitdir:r,ref:i}))throw new Vn(`tag`,i);let d=await X.resolve({fs:e,gitdir:r,ref:c||`HEAD`}),{type:f}=await Bn({fs:e,cache:t,gitdir:r,oid:d}),p=wr.from({object:d,type:f,tag:i.replace(`refs/tags/`,``),tagger:a,message:o,gpgsig:s});l&&(p=await wr.sign(p,n,l));let m=await ni({fs:e,gitdir:r,type:`tag`,object:p.toObject()});await X.writeRef({fs:e,gitdir:r,ref:i,value:m})}async function ki({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ref:i,tagger:a,message:o=i,gpgsig:s,object:c,signingKey:l,force:u=!1,cache:d={}}){try{Q(`fs`,e),Q(`gitdir`,r),Q(`ref`,i),l&&Q(`onSign`,t);let n=new Z(e),f=await $({fsp:n,dotgit:r}),p=await fi({fs:n,gitdir:f,author:a});if(!p)throw new rr(`tagger`);return await Oi({fs:n,cache:d,onSign:t,gitdir:f,ref:i,tagger:p,message:o,gpgsig:s,object:c,signingKey:l,force:u})}catch(e){throw e.caller=`git.annotatedTag`,e}}async function Ai({fs:e,gitdir:t,ref:n,object:r,checkout:i=!1,force:a=!1}){if(!Pt(n,!0))throw new Dt(n,Le.default.clean(n));let o=`refs/heads/${n}`;if(!a&&await X.exists({fs:e,gitdir:t,ref:o}))throw new Vn(`branch`,n,!1);let s;try{s=await X.resolve({fs:e,gitdir:t,ref:r||`HEAD`})}catch(e){if(!(e instanceof J))throw e}s&&(s=(await mi({fs:e,cache:{},gitdir:t,oid:s})).oid,await X.writeRef({fs:e,gitdir:t,ref:o,value:s})),i&&await X.writeSymbolicRef({fs:e,gitdir:t,ref:`HEAD`,value:o})}async function ji({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,object:i,checkout:a=!1,force:o=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e);return await Ai({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r,object:i,checkout:a,force:o})}catch(e){throw e.caller=`git.branch`,e}}async function Mi(e,t,n){let r=n.split(`/`);r.pop();let i=t;for(let t of r){if(t===``||t===`.`)continue;i=`${i}/${t}`;let r=await e.lstat(i);if(r&&r.isSymbolicLink())throw new We(n)}}var Ni=(e,t)=>{if(e===`.`||t==null||t.length===0||t===`.`)return!0;let n=t.endsWith(`/`)?t.slice(0,-1):t;return n===`.`?!0:n.length>=e.length?n===e||n.startsWith(`${e}/`):e.startsWith(`${n}/`)};async function Pi({fs:e,cache:t,onProgress:n,onPostCheckout:r,dir:i,gitdir:a,remote:o,ref:s,filepaths:c,noCheckout:l,noUpdateHead:u,dryRun:d,force:f,track:p=!0,restoreFromIndex:m=!1,nonBlocking:h=!1,batchSize:g=100}){let _;if(r)try{_=await X.resolve({fs:e,gitdir:a,ref:`HEAD`})}catch{_=`0000000000000000000000000000000000000000`}let v;try{v=await X.resolve({fs:e,gitdir:a,ref:s})}catch(t){if(s===`HEAD`||!(t instanceof J))throw t;let n=`${o}/${s}`;if(v=await X.resolve({fs:e,gitdir:a,ref:n}),p){let t=await tn.get({fs:e,gitdir:a});await t.set(`branch.${s}.remote`,o),await t.set(`branch.${s}.merge`,`refs/heads/${s}`),await tn.save({fs:e,gitdir:a,config:t})}await X.writeRef({fs:e,gitdir:a,ref:`refs/heads/${s}`,value:v})}if(!u)try{v=(await mi({fs:e,cache:t,gitdir:a,oid:v})).oid}catch(e){throw e instanceof J?new qn(s,e.data.what):e}if(!l){let o;try{o=await Fi({fs:e,cache:t,onProgress:n,dir:i,gitdir:a,ref:s,force:f,filepaths:c,restoreFromIndex:m})}catch(e){throw e instanceof J&&e.data.what===v?new qn(s,v):e}let l=o.filter(([e])=>e===`conflict`).map(([e,t])=>t);if(l.length>0)throw new Un(l);let u=o.filter(([e])=>e===`error`).map(([e,t])=>t);if(u.length>0)throw new q(u.join(`, `));if(d){r&&await r({previousHead:_,newHead:v,type:c!=null&&c.length>0?`file`:`branch`});return}let p=0,y=o.length;if(await _t.acquire({fs:e,gitdir:a,cache:t},async function(t){await Promise.all(o.filter(([e])=>e===`delete`||e===`delete-index`).map(async function([r,a]){let o=`${i}/${a}`;r===`delete`&&await e.rm(o),t.delete({filepath:a}),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})}))}),await _t.acquire({fs:e,gitdir:a,cache:t},async function(t){for(let[r,a]of o)if(r===`rmdir`||r===`rmdir-index`){let o=`${i}/${a}`;try{r===`rmdir`&&await e.rmdir(o),t.delete({filepath:a}),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})}catch(e){if(e.code===`ENOTEMPTY`)console.log(`Did not delete ${a} because directory is not empty`);else throw e}}}),await Promise.all(o.filter(([e])=>e===`mkdir`||e===`mkdir-index`).map(async function([t,r]){let a=`${i}/${r}`;await Mi(e,i,r),await e.mkdir(a),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})})),h){let r=await Ri(`Update Working Dir`,o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(([n,r,o,s,c])=>()=>Li({fs:e,cache:t,gitdir:a,dir:i},[n,r,o,s,c])),n,g);await _t.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(e){await Ri(`Update Index`,r.map(([t,n,r])=>()=>Ii({index:e,fullpath:t,oid:n,stats:r})),n,g)})}else await _t.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(r){let s=await Promise.allSettled(o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(async function([o,s,c,l,u]){let d=`${i}/${s}`;if(o!==`create-index`&&o!==`mkdir-index`){await Mi(e,i,s);let{object:n}=await Bn({fs:e,cache:t,gitdir:a,oid:c});if(u&&await e.rm(d),l===33188)await e.write(d,n);else if(l===33261)await e.write(d,n,{mode:511});else if(l===40960)await e.writelink(d,n);else throw new q(`Invalid mode 0o${l.toString(8)} detected in blob ${c}`)}let f=await e.lstat(d);l===33261&&(f.mode=493),o===`mkdir-index`&&(f.mode=57344),r.insert({filepath:s,stats:f,oid:c}),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})})),c=[];for(let e of s)e.status===`rejected`&&(c.push(e.reason),console.error(`[isomorphic-git checkout] task rejected:`,e.reason?.stack??e.reason));if(c.length>0)throw new ar(c)});r&&await r({previousHead:_,newHead:v,type:c!=null&&c.length>0?`file`:`branch`})}if(!u){let t=await X.expand({fs:e,gitdir:a,ref:s});t.startsWith(`refs/heads`)?await X.writeSymbolicRef({fs:e,gitdir:a,ref:`HEAD`,value:t}):await X.writeRef({fs:e,gitdir:a,ref:`HEAD`,value:v})}}async function Fi({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,ref:a,force:o,filepaths:s,restoreFromIndex:c}){let l=0;return Lr({fs:e,cache:t,dir:r,gitdir:i,trees:[c?wt():Ar({ref:a}),Mr(),wt()],map:async function(e,[t,r,i]){if(e!==`.`){if(s&&!s.some(t=>Ni(e,t)))return null;switch(n&&await n({phase:`Analyzing workdir`,loaded:++l}),[!!i,!!t,!!r].map(Number).join(``)){case`000`:return;case`001`:return!c&&o&&s&&s.includes(e)?[`delete`,e]:void 0;case`010`:switch(await t.type()){case`tree`:return[`mkdir`,e];case`blob`:return[`create`,e,await t.oid(),await t.mode()];case`commit`:return[`mkdir-index`,e,await t.oid(),await t.mode()];default:return[`error`,`new entry Unhandled type ${await t.type()}`]}case`011`:switch(`${await t.type()}-${await r.type()}`){case`tree-tree`:return;case`tree-blob`:case`blob-tree`:return[`conflict`,e];case`blob-blob`:return await t.oid()===await r.oid()?await t.mode()===await r.mode()?[`create-index`,e,await t.oid(),await t.mode()]:o?[`update`,e,await t.oid(),await t.mode(),!0]:[`conflict`,e]:o?[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await r.mode()]:[`conflict`,e];case`commit-tree`:return;case`commit-blob`:return[`conflict`,e];default:return[`error`,`new entry Unhandled type ${t.type}`]}case`100`:return[`delete-index`,e];case`101`:switch(await i.type()){case`tree`:return[`rmdir-index`,e];case`blob`:return await i.oid()===await r.oid()||o?[`delete`,e]:[`conflict`,e];case`commit`:return[`rmdir-index`,e];default:return[`error`,`delete entry Unhandled type ${await i.type()}`]}case`110`:case`111`:switch(`${await i.type()}-${await t.type()}`){case`tree-tree`:return;case`blob-blob`:if(await i.oid()===await t.oid()&&await i.mode()===await t.mode()&&!o)return;if(r){if(await r.oid()!==await i.oid()&&await r.oid()!==await t.oid())return o?[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await r.mode()]:[`conflict`,e]}else if(o)return[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await i.mode()];return await t.mode()===await i.mode()?await t.oid()===await i.oid()?void 0:[`update`,e,await t.oid(),await t.mode(),!1]:[`update`,e,await t.oid(),await t.mode(),!0];case`tree-blob`:return[`update-dir-to-blob`,e,await t.oid()];case`blob-tree`:return[`update-blob-to-tree`,e];case`commit-commit`:return[`mkdir-index`,e,await t.oid(),await t.mode()];default:return[`error`,`update entry Unhandled type ${await i.type()}-${await t.type()}`]}}}},reduce:async function(e,t){return t=Pr(t),e?e&&e[0]===`rmdir`?(t.push(e),t):(t.unshift(e),t):t}})}async function Ii({index:e,fullpath:t,stats:n,oid:r}){try{e.insert({filepath:t,stats:n,oid:r})}catch(e){console.warn(`Error inserting ${t} into index:`,e)}}async function Li({fs:e,cache:t,gitdir:n,dir:r},[i,a,o,s,c]){let l=`${r}/${a}`;if(i!==`create-index`&&i!==`mkdir-index`){await Mi(e,r,a);let{object:i}=await Bn({fs:e,cache:t,gitdir:n,oid:o});if(c&&await e.rm(l),s===33188)await e.write(l,i);else if(s===33261)await e.write(l,i,{mode:511});else if(s===40960)await e.writelink(l,i);else throw new q(`Invalid mode 0o${s.toString(8)} detected in blob ${o}`)}let u=await e.lstat(l);return s===33261&&(u.mode=493),i===`mkdir-index`&&(u.mode=57344),[a,o,u]}async function Ri(e,t,n,r){let i=[],a=[];for(let o=0;o<t.length;o+=r){let s=t.slice(o,o+r).map(e=>e());(await Promise.allSettled(s)).forEach(t=>{t.status===`fulfilled`?i.push(t.value):(a.push(t.reason),console.error(`[isomorphic-git ${e}] task rejected:`,t.reason?.stack??t.reason))}),n&&await n({phase:`Updating workdir`,loaded:o+s.length,total:t.length})}if(a.length>0)throw new ar(a);return i}async function zi({fs:e,onProgress:t,onPostCheckout:n,dir:r,gitdir:i=Y(r,`.git`),remote:a=`origin`,ref:o,filepaths:s,noCheckout:c=!1,noUpdateHead:l=o===void 0,dryRun:u=!1,force:d=!1,track:f=!0,cache:p={},nonBlocking:m=!1,batchSize:h=100}){try{Q(`fs`,e),Q(`dir`,r),Q(`gitdir`,i);let g=o||`HEAD`,_=o===void 0&&s!=null&&s.length>0,v=new Z(e);return await Pi({fs:v,cache:p,onProgress:t,onPostCheckout:n,dir:r,gitdir:await $({fsp:v,dotgit:i}),remote:a,ref:g,filepaths:s,noCheckout:c,noUpdateHead:l,dryRun:u,force:d,track:f,restoreFromIndex:_,nonBlocking:m,batchSize:h})}catch(e){throw e.caller=`git.checkout`,e}}var Bi=/^.*(\r?\n|$)/gm;function Vi({branches:e,contents:t}){let n=e[1],r=e[2],i=t[0],a=t[1],o=t[2],s=a.match(Bi),c=i.match(Bi),l=o.match(Bi),u=(0,He.default)(s,c,l),d=``,f=!0;for(let e of u)e.ok&&(d+=e.ok.join(``)),e.conflict&&(f=!1,d+=`${`<`.repeat(7)} ${n}\n`,d+=e.conflict.a.join(``),d+=`${`=`.repeat(7)}\n`,d+=e.conflict.b.join(``),d+=`${`>`.repeat(7)} ${r}\n`);return{cleanMerge:f,mergedText:d}}async function Hi({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),index:i,ourOid:a,baseOid:o,theirOid:s,ourName:c=`ours`,baseName:l=`base`,theirName:u=`theirs`,dryRun:d=!1,abortOnConflict:f=!0,mergeDriver:p}){let m=Ar({ref:a}),h=Ar({ref:o}),g=Ar({ref:s}),_=[],v=[],y=[],b=[],x=await Lr({fs:e,cache:t,dir:n,gitdir:r,trees:[m,h,g],map:async function(t,[n,a,o]){let s=vt(t);switch(`${await Jr(n,a)}-${await Jr(o,a)}`){case`false-false`:return{mode:await a.mode(),path:s,oid:await a.oid(),type:await a.type()};case`false-true`:return!o&&await n.type()===`tree`?{mode:await n.mode(),path:s,oid:await n.oid(),type:await n.type()}:o?{mode:await o.mode(),path:s,oid:await o.oid(),type:await o.type()}:void 0;case`true-false`:return!n&&await o.type()===`tree`?{mode:await o.mode(),path:s,oid:await o.oid(),type:await o.type()}:n?{mode:await n.mode(),path:s,oid:await n.oid(),type:await n.type()}:void 0;case`true-true`:if(n&&o&&await n.type()===`tree`&&await o.type()===`tree`)return{mode:await n.mode(),path:s,oid:await n.oid(),type:`tree`};if(n&&o&&await n.type()===`blob`&&await o.type()===`blob`)return Ui({fs:e,gitdir:r,path:s,ours:n,base:a,theirs:o,ourName:c,baseName:l,theirName:u,mergeDriver:p}).then(async e=>{if(e.cleanMerge)f||i.insert({filepath:t,oid:e.mergeResult.oid,stage:0});else if(_.push(t),v.push(t),!f){let e=``;a&&await a.type()===`blob`&&(e=await a.oid());let r=await n.oid(),s=await o.oid();i.delete({filepath:t}),e&&i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:r,stage:2}),i.insert({filepath:t,oid:s,stage:3})}return e.mergeResult});if(a&&!n&&o&&await a.type()===`blob`&&await o.type()===`blob`){if(_.push(t),y.push(t),!f){let e=await a.oid(),n=await o.oid();i.delete({filepath:t}),i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:n,stage:3})}return{mode:await o.mode(),oid:await o.oid(),type:`blob`,path:s}}if(a&&n&&!o&&await a.type()===`blob`&&await n.type()===`blob`){if(_.push(t),b.push(t),!f){let e=await a.oid(),r=await n.oid();i.delete({filepath:t}),i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:r,stage:2})}return{mode:await n.mode(),oid:await n.oid(),type:`blob`,path:s}}if(a&&!n&&!o&&(await a.type()===`blob`||await a.type()===`tree`))return;throw new tr}},reduce:_.length!==0&&(!n||f)?void 0:async(t,n)=>{let i=n.filter(Boolean);if(t&&!(t&&t.type===`tree`&&i.length===0&&t.path!==`.`))return(i.length>0||t.path===`.`&&i.length===0)&&(t.oid=await ni({fs:e,gitdir:r,type:`tree`,object:new fn(i).toObject(),dryRun:d})),t}});return _.length===0?x.oid:(n&&!f&&await Lr({fs:e,cache:t,dir:n,gitdir:r,trees:[Ar({ref:x.oid})],map:async function(t,[r]){let i=`${n}/${t}`;if(await r.type()===`blob`){let t=await r.mode(),n=await r.content();await e.write(i,n,{mode:t})}return!0}}),new nr(_,v,y,b))}async function Ui({fs:e,gitdir:t,path:n,ours:r,base:i,theirs:a,ourName:o,theirName:s,baseName:c,dryRun:l,mergeDriver:u=Vi}){let d=`blob`,f=`100755`,p=``,m=``;i&&await i.type()===`blob`&&(f=await i.mode(),p=await i.oid(),m=Buffer.from(await i.content()).toString(`utf8`));let h=f===await r.mode()?await a.mode():await r.mode();if(await r.oid()===await a.oid())return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await r.oid(),type:d}};if(await r.oid()===p)return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await a.oid(),type:d}};if(await a.oid()===p)return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await r.oid(),type:d}};let g=Buffer.from(await r.content()).toString(`utf8`),_=Buffer.from(await a.content()).toString(`utf8`),{mergedText:v,cleanMerge:y}=await u({branches:[c,o,s],contents:[m,g,_],path:n});return{cleanMerge:y,mergeResult:{mode:h,path:n,oid:await ni({fs:e,gitdir:t,type:`blob`,object:Buffer.from(v,`utf8`),dryRun:l}),type:d}}}var Wi={stage:wt,workdir:Mr};async function Gi(e,t,n,r,i=null){let a=Y(n,r),o=await e.lstat(a);if(!o)throw new J(a);if(o.isDirectory())throw new q(`${a}: file expected, but found directory`);let s=i?await mn({fs:e,gitdir:t,oid:i}):void 0,c=s?i:void 0;return s||await ft(a,async()=>{let n=o.isSymbolicLink()?await e.readlink(a).then(ri):await e.read(a);if(n===null)throw new J(a);c=await ni({fs:e,gitdir:t,type:`blob`,object:n})}),c}async function Ki({fs:e,dir:t,gitdir:n,entries:r}){async function i(r){return r.type===`tree`?r.oid||(r.oid=await Ci({fs:e,gitdir:n,tree:await Promise.all(r.children.map(i))}),r.mode=16384):r.type===`blob`&&(r.oid=await Gi(e,n,t,r.path,r.oid),r.mode=33188),r.path=r.path.split(`/`).pop(),r}return Promise.all(r.map(i))}async function qi({fs:e,dir:t,gitdir:n,treePair:r}){let i=r[1]===`stage`,a=r.map(e=>typeof e==`string`?Wi[e]():e),o=[],s=await Lr({fs:e,cache:{},dir:t,gitdir:n,trees:a,map:async(r,[i,a])=>{if(!(r===`.`||await Xr.isIgnored({fs:e,dir:t,gitdir:n,filepath:r}))&&a)return(!i||await i.oid()!==await a.oid()&&await a.oid()!==void 0)&&o.push([i,a]),{mode:await a.mode(),path:r,oid:await a.oid(),type:await a.type()}},reduce:async(e,t)=>(t=t.filter(Boolean),e?(e.children=t,e):t.length>0?t:void 0),iterate:async(n,r)=>{let a=[];for(let n of r){let[r,s]=n;i?s&&(await e.exists(`${t}/${s.toString()}`)?a.push(n):o.push([null,s])):r&&(s?a.push(n):o.push([r,null]))}return a.length?Promise.all(a.map(n)):[]}});return o.length===0||s.length===0?null:Ci({fs:e,gitdir:n,tree:(await Ki({fs:e,dir:t,gitdir:n,entries:s})).filter(Boolean).map(e=>({mode:e.mode,path:e.path,oid:e.oid,type:e.type}))})}async function Ji({fs:e,dir:t,gitdir:n,stashCommit:r,parentCommit:i,wasStaged:a}){let o=[],s=[],c=await Lr({fs:e,cache:{},dir:t,gitdir:n,trees:[Ar({ref:i}),Ar({ref:r})],map:async(r,[i,c])=>{if(r===`.`||await Xr.isIgnored({fs:e,dir:t,gitdir:n,filepath:r}))return;let l=c?await c.type():await i.type();if(l!==`tree`&&l!==`blob`)return;if(!c&&i){let e=l===`tree`?`rmdir`:`rm`;return l===`tree`&&o.push(r),l===`blob`&&a&&s.push({filepath:r,oid:await i.oid()}),{method:e,filepath:r}}let u=await c.oid();if(!i||await i.oid()!==u)return l===`tree`?{method:`mkdir`,filepath:r}:(a&&s.push({filepath:r,oid:u,stats:await e.lstat(Y(t,r))}),{method:`write`,filepath:r,oid:u})}});await ft(n,async()=>{for(let r of c){let i=Y(t,r.filepath);switch(r.method){case`rmdir`:await e.rmdir(i);break;case`mkdir`:await Mi(e,t,r.filepath),await e.mkdir(i);break;case`rm`:await e.rm(i);break;case`write`:if(!o.some(e=>i.startsWith(e))){await Mi(e,t,r.filepath);let{object:a}=await Bn({fs:e,cache:{},gitdir:n,oid:r.oid});await e.exists(i)&&await e.rm(i),await e.write(i,a)}}}}),await _t.acquire({fs:e,gitdir:n,cache:{}},async e=>{s.forEach(({filepath:t,stats:n,oid:r})=>{e.insert({filepath:t,stats:n,oid:r})})})}async function Yi({fs:e,cache:t,dir:n,gitdir:r,oid:i,dryRun:a=!1,noUpdateBranch:o=!1,abortOnConflict:s=!0,committer:c,mergeDriver:l}){let{commit:u,oid:d}=await hi({fs:e,cache:t,gitdir:r,oid:i});if(u.parent.length>1)throw new Gn(d,u.parent.length);if(u.parent.length===0)throw new Kn(d);let f=await X.resolve({fs:e,gitdir:r,ref:`HEAD`}),{commit:p}=await hi({fs:e,cache:t,gitdir:r,oid:f}),m=u.parent[0],{commit:h}=await hi({fs:e,cache:t,gitdir:r,oid:m});if(n&&(!a&&!o||!s)){let i=await Xi({fs:e,cache:t,dir:n,gitdir:r,headTree:p.tree,baseTree:h.tree,theirTree:u.tree,allTracked:!s});if(i.length>0)throw new Wn(i)}let g=await _t.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async i=>Hi({fs:e,cache:t,dir:n,gitdir:r,index:i,ourOid:p.tree,baseOid:h.tree,theirOid:u.tree,ourName:`HEAD`,baseName:`parent of ${d.slice(0,7)}`,theirName:d.slice(0,7),dryRun:a,abortOnConflict:s,mergeDriver:l}));if(g instanceof nr)throw g;let _=await _i({fs:e,cache:t,gitdir:r,message:u.message,tree:g,parent:[f],author:u.author,committer:c,dryRun:a,noUpdateBranch:o});return n&&!a&&!o&&await Ji({fs:e,dir:n,gitdir:r,stashCommit:_,parentCommit:f,wasStaged:!0}),_}async function Xi({fs:e,cache:t,dir:n,gitdir:r,headTree:i,baseTree:a,theirTree:o,allTracked:s}){let c=await Lr({fs:e,cache:t,dir:n,gitdir:r,trees:[Ar({ref:a}),Ar({ref:o})],map:async(e,[t,n])=>{if(e!==`.`){if(t&&n&&await t.oid()===await n.oid())return null;if([t?await t.type():void 0,n?await n.type():void 0].includes(`blob`))return e}}});return c.length===0&&!s?[]:Lr({fs:e,cache:t,dir:n,gitdir:r,trees:[Ar({ref:i}),wt(),Mr()],map:async(e,[t,n,r])=>{if(e===`.`)return;if(!s&&!c.some(t=>Ni(e,t)))return null;let i=t&&await t.type()===`blob`?await t.oid():void 0;if((c.includes(e)||s&&i)&&((n?await n.oid():void 0)!==i||r&&(!i||await r.type()!==`blob`||await r.oid()!==i)))return e}})}async function Zi({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={},committer:a,dryRun:o=!1,noUpdateBranch:s=!1,abortOnConflict:c=!0,mergeDriver:l}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let u=new Z(e),d=await $({fsp:u,dotgit:n}),{commit:f}=await hi({fs:u,cache:i,gitdir:d,oid:r});if(f.parent&&f.parent.length>1)return await Yi({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:void 0,mergeDriver:l});let p=await pi({fs:u,gitdir:d,committer:a});if(!p)throw new rr(`committer`);return await Yi({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:p,mergeDriver:l})}catch(e){throw e.caller=`git.cherryPick`,e}}var Qi=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function $i(e){let t=Qi.exec(e);return t?t[1]===`remotes/`&&e.endsWith(`/HEAD`)?t[2].slice(0,-5):t[2]:e}async function ea({fs:e,gitdir:t,fullname:n=!1,test:r=!1}){let i=await X.resolve({fs:e,gitdir:t,ref:`HEAD`,depth:2});if(r)try{await X.resolve({fs:e,gitdir:t,ref:i})}catch(e){if(e instanceof J)return;throw e}if(i.startsWith(`refs/`))return n?i:$i(i)}function ta(e){return e=e.replace(/^[^/@:]+@([^/@:]+):/,`https://$1/`),e=e.replace(/^ssh:\/\//,`https://`),e}function na({username:e=``,password:t=``}){return`Basic ${Buffer.from(`${e}:${t}`).toString(`base64`)}`}async function ra(e,t){let n=bn(e);for(;;){let{value:e,done:r}=await n.next();if(e&&await t(e),r)break}n.return&&n.return()}async function ia(e){let t=0,n=[];await ra(e,e=>{n.push(e),t+=e.byteLength});let r=new Uint8Array(t),i=0;for(let e of n)r.set(e,i),i+=e.byteLength;return r}var aa=/^(https?:\/\/)([^/?#]+)@/i;function oa(e){let t=e.match(aa);return t==null?{url:e,auth:{}}:{url:e.replace(aa,`$1`),auth:sa(e,t[2])}}function sa(e,t){let n=ca(e),r=t.indexOf(`:`)!==-1;if(n!==null)return{username:la(n.username),password:r?la(n.password):void 0};let i=t.indexOf(`:`);return{username:r?t.slice(0,i):t,password:r?t.slice(i+1):void 0}}function ca(e){if(typeof URL!=`function`)return null;try{return new URL(e)}catch{return null}}function la(e){try{return decodeURIComponent(e)}catch{return e}}function ua(e,t){let n=t.toString(16);return`0`.repeat(e-n.length)+n}var da=class{static flush(){return Buffer.from(`0000`,`utf8`)}static delim(){return Buffer.from(`0001`,`utf8`)}static encode(e){typeof e==`string`&&(e=Buffer.from(e));let t=ua(4,e.length+4);return Buffer.concat([Buffer.from(t,`utf8`),e])}static streamReader(e){let t=new xn(e);return async function(){try{let e=await t.read(4);return e==null||(e=parseInt(e.toString(`utf8`),16),e===0||e===1?null:await t.read(e-4)??!0)}catch(t){return e.error=t,!0}}}};async function fa(e){let t={},n;for(;n=await e(),n!==!0;){if(n===null)continue;n=n.toString(`utf8`).replace(/\n$/,``);let e=n.indexOf(`=`);if(e>-1){let r=n.slice(0,e);t[r]=n.slice(e+1)}else t[n]=!0}return{protocolVersion:2,capabilities2:t}}async function pa(e,{service:t}){let n=new Set,r=new Map,i=new Map,a=da.streamReader(e),o=await a();for(;o===null;)o=await a();if(o===!0)throw new Yn;if(o.includes(`version 2`))return fa(a);if(o.toString(`utf8`).replace(/\n$/,``)!==`# service=${t}`)throw new or(`# service=${t}\\n`,o.toString(`utf8`));let s=await a();for(;s===null;)s=await a();if(s===!0)return{capabilities:n,refs:r,symrefs:i};if(s=s.toString(`utf8`),s.includes(`version 2`))return fa(a);let[c,l]=ma(s,`\0`,`\\x00`);if(l.split(` `).map(e=>n.add(e)),c!==`0000000000000000000000000000000000000000 capabilities^{}`){let[e,t]=ma(c,` `,` `);for(r.set(t,e);;){let e=await a();if(e===!0)break;if(e!==null){let[t,n]=ma(e.toString(`utf8`),` `,` `);r.set(n,t)}}}for(let e of n)if(e.startsWith(`symref=`)){let t=e.match(/symref=([^:]+):(.*)/);t.length===3&&i.set(t[1],t[2])}return{protocolVersion:1,capabilities:n,refs:r,symrefs:i}}function ma(e,t,n){let r=e.trim().split(t);if(r.length!==2)throw new or(`Two strings separated by '${n}'`,e.toString(`utf8`));return r}var ha=(e,t)=>e.endsWith(`?`)?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,``)}`,ga=(e,t)=>{(t.username||t.password)&&(e.Authorization=na(t)),t.headers&&Object.assign(e,t.headers)},_a=async e=>{try{let t=Buffer.from(await ia(e.body)),n=t.toString(`utf8`);return{preview:n.length<256?n:n.slice(0,256)+`...`,response:n,data:t}}catch{return{}}},va=class{static async capabilities(){return[`discover`,`connect`]}static async discover({http:e,onProgress:t,onAuth:n,onAuthSuccess:r,onAuthFailure:i,corsProxy:a,service:o,url:s,headers:c,signal:l,protocolVersion:u}){let{url:d,auth:f}=oa(s),p=a?ha(a,d):d;(f.username||f.password)&&(c.Authorization=na(f)),u===2&&(c[`Git-Protocol`]=`version=2`);let m,h,g=!1;do if(m=await e.request({onProgress:t,method:`GET`,url:`${p}/info/refs?service=${o}`,headers:c,signal:l}),h=!1,m.statusCode===401||m.statusCode===203){let e=g?i:n;if(e){if(f=await e(d,{...f,headers:{...c}}),f&&f.cancel)throw new fr;f&&(ga(c,f),g=!0,h=!0)}}else m.statusCode===200&&g&&r&&await r(d,f);while(h);if(m.statusCode!==200){let{response:e}=await _a(m);throw new Qn(m.statusCode,m.statusMessage,e)}if(m.headers[`content-type`]===`application/x-${o}-advertisement`){let e=await pa(m.body,{service:o});return e.auth=f,e}{let{preview:e,response:t,data:n}=await _a(m);try{let e=await pa([n],{service:o});return e.auth=f,e}catch{throw new lr(e,t)}}}static async connect({http:e,onProgress:t,corsProxy:n,service:r,url:i,auth:a,body:o,headers:s,signal:c}){let l=oa(i);l&&(i=l.url),n&&(i=ha(n,i)),s[`content-type`]=`application/x-${r}-request`,s.accept=`application/x-${r}-result`,ga(s,a);let u=await e.request({onProgress:t,method:`POST`,url:`${i}/${r}`,body:o,headers:s,signal:c});if(u.statusCode!==200){let{response:e}=_a(u);throw new Qn(u.statusCode,u.statusMessage,e)}return u}},ya=class{static getRemoteHelperFor({url:e}){let t=new Map;t.set(`http`,va),t.set(`https`,va);let n=xa({url:e});if(!n)throw new dr(e);if(t.has(n.transport))return t.get(n.transport);throw new ur(e,n.transport,n.transport===`ssh`?ta(e):void 0)}},ba=/^[^/@:]+@[^/@:]+:/;function xa({url:e}){if(ba.test(e))return{transport:`ssh`,address:e};let t=e.match(/(\w+)(:\/\/|::)(.*)/);if(t!==null){if(t[2]===`://`)return{transport:t[1],address:t[0]};if(t[2]===`::`)return{transport:t[1],address:t[3]}}}var Sa=class{static async read({fs:e,gitdir:t}){let n=Y(t,`shallow`),r=new Set;return await ft(n,async function(){let t=await e.read(n,{encoding:`utf8`});if(t===null||t.trim()===``)return r;t.trim().split(`
52
54
  `).map(e=>r.add(e))}),r}static async write({fs:e,gitdir:t,oids:n}){let r=Y(t,`shallow`);if(n.size>0){let t=[...n].join(`
53
55
  `)+`
54
- `;await ft(r,async function(){await e.write(r,t,{encoding:`utf8`})})}else await ft(r,async function(){await e.rm(r)})}};function wa({config:e,onAuth:t}){return t&&(async(n,r)=>{let i=r.username||await e.get(`credential.${n}.username`);return t(n,i?{...r,username:i}:r)})}function Ta(e){return e.slice(0,12).toString(`hex`)===`5041434b0000000200000000`}function Ea(e,t){let n=e.map(e=>e.split(`=`,1)[0]);return t.filter(e=>{let t=e.split(`=`,1)[0];return n.includes(t)})}var Da={name:`isomorphic-git`,version:`1.44.3`,agent:`git/isomorphic-git@1.44.3`},Oa=class{constructor(){this._queue=[]}write(e){if(this._ended)throw Error(`You cannot write to a FIFO that has already been ended!`);if(this._waiting){let t=this._waiting;this._waiting=null,t({value:e})}else this._queue.push(e)}end(){if(this._ended=!0,this._waiting){let e=this._waiting;this._waiting=null,e({done:!0})}}destroy(e){this.error=e,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error(`You cannot call read until the previous call to read has returned!`);return new Promise(e=>{this._waiting=e})}};function ka(e){let t=e.indexOf(`\r`),n=e.indexOf(`
55
- `);return t===-1&&n===-1?-1:t===-1?n+1:n===-1?t+1:n===t+1?n+1:Math.min(t,n)+1}function Aa(e){let t=new Oa,n=``;return(async()=>{await ia(e,e=>{for(e=e.toString(`utf8`),n+=e;;){let e=ka(n);if(e===-1||e===n.length&&n[e-1]===`\r`)break;t.write(n.slice(0,e)),n=n.slice(e)}}),n.length>0&&t.write(n),t.end()})(),t}var ja=class{static demux(e){let t=fa.streamReader(e),n=new Oa,r=new Oa,i=new Oa,a=async function(){let o=await t();if(o===null)return a();if(o===!0)n.end(),i.end(),e.error?r.destroy(e.error):r.end();else{switch(o[0]){case 1:r.write(o.slice(1));break;case 2:i.write(o.slice(1));break;case 3:{let e=o.slice(1);i.write(e),n.end(),i.end(),r.destroy(Error(e.toString(`utf8`)));return}default:n.write(o)}a()}};return a(),{packetlines:n,packfile:r,progress:i}}};async function Ma(e){let{packetlines:t,packfile:n,progress:r}=ja.demux(e),i=[],a=[],o=[],s=!1,c=!1;return new Promise((l,u)=>{ia(t,t=>{let d=t.toString(`utf8`).trim();if(d.startsWith(`shallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new Et(e)),i.push(e)}else if(d.startsWith(`unshallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new Et(e)),a.push(e)}else if(d.startsWith(`ACK`)){let[,e,t]=d.split(` `);o.push({oid:e,status:t}),t||(c=!0)}else d.startsWith(`NAK`)?(s=!0,c=!0):(c=!0,s=!0);c&&(e.error?u(e.error):l({shallows:i,unshallows:a,acks:o,nak:s,packfile:n,progress:r}))}).finally(()=>{c||(e.error?u(e.error):l({shallows:i,unshallows:a,acks:o,nak:s,packfile:n,progress:r}))})})}function Na({capabilities:e=[],wants:t=[],haves:n=[],shallows:r=[],depth:i=null,since:a=null,exclude:o=[]}){let s=[];t=[...new Set(t)];let c=` ${e.join(` `)}`;for(let e of t)s.push(fa.encode(`want ${e}${c}\n`)),c=``;for(let e of r)s.push(fa.encode(`shallow ${e}\n`));i!==null&&s.push(fa.encode(`deepen ${i}\n`)),a!==null&&s.push(fa.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}\n`));for(let e of o)s.push(fa.encode(`deepen-not ${e}\n`));s.push(fa.flush());for(let e of n)s.push(fa.encode(`have ${e}\n`));return s.push(fa.encode(`done
56
- `)),s}async function Pa({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:c,ref:l,remoteRef:u,remote:d,url:f,corsProxy:p,depth:m=null,since:h=null,exclude:g=[],relative:_=!1,tags:v=!1,singleBranch:y=!1,headers:b={},prune:x=!1,pruneTags:S=!1}){let C=l||await ta({fs:e,gitdir:c,test:!0}),w=await nn.get({fs:e,gitdir:c}),T=d||C&&await w.get(`branch.${C}.remote`)||`origin`,E=f||await w.get(`remote.${T}.url`);if(E===void 0)throw new ar(`remote OR url`);let ee=u||C&&await w.get(`branch.${C}.merge`)||l||`HEAD`;p===void 0&&(p=await w.get(`http.corsProxy`));let D=ba.getRemoteHelperFor({url:E}),O=await D.discover({http:n,onAuth:wa({config:w,onAuth:a}),onAuthSuccess:o,onAuthFailure:wa({config:w,onAuth:s}),corsProxy:p,service:`git-upload-pack`,url:E,headers:b,protocolVersion:1}),k=O.auth,A=O.refs;if(A.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(m!==null&&!O.capabilities.has(`shallow`))throw new lr(`shallow`,`depth`);if(h!==null&&!O.capabilities.has(`deepen-since`))throw new lr(`deepen-since`,`since`);if(g.length>0&&!O.capabilities.has(`deepen-not`))throw new lr(`deepen-not`,`exclude`);if(_===!0&&!O.capabilities.has(`deepen-relative`))throw new lr(`deepen-relative`,`relative`);let{oid:j,fullref:te}=X.resolveAgainstMap({ref:ee,map:A});for(let e of A.keys())e===te||e===`HEAD`||e.startsWith(`refs/heads/`)||v&&e.startsWith(`refs/tags/`)||A.delete(e);let M=Ea([...O.capabilities],[`multi_ack_detailed`,`no-done`,`side-band-64k`,`ofs-delta`,`agent=${Da.agent}`]);_&&M.push(`deepen-relative`);let ne=y?[j]:A.values(),re=y?[C]:await X.listRefs({fs:e,gitdir:c,filepath:`refs`}),ie=[];for(let n of re)try{n=await X.expand({fs:e,gitdir:c,ref:n});let r=await X.resolve({fs:e,gitdir:c,ref:n});await ui({fs:e,cache:t,gitdir:c,oid:r})&&ie.push(r)}catch{}ie=[...new Set(ie)];let ae=await Ca.read({fs:e,gitdir:c}),oe=O.capabilities.has(`shallow`)?[...ae]:[],se=Na({capabilities:M,wants:ne,haves:ie,shallows:oe,depth:m,since:h,exclude:g}),ce=Buffer.from(await aa(se)),le=await D.connect({http:n,onProgress:r,corsProxy:p,service:`git-upload-pack`,url:E,auth:k,body:[ce],headers:b}),N=await Ma(le.body);le.headers&&(N.headers=le.headers);for(let n of N.shallows)if(!ae.has(n))try{let{object:r}=await Vn({fs:e,cache:t,gitdir:c,oid:n}),i=new Or(r),a=await Promise.all(i.headers().parent.map(n=>ui({fs:e,cache:t,gitdir:c,oid:n})));a.length===0||a.every(e=>e)||ae.add(n)}catch{ae.add(n)}for(let e of N.unshallows)ae.delete(e);if(await Ca.write({fs:e,gitdir:c,oids:ae}),y){let t=new Map([[te,j]]),n=new Map,r=10,i=te;for(;r--;){let e=O.symrefs.get(i);if(e===void 0)break;n.set(i,e),i=e}let a=A.get(i);a&&t.set(i,a);let{pruned:o}=await X.updateRemoteRefs({fs:e,gitdir:c,remote:T,refs:t,symrefs:n,tags:v,prune:x});x&&(N.pruned=o)}else{let{pruned:t}=await X.updateRemoteRefs({fs:e,gitdir:c,remote:T,refs:A,symrefs:O.symrefs,tags:v,prune:x,pruneTags:S});x&&(N.pruned=t)}if(N.HEAD=O.symrefs.get(`HEAD`),N.HEAD===void 0){let{oid:e}=X.resolveAgainstMap({ref:`HEAD`,map:A});for(let[t,n]of A.entries())if(t!==`HEAD`&&n===e){N.HEAD=t;break}}N.FETCH_HEAD={oid:j,description:`${te.startsWith(`refs/tags`)?`tag`:`branch`} '${ea(te)}' of ${E}`},(r||i)&&ia(Aa(N.progress),async e=>{if(i&&await i(e),r){let t=e.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);t&&await r({phase:t[1].trim(),loaded:parseInt(t[2],10),total:parseInt(t[3],10)})}});let P=Buffer.from(await aa(N.packfile));if(le.body.error)throw le.body.error;let ue=P.slice(-20).toString(`hex`),de={defaultBranch:N.HEAD,fetchHead:N.FETCH_HEAD.oid,fetchHeadDescription:N.FETCH_HEAD.description};if(N.headers&&(de.headers=N.headers),x&&(de.pruned=N.pruned),ue!==``&&!Ta(P)){de.packfile=`objects/pack/pack-${ue}.pack`;let n=Y(c,de.packfile);await e.write(n,P);let i=await Nn.fromPack({pack:P,getExternalRefDelta:n=>Vn({fs:e,cache:t,gitdir:c,oid:n}),onProgress:r});await e.write(n.replace(/\.pack$/,`.idx`),await i.toBuffer())}return de}async function Fa({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:Y(n,`.git`),defaultBranch:i=`master`}){if(await e.exists(r+`/config`))return;let a=[`hooks`,`info`,`objects/info`,`objects/pack`,`refs/heads`,`refs/tags`];a=a.map(e=>r+`/`+e);for(let t of a)await e.mkdir(t);await e.write(r+`/config`,`[core]
56
+ `;await ft(r,async function(){await e.write(r,t,{encoding:`utf8`})})}else await ft(r,async function(){await e.rm(r)})}};function Ca({config:e,onAuth:t}){return t&&(async(n,r)=>{let i=r.username||await e.get(`credential.${n}.username`);return t(n,i?{...r,username:i}:r)})}function wa(e){return e.slice(0,12).toString(`hex`)===`5041434b0000000200000000`}function Ta(e,t){let n=e.map(e=>e.split(`=`,1)[0]);return t.filter(e=>{let t=e.split(`=`,1)[0];return n.includes(t)})}var Ea={name:`isomorphic-git`,version:`1.44.4`,agent:`git/isomorphic-git@1.44.4`},Da=class{constructor(){this._queue=[]}write(e){if(this._ended)throw Error(`You cannot write to a FIFO that has already been ended!`);if(this._waiting){let t=this._waiting;this._waiting=null,t({value:e})}else this._queue.push(e)}end(){if(this._ended=!0,this._waiting){let e=this._waiting;this._waiting=null,e({done:!0})}}destroy(e){this.error=e,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error(`You cannot call read until the previous call to read has returned!`);return new Promise(e=>{this._waiting=e})}};function Oa(e){let t=e.indexOf(`\r`),n=e.indexOf(`
57
+ `);return t===-1&&n===-1?-1:t===-1?n+1:n===-1?t+1:n===t+1?n+1:Math.min(t,n)+1}function ka(e){let t=new Da,n=``;return(async()=>{await ra(e,e=>{for(e=e.toString(`utf8`),n+=e;;){let e=Oa(n);if(e===-1||e===n.length&&n[e-1]===`\r`)break;t.write(n.slice(0,e)),n=n.slice(e)}}),n.length>0&&t.write(n),t.end()})(),t}var Aa=class{static demux(e){let t=da.streamReader(e),n=new Da,r=new Da,i=new Da,a=async function(){let o=await t();if(o===null)return a();if(o===!0)n.end(),i.end(),e.error?r.destroy(e.error):r.end();else{switch(o[0]){case 1:r.write(o.slice(1));break;case 2:i.write(o.slice(1));break;case 3:{let e=o.slice(1);i.write(e),n.end(),i.end(),r.destroy(Error(e.toString(`utf8`)));return}default:n.write(o)}a()}};return a(),{packetlines:n,packfile:r,progress:i}}};async function ja(e){let{packetlines:t,packfile:n,progress:r}=Aa.demux(e),i=[],a=[],o=[],s=!1,c=!1;return new Promise((l,u)=>{ra(t,t=>{let d=t.toString(`utf8`).trim();if(d.startsWith(`shallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new Et(e)),i.push(e)}else if(d.startsWith(`unshallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new Et(e)),a.push(e)}else if(d.startsWith(`ACK`)){let[,e,t]=d.split(` `);o.push({oid:e,status:t}),t||(c=!0)}else d.startsWith(`NAK`)?(s=!0,c=!0):(c=!0,s=!0);c&&(e.error?u(e.error):l({shallows:i,unshallows:a,acks:o,nak:s,packfile:n,progress:r}))}).finally(()=>{c||(e.error?u(e.error):l({shallows:i,unshallows:a,acks:o,nak:s,packfile:n,progress:r}))})})}function Ma({capabilities:e=[],wants:t=[],haves:n=[],shallows:r=[],depth:i=null,since:a=null,exclude:o=[]}){let s=[];t=[...new Set(t)];let c=` ${e.join(` `)}`;for(let e of t)s.push(da.encode(`want ${e}${c}\n`)),c=``;for(let e of r)s.push(da.encode(`shallow ${e}\n`));i!==null&&s.push(da.encode(`deepen ${i}\n`)),a!==null&&s.push(da.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}\n`));for(let e of o)s.push(da.encode(`deepen-not ${e}\n`));s.push(da.flush());for(let e of n)s.push(da.encode(`have ${e}\n`));return s.push(da.encode(`done
58
+ `)),s}async function Na({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:c,ref:l,remoteRef:u,remote:d,url:f,corsProxy:p,depth:m=null,since:h=null,exclude:g=[],relative:_=!1,tags:v=!1,singleBranch:y=!1,headers:b={},prune:x=!1,pruneTags:S=!1}){let C=l||await ea({fs:e,gitdir:c,test:!0}),w=await tn.get({fs:e,gitdir:c}),T=d||C&&await w.get(`branch.${C}.remote`)||`origin`,E=f||await w.get(`remote.${T}.url`);if(E===void 0)throw new ir(`remote OR url`);let ee=u||C&&await w.get(`branch.${C}.merge`)||l||`HEAD`;p===void 0&&(p=await w.get(`http.corsProxy`));let D=ya.getRemoteHelperFor({url:E}),O=await D.discover({http:n,onAuth:Ca({config:w,onAuth:a}),onAuthSuccess:o,onAuthFailure:Ca({config:w,onAuth:s}),corsProxy:p,service:`git-upload-pack`,url:E,headers:b,protocolVersion:1}),k=O.auth,A=O.refs;if(A.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(m!==null&&!O.capabilities.has(`shallow`))throw new cr(`shallow`,`depth`);if(h!==null&&!O.capabilities.has(`deepen-since`))throw new cr(`deepen-since`,`since`);if(g.length>0&&!O.capabilities.has(`deepen-not`))throw new cr(`deepen-not`,`exclude`);if(_===!0&&!O.capabilities.has(`deepen-relative`))throw new cr(`deepen-relative`,`relative`);let{oid:j,fullref:te}=X.resolveAgainstMap({ref:ee,map:A});for(let e of A.keys())e===te||e===`HEAD`||e.startsWith(`refs/heads/`)||v&&e.startsWith(`refs/tags/`)||A.delete(e);let M=Ta([...O.capabilities],[`multi_ack_detailed`,`no-done`,`side-band-64k`,`ofs-delta`,`agent=${Ea.agent}`]);_&&M.push(`deepen-relative`);let ne=y?[j]:A.values(),re=y?[C]:await X.listRefs({fs:e,gitdir:c,filepath:`refs`}),ie=[];for(let n of re)try{n=await X.expand({fs:e,gitdir:c,ref:n});let r=await X.resolve({fs:e,gitdir:c,ref:n});await li({fs:e,cache:t,gitdir:c,oid:r})&&ie.push(r)}catch{}ie=[...new Set(ie)];let ae=await Sa.read({fs:e,gitdir:c}),oe=O.capabilities.has(`shallow`)?[...ae]:[],se=Ma({capabilities:M,wants:ne,haves:ie,shallows:oe,depth:m,since:h,exclude:g}),ce=Buffer.from(await ia(se)),le=await D.connect({http:n,onProgress:r,corsProxy:p,service:`git-upload-pack`,url:E,auth:k,body:[ce],headers:b}),N=await ja(le.body);le.headers&&(N.headers=le.headers);for(let n of N.shallows)if(!ae.has(n))try{let{object:r}=await Bn({fs:e,cache:t,gitdir:c,oid:n}),i=new Dr(r),a=await Promise.all(i.headers().parent.map(n=>li({fs:e,cache:t,gitdir:c,oid:n})));a.length===0||a.every(e=>e)||ae.add(n)}catch{ae.add(n)}for(let e of N.unshallows)ae.delete(e);if(await Sa.write({fs:e,gitdir:c,oids:ae}),y){let t=new Map([[te,j]]),n=new Map,r=10,i=te;for(;r--;){let e=O.symrefs.get(i);if(e===void 0)break;n.set(i,e),i=e}let a=A.get(i);a&&t.set(i,a);let{pruned:o}=await X.updateRemoteRefs({fs:e,gitdir:c,remote:T,refs:t,symrefs:n,tags:v,prune:x});x&&(N.pruned=o)}else{let{pruned:t}=await X.updateRemoteRefs({fs:e,gitdir:c,remote:T,refs:A,symrefs:O.symrefs,tags:v,prune:x,pruneTags:S});x&&(N.pruned=t)}if(N.HEAD=O.symrefs.get(`HEAD`),N.HEAD===void 0){let{oid:e}=X.resolveAgainstMap({ref:`HEAD`,map:A});for(let[t,n]of A.entries())if(t!==`HEAD`&&n===e){N.HEAD=t;break}}N.FETCH_HEAD={oid:j,description:`${te.startsWith(`refs/tags`)?`tag`:`branch`} '${$i(te)}' of ${E}`},(r||i)&&ra(ka(N.progress),async e=>{if(i&&await i(e),r){let t=e.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);t&&await r({phase:t[1].trim(),loaded:parseInt(t[2],10),total:parseInt(t[3],10)})}});let P=Buffer.from(await ia(N.packfile));if(le.body.error)throw le.body.error;let ue=P.slice(-20).toString(`hex`),de={defaultBranch:N.HEAD,fetchHead:N.FETCH_HEAD.oid,fetchHeadDescription:N.FETCH_HEAD.description};if(N.headers&&(de.headers=N.headers),x&&(de.pruned=N.pruned),ue!==``&&!wa(P)){de.packfile=`objects/pack/pack-${ue}.pack`;let n=Y(c,de.packfile);await e.write(n,P);let i=await Mn.fromPack({pack:P,getExternalRefDelta:n=>Bn({fs:e,cache:t,gitdir:c,oid:n}),onProgress:r});await e.write(n.replace(/\.pack$/,`.idx`),await i.toBuffer())}return de}async function Pa({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:Y(n,`.git`),defaultBranch:i=`master`}){if(await e.exists(r+`/config`))return;let a=[`hooks`,`info`,`objects/info`,`objects/pack`,`refs/heads`,`refs/tags`];a=a.map(e=>r+`/`+e);for(let t of a)await e.mkdir(t);await e.write(r+`/config`,`[core]
57
59
  repositoryformatversion = 0
58
60
  filemode = false
59
61
  \tbare = ${t}\n`+(t?``:` logallrefupdates = true
60
62
  `)+` symlinks = false
61
63
  ignorecase = true
62
- `),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function Ia({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPostCheckout:c,dir:l,gitdir:u,url:d,corsProxy:f,ref:p,remote:m,depth:h,since:g,exclude:_,relative:v,singleBranch:y,noCheckout:b,noTags:x,headers:S,nonBlocking:C,batchSize:w=100}){try{if(await Fa({fs:e,gitdir:u}),await Di({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await nn.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await nn.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:E}=await Pa({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:u,ref:p,remote:m,corsProxy:f,depth:h,since:g,exclude:_,relative:v,singleBranch:y,headers:S,tags:!x});if(E===null)return;p||=T,p=p.replace(`refs/heads/`,``),await Fi({fs:e,cache:t,onProgress:r,onPostCheckout:c,dir:l,gitdir:u,ref:p,remote:m,noCheckout:b,nonBlocking:C,batchSize:w})}catch(t){throw await e.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>void 0),t}}async function La({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:l=Y(c,`.git`),url:u,corsProxy:d=void 0,ref:f=void 0,remote:p=`origin`,depth:m=void 0,since:h=void 0,exclude:g=[],relative:_=!1,singleBranch:v=!1,noCheckout:y=!1,noTags:b=!1,headers:x={},cache:S={},nonBlocking:C=!1,batchSize:w=100}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,l),y||Q(`dir`,c),Q(`url`,u);let T=new Z(e);return await Ia({fs:T,cache:S,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:await $({fsp:T,dotgit:l}),url:u,corsProxy:d,ref:f,remote:p,depth:m,since:h,exclude:g,relative:_,singleBranch:v,noCheckout:y,noTags:b,headers:x,nonBlocking:C,batchSize:w})}catch(e){throw e.caller=`git.clone`,e}}async function Ra({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,disallowEmpty:d=!1,ref:f,parent:p,tree:m,cache:h={}}){try{Q(`fs`,e),c||Q(`message`,i),s&&Q(`onSign`,t);let n=new Z(e);return await vi({fs:n,cache:h,onSign:t,gitdir:await $({fsp:n,dotgit:r}),message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:l,noUpdateBranch:u,disallowEmpty:d,ref:f,parent:p,tree:m})}catch(e){throw e.caller=`git.commit`,e}}async function za({fs:e,dir:t,gitdir:n=Y(t,`.git`),fullname:r=!1,test:i=!1}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await ta({fs:t,gitdir:await $({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function Ba({fs:e,gitdir:t,ref:n}){if(n=n.startsWith(`refs/heads/`)?n:`refs/heads/${n}`,!await X.exists({fs:e,gitdir:t,ref:n}))throw new J(n);let r=await X.expand({fs:e,gitdir:t,ref:n});if(r===await ta({fs:e,gitdir:t,fullname:!0})){let n=await X.resolve({fs:e,gitdir:t,ref:r});await X.writeRef({fs:e,gitdir:t,ref:`HEAD`,value:n})}await X.deleteRef({fs:e,gitdir:t,ref:r});let i=ea(n),a=await nn.get({fs:e,gitdir:t});await a.deleteSection(`branch`,i),await nn.save({fs:e,gitdir:t,config:a})}async function Va({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`ref`,r);let t=new Z(e);return await Ba({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteBranch`,e}}async function Ha({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`ref`,r);let t=new Z(e),i=await $({fsp:t,dotgit:n});await X.deleteRef({fs:t,gitdir:i,ref:r})}catch(e){throw e.caller=`git.deleteRef`,e}}async function Ua({fs:e,gitdir:t,remote:n}){let r=await nn.get({fs:e,gitdir:t});await r.deleteSection(`remote`,n),await nn.save({fs:e,gitdir:t,config:r})}async function Wa({fs:e,dir:t,gitdir:n=Y(t,`.git`),remote:r}){try{Q(`fs`,e),Q(`remote`,r);let t=new Z(e);return await Ua({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r})}catch(e){throw e.caller=`git.deleteRemote`,e}}async function Ga({fs:e,gitdir:t,ref:n}){n=n.startsWith(`refs/tags/`)?n:`refs/tags/${n}`,await X.deleteRef({fs:e,gitdir:t,ref:n})}async function Ka({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`ref`,r);let t=new Z(e);return await Ga({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteTag`,e}}async function qa({fs:e,gitdir:t,oid:n}){let r=n.slice(0,2);return(await e.readdir(`${t}/objects/${r}`)).map(e=>`${r}${e}`).filter(e=>e.startsWith(n))}async function Ja({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=[],o=await e.readdir(Y(n,`objects/pack`));o=o.filter(e=>e.endsWith(`.idx`));for(let s of o){let o=await In({fs:e,cache:t,filename:`${n}/objects/pack/${s}`,getExternalRefDelta:i});if(o.error)throw new q(o.error);for(let e of o.offsets.keys())e.startsWith(r)&&a.push(e)}return a}async function Ya({fs:e,cache:t,gitdir:n,oid:r}){let i=r=>Vn({fs:e,cache:t,gitdir:n,oid:r}),a=await qa({fs:e,gitdir:n,oid:r}),o=await Ja({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i});for(let e of o)a.indexOf(e)===-1&&a.push(e);if(a.length===1)return a[0];throw a.length>1?new Un(`oids`,r,a):new J(`an object matching "${r}"`)}async function Xa({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await Ya({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.expandOid`,e}}async function Za({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e),i=await $({fsp:t,dotgit:n});return await X.expand({fs:t,gitdir:i,ref:r})}catch(e){throw e.caller=`git.expandRef`,e}}async function Qa({fs:e,cache:t,gitdir:n,oids:r}){let i={},a=r.length,o=new Set,s=new Map,c=await Ca.read({fs:e,gitdir:n}),l=async r=>{if(s.has(r))return s.get(r);let{object:i,type:a}=await Vn({fs:e,cache:t,gitdir:n,oid:r});if(a!==`commit`)throw new Tt(r,a,`commit`);let{parent:o}=Or.from(i).parseHeaders(),l=c.has(r)?[]:o;return s.set(r,l),l},u=r.map((e,t)=>({index:t,oid:e}));for(;u.length;){for(let{oid:e,index:t}of u)await l(e),i[e]||(i[e]=new Set),i[e].add(t),i[e].size===a&&o.add(e);let e=new Map;for(let{oid:t,index:n}of u)if(!o.has(t))for(let r of await l(t))i[r]&&i[r].has(n)||e.set(r+`:`+n,{oid:r,index:n});u=Array.from(e.values())}if(o.size<2)return[...o];let d=new Set;for(let e of o){let t=[...await l(e)],n=new Set;for(;t.length;){let e=t.pop();n.has(e)||(n.add(e),o.has(e)?d.add(e):t.push(...await l(e)))}}return[...o].filter(e=>!d.has(e))}async function $a({fs:e,cache:t,dir:n,gitdir:r,ours:i,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:c=!1,noUpdateBranch:l=!1,abortOnConflict:u=!0,message:d,author:f,committer:p,signingKey:m,onSign:h,mergeDriver:g,allowUnrelatedHistories:_=!1}){i===void 0&&(i=await ta({fs:e,gitdir:r,fullname:!0})),i=await X.expand({fs:e,gitdir:r,ref:i}),a=await X.expand({fs:e,gitdir:r,ref:a});let v=await X.resolve({fs:e,gitdir:r,ref:i}),{oid:y}=await hi({fs:e,cache:t,gitdir:r,oid:await X.resolve({fs:e,gitdir:r,ref:a})}),b=await Qa({fs:e,cache:t,gitdir:r,oids:[v,y]});if(b.length!==1){if(b.length===0&&_)b.push(`4b825dc642cb6eb9a060e54bf8d69288fbee4904`);else throw new nr}let x=b[0];if(x===y)return{oid:v,alreadyMerged:!0};if(o&&x===v)return!c&&!l&&await X.writeRef({fs:e,gitdir:r,ref:i,value:y}),{oid:y,fastForward:!0};{if(s)throw new Zn;let o=await _t.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async o=>Ui({fs:e,cache:t,dir:n,gitdir:r,index:o,ourOid:v,theirOid:y,baseOid:x,ourName:ea(i),baseName:`base`,theirName:ea(a),dryRun:c,abortOnConflict:u,mergeDriver:g}));if(o instanceof rr)throw o;return d||=`Merge branch '${ea(a)}' into ${ea(i)}`,{oid:await vi({fs:e,cache:t,gitdir:r,message:d,ref:i,tree:o,parent:[v,y],author:f,committer:p,signingKey:m,onSign:h,dryRun:c,noUpdateBranch:l}),tree:o,mergeCommit:!0}}}async function eo({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,dir:c,gitdir:l,ref:u,url:d,remote:f,remoteRef:p,prune:m,pruneTags:h,fastForward:g,fastForwardOnly:_,corsProxy:v,singleBranch:y,headers:b,author:x,committer:S,signingKey:C}){try{if(!u){let t=await ta({fs:e,gitdir:l});if(!t)throw new ar(`ref`);u=t}let{fetchHead:w,fetchHeadDescription:T}=await Pa({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:l,corsProxy:v,ref:u,url:d,remote:f,remoteRef:p,singleBranch:y,headers:b,prune:m,pruneTags:h});await $a({fs:e,cache:t,gitdir:l,ours:u,theirs:w,fastForward:g,fastForwardOnly:_,message:`Merge ${T}`,author:x,committer:S,signingKey:C,dryRun:!1,noUpdateBranch:!1}),await Fi({fs:e,cache:t,onProgress:r,dir:c,gitdir:l,ref:u,remote:f,noCheckout:!1})}catch(e){throw e.caller=`git.pull`,e}}async function to({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=Y(s,`.git`),ref:l,url:u,remote:d,remoteRef:f,corsProxy:p,singleBranch:m,headers:h={},cache:g={}}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,c);let _={name:``,email:``,timestamp:Date.now(),timezoneOffset:0},v=new Z(e);return await eo({fs:v,cache:g,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:await $({fsp:v,dotgit:c}),ref:l,url:u,remote:d,remoteRef:f,fastForwardOnly:!0,corsProxy:p,singleBranch:m,headers:h,author:_,committer:_})}catch(e){throw e.caller=`git.fastForward`,e}}async function no({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=Y(s,`.git`),ref:l,remote:u,remoteRef:d,url:f,corsProxy:p,depth:m=null,since:h=null,exclude:g=[],relative:_=!1,tags:v=!1,singleBranch:y=!1,headers:b={},prune:x=!1,pruneTags:S=!1,cache:C={}}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,c);let s=new Z(e);return await Pa({fs:s,cache:C,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,gitdir:await $({fsp:s,dotgit:c}),ref:l,remote:u,remoteRef:d,url:f,corsProxy:p,depth:m,since:h,exclude:g,relative:_,tags:v,singleBranch:y,headers:b,prune:x,pruneTags:S})}catch(e){throw e.caller=`git.fetch`,e}}async function ro({fs:e,dir:t,gitdir:n=Y(t,`.git`),oids:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oids`,r);let t=new Z(e);return await Qa({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oids:r})}catch(e){throw e.caller=`git.findMergeBase`,e}}async function io({fs:e,filepath:t}){if(await e.exists(Y(t,`.git`)))return t;{let n=yt(t);if(n===t)throw new J(`git root for ${t}`);return io({fs:e,filepath:n})}}async function ao({fs:e,filepath:t}){try{return Q(`fs`,e),Q(`filepath`,t),await io({fs:new Z(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function oo({fs:e,dir:t,gitdir:n=Y(t,`.git`),path:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`path`,r);let t=new Z(e);return await di({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfig`,e}}async function so({fs:e,gitdir:t,path:n}){return(await nn.get({fs:e,gitdir:t})).getall(n)}async function co({fs:e,dir:t,gitdir:n=Y(t,`.git`),path:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`path`,r);let t=new Z(e);return await so({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfigAll`,e}}function lo(e,t,n){let r=t.split(`/`),i=r.pop();if(i===`__proto__`||r.includes(`__proto__`))return;let a=e;for(let e of r)Object.prototype.hasOwnProperty.call(a,e)||(a[e]={}),a=a[e];a[i]=n}async function uo({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1}){try{Q(`http`,e),Q(`url`,a);let c=await ba.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:1}),l={capabilities:[...c.capabilities]};for(let[e,t]of c.refs)lo(l,e,t);for(let[e,t]of c.symrefs)lo(l,e,t);return l}catch(e){throw e.caller=`git.getRemoteInfo`,e}}function fo(e,t,n,r){let i=[];for(let[a,o]of e.refs){if(t&&!a.startsWith(t))continue;if(a.endsWith(`^{}`)){if(r){let e=a.replace(`^{}`,``),t=i[i.length-1],n=t?.ref===e?t:i.find(t=>t.ref===e);n!==void 0&&(n.peeled=o)}continue}let s={ref:a,oid:o};n&&e.symrefs.has(a)&&(s.target=e.symrefs.get(a)),i.push(s)}return i}async function po({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1,protocolVersion:c=2}){try{Q(`http`,e),Q(`url`,a);let l=await ba.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:c});if(l.protocolVersion===2)return{protocolVersion:l.protocolVersion,capabilities:l.capabilities2};let u={};for(let e of l.capabilities){let[t,n]=e.split(`=`);u[t]=n||!0}return{protocolVersion:1,capabilities:u,refs:fo(l,void 0,!0,!0)}}catch(e){throw e.caller=`git.getRemoteInfo2`,e}}async function mo({type:e,object:t,format:n=`content`,oid:r=void 0}){return n!==`deflated`&&(n!==`wrapped`&&(t=mn.wrap({type:e,object:t})),r=await nt(t)),{oid:r,object:t}}async function ho({object:e}){try{Q(`object`,e),typeof e==`string`?e=Buffer.from(e,`utf8`):e instanceof Uint8Array||(e=new Uint8Array(e));let t=`blob`,{oid:n,object:r}=await mo({type:t,format:`content`,object:e});return{oid:n,type:t,object:r,format:`wrapped`}}catch(e){throw e.caller=`git.hashBlob`,e}}async function go({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,filepath:a}){try{a=Y(r,a);let o=await e.read(a),s=await Nn.fromPack({pack:o,getExternalRefDelta:n=>Vn({fs:e,cache:t,gitdir:i,oid:n}),onProgress:n});return await e.write(a.replace(/\.pack$/,`.idx`),await s.toBuffer()),{oids:[...s.hashes]}}catch(e){throw e.caller=`git.indexPack`,e}}async function _o({fs:e,onProgress:t,dir:n,gitdir:r=Y(n,`.git`),filepath:i,cache:a={}}){try{Q(`fs`,e),Q(`dir`,n),Q(`gitdir`,n),Q(`filepath`,i);let o=new Z(e);return await go({fs:o,cache:a,onProgress:t,dir:n,gitdir:await $({fsp:o,dotgit:r}),filepath:i})}catch(e){throw e.caller=`git.indexPack`,e}}async function vo({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:Y(n,`.git`),defaultBranch:i=`master`}){try{Q(`fs`,e),Q(`gitdir`,r),t||Q(`dir`,n);let a=new Z(e);return await Fa({fs:a,bare:t,dir:n,gitdir:await $({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function yo({fs:e,cache:t,gitdir:n,oid:r,ancestor:i,depth:a}){let o=await Ca.read({fs:e,gitdir:n});if(!r)throw new ar(`oid`);if(!i)throw new ar(`ancestor`);if(r===i)return!1;let s=[r],c=new Set,l=0;for(;s.length;){if(l++===a)throw new tr(a);let r=s.shift(),{type:u,object:d}=await Vn({fs:e,cache:t,gitdir:n,oid:r});if(u!==`commit`)throw new Tt(r,u,`commit`);let f=Or.from(d).parse();for(let e of f.parent)if(e===i)return!0;if(!o.has(r))for(let e of f.parent)c.has(e)||(s.push(e),c.add(e))}return!1}async function bo({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,ancestor:i,depth:a=-1,cache:o={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r),Q(`ancestor`,i);let t=new Z(e);return await yo({fs:t,cache:o,gitdir:await $({fsp:t,dotgit:n}),oid:r,ancestor:i,depth:a})}catch(e){throw e.caller=`git.isDescendent`,e}}async function xo({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r}){try{Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n),Q(`filepath`,r);let i=new Z(e),a=await $({fsp:i,dotgit:n});return Zr.isIgnored({fs:i,dir:t,gitdir:a,filepath:r})}catch(e){throw e.caller=`git.isIgnored`,e}}async function So({fs:e,dir:t,gitdir:n=Y(t,`.git`),remote:r}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e),i=await $({fsp:t,dotgit:n});return X.listBranches({fs:t,gitdir:i,remote:r})}catch(e){throw e.caller=`git.listBranches`,e}}async function Co({fs:e,gitdir:t,ref:n,cache:r}){if(n){let i=await X.resolve({gitdir:t,fs:e,ref:n}),a=[];return await wo({fs:e,cache:r,gitdir:t,oid:i,filenames:a,prefix:``}),a}return _t.acquire({fs:e,gitdir:t,cache:r},async function(e){return e.entries.map(e=>e.path)})}async function wo({fs:e,cache:t,gitdir:n,oid:r,filenames:i,prefix:a}){let{tree:o}=await Ci({fs:e,cache:t,gitdir:n,oid:r});for(let r of o)r.type===`tree`?await wo({fs:e,cache:t,gitdir:n,oid:r.oid,filenames:i,prefix:Y(a,r.path)}):i.push(Y(a,r.path))}async function To({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await Co({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listFiles`,e}}async function Eo({fs:e,cache:t,gitdir:n,ref:r}){let i;try{i=await X.resolve({gitdir:n,fs:e,ref:r})}catch(e){if(e instanceof J)return[];throw e}return(await Ci({fs:e,cache:t,gitdir:n,oid:i})).tree.map(e=>({target:e.path,note:e.oid}))}async function Do({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r=`refs/notes/commits`,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e);return await Eo({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listNotes`,e}}async function Oo({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e),i=await $({fsp:t,dotgit:n});return X.listRefs({fs:t,gitdir:i,filepath:r})}catch(e){throw e.caller=`git.listRefs`,e}}async function ko({fs:e,gitdir:t}){let n=await nn.get({fs:e,gitdir:t}),r=await n.getSubsections(`remote`);return Promise.all(r.map(async e=>({remote:e,url:await n.get(`remote.${e}.url`)})))}async function Ao({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await ko({fs:t,gitdir:await $({fsp:t,dotgit:n})})}catch(e){throw e.caller=`git.listRemotes`,e}}async function jo(e){let t=fa.streamReader(e),n=[],r;for(;r=await t(),r!==!0;){if(r===null)continue;r=r.toString(`utf8`).replace(/\n$/,``);let[e,t,...i]=r.split(` `),a={ref:t,oid:e};for(let e of i){let[t,n]=e.split(`:`);t===`symref-target`?a.target=n:t===`peeled`&&(a.peeled=n)}n.push(a)}return n}async function Mo({prefix:e,symrefs:t,peelTags:n}){let r=[];return r.push(fa.encode(`command=ls-refs
63
- `)),r.push(fa.encode(`agent=${Da.agent}\n`)),(n||t||e)&&r.push(fa.delim()),n&&r.push(fa.encode(`peel`)),t&&r.push(fa.encode(`symrefs`)),e&&r.push(fa.encode(`ref-prefix ${e}`)),r.push(fa.flush()),r}async function No({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1,protocolVersion:c=2,prefix:l,symrefs:u,peelTags:d}){try{Q(`http`,e),Q(`url`,a);let f=await ya.discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:c});if(f.protocolVersion===1)return fo(f,l,u,d);let p=await Mo({prefix:l,symrefs:u,peelTags:d});return jo((await ya.connect({http:e,auth:f.auth,headers:o,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,body:p})).body)}catch(e){throw e.caller=`git.listServerRefs`,e}}async function Po({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e),r=await $({fsp:t,dotgit:n});return X.listTags({fs:t,gitdir:r})}catch(e){throw e.caller=`git.listTags`,e}}function Fo(e,t){return e.committer.timestamp-t.committer.timestamp}var Io=`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`;async function Lo({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===Io)return;let a=r,o,s=await kr({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await Ro({fs:e,cache:t,gitdir:n,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Ro({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:o=[],parentPath:s=``}){let c=r.entries().map(function(r){let c;return r.oid===i?(c=Y(s,r.path),o.push(c)):r.type===`tree`&&(c=Vn({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return Ro({fs:e,cache:t,gitdir:n,tree:pn.from(c),fileId:i,oid:a,filepaths:o,parentPath:Y(s,r.path)})})),c});return await Promise.all(c),o}async function zo({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u}){let d=o===void 0?void 0:Math.floor(o.valueOf()/1e3),f=s==null?void 0:new RegExp(s,`i`),p=({commit:e})=>f===void 0?!0:e.author?f.test(`${e.author.name} <${e.author.email}>`):!1,m=[],h=e=>{p(e)&&m.push(e)},g=await Ca.read({fs:e,gitdir:n}),_=[await gi({fs:e,cache:t,gitdir:n,oid:await X.resolve({fs:e,gitdir:n,ref:i})})],v,y,b,x;function S(e){x&&r&&h(e)}for(;_.length>0;){let i=_.pop();if(d!==void 0&&i.commit.committer.timestamp<=d)break;if(r){let a;try{a=await xi({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),b&&(v!==a.oid||y!==a.mode)&&h(b),v=a.oid,y=a.mode,b=i,x=!0}catch(a){if(a instanceof J){let o=l&&v;if(o&&(o=await Lo({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:v}),o)){if(Array.isArray(o)){if(b){let i=await Lo({fs:e,cache:t,gitdir:n,oid:b.commit.tree,fileId:v});if(Array.isArray(i)){if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,b&&h(b);else{o=!1,b&&h(b);break}}}}else r=o,b&&h(b)}if(!o){if(x&&v&&(h(b),!c))break;if(!c&&!l)throw a}b=i,x=!1}else throw a}}else h(i);if(a!==void 0&&m.length===a){S(i);break}if(!g.has(i.oid))for(let r of i.commit.parent){let i=await gi({fs:e,cache:t,gitdir:n,oid:r});_.map(e=>e.oid).includes(i.oid)||_.push(i)}_.length===0&&S(i),_.sort((e,t)=>Fo(e.commit,t.commit))}if(u)for(let r of m)r.commit.changes=await Bo({fs:e,cache:t,gitdir:n,commit:r,shallow:g.has(r.oid)});return m}async function Bo({fs:e,cache:t,gitdir:n,commit:r,shallow:i}){let a=i||!r.commit.parent[0]?`4b825dc642cb6eb9a060e54bf8d69288fbee4904`:r.commit.parent[0];return Rr({fs:e,cache:t,gitdir:n,trees:[jr({ref:r.oid}),jr({ref:a})],map:async(e,[t,n])=>{let[r,i]=await Promise.all([t&&t.type(),n&&n.type()]);if(r===`tree`)return i&&i!==`tree`?[null,await n.oid(),e]:void 0;if(i===`tree`)return r?[await t.oid(),null,e]:void 0;let[a,o]=await Promise.all([t?t.oid():null,n?n.oid():null]);if(a!==o)return[a,o,e]}})}async function Vo({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u=!1,cache:d={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,i);let t=new Z(e);return await zo({fs:t,cache:d,gitdir:await $({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u})}catch(e){throw e.caller=`git.log`,e}}async function Ho({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ours:i,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:c=!1,noUpdateBranch:l=!1,abortOnConflict:u=!0,message:d,author:f,committer:p,signingKey:m,cache:h={},mergeDriver:g,allowUnrelatedHistories:_=!1}){try{Q(`fs`,e),m&&Q(`onSign`,t);let v=new Z(e),y=await $({fsp:v,dotgit:r}),b=await pi({fs:v,gitdir:y,author:f});if(!b&&(!s||!o))throw new ir(`author`);let x=await mi({fs:v,gitdir:y,author:b,committer:p});if(!x&&(!s||!o))throw new ir(`committer`);return await $a({fs:v,cache:h,dir:n,gitdir:y,ours:i,theirs:a,fastForward:o,fastForwardOnly:s,dryRun:c,noUpdateBranch:l,abortOnConflict:u,message:d,author:b,committer:x,signingKey:m,onSign:t,mergeDriver:g,allowUnrelatedHistories:_})}catch(e){throw e.caller=`git.merge`,e}}var Uo={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function Wo({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),oids:i}){let a=new Fe.default,o=[];function s(e,t){let n=Buffer.from(e,t);o.push(n),a.update(n)}async function c({stype:e,object:t}){let n=Uo[e],r=t.length,i=r>15?128:0,a=r&15;r>>>=4;let o=(i|n|a).toString(16);for(s(o,`hex`);i;)i=r>127?128:0,o=i|r&127,s(da(2,o),`hex`),r>>>=7;s(Buffer.from(await ei(t)))}s(`PACK`),s(`00000002`,`hex`),s(da(8,i.length),`hex`);for(let n of i){let{type:i,object:a}=await Vn({fs:e,cache:t,gitdir:r,oid:n});await c({write:s,object:a,stype:i})}let l=a.digest();return o.push(l),o}async function Go({fs:e,cache:t,gitdir:n,oids:r,write:i}){let a=await Wo({fs:e,cache:t,gitdir:n,oids:r}),o=Buffer.from(await aa(a)),s=`pack-${o.slice(-20).toString(`hex`)}.pack`;return i?(await e.write(Y(n,`objects/pack/${s}`),o),{filename:s}):{filename:s,packfile:new Uint8Array(o)}}async function Ko({fs:e,dir:t,gitdir:n=Y(t,`.git`),oids:r,write:i=!1,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oids`,r);let t=new Z(e);return await Go({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oids:r,write:i})}catch(e){throw e.caller=`git.packObjects`,e}}async function qo({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=Y(s,`.git`),ref:l,url:u,remote:d,remoteRef:f,prune:p=!1,pruneTags:m=!1,fastForward:h=!0,fastForwardOnly:g=!1,corsProxy:_,singleBranch:v,headers:y={},author:b,committer:x,signingKey:S,cache:C={}}){try{Q(`fs`,e),Q(`gitdir`,c);let w=new Z(e),T=await $({fsp:w,dotgit:c}),E=await pi({fs:w,gitdir:T,author:b});if(!E)throw new ir(`author`);let ee=await mi({fs:w,gitdir:T,author:E,committer:x});if(!ee)throw new ir(`committer`);return await eo({fs:w,cache:C,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:T,ref:l,url:u,remote:d,remoteRef:f,fastForward:h,fastForwardOnly:g,corsProxy:_,singleBranch:v,headers:y,author:E,committer:ee,signingKey:S,prune:p,pruneTags:m})}catch(e){throw e.caller=`git.pull`,e}}async function Jo({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),start:i,finish:a}){let o=await Ca.read({fs:e,gitdir:r}),s=new Set,c=new Set;for(let t of i)s.add(await X.resolve({fs:e,gitdir:r,ref:t}));for(let t of a)try{let n=await X.resolve({fs:e,gitdir:r,ref:t});c.add(n)}catch{}let l=new Set;async function u(n){l.add(n);let{type:i,object:a}=await Vn({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=Tr.from(a).headers().object;return u(e)}if(i!==`commit`)throw new Tt(n,i,`commit`);if(!o.has(n))for(n of Or.from(a).headers().parent)!c.has(n)&&!l.has(n)&&await u(n)}for(let e of s)await u(e);return l}async function Yo({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),oids:i}){let a=new Set;async function o(n){if(a.has(n))return;a.add(n);let{type:i,object:s}=await Vn({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=Tr.from(s).headers().object;await o(e)}else if(i===`commit`){let e=Or.from(s).headers().tree;await o(e)}else if(i===`tree`){let e=pn.from(s);for(let t of e)t.type===`blob`&&a.add(t.oid),t.type===`tree`&&await o(t.oid)}}for(let e of i)await o(e);return a}async function Xo(e){let t={},n=``,r=fa.streamReader(e),i=await r();for(;i!==!0;)i!==null&&(n+=i.toString(`utf8`)+`
64
+ `),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function Fa({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPostCheckout:c,dir:l,gitdir:u,url:d,corsProxy:f,ref:p,remote:m,depth:h,since:g,exclude:_,relative:v,singleBranch:y,noCheckout:b,noTags:x,headers:S,nonBlocking:C,batchSize:w=100}){try{if(await Pa({fs:e,gitdir:u}),await Ei({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await tn.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await tn.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:E}=await Na({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:u,ref:p,remote:m,corsProxy:f,depth:h,since:g,exclude:_,relative:v,singleBranch:y,headers:S,tags:!x});if(E===null)return;p||=T,p=p.replace(`refs/heads/`,``),await Pi({fs:e,cache:t,onProgress:r,onPostCheckout:c,dir:l,gitdir:u,ref:p,remote:m,noCheckout:b,nonBlocking:C,batchSize:w})}catch(t){throw await e.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>void 0),t}}async function Ia({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:l=Y(c,`.git`),url:u,corsProxy:d=void 0,ref:f=void 0,remote:p=`origin`,depth:m=void 0,since:h=void 0,exclude:g=[],relative:_=!1,singleBranch:v=!1,noCheckout:y=!1,noTags:b=!1,headers:x={},cache:S={},nonBlocking:C=!1,batchSize:w=100}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,l),y||Q(`dir`,c),Q(`url`,u);let T=new Z(e);return await Fa({fs:T,cache:S,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:await $({fsp:T,dotgit:l}),url:u,corsProxy:d,ref:f,remote:p,depth:m,since:h,exclude:g,relative:_,singleBranch:v,noCheckout:y,noTags:b,headers:x,nonBlocking:C,batchSize:w})}catch(e){throw e.caller=`git.clone`,e}}async function La({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,disallowEmpty:d=!1,ref:f,parent:p,tree:m,cache:h={}}){try{Q(`fs`,e),c||Q(`message`,i),s&&Q(`onSign`,t);let n=new Z(e);return await _i({fs:n,cache:h,onSign:t,gitdir:await $({fsp:n,dotgit:r}),message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:l,noUpdateBranch:u,disallowEmpty:d,ref:f,parent:p,tree:m})}catch(e){throw e.caller=`git.commit`,e}}async function Ra({fs:e,dir:t,gitdir:n=Y(t,`.git`),fullname:r=!1,test:i=!1}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await ea({fs:t,gitdir:await $({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function za({fs:e,gitdir:t,ref:n}){if(n=n.startsWith(`refs/heads/`)?n:`refs/heads/${n}`,!await X.exists({fs:e,gitdir:t,ref:n}))throw new J(n);let r=await X.expand({fs:e,gitdir:t,ref:n});if(r===await ea({fs:e,gitdir:t,fullname:!0})){let n=await X.resolve({fs:e,gitdir:t,ref:r});await X.writeRef({fs:e,gitdir:t,ref:`HEAD`,value:n})}await X.deleteRef({fs:e,gitdir:t,ref:r});let i=$i(n),a=await tn.get({fs:e,gitdir:t});await a.deleteSection(`branch`,i),await tn.save({fs:e,gitdir:t,config:a})}async function Ba({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`ref`,r);let t=new Z(e);return await za({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteBranch`,e}}async function Va({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`ref`,r);let t=new Z(e),i=await $({fsp:t,dotgit:n});await X.deleteRef({fs:t,gitdir:i,ref:r})}catch(e){throw e.caller=`git.deleteRef`,e}}async function Ha({fs:e,gitdir:t,remote:n}){let r=await tn.get({fs:e,gitdir:t});await r.deleteSection(`remote`,n),await tn.save({fs:e,gitdir:t,config:r})}async function Ua({fs:e,dir:t,gitdir:n=Y(t,`.git`),remote:r}){try{Q(`fs`,e),Q(`remote`,r);let t=new Z(e);return await Ha({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r})}catch(e){throw e.caller=`git.deleteRemote`,e}}async function Wa({fs:e,gitdir:t,ref:n}){n=n.startsWith(`refs/tags/`)?n:`refs/tags/${n}`,await X.deleteRef({fs:e,gitdir:t,ref:n})}async function Ga({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`ref`,r);let t=new Z(e);return await Wa({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteTag`,e}}async function Ka({fs:e,gitdir:t,oid:n}){let r=n.slice(0,2);return(await e.readdir(`${t}/objects/${r}`)).map(e=>`${r}${e}`).filter(e=>e.startsWith(n))}async function qa({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=[],o=await e.readdir(Y(n,`objects/pack`));o=o.filter(e=>e.endsWith(`.idx`));for(let s of o){let o=await Fn({fs:e,cache:t,filename:`${n}/objects/pack/${s}`,getExternalRefDelta:i});if(o.error)throw new q(o.error);for(let e of o.offsets.keys())e.startsWith(r)&&a.push(e)}return a}async function Ja({fs:e,cache:t,gitdir:n,oid:r}){let i=r=>Bn({fs:e,cache:t,gitdir:n,oid:r}),a=await Ka({fs:e,gitdir:n,oid:r}),o=await qa({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i});for(let e of o)a.indexOf(e)===-1&&a.push(e);if(a.length===1)return a[0];throw a.length>1?new Hn(`oids`,r,a):new J(`an object matching "${r}"`)}async function Ya({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await Ja({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.expandOid`,e}}async function Xa({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e),i=await $({fsp:t,dotgit:n});return await X.expand({fs:t,gitdir:i,ref:r})}catch(e){throw e.caller=`git.expandRef`,e}}async function Za({fs:e,cache:t,gitdir:n,oids:r}){let i={},a=r.length,o=new Set,s=new Map,c=await Sa.read({fs:e,gitdir:n}),l=async r=>{if(s.has(r))return s.get(r);let{object:i,type:a}=await Bn({fs:e,cache:t,gitdir:n,oid:r});if(a!==`commit`)throw new Tt(r,a,`commit`);let{parent:o}=Dr.from(i).parseHeaders(),l=c.has(r)?[]:o;return s.set(r,l),l},u=r.map((e,t)=>({index:t,oid:e}));for(;u.length;){for(let{oid:e,index:t}of u)await l(e),i[e]||(i[e]=new Set),i[e].add(t),i[e].size===a&&o.add(e);let e=new Map;for(let{oid:t,index:n}of u)if(!o.has(t))for(let r of await l(t))i[r]&&i[r].has(n)||e.set(r+`:`+n,{oid:r,index:n});u=Array.from(e.values())}if(o.size<2)return[...o];let d=new Set;for(let e of o){let t=[...await l(e)],n=new Set;for(;t.length;){let e=t.pop();n.has(e)||(n.add(e),o.has(e)?d.add(e):t.push(...await l(e)))}}return[...o].filter(e=>!d.has(e))}async function Qa({fs:e,cache:t,dir:n,gitdir:r,ours:i,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:c=!1,noUpdateBranch:l=!1,abortOnConflict:u=!0,message:d,author:f,committer:p,signingKey:m,onSign:h,mergeDriver:g,allowUnrelatedHistories:_=!1}){i===void 0&&(i=await ea({fs:e,gitdir:r,fullname:!0})),i=await X.expand({fs:e,gitdir:r,ref:i}),a=await X.expand({fs:e,gitdir:r,ref:a});let v=await X.resolve({fs:e,gitdir:r,ref:i}),{oid:y}=await mi({fs:e,cache:t,gitdir:r,oid:await X.resolve({fs:e,gitdir:r,ref:a})}),b=await Za({fs:e,cache:t,gitdir:r,oids:[v,y]});if(b.length!==1){if(b.length===0&&_)b.push(`4b825dc642cb6eb9a060e54bf8d69288fbee4904`);else throw new tr}let x=b[0];if(x===y)return{oid:v,alreadyMerged:!0};if(o&&x===v)return!c&&!l&&await X.writeRef({fs:e,gitdir:r,ref:i,value:y}),{oid:y,fastForward:!0};{if(s)throw new Xn;let o=await _t.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async o=>Hi({fs:e,cache:t,dir:n,gitdir:r,index:o,ourOid:v,theirOid:y,baseOid:x,ourName:$i(i),baseName:`base`,theirName:$i(a),dryRun:c,abortOnConflict:u,mergeDriver:g}));if(o instanceof nr)throw o;return d||=`Merge branch '${$i(a)}' into ${$i(i)}`,{oid:await _i({fs:e,cache:t,gitdir:r,message:d,ref:i,tree:o,parent:[v,y],author:f,committer:p,signingKey:m,onSign:h,dryRun:c,noUpdateBranch:l}),tree:o,mergeCommit:!0}}}async function $a({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,dir:c,gitdir:l,ref:u,url:d,remote:f,remoteRef:p,prune:m,pruneTags:h,fastForward:g,fastForwardOnly:_,corsProxy:v,singleBranch:y,headers:b,author:x,committer:S,signingKey:C}){try{if(!u){let t=await ea({fs:e,gitdir:l});if(!t)throw new ir(`ref`);u=t}let{fetchHead:w,fetchHeadDescription:T}=await Na({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:l,corsProxy:v,ref:u,url:d,remote:f,remoteRef:p,singleBranch:y,headers:b,prune:m,pruneTags:h});await Qa({fs:e,cache:t,gitdir:l,ours:u,theirs:w,fastForward:g,fastForwardOnly:_,message:`Merge ${T}`,author:x,committer:S,signingKey:C,dryRun:!1,noUpdateBranch:!1}),await Pi({fs:e,cache:t,onProgress:r,dir:c,gitdir:l,ref:u,remote:f,noCheckout:!1})}catch(e){throw e.caller=`git.pull`,e}}async function eo({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=Y(s,`.git`),ref:l,url:u,remote:d,remoteRef:f,corsProxy:p,singleBranch:m,headers:h={},cache:g={}}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,c);let _={name:``,email:``,timestamp:Date.now(),timezoneOffset:0},v=new Z(e);return await $a({fs:v,cache:g,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:await $({fsp:v,dotgit:c}),ref:l,url:u,remote:d,remoteRef:f,fastForwardOnly:!0,corsProxy:p,singleBranch:m,headers:h,author:_,committer:_})}catch(e){throw e.caller=`git.fastForward`,e}}async function to({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=Y(s,`.git`),ref:l,remote:u,remoteRef:d,url:f,corsProxy:p,depth:m=null,since:h=null,exclude:g=[],relative:_=!1,tags:v=!1,singleBranch:y=!1,headers:b={},prune:x=!1,pruneTags:S=!1,cache:C={}}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,c);let s=new Z(e);return await Na({fs:s,cache:C,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,gitdir:await $({fsp:s,dotgit:c}),ref:l,remote:u,remoteRef:d,url:f,corsProxy:p,depth:m,since:h,exclude:g,relative:_,tags:v,singleBranch:y,headers:b,prune:x,pruneTags:S})}catch(e){throw e.caller=`git.fetch`,e}}async function no({fs:e,dir:t,gitdir:n=Y(t,`.git`),oids:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oids`,r);let t=new Z(e);return await Za({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oids:r})}catch(e){throw e.caller=`git.findMergeBase`,e}}async function ro({fs:e,filepath:t}){if(await e.exists(Y(t,`.git`)))return t;{let n=yt(t);if(n===t)throw new J(`git root for ${t}`);return ro({fs:e,filepath:n})}}async function io({fs:e,filepath:t}){try{return Q(`fs`,e),Q(`filepath`,t),await ro({fs:new Z(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function ao({fs:e,dir:t,gitdir:n=Y(t,`.git`),path:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`path`,r);let t=new Z(e);return await ui({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfig`,e}}async function oo({fs:e,gitdir:t,path:n}){return(await tn.get({fs:e,gitdir:t})).getall(n)}async function so({fs:e,dir:t,gitdir:n=Y(t,`.git`),path:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`path`,r);let t=new Z(e);return await oo({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfigAll`,e}}function co(e,t,n){let r=t.split(`/`),i=r.pop();if(i===`__proto__`||r.includes(`__proto__`))return;let a=e;for(let e of r)Object.prototype.hasOwnProperty.call(a,e)||(a[e]={}),a=a[e];a[i]=n}async function lo({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1}){try{Q(`http`,e),Q(`url`,a);let c=await ya.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:1}),l={capabilities:[...c.capabilities]};for(let[e,t]of c.refs)co(l,e,t);for(let[e,t]of c.symrefs)co(l,e,t);return l}catch(e){throw e.caller=`git.getRemoteInfo`,e}}function uo(e,t,n,r){let i=[];for(let[a,o]of e.refs){if(t&&!a.startsWith(t))continue;if(a.endsWith(`^{}`)){if(r){let e=a.replace(`^{}`,``),t=i[i.length-1],n=t?.ref===e?t:i.find(t=>t.ref===e);n!==void 0&&(n.peeled=o)}continue}let s={ref:a,oid:o};n&&e.symrefs.has(a)&&(s.target=e.symrefs.get(a)),i.push(s)}return i}async function fo({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1,protocolVersion:c=2}){try{Q(`http`,e),Q(`url`,a);let l=await ya.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:c});if(l.protocolVersion===2)return{protocolVersion:l.protocolVersion,capabilities:l.capabilities2};let u={};for(let e of l.capabilities){let[t,n]=e.split(`=`);u[t]=n||!0}return{protocolVersion:1,capabilities:u,refs:uo(l,void 0,!0,!0)}}catch(e){throw e.caller=`git.getRemoteInfo2`,e}}async function po({type:e,object:t,format:n=`content`,oid:r=void 0}){return n!==`deflated`&&(n!==`wrapped`&&(t=pn.wrap({type:e,object:t})),r=await nt(t)),{oid:r,object:t}}async function mo({object:e}){try{Q(`object`,e),typeof e==`string`?e=Buffer.from(e,`utf8`):e instanceof Uint8Array||(e=new Uint8Array(e));let t=`blob`,{oid:n,object:r}=await po({type:t,format:`content`,object:e});return{oid:n,type:t,object:r,format:`wrapped`}}catch(e){throw e.caller=`git.hashBlob`,e}}async function ho({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,filepath:a}){try{a=Y(r,a);let o=await e.read(a),s=await Mn.fromPack({pack:o,getExternalRefDelta:n=>Bn({fs:e,cache:t,gitdir:i,oid:n}),onProgress:n});return await e.write(a.replace(/\.pack$/,`.idx`),await s.toBuffer()),{oids:[...s.hashes]}}catch(e){throw e.caller=`git.indexPack`,e}}async function go({fs:e,onProgress:t,dir:n,gitdir:r=Y(n,`.git`),filepath:i,cache:a={}}){try{Q(`fs`,e),Q(`dir`,n),Q(`gitdir`,n),Q(`filepath`,i);let o=new Z(e);return await ho({fs:o,cache:a,onProgress:t,dir:n,gitdir:await $({fsp:o,dotgit:r}),filepath:i})}catch(e){throw e.caller=`git.indexPack`,e}}async function _o({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:Y(n,`.git`),defaultBranch:i=`master`}){try{Q(`fs`,e),Q(`gitdir`,r),t||Q(`dir`,n);let a=new Z(e);return await Pa({fs:a,bare:t,dir:n,gitdir:await $({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function vo({fs:e,cache:t,gitdir:n,oid:r,ancestor:i,depth:a}){let o=await Sa.read({fs:e,gitdir:n});if(!r)throw new ir(`oid`);if(!i)throw new ir(`ancestor`);if(r===i)return!1;let s=[r],c=new Set,l=0;for(;s.length;){if(l++===a)throw new er(a);let r=s.shift(),{type:u,object:d}=await Bn({fs:e,cache:t,gitdir:n,oid:r});if(u!==`commit`)throw new Tt(r,u,`commit`);let f=Dr.from(d).parse();for(let e of f.parent)if(e===i)return!0;if(!o.has(r))for(let e of f.parent)c.has(e)||(s.push(e),c.add(e))}return!1}async function yo({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,ancestor:i,depth:a=-1,cache:o={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r),Q(`ancestor`,i);let t=new Z(e);return await vo({fs:t,cache:o,gitdir:await $({fsp:t,dotgit:n}),oid:r,ancestor:i,depth:a})}catch(e){throw e.caller=`git.isDescendent`,e}}async function bo({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r}){try{Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n),Q(`filepath`,r);let i=new Z(e),a=await $({fsp:i,dotgit:n});return Xr.isIgnored({fs:i,dir:t,gitdir:a,filepath:r})}catch(e){throw e.caller=`git.isIgnored`,e}}async function xo({fs:e,dir:t,gitdir:n=Y(t,`.git`),remote:r}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e),i=await $({fsp:t,dotgit:n});return X.listBranches({fs:t,gitdir:i,remote:r})}catch(e){throw e.caller=`git.listBranches`,e}}async function So({fs:e,gitdir:t,ref:n,cache:r}){if(n){let i=await X.resolve({gitdir:t,fs:e,ref:n}),a=[];return await Co({fs:e,cache:r,gitdir:t,oid:i,filenames:a,prefix:``}),a}return _t.acquire({fs:e,gitdir:t,cache:r},async function(e){return e.entries.map(e=>e.path)})}async function Co({fs:e,cache:t,gitdir:n,oid:r,filenames:i,prefix:a}){let{tree:o}=await Si({fs:e,cache:t,gitdir:n,oid:r});for(let r of o)r.type===`tree`?await Co({fs:e,cache:t,gitdir:n,oid:r.oid,filenames:i,prefix:Y(a,r.path)}):i.push(Y(a,r.path))}async function wo({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await So({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listFiles`,e}}async function To({fs:e,cache:t,gitdir:n,ref:r}){let i;try{i=await X.resolve({gitdir:n,fs:e,ref:r})}catch(e){if(e instanceof J)return[];throw e}return(await Si({fs:e,cache:t,gitdir:n,oid:i})).tree.map(e=>({target:e.path,note:e.oid}))}async function Eo({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r=`refs/notes/commits`,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e);return await To({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listNotes`,e}}async function Do({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e),i=await $({fsp:t,dotgit:n});return X.listRefs({fs:t,gitdir:i,filepath:r})}catch(e){throw e.caller=`git.listRefs`,e}}async function Oo({fs:e,gitdir:t}){let n=await tn.get({fs:e,gitdir:t}),r=await n.getSubsections(`remote`);return Promise.all(r.map(async e=>({remote:e,url:await n.get(`remote.${e}.url`)})))}async function ko({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await Oo({fs:t,gitdir:await $({fsp:t,dotgit:n})})}catch(e){throw e.caller=`git.listRemotes`,e}}async function Ao(e){let t=da.streamReader(e),n=[],r;for(;r=await t(),r!==!0;){if(r===null)continue;r=r.toString(`utf8`).replace(/\n$/,``);let[e,t,...i]=r.split(` `),a={ref:t,oid:e};for(let e of i){let[t,n]=e.split(`:`);t===`symref-target`?a.target=n:t===`peeled`&&(a.peeled=n)}n.push(a)}return n}async function jo({prefix:e,symrefs:t,peelTags:n}){let r=[];return r.push(da.encode(`command=ls-refs
65
+ `)),r.push(da.encode(`agent=${Ea.agent}\n`)),(n||t||e)&&r.push(da.delim()),n&&r.push(da.encode(`peel`)),t&&r.push(da.encode(`symrefs`)),e&&r.push(da.encode(`ref-prefix ${e}`)),r.push(da.flush()),r}async function Mo({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1,protocolVersion:c=2,prefix:l,symrefs:u,peelTags:d}){try{Q(`http`,e),Q(`url`,a);let f=await va.discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:c});if(f.protocolVersion===1)return uo(f,l,u,d);let p=await jo({prefix:l,symrefs:u,peelTags:d});return Ao((await va.connect({http:e,auth:f.auth,headers:o,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,body:p})).body)}catch(e){throw e.caller=`git.listServerRefs`,e}}async function No({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e),r=await $({fsp:t,dotgit:n});return X.listTags({fs:t,gitdir:r})}catch(e){throw e.caller=`git.listTags`,e}}function Po(e,t){return e.committer.timestamp-t.committer.timestamp}var Fo=`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`;async function Io({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===Fo)return;let a=r,o,s=await Or({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await Lo({fs:e,cache:t,gitdir:n,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Lo({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:o=[],parentPath:s=``}){let c=r.entries().map(function(r){let c;return r.oid===i?(c=Y(s,r.path),o.push(c)):r.type===`tree`&&(c=Bn({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return Lo({fs:e,cache:t,gitdir:n,tree:fn.from(c),fileId:i,oid:a,filepaths:o,parentPath:Y(s,r.path)})})),c});return await Promise.all(c),o}async function Ro({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u}){let d=o===void 0?void 0:Math.floor(o.valueOf()/1e3),f=s==null?void 0:new RegExp(s,`i`),p=({commit:e})=>f===void 0?!0:e.author?f.test(`${e.author.name} <${e.author.email}>`):!1,m=[],h=e=>{p(e)&&m.push(e)},g=await Sa.read({fs:e,gitdir:n}),_=[await hi({fs:e,cache:t,gitdir:n,oid:await X.resolve({fs:e,gitdir:n,ref:i})})],v,y,b,x;function S(e){x&&r&&h(e)}for(;_.length>0;){let i=_.pop();if(d!==void 0&&i.commit.committer.timestamp<=d)break;if(r){let a;try{a=await bi({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),b&&(v!==a.oid||y!==a.mode)&&h(b),v=a.oid,y=a.mode,b=i,x=!0}catch(a){if(a instanceof J){let o=l&&v;if(o&&(o=await Io({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:v}),o)){if(Array.isArray(o)){if(b){let i=await Io({fs:e,cache:t,gitdir:n,oid:b.commit.tree,fileId:v});if(Array.isArray(i)){if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,b&&h(b);else{o=!1,b&&h(b);break}}}}else r=o,b&&h(b)}if(!o){if(x&&v&&(h(b),!c))break;if(!c&&!l)throw a}b=i,x=!1}else throw a}}else h(i);if(a!==void 0&&m.length===a){S(i);break}if(!g.has(i.oid))for(let r of i.commit.parent){let i=await hi({fs:e,cache:t,gitdir:n,oid:r});_.map(e=>e.oid).includes(i.oid)||_.push(i)}_.length===0&&S(i),_.sort((e,t)=>Po(e.commit,t.commit))}if(u)for(let r of m)r.commit.changes=await zo({fs:e,cache:t,gitdir:n,commit:r,shallow:g.has(r.oid)});return m}async function zo({fs:e,cache:t,gitdir:n,commit:r,shallow:i}){let a=i||!r.commit.parent[0]?`4b825dc642cb6eb9a060e54bf8d69288fbee4904`:r.commit.parent[0];return Lr({fs:e,cache:t,gitdir:n,trees:[Ar({ref:r.oid}),Ar({ref:a})],map:async(e,[t,n])=>{let[r,i]=await Promise.all([t&&t.type(),n&&n.type()]);if(r===`tree`)return i&&i!==`tree`?[null,await n.oid(),e]:void 0;if(i===`tree`)return r?[await t.oid(),null,e]:void 0;let[a,o]=await Promise.all([t?t.oid():null,n?n.oid():null]);if(a!==o)return[a,o,e]}})}async function Bo({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u=!1,cache:d={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,i);let t=new Z(e);return await Ro({fs:t,cache:d,gitdir:await $({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,author:s,force:c,follow:l,includeChanges:u})}catch(e){throw e.caller=`git.log`,e}}async function Vo({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ours:i,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:c=!1,noUpdateBranch:l=!1,abortOnConflict:u=!0,message:d,author:f,committer:p,signingKey:m,cache:h={},mergeDriver:g,allowUnrelatedHistories:_=!1}){try{Q(`fs`,e),m&&Q(`onSign`,t);let v=new Z(e),y=await $({fsp:v,dotgit:r}),b=await fi({fs:v,gitdir:y,author:f});if(!b&&(!s||!o))throw new rr(`author`);let x=await pi({fs:v,gitdir:y,author:b,committer:p});if(!x&&(!s||!o))throw new rr(`committer`);return await Qa({fs:v,cache:h,dir:n,gitdir:y,ours:i,theirs:a,fastForward:o,fastForwardOnly:s,dryRun:c,noUpdateBranch:l,abortOnConflict:u,message:d,author:b,committer:x,signingKey:m,onSign:t,mergeDriver:g,allowUnrelatedHistories:_})}catch(e){throw e.caller=`git.merge`,e}}var Ho={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function Uo({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),oids:i}){let a=new Fe.default,o=[];function s(e,t){let n=Buffer.from(e,t);o.push(n),a.update(n)}async function c({stype:e,object:t}){let n=Ho[e],r=t.length,i=r>15?128:0,a=r&15;r>>>=4;let o=(i|n|a).toString(16);for(s(o,`hex`);i;)i=r>127?128:0,o=i|r&127,s(ua(2,o),`hex`),r>>>=7;s(Buffer.from(await $r(t)))}s(`PACK`),s(`00000002`,`hex`),s(ua(8,i.length),`hex`);for(let n of i){let{type:i,object:a}=await Bn({fs:e,cache:t,gitdir:r,oid:n});await c({write:s,object:a,stype:i})}let l=a.digest();return o.push(l),o}async function Wo({fs:e,cache:t,gitdir:n,oids:r,write:i}){let a=await Uo({fs:e,cache:t,gitdir:n,oids:r}),o=Buffer.from(await ia(a)),s=`pack-${o.slice(-20).toString(`hex`)}.pack`;return i?(await e.write(Y(n,`objects/pack/${s}`),o),{filename:s}):{filename:s,packfile:new Uint8Array(o)}}async function Go({fs:e,dir:t,gitdir:n=Y(t,`.git`),oids:r,write:i=!1,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oids`,r);let t=new Z(e);return await Wo({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oids:r,write:i})}catch(e){throw e.caller=`git.packObjects`,e}}async function Ko({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=Y(s,`.git`),ref:l,url:u,remote:d,remoteRef:f,prune:p=!1,pruneTags:m=!1,fastForward:h=!0,fastForwardOnly:g=!1,corsProxy:_,singleBranch:v,headers:y={},author:b,committer:x,signingKey:S,cache:C={}}){try{Q(`fs`,e),Q(`gitdir`,c);let w=new Z(e),T=await $({fsp:w,dotgit:c}),E=await fi({fs:w,gitdir:T,author:b});if(!E)throw new rr(`author`);let ee=await pi({fs:w,gitdir:T,author:E,committer:x});if(!ee)throw new rr(`committer`);return await $a({fs:w,cache:C,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:T,ref:l,url:u,remote:d,remoteRef:f,fastForward:h,fastForwardOnly:g,corsProxy:_,singleBranch:v,headers:y,author:E,committer:ee,signingKey:S,prune:p,pruneTags:m})}catch(e){throw e.caller=`git.pull`,e}}async function qo({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),start:i,finish:a}){let o=await Sa.read({fs:e,gitdir:r}),s=new Set,c=new Set;for(let t of i)s.add(await X.resolve({fs:e,gitdir:r,ref:t}));for(let t of a)try{let n=await X.resolve({fs:e,gitdir:r,ref:t});c.add(n)}catch{}let l=new Set;async function u(n){l.add(n);let{type:i,object:a}=await Bn({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=wr.from(a).headers().object;return u(e)}if(i!==`commit`)throw new Tt(n,i,`commit`);if(!o.has(n))for(n of Dr.from(a).headers().parent)!c.has(n)&&!l.has(n)&&await u(n)}for(let e of s)await u(e);return l}async function Jo({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),oids:i}){let a=new Set;async function o(n){if(a.has(n))return;a.add(n);let{type:i,object:s}=await Bn({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=wr.from(s).headers().object;await o(e)}else if(i===`commit`){let e=Dr.from(s).headers().tree;await o(e)}else if(i===`tree`){let e=fn.from(s);for(let t of e)t.type===`blob`&&a.add(t.oid),t.type===`tree`&&await o(t.oid)}}for(let e of i)await o(e);return a}async function Yo(e){let t={},n=``,r=da.streamReader(e),i=await r();for(;i!==!0;)i!==null&&(n+=i.toString(`utf8`)+`
64
66
  `),i=await r();let a=n.toString(`utf8`).split(`
65
- `);if(i=a.shift(),!i.startsWith(`unpack `))throw new sr(`unpack ok" or "unpack [error message]`,i);t.ok=i===`unpack ok`,t.ok||(t.error=i.slice(7)),t.refs={};for(let e of a){if(e.trim()===``)continue;let n=e.slice(0,2),r=e.slice(3),i=r.indexOf(` `);i===-1&&(i=r.length);let a=r.slice(0,i),o=r.slice(i+1);t.refs[a]={ok:n===`ok`,error:o}}return t}async function Zo({capabilities:e=[],triplets:t=[]}){let n=[],r=`\x00 ${e.join(` `)}`;for(let e of t)n.push(fa.encode(`${e.oldoid} ${e.oid} ${e.fullRef}${r}\n`)),r=``;return n.push(fa.flush()),n}async function Qo({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPrePush:c,gitdir:l,ref:u,remoteRef:d,remote:f,url:p,force:m=!1,delete:h=!1,corsProxy:g,headers:_={},signal:v}){let y=u||await ta({fs:e,gitdir:l});if(y===void 0)throw new ar(`ref`);let b=await nn.get({fs:e,gitdir:l});f=f||await b.get(`branch.${y}.pushRemote`)||await b.get(`remote.pushDefault`)||await b.get(`branch.${y}.remote`)||`origin`;let x=p||await b.get(`remote.${f}.pushurl`)||await b.get(`remote.${f}.url`);if(x===void 0)throw new ar(`remote OR url`);let S=d||await b.get(`branch.${y}.merge`);if(x===void 0)throw new ar(`remoteRef`);g===void 0&&(g=await b.get(`http.corsProxy`));let C=await X.expand({fs:e,gitdir:l,ref:y}),w=h?`0000000000000000000000000000000000000000`:await X.resolve({fs:e,gitdir:l,ref:C}),T=ba.getRemoteHelperFor({url:x}),E=await T.discover({http:n,onAuth:wa({config:b,onAuth:a}),onAuthSuccess:o,onAuthFailure:wa({config:b,onAuth:s}),corsProxy:g,service:`git-receive-pack`,url:x,headers:_,protocolVersion:1,signal:v}),ee=E.auth,D;if(!S)D=C;else try{D=await X.expandAgainstMap({ref:S,map:E.refs})}catch(e){if(e instanceof J)D=S.startsWith(`refs/`)?S:`refs/heads/${S}`;else throw e}let O=E.refs.get(D)||`0000000000000000000000000000000000000000`;if(c&&!await c({remote:f,url:x,localRef:{ref:h?`(delete)`:C,oid:w},remoteRef:{ref:D,oid:O}}))throw new pr;let k=!E.capabilities.has(`no-thin`),A=new Set;if(!h){let n=[...E.refs.values()],r=new Set;if(O!==`0000000000000000000000000000000000000000`){let i=[];try{i=await Qa({fs:e,cache:t,gitdir:l,oids:[w,O]})}catch{i=[]}for(let e of i)n.push(e);k&&(r=await Yo({fs:e,cache:t,gitdir:l,oids:i}))}if(n.includes(w)||(A=await Yo({fs:e,cache:t,gitdir:l,oids:await Jo({fs:e,cache:t,gitdir:l,start:[w],finish:n})})),k){try{let n=await X.resolve({fs:e,gitdir:l,ref:`refs/remotes/${f}/HEAD`,depth:2}),{oid:i}=await X.resolveAgainstMap({ref:n.replace(`refs/remotes/${f}/`,``),fullref:n,map:E.refs}),a=[i];for(let n of await Yo({fs:e,cache:t,gitdir:l,oids:a}))r.add(n)}catch{}for(let e of r)A.delete(e)}if(w===O&&(m=!0),!m){if(C.startsWith(`refs/tags`)&&O!==`0000000000000000000000000000000000000000`)throw new cr(`tag-exists`);if(w!==`0000000000000000000000000000000000000000`&&O!==`0000000000000000000000000000000000000000`&&!await yo({fs:e,cache:t,gitdir:l,oid:w,ancestor:O,depth:-1}))throw new cr(`not-fast-forward`)}}let j=await Zo({capabilities:Ea([...E.capabilities],[`report-status`,`side-band-64k`,`agent=${Da.agent}`]),triplets:[{oldoid:O,oid:w,fullRef:D}]}),te=h?[]:await Wo({fs:e,cache:t,gitdir:l,oids:[...A]}),M=await T.connect({http:n,onProgress:r,corsProxy:g,service:`git-receive-pack`,url:x,auth:ee,headers:_,body:[...j,...te],signal:v}),{packfile:ne,progress:re}=await ja.demux(M.body);i&&ia(Aa(re),async e=>{await i(e)});let ie=await Xo(ne);if(M.headers&&(ie.headers=M.headers),f&&ie.ok&&ie.refs[D].ok&&!C.startsWith(`refs/tags`)){let t=`refs/remotes/${f}/${D.replace(`refs/heads/`,``)}`;h?await X.deleteRef({fs:e,gitdir:l,ref:t}):await X.writeRef({fs:e,gitdir:l,ref:t,value:w})}if(ie.ok&&Object.values(ie.refs).every(e=>e.ok))return ie;throw new Qn(Object.entries(ie.refs).filter(([e,t])=>!t.ok).map(([e,t])=>`\n - ${e}: ${t.error}`).join(``),ie)}async function $o({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,dir:c,gitdir:l=Y(c,`.git`),ref:u,remoteRef:d,remote:f=`origin`,url:p,force:m=!1,delete:h=!1,corsProxy:g,headers:_={},cache:v={},signal:y}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,l);let c=new Z(e);return await Qo({fs:c,cache:v,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,gitdir:await $({fsp:c,dotgit:l}),ref:u,remoteRef:d,remote:f,url:p,force:m,delete:h,corsProxy:g,headers:_,signal:y})}catch(e){throw e.caller=`git.push`,e}}async function es({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Vn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=Tr.from(a).parse().object,es({fs:e,cache:t,gitdir:n,oid:r});if(i!==`blob`)throw new Tt(r,i,`blob`);return{oid:r,blob:new Uint8Array(a)}}async function ts({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await bi({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await es({fs:e,cache:t,gitdir:n,oid:r})}async function ns({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,filepath:i,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await ts({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readBlob`,e}}async function rs({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await gi({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readCommit`,e}}async function is({fs:e,cache:t,gitdir:n,ref:r=`refs/notes/commits`,oid:i}){let{blob:a}=await ts({fs:e,cache:t,gitdir:n,oid:await X.resolve({gitdir:n,fs:e,ref:r}),filepath:i});return a}async function as({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r=`refs/notes/commits`,oid:i,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r),Q(`oid`,i);let t=new Z(e);return await is({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),ref:r,oid:i})}catch(e){throw e.caller=`git.readNote`,e}}async function os({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,format:i=`parsed`,filepath:a=void 0,encoding:o=void 0,cache:s={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e),c=await $({fsp:t,dotgit:n});a!==void 0&&(r=await bi({fs:t,cache:s,gitdir:c,oid:r,filepath:a}));let l=await Vn({fs:t,cache:s,gitdir:c,oid:r,format:i===`parsed`?`content`:i});if(l.oid=r,i===`parsed`)switch(l.format=`parsed`,l.type){case`commit`:l.object=Or.from(l.object).parse();break;case`tree`:l.object=pn.from(l.object).entries();break;case`blob`:o?l.object=l.object.toString(o):(l.object=new Uint8Array(l.object),l.format=`content`);break;case`tag`:l.object=Tr.from(l.object).parse();break;default:throw new Tt(l.oid,l.type,`blob|commit|tag|tree`)}else(l.format===`deflated`||l.format===`wrapped`)&&(l.type=l.format);return l}catch(e){throw e.caller=`git.readObject`,e}}async function ss({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Vn({fs:e,cache:t,gitdir:n,oid:r,format:`content`});if(i!==`tag`)throw new Tt(r,i,`tag`);let o=Tr.from(a);return{oid:r,tag:o.parse(),payload:o.payload()}}async function cs({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await ss({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readTag`,e}}async function ls({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,filepath:i=void 0,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await Ci({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readTree`,e}}async function us({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,r);let t=new Z(e),a=await $({fsp:t,dotgit:n});await _t.acquire({fs:t,gitdir:a,cache:i},async function(e){let t=Array.isArray(r)?r:[r];for(let n of t)e.delete({filepath:n})})}catch(e){throw e.caller=`git.remove`,e}}async function ds({fs:e,cache:t,onSign:n,gitdir:r,ref:i=`refs/notes/commits`,oid:a,author:o,committer:s,signingKey:c}){let l;try{l=await X.resolve({gitdir:r,fs:e,ref:i})}catch(e){if(!(e instanceof J))throw e}let u=(await Ci({fs:e,cache:t,gitdir:r,oid:l||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;return u=u.filter(e=>e.path!==a),await vi({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:await wi({fs:e,gitdir:r,tree:u}),parent:l&&[l],message:`Note removed by 'isomorphic-git removeNote'
66
- `,author:o,committer:s,signingKey:c})}async function fs({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ref:i=`refs/notes/commits`,oid:a,author:o,committer:s,signingKey:c,cache:l={}}){try{Q(`fs`,e),Q(`gitdir`,r),Q(`oid`,a);let n=new Z(e),u=await $({fsp:n,dotgit:r}),d=await pi({fs:n,gitdir:u,author:o});if(!d)throw new ir(`author`);let f=await mi({fs:n,gitdir:u,author:d,committer:s});if(!f)throw new ir(`committer`);return await ds({fs:n,cache:l,onSign:t,gitdir:u,ref:i,oid:a,author:d,committer:f,signingKey:c})}catch(e){throw e.caller=`git.removeNote`,e}}async function ps({fs:e,gitdir:t,oldref:n,ref:r,checkout:i=!1}){if(!Pt(r,!0))throw new Dt(r,Le.default.clean(r));if(!Pt(n,!0))throw new Dt(n,Le.default.clean(n));let a=`refs/heads/${n}`,o=`refs/heads/${r}`;if(await X.exists({fs:e,gitdir:t,ref:o}))throw new Hn(`branch`,r,!1);let s=await X.resolve({fs:e,gitdir:t,ref:a,depth:1});await X.writeRef({fs:e,gitdir:t,ref:o,value:s}),await X.deleteRef({fs:e,gitdir:t,ref:a});let c=await ta({fs:e,gitdir:t,fullname:!0})===a;(i||c)&&await X.writeSymbolicRef({fs:e,gitdir:t,ref:`HEAD`,value:o})}async function ms({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,oldref:i,checkout:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r),Q(`oldref`,i);let t=new Z(e);return await ps({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r,oldref:i,checkout:a})}catch(e){throw e.caller=`git.renameBranch`,e}}async function hs({gitdir:e,type:t,object:n}){return nt(mn.wrap({type:t,object:n}))}async function gs({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,ref:i,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,r);let o=new Z(e),s=await $({fsp:o,dotgit:n}),c,l;try{c=await X.resolve({fs:o,gitdir:s,ref:i||`HEAD`})}catch(e){if(i||!(e instanceof J))throw e}if(c)try{c=await bi({fs:o,cache:a,gitdir:s,oid:c,filepath:r})}catch(e){if(!(e instanceof J)&&!(e instanceof er)&&!(e instanceof Tt&&e.data.filepath))throw e;c=null}let u={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0},d=t&&await o.read(Y(t,r));d&&(l=await hs({gitdir:s,type:`blob`,object:d}),c===l&&(u=await o.lstat(Y(t,r)))),await _t.acquire({fs:o,gitdir:s,cache:a},async function(e){e.delete({filepath:r}),c&&e.insert({filepath:r,stats:u,oid:c})})}catch(e){throw e.caller=`git.reset`,e}}async function _s({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,depth:i}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e),a=await $({fsp:t,dotgit:n});return await X.resolve({fs:t,gitdir:a,ref:r,depth:i})}catch(e){throw e.caller=`git.resolveRef`,e}}async function vs({fs:e,dir:t,gitdir:n=Y(t,`.git`),path:r,value:i,append:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`path`,r);let t=new Z(e),o=await $({fsp:t,dotgit:n}),s=await nn.get({fs:t,gitdir:o});a?await s.append(r,i):await s.set(r,i),await nn.save({fs:t,gitdir:o,config:s})}catch(e){throw e.caller=`git.setConfig`,e}}async function ys({fs:e,gitdir:t,commit:n}){return await ri({fs:e,gitdir:t,type:`commit`,object:Or.from(n).toObject(),format:`content`})}var bs=class e{static get timezoneOffsetForRefLogEntry(){let e=new Date().getTimezoneOffset(),t=Math.abs(Math.floor(e/60)),n=Math.abs(e%60).toString().padStart(2,`0`);return`${e>0?`-`:`+`}${t.toString().padStart(2,`0`)}${n}`}static createStashReflogEntry(t,n,r){let i=t.name.replace(/\s/g,``),a=Math.floor(Date.now()/1e3),o=e.timezoneOffsetForRefLogEntry;return`0000000000000000000000000000000000000000 ${n} ${i} ${t.email} ${a} ${o}\t${r}\n`}static getStashReflogEntry(e,t=!1){return e.split(`
67
- `).filter(e=>e).reverse().map((e,n)=>t?`stash@{${n}}: ${e.split(` `)[1]}`:e)}},xs=class e{constructor({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){Object.assign(this,{fs:e,dir:t,gitdir:n,_author:null})}static get refStash(){return`refs/stash`}static get refLogsStash(){return`logs/refs/stash`}get refStashPath(){return Y(this.gitdir,e.refStash)}get refLogsStashPath(){return Y(this.gitdir,e.refLogsStash)}async getAuthor(){if(!this._author&&(this._author=await pi({fs:this.fs,gitdir:this.gitdir,author:{}}),!this._author))throw new ir(`author`);return this._author}async getStashSHA(e,t){return await this.fs.exists(this.refStashPath)?(t||await this.readStashReflogs({parsed:!1}))[e].split(` `)[1]:null}async writeStashCommit({message:e,tree:t,parent:n}){return ys({fs:this.fs,gitdir:this.gitdir,commit:{message:e,tree:t,parent:n,author:await this.getAuthor(),committer:await this.getAuthor()}})}async readStashCommit(e){let t=await this.readStashReflogs({parsed:!1});if(e!==0&&(e<0||e>t.length-1))throw new Dt(`stash@${e}`,`number that is in range of [0, num of stash pushed]`);let n=await this.getStashSHA(e,t);return n?gi({fs:this.fs,cache:{},gitdir:this.gitdir,oid:n}):{}}async writeStashRef(t){return X.writeRef({fs:this.fs,gitdir:this.gitdir,ref:e.refStash,value:t})}async writeStashReflogEntry({stashCommit:e,message:t}){let n=await this.getAuthor(),r=bs.createStashReflogEntry(n,e,t),i=this.refLogsStashPath;await ft(i,async()=>{let e=await this.fs.exists(i)?await this.fs.read(i,`utf8`):``;await this.fs.write(i,e+r,`utf8`)})}async readStashReflogs({parsed:e=!1}){if(!await this.fs.exists(this.refLogsStashPath))return[];let t=await this.fs.read(this.refLogsStashPath,`utf8`);return bs.getStashReflogEntry(t,e)}};async function Ss({fs:e,dir:t,gitdir:n,message:r=``}){let i=new xs({fs:e,dir:t,gitdir:n});await i.getAuthor();let a=await ta({fs:e,gitdir:n,fullname:!1}),o=await X.resolve({fs:e,gitdir:n,ref:`HEAD`}),s=(await rs({fs:e,dir:t,gitdir:n,oid:o})).commit.message,c=[o],l=null,u=jr({ref:`HEAD`}),d=await Ji({fs:e,dir:t,gitdir:n,treePair:[jr({ref:`HEAD`}),`stage`]});if(d){let e=await i.writeStashCommit({message:`stash-Index: WIP on ${a} - ${new Date().toISOString()}`,tree:d,parent:c});c.push(e),l=d,u=wt()}let f=await Ji({fs:e,dir:t,gitdir:n,treePair:[u,`workdir`]});if(f){let e=await i.writeStashCommit({message:`stash-WorkDir: WIP on ${a} - ${new Date().toISOString()}`,tree:f,parent:[c[c.length-1]]});c.push(e),l=f}if(!l||!d&&!f)throw new J(`changes, nothing to stash`);let p=(r.trim()||`WIP on ${a}`)+`: ${o.substring(0,7)} ${s}`;return{stashCommit:await i.writeStashCommit({message:p,tree:l,parent:c}),stashMsg:p,branch:a,stashMgr:i}}async function Cs({fs:e,dir:t,gitdir:n,message:r=``}){let{stashCommit:i,stashMsg:a,branch:o,stashMgr:s}=await Ss({fs:e,dir:t,gitdir:n,message:r});return await s.writeStashRef(i),await s.writeStashReflogEntry({stashCommit:i,message:a}),await Bi({fs:e,dir:t,gitdir:n,ref:o,track:!1,force:!0}),i}async function ws({fs:e,dir:t,gitdir:n,message:r=``}){let{stashCommit:i}=await Ss({fs:e,dir:t,gitdir:n,message:r});return i}async function Ts({fs:e,dir:t,gitdir:n,refIdx:r=0}){let i=await new xs({fs:e,dir:t,gitdir:n}).readStashCommit(r),{parent:a=null}=i.commit?i.commit:{};if(a&&Array.isArray(a))for(let r=0;r<a.length-1;r++){let i=(await gi({fs:e,cache:{},gitdir:n,oid:a[r+1]})).commit.message.startsWith(`stash-Index`);await Yi({fs:e,dir:t,gitdir:n,stashCommit:a[r+1],parentCommit:a[r],wasStaged:i})}}async function Es({fs:e,dir:t,gitdir:n,refIdx:r=0}){let i=new xs({fs:e,dir:t,gitdir:n});if(!(await i.readStashCommit(r)).commit)return;let a=i.refStashPath;await ft(a,async()=>{await e.exists(a)&&await e.rm(a)});let o=await i.readStashReflogs({parsed:!1});if(!o.length)return;o.splice(r,1);let s=i.refLogsStashPath;await ft(s,async()=>{if(o.length){await e.write(s,o.reverse().join(`
67
+ `);if(i=a.shift(),!i.startsWith(`unpack `))throw new or(`unpack ok" or "unpack [error message]`,i);t.ok=i===`unpack ok`,t.ok||(t.error=i.slice(7)),t.refs={};for(let e of a){if(e.trim()===``)continue;let n=e.slice(0,2),r=e.slice(3),i=r.indexOf(` `);i===-1&&(i=r.length);let a=r.slice(0,i),o=r.slice(i+1);t.refs[a]={ok:n===`ok`,error:o}}return t}async function Xo({capabilities:e=[],triplets:t=[]}){let n=[],r=`\x00 ${e.join(` `)}`;for(let e of t)n.push(da.encode(`${e.oldoid} ${e.oid} ${e.fullRef}${r}\n`)),r=``;return n.push(da.flush()),n}async function Zo({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPrePush:c,gitdir:l,ref:u,remoteRef:d,remote:f,url:p,force:m=!1,delete:h=!1,corsProxy:g,headers:_={},signal:v}){let y=u||await ea({fs:e,gitdir:l});if(y===void 0)throw new ir(`ref`);let b=await tn.get({fs:e,gitdir:l});f=f||await b.get(`branch.${y}.pushRemote`)||await b.get(`remote.pushDefault`)||await b.get(`branch.${y}.remote`)||`origin`;let x=p||await b.get(`remote.${f}.pushurl`)||await b.get(`remote.${f}.url`);if(x===void 0)throw new ir(`remote OR url`);let S=d||await b.get(`branch.${y}.merge`);if(x===void 0)throw new ir(`remoteRef`);g===void 0&&(g=await b.get(`http.corsProxy`));let C=await X.expand({fs:e,gitdir:l,ref:y}),w=h?`0000000000000000000000000000000000000000`:await X.resolve({fs:e,gitdir:l,ref:C}),T=ya.getRemoteHelperFor({url:x}),E=await T.discover({http:n,onAuth:Ca({config:b,onAuth:a}),onAuthSuccess:o,onAuthFailure:Ca({config:b,onAuth:s}),corsProxy:g,service:`git-receive-pack`,url:x,headers:_,protocolVersion:1,signal:v}),ee=E.auth,D;if(!S)D=C;else try{D=await X.expandAgainstMap({ref:S,map:E.refs})}catch(e){if(e instanceof J)D=S.startsWith(`refs/`)?S:`refs/heads/${S}`;else throw e}let O=E.refs.get(D)||`0000000000000000000000000000000000000000`;if(c&&!await c({remote:f,url:x,localRef:{ref:h?`(delete)`:C,oid:w},remoteRef:{ref:D,oid:O}}))throw new fr;let k=!E.capabilities.has(`no-thin`),A=new Set;if(!h){let n=[...E.refs.values()],r=new Set;if(O!==`0000000000000000000000000000000000000000`){let i=[];try{i=await Za({fs:e,cache:t,gitdir:l,oids:[w,O]})}catch{i=[]}for(let e of i)n.push(e);k&&(r=await Jo({fs:e,cache:t,gitdir:l,oids:i}))}if(n.includes(w)||(A=await Jo({fs:e,cache:t,gitdir:l,oids:await qo({fs:e,cache:t,gitdir:l,start:[w],finish:n})})),k){try{let n=await X.resolve({fs:e,gitdir:l,ref:`refs/remotes/${f}/HEAD`,depth:2}),{oid:i}=await X.resolveAgainstMap({ref:n.replace(`refs/remotes/${f}/`,``),fullref:n,map:E.refs}),a=[i];for(let n of await Jo({fs:e,cache:t,gitdir:l,oids:a}))r.add(n)}catch{}for(let e of r)A.delete(e)}if(w===O&&(m=!0),!m){if(C.startsWith(`refs/tags`)&&O!==`0000000000000000000000000000000000000000`)throw new sr(`tag-exists`);if(w!==`0000000000000000000000000000000000000000`&&O!==`0000000000000000000000000000000000000000`&&!await vo({fs:e,cache:t,gitdir:l,oid:w,ancestor:O,depth:-1}))throw new sr(`not-fast-forward`)}}let j=await Xo({capabilities:Ta([...E.capabilities],[`report-status`,`side-band-64k`,`agent=${Ea.agent}`]),triplets:[{oldoid:O,oid:w,fullRef:D}]}),te=h?[]:await Uo({fs:e,cache:t,gitdir:l,oids:[...A]}),M=await T.connect({http:n,onProgress:r,corsProxy:g,service:`git-receive-pack`,url:x,auth:ee,headers:_,body:[...j,...te],signal:v}),{packfile:ne,progress:re}=await Aa.demux(M.body);i&&ra(ka(re),async e=>{await i(e)});let ie=await Yo(ne);if(M.headers&&(ie.headers=M.headers),f&&ie.ok&&ie.refs[D].ok&&!C.startsWith(`refs/tags`)){let t=`refs/remotes/${f}/${D.replace(`refs/heads/`,``)}`;h?await X.deleteRef({fs:e,gitdir:l,ref:t}):await X.writeRef({fs:e,gitdir:l,ref:t,value:w})}if(ie.ok&&Object.values(ie.refs).every(e=>e.ok))return ie;throw new Zn(Object.entries(ie.refs).filter(([e,t])=>!t.ok).map(([e,t])=>`\n - ${e}: ${t.error}`).join(``),ie)}async function Qo({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,dir:c,gitdir:l=Y(c,`.git`),ref:u,remoteRef:d,remote:f=`origin`,url:p,force:m=!1,delete:h=!1,corsProxy:g,headers:_={},cache:v={},signal:y}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,l);let c=new Z(e);return await Zo({fs:c,cache:v,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,gitdir:await $({fsp:c,dotgit:l}),ref:u,remoteRef:d,remote:f,url:p,force:m,delete:h,corsProxy:g,headers:_,signal:y})}catch(e){throw e.caller=`git.push`,e}}async function $o({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Bn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=wr.from(a).parse().object,$o({fs:e,cache:t,gitdir:n,oid:r});if(i!==`blob`)throw new Tt(r,i,`blob`);return{oid:r,blob:new Uint8Array(a)}}async function es({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await yi({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await $o({fs:e,cache:t,gitdir:n,oid:r})}async function ts({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,filepath:i,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await es({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readBlob`,e}}async function ns({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await hi({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readCommit`,e}}async function rs({fs:e,cache:t,gitdir:n,ref:r=`refs/notes/commits`,oid:i}){let{blob:a}=await es({fs:e,cache:t,gitdir:n,oid:await X.resolve({gitdir:n,fs:e,ref:r}),filepath:i});return a}async function is({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r=`refs/notes/commits`,oid:i,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r),Q(`oid`,i);let t=new Z(e);return await rs({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),ref:r,oid:i})}catch(e){throw e.caller=`git.readNote`,e}}async function as({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,format:i=`parsed`,filepath:a=void 0,encoding:o=void 0,cache:s={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e),c=await $({fsp:t,dotgit:n});a!==void 0&&(r=await yi({fs:t,cache:s,gitdir:c,oid:r,filepath:a}));let l=await Bn({fs:t,cache:s,gitdir:c,oid:r,format:i===`parsed`?`content`:i});if(l.oid=r,i===`parsed`)switch(l.format=`parsed`,l.type){case`commit`:l.object=Dr.from(l.object).parse();break;case`tree`:l.object=fn.from(l.object).entries();break;case`blob`:o?l.object=l.object.toString(o):(l.object=new Uint8Array(l.object),l.format=`content`);break;case`tag`:l.object=wr.from(l.object).parse();break;default:throw new Tt(l.oid,l.type,`blob|commit|tag|tree`)}else(l.format===`deflated`||l.format===`wrapped`)&&(l.type=l.format);return l}catch(e){throw e.caller=`git.readObject`,e}}async function os({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Bn({fs:e,cache:t,gitdir:n,oid:r,format:`content`});if(i!==`tag`)throw new Tt(r,i,`tag`);let o=wr.from(a);return{oid:r,tag:o.parse(),payload:o.payload()}}async function ss({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await os({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readTag`,e}}async function cs({fs:e,dir:t,gitdir:n=Y(t,`.git`),oid:r,filepath:i=void 0,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`oid`,r);let t=new Z(e);return await Si({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readTree`,e}}async function ls({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,cache:i={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,r);let t=new Z(e),a=await $({fsp:t,dotgit:n});await _t.acquire({fs:t,gitdir:a,cache:i},async function(e){let t=Array.isArray(r)?r:[r];for(let n of t)e.delete({filepath:n})})}catch(e){throw e.caller=`git.remove`,e}}async function us({fs:e,cache:t,onSign:n,gitdir:r,ref:i=`refs/notes/commits`,oid:a,author:o,committer:s,signingKey:c}){let l;try{l=await X.resolve({gitdir:r,fs:e,ref:i})}catch(e){if(!(e instanceof J))throw e}let u=(await Si({fs:e,cache:t,gitdir:r,oid:l||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;return u=u.filter(e=>e.path!==a),await _i({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:await Ci({fs:e,gitdir:r,tree:u}),parent:l&&[l],message:`Note removed by 'isomorphic-git removeNote'
68
+ `,author:o,committer:s,signingKey:c})}async function ds({fs:e,onSign:t,dir:n,gitdir:r=Y(n,`.git`),ref:i=`refs/notes/commits`,oid:a,author:o,committer:s,signingKey:c,cache:l={}}){try{Q(`fs`,e),Q(`gitdir`,r),Q(`oid`,a);let n=new Z(e),u=await $({fsp:n,dotgit:r}),d=await fi({fs:n,gitdir:u,author:o});if(!d)throw new rr(`author`);let f=await pi({fs:n,gitdir:u,author:d,committer:s});if(!f)throw new rr(`committer`);return await us({fs:n,cache:l,onSign:t,gitdir:u,ref:i,oid:a,author:d,committer:f,signingKey:c})}catch(e){throw e.caller=`git.removeNote`,e}}async function fs({fs:e,gitdir:t,oldref:n,ref:r,checkout:i=!1}){if(!Pt(r,!0))throw new Dt(r,Le.default.clean(r));if(!Pt(n,!0))throw new Dt(n,Le.default.clean(n));let a=`refs/heads/${n}`,o=`refs/heads/${r}`;if(await X.exists({fs:e,gitdir:t,ref:o}))throw new Vn(`branch`,r,!1);let s=await X.resolve({fs:e,gitdir:t,ref:a,depth:1});await X.writeRef({fs:e,gitdir:t,ref:o,value:s}),await X.deleteRef({fs:e,gitdir:t,ref:a});let c=await ea({fs:e,gitdir:t,fullname:!0})===a;(i||c)&&await X.writeSymbolicRef({fs:e,gitdir:t,ref:`HEAD`,value:o})}async function ps({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,oldref:i,checkout:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r),Q(`oldref`,i);let t=new Z(e);return await fs({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r,oldref:i,checkout:a})}catch(e){throw e.caller=`git.renameBranch`,e}}async function ms({gitdir:e,type:t,object:n}){return nt(pn.wrap({type:t,object:n}))}async function hs({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,ref:i,cache:a={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,r);let o=new Z(e),s=await $({fsp:o,dotgit:n}),c,l;try{c=await X.resolve({fs:o,gitdir:s,ref:i||`HEAD`})}catch(e){if(i||!(e instanceof J))throw e}if(c)try{c=await yi({fs:o,cache:a,gitdir:s,oid:c,filepath:r})}catch(e){if(!(e instanceof J)&&!(e instanceof $n)&&!(e instanceof Tt&&e.data.filepath))throw e;c=null}let u={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0},d=t&&await o.read(Y(t,r));d&&(l=await ms({gitdir:s,type:`blob`,object:d}),c===l&&(u=await o.lstat(Y(t,r)))),await _t.acquire({fs:o,gitdir:s,cache:a},async function(e){e.delete({filepath:r}),c&&e.insert({filepath:r,stats:u,oid:c})})}catch(e){throw e.caller=`git.reset`,e}}async function gs({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,depth:i}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e),a=await $({fsp:t,dotgit:n});return await X.resolve({fs:t,gitdir:a,ref:r,depth:i})}catch(e){throw e.caller=`git.resolveRef`,e}}async function _s({fs:e,dir:t,gitdir:n=Y(t,`.git`),path:r,value:i,append:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`path`,r);let t=new Z(e),o=await $({fsp:t,dotgit:n}),s=await tn.get({fs:t,gitdir:o});a?await s.append(r,i):await s.set(r,i),await tn.save({fs:t,gitdir:o,config:s})}catch(e){throw e.caller=`git.setConfig`,e}}async function vs({fs:e,gitdir:t,commit:n}){return await ni({fs:e,gitdir:t,type:`commit`,object:Dr.from(n).toObject(),format:`content`})}var ys=class e{static get timezoneOffsetForRefLogEntry(){let e=new Date().getTimezoneOffset(),t=Math.abs(Math.floor(e/60)),n=Math.abs(e%60).toString().padStart(2,`0`);return`${e>0?`-`:`+`}${t.toString().padStart(2,`0`)}${n}`}static createStashReflogEntry(t,n,r){let i=t.name.replace(/\s/g,``),a=Math.floor(Date.now()/1e3),o=e.timezoneOffsetForRefLogEntry;return`0000000000000000000000000000000000000000 ${n} ${i} ${t.email} ${a} ${o}\t${r}\n`}static getStashReflogEntry(e,t=!1){return e.split(`
69
+ `).filter(e=>e).reverse().map((e,n)=>t?`stash@{${n}}: ${e.split(` `)[1]}`:e)}},bs=class e{constructor({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){Object.assign(this,{fs:e,dir:t,gitdir:n,_author:null})}static get refStash(){return`refs/stash`}static get refLogsStash(){return`logs/refs/stash`}get refStashPath(){return Y(this.gitdir,e.refStash)}get refLogsStashPath(){return Y(this.gitdir,e.refLogsStash)}async getAuthor(){if(!this._author&&(this._author=await fi({fs:this.fs,gitdir:this.gitdir,author:{}}),!this._author))throw new rr(`author`);return this._author}async getStashSHA(e,t){return await this.fs.exists(this.refStashPath)?(t||await this.readStashReflogs({parsed:!1}))[e].split(` `)[1]:null}async writeStashCommit({message:e,tree:t,parent:n}){return vs({fs:this.fs,gitdir:this.gitdir,commit:{message:e,tree:t,parent:n,author:await this.getAuthor(),committer:await this.getAuthor()}})}async readStashCommit(e){let t=await this.readStashReflogs({parsed:!1});if(e!==0&&(e<0||e>t.length-1))throw new Dt(`stash@${e}`,`number that is in range of [0, num of stash pushed]`);let n=await this.getStashSHA(e,t);return n?hi({fs:this.fs,cache:{},gitdir:this.gitdir,oid:n}):{}}async writeStashRef(t){return X.writeRef({fs:this.fs,gitdir:this.gitdir,ref:e.refStash,value:t})}async writeStashReflogEntry({stashCommit:e,message:t}){let n=await this.getAuthor(),r=ys.createStashReflogEntry(n,e,t),i=this.refLogsStashPath;await ft(i,async()=>{let e=await this.fs.exists(i)?await this.fs.read(i,`utf8`):``;await this.fs.write(i,e+r,`utf8`)})}async readStashReflogs({parsed:e=!1}){if(!await this.fs.exists(this.refLogsStashPath))return[];let t=await this.fs.read(this.refLogsStashPath,`utf8`);return ys.getStashReflogEntry(t,e)}};async function xs({fs:e,dir:t,gitdir:n,message:r=``}){let i=new bs({fs:e,dir:t,gitdir:n});await i.getAuthor();let a=await ea({fs:e,gitdir:n,fullname:!1}),o=await X.resolve({fs:e,gitdir:n,ref:`HEAD`}),s=(await ns({fs:e,dir:t,gitdir:n,oid:o})).commit.message,c=[o],l=null,u=Ar({ref:`HEAD`}),d=await qi({fs:e,dir:t,gitdir:n,treePair:[Ar({ref:`HEAD`}),`stage`]});if(d){let e=await i.writeStashCommit({message:`stash-Index: WIP on ${a} - ${new Date().toISOString()}`,tree:d,parent:c});c.push(e),l=d,u=wt()}let f=await qi({fs:e,dir:t,gitdir:n,treePair:[u,`workdir`]});if(f){let e=await i.writeStashCommit({message:`stash-WorkDir: WIP on ${a} - ${new Date().toISOString()}`,tree:f,parent:[c[c.length-1]]});c.push(e),l=f}if(!l||!d&&!f)throw new J(`changes, nothing to stash`);let p=(r.trim()||`WIP on ${a}`)+`: ${o.substring(0,7)} ${s}`;return{stashCommit:await i.writeStashCommit({message:p,tree:l,parent:c}),stashMsg:p,branch:a,stashMgr:i}}async function Ss({fs:e,dir:t,gitdir:n,message:r=``}){let{stashCommit:i,stashMsg:a,branch:o,stashMgr:s}=await xs({fs:e,dir:t,gitdir:n,message:r});return await s.writeStashRef(i),await s.writeStashReflogEntry({stashCommit:i,message:a}),await zi({fs:e,dir:t,gitdir:n,ref:o,track:!1,force:!0}),i}async function Cs({fs:e,dir:t,gitdir:n,message:r=``}){let{stashCommit:i}=await xs({fs:e,dir:t,gitdir:n,message:r});return i}async function ws({fs:e,dir:t,gitdir:n,refIdx:r=0}){let i=await new bs({fs:e,dir:t,gitdir:n}).readStashCommit(r),{parent:a=null}=i.commit?i.commit:{};if(a&&Array.isArray(a))for(let r=0;r<a.length-1;r++){let i=(await hi({fs:e,cache:{},gitdir:n,oid:a[r+1]})).commit.message.startsWith(`stash-Index`);await Ji({fs:e,dir:t,gitdir:n,stashCommit:a[r+1],parentCommit:a[r],wasStaged:i})}}async function Ts({fs:e,dir:t,gitdir:n,refIdx:r=0}){let i=new bs({fs:e,dir:t,gitdir:n});if(!(await i.readStashCommit(r)).commit)return;let a=i.refStashPath;await ft(a,async()=>{await e.exists(a)&&await e.rm(a)});let o=await i.readStashReflogs({parsed:!1});if(!o.length)return;o.splice(r,1);let s=i.refLogsStashPath;await ft(s,async()=>{if(o.length){await e.write(s,o.reverse().join(`
68
70
  `)+`
69
- `,`utf8`);let t=o[o.length-1].split(` `)[1];await i.writeStashRef(t)}else await e.rm(s)})}async function Ds({fs:e,dir:t,gitdir:n}){return new xs({fs:e,dir:t,gitdir:n}).readStashReflogs({parsed:!0})}async function Os({fs:e,dir:t,gitdir:n}){let r=new xs({fs:e,dir:t,gitdir:n}),i=[r.refStashPath,r.refLogsStashPath];await ft(i,async()=>{await Promise.all(i.map(async t=>{if(await e.exists(t))return e.rm(t)}))})}async function ks({fs:e,dir:t,gitdir:n,refIdx:r=0}){await Ts({fs:e,dir:t,gitdir:n,refIdx:r}),await Es({fs:e,dir:t,gitdir:n,refIdx:r})}async function As({fs:e,dir:t,gitdir:n=Y(t,`.git`),op:r=`push`,message:i=``,refIdx:a=0}){Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n),Q(`op`,r);let o={push:Cs,apply:Ts,drop:Es,list:Ds,clear:Os,pop:ks,create:ws},s=[`apply`,`drop`,`pop`];try{let c=new Z(e),l=await $({fsp:c,dotgit:n});[`refs`,`logs`,`logs/refs`].map(e=>Y(l,e)).forEach(async e=>{await c.exists(e)||await c.mkdir(e)});let u=o[r];if(u){if(s.includes(r)&&a<0)throw new Dt(`stash@${a}`,`number that is in range of [0, num of stash pushed]`);return await u({fs:c,dir:t,gitdir:l,message:i,refIdx:a})}throw Error(`To be implemented: ${r}`)}catch(e){throw e.caller=`git.stash`,e}}async function js({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,cache:i={},refresh:a=!0}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,r);let o=new Z(e),s=await $({fsp:o,dotgit:n}),c=await Ns({fs:o,cache:i,gitdir:s,tree:await Ps({fs:o,cache:i,gitdir:s}),path:r}),l=await _t.acquire({fs:o,gitdir:s,cache:i},async function(e){for(let t of e)if(t.path===r)return t;return null});if(c===null&&l===null&&await Zr.isIgnored({fs:o,gitdir:s,dir:t,filepath:r}))return`ignored`;let u=await o.lstat(Y(t,r)),d=c!==null,f=l!==null,p=u!==null&&(d||f||await Ms({fs:o,dir:t,filepath:r})),m=async()=>{if(f&&!lt(l,u))return l.oid;{let e=await(await nn.get({fs:o,gitdir:s})).get(`core.autocrlf`),n=await o.read(Y(t,r),{autocrlf:e}),c=await hs({gitdir:s,type:`blob`,object:n});return a&&f&&l.oid===c&&u.size!==-1&&await _t.acquire({fs:o,gitdir:s,cache:i},async function(e){e.insert({filepath:r,stats:u,oid:c})}),c}};if(!d&&!p&&!f)return`absent`;if(!d&&!p&&f)return`*absent`;if(!d&&p&&!f)return`*added`;if(!d&&p&&f)return await m()===l.oid?`added`:`*added`;if(d&&!p&&!f)return`deleted`;if(d&&!p&&f)return l.oid,`*deleted`;if(d&&p&&!f)return await m()===c?`*undeleted`:`*undeletemodified`;if(d&&p&&f){let e=await m();return e===c?e===l.oid?`unmodified`:`*unmodified`:e===l.oid?`modified`:`*modified`}}catch(e){throw e.caller=`git.status`,e}}async function Ms({fs:e,dir:t,filepath:n}){let r=n.replace(/\\/g,`/`).split(`/`).filter(e=>e!==``&&e!==`.`),i=t;for(let t of r){let n;try{n=await e._readdir(i)}catch(e){if(e.code===`ENOENT`||e.code===`ENOTDIR`)return!1;throw e}if(!n.some(e=>e.normalize()===t.normalize()))return!1;i=Y(i,t)}return!0}async function Ns({fs:e,cache:t,gitdir:n,tree:r,path:i}){typeof i==`string`&&(i=i.split(`/`));let a=i.shift();for(let o of r)if(o.path===a){if(i.length===0)return o.oid;let{type:r,object:a}=await Vn({fs:e,cache:t,gitdir:n,oid:o.oid});if(r===`tree`)return Ns({fs:e,cache:t,gitdir:n,tree:pn.from(a),path:i});if(r===`blob`)throw new Tt(o.oid,r,`blob`,i.join(`/`))}return null}async function Ps({fs:e,cache:t,gitdir:n}){let r;try{r=await X.resolve({fs:e,gitdir:n,ref:`HEAD`})}catch(e){if(e instanceof J)return[];throw e}let{tree:i}=await Ci({fs:e,cache:t,gitdir:n,oid:r});return i}async function Fs({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r=`HEAD`,filepaths:i=[`.`],filter:a,cache:o={},ignored:s=!1,refresh:c=!0}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let l=new Z(e);return await Rr({fs:l,cache:o,dir:t,gitdir:await $({fsp:l,dotgit:n}),trees:[jr({ref:r}),Nr({refresh:c}),wt()],map:async function(e,[n,r,o]){if(!n&&!o&&r&&!s&&await Zr.isIgnored({fs:l,dir:t,filepath:e})||!i.some(t=>Pi(e,t)))return null;if(a&&!a(e))return;let[c,u,d]=await Promise.all([n&&n.type(),r&&r.type(),o&&o.type()]),f=[c,u,d].includes(`blob`);if((c===`tree`||c===`special`)&&!f)return;if(c===`commit`)return null;if((u===`tree`||u===`special`)&&!f)return;if(d===`commit`)return null;if((d===`tree`||d===`special`)&&!f)return;let p=c===`blob`?await n.oid():void 0,m=d===`blob`?await o.oid():void 0,h;c!==`blob`&&u===`blob`&&d!==`blob`?h=`42`:u===`blob`&&(h=await r.oid());let g=[void 0,p,h,m],_=g.map(e=>g.indexOf(e));return _.shift(),[e,..._]}})}catch(e){throw e.caller=`git.statusMatrix`,e}}async function Is({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,object:i,force:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e);if(r===void 0)throw new ar(`ref`);r=r.startsWith(`refs/tags/`)?r:`refs/tags/${r}`;let o=await $({fsp:t,dotgit:n}),s=await X.resolve({fs:t,gitdir:o,ref:i||`HEAD`});if(!a&&await X.exists({fs:t,gitdir:o,ref:r}))throw new Hn(`tag`,r);await X.writeRef({fs:t,gitdir:o,ref:r,value:s})}catch(e){throw e.caller=`git.tag`,e}}async function Ls({fs:e,dir:t,gitdir:n=Y(t,`.git`),cache:r={},filepath:i,oid:a,mode:o,add:s,remove:c,force:l}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,i);let u=new Z(e),d=await $({fsp:u,dotgit:n});if(c)return await _t.acquire({fs:u,gitdir:d,cache:r},async function(e){if(!l){let e=await u.lstat(Y(t,i));if(e){if(e.isDirectory())throw new er(`directory`);return}}e.has({filepath:i})&&e.delete({filepath:i})});let f;if(!a){if(f=await u.lstat(Y(t,i)),!f)throw new J(`file at "${i}" on disk and "remove" not set`);if(f.isDirectory())throw new er(`directory`)}return await _t.acquire({fs:u,gitdir:d,cache:r},async function(e){if(!s&&!e.has({filepath:i}))throw new J(`file at "${i}" in index and "add" not set`);let n;if(a)n={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:o,uid:0,gid:0,size:0};else{n=f;let e=n.isSymbolicLink()?await u.readlink(Y(t,i)):await u.read(Y(t,i));a=await ri({fs:u,gitdir:d,type:`blob`,format:`content`,object:e})}return e.insert({filepath:i,oid:a,stats:n}),a})}catch(e){throw e.caller=`git.updateIndex`,e}}function Rs(){try{return Da.version}catch(e){throw e.caller=`git.version`,e}}async function zs({fs:e,dir:t,gitdir:n=Y(t,`.git`),trees:r,map:i,reduce:a,iterate:o,cache:s={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`trees`,r);let c=new Z(e);return await Rr({fs:c,cache:s,dir:t,gitdir:await $({fsp:c,dotgit:n}),trees:r,map:i,reduce:a,iterate:o})}catch(e){throw e.caller=`git.walk`,e}}async function Bs({fs:e,dir:t,gitdir:n=Y(t,`.git`),blob:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`blob`,r);let t=new Z(e);return await ri({fs:t,gitdir:await $({fsp:t,dotgit:n}),type:`blob`,object:r,format:`content`})}catch(e){throw e.caller=`git.writeBlob`,e}}async function Vs({fs:e,dir:t,gitdir:n=Y(t,`.git`),commit:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`commit`,r);let t=new Z(e);return await ys({fs:t,gitdir:await $({fsp:t,dotgit:n}),commit:r})}catch(e){throw e.caller=`git.writeCommit`,e}}async function Hs({fs:e,dir:t,gitdir:n=Y(t,`.git`),type:r,object:i,format:a=`parsed`,oid:o,encoding:s=void 0}){try{let t=new Z(e),c=await $({fsp:t,dotgit:n});if(a===`parsed`){switch(r){case`commit`:i=Or.from(i).toObject();break;case`tree`:i=pn.from(i).toObject();break;case`blob`:i=Buffer.from(i,s);break;case`tag`:i=Tr.from(i).toObject();break;default:throw new Tt(o||``,r,`blob|commit|tag|tree`)}a=`content`}return o=await ri({fs:t,gitdir:c,type:r,object:i,oid:o,format:a}),o}catch(e){throw e.caller=`git.writeObject`,e}}async function Us({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,value:i,force:a=!1,symbolic:o=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r),Q(`value`,i);let t=new Z(e);if(!Pt(r,!0))throw new Dt(r,Le.default.clean(r));let s=await $({fsp:t,dotgit:n});if(!a&&await X.exists({fs:t,gitdir:s,ref:r}))throw new Hn(`ref`,r);o?await X.writeSymbolicRef({fs:t,gitdir:s,ref:r,value:i}):(i=await X.resolve({fs:t,gitdir:s,ref:i}),await X.writeRef({fs:t,gitdir:s,ref:r,value:i}))}catch(e){throw e.caller=`git.writeRef`,e}}async function Ws({fs:e,gitdir:t,tag:n}){return await ri({fs:e,gitdir:t,type:`tag`,object:Tr.from(n).toObject(),format:`content`})}async function Gs({fs:e,dir:t,gitdir:n=Y(t,`.git`),tag:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`tag`,r);let t=new Z(e);return await Ws({fs:t,gitdir:await $({fsp:t,dotgit:n}),tag:r})}catch(e){throw e.caller=`git.writeTag`,e}}async function Ks({fs:e,dir:t,gitdir:n=Y(t,`.git`),tree:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`tree`,r);let t=new Z(e);return await wi({fs:t,gitdir:await $({fsp:t,dotgit:n}),tree:r})}catch(e){throw e.caller=`git.writeTree`,e}}var qs={Errors:gr,STAGE:wt,TREE:jr,WORKDIR:Nr,add:ai,abortMerge:Xr,addNote:Ei,addRemote:Oi,annotatedTag:Ai,branch:Mi,cherryPick:Qi,checkout:Bi,clone:La,commit:Ra,getConfig:oo,getConfigAll:co,setConfig:vs,currentBranch:za,deleteBranch:Va,deleteRef:Ha,deleteRemote:Wa,deleteTag:Ka,expandOid:Xa,expandRef:Za,fastForward:to,fetch:no,findMergeBase:ro,findRoot:ao,getRemoteInfo:uo,getRemoteInfo2:po,hashBlob:ho,indexPack:_o,init:vo,isDescendent:bo,isIgnored:xo,listBranches:So,listFiles:To,listNotes:Do,listRefs:Oo,listRemotes:Ao,listServerRefs:No,listTags:Po,log:Vo,merge:Ho,packObjects:Ko,pull:qo,push:$o,readBlob:ns,readCommit:rs,readNote:as,readObject:os,readTag:cs,readTree:ls,remove:us,removeNote:fs,renameBranch:ms,resetIndex:gs,updateIndex:Ls,resolveRef:_s,status:js,statusMatrix:Fs,tag:Is,version:Rs,walk:zs,writeBlob:Bs,writeCommit:Vs,writeObject:Hs,writeRef:Us,writeTag:Gs,writeTree:Ks,stash:As};export{gr as Errors,wt as STAGE,jr as TREE,Nr as WORKDIR,Xr as abortMerge,ai as add,Ei as addNote,Oi as addRemote,Ai as annotatedTag,Mi as branch,Bi as checkout,Qi as cherryPick,La as clone,Ra as commit,za as currentBranch,qs as default,Va as deleteBranch,Ha as deleteRef,Wa as deleteRemote,Ka as deleteTag,Xa as expandOid,Za as expandRef,to as fastForward,no as fetch,ro as findMergeBase,ao as findRoot,oo as getConfig,co as getConfigAll,uo as getRemoteInfo,po as getRemoteInfo2,ho as hashBlob,_o as indexPack,vo as init,bo as isDescendent,xo as isIgnored,So as listBranches,To as listFiles,Do as listNotes,Oo as listRefs,Ao as listRemotes,No as listServerRefs,Po as listTags,Vo as log,Ho as merge,Ko as packObjects,qo as pull,$o as push,ns as readBlob,rs as readCommit,as as readNote,os as readObject,cs as readTag,ls as readTree,us as remove,fs as removeNote,ms as renameBranch,gs as resetIndex,_s as resolveRef,vs as setConfig,As as stash,js as status,Fs as statusMatrix,Is as tag,Ls as updateIndex,Rs as version,zs as walk,Bs as writeBlob,Vs as writeCommit,Hs as writeObject,Us as writeRef,Gs as writeTag,Ks as writeTree};
71
+ `,`utf8`);let t=o[o.length-1].split(` `)[1];await i.writeStashRef(t)}else await e.rm(s)})}async function Es({fs:e,dir:t,gitdir:n}){return new bs({fs:e,dir:t,gitdir:n}).readStashReflogs({parsed:!0})}async function Ds({fs:e,dir:t,gitdir:n}){let r=new bs({fs:e,dir:t,gitdir:n}),i=[r.refStashPath,r.refLogsStashPath];await ft(i,async()=>{await Promise.all(i.map(async t=>{if(await e.exists(t))return e.rm(t)}))})}async function Os({fs:e,dir:t,gitdir:n,refIdx:r=0}){await ws({fs:e,dir:t,gitdir:n,refIdx:r}),await Ts({fs:e,dir:t,gitdir:n,refIdx:r})}async function ks({fs:e,dir:t,gitdir:n=Y(t,`.git`),op:r=`push`,message:i=``,refIdx:a=0}){Q(`fs`,e),Q(`dir`,t),Q(`gitdir`,n),Q(`op`,r);let o={push:Ss,apply:ws,drop:Ts,list:Es,clear:Ds,pop:Os,create:Cs},s=[`apply`,`drop`,`pop`];try{let c=new Z(e),l=await $({fsp:c,dotgit:n});[`refs`,`logs`,`logs/refs`].map(e=>Y(l,e)).forEach(async e=>{await c.exists(e)||await c.mkdir(e)});let u=o[r];if(u){if(s.includes(r)&&a<0)throw new Dt(`stash@${a}`,`number that is in range of [0, num of stash pushed]`);return await u({fs:c,dir:t,gitdir:l,message:i,refIdx:a})}throw Error(`To be implemented: ${r}`)}catch(e){throw e.caller=`git.stash`,e}}async function As({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,cache:i={},refresh:a=!0}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,r);let o=new Z(e),s=await $({fsp:o,dotgit:n}),c=await Ms({fs:o,cache:i,gitdir:s,tree:await Ns({fs:o,cache:i,gitdir:s}),path:r}),l=await _t.acquire({fs:o,gitdir:s,cache:i},async function(e){for(let t of e)if(t.path===r)return t;return null});if(c===null&&l===null&&await Xr.isIgnored({fs:o,gitdir:s,dir:t,filepath:r}))return`ignored`;let u=await o.lstat(Y(t,r)),d=c!==null,f=l!==null,p=u!==null&&(d||f||await js({fs:o,dir:t,filepath:r})),m=async()=>{if(f&&!lt(l,u))return l.oid;{let e=await(await tn.get({fs:o,gitdir:s})).get(`core.autocrlf`),n=await o.read(Y(t,r),{autocrlf:e}),c=await ms({gitdir:s,type:`blob`,object:n});return a&&f&&l.oid===c&&u.size!==-1&&await _t.acquire({fs:o,gitdir:s,cache:i},async function(e){e.insert({filepath:r,stats:u,oid:c})}),c}};if(!d&&!p&&!f)return`absent`;if(!d&&!p&&f)return`*absent`;if(!d&&p&&!f)return`*added`;if(!d&&p&&f)return await m()===l.oid?`added`:`*added`;if(d&&!p&&!f)return`deleted`;if(d&&!p&&f)return l.oid,`*deleted`;if(d&&p&&!f)return await m()===c?`*undeleted`:`*undeletemodified`;if(d&&p&&f){let e=await m();return e===c?e===l.oid?`unmodified`:`*unmodified`:e===l.oid?`modified`:`*modified`}}catch(e){throw e.caller=`git.status`,e}}async function js({fs:e,dir:t,filepath:n}){let r=n.replace(/\\/g,`/`).split(`/`).filter(e=>e!==``&&e!==`.`),i=t;for(let t of r){let n;try{n=await e._readdir(i)}catch(e){if(e.code===`ENOENT`||e.code===`ENOTDIR`)return!1;throw e}if(!n.some(e=>e.normalize()===t.normalize()))return!1;i=Y(i,t)}return!0}async function Ms({fs:e,cache:t,gitdir:n,tree:r,path:i}){typeof i==`string`&&(i=i.split(`/`));let a=i.shift();for(let o of r)if(o.path===a){if(i.length===0)return o.oid;let{type:r,object:a}=await Bn({fs:e,cache:t,gitdir:n,oid:o.oid});if(r===`tree`)return Ms({fs:e,cache:t,gitdir:n,tree:fn.from(a),path:i});if(r===`blob`)throw new Tt(o.oid,r,`blob`,i.join(`/`))}return null}async function Ns({fs:e,cache:t,gitdir:n}){let r;try{r=await X.resolve({fs:e,gitdir:n,ref:`HEAD`})}catch(e){if(e instanceof J)return[];throw e}let{tree:i}=await Si({fs:e,cache:t,gitdir:n,oid:r});return i}async function Ps({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r=`HEAD`,filepaths:i=[`.`],filter:a,cache:o={},ignored:s=!1,refresh:c=!0}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let l=new Z(e);return await Lr({fs:l,cache:o,dir:t,gitdir:await $({fsp:l,dotgit:n}),trees:[Ar({ref:r}),Mr({refresh:c}),wt()],map:async function(e,[n,r,o]){if(!n&&!o&&r&&!s&&await Xr.isIgnored({fs:l,dir:t,filepath:e})||!i.some(t=>Ni(e,t)))return null;if(a&&!a(e))return;let[c,u,d]=await Promise.all([n&&n.type(),r&&r.type(),o&&o.type()]),f=[c,u,d].includes(`blob`);if((c===`tree`||c===`special`)&&!f)return;if(c===`commit`)return null;if((u===`tree`||u===`special`)&&!f)return;if(d===`commit`)return null;if((d===`tree`||d===`special`)&&!f)return;let p=c===`blob`?await n.oid():void 0,m=d===`blob`?await o.oid():void 0,h;c!==`blob`&&u===`blob`&&d!==`blob`?h=`42`:u===`blob`&&(h=await r.oid());let g=[void 0,p,h,m],_=g.map(e=>g.indexOf(e));return _.shift(),[e,..._]}})}catch(e){throw e.caller=`git.statusMatrix`,e}}async function Fs({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,object:i,force:a=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r);let t=new Z(e);if(r===void 0)throw new ir(`ref`);r=r.startsWith(`refs/tags/`)?r:`refs/tags/${r}`;let o=await $({fsp:t,dotgit:n}),s=await X.resolve({fs:t,gitdir:o,ref:i||`HEAD`});if(!a&&await X.exists({fs:t,gitdir:o,ref:r}))throw new Vn(`tag`,r);await X.writeRef({fs:t,gitdir:o,ref:r,value:s})}catch(e){throw e.caller=`git.tag`,e}}async function Is({fs:e,dir:t,gitdir:n=Y(t,`.git`),cache:r={},filepath:i,oid:a,mode:o,add:s,remove:c,force:l}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`filepath`,i);let u=new Z(e),d=await $({fsp:u,dotgit:n});if(c)return await _t.acquire({fs:u,gitdir:d,cache:r},async function(e){if(!l){let e=await u.lstat(Y(t,i));if(e){if(e.isDirectory())throw new $n(`directory`);return}}e.has({filepath:i})&&e.delete({filepath:i})});let f;if(!a){if(f=await u.lstat(Y(t,i)),!f)throw new J(`file at "${i}" on disk and "remove" not set`);if(f.isDirectory())throw new $n(`directory`)}return await _t.acquire({fs:u,gitdir:d,cache:r},async function(e){if(!s&&!e.has({filepath:i}))throw new J(`file at "${i}" in index and "add" not set`);let n;if(a)n={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:o,uid:0,gid:0,size:0};else{n=f;let e=n.isSymbolicLink()?await u.readlink(Y(t,i)):await u.read(Y(t,i));a=await ni({fs:u,gitdir:d,type:`blob`,format:`content`,object:e})}return e.insert({filepath:i,oid:a,stats:n}),a})}catch(e){throw e.caller=`git.updateIndex`,e}}function Ls(){try{return Ea.version}catch(e){throw e.caller=`git.version`,e}}async function Rs({fs:e,dir:t,gitdir:n=Y(t,`.git`),trees:r,map:i,reduce:a,iterate:o,cache:s={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`trees`,r);let c=new Z(e);return await Lr({fs:c,cache:s,dir:t,gitdir:await $({fsp:c,dotgit:n}),trees:r,map:i,reduce:a,iterate:o})}catch(e){throw e.caller=`git.walk`,e}}async function zs({fs:e,dir:t,gitdir:n=Y(t,`.git`),blob:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`blob`,r);let t=new Z(e);return await ni({fs:t,gitdir:await $({fsp:t,dotgit:n}),type:`blob`,object:r,format:`content`})}catch(e){throw e.caller=`git.writeBlob`,e}}async function Bs({fs:e,dir:t,gitdir:n=Y(t,`.git`),commit:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`commit`,r);let t=new Z(e);return await vs({fs:t,gitdir:await $({fsp:t,dotgit:n}),commit:r})}catch(e){throw e.caller=`git.writeCommit`,e}}async function Vs({fs:e,dir:t,gitdir:n=Y(t,`.git`),type:r,object:i,format:a=`parsed`,oid:o,encoding:s=void 0}){try{let t=new Z(e),c=await $({fsp:t,dotgit:n});if(a===`parsed`){switch(r){case`commit`:i=Dr.from(i).toObject();break;case`tree`:i=fn.from(i).toObject();break;case`blob`:i=Buffer.from(i,s);break;case`tag`:i=wr.from(i).toObject();break;default:throw new Tt(o||``,r,`blob|commit|tag|tree`)}a=`content`}return o=await ni({fs:t,gitdir:c,type:r,object:i,oid:o,format:a}),o}catch(e){throw e.caller=`git.writeObject`,e}}async function Hs({fs:e,dir:t,gitdir:n=Y(t,`.git`),ref:r,value:i,force:a=!1,symbolic:o=!1}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,r),Q(`value`,i);let t=new Z(e);if(!Pt(r,!0))throw new Dt(r,Le.default.clean(r));let s=await $({fsp:t,dotgit:n});if(!a&&await X.exists({fs:t,gitdir:s,ref:r}))throw new Vn(`ref`,r);o?await X.writeSymbolicRef({fs:t,gitdir:s,ref:r,value:i}):(i=await X.resolve({fs:t,gitdir:s,ref:i}),await X.writeRef({fs:t,gitdir:s,ref:r,value:i}))}catch(e){throw e.caller=`git.writeRef`,e}}async function Us({fs:e,gitdir:t,tag:n}){return await ni({fs:e,gitdir:t,type:`tag`,object:wr.from(n).toObject(),format:`content`})}async function Ws({fs:e,dir:t,gitdir:n=Y(t,`.git`),tag:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`tag`,r);let t=new Z(e);return await Us({fs:t,gitdir:await $({fsp:t,dotgit:n}),tag:r})}catch(e){throw e.caller=`git.writeTag`,e}}async function Gs({fs:e,dir:t,gitdir:n=Y(t,`.git`),tree:r}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`tree`,r);let t=new Z(e);return await Ci({fs:t,gitdir:await $({fsp:t,dotgit:n}),tree:r})}catch(e){throw e.caller=`git.writeTree`,e}}var Ks={Errors:hr,STAGE:wt,TREE:Ar,WORKDIR:Mr,add:ii,abortMerge:Yr,addNote:Ti,addRemote:Di,annotatedTag:ki,branch:ji,cherryPick:Zi,checkout:zi,clone:Ia,commit:La,getConfig:ao,getConfigAll:so,setConfig:_s,currentBranch:Ra,deleteBranch:Ba,deleteRef:Va,deleteRemote:Ua,deleteTag:Ga,expandOid:Ya,expandRef:Xa,fastForward:eo,fetch:to,findMergeBase:no,findRoot:io,getRemoteInfo:lo,getRemoteInfo2:fo,hashBlob:mo,indexPack:go,init:_o,isDescendent:yo,isIgnored:bo,listBranches:xo,listFiles:wo,listNotes:Eo,listRefs:Do,listRemotes:ko,listServerRefs:Mo,listTags:No,log:Bo,merge:Vo,packObjects:Go,pull:Ko,push:Qo,readBlob:ts,readCommit:ns,readNote:is,readObject:as,readTag:ss,readTree:cs,remove:ls,removeNote:ds,renameBranch:ps,resetIndex:hs,updateIndex:Is,resolveRef:gs,status:As,statusMatrix:Ps,tag:Fs,version:Ls,walk:Rs,writeBlob:zs,writeCommit:Bs,writeObject:Vs,writeRef:Hs,writeTag:Ws,writeTree:Gs,stash:ks};export{hr as Errors,wt as STAGE,Ar as TREE,Mr as WORKDIR,Yr as abortMerge,ii as add,Ti as addNote,Di as addRemote,ki as annotatedTag,ji as branch,zi as checkout,Zi as cherryPick,Ia as clone,La as commit,Ra as currentBranch,Ks as default,Ba as deleteBranch,Va as deleteRef,Ua as deleteRemote,Ga as deleteTag,Ya as expandOid,Xa as expandRef,eo as fastForward,to as fetch,no as findMergeBase,io as findRoot,ao as getConfig,so as getConfigAll,lo as getRemoteInfo,fo as getRemoteInfo2,mo as hashBlob,go as indexPack,_o as init,yo as isDescendent,bo as isIgnored,xo as listBranches,wo as listFiles,Eo as listNotes,Do as listRefs,ko as listRemotes,Mo as listServerRefs,No as listTags,Bo as log,Vo as merge,Go as packObjects,Ko as pull,Qo as push,ts as readBlob,ns as readCommit,is as readNote,as as readObject,ss as readTag,cs as readTree,ls as remove,ds as removeNote,ps as renameBranch,hs as resetIndex,gs as resolveRef,_s as setConfig,ks as stash,As as status,Ps as statusMatrix,Fs as tag,Is as updateIndex,Ls as version,Rs as walk,zs as writeBlob,Bs as writeCommit,Vs as writeObject,Hs as writeRef,Ws as writeTag,Gs as writeTree};