{"version":3,"file":"InlineStyles.mjs","names":[],"sources":["../../../src/core/InlineStyles/InlineStyles.tsx"],"sourcesContent":["import { useMantineStyleNonce } from '../MantineProvider';\nimport { InlineStylesInput, stylesToString } from './styles-to-string/styles-to-string';\n\nexport interface InlineStylesProps\n  extends InlineStylesInput, Omit<React.ComponentProps<'style'>, keyof InlineStylesInput> {\n  deduplicate?: boolean;\n}\n\nfunction simpleHash(str: string): string {\n  let hash = 5381;\n  for (let i = 0; i < str.length; i++) {\n    hash = ((hash << 5) + hash + str.charCodeAt(i)) & 0xffffffff;\n  }\n  return (hash >>> 0).toString(36);\n}\n\nexport function InlineStyles({ deduplicate, ...props }: InlineStylesProps) {\n  const nonce = useMantineStyleNonce();\n  const css = stylesToString(props);\n\n  if (deduplicate) {\n    return (\n      <style href={`mantine-${simpleHash(css)}`} precedence=\"mantine\" nonce={nonce?.()}>\n        {css}\n      </style>\n    );\n  }\n\n  return (\n    <style\n      data-mantine-styles=\"inline\"\n      nonce={nonce?.()}\n      dangerouslySetInnerHTML={{ __html: css }}\n    />\n  );\n}\n"],"mappings":";;;;;AAQA,SAAS,WAAW,KAAqB;CACvC,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,IAC9B,SAAS,QAAQ,KAAK,OAAO,IAAI,WAAW,EAAE,GAAI;AAEpD,SAAQ,SAAS,GAAG,SAAS,GAAG;;AAGlC,SAAgB,aAAa,EAAE,aAAa,GAAG,SAA4B;CACzE,MAAM,QAAQ,sBAAsB;CACpC,MAAM,MAAM,eAAe,MAAM;AAEjC,KAAI,YACF,QACE,oBAAC,SAAD;EAAO,MAAM,WAAW,WAAW,IAAI;EAAI,YAAW;EAAU,OAAO,SAAS;YAC7E;EACK,CAAA;AAIZ,QACE,oBAAC,SAAD;EACE,uBAAoB;EACpB,OAAO,SAAS;EAChB,yBAAyB,EAAE,QAAQ,KAAK;EACxC,CAAA"}