{
  "version": 3,
  "sources": ["../../../src/higher-order/with-fallback-styles/index.tsx"],
  "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { createHigherOrderComponent, useIsomorphicLayoutEffect } from '@wordpress/compose';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport default mapNodeToProps => createHigherOrderComponent(WrappedComponent => {\n  return function WithFallbackStyles(props) {\n    const [fallbackStyles, setFallbackStyles] = useState(undefined);\n    const nodeRef = useRef(null);\n\n    // Runs before paint, so the fallback styles apply without a flash.\n    useIsomorphicLayoutEffect(() => {\n      const node = props.node ?? nodeRef.current;\n      // Derived from fallbackStyles: the grab is complete once every\n      // mapped value has resolved to a truthy style.\n      const grabStylesCompleted = !!fallbackStyles && Object.values(fallbackStyles).every(Boolean);\n      if (node && !grabStylesCompleted) {\n        const newFallbackStyles = mapNodeToProps(node, props);\n        if (!fastDeepEqual(newFallbackStyles, fallbackStyles)) {\n          setFallbackStyles(newFallbackStyles);\n        }\n      }\n    });\n    const wrappedComponent = /*#__PURE__*/_jsx(WrappedComponent, {\n      ...props,\n      ...fallbackStyles\n    });\n    return props.node ? wrappedComponent : /*#__PURE__*/_jsxs(\"div\", {\n      ref: nodeRef,\n      children: [\" \", wrappedComponent, \" \"]\n    });\n  };\n}, 'withFallbackStyles');"],
  "mappings": ";AAGA,OAAO,mBAAmB;AAK1B,SAAS,UAAU,cAAc;AACjC,SAAS,4BAA4B,iCAAiC;AACtE,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAO,+BAAQ,oBAAkB,2BAA2B,sBAAoB;AAC9E,SAAO,SAAS,mBAAmB,OAAO;AACxC,UAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,MAAS;AAC9D,UAAM,UAAU,OAAO,IAAI;AAG3B,8BAA0B,MAAM;AAC9B,YAAM,OAAO,MAAM,QAAQ,QAAQ;AAGnC,YAAM,sBAAsB,CAAC,CAAC,kBAAkB,OAAO,OAAO,cAAc,EAAE,MAAM,OAAO;AAC3F,UAAI,QAAQ,CAAC,qBAAqB;AAChC,cAAM,oBAAoB,eAAe,MAAM,KAAK;AACpD,YAAI,CAAC,cAAc,mBAAmB,cAAc,GAAG;AACrD,4BAAkB,iBAAiB;AAAA,QACrC;AAAA,MACF;AAAA,IACF,CAAC;AACD,UAAM,mBAAgC,qBAAK,kBAAkB;AAAA,MAC3D,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AACD,WAAO,MAAM,OAAO,mBAAgC,sBAAM,OAAO;AAAA,MAC/D,KAAK;AAAA,MACL,UAAU,CAAC,KAAK,kBAAkB,GAAG;AAAA,IACvC,CAAC;AAAA,EACH;AACF,GAAG,oBAAoB;",
  "names": []
}
