flopflip
Version:
A feature toggle wrapper to use LaunchDarkly with React Redux
3 lines (2 loc) • 27.5 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("redux"),require("react"),require("prop-types"),require("react-redux")):"function"==typeof define&&define.amd?define(["exports","redux","react","prop-types","react-redux"],e):e(t.flopflip={},t.redux,t.React,t.PropTypes,t["react-redux"])}(this,function(t,e,n,r,o){"use strict";function u(t,e){return e={exports:{}},t(e,e.exports),e.exports}function i(t){return lt.btoa(unescape(encodeURIComponent(t)))}function a(t,e,n,r){var o,u,i=e.replace(n,"").replace(r,"");switch(t.kind){case"exact":u=e,o=new RegExp("^"+gt(t.url)+"/?$");break;case"canonical":u=i,o=new RegExp("^"+gt(t.url)+"/?$");break;case"substring":u=i,o=new RegExp(".*"+gt(t.substring)+".*$");break;case"regex":u=i,o=new RegExp(t.pattern);break;default:return!1}return o.test(u)}function f(t,e){for(var n=[],r=0;r<e.length;r++)for(var o=t.target,u=e[r],i=u.selector,a=document.querySelectorAll(i);o&&a.length>0;){for(var f=0;f<a.length;f++)o===a[f]&&n.push(u);o=o.parentNode}return n}function c(t,e){var n=new XMLHttpRequest;return n.addEventListener("load",function(){200===n.status&&n.getResponseHeader("Content-type")===bt?e(null,JSON.parse(n.responseText)):e(n.statusText)}),n.addEventListener("error",function(){e(n.statusText)}),n.open("GET",t),n.send(),n}function l(t){var e=st.clone(t);return e.key&&(e.key=e.key.toString()),e}function s(t,e,n,r){var o=-1,u=t?t.length:0;for(r&&u&&(n=t[++o]);++o<u;)n=e(n,t[o],o,t);return n}function p(t){return t.split("")}function d(t){return t.match(St)||[]}function h(t){return Zt.test(t)}function g(t){return Bt.test(t)}function y(t){return h(t)?v(t):p(t)}function v(t){return t.match($t)||[]}function b(t){return t.match(Gt)||[]}function x(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var u=Array(o);++r<o;)u[r]=t[r+e];return u}function w(t){if("string"==typeof t)return t;if(E(t))return ee?ee.call(t):"";var e=t+"";return"0"==e&&1/t==-Et?"-0":e}function _(t,e,n){var r=t.length;return n=void 0===n?r:n,!e&&n>=r?t:x(t,e,n)}function m(t){return!!t&&"object"==typeof t}function E(t){return"symbol"==typeof t||m(t)&&Wt.call(t)==Ot}function O(t){return null==t?"":w(t)}function S(t){return re(O(t).toLowerCase())}function j(t){return(t=O(t))&&t.replace(jt,Vt).replace(Jt,"")}function k(t,e,n){return t=O(t),void 0===(e=n?void 0:e)?g(t)?b(t):d(t):t.match(e)||[]}function T(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce(function(t,e){return function(){return t(e.apply(void 0,arguments))}})}function A(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function C(t,e){return!!(t?t.length:0)&&R(t,e,0)>-1}function U(t,e,n){for(var r=-1,o=t?t.length:0;++r<o;)if(n(e,t[r]))return!0;return!1}function F(t,e){for(var n=-1,r=t?t.length:0,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}function L(t,e,n,r){for(var o=t.length,u=n+(r?1:-1);r?u--:++u<o;)if(e(t[u],u,t))return u;return-1}function R(t,e,n){if(e!==e)return L(t,P,n);for(var r=n-1,o=t.length;++r<o;)if(t[r]===e)return r;return-1}function P(t){return t!==t}function I(t){return function(e){return t(e)}}function N(t,e){return t.has(e)}function D(t,e){return null==t?void 0:t[e]}function M(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function q(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function z(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function J(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function $(t){var e=-1,n=t?t.length:0;for(this.__data__=new J;++e<n;)this.add(t[e])}function G(t,e){for(var n=t.length;n--;)if(Q(t[n][0],e))return n;return-1}function Z(t,e,n){for(var r=n?U:C,o=t[0].length,u=t.length,i=u,a=Array(u),f=1/0,c=[];i--;){var l=t[i];i&&e&&(l=F(l,I(e))),f=pn(l.length,f),a[i]=!n&&(e||o>=120&&l.length>=120)?new $(i&&l):void 0}l=t[0];var s=-1,p=a[0];t:for(;++s<o&&c.length<f;){var d=l[s],h=e?e(d):d;if(d=n||0!==d?d:0,!(p?N(p,h):r(c,h,n))){for(i=u;--i;){var g=a[i];if(!(g?N(g,h):r(t[i],h,n)))continue t}p&&p.push(h),c.push(d)}}return c}function B(t){return!(!ot(t)||V(t))&&(nt(t)||M(t)?cn:Xe).test(W(t))}function H(t){return et(t)?t:[]}function K(t,e){var n=t.__data__;return X(e)?n["string"==typeof e?"string":"hash"]:n.map}function Y(t,e){var n=D(t,e);return B(n)?n:void 0}function X(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function V(t){return!!on&&on in t}function W(t){if(null!=t){try{return un.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Q(t,e){return t===e||t!==t&&e!==e}function tt(t){return null!=t&&rt(t.length)&&!nt(t)}function et(t){return ut(t)&&tt(t)}function nt(t){var e=ot(t)?fn.call(t):"";return e==He||e==Ke}function rt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Be}function ot(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function ut(t){return!!t&&"object"==typeof t}var it="default"in n?n.default:n;r=r&&r.hasOwnProperty("default")?r.default:r;var at,ft,ct="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},lt=u(function(t,e){!function(){function t(t){this.message=t}var n=e,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";(t.prototype=new Error).name="InvalidCharacterError",n.btoa||(n.btoa=function(e){for(var n,o,u=String(e),i=0,a=r,f="";u.charAt(0|i)||(a="=",i%1);f+=a.charAt(63&n>>8-i%1*8)){if((o=u.charCodeAt(i+=.75))>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|o}return f}),n.atob||(n.atob=function(e){var n=String(e).replace(/=+$/,"");if(n.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var o,u,i=0,a=0,f="";u=n.charAt(a++);~u&&(o=i%4?64*o+u:u,i++%4)?f+=String.fromCharCode(255&o>>(-2*i&6)):0)u=r.indexOf(u);return f})}()}),st={btoa:i,base64URLEncode:function(t){return i(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},clone:function(t){return JSON.parse(JSON.stringify(t))},modifications:function(t,e){var n={};if(!t||!e)return{};for(var r in t)t.hasOwnProperty(r)&&e[r]!==t[r]&&(n[r]={previous:t[r],current:e[r]});return n}},pt=function(t){var e={},n=[],r=!0;return e.enqueue=function(t){n.push(t)},e.flush=function(o,u){var i=2e3-t.length,a=[];if(!o)return r&&console&&console.warn&&console.warn("Be sure to call `identify` in the LaunchDarkly client: http://docs.launchdarkly.com/docs/running-an-ab-test#include-the-client-side-snippet"),!1;for(r=!1;i>0&&n.length>0;){var f=n.pop();f.user=o,(i-=st.base64URLEncode(JSON.stringify(f)).length)<0&&a.length>0?n.push(f):a.push(f)}if(a.length>0){var c=t+"?d="+st.base64URLEncode(JSON.stringify(a));if("withCredentials"in new XMLHttpRequest){var l=new XMLHttpRequest;l.open("GET",c,!u),l.send()}else(new Image).src=c}return n.length>0&&(u?e.flush(o,u):setTimeout(function(){e.flush(o)},0)),!1},e},dt=function(){var t={},e={};return t.on=function(t,n,r){e[t]=e[t]||[],e[t]=e[t].concat({handler:n,context:r})},t.off=function(t,n,r){if(e[t])for(var o=0;o<e[t].length;o++)e[t][o].handler===n&&e[t][o].context===r&&(e[t]=e[t].slice(0,o).concat(e[t].slice(o+1)))},t.emit=function(t){if(e[t])for(var n=0;n<e[t].length;n++)e[t][n].handler.apply(e[t][n].context,Array.prototype.slice.call(arguments,1))},t},ht=/[|\\{}()[\]^$+*?.]/g,gt=function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(ht,"\\$&")},yt=function(t,e){for(var n={},t=t,r=null,o=[],u=0;u<t.length;u++)for(var i=t[u],c=i.urls||[],l=0;l<c.length;l++)if(a(c[l],location.href,location.search,location.hash)){"pageview"===i.kind?e("pageview",i):(o.push(i),e("click_pageview",i));break}return o.length>0&&(r=function(t){for(var n=f(t,o),r=0;r<n.length;r++)e("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n},vt=function(t,e){var n={},t=t+"/ping/"+e,r=null;return n.connect=function(e){"undefined"!=typeof EventSource&&(r=new window.EventSource(t)).addEventListener("ping",e)},n.disconnect=function(){r&&r.close()},n.isConnected=function(){return r&&(r.readyState===EventSource.OPEN||r.readyState===EventSource.CONNECTING)},n},bt="application/json",xt=function(t,e){var n={};return n.fetchFlagSettings=function(n,r,o){var u,i=st.base64URLEncode(JSON.stringify(n)),a=[t,"/sdk/eval/",e,"/users/",i,r?"?h="+r:""].join(""),f=function(t){return function(){t.apply(null,arguments),at=null,ft=null}}(o);at?(at.abort(),u=function(t){return function(){t&&t.apply(null,arguments),f.apply(null,arguments)}}(ft)):u=f,ft=u,at=c(a,u)},n.fetchGoals=function(n){c([t,"/sdk/goals/",e].join(""),n)},n},wt=function(t,e){var n,r={};return r.setUser=function(t){n=l(t),e(st.clone(n))},r.getUser=function(){return st.clone(n)},t&&r.setUser(t),r},_t={invalidKey:function(){return"Event key must be a string"},unknownCustomEventKey:function(t){return'Custom event "'+t+'" does not exist'}},mt=u(function(t){function e(t){s.enqueue({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()})}function n(t,e,n){var r=y.getUser(),o=JSON.stringify(e)+(r&&r.key?r.key:"")+t,u=new Date,i=k[o];i&&u-i<3e5||(k[o]=u,s.enqueue({kind:"feature",key:t,user:r,value:e,default:n,creationDate:u.getTime()}))}function r(t,e){var n={kind:t,key:e.key,data:null,url:window.location.href,creationDate:(new Date).getTime()};return"click"===t&&(n.selector=e.selector),s.enqueue(n)}function o(t,e){var r;return r=E&&E.hasOwnProperty(t)?null===E[t]?e:E[t]:e,n(t,r,e),r}function u(t){if(!m||0===m.length)return!1;for(var e=0;e<m.length;e++)if("custom"===m[e].kind&&m[e].key===t)return!0;return!1}function i(){d.connect(function(){p.fetchFlagSettings(y.getUser(),g,function(t,e){t&&console.warn("Error fetching flag settings: ",t),a(e)})})}function a(t){var e,r;t&&(e=st.modifications(E,t),r=Object.keys(e),E=t,_&&localStorage.setItem(c(l,y.getUser()),JSON.stringify(E)),r.length>0&&(r.forEach(function(t){h.emit(S+":"+t,e[t].current,e[t].previous)}),h.emit(S,e),r.forEach(function(t){n(t,e[t].current)})))}function f(t){if(t.origin===v&&"SYN"===t.data.type){window.editorClientBaseUrl=v;var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=v+t.data.editorClientUrl;var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)}}function c(t,e){var n="";return e&&e.key&&(n=e.key),"ld:"+t+":"+n}var l,s,p,d,h,g,y,v,b,x,w,_,m,E={},O="ready",S="change",j=2e3,k={},T={identify:function(t,e,n){y.setUser(t),p.fetchFlagSettings(y.getUser(),e,function(t,e){t&&console.warn("Error fetching flag settings: ",t),e&&a(e),n&&n()})},variation:o,track:function(t,e){if("string"!=typeof t)throw _t.invalidKey();m&&!u(t)&&console.warn(_t.unknownCustomEventKey(t)),s.enqueue({kind:"custom",key:t,data:e,url:window.location.href,creationDate:(new Date).getTime()})},on:function(t,e,n){t.substr(0,S.length)===S?(d.isConnected()||i(),h.on.apply(h,[t,e,n])):h.on.apply(h,Array.prototype.slice.call(arguments))},off:function(){h.off.apply(h,Array.prototype.slice.call(arguments))},allFlags:function(){var t={};if(!E)return t;for(var e in E)E.hasOwnProperty(e)&&(t[e]=o(e,null));return t}};t.exports={initialize:function(t,n,o){function u(){setTimeout(function t(){s.flush(y.getUser()),setTimeout(t,j)},j)}function i(){w&&w.dispose(),m&&m.length&&(w=yt(m,r))}var a;if(o=o||{},l=t,E="object"==typeof o.bootstrap?o.bootstrap:{},g=o.hash,v=o.baseUrl||"https://app.launchdarkly.com",b=o.eventsUrl||"https://events.launchdarkly.com",x=o.streamUrl||"https://clientstream.launchdarkly.com",d=vt(x,l),s=pt(b+"/a/"+l+".gif"),h=dt(),y=wt(n,e),p=xt(v,l),a=c(l,y.getUser()),"object"==typeof o.bootstrap)setTimeout(function(){h.emit(O)},0);else if("string"==typeof o.bootstrap&&"LOCALSTORAGE"===o.bootstrap.toUpperCase()&&"undefined"!=typeof Storage){_=!0;try{E=JSON.parse(localStorage.getItem(a))}catch(t){localStorage.setItem(a,null)}null===E?p.fetchFlagSettings(y.getUser(),g,function(t,e){t&&console.warn("Error fetching flag settings: ",t),E=e,e&&localStorage.setItem(a,JSON.stringify(E)),h.emit(O)}):(setTimeout(function(){h.emit(O)},0),p.fetchFlagSettings(y.getUser(),g,function(t,e){t&&console.warn("Error fetching flag settings: ",t),e&&localStorage.setItem(a,JSON.stringify(e))}))}else p.fetchFlagSettings(y.getUser(),g,function(t,e){t&&console.warn("Error fetching flag settings: ",t),E=e,h.emit(O)});return p.fetchGoals(function(t,e){t&&console.warn("Error fetching goals: ",t),e&&e.length>0&&(w=yt(m=e,r))}),"complete"!==document.readyState?window.addEventListener("load",u):u(),window.addEventListener("beforeunload",function(){s.flush(y.getUser(),!0)}),m&&m.length>0&&(window.history&&history.pushState?window.addEventListener("popstate",i):window.addEventListener("hashchange",i)),window.addEventListener("message",f),T}},t.exports.version="1.0.0"}),Et=1/0,Ot="[object Symbol]",St=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,jt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,kt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Tt="["+kt+"]",At="[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]",Ct="[a-z\\xdf-\\xf6\\xf8-\\xff]",Ut="[^\\ud800-\\udfff"+kt+"\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",Ft="\\ud83c[\\udffb-\\udfff]",Lt="(?:\\ud83c[\\udde6-\\uddff]){2}",Rt="[\\ud800-\\udbff][\\udc00-\\udfff]",Pt="[A-Z\\xc0-\\xd6\\xd8-\\xde]",It="(?:"+Ct+"|"+Ut+")",Nt="(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?",Dt="[\\ufe0e\\ufe0f]?"+Nt+("(?:\\u200d(?:"+["[^\\ud800-\\udfff]",Lt,Rt].join("|")+")[\\ufe0e\\ufe0f]?"+Nt+")*"),Mt="(?:"+["[\\u2700-\\u27bf]",Lt,Rt].join("|")+")"+Dt,qt="(?:"+["[^\\ud800-\\udfff]"+At+"?",At,Lt,Rt,"[\\ud800-\\udfff]"].join("|")+")",zt=RegExp("['’]","g"),Jt=RegExp(At,"g"),$t=RegExp(Ft+"(?="+Ft+")|"+qt+Dt,"g"),Gt=RegExp([Pt+"?"+Ct+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Tt,Pt,"$"].join("|")+")","(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Tt,Pt+It,"$"].join("|")+")",Pt+"?"+It+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Pt+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d+",Mt].join("|"),"g"),Zt=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),Bt=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ht={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"ss"},Kt="object"==typeof ct&&ct&&ct.Object===Object&&ct,Yt="object"==typeof self&&self&&self.Object===Object&&self,Xt=Kt||Yt||Function("return this")(),Vt=function(t){return function(e){return null==t?void 0:t[e]}}(Ht),Wt=Object.prototype.toString,Qt=Xt.Symbol,te=Qt?Qt.prototype:void 0,ee=te?te.toString:void 0,ne=function(t){return function(e){return s(k(j(e).replace(zt,"")),t,"")}}(function(t,e,n){return e=e.toLowerCase(),t+(n?S(e):e)}),re=function(t){return function(e){var n=h(e=O(e))?y(e):void 0,r=n?n[0]:e.charAt(0),o=n?_(n,1).join(""):e.slice(1);return r[t]()+o}}("toUpperCase"),oe=ne,ue=function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?n:3&n|8).toString(16)})},ie=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},ae=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),fe=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},ce=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},le=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},se=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},pe=function(){function t(t,e){var n=[],r=!0,o=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(r=(i=a.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,u=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw u}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),de=function(){return{key:ue()}},he=function(t,e){return[oe(t),null!==e&&e]},ge=function(t){return Object.entries(t).reduce(function(t,e){var n=pe(e,2),r=n[0],o=n[1],u=he(r,o),i=pe(u,2),a=i[0],f=i[1];return t[a]=f,t},{})},ye=function(t){var e=t.clientSideId,n=t.user;return mt.initialize(e,n||de())},ve=function(t){var e=t.rawFlags,n=t.client,r=t.updateFlags;for(var o in e)!function(t){Object.prototype.hasOwnProperty.call(e,t)&&n.on("change:"+t,function(e){var n=he(t,e),o=pe(n,2),u=o[0],i=o[1];r(fe({},u,i))})}(o)},be=function(t){var e=t.client,n=t.updateFlags,r=t.updateStatus;e.on("ready",function(){r({isReady:!0});var t=e.allFlags(),o=ge(t);n(o),ve({rawFlags:t,client:e,updateFlags:n})})},xe="@flopflip/flags/update",we={},_e=function(t){return{type:xe,payload:t}},me="@flopflip/status/update",Ee={isReady:!1},Oe=function(t){return{type:me,payload:t}},Se=e.combineReducers({flags:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:we,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(e.type){case xe:return ce({},t,e.payload);default:return t}},status:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ee,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(e.type){case me:return ce({},t,{isReady:e.payload.isReady});default:return t}}}),je=function(t){function e(){return ie(this,e),se(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return le(e,t),ae(e,[{key:"render",value:function(){return this.props.isFeatureEnabled?this.props.children:this.props.untoggledComponent}}]),e}(it.Component);je.defaultProps={untoggledComponent:null};var ke=o.connect(function(t,e){return{isFeatureEnabled:Boolean(t["@flopflip"].flags[e.flag])}})(je),Te=(u(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});e.createChangeEmitter=function(){function t(){n===e&&(n=e.slice())}var e=[],n=e;return{listen:function(e){if("function"!=typeof e)throw new Error("Expected listener to be a function.");var r=!0;return t(),n.push(e),function(){if(r){r=!1,t();var o=n.indexOf(e);n.splice(o,1)}}},emit:function(){for(var t=e=n,r=0;r<t.length;r++)t[r].apply(t,arguments)}}}}),u(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e,n=t.Symbol;return"function"==typeof n?n.observable?e=n.observable:(e=n("observable"),n.observable=e):e="@@observable",e}})),Ae=(u(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n,r=function(t){return t&&t.__esModule?t:{default:t}}(Te);n="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==ct?ct:t;var o=(0,r.default)(n);e.default=o}),"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t}),Ce=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Ue=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Fe=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},Le=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},Re=function(t,e,n,r,o){if(!t&&e)return n(o?Ue({},r,{children:o}):r);var u=n;return o?it.createElement(u,r,o):it.createElement(u,r)},Pe=function(t){return Boolean(t&&t.prototype&&"object"===Ae(t.prototype.isReactComponent))},Ie=function(t){return Boolean(!("function"!=typeof t||Pe(t)||t.defaultProps||t.contextTypes))},Ne=function(t){var e=Ie(t);return function(n,r){return Re(!1,e,t,n,r)}},De=function(t){return function(e){var n=Ne(e);return function(e){return n(t(e))}}},Me=function(t){return De(function(e){return Ue({},e,"function"==typeof t?t(e):t)})},qe=function(t){return t},ze=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:qe;return function(r){var o=void 0,u=void 0;return function(i){return t(i)?(o=o||Ne(e(r)))(i):(u=u||Ne(n(r)))(i)}}},Je=function(t){return function(e){var n=Ne(t);return function(t){return n(t)}}},$e=function(t){function e(){return Ce(this,e),Le(this,t.apply(this,arguments))}return Fe(e,t),e.prototype.render=function(){return null},e}(n.Component),Ge=function(t){return $e},Ze="__lodash_hash_undefined__",Be=9007199254740991,He="[object Function]",Ke="[object GeneratorFunction]",Ye=/[\\^$.*+?()[\]{}|]/g,Xe=/^\[object .+?Constructor\]$/,Ve="object"==typeof ct&&ct&&ct.Object===Object&&ct,We="object"==typeof self&&self&&self.Object===Object&&self,Qe=Ve||We||Function("return this")(),tn=Array.prototype,en=Function.prototype,nn=Object.prototype,rn=Qe["__core-js_shared__"],on=function(){var t=/[^.]+$/.exec(rn&&rn.keys&&rn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),un=en.toString,an=nn.hasOwnProperty,fn=nn.toString,cn=RegExp("^"+un.call(an).replace(Ye,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ln=tn.splice,sn=Math.max,pn=Math.min,dn=Y(Qe,"Map"),hn=Y(Object,"create");q.prototype.clear=function(){this.__data__=hn?hn(null):{}},q.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},q.prototype.get=function(t){var e=this.__data__;if(hn){var n=e[t];return n===Ze?void 0:n}return an.call(e,t)?e[t]:void 0},q.prototype.has=function(t){var e=this.__data__;return hn?void 0!==e[t]:an.call(e,t)},q.prototype.set=function(t,e){return this.__data__[t]=hn&&void 0===e?Ze:e,this},z.prototype.clear=function(){this.__data__=[]},z.prototype.delete=function(t){var e=this.__data__,n=G(e,t);return!(n<0||(n==e.length-1?e.pop():ln.call(e,n,1),0))},z.prototype.get=function(t){var e=this.__data__,n=G(e,t);return n<0?void 0:e[n][1]},z.prototype.has=function(t){return G(this.__data__,t)>-1},z.prototype.set=function(t,e){var n=this.__data__,r=G(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},J.prototype.clear=function(){this.__data__={hash:new q,map:new(dn||z),string:new q}},J.prototype.delete=function(t){return K(this,t).delete(t)},J.prototype.get=function(t){return K(this,t).get(t)},J.prototype.has=function(t){return K(this,t).has(t)},J.prototype.set=function(t,e){return K(this,t).set(t,e),this},$.prototype.add=$.prototype.push=function(t){return this.__data__.set(t,Ze),this},$.prototype.has=function(t){return this.__data__.has(t)};var gn=function(t,e){return e=sn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,r=-1,o=sn(n.length-e,0),u=Array(o);++r<o;)u[r]=n[e+r];r=-1;for(var i=Array(e+1);++r<e;)i[r]=n[r];return i[e]=u,A(t,this,i)}}(function(t){var e=F(t,H);return e.length&&e[0]===t[0]?Z(e):[]}),yn=function(t,e){return gn(Object.keys(t),e).reduce(function(e,n){return fe({},n,t[n])},{})},vn=function(t){return Me(function(e){return{featureToggles:yn(e.availableFeatureToggles,t)}})},bn=function(t){return T(o.connect(function(t){return{availableFeatureToggles:t["@flopflip"].flags}}),vn(t))},xn=function(t){return ze(function(t){return!Object.values(t.featureToggles).some(function(t){return t})},t?Je(t):Ge)},wn=function(t){function e(){return ie(this,e),se(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return le(e,t),ae(e,[{key:"render",value:function(){return be({client:ye({clientSideId:this.props.clientSideId,user:this.props.user}),updateFlags:this.props.updateFlags,updateStatus:this.props.updateStatus}),this.props.children?it.Children.only(this.props.children):null}}]),e}(it.Component);wn.defaultProps={children:null,user:{}};var _n=o.connect(null,function(t){return e.bindActionCreators({updateStatus:Oe,updateFlags:_e},t)})(wn);t.createFlopFlipEnhancer=function(t,e){var n=ye({clientSideId:t,user:e});return function(t){return function(){var e=t.apply(void 0,arguments);return be({client:n,updateFlags:e.dispatch(_e),updateStatus:e.dispatch(Oe)}),e}}},t.FLOPFLIP_STATE_SLICE="@flopflip",t.flopflipReducer=Se,t.updateStatus=Oe,t.updateFlags=_e,t.UPDATE_STATUS=me,t.UPDATE_FLAGS=xe,t.FeatureToggled=ke,t.injectFeatureToggles=bn,t.withFeatureToggle=function(t,e){return T(bn([t]),xn(e))},t.ConfigureFlopFlip=_n,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=flopflip.umd.min.js.map