1{"version":3,"file":"css.js","names":["pathToHtmlSafeName","path","replace","getHotReplaceTemplate","id","attr","JSON","stringify","wrapDevelopmentCSS","props","withBackTicksEscaped","escapeBackticksAndOctals","src","filename","str","match","charCodeAt","toString"],"sources":["../../src/transform-worker/css.ts"],"sourcesContent":["export function pathToHtmlSafeName(path: string) {\n  return path.replace(/[^a-zA-Z0-9_]/g, '_');\n}\n\nexport function getHotReplaceTemplate(id: string) {\n  // In dev mode, we need to replace the style tag instead of appending it\n  // use the path as the expo-css-hmr attribute to find the style tag\n  // to replace.\n  const attr = JSON.stringify(pathToHtmlSafeName(id));\n  return `style.setAttribute('data-expo-css-hmr', ${attr});\n  const previousStyle = document.querySelector('[data-expo-css-hmr=${attr}]');\n  if (previousStyle) {\n    previousStyle.parentNode.removeChild(previousStyle);\n  }`;\n}\n\nexport function wrapDevelopmentCSS(props: { src: string; filename: string }) {\n  const withBackTicksEscaped = escapeBackticksAndOctals(props.src);\n  return `(() => {\n  if (typeof document === 'undefined') {\n    return\n  }\n  const head = document.head || document.getElementsByTagName('head')[0];\n  const style = document.createElement('style');\n  ${getHotReplaceTemplate(props.filename)}\n  style.setAttribute('data-expo-loader', 'css');\n  head.appendChild(style);\n  const css = \\`${withBackTicksEscaped}\\`;\n  if (style.styleSheet){\n    style.styleSheet.cssText = css;\n  } else {\n    style.appendChild(document.createTextNode(css));\n  }\n})();`;\n}\n\nexport function escapeBackticksAndOctals(str: string) {\n  if (typeof str !== 'string') {\n    return '';\n  }\n\n  return str\n    .replace(/\\\\/g, '\\\\\\\\')\n    .replace(/`/g, '\\\\`')\n    .replace(/[\\0-\\7]/g, (match) => `\\\\0${match.charCodeAt(0).toString(8)}`);\n}\n"],"mappings":";;;;;;;;;AAAO,SAASA,kBAAkBA,CAACC,IAAY,EAAE;EAC/C,OAAOA,IAAI,CAACC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAC5C;AAEO,SAASC,qBAAqBA,CAACC,EAAU,EAAE;EAChD;EACA;EACA;EACA,MAAMC,IAAI,GAAGC,IAAI,CAACC,SAAS,CAACP,kBAAkB,CAACI,EAAE,CAAC,CAAC;EACnD,OAAQ,2CAA0CC,IAAK;AACzD,qEAAqEA,IAAK;AAC1E;AACA;AACA,IAAI;AACJ;AAEO,SAASG,kBAAkBA,CAACC,KAAwC,EAAE;EAC3E,MAAMC,oBAAoB,GAAGC,wBAAwB,CAACF,KAAK,CAACG,GAAG,CAAC;EAChE,OAAQ;AACV;AACA;AACA;AACA;AACA;AACA,IAAIT,qBAAqB,CAACM,KAAK,CAACI,QAAQ,CAAE;AAC1C;AACA;AACA,kBAAkBH,oBAAqB;AACvC;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AAEO,SAASC,wBAAwBA,CAACG,GAAW,EAAE;EACpD,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAO,EAAE;EACX;EAEA,OAAOA,GAAG,CACPZ,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CACtBA,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CACpBA,OAAO,CAAC,UAAU,EAAGa,KAAK,IAAM,MAAKA,KAAK,CAACC,UAAU,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAE,EAAC,CAAC;AAC5E"}