"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=default_1;const tslib_1=require("tslib"),config_1=require("../../../../config/config"),log=tslib_1.__importStar(require("../../../../utils/log")),customError_1=require("../../../../utils/customError"),minifywxml_1=require("../../original/workerThread/task/minifywxml");function default_1(e,t){const{minify:r=!0}=t||{};return{name:"summer-minifywxml",workerMethods:{async doCompress(e,t,r){try{const i=await(0,minifywxml_1.minifyWXML)({code:e,filePath:t,setting:r});if(i.error)throw i.error;return i.code}catch(e){throw log.error(e),(0,customError_1.makeCustomError)(e.message,config_1.MINIFY_WXML_ERR,t)}}},async compress(t,i){var s,o;if(!r||"dev"===i.resultType||!t.targetPath.endsWith(".wxml"))return t;const n=Date.now(),a=t.target.code,c=await this.runWorkerMethod("doCompress",a,t.targetPath,Object.assign(Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},null===(s=e.setting.minifyWXMLSetting)||void 0===s?void 0:s.global),null===(o=e.setting.minifyWXMLSetting)||void 0===o?void 0:o[t.targetPath]));return Object.assign(Object.assign({},t),{target:Object.assign(Object.assign({},t.target),{code:c}),process:[...t.process,{cost:Date.now()-n,pluginName:"summer-minifywxml",action:"compress"}]})}}}