/**! * polycon - v0.2.3 * revision: cced72aa4f7be70117433d69eb21b8778e9958b9 * update: 2016-11-15 * Author: Yusuke Hirao [http://yusukehirao.github.io/polycon/] * Github: https://github.com/YusukeHirao/polycon.git * License: Licensed under the MIT License */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.l = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // identity function for calling harmory imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ // define getter function for harmory exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ }; /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 84); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { var store = __webpack_require__(27)('wks') , uid = __webpack_require__(14) , Symbol = __webpack_require__(1).Symbol , USE_SYMBOL = typeof Symbol == 'function'; var $exports = module.exports = function(name){ return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); }; $exports.store = store; /***/ }, /* 1 */ /***/ function(module, exports) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef /***/ }, /* 2 */ /***/ function(module, exports) { module.exports = function(it){ return typeof it === 'object' ? it !== null : typeof it === 'function'; }; /***/ }, /* 3 */ /***/ function(module, exports) { var hasOwnProperty = {}.hasOwnProperty; module.exports = function(it, key){ return hasOwnProperty.call(it, key); }; /***/ }, /* 4 */ /***/ function(module, exports, __webpack_require__) { var isObject = __webpack_require__(2); module.exports = function(it){ if(!isObject(it))throw TypeError(it + ' is not an object!'); return it; }; /***/ }, /* 5 */ /***/ function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , hide = __webpack_require__(6) , has = __webpack_require__(3) , SRC = __webpack_require__(14)('src') , TO_STRING = 'toString' , $toString = Function[TO_STRING] , TPL = ('' + $toString).split(TO_STRING); __webpack_require__(8).inspectSource = function(it){ return $toString.call(it); }; (module.exports = function(O, key, val, safe){ var isFunction = typeof val == 'function'; if(isFunction)has(val, 'name') || hide(val, 'name', key); if(O[key] === val)return; if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); if(O === global){ O[key] = val; } else { if(!safe){ delete O[key]; hide(O, key, val); } else { if(O[key])O[key] = val; else hide(O, key, val); } } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString(){ return typeof this == 'function' && this[SRC] || $toString.call(this); }); /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { var dP = __webpack_require__(11) , createDesc = __webpack_require__(18); module.exports = __webpack_require__(9) ? function(object, key, value){ return dP.f(object, key, createDesc(1, value)); } : function(object, key, value){ object[key] = value; return object; }; /***/ }, /* 7 */ /***/ function(module, exports, __webpack_require__) { // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = __webpack_require__(23) , defined = __webpack_require__(36); module.exports = function(it){ return IObject(defined(it)); }; /***/ }, /* 8 */ /***/ function(module, exports) { var core = module.exports = {version: '2.4.0'}; if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty module.exports = !__webpack_require__(10)(function(){ return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; }); /***/ }, /* 10 */ /***/ function(module, exports) { module.exports = function(exec){ try { return !!exec(); } catch(e){ return true; } }; /***/ }, /* 11 */ /***/ function(module, exports, __webpack_require__) { var anObject = __webpack_require__(4) , IE8_DOM_DEFINE = __webpack_require__(39) , toPrimitive = __webpack_require__(30) , dP = Object.defineProperty; exports.f = __webpack_require__(9) ? Object.defineProperty : function defineProperty(O, P, Attributes){ anObject(O); P = toPrimitive(P, true); anObject(Attributes); if(IE8_DOM_DEFINE)try { return dP(O, P, Attributes); } catch(e){ /* empty */ } if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); if('value' in Attributes)O[P] = Attributes.value; return O; }; /***/ }, /* 12 */ /***/ function(module, exports) { module.exports = {}; /***/ }, /* 13 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = __webpack_require__(44) , enumBugKeys = __webpack_require__(21); module.exports = Object.keys || function keys(O){ return $keys(O, enumBugKeys); }; /***/ }, /* 14 */ /***/ function(module, exports) { var id = 0 , px = Math.random(); module.exports = function(key){ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; /***/ }, /* 15 */ /***/ function(module, exports, __webpack_require__) { // optional / simple context binding var aFunction = __webpack_require__(54); module.exports = function(fn, that, length){ aFunction(fn); if(that === undefined)return fn; switch(length){ case 1: return function(a){ return fn.call(that, a); }; case 2: return function(a, b){ return fn.call(that, a, b); }; case 3: return function(a, b, c){ return fn.call(that, a, b, c); }; } return function(/* ...args */){ return fn.apply(that, arguments); }; }; /***/ }, /* 16 */ /***/ function(module, exports, __webpack_require__) { var META = __webpack_require__(14)('meta') , isObject = __webpack_require__(2) , has = __webpack_require__(3) , setDesc = __webpack_require__(11).f , id = 0; var isExtensible = Object.isExtensible || function(){ return true; }; var FREEZE = !__webpack_require__(10)(function(){ return isExtensible(Object.preventExtensions({})); }); var setMeta = function(it){ setDesc(it, META, {value: { i: 'O' + ++id, // object ID w: {} // weak collections IDs }}); }; var fastKey = function(it, create){ // return primitive with prefix if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; if(!has(it, META)){ // can't set metadata to uncaught frozen object if(!isExtensible(it))return 'F'; // not necessary to add metadata if(!create)return 'E'; // add missing metadata setMeta(it); // return object ID } return it[META].i; }; var getWeak = function(it, create){ if(!has(it, META)){ // can't set metadata to uncaught frozen object if(!isExtensible(it))return true; // not necessary to add metadata if(!create)return false; // add missing metadata setMeta(it); // return hash weak collections IDs } return it[META].w; }; // add metadata on freeze-family methods calling var onFreeze = function(it){ if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it); return it; }; var meta = module.exports = { KEY: META, NEED: false, fastKey: fastKey, getWeak: getWeak, onFreeze: onFreeze }; /***/ }, /* 17 */ /***/ function(module, exports) { exports.f = {}.propertyIsEnumerable; /***/ }, /* 18 */ /***/ function(module, exports) { module.exports = function(bitmap, value){ return { enumerable : !(bitmap & 1), configurable: !(bitmap & 2), writable : !(bitmap & 4), value : value }; }; /***/ }, /* 19 */ /***/ function(module, exports, __webpack_require__) { var def = __webpack_require__(11).f , has = __webpack_require__(3) , TAG = __webpack_require__(0)('toStringTag'); module.exports = function(it, tag, stat){ if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); }; /***/ }, /* 20 */ /***/ function(module, exports) { var toString = {}.toString; module.exports = function(it){ return toString.call(it).slice(8, -1); }; /***/ }, /* 21 */ /***/ function(module, exports) { // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); /***/ }, /* 22 */ /***/ function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , core = __webpack_require__(8) , hide = __webpack_require__(6) , redefine = __webpack_require__(5) , ctx = __webpack_require__(15) , PROTOTYPE = 'prototype'; var $export = function(type, name, source){ var IS_FORCED = type & $export.F , IS_GLOBAL = type & $export.G , IS_STATIC = type & $export.S , IS_PROTO = type & $export.P , IS_BIND = type & $export.B , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}) , key, own, out, exp; if(IS_GLOBAL)source = name; for(key in source){ // contains in native own = !IS_FORCED && target && target[key] !== undefined; // export native or passed out = (own ? target : source)[key]; // bind timers to global for call from export context exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; // extend global if(target)redefine(target, key, out, type & $export.U); // export if(exports[key] != out)hide(exports, key, exp); if(IS_PROTO && expProto[key] != out)expProto[key] = out; } }; global.core = core; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; /***/ }, /* 23 */ /***/ function(module, exports, __webpack_require__) { // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = __webpack_require__(20); module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ return cof(it) == 'String' ? it.split('') : Object(it); }; /***/ }, /* 24 */ /***/ function(module, exports) { module.exports = false; /***/ }, /* 25 */ /***/ function(module, exports) { exports.f = Object.getOwnPropertySymbols; /***/ }, /* 26 */ /***/ function(module, exports, __webpack_require__) { var shared = __webpack_require__(27)('keys') , uid = __webpack_require__(14); module.exports = function(key){ return shared[key] || (shared[key] = uid(key)); }; /***/ }, /* 27 */ /***/ function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , SHARED = '__core-js_shared__' , store = global[SHARED] || (global[SHARED] = {}); module.exports = function(key){ return store[key] || (store[key] = {}); }; /***/ }, /* 28 */ /***/ function(module, exports, __webpack_require__) { // 7.1.15 ToLength var toInteger = __webpack_require__(46) , min = Math.min; module.exports = function(it){ return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; /***/ }, /* 29 */ /***/ function(module, exports, __webpack_require__) { // 7.1.13 ToObject(argument) var defined = __webpack_require__(36); module.exports = function(it){ return Object(defined(it)); }; /***/ }, /* 30 */ /***/ function(module, exports, __webpack_require__) { // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = __webpack_require__(2); // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string module.exports = function(it, S){ if(!isObject(it))return it; var fn, val; if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; throw TypeError("Can't convert object to primitive value"); }; /***/ }, /* 31 */ /***/ function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , core = __webpack_require__(8) , LIBRARY = __webpack_require__(24) , wksExt = __webpack_require__(47) , defineProperty = __webpack_require__(11).f; module.exports = function(name){ var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)}); }; /***/ }, /* 32 */ /***/ function(module, exports, __webpack_require__) { __webpack_require__(48); __webpack_require__(83); __webpack_require__(80); module.exports = __webpack_require__(8).WeakMap; /***/ }, /* 33 */ /***/ function(module, exports) { module.exports = function(it, Constructor, name, forbiddenField){ if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){ throw TypeError(name + ': incorrect invocation!'); } return it; }; /***/ }, /* 34 */ /***/ function(module, exports, __webpack_require__) { // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter // 3 -> Array#some // 4 -> Array#every // 5 -> Array#find // 6 -> Array#findIndex var ctx = __webpack_require__(15) , IObject = __webpack_require__(23) , toObject = __webpack_require__(29) , toLength = __webpack_require__(28) , asc = __webpack_require__(58); module.exports = function(TYPE, $create){ var IS_MAP = TYPE == 1 , IS_FILTER = TYPE == 2 , IS_SOME = TYPE == 3 , IS_EVERY = TYPE == 4 , IS_FIND_INDEX = TYPE == 6 , NO_HOLES = TYPE == 5 || IS_FIND_INDEX , create = $create || asc; return function($this, callbackfn, that){ var O = toObject($this) , self = IObject(O) , f = ctx(callbackfn, that, 3) , length = toLength(self.length) , index = 0 , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined , val, res; for(;length > index; index++)if(NO_HOLES || index in self){ val = self[index]; res = f(val, index, O); if(TYPE){ if(IS_MAP)result[index] = res; // map else if(res)switch(TYPE){ case 3: return true; // some case 5: return val; // find case 6: return index; // findIndex case 2: result.push(val); // filter } else if(IS_EVERY)return false; // every } } return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; }; }; /***/ }, /* 35 */ /***/ function(module, exports, __webpack_require__) { // getting tag from 19.1.3.6 Object.prototype.toString() var cof = __webpack_require__(20) , TAG = __webpack_require__(0)('toStringTag') // ES3 wrong here , ARG = cof(function(){ return arguments; }()) == 'Arguments'; // fallback for IE11 Script Access Denied error var tryGet = function(it, key){ try { return it[key]; } catch(e){ /* empty */ } }; module.exports = function(it){ var O, T, B; return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T // builtinTag case : ARG ? cof(O) // ES3 arguments fallback : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; /***/ }, /* 36 */ /***/ function(module, exports) { // 7.2.1 RequireObjectCoercible(argument) module.exports = function(it){ if(it == undefined)throw TypeError("Can't call method on " + it); return it; }; /***/ }, /* 37 */ /***/ function(module, exports, __webpack_require__) { var isObject = __webpack_require__(2) , document = __webpack_require__(1).document // in old IE typeof document.createElement is 'object' , is = isObject(document) && isObject(document.createElement); module.exports = function(it){ return is ? document.createElement(it) : {}; }; /***/ }, /* 38 */ /***/ function(module, exports, __webpack_require__) { var ctx = __webpack_require__(15) , call = __webpack_require__(65) , isArrayIter = __webpack_require__(64) , anObject = __webpack_require__(4) , toLength = __webpack_require__(28) , getIterFn = __webpack_require__(77) , BREAK = {} , RETURN = {}; var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){ var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable) , f = ctx(fn, that, entries ? 2 : 1) , index = 0 , length, step, iterator, result; if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!'); // fast case for arrays with default iterator if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){ result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); if(result === BREAK || result === RETURN)return result; } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ result = call(iterator, f, step.value, entries); if(result === BREAK || result === RETURN)return result; } }; exports.BREAK = BREAK; exports.RETURN = RETURN; /***/ }, /* 39 */ /***/ function(module, exports, __webpack_require__) { module.exports = !__webpack_require__(9) && !__webpack_require__(10)(function(){ return Object.defineProperty(__webpack_require__(37)('div'), 'a', {get: function(){ return 7; }}).a != 7; }); /***/ }, /* 40 */ /***/ function(module, exports, __webpack_require__) { // 7.2.2 IsArray(argument) var cof = __webpack_require__(20); module.exports = Array.isArray || function isArray(arg){ return cof(arg) == 'Array'; }; /***/ }, /* 41 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = __webpack_require__(4) , dPs = __webpack_require__(72) , enumBugKeys = __webpack_require__(21) , IE_PROTO = __webpack_require__(26)('IE_PROTO') , Empty = function(){ /* empty */ } , PROTOTYPE = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype var createDict = function(){ // Thrash, waste and sodomy: IE GC bug var iframe = __webpack_require__(37)('iframe') , i = enumBugKeys.length , lt = '<' , gt = '>' , iframeDocument; iframe.style.display = 'none'; __webpack_require__(62).appendChild(iframe); iframe.src = 'javascript:'; // eslint-disable-line no-script-url // createDict = iframe.contentWindow.Object; // html.removeChild(iframe); iframeDocument = iframe.contentWindow.document; iframeDocument.open(); iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); iframeDocument.close(); createDict = iframeDocument.F; while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]]; return createDict(); }; module.exports = Object.create || function create(O, Properties){ var result; if(O !== null){ Empty[PROTOTYPE] = anObject(O); result = new Empty; Empty[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill result[IE_PROTO] = O; } else result = createDict(); return Properties === undefined ? result : dPs(result, Properties); }; /***/ }, /* 42 */ /***/ function(module, exports, __webpack_require__) { var pIE = __webpack_require__(17) , createDesc = __webpack_require__(18) , toIObject = __webpack_require__(7) , toPrimitive = __webpack_require__(30) , has = __webpack_require__(3) , IE8_DOM_DEFINE = __webpack_require__(39) , gOPD = Object.getOwnPropertyDescriptor; exports.f = __webpack_require__(9) ? gOPD : function getOwnPropertyDescriptor(O, P){ O = toIObject(O); P = toPrimitive(P, true); if(IE8_DOM_DEFINE)try { return gOPD(O, P); } catch(e){ /* empty */ } if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]); }; /***/ }, /* 43 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) var $keys = __webpack_require__(44) , hiddenKeys = __webpack_require__(21).concat('length', 'prototype'); exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){ return $keys(O, hiddenKeys); }; /***/ }, /* 44 */ /***/ function(module, exports, __webpack_require__) { var has = __webpack_require__(3) , toIObject = __webpack_require__(7) , arrayIndexOf = __webpack_require__(56)(false) , IE_PROTO = __webpack_require__(26)('IE_PROTO'); module.exports = function(object, names){ var O = toIObject(object) , i = 0 , result = [] , key; for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); // Don't enum bug & hidden keys while(names.length > i)if(has(O, key = names[i++])){ ~arrayIndexOf(result, key) || result.push(key); } return result; }; /***/ }, /* 45 */ /***/ function(module, exports, __webpack_require__) { var redefine = __webpack_require__(5); module.exports = function(target, src, safe){ for(var key in src)redefine(target, key, src[key], safe); return target; }; /***/ }, /* 46 */ /***/ function(module, exports) { // 7.1.4 ToInteger var ceil = Math.ceil , floor = Math.floor; module.exports = function(it){ return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; /***/ }, /* 47 */ /***/ function(module, exports, __webpack_require__) { exports.f = __webpack_require__(0); /***/ }, /* 48 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; // 19.1.3.6 Object.prototype.toString() var classof = __webpack_require__(35) , test = {}; test[__webpack_require__(0)('toStringTag')] = 'z'; if(test + '' != '[object z]'){ __webpack_require__(5)(Object.prototype, 'toString', function toString(){ return '[object ' + classof(this) + ']'; }, true); } /***/ }, /* 49 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } __webpack_require__(32); var FlexPointList_1 = __webpack_require__(52); var NS_SVG = 'http://www.w3.org/2000/svg'; var ATTRIBUTE_NAME = 'data-polycon-node'; var STYLE_NODE_NAME = 'style'; var ROOT_NODE_NAME = 'root'; var BACKGROUND_NODE_NAME = 'background'; var STYLE_SELECTOR = "[" + ATTRIBUTE_NAME + "=\"" + STYLE_NODE_NAME + "\"]"; var ROOT_SELECTOR = "[" + ATTRIBUTE_NAME + "=\"" + ROOT_NODE_NAME + "\"]"; var BACKGROUND_SELECTOR = "[" + ATTRIBUTE_NAME + "=\"" + BACKGROUND_NODE_NAME + "\"]"; var SVG_LENGTHTYPE_PX = SVGLength.SVG_LENGTHTYPE_PX; var rootMap = new WeakMap(); var svgMap = new WeakMap(); var polygonMap = new WeakMap(); var Polycon = function () { /** * create a `Polycon` element * * @param el An element */ function Polycon(el) { _classCallCheck(this, Polycon); if (!(el instanceof Element)) { throw new TypeError("Invalid argument type"); } var rect = el.getBoundingClientRect(); var points = el.getAttribute('data-points') || ''; this._id = Polycon._createUUID(); this._width = rect.width; this._height = rect.height; this.el = el; this._styleTransport(); this._createSVG(); this._setPoints(points); Polycon._setStyle(); el.setAttribute(ATTRIBUTE_NAME, ROOT_NODE_NAME); window.addEventListener('resize', this._onResize.bind(this), false); } /** * Create a new instance or instance list * * @param selector A selector string or an element or element List */ _createClass(Polycon, [{ key: "_styleTransport", /** * Inheritance of styles * */ value: function _styleTransport() { var el = this.el; this._backgroundImage = Polycon._getBackgroundImagePath(el); this._backgroundColor = Polycon._getBackgroundColor(el); } /** * Create a SVG element for psuedo-background * * ```html * * * * * * * * * ``` */ }, { key: "_createSVG", value: function _createSVG() { var svg = document.createElementNS(NS_SVG, 'svg'); svg.setAttribute('role', 'presentation'); svg.setAttribute(ATTRIBUTE_NAME, BACKGROUND_NODE_NAME); svg.width.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, this._width); svg.height.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, this._height); var polygon = document.createElementNS(NS_SVG, 'polygon'); svg.appendChild(polygon); var fill = ''; if (this._backgroundImage) { var fillId = "fill-" + this._id; this._patternImage(svg, fillId); fill = "url(#" + fillId + ")"; } else if (this._backgroundColor) { fill = this._backgroundColor; } if (fill) { polygon.setAttribute('fill', fill); } this.el.appendChild(svg); this.svg = svg; this.polygon = polygon; } /** * Create a pattern for background image */ }, { key: "_patternImage", value: function _patternImage(svg, id) { var defs = document.createElementNS(NS_SVG, 'defs'); var pattern = document.createElementNS(NS_SVG, 'pattern'); pattern.id = id; pattern.setAttribute('patternUnits', 'userSpaceOnUse'); pattern.x.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, 0); pattern.y.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, 0); var image = document.createElementNS(NS_SVG, 'image'); image.x.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, 0); image.y.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, 0); image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this._backgroundImage); pattern.appendChild(image); defs.appendChild(pattern); svg.appendChild(defs); var img = new Image(); img.onload = this._onLoadedImage.bind(this, img, pattern, image); img.src = this._backgroundImage; } /** * Set image sizes when loaded image * * @param width Width of loaded background image * @param height Height of loaded background image * @param pattern `` element for background image * @param image `` element for background image */ }, { key: "_onLoadedImage", value: function _onLoadedImage(_ref, pattern, image) { var width = _ref.width, height = _ref.height; var ratio = window.devicePixelRatio || 1; pattern.width.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, width / ratio); pattern.height.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, height / ratio); image.width.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, width / ratio); image.height.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, height / ratio); } /** * Set points(vertices) at first time */ }, { key: "_setPoints", value: function _setPoints(points) { this._points = new FlexPointList_1.default(points); var l = this._points.length; var pointsAttr = this.polygon.points; for (var i = 0; i < l; i++) { var _points$update = this._points.update(i, this._width, this._height), newPoint = _points$update.newPoint; if (newPoint) { var point = this.svg.createSVGPoint(); point.x = newPoint.x; point.y = newPoint.y; pointsAttr.appendItem(point); } } } /** * Update points(vertices) */ }, { key: "_update", value: function _update() { var rect = this.el.getBoundingClientRect(); this._width = rect.width; this._height = rect.height; var svg = this.svg; svg.width.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, this._width); svg.height.baseVal.newValueSpecifiedUnits(SVG_LENGTHTYPE_PX, this._height); var l = this._points.length; var pointsAttr = this.polygon.points; for (var i = 0; i < l; i++) { var _points$update2 = this._points.update(i, this._width, this._height), isChanged = _points$update2.isChanged, newPoint = _points$update2.newPoint; if (isChanged && newPoint) { var point = this.svg.createSVGPoint(); point.x = newPoint.x; point.y = newPoint.y; pointsAttr.replaceItem(point, i); } } } /** * A resize handler */ }, { key: "_onResize", value: function _onResize(e) { if (window.requestAnimationFrame) { if (window.cancelAnimationFrame) { cancelAnimationFrame(this._rafid); } this._rafid = window.requestAnimationFrame(this._update.bind(this)); } else { this._update(); } } }, { key: "el", /** * A corresponding element */ set: function set(el) { rootMap.set(this, el); }, get: function get() { return rootMap.get(this); } /** * An innerHTML string of corresponding element * * @readonly */ }, { key: "innerHTML", get: function get() { return this.el.innerHTML; } /** * A polygonal SVG element */ }, { key: "svg", set: function set(svg) { svgMap.set(this, svg); }, get: function get() { return svgMap.get(this); } /** * An element of `` in SVG element */ }, { key: "polygon", set: function set(polygon) { polygonMap.set(this, polygon); }, get: function get() { return polygonMap.get(this); } }], [{ key: "new", value: function _new(selector) { var nodeList = void 0; if (selector instanceof Node) { return new Polycon(selector); } else if (typeof selector === 'string') { nodeList = document.querySelectorAll(selector); } else if (selector instanceof NodeList) { nodeList = selector; } else { throw new TypeError("Invalid argument type"); } var polycons = []; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = nodeList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var el = _step.value; polycons.push(new Polycon(el)); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return polycons; } /** * Create string of UUID */ }, { key: "_createUUID", value: function _createUUID() { return Math.round(Date.now() * Math.random()).toString(36); } /** * Get path of background image from an element */ }, { key: "_getBackgroundImagePath", value: function _getBackgroundImagePath(el) { var style = window.getComputedStyle(el); var styleValue = style.getPropertyValue('background-image'); if (!styleValue) { return ''; } var matchArray = styleValue.match(/url\(("|')?([^\)]*)\1\)/); if (!matchArray) { return ''; } var _matchArray = _slicedToArray(matchArray, 3), path = _matchArray[2]; return path || ''; } /** * Get color of background from an element */ }, { key: "_getBackgroundColor", value: function _getBackgroundColor(el) { var style = window.getComputedStyle(el); var colorCode = style.getPropertyValue('background-color'); return colorCode || ''; } /** * Create a `