import e,{useRef as t,useEffect as r,forwardRef as n,useState as o}from"react";import{createPortal as a}from"react-dom";import c from"prop-types";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e,t){return e(t={exports:{}},t.exports),t.exports}var l=i((function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}e.exports=t}));var s=function(e){if(Array.isArray(e))return e};var f=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var c,u=e[Symbol.iterator]();!(n=(c=u.next()).done)&&(r.push(c.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}};var p=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var d=function(e,t){return s(e)||f(e,t)||p()};var y=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o};var h=function(e,t){if(null==e)return{};var r,n,o=y(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o};var v=i((function(e){!function(t){var r=function(e,t,n){if(!i(t)||s(t)||f(t)||p(t)||u(t))return t;var o,a=0,c=0;if(l(t))for(o=[],c=t.length;a<c;a++)o.push(r(e,t[a],n));else for(var d in o={},t)Object.prototype.hasOwnProperty.call(t,d)&&(o[e(d,n)]=r(e,t[d],n));return o},n=function(e){return d(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,(function(e,t){return t?t.toUpperCase():""}))).substr(0,1).toLowerCase()+e.substr(1)},o=function(e){var t=n(e);return t.substr(0,1).toUpperCase()+t.substr(1)},a=function(e,t){return function(e,t){var r=(t=t||{}).separator||"_",n=t.split||/(?=[A-Z])/;return e.split(n).join(r)}(e,t).toLowerCase()},c=Object.prototype.toString,u=function(e){return"function"==typeof e},i=function(e){return e===Object(e)},l=function(e){return"[object Array]"==c.call(e)},s=function(e){return"[object Date]"==c.call(e)},f=function(e){return"[object RegExp]"==c.call(e)},p=function(e){return"[object Boolean]"==c.call(e)},d=function(e){return(e-=0)==e},y=function(e,t){var r=t&&"process"in t?t.process:t;return"function"!=typeof r?e:function(t,n){return r(t,e,n)}},h={camelize:n,decamelize:a,pascalize:o,depascalize:a,camelizeKeys:function(e,t){return r(y(n,t),e)},decamelizeKeys:function(e,t){return r(y(a,t),e,t)},pascalizeKeys:function(e,t){return r(y(o,t),e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};e.exports?e.exports=h:t.humps=h}(u)})).decamelize;function b(e){return e.children}function g(e){var t=e.root,r=e.children;return a(r,t)}g.propTypes={root:c.object.isRequired,children:c.node},g.defaultProps={children:null};var m=new Map;function S(a){var u=n((function(n,c){var u,i,s=n.mode,f=n.delegatesFocus,p=n.styleSheets,y=n.children,v=h(n,["mode","delegatesFocus","styleSheets","children"]),m=(i=t((u=c)&&u.current),r((function(){u&&(u.current=i.current)}),[u]),i),S=o(null),w=d(S,2),O=w[0],j=w[1],x=function(){try{var e=require("styled-components");if(!("StyleSheetManager"in e))throw new Error("`StyleSheetManager` not found in `styled-components` library.");return e.StyleSheetManager}catch(e){return b}}(),z="node_".concat(s).concat(f);return r((function(){if(m.current)try{"function"==typeof c&&c(m.current);var e=m.current.attachShadow({mode:s,delegatesFocus:f});p.length>0&&(e.adoptedStyleSheets=p),j(e)}catch(e){switch(e.name){case"NotSupportedError":p.length>0&&(O.adoptedStyleSheets=p);break;default:throw e}}}),[c,m,p]),e.createElement(a.tag,l({key:z,ref:m},v),O&&e.createElement(x,{target:O},e.createElement(g,{root:O},y)))}));return u.propTypes={mode:c.oneOf(["open","closed"]),delegatesFocus:c.bool,styleSheets:c.arrayOf(c.instanceOf(global.CSSStyleSheet)),children:c.node},u.defaultProps={mode:"open",delegatesFocus:!1,styleSheets:[],children:null},u}function w(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Proxy(e,{get:function(e,t){var r=v(t,{separator:"-"});return m.has(r)||m.set(r,S({tag:r})),m.get(r)}})}var O=w();export default O;export{w as createProxy};
//# sourceMappingURL=react-shadow.esm.js.map
