sliccy 6.99.0 → 6.99.2

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 (80) hide show
  1. package/dist/ui/.vite/manifest.json +122 -122
  2. package/dist/ui/assets/{SKILL-BpeW5CoS.js → SKILL-D6a6ZdMA.js} +1 -0
  3. package/dist/ui/assets/{account-store-PGhT8u8K.js → account-store-7x-nfWBM.js} +1 -1
  4. package/dist/ui/assets/{account-store-UhvCpVi5.js → account-store-DADHAp2B.js} +1 -1
  5. package/dist/ui/assets/{adobe-CbQx7GGT.js → adobe-CpKSqL6G.js} +1 -1
  6. package/dist/ui/assets/{adobe-B0t9xpao.js → adobe-Ctj8J1x5.js} +1 -1
  7. package/dist/ui/assets/{apply-layout-DesK_rTC.js → apply-layout-1PEl6vWo.js} +1 -1
  8. package/dist/ui/assets/{apps-D-cDcEBd.js → apps-Tn2xBP-k.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-tx7uteql.js → azure-openai-8SD1DRJX.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-tjg_Jac-.js → azure-openai-Bx_c_cvE.js} +1 -1
  11. package/dist/ui/assets/{cerebras-DHTBGb5d.js → cerebras-B0spyys1.js} +1 -1
  12. package/dist/ui/assets/{cerebras-E43VFxsv.js → cerebras-CtDnzLJY.js} +1 -1
  13. package/dist/ui/assets/{connect-surface-DBraaKfB.js → connect-surface-aLLDbvfG.js} +1 -1
  14. package/dist/ui/assets/{fs-5TZPzTFc.js → fs-Dh6IiuaU.js} +1 -1
  15. package/dist/ui/assets/{fs-fHIHSoGm.js → fs-k5zkPv3W.js} +2 -2
  16. package/dist/ui/assets/{github-CW-SPSdU.js → github-DLFHVPtp.js} +2 -2
  17. package/dist/ui/assets/{github-copilot-B2uCXhTH.js → github-copilot-D5MTdmM6.js} +1 -1
  18. package/dist/ui/assets/{github-copilot-DmnUQ1GA.js → github-copilot-RykE0ro3.js} +1 -1
  19. package/dist/ui/assets/{github-install-oNYELWrF.js → github-install-DFPWd3_F.js} +1 -1
  20. package/dist/ui/assets/{github-olMzIeFS.js → github-tJfxzJw6.js} +1 -1
  21. package/dist/ui/assets/{github-zip-D48f7PNt.js → github-zip-D-H-YIqE.js} +1 -1
  22. package/dist/ui/assets/{isomorphic-git-C6P5z4OC.js → isomorphic-git-BAj-fLD-.js} +3 -3
  23. package/dist/ui/assets/{js-realm-worker-BXYcQvVa.js → js-realm-worker-BrmMrzPH.js} +1 -1
  24. package/dist/ui/assets/{kernel-worker-CDlC4Khp.js → kernel-worker-DNl1o0Lj.js} +655 -651
  25. package/dist/ui/assets/{local-llm-yAuiAi8x.js → local-llm-D0kR_cIR.js} +1 -1
  26. package/dist/ui/assets/{local-llm-Da-S9Rwh.js → local-llm-DNeV4XoZ.js} +1 -1
  27. package/dist/ui/assets/{main-CjVUpZQF.js → main-DKPHBQyu.js} +3 -3
  28. package/dist/ui/assets/{mount-NuIgZQ5K.js → mount-BQohU706.js} +1 -1
  29. package/dist/ui/assets/{mount-CElAhSXQ.js → mount-CmmTzJEg.js} +2 -2
  30. package/dist/ui/assets/{mount-recovery-CPdlB14n.js → mount-recovery-DE-xAEjJ.js} +1 -1
  31. package/dist/ui/assets/{new-session-CzJbuo5H.js → new-session-DYwEoSD7.js} +2 -2
  32. package/dist/ui/assets/{oauth-bootstrap-CyJ1t1fx.js → oauth-bootstrap-Bik9vS6V.js} +2 -2
  33. package/dist/ui/assets/{openai-codex-B-dbXWiv.js → openai-codex-C93G0CYW.js} +1 -1
  34. package/dist/ui/assets/{openai-codex-s9z4Oe5H.js → openai-codex-CFKfbN5z.js} +1 -1
  35. package/dist/ui/assets/{openrouter-JAWMEkX8.js → openrouter-D3JgB9cc.js} +1 -1
  36. package/dist/ui/assets/{openrouter-oauth-B2dqDEOw.js → openrouter-oauth-dvwP07-i.js} +1 -1
  37. package/dist/ui/assets/{openrouter-oauth-CcdLIqjS.js → openrouter-oauth-pG_ZSGVk.js} +1 -1
  38. package/dist/ui/assets/{openrouter-BYtnhBPk.js → openrouter-wleoMG9m.js} +1 -1
  39. package/dist/ui/assets/{panel-rpc-handlers-81nV4l2z.js → panel-rpc-handlers-CCm_g-fi.js} +2 -2
  40. package/dist/ui/assets/{provider-BrGxm1af.js → provider-DdZDEGXx.js} +2 -2
  41. package/dist/ui/assets/{provider-5iXJYXIP.js → provider-ciQ5h0yA.js} +1 -1
  42. package/dist/ui/assets/{provider-settings-iKaSUXO2.js → provider-settings-B7xJGdeQ.js} +1 -1
  43. package/dist/ui/assets/provider-settings-CqfNX_ir.js +1 -0
  44. package/dist/ui/assets/{provider-store-access-C0VGVu4i.js → provider-store-access-CeqayEZH.js} +2 -2
  45. package/dist/ui/assets/provider-store-access-Dyy6ROtg.js +1 -0
  46. package/dist/ui/assets/{providers-BEtOul-J.js → providers-B58XMjBg.js} +1 -1
  47. package/dist/ui/assets/{providers-DePjGjI9.js → providers-BptTgMB6.js} +2 -2
  48. package/dist/ui/assets/{quick-llm-CA49HefL.js → quick-llm-BLLDyv6a.js} +1 -1
  49. package/dist/ui/assets/{recovery-screen-C820fnXa.js → recovery-screen-BWVFOj3x.js} +1 -1
  50. package/dist/ui/assets/{redirect-uri-_DXXUb3_.js → redirect-uri-Bpi1Fl3o.js} +1 -1
  51. package/dist/ui/assets/{run-BtFwUHL1.js → run-D2eUknJ5.js} +1 -1
  52. package/dist/ui/assets/{session-freezer--jQwkHBW.js → session-freezer-DmgHX3fj.js} +3 -3
  53. package/dist/ui/assets/{setup-feature-flags-remote-CemRpM4O.js → setup-feature-flags-remote-Yw-3d4JJ.js} +1 -1
  54. package/dist/ui/assets/{setup-standalone-prelude-B_CwyTA7.js → setup-standalone-prelude-r9cVGJxc.js} +1 -1
  55. package/dist/ui/assets/{setup-sudo-B6DI1Any.js → setup-sudo-kIO8ixOB.js} +2 -2
  56. package/dist/ui/assets/{skills-OJDKT8VI.js → skills-r6qeToKp.js} +4 -4
  57. package/dist/ui/assets/slicc-version-JyL0p8Pr.js +1 -0
  58. package/dist/ui/assets/{state-DUdcCGso.js → state-DX8NSHRp.js} +1 -1
  59. package/dist/ui/assets/{store-WNZa0aQX.js → store-DNOemDV7.js} +1 -1
  60. package/dist/ui/assets/{store-Cxu67puX.js → store-DnkG__io.js} +1 -1
  61. package/dist/ui/assets/{sudo-w5yl__4P.js → sudo-sLKMZgmh.js} +1 -1
  62. package/dist/ui/assets/{upgrade-detection-BsjYW856.js → upgrade-detection-CJ_MChYv.js} +1 -1
  63. package/dist/ui/assets/{wc-extension-CnWiY4XW.js → wc-extension-CPsrwogd.js} +2 -2
  64. package/dist/ui/assets/{wc-follower-BxgSEnFh.js → wc-follower-DPqzOEZB.js} +3 -3
  65. package/dist/ui/assets/{wc-live-C-Tc-fkR.js → wc-live-ChCbDRCx.js} +4 -4
  66. package/dist/ui/assets/{wc-nav-4BWGTo3o.js → wc-nav-BtcG0NX5.js} +2 -2
  67. package/dist/ui/assets/{wc-onboarding-C_K_bkLE.js → wc-onboarding-DFQuEI9V.js} +2 -2
  68. package/dist/ui/assets/{wc-placeholder-BJUxgyv_.js → wc-placeholder-XSaVJjgH.js} +2 -2
  69. package/dist/ui/assets/{wc-settings-vHpNnJj9.js → wc-settings-CZ-QqWUs.js} +2 -2
  70. package/dist/ui/assets/{wc-shell-tlPtWG89.js → wc-shell-K2Fm8fgP.js} +2 -2
  71. package/dist/ui/assets/{wc-sprinkles-Mzuq6tXf.js → wc-sprinkles-DssbJi2F.js} +2 -2
  72. package/dist/ui/assets/{wc-tray-CiN14R7Y.js → wc-tray-CedX90Pq.js} +2 -2
  73. package/dist/ui/assets/{xai-grok-C3Cl0btv.js → xai-grok-Blz9gclB.js} +1 -1
  74. package/dist/ui/assets/{xai-grok-CDtgl5Ap.js → xai-grok-BpLGdjMn.js} +1 -1
  75. package/dist/ui/index.html +6 -6
  76. package/dist/ui/packages/webapp/index.html +6 -6
  77. package/package.json +1 -1
  78. package/dist/ui/assets/provider-settings-BcDzUFLS.js +0 -1
  79. package/dist/ui/assets/provider-store-access-XG-jW25O.js +0 -1
  80. package/dist/ui/assets/slicc-version-DJdeZSuo.js +0 -1
@@ -1 +1 @@
1
- import{H as e,d as t}from"./account-store-UhvCpVi5.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,s as i,u as a}from"./claude-model-version-Csn7RPVg.js";import{a as o,c as s,i as c,r as l,s as u,t as d}from"./legacy-api-aliases-oJPAvhVV.js";import"./provider-settings-BcDzUFLS.js";const f=`github-copilot`,p=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),m={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},h={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function g(){return t().find(e=>e.providerId===f)}async function _(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function v(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await y(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function y(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function b(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function x(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...m,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-3e5,apiBaseUrl:b(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const S=`github-copilot.models.v1`;function C(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function w(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:C(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function T(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...m,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return w(await t.json())}function E(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(S);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function D(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(S,JSON.stringify(e))}catch{}}function O(e){return E().find(t=>t.id===e)??null}async function k(e){let t;try{t=await T(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}D(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...m,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),D(t)}async function A(t,n){await e({providerId:f,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function j(){let e=g();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await x(e.refreshToken);return await A(n,e.userName),n.copilotToken}const M=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function N(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!M.some(e=>t.some(t=>t.includes(e)))}function P(){if(!g()?.accessToken)return[];let e=E();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>N(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=r(`github-copilot`)}catch{return[]}return t.filter(e=>N({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function F(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const I={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function L(e){let t=g(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=O(e);if(r)return{api:r.api,baseUrl:n,headers:{...I}};try{let n=i(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...I}}}catch{return null}}function R(e,t){let n=E(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},D(n))}function z(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function B(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function V(e,t){return e===`anthropic-messages`?t?o:d:e===`openai-responses`?t?s:c:t?u:l}function H(e,t,n){let r=B(n);if(r&&/model_not_supported/i.test(r)){R(t.id,`model_not_supported`);let n=z(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(F(t,Error(n))),e.end(),!0}return e.push(n),!1}function U(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(R(t.id,`model_not_supported`),i=Error(z(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(F(t,i)),e.end()}async function W(e,t,n,r,i){try{let a=await j(),o=L(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=V(o.api,i)(s,n,c);for await(let n of l)if(H(e,t,n))return;e.end()}catch(n){U(e,t,n)}}function G(e){return(t,r,i={})=>{let a=n();return W(a,t,r,i,e),a}}const K=G(!1),q=G(!0),J=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./clipboard-CknViQHB.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),Y={id:f,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:P,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await _(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??J)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await v(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await x(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await A(c,l),await k(c),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=g();if(!e?.refreshToken)return null;try{let t=await x(e.refreshToken);return await A(t,e.userName),await k(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function X(){a({api:`github-copilot-anthropic`,stream:K,streamSimple:q}),a({api:`github-copilot-openai`,stream:K,streamSimple:q})}export{Y as config,N as isCopilotConeCompatible,X as register};
1
+ import{H as e,d as t}from"./account-store-DADHAp2B.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,s as i,u as a}from"./claude-model-version-Csn7RPVg.js";import{a as o,c as s,i as c,r as l,s as u,t as d}from"./legacy-api-aliases-oJPAvhVV.js";import"./provider-settings-CqfNX_ir.js";const f=`github-copilot`,p=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),m={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},h={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function g(){return t().find(e=>e.providerId===f)}async function _(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function v(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await y(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function y(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function b(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function x(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...m,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-3e5,apiBaseUrl:b(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const S=`github-copilot.models.v1`;function C(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function w(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:C(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function T(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...m,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return w(await t.json())}function E(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(S);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function D(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(S,JSON.stringify(e))}catch{}}function O(e){return E().find(t=>t.id===e)??null}async function k(e){let t;try{t=await T(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}D(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...m,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),D(t)}async function A(t,n){await e({providerId:f,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function j(){let e=g();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await x(e.refreshToken);return await A(n,e.userName),n.copilotToken}const M=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function N(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!M.some(e=>t.some(t=>t.includes(e)))}function P(){if(!g()?.accessToken)return[];let e=E();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>N(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=r(`github-copilot`)}catch{return[]}return t.filter(e=>N({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function F(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const I={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function L(e){let t=g(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=O(e);if(r)return{api:r.api,baseUrl:n,headers:{...I}};try{let n=i(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...I}}}catch{return null}}function R(e,t){let n=E(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},D(n))}function z(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function B(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function V(e,t){return e===`anthropic-messages`?t?o:d:e===`openai-responses`?t?s:c:t?u:l}function H(e,t,n){let r=B(n);if(r&&/model_not_supported/i.test(r)){R(t.id,`model_not_supported`);let n=z(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(F(t,Error(n))),e.end(),!0}return e.push(n),!1}function U(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(R(t.id,`model_not_supported`),i=Error(z(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(F(t,i)),e.end()}async function W(e,t,n,r,i){try{let a=await j(),o=L(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=V(o.api,i)(s,n,c);for await(let n of l)if(H(e,t,n))return;e.end()}catch(n){U(e,t,n)}}function G(e){return(t,r,i={})=>{let a=n();return W(a,t,r,i,e),a}}const K=G(!1),q=G(!0),J=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./clipboard-CknViQHB.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),Y={id:f,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:P,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await _(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??J)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await v(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await x(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await A(c,l),await k(c),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=g();if(!e?.refreshToken)return null;try{let t=await x(e.refreshToken);return await A(t,e.userName),await k(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function X(){a({api:`github-copilot-anthropic`,stream:K,streamSimple:q}),a({api:`github-copilot-openai`,stream:K,streamSimple:q})}export{Y as config,N as isCopilotConeCompatible,X as register};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./fetch-body-DDu_AU5I.js";import{a as n,c as r,d as i,f as a,g as o,o as s,r as c,s as l,t as u}from"./github-zip-D48f7PNt.js";function d(e){return`${o}/${e}/.upskill`}async function f(e,t){try{let n=await e.readTextFile(d(t)),r=JSON.parse(n);return!r||typeof r!=`object`||!r.kind||!r.source?null:r}catch{return null}}async function p(e,t,n){try{let r={...n,version:1,installed:new Date().toISOString()};await e.writeFile(d(t),`${JSON.stringify(r,null,2)}\n`)}catch{}}async function m(e){let t;try{t=await e.readDir(o)}catch{return[]}let n=[];for(let r of t.sort((e,t)=>e.name.localeCompare(t.name))){if(r.type!==`directory`)continue;let t=await f(e,r.name);t&&n.push({name:r.name,provenance:t})}return n}async function h(e,n,r,i,a=!1){if(!(!i.hasToken&&!a))try{let a=r||`HEAD`,o=await i.request(`https://api.github.com/repos/${e}/${n}/commits/${encodeURIComponent(a)}`);if(o.status!==200)return;let s=t(o.body);return typeof s.sha==`string`?s.sha:void 0}catch{return}}function g(e){let t=`Installed from: ${e.kind}:${e.source}\n`;return e.ref&&(t+=`Ref: ${e.ref}\n`),e.path&&(t+=`Upstream path: ${e.path}\n`),e.sha&&(t+=`Commit: ${e.sha}\n`),t+=`Installed at: ${e.installed}\n`,t}async function _(){try{let e=(typeof window<`u`?window:globalThis).__slicc_reloadSkills;if(typeof e==`function`){await e();return}typeof chrome<`u`&&chrome?.runtime?.sendMessage&&chrome.runtime.sendMessage({source:`panel`,payload:{type:`reload-skills`}})}catch{}}async function v(){try{let e=globalThis.__slicc_sprinkleManager;typeof e?.openNewAutoOpenSprinkles==`function`&&await e.openNewAutoOpenSprinkles()}catch{}}async function y(){await v(),await _()}async function b(e,t,n,s,c=!1,l){let u=`${o}/${t}`,d=!1;try{if(await s.stat(u),!c)return{ok:!1,error:`skill "${t}" already exists (use --force to overwrite)`};d=!0,await a(s,u,await x(s,t))}catch{}let f=e.replace(/^\/|\/$/g,``),m=f?f+`/`:``;await s.mkdir(u,{recursive:!0});let h=0,g=[];try{for(let[e,t]of Object.entries(n)){if(!e.startsWith(m))continue;let n=e.slice(m.length);if(!n||e.endsWith(`/`)||!await i(s,u,n)||!r(n))continue;let a=`${u}/${n}`,o=a.substring(0,a.lastIndexOf(`/`));o!==u&&await s.mkdir(o,{recursive:!0}),await s.writeFile(a,t),g.push(n),h++}}catch(e){throw await S(s,u,d),e}return h===0?(await S(s,u,d),{ok:!1,error:`no files found for skill "${t}" in ZIP`}):(l&&await p(s,t,{...l,skill:t,files:g.sort()}),{ok:!0})}async function x(e,t){let n=await f(e,t);return n?.files?.length?new Set(n.files):void 0}async function S(e,t,n){if(n){await a(e,t).catch(()=>!1);return}await e.rm(t,{recursive:!0}).catch(()=>{})}var C=e({installFromGitHub:()=>D,listGitHubSkills:()=>T,parseGitHubRef:()=>O,parseGitHubUrl:()=>w});function w(e){let t=e.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,``)}:null}async function T(e,r,i,a,o,s){if(o){let t=await c(e,r,o,s);if(t.status===`ok`){let e=n(t.files),r=[],i=a?a.replace(/^\/|\/$/g,``)+`/`:``;for(let t of Object.keys(e))if(t.startsWith(i)&&(t.split(`/`).pop()||``)===`SKILL.md`){let e=t.replace(/\/SKILL\.md$/,``),n=e.split(`/`).pop()||e;r.push({name:n,path:e})}return{skills:r}}}let u=[];async function d(n){let a=`https://api.github.com/repos/${e}/${r}/contents/${n}`,o=s?`${a}?ref=${encodeURIComponent(s)}`:a,c=await i.request(o);if(c.status!==200)throw Error(l(c,`${e}/${r}${n?`/${n}`:``}`,i.hasToken));let f=t(c.body);for(let e of f)if(e.type===`file`&&e.name===`SKILL.md`){let t=e.path.replace(`/SKILL.md`,``),n=t.split(`/`).pop()||t;u.push({name:n,path:t})}else e.type===`dir`&&await d(e.path)}try{return await d(a||``),{skills:u}}catch(e){return{skills:[],error:e instanceof Error?e.message:String(e)}}}async function E(e,t,n,r,i,a,o,s){let c=await h(t,n,a,o);await p(e,i,{kind:`github`,source:`${t}/${n}`,skill:i,ref:a,path:r.replace(/^\/|\/$/g,``),sha:c,files:s})}async function D(e,r,i,d,f,p,m=!1,h,g){let b=!1;try{let C=`${o}/${d}`;try{if(await f.stat(C),!m)return{stdout:``,stderr:`upskill: skill "${d}" already exists (use --force to overwrite)\n`,exitCode:1};b=!0,await a(f,C,await x(f,d))}catch{}if(h){let t=await c(e,r,h,g);if(t.status===`ok`){let a=n(t.files),o=i.replace(/^\/|\/$/g,``)+`/`;await f.mkdir(C,{recursive:!0});let c=await s(a,o,C,f);if(c.length>0)return await E(f,e,r,i,d,g,p,c),await v(),await _(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}}let w=`https://api.github.com/repos/${e}/${r}/contents/${i}`,T=g?`${w}?ref=${encodeURIComponent(g)}`:w,D=await p.request(T);if(D.status!==200)return{stdout:``,stderr:`upskill: ${l(D,`${e}/${r}/${i}`,p.hasToken)}\n`,exitCode:1};let O=t(D.body);await f.mkdir(C,{recursive:!0});let k;try{k=await u(O,C,e,r,g,f,p)}catch(e){throw await S(f,C,b),e}return await E(f,e,r,i,d,g,p,k),await y(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`upskill: failed to install from GitHub: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function O(e){let t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+?)(?:\/(.+?))?)?\/?$/);if(t)return{owner:t[1],repo:t[2],branch:t[3],path:t[4]};let n=e.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:@([a-zA-Z0-9_./-]+))?$/);return n?{owner:n[1],repo:n[2],branch:n[3]}:null}export{w as a,y as c,f as d,h as f,O as i,g as l,D as n,b as o,p,T as r,x as s,C as t,m as u};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./fetch-body-DDu_AU5I.js";import{a as n,c as r,d as i,f as a,g as o,o as s,r as c,s as l,t as u}from"./github-zip-D-H-YIqE.js";function d(e){return`${o}/${e}/.upskill`}async function f(e,t){try{let n=await e.readTextFile(d(t)),r=JSON.parse(n);return!r||typeof r!=`object`||!r.kind||!r.source?null:r}catch{return null}}async function p(e,t,n){try{let r={...n,version:1,installed:new Date().toISOString()};await e.writeFile(d(t),`${JSON.stringify(r,null,2)}\n`)}catch{}}async function m(e){let t;try{t=await e.readDir(o)}catch{return[]}let n=[];for(let r of t.sort((e,t)=>e.name.localeCompare(t.name))){if(r.type!==`directory`)continue;let t=await f(e,r.name);t&&n.push({name:r.name,provenance:t})}return n}async function h(e,n,r,i,a=!1){if(!(!i.hasToken&&!a))try{let a=r||`HEAD`,o=await i.request(`https://api.github.com/repos/${e}/${n}/commits/${encodeURIComponent(a)}`);if(o.status!==200)return;let s=t(o.body);return typeof s.sha==`string`?s.sha:void 0}catch{return}}function g(e){let t=`Installed from: ${e.kind}:${e.source}\n`;return e.ref&&(t+=`Ref: ${e.ref}\n`),e.path&&(t+=`Upstream path: ${e.path}\n`),e.sha&&(t+=`Commit: ${e.sha}\n`),t+=`Installed at: ${e.installed}\n`,t}async function _(){try{let e=(typeof window<`u`?window:globalThis).__slicc_reloadSkills;if(typeof e==`function`){await e();return}typeof chrome<`u`&&chrome?.runtime?.sendMessage&&chrome.runtime.sendMessage({source:`panel`,payload:{type:`reload-skills`}})}catch{}}async function v(){try{let e=globalThis.__slicc_sprinkleManager;typeof e?.openNewAutoOpenSprinkles==`function`&&await e.openNewAutoOpenSprinkles()}catch{}}async function y(){await v(),await _()}async function b(e,t,n,s,c=!1,l){let u=`${o}/${t}`,d=!1;try{if(await s.stat(u),!c)return{ok:!1,error:`skill "${t}" already exists (use --force to overwrite)`};d=!0,await a(s,u,await x(s,t))}catch{}let f=e.replace(/^\/|\/$/g,``),m=f?f+`/`:``;await s.mkdir(u,{recursive:!0});let h=0,g=[];try{for(let[e,t]of Object.entries(n)){if(!e.startsWith(m))continue;let n=e.slice(m.length);if(!n||e.endsWith(`/`)||!await i(s,u,n)||!r(n))continue;let a=`${u}/${n}`,o=a.substring(0,a.lastIndexOf(`/`));o!==u&&await s.mkdir(o,{recursive:!0}),await s.writeFile(a,t),g.push(n),h++}}catch(e){throw await S(s,u,d),e}return h===0?(await S(s,u,d),{ok:!1,error:`no files found for skill "${t}" in ZIP`}):(l&&await p(s,t,{...l,skill:t,files:g.sort()}),{ok:!0})}async function x(e,t){let n=await f(e,t);return n?.files?.length?new Set(n.files):void 0}async function S(e,t,n){if(n){await a(e,t).catch(()=>!1);return}await e.rm(t,{recursive:!0}).catch(()=>{})}var C=e({installFromGitHub:()=>D,listGitHubSkills:()=>T,parseGitHubRef:()=>O,parseGitHubUrl:()=>w});function w(e){let t=e.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,``)}:null}async function T(e,r,i,a,o,s){if(o){let t=await c(e,r,o,s);if(t.status===`ok`){let e=n(t.files),r=[],i=a?a.replace(/^\/|\/$/g,``)+`/`:``;for(let t of Object.keys(e))if(t.startsWith(i)&&(t.split(`/`).pop()||``)===`SKILL.md`){let e=t.replace(/\/SKILL\.md$/,``),n=e.split(`/`).pop()||e;r.push({name:n,path:e})}return{skills:r}}}let u=[];async function d(n){let a=`https://api.github.com/repos/${e}/${r}/contents/${n}`,o=s?`${a}?ref=${encodeURIComponent(s)}`:a,c=await i.request(o);if(c.status!==200)throw Error(l(c,`${e}/${r}${n?`/${n}`:``}`,i.hasToken));let f=t(c.body);for(let e of f)if(e.type===`file`&&e.name===`SKILL.md`){let t=e.path.replace(`/SKILL.md`,``),n=t.split(`/`).pop()||t;u.push({name:n,path:t})}else e.type===`dir`&&await d(e.path)}try{return await d(a||``),{skills:u}}catch(e){return{skills:[],error:e instanceof Error?e.message:String(e)}}}async function E(e,t,n,r,i,a,o,s){let c=await h(t,n,a,o);await p(e,i,{kind:`github`,source:`${t}/${n}`,skill:i,ref:a,path:r.replace(/^\/|\/$/g,``),sha:c,files:s})}async function D(e,r,i,d,f,p,m=!1,h,g){let b=!1;try{let C=`${o}/${d}`;try{if(await f.stat(C),!m)return{stdout:``,stderr:`upskill: skill "${d}" already exists (use --force to overwrite)\n`,exitCode:1};b=!0,await a(f,C,await x(f,d))}catch{}if(h){let t=await c(e,r,h,g);if(t.status===`ok`){let a=n(t.files),o=i.replace(/^\/|\/$/g,``)+`/`;await f.mkdir(C,{recursive:!0});let c=await s(a,o,C,f);if(c.length>0)return await E(f,e,r,i,d,g,p,c),await v(),await _(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}}let w=`https://api.github.com/repos/${e}/${r}/contents/${i}`,T=g?`${w}?ref=${encodeURIComponent(g)}`:w,D=await p.request(T);if(D.status!==200)return{stdout:``,stderr:`upskill: ${l(D,`${e}/${r}/${i}`,p.hasToken)}\n`,exitCode:1};let O=t(D.body);await f.mkdir(C,{recursive:!0});let k;try{k=await u(O,C,e,r,g,f,p)}catch(e){throw await S(f,C,b),e}return await E(f,e,r,i,d,g,p,k),await y(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`upskill: failed to install from GitHub: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function O(e){let t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+?)(?:\/(.+?))?)?\/?$/);if(t)return{owner:t[1],repo:t[2],branch:t[3],path:t[4]};let n=e.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:@([a-zA-Z0-9_./-]+))?$/);return n?{owner:n[1],repo:n[2],branch:n[3]}:null}export{w as a,y as c,f as d,h as f,O as i,g as l,D as n,b as o,p,T as r,x as s,C as t,m as u};
@@ -1 +1 @@
1
- import"./proxied-fetch-Co-pb0x0.js";import{H as e,S as t,d as n}from"./account-store-UhvCpVi5.js";import{r}from"./api-endpoint-C00IT5T9.js";import{r as i,t as a}from"./tray-runtime-config-CVoPQrT2.js";import{t as o}from"./global-db-DJXlpNui.js";import{r as s,t as c}from"./silent-renew-backoff-C_Iv54ZG.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-CTntqv0R.js";import"./provider-settings-BcDzUFLS.js";var d={clientId:``,scopes:`repo,read:user,user:email`};function f(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return a}async function p(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return t}async function m(e){let t=`${f()}/oauth/token`;return p(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function h(e){let t=`${f()}/oauth/token`;return p(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function g(e){let t=`${f()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}const _=Object.assign({"/packages/webapp/providers/github-config.json":d})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`};let v=null,y=null;function b(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,bridgeApiBaseUrl:o,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(o&&a&&s(a)){let t=null;try{let e=new URL(o);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function x(){if(v)return v;if(S){try{let e=await fetch(`${f()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,v}}catch{}return _.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,t.trayWorkerBaseUrl&&(y=t.trayWorkerBaseUrl),v;if(t.trayWorkerBaseUrl){y=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,v}}}}catch{}return _.clientId}const S=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function C(){return n().find(e=>e.providerId===`github`)}function w(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function T(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e,t){return`${e}+${t}@users.noreply.github.com`}async function D(e){try{let{VirtualFS:t}=await import(`./fs-5TZPzTFc.js`).then(e=>e.t);await(await t.create({dbName:o})).writeFile(`/workspace/.git/github-token`,e),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function O(){try{let{VirtualFS:e}=await import(`./fs-5TZPzTFc.js`).then(e=>e.t);await(await e.create({dbName:o})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function k(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await import(`./fs-5TZPzTFc.js`).then(e=>e.t),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:r}=await import(`./git-config-DA8M5e8O.js`).then(e=>e.n),i=await t.create({dbName:o}),a=e.name||e.login,s=E(e.id,e.login);!await n(i,`user.name`)&&a&&await r(i,`user.name`,a),await n(i,`user.email`)||await r(i,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}const A=c();async function j(){try{let n=C();if(!n?.refreshToken)return null;let r=await h({provider:`github`,refreshToken:n.refreshToken});await e({providerId:`github`,accessToken:r.access_token,refreshToken:r.refresh_token,tokenExpiresAt:r.expires_in?Date.now()+r.expires_in*1e3:void 0,userName:n.userName,userAvatar:n.userAvatar,scopes:r.scope??n.scopes});let i=t(`github`)?.maskedValue;return i?await D(i):await O(),r.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}async function M(){let e=C();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return e.accessToken;let t=await A.run(()=>j());if(t)return t;let n=C();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`GitHub session expired — please log in again`)}const N={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(n,i,a)=>{let o=await x();if(!o)throw Error(`GitHub OAuth not configured — no client ID available`);let s=a?.scopes??_.scopes,c=S?null:await l(),d=!S&&await u(),p=crypto.randomUUID(),h=S?chrome.runtime.id:``,{redirectUri:g,state:v}=b({isExtension:S,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:f(),runtimeWorkerBaseUrl:y,pageOrigin:c?.origin??null,pageHref:c?.href??null,bridgeApiBaseUrl:r(),delegated:d,extensionId:h,nonce:p}),C=btoa(JSON.stringify(v)),E=p,A=new URLSearchParams({client_id:o,scope:s,redirect_uri:g});C&&A.set(`state`,C);let j=await n(`https://github.com/login/oauth/authorize?${A}`);if(!j)return;if(E)try{if(new URL(j).searchParams.get(`nonce`)!==E){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let M=w(j);if(!M){console.error(`[github] Could not extract authorization code from redirect URL`);return}let N=await m({provider:`github`,code:M,redirectUri:g}),P=await T(N.access_token);await e({providerId:`github`,accessToken:N.access_token,refreshToken:N.refresh_token,tokenExpiresAt:N.expires_in?Date.now()+N.expires_in*1e3:void 0,userName:P.name,userAvatar:P.avatar,scopes:N.scope});let F=t(`github`)?.maskedValue;F?await D(F):await O(),await k(P),i()},onSilentRenew:j,getValidAccessToken:M,onOAuthLogout:async()=>{let t=C();t?.accessToken&&await g({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await O(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{E as buildNoreplyEmail,N as config,w as extractCodeFromUrl,M as getValidAccessToken,b as resolveGithubOAuthRedirect,k as syncGitIdentityFromGitHub};
1
+ import"./proxied-fetch-Co-pb0x0.js";import{H as e,S as t,d as n}from"./account-store-DADHAp2B.js";import{r}from"./api-endpoint-C00IT5T9.js";import{r as i,t as a}from"./tray-runtime-config-CVoPQrT2.js";import{t as o}from"./global-db-DJXlpNui.js";import{r as s,t as c}from"./silent-renew-backoff-C_Iv54ZG.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-CTntqv0R.js";import"./provider-settings-CqfNX_ir.js";var d={clientId:``,scopes:`repo,read:user,user:email`};function f(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return a}async function p(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return t}async function m(e){let t=`${f()}/oauth/token`;return p(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function h(e){let t=`${f()}/oauth/token`;return p(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function g(e){let t=`${f()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}const _=Object.assign({"/packages/webapp/providers/github-config.json":d})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`};let v=null,y=null;function b(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,bridgeApiBaseUrl:o,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(o&&a&&s(a)){let t=null;try{let e=new URL(o);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function x(){if(v)return v;if(S){try{let e=await fetch(`${f()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,v}}catch{}return _.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,t.trayWorkerBaseUrl&&(y=t.trayWorkerBaseUrl),v;if(t.trayWorkerBaseUrl){y=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,v}}}}catch{}return _.clientId}const S=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function C(){return n().find(e=>e.providerId===`github`)}function w(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function T(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e,t){return`${e}+${t}@users.noreply.github.com`}async function D(e){try{let{VirtualFS:t}=await import(`./fs-Dh6IiuaU.js`).then(e=>e.t);await(await t.create({dbName:o})).writeFile(`/workspace/.git/github-token`,e),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function O(){try{let{VirtualFS:e}=await import(`./fs-Dh6IiuaU.js`).then(e=>e.t);await(await e.create({dbName:o})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function k(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await import(`./fs-Dh6IiuaU.js`).then(e=>e.t),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:r}=await import(`./git-config-DA8M5e8O.js`).then(e=>e.n),i=await t.create({dbName:o}),a=e.name||e.login,s=E(e.id,e.login);!await n(i,`user.name`)&&a&&await r(i,`user.name`,a),await n(i,`user.email`)||await r(i,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}const A=c();async function j(){try{let n=C();if(!n?.refreshToken)return null;let r=await h({provider:`github`,refreshToken:n.refreshToken});await e({providerId:`github`,accessToken:r.access_token,refreshToken:r.refresh_token,tokenExpiresAt:r.expires_in?Date.now()+r.expires_in*1e3:void 0,userName:n.userName,userAvatar:n.userAvatar,scopes:r.scope??n.scopes});let i=t(`github`)?.maskedValue;return i?await D(i):await O(),r.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}async function M(){let e=C();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return e.accessToken;let t=await A.run(()=>j());if(t)return t;let n=C();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`GitHub session expired — please log in again`)}const N={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(n,i,a)=>{let o=await x();if(!o)throw Error(`GitHub OAuth not configured — no client ID available`);let s=a?.scopes??_.scopes,c=S?null:await l(),d=!S&&await u(),p=crypto.randomUUID(),h=S?chrome.runtime.id:``,{redirectUri:g,state:v}=b({isExtension:S,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:f(),runtimeWorkerBaseUrl:y,pageOrigin:c?.origin??null,pageHref:c?.href??null,bridgeApiBaseUrl:r(),delegated:d,extensionId:h,nonce:p}),C=btoa(JSON.stringify(v)),E=p,A=new URLSearchParams({client_id:o,scope:s,redirect_uri:g});C&&A.set(`state`,C);let j=await n(`https://github.com/login/oauth/authorize?${A}`);if(!j)return;if(E)try{if(new URL(j).searchParams.get(`nonce`)!==E){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let M=w(j);if(!M){console.error(`[github] Could not extract authorization code from redirect URL`);return}let N=await m({provider:`github`,code:M,redirectUri:g}),P=await T(N.access_token);await e({providerId:`github`,accessToken:N.access_token,refreshToken:N.refresh_token,tokenExpiresAt:N.expires_in?Date.now()+N.expires_in*1e3:void 0,userName:P.name,userAvatar:P.avatar,scopes:N.scope});let F=t(`github`)?.maskedValue;F?await D(F):await O(),await k(P),i()},onSilentRenew:j,getValidAccessToken:M,onOAuthLogout:async()=>{let t=C();t?.accessToken&&await g({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await O(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{E as buildNoreplyEmail,N as config,w as extractCodeFromUrl,M as getValidAccessToken,b as resolveGithubOAuthRedirect,k as syncGitIdentityFromGitHub};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./binary-cache-bSOhqXB1.js";import{n,r,t as i}from"./fetch-body-DDu_AU5I.js";import{n as a}from"./fs-5TZPzTFc.js";import{r as o}from"./browser-2rCVqcqy.js";import{t as s}from"./global-db-DJXlpNui.js";const c=`https://api.tessl.io`,l=`https://browse.sh/api/skills`,u=`/workspace/skills`,d=s,f=`application/vnd.github.v3+json`,p=`https://www.sliccy.com/skills/`,m=`${p}catalog.json`;function h(e){return e.split(`/`).some(e=>e.startsWith(`.`))}async function g(e,t,n){return!h(n)||!await e.exists(`${t}/${n}`)}async function _(e,t,n,r=``){let i;try{i=await e.readDir(t)}catch{return!1}let a=!1;for(let o of i){let i=`${t}/${o.name}`,s=r?`${r}/${o.name}`:o.name;if(o.name.startsWith(`.`)){a=!0;continue}o.type===`directory`?await _(e,i,n,s)?a=!0:await e.rm(i,{recursive:!0}):n&&!n.has(s)?a=!0:await e.rm(i)}return a}async function v(e,t,n=!1,r=``){let i;try{i=await e.readDir(t)}catch{return[]}let a=[];for(let o of i){if(!n&&o.name.startsWith(`.`))continue;let i=r?`${r}/${o.name}`:o.name;o.type===`directory`?a.push(...await v(e,`${t}/${o.name}`,n,i)):a.push(i)}return a.sort()}function y(e,t){let n=e instanceof Error?e.message:String(e),r;try{r=new URL(t).host}catch{return n}return!r||n.includes(r)?n:`${n} (host: ${r} — network or CORS error)`}let b;function x(){return b||=a.create({dbName:d}),b}async function S(){try{return(await(await x()).readTextFile(`/workspace/.git/github-token`)).trim()||void 0}catch{return}}function C(e,t=f){let n={Accept:t,"User-Agent":`slicc-upskill`};return e&&(n.Authorization=`Bearer ${e}`),n}async function w(e){let t=await S();return{hasToken:!!t,request:async(n,r=f)=>{try{return await e(n,{headers:C(t,r)})}catch(e){throw Error(y(e,n))}}}}function T(e,t){if(!e)return;let n=t.toLowerCase();for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n)return r}function E(e){return!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)?!1:!e.split(`/`).some(e=>e===``||e===`.`||e===`..`)}function D(e){let t=i(e);if(!t)return;try{let e=JSON.parse(t);if(typeof e.message==`string`&&e.message.trim())return e.message.trim()}catch{}let n=t.trim();if(n)return n.slice(0,200)}function O(e,t,n){let r=D(e.body),i=r?` GitHub said: ${r}`:``,a=T(e.headers,`retry-after`),o=T(e.headers,`x-ratelimit-remaining`),s=r?.toLowerCase()??``;if(e.status===429||o===`0`||s.includes(`rate limit`))return n?`GitHub rate-limited access to ${t} (HTTP ${e.status}). The configured github.token was used, so retry later${a?` after about ${a} seconds`:``}.${i}`:`GitHub rate-limited anonymous access to ${t} (HTTP ${e.status}). This often happens on shared VPNs or corporate egress IPs because unauthenticated GitHub API requests are limited per IP. Configure a token with: git config github.token <PAT>, then retry. You can also retry off VPN or later.${i}`;if(e.status===401)return n?`GitHub rejected the configured github.token while accessing ${t} (HTTP 401). Update it with: git config github.token <PAT>, then retry.${i}`:`GitHub requires authentication to access ${t} (HTTP 401). Configure a token with: git config github.token <PAT>, then retry.${i}`;if(e.status===404)return`GitHub could not find ${t} (HTTP 404). Check the repository, path, and permissions.${i}`;if(e.status===403)return n?`GitHub denied access to ${t} (HTTP 403). Check that your github.token can access this repository or retry later if GitHub is throttling requests.${i}`:`GitHub denied anonymous access to ${t} (HTTP 403). If this repo is public on a shared VPN, you may have hit GitHub's shared IP limit; otherwise the repository or path may require authentication. Configure a token with: git config github.token <PAT>, then retry.${i}`;let c=e.statusText?` ${e.statusText}`:``;return`GitHub request for ${t} failed (HTTP ${e.status}${c}).${i}`}var k=e({downloadGitHubDir:()=>P,fetchGitHubDirFiles:()=>N,fetchRepoZip:()=>A,stripZipPrefix:()=>j,writeZipFilesToDir:()=>M});async function A(e,r,i,a=`main`){let s=`https://codeload.github.com/${e}/${r}/zip/refs/heads/${a}`,c;try{c=await i(s,{headers:{"User-Agent":`slicc-upskill`}})}catch(e){return{status:`error`,message:y(e,s)}}if(c.status===404)return a===`main`?A(e,r,i,`master`):{status:`error`,message:`codeload returned HTTP 404`};if(c.status!==200)return{status:`error`,message:`codeload returned HTTP ${c.status}`};let l=t(s);l||=n(c.body);try{return{status:`ok`,files:o(l)}}catch(e){return{status:`error`,message:`failed to unzip: ${e instanceof Error?e.message:String(e)}`}}}function j(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.indexOf(`/`);if(e<0)continue;let i=n.slice(e+1);i&&(t[i]=r)}return t}async function M(e,t,n,r,i=!0){let a=[];for(let[o,s]of Object.entries(e)){if(!o.startsWith(t))continue;let e=o.slice(t.length);if(o.endsWith(`/`)||!E(e)||i&&!await g(r,n,e))continue;let c=`${n}/${e}`,l=c.substring(0,c.lastIndexOf(`/`));l!==n&&await r.mkdir(l,{recursive:!0}),await r.writeFile(c,s),a.push(e)}return a.sort()}async function N(e,i,a,o,s,c=new Map,l=``){let u=`https://api.github.com/repos/${e}/${i}/contents/${a}`,d=o?`${u}?ref=${encodeURIComponent(o)}`:u,f=await s.request(d);if(f.status!==200)throw Error(O(f,`${e}/${i}${a?`/${a}`:``}`,s.hasToken));for(let a of r(f.body)){let r=l?`${l}/${a.name}`:a.name;if(E(r))if(a.type===`file`&&a.download_url){let o=await s.request(a.download_url,`*/*`);if(o.status!==200)throw Error(O(o,`${e}/${i}/${a.path}`,s.hasToken));let l=t(a.download_url);c.set(r,l??n(o.body))}else a.type===`dir`&&await N(e,i,a.path,o,s,c,r)}return c}async function P(e,n,i,a,o,s,c,l=[],u=``){for(let d of e){let e=u?`${u}/${d.name}`:d.name;if(E(e)){if(d.type===`file`&&d.download_url){if(h(e)&&await s.exists(`${n}/${d.name}`))continue;let r=await c.request(d.download_url,`*/*`);if(r.status!==200)throw Error(O(r,`${i}/${a}/${d.path}`,c.hasToken));let o=t(d.download_url);await s.writeFile(`${n}/${d.name}`,o??r.body),l.push(e)}else if(d.type===`dir`){let t=`https://api.github.com/repos/${i}/${a}/contents/${d.path}`,u=o?`${t}?ref=${encodeURIComponent(o)}`:t,f=await c.request(u);if(f.status!==200)throw Error(O(f,`${i}/${a}/${d.path}`,c.hasToken));let p=r(f.body);await s.mkdir(`${n}/${d.name}`,{recursive:!0}),await P(p,`${n}/${d.name}`,i,a,o,s,c,l,e)}}}return l.sort()}export{p as _,j as a,E as c,g as d,_ as f,u as g,l as h,k as i,w as l,v as m,N as n,M as o,h as p,A as r,O as s,P as t,y as u,m as v,c as y};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./binary-cache-bSOhqXB1.js";import{n,r,t as i}from"./fetch-body-DDu_AU5I.js";import{n as a}from"./fs-Dh6IiuaU.js";import{r as o}from"./browser-2rCVqcqy.js";import{t as s}from"./global-db-DJXlpNui.js";const c=`https://api.tessl.io`,l=`https://browse.sh/api/skills`,u=`/workspace/skills`,d=s,f=`application/vnd.github.v3+json`,p=`https://www.sliccy.com/skills/`,m=`${p}catalog.json`;function h(e){return e.split(`/`).some(e=>e.startsWith(`.`))}async function g(e,t,n){return!h(n)||!await e.exists(`${t}/${n}`)}async function _(e,t,n,r=``){let i;try{i=await e.readDir(t)}catch{return!1}let a=!1;for(let o of i){let i=`${t}/${o.name}`,s=r?`${r}/${o.name}`:o.name;if(o.name.startsWith(`.`)){a=!0;continue}o.type===`directory`?await _(e,i,n,s)?a=!0:await e.rm(i,{recursive:!0}):n&&!n.has(s)?a=!0:await e.rm(i)}return a}async function v(e,t,n=!1,r=``){let i;try{i=await e.readDir(t)}catch{return[]}let a=[];for(let o of i){if(!n&&o.name.startsWith(`.`))continue;let i=r?`${r}/${o.name}`:o.name;o.type===`directory`?a.push(...await v(e,`${t}/${o.name}`,n,i)):a.push(i)}return a.sort()}function y(e,t){let n=e instanceof Error?e.message:String(e),r;try{r=new URL(t).host}catch{return n}return!r||n.includes(r)?n:`${n} (host: ${r} — network or CORS error)`}let b;function x(){return b||=a.create({dbName:d}),b}async function S(){try{return(await(await x()).readTextFile(`/workspace/.git/github-token`)).trim()||void 0}catch{return}}function C(e,t=f){let n={Accept:t,"User-Agent":`slicc-upskill`};return e&&(n.Authorization=`Bearer ${e}`),n}async function w(e){let t=await S();return{hasToken:!!t,request:async(n,r=f)=>{try{return await e(n,{headers:C(t,r)})}catch(e){throw Error(y(e,n))}}}}function T(e,t){if(!e)return;let n=t.toLowerCase();for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n)return r}function E(e){return!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)?!1:!e.split(`/`).some(e=>e===``||e===`.`||e===`..`)}function D(e){let t=i(e);if(!t)return;try{let e=JSON.parse(t);if(typeof e.message==`string`&&e.message.trim())return e.message.trim()}catch{}let n=t.trim();if(n)return n.slice(0,200)}function O(e,t,n){let r=D(e.body),i=r?` GitHub said: ${r}`:``,a=T(e.headers,`retry-after`),o=T(e.headers,`x-ratelimit-remaining`),s=r?.toLowerCase()??``;if(e.status===429||o===`0`||s.includes(`rate limit`))return n?`GitHub rate-limited access to ${t} (HTTP ${e.status}). The configured github.token was used, so retry later${a?` after about ${a} seconds`:``}.${i}`:`GitHub rate-limited anonymous access to ${t} (HTTP ${e.status}). This often happens on shared VPNs or corporate egress IPs because unauthenticated GitHub API requests are limited per IP. Configure a token with: git config github.token <PAT>, then retry. You can also retry off VPN or later.${i}`;if(e.status===401)return n?`GitHub rejected the configured github.token while accessing ${t} (HTTP 401). Update it with: git config github.token <PAT>, then retry.${i}`:`GitHub requires authentication to access ${t} (HTTP 401). Configure a token with: git config github.token <PAT>, then retry.${i}`;if(e.status===404)return`GitHub could not find ${t} (HTTP 404). Check the repository, path, and permissions.${i}`;if(e.status===403)return n?`GitHub denied access to ${t} (HTTP 403). Check that your github.token can access this repository or retry later if GitHub is throttling requests.${i}`:`GitHub denied anonymous access to ${t} (HTTP 403). If this repo is public on a shared VPN, you may have hit GitHub's shared IP limit; otherwise the repository or path may require authentication. Configure a token with: git config github.token <PAT>, then retry.${i}`;let c=e.statusText?` ${e.statusText}`:``;return`GitHub request for ${t} failed (HTTP ${e.status}${c}).${i}`}var k=e({downloadGitHubDir:()=>P,fetchGitHubDirFiles:()=>N,fetchRepoZip:()=>A,stripZipPrefix:()=>j,writeZipFilesToDir:()=>M});async function A(e,r,i,a=`main`){let s=`https://codeload.github.com/${e}/${r}/zip/refs/heads/${a}`,c;try{c=await i(s,{headers:{"User-Agent":`slicc-upskill`}})}catch(e){return{status:`error`,message:y(e,s)}}if(c.status===404)return a===`main`?A(e,r,i,`master`):{status:`error`,message:`codeload returned HTTP 404`};if(c.status!==200)return{status:`error`,message:`codeload returned HTTP ${c.status}`};let l=t(s);l||=n(c.body);try{return{status:`ok`,files:o(l)}}catch(e){return{status:`error`,message:`failed to unzip: ${e instanceof Error?e.message:String(e)}`}}}function j(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.indexOf(`/`);if(e<0)continue;let i=n.slice(e+1);i&&(t[i]=r)}return t}async function M(e,t,n,r,i=!0){let a=[];for(let[o,s]of Object.entries(e)){if(!o.startsWith(t))continue;let e=o.slice(t.length);if(o.endsWith(`/`)||!E(e)||i&&!await g(r,n,e))continue;let c=`${n}/${e}`,l=c.substring(0,c.lastIndexOf(`/`));l!==n&&await r.mkdir(l,{recursive:!0}),await r.writeFile(c,s),a.push(e)}return a.sort()}async function N(e,i,a,o,s,c=new Map,l=``){let u=`https://api.github.com/repos/${e}/${i}/contents/${a}`,d=o?`${u}?ref=${encodeURIComponent(o)}`:u,f=await s.request(d);if(f.status!==200)throw Error(O(f,`${e}/${i}${a?`/${a}`:``}`,s.hasToken));for(let a of r(f.body)){let r=l?`${l}/${a.name}`:a.name;if(E(r))if(a.type===`file`&&a.download_url){let o=await s.request(a.download_url,`*/*`);if(o.status!==200)throw Error(O(o,`${e}/${i}/${a.path}`,s.hasToken));let l=t(a.download_url);c.set(r,l??n(o.body))}else a.type===`dir`&&await N(e,i,a.path,o,s,c,r)}return c}async function P(e,n,i,a,o,s,c,l=[],u=``){for(let d of e){let e=u?`${u}/${d.name}`:d.name;if(E(e)){if(d.type===`file`&&d.download_url){if(h(e)&&await s.exists(`${n}/${d.name}`))continue;let r=await c.request(d.download_url,`*/*`);if(r.status!==200)throw Error(O(r,`${i}/${a}/${d.path}`,c.hasToken));let o=t(d.download_url);await s.writeFile(`${n}/${d.name}`,o??r.body),l.push(e)}else if(d.type===`dir`){let t=`https://api.github.com/repos/${i}/${a}/contents/${d.path}`,u=o?`${t}?ref=${encodeURIComponent(o)}`:t,f=await c.request(u);if(f.status!==200)throw Error(O(f,`${i}/${a}/${d.path}`,c.hasToken));let p=r(f.body);await s.mkdir(`${n}/${d.name}`,{recursive:!0}),await P(p,`${n}/${d.name}`,i,a,o,s,c,l,e)}}}return l.sort()}export{p as _,j as a,E as c,g as d,_ as f,u as g,l as h,k as i,w as l,v as m,N as n,M as o,h as p,A as r,O as s,P as t,y as u,m as v,c as y};
@@ -8,7 +8,7 @@ import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./safe-b
8
8
  `}},Dt=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 J(`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}},Ot=class e{constructor(e=[]){this.rules=e}static from(t){let n=[];for(let e of t)n.push(Dt.from(e));return new e(n)}add(e){let t=Dt.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 kt(e,t){let n=e.replace(/\^\{\}$/,``),r=t.replace(/\^\{\}$/,``),i=-(n<r)||+(n>r);return i===0?e.endsWith(`^{}`)?1:-1:i}function At(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 jt(e){return e.length>=2&&/^[a-zA-Z]:/.test(e)?e.slice(0,2):null}function Mt(e){if(!e.length)return`.`;e=e.replace(/\\/g,`/`);let t=jt(e),n=e[0]===`/`||t!==null&&e[2]===`/`,r=e.at(-1)===`/`,i=At(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?`.`:Mt(t)}var Nt=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},Pt=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}`)},Ft={core:{filemode:Pt,bare:Pt,logallrefupdates:Pt,symlinks:Pt,ignorecase:Pt,bigFileThreshold:Nt}},It=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,Lt=/^[A-Za-z0-9-.]+$/,Rt=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,zt=/^[A-Za-z][A-Za-z-]*$/,Bt=/^(.*?)( *[#;].*)$/,Vt=e=>{let t=It.exec(e);if(t!=null){let[e,n]=t.slice(1);return[e,n]}return null},Ht=e=>{let t=Rt.exec(e);if(t!=null){let[e,n=`true`]=t.slice(1);return[e,Gt(Ut(n))]}return null},Ut=e=>{let t=Bt.exec(e);if(t==null)return e;let[n,r]=t.slice(1);return Wt(n)&&Wt(r)?`${n}${r}`:n},Wt=e=>(e.match(/(?:^|[^\\])"/g)||[]).length%2!=0,Gt=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},``),Kt=e=>e==null?null:e.toLowerCase(),qt=(e,t,n)=>[Kt(e),t,Kt(n)].filter(e=>e!=null).join(`.`),Jt=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}},Yt=(e,t)=>e.reduce((e,n,r)=>t(n)?r:e,-1),Xt=class e{constructor(e){let t=null,n=null;this.parsedConfig=e?e.split(`
9
9
  `).map(e=>{let r=null,i=null,a=e.trim(),o=Vt(a),s=o!=null;if(s)[t,n]=o;else{let e=Ht(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=Jt(e).path,r=this.parsedConfig.filter(e=>e.path===n).map(({section:e,name:t,value:n})=>{let r=Ft[e]&&Ft[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}=Jt(e),l=Yt(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(Lt.test(r)&&zt.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
10
  `)}},Zt=class{static async get({fs:e,gitdir:t}){let n=await e.read(`${t}/config`,{encoding:`utf8`});return Xt.from(n)}static async save({fs:e,gitdir:t,config:n}){await e.write(`${t}/config`,n.toString(),{encoding:`utf8`})}},Qt=e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],$t=[`config`,`description`,`index`,`shallow`,`commondir`];function en(e){if($t.includes(e))throw new wt(e,`refs/heads/${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 Ct(e);let u=await Zt.get({fs:t,gitdir:n});if(!s){if(s=await u.getall(`remote.${r}.fetch`),s.length===0)throw new Tt(r);s.unshift(`+HEAD:refs/remotes/${r}/HEAD`)}let d=Ot.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&&m.push([t,`ref: ${n}`])}for(let[,e]of p)en(e);for(let[e]of m)en(e);if(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}`)})}if(o){for(let r of i.keys())if(r.startsWith(`refs/tags`)&&!r.endsWith(`^{}`)&&!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 h=[];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)||h.push(e)}h.length>0&&await e.deleteRefs({fs:t,gitdir:n,refs:h})}for(let[e,r]of f)await ct(e,async()=>t.write(Y(n,e),`${r.trim()}\n`,`utf8`));return{pruned:h}}static async writeRef({fs:e,gitdir:t,ref:n,value:r}){if(en(n),!r.match(/[0-9a-f]{40}/))throw new Ct(r);await ct(n,async()=>e.write(Y(t,n),`${r.trim()}\n`,`utf8`))}static async writeSymbolicRef({fs:e,gitdir:t,ref:n,value:r}){en(n),await ct(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(en),await Promise.all(n.map(n=>e.rm(Y(t,n))));let r=await ct(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`})),i=Et.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 ct(`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=Qt(r).filter(e=>!$t.includes(e));for(let r of s){let s=await ct(r,async()=>await t.read(`${n}/${r}`,{encoding:`utf8`})||o.get(r));if(s){if(a.has(r))throw new J(`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 xt(r)}static async exists({fs:t,gitdir:n,ref:r}){try{return await e.expand({fs:t,gitdir:n,ref:r}),!0}catch{return!1}}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=Qt(r).filter(e=>!$t.includes(e));for(let e of a)if(await ct(e,async()=>t.exists(`${n}/${e}`))||i.has(e))return e;throw new xt(r)}static async expandAgainstMap({ref:e,map:t}){let n=Qt(e);for(let e of n)if(await t.has(e))return e;throw new xt(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=Qt(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 xt(t)}static async packedRefs({fs:e,gitdir:t}){let n=await ct(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`}));return Et.from(n).refs}static async listRefs({fs:t,gitdir:n,filepath:r}){let i=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(await i).keys())e.startsWith(r)&&(e=e.replace(r+`/`,``),a.includes(e)||a.push(e));return a.sort(kt),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 tn(e,t){return We(nn(e),nn(t))}function nn(e){return e.mode===`040000`?e.path+`/`:e.path}function rn(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 J(`Unexpected GitTree entry mode: ${e}`)}function an(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(32,n);if(r===-1)throw new J(`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 J(`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=rn(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 He(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 on(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 J(`Could not understand file mode: ${e}`)}function sn(e){return!e.oid&&e.sha&&(e.oid=e.sha),e.mode=on(e.mode),e.type||=rn(e.mode),e}var cn=class e{constructor(e){if(Buffer.isBuffer(e))this._entries=an(e);else if(Array.isArray(e))this._entries=e.map(sn);else throw new J(`invalid type passed to GitTree constructor`);this._entries.sort(Ge)}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(tn),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}},ln=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 J(`Length mismatch: expected ${i} bytes but got ${a} instead.`);return{type:r,object:Buffer.from(e.slice(n+1))}}};async function un({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 dn(e,t){let n=new Ue(e),r=fn(n);if(r!==t.byteLength)throw new J(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${t.length} bytes`);let i=fn(n),a,o=mn(n,t);if(o.byteLength===i)a=o;else{let e=[o],r=o.byteLength;for(;!n.eof();){let i=mn(n,t);e.push(i),r+=i.byteLength}if(i!==r)throw new J(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${r} bytes`);a=Buffer.concat(e,i)}return a}function fn(e){let t=0,n=0,r=null;do r=e.readUInt8(),t|=(r&127)<<n,n+=7;while(r&128);return t}function pn(e,t,n){let r=0,i=0;for(;n--;)t&1&&(r|=e.readUInt8()<<i),t>>=1,i+=8;return r}function mn(e,t){let n=e.readUInt8();if(n&128){let r=pn(e,n&15,4),i=pn(e,(n&112)>>4,3);return i===0&&(i=65536),t.slice(r,r+i)}return e.slice(n)}function hn(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function gn(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:hn(e)}var _n=class{constructor(e){if(typeof Buffer>`u`)throw Error(`Missing Buffer dependency`);this.stream=gn(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>vn(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 vn(e){return e.reduce((e,t)=>e+t.length,0)}async function yn(e,t){let n=new _n(e),r=await n.read(4);if(r=r.toString(`utf8`),r!==`PACK`)throw new J(`Invalid PACK header '${r}'`);let i=await n.read(4);if(i=i.readUInt32BE(0),i!==2)throw new J(`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 bn(n),c=new Ie.default.Inflate;for(;!c.result;){let l=await n.chunk();if(!l)break;if(c.push(l,!1),c.err)throw new J(`Pako error: ${c.msg}`);if(c.result){if(c.result.length!==i)throw new J(`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 bn(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 xn=!1;async function Sn(e){return xn===null&&(xn=wn()),xn?Cn(e):Ie.default.inflate(e)}async function Cn(e){let t=new DecompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function wn(){try{if(new DecompressionStream(`deflate`))return!0}catch{}return!1}function Tn(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 En(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 Dn=class e{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:n}){let r=new Ue(t);if(r.slice(4).toString(`hex`)!==`ff744f63`)return;let i=r.readUInt32BE();if(i!==2)throw new J(`Unable to read version ${i} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2147483648)throw new J(`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 yn([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=Fe.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 Qe(ln.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 Ue(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 Ue(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)r.writeUInt32BE(this.crcs[e]);e.push(r.buffer);let i=new Ue(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 Qe(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 J(`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 J(`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 Ue(r),a=i.readUInt8(),o=a&112,s=t[o];if(s===void 0)throw new J(`Unrecognized type: 0b`+o.toString(2));let c=a&15,l=c;a&128&&(l=En(i,c));let u=null,d=null;if(s===`ofs_delta`){let t=e-Tn(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 Sn(f)),d.byteLength!==l)throw new J(`Packfile told us object would have length ${l} but it had length ${d.byteLength}`);return u&&(d=Buffer.from(dn(d,u))),this.readDepth>3&&(this.offsetCache[e]={type:s,object:d}),{type:s,format:`content`,object:d}}},On=Symbol(`PackfileCache`);async function kn({fs:e,filename:t,getExternalRefDelta:n,emitter:r,emitterPrefix:i}){let a=await e.read(t);return Dn.fromIdx({idx:a,getExternalRefDelta:n})}function An({fs:e,cache:t,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}){t[On]||(t[On]=new Map);let o=t[On].get(n);return o||(o=kn({fs:e,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}),t[On].set(n,o)),o}async function jn(e,{start:t=0,end:n=e.length}={}){return Qe(e.subarray(t,n))}async function Mn({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 An({fs:e,cache:t,filename:o,getExternalRefDelta:a});if(s.error)throw new J(s.error);if(s.offsets.has(r)){let t=o.replace(/idx$/,`pack`);s.pack||=e.read(t);let n=await s.pack;if(!n)throw s.pack=null,new J(`Could not read packfile at ${t}. The file may be missing, corrupted, or too large to read into memory.`);if(!s._checksumVerified){let e=s.packfileSha,t=n.subarray(-20),r=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(r!==e)throw new J(`Packfile trailer mismatch: expected ${e}, got ${r}. The packfile may be corrupted.`);let i=await jn(n,{start:0,end:n.length-20});if(i!==e)throw new J(`Packfile payload corrupted: calculated ${i} but expected ${e}. The packfile may have been tampered with.`);s._checksumVerified=!0}let c=await s.read({oid:r,getExternalRefDelta:a});return c.format=`content`,c.source=`objects/pack/${i.replace(/idx$/,`pack`)}`,c}}return null}async function Nn({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>Nn({fs:e,cache:t,gitdir:n,oid:r}),o;if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`&&(o={format:`wrapped`,object:Buffer.from(`tree 0\0`)}),o||=await un({fs:e,gitdir:n,oid:r}),!o){if(o=await Mn({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),!o)throw new xt(r);return o}if(i===`deflated`||(o.format===`deflated`&&(o.object=Buffer.from(await Sn(o.object)),o.format=`wrapped`),i===`wrapped`))return o;let s=await Qe(o.object);if(s!==r)throw new J(`SHA check failed! Expected ${r}, computed ${s}`);let{object:c,type:l}=ln.unwrap(o.object);if(o.type=l,o.object=c,o.format=`content`,i===`content`)return o;throw new J(`invalid requested format "${i}"`)}var Pn=class e extends q{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}}};Pn.code=`AlreadyExistsError`;var Fn=class e extends q{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}}};Fn.code=`AmbiguousError`;var In=class e extends q{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}}};In.code=`CheckoutConflictError`;var Ln=class e extends q{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}}};Ln.code=`CherryPickMergeCommitError`;var Rn=class e extends q{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=e.code,this.data={oid:t}}};Rn.code=`CherryPickRootCommitError`;var zn=class e extends q{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}}};zn.code=`CommitNotFetchedError`;var Bn=class e extends q{constructor(){super(`Cannot create an empty commit when disallowEmpty is true.`),this.code=this.name=e.code,this.data={}}};Bn.code=`EmptyCommitError`;var Vn=class e extends q{constructor(){super(`Empty response from git server.`),this.code=this.name=e.code,this.data={}}};Vn.code=`EmptyServerResponseError`;var Hn=class e extends q{constructor(){super(`A simple fast-forward merge was not possible.`),this.code=this.name=e.code,this.data={}}};Hn.code=`FastForwardError`;var Un=class e extends q{constructor(t,n){super(`One or more branches were not updated: ${t}`),this.code=this.name=e.code,this.data={prettyDetails:t,result:n}}};Un.code=`GitPushError`;var Wn=class e extends q{constructor(t,n,r){super(`HTTP Error: ${t} ${n}`),this.code=this.name=e.code,this.data={statusCode:t,statusMessage:n,response:r}}};Wn.code=`HttpError`;var Gn=class e extends q{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}}};Gn.code=`InvalidFilepathError`;var Kn=class e extends q{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=e.code,this.data={depth:t}}};Kn.code=`MaxDepthError`;var qn=class e extends q{constructor(){super(`Merges with conflicts are not supported yet.`),this.code=this.name=e.code,this.data={}}};qn.code=`MergeNotSupportedError`;var Jn=class e extends q{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}}};Jn.code=`MergeConflictError`;var Yn=class e extends q{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}}};Yn.code=`MissingNameError`;var Xn=class e extends q{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=e.code,this.data={parameter:t}}};Xn.code=`MissingParameterError`;var Zn=class e extends q{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}};Zn.code=`MultipleGitError`;var Qn=class e extends q{constructor(t,n){super(`Expected "${t}" but received "${n}".`),this.code=this.name=e.code,this.data={expected:t,actual:n}}};Qn.code=`ParseError`;var $n=class e extends q{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}}};$n.code=`PushRejectedError`;var er=class e extends q{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}}};er.code=`RemoteCapabilityError`;var tr=class e extends q{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}}};tr.code=`SmartHttpError`;var nr=class e extends q{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}}};nr.code=`UnknownTransportError`;var rr=class e extends q{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=e.code,this.data={url:t}}};rr.code=`UrlParseError`;var ir=class e extends q{constructor(){super(`The operation was canceled.`),this.code=this.name=e.code,this.data={}}};ir.code=`UserCanceledError`;var ar=class e extends q{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}}};ar.code=`IndexResetError`;var or=class e extends q{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}}};or.code=`NoCommitError`;var sr=Object.freeze({__proto__:null,AlreadyExistsError:Pn,AmbiguousError:Fn,CheckoutConflictError:In,CherryPickMergeCommitError:Ln,CherryPickRootCommitError:Rn,CommitNotFetchedError:zn,EmptyCommitError:Bn,EmptyServerResponseError:Vn,FastForwardError:Hn,GitPushError:Un,HttpError:Wn,InternalError:J,InvalidFilepathError:Gn,InvalidOidError:Ct,InvalidRefNameError:wt,MaxDepthError:Kn,MergeNotSupportedError:qn,MergeConflictError:Jn,MissingNameError:Yn,MissingParameterError:Xn,MultipleGitError:Zn,NoRefspecError:Tt,NotFoundError:xt,ObjectTypeError:St,ParseError:Qn,PushRejectedError:$n,RemoteCapabilityError:er,SmartHttpError:tr,UnknownTransportError:nr,UnsafeFilepathError:He,UrlParseError:rr,UserCanceledError:ir,UnmergedPathsError:Ve,IndexResetError:ar,NoCommitError:or});function cr({name:e,email:t,timestamp:n,timezoneOffset:r}){return r=lr(r),`${e} <${t}> ${n} ${r}`}function lr(e){let t=ur(dr(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 ur(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}function dr(e){return e===0?e:-e}function fr(e){return e=e.replace(/\r/g,``),e=e.replace(/^\n+/,``),e=e.replace(/\n+$/,``)+`
11
+ `)}toObject(){let e=[...this._entries];return e.sort(tn),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}},ln=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 J(`Length mismatch: expected ${i} bytes but got ${a} instead.`);return{type:r,object:Buffer.from(e.slice(n+1))}}};async function un({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 dn(e,t){let n=new Ue(e),r=fn(n);if(r!==t.byteLength)throw new J(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${t.length} bytes`);let i=fn(n),a,o=mn(n,t);if(o.byteLength===i)a=o;else{let e=[o],r=o.byteLength;for(;!n.eof();){let i=mn(n,t);e.push(i),r+=i.byteLength}if(i!==r)throw new J(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${r} bytes`);a=Buffer.concat(e,i)}return a}function fn(e){let t=0,n=0,r=null;do r=e.readUInt8(),t|=(r&127)<<n,n+=7;while(r&128);return t}function pn(e,t,n){let r=0,i=0;for(;n--;)t&1&&(r|=e.readUInt8()<<i),t>>=1,i+=8;return r}function mn(e,t){let n=e.readUInt8();if(n&128){let r=pn(e,n&15,4),i=pn(e,(n&112)>>4,3);return i===0&&(i=65536),t.slice(r,r+i)}return e.slice(n)}function hn(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function gn(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:hn(e)}var _n=class{constructor(e){if(typeof Buffer>`u`)throw Error(`Missing Buffer dependency`);this.stream=gn(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>vn(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 vn(e){return e.reduce((e,t)=>e+t.length,0)}async function yn(e,t){let n=new _n(e),r=await n.read(4);if(r=r.toString(`utf8`),r!==`PACK`)throw new J(`Invalid PACK header '${r}'`);let i=await n.read(4);if(i=i.readUInt32BE(0),i!==2)throw new J(`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 bn(n),c=new Ie.default.Inflate;for(;!c.result;){let l=await n.chunk();if(!l)break;if(c.push(l,!1),c.err)throw new J(`Pako error: ${c.msg}`);if(c.result){if(c.result.length!==i)throw new J(`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 bn(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 xn=!1;async function Sn(e){return xn===null&&(xn=wn()),xn?Cn(e):Ie.default.inflate(e)}async function Cn(e){let t=new DecompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function wn(){try{if(new DecompressionStream(`deflate`))return!0}catch{}return!1}function Tn(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 En(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 Dn=class e{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:n}){let r=new Ue(t);if(r.slice(4).toString(`hex`)!==`ff744f63`)return;let i=r.readUInt32BE();if(i!==2)throw new J(`Unable to read version ${i} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2147483648)throw new J(`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 yn([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=Fe.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 Qe(ln.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 Ue(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 Ue(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)r.writeUInt32BE(this.crcs[e]);e.push(r.buffer);let i=new Ue(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 Qe(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 J(`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 J(`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 Ue(r),a=i.readUInt8(),o=a&112,s=t[o];if(s===void 0)throw new J(`Unrecognized type: 0b`+o.toString(2));let c=a&15,l=c;a&128&&(l=En(i,c));let u=null,d=null;if(s===`ofs_delta`){let t=e-Tn(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 Sn(f)),d.byteLength!==l)throw new J(`Packfile told us object would have length ${l} but it had length ${d.byteLength}`);return u&&(d=Buffer.from(dn(d,u))),this.readDepth>3&&(this.offsetCache[e]={type:s,object:d}),{type:s,format:`content`,object:d}}},On=Symbol(`PackfileCache`);async function kn({fs:e,filename:t,getExternalRefDelta:n,emitter:r,emitterPrefix:i}){let a=await e.read(t);return Dn.fromIdx({idx:a,getExternalRefDelta:n})}function An({fs:e,cache:t,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}){t[On]||(t[On]=new Map);let o=t[On].get(n);return o||(o=kn({fs:e,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}),t[On].set(n,o)),o}async function jn(e,{start:t=0,end:n=e.length}={}){return Qe(e.subarray(t,n))}async function Mn({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 An({fs:e,cache:t,filename:o,getExternalRefDelta:a});if(s.error)throw new J(s.error);if(s.offsets.has(r)){let t=o.replace(/idx$/,`pack`);s.pack||=e.read(t);let n=await s.pack;if(!n)throw s.pack=null,new J(`Could not read packfile at ${t}. The file may be missing, corrupted, or too large to read into memory.`);if(!s._checksumVerified){let e=s.packfileSha,t=n.subarray(-20),r=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(r!==e)throw new J(`Packfile trailer mismatch: expected ${e}, got ${r}. The packfile may be corrupted.`);let i=await jn(n,{start:0,end:n.length-20});if(i!==e)throw new J(`Packfile payload corrupted: calculated ${i} but expected ${e}. The packfile may have been tampered with.`);s._checksumVerified=!0}let c=await s.read({oid:r,getExternalRefDelta:a});return c.format=`content`,c.source=`objects/pack/${i.replace(/idx$/,`pack`)}`,c}}return null}async function Nn({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){if(![`deflated`,`wrapped`,`content`].includes(i))throw new J(`invalid requested format "${i}"`);let a=r=>Nn({fs:e,cache:t,gitdir:n,oid:r}),o;if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`&&(o={format:`wrapped`,object:Buffer.from(`tree 0\0`)}),o||=await un({fs:e,gitdir:n,oid:r}),!o){if(o=await Mn({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),!o)throw new xt(r);return o}if(i===`deflated`||(o.format===`deflated`&&(o.object=Buffer.from(await Sn(o.object)),o.format=`wrapped`),i===`wrapped`))return o;let s=await Qe(o.object);if(s!==r)throw new J(`SHA check failed! Expected ${r}, computed ${s}`);let{object:c,type:l}=ln.unwrap(o.object);return o.type=l,o.object=c,o.format=`content`,o}var Pn=class e extends q{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}}};Pn.code=`AlreadyExistsError`;var Fn=class e extends q{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}}};Fn.code=`AmbiguousError`;var In=class e extends q{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}}};In.code=`CheckoutConflictError`;var Ln=class e extends q{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}}};Ln.code=`CherryPickMergeCommitError`;var Rn=class e extends q{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=e.code,this.data={oid:t}}};Rn.code=`CherryPickRootCommitError`;var zn=class e extends q{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}}};zn.code=`CommitNotFetchedError`;var Bn=class e extends q{constructor(){super(`Cannot create an empty commit when disallowEmpty is true.`),this.code=this.name=e.code,this.data={}}};Bn.code=`EmptyCommitError`;var Vn=class e extends q{constructor(){super(`Empty response from git server.`),this.code=this.name=e.code,this.data={}}};Vn.code=`EmptyServerResponseError`;var Hn=class e extends q{constructor(){super(`A simple fast-forward merge was not possible.`),this.code=this.name=e.code,this.data={}}};Hn.code=`FastForwardError`;var Un=class e extends q{constructor(t,n){super(`One or more branches were not updated: ${t}`),this.code=this.name=e.code,this.data={prettyDetails:t,result:n}}};Un.code=`GitPushError`;var Wn=class e extends q{constructor(t,n,r){super(`HTTP Error: ${t} ${n}`),this.code=this.name=e.code,this.data={statusCode:t,statusMessage:n,response:r}}};Wn.code=`HttpError`;var Gn=class e extends q{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}}};Gn.code=`InvalidFilepathError`;var Kn=class e extends q{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=e.code,this.data={depth:t}}};Kn.code=`MaxDepthError`;var qn=class e extends q{constructor(){super(`Merges with conflicts are not supported yet.`),this.code=this.name=e.code,this.data={}}};qn.code=`MergeNotSupportedError`;var Jn=class e extends q{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}}};Jn.code=`MergeConflictError`;var Yn=class e extends q{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}}};Yn.code=`MissingNameError`;var Xn=class e extends q{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=e.code,this.data={parameter:t}}};Xn.code=`MissingParameterError`;var Zn=class e extends q{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}};Zn.code=`MultipleGitError`;var Qn=class e extends q{constructor(t,n){super(`Expected "${t}" but received "${n}".`),this.code=this.name=e.code,this.data={expected:t,actual:n}}};Qn.code=`ParseError`;var $n=class e extends q{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}}};$n.code=`PushRejectedError`;var er=class e extends q{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}}};er.code=`RemoteCapabilityError`;var tr=class e extends q{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}}};tr.code=`SmartHttpError`;var nr=class e extends q{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}}};nr.code=`UnknownTransportError`;var rr=class e extends q{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=e.code,this.data={url:t}}};rr.code=`UrlParseError`;var ir=class e extends q{constructor(){super(`The operation was canceled.`),this.code=this.name=e.code,this.data={}}};ir.code=`UserCanceledError`;var ar=class e extends q{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}}};ar.code=`IndexResetError`;var or=class e extends q{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}}};or.code=`NoCommitError`;var sr=Object.freeze({__proto__:null,AlreadyExistsError:Pn,AmbiguousError:Fn,CheckoutConflictError:In,CherryPickMergeCommitError:Ln,CherryPickRootCommitError:Rn,CommitNotFetchedError:zn,EmptyCommitError:Bn,EmptyServerResponseError:Vn,FastForwardError:Hn,GitPushError:Un,HttpError:Wn,InternalError:J,InvalidFilepathError:Gn,InvalidOidError:Ct,InvalidRefNameError:wt,MaxDepthError:Kn,MergeNotSupportedError:qn,MergeConflictError:Jn,MissingNameError:Yn,MissingParameterError:Xn,MultipleGitError:Zn,NoRefspecError:Tt,NotFoundError:xt,ObjectTypeError:St,ParseError:Qn,PushRejectedError:$n,RemoteCapabilityError:er,SmartHttpError:tr,UnknownTransportError:nr,UnsafeFilepathError:He,UrlParseError:rr,UserCanceledError:ir,UnmergedPathsError:Ve,IndexResetError:ar,NoCommitError:or});function cr({name:e,email:t,timestamp:n,timezoneOffset:r}){return r=lr(r),`${e} <${t}> ${n} ${r}`}function lr(e){let t=ur(dr(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 ur(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}function dr(e){return e===0?e:-e}function fr(e){return e=e.replace(/\r/g,``),e=e.replace(/^\n+/,``),e=e.replace(/\n+$/,``)+`
12
12
  `,e}function pr(e){let[,t,n,r,i]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(r),timezoneOffset:mr(i)}}function mr(e){let[,t,n,r]=e.match(/(\+|-)(\d\d)(\d\d)/);return r=(t===`+`?1:-1)*(Number(n)*60+Number(r)),hr(r)}function hr(e){return e===0?e:-e}var gr=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 J(`invalid type passed to GitAnnotatedTag constructor`)}static from(t){return new e(t)}static render(e){return`object ${e.object}
13
13
  type ${e.type}
14
14
  tag ${e.tag}
@@ -51,7 +51,7 @@ gpgsig`+_r(o)+`
51
51
  `,author:c,committer:l,signingKey:u})}async function pi({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 ei({fs:n,gitdir:r,author:c});if(!f)throw new Yn(`author`);let p=await ti({fs:n,gitdir:r,author:f,committer:l});if(!p)throw new Yn(`committer`);return await fi({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}}var mi=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function hi(e,t){if(typeof e!=`string`)throw TypeError(`Reference name must be a string`);return!mi.test(e)&&(!!t||e.includes(`/`))}async function gi({fs:e,gitdir:t,remote:n,url:r,force:i}){if(!hi(n,!0))throw new wt(n,ze.default.clean(n));let a=await Zt.get({fs:e,gitdir:t});if(!i&&(await a.getSubsections(`remote`)).includes(n)&&r!==await a.get(`remote.${n}.url`))throw new Pn(`remote`,n);await a.set(`remote.${n}.url`,r),await a.set(`remote.${n}.fetch`,`+refs/heads/*:refs/remotes/${n}/*`),await Zt.save({fs:e,gitdir:t,config:a})}async function _i({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 gi({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r,url:i,force:a})}catch(e){throw e.caller=`git.addRemote`,e}}async function vi({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 Pn(`tag`,i);let d=await X.resolve({fs:e,gitdir:r,ref:c||`HEAD`}),{type:f}=await Nn({fs:e,cache:t,gitdir:r,oid:d}),p=gr.from({object:d,type:f,tag:i.replace(`refs/tags/`,``),tagger:a,message:o,gpgsig:s});l&&(p=await gr.sign(p,n,l));let m=await qr({fs:e,gitdir:r,type:`tag`,object:p.toObject()});await X.writeRef({fs:e,gitdir:r,ref:i,value:m})}async function yi({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 ei({fs:n,gitdir:f,author:a});if(!p)throw new Yn(`tagger`);return await vi({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 bi({fs:e,gitdir:t,ref:n,object:r,checkout:i=!1,force:a=!1}){if(!hi(n,!0))throw new wt(n,ze.default.clean(n));let o=`refs/heads/${n}`;if(!a&&await X.exists({fs:e,gitdir:t,ref:o}))throw new Pn(`branch`,n,!1);let s;try{s=await X.resolve({fs:e,gitdir:t,ref:r||`HEAD`})}catch{}s&&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 xi({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 bi({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 Si(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 He(n)}}var Ci=(e,t)=>e===`.`||t==null||t.length===0||t===`.`?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t);async function wi({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`)throw t;let n=`${o}/${s}`;if(v=await X.resolve({fs:e,gitdir:a,ref:n}),p){let t=await Zt.get({fs:e,gitdir:a});await t.set(`branch.${s}.remote`,o),await t.set(`branch.${s}.merge`,`refs/heads/${s}`),await Zt.save({fs:e,gitdir:a,config:t})}await X.writeRef({fs:e,gitdir:a,ref:`refs/heads/${s}`,value:v})}if(!l){let o;try{o=await Ti({fs:e,cache:t,onProgress:n,dir:i,gitdir:a,ref:s,force:f,filepaths:c,restoreFromIndex:m})}catch(e){throw e instanceof xt&&e.data.what===v?new zn(s,v):e}let l=o.filter(([e])=>e===`conflict`).map(([e,t])=>t);if(l.length>0)throw new In(l);let u=o.filter(([e])=>e===`error`).map(([e,t])=>t);if(u.length>0)throw new J(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 pt.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 pt.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 Si(e,i,r),await e.mkdir(a),n&&await n({phase:`Updating workdir`,loaded:++p,total:y})})),h){let r=await Oi(`Update Working Dir`,o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(([n,r,o,s,c])=>()=>Di({fs:e,cache:t,gitdir:a,dir:i},[n,r,o,s,c])),n,g);await pt.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(e){await Oi(`Update Index`,r.map(([t,n,r])=>()=>Ei({index:e,fullpath:t,oid:n,stats:r})),n,g)})}else await pt.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 Si(e,i,s);let{object:n}=await Nn({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 J(`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 Zn(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 Ti({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,ref:a,force:o,filepaths:s,restoreFromIndex:c}){let l=0;return kr({fs:e,cache:t,dir:r,gitdir:i,trees:[c?bt():Sr({ref:a}),wr(),bt()],map:async function(e,[t,r,i]){if(e!==`.`){if(s&&!s.some(t=>Ci(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=Er(t),e?e&&e[0]===`rmdir`?(t.push(e),t):(t.unshift(e),t):t}})}async function Ei({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 Di({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 Si(e,r,a);let{object:i}=await Nn({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 J(`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 Oi(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 Zn(a);return i}async function ki({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 wi({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 Ai=/^.*(\r?\n|$)/gm;function ji({branches:e,contents:t}){let n=e[1],r=e[2],i=t[0],a=t[1],o=t[2],s=a.match(Ai),c=i.match(Ai),l=o.match(Ai),u=(0,Be.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 Mi({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=Sr({ref:a}),h=Sr({ref:o}),g=Sr({ref:s}),_=[],v=[],y=[],b=[],x=await kr({fs:e,cache:t,dir:n,gitdir:r,trees:[m,h,g],map:async function(t,[n,a,o]){let s=mt(t);switch(`${await zr(n,a)}-${await zr(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 Ni({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 qn}},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 qr({fs:e,gitdir:r,type:`tree`,object:new cn(i).toObject(),dryRun:d})),t}});return _.length===0?x.oid:(n&&!f&&await kr({fs:e,cache:t,dir:n,gitdir:r,trees:[Sr({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 Jn(_,v,y,b))}async function Ni({fs:e,gitdir:t,path:n,ours:r,base:i,theirs:a,ourName:o,theirName:s,baseName:c,dryRun:l,mergeDriver:u=ji}){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 qr({fs:e,gitdir:t,type:`blob`,object:Buffer.from(v,`utf8`),dryRun:l}),type:d}}}var Pi={stage:bt,workdir:wr};async function Fi(e,t,n,r,i=null){let a=Y(n,r),o=await e.lstat(a);if(!o)throw new xt(a);if(o.isDirectory())throw new J(`${a}: file expected, but found directory`);let s=i?await un({fs:e,gitdir:t,oid:i}):void 0,c=s?i:void 0;return s||await ct(a,async()=>{let n=o.isSymbolicLink()?await e.readlink(a).then(Jr):await e.read(a);if(n===null)throw new xt(a);c=await qr({fs:e,gitdir:t,type:`blob`,object:n})}),c}async function Ii({fs:e,dir:t,gitdir:n,entries:r}){async function i(r){return r.type===`tree`?r.oid||(r.oid=await di({fs:e,gitdir:n,tree:await Promise.all(r.children.map(i))}),r.mode=16384):r.type===`blob`&&(r.oid=await Fi(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 Li({fs:e,dir:t,gitdir:n,treePair:r}){let i=r[1]===`stage`,a=r.map(e=>typeof e==`string`?Pi[e]():e),o=[],s=await kr({fs:e,cache:{},dir:t,gitdir:n,trees:a,map:async(r,[i,a])=>{if(!(r===`.`||await Vr.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:di({fs:e,gitdir:n,tree:(await Ii({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 Ri({fs:e,dir:t,gitdir:n,stashCommit:r,parentCommit:i,wasStaged:a}){let o=[],s=[],c=await kr({fs:e,cache:{},dir:t,gitdir:n,trees:[Sr({ref:i}),Sr({ref:r})],map:async(r,[i,c])=>{if(r===`.`||await Vr.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 ct(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 Si(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 Si(e,t,r.filepath);let{object:a}=await Nn({fs:e,cache:{},gitdir:n,oid:r.oid});await e.exists(i)&&await e.rm(i),await e.write(i,a)}}}}),await pt.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 zi({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 ri({fs:e,cache:t,gitdir:r,oid:i});if(u.parent.length>1)throw new Ln(d,u.parent.length);if(u.parent.length===0)throw new Rn(d);let f=await X.resolve({fs:e,gitdir:r,ref:`HEAD`}),{commit:p}=await ri({fs:e,cache:t,gitdir:r,oid:f}),m=u.parent[0],{commit:h}=await ri({fs:e,cache:t,gitdir:r,oid:m}),g=await pt.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async i=>Mi({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 Jn)throw g;let _=await ai({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 Ri({fs:e,dir:n,gitdir:r,stashCommit:_,parentCommit:f,wasStaged:!0}),_}async function Bi({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 ri({fs:u,cache:i,gitdir:d,oid:r});if(f.parent&&f.parent.length>1)return await zi({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:void 0,mergeDriver:l});let p=await ti({fs:u,gitdir:d,committer:a});if(!p)throw new Yn(`committer`);return await zi({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 Vi=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function Hi(e){let t=Vi.exec(e);return t?t[1]===`remotes/`&&e.endsWith(`/HEAD`)?t[2].slice(0,-5):t[2]:e}async function Ui({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{return}if(i.startsWith(`refs/`))return n?i:Hi(i)}function Wi(e){return e=e.replace(/^[^/@:]+@([^/@:]+):/,`https://$1/`),e=e.replace(/^ssh:\/\//,`https://`),e}function Gi({username:e=``,password:t=``}){return`Basic ${Buffer.from(`${e}:${t}`).toString(`base64`)}`}async function Ki(e,t){let n=gn(e);for(;;){let{value:e,done:r}=await n.next();if(e&&await t(e),r)break}n.return&&n.return()}async function qi(e){let t=0,n=[];await Ki(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 Ji=/^(https?:\/\/)([^/?#]+)@/i;function Yi(e){let t=e.match(Ji);return t==null?{url:e,auth:{}}:{url:e.replace(Ji,`$1`),auth:Xi(e,t[2])}}function Xi(e,t){let n=Zi(e),r=t.indexOf(`:`)!==-1;if(n!==null)return{username:Qi(n.username),password:r?Qi(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 Zi(e){if(typeof URL!=`function`)return null;try{return new URL(e)}catch{return null}}function Qi(e){try{return decodeURIComponent(e)}catch{return e}}function $i(e,t){let n=t.toString(16);return`0`.repeat(e-n.length)+n}var ea=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=$i(4,e.length+4);return Buffer.concat([Buffer.from(t,`utf8`),e])}static streamReader(e){let t=new _n(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 ta(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 na(e,{service:t}){let n=new Set,r=new Map,i=new Map,a=ea.streamReader(e),o=await a();for(;o===null;)o=await a();if(o===!0)throw new Vn;if(o.includes(`version 2`))return ta(a);if(o.toString(`utf8`).replace(/\n$/,``)!==`# service=${t}`)throw new Qn(`# 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 ta(a);let[c,l]=ra(s,`\0`,`\\x00`);if(l.split(` `).map(e=>n.add(e)),c!==`0000000000000000000000000000000000000000 capabilities^{}`){let[e,t]=ra(c,` `,` `);for(r.set(t,e);;){let e=await a();if(e===!0)break;if(e!==null){let[t,n]=ra(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 ra(e,t,n){let r=e.trim().split(t);if(r.length!==2)throw new Qn(`Two strings separated by '${n}'`,e.toString(`utf8`));return r}var ia=(e,t)=>e.endsWith(`?`)?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,``)}`,aa=(e,t)=>{(t.username||t.password)&&(e.Authorization=Gi(t)),t.headers&&Object.assign(e,t.headers)},oa=async e=>{try{let t=Buffer.from(await qi(e.body)),n=t.toString(`utf8`);return{preview:n.length<256?n:n.slice(0,256)+`...`,response:n,data:t}}catch{return{}}},sa=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,protocolVersion:l}){let{url:u,auth:d}=Yi(s),f=a?ia(a,u):u;(d.username||d.password)&&(c.Authorization=Gi(d)),l===2&&(c[`Git-Protocol`]=`version=2`);let p,m,h=!1;do if(p=await e.request({onProgress:t,method:`GET`,url:`${f}/info/refs?service=${o}`,headers:c}),m=!1,p.statusCode===401||p.statusCode===203){let e=h?i:n;if(e){if(d=await e(u,{...d,headers:{...c}}),d&&d.cancel)throw new ir;d&&(aa(c,d),h=!0,m=!0)}}else p.statusCode===200&&h&&r&&await r(u,d);while(m);if(p.statusCode!==200){let{response:e}=await oa(p);throw new Wn(p.statusCode,p.statusMessage,e)}if(p.headers[`content-type`]===`application/x-${o}-advertisement`){let e=await na(p.body,{service:o});return e.auth=d,e}{let{preview:e,response:t,data:n}=await oa(p);try{let e=await na([n],{service:o});return e.auth=d,e}catch{throw new tr(e,t)}}}static async connect({http:e,onProgress:t,corsProxy:n,service:r,url:i,auth:a,body:o,headers:s}){let c=Yi(i);c&&(i=c.url),n&&(i=ia(n,i)),s[`content-type`]=`application/x-${r}-request`,s.accept=`application/x-${r}-result`,aa(s,a);let l=await e.request({onProgress:t,method:`POST`,url:`${i}/${r}`,body:o,headers:s});if(l.statusCode!==200){let{response:e}=oa(l);throw new Wn(l.statusCode,l.statusMessage,e)}return l}},ca=class{static getRemoteHelperFor({url:e}){let t=new Map;t.set(`http`,sa),t.set(`https`,sa);let n=ua({url:e});if(!n)throw new rr(e);if(t.has(n.transport))return t.get(n.transport);throw new nr(e,n.transport,n.transport===`ssh`?Wi(e):void 0)}},la=/^[^/@:]+@[^/@:]+:/;function ua({url:e}){if(la.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 da=class{static async read({fs:e,gitdir:t}){let n=Y(t,`shallow`),r=new Set;return await ct(n,async function(){let t=await e.read(n,{encoding:`utf8`});if(t===null||t.trim()===``)return r;t.trim().split(`
52
52
  `).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
53
  `)+`
54
- `;await ct(r,async function(){await e.write(r,t,{encoding:`utf8`})})}else await ct(r,async function(){await e.rm(r)})}};async function fa({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`;return e.exists(`${t}/${r}`)}async function pa({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 An({fs:e,cache:t,filename:`${n}/objects/pack/${o}`,getExternalRefDelta:i});if(a.error)throw new J(a.error);if(a.offsets.has(r))return!0}return!1}async function ma({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>Nn({fs:e,cache:t,gitdir:n,oid:r}),o=await fa({fs:e,gitdir:n,oid:r});return o||=await pa({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),o}function ha({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 ga(e){return e.slice(0,12).toString(`hex`)===`5041434b0000000200000000`}function _a(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 va={name:`isomorphic-git`,version:`1.41.5`,agent:`git/isomorphic-git@1.41.5`},ya=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 ba(e){let t=e.indexOf(`\r`),n=e.indexOf(`
54
+ `;await ct(r,async function(){await e.write(r,t,{encoding:`utf8`})})}else await ct(r,async function(){await e.rm(r)})}};async function fa({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`;return e.exists(`${t}/${r}`)}async function pa({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 An({fs:e,cache:t,filename:`${n}/objects/pack/${o}`,getExternalRefDelta:i});if(a.error)throw new J(a.error);if(a.offsets.has(r))return!0}return!1}async function ma({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>Nn({fs:e,cache:t,gitdir:n,oid:r}),o=await fa({fs:e,gitdir:n,oid:r});return o||=await pa({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),o}function ha({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 ga(e){return e.slice(0,12).toString(`hex`)===`5041434b0000000200000000`}function _a(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 va={name:`isomorphic-git`,version:`1.41.7`,agent:`git/isomorphic-git@1.41.7`},ya=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 ba(e){let t=e.indexOf(`\r`),n=e.indexOf(`
55
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 xa(e){let t=new ya,n=``;return(async()=>{await Ki(e,e=>{for(e=e.toString(`utf8`),n+=e;;){let e=ba(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 Sa=class{static demux(e){let t=ea.streamReader(e),n=new ya,r=new ya,i=new ya,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();return}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 Ca(e){let{packetlines:t,packfile:n,progress:r}=Sa.demux(e),i=[],a=[],o=[],s=!1,c=!1;return new Promise((l,u)=>{Ki(t,t=>{let d=t.toString(`utf8`).trim();if(d.startsWith(`shallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new Ct(e)),i.push(e)}else if(d.startsWith(`unshallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new Ct(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 wa({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(ea.encode(`want ${e}${c}\n`)),c=``;for(let e of r)s.push(ea.encode(`shallow ${e}\n`));i!==null&&s.push(ea.encode(`deepen ${i}\n`)),a!==null&&s.push(ea.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}\n`));for(let e of o)s.push(ea.encode(`deepen-not ${e}\n`));s.push(ea.flush());for(let e of n)s.push(ea.encode(`have ${e}\n`));return s.push(ea.encode(`done
56
56
  `)),s}async function Ta({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 Ui({fs:e,gitdir:c,test:!0}),w=await Zt.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 Xn(`remote OR url`);let D=u||C&&await w.get(`branch.${C}.merge`)||l||`HEAD`;p===void 0&&(p=await w.get(`http.corsProxy`));let O=ca.getRemoteHelperFor({url:E}),k=await O.discover({http:n,onAuth:ha({config:w,onAuth:a}),onAuthSuccess:o,onAuthFailure:ha({config:w,onAuth:s}),corsProxy:p,service:`git-upload-pack`,url:E,headers:b,protocolVersion:1}),A=k.auth,j=k.refs;if(j.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(m!==null&&!k.capabilities.has(`shallow`))throw new er(`shallow`,`depth`);if(h!==null&&!k.capabilities.has(`deepen-since`))throw new er(`deepen-since`,`since`);if(g.length>0&&!k.capabilities.has(`deepen-not`))throw new er(`deepen-not`,`exclude`);if(_===!0&&!k.capabilities.has(`deepen-relative`))throw new er(`deepen-relative`,`relative`);let{oid:M,fullref:N}=X.resolveAgainstMap({ref:D,map:j});for(let e of j.keys())e===N||e===`HEAD`||e.startsWith(`refs/heads/`)||v&&e.startsWith(`refs/tags/`)||j.delete(e);let ee=_a([...k.capabilities],[`multi_ack_detailed`,`no-done`,`side-band-64k`,`ofs-delta`,`agent=${va.agent}`]);_&&ee.push(`deepen-relative`);let te=y?[M]:j.values(),ne=y?[C]:await X.listRefs({fs:e,gitdir:c,filepath:`refs`}),re=[];for(let n of ne)try{n=await X.expand({fs:e,gitdir:c,ref:n});let r=await X.resolve({fs:e,gitdir:c,ref:n});await ma({fs:e,cache:t,gitdir:c,oid:r})&&re.push(r)}catch{}re=[...new Set(re)];let ie=await da.read({fs:e,gitdir:c}),ae=k.capabilities.has(`shallow`)?[...ie]:[],oe=wa({capabilities:ee,wants:te,haves:re,shallows:ae,depth:m,since:h,exclude:g}),se=Buffer.from(await qi(oe)),ce=await O.connect({http:n,onProgress:r,corsProxy:p,service:`git-upload-pack`,url:E,auth:A,body:[se],headers:b}),P=await Ca(ce.body);ce.headers&&(P.headers=ce.headers);for(let n of P.shallows)if(!ie.has(n))try{let{object:r}=await Nn({fs:e,cache:t,gitdir:c,oid:n}),i=new yr(r),a=await Promise.all(i.headers().parent.map(n=>ma({fs:e,cache:t,gitdir:c,oid:n})));a.length===0||a.every(e=>e)||ie.add(n)}catch{ie.add(n)}for(let e of P.unshallows)ie.delete(e);if(await da.write({fs:e,gitdir:c,oids:ie}),y){let t=new Map([[N,M]]),n=new Map,r=10,i=N;for(;r--;){let e=k.symrefs.get(i);if(e===void 0)break;n.set(i,e),i=e}let a=j.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&&(P.pruned=o)}else{let{pruned:t}=await X.updateRemoteRefs({fs:e,gitdir:c,remote:T,refs:j,symrefs:k.symrefs,tags:v,prune:x,pruneTags:S});x&&(P.pruned=t)}if(P.HEAD=k.symrefs.get(`HEAD`),P.HEAD===void 0){let{oid:e}=X.resolveAgainstMap({ref:`HEAD`,map:j});for(let[t,n]of j.entries())if(t!==`HEAD`&&n===e){P.HEAD=t;break}}P.FETCH_HEAD={oid:M,description:`${N.startsWith(`refs/tags`)?`tag`:`branch`} '${Hi(N)}' of ${E}`},(r||i)&&Ki(xa(P.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 le=Buffer.from(await qi(P.packfile));if(ce.body.error)throw ce.body.error;let ue=le.slice(-20).toString(`hex`),de={defaultBranch:P.HEAD,fetchHead:P.FETCH_HEAD.oid,fetchHeadDescription:P.FETCH_HEAD.description};if(P.headers&&(de.headers=P.headers),x&&(de.pruned=P.pruned),ue!==``&&!ga(le)){de.packfile=`objects/pack/pack-${ue}.pack`;let n=Y(c,de.packfile);await e.write(n,le);let i=await Dn.fromPack({pack:le,getExternalRefDelta:n=>Nn({fs:e,cache:t,gitdir:c,oid:n}),onProgress:r});await e.write(n.replace(/\.pack$/,`.idx`),await i.toBuffer())}return de}async function Ea({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
57
  repositoryformatversion = 0
@@ -59,7 +59,7 @@ gpgsig`+_r(o)+`
59
59
  \tbare = ${t}\n`+(t?``:` logallrefupdates = true
60
60
  `)+` symlinks = false
61
61
  ignorecase = true
62
- `),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function Da({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 Ea({fs:e,gitdir:u}),await gi({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await Zt.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await Zt.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:E}=await Ta({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 wi({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 Oa({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 Da({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 ka({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 ai({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 Aa({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 Ui({fs:t,gitdir:await $({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function ja({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 xt(n);let r=await X.expand({fs:e,gitdir:t,ref:n});if(r===await Ui({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=Hi(n),a=await Zt.get({fs:e,gitdir:t});await a.deleteSection(`branch`,i),await Zt.save({fs:e,gitdir:t,config:a})}async function Ma({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 ja({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteBranch`,e}}async function Na({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 Pa({fs:e,gitdir:t,remote:n}){let r=await Zt.get({fs:e,gitdir:t});await r.deleteSection(`remote`,n),await Zt.save({fs:e,gitdir:t,config:r})}async function Fa({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 Pa({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r})}catch(e){throw e.caller=`git.deleteRemote`,e}}async function Ia({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 La({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 Ia({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteTag`,e}}async function Ra({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 za({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 An({fs:e,cache:t,filename:`${n}/objects/pack/${s}`,getExternalRefDelta:i});if(o.error)throw new J(o.error);for(let e of o.offsets.keys())e.startsWith(r)&&a.push(e)}return a}async function Ba({fs:e,cache:t,gitdir:n,oid:r}){let i=r=>Nn({fs:e,cache:t,gitdir:n,oid:r}),a=await Ra({fs:e,gitdir:n,oid:r}),o=await za({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 Fn(`oids`,r,a):new xt(`an object matching "${r}"`)}async function Va({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 Ba({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.expandOid`,e}}async function Ha({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 Ua({fs:e,cache:t,gitdir:n,oids:r}){let i={},a=r.length,o=r.map((e,t)=>({index:t,oid:e}));for(;o.length;){let r=new Set;for(let{oid:e,index:t}of o)i[e]||(i[e]=new Set),i[e].add(t),i[e].size===a&&r.add(e);if(r.size>0)return[...r];let s=new Map;for(let{oid:r,index:a}of o)try{let{object:o}=await Nn({fs:e,cache:t,gitdir:n,oid:r}),{parent:c}=yr.from(o).parseHeaders();for(let e of c)(!i[e]||!i[e].has(a))&&s.set(e+`:`+a,{oid:e,index:a})}catch{}o=Array.from(s.values())}return[]}async function Wa({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 Ui({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}),y=await X.resolve({fs:e,gitdir:r,ref:a}),b=await Ua({fs:e,cache:t,gitdir:r,oids:[v,y]});if(b.length!==1)if(b.length===0&&_)b.push(`4b825dc642cb6eb9a060e54bf8d69288fbee4904`);else throw new qn;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 Hn;let o=await pt.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async o=>Mi({fs:e,cache:t,dir:n,gitdir:r,index:o,ourOid:v,theirOid:y,baseOid:x,ourName:Hi(i),baseName:`base`,theirName:Hi(a),dryRun:c,abortOnConflict:u,mergeDriver:g}));if(o instanceof Jn)throw o;return d||=`Merge branch '${Hi(a)}' into ${Hi(i)}`,{oid:await ai({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 Ga({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 Ui({fs:e,gitdir:l});if(!t)throw new Xn(`ref`);u=t}let{fetchHead:w,fetchHeadDescription:T}=await Ta({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 Wa({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 wi({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 Ka({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 Ga({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 qa({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 Ta({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 Ja({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 Ua({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oids:r})}catch(e){throw e.caller=`git.findMergeBase`,e}}async function Ya({fs:e,filepath:t}){if(await e.exists(Y(t,`.git`)))return t;{let n=ht(t);if(n===t)throw new xt(`git root for ${t}`);return Ya({fs:e,filepath:n})}}async function Xa({fs:e,filepath:t}){try{return Q(`fs`,e),Q(`filepath`,t),await Ya({fs:new Z(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function Za({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 Qr({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfig`,e}}async function Qa({fs:e,gitdir:t,path:n}){return(await Zt.get({fs:e,gitdir:t})).getall(n)}async function $a({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 Qa({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfigAll`,e}}async function eo({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 ca.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){let n=e.split(`/`),r=n.pop(),i=l;for(let e of n)i[e]=i[e]||{},i=i[e];i[r]=t}for(let[e,t]of c.symrefs){let n=e.split(`/`),r=n.pop(),i=l;for(let e of n)i[e]=i[e]||{},i=i[e];i[r]=t}return l}catch(e){throw e.caller=`git.getRemoteInfo`,e}}function to(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 no({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 ca.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:to(l,void 0,!0,!0)}}catch(e){throw e.caller=`git.getRemoteInfo2`,e}}async function ro({type:e,object:t,format:n=`content`,oid:r=void 0}){return n!==`deflated`&&(n!==`wrapped`&&(t=ln.wrap({type:e,object:t})),r=await Qe(t)),{oid:r,object:t}}async function io({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 ro({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 ao({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 Dn.fromPack({pack:o,getExternalRefDelta:n=>Nn({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 oo({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 ao({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 so({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 Ea({fs:a,bare:t,dir:n,gitdir:await $({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function co({fs:e,cache:t,gitdir:n,oid:r,ancestor:i,depth:a}){let o=await da.read({fs:e,gitdir:n});if(!r)throw new Xn(`oid`);if(!i)throw new Xn(`ancestor`);if(r===i)return!1;let s=[r],c=new Set,l=0;for(;s.length;){if(l++===a)throw new Kn(a);let r=s.shift(),{type:u,object:d}=await Nn({fs:e,cache:t,gitdir:n,oid:r});if(u!==`commit`)throw new St(r,u,`commit`);let f=yr.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 lo({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 co({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 uo({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 Vr.isIgnored({fs:i,dir:t,gitdir:a,filepath:r})}catch(e){throw e.caller=`git.isIgnored`,e}}async function fo({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 po({fs:e,gitdir:t,ref:n,cache:r}){if(n){let i=await X.resolve({gitdir:t,fs:e,ref:n}),a=[];return await mo({fs:e,cache:r,gitdir:t,oid:i,filenames:a,prefix:``}),a}return pt.acquire({fs:e,gitdir:t,cache:r},async function(e){return e.entries.map(e=>e.path)})}async function mo({fs:e,cache:t,gitdir:n,oid:r,filenames:i,prefix:a}){let{tree:o}=await ui({fs:e,cache:t,gitdir:n,oid:r});for(let r of o)r.type===`tree`?await mo({fs:e,cache:t,gitdir:n,oid:r.oid,filenames:i,prefix:Y(a,r.path)}):i.push(Y(a,r.path))}async function ho({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 po({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listFiles`,e}}async function go({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 xt)return[]}return(await ui({fs:e,cache:t,gitdir:n,oid:i})).tree.map(e=>({target:e.path,note:e.oid}))}async function _o({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 go({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listNotes`,e}}async function vo({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 yo({fs:e,gitdir:t}){let n=await Zt.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 bo({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await yo({fs:t,gitdir:await $({fsp:t,dotgit:n})})}catch(e){throw e.caller=`git.listRemotes`,e}}async function xo(e){let t=ea.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 So({prefix:e,symrefs:t,peelTags:n}){let r=[];return r.push(ea.encode(`command=ls-refs
62
+ `),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function Da({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 Ea({fs:e,gitdir:u}),await gi({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await Zt.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await Zt.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:E}=await Ta({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 wi({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 Oa({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 Da({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 ka({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 ai({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 Aa({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 Ui({fs:t,gitdir:await $({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function ja({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 xt(n);let r=await X.expand({fs:e,gitdir:t,ref:n});if(r===await Ui({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=Hi(n),a=await Zt.get({fs:e,gitdir:t});await a.deleteSection(`branch`,i),await Zt.save({fs:e,gitdir:t,config:a})}async function Ma({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 ja({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteBranch`,e}}async function Na({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 Pa({fs:e,gitdir:t,remote:n}){let r=await Zt.get({fs:e,gitdir:t});await r.deleteSection(`remote`,n),await Zt.save({fs:e,gitdir:t,config:r})}async function Fa({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 Pa({fs:t,gitdir:await $({fsp:t,dotgit:n}),remote:r})}catch(e){throw e.caller=`git.deleteRemote`,e}}async function Ia({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 La({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 Ia({fs:t,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteTag`,e}}async function Ra({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 za({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 An({fs:e,cache:t,filename:`${n}/objects/pack/${s}`,getExternalRefDelta:i});if(o.error)throw new J(o.error);for(let e of o.offsets.keys())e.startsWith(r)&&a.push(e)}return a}async function Ba({fs:e,cache:t,gitdir:n,oid:r}){let i=r=>Nn({fs:e,cache:t,gitdir:n,oid:r}),a=await Ra({fs:e,gitdir:n,oid:r}),o=await za({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 Fn(`oids`,r,a):new xt(`an object matching "${r}"`)}async function Va({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 Ba({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.expandOid`,e}}async function Ha({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 Ua({fs:e,cache:t,gitdir:n,oids:r}){let i={},a=r.length,o=new Set,s=new Map,c=await da.read({fs:e,gitdir:n}),l=async r=>{if(s.has(r))return s.get(r);let{object:i,type:a}=await Nn({fs:e,cache:t,gitdir:n,oid:r});if(a!==`commit`)throw new St(r,a,`commit`);let{parent:o}=yr.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 Wa({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 Ui({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}),y=await X.resolve({fs:e,gitdir:r,ref:a}),b=await Ua({fs:e,cache:t,gitdir:r,oids:[v,y]});if(b.length!==1)if(b.length===0&&_)b.push(`4b825dc642cb6eb9a060e54bf8d69288fbee4904`);else throw new qn;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 Hn;let o=await pt.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async o=>Mi({fs:e,cache:t,dir:n,gitdir:r,index:o,ourOid:v,theirOid:y,baseOid:x,ourName:Hi(i),baseName:`base`,theirName:Hi(a),dryRun:c,abortOnConflict:u,mergeDriver:g}));if(o instanceof Jn)throw o;return d||=`Merge branch '${Hi(a)}' into ${Hi(i)}`,{oid:await ai({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 Ga({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 Ui({fs:e,gitdir:l});if(!t)throw new Xn(`ref`);u=t}let{fetchHead:w,fetchHeadDescription:T}=await Ta({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 Wa({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 wi({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 Ka({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 Ga({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 qa({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 Ta({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 Ja({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 Ua({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oids:r})}catch(e){throw e.caller=`git.findMergeBase`,e}}async function Ya({fs:e,filepath:t}){if(await e.exists(Y(t,`.git`)))return t;{let n=ht(t);if(n===t)throw new xt(`git root for ${t}`);return Ya({fs:e,filepath:n})}}async function Xa({fs:e,filepath:t}){try{return Q(`fs`,e),Q(`filepath`,t),await Ya({fs:new Z(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function Za({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 Qr({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfig`,e}}async function Qa({fs:e,gitdir:t,path:n}){return(await Zt.get({fs:e,gitdir:t})).getall(n)}async function $a({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 Qa({fs:t,gitdir:await $({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfigAll`,e}}async function eo({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 ca.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){let n=e.split(`/`),r=n.pop(),i=l;for(let e of n)i[e]=i[e]||{},i=i[e];i[r]=t}for(let[e,t]of c.symrefs){let n=e.split(`/`),r=n.pop(),i=l;for(let e of n)i[e]=i[e]||{},i=i[e];i[r]=t}return l}catch(e){throw e.caller=`git.getRemoteInfo`,e}}function to(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 no({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 ca.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:to(l,void 0,!0,!0)}}catch(e){throw e.caller=`git.getRemoteInfo2`,e}}async function ro({type:e,object:t,format:n=`content`,oid:r=void 0}){return n!==`deflated`&&(n!==`wrapped`&&(t=ln.wrap({type:e,object:t})),r=await Qe(t)),{oid:r,object:t}}async function io({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 ro({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 ao({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 Dn.fromPack({pack:o,getExternalRefDelta:n=>Nn({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 oo({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 ao({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 so({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 Ea({fs:a,bare:t,dir:n,gitdir:await $({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function co({fs:e,cache:t,gitdir:n,oid:r,ancestor:i,depth:a}){let o=await da.read({fs:e,gitdir:n});if(!r)throw new Xn(`oid`);if(!i)throw new Xn(`ancestor`);if(r===i)return!1;let s=[r],c=new Set,l=0;for(;s.length;){if(l++===a)throw new Kn(a);let r=s.shift(),{type:u,object:d}=await Nn({fs:e,cache:t,gitdir:n,oid:r});if(u!==`commit`)throw new St(r,u,`commit`);let f=yr.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 lo({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 co({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 uo({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 Vr.isIgnored({fs:i,dir:t,gitdir:a,filepath:r})}catch(e){throw e.caller=`git.isIgnored`,e}}async function fo({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 po({fs:e,gitdir:t,ref:n,cache:r}){if(n){let i=await X.resolve({gitdir:t,fs:e,ref:n}),a=[];return await mo({fs:e,cache:r,gitdir:t,oid:i,filenames:a,prefix:``}),a}return pt.acquire({fs:e,gitdir:t,cache:r},async function(e){return e.entries.map(e=>e.path)})}async function mo({fs:e,cache:t,gitdir:n,oid:r,filenames:i,prefix:a}){let{tree:o}=await ui({fs:e,cache:t,gitdir:n,oid:r});for(let r of o)r.type===`tree`?await mo({fs:e,cache:t,gitdir:n,oid:r.oid,filenames:i,prefix:Y(a,r.path)}):i.push(Y(a,r.path))}async function ho({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 po({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listFiles`,e}}async function go({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 xt)return[]}return(await ui({fs:e,cache:t,gitdir:n,oid:i})).tree.map(e=>({target:e.path,note:e.oid}))}async function _o({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 go({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listNotes`,e}}async function vo({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 yo({fs:e,gitdir:t}){let n=await Zt.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 bo({fs:e,dir:t,gitdir:n=Y(t,`.git`)}){try{Q(`fs`,e),Q(`gitdir`,n);let t=new Z(e);return await yo({fs:t,gitdir:await $({fsp:t,dotgit:n})})}catch(e){throw e.caller=`git.listRemotes`,e}}async function xo(e){let t=ea.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 So({prefix:e,symrefs:t,peelTags:n}){let r=[];return r.push(ea.encode(`command=ls-refs
63
63
  `)),r.push(ea.encode(`agent=${va.agent}\n`)),(n||t||e)&&r.push(ea.delim()),n&&r.push(ea.encode(`peel`)),t&&r.push(ea.encode(`symrefs`)),e&&r.push(ea.encode(`ref-prefix ${e}`)),r.push(ea.flush()),r}async function Co({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 sa.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 to(f,l,u,d);let p=await So({prefix:l,symrefs:u,peelTags:d});return xo((await sa.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 wo({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 To(e,t){return e.committer.timestamp-t.committer.timestamp}var Eo=`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`;async function Do({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===Eo)return;let a=r,o,s=await br({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await Oo({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 Oo({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=Nn({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return Oo({fs:e,cache:t,gitdir:n,tree:cn.from(c),fileId:i,oid:a,filepaths:o,parentPath:Y(s,r.path)})})),c});return await Promise.all(c),o}async function ko({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,force:s,follow:c,includeChanges:l}){let u=o===void 0?void 0:Math.floor(o.valueOf()/1e3),d=[],f=await da.read({fs:e,gitdir:n}),p=[await ri({fs:e,cache:t,gitdir:n,oid:await X.resolve({fs:e,gitdir:n,ref:i})})],m,h,g,_;function v(e){_&&r&&d.push(e)}for(;p.length>0;){let i=p.pop();if(u!==void 0&&i.commit.committer.timestamp<=u)break;if(r){let a;try{a=await ci({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),g&&(m!==a.oid||h!==a.mode)&&d.push(g),m=a.oid,h=a.mode,g=i,_=!0}catch(a){if(a instanceof xt){let o=c&&m;if(o&&(o=await Do({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:m}),o))if(Array.isArray(o)){if(g){let i=await Do({fs:e,cache:t,gitdir:n,oid:g.commit.tree,fileId:m});if(Array.isArray(i))if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,g&&d.push(g);else{o=!1,g&&d.push(g);break}}}else r=o,g&&d.push(g);if(!o){if(_&&m&&(d.push(g),!s))break;if(!s&&!c)throw a}g=i,_=!1}else throw a}}else d.push(i);if(a!==void 0&&d.length===a){v(i);break}if(!f.has(i.oid))for(let r of i.commit.parent){let i=await ri({fs:e,cache:t,gitdir:n,oid:r});p.map(e=>e.oid).includes(i.oid)||p.push(i)}p.length===0&&v(i),p.sort((e,t)=>To(e.commit,t.commit))}if(l)for(let r of d)r.commit.changes=await Ao({fs:e,cache:t,gitdir:n,commit:r,shallow:f.has(r.oid)});return d}async function Ao({fs:e,cache:t,gitdir:n,commit:r,shallow:i}){let a=i||!r.commit.parent[0]?`4b825dc642cb6eb9a060e54bf8d69288fbee4904`:r.commit.parent[0];return kr({fs:e,cache:t,gitdir:n,trees:[Sr({ref:r.oid}),Sr({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 jo({fs:e,dir:t,gitdir:n=Y(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,force:s,follow:c,includeChanges:l=!1,cache:u={}}){try{Q(`fs`,e),Q(`gitdir`,n),Q(`ref`,i);let t=new Z(e);return await ko({fs:t,cache:u,gitdir:await $({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,force:s,follow:c,includeChanges:l})}catch(e){throw e.caller=`git.log`,e}}async function Mo({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 ei({fs:v,gitdir:y,author:f});if(!b&&(!s||!o))throw new Yn(`author`);let x=await ti({fs:v,gitdir:y,author:b,committer:p});if(!x&&(!s||!o))throw new Yn(`committer`);return await Wa({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 No={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function Po({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),oids:i}){let a=new Ne.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=No[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($i(2,o),`hex`),r>>>=7;s(Buffer.from(await Wr(t)))}s(`PACK`),s(`00000002`,`hex`),s($i(8,i.length),`hex`);for(let n of i){let{type:i,object:a}=await Nn({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 Fo({fs:e,cache:t,gitdir:n,oids:r,write:i}){let a=await Po({fs:e,cache:t,gitdir:n,oids:r}),o=Buffer.from(await qi(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 Io({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 Fo({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oids:r,write:i})}catch(e){throw e.caller=`git.packObjects`,e}}async function Lo({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 ei({fs:w,gitdir:T,author:b});if(!E)throw new Yn(`author`);let D=await ti({fs:w,gitdir:T,author:E,committer:x});if(!D)throw new Yn(`committer`);return await Ga({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:D,signingKey:S,prune:p,pruneTags:m})}catch(e){throw e.caller=`git.pull`,e}}async function Ro({fs:e,cache:t,dir:n,gitdir:r=Y(n,`.git`),start:i,finish:a}){let o=await da.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 Nn({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=gr.from(a).headers().object;return u(e)}if(i!==`commit`)throw new St(n,i,`commit`);if(!o.has(n))for(n of yr.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 zo({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 Nn({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=gr.from(s).headers().object;await o(e)}else if(i===`commit`){let e=yr.from(s).headers().tree;await o(e)}else if(i===`tree`){let e=cn.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 Bo(e){let t={},n=``,r=ea.streamReader(e),i=await r();for(;i!==!0;)i!==null&&(n+=i.toString(`utf8`)+`
64
64
  `),i=await r();let a=n.toString(`utf8`).split(`
65
65
  `);if(i=a.shift(),!i.startsWith(`unpack `))throw new Qn(`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 Vo({capabilities:e=[],triplets:t=[]}){let n=[],r=`\x00 ${e.join(` `)}`;for(let e of t)n.push(ea.encode(`${e.oldoid} ${e.oid} ${e.fullRef}${r}\n`)),r=``;return n.push(ea.flush()),n}async function Ho({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:_={}}){let v=u||await Ui({fs:e,gitdir:l});if(v===void 0)throw new Xn(`ref`);let y=await Zt.get({fs:e,gitdir:l});f=f||await y.get(`branch.${v}.pushRemote`)||await y.get(`remote.pushDefault`)||await y.get(`branch.${v}.remote`)||`origin`;let b=p||await y.get(`remote.${f}.pushurl`)||await y.get(`remote.${f}.url`);if(b===void 0)throw new Xn(`remote OR url`);let x=d||await y.get(`branch.${v}.merge`);if(b===void 0)throw new Xn(`remoteRef`);g===void 0&&(g=await y.get(`http.corsProxy`));let S=await X.expand({fs:e,gitdir:l,ref:v}),C=h?`0000000000000000000000000000000000000000`:await X.resolve({fs:e,gitdir:l,ref:S}),w=ca.getRemoteHelperFor({url:b}),T=await w.discover({http:n,onAuth:ha({config:y,onAuth:a}),onAuthSuccess:o,onAuthFailure:ha({config:y,onAuth:s}),corsProxy:g,service:`git-receive-pack`,url:b,headers:_,protocolVersion:1}),E=T.auth,D;if(!x)D=S;else try{D=await X.expandAgainstMap({ref:x,map:T.refs})}catch(e){if(e instanceof xt)D=x.startsWith(`refs/`)?x:`refs/heads/${x}`;else throw e}let O=T.refs.get(D)||`0000000000000000000000000000000000000000`;if(c&&!await c({remote:f,url:b,localRef:{ref:h?`(delete)`:S,oid:C},remoteRef:{ref:D,oid:O}}))throw new ir;let k=!T.capabilities.has(`no-thin`),A=new Set;if(!h){let n=[...T.refs.values()],r=new Set;if(O!==`0000000000000000000000000000000000000000`){let i=await Ua({fs:e,cache:t,gitdir:l,oids:[C,O]});for(let e of i)n.push(e);k&&(r=await zo({fs:e,cache:t,gitdir:l,oids:i}))}if(n.includes(C)||(A=await zo({fs:e,cache:t,gitdir:l,oids:await Ro({fs:e,cache:t,gitdir:l,start:[C],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:T.refs}),a=[i];for(let n of await zo({fs:e,cache:t,gitdir:l,oids:a}))r.add(n)}catch{}for(let e of r)A.delete(e)}if(C===O&&(m=!0),!m){if(S.startsWith(`refs/tags`)&&O!==`0000000000000000000000000000000000000000`)throw new $n(`tag-exists`);if(C!==`0000000000000000000000000000000000000000`&&O!==`0000000000000000000000000000000000000000`&&!await co({fs:e,cache:t,gitdir:l,oid:C,ancestor:O,depth:-1}))throw new $n(`not-fast-forward`)}}let j=await Vo({capabilities:_a([...T.capabilities],[`report-status`,`side-band-64k`,`agent=${va.agent}`]),triplets:[{oldoid:O,oid:C,fullRef:D}]}),M=h?[]:await Po({fs:e,cache:t,gitdir:l,oids:[...A]}),N=await w.connect({http:n,onProgress:r,corsProxy:g,service:`git-receive-pack`,url:b,auth:E,headers:_,body:[...j,...M]}),{packfile:ee,progress:te}=await Sa.demux(N.body);i&&Ki(xa(te),async e=>{await i(e)});let ne=await Bo(ee);if(N.headers&&(ne.headers=N.headers),f&&ne.ok&&ne.refs[D].ok&&!S.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:C})}if(ne.ok&&Object.values(ne.refs).every(e=>e.ok))return ne;throw new Un(Object.entries(ne.refs).filter(([e,t])=>!t.ok).map(([e,t])=>`\n - ${e}: ${t.error}`).join(``),ne)}async function Uo({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={}}){try{Q(`fs`,e),Q(`http`,t),Q(`gitdir`,l);let c=new Z(e);return await Ho({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:_})}catch(e){throw e.caller=`git.push`,e}}async function Wo({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Nn({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=gr.from(a).parse().object,Wo({fs:e,cache:t,gitdir:n,oid:r});if(i!==`blob`)throw new St(r,i,`blob`);return{oid:r,blob:new Uint8Array(a)}}async function Go({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await si({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await Wo({fs:e,cache:t,gitdir:n,oid:r})}async function Ko({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 Go({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readBlob`,e}}async function qo({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 ri({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readCommit`,e}}async function Jo({fs:e,cache:t,gitdir:n,ref:r=`refs/notes/commits`,oid:i}){let{blob:a}=await Go({fs:e,cache:t,gitdir:n,oid:await X.resolve({gitdir:n,fs:e,ref:r}),filepath:i});return a}async function Yo({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 Jo({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),ref:r,oid:i})}catch(e){throw e.caller=`git.readNote`,e}}async function Xo({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 si({fs:t,cache:s,gitdir:c,oid:r,filepath:a}));let l=await Nn({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=yr.from(l.object).parse();break;case`tree`:l.object=cn.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=gr.from(l.object).parse();break;default:throw new St(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 Zo({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await Nn({fs:e,cache:t,gitdir:n,oid:r,format:`content`});if(i!==`tag`)throw new St(r,i,`tag`);let o=gr.from(a);return{oid:r,tag:o.parse(),payload:o.payload()}}async function Qo({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 Zo({fs:t,cache:i,gitdir:await $({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readTag`,e}}async function $o({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 ui({fs:t,cache:a,gitdir:await $({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readTree`,e}}async function es({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 pt.acquire({fs:t,gitdir:a,cache:i},async function(e){e.delete({filepath:r})})}catch(e){throw e.caller=`git.remove`,e}}async function ts({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 xt))throw e}let u=(await ui({fs:e,cache:t,gitdir:r,oid:l||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;return u=u.filter(e=>e.path!==a),await ai({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:await di({fs:e,gitdir:r,tree:u}),parent:l&&[l],message:`Note removed by 'isomorphic-git removeNote'