(()=>{"use strict";var e={1398:e=>{e.exports=require("vscode")},6928:e=>{e.exports=require("path")},7194:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.escapeJsonForHtmlScriptTag=function(e){return e.replace(/</g,"\\u003C").replace(/>/g,"\\u003E").replace(/&/g,"\\u0026")}},9072:function(e,t,r){var o,i=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=o(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return n(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.TemplateUtils=void 0;const a=s(r(6928)),c=s(r(9896)),l=s(r(1398)),u=r(7194);t.TemplateUtils=class{static escapeJsonForHtmlScriptTag(e){return(0,u.escapeJsonForHtmlScriptTag)(e)}static async loadTemplate(e,t,r){const o=a.join(e.extensionPath,"src","templates",t);try{let t=await c.promises.readFile(o,"utf8");t=await this.inlineExternalFiles(e,o,t);for(const[e,o]of Object.entries(r)){const r=`{{${e}}}`,i=null==o?"":String(o);t=t.split(r).join(i)}return t}catch(e){throw console.error(`Error loading template ${t}:`,e),new Error(`Failed to load template: ${t}`)}}static async inlineExternalFiles(e,t,r){const o=a.dirname(t),i=r.match(/<link[^>]*href="([^"]*\.css)"[^>]*>/g);if(i)for(const e of i){const t=e.match(/href="([^"]*\.css)"/);if(t){const i=t[1],n=a.join(o,i);try{const t=`<style>\n${await c.promises.readFile(n,"utf8")}\n</style>`;r=r.replace(e,()=>t)}catch(e){throw console.error(`Failed to inline required CSS file ${i}:`,e),new Error(`Required CSS asset could not be loaded: ${i}`)}}}const n=r.match(/<script[^>]*src="([^"]*\.js)"[^>]*><\/script>/g);if(n)for(const e of n){const t=e.match(/src="([^"]*\.js)"/);if(t){const i=t[1];if(i.startsWith("http://")||i.startsWith("https://"))continue;const n=a.join(o,i);try{const t=`<script>\n${await c.promises.readFile(n,"utf8")}\n<\/script>`;r=r.replace(e,()=>t)}catch(e){throw console.error(`Failed to inline required JavaScript file ${i}:`,e),new Error(`Required JavaScript asset could not be loaded: ${i}`)}}}return r}static getWebviewOptions(e){return{enableScripts:!0,localResourceRoots:[l.Uri.file(a.join(e.extensionPath,"media")),l.Uri.file(a.join(e.extensionPath,"node_modules")),l.Uri.file(a.join(e.extensionPath,"src","templates"))]}}}},9896:e=>{e.exports=require("fs")}},t={},r=function r(o){var i=t[o];if(void 0!==i)return i.exports;var n=t[o]={exports:{}};return e[o].call(n.exports,n,n.exports,r),n.exports}(9072);module.exports=r})();
//# sourceMappingURL=templateUtils.js.map