tang 0.0.9 → 0.1.0

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/controllers/tang/admin/subscriptions_controller.rb +1 -1
  4. data/app/jobs/tang/import_customers_job.rb +7 -1
  5. data/app/models/tang/invoice.rb +2 -2
  6. data/app/models/tang/subscription.rb +3 -3
  7. data/app/services/tang/create_subscription.rb +4 -1
  8. data/app/services/tang/delete_card.rb +4 -2
  9. data/app/services/tang/fail_invoice.rb +6 -3
  10. data/app/services/tang/save_card.rb +4 -1
  11. data/app/services/tang/update_subscription.rb +1 -1
  12. data/app/views/tang/account/cards/_payment.html.erb +0 -32
  13. data/app/views/tang/admin/subscriptions/_form.html.erb +0 -5
  14. data/app/views/tang/admin/subscriptions/show.html.erb +0 -7
  15. data/lib/css/main.css +31 -0
  16. data/lib/js/index.js +3 -2
  17. data/lib/tang/version.rb +1 -1
  18. data/spec/fixtures/stripe_webhooks/invoice.created.json +1 -2
  19. data/spec/fixtures/stripe_webhooks/invoice.payment_failed.json +172 -0
  20. data/spec/models/tang/card_spec.rb +4 -1
  21. data/spec/models/tang/charge_spec.rb +47 -1
  22. data/spec/tang_app/Gemfile.lock +70 -0
  23. data/spec/tang_app/app/javascript/packs/application.js +2 -1
  24. data/spec/tang_app/app/views/layouts/application.html.erb +1 -0
  25. data/spec/tang_app/log/development.log +342 -0
  26. data/spec/tang_app/log/test.log +52349 -0
  27. data/spec/tang_app/node_modules/fsevents/build/Release/fse.node +0 -0
  28. data/spec/tang_app/package.json +3 -0
  29. data/spec/tang_app/public/packs-test/js/application-0dded7840d00b04c8937.js +653 -0
  30. data/spec/tang_app/public/packs-test/js/application-0dded7840d00b04c8937.js.map +1 -0
  31. data/spec/tang_app/public/packs-test/manifest.json +4 -4
  32. data/spec/tang_app/public/packs/js/application-080539f58098495f5fea.js +873 -0
  33. data/spec/tang_app/public/packs/js/application-080539f58098495f5fea.js.map +1 -0
  34. data/spec/tang_app/public/packs/js/application-63744ba8e1d5132a70a7.js +653 -0
  35. data/spec/tang_app/public/packs/js/application-63744ba8e1d5132a70a7.js.map +1 -0
  36. data/spec/tang_app/public/packs/js/application-6ed6c7d5740861886e33.js +908 -0
  37. data/spec/tang_app/public/packs/js/application-6ed6c7d5740861886e33.js.map +1 -0
  38. data/spec/tang_app/public/packs/js/application-95a81db325472bcd27be.js +873 -0
  39. data/spec/tang_app/public/packs/js/application-95a81db325472bcd27be.js.map +1 -0
  40. data/spec/tang_app/public/packs/js/application-a4d14e60f459eb6278f8.js +873 -0
  41. data/spec/tang_app/public/packs/js/application-a4d14e60f459eb6278f8.js.map +1 -0
  42. data/spec/tang_app/public/packs/js/application-e5d6d1269e6e876bad16.js +654 -0
  43. data/spec/tang_app/public/packs/js/application-e5d6d1269e6e876bad16.js.map +1 -0
  44. data/spec/tang_app/public/packs/manifest.json +4 -4
  45. data/spec/tang_app/tmp/cache/webpacker/last-compilation-digest-development +1 -1
  46. data/spec/tang_app/tmp/cache/webpacker/last-compilation-digest-test +1 -1
  47. metadata +35 -2
@@ -8,5 +8,8 @@
8
8
  },
9
9
  "devDependencies": {
10
10
  "webpack-dev-server": "^3.11.0"
11
+ },
12
+ "scripts": {
13
+ "build": "RAILS_ENV=development NODE_ENV=development bin/webpack --watch"
11
14
  }
12
15
  }
@@ -0,0 +1,653 @@
1
+ /******/ (function(modules) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = {};
4
+ /******/
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__(moduleId) {
7
+ /******/
8
+ /******/ // Check if module is in cache
9
+ /******/ if(installedModules[moduleId]) {
10
+ /******/ return installedModules[moduleId].exports;
11
+ /******/ }
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules[moduleId] = {
14
+ /******/ i: moduleId,
15
+ /******/ l: false,
16
+ /******/ exports: {}
17
+ /******/ };
18
+ /******/
19
+ /******/ // Execute the module function
20
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
+ /******/
22
+ /******/ // Flag the module as loaded
23
+ /******/ module.l = true;
24
+ /******/
25
+ /******/ // Return the exports of the module
26
+ /******/ return module.exports;
27
+ /******/ }
28
+ /******/
29
+ /******/
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__.m = modules;
32
+ /******/
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__.c = installedModules;
35
+ /******/
36
+ /******/ // define getter function for harmony exports
37
+ /******/ __webpack_require__.d = function(exports, name, getter) {
38
+ /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40
+ /******/ }
41
+ /******/ };
42
+ /******/
43
+ /******/ // define __esModule on exports
44
+ /******/ __webpack_require__.r = function(exports) {
45
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
+ /******/ }
48
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
49
+ /******/ };
50
+ /******/
51
+ /******/ // create a fake namespace object
52
+ /******/ // mode & 1: value is a module id, require it
53
+ /******/ // mode & 2: merge all properties of value into the ns
54
+ /******/ // mode & 4: return value when already ns object
55
+ /******/ // mode & 8|1: behave like require
56
+ /******/ __webpack_require__.t = function(value, mode) {
57
+ /******/ if(mode & 1) value = __webpack_require__(value);
58
+ /******/ if(mode & 8) return value;
59
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60
+ /******/ var ns = Object.create(null);
61
+ /******/ __webpack_require__.r(ns);
62
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64
+ /******/ return ns;
65
+ /******/ };
66
+ /******/
67
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
68
+ /******/ __webpack_require__.n = function(module) {
69
+ /******/ var getter = module && module.__esModule ?
70
+ /******/ function getDefault() { return module['default']; } :
71
+ /******/ function getModuleExports() { return module; };
72
+ /******/ __webpack_require__.d(getter, 'a', getter);
73
+ /******/ return getter;
74
+ /******/ };
75
+ /******/
76
+ /******/ // Object.prototype.hasOwnProperty.call
77
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78
+ /******/
79
+ /******/ // __webpack_public_path__
80
+ /******/ __webpack_require__.p = "/packs-test/";
81
+ /******/
82
+ /******/
83
+ /******/ // Load entry module and return exports
84
+ /******/ return __webpack_require__(__webpack_require__.s = "./app/javascript/packs/application.js");
85
+ /******/ })
86
+ /************************************************************************/
87
+ /******/ ({
88
+
89
+ /***/ "../../lib/css/main.css":
90
+ /*!*****************************************************!*\
91
+ !*** /Users/craigphares/Code/tang/lib/css/main.css ***!
92
+ \*****************************************************/
93
+ /*! no static exports found */
94
+ /***/ (function(module, exports, __webpack_require__) {
95
+
96
+ var api = __webpack_require__(/*! ../../spec/tang_app/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
97
+ var content = __webpack_require__(/*! !../../spec/tang_app/node_modules/css-loader/dist/cjs.js??ref--5-1!../../spec/tang_app/node_modules/postcss-loader/src??ref--5-2!./main.css */ "./node_modules/css-loader/dist/cjs.js?!./node_modules/postcss-loader/src/index.js?!../../lib/css/main.css");
98
+
99
+ content = content.__esModule ? content.default : content;
100
+
101
+ if (typeof content === 'string') {
102
+ content = [[module.i, content, '']];
103
+ }
104
+
105
+ var options = {};
106
+
107
+ options.insert = "head";
108
+ options.singleton = false;
109
+
110
+ var update = api(content, options);
111
+
112
+
113
+
114
+ module.exports = content.locals || {};
115
+
116
+ /***/ }),
117
+
118
+ /***/ "../../lib/js/index.js":
119
+ /*!****************************************************!*\
120
+ !*** /Users/craigphares/Code/tang/lib/js/index.js ***!
121
+ \****************************************************/
122
+ /*! exports provided: default */
123
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
124
+
125
+ "use strict";
126
+ __webpack_require__.r(__webpack_exports__);
127
+ // Create a Stripe client.
128
+ var stripe = Stripe("pk_test_ufmXOx2149BsFX2Hf6i8zTTL");
129
+
130
+ const registerElements = () => {
131
+
132
+ if (!document.getElementById('card-element')) {
133
+ return
134
+ }
135
+
136
+ // Create an instance of Elements.
137
+ var elements = stripe.elements();
138
+
139
+ // Custom styling can be passed to options when creating an Element.
140
+ // (Note that this demo uses a wider set of styles than the guide below.)
141
+ var style = {
142
+ base: {
143
+ color: '#32325d',
144
+ fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
145
+ fontSmoothing: 'antialiased',
146
+ fontSize: '16px',
147
+ '::placeholder': {
148
+ color: '#aab7c4'
149
+ }
150
+ },
151
+ invalid: {
152
+ color: '#fa755a',
153
+ iconColor: '#fa755a'
154
+ }
155
+ };
156
+
157
+ // Create an instance of the card Element.
158
+ var card = elements.create('card', {style: style});
159
+
160
+ // Add an instance of the card Element into the `card-element` <div>.
161
+ card.mount('#card-element');
162
+ // Handle real-time validation errors from the card Element.
163
+ card.on('change', function(event) {
164
+ var displayError = document.getElementById('card-errors');
165
+ if (event.error) {
166
+ displayError.textContent = event.error.message;
167
+ } else {
168
+ displayError.textContent = '';
169
+ }
170
+ });
171
+
172
+ // Handle form submission.
173
+ var form = document.getElementById('payment-form');
174
+ form.addEventListener('submit', function(event) {
175
+ event.preventDefault();
176
+
177
+ const name = form.querySelector('#name')
178
+ // const zip = form.querySelector('#zip')
179
+ const additionalData = {
180
+ name: name ? name.value : undefined,
181
+ // address_zip: zip ? zip.value : undefined
182
+ }
183
+
184
+ stripe.createToken(card, additionalData).then(function(result) {
185
+ if (result.error) {
186
+ // Inform the user if there was an error.
187
+ var errorElement = document.getElementById('card-errors');
188
+ errorElement.textContent = result.error.message;
189
+ } else {
190
+ // Send the token to your server.
191
+ stripeTokenHandler(result.token);
192
+ }
193
+ });
194
+ });
195
+
196
+ // Submit the form with the token ID.
197
+ function stripeTokenHandler(token) {
198
+ // Insert the token ID into the form so it gets submitted to the server
199
+ var form = document.getElementById('payment-form');
200
+ var hiddenInput = document.createElement('input');
201
+ hiddenInput.setAttribute('type', 'hidden');
202
+ hiddenInput.setAttribute('name', 'stripe_token');
203
+ hiddenInput.setAttribute('value', token.id);
204
+ form.appendChild(hiddenInput);
205
+
206
+ // Submit the form
207
+ form.submit();
208
+ }
209
+
210
+ }
211
+
212
+ /* harmony default export */ __webpack_exports__["default"] = (registerElements);
213
+
214
+ /***/ }),
215
+
216
+ /***/ "./app/javascript/packs/application.js":
217
+ /*!*********************************************!*\
218
+ !*** ./app/javascript/packs/application.js ***!
219
+ \*********************************************/
220
+ /*! no exports provided */
221
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
222
+
223
+ "use strict";
224
+ __webpack_require__.r(__webpack_exports__);
225
+ /* harmony import */ var _sixoverground_tang__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sixoverground/tang */ "../../lib/js/index.js");
226
+ /* harmony import */ var _sixoverground_tang_lib_css_main_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @sixoverground/tang/lib/css/main.css */ "../../lib/css/main.css");
227
+ /* harmony import */ var _sixoverground_tang_lib_css_main_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_sixoverground_tang_lib_css_main_css__WEBPACK_IMPORTED_MODULE_1__);
228
+ /* eslint no-console:0 */
229
+ // This file is automatically compiled by Webpack, along with any other files
230
+ // present in this directory. You're encouraged to place your actual application logic in
231
+ // a relevant structure within app/javascript and only use these pack files to reference
232
+ // that code so it'll be compiled.
233
+ //
234
+ // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
235
+ // layout file, like app/views/layouts/application.html.erb
236
+ // Uncomment to copy all static images under ../images to the output folder and reference
237
+ // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
238
+ // or the `imagePath` JavaScript helper below.
239
+ //
240
+ // const images = require.context('../images', true)
241
+ // const imagePath = (name) => images(name, true)
242
+
243
+
244
+ console.log('Hello World from Webpacker 1');
245
+ Object(_sixoverground_tang__WEBPACK_IMPORTED_MODULE_0__["default"])();
246
+
247
+ /***/ }),
248
+
249
+ /***/ "./node_modules/css-loader/dist/cjs.js?!./node_modules/postcss-loader/src/index.js?!../../lib/css/main.css":
250
+ /*!*************************************************************************************************************************************************!*\
251
+ !*** ./node_modules/css-loader/dist/cjs.js??ref--5-1!./node_modules/postcss-loader/src??ref--5-2!/Users/craigphares/Code/tang/lib/css/main.css ***!
252
+ \*************************************************************************************************************************************************/
253
+ /*! no static exports found */
254
+ /***/ (function(module, exports, __webpack_require__) {
255
+
256
+ // Imports
257
+ var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../spec/tang_app/node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
258
+ exports = ___CSS_LOADER_API_IMPORT___(true);
259
+ // Module
260
+ exports.push([module.i, "/**\n * The CSS shown here will not be introduced in the Quickstart guide, but shows\n * how you can use CSS to style your Element's container.\n */\n .StripeElement {\n box-sizing: border-box;\n\n height: 40px;\n\n padding: 10px 12px;\n\n border: 1px solid transparent;\n border-radius: 4px;\n background-color: white;\n\n box-shadow: 0 1px 3px 0 #e6ebf1;\n transition: box-shadow 150ms ease;\n}\n .StripeElement--focus {\n box-shadow: 0 1px 3px 0 #cfd7df;\n }\n .StripeElement--invalid {\n border-color: #fa755a;\n }\n .StripeElement--webkit-autofill {\n background-color: #fefde5 !important;\n }", "",{"version":3,"sources":["main.css"],"names":[],"mappings":"AAAA;;;EAGE;CACD;EACC,sBAAsB;;EAEtB,YAAY;;EAEZ,kBAAkB;;EAElB,6BAA6B;EAC7B,kBAAkB;EAClB,uBAAuB;;EAEvB,+BAA+B;EAE/B,iCAAiC;AACnC;CAEE;IACE,+BAA+B;EACjC;CAEA;IACE,qBAAqB;EACvB;CAEA;IACE,oCAAoC;EACtC","file":"main.css","sourcesContent":["/**\n * The CSS shown here will not be introduced in the Quickstart guide, but shows\n * how you can use CSS to style your Element's container.\n */\n .StripeElement {\n box-sizing: border-box;\n\n height: 40px;\n\n padding: 10px 12px;\n\n border: 1px solid transparent;\n border-radius: 4px;\n background-color: white;\n\n box-shadow: 0 1px 3px 0 #e6ebf1;\n -webkit-transition: box-shadow 150ms ease;\n transition: box-shadow 150ms ease;\n}\n \n .StripeElement--focus {\n box-shadow: 0 1px 3px 0 #cfd7df;\n }\n \n .StripeElement--invalid {\n border-color: #fa755a;\n }\n \n .StripeElement--webkit-autofill {\n background-color: #fefde5 !important;\n }"]}]);
261
+ // Exports
262
+ module.exports = exports;
263
+
264
+
265
+ /***/ }),
266
+
267
+ /***/ "./node_modules/css-loader/dist/runtime/api.js":
268
+ /*!*****************************************************!*\
269
+ !*** ./node_modules/css-loader/dist/runtime/api.js ***!
270
+ \*****************************************************/
271
+ /*! no static exports found */
272
+ /***/ (function(module, exports, __webpack_require__) {
273
+
274
+ "use strict";
275
+
276
+ /*
277
+ MIT License http://www.opensource.org/licenses/mit-license.php
278
+ Author Tobias Koppers @sokra
279
+ */
280
+ // css base code, injected by the css-loader
281
+ // eslint-disable-next-line func-names
282
+
283
+ module.exports = function (useSourceMap) {
284
+ var list = []; // return the list of modules as css string
285
+
286
+ list.toString = function toString() {
287
+ return this.map(function (item) {
288
+ var content = cssWithMappingToString(item, useSourceMap);
289
+
290
+ if (item[2]) {
291
+ return "@media ".concat(item[2], " {").concat(content, "}");
292
+ }
293
+
294
+ return content;
295
+ }).join('');
296
+ }; // import a list of modules into the list
297
+ // eslint-disable-next-line func-names
298
+
299
+
300
+ list.i = function (modules, mediaQuery, dedupe) {
301
+ if (typeof modules === 'string') {
302
+ // eslint-disable-next-line no-param-reassign
303
+ modules = [[null, modules, '']];
304
+ }
305
+
306
+ var alreadyImportedModules = {};
307
+
308
+ if (dedupe) {
309
+ for (var i = 0; i < this.length; i++) {
310
+ // eslint-disable-next-line prefer-destructuring
311
+ var id = this[i][0];
312
+
313
+ if (id != null) {
314
+ alreadyImportedModules[id] = true;
315
+ }
316
+ }
317
+ }
318
+
319
+ for (var _i = 0; _i < modules.length; _i++) {
320
+ var item = [].concat(modules[_i]);
321
+
322
+ if (dedupe && alreadyImportedModules[item[0]]) {
323
+ // eslint-disable-next-line no-continue
324
+ continue;
325
+ }
326
+
327
+ if (mediaQuery) {
328
+ if (!item[2]) {
329
+ item[2] = mediaQuery;
330
+ } else {
331
+ item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
332
+ }
333
+ }
334
+
335
+ list.push(item);
336
+ }
337
+ };
338
+
339
+ return list;
340
+ };
341
+
342
+ function cssWithMappingToString(item, useSourceMap) {
343
+ var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
344
+
345
+ var cssMapping = item[3];
346
+
347
+ if (!cssMapping) {
348
+ return content;
349
+ }
350
+
351
+ if (useSourceMap && typeof btoa === 'function') {
352
+ var sourceMapping = toComment(cssMapping);
353
+ var sourceURLs = cssMapping.sources.map(function (source) {
354
+ return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
355
+ });
356
+ return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
357
+ }
358
+
359
+ return [content].join('\n');
360
+ } // Adapted from convert-source-map (MIT)
361
+
362
+
363
+ function toComment(sourceMap) {
364
+ // eslint-disable-next-line no-undef
365
+ var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
366
+ var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
367
+ return "/*# ".concat(data, " */");
368
+ }
369
+
370
+ /***/ }),
371
+
372
+ /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
373
+ /*!****************************************************************************!*\
374
+ !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
375
+ \****************************************************************************/
376
+ /*! no static exports found */
377
+ /***/ (function(module, exports, __webpack_require__) {
378
+
379
+ "use strict";
380
+
381
+
382
+ var isOldIE = function isOldIE() {
383
+ var memo;
384
+ return function memorize() {
385
+ if (typeof memo === 'undefined') {
386
+ // Test for IE <= 9 as proposed by Browserhacks
387
+ // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
388
+ // Tests for existence of standard globals is to allow style-loader
389
+ // to operate correctly into non-standard environments
390
+ // @see https://github.com/webpack-contrib/style-loader/issues/177
391
+ memo = Boolean(window && document && document.all && !window.atob);
392
+ }
393
+
394
+ return memo;
395
+ };
396
+ }();
397
+
398
+ var getTarget = function getTarget() {
399
+ var memo = {};
400
+ return function memorize(target) {
401
+ if (typeof memo[target] === 'undefined') {
402
+ var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
403
+
404
+ if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
405
+ try {
406
+ // This will throw an exception if access to iframe is blocked
407
+ // due to cross-origin restrictions
408
+ styleTarget = styleTarget.contentDocument.head;
409
+ } catch (e) {
410
+ // istanbul ignore next
411
+ styleTarget = null;
412
+ }
413
+ }
414
+
415
+ memo[target] = styleTarget;
416
+ }
417
+
418
+ return memo[target];
419
+ };
420
+ }();
421
+
422
+ var stylesInDom = [];
423
+
424
+ function getIndexByIdentifier(identifier) {
425
+ var result = -1;
426
+
427
+ for (var i = 0; i < stylesInDom.length; i++) {
428
+ if (stylesInDom[i].identifier === identifier) {
429
+ result = i;
430
+ break;
431
+ }
432
+ }
433
+
434
+ return result;
435
+ }
436
+
437
+ function modulesToDom(list, options) {
438
+ var idCountMap = {};
439
+ var identifiers = [];
440
+
441
+ for (var i = 0; i < list.length; i++) {
442
+ var item = list[i];
443
+ var id = options.base ? item[0] + options.base : item[0];
444
+ var count = idCountMap[id] || 0;
445
+ var identifier = "".concat(id, " ").concat(count);
446
+ idCountMap[id] = count + 1;
447
+ var index = getIndexByIdentifier(identifier);
448
+ var obj = {
449
+ css: item[1],
450
+ media: item[2],
451
+ sourceMap: item[3]
452
+ };
453
+
454
+ if (index !== -1) {
455
+ stylesInDom[index].references++;
456
+ stylesInDom[index].updater(obj);
457
+ } else {
458
+ stylesInDom.push({
459
+ identifier: identifier,
460
+ updater: addStyle(obj, options),
461
+ references: 1
462
+ });
463
+ }
464
+
465
+ identifiers.push(identifier);
466
+ }
467
+
468
+ return identifiers;
469
+ }
470
+
471
+ function insertStyleElement(options) {
472
+ var style = document.createElement('style');
473
+ var attributes = options.attributes || {};
474
+
475
+ if (typeof attributes.nonce === 'undefined') {
476
+ var nonce = true ? __webpack_require__.nc : undefined;
477
+
478
+ if (nonce) {
479
+ attributes.nonce = nonce;
480
+ }
481
+ }
482
+
483
+ Object.keys(attributes).forEach(function (key) {
484
+ style.setAttribute(key, attributes[key]);
485
+ });
486
+
487
+ if (typeof options.insert === 'function') {
488
+ options.insert(style);
489
+ } else {
490
+ var target = getTarget(options.insert || 'head');
491
+
492
+ if (!target) {
493
+ throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
494
+ }
495
+
496
+ target.appendChild(style);
497
+ }
498
+
499
+ return style;
500
+ }
501
+
502
+ function removeStyleElement(style) {
503
+ // istanbul ignore if
504
+ if (style.parentNode === null) {
505
+ return false;
506
+ }
507
+
508
+ style.parentNode.removeChild(style);
509
+ }
510
+ /* istanbul ignore next */
511
+
512
+
513
+ var replaceText = function replaceText() {
514
+ var textStore = [];
515
+ return function replace(index, replacement) {
516
+ textStore[index] = replacement;
517
+ return textStore.filter(Boolean).join('\n');
518
+ };
519
+ }();
520
+
521
+ function applyToSingletonTag(style, index, remove, obj) {
522
+ var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
523
+
524
+ /* istanbul ignore if */
525
+
526
+ if (style.styleSheet) {
527
+ style.styleSheet.cssText = replaceText(index, css);
528
+ } else {
529
+ var cssNode = document.createTextNode(css);
530
+ var childNodes = style.childNodes;
531
+
532
+ if (childNodes[index]) {
533
+ style.removeChild(childNodes[index]);
534
+ }
535
+
536
+ if (childNodes.length) {
537
+ style.insertBefore(cssNode, childNodes[index]);
538
+ } else {
539
+ style.appendChild(cssNode);
540
+ }
541
+ }
542
+ }
543
+
544
+ function applyToTag(style, options, obj) {
545
+ var css = obj.css;
546
+ var media = obj.media;
547
+ var sourceMap = obj.sourceMap;
548
+
549
+ if (media) {
550
+ style.setAttribute('media', media);
551
+ } else {
552
+ style.removeAttribute('media');
553
+ }
554
+
555
+ if (sourceMap && btoa) {
556
+ css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
557
+ } // For old IE
558
+
559
+ /* istanbul ignore if */
560
+
561
+
562
+ if (style.styleSheet) {
563
+ style.styleSheet.cssText = css;
564
+ } else {
565
+ while (style.firstChild) {
566
+ style.removeChild(style.firstChild);
567
+ }
568
+
569
+ style.appendChild(document.createTextNode(css));
570
+ }
571
+ }
572
+
573
+ var singleton = null;
574
+ var singletonCounter = 0;
575
+
576
+ function addStyle(obj, options) {
577
+ var style;
578
+ var update;
579
+ var remove;
580
+
581
+ if (options.singleton) {
582
+ var styleIndex = singletonCounter++;
583
+ style = singleton || (singleton = insertStyleElement(options));
584
+ update = applyToSingletonTag.bind(null, style, styleIndex, false);
585
+ remove = applyToSingletonTag.bind(null, style, styleIndex, true);
586
+ } else {
587
+ style = insertStyleElement(options);
588
+ update = applyToTag.bind(null, style, options);
589
+
590
+ remove = function remove() {
591
+ removeStyleElement(style);
592
+ };
593
+ }
594
+
595
+ update(obj);
596
+ return function updateStyle(newObj) {
597
+ if (newObj) {
598
+ if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
599
+ return;
600
+ }
601
+
602
+ update(obj = newObj);
603
+ } else {
604
+ remove();
605
+ }
606
+ };
607
+ }
608
+
609
+ module.exports = function (list, options) {
610
+ options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
611
+ // tags it will allow on a page
612
+
613
+ if (!options.singleton && typeof options.singleton !== 'boolean') {
614
+ options.singleton = isOldIE();
615
+ }
616
+
617
+ list = list || [];
618
+ var lastIdentifiers = modulesToDom(list, options);
619
+ return function update(newList) {
620
+ newList = newList || [];
621
+
622
+ if (Object.prototype.toString.call(newList) !== '[object Array]') {
623
+ return;
624
+ }
625
+
626
+ for (var i = 0; i < lastIdentifiers.length; i++) {
627
+ var identifier = lastIdentifiers[i];
628
+ var index = getIndexByIdentifier(identifier);
629
+ stylesInDom[index].references--;
630
+ }
631
+
632
+ var newLastIdentifiers = modulesToDom(newList, options);
633
+
634
+ for (var _i = 0; _i < lastIdentifiers.length; _i++) {
635
+ var _identifier = lastIdentifiers[_i];
636
+
637
+ var _index = getIndexByIdentifier(_identifier);
638
+
639
+ if (stylesInDom[_index].references === 0) {
640
+ stylesInDom[_index].updater();
641
+
642
+ stylesInDom.splice(_index, 1);
643
+ }
644
+ }
645
+
646
+ lastIdentifiers = newLastIdentifiers;
647
+ };
648
+ };
649
+
650
+ /***/ })
651
+
652
+ /******/ });
653
+ //# sourceMappingURL=application-0dded7840d00b04c8937.js.map