"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _chunkIWTTFLP7js = require('./chunk-IWTTFLP7.js'); var _chunkYNXVNEEBjs = require('./chunk-YNXVNEEB.js'); var _chunkCDFZGZHMjs = require('./chunk-CDFZGZHM.js'); // src/vue.ts var _compilersfc = require('@vue/compiler-sfc'); function parseSFC(code, id) { var _a; const sfc = _compilersfc.parse.call(void 0, code, { filename: id }); const { descriptor, errors } = sfc; const lang = (_a = descriptor.script || descriptor.scriptSetup) == null ? void 0 : _a.lang; return { sfc, ...descriptor, lang, errors, getSetupAst() { if (!descriptor.scriptSetup) return; return _chunkIWTTFLP7js.babelParse.call(void 0, descriptor.scriptSetup.content, lang); }, getScriptAst() { if (!descriptor.script) return; return _chunkIWTTFLP7js.babelParse.call(void 0, descriptor.script.content, lang); } }; } function getFileCodeAndLang(code, id) { var _a; if (!_chunkCDFZGZHMjs.REGEX_VUE_SFC.test(id)) return { code, lang: _chunkYNXVNEEBjs.getLang.call(void 0, id) }; const sfc = parseSFC(code, id); const scriptCode = _nullishCoalesce(((_a = sfc.script) == null ? void 0 : _a.content), () => ( "")); return { code: sfc.scriptSetup ? `${scriptCode} ; ${sfc.scriptSetup.content}` : scriptCode, lang: _nullishCoalesce(sfc.lang, () => ( "js")) }; } function addNormalScript({ script, lang }, s) { return { start() { if (script) return script.loc.end.offset; const attrs = lang ? ` lang="${lang}"` : ""; s.prependLeft(0, ``); return 0; }, end() { if (!script) s.appendRight(0, ` `); } }; } var imported = /* @__PURE__ */ new WeakMap(); var HELPER_PREFIX = "__MACROS_"; function importHelperFn(s, offset, name, from) { var _a; const cacheKey = `${from}@${name}`; if (!((_a = imported.get(s)) == null ? void 0 : _a.has(cacheKey))) { s.appendLeft( offset, ` import { ${name} as ${HELPER_PREFIX}${name} } from '${from}';` ); if (!imported.has(s)) { imported.set(s, /* @__PURE__ */ new Set([cacheKey])); } else { imported.get(s).add(cacheKey); } } } exports.parseSFC = parseSFC; exports.getFileCodeAndLang = getFileCodeAndLang; exports.addNormalScript = addNormalScript; exports.HELPER_PREFIX = HELPER_PREFIX; exports.importHelperFn = importHelperFn;