"use strict";var T=(s,e,t)=>new Promise((p,a)=>{var l=i=>{try{c(t.next(i))}catch(n){a(n)}},u=i=>{try{c(t.throw(i))}catch(n){a(n)}},c=i=>i.done?p(i.value):Promise.resolve(i.value).then(l,u);c((t=t.apply(s,e)).next())});const r=require("code-inspector-core"),x=["isJsx","isTsx","lang.jsx","lang.tsx"];function S(s){return T(this,null,function*(){var y,f,g;this.cacheable&&this.cacheable(!0);let e=r.normalizePath(this.resourcePath),t=new URLSearchParams(((y=this.resource.split("?"))==null?void 0:y[1])||"");const p=this.query,{escapeTags:a=[],mappings:l}=p||{};if(e=r.getMappingFilePath(e,l),r.isJsTypeFile(e)||e.endsWith(".vue")&&x.some(o=>t.get(o)!==null))return r.transformCode({content:s,filePath:e,fileType:"jsx",escapeTags:a,pathType:p.pathType});if(e.endsWith(".vue")&&(t.get("lang")==="tsx"||t.get("lang")==="jsx")){const{descriptor:o}=r.parseSFC(s,{sourceMap:!1}),d=[(f=o.script)==null?void 0:f.content,(g=o.scriptSetup)==null?void 0:g.content];for(const h of d){if(!h)continue;const m=r.transformCode({content:h,filePath:e,fileType:"jsx",escapeTags:a,pathType:p.pathType});s=s.replace(h,m)}return s}const i=e.endsWith(".vue")&&t.get("type")!=="style"&&t.get("type")!=="script"&&t.get("raw")===null,n=e.endsWith(".html")&&t.get("type")==="template"&&t.has("vue");return i||n?r.transformCode({content:s,filePath:e,fileType:"vue",escapeTags:a,pathType:p.pathType}):e.endsWith(".svelte")?r.transformCode({content:s,filePath:e,fileType:"svelte",escapeTags:a,pathType:p.pathType}):s})}module.exports=S;
