dll.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  1. var dll =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, {
  41. /******/ configurable: false,
  42. /******/ enumerable: true,
  43. /******/ get: getter
  44. /******/ });
  45. /******/ }
  46. /******/ };
  47. /******/
  48. /******/ // getDefaultExport function for compatibility with non-harmony modules
  49. /******/ __webpack_require__.n = function(module) {
  50. /******/ var getter = module && module.__esModule ?
  51. /******/ function getDefault() { return module['default']; } :
  52. /******/ function getModuleExports() { return module; };
  53. /******/ __webpack_require__.d(getter, 'a', getter);
  54. /******/ return getter;
  55. /******/ };
  56. /******/
  57. /******/ // Object.prototype.hasOwnProperty.call
  58. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  59. /******/
  60. /******/ // __webpack_public_path__
  61. /******/ __webpack_require__.p = "";
  62. /******/
  63. /******/ // Load entry module and return exports
  64. /******/ return __webpack_require__(__webpack_require__.s = 1);
  65. /******/ })
  66. /************************************************************************/
  67. /******/ ([
  68. /* 0 */
  69. /***/ (function(module, exports) {
  70. var g;
  71. // This works in non-strict mode
  72. g = (function() {
  73. return this;
  74. })();
  75. try {
  76. // This works if eval is allowed (see CSP)
  77. g = g || Function("return this")() || (1,eval)("this");
  78. } catch(e) {
  79. // This works if the window reference is available
  80. if(typeof window === "object")
  81. g = window;
  82. }
  83. // g can still be undefined, but nothing to do about it...
  84. // We return undefined, instead of nothing here, so it's
  85. // easier to handle this case. if(!global) { ...}
  86. module.exports = g;
  87. /***/ }),
  88. /* 1 */
  89. /***/ (function(module, exports, __webpack_require__) {
  90. module.exports = __webpack_require__;
  91. /***/ }),
  92. /* 2 */
  93. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94. "use strict";
  95. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  96. /* harmony export (immutable) */ __webpack_exports__["dll"] = dll;
  97. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assets_facebook_svg__ = __webpack_require__(3);
  98. function dll() {
  99. console.log('dll module');
  100. }
  101. /***/ }),
  102. /* 3 */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  106. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_browser_symbol_js__ = __webpack_require__(4);
  107. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_browser_symbol_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_browser_symbol_js__);
  108. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__runtime_browser_sprite_build_js__ = __webpack_require__(5);
  109. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__runtime_browser_sprite_build_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__runtime_browser_sprite_build_js__);
  110. var symbol = new __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_browser_symbol_js___default.a({
  111. "id": "facebook",
  112. "use": "facebook-usage",
  113. "viewBox": "0 0 1000 1000",
  114. "content": "<symbol xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1000 1000\" id=\"facebook\"><path d=\"M990 500c0-270.6-219.4-490-490-490S10 229.4 10 500s219.4 490 490 490 490-219.4 490-490zm-935.5 0C54.5 254 254 54.5 500 54.5S945.5 254 945.5 500 746.1 945.5 500 945.5C254 945.5 54.5 746 54.5 500z\" /><path d=\"M518.8 782.8V500h93.3l14.7-93.7h-108v-47c0-24.5 8-47.8 43.1-47.8h70.2V218h-99.6c-83.7 0-106.6 55.1-106.6 131.6v56.7h-57.5V500h57.5v282.8h92.9z\" /></symbol>"
  115. });
  116. var result = __WEBPACK_IMPORTED_MODULE_1__runtime_browser_sprite_build_js___default.a.add(symbol);
  117. /* harmony default export */ __webpack_exports__["default"] = (symbol);
  118. /***/ }),
  119. /* 4 */
  120. /***/ (function(module, exports, __webpack_require__) {
  121. /* WEBPACK VAR INJECTION */(function(global) {(function (global, factory) {
  122. true ? module.exports = factory() :
  123. typeof define === 'function' && define.amd ? define(factory) :
  124. (global.BrowserSpriteSymbol = factory());
  125. }(this, (function () { 'use strict';
  126. var SpriteSymbol = function SpriteSymbol(ref) {
  127. var id = ref.id;
  128. var viewBox = ref.viewBox;
  129. var content = ref.content;
  130. this.id = id;
  131. this.viewBox = viewBox;
  132. this.content = content;
  133. };
  134. /**
  135. * @return {string}
  136. */
  137. SpriteSymbol.prototype.stringify = function stringify () {
  138. return this.content;
  139. };
  140. /**
  141. * @return {string}
  142. */
  143. SpriteSymbol.prototype.toString = function toString () {
  144. return this.stringify();
  145. };
  146. SpriteSymbol.prototype.destroy = function destroy () {
  147. var this$1 = this;
  148. ['id', 'viewBox', 'content'].forEach(function (prop) { return delete this$1[prop]; });
  149. };
  150. /**
  151. * @param {string} content
  152. * @return {Element}
  153. */
  154. var parse = function (content) {
  155. var hasImportNode = !!document.importNode;
  156. var doc = new DOMParser().parseFromString(content, 'image/svg+xml').documentElement;
  157. /**
  158. * Fix for browser which are throwing WrongDocumentError
  159. * if you insert an element which is not part of the document
  160. * @see http://stackoverflow.com/a/7986519/4624403
  161. */
  162. if (hasImportNode) {
  163. return document.importNode(doc, true);
  164. }
  165. return doc;
  166. };
  167. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  168. function createCommonjsModule(fn, module) {
  169. return module = { exports: {} }, fn(module, module.exports), module.exports;
  170. }
  171. var deepmerge = createCommonjsModule(function (module, exports) {
  172. (function (root, factory) {
  173. if (false) {
  174. undefined(factory);
  175. } else {
  176. module.exports = factory();
  177. }
  178. }(commonjsGlobal, function () {
  179. function isMergeableObject(val) {
  180. var nonNullObject = val && typeof val === 'object';
  181. return nonNullObject
  182. && Object.prototype.toString.call(val) !== '[object RegExp]'
  183. && Object.prototype.toString.call(val) !== '[object Date]'
  184. }
  185. function emptyTarget(val) {
  186. return Array.isArray(val) ? [] : {}
  187. }
  188. function cloneIfNecessary(value, optionsArgument) {
  189. var clone = optionsArgument && optionsArgument.clone === true;
  190. return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
  191. }
  192. function defaultArrayMerge(target, source, optionsArgument) {
  193. var destination = target.slice();
  194. source.forEach(function(e, i) {
  195. if (typeof destination[i] === 'undefined') {
  196. destination[i] = cloneIfNecessary(e, optionsArgument);
  197. } else if (isMergeableObject(e)) {
  198. destination[i] = deepmerge(target[i], e, optionsArgument);
  199. } else if (target.indexOf(e) === -1) {
  200. destination.push(cloneIfNecessary(e, optionsArgument));
  201. }
  202. });
  203. return destination
  204. }
  205. function mergeObject(target, source, optionsArgument) {
  206. var destination = {};
  207. if (isMergeableObject(target)) {
  208. Object.keys(target).forEach(function (key) {
  209. destination[key] = cloneIfNecessary(target[key], optionsArgument);
  210. });
  211. }
  212. Object.keys(source).forEach(function (key) {
  213. if (!isMergeableObject(source[key]) || !target[key]) {
  214. destination[key] = cloneIfNecessary(source[key], optionsArgument);
  215. } else {
  216. destination[key] = deepmerge(target[key], source[key], optionsArgument);
  217. }
  218. });
  219. return destination
  220. }
  221. function deepmerge(target, source, optionsArgument) {
  222. var array = Array.isArray(source);
  223. var options = optionsArgument || { arrayMerge: defaultArrayMerge };
  224. var arrayMerge = options.arrayMerge || defaultArrayMerge;
  225. if (array) {
  226. return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
  227. } else {
  228. return mergeObject(target, source, optionsArgument)
  229. }
  230. }
  231. deepmerge.all = function deepmergeAll(array, optionsArgument) {
  232. if (!Array.isArray(array) || array.length < 2) {
  233. throw new Error('first argument should be an array with at least two elements')
  234. }
  235. // we are sure there are at least 2 values, so it is safe to have no initial value
  236. return array.reduce(function(prev, next) {
  237. return deepmerge(prev, next, optionsArgument)
  238. })
  239. };
  240. return deepmerge
  241. }));
  242. });
  243. var namespaces_1 = createCommonjsModule(function (module, exports) {
  244. var namespaces = {
  245. svg: {
  246. name: 'xmlns',
  247. uri: 'http://www.w3.org/2000/svg'
  248. },
  249. xlink: {
  250. name: 'xmlns:xlink',
  251. uri: 'http://www.w3.org/1999/xlink'
  252. }
  253. };
  254. exports.default = namespaces;
  255. module.exports = exports.default;
  256. });
  257. /**
  258. * @param {Object} attrs
  259. * @return {string}
  260. */
  261. var objectToAttrsString = function (attrs) {
  262. return Object.keys(attrs).map(function (attr) {
  263. var value = attrs[attr].toString().replace(/"/g, '&quot;');
  264. return (attr + "=\"" + value + "\"");
  265. }).join(' ');
  266. };
  267. var svg = namespaces_1.svg;
  268. var xlink = namespaces_1.xlink;
  269. var defaultAttrs = {};
  270. defaultAttrs[svg.name] = svg.uri;
  271. defaultAttrs[xlink.name] = xlink.uri;
  272. /**
  273. * @param {string} [content]
  274. * @param {Object} [attributes]
  275. * @return {string}
  276. */
  277. var wrapInSvgString = function (content, attributes) {
  278. if ( content === void 0 ) content = '';
  279. var attrs = deepmerge(defaultAttrs, attributes || {});
  280. var attrsRendered = objectToAttrsString(attrs);
  281. return ("<svg " + attrsRendered + ">" + content + "</svg>");
  282. };
  283. var BrowserSpriteSymbol = (function (SpriteSymbol$$1) {
  284. function BrowserSpriteSymbol () {
  285. SpriteSymbol$$1.apply(this, arguments);
  286. }
  287. if ( SpriteSymbol$$1 ) BrowserSpriteSymbol.__proto__ = SpriteSymbol$$1;
  288. BrowserSpriteSymbol.prototype = Object.create( SpriteSymbol$$1 && SpriteSymbol$$1.prototype );
  289. BrowserSpriteSymbol.prototype.constructor = BrowserSpriteSymbol;
  290. var prototypeAccessors = { isMounted: {} };
  291. prototypeAccessors.isMounted.get = function () {
  292. return !!this.node;
  293. };
  294. /**
  295. * @param {Element} node
  296. * @return {BrowserSpriteSymbol}
  297. */
  298. BrowserSpriteSymbol.createFromExistingNode = function createFromExistingNode (node) {
  299. return new BrowserSpriteSymbol({
  300. id: node.getAttribute('id'),
  301. viewBox: node.getAttribute('viewBox'),
  302. content: node.outerHTML
  303. });
  304. };
  305. BrowserSpriteSymbol.prototype.destroy = function destroy () {
  306. if (this.isMounted) {
  307. this.unmount();
  308. }
  309. SpriteSymbol$$1.prototype.destroy.call(this);
  310. };
  311. /**
  312. * @param {Element|string} target
  313. * @return {Element}
  314. */
  315. BrowserSpriteSymbol.prototype.mount = function mount (target) {
  316. if (this.isMounted) {
  317. return this.node;
  318. }
  319. var mountTarget = typeof target === 'string' ? document.querySelector(target) : target;
  320. var node = this.render();
  321. this.node = node;
  322. mountTarget.appendChild(node);
  323. return node;
  324. };
  325. /**
  326. * @return {Element}
  327. */
  328. BrowserSpriteSymbol.prototype.render = function render () {
  329. var content = this.stringify();
  330. return parse(wrapInSvgString(content)).childNodes[0];
  331. };
  332. BrowserSpriteSymbol.prototype.unmount = function unmount () {
  333. this.node.parentNode.removeChild(this.node);
  334. };
  335. Object.defineProperties( BrowserSpriteSymbol.prototype, prototypeAccessors );
  336. return BrowserSpriteSymbol;
  337. }(SpriteSymbol));
  338. return BrowserSpriteSymbol;
  339. })));
  340. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  341. /***/ }),
  342. /* 5 */
  343. /***/ (function(module, exports, __webpack_require__) {
  344. /* WEBPACK VAR INJECTION */(function(global) {(function (global, factory) {
  345. true ? module.exports = factory() :
  346. typeof define === 'function' && define.amd ? define(factory) :
  347. (global.BrowserSprite = factory());
  348. }(this, (function () { 'use strict';
  349. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  350. function createCommonjsModule(fn, module) {
  351. return module = { exports: {} }, fn(module, module.exports), module.exports;
  352. }
  353. var deepmerge = createCommonjsModule(function (module, exports) {
  354. (function (root, factory) {
  355. if (false) {
  356. undefined(factory);
  357. } else {
  358. module.exports = factory();
  359. }
  360. }(commonjsGlobal, function () {
  361. function isMergeableObject(val) {
  362. var nonNullObject = val && typeof val === 'object';
  363. return nonNullObject
  364. && Object.prototype.toString.call(val) !== '[object RegExp]'
  365. && Object.prototype.toString.call(val) !== '[object Date]'
  366. }
  367. function emptyTarget(val) {
  368. return Array.isArray(val) ? [] : {}
  369. }
  370. function cloneIfNecessary(value, optionsArgument) {
  371. var clone = optionsArgument && optionsArgument.clone === true;
  372. return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
  373. }
  374. function defaultArrayMerge(target, source, optionsArgument) {
  375. var destination = target.slice();
  376. source.forEach(function(e, i) {
  377. if (typeof destination[i] === 'undefined') {
  378. destination[i] = cloneIfNecessary(e, optionsArgument);
  379. } else if (isMergeableObject(e)) {
  380. destination[i] = deepmerge(target[i], e, optionsArgument);
  381. } else if (target.indexOf(e) === -1) {
  382. destination.push(cloneIfNecessary(e, optionsArgument));
  383. }
  384. });
  385. return destination
  386. }
  387. function mergeObject(target, source, optionsArgument) {
  388. var destination = {};
  389. if (isMergeableObject(target)) {
  390. Object.keys(target).forEach(function (key) {
  391. destination[key] = cloneIfNecessary(target[key], optionsArgument);
  392. });
  393. }
  394. Object.keys(source).forEach(function (key) {
  395. if (!isMergeableObject(source[key]) || !target[key]) {
  396. destination[key] = cloneIfNecessary(source[key], optionsArgument);
  397. } else {
  398. destination[key] = deepmerge(target[key], source[key], optionsArgument);
  399. }
  400. });
  401. return destination
  402. }
  403. function deepmerge(target, source, optionsArgument) {
  404. var array = Array.isArray(source);
  405. var options = optionsArgument || { arrayMerge: defaultArrayMerge };
  406. var arrayMerge = options.arrayMerge || defaultArrayMerge;
  407. if (array) {
  408. return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
  409. } else {
  410. return mergeObject(target, source, optionsArgument)
  411. }
  412. }
  413. deepmerge.all = function deepmergeAll(array, optionsArgument) {
  414. if (!Array.isArray(array) || array.length < 2) {
  415. throw new Error('first argument should be an array with at least two elements')
  416. }
  417. // we are sure there are at least 2 values, so it is safe to have no initial value
  418. return array.reduce(function(prev, next) {
  419. return deepmerge(prev, next, optionsArgument)
  420. })
  421. };
  422. return deepmerge
  423. }));
  424. });
  425. //
  426. // An event handler can take an optional event argument
  427. // and should not return a value
  428. // An array of all currently registered event handlers for a type
  429. // A map of event types and their corresponding event handlers.
  430. /** Mitt: Tiny (~200b) functional event emitter / pubsub.
  431. * @name mitt
  432. * @returns {Mitt}
  433. */
  434. function mitt(all ) {
  435. all = all || Object.create(null);
  436. return {
  437. /**
  438. * Register an event handler for the given type.
  439. *
  440. * @param {String} type Type of event to listen for, or `"*"` for all events
  441. * @param {Function} handler Function to call in response to given event
  442. * @memberOf mitt
  443. */
  444. on: function on(type , handler ) {
  445. (all[type] || (all[type] = [])).push(handler);
  446. },
  447. /**
  448. * Remove an event handler for the given type.
  449. *
  450. * @param {String} type Type of event to unregister `handler` from, or `"*"`
  451. * @param {Function} handler Handler function to remove
  452. * @memberOf mitt
  453. */
  454. off: function off(type , handler ) {
  455. if (all[type]) {
  456. all[type].splice(all[type].indexOf(handler) >>> 0, 1);
  457. }
  458. },
  459. /**
  460. * Invoke all handlers for the given type.
  461. * If present, `"*"` handlers are invoked after type-matched handlers.
  462. *
  463. * @param {String} type The event type to invoke
  464. * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
  465. * @memberof mitt
  466. */
  467. emit: function emit(type , evt ) {
  468. (all[type] || []).map(function (handler) { handler(evt); });
  469. (all['*'] || []).map(function (handler) { handler(type, evt); });
  470. }
  471. };
  472. }
  473. var namespaces_1 = createCommonjsModule(function (module, exports) {
  474. var namespaces = {
  475. svg: {
  476. name: 'xmlns',
  477. uri: 'http://www.w3.org/2000/svg'
  478. },
  479. xlink: {
  480. name: 'xmlns:xlink',
  481. uri: 'http://www.w3.org/1999/xlink'
  482. }
  483. };
  484. exports.default = namespaces;
  485. module.exports = exports.default;
  486. });
  487. /**
  488. * @param {Object} attrs
  489. * @return {string}
  490. */
  491. var objectToAttrsString = function (attrs) {
  492. return Object.keys(attrs).map(function (attr) {
  493. var value = attrs[attr].toString().replace(/"/g, '&quot;');
  494. return (attr + "=\"" + value + "\"");
  495. }).join(' ');
  496. };
  497. var svg = namespaces_1.svg;
  498. var xlink = namespaces_1.xlink;
  499. var defaultAttrs = {};
  500. defaultAttrs[svg.name] = svg.uri;
  501. defaultAttrs[xlink.name] = xlink.uri;
  502. /**
  503. * @param {string} [content]
  504. * @param {Object} [attributes]
  505. * @return {string}
  506. */
  507. var wrapInSvgString = function (content, attributes) {
  508. if ( content === void 0 ) content = '';
  509. var attrs = deepmerge(defaultAttrs, attributes || {});
  510. var attrsRendered = objectToAttrsString(attrs);
  511. return ("<svg " + attrsRendered + ">" + content + "</svg>");
  512. };
  513. var svg$1 = namespaces_1.svg;
  514. var xlink$1 = namespaces_1.xlink;
  515. var defaultConfig = {
  516. attrs: ( obj = {
  517. style: ['position: absolute', 'width: 0', 'height: 0'].join('; '),
  518. 'aria-hidden': 'true'
  519. }, obj[svg$1.name] = svg$1.uri, obj[xlink$1.name] = xlink$1.uri, obj )
  520. };
  521. var obj;
  522. var Sprite = function Sprite(config) {
  523. this.config = deepmerge(defaultConfig, config || {});
  524. this.symbols = [];
  525. };
  526. /**
  527. * Add new symbol. If symbol with the same id exists it will be replaced.
  528. * @param {SpriteSymbol} symbol
  529. * @return {boolean} `true` - symbol was added, `false` - replaced
  530. */
  531. Sprite.prototype.add = function add (symbol) {
  532. var ref = this;
  533. var symbols = ref.symbols;
  534. var existing = this.find(symbol.id);
  535. if (existing) {
  536. symbols[symbols.indexOf(existing)] = symbol;
  537. return false;
  538. }
  539. symbols.push(symbol);
  540. return true;
  541. };
  542. /**
  543. * Remove symbol & destroy it
  544. * @param {string} id
  545. * @return {boolean} `true` - symbol was found & successfully destroyed, `false` - otherwise
  546. */
  547. Sprite.prototype.remove = function remove (id) {
  548. var ref = this;
  549. var symbols = ref.symbols;
  550. var symbol = this.find(id);
  551. if (symbol) {
  552. symbols.splice(symbols.indexOf(symbol), 1);
  553. symbol.destroy();
  554. return true;
  555. }
  556. return false;
  557. };
  558. /**
  559. * @param {string} id
  560. * @return {SpriteSymbol|null}
  561. */
  562. Sprite.prototype.find = function find (id) {
  563. return this.symbols.filter(function (s) { return s.id === id; })[0] || null;
  564. };
  565. /**
  566. * @param {string} id
  567. * @return {boolean}
  568. */
  569. Sprite.prototype.has = function has (id) {
  570. return this.find(id) !== null;
  571. };
  572. /**
  573. * @return {string}
  574. */
  575. Sprite.prototype.stringify = function stringify () {
  576. var ref = this.config;
  577. var attrs = ref.attrs;
  578. var stringifiedSymbols = this.symbols.map(function (s) { return s.stringify(); }).join('');
  579. return wrapInSvgString(stringifiedSymbols, attrs);
  580. };
  581. /**
  582. * @return {string}
  583. */
  584. Sprite.prototype.toString = function toString () {
  585. return this.stringify();
  586. };
  587. Sprite.prototype.destroy = function destroy () {
  588. this.symbols.forEach(function (s) { return s.destroy(); });
  589. };
  590. var SpriteSymbol = function SpriteSymbol(ref) {
  591. var id = ref.id;
  592. var viewBox = ref.viewBox;
  593. var content = ref.content;
  594. this.id = id;
  595. this.viewBox = viewBox;
  596. this.content = content;
  597. };
  598. /**
  599. * @return {string}
  600. */
  601. SpriteSymbol.prototype.stringify = function stringify () {
  602. return this.content;
  603. };
  604. /**
  605. * @return {string}
  606. */
  607. SpriteSymbol.prototype.toString = function toString () {
  608. return this.stringify();
  609. };
  610. SpriteSymbol.prototype.destroy = function destroy () {
  611. var this$1 = this;
  612. ['id', 'viewBox', 'content'].forEach(function (prop) { return delete this$1[prop]; });
  613. };
  614. /**
  615. * @param {string} content
  616. * @return {Element}
  617. */
  618. var parse = function (content) {
  619. var hasImportNode = !!document.importNode;
  620. var doc = new DOMParser().parseFromString(content, 'image/svg+xml').documentElement;
  621. /**
  622. * Fix for browser which are throwing WrongDocumentError
  623. * if you insert an element which is not part of the document
  624. * @see http://stackoverflow.com/a/7986519/4624403
  625. */
  626. if (hasImportNode) {
  627. return document.importNode(doc, true);
  628. }
  629. return doc;
  630. };
  631. var BrowserSpriteSymbol = (function (SpriteSymbol$$1) {
  632. function BrowserSpriteSymbol () {
  633. SpriteSymbol$$1.apply(this, arguments);
  634. }
  635. if ( SpriteSymbol$$1 ) BrowserSpriteSymbol.__proto__ = SpriteSymbol$$1;
  636. BrowserSpriteSymbol.prototype = Object.create( SpriteSymbol$$1 && SpriteSymbol$$1.prototype );
  637. BrowserSpriteSymbol.prototype.constructor = BrowserSpriteSymbol;
  638. var prototypeAccessors = { isMounted: {} };
  639. prototypeAccessors.isMounted.get = function () {
  640. return !!this.node;
  641. };
  642. /**
  643. * @param {Element} node
  644. * @return {BrowserSpriteSymbol}
  645. */
  646. BrowserSpriteSymbol.createFromExistingNode = function createFromExistingNode (node) {
  647. return new BrowserSpriteSymbol({
  648. id: node.getAttribute('id'),
  649. viewBox: node.getAttribute('viewBox'),
  650. content: node.outerHTML
  651. });
  652. };
  653. BrowserSpriteSymbol.prototype.destroy = function destroy () {
  654. if (this.isMounted) {
  655. this.unmount();
  656. }
  657. SpriteSymbol$$1.prototype.destroy.call(this);
  658. };
  659. /**
  660. * @param {Element|string} target
  661. * @return {Element}
  662. */
  663. BrowserSpriteSymbol.prototype.mount = function mount (target) {
  664. if (this.isMounted) {
  665. return this.node;
  666. }
  667. var mountTarget = typeof target === 'string' ? document.querySelector(target) : target;
  668. var node = this.render();
  669. this.node = node;
  670. mountTarget.appendChild(node);
  671. return node;
  672. };
  673. /**
  674. * @return {Element}
  675. */
  676. BrowserSpriteSymbol.prototype.render = function render () {
  677. var content = this.stringify();
  678. return parse(wrapInSvgString(content)).childNodes[0];
  679. };
  680. BrowserSpriteSymbol.prototype.unmount = function unmount () {
  681. this.node.parentNode.removeChild(this.node);
  682. };
  683. Object.defineProperties( BrowserSpriteSymbol.prototype, prototypeAccessors );
  684. return BrowserSpriteSymbol;
  685. }(SpriteSymbol));
  686. var defaultConfig$1 = {
  687. /**
  688. * Should following options be automatically configured:
  689. * - `syncUrlsWithBaseTag`
  690. * - `locationChangeAngularEmitter`
  691. * - `moveGradientsOutsideSymbol`
  692. * @type {boolean}
  693. */
  694. autoConfigure: true,
  695. /**
  696. * Default mounting selector
  697. * @type {string}
  698. */
  699. mountTo: 'body',
  700. /**
  701. * Fix disappearing SVG elements when <base href> exists.
  702. * Executes when sprite mounted.
  703. * @see http://stackoverflow.com/a/18265336/796152
  704. * @see https://github.com/everdimension/angular-svg-base-fix
  705. * @see https://github.com/angular/angular.js/issues/8934#issuecomment-56568466
  706. * @type {boolean}
  707. */
  708. syncUrlsWithBaseTag: false,
  709. /**
  710. * Should sprite listen custom location change event
  711. * @type {boolean}
  712. */
  713. listenLocationChangeEvent: true,
  714. /**
  715. * Custom window event name which should be emitted to update sprite urls
  716. * @type {string}
  717. */
  718. locationChangeEvent: 'locationChange',
  719. /**
  720. * Emit location change event in Angular automatically
  721. * @type {boolean}
  722. */
  723. locationChangeAngularEmitter: false,
  724. /**
  725. * Selector to find symbols usages when updating sprite urls
  726. * @type {string}
  727. */
  728. usagesToUpdate: 'use[*|href]',
  729. /**
  730. * Fix Firefox bug when gradients and patterns don't work if they are within a symbol.
  731. * Executes when sprite is rendered, but not mounted.
  732. * @see https://bugzilla.mozilla.org/show_bug.cgi?id=306674
  733. * @see https://bugzilla.mozilla.org/show_bug.cgi?id=353575
  734. * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1235364
  735. * @type {boolean}
  736. */
  737. moveGradientsOutsideSymbol: false
  738. };
  739. /**
  740. * @param {*} arrayLike
  741. * @return {Array}
  742. */
  743. var arrayFrom = function (arrayLike) {
  744. return Array.prototype.slice.call(arrayLike, 0);
  745. };
  746. var browser = {
  747. isChrome: function () { return /chrome/i.test(navigator.userAgent); },
  748. isFirefox: function () { return /firefox/i.test(navigator.userAgent); },
  749. // https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  750. isIE: function () { return /msie/i.test(navigator.userAgent) || /trident/i.test(navigator.userAgent); },
  751. isEdge: function () { return /edge/i.test(navigator.userAgent); }
  752. };
  753. /**
  754. * @param {string} name
  755. * @param {*} data
  756. */
  757. var dispatchEvent = function (name, data) {
  758. var event = document.createEvent('CustomEvent');
  759. event.initCustomEvent(name, false, false, data);
  760. window.dispatchEvent(event);
  761. };
  762. /**
  763. * IE doesn't evaluate <style> tags in SVGs that are dynamically added to the page.
  764. * This trick will trigger IE to read and use any existing SVG <style> tags.
  765. * @see https://github.com/iconic/SVGInjector/issues/23
  766. * @see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10898469/
  767. *
  768. * @param {Element} node DOM Element to search <style> tags in
  769. * @return {Array<HTMLStyleElement>}
  770. */
  771. var evalStylesIEWorkaround = function (node) {
  772. var updatedNodes = [];
  773. arrayFrom(node.querySelectorAll('style'))
  774. .forEach(function (style) {
  775. style.textContent += '';
  776. updatedNodes.push(style);
  777. });
  778. return updatedNodes;
  779. };
  780. /**
  781. * @param {string} [url] If not provided - current URL will be used
  782. * @return {string}
  783. */
  784. var getUrlWithoutFragment = function (url) {
  785. return (url || window.location.href).split('#')[0];
  786. };
  787. /* global angular */
  788. /**
  789. * @param {string} eventName
  790. */
  791. var locationChangeAngularEmitter = function (eventName) {
  792. angular.module('ng').run(['$rootScope', function ($rootScope) {
  793. $rootScope.$on('$locationChangeSuccess', function (e, newUrl, oldUrl) {
  794. dispatchEvent(eventName, { oldUrl: oldUrl, newUrl: newUrl });
  795. });
  796. }]);
  797. };
  798. var defaultSelector = 'linearGradient, radialGradient, pattern, mask, clipPath';
  799. /**
  800. * @param {Element} svg
  801. * @param {string} [selector]
  802. * @return {Element}
  803. */
  804. var moveGradientsOutsideSymbol = function (svg, selector) {
  805. if ( selector === void 0 ) selector = defaultSelector;
  806. arrayFrom(svg.querySelectorAll('symbol')).forEach(function (symbol) {
  807. arrayFrom(symbol.querySelectorAll(selector)).forEach(function (node) {
  808. symbol.parentNode.insertBefore(node, symbol);
  809. });
  810. });
  811. return svg;
  812. };
  813. /**
  814. * @param {NodeList} nodes
  815. * @param {Function} [matcher]
  816. * @return {Attr[]}
  817. */
  818. function selectAttributes(nodes, matcher) {
  819. var attrs = arrayFrom(nodes).reduce(function (acc, node) {
  820. if (!node.attributes) {
  821. return acc;
  822. }
  823. var arrayfied = arrayFrom(node.attributes);
  824. var matched = matcher ? arrayfied.filter(matcher) : arrayfied;
  825. return acc.concat(matched);
  826. }, []);
  827. return attrs;
  828. }
  829. /**
  830. * @param {NodeList|Node} nodes
  831. * @param {boolean} [clone=true]
  832. * @return {string}
  833. */
  834. var xLinkNS = namespaces_1.xlink.uri;
  835. var xLinkAttrName = 'xlink:href';
  836. // eslint-disable-next-line no-useless-escape
  837. var specialUrlCharsPattern = /[{}|\\\^\[\]`"<>]/g;
  838. function encoder(url) {
  839. return url.replace(specialUrlCharsPattern, function (match) {
  840. return ("%" + (match[0].charCodeAt(0).toString(16).toUpperCase()));
  841. });
  842. }
  843. function escapeRegExp(str) {
  844. return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
  845. }
  846. /**
  847. * @param {NodeList} nodes
  848. * @param {string} startsWith
  849. * @param {string} replaceWith
  850. * @return {NodeList}
  851. */
  852. function updateReferences(nodes, startsWith, replaceWith) {
  853. arrayFrom(nodes).forEach(function (node) {
  854. var href = node.getAttribute(xLinkAttrName);
  855. if (href && href.indexOf(startsWith) === 0) {
  856. var newUrl = href.replace(startsWith, replaceWith);
  857. node.setAttributeNS(xLinkNS, xLinkAttrName, newUrl);
  858. }
  859. });
  860. return nodes;
  861. }
  862. /**
  863. * List of SVG attributes to update url() target in them
  864. */
  865. var attList = [
  866. 'clipPath',
  867. 'colorProfile',
  868. 'src',
  869. 'cursor',
  870. 'fill',
  871. 'filter',
  872. 'marker',
  873. 'markerStart',
  874. 'markerMid',
  875. 'markerEnd',
  876. 'mask',
  877. 'stroke',
  878. 'style'
  879. ];
  880. var attSelector = attList.map(function (attr) { return ("[" + attr + "]"); }).join(',');
  881. /**
  882. * Update URLs in svg image (like `fill="url(...)"`) and update referencing elements
  883. * @param {Element} svg
  884. * @param {NodeList} references
  885. * @param {string|RegExp} startsWith
  886. * @param {string} replaceWith
  887. * @return {void}
  888. *
  889. * @example
  890. * const sprite = document.querySelector('svg.sprite');
  891. * const usages = document.querySelectorAll('use');
  892. * updateUrls(sprite, usages, '#', 'prefix#');
  893. */
  894. var updateUrls = function (svg, references, startsWith, replaceWith) {
  895. var startsWithEncoded = encoder(startsWith);
  896. var replaceWithEncoded = encoder(replaceWith);
  897. var nodes = svg.querySelectorAll(attSelector);
  898. var attrs = selectAttributes(nodes, function (ref) {
  899. var localName = ref.localName;
  900. var value = ref.value;
  901. return attList.indexOf(localName) !== -1 && value.indexOf(("url(" + startsWithEncoded)) !== -1;
  902. });
  903. attrs.forEach(function (attr) { return attr.value = attr.value.replace(new RegExp(escapeRegExp(startsWithEncoded), 'g'), replaceWithEncoded); });
  904. updateReferences(references, startsWithEncoded, replaceWithEncoded);
  905. };
  906. /**
  907. * Internal emitter events
  908. * @enum
  909. * @private
  910. */
  911. var Events = {
  912. MOUNT: 'mount',
  913. SYMBOL_MOUNT: 'symbol_mount'
  914. };
  915. var BrowserSprite = (function (Sprite$$1) {
  916. function BrowserSprite(cfg) {
  917. var this$1 = this;
  918. if ( cfg === void 0 ) cfg = {};
  919. Sprite$$1.call(this, deepmerge(defaultConfig$1, cfg));
  920. var emitter = mitt();
  921. this._emitter = emitter;
  922. this.node = null;
  923. var ref = this;
  924. var config = ref.config;
  925. if (config.autoConfigure) {
  926. this._autoConfigure(cfg);
  927. }
  928. if (config.syncUrlsWithBaseTag) {
  929. var baseUrl = document.getElementsByTagName('base')[0].getAttribute('href');
  930. emitter.on(Events.MOUNT, function () { return this$1.updateUrls('#', baseUrl); });
  931. }
  932. var handleLocationChange = this._handleLocationChange.bind(this);
  933. this._handleLocationChange = handleLocationChange;
  934. // Provide way to update sprite urls externally via dispatching custom window event
  935. if (config.listenLocationChangeEvent) {
  936. window.addEventListener(config.locationChangeEvent, handleLocationChange);
  937. }
  938. // Emit location change event in Angular automatically
  939. if (config.locationChangeAngularEmitter) {
  940. locationChangeAngularEmitter(config.locationChangeEvent);
  941. }
  942. // After sprite mounted
  943. emitter.on(Events.MOUNT, function (spriteNode) {
  944. if (config.moveGradientsOutsideSymbol) {
  945. moveGradientsOutsideSymbol(spriteNode);
  946. }
  947. });
  948. // After symbol mounted into sprite
  949. emitter.on(Events.SYMBOL_MOUNT, function (symbolNode) {
  950. if (config.moveGradientsOutsideSymbol) {
  951. moveGradientsOutsideSymbol(symbolNode.parentNode);
  952. }
  953. if (browser.isIE() || browser.isEdge()) {
  954. evalStylesIEWorkaround(symbolNode);
  955. }
  956. });
  957. }
  958. if ( Sprite$$1 ) BrowserSprite.__proto__ = Sprite$$1;
  959. BrowserSprite.prototype = Object.create( Sprite$$1 && Sprite$$1.prototype );
  960. BrowserSprite.prototype.constructor = BrowserSprite;
  961. var prototypeAccessors = { isMounted: {} };
  962. /**
  963. * @return {boolean}
  964. */
  965. prototypeAccessors.isMounted.get = function () {
  966. return !!this.node;
  967. };
  968. /**
  969. * Automatically configure following options
  970. * - `syncUrlsWithBaseTag`
  971. * - `locationChangeAngularEmitter`
  972. * - `moveGradientsOutsideSymbol`
  973. * @param {Object} cfg
  974. * @private
  975. */
  976. BrowserSprite.prototype._autoConfigure = function _autoConfigure (cfg) {
  977. var ref = this;
  978. var config = ref.config;
  979. if (typeof cfg.syncUrlsWithBaseTag === 'undefined') {
  980. config.syncUrlsWithBaseTag = typeof document.getElementsByTagName('base')[0] !== 'undefined';
  981. }
  982. if (typeof cfg.locationChangeAngularEmitter === 'undefined') {
  983. config.locationChangeAngularEmitter = typeof window.angular !== 'undefined';
  984. }
  985. if (typeof cfg.moveGradientsOutsideSymbol === 'undefined') {
  986. config.moveGradientsOutsideSymbol = browser.isFirefox();
  987. }
  988. };
  989. /**
  990. * @param {Event} event
  991. * @param {Object} event.detail
  992. * @param {string} event.detail.oldUrl
  993. * @param {string} event.detail.newUrl
  994. * @private
  995. */
  996. BrowserSprite.prototype._handleLocationChange = function _handleLocationChange (event) {
  997. var ref = event.detail;
  998. var oldUrl = ref.oldUrl;
  999. var newUrl = ref.newUrl;
  1000. this.updateUrls(oldUrl, newUrl);
  1001. };
  1002. /**
  1003. * Add new symbol. If symbol with the same id exists it will be replaced.
  1004. * If sprite already mounted - `symbol.mount(sprite.node)` will be called.
  1005. * @fires Events#SYMBOL_MOUNT
  1006. * @param {BrowserSpriteSymbol} symbol
  1007. * @return {boolean} `true` - symbol was added, `false` - replaced
  1008. */
  1009. BrowserSprite.prototype.add = function add (symbol) {
  1010. var sprite = this;
  1011. var isNewSymbol = Sprite$$1.prototype.add.call(this, symbol);
  1012. if (this.isMounted && isNewSymbol) {
  1013. symbol.mount(sprite.node);
  1014. this._emitter.emit(Events.SYMBOL_MOUNT, symbol.node);
  1015. }
  1016. return isNewSymbol;
  1017. };
  1018. /**
  1019. * Attach to existing DOM node
  1020. * @param {string|Element} target
  1021. * @return {Element|null} attached DOM Element. null if node to attach not found.
  1022. */
  1023. BrowserSprite.prototype.attach = function attach (target) {
  1024. var this$1 = this;
  1025. var sprite = this;
  1026. if (sprite.isMounted) {
  1027. return sprite.node;
  1028. }
  1029. /** @type Element */
  1030. var node = typeof target === 'string' ? document.querySelector(target) : target;
  1031. sprite.node = node;
  1032. // Already added symbols needs to be mounted
  1033. this.symbols.forEach(function (symbol) {
  1034. symbol.mount(sprite.node);
  1035. this$1._emitter.emit(Events.SYMBOL_MOUNT, symbol.node);
  1036. });
  1037. // Create symbols from existing DOM nodes, add and mount them
  1038. arrayFrom(node.querySelectorAll('symbol'))
  1039. .forEach(function (symbolNode) {
  1040. var symbol = BrowserSpriteSymbol.createFromExistingNode(symbolNode);
  1041. symbol.node = symbolNode; // hack to prevent symbol mounting to sprite when adding
  1042. sprite.add(symbol);
  1043. });
  1044. this._emitter.emit(Events.MOUNT, node);
  1045. return node;
  1046. };
  1047. BrowserSprite.prototype.destroy = function destroy () {
  1048. var ref = this;
  1049. var config = ref.config;
  1050. var symbols = ref.symbols;
  1051. var _emitter = ref._emitter;
  1052. symbols.forEach(function (s) { return s.destroy(); });
  1053. _emitter.off('*');
  1054. window.removeEventListener(config.locationChangeEvent, this._handleLocationChange);
  1055. if (this.isMounted) {
  1056. this.unmount();
  1057. }
  1058. };
  1059. /**
  1060. * @fires Events#MOUNT
  1061. * @param {string|Element} [target]
  1062. * @param {boolean} [prepend=false]
  1063. * @return {Element|null} rendered sprite node. null if mount node not found.
  1064. */
  1065. BrowserSprite.prototype.mount = function mount (target, prepend) {
  1066. if ( target === void 0 ) target = this.config.mountTo;
  1067. if ( prepend === void 0 ) prepend = false;
  1068. var sprite = this;
  1069. if (sprite.isMounted) {
  1070. return sprite.node;
  1071. }
  1072. var mountNode = typeof target === 'string' ? document.querySelector(target) : target;
  1073. var node = sprite.render();
  1074. this.node = node;
  1075. if (prepend && mountNode.childNodes[0]) {
  1076. mountNode.insertBefore(node, mountNode.childNodes[0]);
  1077. } else {
  1078. mountNode.appendChild(node);
  1079. }
  1080. this._emitter.emit(Events.MOUNT, node);
  1081. return node;
  1082. };
  1083. /**
  1084. * @return {Element}
  1085. */
  1086. BrowserSprite.prototype.render = function render () {
  1087. return parse(this.stringify());
  1088. };
  1089. /**
  1090. * Detach sprite from the DOM
  1091. */
  1092. BrowserSprite.prototype.unmount = function unmount () {
  1093. this.node.parentNode.removeChild(this.node);
  1094. };
  1095. /**
  1096. * Update URLs in sprite and usage elements
  1097. * @param {string} oldUrl
  1098. * @param {string} newUrl
  1099. * @return {boolean} `true` - URLs was updated, `false` - sprite is not mounted
  1100. */
  1101. BrowserSprite.prototype.updateUrls = function updateUrls$1 (oldUrl, newUrl) {
  1102. if (!this.isMounted) {
  1103. return false;
  1104. }
  1105. var usages = document.querySelectorAll(this.config.usagesToUpdate);
  1106. updateUrls(
  1107. this.node,
  1108. usages,
  1109. ((getUrlWithoutFragment(oldUrl)) + "#"),
  1110. ((getUrlWithoutFragment(newUrl)) + "#")
  1111. );
  1112. return true;
  1113. };
  1114. Object.defineProperties( BrowserSprite.prototype, prototypeAccessors );
  1115. return BrowserSprite;
  1116. }(Sprite));
  1117. var ready$1 = createCommonjsModule(function (module) {
  1118. /*!
  1119. * domready (c) Dustin Diaz 2014 - License MIT
  1120. */
  1121. !function (name, definition) {
  1122. { module.exports = definition(); }
  1123. }('domready', function () {
  1124. var fns = [], listener
  1125. , doc = document
  1126. , hack = doc.documentElement.doScroll
  1127. , domContentLoaded = 'DOMContentLoaded'
  1128. , loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
  1129. if (!loaded)
  1130. { doc.addEventListener(domContentLoaded, listener = function () {
  1131. doc.removeEventListener(domContentLoaded, listener);
  1132. loaded = 1;
  1133. while (listener = fns.shift()) { listener(); }
  1134. }); }
  1135. return function (fn) {
  1136. loaded ? setTimeout(fn, 0) : fns.push(fn);
  1137. }
  1138. });
  1139. });
  1140. var spriteNodeId = '__SVG_SPRITE_NODE__';
  1141. var spriteGlobalVarName = '__SVG_SPRITE__';
  1142. var isSpriteExists = !!window[spriteGlobalVarName];
  1143. // eslint-disable-next-line import/no-mutable-exports
  1144. var sprite;
  1145. if (isSpriteExists) {
  1146. sprite = window[spriteGlobalVarName];
  1147. } else {
  1148. sprite = new BrowserSprite({
  1149. attrs: {
  1150. id: spriteNodeId,
  1151. 'aria-hidden': 'true'
  1152. }
  1153. });
  1154. window[spriteGlobalVarName] = sprite;
  1155. }
  1156. var loadSprite = function () {
  1157. /**
  1158. * Check for page already contains sprite node
  1159. * If found - attach to and reuse it's content
  1160. * If not - render and mount the new sprite
  1161. */
  1162. var existing = document.getElementById(spriteNodeId);
  1163. if (existing) {
  1164. sprite.attach(existing);
  1165. } else {
  1166. sprite.mount(document.body, true);
  1167. }
  1168. };
  1169. if (document.body) {
  1170. loadSprite();
  1171. } else {
  1172. ready$1(loadSprite);
  1173. }
  1174. var sprite$1 = sprite;
  1175. return sprite$1;
  1176. })));
  1177. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  1178. /***/ })
  1179. /******/ ]);