import{StyleSheet as e}from"../../../../../sheet/dist/emotion-sheet.esm.js";import t from"../../../../../weak-memoize/dist/weak-memoize.esm.js";import r from"../../../../../memoize/dist/emotion-memoize.esm.js";import{stringify as n,serialize as o}from"../../../stylis/src/Serializer.js";import{COMMENT as s}from"../../../stylis/src/Enum.js";import{rulesheet as i,middleware as a,prefixer as c}from"../../../stylis/src/Middleware.js";import{dealloc as u,alloc as l,next as p,token as d,peek as f,delimit as m,identifier as h,position as y}from"../../../stylis/src/Tokenizer.js";import{compile as v}from"../../../stylis/src/Parser.js";import{from as g}from"../../../stylis/src/Utility.js";var E=function(e,t){return u(function(e,t){var r=-1,n=44;do{switch(d(n)){case 0:38===n&&12===f()&&(t[r]=1),e[r]+=h(y-1);break;case 2:e[r]+=m(n);break;case 4:if(44===n){e[++r]=58===f()?"&\f":"",t[r]=e[r].length;break}default:e[r]+=g(n)}}while(n=p());return e}(l(e),t))},w=new WeakMap,b=function(e){if("rule"===e.type&&e.parent&&e.length){for(var t=e.value,r=e.parent,n=e.column===r.column&&e.line===r.line;"rule"!==r.type;)if(!(r=r.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||w.get(r))&&!n){w.set(e,!0);for(var o=[],s=E(t,o),i=r.props,a=0,c=0;a<s.length;a++)for(var u=0;u<i.length;u++,c++)e.props[c]=o[a]?s[a].replace(/&\f/g,i[u]):i[u]+" "+s[a]}}},k=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}},A=function(e){return 105===e.type.charCodeAt(1)&&64===e.type.charCodeAt(0)},N=function(e){e.type="",e.value="",e.return="",e.children="",e.props=""},j=function(e,t,r){A(e)&&(e.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),N(e)):function(e,t){for(var r=e-1;r>=0;r--)if(!A(t[r]))return!0;return!1}(t,r)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),N(e)))},O="undefined"!=typeof document,z=O?void 0:t((function(){return r((function(){var e={};return function(t){return e[t]}}))})),C=[c];export default function(t){var r=t.key;if("production"!==process.env.NODE_ENV&&!r)throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\nIf multiple caches share the same key they might \"fight\" for each other's style elements.");if(O&&"css"===r){var c=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(c,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var u=t.stylisPlugins||C;if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(r))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+r+'" was passed');var l,p,d={},f=[];O&&(l=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),r=1;r<t.length;r++)d[t[r]]=!0;f.push(e)})));var m=[b,k];if("production"!==process.env.NODE_ENV&&m.push(function(e){return function(t,r,n){if("rule"===t.type){var o,s=t.value.match(/(:first|:nth|:nth-last)-child/g);if(s&&!0!==e.compat){var i=r>0?n[r-1]:null;if(i&&function(e){return!!e&&"comm"===e.type&&e.children.indexOf("emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason")>-1}((o=i.children).length?o[o.length-1]:null))return;s.forEach((function(e){console.error('The pseudo class "'+e+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+e.split("-child")[0]+'-of-type".')}))}}}}({get compat(){return D.compat}}),j),O){var h,y=[n,"production"!==process.env.NODE_ENV?function(e){e.root||(e.return?h.insert(e.return):e.value&&e.type!==s&&h.insert(e.value+"{}"))}:i((function(e){h.insert(e)}))],g=a(m.concat(u,y));p=function(e,t,r,n){var s;h=r,"production"!==process.env.NODE_ENV&&void 0!==t.map&&(h={insert:function(e){r.insert(e+t.map)}}),s=e?e+"{"+t.styles+"}":t.styles,o(v(s),g),n&&(D.inserted[t.name]=!0)}}else{var E=[n],w=a(m.concat(u,E)),A=z(u)(r),N=function(e,t){var r,n=t.name;return void 0===A[n]&&(A[n]=(r=e?e+"{"+t.styles+"}":t.styles,o(v(r),w))),A[n]};p=function(e,t,r,n){var o=t.name,s=N(e,t);return void 0===D.compat?(n&&(D.inserted[o]=!0),"development"===process.env.NODE_ENV&&void 0!==t.map?s+t.map:s):n?void(D.inserted[o]=s):s}}var D={key:r,sheet:new e({key:r,container:l,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend}),nonce:t.nonce,inserted:d,registered:{},insert:p};return D.sheet.hydrate(f),D}
//# sourceMappingURL=emotion-cache.esm.js.map
