"use strict";var E=Object.create;var S=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var C=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!d.call(s,n)&&n!==e&&S(s,n,{get:()=>t[n],enumerable:!(o=f(t,n))||o.enumerable});return s};var _=(s,t,e)=>(e=s!=null?E(T(s)):{},C(t||!s||!s.__esModule?S(e,"default",{value:s,enumerable:!0}):e,s));var P=_(require("fs"));var h=_(require("http")),c=class{constructor(t){this.handlerName=t;let e=process.env.VSCODE_GIT_IPC_HANDLE;if(!e)throw new Error("Missing VSCODE_GIT_IPC_HANDLE");this.ipcHandlePath=e}ipcHandlePath;call(t){let e={socketPath:this.ipcHandlePath,path:`/${this.handlerName}`,method:"POST"};return new Promise((o,n)=>{let p=h.request(e,r=>{if(r.statusCode!==200)return n(new Error(`Bad status code: ${r.statusCode}`));let a=[];r.on("data",u=>a.push(u)),r.on("end",()=>o(JSON.parse(Buffer.concat(a).toString("utf8"))))});p.on("error",r=>n(r)),p.write(JSON.stringify(t)),p.end()})}};function i(s){console.error("Missing or invalid credentials."),console.error(s),process.exit(1)}function v(s){if(!process.env.VSCODE_GIT_ASKPASS_PIPE)return i("Missing pipe");if(!process.env.VSCODE_GIT_ASKPASS_TYPE)return i("Missing type");if(process.env.VSCODE_GIT_ASKPASS_TYPE!=="https"&&process.env.VSCODE_GIT_ASKPASS_TYPE!=="ssh")return i(`Invalid type: ${process.env.VSCODE_GIT_ASKPASS_TYPE}`);if(process.env.VSCODE_GIT_COMMAND==="fetch"&&process.env.VSCODE_GIT_FETCH_SILENT)return i("Skip silent fetch commands");let t=process.env.VSCODE_GIT_ASKPASS_PIPE,e=process.env.VSCODE_GIT_ASKPASS_TYPE;new c("askpass").call({askpassType:e,argv:s}).then(n=>{P.writeFileSync(t,n+`
`),setTimeout(()=>process.exit(0),0)}).catch(n=>i(n))}v(process.argv);
//# sourceMappingURL=askpass-main.js.map
