(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else {
		var a = factory();
		for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
	}
})(this, function() {
return /******/ (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;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			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 = 13);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


module.exports = {
  xmetres: 20,
  ymetres: 80,
  fm: 'hot_click'
};

/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _config = __webpack_require__(0);

var _config2 = _interopRequireDefault(_config);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var getCount = function getCount(length, clientLength, metres) {
  return Math.round(length * metres / clientLength);
};

var getPx = function getPx(count, clientLength, metres) {
  return window.parseInt(count / metres * clientLength);
};

var isFixed = function isFixed(target) {
  return (window.getComputedStyle(target) || {}).position === 'fixed';
};

var matrix = {
  getCountPosition: function getCountPosition(event) {
    var target = event.target;

    var width = window.innerWidth;
    var height = window.innerHeight;

    if (matrix.checkInFixDom(target)) {
      return {
        x: getCount(event.clientX, width, _config2.default.xmetres),
        y: getCount(event.clientY, height, _config2.default.ymetres)
      };
    }

    return {
      x: getCount(event.clientX, width, _config2.default.xmetres),
      // 兼容ie
      y: getCount(event.clientY + document.documentElement.scrollTop, width, _config2.default.xmetres)
    };
  },
  getFlowPx: function getFlowPx(item, width) {
    item.x = getPx(item.loc_x, width, _config2.default.xmetres);
    item.y = getPx(item.loc_y, width, _config2.default.xmetres);
    return item;
  },
  getFixPx: function getFixPx(item, width, height) {
    item.x = getPx(item.loc_x, width, _config2.default.xmetres);
    item.y = getPx(item.loc_y, height, _config2.default.ymetres);
    return item;
  },
  getPxList: function getPxList(list, width, screenHeight) {
    var result = {
      flow: [],
      fix: []
    };
    var max = 0;

    list.forEach(function (item) {
      if (item.click_pv > max) {
        max = item.click_pv;
      }
    });

    if (max === 0) {
      return result;
    }

    list.forEach(function (item) {
      item.value = window.parseInt(item.click_pv / max * 100);
      if (item.is_fix * 1 === 0) {
        result.flow.push(matrix.getFlowPx(item, width));
      } else {
        result.fix.push(matrix.getFixPx(item, width, screenHeight));
      }
    });
    result.max = 100;

    return result;
  },
  checkInFixDom: function checkInFixDom(target) {
    var result = 0;

    if (isFixed(target)) {
      result = 1;
    } else {
      while (target.parentElement) {
        target = target.parentElement;
        if (isFixed(target)) {
          result = 1;
          break;
        }
      }
    }
    return result;
  }
};

exports.default = matrix;

/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.middle = undefined;
exports.default = getXPath;
exports.shouldRerender = shouldRerender;
exports.getShowBoundary = getShowBoundary;

var _constants = __webpack_require__(3);

/* eslint-disable */
function getXPath(elm) {
  try {
    var allNodes = document.getElementsByTagName('*');
    for (var segs = []; elm && elm.nodeType == 1; elm = elm.parentNode) {
      if (elm.hasAttribute('id')) {
        var uniqueIdCount = 0;
        for (var n = 0; n < allNodes.length; n++) {
          if (allNodes[n].hasAttribute('id') && allNodes[n].id == elm.id) uniqueIdCount++;
          if (uniqueIdCount > 1) break;
        }
        if (uniqueIdCount == 1) {
          segs.unshift('//*[@id="' + elm.getAttribute('id') + '"]');
          return segs.join('/');
        } else {
          return false;
        }
      } else {
        for (var i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) {
          if (sib.localName == elm.localName) i++;
        }
        if (i == 1) {
          if (elm.nextElementSibling) {
            if (elm.nextElementSibling.localName != elm.localName) {
              segs.unshift(elm.localName.toLowerCase());
            } else {
              segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
            }
          } else {
            segs.unshift(elm.localName.toLowerCase());
          }
        } else {
          segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
        }

        var title = elm.getAttribute('title');
        if (title) {
          segs[0] = segs[0] + '[@title="' + title + '"]';
        }
      }
    }
    return segs.length ? '/' + segs.join('/') : null;
  } catch (err) {
    console.log(err);
    return null;
  }
}

var lastPageY = void 0,
    lastBodyHeight = void 0;
function shouldRerender(boundary) {
  var body = document.body.getBoundingClientRect();
  if (lastBodyHeight && lastBodyHeight !== body.height) {
    lastBodyHeight = body.height;
    return true;
  }

  lastBodyHeight = body.height;

  var pageY = window.pageYOffset;

  if (lastPageY === pageY) {
    return false;
  }

  var isScrollUp = pageY > lastPageY;
  lastPageY = pageY;
  if (!isScrollUp && pageY < boundary[0] + _constants.BLOCK_BUFFER && boundary[0] > 0) {
    return true;
  }

  if (isScrollUp && pageY > boundary[1] - _constants.BLOCK_BUFFER && boundary[1] < document.body.getBoundingClientRect().height) {
    return true;
  }
  return false;
}

function getShowBoundary() {
  var body = document.body.getBoundingClientRect();
  if (body.height <= _constants.MAX_HEIGHT) {
    return [0, body.height];
  }

  var pageY = window.pageYOffset;
  var top = Math.max(pageY - _constants.BLOCK_HEIGHT / 2 - _constants.BLOCK_BUFFER, 0);
  var bottom = Math.min(pageY + _constants.BLOCK_HEIGHT / 2 + _constants.BLOCK_BUFFER, body.height);
  return [top, bottom];
}

var middle = exports.middle = function middle(a, b, c) {
  return [a, b, c].sort(function (a, b) {
    return a - b;
  })[1];
};

/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
// https://stackoverflow.com/questions/12642222/canvascontext-fillrect-throws-ns-error-failure-exception-in-firefox
// 对于超长的页面，每次仅绘制部分数据
var MAX_HEIGHT = exports.MAX_HEIGHT = 7000;
var BLOCK_HEIGHT = exports.BLOCK_HEIGHT = 5000;
// 绘制的缓冲区域
var BLOCK_BUFFER = exports.BLOCK_BUFFER = 1000;

/***/ }),
/* 4 */,
/* 5 */,
/* 6 */,
/* 7 */,
/* 8 */,
/* 9 */,
/* 10 */,
/* 11 */,
/* 12 */,
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _log = __webpack_require__(14);

var _log2 = _interopRequireDefault(_log);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

window.document.addEventListener('click', _log2.default, true);

/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _matrix = __webpack_require__(1);

var _matrix2 = _interopRequireDefault(_matrix);

var _config = __webpack_require__(0);

var _spm = __webpack_require__(15);

var _spm2 = _interopRequireDefault(_spm);

var _util = __webpack_require__(2);

var _util2 = _interopRequireDefault(_util);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function log(event) {
  if (!event || !event.target || event.target.tagName === 'CANVAS') {
    return;
  }

  var spm = (0, _spm2.default)();
  var loc = _matrix2.default.getCountPosition(event);
  var isFixed = _matrix2.default.checkInFixDom(event.target);
  // 点击位置node
  var targetNode = event.target || event.srcElement;
  var xPath = (0, _util2.default)(targetNode) || '';

  // 目前有微页面在用，yzlogInstance 也是微页面的 logger 实例
  if (window.yzlogInstance) {
    window.yzlogInstance.log({
      et: 'custom',
      ei: 'hot_click',
      en: '热力图点击',
      params: {
        fm: _config.fm,
        spm: spm,
        is_fix: isFixed,
        loc_x: loc.x,
        loc_y: loc.y,
        xpath: xPath
      }
    });
  }
};

exports.default = log;

/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _querystring = __webpack_require__(16);

var _global = window._global || {};

var getLastSpm = function getLastSpm() {
  if (!_global.spm) {
    return 'fake';
  }

  return _global.spm.logType + _global.spm.logId || 'fake' + _global.kdt_id;
};

function spm() {
  var spm = (0, _querystring.decode)(window.href).spam;
  var arr = [];

  if (spm) {
    arr = spm.split('_');

    if (arr.length > 2) {
      spm = arr[0] + '_' + arr[arr.length - 1];
    }
    spm += '_' + getLastSpm();
  } else {
    spm = getLastSpm();
  }
  return spm;
}

exports.default = spm;

/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


exports.decode = exports.parse = __webpack_require__(17);
exports.encode = exports.stringify = __webpack_require__(18);


/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.



// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProperty(obj, prop) {
  return Object.prototype.hasOwnProperty.call(obj, prop);
}

module.exports = function(qs, sep, eq, options) {
  sep = sep || '&';
  eq = eq || '=';
  var obj = {};

  if (typeof qs !== 'string' || qs.length === 0) {
    return obj;
  }

  var regexp = /\+/g;
  qs = qs.split(sep);

  var maxKeys = 1000;
  if (options && typeof options.maxKeys === 'number') {
    maxKeys = options.maxKeys;
  }

  var len = qs.length;
  // maxKeys <= 0 means that we should not limit keys count
  if (maxKeys > 0 && len > maxKeys) {
    len = maxKeys;
  }

  for (var i = 0; i < len; ++i) {
    var x = qs[i].replace(regexp, '%20'),
        idx = x.indexOf(eq),
        kstr, vstr, k, v;

    if (idx >= 0) {
      kstr = x.substr(0, idx);
      vstr = x.substr(idx + 1);
    } else {
      kstr = x;
      vstr = '';
    }

    k = decodeURIComponent(kstr);
    v = decodeURIComponent(vstr);

    if (!hasOwnProperty(obj, k)) {
      obj[k] = v;
    } else if (isArray(obj[k])) {
      obj[k].push(v);
    } else {
      obj[k] = [obj[k], v];
    }
  }

  return obj;
};

var isArray = Array.isArray || function (xs) {
  return Object.prototype.toString.call(xs) === '[object Array]';
};


/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.



var stringifyPrimitive = function(v) {
  switch (typeof v) {
    case 'string':
      return v;

    case 'boolean':
      return v ? 'true' : 'false';

    case 'number':
      return isFinite(v) ? v : '';

    default:
      return '';
  }
};

module.exports = function(obj, sep, eq, name) {
  sep = sep || '&';
  eq = eq || '=';
  if (obj === null) {
    obj = undefined;
  }

  if (typeof obj === 'object') {
    return map(objectKeys(obj), function(k) {
      var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
      if (isArray(obj[k])) {
        return map(obj[k], function(v) {
          return ks + encodeURIComponent(stringifyPrimitive(v));
        }).join(sep);
      } else {
        return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
      }
    }).join(sep);

  }

  if (!name) return '';
  return encodeURIComponent(stringifyPrimitive(name)) + eq +
         encodeURIComponent(stringifyPrimitive(obj));
};

var isArray = Array.isArray || function (xs) {
  return Object.prototype.toString.call(xs) === '[object Array]';
};

function map (xs, f) {
  if (xs.map) return xs.map(f);
  var res = [];
  for (var i = 0; i < xs.length; i++) {
    res.push(f(xs[i], i));
  }
  return res;
}

var objectKeys = Object.keys || function (obj) {
  var res = [];
  for (var key in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  }
  return res;
};


/***/ })
/******/ ]);
});