/*!--------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
(function(){var e=["vs/github1s/util","require","exports","vs/code/browser/workbench/workbench","vs/workbench/workbench.web.api","vs/base/common/uri","vs/base/common/event","vs/base/common/uuid","vs/base/common/cancellation","vs/base/common/buffer","vs/base/common/lifecycle","vs/base/parts/request/browser/request","vs/platform/windows/common/windows","vs/base/common/resources","vs/base/browser/browser","vs/nls!vs/code/browser/workbench/workbench","vs/base/common/network","vs/platform/product/common/product","vs/platform/log/common/log"],o=function(o){for(var t=[],s=0,r=o.length;s<r;s++)t[s]=e[o[s]];return t};define(e[0],o([1,2]),(function(e,o){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.parseGitHubUrl=void 0;o.parseGitHubUrl=e=>{const o=new window.URL(e).pathname.split("/").filter(Boolean),t=["tree","blob"].includes(o[2]),s=t&&o[3];return{owner:o[0]||"conwnet",repo:o[1]||"github1s",type:t?o[2]:"tree",branch:s?o[3]:"HEAD",path:"/"+(s?o.slice(4).join("/"):"")}}})),
define(e[3],o([1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0]),(function(e,o,t,s,r,i,n,a,c,l,d,h,u,p,w,E,v,m){"use strict";function f(e,o){let t=void 0;if(o){let e=0;o.forEach((o,s)=>{t||(t="");const r=0==e++?"":"&";t+=`${r}${s}=${encodeURIComponent(o)}`})}return s.URI.parse(window.location.href).with({path:e,query:t})}Object.defineProperty(o,"__esModule",{value:!0});class R{constructor(){let e;const o=document.getElementById("vscode-workbench-auth-session"),t=o?o.getAttribute("data-settings"):void 0;if(t)try{e=JSON.parse(t)}catch(e){}e&&(this.setPassword(`${E.default.urlProtocol}.login`,"account",JSON.stringify(e)),this.authService=`${E.default.urlProtocol}-${e.providerId}.login`,this.setPassword(this.authService,"account",JSON.stringify(e.scopes.map(o=>({id:e.id,scopes:o,accessToken:e.accessToken})))))}get credentials(){if(!this._credentials){try{const e=window.localStorage.getItem(R.CREDENTIALS_OPENED_KEY);e&&(this._credentials=JSON.parse(e))}catch(e){}
Array.isArray(this._credentials)||(this._credentials=[])}return this._credentials}save(){window.localStorage.setItem(R.CREDENTIALS_OPENED_KEY,JSON.stringify(this.credentials))}async getPassword(e,o){return this.doGetPassword(e,o)}async doGetPassword(e,o){for(const t of this.credentials)if(t.service===e&&("string"!=typeof o||o===t.account))return t.password;return null}async setPassword(e,o,t){this.doDeletePassword(e,o),this.credentials.push({service:e,account:o,password:t}),this.save();try{if(t&&e===this.authService){const o=JSON.parse(t);Array.isArray(o)&&0===o.length&&await this.logout(e)}}catch(e){console.log(e)}}async deletePassword(e,o){const t=await this.doDeletePassword(e,o);if(t&&e===this.authService)try{await this.logout(e)}catch(e){console.log(e)}return t}async doDeletePassword(e,o){let t=!1;return this._credentials=this.credentials.filter(s=>s.service!==e||s.account!==o||(t=!0,!1)),t&&this.save(),t}async findPassword(e){return this.doGetPassword(e)}async findCredentials(e){
return this.credentials.filter(o=>o.service===e).map(({account:e,password:o})=>({account:e,password:o}))}async logout(e){const o=new Map;o.set("logout",String(!0)),o.set("service",e),await l.request({url:f("/auth/logout",o).toString(!0)},n.CancellationToken.None)}}R.CREDENTIALS_OPENED_KEY="credentials.provider";class b extends c.Disposable{constructor(){super(...arguments),this._onCallback=this._register(new r.Emitter),this.onCallback=this._onCallback.event}create(e){const o=new Map,t=i.generateUuid();o.set(b.QUERY_KEYS.REQUEST_ID,t);const{scheme:s,authority:r,path:n,query:a,fragment:c}=e||{scheme:void 0,authority:void 0,path:void 0,query:void 0,fragment:void 0};return s&&o.set(b.QUERY_KEYS.SCHEME,s),r&&o.set(b.QUERY_KEYS.AUTHORITY,r),n&&o.set(b.QUERY_KEYS.PATH,n),a&&o.set(b.QUERY_KEYS.QUERY,a),c&&o.set(b.QUERY_KEYS.FRAGMENT,c),this.periodicFetchCallback(t,Date.now()),f("/callback",o)}async periodicFetchCallback(e,o){const t=new Map;t.set(b.QUERY_KEYS.REQUEST_ID,e);const r=await l.request({
url:f("/fetch-callback",t).toString(!0)},n.CancellationToken.None),i=await a.streamToBuffer(r.stream);if(i.byteLength>0)try{this._onCallback.fire(s.URI.revive(JSON.parse(i.toString())))}catch(e){console.error(e)}else Date.now()-o<b.FETCH_TIMEOUT&&setTimeout(()=>this.periodicFetchCallback(e,o),b.FETCH_INTERVAL)}}b.FETCH_INTERVAL=500,b.FETCH_TIMEOUT=3e5,b.QUERY_KEYS={REQUEST_ID:"vscode-requestId",SCHEME:"vscode-scheme",AUTHORITY:"vscode-authority",PATH:"vscode-path",QUERY:"vscode-query",FRAGMENT:"vscode-fragment"};class U{constructor(e,o){this.workspace=e,this.payload=o}async open(e,o){if((null==o?void 0:o.reuse)&&!o.payload&&this.isSame(this.workspace,e))return;const t=this.createTargetUrl(e,o);t&&((null==o?void 0:o.reuse)?window.location.href=t:u.isStandalone?window.open(t,"_blank","toolbar=no"):window.open(t))}createTargetUrl(e,o){let t=void 0
;return e?d.isFolderToOpen(e)?t=`${document.location.origin}${document.location.pathname}?${U.QUERY_PARAM_FOLDER}=${encodeURIComponent(e.folderUri.toString())}`:d.isWorkspaceToOpen(e)&&(t=`${document.location.origin}${document.location.pathname}?${U.QUERY_PARAM_WORKSPACE}=${encodeURIComponent(e.workspaceUri.toString())}`):t=`${document.location.origin}${document.location.pathname}?${U.QUERY_PARAM_EMPTY_WINDOW}=true`,(null==o?void 0:o.payload)&&(t+=`&${U.QUERY_PARAM_PAYLOAD}=${encodeURIComponent(JSON.stringify(o.payload))}`),t}isSame(e,o){return e&&o?d.isFolderToOpen(e)&&d.isFolderToOpen(o)?h.isEqual(e.folderUri,o.folderUri):!(!d.isWorkspaceToOpen(e)||!d.isWorkspaceToOpen(o))&&h.isEqual(e.workspaceUri,o.workspaceUri):e===o}hasRemote(){if(this.workspace){if(d.isFolderToOpen(this.workspace))return this.workspace.folderUri.scheme===w.Schemas.vscodeRemote;if(d.isWorkspaceToOpen(this.workspace))return this.workspace.workspaceUri.scheme===w.Schemas.vscodeRemote}return!0}}U.QUERY_PARAM_EMPTY_WINDOW="ew",
U.QUERY_PARAM_FOLDER="folder",U.QUERY_PARAM_WORKSPACE="workspace",U.QUERY_PARAM_PAYLOAD="payload";class g{constructor(e){this.onDidChange=r.Event.None;let o=void 0,t=void 0;if(e){let s=void 0;d.isFolderToOpen(e)?s=e.folderUri:d.isWorkspaceToOpen(e)&&(s=e.workspaceUri),"github1s"===(null==s?void 0:s.scheme)&&([o,t]=s.authority.split("+"))}t&&o?(this.label=p.localize(0,null,o,t),this.tooltip=p.localize(1,null,o,t)):(this.label=p.localize(2,null),this.tooltip=p.localize(3,null))}}!function(){const e=m.parseGitHubUrl(window.location.href),o={folderUri:s.URI.from({scheme:"github1s",path:"/",authority:`${e.owner}+${e.repo}+${e.branch}`}),staticExtensions:[],enableSyncByDefault:!1,webWorkerExtensionHostIframeSrc:"/static/vscode/vs/workbench/services/extensions/worker/httpWebWorkerExtensionHostIframe.html"};Array.isArray(o.staticExtensions)&&o.staticExtensions.forEach(e=>{e.extensionLocation=s.URI.revive(e.extensionLocation)});let r,i=!1,n=Object.create(null),a=void 0
;new URL(document.location.href).searchParams.forEach((e,o)=>{switch(o){case U.QUERY_PARAM_FOLDER:r={folderUri:s.URI.parse(e)},i=!0;break;case U.QUERY_PARAM_WORKSPACE:r={workspaceUri:s.URI.parse(e)},i=!0;break;case U.QUERY_PARAM_EMPTY_WINDOW:r=void 0,i=!0;break;case U.QUERY_PARAM_PAYLOAD:try{n=JSON.parse(e)}catch(e){console.error(e)}break;case"logLevel":a=e}}),i||(r=o.folderUri?{folderUri:s.URI.revive(o.folderUri)}:o.workspaceUri?{workspaceUri:s.URI.revive(o.workspaceUri)}:void 0);const c=new U(r,n),l={href:"https://github.com/conwnet/github1s",icon:"code",title:p.localize(4,null)};let d=void 0;c.hasRemote()||(d=new g(r));const h=o.settingsSyncOptions?{enabled:o.settingsSyncOptions.enabled,enablementHandler:e=>{let o=`settingsSync=${e?"true":"false"}`;new URL(document.location.href).searchParams.forEach((e,t)=>{"settingsSync"!==t&&(o+=`&${t}=${e}`)}),window.location.href=`${window.location.origin}?${o}`}}:void 0;t.create(document.body,Object.assign(Object.assign({},o),{logLevel:a?v.parseLogLevel(a):void 0,
settingsSyncOptions:h,homeIndicator:l,windowIndicator:d,productQualityChangeHandler:e=>{let o=`quality=${e}`;new URL(document.location.href).searchParams.forEach((e,t)=>{"quality"!==t&&(o+=`&${t}=${e}`)}),window.location.href=`${window.location.origin}?${o}`},workspaceProvider:c,urlCallbackProvider:new b,credentialsProvider:new R}))}()}))}).call(this);
//# sourceMappingURL=workbench.js.map
