import{extractStylesSync as e}from"@astrojs/compiler-binding";function t(e){if(!e)return;let t;e.preprocessedStyles&&e.preprocessedStyles.styles.some(e=>e!=null)&&(t=e.preprocessedStyles.styles);let n=(e.compact===!0?`html`:e.compact===`jsx`?`jsx`:void 0)??`none`;return{filename:e.filename,normalizedFilename:e.normalizedFilename,internalURL:e.internalURL,sourcemap:e.sourcemap,astroGlobalArgs:e.astroGlobalArgs,compact:n,resultScopedSlot:e.resultScopedSlot,scopedStyleStrategy:e.scopedStyleStrategy,transitionsAnimationURL:e.transitionsAnimationURL,annotateSourceFile:e.annotateSourceFile,resolvePathProvided:typeof e.resolvePath==`function`?!0:void 0,preprocessedStyles:t}}function n(e,t){return t?.styleError?.length?{...e,styleError:t.styleError}:e}function r(e){return{ast:JSON.parse(e.ast),diagnostics:e.diagnostics}}function i(e){return`error`in e&&typeof e.error==`string`}function a(e){let t=[];return{styles:e.map(e=>{if(e!=null)return i(e)?(t.push(e.error),``):e.code}),styleError:t}}function o(t,n){let r=e(t);if(r.length===0)return{styles:[],styleError:[]};let i=[],o=!1;for(let e of r)try{let t=n(e.content,e.attrs);t!=null&&typeof t.then==`function`&&(o=!0),i.push(t)}catch(e){i.push({error:e instanceof Error?e.message:String(e)})}return o?Promise.all(i.map(async e=>{try{return await e}catch(e){return{error:e instanceof Error?e.message:String(e)}}})).then(a):a(i)}export{t as mapOptions,r as mapParseResult,n as mapResult,o as preprocessStyles};