// @bun
var{defineProperty:U,getOwnPropertyNames:$,getOwnPropertyDescriptor:k}=Object,F=Object.prototype.hasOwnProperty;function I(B){return this[B]}var T=(B)=>{var j=(_??=new WeakMap).get(B),q;if(j)return j;if(j=U({},"__esModule",{value:!0}),B&&typeof B==="object"||typeof B==="function"){for(var E of $(B))if(!F.call(j,E))U(j,E,{get:I.bind(B,E),enumerable:!(q=k(B,E))||q.enumerable})}return _.set(B,j),j},_;var O=(B)=>B;function y(B,j){this[B]=O.bind(null,j)}var D=(B,j)=>{for(var q in j)U(B,q,{get:j[q],enumerable:!0,configurable:!0,set:y.bind(j,q)})};var S=(B,j)=>()=>(B&&(j=B(B=0)),j);var H=import.meta.require;function R(B,j,q,E){let K=[],L=E.join(" ");for(let G of B)if(K.push({src:`${j}/icon-${G}x${G}.png`,sizes:`${G}x${G}`,type:"image/png",purpose:L}),q)K.push({src:`${j}/icon-${G}x${G}.webp`,sizes:`${G}x${G}`,type:"image/webp",purpose:L});return K}function v(B){return B.map((j)=>({name:j.name,short_name:j.shortName,description:j.description,url:j.url,icons:j.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function W(B){let j=B.pwa?.shareTarget;if(!j?.enabled)return;let q={action:j.action||"/share",method:j.method||"POST",enctype:j.enctype||"multipart/form-data",params:{title:j.params?.title||"title",text:j.params?.text||"text",url:j.params?.url||"url"}};if(j.acceptFiles&&j.acceptFiles.length>0)q.params.files=j.acceptFiles.map((E)=>({name:E.name,accept:E.accept}));return q}function P(B){let j=B.pwa?.fileHandlers;if(!j?.enabled||!j.accept)return;let q=[{action:j.action||"/",accept:j.accept,launch_type:j.launchType||"single-client"}];if(j.icons)q[0].icons=j.icons.map((E)=>({src:E.src,sizes:E.sizes,type:E.type}));return q}function V(B){let j=B.pwa?.protocolHandlers;if(!j||j.length===0)return;return j.map((q)=>({protocol:q.protocol,url:q.url}))}function x(B){let j=B.pwa;if(!j?.enabled||!j.manifest)return null;let{manifest:q,icons:E}=j,K=E?.sizes||[72,96,128,144,152,192,384,512],L=E?.outputDir?`/${E.outputDir}`:"/pwa-icons",G=E?.generateWebP??!0,N=E?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:R(K,L,G,N)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=v(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((Q)=>({src:Q.src,sizes:Q.sizes,type:Q.type,label:Q.label,form_factor:Q.platform}));let X=W(B);if(X)J.share_target=X;let Y=P(B);if(Y)J.file_handlers=Y;let Z=V(B);if(Z)J.protocol_handlers=Z;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function z(B){let j=x(B);if(!j)return"";let q=JSON.parse(JSON.stringify(j));return JSON.stringify(q,null,2)}function b(B,j){return{...j,...B,shortcuts:B.shortcuts||j.shortcuts,screenshots:B.screenshots||j.screenshots,categories:B.categories||j.categories}}function M(B){let j=[],q=B.pwa;if(!q?.enabled)return j;let E=q.manifest;if(!E)return j.push("PWA manifest configuration is missing"),j;if(!E.name)j.push("Manifest name is required");let K=["fullscreen","standalone","minimal-ui","browser"];if(E.display&&!K.includes(E.display))j.push(`Invalid display mode: ${E.display}. Must be one of: ${K.join(", ")}`);let L=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(E.orientation&&!L.includes(E.orientation))j.push(`Invalid orientation: ${E.orientation}`);let G=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(E.themeColor&&!G.test(E.themeColor))j.push(`Invalid theme color: ${E.themeColor}. Must be a valid hex color.`);if(E.backgroundColor&&!G.test(E.backgroundColor))j.push(`Invalid background color: ${E.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)j.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)j.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let N of q.protocolHandlers){if(!N.protocol)j.push("Protocol handler missing protocol");if(!N.url||!N.url.includes("%s"))j.push(`Protocol handler URL must contain %s placeholder: ${N.protocol}`)}return j}export{M as validateManifest,b as mergeManifestConfig,z as generateManifestJson,x as generateManifest};
