var D=Object.create;var l=Object.defineProperty,E=Object.defineProperties,$=Object.getOwnPropertyDescriptor,j=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols,G=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var U=(e,o,s)=>o in e?l(e,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[o]=s,f=(e,o)=>{for(var s in o||(o={}))x.call(o,s)&&U(e,s,o[s]);if(C)for(var s of C(o))H.call(o,s)&&U(e,s,o[s]);return e},S=(e,o)=>E(e,j(o)),P=e=>l(e,"__esModule",{value:!0});var J=(e,o)=>{P(e);for(var s in o)l(e,s,{get:o[s],enumerable:!0})},L=(e,o,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of O(o))!x.call(e,i)&&i!=="default"&&l(e,i,{get:()=>o[i],enumerable:!(s=$(o,i))||s.enumerable});return e},v=e=>L(P(l(e!=null?D(G(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var y=(e,o,s)=>new Promise((i,r)=>{var h=d=>{try{b(s.next(d))}catch(w){r(w)}},u=d=>{try{b(s.throw(d))}catch(w){r(w)}},b=d=>d.done?i(d.value):Promise.resolve(d.value).then(h,u);b((s=s.apply(e,o)).next())});J(exports,{activate:()=>F,deactivate:()=>I});var c=v(require("vscode")),k=v(require("child_process")),p=v(require("fs"));var n=v(require("vscode")),m=v(require("path")),N=(e,o,s="web")=>{let i=r=>o.webview.asWebviewUri(n.Uri.file(m.join(e.extensionPath,s,"dist",r)));return`
    <html>
      <head>
        <meta charset="utf-8" />
        <meta
          name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
        />
        <link rel="stylesheet" href="${i("umi.css")}" />
        <style>
          html, body, #root {
            background-color: var(--vscode-editor-background);
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
          }
          // \u7ED9 webview \u5185\u5BB9\u52A0\u4E0A\u4E3B\u9898
          body.vscode-light {
            color: black;
            background-color: var(--vscode-editor-background);
          }
          body.vscode-light h1, h2, h3, h4, h5, h6 {
            color: black;
          }
          body.vscode-dark {
            color: white;
            background-color: var(--vscode-editor-background);
          }
          body.vscode-dark h1, h2, h3, h4, h5, h6 {
            color: white;
          }
          body.vscode-high-contrast {
            color: red;
            background-color: var(--vscode-editor-background);
          }
          body.vscode-high-contrast h1, h2, h3, h4, h5, h6 {
            color: red;
          }
        </style>
        <script>
          window.vscodeEnv = ${JSON.stringify({language:n.env.language})}
        <\/script>
      </head>
      <body>
        <div id="root"></div>
        <script src="${i("umi.js")}"><\/script>
      </body>
    </html>
  `},a,W=(e,o,s,i)=>{let r=n.window.activeTextEditor?n.window.activeTextEditor.viewColumn:void 0;return a?a.reveal(r):(a=n.window.createWebviewPanel(o,s,n.ViewColumn.One,{enableScripts:!0,localResourceRoots:[n.Uri.file(m.join(e.extensionPath,"web/dist"))],retainContextWhenHidden:!0}),a.iconPath=n.Uri.file(m.join(e.extensionPath,i)),a.webview.html=N(e,a)),a.onDidDispose(()=>{a=void 0},null,e.subscriptions),a};var t,g,M=p.realpathSync(c.workspace.workspaceFolders[0].uri.fsPath),R=p.existsSync(`${c.workspace.workspaceFolders[0].uri.fsPath}/.git`),T=()=>{R&&(g=k.execSync('([ "$(git remote | wc -l)" -eq "1" ] && (git remote |xargs git remote get-url)) || (git remote get-url origin 2> /dev/null)',{cwd:M}).toString(),console.log("gitUrl",g))};function F(e){return y(this,null,function*(){T();let o=yield c.commands.executeCommand("cloudstudio.getPublicConfig");t&&c.commands.executeCommand("custom-template.start"),e.subscriptions.push(c.commands.registerCommand("custom-template.start",()=>y(this,null,function*(){if(T(),t)return t.reveal(c.ViewColumn.Active);t=W(e,"custom-template","\u81EA\u5B9A\u4E49\u6A21\u677F","assets/favicon.ico"),t.webview.onDidReceiveMessage(i=>{switch(i.type){case"deploy":case"reissue":let{versionControlType:r,versionControlUrl:h}=i.params;console.log({event:i.type,label:"\u6A21\u677F",params:S(f({},i.params),{versionControlUrl:g||h,versionControlType:g?"GIT":r})});let u=k.execSync("du -s .",{cwd:M}).toString().replace(/\./g,"");t==null||t.webview.postMessage({memory:u});break;case"icons-tags":console.log({event:"icons-tags",label:"\u6A21\u677F"});break;case"get template":console.log({event:"get template",label:"\u6A21\u677F"}),o&&(t==null||t.webview.postMessage({config:o}));break;default:console.log({event:"get template",label:"\u6A21\u677F"});break}},void 0,e.subscriptions),t.onDidDispose(()=>{t=void 0},void 0,e.subscriptions)})));let s=c.commands.registerCommand("template.messageHandler",i=>{let r=JSON.parse(JSON.stringify(i));t==null||t.webview.postMessage(f({},r))});e.subscriptions.push(s)})}function I(){t==null||t.dispose(),t=void 0}0&&(module.exports={activate,deactivate});
