// @bun
var{defineProperty:H,getOwnPropertyNames:m,getOwnPropertyDescriptor:A}=Object,E=Object.prototype.hasOwnProperty;function b(q){return this[q]}var C=(q)=>{var x=(F??=new WeakMap).get(q),j;if(x)return x;if(x=H({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var G of m(q))if(!E.call(x,G))H(x,G,{get:b.bind(q,G),enumerable:!(j=A(q,G))||j.enumerable})}return F.set(q,x),x},F;var _=(q)=>q;function I(q,x){this[q]=_.bind(null,x)}var d=(q,x)=>{for(var j in x)H(q,j,{get:x[j],enumerable:!0,configurable:!0,set:I.bind(x,j)})};var D=(q,x)=>()=>(q&&(x=q(q=0)),x);var L=import.meta.require;import O from"fs";import X from"path";var T=[72,96,128,144,152,192,384,512],U=[120,152,167,180],N=[16,32];async function g(q,x){let j={success:!0,generatedFiles:[],errors:[],warnings:[]},G=q.pwa?.icons;if(!G?.src)return j.errors.push("No source icon specified in pwa.icons.src"),j.success=!1,j;let Q=X.isAbsolute(G.src)?G.src:X.resolve(process.cwd(),G.src);if(!await Bun.file(Q).exists())return j.errors.push(`Source icon not found: ${Q}`),j.success=!1,j;let y=X.resolve(x,G.outputDir||"pwa-icons");try{O.mkdirSync(y,{recursive:!0})}catch{return j.errors.push(`Failed to create output directory: ${y}`),j.success=!1,j}let J=G.sizes||T,Z=G.generateWebP??!0,k=G.generateAppleIcons??!0;try{let K;try{K=await import("sharp")}catch{return j.errors.push(`sharp is not installed. Install it with: bun add sharp
Icon generation requires the sharp package for image processing.`),j.success=!1,j}let M=await K.default(Q).metadata();if(M.width&&M.width<512)j.warnings.push(`Source icon is ${M.width}x${M.height}. Recommend using at least 512x512 for best quality.`);for(let B of J){let R=X.join(y,`icon-${B}x${B}.png`);if(await K.default(Q).resize(B,B,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(R),j.generatedFiles.push(R),Z){let $=X.join(y,`icon-${B}x${B}.webp`);await K.default(Q).resize(B,B,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile($),j.generatedFiles.push($)}}if(k){for(let R of U){let $=X.join(y,`apple-touch-icon-${R}x${R}.png`);await K.default(Q).resize(R,R,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),j.generatedFiles.push($)}let B=X.join(y,"apple-touch-icon.png");await K.default(Q).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(B),j.generatedFiles.push(B)}for(let B of N){let R=X.join(y,`favicon-${B}x${B}.png`);await K.default(Q).resize(B,B,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(R),j.generatedFiles.push(R)}let w=512,W=X.join(y,`icon-maskable-${w}x${w}.png`),Y=Math.floor(w*0.1),v=w-Y*2;await K.default(Q).resize(v,v,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Y,bottom:Y,left:Y,right:Y,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(W),j.generatedFiles.push(W)}catch(K){let V=K instanceof Error?K.message:String(K);j.errors.push(`Icon generation failed: ${V}`),j.success=!1}return j}function z(q){let x=q.sizes||T,j=q.outputDir?`/${q.outputDir}`:"/pwa-icons",G=q.generateWebP??!0,Q=q.generateAppleIcons??!0,y=[];for(let J of x)if(y.push(`${j}/icon-${J}x${J}.png`),G)y.push(`${j}/icon-${J}x${J}.webp`);if(Q){y.push(`${j}/apple-touch-icon.png`);for(let J of U)y.push(`${j}/apple-touch-icon-${J}x${J}.png`)}for(let J of N)y.push(`${j}/favicon-${J}x${J}.png`);return y.push(`${j}/icon-maskable-512x512.png`),y}async function l(){try{return await import("sharp"),!0}catch{return!1}}export{l as isSharpAvailable,z as getExpectedIconPaths,g as generatePwaIcons,N as FAVICON_SIZES,T as DEFAULT_ICON_SIZES,U as APPLE_TOUCH_ICON_SIZES};
