import hyphenate from"fbjs/lib/hyphenateStyleName";import React,{cloneElement,Component,createElement}from"react";import Stylis from"stylis";import _insertRulePlugin from"stylis-rule-sheet";import PropTypes from"prop-types";import stream from"stream";import hoistStatics from"hoist-non-react-statics";import{isValidElementType}from"react-is";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},isPlainObject=function(e){return"object"===(void 0===e?"undefined":_typeof(e))&&e.constructor===Object},StyledComponentsError=function(e){function t(n){classCallCheck(this,t);for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i25?39:97))},generateAlphabeticName=function(e){var t="",n=void 0;for(n=e;n>charsLength;n=Math.floor(n/charsLength))t=getAlphabeticChar(n%charsLength)+t;return getAlphabeticChar(n%charsLength)+t},interleave=function(e,t){for(var n=[e[0]],r=0,o=t.length;r1?t-1:0),r=1;rr;o-=1)e.deleteRule(o)},makeTextMarker=function(e){return"\n/* sc-component-id: "+e+" */\n"},addUpUntilIndex=function(e,t){for(var n=0,r=0;r<=t;r+=1)n+=e[r];return n},makeStyleTag=function(e,t,n){var r=document.createElement("style");r.setAttribute(SC_ATTR,"");var o=getNonce();if(o&&r.setAttribute("nonce",o),r.appendChild(document.createTextNode("")),e&&!t)e.appendChild(r);else{if(!t||!e||!t.parentNode)throw new StyledComponentsError(6);t.parentNode.insertBefore(r,n?t:t.nextSibling)}return r},wrapAsHtmlTag=function(e,t){return function(n){var r=getNonce();return""}},wrapAsElement=function(e,t){return function(){var n,r=((n={})[SC_ATTR]=stringifyNames(t),n),o=getNonce();return o&&(r.nonce=o),React.createElement("style",_extends({},r,{dangerouslySetInnerHTML:{__html:e()}}))}},getIdsFromMarkersFactory=function(e){return function(){return Object.keys(e)}},makeSpeedyTag=function(e,t){var n=Object.create(null),r=Object.create(null),o=[],i=void 0!==t,s=!1,a=function(e){var t=r[e];return void 0!==t?t:(r[e]=o.length,o.push(0),resetIdNames(n,e),r[e])},c=function(){var t=sheetForTag(e).cssRules,n="";for(var i in r){n+=makeTextMarker(i);for(var s=r[i],a=addUpUntilIndex(o,s),c=a-o[s];c0&&(s=!0,t().insertRules(r+"-import",m)),o[l]+=d,addNameForId(n,r,u)},removeRules:function(a){var c=r[a];if(void 0!==c){var u=o[c],l=sheetForTag(e),p=addUpUntilIndex(o,c);deleteRules(l,p,u),o[c]=0,resetIdNames(n,a),i&&s&&t().removeRules(a+"-import")}},sealed:!1,styleTag:e,toElement:wrapAsElement(c,n),toHTML:wrapAsHtmlTag(c,n)}},makeServerTagInternal=function e(t,n){var r=void 0===t?Object.create(null):t,o=void 0===n?Object.create(null):n,i=function(e){var t=o[e];return void 0!==t?t:o[e]=[""]},s=function(){var e="";for(var t in o){var n=o[t][0];n&&(e+=makeTextMarker(t)+n)}return e};return{clone:function(){var t=cloneNames(r),n=Object.create(null);for(var i in o)n[i]=[o[i][0]];return e(t,n)},css:s,getIds:getIdsFromMarkersFactory(o),hasNameForId:hasNameForId(r),insertMarker:i,insertRules:function(e,t,n){i(e)[0]+=t.join(" "),addNameForId(r,e,n)},removeRules:function(e){var t=o[e];void 0!==t&&(t[0]="",resetIdNames(r,e))},sealed:!1,styleTag:null,toElement:wrapAsElement(s,r),toHTML:wrapAsHtmlTag(s,r)}},makeServerTag=function(){return makeServerTagInternal()},makeTag=function(e,t,n,r,o){if(IS_BROWSER&&!n){var i=makeStyleTag(e,t,r);return makeSpeedyTag(i,o)}return makeServerTag()},makeRehydrationTag=function(e,t,n,r){var o=once(function(){for(var r=0,o=n.length;r0&&void 0!==arguments[0]?arguments[0]:IS_BROWSER?document.head:null,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];classCallCheck(this,e),this.getImportRuleTag=function(){var e=t.importRuleTag;if(void 0!==e)return e;var n=t.tags[0];return t.importRuleTag=makeTag(t.target,n?n.styleTag:null,t.forceServer,!0)},sheetRunningId+=1,this.id=sheetRunningId,this.forceServer=r,this.target=r?null:n,this.tagMap={},this.deferred={},this.rehydratedNames={},this.ignoreRehydratedNames={},this.tags=[],this.capacity=1,this.clones=[]}return e.prototype.rehydrate=function(){if(!IS_BROWSER||this.forceServer)return this;var e=[],t=[],n=!1,r=document.querySelectorAll("style["+SC_ATTR+"]"),o=r.length;if(0===o)return this;for(var i=0;i0&&void 0!==arguments[0]&&arguments[0];master=new e(void 0,t).rehydrate()},e.prototype.clone=function(){var t=new e(this.target,this.forceServer);return this.clones.push(t),t.tags=this.tags.map(function(e){for(var n=e.getIds(),r=e.clone(),o=0;o<+~=|^:(),"'`-]+/g,dashesAtEnds=/(^-|-$)/g;function escape(e){return e.replace(escapeRegex,"-").replace(dashesAtEnds,"")}function getComponentName(e){return e.displayName||e.name||"Component"}function isTag(e){return"string"==typeof e}function generateDisplayName(e){return isTag(e)?"styled."+e:"Styled("+getComponentName(e)+")"}var ATTRIBUTE_REGEX=/^((?:s(?:uppressContentEditableWarn|croll|pac)|(?:shape|image|text)Render|(?:letter|word)Spac|vHang|hang)ing|(?:on(?:AnimationIteration|C(?:o(?:mposition(?:Update|Start|End)|ntextMenu|py)|anPlayThrough|anPlay|hange|lick|ut)|(?:Animation|Touch|Load|Drag)Start|(?:(?:Duration|Volume|Rate)Chang|(?:MouseLea|(?:Touch|Mouse)Mo|DragLea)v|Paus)e|Loaded(?:Metad|D)ata|(?:(?:T(?:ransition|ouch)|Animation)E|Suspe)nd|DoubleClick|(?:TouchCanc|Whe)el|Lo(?:stPointer|ad)|TimeUpdate|(?:Mouse(?:Ent|Ov)e|Drag(?:Ent|Ov)e|Erro)r|GotPointer|MouseDown|(?:E(?:n(?:crypt|d)|mpti)|S(?:tall|eek))ed|KeyPress|(?:MouseOu|DragExi|S(?:elec|ubmi)|Rese|Inpu)t|P(?:rogress|laying)|DragEnd|Key(?:Down|Up)|(?:MouseU|Dro)p|(?:Wait|Seek)ing|Scroll|Focus|Paste|Abort|Drag|Play|Blur)Captur|alignmentBaselin|(?:limitingConeAng|xlink(?:(?:Arcr|R)o|Tit)|s(?:urfaceSca|ty|ca)|unselectab|baseProfi|fontSty|(?:focus|dragg)ab|multip|profi|tit)l|d(?:ominantBaselin|efaultValu)|onPointerLeav|a(?:uto(?:Capitaliz|Revers|Sav)|dditiv)|(?:(?:formNoValid|xlinkActu|noValid|accumul|rot)a|autoComple|decelera)t|(?:(?:attribute|item)T|datat)yp|onPointerMov|(?:attribute|glyph)Nam|playsInlin|(?:writing|input|edge)Mod|(?:formE|e)ncTyp|(?:amplitu|mo)d|(?:xlinkTy|itemSco|keyTy|slo)p|(?:xmlSpa|non)c|fillRul|(?:dateTi|na)m|r(?:esourc|ol)|xmlBas|wmod)e|(?:glyphOrientationHorizont|loc)al|(?:externalResourcesRequir|select|revers|mut)ed|c(?:o(?:lorInterpolationFilter|ord)s|o(?:lor(?:Interpolation)?|nt(?:rols|ent))|(?:ontentS(?:cript|tyle)Typ|o(?:ntentEditab|lorProfi)l|l(?:assNam|ipRul)|a(?:lcMod|ptur)|it)e|olorRendering|l(?:ipPathUnits|assID)|(?:ontrolsLis|apHeigh)t|h(?:eckedLink|a(?:llenge|rSet)|ildren|ecked)|ell(?:Spac|Padd)ing|o(?:ntextMenu|ls)|(?:rossOrigi|olSpa)n|l(?:ip(?:Path)?|ass)|ursor|[xy])|glyphOrientationVertical|d(?:angerouslySetInnerHTML|efaultChecked|ownload|isabled|isplay|[xy])|(?:s(?:trikethroughThickn|eaml)es|(?:und|ov)erlineThicknes|r(?:equiredExtension|adiu)|(?:requiredFeatur|tableValu|stitchTil|numOctav|filterR)e|key(?:(?:Splin|Tim)e|Param)|auto[Ff]ocu|header|bia)s|(?:(?:st(?:rikethroughPosi|dDevia)|(?:und|ov)erlinePosi|(?:textDecor|elev)a|orienta)tio|(?:strokeLinejo|orig)i|on(?:PointerDow|FocusI)|formActio|zoomAndPa|directio|(?:vers|act)io|rowSpa|begi|ico)n|o(?:n(?:AnimationIteration|C(?:o(?:mposition(?:Update|Start|End)|ntextMenu|py)|anPlayThrough|anPlay|hange|lick|ut)|(?:(?:Duration|Volume|Rate)Chang|(?:MouseLea|(?:Touch|Mouse)Mo|DragLea)v|Paus)e|Loaded(?:Metad|D)ata|(?:Animation|Touch|Load|Drag)Start|(?:(?:T(?:ransition|ouch)|Animation)E|Suspe)nd|DoubleClick|(?:TouchCanc|Whe)el|(?:Mouse(?:Ent|Ov)e|Drag(?:Ent|Ov)e|Erro)r|TimeUpdate|(?:E(?:n(?:crypt|d)|mpti)|S(?:tall|eek))ed|MouseDown|P(?:rogress|laying)|(?:MouseOu|DragExi|S(?:elec|ubmi)|Rese|Inpu)t|KeyPress|DragEnd|Key(?:Down|Up)|(?:Wait|Seek)ing|(?:MouseU|Dro)p|Scroll|Paste|Focus|Abort|Drag|Play|Load|Blur)|rient)|p(?:reserveAspectRatio|ointsAt[X-Z]|anose1)|(?:(?:allowPaymentReque|(?:fontSize|length)Adju|manife)s|strokeMiterlimi|(?:(?:specularE|e)xpon|renderingInt|asc)en|(?:specularConsta|repeatCou|fontVaria)n|d(?:iffuseConsta|esce)n|baselineShif|vectorEffec|onPointerOu|(?:(?:mar(?:ker|gin)|x)H|accentH|fontW)eigh|markerStar|a(?:utoCorrec|bou)|onFocusOu|intercep|restar|forma|inlis|heigh|lis)t|(?:patternContent|ma(?:sk(?:Content)?|rker)|primitive|gradient|pattern|filter)Units|(?:(?:allowTranspar|baseFrequ)enc|re(?:ferrerPolic|adOnl)|(?:(?:st(?:roke|op)O|floodO|fillO|o)pac|integr|secur)it|visibilit|fontFamil|accessKe|propert|summar)y|(?:gradientT|patternT|t)ransform|(?:(?:st(?:rokeDasho|artO)|o)ffs|acceptChars|formTarg|viewTarg|srcS)et|(?:[xy]ChannelSelect|lightingCol|textAnch|floodCol|stopCol|operat|htmlF)or|(?:(?:enableBackgrou|markerE)n|s(?:p(?:readMetho|ee)|ee)|formMetho|(?:markerM|onInval)i|preloa|metho|kin)d|k(?:ernel(?:UnitLength|Matrix)|[1-4])|strokeDasharray|(?:onPointerCanc|lab)el|(?:allowFullScre|hidd)en|a(?:l(?:lowUserMedia|phabetic|t)|rabicForm|sync)|systemLanguage|(?:(?:o(?:nPointer(?:Ent|Ov)|rd)|allowReord|placehold|frameBord|paintOrd|post)e|repeatDu|d(?:efe|u))r|(?:pointerEve|keyPoi)nts|preserveAlpha|(?:strokeLineca|onPointerU|itemPro|useMa|wra|loo)p|v(?:Mathematical|ert(?:Origin[XY]|AdvY)|alues|ocab)|unicodeRange|h(?:oriz(?:Origin|Adv)X|ttpEquiv)|(?:vI|i)deographic|mathematical|u(?:nicodeBidi|[12])|(?:fontStretc|hig)h|vAlphabetic|(?:(?:mar(?:ker|gin)W|strokeW)id|azimu)th|(?:xmlnsXl|valueL)ink|mediaGroup|spellCheck|(?:text|m(?:in|ax))Length|(?:unitsPerE|optimu|fro)m|r(?:adioGroup|e(?:sults|f[XY]|l)|ows|[xy])|pathLength|(?:xlinkHr|glyphR)ef|innerHTML|xlinkShow|f(?:o(?:ntSize|rm?)|il(?:ter|l))|(?:tabInde|(?:sand|b)bo|viewBo)x|autoPlay|r(?:e(?:quired|sult|f))?|(?:(?:href|xml|src)La|kerni)ng|o(?:verflow|pen)|i(?:temRef|n2|s)|p(?:attern|oints)|unicode|d(?:efault|ata|ir)?|divisor|t(?:arget[XY]|o)|(?:stri|la)ng|(?:width|size)s|prefix|typeof|srcDoc|s(?:coped|te(?:m[hv]|p)|pan)|s(?:t(?:roke|art)|hape|cope|rc)|a(?:ccept|llow|s)|itemID|t(?:arget|ype)|m(?:edia|a(?:sk|x)|in)|value|width|x(?:mlns)?|size|href|k(?:ey)?|end|low|by|x[12]|y[12]|g[12]|i[dn]|f[xy]|[yz])$/,ATTRIBUTE_NAME_START_CHAR=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ATTRIBUTE_NAME_CHAR=ATTRIBUTE_NAME_START_CHAR+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",isCustomAttribute=RegExp.prototype.test.bind(new RegExp("^(x|data|aria)-["+ATTRIBUTE_NAME_CHAR+"]*$")),validAttr=function(e){return ATTRIBUTE_REGEX.test(e)||isCustomAttribute(e.toLowerCase())};function hasInInheritanceChain(e,t){for(var n=e;n;)if((n=Object.getPrototypeOf(n))&&n===t)return!0;return!1}var _contextShape,_ThemeProvider$contex,_babelHelpers$extends,createBroadcast=function(e){var t={},n=0,r=e;return{publish:function(e){for(var n in r=e,t){var o=t[n];void 0!==o&&o(r)}},subscribe:function(e){var o=n;return t[o]=e,n+=1,e(r),o},unsubscribe:function(e){t[e]=void 0}}},CHANNEL="__styled-components__",CHANNEL_NEXT=CHANNEL+"next__",CONTEXT_CHANNEL_SHAPE=PropTypes.shape({getTheme:PropTypes.func,subscribe:PropTypes.func,unsubscribe:PropTypes.func}),contextShape=((_contextShape={})[CHANNEL]=PropTypes.func,_contextShape[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,_contextShape),isFunction=function(e){return"function"==typeof e},ThemeProvider=function(e){function t(){classCallCheck(this,t);var n=possibleConstructorReturn(this,e.call(this));return n.unsubscribeToOuterId=-1,n.getTheme=n.getTheme.bind(n),n}return inherits(t,e),t.prototype.componentWillMount=function(){var e=this,t=this.context[CHANNEL_NEXT];void 0!==t&&(this.unsubscribeToOuterId=t.subscribe(function(t){e.outerTheme=t,void 0!==e.broadcast&&e.publish(e.props.theme)})),this.broadcast=createBroadcast(this.getTheme())},t.prototype.getChildContext=function(){var e,t=this;return _extends({},this.context,((e={})[CHANNEL_NEXT]={getTheme:this.getTheme,subscribe:this.broadcast.subscribe,unsubscribe:this.broadcast.unsubscribe},e[CHANNEL]=function(e){var n=t.broadcast.subscribe(e);return function(){return t.broadcast.unsubscribe(n)}},e))},t.prototype.componentWillReceiveProps=function(e){this.props.theme!==e.theme&&this.publish(e.theme)},t.prototype.componentWillUnmount=function(){-1!==this.unsubscribeToOuterId&&this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeToOuterId)},t.prototype.getTheme=function(e){var t=e||this.props.theme;if(isFunction(t))return t(this.outerTheme);if(null===t||Array.isArray(t)||"object"!==(void 0===t?"undefined":_typeof(t)))throw new StyledComponentsError(8);return _extends({},this.outerTheme,t)},t.prototype.publish=function(e){this.broadcast.publish(this.getTheme(e))},t.prototype.render=function(){return this.props.children?React.Children.only(this.props.children):null},t}(Component);ThemeProvider.childContextTypes=contextShape,ThemeProvider.contextTypes=((_ThemeProvider$contex={})[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,_ThemeProvider$contex);var STATIC_EXECUTION_CONTEXT={},modifiedContextShape=_extends({},contextShape,((_babelHelpers$extends={})[CONTEXT_KEY]=PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet),PropTypes.instanceOf(ServerStyleSheet)]),_babelHelpers$extends)),identifiers={},generateId=function(e,t,n){var r="string"!=typeof t?"sc":escape(t),o=(identifiers[r]||0)+1;identifiers[r]=o;var i=r+"-"+e.generateName(r+o);return void 0!==n?n+"-"+i:i},warnExtendDeprecated=function(){},BaseStyledComponent=function(e){function t(){var n,r;classCallCheck(this,t);for(var o=arguments.length,i=Array(o),s=0;s=4;)t=1540483477*(65535&(t=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(t>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(t=1540483477*(65535&(t^=t>>>24))+((1540483477*(t>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}var areStylesCacheable=IS_BROWSER,isStaticRules=function e(t,n){for(var r=0,o=t.length;r2&&void 0!==arguments[2]?arguments[2]:EMPTY_OBJECT;if(!isValidElementType(r))throw new StyledComponentsError(1,String(r));var i=function(){return n(r,o,e.apply(void 0,arguments))};return i.withConfig=function(e){return t(n,r,_extends({},o,e))},i.attrs=function(e){return t(n,r,_extends({},o,{attrs:_extends({},o.attrs||EMPTY_OBJECT,e)}))},i}},withTheme=function(e){var t="function"==typeof e&&!(e.prototype&&"isReactComponent"in e.prototype),n=isStyledComponent(e)||t,r=function(t){function r(){var e,n;classCallCheck(this,r);for(var o=arguments.length,i=Array(o),s=0;s