1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/hashStyleCopy-B7l2OPhl.js","assets/ctFullscreenAd-CL-AA_Ul.js","assets/app-gOHIPY12.js"])))=>i.map(i=>d[i]); 2import{_ as I,T as L}from"./app-gOHIPY12.js";import{M as w,r as B,d as $}from"./csvSqlCore-M_4k9GW7.js";import{c as M,w as O}from"./fileDropzone-CA_uaFcV.js";import"./papaparse.min-DtqB8VRF.js";import"./_commonjsHelpers-BosuxZz1.js";import"./FileSaver.min-BR20wtAe.js";import"./transientNotice-Ds_di7lD.js";const x={html:{label:"HTML",ext:"html",sample:`<!doctype html> 3<html> 4 <body> 5 <!-- demo --> 6 <main class="card"> 7 <h1>ConversionTab</h1> 8 <p>Fast tools in your browser.</p> 9 </main> 10 </body> 11</html>`,minify:k},css:{label:"CSS",ext:"css",sample:`/* Demo card */ 12.card { 13 color: #222; 14 margin: 0 auto; 15 padding: 1rem; 16} 17.card h1 { 18 font-size: 1.5rem; 19}`,minify:N},javascript:{label:"JavaScript",ext:"js",sample:`function greet(name) { 20 const message = \`Hello, \${name}!\`; 21 console.log(message); 22} 23 24greet("ConversionTab");`,minify:D},json:{label:"JSON",ext:"json",sample:`{ 25 "name": "ConversionTab", 26 "features": ["convert", "minify", "download"], 27 "active": true 28}`,minify:t=>JSON.stringify(JSON.parse(t))},xml:{label:"XML",ext:"xml",sample:`<?xml version="1.0"?> 29<root> 30 <!-- demo --> 31 <item id="1">ConversionTab</item> 32 <item id="2">Minifier</item> 33</root>`,minify:X},svg:{label:"SVG",ext:"svg",sample:`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="40"> 34 <title>Demo</title> 35 <rect width="120" height="40" fill="#0d6efd" /> 36 <text x="12" y="25" fill="white">SVG</text> 37</svg>`,minify:z}};function g(t,e=!0){const i=document.getElementById("ctMinifierToast"),o=document.getElementById("ctMinifierToastBody");if(!i||!o){window.alert(t);return}o.textContent=t,i.classList.remove("text-bg-success","text-bg-danger"),i.classList.add(e?"text-bg-danger":"text-bg-success"),L.getOrCreateInstance(i,{delay:4e3}).show()}function v(t,e=!0){var i,o;t&&(t.classList.toggle("ct-hash-copy-btn--success",e),(i=t.querySelector(".ct-hash-copy-ic--default"))==null||i.classList.toggle("d-none",e),(o=t.querySelector(".ct-hash-copy-ic--done"))==null||o.classList.toggle("d-none",!e))}function _(t){return String(t).replace(/<!--(?!\[if\b|\s*<!|\s*>)[\s\S]*?-->/gi,"")}function F(t){let e="",i="",o=!1;for(let l=0;l<t.length;l+=1){const s=t[l];if(i){e+=s,s==="\\"?(l+=1,e+=t[l]||""):s===i&&(i=""),o=!1;continue}if(s==='"'||s==="'"){i=s,e+=s,o=!1;continue}if(/\s/.test(s)){o||(e+=" "),o=!0;continue}e+=s,o=!1}return e.trim()}function k(t){return F(_(t)).replace(/>\s+</g,"><").replace(/\s+\/>/g,"/>").trim()}function N(t){return String(t).replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,>+~])\s*/g,"$1").replace(/;}/g,"}").replace(/\s*!important/g,"!important").trim()}function D(t){let e="",i="code",o="",l=!1,s="";const p=(c,n)=>/[$\w]/.test(c||"")&&/[$\w]/.test(n||"");for(let c=0;c<t.length;c+=1){const n=t[c],f=t[c+1]||"";if(i==="lineComment"){(n===` 38`||n==="\r")&&(i="code",p(s,f)&&(e+=" "));continue}if(i==="blockComment"){n==="*"&&f==="/"&&(i="code",c+=1,p(s,t[c+1]||"")&&(e+=" "));continue}if(i==="string"){e+=n,n==="\\"?(c+=1,e+=t[c]||""):n===o&&(i="code",o="",s=n);continue}if(i==="template"){e+=n,n==="\\"?(c+=1,e+=t[c]||""):n==="`"&&(i="code",s=n);continue}if(i==="regex"){e+=n,n==="\\"?(c+=1,e+=t[c]||""):n==="["?l=!0:n==="]"?l=!1:n==="/"&&!l&&(i="code",s=n);continue}if(n==="/"&&f==="/"){i="lineComment",c+=1;continue}if(n==="/"&&f==="*"){i="blockComment",c+=1;continue}if(n==='"'||n==="'"){i="string",o=n,e+=n;continue}if(n==="`"){i="template",e+=n;continue}if(n==="/"&&/[({[=,:;!&|?+\-*~^<>]|^$/.test(s||"")){i="regex",l=!1,e+=n;continue}if(/\s/.test(n)){p(s,f)&&(e+=" ");continue}/[\w$]/.test(n)||(e=e.replace(/\s+$/g,"")),e+=n,/\s/.test(n)||(s=n)}return e.trim()}function C(t){Array.from(t.childNodes).forEach(e=>{if(e.nodeType===Node.COMMENT_NODE){e.remove();return}if(e.nodeType===Node.TEXT_NODE&&!e.textContent.trim()){e.remove();return}C(e)})}function b(t,e){const o=new DOMParser().parseFromString(String(t).trim(),e),l=o.querySelector("parsererror");
38if(l)throw new Error(l.textContent||"Invalid XML");return C(o),new XMLSerializer().serializeToString(o).trim()}function X(t){return b(t,"application/xml")}function z(t){return b(t,"image/svg+xml")}function q(t,e){const i=t.length-e.length,o=t.length>0?Math.max(0,Math.round(i/t.length*100)):0;return`${t.length.toLocaleString()} chars -> ${e.length.toLocaleString()} chars (${o}% smaller)`}function V(){const t=document.getElementById("ct-minifier-root");if(!t)return;const e=t.dataset.ctType||"html",i=x[e]||x.html,o=document.getElementById("ctMinifierInput"),l=document.getElementById("ctMinifierOutput"),s=document.getElementById("ctMinifierFile"),p=document.getElementById("ctMinifierFileZone"),c=document.getElementById("ctMinifierFileDropCaption"),n=document.getElementById("ctMinifierRun"),f=document.getElementById("ctMinifierExample"),E=document.getElementById("ctMinifierClear"),a=document.getElementById("ctMinifierCopy"),d=document.getElementById("ctMinifierDownload"),u=document.getElementById("ctMinifierFileName"),S=document.getElementById("ctMinifierStats");let y="";function h(r,m){y=r,l&&(l.value=r),a&&(a.disabled=!r),d&&(d.disabled=!r),u&&(u.disabled=!r),S&&(S.textContent=r?q(m,r):"Ready."),v(a,!1)}f==null||f.addEventListener("click",()=>{o&&(o.value=i.sample),h("","")}),E==null||E.addEventListener("click",()=>{o&&(o.value=""),M(s),h("","")}),s==null||s.addEventListener("change",async()=>{var m;const r=(m=s.files)==null?void 0:m[0];if(!(!r||!o)){if(r.size/(1024*1024)>w){g(`The file size exceeds the limit of ${w}MB`),M(s);return}try{o.value=await B(r),h("","")}catch{g("Could not read file.")}}}),s&&p&&O({input:s,drop:p,captionEl:c}),n==null||n.addEventListener("click",()=>{const r=String((o==null?void 0:o.value)||"").trim();if(!r){g(`Paste ${i.label} or choose a file.`);return}try{const m=i.minify(r);h(m,r),g(`${i.label} minified.`,!1)}catch(m){h("",""),g(m instanceof Error?m.message:`Invalid ${i.label}.`)}}),a==null||a.addEventListener("click",async()=>{if(y)try{const{copyText:r}=await I(async()=>{const{copyText:T}=await import("./hashStyleCopy-B7l2OPhl.js");return{copyText:T}},__vite__mapDeps([0,1,2]));if(!await r(y)){g("Could not copy output.");return}v(a,!0),window.setTimeout(()=>v(a,!1),1200)}catch{g("Could not copy output.")}}),d==null||d.addEventListener("click",()=>{if(!y)return;const r=((u==null?void 0:u.value)||"minified").trim().replace(/[^\w.-]+/g,"_")||"minified";$(y,`${r}.${i.ext}`)}),a&&(a.disabled=!0),d&&(d.disabled=!0),u&&(u.disabled=!0)}export{V as initMinifierToolPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.