styled-components 3.3.2 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/styled-components-no-parser.browser.cjs.js +24 -21
  3. package/dist/styled-components-no-parser.browser.cjs.js.map +1 -1
  4. package/dist/styled-components-no-parser.browser.es.js +24 -21
  5. package/dist/styled-components-no-parser.browser.es.js.map +1 -1
  6. package/dist/styled-components-no-parser.cjs.js +24 -21
  7. package/dist/styled-components-no-parser.cjs.js.map +1 -1
  8. package/dist/styled-components-no-parser.es.js +24 -21
  9. package/dist/styled-components-no-parser.es.js.map +1 -1
  10. package/dist/styled-components-primitives.cjs.js +17 -7
  11. package/dist/styled-components-primitives.cjs.js.map +1 -1
  12. package/dist/styled-components-primitives.es.js +17 -7
  13. package/dist/styled-components-primitives.es.js.map +1 -1
  14. package/dist/styled-components.browser.cjs.js +24 -21
  15. package/dist/styled-components.browser.cjs.js.map +1 -1
  16. package/dist/styled-components.browser.cjs.min.js +1 -1
  17. package/dist/styled-components.browser.cjs.min.js.map +1 -1
  18. package/dist/styled-components.browser.es.js +24 -21
  19. package/dist/styled-components.browser.es.js.map +1 -1
  20. package/dist/styled-components.browser.es.min.js +1 -1
  21. package/dist/styled-components.browser.es.min.js.map +1 -1
  22. package/dist/styled-components.cjs.js +24 -21
  23. package/dist/styled-components.cjs.js.map +1 -1
  24. package/dist/styled-components.cjs.min.js +1 -1
  25. package/dist/styled-components.cjs.min.js.map +1 -1
  26. package/dist/styled-components.es.js +24 -21
  27. package/dist/styled-components.es.js.map +1 -1
  28. package/dist/styled-components.es.min.js +1 -1
  29. package/dist/styled-components.es.min.js.map +1 -1
  30. package/dist/styled-components.js +24 -21
  31. package/dist/styled-components.js.map +1 -1
  32. package/dist/styled-components.min.js +1 -1
  33. package/dist/styled-components.min.js.map +1 -1
  34. package/dist/styled-components.native.cjs.js +17 -7
  35. package/dist/styled-components.native.cjs.js.map +1 -1
  36. package/docs/tips-and-tricks.md +33 -2
  37. package/package.json +1 -1
  38. package/src/models/StyledComponent.js +28 -24
  39. package/src/models/StyledNativeComponent.js +18 -7
  40. package/src/test/__snapshots__/extending.test.js.snap +3 -0
  41. package/src/test/basic.test.js +32 -1
  42. package/src/test/extending.test.js +79 -23
  43. package/typings/styled-components.d.ts +2 -3
  44. package/typings/tests/issue1068.tsx +265 -0
  45. package/typings/tests/themed-tests/issue1068.tsx +265 -0
@@ -1,2 +1,2 @@
1
- "use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var isPlainObject=_interopDefault(require("is-plain-object")),Stylis=_interopDefault(require("stylis")),_insertRulePlugin=_interopDefault(require("stylis-rule-sheet")),React=require("react"),React__default=_interopDefault(React),PropTypes=_interopDefault(require("prop-types")),hoist=_interopDefault(require("hoist-non-react-statics")),reactIs=require("react-is"),_uppercasePattern=/([A-Z])/g;function hyphenate$2(e){return e.replace(_uppercasePattern,"-$1").toLowerCase()}var hyphenate_1=hyphenate$2,hyphenate=hyphenate_1,msPattern=/^ms-/;function hyphenateStyleName(e){return hyphenate(e).replace(msPattern,"-ms-")}var hyphenateStyleName_1=hyphenateStyleName,objToCss=function e(t,r){var n=Object.keys(t).filter(function(e){var r=t[e];return void 0!==r&&null!==r&&!1!==r&&""!==r}).map(function(r){return isPlainObject(t[r])?e(t[r],r):hyphenateStyleName_1(r)+": "+t[r]+";"}).join(" ");return r?r+" {\n "+n+"\n}":n},flatten=function e(t,r){return t.reduce(function(t,n){return void 0===n||null===n||!1===n||""===n?t:Array.isArray(n)?[].concat(t,e(n,r)):n.hasOwnProperty("styledComponentId")?[].concat(t,["."+n.styledComponentId]):"function"==typeof n?r?t.concat.apply(t,e([n(r)],r)):t.concat(n):t.concat(isPlainObject(n)?objToCss(n):n.toString())},[])},stylisSplitter=new Stylis({global:!1,cascade:!0,keyframe:!1,prefix:!1,compress:!1,semicolon:!0}),stylis=new Stylis({global:!1,cascade:!0,keyframe:!1,prefix:!0,compress:!1,semicolon:!1}),parsingRules=[],returnRulesPlugin=function(e){if(-2===e){var t=parsingRules;return parsingRules=[],t}},parseRulesPlugin=_insertRulePlugin(function(e){parsingRules.push(e)});stylis.use([parseRulesPlugin,returnRulesPlugin]),stylisSplitter.use([parseRulesPlugin,returnRulesPlugin]);var stringifyRules=function(e,t,r){var n=e.join("").replace(/^\s*\/\/.*$/gm,"");return stylis(r||!t?"":t,t&&r?r+" "+t+" { "+n+" }":n)},splitByRules=function(e){return stylisSplitter("",e)};function isStyledComponent(e){return"function"==typeof e&&"string"==typeof e.styledComponentId}function consolidateStreamedStyles(){}var charsLength=52,getAlphabeticChar=function(e){return String.fromCharCode(e+(e>25?39:97))},generateAlphabeticName=function(e){var t="",r=void 0;for(r=e;r>charsLength;r=Math.floor(r/charsLength))t=getAlphabeticChar(r%charsLength)+t;return getAlphabeticChar(r%charsLength)+t},interleave=function(e,t){return t.reduce(function(t,r,n){return t.concat(r,e[n+1])},[e[0]])},_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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_extends=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},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},objectWithoutProperties=function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r},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},css=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Array.isArray(e)||"object"!==(void 0===e?"undefined":_typeof(e))?flatten(interleave(e,r)):flatten(interleave([],[e].concat(r)))},stream={},SC_ATTR="undefined"!=typeof process&&process.env.SC_ATTR||"data-styled-components",SC_STREAM_ATTR="data-styled-streamed",CONTEXT_KEY="__styled-components-stylesheet__",IS_BROWSER="undefined"!=typeof window&&"HTMLElement"in window,DISABLE_SPEEDY=!1,SC_COMPONENT_ID=/^[^\S\n]*?\/\* sc-component-id:\s*(\S+)\s+\*\//gm,extractComps=function(e){var t=""+(e||""),r=[];return t.replace(SC_COMPONENT_ID,function(e,t,n){return r.push({componentId:t,matchIndex:n}),e}),r.map(function(e,n){var o=e.componentId,a=e.matchIndex,i=r[n+1];return{componentId:o,cssFromDOM:i?t.slice(a,i.matchIndex):t.slice(a)}})},getNonce=function(){return"undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null},once=function(e){var t=!1;return function(){t||(t=!0,e())}},addNameForId=function(e,t,r){r&&((e[t]||(e[t]=Object.create(null)))[r]=!0)},resetIdNames=function(e,t){e[t]=Object.create(null)},hasNameForId=function(e){return function(t,r){return void 0!==e[t]&&e[t][r]}},stringifyNames=function(e){var t="";for(var r in e)t+=Object.keys(e[r]).join(" ")+" ";return t.trim()},cloneNames=function(e){var t=Object.create(null);for(var r in e)t[r]=_extends({},e[r]);return t},sheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets.length,r=0;r<t;r+=1){var n=document.styleSheets[r];if(n.ownerNode===e)return n}throw new Error},safeInsertRule=function(e,t,r){if(!t)return!1;var n=e.cssRules.length;try{e.insertRule(t,r<=n?r:n)}catch(e){return!1}return!0},deleteRules=function(e,t,r){for(var n=t-r,o=t;o>n;o-=1)e.deleteRule(o)},parentNodeUnmountedErr="",throwCloneTagErr=function(){throw new Error("")},makeTextMarker=function(e){return"\n/* sc-component-id: "+e+" */\n"},addUpUntilIndex=function(e,t){for(var r=0,n=0;n<=t;n+=1)r+=e[n];return r},makeStyleTag=function(e,t,r){var n=document.createElement("style");n.setAttribute(SC_ATTR,"");var o=getNonce();if(o&&n.setAttribute("nonce",o),n.appendChild(document.createTextNode("")),e&&!t)e.appendChild(n);else{if(!t||!e||!t.parentNode)throw new Error(parentNodeUnmountedErr);t.parentNode.insertBefore(n,r?t:t.nextSibling)}return n},wrapAsHtmlTag=function(e,t){return function(r){var n=getNonce();return"<style "+[n&&'nonce="'+n+'"',SC_ATTR+'="'+stringifyNames(t)+'"',r].filter(Boolean).join(" ")+">"+e()+"</style>"}},wrapAsElement=function(e,t){return function(){var r,n=((r={})[SC_ATTR]=stringifyNames(t),r),o=getNonce();return o&&(n.nonce=o),React__default.createElement("style",_extends({},n,{dangerouslySetInnerHTML:{__html:e()}}))}},getIdsFromMarkersFactory=function(e){return function(){return Object.keys(e)}},makeSpeedyTag=function(e,t){var r=Object.create(null),n=Object.create(null),o=[],a=void 0!==t,i=!1,s=function(e){var t=n[e];return void 0!==t?t:(n[e]=o.length,o.push(0),resetIdNames(r,e),n[e])},u=function(){var t=sheetForTag(e).cssRules,r="";for(var a in n){r+=makeTextMarker(a);for(var i=n[a],s=addUpUntilIndex(o,i),u=s-o[i];u<s;u+=1){var c=t[u];void 0!==c&&(r+=c.cssText)}}return r};return{styleTag:e,getIds:getIdsFromMarkersFactory(n),hasNameForId:hasNameForId(r),insertMarker:s,insertRules:function(n,u,c){for(var l=s(n),p=sheetForTag(e),h=addUpUntilIndex(o,l),d=0,m=[],f=u.length,y=0;y<f;y+=1){var g=u[y],v=a;v&&-1!==g.indexOf("@import")?m.push(g):safeInsertRule(p,g,h+d)&&(v=!1,d+=1)}a&&m.length>0&&(i=!0,t().insertRules(n+"-import",m)),o[l]+=d,addNameForId(r,n,c)},removeRules:function(s){var u=n[s];if(void 0!==u){var c=o[u],l=sheetForTag(e),p=addUpUntilIndex(o,u);deleteRules(l,p,c),o[u]=0,resetIdNames(r,s),a&&i&&t().removeRules(s+"-import")}},css:u,toHTML:wrapAsHtmlTag(u,r),toElement:wrapAsElement(u,r),clone:throwCloneTagErr}},makeBrowserTag=function(e,t){var r=Object.create(null),n=Object.create(null),o=void 0!==t,a=function(e){return document.createTextNode(makeTextMarker(e))},i=!1,s=function(t){var o=n[t];return void 0!==o?o:(n[t]=a(t),e.appendChild(n[t]),r[t]=Object.create(null),n[t])},u=function(){var e="";for(var t in n)e+=n[t].data;return e};return{styleTag:e,getIds:getIdsFromMarkersFactory(n),hasNameForId:hasNameForId(r),insertMarker:s,insertRules:function(e,n,a){for(var u=s(e),c=[],l=n.length,p=0;p<l;p+=1){var h=n[p],d=o;if(d&&-1!==h.indexOf("@import"))c.push(h);else{d=!1;var m=p===l-1?"":" ";u.appendData(""+h+m)}}addNameForId(r,e,a),o&&c.length>0&&(i=!0,t().insertRules(e+"-import",c))},removeRules:function(s){var u=n[s];if(void 0!==u){var c=a(s);e.replaceChild(c,u),n[s]=c,resetIdNames(r,s),o&&i&&t().removeRules(s+"-import")}},css:u,toHTML:wrapAsHtmlTag(u,r),toElement:wrapAsElement(u,r),clone:throwCloneTagErr}},makeServerTagInternal=function e(t,r){var n=void 0===t?Object.create(null):t,o=void 0===r?Object.create(null):r,a=function(e){var t=o[e];return void 0!==t?t:o[e]=[""]},i=function(){var e="";for(var t in o){var r=o[t][0];r&&(e+=makeTextMarker(t)+r)}return e};return{styleTag:null,getIds:getIdsFromMarkersFactory(o),hasNameForId:hasNameForId(n),insertMarker:a,insertRules:function(e,t,r){a(e)[0]+=t.join(" "),addNameForId(n,e,r)},removeRules:function(e){var t=o[e];void 0!==t&&(t[0]="",resetIdNames(n,e))},css:i,toHTML:wrapAsHtmlTag(i,n),toElement:wrapAsElement(i,n),clone:function(){var t=cloneNames(n),r=Object.create(null);for(var a in o)r[a]=[o[a][0]];return e(t,r)}}},makeServerTag=function(){return makeServerTagInternal()},makeTag=function(e,t,r,n,o){if(IS_BROWSER&&!r){var a=makeStyleTag(e,t,n);return DISABLE_SPEEDY?makeBrowserTag(a,o):makeSpeedyTag(a,o)}return makeServerTag()},makeRehydrationTag=function(e,t,r,n,o){var a=once(function(){for(var n=0;n<r.length;n+=1){var o=r[n],a=o.componentId,i=o.cssFromDOM,s=splitByRules(i);e.insertRules(a,s)}for(var u=0;u<t.length;u+=1){var c=t[u];c.parentNode&&c.parentNode.removeChild(c)}});return o&&a(),_extends({},e,{insertMarker:function(t){return a(),e.insertMarker(t)},insertRules:function(t,r,n){return a(),e.insertRules(t,r,n)}})},MAX_SIZE=void 0;MAX_SIZE=IS_BROWSER?DISABLE_SPEEDY?40:1e3:-1;var _StyleSheetManager$ch,sheetRunningId=0,master=void 0,StyleSheet=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:IS_BROWSER?document.head:null,n=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 r=t.tags[0];return t.importRuleTag=makeTag(t.target,r?r.styleTag:null,t.forceServer,!0)},sheetRunningId+=1,this.id=sheetRunningId,this.sealed=!1,this.forceServer=n,this.target=n?null:r,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=[],r=[],n=!1,o=document.querySelectorAll("style["+SC_ATTR+"]"),a=o.length;if(0===a)return this;for(var i=0;i<a;i+=1){var s=o[i];n=!!s.getAttribute(SC_STREAM_ATTR)||n;for(var u=(s.getAttribute(SC_ATTR)||"").trim().split(/\s+/),c=u.length,l=0;l<c;l+=1){var p=u[l];this.rehydratedNames[p]=!0,t.push(p)}r=r.concat(extractComps(s.textContent)),e.push(s)}var h=r.length;if(0===h)return this;var d=this.makeTag(null),m=makeRehydrationTag(d,e,r,t,n);this.capacity=Math.max(1,MAX_SIZE-h),this.tags.push(m);for(var f=0;f<h;f+=1)this.tagMap[r[f].componentId]=m;return this},e.reset=function(){var t=arguments.length>0&&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 r=e.getIds(),n=e.clone(),o=0;o<r.length;o+=1)t.tagMap[r[o]]=n;return n}),t.rehydratedNames=_extends({},this.rehydratedNames),t.deferred=_extends({},this.deferred),t},e.prototype.sealAllTags=function(){this.capacity=1,this.sealed=!0},e.prototype.makeTag=function(e){var t=e?e.styleTag:null;return makeTag(this.target,t,this.forceServer,!1,this.getImportRuleTag)},e.prototype.getTagForId=function(e){var t=this.tagMap[e];if(void 0!==t&&!this.sealed)return t;var r=this.tags[this.tags.length-1];return this.capacity-=1,0===this.capacity&&(this.capacity=MAX_SIZE,this.sealed=!1,r=this.makeTag(r),this.tags.push(r)),this.tagMap[e]=r},e.prototype.hasId=function(e){return void 0!==this.tagMap[e]},e.prototype.hasNameForId=function(e,t){if(void 0===this.ignoreRehydratedNames[e]&&this.rehydratedNames[t])return!0;var r=this.tagMap[e];return void 0!==r&&r.hasNameForId(e,t)},e.prototype.deferredInject=function(e,t){if(void 0===this.tagMap[e]){for(var r=this.clones,n=0;n<r.length;n+=1)r[n].deferredInject(e,t);this.getTagForId(e).insertMarker(e),this.deferred[e]=t}},e.prototype.inject=function(e,t,r){for(var n=this.clones,o=0;o<n.length;o+=1)n[o].inject(e,t,r);var a=t,i=this.deferred[e];void 0!==i&&(a=i.concat(a),delete this.deferred[e]),this.getTagForId(e).insertRules(e,a,r)},e.prototype.remove=function(e){var t=this.tagMap[e];if(void 0!==t){for(var r=this.clones,n=0;n<r.length;n+=1)r[n].remove(e);t.removeRules(e),this.ignoreRehydratedNames[e]=!0,delete this.deferred[e]}},e.prototype.toHTML=function(){return this.tags.map(function(e){return e.toHTML()}).join("")},e.prototype.toReactElements=function(){var e=this.id;return this.tags.map(function(t,r){var n="sc-"+e+"-"+r;return React.cloneElement(t.toElement(),{key:n})})},createClass(e,null,[{key:"master",get:function(){return master||(master=(new e).rehydrate())}},{key:"instance",get:function(){return e.master}}]),e}(),targetPropErr="",StyleSheetManager=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,e.apply(this,arguments))}return inherits(t,e),t.prototype.getChildContext=function(){var e;return(e={})[CONTEXT_KEY]=this.sheetInstance,e},t.prototype.componentWillMount=function(){if(this.props.sheet)this.sheetInstance=this.props.sheet;else{if(!this.props.target)throw new Error(targetPropErr);this.sheetInstance=new StyleSheet(this.props.target)}},t.prototype.render=function(){return React__default.Children.only(this.props.children)},t}(React.Component);StyleSheetManager.childContextTypes=((_StyleSheetManager$ch={})[CONTEXT_KEY]=PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet),PropTypes.instanceOf(ServerStyleSheet)]).isRequired,_StyleSheetManager$ch);var sheetClosedErr="",streamBrowserErr="",ServerStyleSheet=function(){function e(){classCallCheck(this,e),this.masterSheet=StyleSheet.master,this.instance=this.masterSheet.clone(),this.closed=!1}return e.prototype.complete=function(){if(!this.closed){var e=this.masterSheet.clones.indexOf(this.instance);this.masterSheet.clones.splice(e,1),this.closed=!0}},e.prototype.collectStyles=function(e){if(this.closed)throw new Error(sheetClosedErr);return React__default.createElement(StyleSheetManager,{sheet:this.instance},e)},e.prototype.getStyleTags=function(){return this.complete(),this.instance.toHTML()},e.prototype.getStyleElement=function(){return this.complete(),this.instance.toReactElements()},e.prototype.interleaveWithNodeStream=function(e){throw new Error(streamBrowserErr)},e}(),determineTheme=function(e,t,r){var n=r&&e.theme===r.theme;return e.theme&&!n?e.theme:t},escapeRegex=/[[\].#*$><+~=|^:(),"'`-]+/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|lip(?:Path)?|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)|autoFocu|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(?:reserveA(?:spectRatio|lpha)|ointsAt[X-Z]|anose1)|(?: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|(?:[xy]ChannelSelect|lightingCol|textAnch|floodCol|stopCol|operat|htmlF)or|(?:strokeMiterlimi|(?:specularConsta|repeatCou|fontVaria)n|(?:(?:specularE|e)xpon|renderingInt|asc)en|d(?:iffuseConsta|esce)n|(?:fontSizeAdju|lengthAdju|manife)s|baselineShif|onPointerOu|vectorEffec|(?:(?:mar(?:ker|gin)|x)H|accentH|fontW)eigh|markerStar|a(?:utoCorrec|bou)|onFocusOu|intercep|restar|forma|inlis|heigh|lis)t|(?:(?:st(?:rokeDasho|artO)|o)ffs|acceptChars|formTarg|viewTarg|srcS)et|k(?:ernel(?:UnitLength|Matrix)|[1-4])|(?:(?:enableBackgrou|markerE)n|s(?:p(?:readMetho|ee)|ee)|formMetho|(?:markerM|onInval)i|preloa|metho|kin)d|strokeDasharray|(?:onPointerCanc|lab)el|(?:allowFullScre|hidd)en|systemLanguage|(?:(?:o(?:nPointer(?:Ent|Ov)|rd)|allowReord|placehold|frameBord|paintOrd|post)e|repeatDu|d(?:efe|u))r|v(?:Mathematical|ert(?:Origin[XY]|AdvY)|alues|ocab)|(?:pointerEve|keyPoi)nts|(?:strokeLineca|onPointerU|itemPro|useMa|wra|loo)p|h(?:oriz(?:Origin|Adv)X|ttpEquiv)|(?:vI|i)deographic|unicodeRange|mathematical|vAlphabetic|u(?:nicodeBidi|[12])|(?:fontStretc|hig)h|(?:(?: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])|a(?:rabicForm|l(?:phabetic|t)|sync)|pathLength|innerHTML|xlinkShow|(?:xlinkHr|glyphR)ef|(?:tabInde|(?:sand|b)bo|viewBo)x|(?:(?:href|xml|src)La|kerni)ng|autoPlay|o(?:verflow|pen)|f(?:o(?:ntSize|rm)|il(?:ter|l))|r(?:e(?:quired|sult|f))?|divisor|p(?:attern|oints)|unicode|d(?:efault|ata|ir)?|i(?:temRef|n2|s)|t(?:arget[XY]|o)|srcDoc|s(?:coped|te(?:m[hv]|p)|pan)|(?:width|size)s|prefix|typeof|itemID|s(?:t(?:roke|art)|hape|cope|rc)|t(?:arget|ype)|(?:stri|la)ng|a(?:ccept|s)|m(?:edia|a(?:sk|x)|in)|x(?:mlns)?|width|value|size|href|k(?:ey)?|end|low|by|i[dn]|y[12]|g[12]|x[12]|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 r=e;r;)if((r=Object.getPrototypeOf(r))&&r===t)return!0;return!1}var _ThemeProvider$childC,_ThemeProvider$contex,createBroadcast=function(e){var t={},r=0,n=e;return{publish:function(e){for(var r in n=e,t){var o=t[r];void 0!==o&&o(n)}},subscribe:function(e){var o=r;return t[o]=e,r+=1,e(n),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}),isFunction=function(e){return"function"==typeof e},ThemeProvider=function(e){function t(){classCallCheck(this,t);var r=possibleConstructorReturn(this,e.call(this));return r.unsubscribeToOuterId=-1,r.getTheme=r.getTheme.bind(r),r}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 r=t.broadcast.subscribe(e);return function(){return t.broadcast.unsubscribe(r)}},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 Error("");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__default.Children.only(this.props.children):null},t}(React.Component);ThemeProvider.childContextTypes=((_ThemeProvider$childC={})[CHANNEL]=PropTypes.func,_ThemeProvider$childC[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,_ThemeProvider$childC),ThemeProvider.contextTypes=((_ThemeProvider$contex={})[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,_ThemeProvider$contex);var STATIC_EXECUTION_CONTEXT={},_StyledComponent=function(e,t){var r={},n=function(e){function t(){var r,n;classCallCheck(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return r=n=possibleConstructorReturn(this,e.call.apply(e,[this].concat(a))),n.attrs={},n.state={theme:null,generatedClassName:""},n.unsubscribeId=-1,possibleConstructorReturn(n,r)}return inherits(t,e),t.prototype.unsubscribeFromContext=function(){-1!==this.unsubscribeId&&this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId)},t.prototype.buildExecutionContext=function(e,t){var r=this.constructor.attrs,n=_extends({},t,{theme:e});return void 0===r?n:(this.attrs=Object.keys(r).reduce(function(e,t){var o=r[t];return e[t]="function"!=typeof o||hasInInheritanceChain(o,React.Component)?o:o(n),e},{}),_extends({},n,this.attrs))},t.prototype.generateAndInjectStyles=function(e,t){var r=this.constructor,n=r.attrs,o=r.componentStyle,a=(r.warnTooManyClasses,this.context[CONTEXT_KEY]||StyleSheet.master);if(o.isStatic&&void 0===n)return o.generateAndInjectStyles(STATIC_EXECUTION_CONTEXT,a);var i=this.buildExecutionContext(e,t);return o.generateAndInjectStyles(i,a)},t.prototype.componentWillMount=function(){var e=this,t=this.constructor.componentStyle,r=this.context[CHANNEL_NEXT];if(t.isStatic){var n=this.generateAndInjectStyles(STATIC_EXECUTION_CONTEXT,this.props);this.setState({generatedClassName:n})}else if(void 0!==r){var o=r.subscribe;this.unsubscribeId=o(function(t){var r=determineTheme(e.props,t,e.constructor.defaultProps),n=e.generateAndInjectStyles(r,e.props);e.setState({theme:r,generatedClassName:n})})}else{var a=this.props.theme||{},i=this.generateAndInjectStyles(a,this.props);this.setState({theme:a,generatedClassName:i})}},t.prototype.componentWillReceiveProps=function(e){var t=this;this.constructor.componentStyle.isStatic||this.setState(function(r){var n=determineTheme(e,r.theme,t.constructor.defaultProps);return{theme:n,generatedClassName:t.generateAndInjectStyles(n,e)}})},t.prototype.componentWillUnmount=function(){this.unsubscribeFromContext()},t.prototype.render=function(){var e=this,t=this.props.innerRef,r=this.state.generatedClassName,n=this.constructor,o=n.styledComponentId,a=n.target,i=isTag(a),s=[this.props.className,o,this.attrs.className,r].filter(Boolean).join(" "),u=_extends({},this.attrs,{className:s});isStyledComponent(a)?u.innerRef=t:u.ref=t;var c=Object.keys(this.props).reduce(function(t,r){return"innerRef"===r||"className"===r||i&&!validAttr(r)||(t[r]=e.props[r]),t},u);return React.createElement(a,c)},t}(React.Component);return function o(a,i,s){var u,c=i.isClass,l=void 0===c?!isTag(a):c,p=i.displayName,h=void 0===p?generateDisplayName(a):p,d=i.componentId,m=void 0===d?function(t,n){var o="string"!=typeof t?"sc":escape(t),a=void 0;if(t)a=o+"-"+e.generateName(o);else{var i=(r[o]||0)+1;r[o]=i,a=o+"-"+e.generateName(o+i)}return void 0!==n?n+"-"+a:a}(i.displayName,i.parentComponentId):d,f=i.ParentComponent,y=void 0===f?n:f,g=i.rules,v=i.attrs,T=i.displayName&&i.componentId?escape(i.displayName)+"-"+i.componentId:m,S=new e(void 0===g?s:g.concat(s),v,T),C=function(e){function r(){return classCallCheck(this,r),possibleConstructorReturn(this,e.apply(this,arguments))}return inherits(r,e),r.withComponent=function(e){var t=i.componentId,n=objectWithoutProperties(i,["componentId"]),a=t&&t+"-"+(isTag(e)?e:escape(getComponentName(e))),u=_extends({},n,{componentId:a,ParentComponent:r});return o(e,u,s)},createClass(r,null,[{key:"extend",get:function(){var e=i.rules,n=i.componentId,u=objectWithoutProperties(i,["rules","componentId"]),c=void 0===e?s:e.concat(s),l=_extends({},u,{rules:c,parentComponentId:n,ParentComponent:r});return t(o,a,l)}}]),r}(y);return C.contextTypes=((u={})[CHANNEL]=PropTypes.func,u[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,u[CONTEXT_KEY]=PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet),PropTypes.instanceOf(ServerStyleSheet)]),u),l&&hoist(C,a),C.displayName=h,C.styledComponentId=T,C.attrs=v,C.componentStyle=S,C.target=a,C}};function murmurhash(e){for(var t,r=0|e.length,n=0|r,o=0;r>=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),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(t=1540483477*(65535&(t^=t>>>24))+((1540483477*(t>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}var areStylesCacheable=IS_BROWSER,isStaticRules=function e(t,r){for(var n=0;n<t.length;n+=1){var o=t[n];if(Array.isArray(o)&&!e(o))return!1;if("function"==typeof o&&!isStyledComponent(o))return!1}if(void 0!==r)for(var a in r){if("function"==typeof r[a])return!1}return!0},isHMREnabled="undefined"!=typeof module&&module.hot&&!1,_ComponentStyle=function(e,t,r){var n=function(t){return e(murmurhash(t))};return function(){function e(t,r,n){if(classCallCheck(this,e),this.rules=t,this.isStatic=!isHMREnabled&&isStaticRules(t,r),this.componentId=n,!StyleSheet.master.hasId(n)){StyleSheet.master.deferredInject(n,[])}}return e.prototype.generateAndInjectStyles=function(e,o){var a=this.isStatic,i=this.componentId,s=this.lastClassName;if(areStylesCacheable&&a&&void 0!==s&&o.hasNameForId(i,s))return s;var u=t(this.rules,e),c=n(this.componentId+u.join(""));if(!o.hasNameForId(i,c)){var l=r(u,"."+c);o.inject(this.componentId,l,c)}return this.lastClassName=c,c},e.generateName=function(e){return n(e)},e}()},domElements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],_styled=function(e,t){var r=function(r){return t(e,r)};return domElements.forEach(function(e){r[e]=r(e)}),r},replaceWhitespace=function(e){return e.replace(/\s|\\n/g,"")},_keyframes=function(e,t,r){return function(){var n=StyleSheet.master,o=r.apply(void 0,arguments),a=e(murmurhash(replaceWhitespace(JSON.stringify(o)))),i="sc-keyframes-"+a;return n.hasNameForId(i,a)||n.inject(i,t(o,a,"@keyframes"),a),a}},_injectGlobal=function(e,t){return function(){var r=StyleSheet.master,n=t.apply(void 0,arguments),o="sc-global-"+murmurhash(JSON.stringify(n));r.hasId(o)||r.inject(o,e(n))}},_constructWithOptions=function(e){return function t(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!reactIs.isValidElementType(n))throw new Error("");var a=function(){return r(n,o,e.apply(void 0,arguments))};return a.withConfig=function(e){return t(r,n,_extends({},o,e))},a.attrs=function(e){return t(r,n,_extends({},o,{attrs:_extends({},o.attrs||{},e)}))},a}},wrapWithTheme=function(e){var t,r=e.displayName||e.name||"Component",n="function"==typeof e&&!(e.prototype&&"isReactComponent"in e.prototype),o=isStyledComponent(e)||n,a=function(t){function r(){var e,n;classCallCheck(this,r);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return e=n=possibleConstructorReturn(this,t.call.apply(t,[this].concat(a))),n.state={},n.unsubscribeId=-1,possibleConstructorReturn(n,e)}return inherits(r,t),r.prototype.componentWillMount=function(){var e=this,t=this.constructor.defaultProps,r=this.context[CHANNEL_NEXT],n=determineTheme(this.props,void 0,t);if(void 0===r&&void 0!==n)this.setState({theme:n});else{var o=r.subscribe;this.unsubscribeId=o(function(r){var n=determineTheme(e.props,r,t);e.setState({theme:n})})}},r.prototype.componentWillReceiveProps=function(e){var t=this.constructor.defaultProps;this.setState(function(r){return{theme:determineTheme(e,r.theme,t)}})},r.prototype.componentWillUnmount=function(){-1!==this.unsubscribeId&&this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId)},r.prototype.render=function(){var t=_extends({theme:this.state.theme},this.props);return o||(t.ref=t.innerRef,delete t.innerRef),React__default.createElement(e,t)},r}(React__default.Component);return a.displayName="WithTheme("+r+")",a.styledComponentId="withTheme",a.contextTypes=((t={})[CHANNEL]=PropTypes.func,t[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,t),hoist(a,e)},__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS={StyleSheet:StyleSheet},ComponentStyle=_ComponentStyle(generateAlphabeticName,flatten,stringifyRules),constructWithOptions=_constructWithOptions(css),StyledComponent=_StyledComponent(ComponentStyle,constructWithOptions),keyframes=_keyframes(generateAlphabeticName,stringifyRules,css),injectGlobal=_injectGlobal(stringifyRules,css),styled=_styled(StyledComponent,constructWithOptions);exports.default=styled,exports.css=css,exports.keyframes=keyframes,exports.injectGlobal=injectGlobal,exports.isStyledComponent=isStyledComponent,exports.consolidateStreamedStyles=consolidateStreamedStyles,exports.ThemeProvider=ThemeProvider,exports.withTheme=wrapWithTheme,exports.ServerStyleSheet=ServerStyleSheet,exports.StyleSheetManager=StyleSheetManager,exports.__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS=__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS;
1
+ "use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var isPlainObject=_interopDefault(require("is-plain-object")),Stylis=_interopDefault(require("stylis")),_insertRulePlugin=_interopDefault(require("stylis-rule-sheet")),React=require("react"),React__default=_interopDefault(React),PropTypes=_interopDefault(require("prop-types")),hoist=_interopDefault(require("hoist-non-react-statics")),reactIs=require("react-is"),_uppercasePattern=/([A-Z])/g;function hyphenate$2(e){return e.replace(_uppercasePattern,"-$1").toLowerCase()}var hyphenate_1=hyphenate$2,hyphenate=hyphenate_1,msPattern=/^ms-/;function hyphenateStyleName(e){return hyphenate(e).replace(msPattern,"-ms-")}var hyphenateStyleName_1=hyphenateStyleName,objToCss=function e(t,r){var n=Object.keys(t).filter(function(e){var r=t[e];return void 0!==r&&null!==r&&!1!==r&&""!==r}).map(function(r){return isPlainObject(t[r])?e(t[r],r):hyphenateStyleName_1(r)+": "+t[r]+";"}).join(" ");return r?r+" {\n "+n+"\n}":n},flatten=function e(t,r){return t.reduce(function(t,n){return void 0===n||null===n||!1===n||""===n?t:Array.isArray(n)?[].concat(t,e(n,r)):n.hasOwnProperty("styledComponentId")?[].concat(t,["."+n.styledComponentId]):"function"==typeof n?r?t.concat.apply(t,e([n(r)],r)):t.concat(n):t.concat(isPlainObject(n)?objToCss(n):n.toString())},[])},stylisSplitter=new Stylis({global:!1,cascade:!0,keyframe:!1,prefix:!1,compress:!1,semicolon:!0}),stylis=new Stylis({global:!1,cascade:!0,keyframe:!1,prefix:!0,compress:!1,semicolon:!1}),parsingRules=[],returnRulesPlugin=function(e){if(-2===e){var t=parsingRules;return parsingRules=[],t}},parseRulesPlugin=_insertRulePlugin(function(e){parsingRules.push(e)});stylis.use([parseRulesPlugin,returnRulesPlugin]),stylisSplitter.use([parseRulesPlugin,returnRulesPlugin]);var stringifyRules=function(e,t,r){var n=e.join("").replace(/^\s*\/\/.*$/gm,"");return stylis(r||!t?"":t,t&&r?r+" "+t+" { "+n+" }":n)},splitByRules=function(e){return stylisSplitter("",e)};function isStyledComponent(e){return"function"==typeof e&&"string"==typeof e.styledComponentId}function consolidateStreamedStyles(){}var charsLength=52,getAlphabeticChar=function(e){return String.fromCharCode(e+(e>25?39:97))},generateAlphabeticName=function(e){var t="",r=void 0;for(r=e;r>charsLength;r=Math.floor(r/charsLength))t=getAlphabeticChar(r%charsLength)+t;return getAlphabeticChar(r%charsLength)+t},interleave=function(e,t){return t.reduce(function(t,r,n){return t.concat(r,e[n+1])},[e[0]])},_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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_extends=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},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},objectWithoutProperties=function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r},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},css=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Array.isArray(e)||"object"!==(void 0===e?"undefined":_typeof(e))?flatten(interleave(e,r)):flatten(interleave([],[e].concat(r)))},stream={},SC_ATTR="undefined"!=typeof process&&process.env.SC_ATTR||"data-styled-components",SC_STREAM_ATTR="data-styled-streamed",CONTEXT_KEY="__styled-components-stylesheet__",IS_BROWSER="undefined"!=typeof window&&"HTMLElement"in window,DISABLE_SPEEDY=!1,SC_COMPONENT_ID=/^[^\S\n]*?\/\* sc-component-id:\s*(\S+)\s+\*\//gm,extractComps=function(e){var t=""+(e||""),r=[];return t.replace(SC_COMPONENT_ID,function(e,t,n){return r.push({componentId:t,matchIndex:n}),e}),r.map(function(e,n){var o=e.componentId,a=e.matchIndex,i=r[n+1];return{componentId:o,cssFromDOM:i?t.slice(a,i.matchIndex):t.slice(a)}})},getNonce=function(){return"undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null},once=function(e){var t=!1;return function(){t||(t=!0,e())}},addNameForId=function(e,t,r){r&&((e[t]||(e[t]=Object.create(null)))[r]=!0)},resetIdNames=function(e,t){e[t]=Object.create(null)},hasNameForId=function(e){return function(t,r){return void 0!==e[t]&&e[t][r]}},stringifyNames=function(e){var t="";for(var r in e)t+=Object.keys(e[r]).join(" ")+" ";return t.trim()},cloneNames=function(e){var t=Object.create(null);for(var r in e)t[r]=_extends({},e[r]);return t},sheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets.length,r=0;r<t;r+=1){var n=document.styleSheets[r];if(n.ownerNode===e)return n}throw new Error},safeInsertRule=function(e,t,r){if(!t)return!1;var n=e.cssRules.length;try{e.insertRule(t,r<=n?r:n)}catch(e){return!1}return!0},deleteRules=function(e,t,r){for(var n=t-r,o=t;o>n;o-=1)e.deleteRule(o)},parentNodeUnmountedErr="",throwCloneTagErr=function(){throw new Error("")},makeTextMarker=function(e){return"\n/* sc-component-id: "+e+" */\n"},addUpUntilIndex=function(e,t){for(var r=0,n=0;n<=t;n+=1)r+=e[n];return r},makeStyleTag=function(e,t,r){var n=document.createElement("style");n.setAttribute(SC_ATTR,"");var o=getNonce();if(o&&n.setAttribute("nonce",o),n.appendChild(document.createTextNode("")),e&&!t)e.appendChild(n);else{if(!t||!e||!t.parentNode)throw new Error(parentNodeUnmountedErr);t.parentNode.insertBefore(n,r?t:t.nextSibling)}return n},wrapAsHtmlTag=function(e,t){return function(r){var n=getNonce();return"<style "+[n&&'nonce="'+n+'"',SC_ATTR+'="'+stringifyNames(t)+'"',r].filter(Boolean).join(" ")+">"+e()+"</style>"}},wrapAsElement=function(e,t){return function(){var r,n=((r={})[SC_ATTR]=stringifyNames(t),r),o=getNonce();return o&&(n.nonce=o),React__default.createElement("style",_extends({},n,{dangerouslySetInnerHTML:{__html:e()}}))}},getIdsFromMarkersFactory=function(e){return function(){return Object.keys(e)}},makeSpeedyTag=function(e,t){var r=Object.create(null),n=Object.create(null),o=[],a=void 0!==t,i=!1,s=function(e){var t=n[e];return void 0!==t?t:(n[e]=o.length,o.push(0),resetIdNames(r,e),n[e])},c=function(){var t=sheetForTag(e).cssRules,r="";for(var a in n){r+=makeTextMarker(a);for(var i=n[a],s=addUpUntilIndex(o,i),c=s-o[i];c<s;c+=1){var u=t[c];void 0!==u&&(r+=u.cssText)}}return r};return{styleTag:e,getIds:getIdsFromMarkersFactory(n),hasNameForId:hasNameForId(r),insertMarker:s,insertRules:function(n,c,u){for(var l=s(n),p=sheetForTag(e),h=addUpUntilIndex(o,l),d=0,m=[],f=c.length,y=0;y<f;y+=1){var g=c[y],v=a;v&&-1!==g.indexOf("@import")?m.push(g):safeInsertRule(p,g,h+d)&&(v=!1,d+=1)}a&&m.length>0&&(i=!0,t().insertRules(n+"-import",m)),o[l]+=d,addNameForId(r,n,u)},removeRules:function(s){var c=n[s];if(void 0!==c){var u=o[c],l=sheetForTag(e),p=addUpUntilIndex(o,c);deleteRules(l,p,u),o[c]=0,resetIdNames(r,s),a&&i&&t().removeRules(s+"-import")}},css:c,toHTML:wrapAsHtmlTag(c,r),toElement:wrapAsElement(c,r),clone:throwCloneTagErr}},makeBrowserTag=function(e,t){var r=Object.create(null),n=Object.create(null),o=void 0!==t,a=function(e){return document.createTextNode(makeTextMarker(e))},i=!1,s=function(t){var o=n[t];return void 0!==o?o:(n[t]=a(t),e.appendChild(n[t]),r[t]=Object.create(null),n[t])},c=function(){var e="";for(var t in n)e+=n[t].data;return e};return{styleTag:e,getIds:getIdsFromMarkersFactory(n),hasNameForId:hasNameForId(r),insertMarker:s,insertRules:function(e,n,a){for(var c=s(e),u=[],l=n.length,p=0;p<l;p+=1){var h=n[p],d=o;if(d&&-1!==h.indexOf("@import"))u.push(h);else{d=!1;var m=p===l-1?"":" ";c.appendData(""+h+m)}}addNameForId(r,e,a),o&&u.length>0&&(i=!0,t().insertRules(e+"-import",u))},removeRules:function(s){var c=n[s];if(void 0!==c){var u=a(s);e.replaceChild(u,c),n[s]=u,resetIdNames(r,s),o&&i&&t().removeRules(s+"-import")}},css:c,toHTML:wrapAsHtmlTag(c,r),toElement:wrapAsElement(c,r),clone:throwCloneTagErr}},makeServerTagInternal=function e(t,r){var n=void 0===t?Object.create(null):t,o=void 0===r?Object.create(null):r,a=function(e){var t=o[e];return void 0!==t?t:o[e]=[""]},i=function(){var e="";for(var t in o){var r=o[t][0];r&&(e+=makeTextMarker(t)+r)}return e};return{styleTag:null,getIds:getIdsFromMarkersFactory(o),hasNameForId:hasNameForId(n),insertMarker:a,insertRules:function(e,t,r){a(e)[0]+=t.join(" "),addNameForId(n,e,r)},removeRules:function(e){var t=o[e];void 0!==t&&(t[0]="",resetIdNames(n,e))},css:i,toHTML:wrapAsHtmlTag(i,n),toElement:wrapAsElement(i,n),clone:function(){var t=cloneNames(n),r=Object.create(null);for(var a in o)r[a]=[o[a][0]];return e(t,r)}}},makeServerTag=function(){return makeServerTagInternal()},makeTag=function(e,t,r,n,o){if(IS_BROWSER&&!r){var a=makeStyleTag(e,t,n);return DISABLE_SPEEDY?makeBrowserTag(a,o):makeSpeedyTag(a,o)}return makeServerTag()},makeRehydrationTag=function(e,t,r,n,o){var a=once(function(){for(var n=0;n<r.length;n+=1){var o=r[n],a=o.componentId,i=o.cssFromDOM,s=splitByRules(i);e.insertRules(a,s)}for(var c=0;c<t.length;c+=1){var u=t[c];u.parentNode&&u.parentNode.removeChild(u)}});return o&&a(),_extends({},e,{insertMarker:function(t){return a(),e.insertMarker(t)},insertRules:function(t,r,n){return a(),e.insertRules(t,r,n)}})},MAX_SIZE=void 0;MAX_SIZE=IS_BROWSER?DISABLE_SPEEDY?40:1e3:-1;var _StyleSheetManager$ch,sheetRunningId=0,master=void 0,StyleSheet=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:IS_BROWSER?document.head:null,n=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 r=t.tags[0];return t.importRuleTag=makeTag(t.target,r?r.styleTag:null,t.forceServer,!0)},sheetRunningId+=1,this.id=sheetRunningId,this.sealed=!1,this.forceServer=n,this.target=n?null:r,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=[],r=[],n=!1,o=document.querySelectorAll("style["+SC_ATTR+"]"),a=o.length;if(0===a)return this;for(var i=0;i<a;i+=1){var s=o[i];n=!!s.getAttribute(SC_STREAM_ATTR)||n;for(var c=(s.getAttribute(SC_ATTR)||"").trim().split(/\s+/),u=c.length,l=0;l<u;l+=1){var p=c[l];this.rehydratedNames[p]=!0,t.push(p)}r=r.concat(extractComps(s.textContent)),e.push(s)}var h=r.length;if(0===h)return this;var d=this.makeTag(null),m=makeRehydrationTag(d,e,r,t,n);this.capacity=Math.max(1,MAX_SIZE-h),this.tags.push(m);for(var f=0;f<h;f+=1)this.tagMap[r[f].componentId]=m;return this},e.reset=function(){var t=arguments.length>0&&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 r=e.getIds(),n=e.clone(),o=0;o<r.length;o+=1)t.tagMap[r[o]]=n;return n}),t.rehydratedNames=_extends({},this.rehydratedNames),t.deferred=_extends({},this.deferred),t},e.prototype.sealAllTags=function(){this.capacity=1,this.sealed=!0},e.prototype.makeTag=function(e){var t=e?e.styleTag:null;return makeTag(this.target,t,this.forceServer,!1,this.getImportRuleTag)},e.prototype.getTagForId=function(e){var t=this.tagMap[e];if(void 0!==t&&!this.sealed)return t;var r=this.tags[this.tags.length-1];return this.capacity-=1,0===this.capacity&&(this.capacity=MAX_SIZE,this.sealed=!1,r=this.makeTag(r),this.tags.push(r)),this.tagMap[e]=r},e.prototype.hasId=function(e){return void 0!==this.tagMap[e]},e.prototype.hasNameForId=function(e,t){if(void 0===this.ignoreRehydratedNames[e]&&this.rehydratedNames[t])return!0;var r=this.tagMap[e];return void 0!==r&&r.hasNameForId(e,t)},e.prototype.deferredInject=function(e,t){if(void 0===this.tagMap[e]){for(var r=this.clones,n=0;n<r.length;n+=1)r[n].deferredInject(e,t);this.getTagForId(e).insertMarker(e),this.deferred[e]=t}},e.prototype.inject=function(e,t,r){for(var n=this.clones,o=0;o<n.length;o+=1)n[o].inject(e,t,r);var a=t,i=this.deferred[e];void 0!==i&&(a=i.concat(a),delete this.deferred[e]),this.getTagForId(e).insertRules(e,a,r)},e.prototype.remove=function(e){var t=this.tagMap[e];if(void 0!==t){for(var r=this.clones,n=0;n<r.length;n+=1)r[n].remove(e);t.removeRules(e),this.ignoreRehydratedNames[e]=!0,delete this.deferred[e]}},e.prototype.toHTML=function(){return this.tags.map(function(e){return e.toHTML()}).join("")},e.prototype.toReactElements=function(){var e=this.id;return this.tags.map(function(t,r){var n="sc-"+e+"-"+r;return React.cloneElement(t.toElement(),{key:n})})},createClass(e,null,[{key:"master",get:function(){return master||(master=(new e).rehydrate())}},{key:"instance",get:function(){return e.master}}]),e}(),targetPropErr="",StyleSheetManager=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,e.apply(this,arguments))}return inherits(t,e),t.prototype.getChildContext=function(){var e;return(e={})[CONTEXT_KEY]=this.sheetInstance,e},t.prototype.componentWillMount=function(){if(this.props.sheet)this.sheetInstance=this.props.sheet;else{if(!this.props.target)throw new Error(targetPropErr);this.sheetInstance=new StyleSheet(this.props.target)}},t.prototype.render=function(){return React__default.Children.only(this.props.children)},t}(React.Component);StyleSheetManager.childContextTypes=((_StyleSheetManager$ch={})[CONTEXT_KEY]=PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet),PropTypes.instanceOf(ServerStyleSheet)]).isRequired,_StyleSheetManager$ch);var sheetClosedErr="",streamBrowserErr="",ServerStyleSheet=function(){function e(){classCallCheck(this,e),this.masterSheet=StyleSheet.master,this.instance=this.masterSheet.clone(),this.closed=!1}return e.prototype.complete=function(){if(!this.closed){var e=this.masterSheet.clones.indexOf(this.instance);this.masterSheet.clones.splice(e,1),this.closed=!0}},e.prototype.collectStyles=function(e){if(this.closed)throw new Error(sheetClosedErr);return React__default.createElement(StyleSheetManager,{sheet:this.instance},e)},e.prototype.getStyleTags=function(){return this.complete(),this.instance.toHTML()},e.prototype.getStyleElement=function(){return this.complete(),this.instance.toReactElements()},e.prototype.interleaveWithNodeStream=function(e){throw new Error(streamBrowserErr)},e}(),determineTheme=function(e,t,r){var n=r&&e.theme===r.theme;return e.theme&&!n?e.theme:t},escapeRegex=/[[\].#*$><+~=|^:(),"'`-]+/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|lip(?:Path)?|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)|autoFocu|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(?:reserveA(?:spectRatio|lpha)|ointsAt[X-Z]|anose1)|(?: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|(?:[xy]ChannelSelect|lightingCol|textAnch|floodCol|stopCol|operat|htmlF)or|(?:strokeMiterlimi|(?:specularConsta|repeatCou|fontVaria)n|(?:(?:specularE|e)xpon|renderingInt|asc)en|d(?:iffuseConsta|esce)n|(?:fontSizeAdju|lengthAdju|manife)s|baselineShif|onPointerOu|vectorEffec|(?:(?:mar(?:ker|gin)|x)H|accentH|fontW)eigh|markerStar|a(?:utoCorrec|bou)|onFocusOu|intercep|restar|forma|inlis|heigh|lis)t|(?:(?:st(?:rokeDasho|artO)|o)ffs|acceptChars|formTarg|viewTarg|srcS)et|k(?:ernel(?:UnitLength|Matrix)|[1-4])|(?:(?:enableBackgrou|markerE)n|s(?:p(?:readMetho|ee)|ee)|formMetho|(?:markerM|onInval)i|preloa|metho|kin)d|strokeDasharray|(?:onPointerCanc|lab)el|(?:allowFullScre|hidd)en|systemLanguage|(?:(?:o(?:nPointer(?:Ent|Ov)|rd)|allowReord|placehold|frameBord|paintOrd|post)e|repeatDu|d(?:efe|u))r|v(?:Mathematical|ert(?:Origin[XY]|AdvY)|alues|ocab)|(?:pointerEve|keyPoi)nts|(?:strokeLineca|onPointerU|itemPro|useMa|wra|loo)p|h(?:oriz(?:Origin|Adv)X|ttpEquiv)|(?:vI|i)deographic|unicodeRange|mathematical|vAlphabetic|u(?:nicodeBidi|[12])|(?:fontStretc|hig)h|(?:(?: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])|a(?:rabicForm|l(?:phabetic|t)|sync)|pathLength|innerHTML|xlinkShow|(?:xlinkHr|glyphR)ef|(?:tabInde|(?:sand|b)bo|viewBo)x|(?:(?:href|xml|src)La|kerni)ng|autoPlay|o(?:verflow|pen)|f(?:o(?:ntSize|rm)|il(?:ter|l))|r(?:e(?:quired|sult|f))?|divisor|p(?:attern|oints)|unicode|d(?:efault|ata|ir)?|i(?:temRef|n2|s)|t(?:arget[XY]|o)|srcDoc|s(?:coped|te(?:m[hv]|p)|pan)|(?:width|size)s|prefix|typeof|itemID|s(?:t(?:roke|art)|hape|cope|rc)|t(?:arget|ype)|(?:stri|la)ng|a(?:ccept|s)|m(?:edia|a(?:sk|x)|in)|x(?:mlns)?|width|value|size|href|k(?:ey)?|end|low|by|i[dn]|y[12]|g[12]|x[12]|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 r=e;r;)if((r=Object.getPrototypeOf(r))&&r===t)return!0;return!1}var _ThemeProvider$childC,_ThemeProvider$contex,createBroadcast=function(e){var t={},r=0,n=e;return{publish:function(e){for(var r in n=e,t){var o=t[r];void 0!==o&&o(n)}},subscribe:function(e){var o=r;return t[o]=e,r+=1,e(n),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}),isFunction=function(e){return"function"==typeof e},ThemeProvider=function(e){function t(){classCallCheck(this,t);var r=possibleConstructorReturn(this,e.call(this));return r.unsubscribeToOuterId=-1,r.getTheme=r.getTheme.bind(r),r}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 r=t.broadcast.subscribe(e);return function(){return t.broadcast.unsubscribe(r)}},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 Error("");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__default.Children.only(this.props.children):null},t}(React.Component);ThemeProvider.childContextTypes=((_ThemeProvider$childC={})[CHANNEL]=PropTypes.func,_ThemeProvider$childC[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,_ThemeProvider$childC),ThemeProvider.contextTypes=((_ThemeProvider$contex={})[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,_ThemeProvider$contex);var STATIC_EXECUTION_CONTEXT={},_StyledComponent=function(e,t){var r={},n=function(e){function t(){var r,n;classCallCheck(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return r=n=possibleConstructorReturn(this,e.call.apply(e,[this].concat(a))),n.attrs={},n.state={theme:null,generatedClassName:""},n.unsubscribeId=-1,possibleConstructorReturn(n,r)}return inherits(t,e),t.prototype.unsubscribeFromContext=function(){-1!==this.unsubscribeId&&this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId)},t.prototype.buildExecutionContext=function(e,t){var r=this.constructor.attrs,n=_extends({},t,{theme:e});return void 0===r?n:(this.attrs=Object.keys(r).reduce(function(e,t){var o=r[t];return e[t]="function"!=typeof o||hasInInheritanceChain(o,React.Component)?o:o(n),e},{}),_extends({},n,this.attrs))},t.prototype.generateAndInjectStyles=function(e,t){var r=this.constructor,n=r.attrs,o=r.componentStyle,a=(r.warnTooManyClasses,this.context[CONTEXT_KEY]||StyleSheet.master);if(o.isStatic&&void 0===n)return o.generateAndInjectStyles(STATIC_EXECUTION_CONTEXT,a);var i=this.buildExecutionContext(e,t);return o.generateAndInjectStyles(i,a)},t.prototype.componentWillMount=function(){var e=this,t=this.constructor.componentStyle,r=this.context[CHANNEL_NEXT];if(t.isStatic){var n=this.generateAndInjectStyles(STATIC_EXECUTION_CONTEXT,this.props);this.setState({generatedClassName:n})}else if(void 0!==r){var o=r.subscribe;this.unsubscribeId=o(function(t){var r=determineTheme(e.props,t,e.constructor.defaultProps),n=e.generateAndInjectStyles(r,e.props);e.setState({theme:r,generatedClassName:n})})}else{var a=this.props.theme||{},i=this.generateAndInjectStyles(a,this.props);this.setState({theme:a,generatedClassName:i})}},t.prototype.componentWillReceiveProps=function(e){var t=this;this.constructor.componentStyle.isStatic||this.setState(function(r){var n=determineTheme(e,r.theme,t.constructor.defaultProps);return{theme:n,generatedClassName:t.generateAndInjectStyles(n,e)}})},t.prototype.componentWillUnmount=function(){this.unsubscribeFromContext()},t.prototype.render=function(){var e=this,t=this.props.innerRef,r=this.state.generatedClassName,n=this.constructor,o=n.styledComponentId,a=n.target,i=isTag(a),s=[this.props.className,o,this.attrs.className,r].filter(Boolean).join(" "),c=_extends({},this.attrs,{className:s});isStyledComponent(a)?c.innerRef=t:c.ref=t;var u=Object.keys(this.props).reduce(function(t,r){return"innerRef"===r||"className"===r||i&&!validAttr(r)||(t[r]=e.props[r]),t},c);return React.createElement(a,u)},t}(React.Component);return function o(a,i,s){var c,u=i.isClass,l=void 0===u?!isTag(a):u,p=i.displayName,h=void 0===p?generateDisplayName(a):p,d=i.componentId,m=void 0===d?function(t,n){var o="string"!=typeof t?"sc":escape(t),a=(r[o]||0)+1;r[o]=a;var i=o+"-"+e.generateName(o+a);return void 0!==n?n+"-"+i:i}(i.displayName,i.parentComponentId):d,f=i.ParentComponent,y=void 0===f?n:f,g=i.rules,v=i.attrs,T=i.displayName&&i.componentId?escape(i.displayName)+"-"+i.componentId:i.componentId||m,S=new e(void 0===g?s:g.concat(s),v,T),C=function(e){function r(){return classCallCheck(this,r),possibleConstructorReturn(this,e.apply(this,arguments))}return inherits(r,e),r.withComponent=function(e){var t=i.componentId,n=objectWithoutProperties(i,["componentId"]),a=t&&t+"-"+(isTag(e)?e:escape(getComponentName(e))),c=_extends({},n,{componentId:a,ParentComponent:r});return o(e,c,s)},createClass(r,null,[{key:"extend",get:function(){var e=i.rules,n=i.componentId,c=objectWithoutProperties(i,["rules","componentId"]),u=void 0===e?s:e.concat(s),l=_extends({},c,{rules:u,parentComponentId:n,ParentComponent:r});return t(o,a,l)}}]),r}(y);return C.attrs=v,C.componentStyle=S,C.displayName=h,C.styledComponentId=T,C.target=a,C.contextTypes=((c={})[CHANNEL]=PropTypes.func,c[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,c[CONTEXT_KEY]=PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet),PropTypes.instanceOf(ServerStyleSheet)]),c),l&&hoist(C,a,{attrs:!0,componentStyle:!0,displayName:!0,extend:!0,styledComponentId:!0,target:!0,warnTooManyClasses:!0,withComponent:!0}),C}};function murmurhash(e){for(var t,r=0|e.length,n=0|r,o=0;r>=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),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(t=1540483477*(65535&(t^=t>>>24))+((1540483477*(t>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}var areStylesCacheable=IS_BROWSER,isStaticRules=function e(t,r){for(var n=0;n<t.length;n+=1){var o=t[n];if(Array.isArray(o)&&!e(o))return!1;if("function"==typeof o&&!isStyledComponent(o))return!1}if(void 0!==r)for(var a in r){if("function"==typeof r[a])return!1}return!0},isHMREnabled="undefined"!=typeof module&&module.hot&&!1,_ComponentStyle=function(e,t,r){var n=function(t){return e(murmurhash(t))};return function(){function e(t,r,n){if(classCallCheck(this,e),this.rules=t,this.isStatic=!isHMREnabled&&isStaticRules(t,r),this.componentId=n,!StyleSheet.master.hasId(n)){StyleSheet.master.deferredInject(n,[])}}return e.prototype.generateAndInjectStyles=function(e,o){var a=this.isStatic,i=this.componentId,s=this.lastClassName;if(areStylesCacheable&&a&&void 0!==s&&o.hasNameForId(i,s))return s;var c=t(this.rules,e),u=n(this.componentId+c.join(""));if(!o.hasNameForId(i,u)){var l=r(c,"."+u);o.inject(this.componentId,l,u)}return this.lastClassName=u,u},e.generateName=function(e){return n(e)},e}()},domElements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],_styled=function(e,t){var r=function(r){return t(e,r)};return domElements.forEach(function(e){r[e]=r(e)}),r},replaceWhitespace=function(e){return e.replace(/\s|\\n/g,"")},_keyframes=function(e,t,r){return function(){var n=StyleSheet.master,o=r.apply(void 0,arguments),a=e(murmurhash(replaceWhitespace(JSON.stringify(o)))),i="sc-keyframes-"+a;return n.hasNameForId(i,a)||n.inject(i,t(o,a,"@keyframes"),a),a}},_injectGlobal=function(e,t){return function(){var r=StyleSheet.master,n=t.apply(void 0,arguments),o="sc-global-"+murmurhash(JSON.stringify(n));r.hasId(o)||r.inject(o,e(n))}},_constructWithOptions=function(e){return function t(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!reactIs.isValidElementType(n))throw new Error("");var a=function(){return r(n,o,e.apply(void 0,arguments))};return a.withConfig=function(e){return t(r,n,_extends({},o,e))},a.attrs=function(e){return t(r,n,_extends({},o,{attrs:_extends({},o.attrs||{},e)}))},a}},wrapWithTheme=function(e){var t,r=e.displayName||e.name||"Component",n="function"==typeof e&&!(e.prototype&&"isReactComponent"in e.prototype),o=isStyledComponent(e)||n,a=function(t){function r(){var e,n;classCallCheck(this,r);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return e=n=possibleConstructorReturn(this,t.call.apply(t,[this].concat(a))),n.state={},n.unsubscribeId=-1,possibleConstructorReturn(n,e)}return inherits(r,t),r.prototype.componentWillMount=function(){var e=this,t=this.constructor.defaultProps,r=this.context[CHANNEL_NEXT],n=determineTheme(this.props,void 0,t);if(void 0===r&&void 0!==n)this.setState({theme:n});else{var o=r.subscribe;this.unsubscribeId=o(function(r){var n=determineTheme(e.props,r,t);e.setState({theme:n})})}},r.prototype.componentWillReceiveProps=function(e){var t=this.constructor.defaultProps;this.setState(function(r){return{theme:determineTheme(e,r.theme,t)}})},r.prototype.componentWillUnmount=function(){-1!==this.unsubscribeId&&this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId)},r.prototype.render=function(){var t=_extends({theme:this.state.theme},this.props);return o||(t.ref=t.innerRef,delete t.innerRef),React__default.createElement(e,t)},r}(React__default.Component);return a.displayName="WithTheme("+r+")",a.styledComponentId="withTheme",a.contextTypes=((t={})[CHANNEL]=PropTypes.func,t[CHANNEL_NEXT]=CONTEXT_CHANNEL_SHAPE,t),hoist(a,e)},__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS={StyleSheet:StyleSheet},ComponentStyle=_ComponentStyle(generateAlphabeticName,flatten,stringifyRules),constructWithOptions=_constructWithOptions(css),StyledComponent=_StyledComponent(ComponentStyle,constructWithOptions),keyframes=_keyframes(generateAlphabeticName,stringifyRules,css),injectGlobal=_injectGlobal(stringifyRules,css),styled=_styled(StyledComponent,constructWithOptions);exports.default=styled,exports.css=css,exports.keyframes=keyframes,exports.injectGlobal=injectGlobal,exports.isStyledComponent=isStyledComponent,exports.consolidateStreamedStyles=consolidateStreamedStyles,exports.ThemeProvider=ThemeProvider,exports.withTheme=wrapWithTheme,exports.ServerStyleSheet=ServerStyleSheet,exports.StyleSheetManager=StyleSheetManager,exports.__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS=__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS;
2
2
  //# sourceMappingURL=styled-components.browser.cjs.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled-components.browser.cjs.min.js","sources":["../src/models/StyleTags.js","../src/models/StyleSheetManager.js","../src/models/ThemeProvider.js","../src/models/StyledComponent.js","../src/models/ComponentStyle.js"],"sourcesContent":["// @flow\n/* eslint-disable flowtype/object-type-delimiter */\n/* eslint-disable react/prop-types */\n\nimport React, { type Element } from 'react'\nimport { IS_BROWSER, DISABLE_SPEEDY, SC_ATTR } from '../constants'\nimport { type ExtractedComp } from '../utils/extractCompsFromCSS'\nimport { splitByRules } from '../utils/stringifyRules'\nimport getNonce from '../utils/nonce'\nimport once from '../utils/once'\n\nimport {\n type Names,\n addNameForId,\n resetIdNames,\n hasNameForId,\n stringifyNames,\n cloneNames,\n} from '../utils/styleNames'\n\nimport {\n sheetForTag,\n safeInsertRule,\n deleteRules,\n} from '../utils/insertRuleHelpers'\n\nexport interface Tag<T> {\n // $FlowFixMe: Doesn't seem to accept any combination w/ HTMLStyleElement for some reason\n styleTag: HTMLStyleElement | null;\n /* lists all ids of the tag */\n getIds(): string[];\n /* checks whether `name` is already injected for `id` */\n hasNameForId(id: string, name: string): boolean;\n /* inserts a marker to ensure the id's correct position in the sheet */\n insertMarker(id: string): T;\n /* inserts rules according to the ids markers */\n insertRules(id: string, cssRules: string[], name: ?string): void;\n /* removes all rules belonging to the id, keeping the marker around */\n removeRules(id: string): void;\n css(): string;\n toHTML(additionalAttrs: ?string): string;\n toElement(): Element<*>;\n clone(): Tag<T>;\n}\n\n/* this error is used for makeStyleTag */\nconst parentNodeUnmountedErr =\n process.env.NODE_ENV !== 'production'\n ? `\nTrying to insert a new style tag, but the given Node is unmounted!\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n`.trim()\n : ''\n\n/* this error is used for tags */\nconst throwCloneTagErr = () => {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `\nThe clone method cannot be used on the client!\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n`.trim()\n : ''\n )\n}\n\n/* this marker separates component styles and is important for rehydration */\nconst makeTextMarker = id => `\\n/* sc-component-id: ${id} */\\n`\n\n/* add up all numbers in array up until and including the index */\nconst addUpUntilIndex = (sizes: number[], index: number): number => {\n let totalUpToIndex = 0\n for (let i = 0; i <= index; i += 1) {\n totalUpToIndex += sizes[i]\n }\n\n return totalUpToIndex\n}\n\n/* create a new style tag after lastEl */\nconst makeStyleTag = (\n target: ?HTMLElement,\n tagEl: ?Node,\n insertBefore: ?boolean\n) => {\n const el = document.createElement('style')\n el.setAttribute(SC_ATTR, '')\n\n const nonce = getNonce()\n if (nonce) {\n el.setAttribute('nonce', nonce)\n }\n\n /* Work around insertRule quirk in EdgeHTML */\n el.appendChild(document.createTextNode(''))\n\n if (target && !tagEl) {\n /* Append to target when no previous element was passed */\n target.appendChild(el)\n } else {\n if (!tagEl || !target || !tagEl.parentNode) {\n throw new Error(parentNodeUnmountedErr)\n }\n\n /* Insert new style tag after the previous one */\n tagEl.parentNode.insertBefore(el, insertBefore ? tagEl : tagEl.nextSibling)\n }\n\n return el\n}\n\n/* takes a css factory function and outputs an html styled tag factory */\nconst wrapAsHtmlTag = (css: () => string, names: Names) => (\n additionalAttrs: ?string\n): string => {\n const nonce = getNonce()\n const attrs = [\n nonce && `nonce=\"${nonce}\"`,\n `${SC_ATTR}=\"${stringifyNames(names)}\"`,\n additionalAttrs,\n ]\n\n const htmlAttr = attrs.filter(Boolean).join(' ')\n return `<style ${htmlAttr}>${css()}</style>`\n}\n\n/* takes a css factory function and outputs an element factory */\nconst wrapAsElement = (css: () => string, names: Names) => () => {\n const props = {\n [SC_ATTR]: stringifyNames(names),\n }\n\n const nonce = getNonce()\n if (nonce) {\n // $FlowFixMe\n props.nonce = nonce\n }\n\n // eslint-disable-next-line react/no-danger\n return <style {...props} dangerouslySetInnerHTML={{ __html: css() }} />\n}\n\nconst getIdsFromMarkersFactory = (markers: Object) => (): string[] =>\n Object.keys(markers)\n\n/* speedy tags utilise insertRule */\nconst makeSpeedyTag = (\n el: HTMLStyleElement,\n getImportRuleTag: ?() => Tag<any>\n): Tag<number> => {\n const names: Names = (Object.create(null): Object)\n const markers = Object.create(null)\n const sizes: number[] = []\n\n const extractImport = getImportRuleTag !== undefined\n /* indicates whther getImportRuleTag was called */\n let usedImportRuleTag = false\n\n const insertMarker = id => {\n const prev = markers[id]\n if (prev !== undefined) {\n return prev\n }\n\n markers[id] = sizes.length\n sizes.push(0)\n resetIdNames(names, id)\n\n return markers[id]\n }\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id)\n const sheet = sheetForTag(el)\n const insertIndex = addUpUntilIndex(sizes, marker)\n\n let injectedRules = 0\n const importRules = []\n const cssRulesSize = cssRules.length\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const cssRule = cssRules[i]\n let mayHaveImport = extractImport /* @import rules are reordered to appear first */\n if (mayHaveImport && cssRule.indexOf('@import') !== -1) {\n importRules.push(cssRule)\n } else if (safeInsertRule(sheet, cssRule, insertIndex + injectedRules)) {\n mayHaveImport = false\n injectedRules += 1\n }\n }\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules)\n }\n\n sizes[marker] += injectedRules /* add up no of injected rules */\n addNameForId(names, id, name)\n }\n\n const removeRules = id => {\n const marker = markers[id]\n if (marker === undefined) return\n\n const size = sizes[marker]\n const sheet = sheetForTag(el)\n const removalIndex = addUpUntilIndex(sizes, marker)\n deleteRules(sheet, removalIndex, size)\n sizes[marker] = 0\n resetIdNames(names, id)\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`)\n }\n }\n\n const css = () => {\n const { cssRules } = sheetForTag(el)\n let str = ''\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += makeTextMarker(id)\n const marker = markers[id]\n const end = addUpUntilIndex(sizes, marker)\n const size = sizes[marker]\n for (let i = end - size; i < end; i += 1) {\n const rule = cssRules[i]\n if (rule !== undefined) {\n str += rule.cssText\n }\n }\n }\n\n return str\n }\n\n return {\n styleTag: el,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n css,\n toHTML: wrapAsHtmlTag(css, names),\n toElement: wrapAsElement(css, names),\n clone: throwCloneTagErr,\n }\n}\n\nconst makeBrowserTag = (\n el: HTMLStyleElement,\n getImportRuleTag: ?() => Tag<any>\n): Tag<Text> => {\n const names = (Object.create(null): Object)\n const markers = Object.create(null)\n\n const extractImport = getImportRuleTag !== undefined\n const makeTextNode = id => document.createTextNode(makeTextMarker(id))\n\n /* indicates whther getImportRuleTag was called */\n let usedImportRuleTag = false\n\n const insertMarker = id => {\n const prev = markers[id]\n if (prev !== undefined) {\n return prev\n }\n\n markers[id] = makeTextNode(id)\n el.appendChild(markers[id])\n names[id] = Object.create(null)\n\n return markers[id]\n }\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id)\n const importRules = []\n const cssRulesSize = cssRules.length\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const rule = cssRules[i]\n let mayHaveImport = extractImport\n if (mayHaveImport && rule.indexOf('@import') !== -1) {\n importRules.push(rule)\n } else {\n mayHaveImport = false\n const separator = i === cssRulesSize - 1 ? '' : ' '\n marker.appendData(`${rule}${separator}`)\n }\n }\n\n addNameForId(names, id, name)\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules)\n }\n }\n\n const removeRules = id => {\n const marker = markers[id]\n if (marker === undefined) return\n\n /* create new empty text node and replace the current one */\n const newMarker = makeTextNode(id)\n el.replaceChild(newMarker, marker)\n markers[id] = newMarker\n resetIdNames(names, id)\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`)\n }\n }\n\n const css = () => {\n let str = ''\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += markers[id].data\n }\n return str\n }\n\n return {\n styleTag: el,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n css,\n toHTML: wrapAsHtmlTag(css, names),\n toElement: wrapAsElement(css, names),\n clone: throwCloneTagErr,\n }\n}\n\nconst makeServerTagInternal = (namesArg, markersArg): Tag<[string]> => {\n const names =\n namesArg === undefined ? (Object.create(null): Object) : namesArg\n const markers = markersArg === undefined ? Object.create(null) : markersArg\n\n const insertMarker = id => {\n const prev = markers[id]\n if (prev !== undefined) {\n return prev\n }\n\n return (markers[id] = [''])\n }\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id)\n marker[0] += cssRules.join(' ')\n addNameForId(names, id, name)\n }\n\n const removeRules = id => {\n const marker = markers[id]\n if (marker === undefined) return\n marker[0] = ''\n resetIdNames(names, id)\n }\n\n const css = () => {\n let str = ''\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n const cssForId = markers[id][0]\n if (cssForId) {\n str += makeTextMarker(id) + cssForId\n }\n }\n return str\n }\n\n const clone = () => {\n const namesClone = cloneNames(names)\n const markersClone = Object.create(null)\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n markersClone[id] = [markers[id][0]]\n }\n\n return makeServerTagInternal(namesClone, markersClone)\n }\n\n const tag = {\n styleTag: null,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n css,\n toHTML: wrapAsHtmlTag(css, names),\n toElement: wrapAsElement(css, names),\n clone,\n }\n\n return tag\n}\n\nconst makeServerTag = (): Tag<[string]> => makeServerTagInternal()\n\nexport const makeTag = (\n target: ?HTMLElement,\n tagEl: ?HTMLStyleElement,\n forceServer?: boolean,\n insertBefore?: boolean,\n getImportRuleTag?: () => Tag<any>\n): Tag<any> => {\n if (IS_BROWSER && !forceServer) {\n const el = makeStyleTag(target, tagEl, insertBefore)\n if (DISABLE_SPEEDY) {\n return makeBrowserTag(el, getImportRuleTag)\n } else {\n return makeSpeedyTag(el, getImportRuleTag)\n }\n }\n\n return makeServerTag()\n}\n\n/* wraps a given tag so that rehydration is performed once when necessary */\nexport const makeRehydrationTag = (\n tag: Tag<any>,\n els: HTMLStyleElement[],\n extracted: ExtractedComp[],\n names: string[],\n immediateRehydration: boolean\n): Tag<any> => {\n /* rehydration function that adds all rules to the new tag */\n const rehydrate = once(() => {\n /* add all extracted components to the new tag */\n for (let i = 0; i < extracted.length; i += 1) {\n const { componentId, cssFromDOM } = extracted[i]\n const cssRules = splitByRules(cssFromDOM)\n tag.insertRules(componentId, cssRules)\n }\n\n /* remove old HTMLStyleElements, since they have been rehydrated */\n for (let i = 0; i < els.length; i += 1) {\n const el = els[i]\n if (el.parentNode) {\n el.parentNode.removeChild(el)\n }\n }\n })\n\n if (immediateRehydration) rehydrate()\n\n return {\n ...tag,\n /* add rehydration hook to insertion methods */\n insertMarker: id => {\n rehydrate()\n return tag.insertMarker(id)\n },\n insertRules: (id, cssRules, name) => {\n rehydrate()\n return tag.insertRules(id, cssRules, name)\n },\n }\n}\n","// @flow\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport StyleSheet from './StyleSheet'\nimport ServerStyleSheet from './ServerStyleSheet'\nimport { CONTEXT_KEY } from '../constants'\n\n/* this error is used for makeStyleTag */\nconst targetPropErr =\n process.env.NODE_ENV !== 'production'\n ? `\nThe StyleSheetManager expects a valid target or sheet prop!\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n`.trim()\n : ''\n\ntype Props = {\n sheet?: StyleSheet | null,\n target?: HTMLElement | null,\n}\n\nclass StyleSheetManager extends Component<Props, void> {\n sheetInstance: StyleSheet\n\n getChildContext() {\n return { [CONTEXT_KEY]: this.sheetInstance }\n }\n\n componentWillMount() {\n if (this.props.sheet) {\n this.sheetInstance = this.props.sheet\n } else if (this.props.target) {\n this.sheetInstance = new StyleSheet(this.props.target)\n } else {\n throw new Error(targetPropErr)\n }\n }\n\n render() {\n /* eslint-disable react/prop-types */\n // Flow v0.43.1 will report an error accessing the `children` property,\n // but v0.47.0 will not. It is necessary to use a type cast instead of\n // a \"fixme\" comment to satisfy both Flow versions.\n return React.Children.only((this.props: any).children)\n }\n}\n\nStyleSheetManager.childContextTypes = {\n [CONTEXT_KEY]: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]).isRequired,\n}\n\nStyleSheetManager.propTypes = {\n sheet: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]),\n target: PropTypes.shape({\n appendChild: PropTypes.func.isRequired,\n }),\n}\n\nexport default StyleSheetManager\n","// @flow\nimport React, { Component, type Element } from 'react'\nimport PropTypes from 'prop-types'\nimport createBroadcast from '../utils/create-broadcast'\nimport type { Broadcast } from '../utils/create-broadcast'\nimport once from '../utils/once'\n\n// NOTE: DO NOT CHANGE, changing this is a semver major change!\nexport const CHANNEL = '__styled-components__'\nexport const CHANNEL_NEXT = `${CHANNEL}next__`\n\nexport const CONTEXT_CHANNEL_SHAPE = PropTypes.shape({\n getTheme: PropTypes.func,\n subscribe: PropTypes.func,\n unsubscribe: PropTypes.func,\n})\n\nexport type Theme = { [key: string]: mixed }\ntype ThemeProviderProps = {|\n children?: Element<any>,\n theme: Theme | ((outerTheme: Theme) => void),\n|}\n\nlet warnChannelDeprecated\nif (process.env.NODE_ENV !== 'production') {\n warnChannelDeprecated = once(() => {\n // eslint-disable-next-line no-console\n console.error(\n `Warning: Usage of \\`context.${CHANNEL}\\` as a function is deprecated. It will be replaced with the object on \\`.context.${CHANNEL_NEXT}\\` in a future version.`\n )\n })\n}\n\nconst isFunction = test => typeof test === 'function'\n\n/**\n * Provide a theme to an entire react component tree via context and event listeners (have to do\n * both context and event emitter as pure components block context updates)\n */\nclass ThemeProvider extends Component<ThemeProviderProps, void> {\n getTheme: (theme?: Theme | ((outerTheme: Theme) => void)) => Theme\n outerTheme: Theme\n unsubscribeToOuterId: string\n props: ThemeProviderProps\n broadcast: Broadcast\n unsubscribeToOuterId: number = -1\n\n constructor() {\n super()\n this.getTheme = this.getTheme.bind(this)\n }\n\n componentWillMount() {\n // If there is a ThemeProvider wrapper anywhere around this theme provider, merge this theme\n // with the outer theme\n const outerContext = this.context[CHANNEL_NEXT]\n if (outerContext !== undefined) {\n this.unsubscribeToOuterId = outerContext.subscribe(theme => {\n this.outerTheme = theme\n\n if (this.broadcast !== undefined) {\n this.publish(this.props.theme)\n }\n })\n }\n\n this.broadcast = createBroadcast(this.getTheme())\n }\n\n getChildContext() {\n return {\n ...this.context,\n [CHANNEL_NEXT]: {\n getTheme: this.getTheme,\n subscribe: this.broadcast.subscribe,\n unsubscribe: this.broadcast.unsubscribe,\n },\n [CHANNEL]: subscriber => {\n if (process.env.NODE_ENV !== 'production') {\n warnChannelDeprecated()\n }\n\n // Patch the old `subscribe` provide via `CHANNEL` for older clients.\n const unsubscribeId = this.broadcast.subscribe(subscriber)\n return () => this.broadcast.unsubscribe(unsubscribeId)\n },\n }\n }\n\n componentWillReceiveProps(nextProps: ThemeProviderProps) {\n if (this.props.theme !== nextProps.theme) {\n this.publish(nextProps.theme)\n }\n }\n\n componentWillUnmount() {\n if (this.unsubscribeToOuterId !== -1) {\n this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeToOuterId)\n }\n }\n\n // Get the theme from the props, supporting both (outerTheme) => {} as well as object notation\n getTheme(passedTheme: (outerTheme: Theme) => void | Theme) {\n const theme = passedTheme || this.props.theme\n if (isFunction(theme)) {\n const mergedTheme = theme(this.outerTheme)\n if (\n process.env.NODE_ENV !== 'production' &&\n (mergedTheme === null ||\n Array.isArray(mergedTheme) ||\n typeof mergedTheme !== 'object')\n ) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? '[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!'\n : ''\n )\n }\n return mergedTheme\n }\n if (theme === null || Array.isArray(theme) || typeof theme !== 'object') {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? '[ThemeProvider] Please make your theme prop an object'\n : ''\n )\n }\n return { ...this.outerTheme, ...(theme: Object) }\n }\n\n publish(theme: Theme | ((outerTheme: Theme) => void)) {\n this.broadcast.publish(this.getTheme(theme))\n }\n\n render() {\n if (!this.props.children) {\n return null\n }\n return React.Children.only(this.props.children)\n }\n}\n\nThemeProvider.childContextTypes = {\n [CHANNEL]: PropTypes.func, // legacy\n [CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,\n}\nThemeProvider.contextTypes = {\n [CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,\n}\n\nexport default ThemeProvider\n","// @flow\n\nimport hoist from 'hoist-non-react-statics'\nimport PropTypes from 'prop-types'\nimport { Component, createElement } from 'react'\nimport { CONTEXT_KEY } from '../constants'\nimport createWarnTooManyClasses from '../utils/createWarnTooManyClasses'\nimport determineTheme from '../utils/determineTheme'\nimport escape from '../utils/escape'\nimport generateDisplayName from '../utils/generateDisplayName'\nimport getComponentName from '../utils/getComponentName'\nimport isStyledComponent from '../utils/isStyledComponent'\nimport isTag from '../utils/isTag'\nimport validAttr from '../utils/validAttr'\nimport hasInInheritanceChain from '../utils/hasInInheritanceChain'\nimport ServerStyleSheet from './ServerStyleSheet'\nimport StyleSheet from './StyleSheet'\nimport { CHANNEL, CHANNEL_NEXT, CONTEXT_CHANNEL_SHAPE } from './ThemeProvider'\n\nimport type { Theme } from './ThemeProvider'\nimport type { RuleSet, Target } from '../types'\n\n// HACK for generating all static styles without needing to allocate\n// an empty execution context every single time...\nconst STATIC_EXECUTION_CONTEXT = {}\n\ntype BaseState = {\n theme?: ?Theme,\n generatedClassName?: string,\n}\n\nexport default (ComponentStyle: Function, constructWithOptions: Function) => {\n const identifiers = {}\n\n /* We depend on components having unique IDs */\n const generateId = (_displayName: string, parentComponentId: string) => {\n const displayName =\n typeof _displayName !== 'string' ? 'sc' : escape(_displayName)\n\n let componentId\n\n /**\n * only fall back to hashing the component injection order if\n * a proper displayName isn't provided by the babel plugin\n */\n if (!_displayName) {\n const nr = (identifiers[displayName] || 0) + 1\n identifiers[displayName] = nr\n\n componentId = `${displayName}-${ComponentStyle.generateName(\n displayName + nr\n )}`\n } else {\n componentId = `${displayName}-${ComponentStyle.generateName(displayName)}`\n }\n\n return parentComponentId !== undefined\n ? `${parentComponentId}-${componentId}`\n : componentId\n }\n\n // $FlowFixMe\n class BaseStyledComponent extends Component<*, BaseState> {\n static target: Target\n static styledComponentId: string\n static attrs: Object\n static componentStyle: Object\n static defaultProps: Object\n static warnTooManyClasses: Function\n\n attrs = {}\n state = {\n theme: null,\n generatedClassName: '',\n }\n unsubscribeId: number = -1\n\n unsubscribeFromContext() {\n if (this.unsubscribeId !== -1) {\n this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId)\n }\n }\n\n buildExecutionContext(theme: any, props: any) {\n const { attrs } = this.constructor\n const context = { ...props, theme }\n if (attrs === undefined) {\n return context\n }\n\n this.attrs = Object.keys(attrs).reduce((acc, key) => {\n const attr = attrs[key]\n // eslint-disable-next-line no-param-reassign\n acc[key] =\n typeof attr === 'function' && !hasInInheritanceChain(attr, Component)\n ? attr(context)\n : attr\n return acc\n }, {})\n\n return { ...context, ...this.attrs }\n }\n\n generateAndInjectStyles(theme: any, props: any) {\n const { attrs, componentStyle, warnTooManyClasses } = this.constructor\n const styleSheet = this.context[CONTEXT_KEY] || StyleSheet.master\n\n // staticaly styled-components don't need to build an execution context object,\n // and shouldn't be increasing the number of class names\n if (componentStyle.isStatic && attrs === undefined) {\n return componentStyle.generateAndInjectStyles(\n STATIC_EXECUTION_CONTEXT,\n styleSheet\n )\n } else {\n const executionContext = this.buildExecutionContext(theme, props)\n const className = componentStyle.generateAndInjectStyles(\n executionContext,\n styleSheet\n )\n\n if (\n process.env.NODE_ENV !== 'production' &&\n warnTooManyClasses !== undefined\n ) {\n warnTooManyClasses(className)\n }\n\n return className\n }\n }\n\n componentWillMount() {\n const { componentStyle } = this.constructor\n const styledContext = this.context[CHANNEL_NEXT]\n\n // If this is a staticaly-styled component, we don't need to the theme\n // to generate or build styles.\n if (componentStyle.isStatic) {\n const generatedClassName = this.generateAndInjectStyles(\n STATIC_EXECUTION_CONTEXT,\n this.props\n )\n this.setState({ generatedClassName })\n // If there is a theme in the context, subscribe to the event emitter. This\n // is necessary due to pure components blocking context updates, this circumvents\n // that by updating when an event is emitted\n } else if (styledContext !== undefined) {\n const { subscribe } = styledContext\n this.unsubscribeId = subscribe(nextTheme => {\n // This will be called once immediately\n const theme = determineTheme(\n this.props,\n nextTheme,\n this.constructor.defaultProps\n )\n const generatedClassName = this.generateAndInjectStyles(\n theme,\n this.props\n )\n\n this.setState({ theme, generatedClassName })\n })\n } else {\n // eslint-disable-next-line react/prop-types\n const theme = this.props.theme || {}\n const generatedClassName = this.generateAndInjectStyles(\n theme,\n this.props\n )\n this.setState({ theme, generatedClassName })\n }\n }\n\n componentWillReceiveProps(nextProps: {\n theme?: Theme,\n [key: string]: any,\n }) {\n // If this is a statically-styled component, we don't need to listen to\n // props changes to update styles\n const { componentStyle } = this.constructor\n if (componentStyle.isStatic) {\n return\n }\n\n this.setState(prevState => {\n const theme = determineTheme(\n nextProps,\n prevState.theme,\n this.constructor.defaultProps\n )\n const generatedClassName = this.generateAndInjectStyles(\n theme,\n nextProps\n )\n\n return { theme, generatedClassName }\n })\n }\n\n componentWillUnmount() {\n this.unsubscribeFromContext()\n }\n\n render() {\n // eslint-disable-next-line react/prop-types\n const { innerRef } = this.props\n const { generatedClassName } = this.state\n const { styledComponentId, target } = this.constructor\n\n const isTargetTag = isTag(target)\n\n const className = [\n // eslint-disable-next-line react/prop-types\n this.props.className,\n styledComponentId,\n this.attrs.className,\n generatedClassName,\n ]\n .filter(Boolean)\n .join(' ')\n\n const baseProps: any = {\n ...this.attrs,\n className,\n }\n\n if (isStyledComponent(target)) {\n baseProps.innerRef = innerRef\n } else {\n baseProps.ref = innerRef\n }\n\n const propsForElement = Object.keys(this.props).reduce(\n (acc, propName) => {\n // Don't pass through non HTML tags through to HTML elements\n // always omit innerRef\n if (\n propName !== 'innerRef' &&\n propName !== 'className' &&\n (!isTargetTag || validAttr(propName))\n ) {\n // eslint-disable-next-line no-param-reassign\n acc[propName] = this.props[propName]\n }\n\n return acc\n },\n baseProps\n )\n\n return createElement(target, propsForElement)\n }\n }\n\n const createStyledComponent = (\n target: Target,\n options: Object,\n rules: RuleSet\n ) => {\n const {\n isClass = !isTag(target),\n displayName = generateDisplayName(target),\n componentId = generateId(options.displayName, options.parentComponentId),\n ParentComponent = BaseStyledComponent,\n rules: extendingRules,\n attrs,\n } = options\n\n const styledComponentId =\n options.displayName && options.componentId\n ? `${escape(options.displayName)}-${options.componentId}`\n : componentId\n\n const componentStyle = new ComponentStyle(\n extendingRules === undefined ? rules : extendingRules.concat(rules),\n attrs,\n styledComponentId\n )\n\n class StyledComponent extends ParentComponent {\n static contextTypes = {\n [CHANNEL]: PropTypes.func,\n [CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,\n [CONTEXT_KEY]: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]),\n }\n\n static withComponent(tag: Target) {\n const { componentId: previousComponentId, ...optionsToCopy } = options\n\n const newComponentId =\n previousComponentId &&\n `${previousComponentId}-${\n isTag(tag) ? tag : escape(getComponentName(tag))\n }`\n\n const newOptions = {\n ...optionsToCopy,\n componentId: newComponentId,\n ParentComponent: StyledComponent,\n }\n\n return createStyledComponent(tag, newOptions, rules)\n }\n\n static get extend() {\n const {\n rules: rulesFromOptions,\n componentId: parentComponentId,\n ...optionsToCopy\n } = options\n\n const newRules =\n rulesFromOptions === undefined\n ? rules\n : rulesFromOptions.concat(rules)\n\n const newOptions = {\n ...optionsToCopy,\n rules: newRules,\n parentComponentId,\n ParentComponent: StyledComponent,\n }\n\n return constructWithOptions(createStyledComponent, target, newOptions)\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n StyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName)\n }\n\n if (isClass) hoist(StyledComponent, target)\n\n // we do this after hoisting to ensure we're overwriting existing\n // rules when wrapping another styled component class\n StyledComponent.displayName = displayName\n StyledComponent.styledComponentId = styledComponentId\n StyledComponent.attrs = attrs\n StyledComponent.componentStyle = componentStyle\n StyledComponent.target = target\n\n return StyledComponent\n }\n\n return createStyledComponent\n}\n","// @flow\nimport hashStr from '../vendor/glamor/hash'\n\nimport type { RuleSet, NameGenerator, Flattener, Stringifier } from '../types'\nimport StyleSheet from './StyleSheet'\nimport { IS_BROWSER } from '../constants'\nimport isStyledComponent from '../utils/isStyledComponent'\n\nconst areStylesCacheable = IS_BROWSER\n\nconst isStaticRules = (rules: RuleSet, attrs?: Object): boolean => {\n for (let i = 0; i < rules.length; i += 1) {\n const rule = rules[i]\n\n // recursive case\n if (Array.isArray(rule) && !isStaticRules(rule)) {\n return false\n } else if (typeof rule === 'function' && !isStyledComponent(rule)) {\n // functions are allowed to be static if they're just being\n // used to get the classname of a nested styled component\n return false\n }\n }\n\n if (attrs !== undefined) {\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const key in attrs) {\n const value = attrs[key]\n if (typeof value === 'function') {\n return false\n }\n }\n }\n\n return true\n}\n\nconst isHMREnabled =\n typeof module !== 'undefined' &&\n module.hot &&\n process.env.NODE_ENV !== 'production'\n\n/*\n ComponentStyle is all the CSS-specific stuff, not\n the React-specific stuff.\n */\nexport default (\n nameGenerator: NameGenerator,\n flatten: Flattener,\n stringifyRules: Stringifier\n) => {\n /* combines hashStr (murmurhash) and nameGenerator for convenience */\n const generateRuleHash = (str: string) => nameGenerator(hashStr(str))\n\n class ComponentStyle {\n rules: RuleSet\n componentId: string\n isStatic: boolean\n lastClassName: ?string\n\n constructor(rules: RuleSet, attrs?: Object, componentId: string) {\n this.rules = rules\n this.isStatic = !isHMREnabled && isStaticRules(rules, attrs)\n this.componentId = componentId\n\n if (!StyleSheet.master.hasId(componentId)) {\n const placeholder =\n process.env.NODE_ENV !== 'production' ? [`.${componentId} {}`] : []\n\n StyleSheet.master.deferredInject(componentId, placeholder)\n }\n }\n\n /*\n * Flattens a rule set into valid CSS\n * Hashes it, wraps the whole chunk in a .hash1234 {}\n * Returns the hash to be injected on render()\n * */\n generateAndInjectStyles(executionContext: Object, styleSheet: StyleSheet) {\n const { isStatic, componentId, lastClassName } = this\n if (\n areStylesCacheable &&\n isStatic &&\n lastClassName !== undefined &&\n styleSheet.hasNameForId(componentId, ((lastClassName: any): string))\n ) {\n return lastClassName\n }\n\n const flatCSS = flatten(this.rules, executionContext)\n const name = generateRuleHash(this.componentId + flatCSS.join(''))\n\n if (!styleSheet.hasNameForId(componentId, name)) {\n const css = stringifyRules(flatCSS, `.${name}`)\n styleSheet.inject(this.componentId, css, name)\n }\n\n this.lastClassName = name\n return name\n }\n\n static generateName(str: string): string {\n return generateRuleHash(str)\n }\n }\n\n return ComponentStyle\n}\n"],"names":["i","getChildContext","componentWillMount","unsubscribeId","unsubscribeFromContext","length"],"mappings":"myLAyE8BA,ymPClD5BC,69PCqBAC,w0DCsBEC,iFAEAC,gtIC1DwBC,OAA0BL"}
1
+ {"version":3,"file":"styled-components.browser.cjs.min.js","sources":["../src/models/StyleTags.js","../src/models/StyleSheetManager.js","../src/models/ThemeProvider.js","../src/models/StyledComponent.js","../src/models/ComponentStyle.js"],"sourcesContent":["// @flow\n/* eslint-disable flowtype/object-type-delimiter */\n/* eslint-disable react/prop-types */\n\nimport React, { type Element } from 'react'\nimport { IS_BROWSER, DISABLE_SPEEDY, SC_ATTR } from '../constants'\nimport { type ExtractedComp } from '../utils/extractCompsFromCSS'\nimport { splitByRules } from '../utils/stringifyRules'\nimport getNonce from '../utils/nonce'\nimport once from '../utils/once'\n\nimport {\n type Names,\n addNameForId,\n resetIdNames,\n hasNameForId,\n stringifyNames,\n cloneNames,\n} from '../utils/styleNames'\n\nimport {\n sheetForTag,\n safeInsertRule,\n deleteRules,\n} from '../utils/insertRuleHelpers'\n\nexport interface Tag<T> {\n // $FlowFixMe: Doesn't seem to accept any combination w/ HTMLStyleElement for some reason\n styleTag: HTMLStyleElement | null;\n /* lists all ids of the tag */\n getIds(): string[];\n /* checks whether `name` is already injected for `id` */\n hasNameForId(id: string, name: string): boolean;\n /* inserts a marker to ensure the id's correct position in the sheet */\n insertMarker(id: string): T;\n /* inserts rules according to the ids markers */\n insertRules(id: string, cssRules: string[], name: ?string): void;\n /* removes all rules belonging to the id, keeping the marker around */\n removeRules(id: string): void;\n css(): string;\n toHTML(additionalAttrs: ?string): string;\n toElement(): Element<*>;\n clone(): Tag<T>;\n}\n\n/* this error is used for makeStyleTag */\nconst parentNodeUnmountedErr =\n process.env.NODE_ENV !== 'production'\n ? `\nTrying to insert a new style tag, but the given Node is unmounted!\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n`.trim()\n : ''\n\n/* this error is used for tags */\nconst throwCloneTagErr = () => {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `\nThe clone method cannot be used on the client!\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n`.trim()\n : ''\n )\n}\n\n/* this marker separates component styles and is important for rehydration */\nconst makeTextMarker = id => `\\n/* sc-component-id: ${id} */\\n`\n\n/* add up all numbers in array up until and including the index */\nconst addUpUntilIndex = (sizes: number[], index: number): number => {\n let totalUpToIndex = 0\n for (let i = 0; i <= index; i += 1) {\n totalUpToIndex += sizes[i]\n }\n\n return totalUpToIndex\n}\n\n/* create a new style tag after lastEl */\nconst makeStyleTag = (\n target: ?HTMLElement,\n tagEl: ?Node,\n insertBefore: ?boolean\n) => {\n const el = document.createElement('style')\n el.setAttribute(SC_ATTR, '')\n\n const nonce = getNonce()\n if (nonce) {\n el.setAttribute('nonce', nonce)\n }\n\n /* Work around insertRule quirk in EdgeHTML */\n el.appendChild(document.createTextNode(''))\n\n if (target && !tagEl) {\n /* Append to target when no previous element was passed */\n target.appendChild(el)\n } else {\n if (!tagEl || !target || !tagEl.parentNode) {\n throw new Error(parentNodeUnmountedErr)\n }\n\n /* Insert new style tag after the previous one */\n tagEl.parentNode.insertBefore(el, insertBefore ? tagEl : tagEl.nextSibling)\n }\n\n return el\n}\n\n/* takes a css factory function and outputs an html styled tag factory */\nconst wrapAsHtmlTag = (css: () => string, names: Names) => (\n additionalAttrs: ?string\n): string => {\n const nonce = getNonce()\n const attrs = [\n nonce && `nonce=\"${nonce}\"`,\n `${SC_ATTR}=\"${stringifyNames(names)}\"`,\n additionalAttrs,\n ]\n\n const htmlAttr = attrs.filter(Boolean).join(' ')\n return `<style ${htmlAttr}>${css()}</style>`\n}\n\n/* takes a css factory function and outputs an element factory */\nconst wrapAsElement = (css: () => string, names: Names) => () => {\n const props = {\n [SC_ATTR]: stringifyNames(names),\n }\n\n const nonce = getNonce()\n if (nonce) {\n // $FlowFixMe\n props.nonce = nonce\n }\n\n // eslint-disable-next-line react/no-danger\n return <style {...props} dangerouslySetInnerHTML={{ __html: css() }} />\n}\n\nconst getIdsFromMarkersFactory = (markers: Object) => (): string[] =>\n Object.keys(markers)\n\n/* speedy tags utilise insertRule */\nconst makeSpeedyTag = (\n el: HTMLStyleElement,\n getImportRuleTag: ?() => Tag<any>\n): Tag<number> => {\n const names: Names = (Object.create(null): Object)\n const markers = Object.create(null)\n const sizes: number[] = []\n\n const extractImport = getImportRuleTag !== undefined\n /* indicates whther getImportRuleTag was called */\n let usedImportRuleTag = false\n\n const insertMarker = id => {\n const prev = markers[id]\n if (prev !== undefined) {\n return prev\n }\n\n markers[id] = sizes.length\n sizes.push(0)\n resetIdNames(names, id)\n\n return markers[id]\n }\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id)\n const sheet = sheetForTag(el)\n const insertIndex = addUpUntilIndex(sizes, marker)\n\n let injectedRules = 0\n const importRules = []\n const cssRulesSize = cssRules.length\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const cssRule = cssRules[i]\n let mayHaveImport = extractImport /* @import rules are reordered to appear first */\n if (mayHaveImport && cssRule.indexOf('@import') !== -1) {\n importRules.push(cssRule)\n } else if (safeInsertRule(sheet, cssRule, insertIndex + injectedRules)) {\n mayHaveImport = false\n injectedRules += 1\n }\n }\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules)\n }\n\n sizes[marker] += injectedRules /* add up no of injected rules */\n addNameForId(names, id, name)\n }\n\n const removeRules = id => {\n const marker = markers[id]\n if (marker === undefined) return\n\n const size = sizes[marker]\n const sheet = sheetForTag(el)\n const removalIndex = addUpUntilIndex(sizes, marker)\n deleteRules(sheet, removalIndex, size)\n sizes[marker] = 0\n resetIdNames(names, id)\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`)\n }\n }\n\n const css = () => {\n const { cssRules } = sheetForTag(el)\n let str = ''\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += makeTextMarker(id)\n const marker = markers[id]\n const end = addUpUntilIndex(sizes, marker)\n const size = sizes[marker]\n for (let i = end - size; i < end; i += 1) {\n const rule = cssRules[i]\n if (rule !== undefined) {\n str += rule.cssText\n }\n }\n }\n\n return str\n }\n\n return {\n styleTag: el,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n css,\n toHTML: wrapAsHtmlTag(css, names),\n toElement: wrapAsElement(css, names),\n clone: throwCloneTagErr,\n }\n}\n\nconst makeBrowserTag = (\n el: HTMLStyleElement,\n getImportRuleTag: ?() => Tag<any>\n): Tag<Text> => {\n const names = (Object.create(null): Object)\n const markers = Object.create(null)\n\n const extractImport = getImportRuleTag !== undefined\n const makeTextNode = id => document.createTextNode(makeTextMarker(id))\n\n /* indicates whther getImportRuleTag was called */\n let usedImportRuleTag = false\n\n const insertMarker = id => {\n const prev = markers[id]\n if (prev !== undefined) {\n return prev\n }\n\n markers[id] = makeTextNode(id)\n el.appendChild(markers[id])\n names[id] = Object.create(null)\n\n return markers[id]\n }\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id)\n const importRules = []\n const cssRulesSize = cssRules.length\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const rule = cssRules[i]\n let mayHaveImport = extractImport\n if (mayHaveImport && rule.indexOf('@import') !== -1) {\n importRules.push(rule)\n } else {\n mayHaveImport = false\n const separator = i === cssRulesSize - 1 ? '' : ' '\n marker.appendData(`${rule}${separator}`)\n }\n }\n\n addNameForId(names, id, name)\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules)\n }\n }\n\n const removeRules = id => {\n const marker = markers[id]\n if (marker === undefined) return\n\n /* create new empty text node and replace the current one */\n const newMarker = makeTextNode(id)\n el.replaceChild(newMarker, marker)\n markers[id] = newMarker\n resetIdNames(names, id)\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`)\n }\n }\n\n const css = () => {\n let str = ''\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += markers[id].data\n }\n return str\n }\n\n return {\n styleTag: el,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n css,\n toHTML: wrapAsHtmlTag(css, names),\n toElement: wrapAsElement(css, names),\n clone: throwCloneTagErr,\n }\n}\n\nconst makeServerTagInternal = (namesArg, markersArg): Tag<[string]> => {\n const names =\n namesArg === undefined ? (Object.create(null): Object) : namesArg\n const markers = markersArg === undefined ? Object.create(null) : markersArg\n\n const insertMarker = id => {\n const prev = markers[id]\n if (prev !== undefined) {\n return prev\n }\n\n return (markers[id] = [''])\n }\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id)\n marker[0] += cssRules.join(' ')\n addNameForId(names, id, name)\n }\n\n const removeRules = id => {\n const marker = markers[id]\n if (marker === undefined) return\n marker[0] = ''\n resetIdNames(names, id)\n }\n\n const css = () => {\n let str = ''\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n const cssForId = markers[id][0]\n if (cssForId) {\n str += makeTextMarker(id) + cssForId\n }\n }\n return str\n }\n\n const clone = () => {\n const namesClone = cloneNames(names)\n const markersClone = Object.create(null)\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n markersClone[id] = [markers[id][0]]\n }\n\n return makeServerTagInternal(namesClone, markersClone)\n }\n\n const tag = {\n styleTag: null,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n css,\n toHTML: wrapAsHtmlTag(css, names),\n toElement: wrapAsElement(css, names),\n clone,\n }\n\n return tag\n}\n\nconst makeServerTag = (): Tag<[string]> => makeServerTagInternal()\n\nexport const makeTag = (\n target: ?HTMLElement,\n tagEl: ?HTMLStyleElement,\n forceServer?: boolean,\n insertBefore?: boolean,\n getImportRuleTag?: () => Tag<any>\n): Tag<any> => {\n if (IS_BROWSER && !forceServer) {\n const el = makeStyleTag(target, tagEl, insertBefore)\n if (DISABLE_SPEEDY) {\n return makeBrowserTag(el, getImportRuleTag)\n } else {\n return makeSpeedyTag(el, getImportRuleTag)\n }\n }\n\n return makeServerTag()\n}\n\n/* wraps a given tag so that rehydration is performed once when necessary */\nexport const makeRehydrationTag = (\n tag: Tag<any>,\n els: HTMLStyleElement[],\n extracted: ExtractedComp[],\n names: string[],\n immediateRehydration: boolean\n): Tag<any> => {\n /* rehydration function that adds all rules to the new tag */\n const rehydrate = once(() => {\n /* add all extracted components to the new tag */\n for (let i = 0; i < extracted.length; i += 1) {\n const { componentId, cssFromDOM } = extracted[i]\n const cssRules = splitByRules(cssFromDOM)\n tag.insertRules(componentId, cssRules)\n }\n\n /* remove old HTMLStyleElements, since they have been rehydrated */\n for (let i = 0; i < els.length; i += 1) {\n const el = els[i]\n if (el.parentNode) {\n el.parentNode.removeChild(el)\n }\n }\n })\n\n if (immediateRehydration) rehydrate()\n\n return {\n ...tag,\n /* add rehydration hook to insertion methods */\n insertMarker: id => {\n rehydrate()\n return tag.insertMarker(id)\n },\n insertRules: (id, cssRules, name) => {\n rehydrate()\n return tag.insertRules(id, cssRules, name)\n },\n }\n}\n","// @flow\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport StyleSheet from './StyleSheet'\nimport ServerStyleSheet from './ServerStyleSheet'\nimport { CONTEXT_KEY } from '../constants'\n\n/* this error is used for makeStyleTag */\nconst targetPropErr =\n process.env.NODE_ENV !== 'production'\n ? `\nThe StyleSheetManager expects a valid target or sheet prop!\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n`.trim()\n : ''\n\ntype Props = {\n sheet?: StyleSheet | null,\n target?: HTMLElement | null,\n}\n\nclass StyleSheetManager extends Component<Props, void> {\n sheetInstance: StyleSheet\n\n getChildContext() {\n return { [CONTEXT_KEY]: this.sheetInstance }\n }\n\n componentWillMount() {\n if (this.props.sheet) {\n this.sheetInstance = this.props.sheet\n } else if (this.props.target) {\n this.sheetInstance = new StyleSheet(this.props.target)\n } else {\n throw new Error(targetPropErr)\n }\n }\n\n render() {\n /* eslint-disable react/prop-types */\n // Flow v0.43.1 will report an error accessing the `children` property,\n // but v0.47.0 will not. It is necessary to use a type cast instead of\n // a \"fixme\" comment to satisfy both Flow versions.\n return React.Children.only((this.props: any).children)\n }\n}\n\nStyleSheetManager.childContextTypes = {\n [CONTEXT_KEY]: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]).isRequired,\n}\n\nStyleSheetManager.propTypes = {\n sheet: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]),\n target: PropTypes.shape({\n appendChild: PropTypes.func.isRequired,\n }),\n}\n\nexport default StyleSheetManager\n","// @flow\nimport React, { Component, type Element } from 'react'\nimport PropTypes from 'prop-types'\nimport createBroadcast from '../utils/create-broadcast'\nimport type { Broadcast } from '../utils/create-broadcast'\nimport once from '../utils/once'\n\n// NOTE: DO NOT CHANGE, changing this is a semver major change!\nexport const CHANNEL = '__styled-components__'\nexport const CHANNEL_NEXT = `${CHANNEL}next__`\n\nexport const CONTEXT_CHANNEL_SHAPE = PropTypes.shape({\n getTheme: PropTypes.func,\n subscribe: PropTypes.func,\n unsubscribe: PropTypes.func,\n})\n\nexport type Theme = { [key: string]: mixed }\ntype ThemeProviderProps = {|\n children?: Element<any>,\n theme: Theme | ((outerTheme: Theme) => void),\n|}\n\nlet warnChannelDeprecated\nif (process.env.NODE_ENV !== 'production') {\n warnChannelDeprecated = once(() => {\n // eslint-disable-next-line no-console\n console.error(\n `Warning: Usage of \\`context.${CHANNEL}\\` as a function is deprecated. It will be replaced with the object on \\`.context.${CHANNEL_NEXT}\\` in a future version.`\n )\n })\n}\n\nconst isFunction = test => typeof test === 'function'\n\n/**\n * Provide a theme to an entire react component tree via context and event listeners (have to do\n * both context and event emitter as pure components block context updates)\n */\nclass ThemeProvider extends Component<ThemeProviderProps, void> {\n getTheme: (theme?: Theme | ((outerTheme: Theme) => void)) => Theme\n outerTheme: Theme\n unsubscribeToOuterId: string\n props: ThemeProviderProps\n broadcast: Broadcast\n unsubscribeToOuterId: number = -1\n\n constructor() {\n super()\n this.getTheme = this.getTheme.bind(this)\n }\n\n componentWillMount() {\n // If there is a ThemeProvider wrapper anywhere around this theme provider, merge this theme\n // with the outer theme\n const outerContext = this.context[CHANNEL_NEXT]\n if (outerContext !== undefined) {\n this.unsubscribeToOuterId = outerContext.subscribe(theme => {\n this.outerTheme = theme\n\n if (this.broadcast !== undefined) {\n this.publish(this.props.theme)\n }\n })\n }\n\n this.broadcast = createBroadcast(this.getTheme())\n }\n\n getChildContext() {\n return {\n ...this.context,\n [CHANNEL_NEXT]: {\n getTheme: this.getTheme,\n subscribe: this.broadcast.subscribe,\n unsubscribe: this.broadcast.unsubscribe,\n },\n [CHANNEL]: subscriber => {\n if (process.env.NODE_ENV !== 'production') {\n warnChannelDeprecated()\n }\n\n // Patch the old `subscribe` provide via `CHANNEL` for older clients.\n const unsubscribeId = this.broadcast.subscribe(subscriber)\n return () => this.broadcast.unsubscribe(unsubscribeId)\n },\n }\n }\n\n componentWillReceiveProps(nextProps: ThemeProviderProps) {\n if (this.props.theme !== nextProps.theme) {\n this.publish(nextProps.theme)\n }\n }\n\n componentWillUnmount() {\n if (this.unsubscribeToOuterId !== -1) {\n this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeToOuterId)\n }\n }\n\n // Get the theme from the props, supporting both (outerTheme) => {} as well as object notation\n getTheme(passedTheme: (outerTheme: Theme) => void | Theme) {\n const theme = passedTheme || this.props.theme\n if (isFunction(theme)) {\n const mergedTheme = theme(this.outerTheme)\n if (\n process.env.NODE_ENV !== 'production' &&\n (mergedTheme === null ||\n Array.isArray(mergedTheme) ||\n typeof mergedTheme !== 'object')\n ) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? '[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!'\n : ''\n )\n }\n return mergedTheme\n }\n if (theme === null || Array.isArray(theme) || typeof theme !== 'object') {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? '[ThemeProvider] Please make your theme prop an object'\n : ''\n )\n }\n return { ...this.outerTheme, ...(theme: Object) }\n }\n\n publish(theme: Theme | ((outerTheme: Theme) => void)) {\n this.broadcast.publish(this.getTheme(theme))\n }\n\n render() {\n if (!this.props.children) {\n return null\n }\n return React.Children.only(this.props.children)\n }\n}\n\nThemeProvider.childContextTypes = {\n [CHANNEL]: PropTypes.func, // legacy\n [CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,\n}\nThemeProvider.contextTypes = {\n [CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,\n}\n\nexport default ThemeProvider\n","// @flow\n\nimport hoist from 'hoist-non-react-statics'\nimport PropTypes from 'prop-types'\nimport { Component, createElement } from 'react'\nimport { CONTEXT_KEY } from '../constants'\nimport createWarnTooManyClasses from '../utils/createWarnTooManyClasses'\nimport determineTheme from '../utils/determineTheme'\nimport escape from '../utils/escape'\nimport generateDisplayName from '../utils/generateDisplayName'\nimport getComponentName from '../utils/getComponentName'\nimport isStyledComponent from '../utils/isStyledComponent'\nimport isTag from '../utils/isTag'\nimport validAttr from '../utils/validAttr'\nimport hasInInheritanceChain from '../utils/hasInInheritanceChain'\nimport ServerStyleSheet from './ServerStyleSheet'\nimport StyleSheet from './StyleSheet'\nimport { CHANNEL, CHANNEL_NEXT, CONTEXT_CHANNEL_SHAPE } from './ThemeProvider'\n\nimport type { Theme } from './ThemeProvider'\nimport type { RuleSet, Target } from '../types'\n\n// HACK for generating all static styles without needing to allocate\n// an empty execution context every single time...\nconst STATIC_EXECUTION_CONTEXT = {}\n\ntype BaseState = {\n theme?: ?Theme,\n generatedClassName?: string,\n}\n\nexport default (ComponentStyle: Function, constructWithOptions: Function) => {\n const identifiers = {}\n\n /* We depend on components having unique IDs */\n const generateId = (_displayName: string, parentComponentId: string) => {\n const displayName =\n typeof _displayName !== 'string' ? 'sc' : escape(_displayName)\n\n /**\n * This ensures uniqueness if two components happen to share\n * the same displayName.\n */\n const nr = (identifiers[displayName] || 0) + 1\n identifiers[displayName] = nr\n\n const componentId = `${displayName}-${ComponentStyle.generateName(\n displayName + nr\n )}`\n\n return parentComponentId !== undefined\n ? `${parentComponentId}-${componentId}`\n : componentId\n }\n\n // $FlowFixMe\n class BaseStyledComponent extends Component<*, BaseState> {\n static target: Target\n static styledComponentId: string\n static attrs: Object\n static componentStyle: Object\n static defaultProps: Object\n static warnTooManyClasses: Function\n\n attrs = {}\n state = {\n theme: null,\n generatedClassName: '',\n }\n unsubscribeId: number = -1\n\n unsubscribeFromContext() {\n if (this.unsubscribeId !== -1) {\n this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId)\n }\n }\n\n buildExecutionContext(theme: any, props: any) {\n const { attrs } = this.constructor\n const context = { ...props, theme }\n if (attrs === undefined) {\n return context\n }\n\n this.attrs = Object.keys(attrs).reduce((acc, key) => {\n const attr = attrs[key]\n // eslint-disable-next-line no-param-reassign\n acc[key] =\n typeof attr === 'function' && !hasInInheritanceChain(attr, Component)\n ? attr(context)\n : attr\n return acc\n }, {})\n\n return { ...context, ...this.attrs }\n }\n\n generateAndInjectStyles(theme: any, props: any) {\n const { attrs, componentStyle, warnTooManyClasses } = this.constructor\n const styleSheet = this.context[CONTEXT_KEY] || StyleSheet.master\n\n // staticaly styled-components don't need to build an execution context object,\n // and shouldn't be increasing the number of class names\n if (componentStyle.isStatic && attrs === undefined) {\n return componentStyle.generateAndInjectStyles(\n STATIC_EXECUTION_CONTEXT,\n styleSheet\n )\n } else {\n const executionContext = this.buildExecutionContext(theme, props)\n const className = componentStyle.generateAndInjectStyles(\n executionContext,\n styleSheet\n )\n\n if (\n process.env.NODE_ENV !== 'production' &&\n warnTooManyClasses !== undefined\n ) {\n warnTooManyClasses(className)\n }\n\n return className\n }\n }\n\n componentWillMount() {\n const { componentStyle } = this.constructor\n const styledContext = this.context[CHANNEL_NEXT]\n\n // If this is a staticaly-styled component, we don't need to the theme\n // to generate or build styles.\n if (componentStyle.isStatic) {\n const generatedClassName = this.generateAndInjectStyles(\n STATIC_EXECUTION_CONTEXT,\n this.props\n )\n this.setState({ generatedClassName })\n // If there is a theme in the context, subscribe to the event emitter. This\n // is necessary due to pure components blocking context updates, this circumvents\n // that by updating when an event is emitted\n } else if (styledContext !== undefined) {\n const { subscribe } = styledContext\n this.unsubscribeId = subscribe(nextTheme => {\n // This will be called once immediately\n const theme = determineTheme(\n this.props,\n nextTheme,\n this.constructor.defaultProps\n )\n const generatedClassName = this.generateAndInjectStyles(\n theme,\n this.props\n )\n\n this.setState({ theme, generatedClassName })\n })\n } else {\n // eslint-disable-next-line react/prop-types\n const theme = this.props.theme || {}\n const generatedClassName = this.generateAndInjectStyles(\n theme,\n this.props\n )\n this.setState({ theme, generatedClassName })\n }\n }\n\n componentWillReceiveProps(nextProps: {\n theme?: Theme,\n [key: string]: any,\n }) {\n // If this is a statically-styled component, we don't need to listen to\n // props changes to update styles\n const { componentStyle } = this.constructor\n if (componentStyle.isStatic) {\n return\n }\n\n this.setState(prevState => {\n const theme = determineTheme(\n nextProps,\n prevState.theme,\n this.constructor.defaultProps\n )\n const generatedClassName = this.generateAndInjectStyles(\n theme,\n nextProps\n )\n\n return { theme, generatedClassName }\n })\n }\n\n componentWillUnmount() {\n this.unsubscribeFromContext()\n }\n\n render() {\n // eslint-disable-next-line react/prop-types\n const { innerRef } = this.props\n const { generatedClassName } = this.state\n const { styledComponentId, target } = this.constructor\n\n const isTargetTag = isTag(target)\n\n const className = [\n // eslint-disable-next-line react/prop-types\n this.props.className,\n styledComponentId,\n this.attrs.className,\n generatedClassName,\n ]\n .filter(Boolean)\n .join(' ')\n\n const baseProps: any = {\n ...this.attrs,\n className,\n }\n\n if (isStyledComponent(target)) {\n baseProps.innerRef = innerRef\n } else {\n baseProps.ref = innerRef\n }\n\n const propsForElement = Object.keys(this.props).reduce(\n (acc, propName) => {\n // Don't pass through non HTML tags through to HTML elements\n // always omit innerRef\n if (\n propName !== 'innerRef' &&\n propName !== 'className' &&\n (!isTargetTag || validAttr(propName))\n ) {\n // eslint-disable-next-line no-param-reassign\n acc[propName] = this.props[propName]\n }\n\n return acc\n },\n baseProps\n )\n\n return createElement(target, propsForElement)\n }\n }\n\n const createStyledComponent = (\n target: Target,\n options: Object,\n rules: RuleSet\n ) => {\n const {\n isClass = !isTag(target),\n displayName = generateDisplayName(target),\n componentId = generateId(options.displayName, options.parentComponentId),\n ParentComponent = BaseStyledComponent,\n rules: extendingRules,\n attrs,\n } = options\n\n const styledComponentId =\n options.displayName && options.componentId\n ? `${escape(options.displayName)}-${options.componentId}`\n : options.componentId || componentId\n\n const componentStyle = new ComponentStyle(\n extendingRules === undefined ? rules : extendingRules.concat(rules),\n attrs,\n styledComponentId\n )\n\n class StyledComponent extends ParentComponent {\n static attrs = attrs\n static componentStyle = componentStyle\n static displayName = displayName\n static styledComponentId = styledComponentId\n static target = target\n\n static contextTypes = {\n [CHANNEL]: PropTypes.func,\n [CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,\n [CONTEXT_KEY]: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]),\n }\n\n static withComponent(tag: Target) {\n const { componentId: previousComponentId, ...optionsToCopy } = options\n\n const newComponentId =\n previousComponentId &&\n `${previousComponentId}-${\n isTag(tag) ? tag : escape(getComponentName(tag))\n }`\n\n const newOptions = {\n ...optionsToCopy,\n componentId: newComponentId,\n ParentComponent: StyledComponent,\n }\n\n return createStyledComponent(tag, newOptions, rules)\n }\n\n static get extend() {\n const {\n rules: rulesFromOptions,\n componentId: parentComponentId,\n ...optionsToCopy\n } = options\n\n const newRules =\n rulesFromOptions === undefined\n ? rules\n : rulesFromOptions.concat(rules)\n\n const newOptions = {\n ...optionsToCopy,\n rules: newRules,\n parentComponentId,\n ParentComponent: StyledComponent,\n }\n\n return constructWithOptions(createStyledComponent, target, newOptions)\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n StyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName)\n }\n\n if (isClass) {\n hoist(StyledComponent, target, {\n // all SC-specific things should not be hoisted\n attrs: true,\n componentStyle: true,\n displayName: true,\n extend: true,\n styledComponentId: true,\n target: true,\n warnTooManyClasses: true,\n withComponent: true,\n })\n }\n\n return StyledComponent\n }\n\n return createStyledComponent\n}\n","// @flow\nimport hashStr from '../vendor/glamor/hash'\n\nimport type { RuleSet, NameGenerator, Flattener, Stringifier } from '../types'\nimport StyleSheet from './StyleSheet'\nimport { IS_BROWSER } from '../constants'\nimport isStyledComponent from '../utils/isStyledComponent'\n\nconst areStylesCacheable = IS_BROWSER\n\nconst isStaticRules = (rules: RuleSet, attrs?: Object): boolean => {\n for (let i = 0; i < rules.length; i += 1) {\n const rule = rules[i]\n\n // recursive case\n if (Array.isArray(rule) && !isStaticRules(rule)) {\n return false\n } else if (typeof rule === 'function' && !isStyledComponent(rule)) {\n // functions are allowed to be static if they're just being\n // used to get the classname of a nested styled component\n return false\n }\n }\n\n if (attrs !== undefined) {\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const key in attrs) {\n const value = attrs[key]\n if (typeof value === 'function') {\n return false\n }\n }\n }\n\n return true\n}\n\nconst isHMREnabled =\n typeof module !== 'undefined' &&\n module.hot &&\n process.env.NODE_ENV !== 'production'\n\n/*\n ComponentStyle is all the CSS-specific stuff, not\n the React-specific stuff.\n */\nexport default (\n nameGenerator: NameGenerator,\n flatten: Flattener,\n stringifyRules: Stringifier\n) => {\n /* combines hashStr (murmurhash) and nameGenerator for convenience */\n const generateRuleHash = (str: string) => nameGenerator(hashStr(str))\n\n class ComponentStyle {\n rules: RuleSet\n componentId: string\n isStatic: boolean\n lastClassName: ?string\n\n constructor(rules: RuleSet, attrs?: Object, componentId: string) {\n this.rules = rules\n this.isStatic = !isHMREnabled && isStaticRules(rules, attrs)\n this.componentId = componentId\n\n if (!StyleSheet.master.hasId(componentId)) {\n const placeholder =\n process.env.NODE_ENV !== 'production' ? [`.${componentId} {}`] : []\n\n StyleSheet.master.deferredInject(componentId, placeholder)\n }\n }\n\n /*\n * Flattens a rule set into valid CSS\n * Hashes it, wraps the whole chunk in a .hash1234 {}\n * Returns the hash to be injected on render()\n * */\n generateAndInjectStyles(executionContext: Object, styleSheet: StyleSheet) {\n const { isStatic, componentId, lastClassName } = this\n if (\n areStylesCacheable &&\n isStatic &&\n lastClassName !== undefined &&\n styleSheet.hasNameForId(componentId, ((lastClassName: any): string))\n ) {\n return lastClassName\n }\n\n const flatCSS = flatten(this.rules, executionContext)\n const name = generateRuleHash(this.componentId + flatCSS.join(''))\n\n if (!styleSheet.hasNameForId(componentId, name)) {\n const css = stringifyRules(flatCSS, `.${name}`)\n styleSheet.inject(this.componentId, css, name)\n }\n\n this.lastClassName = name\n return name\n }\n\n static generateName(str: string): string {\n return generateRuleHash(str)\n }\n }\n\n return ComponentStyle\n}\n"],"names":["i","getChildContext","componentWillMount","unsubscribeId","unsubscribeFromContext","length"],"mappings":"myLAyE8BA,ymPClD5BC,69PCqBAC,w0DCgBEC,iFAEAC,8yICpDwBC,OAA0BL"}
@@ -1655,20 +1655,14 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
1655
1655
  var generateId = function generateId(_displayName, parentComponentId) {
1656
1656
  var displayName = typeof _displayName !== 'string' ? 'sc' : escape(_displayName);
1657
1657
 
1658
- var componentId = void 0;
1659
-
1660
1658
  /**
1661
- * only fall back to hashing the component injection order if
1662
- * a proper displayName isn't provided by the babel plugin
1659
+ * This ensures uniqueness if two components happen to share
1660
+ * the same displayName.
1663
1661
  */
1664
- if (!_displayName) {
1665
- var nr = (identifiers[displayName] || 0) + 1;
1666
- identifiers[displayName] = nr;
1662
+ var nr = (identifiers[displayName] || 0) + 1;
1663
+ identifiers[displayName] = nr;
1667
1664
 
1668
- componentId = displayName + '-' + ComponentStyle.generateName(displayName + nr);
1669
- } else {
1670
- componentId = displayName + '-' + ComponentStyle.generateName(displayName);
1671
- }
1665
+ var componentId = displayName + '-' + ComponentStyle.generateName(displayName + nr);
1672
1666
 
1673
1667
  return parentComponentId !== undefined ? parentComponentId + '-' + componentId : componentId;
1674
1668
  };
@@ -1856,7 +1850,7 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
1856
1850
  attrs = options.attrs;
1857
1851
 
1858
1852
 
1859
- var styledComponentId = options.displayName && options.componentId ? escape(options.displayName) + '-' + options.componentId : componentId;
1853
+ var styledComponentId = options.displayName && options.componentId ? escape(options.displayName) + '-' + options.componentId : options.componentId || componentId;
1860
1854
 
1861
1855
  var componentStyle = new ComponentStyle(extendingRules === undefined ? rules : extendingRules.concat(rules), attrs, styledComponentId);
1862
1856
 
@@ -1905,6 +1899,11 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
1905
1899
  return StyledComponent;
1906
1900
  }(ParentComponent);
1907
1901
 
1902
+ StyledComponent.attrs = attrs;
1903
+ StyledComponent.componentStyle = componentStyle;
1904
+ StyledComponent.displayName = displayName;
1905
+ StyledComponent.styledComponentId = styledComponentId;
1906
+ StyledComponent.target = target;
1908
1907
  StyledComponent.contextTypes = (_StyledComponent$cont = {}, _StyledComponent$cont[CHANNEL] = PropTypes.func, _StyledComponent$cont[CHANNEL_NEXT] = CONTEXT_CHANNEL_SHAPE, _StyledComponent$cont[CONTEXT_KEY] = PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet), PropTypes.instanceOf(ServerStyleSheet)]), _StyledComponent$cont);
1909
1908
 
1910
1909
 
@@ -1912,15 +1911,19 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
1912
1911
  StyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName);
1913
1912
  }
1914
1913
 
1915
- if (isClass) hoist(StyledComponent, target);
1916
-
1917
- // we do this after hoisting to ensure we're overwriting existing
1918
- // rules when wrapping another styled component class
1919
- StyledComponent.displayName = displayName;
1920
- StyledComponent.styledComponentId = styledComponentId;
1921
- StyledComponent.attrs = attrs;
1922
- StyledComponent.componentStyle = componentStyle;
1923
- StyledComponent.target = target;
1914
+ if (isClass) {
1915
+ hoist(StyledComponent, target, {
1916
+ // all SC-specific things should not be hoisted
1917
+ attrs: true,
1918
+ componentStyle: true,
1919
+ displayName: true,
1920
+ extend: true,
1921
+ styledComponentId: true,
1922
+ target: true,
1923
+ warnTooManyClasses: true,
1924
+ withComponent: true
1925
+ });
1926
+ }
1924
1927
 
1925
1928
  return StyledComponent;
1926
1929
  };