From 8344a6b2fd268d8ff8323fb2c2afaec55c0e09db Mon Sep 17 00:00:00 2001 From: Muah Date: Thu, 3 Aug 2017 05:37:33 +0200 Subject: [PATCH] v1.0.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - update rdme - update v:publish - add dist “js & css” files for quick testing - cleanup media view --- README.md | 47 +- src/MediaManagerServiceProvider.php | 14 + src/dist/script.9907be5e69ad75007397.js | 27098 ++++++++++++++++ ...style.c769d7bc24e95f980d5d13b4d8819bdb.css | 793 + src/resources/assets/sass/bulma/media.scss | 8 +- src/resources/assets/sass/shared-styles.scss | 6 +- src/resources/views/bulma/media.blade.php | 899 +- 7 files changed, 28394 insertions(+), 471 deletions(-) create mode 100644 src/dist/script.9907be5e69ad75007397.js create mode 100644 src/dist/style.c769d7bc24e95f980d5d13b4d8819bdb.css diff --git a/README.md b/README.md index ba8e9bf..8a1d8aa 100644 --- a/README.md +++ b/README.md @@ -33,16 +33,6 @@ `php artisan vendor:publish --provider="ctf0\MediaManager\MediaManagerServiceProvider"` -- install javascript dependencies - -```bash -yarn add vue dropzone keycode vue-tippy vue2-filters vue-lightbox vuemit -# or -npm install vue dropzone keycode vue-tippy vue2-filters vue-lightbox vuemit -``` - -- for styling we use ***bulma*** so install it aswell, or [Use another Framework](#use-another-framework) - ## Features - multi @@ -127,23 +117,34 @@ return [ ## Usage -- add `new MediaRoutes();` to your route file, or under any route group ex.`admin` - - \>\> **dont forget to update the `root_url`** << +- package automatically appends routes to `routes/web.php` +- package automatically appends assets compiling to `webpack.mix.js` +- add `MIX_MM_FRAMEWORK=bulma` to `.env` -- to provide as much flexibility as possible, edit the `views/vendor/MediaManager/(framework)/media` file and let it extend from your main layout. -- add `MIX_MM_FRAMEWORK=bulma` to your `.env` file. -- run `npm run watch` to compile your `js/css` files. +#### - Simple +- visit `http://127.0.0.1:8000/media` -#### Use another Framework +#### - Advanced +- install javascript dependencies -- duplicate `views/vendor/MediaManager/bulma` and rename it to the framework you want ex.`bootstrap` -- duplicate `assets/vendor/MediaManager/js/components/bulma-notif` and rename it to the framework you want ex.`bootstrap-notif` -- duplicate `assets/vendor/MediaManager/sass/bulma` and rename it to the framework you want ex.`bootstrap` -- set `MIX_MM_FRAMEWORK` to the framework name ex.`MIX_MM_FRAMEWORK=bootstrap` -- start editing the new files. +```bash +yarn add vue dropzone keycode vue-tippy vue2-filters vue-lightbox vuemit +# or +npm install vue dropzone keycode vue-tippy vue2-filters vue-lightbox vuemit +``` -after you are done, maybe you can send me a PR so everyone else can benefit from it :trophy: +- for styling we use ***bulma*** + +> ***Or Use another Framework*** +> +> - duplicate `views/vendor/MediaManager/bulma` and rename it to the framework you want ex.`bootstrap` +> - duplicate `assets/vendor/MediaManager/js/components/bulma-notif` and rename it to the framework you want ex.`bootstrap-notif` +> - duplicate `assets/vendor/MediaManager/sass/bulma` and rename it to the framework you want ex.`bootstrap` +> - set `MIX_MM_FRAMEWORK` to the framework name ex.`MIX_MM_FRAMEWORK=bootstrap` +> - start editing the new files. +> - run `npm run watch` to compile your `js/css` files. +> +> after you are done, maybe you can send me a PR so everyone else can benefit from it :trophy: ## ToDo "ANY HELP IS DEEPLY APPRECIATED" diff --git a/src/MediaManagerServiceProvider.php b/src/MediaManagerServiceProvider.php index 6a99949..ba4c919 100644 --- a/src/MediaManagerServiceProvider.php +++ b/src/MediaManagerServiceProvider.php @@ -17,6 +17,11 @@ public function boot() __DIR__.'/config' => config_path(), ], 'config'); + // public + $this->publishes([ + __DIR__.'/dist' => public_path('assets/vendor/MediaManager'), + ], 'dist'); + // resources $this->publishes([ __DIR__.'/resources/assets' => resource_path('assets/vendor/MediaManager'), @@ -34,6 +39,15 @@ public function boot() __DIR__.'/resources/views' => resource_path('views/vendor/MediaManager'), ], 'view'); + // routes + $route_file = base_path('routes/web.php'); + $search = 'MediaManager'; + if (File::exists($route_file) && !str_contains(File::get($route_file), $search)) { + $data = "\n// Media-Manager\nnew \ctf0\MediaManager\MediaRoutes();"; + + File::append($route_file, $data); + } + // mix $mix_file = base_path('webpack.mix.js'); $search = 'MediaManager'; diff --git a/src/dist/script.9907be5e69ad75007397.js b/src/dist/script.9907be5e69ad75007397.js new file mode 100644 index 0000000..a400658 --- /dev/null +++ b/src/dist/script.9907be5e69ad75007397.js @@ -0,0 +1,27098 @@ +/******/ (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 harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // 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 = 1); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/babel-loader/lib/index.js?{\"cacheDirectory\":true,\"presets\":[[\"env\",{\"modules\":false,\"targets\":{\"browsers\":[\"> 2%\"],\"uglify\":true}}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/Alert/Announcement.vue": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +// +// + +/* harmony default export */ __webpack_exports__["default"] = ({ + created: function created() { + this.registerEcho(); + this.publicChannels(); + this.privateChannels(); + }, + + methods: { + registerEcho: function registerEcho() { + window.Pusher = __webpack_require__("./node_modules/pusher-js/dist/web/pusher.js"); + window.Echo = __webpack_require__("./node_modules/laravel-echo/dist/echo.js"); + + Echo = new Echo({ + broadcaster: 'pusher', + key: "" + }); + }, + publicChannels: function publicChannels() { + Echo.channel('all-channel').listen('NewArticleWasPublished', function (_ref) { + var data = _ref.data; + + EventHub.fire('showNotif', { + title: data.message, + body: '' + data.title + '', + type: data.type + }); + }); + }, + privateChannels: function privateChannels() {} + } +}); + +/***/ }), + +/***/ "./node_modules/babel-loader/lib/index.js?{\"cacheDirectory\":true,\"presets\":[[\"env\",{\"modules\":false,\"targets\":{\"browsers\":[\"> 2%\"],\"uglify\":true}}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/Alert/Notification.vue": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// + +/* harmony default export */ __webpack_exports__["default"] = ({ + props: { + title: '', + body: '', + icon: { + default: true + }, + type: { default: 'info' }, + duration: null + }, + + data: function data() { + return { + notif_group: [], + self_title: this.title, + self_body: this.body, + self_type: this.type, + self_icon: Boolean(this.icon), + self_duration: this.duration, + self_show: false + }; + }, + created: function created() { + var _this = this; + + this.checkProp(); + + EventHub.listen('showNotif', function (data) { + _this.collectData(data); + }); + }, + + + methods: { + checkForGroup: function checkForGroup() { + return this.notif_group.length > 1 && this.notif_group.filter(function (item) { + return item.show == true; + }).length > 1; + }, + closeAll: function closeAll() { + this.notif_group.map(function (item) { + item.show = false; + item.duration = null; + }); + }, + checkProp: function checkProp() { + var _this2 = this; + + if (this.self_title) { + this.self_show = true; + } + + if (this.self_duration !== undefined) { + setTimeout(function () { + _this2.self_show = false; + }, this.self_duration * 1000); + } + }, + collectData: function collectData(data) { + this.notif_group.push({ + title: data.title, + body: data.body, + type: data.type, + icon: data.icon == null ? true : false, + duration: data.duration, + onClose: data.onClose, + show: true + }); + }, + IsVisible: function IsVisible(index) { + var _this3 = this; + + var dur = this.notif_group[index].duration; + + if (dur !== undefined) { + setTimeout(function () { + _this3.closeNotif(index); + }, dur * 1000); + } + + return this.notif_group[index].show; + }, + closeNotif: function closeNotif(index) { + this.notif_group[index].show = false; + + if (typeof this.notif_group[index].onClose != 'undefined' && typeof this.notif_group[index].onClose === 'function') { + this.notif_group[index].onClose(); + } + }, + classObj: function classObj(type) { + return 'notification has-shadow is-' + type; + }, + getIcon: function getIcon(type) { + switch (type) { + case 'primary': + return 'track_changes'; + break; + case 'success': + return 'check_circle'; + break; + case 'info': + return 'live_help'; + break; + case 'warning': + return 'power_settings_new'; + break; + case 'danger': + return 'add_alert'; + break; + default: + return 'error'; + } + } + } +}); + +/***/ }), + +/***/ "./node_modules/css-loader/index.js!./node_modules/tippy.js/dist/tippy.css": +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__("./node_modules/css-loader/lib/css-base.js")(); +exports.push([module.i, ".tippy-touch{cursor:pointer!important}.tippy-notransition{-webkit-transition:none!important;transition:none!important}.tippy-popper{max-width:400px;-webkit-perspective:800px;perspective:800px;z-index:9999}.tippy-popper.html-template{max-width:96%;max-width:calc(100% - 20px)}.tippy-popper[x-placement^=top] [x-arrow]{position:absolute;width:0;height:0;border-top:7px solid #333;border-right:7px solid transparent;border-left:7px solid transparent;bottom:-7px}.tippy-popper[x-placement^=top] [x-arrow].arrow-small{border-top:5px solid #333;border-right:5px solid transparent;border-left:5px solid transparent;bottom:-5px}.tippy-popper[x-placement^=top] [x-arrow].arrow-big{border-top:9px solid #333;border-right:9px solid transparent;border-left:9px solid transparent;bottom:-9px}.tippy-popper[x-placement^=top] [x-circle]{-webkit-transform-origin:0 100%;transform-origin:0 100%}.tippy-popper[x-placement^=top] [x-circle].enter{opacity:1;-webkit-transform:scale(1) translate(-50%,-50%);transform:scale(1) translate(-50%,-50%)}.tippy-popper[x-placement^=top] [x-circle].leave{opacity:0;-webkit-transform:scale(.45) translate(-50%,-100%);transform:scale(.45) translate(-50%,-100%)}.tippy-popper[x-placement^=top] .tippy-tooltip.light-theme [x-circle]{background-color:#fff}.tippy-popper[x-placement^=top] .tippy-tooltip.light-theme [x-arrow]{border-top:7px solid #fff;border-right:7px solid transparent;border-left:7px solid transparent}.tippy-popper[x-placement^=top] .tippy-tooltip.light-theme [x-arrow].arrow-small{border-top:5px solid #fff;border-right:5px solid transparent;border-left:5px solid transparent}.tippy-popper[x-placement^=top] .tippy-tooltip.light-theme [x-arrow].arrow-big{border-top:9px solid #fff;border-right:9px solid transparent;border-left:9px solid transparent}.tippy-popper[x-placement^=top] .tippy-tooltip.transparent-theme [x-circle]{background-color:rgba(0,0,0,.7)}.tippy-popper[x-placement^=top] .tippy-tooltip.transparent-theme [x-arrow]{border-top:7px solid rgba(0,0,0,.7);border-right:7px solid transparent;border-left:7px solid transparent}.tippy-popper[x-placement^=top] .tippy-tooltip.transparent-theme [x-arrow].arrow-small{border-top:5px solid rgba(0,0,0,.7);border-right:5px solid transparent;border-left:5px solid transparent}.tippy-popper[x-placement^=top] .tippy-tooltip.transparent-theme [x-arrow].arrow-big{border-top:9px solid rgba(0,0,0,.7);border-right:9px solid transparent;border-left:9px solid transparent}.tippy-popper[x-placement^=top] [data-animation=perspective]{-webkit-transform-origin:bottom;transform-origin:bottom}.tippy-popper[x-placement^=top] [data-animation=perspective].enter{opacity:1;-webkit-transform:translateY(-10px) rotateX(0);transform:translateY(-10px) rotateX(0)}.tippy-popper[x-placement^=top] [data-animation=perspective].leave{opacity:0;-webkit-transform:translateY(0) rotateX(90deg);transform:translateY(0) rotateX(90deg)}.tippy-popper[x-placement^=top] [data-animation=fade].enter{opacity:1;-webkit-transform:translateY(-10px);transform:translateY(-10px)}.tippy-popper[x-placement^=top] [data-animation=fade].leave{opacity:0;-webkit-transform:translateY(-10px);transform:translateY(-10px)}.tippy-popper[x-placement^=top] [data-animation=shift].enter{opacity:1;-webkit-transform:translateY(-10px);transform:translateY(-10px)}.tippy-popper[x-placement^=top] [data-animation=shift].leave{opacity:0;-webkit-transform:translateY(0);transform:translateY(0)}.tippy-popper[x-placement^=top] [data-animation=scale].enter{opacity:1;-webkit-transform:translateY(-10px) scale(1);transform:translateY(-10px) scale(1)}.tippy-popper[x-placement^=top] [data-animation=scale].leave{opacity:0;-webkit-transform:translateY(0) scale(0);transform:translateY(0) scale(0)}.tippy-popper[x-placement^=bottom] [x-arrow]{position:absolute;width:0;height:0;border-bottom:7px solid #333;border-right:7px solid transparent;border-left:7px solid transparent;top:-7px}.tippy-popper[x-placement^=bottom] [x-arrow].arrow-small{border-bottom:5px solid #333;border-right:5px solid transparent;border-left:5px solid transparent;top:-5px}.tippy-popper[x-placement^=bottom] [x-arrow].arrow-big{border-bottom:9px solid #333;border-right:9px solid transparent;border-left:9px solid transparent;top:-9px}.tippy-popper[x-placement^=bottom] [x-circle]{-webkit-transform-origin:0 -100%;transform-origin:0 -100%}.tippy-popper[x-placement^=bottom] [x-circle].enter{opacity:1;-webkit-transform:scale(1) translate(-50%,-50%);transform:scale(1) translate(-50%,-50%)}.tippy-popper[x-placement^=bottom] [x-circle].leave{opacity:0;-webkit-transform:scale(.45) translate(-50%,5%);transform:scale(.45) translate(-50%,5%)}.tippy-popper[x-placement^=bottom] .tippy-tooltip.light-theme [x-circle]{background-color:#fff}.tippy-popper[x-placement^=bottom] .tippy-tooltip.light-theme [x-arrow]{border-bottom:7px solid #fff;border-right:7px solid transparent;border-left:7px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.light-theme [x-arrow].arrow-small{border-bottom:5px solid #fff;border-right:5px solid transparent;border-left:5px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.light-theme [x-arrow].arrow-big{border-bottom:9px solid #fff;border-right:9px solid transparent;border-left:9px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.transparent-theme [x-circle]{background-color:rgba(0,0,0,.7)}.tippy-popper[x-placement^=bottom] .tippy-tooltip.transparent-theme [x-arrow]{border-bottom:7px solid rgba(0,0,0,.7);border-right:7px solid transparent;border-left:7px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.transparent-theme [x-arrow].arrow-small{border-bottom:5px solid rgba(0,0,0,.7);border-right:5px solid transparent;border-left:5px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.transparent-theme [x-arrow].arrow-big{border-bottom:9px solid rgba(0,0,0,.7);border-right:9px solid transparent;border-left:9px solid transparent}.tippy-popper[x-placement^=bottom] [data-animation=perspective]{-webkit-transform-origin:top;transform-origin:top}.tippy-popper[x-placement^=bottom] [data-animation=perspective].enter{opacity:1;-webkit-transform:translateY(10px) rotateX(0);transform:translateY(10px) rotateX(0)}.tippy-popper[x-placement^=bottom] [data-animation=perspective].leave{opacity:0;-webkit-transform:translateY(0) rotateX(-90deg);transform:translateY(0) rotateX(-90deg)}.tippy-popper[x-placement^=bottom] [data-animation=fade].enter{opacity:1;-webkit-transform:translateY(10px);transform:translateY(10px)}.tippy-popper[x-placement^=bottom] [data-animation=fade].leave{opacity:0;-webkit-transform:translateY(10px);transform:translateY(10px)}.tippy-popper[x-placement^=bottom] [data-animation=shift].enter{opacity:1;-webkit-transform:translateY(10px);transform:translateY(10px)}.tippy-popper[x-placement^=bottom] [data-animation=shift].leave{opacity:0;-webkit-transform:translateY(0);transform:translateY(0)}.tippy-popper[x-placement^=bottom] [data-animation=scale].enter{opacity:1;-webkit-transform:translateY(10px) scale(1);transform:translateY(10px) scale(1)}.tippy-popper[x-placement^=bottom] [data-animation=scale].leave{opacity:0;-webkit-transform:translateY(0) scale(0);transform:translateY(0) scale(0)}.tippy-popper[x-placement^=left] [x-arrow]{position:absolute;width:0;height:0;border-left:7px solid #333;border-top:7px solid transparent;border-bottom:7px solid transparent;right:-7px;top:50%}.tippy-popper[x-placement^=left] [x-arrow].arrow-small{border-left:5px solid #333;border-top:5px solid transparent;border-bottom:5px solid transparent;right:-5px;top:50%}.tippy-popper[x-placement^=left] [x-arrow].arrow-big{border-left:9px solid #333;border-top:9px solid transparent;border-bottom:9px solid transparent;right:-9px;top:50%}.tippy-popper[x-placement^=left] [x-circle]{-webkit-transform-origin:50% 0;transform-origin:50% 0}.tippy-popper[x-placement^=left] [x-circle].enter{opacity:1;-webkit-transform:scale(1) translate(-50%,-50%);transform:scale(1) translate(-50%,-50%)}.tippy-popper[x-placement^=left] [x-circle].leave{opacity:0;-webkit-transform:scale(.45) translate(-50%,-50%);transform:scale(.45) translate(-50%,-50%)}.tippy-popper[x-placement^=left] .tippy-tooltip.light-theme [x-circle]{background-color:#fff}.tippy-popper[x-placement^=left] .tippy-tooltip.light-theme [x-arrow]{border-left:7px solid #fff;border-top:7px solid transparent;border-bottom:7px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.light-theme [x-arrow].arrow-small{border-left:5px solid #fff;border-top:5px solid transparent;border-bottom:5px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.light-theme [x-arrow].arrow-big{border-left:9px solid #fff;border-top:9px solid transparent;border-bottom:9px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.transparent-theme [x-circle]{background-color:rgba(0,0,0,.7)}.tippy-popper[x-placement^=left] .tippy-tooltip.transparent-theme [x-arrow]{border-left:7px solid rgba(0,0,0,.7);border-top:7px solid transparent;border-bottom:7px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.transparent-theme [x-arrow].arrow-small{border-left:5px solid rgba(0,0,0,.7);border-top:5px solid transparent;border-bottom:5px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.transparent-theme [x-arrow].arrow-big{border-left:9px solid rgba(0,0,0,.7);border-top:9px solid transparent;border-bottom:9px solid transparent}.tippy-popper[x-placement^=left] [data-animation=perspective]{-webkit-transform-origin:right;transform-origin:right}.tippy-popper[x-placement^=left] [data-animation=perspective].enter{opacity:1;-webkit-transform:translateX(-10px) rotateY(0);transform:translateX(-10px) rotateY(0)}.tippy-popper[x-placement^=left] [data-animation=perspective].leave{opacity:0;-webkit-transform:translateX(0) rotateY(-90deg);transform:translateX(0) rotateY(-90deg)}.tippy-popper[x-placement^=left] [data-animation=fade].enter{opacity:1;-webkit-transform:translateX(-10px);transform:translateX(-10px)}.tippy-popper[x-placement^=left] [data-animation=fade].leave{opacity:0;-webkit-transform:translateX(-10px);transform:translateX(-10px)}.tippy-popper[x-placement^=left] [data-animation=shift].enter{opacity:1;-webkit-transform:translateX(-10px);transform:translateX(-10px)}.tippy-popper[x-placement^=left] [data-animation=shift].leave{opacity:0;-webkit-transform:translateX(0);transform:translateX(0)}.tippy-popper[x-placement^=left] [data-animation=scale].enter{opacity:1;-webkit-transform:translateX(-10px) scale(1);transform:translateX(-10px) scale(1)}.tippy-popper[x-placement^=left] [data-animation=scale].leave{opacity:0;-webkit-transform:translateX(0) scale(0);transform:translateX(0) scale(0)}.tippy-popper[x-placement^=right] [x-arrow]{position:absolute;width:0;height:0;border-right:7px solid #333;border-top:7px solid transparent;border-bottom:7px solid transparent;left:-7px;top:50%}.tippy-popper[x-placement^=right] [x-arrow].arrow-small{border-right:5px solid #333;border-top:5px solid transparent;border-bottom:5px solid transparent;left:-5px;top:50%}.tippy-popper[x-placement^=right] [x-arrow].arrow-big{border-right:9px solid #333;border-top:9px solid transparent;border-bottom:9px solid transparent;left:-9px;top:50%}.tippy-popper[x-placement^=right] [x-circle]{-webkit-transform-origin:-50% 0;transform-origin:-50% 0}.tippy-popper[x-placement^=right] [x-circle].enter{opacity:1;-webkit-transform:scale(1) translate(-50%,-50%);transform:scale(1) translate(-50%,-50%)}.tippy-popper[x-placement^=right] [x-circle].leave{opacity:0;-webkit-transform:scale(.45) translate(-50%,-50%);transform:scale(.45) translate(-50%,-50%)}.tippy-popper[x-placement^=right] .tippy-tooltip.light-theme [x-circle]{background-color:#fff}.tippy-popper[x-placement^=right] .tippy-tooltip.light-theme [x-arrow]{border-right:7px solid #fff;border-top:7px solid transparent;border-bottom:7px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.light-theme [x-arrow].arrow-small{border-right:5px solid #fff;border-top:5px solid transparent;border-bottom:5px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.light-theme [x-arrow].arrow-big{border-right:9px solid #fff;border-top:9px solid transparent;border-bottom:9px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.transparent-theme [x-circle]{background-color:rgba(0,0,0,.7)}.tippy-popper[x-placement^=right] .tippy-tooltip.transparent-theme [x-arrow]{border-right:7px solid rgba(0,0,0,.7);border-top:7px solid transparent;border-bottom:7px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.transparent-theme [x-arrow].arrow-small{border-right:5px solid rgba(0,0,0,.7);border-top:5px solid transparent;border-bottom:5px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.transparent-theme [x-arrow].arrow-big{border-right:9px solid rgba(0,0,0,.7);border-top:9px solid transparent;border-bottom:9px solid transparent}.tippy-popper[x-placement^=right] [data-animation=perspective]{-webkit-transform-origin:left;transform-origin:left}.tippy-popper[x-placement^=right] [data-animation=perspective].enter{opacity:1;-webkit-transform:translateX(10px) rotateY(0);transform:translateX(10px) rotateY(0)}.tippy-popper[x-placement^=right] [data-animation=perspective].leave{opacity:0;-webkit-transform:translateX(0) rotateY(90deg);transform:translateX(0) rotateY(90deg)}.tippy-popper[x-placement^=right] [data-animation=fade].enter{opacity:1;-webkit-transform:translateX(10px);transform:translateX(10px)}.tippy-popper[x-placement^=right] [data-animation=fade].leave{opacity:0;-webkit-transform:translateX(10px);transform:translateX(10px)}.tippy-popper[x-placement^=right] [data-animation=shift].enter{opacity:1;-webkit-transform:translateX(10px);transform:translateX(10px)}.tippy-popper[x-placement^=right] [data-animation=shift].leave{opacity:0;-webkit-transform:translateX(0);transform:translateX(0)}.tippy-popper[x-placement^=right] [data-animation=scale].enter{opacity:1;-webkit-transform:translateX(10px) scale(1);transform:translateX(10px) scale(1)}.tippy-popper[x-placement^=right] [data-animation=scale].leave{opacity:0;-webkit-transform:translateX(0) scale(0);transform:translateX(0) scale(0)}.tippy-popper [x-circle]{background-color:#fff}.tippy-popper[data-animatefill]{background-color:transparent}.tippy-popper [x-arrow]{position:absolute;width:0;height:0}.tippy-popper .tippy-tooltip.transparent-theme{background-color:rgba(0,0,0,.7)}.tippy-popper .tippy-tooltip.transparent-theme[data-animatefill]{background-color:transparent}.tippy-popper .tippy-tooltip.light-theme{color:#203d5d;box-shadow:0 4px 20px 4px rgba(0,20,60,.1),0 4px 80px -8px rgba(0,20,60,.2);background-color:#fff}.tippy-popper .tippy-tooltip.light-theme[data-animatefill]{background-color:transparent}.tippy-tooltip{position:relative;color:#fff;border-radius:4px;font-size:.95rem;padding:.4rem .8rem;text-align:center;will-change:transform;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-color:#333}.tippy-tooltip--small{padding:.25rem .5rem;font-size:.8rem}.tippy-tooltip--big{padding:.6rem 1.2rem;font-size:1.2rem}.tippy-tooltip[data-animatefill]{overflow:hidden;background-color:transparent}.tippy-tooltip[data-inertia]{-webkit-transition-timing-function:cubic-bezier(.53,1,.36,.85);transition-timing-function:cubic-bezier(.53,2,.36,.85)}.tippy-tooltip [x-circle]{position:absolute;will-change:transform;background-color:#333;border-radius:50%;width:120%;width:calc(100% + 2rem);-webkit-transition:all ease-out;transition:all ease-out;left:50%;top:50%;z-index:-1;opacity:0;overflow:hidden}.tippy-tooltip [x-circle]:before{content:\"\";padding-top:75%;float:left}@media (max-width:450px){.tippy-popper{max-width:96%;max-width:calc(100% - 20px)}}", ""]); + +/***/ }), + +/***/ "./node_modules/css-loader/index.js!./node_modules/vue-loader/lib/style-compiler/index.js?{\"id\":\"data-v-4eeedfda\",\"scoped\":true,\"hasInlineConfig\":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./resources/assets/js/components/Alert/Notification.vue": +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__("./node_modules/css-loader/lib/css-base.js")(); +exports.push([module.i, "@import url(https://fonts.googleapis.com/icon?family=Material+Icons);", ""]); +exports.push([module.i, "\n\n.item[data-v-4eeedfda] {\n width: 330px;\n}\n.material-icons[data-v-4eeedfda] {\n font-size: 3rem;\n}\n.media-left[data-v-4eeedfda] {\n -ms-flex-item-align: center;\n -ms-grid-row-align: center;\n align-self: center;\n position: relative;\n margin-right: 1.25rem;\n}\n.has-shadow[data-v-4eeedfda] {\n box-shadow: 0 2px 4px rgba(0,0,0,0.12), 0 0 6px rgba(0,0,0,0.04);\n}\n.notification[data-v-4eeedfda] {\n padding: 1.25rem;\n margin-bottom: 10px;\n}\n#close_all[data-v-4eeedfda] {\n background-color: rgba(54, 54, 54, 0.9);\n cursor: pointer;\n position: fixed;\n z-index: 1;\n top: 1rem;\n right: 1rem;\n}\n#close_all[data-v-4eeedfda]:hover{\n background-color: rgb(54, 54, 54);\n}\n", ""]); + +/***/ }), + +/***/ "./node_modules/css-loader/lib/css-base.js": +/***/ (function(module, exports) { + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +// css base code, injected by the css-loader +module.exports = function() { + var list = []; + + // return the list of modules as css string + list.toString = function toString() { + var result = []; + for(var i = 0; i < this.length; i++) { + var item = this[i]; + if(item[2]) { + result.push("@media " + item[2] + "{" + item[1] + "}"); + } else { + result.push(item[1]); + } + } + return result.join(""); + }; + + // import a list of modules into the list + list.i = function(modules, mediaQuery) { + if(typeof modules === "string") + modules = [[null, modules, ""]]; + var alreadyImportedModules = {}; + for(var i = 0; i < this.length; i++) { + var id = this[i][0]; + if(typeof id === "number") + alreadyImportedModules[id] = true; + } + for(i = 0; i < modules.length; i++) { + var item = modules[i]; + // skip already imported module + // this implementation is not 100% perfect for weird media query combinations + // when a module is imported multiple times with different media queries. + // I hope this will never occur (Hey this way we have smaller bundles) + if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { + if(mediaQuery && !item[2]) { + item[2] = mediaQuery; + } else if(mediaQuery) { + item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; + } + list.push(item); + } + } + }; + return list; +}; + + +/***/ }), + +/***/ "./node_modules/dropzone/dist/dropzone.js": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(module) { +/* + * + * More info at [www.dropzonejs.com](http://www.dropzonejs.com) + * + * Copyright (c) 2012, Matias Meno + * + * 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. + * + */ + +(function() { + var Dropzone, Emitter, ExifRestore, camelize, contentLoaded, detectVerticalSquash, drawImageIOSFix, noop, without, + slice = [].slice, + extend1 = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + noop = function() {}; + + Emitter = (function() { + function Emitter() {} + + Emitter.prototype.addEventListener = Emitter.prototype.on; + + Emitter.prototype.on = function(event, fn) { + this._callbacks = this._callbacks || {}; + if (!this._callbacks[event]) { + this._callbacks[event] = []; + } + this._callbacks[event].push(fn); + return this; + }; + + Emitter.prototype.emit = function() { + var args, callback, callbacks, event, j, len; + event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; + this._callbacks = this._callbacks || {}; + callbacks = this._callbacks[event]; + if (callbacks) { + for (j = 0, len = callbacks.length; j < len; j++) { + callback = callbacks[j]; + callback.apply(this, args); + } + } + return this; + }; + + Emitter.prototype.removeListener = Emitter.prototype.off; + + Emitter.prototype.removeAllListeners = Emitter.prototype.off; + + Emitter.prototype.removeEventListener = Emitter.prototype.off; + + Emitter.prototype.off = function(event, fn) { + var callback, callbacks, i, j, len; + if (!this._callbacks || arguments.length === 0) { + this._callbacks = {}; + return this; + } + callbacks = this._callbacks[event]; + if (!callbacks) { + return this; + } + if (arguments.length === 1) { + delete this._callbacks[event]; + return this; + } + for (i = j = 0, len = callbacks.length; j < len; i = ++j) { + callback = callbacks[i]; + if (callback === fn) { + callbacks.splice(i, 1); + break; + } + } + return this; + }; + + return Emitter; + + })(); + + Dropzone = (function(superClass) { + var extend, resolveOption; + + extend1(Dropzone, superClass); + + Dropzone.prototype.Emitter = Emitter; + + + /* + This is a list of all available events you can register on a dropzone object. + + You can register an event handler like this: + + dropzone.on("dragEnter", function() { }); + */ + + Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "addedfiles", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached", "queuecomplete"]; + + Dropzone.prototype.defaultOptions = { + url: null, + method: "post", + withCredentials: false, + timeout: 30000, + parallelUploads: 2, + uploadMultiple: false, + maxFilesize: 256, + paramName: "file", + createImageThumbnails: true, + maxThumbnailFilesize: 10, + thumbnailWidth: 120, + thumbnailHeight: 120, + thumbnailMethod: 'crop', + resizeWidth: null, + resizeHeight: null, + resizeMimeType: null, + resizeQuality: 0.8, + resizeMethod: 'contain', + filesizeBase: 1000, + maxFiles: null, + params: {}, + headers: null, + clickable: true, + ignoreHiddenFiles: true, + acceptedFiles: null, + acceptedMimeTypes: null, + autoProcessQueue: true, + autoQueue: true, + addRemoveLinks: false, + previewsContainer: null, + hiddenInputContainer: "body", + capture: null, + renameFilename: null, + renameFile: null, + forceFallback: false, + dictDefaultMessage: "Drop files here to upload", + dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.", + dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.", + dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.", + dictInvalidFileType: "You can't upload files of this type.", + dictResponseError: "Server responded with {{statusCode}} code.", + dictCancelUpload: "Cancel upload", + dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", + dictRemoveFile: "Remove file", + dictRemoveFileConfirmation: null, + dictMaxFilesExceeded: "You can not upload any more files.", + dictFileSizeUnits: { + tb: "TB", + gb: "GB", + mb: "MB", + kb: "KB", + b: "b" + }, + init: function() { + return noop; + }, + accept: function(file, done) { + return done(); + }, + fallback: function() { + var child, j, len, messageElement, ref, span; + this.element.className = this.element.className + " dz-browser-not-supported"; + ref = this.element.getElementsByTagName("div"); + for (j = 0, len = ref.length; j < len; j++) { + child = ref[j]; + if (/(^| )dz-message($| )/.test(child.className)) { + messageElement = child; + child.className = "dz-message"; + continue; + } + } + if (!messageElement) { + messageElement = Dropzone.createElement("
"); + this.element.appendChild(messageElement); + } + span = messageElement.getElementsByTagName("span")[0]; + if (span) { + if (span.textContent != null) { + span.textContent = this.options.dictFallbackMessage; + } else if (span.innerText != null) { + span.innerText = this.options.dictFallbackMessage; + } + } + return this.element.appendChild(this.getFallbackForm()); + }, + resize: function(file, width, height, resizeMethod) { + var info, srcRatio, trgRatio; + info = { + srcX: 0, + srcY: 0, + srcWidth: file.width, + srcHeight: file.height + }; + srcRatio = file.width / file.height; + if ((width == null) && (height == null)) { + width = info.srcWidth; + height = info.srcHeight; + } else if (width == null) { + width = height * srcRatio; + } else if (height == null) { + height = width / srcRatio; + } + width = Math.min(width, info.srcWidth); + height = Math.min(height, info.srcHeight); + trgRatio = width / height; + if (info.srcWidth > width || info.srcHeight > height) { + if (resizeMethod === 'crop') { + if (srcRatio > trgRatio) { + info.srcHeight = file.height; + info.srcWidth = info.srcHeight * trgRatio; + } else { + info.srcWidth = file.width; + info.srcHeight = info.srcWidth / trgRatio; + } + } else if (resizeMethod === 'contain') { + if (srcRatio > trgRatio) { + height = width / srcRatio; + } else { + width = height * srcRatio; + } + } else { + throw new Error("Unknown resizeMethod '" + resizeMethod + "'"); + } + } + info.srcX = (file.width - info.srcWidth) / 2; + info.srcY = (file.height - info.srcHeight) / 2; + info.trgWidth = width; + info.trgHeight = height; + return info; + }, + transformFile: function(file, done) { + if ((this.options.resizeWidth || this.options.resizeHeight) && file.type.match(/image.*/)) { + return this.resizeImage(file, this.options.resizeWidth, this.options.resizeHeight, this.options.resizeMethod, done); + } else { + return done(file); + } + }, + previewTemplate: "
\n
\n
\n
\n
\n
\n
\n
\n
\n \n Check\n \n \n \n \n \n
\n
\n \n Error\n \n \n \n \n \n \n \n
\n
", + + /* + Those functions register themselves to the events on init and handle all + the user interface specific stuff. Overwriting them won't break the upload + but can break the way it's displayed. + You can overwrite them if you don't like the default behavior. If you just + want to add an additional event handler, register it on the dropzone object + and don't overwrite those options. + */ + drop: function(e) { + return this.element.classList.remove("dz-drag-hover"); + }, + dragstart: noop, + dragend: function(e) { + return this.element.classList.remove("dz-drag-hover"); + }, + dragenter: function(e) { + return this.element.classList.add("dz-drag-hover"); + }, + dragover: function(e) { + return this.element.classList.add("dz-drag-hover"); + }, + dragleave: function(e) { + return this.element.classList.remove("dz-drag-hover"); + }, + paste: noop, + reset: function() { + return this.element.classList.remove("dz-started"); + }, + addedfile: function(file) { + var j, k, l, len, len1, len2, node, ref, ref1, ref2, removeFileEvent, removeLink, results; + if (this.element === this.previewsContainer) { + this.element.classList.add("dz-started"); + } + if (this.previewsContainer) { + file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim()); + file.previewTemplate = file.previewElement; + this.previewsContainer.appendChild(file.previewElement); + ref = file.previewElement.querySelectorAll("[data-dz-name]"); + for (j = 0, len = ref.length; j < len; j++) { + node = ref[j]; + node.textContent = file.name; + } + ref1 = file.previewElement.querySelectorAll("[data-dz-size]"); + for (k = 0, len1 = ref1.length; k < len1; k++) { + node = ref1[k]; + node.innerHTML = this.filesize(file.size); + } + if (this.options.addRemoveLinks) { + file._removeLink = Dropzone.createElement("" + this.options.dictRemoveFile + ""); + file.previewElement.appendChild(file._removeLink); + } + removeFileEvent = (function(_this) { + return function(e) { + e.preventDefault(); + e.stopPropagation(); + if (file.status === Dropzone.UPLOADING) { + return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() { + return _this.removeFile(file); + }); + } else { + if (_this.options.dictRemoveFileConfirmation) { + return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() { + return _this.removeFile(file); + }); + } else { + return _this.removeFile(file); + } + } + }; + })(this); + ref2 = file.previewElement.querySelectorAll("[data-dz-remove]"); + results = []; + for (l = 0, len2 = ref2.length; l < len2; l++) { + removeLink = ref2[l]; + results.push(removeLink.addEventListener("click", removeFileEvent)); + } + return results; + } + }, + removedfile: function(file) { + var ref; + if (file.previewElement) { + if ((ref = file.previewElement) != null) { + ref.parentNode.removeChild(file.previewElement); + } + } + return this._updateMaxFilesReachedClass(); + }, + thumbnail: function(file, dataUrl) { + var j, len, ref, thumbnailElement; + if (file.previewElement) { + file.previewElement.classList.remove("dz-file-preview"); + ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]"); + for (j = 0, len = ref.length; j < len; j++) { + thumbnailElement = ref[j]; + thumbnailElement.alt = file.name; + thumbnailElement.src = dataUrl; + } + return setTimeout(((function(_this) { + return function() { + return file.previewElement.classList.add("dz-image-preview"); + }; + })(this)), 1); + } + }, + error: function(file, message) { + var j, len, node, ref, results; + if (file.previewElement) { + file.previewElement.classList.add("dz-error"); + if (typeof message !== "String" && message.error) { + message = message.error; + } + ref = file.previewElement.querySelectorAll("[data-dz-errormessage]"); + results = []; + for (j = 0, len = ref.length; j < len; j++) { + node = ref[j]; + results.push(node.textContent = message); + } + return results; + } + }, + errormultiple: noop, + processing: function(file) { + if (file.previewElement) { + file.previewElement.classList.add("dz-processing"); + if (file._removeLink) { + return file._removeLink.textContent = this.options.dictCancelUpload; + } + } + }, + processingmultiple: noop, + uploadprogress: function(file, progress, bytesSent) { + var j, len, node, ref, results; + if (file.previewElement) { + ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]"); + results = []; + for (j = 0, len = ref.length; j < len; j++) { + node = ref[j]; + if (node.nodeName === 'PROGRESS') { + results.push(node.value = progress); + } else { + results.push(node.style.width = progress + "%"); + } + } + return results; + } + }, + totaluploadprogress: noop, + sending: noop, + sendingmultiple: noop, + success: function(file) { + if (file.previewElement) { + return file.previewElement.classList.add("dz-success"); + } + }, + successmultiple: noop, + canceled: function(file) { + return this.emit("error", file, "Upload canceled."); + }, + canceledmultiple: noop, + complete: function(file) { + if (file._removeLink) { + file._removeLink.textContent = this.options.dictRemoveFile; + } + if (file.previewElement) { + return file.previewElement.classList.add("dz-complete"); + } + }, + completemultiple: noop, + maxfilesexceeded: noop, + maxfilesreached: noop, + queuecomplete: noop, + addedfiles: noop + }; + + extend = function() { + var j, key, len, object, objects, target, val; + target = arguments[0], objects = 2 <= arguments.length ? slice.call(arguments, 1) : []; + for (j = 0, len = objects.length; j < len; j++) { + object = objects[j]; + for (key in object) { + val = object[key]; + target[key] = val; + } + } + return target; + }; + + function Dropzone(element1, options) { + var elementOptions, fallback, ref; + this.element = element1; + this.version = Dropzone.version; + this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, ""); + this.clickableElements = []; + this.listeners = []; + this.files = []; + if (typeof this.element === "string") { + this.element = document.querySelector(this.element); + } + if (!(this.element && (this.element.nodeType != null))) { + throw new Error("Invalid dropzone element."); + } + if (this.element.dropzone) { + throw new Error("Dropzone already attached."); + } + Dropzone.instances.push(this); + this.element.dropzone = this; + elementOptions = (ref = Dropzone.optionsForElement(this.element)) != null ? ref : {}; + this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {}); + if (this.options.forceFallback || !Dropzone.isBrowserSupported()) { + return this.options.fallback.call(this); + } + if (this.options.url == null) { + this.options.url = this.element.getAttribute("action"); + } + if (!this.options.url) { + throw new Error("No URL provided."); + } + if (this.options.acceptedFiles && this.options.acceptedMimeTypes) { + throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated."); + } + if (this.options.acceptedMimeTypes) { + this.options.acceptedFiles = this.options.acceptedMimeTypes; + delete this.options.acceptedMimeTypes; + } + if (this.options.renameFilename != null) { + this.options.renameFile = (function(_this) { + return function(file) { + return _this.options.renameFilename.call(_this, file.name, file); + }; + })(this); + } + this.options.method = this.options.method.toUpperCase(); + if ((fallback = this.getExistingFallback()) && fallback.parentNode) { + fallback.parentNode.removeChild(fallback); + } + if (this.options.previewsContainer !== false) { + if (this.options.previewsContainer) { + this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer"); + } else { + this.previewsContainer = this.element; + } + } + if (this.options.clickable) { + if (this.options.clickable === true) { + this.clickableElements = [this.element]; + } else { + this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable"); + } + } + this.init(); + } + + Dropzone.prototype.getAcceptedFiles = function() { + var file, j, len, ref, results; + ref = this.files; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + if (file.accepted) { + results.push(file); + } + } + return results; + }; + + Dropzone.prototype.getRejectedFiles = function() { + var file, j, len, ref, results; + ref = this.files; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + if (!file.accepted) { + results.push(file); + } + } + return results; + }; + + Dropzone.prototype.getFilesWithStatus = function(status) { + var file, j, len, ref, results; + ref = this.files; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + if (file.status === status) { + results.push(file); + } + } + return results; + }; + + Dropzone.prototype.getQueuedFiles = function() { + return this.getFilesWithStatus(Dropzone.QUEUED); + }; + + Dropzone.prototype.getUploadingFiles = function() { + return this.getFilesWithStatus(Dropzone.UPLOADING); + }; + + Dropzone.prototype.getAddedFiles = function() { + return this.getFilesWithStatus(Dropzone.ADDED); + }; + + Dropzone.prototype.getActiveFiles = function() { + var file, j, len, ref, results; + ref = this.files; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + if (file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED) { + results.push(file); + } + } + return results; + }; + + Dropzone.prototype.init = function() { + var eventName, j, len, noPropagation, ref, ref1, setupHiddenFileInput; + if (this.element.tagName === "form") { + this.element.setAttribute("enctype", "multipart/form-data"); + } + if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) { + this.element.appendChild(Dropzone.createElement("
" + this.options.dictDefaultMessage + "
")); + } + if (this.clickableElements.length) { + setupHiddenFileInput = (function(_this) { + return function() { + if (_this.hiddenFileInput) { + _this.hiddenFileInput.parentNode.removeChild(_this.hiddenFileInput); + } + _this.hiddenFileInput = document.createElement("input"); + _this.hiddenFileInput.setAttribute("type", "file"); + if ((_this.options.maxFiles == null) || _this.options.maxFiles > 1) { + _this.hiddenFileInput.setAttribute("multiple", "multiple"); + } + _this.hiddenFileInput.className = "dz-hidden-input"; + if (_this.options.acceptedFiles != null) { + _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles); + } + if (_this.options.capture != null) { + _this.hiddenFileInput.setAttribute("capture", _this.options.capture); + } + _this.hiddenFileInput.style.visibility = "hidden"; + _this.hiddenFileInput.style.position = "absolute"; + _this.hiddenFileInput.style.top = "0"; + _this.hiddenFileInput.style.left = "0"; + _this.hiddenFileInput.style.height = "0"; + _this.hiddenFileInput.style.width = "0"; + document.querySelector(_this.options.hiddenInputContainer).appendChild(_this.hiddenFileInput); + return _this.hiddenFileInput.addEventListener("change", function() { + var file, files, j, len; + files = _this.hiddenFileInput.files; + if (files.length) { + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + _this.addFile(file); + } + } + _this.emit("addedfiles", files); + return setupHiddenFileInput(); + }); + }; + })(this); + setupHiddenFileInput(); + } + this.URL = (ref = window.URL) != null ? ref : window.webkitURL; + ref1 = this.events; + for (j = 0, len = ref1.length; j < len; j++) { + eventName = ref1[j]; + this.on(eventName, this.options[eventName]); + } + this.on("uploadprogress", (function(_this) { + return function() { + return _this.updateTotalUploadProgress(); + }; + })(this)); + this.on("removedfile", (function(_this) { + return function() { + return _this.updateTotalUploadProgress(); + }; + })(this)); + this.on("canceled", (function(_this) { + return function(file) { + return _this.emit("complete", file); + }; + })(this)); + this.on("complete", (function(_this) { + return function(file) { + if (_this.getAddedFiles().length === 0 && _this.getUploadingFiles().length === 0 && _this.getQueuedFiles().length === 0) { + return setTimeout((function() { + return _this.emit("queuecomplete"); + }), 0); + } + }; + })(this)); + noPropagation = function(e) { + e.stopPropagation(); + if (e.preventDefault) { + return e.preventDefault(); + } else { + return e.returnValue = false; + } + }; + this.listeners = [ + { + element: this.element, + events: { + "dragstart": (function(_this) { + return function(e) { + return _this.emit("dragstart", e); + }; + })(this), + "dragenter": (function(_this) { + return function(e) { + noPropagation(e); + return _this.emit("dragenter", e); + }; + })(this), + "dragover": (function(_this) { + return function(e) { + var efct; + try { + efct = e.dataTransfer.effectAllowed; + } catch (undefined) {} + e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy'; + noPropagation(e); + return _this.emit("dragover", e); + }; + })(this), + "dragleave": (function(_this) { + return function(e) { + return _this.emit("dragleave", e); + }; + })(this), + "drop": (function(_this) { + return function(e) { + noPropagation(e); + return _this.drop(e); + }; + })(this), + "dragend": (function(_this) { + return function(e) { + return _this.emit("dragend", e); + }; + })(this) + } + } + ]; + this.clickableElements.forEach((function(_this) { + return function(clickableElement) { + return _this.listeners.push({ + element: clickableElement, + events: { + "click": function(evt) { + if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) { + _this.hiddenFileInput.click(); + } + return true; + } + } + }); + }; + })(this)); + this.enable(); + return this.options.init.call(this); + }; + + Dropzone.prototype.destroy = function() { + var ref; + this.disable(); + this.removeAllFiles(true); + if ((ref = this.hiddenFileInput) != null ? ref.parentNode : void 0) { + this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); + this.hiddenFileInput = null; + } + delete this.element.dropzone; + return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1); + }; + + Dropzone.prototype.updateTotalUploadProgress = function() { + var activeFiles, file, j, len, ref, totalBytes, totalBytesSent, totalUploadProgress; + totalBytesSent = 0; + totalBytes = 0; + activeFiles = this.getActiveFiles(); + if (activeFiles.length) { + ref = this.getActiveFiles(); + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + totalBytesSent += file.upload.bytesSent; + totalBytes += file.upload.total; + } + totalUploadProgress = 100 * totalBytesSent / totalBytes; + } else { + totalUploadProgress = 100; + } + return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent); + }; + + Dropzone.prototype._getParamName = function(n) { + if (typeof this.options.paramName === "function") { + return this.options.paramName(n); + } else { + return "" + this.options.paramName + (this.options.uploadMultiple ? "[" + n + "]" : ""); + } + }; + + Dropzone.prototype._renameFile = function(file) { + if (typeof this.options.renameFile !== "function") { + return file.name; + } + return this.options.renameFile(file); + }; + + Dropzone.prototype.getFallbackForm = function() { + var existingFallback, fields, fieldsString, form; + if (existingFallback = this.getExistingFallback()) { + return existingFallback; + } + fieldsString = "
"; + if (this.options.dictFallbackText) { + fieldsString += "

" + this.options.dictFallbackText + "

"; + } + fieldsString += "
"; + fields = Dropzone.createElement(fieldsString); + if (this.element.tagName !== "FORM") { + form = Dropzone.createElement("
"); + form.appendChild(fields); + } else { + this.element.setAttribute("enctype", "multipart/form-data"); + this.element.setAttribute("method", this.options.method); + } + return form != null ? form : fields; + }; + + Dropzone.prototype.getExistingFallback = function() { + var fallback, getFallback, j, len, ref, tagName; + getFallback = function(elements) { + var el, j, len; + for (j = 0, len = elements.length; j < len; j++) { + el = elements[j]; + if (/(^| )fallback($| )/.test(el.className)) { + return el; + } + } + }; + ref = ["div", "form"]; + for (j = 0, len = ref.length; j < len; j++) { + tagName = ref[j]; + if (fallback = getFallback(this.element.getElementsByTagName(tagName))) { + return fallback; + } + } + }; + + Dropzone.prototype.setupEventListeners = function() { + var elementListeners, event, j, len, listener, ref, results; + ref = this.listeners; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + elementListeners = ref[j]; + results.push((function() { + var ref1, results1; + ref1 = elementListeners.events; + results1 = []; + for (event in ref1) { + listener = ref1[event]; + results1.push(elementListeners.element.addEventListener(event, listener, false)); + } + return results1; + })()); + } + return results; + }; + + Dropzone.prototype.removeEventListeners = function() { + var elementListeners, event, j, len, listener, ref, results; + ref = this.listeners; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + elementListeners = ref[j]; + results.push((function() { + var ref1, results1; + ref1 = elementListeners.events; + results1 = []; + for (event in ref1) { + listener = ref1[event]; + results1.push(elementListeners.element.removeEventListener(event, listener, false)); + } + return results1; + })()); + } + return results; + }; + + Dropzone.prototype.disable = function() { + var file, j, len, ref, results; + this.clickableElements.forEach(function(element) { + return element.classList.remove("dz-clickable"); + }); + this.removeEventListeners(); + ref = this.files; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + results.push(this.cancelUpload(file)); + } + return results; + }; + + Dropzone.prototype.enable = function() { + this.clickableElements.forEach(function(element) { + return element.classList.add("dz-clickable"); + }); + return this.setupEventListeners(); + }; + + Dropzone.prototype.filesize = function(size) { + var cutoff, i, j, len, selectedSize, selectedUnit, unit, units; + selectedSize = 0; + selectedUnit = "b"; + if (size > 0) { + units = ['tb', 'gb', 'mb', 'kb', 'b']; + for (i = j = 0, len = units.length; j < len; i = ++j) { + unit = units[i]; + cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10; + if (size >= cutoff) { + selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i); + selectedUnit = unit; + break; + } + } + selectedSize = Math.round(10 * selectedSize) / 10; + } + return "" + selectedSize + " " + this.options.dictFileSizeUnits[selectedUnit]; + }; + + Dropzone.prototype._updateMaxFilesReachedClass = function() { + if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) { + if (this.getAcceptedFiles().length === this.options.maxFiles) { + this.emit('maxfilesreached', this.files); + } + return this.element.classList.add("dz-max-files-reached"); + } else { + return this.element.classList.remove("dz-max-files-reached"); + } + }; + + Dropzone.prototype.drop = function(e) { + var files, items; + if (!e.dataTransfer) { + return; + } + this.emit("drop", e); + files = e.dataTransfer.files; + this.emit("addedfiles", files); + if (files.length) { + items = e.dataTransfer.items; + if (items && items.length && (items[0].webkitGetAsEntry != null)) { + this._addFilesFromItems(items); + } else { + this.handleFiles(files); + } + } + }; + + Dropzone.prototype.paste = function(e) { + var items, ref; + if ((e != null ? (ref = e.clipboardData) != null ? ref.items : void 0 : void 0) == null) { + return; + } + this.emit("paste", e); + items = e.clipboardData.items; + if (items.length) { + return this._addFilesFromItems(items); + } + }; + + Dropzone.prototype.handleFiles = function(files) { + var file, j, len, results; + results = []; + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + results.push(this.addFile(file)); + } + return results; + }; + + Dropzone.prototype._addFilesFromItems = function(items) { + var entry, item, j, len, results; + results = []; + for (j = 0, len = items.length; j < len; j++) { + item = items[j]; + if ((item.webkitGetAsEntry != null) && (entry = item.webkitGetAsEntry())) { + if (entry.isFile) { + results.push(this.addFile(item.getAsFile())); + } else if (entry.isDirectory) { + results.push(this._addFilesFromDirectory(entry, entry.name)); + } else { + results.push(void 0); + } + } else if (item.getAsFile != null) { + if ((item.kind == null) || item.kind === "file") { + results.push(this.addFile(item.getAsFile())); + } else { + results.push(void 0); + } + } else { + results.push(void 0); + } + } + return results; + }; + + Dropzone.prototype._addFilesFromDirectory = function(directory, path) { + var dirReader, errorHandler, readEntries; + dirReader = directory.createReader(); + errorHandler = function(error) { + return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0; + }; + readEntries = (function(_this) { + return function() { + return dirReader.readEntries(function(entries) { + var entry, j, len; + if (entries.length > 0) { + for (j = 0, len = entries.length; j < len; j++) { + entry = entries[j]; + if (entry.isFile) { + entry.file(function(file) { + if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { + return; + } + file.fullPath = path + "/" + file.name; + return _this.addFile(file); + }); + } else if (entry.isDirectory) { + _this._addFilesFromDirectory(entry, path + "/" + entry.name); + } + } + readEntries(); + } + return null; + }, errorHandler); + }; + })(this); + return readEntries(); + }; + + Dropzone.prototype.accept = function(file, done) { + if (file.size > this.options.maxFilesize * 1024 * 1024) { + return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); + } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { + return done(this.options.dictInvalidFileType); + } else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) { + done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles)); + return this.emit("maxfilesexceeded", file); + } else { + return this.options.accept.call(this, file, done); + } + }; + + Dropzone.prototype.addFile = function(file) { + file.upload = { + progress: 0, + total: file.size, + bytesSent: 0, + filename: this._renameFile(file) + }; + this.files.push(file); + file.status = Dropzone.ADDED; + this.emit("addedfile", file); + this._enqueueThumbnail(file); + return this.accept(file, (function(_this) { + return function(error) { + if (error) { + file.accepted = false; + _this._errorProcessing([file], error); + } else { + file.accepted = true; + if (_this.options.autoQueue) { + _this.enqueueFile(file); + } + } + return _this._updateMaxFilesReachedClass(); + }; + })(this)); + }; + + Dropzone.prototype.enqueueFiles = function(files) { + var file, j, len; + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + this.enqueueFile(file); + } + return null; + }; + + Dropzone.prototype.enqueueFile = function(file) { + if (file.status === Dropzone.ADDED && file.accepted === true) { + file.status = Dropzone.QUEUED; + if (this.options.autoProcessQueue) { + return setTimeout(((function(_this) { + return function() { + return _this.processQueue(); + }; + })(this)), 0); + } + } else { + throw new Error("This file can't be queued because it has already been processed or was rejected."); + } + }; + + Dropzone.prototype._thumbnailQueue = []; + + Dropzone.prototype._processingThumbnail = false; + + Dropzone.prototype._enqueueThumbnail = function(file) { + if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { + this._thumbnailQueue.push(file); + return setTimeout(((function(_this) { + return function() { + return _this._processThumbnailQueue(); + }; + })(this)), 0); + } + }; + + Dropzone.prototype._processThumbnailQueue = function() { + var file; + if (this._processingThumbnail || this._thumbnailQueue.length === 0) { + return; + } + this._processingThumbnail = true; + file = this._thumbnailQueue.shift(); + return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, (function(_this) { + return function(dataUrl) { + _this.emit("thumbnail", file, dataUrl); + _this._processingThumbnail = false; + return _this._processThumbnailQueue(); + }; + })(this)); + }; + + Dropzone.prototype.removeFile = function(file) { + if (file.status === Dropzone.UPLOADING) { + this.cancelUpload(file); + } + this.files = without(this.files, file); + this.emit("removedfile", file); + if (this.files.length === 0) { + return this.emit("reset"); + } + }; + + Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) { + var file, j, len, ref; + if (cancelIfNecessary == null) { + cancelIfNecessary = false; + } + ref = this.files.slice(); + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { + this.removeFile(file); + } + } + return null; + }; + + Dropzone.prototype.resizeImage = function(file, width, height, resizeMethod, callback) { + return this.createThumbnail(file, width, height, resizeMethod, false, (function(_this) { + return function(dataUrl, canvas) { + var resizeMimeType, resizedDataURL; + if (canvas === null) { + return callback(file); + } else { + resizeMimeType = _this.options.resizeMimeType; + if (resizeMimeType == null) { + resizeMimeType = file.type; + } + resizedDataURL = canvas.toDataURL(resizeMimeType, _this.options.resizeQuality); + if (resizeMimeType === 'image/jpeg' || resizeMimeType === 'image/jpg') { + resizedDataURL = ExifRestore.restore(file.dataURL, resizedDataURL); + } + return callback(Dropzone.dataURItoBlob(resizedDataURL)); + } + }; + })(this)); + }; + + Dropzone.prototype.createThumbnail = function(file, width, height, resizeMethod, fixOrientation, callback) { + var fileReader; + fileReader = new FileReader; + fileReader.onload = (function(_this) { + return function() { + file.dataURL = fileReader.result; + if (file.type === "image/svg+xml") { + if (callback != null) { + callback(fileReader.result); + } + return; + } + return _this.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback); + }; + })(this); + return fileReader.readAsDataURL(file); + }; + + Dropzone.prototype.createThumbnailFromUrl = function(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) { + var img; + img = document.createElement("img"); + if (crossOrigin) { + img.crossOrigin = crossOrigin; + } + img.onload = (function(_this) { + return function() { + var loadExif; + loadExif = function(callback) { + return callback(1); + }; + if ((typeof EXIF !== "undefined" && EXIF !== null) && fixOrientation) { + loadExif = function(callback) { + return EXIF.getData(img, function() { + return callback(EXIF.getTag(this, 'Orientation')); + }); + }; + } + return loadExif(function(orientation) { + var canvas, ctx, ref, ref1, ref2, ref3, resizeInfo, thumbnail; + file.width = img.width; + file.height = img.height; + resizeInfo = _this.options.resize.call(_this, file, width, height, resizeMethod); + canvas = document.createElement("canvas"); + ctx = canvas.getContext("2d"); + canvas.width = resizeInfo.trgWidth; + canvas.height = resizeInfo.trgHeight; + if (orientation > 4) { + canvas.width = resizeInfo.trgHeight; + canvas.height = resizeInfo.trgWidth; + } + switch (orientation) { + case 2: + ctx.translate(canvas.width, 0); + ctx.scale(-1, 1); + break; + case 3: + ctx.translate(canvas.width, canvas.height); + ctx.rotate(Math.PI); + break; + case 4: + ctx.translate(0, canvas.height); + ctx.scale(1, -1); + break; + case 5: + ctx.rotate(0.5 * Math.PI); + ctx.scale(1, -1); + break; + case 6: + ctx.rotate(0.5 * Math.PI); + ctx.translate(0, -canvas.height); + break; + case 7: + ctx.rotate(0.5 * Math.PI); + ctx.translate(canvas.width, -canvas.height); + ctx.scale(-1, 1); + break; + case 8: + ctx.rotate(-0.5 * Math.PI); + ctx.translate(-canvas.width, 0); + } + drawImageIOSFix(ctx, img, (ref = resizeInfo.srcX) != null ? ref : 0, (ref1 = resizeInfo.srcY) != null ? ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (ref2 = resizeInfo.trgX) != null ? ref2 : 0, (ref3 = resizeInfo.trgY) != null ? ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight); + thumbnail = canvas.toDataURL("image/png"); + if (callback != null) { + return callback(thumbnail, canvas); + } + }); + }; + })(this); + if (callback != null) { + img.onerror = callback; + } + return img.src = file.dataURL; + }; + + Dropzone.prototype.processQueue = function() { + var i, parallelUploads, processingLength, queuedFiles; + parallelUploads = this.options.parallelUploads; + processingLength = this.getUploadingFiles().length; + i = processingLength; + if (processingLength >= parallelUploads) { + return; + } + queuedFiles = this.getQueuedFiles(); + if (!(queuedFiles.length > 0)) { + return; + } + if (this.options.uploadMultiple) { + return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); + } else { + while (i < parallelUploads) { + if (!queuedFiles.length) { + return; + } + this.processFile(queuedFiles.shift()); + i++; + } + } + }; + + Dropzone.prototype.processFile = function(file) { + return this.processFiles([file]); + }; + + Dropzone.prototype.processFiles = function(files) { + var file, j, len; + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + file.processing = true; + file.status = Dropzone.UPLOADING; + this.emit("processing", file); + } + if (this.options.uploadMultiple) { + this.emit("processingmultiple", files); + } + return this.uploadFiles(files); + }; + + Dropzone.prototype._getFilesWithXhr = function(xhr) { + var file, files; + return files = (function() { + var j, len, ref, results; + ref = this.files; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + file = ref[j]; + if (file.xhr === xhr) { + results.push(file); + } + } + return results; + }).call(this); + }; + + Dropzone.prototype.cancelUpload = function(file) { + var groupedFile, groupedFiles, j, k, len, len1, ref; + if (file.status === Dropzone.UPLOADING) { + groupedFiles = this._getFilesWithXhr(file.xhr); + for (j = 0, len = groupedFiles.length; j < len; j++) { + groupedFile = groupedFiles[j]; + groupedFile.status = Dropzone.CANCELED; + } + file.xhr.abort(); + for (k = 0, len1 = groupedFiles.length; k < len1; k++) { + groupedFile = groupedFiles[k]; + this.emit("canceled", groupedFile); + } + if (this.options.uploadMultiple) { + this.emit("canceledmultiple", groupedFiles); + } + } else if ((ref = file.status) === Dropzone.ADDED || ref === Dropzone.QUEUED) { + file.status = Dropzone.CANCELED; + this.emit("canceled", file); + if (this.options.uploadMultiple) { + this.emit("canceledmultiple", [file]); + } + } + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + }; + + resolveOption = function() { + var args, option; + option = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; + if (typeof option === 'function') { + return option.apply(this, args); + } + return option; + }; + + Dropzone.prototype.uploadFile = function(file) { + return this.uploadFiles([file]); + }; + + Dropzone.prototype.uploadFiles = function(files) { + var doneCounter, doneFunction, file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType, j, k, key, l, len, len1, len2, len3, m, method, o, option, progressObj, ref, ref1, ref2, ref3, ref4, ref5, response, results, updateProgress, url, value, xhr; + xhr = new XMLHttpRequest(); + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + file.xhr = xhr; + } + method = resolveOption(this.options.method, files); + url = resolveOption(this.options.url, files); + xhr.open(method, url, true); + xhr.timeout = resolveOption(this.options.timeout, files); + xhr.withCredentials = !!this.options.withCredentials; + response = null; + handleError = (function(_this) { + return function() { + var k, len1, results; + results = []; + for (k = 0, len1 = files.length; k < len1; k++) { + file = files[k]; + results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)); + } + return results; + }; + })(this); + updateProgress = (function(_this) { + return function(e) { + var allFilesFinished, k, l, len1, len2, len3, m, progress, results; + if (e != null) { + progress = 100 * e.loaded / e.total; + for (k = 0, len1 = files.length; k < len1; k++) { + file = files[k]; + file.upload.progress = progress; + file.upload.total = e.total; + file.upload.bytesSent = e.loaded; + } + } else { + allFilesFinished = true; + progress = 100; + for (l = 0, len2 = files.length; l < len2; l++) { + file = files[l]; + if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) { + allFilesFinished = false; + } + file.upload.progress = progress; + file.upload.bytesSent = file.upload.total; + } + if (allFilesFinished) { + return; + } + } + results = []; + for (m = 0, len3 = files.length; m < len3; m++) { + file = files[m]; + results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent)); + } + return results; + }; + })(this); + xhr.onload = (function(_this) { + return function(e) { + var error1, ref; + if (files[0].status === Dropzone.CANCELED) { + return; + } + if (xhr.readyState !== 4) { + return; + } + if (xhr.responseType !== 'arraybuffer' && xhr.responseType !== 'blob') { + response = xhr.responseText; + if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { + try { + response = JSON.parse(response); + } catch (error1) { + e = error1; + response = "Invalid JSON response from server."; + } + } + } + updateProgress(); + if (!((200 <= (ref = xhr.status) && ref < 300))) { + return handleError(); + } else { + return _this._finished(files, response, e); + } + }; + })(this); + xhr.onerror = (function(_this) { + return function() { + if (files[0].status === Dropzone.CANCELED) { + return; + } + return handleError(); + }; + })(this); + progressObj = (ref = xhr.upload) != null ? ref : xhr; + progressObj.onprogress = updateProgress; + headers = { + "Accept": "application/json", + "Cache-Control": "no-cache", + "X-Requested-With": "XMLHttpRequest" + }; + if (this.options.headers) { + extend(headers, this.options.headers); + } + for (headerName in headers) { + headerValue = headers[headerName]; + if (headerValue) { + xhr.setRequestHeader(headerName, headerValue); + } + } + formData = new FormData(); + if (this.options.params) { + ref1 = this.options.params; + for (key in ref1) { + value = ref1[key]; + formData.append(key, value); + } + } + for (k = 0, len1 = files.length; k < len1; k++) { + file = files[k]; + this.emit("sending", file, xhr, formData); + } + if (this.options.uploadMultiple) { + this.emit("sendingmultiple", files, xhr, formData); + } + if (this.element.tagName === "FORM") { + ref2 = this.element.querySelectorAll("input, textarea, select, button"); + for (l = 0, len2 = ref2.length; l < len2; l++) { + input = ref2[l]; + inputName = input.getAttribute("name"); + inputType = input.getAttribute("type"); + if (input.tagName === "SELECT" && input.hasAttribute("multiple")) { + ref3 = input.options; + for (m = 0, len3 = ref3.length; m < len3; m++) { + option = ref3[m]; + if (option.selected) { + formData.append(inputName, option.value); + } + } + } else if (!inputType || ((ref4 = inputType.toLowerCase()) !== "checkbox" && ref4 !== "radio") || input.checked) { + formData.append(inputName, input.value); + } + } + } + doneCounter = 0; + results = []; + for (i = o = 0, ref5 = files.length - 1; 0 <= ref5 ? o <= ref5 : o >= ref5; i = 0 <= ref5 ? ++o : --o) { + doneFunction = (function(_this) { + return function(file, paramName, fileName) { + return function(transformedFile) { + formData.append(paramName, transformedFile, fileName); + if (++doneCounter === files.length) { + return _this.submitRequest(xhr, formData, files); + } + }; + }; + })(this); + results.push(this.options.transformFile.call(this, files[i], doneFunction(files[i], this._getParamName(i), files[i].upload.filename))); + } + return results; + }; + + Dropzone.prototype.submitRequest = function(xhr, formData, files) { + return xhr.send(formData); + }; + + Dropzone.prototype._finished = function(files, responseText, e) { + var file, j, len; + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + file.status = Dropzone.SUCCESS; + this.emit("success", file, responseText, e); + this.emit("complete", file); + } + if (this.options.uploadMultiple) { + this.emit("successmultiple", files, responseText, e); + this.emit("completemultiple", files); + } + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + }; + + Dropzone.prototype._errorProcessing = function(files, message, xhr) { + var file, j, len; + for (j = 0, len = files.length; j < len; j++) { + file = files[j]; + file.status = Dropzone.ERROR; + this.emit("error", file, message, xhr); + this.emit("complete", file); + } + if (this.options.uploadMultiple) { + this.emit("errormultiple", files, message, xhr); + this.emit("completemultiple", files); + } + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + }; + + return Dropzone; + + })(Emitter); + + Dropzone.version = "5.1.1"; + + Dropzone.options = {}; + + Dropzone.optionsForElement = function(element) { + if (element.getAttribute("id")) { + return Dropzone.options[camelize(element.getAttribute("id"))]; + } else { + return void 0; + } + }; + + Dropzone.instances = []; + + Dropzone.forElement = function(element) { + if (typeof element === "string") { + element = document.querySelector(element); + } + if ((element != null ? element.dropzone : void 0) == null) { + throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone."); + } + return element.dropzone; + }; + + Dropzone.autoDiscover = true; + + Dropzone.discover = function() { + var checkElements, dropzone, dropzones, j, len, results; + if (document.querySelectorAll) { + dropzones = document.querySelectorAll(".dropzone"); + } else { + dropzones = []; + checkElements = function(elements) { + var el, j, len, results; + results = []; + for (j = 0, len = elements.length; j < len; j++) { + el = elements[j]; + if (/(^| )dropzone($| )/.test(el.className)) { + results.push(dropzones.push(el)); + } else { + results.push(void 0); + } + } + return results; + }; + checkElements(document.getElementsByTagName("div")); + checkElements(document.getElementsByTagName("form")); + } + results = []; + for (j = 0, len = dropzones.length; j < len; j++) { + dropzone = dropzones[j]; + if (Dropzone.optionsForElement(dropzone) !== false) { + results.push(new Dropzone(dropzone)); + } else { + results.push(void 0); + } + } + return results; + }; + + Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i]; + + Dropzone.isBrowserSupported = function() { + var capableBrowser, j, len, ref, regex; + capableBrowser = true; + if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) { + if (!("classList" in document.createElement("a"))) { + capableBrowser = false; + } else { + ref = Dropzone.blacklistedBrowsers; + for (j = 0, len = ref.length; j < len; j++) { + regex = ref[j]; + if (regex.test(navigator.userAgent)) { + capableBrowser = false; + continue; + } + } + } + } else { + capableBrowser = false; + } + return capableBrowser; + }; + + Dropzone.dataURItoBlob = function(dataURI) { + var ab, byteString, i, ia, j, mimeString, ref; + byteString = atob(dataURI.split(',')[1]); + mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; + ab = new ArrayBuffer(byteString.length); + ia = new Uint8Array(ab); + for (i = j = 0, ref = byteString.length; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { + ia[i] = byteString.charCodeAt(i); + } + return new Blob([ab], { + type: mimeString + }); + }; + + without = function(list, rejectedItem) { + var item, j, len, results; + results = []; + for (j = 0, len = list.length; j < len; j++) { + item = list[j]; + if (item !== rejectedItem) { + results.push(item); + } + } + return results; + }; + + camelize = function(str) { + return str.replace(/[\-_](\w)/g, function(match) { + return match.charAt(1).toUpperCase(); + }); + }; + + Dropzone.createElement = function(string) { + var div; + div = document.createElement("div"); + div.innerHTML = string; + return div.childNodes[0]; + }; + + Dropzone.elementInside = function(element, container) { + if (element === container) { + return true; + } + while (element = element.parentNode) { + if (element === container) { + return true; + } + } + return false; + }; + + Dropzone.getElement = function(el, name) { + var element; + if (typeof el === "string") { + element = document.querySelector(el); + } else if (el.nodeType != null) { + element = el; + } + if (element == null) { + throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); + } + return element; + }; + + Dropzone.getElements = function(els, name) { + var e, el, elements, error1, j, k, len, len1, ref; + if (els instanceof Array) { + elements = []; + try { + for (j = 0, len = els.length; j < len; j++) { + el = els[j]; + elements.push(this.getElement(el, name)); + } + } catch (error1) { + e = error1; + elements = null; + } + } else if (typeof els === "string") { + elements = []; + ref = document.querySelectorAll(els); + for (k = 0, len1 = ref.length; k < len1; k++) { + el = ref[k]; + elements.push(el); + } + } else if (els.nodeType != null) { + elements = [els]; + } + if (!((elements != null) && elements.length)) { + throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); + } + return elements; + }; + + Dropzone.confirm = function(question, accepted, rejected) { + if (window.confirm(question)) { + return accepted(); + } else if (rejected != null) { + return rejected(); + } + }; + + Dropzone.isValidFile = function(file, acceptedFiles) { + var baseMimeType, j, len, mimeType, validType; + if (!acceptedFiles) { + return true; + } + acceptedFiles = acceptedFiles.split(","); + mimeType = file.type; + baseMimeType = mimeType.replace(/\/.*$/, ""); + for (j = 0, len = acceptedFiles.length; j < len; j++) { + validType = acceptedFiles[j]; + validType = validType.trim(); + if (validType.charAt(0) === ".") { + if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) { + return true; + } + } else if (/\/\*$/.test(validType)) { + if (baseMimeType === validType.replace(/\/.*$/, "")) { + return true; + } + } else { + if (mimeType === validType) { + return true; + } + } + } + return false; + }; + + if (typeof jQuery !== "undefined" && jQuery !== null) { + jQuery.fn.dropzone = function(options) { + return this.each(function() { + return new Dropzone(this, options); + }); + }; + } + + if (typeof module !== "undefined" && module !== null) { + module.exports = Dropzone; + } else { + window.Dropzone = Dropzone; + } + + Dropzone.ADDED = "added"; + + Dropzone.QUEUED = "queued"; + + Dropzone.ACCEPTED = Dropzone.QUEUED; + + Dropzone.UPLOADING = "uploading"; + + Dropzone.PROCESSING = Dropzone.UPLOADING; + + Dropzone.CANCELED = "canceled"; + + Dropzone.ERROR = "error"; + + Dropzone.SUCCESS = "success"; + + + /* + + Bugfix for iOS 6 and 7 + Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios + based on the work of https://github.com/stomita/ios-imagefile-megapixel + */ + + detectVerticalSquash = function(img) { + var alpha, canvas, ctx, data, ey, ih, iw, py, ratio, sy; + iw = img.naturalWidth; + ih = img.naturalHeight; + canvas = document.createElement("canvas"); + canvas.width = 1; + canvas.height = ih; + ctx = canvas.getContext("2d"); + ctx.drawImage(img, 0, 0); + data = ctx.getImageData(1, 0, 1, ih).data; + sy = 0; + ey = ih; + py = ih; + while (py > sy) { + alpha = data[(py - 1) * 4 + 3]; + if (alpha === 0) { + ey = py; + } else { + sy = py; + } + py = (ey + sy) >> 1; + } + ratio = py / ih; + if (ratio === 0) { + return 1; + } else { + return ratio; + } + }; + + drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) { + var vertSquashRatio; + vertSquashRatio = detectVerticalSquash(img); + return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio); + }; + + ExifRestore = (function() { + function ExifRestore() {} + + ExifRestore.KEY_STR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + ExifRestore.encode64 = function(input) { + var chr1, chr2, chr3, enc1, enc2, enc3, enc4, i, output; + output = ''; + chr1 = void 0; + chr2 = void 0; + chr3 = ''; + enc1 = void 0; + enc2 = void 0; + enc3 = void 0; + enc4 = ''; + i = 0; + while (true) { + chr1 = input[i++]; + chr2 = input[i++]; + chr3 = input[i++]; + enc1 = chr1 >> 2; + enc2 = (chr1 & 3) << 4 | chr2 >> 4; + enc3 = (chr2 & 15) << 2 | chr3 >> 6; + enc4 = chr3 & 63; + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + if (!(i < input.length)) { + break; + } + } + return output; + }; + + ExifRestore.restore = function(origFileBase64, resizedFileBase64) { + var image, rawImage, segments; + if (!origFileBase64.match('data:image/jpeg;base64,')) { + return resizedFileBase64; + } + rawImage = this.decode64(origFileBase64.replace('data:image/jpeg;base64,', '')); + segments = this.slice2Segments(rawImage); + image = this.exifManipulation(resizedFileBase64, segments); + return 'data:image/jpeg;base64,' + this.encode64(image); + }; + + ExifRestore.exifManipulation = function(resizedFileBase64, segments) { + var aBuffer, exifArray, newImageArray; + exifArray = this.getExifArray(segments); + newImageArray = this.insertExif(resizedFileBase64, exifArray); + aBuffer = new Uint8Array(newImageArray); + return aBuffer; + }; + + ExifRestore.getExifArray = function(segments) { + var seg, x; + seg = void 0; + x = 0; + while (x < segments.length) { + seg = segments[x]; + if (seg[0] === 255 & seg[1] === 225) { + return seg; + } + x++; + } + return []; + }; + + ExifRestore.insertExif = function(resizedFileBase64, exifArray) { + var array, ato, buf, imageData, mae, separatePoint; + imageData = resizedFileBase64.replace('data:image/jpeg;base64,', ''); + buf = this.decode64(imageData); + separatePoint = buf.indexOf(255, 3); + mae = buf.slice(0, separatePoint); + ato = buf.slice(separatePoint); + array = mae; + array = array.concat(exifArray); + array = array.concat(ato); + return array; + }; + + ExifRestore.slice2Segments = function(rawImageArray) { + var endPoint, head, length, seg, segments; + head = 0; + segments = []; + while (true) { + if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) { + break; + } + if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) { + head += 2; + } else { + length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3]; + endPoint = head + length + 2; + seg = rawImageArray.slice(head, endPoint); + segments.push(seg); + head = endPoint; + } + if (head > rawImageArray.length) { + break; + } + } + return segments; + }; + + ExifRestore.decode64 = function(input) { + var base64test, buf, chr1, chr2, chr3, enc1, enc2, enc3, enc4, i, output; + output = ''; + chr1 = void 0; + chr2 = void 0; + chr3 = ''; + enc1 = void 0; + enc2 = void 0; + enc3 = void 0; + enc4 = ''; + i = 0; + buf = []; + base64test = /[^A-Za-z0-9\+\/\=]/g; + if (base64test.exec(input)) { + console.warning('There were invalid base64 characters in the input text.\n' + 'Valid base64 characters are A-Z, a-z, 0-9, \'+\', \'/\',and \'=\'\n' + 'Expect errors in decoding.'); + } + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); + while (true) { + enc1 = this.KEY_STR.indexOf(input.charAt(i++)); + enc2 = this.KEY_STR.indexOf(input.charAt(i++)); + enc3 = this.KEY_STR.indexOf(input.charAt(i++)); + enc4 = this.KEY_STR.indexOf(input.charAt(i++)); + chr1 = enc1 << 2 | enc2 >> 4; + chr2 = (enc2 & 15) << 4 | enc3 >> 2; + chr3 = (enc3 & 3) << 6 | enc4; + buf.push(chr1); + if (enc3 !== 64) { + buf.push(chr2); + } + if (enc4 !== 64) { + buf.push(chr3); + } + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + if (!(i < input.length)) { + break; + } + } + return buf; + }; + + return ExifRestore; + + })(); + + + /* + * contentloaded.js + * + * Author: Diego Perini (diego.perini at gmail.com) + * Summary: cross-browser wrapper for DOMContentLoaded + * Updated: 20101020 + * License: MIT + * Version: 1.2 + * + * URL: + * http://javascript.nwbox.com/ContentLoaded/ + * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE + */ + + contentLoaded = function(win, fn) { + var add, doc, done, init, poll, pre, rem, root, top; + done = false; + top = true; + doc = win.document; + root = doc.documentElement; + add = (doc.addEventListener ? "addEventListener" : "attachEvent"); + rem = (doc.addEventListener ? "removeEventListener" : "detachEvent"); + pre = (doc.addEventListener ? "" : "on"); + init = function(e) { + if (e.type === "readystatechange" && doc.readyState !== "complete") { + return; + } + (e.type === "load" ? win : doc)[rem](pre + e.type, init, false); + if (!done && (done = true)) { + return fn.call(win, e.type || e); + } + }; + poll = function() { + var e, error1; + try { + root.doScroll("left"); + } catch (error1) { + e = error1; + setTimeout(poll, 50); + return; + } + return init("poll"); + }; + if (doc.readyState !== "complete") { + if (doc.createEventObject && root.doScroll) { + try { + top = !win.frameElement; + } catch (undefined) {} + if (top) { + poll(); + } + } + doc[add](pre + "DOMContentLoaded", init, false); + doc[add](pre + "readystatechange", init, false); + return win[add](pre + "load", init, false); + } + }; + + Dropzone._autoDiscoverFunction = function() { + if (Dropzone.autoDiscover) { + return Dropzone.discover(); + } + }; + + contentLoaded(window, Dropzone._autoDiscoverFunction); + +}).call(this); + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/module.js")(module))) + +/***/ }), + +/***/ "./node_modules/keycode/index.js": +/***/ (function(module, exports) { + +// Source: http://jsfiddle.net/vWx8V/ +// http://stackoverflow.com/questions/5603195/full-list-of-javascript-keycodes + +/** + * Conenience method returns corresponding value for given keyName or keyCode. + * + * @param {Mixed} keyCode {Number} or keyName {String} + * @return {Mixed} + * @api public + */ + +exports = module.exports = function(searchInput) { + // Keyboard Events + if (searchInput && 'object' === typeof searchInput) { + var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode + if (hasKeyCode) searchInput = hasKeyCode + } + + // Numbers + if ('number' === typeof searchInput) return names[searchInput] + + // Everything else (cast to string) + var search = String(searchInput) + + // check codes + var foundNamedKey = codes[search.toLowerCase()] + if (foundNamedKey) return foundNamedKey + + // check aliases + var foundNamedKey = aliases[search.toLowerCase()] + if (foundNamedKey) return foundNamedKey + + // weird character? + if (search.length === 1) return search.charCodeAt(0) + + return undefined +} + +/** + * Get by name + * + * exports.code['enter'] // => 13 + */ + +var codes = exports.code = exports.codes = { + 'backspace': 8, + 'tab': 9, + 'enter': 13, + 'shift': 16, + 'ctrl': 17, + 'alt': 18, + 'pause/break': 19, + 'caps lock': 20, + 'esc': 27, + 'space': 32, + 'page up': 33, + 'page down': 34, + 'end': 35, + 'home': 36, + 'left': 37, + 'up': 38, + 'right': 39, + 'down': 40, + 'insert': 45, + 'delete': 46, + 'command': 91, + 'left command': 91, + 'right command': 93, + 'numpad *': 106, + 'numpad +': 107, + 'numpad -': 109, + 'numpad .': 110, + 'numpad /': 111, + 'num lock': 144, + 'scroll lock': 145, + 'my computer': 182, + 'my calculator': 183, + ';': 186, + '=': 187, + ',': 188, + '-': 189, + '.': 190, + '/': 191, + '`': 192, + '[': 219, + '\\': 220, + ']': 221, + "'": 222 +} + +// Helper aliases + +var aliases = exports.aliases = { + 'windows': 91, + '⇧': 16, + '⌥': 18, + '⌃': 17, + '⌘': 91, + 'ctl': 17, + 'control': 17, + 'option': 18, + 'pause': 19, + 'break': 19, + 'caps': 20, + 'return': 13, + 'escape': 27, + 'spc': 32, + 'pgup': 33, + 'pgdn': 34, + 'ins': 45, + 'del': 46, + 'cmd': 91 +} + + +/*! + * Programatically add the following + */ + +// lower case chars +for (i = 97; i < 123; i++) codes[String.fromCharCode(i)] = i - 32 + +// numbers +for (var i = 48; i < 58; i++) codes[i - 48] = i + +// function keys +for (i = 1; i < 13; i++) codes['f'+i] = i + 111 + +// numpad keys +for (i = 0; i < 10; i++) codes['numpad '+i] = i + 96 + +/** + * Get by code + * + * exports.name[13] // => 'Enter' + */ + +var names = exports.names = exports.title = {} // title for backward compat + +// Create reverse mapping +for (i in codes) names[codes[i]] = i + +// Add aliases +for (var alias in aliases) { + codes[alias] = aliases[alias] +} + + +/***/ }), + +/***/ "./node_modules/laravel-echo/dist/echo.js": +/***/ (function(module, exports) { + +var asyncGenerator = function () { + function AwaitValue(value) { + this.value = value; + } + + function AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + + if (value instanceof AwaitValue) { + Promise.resolve(value.value).then(function (arg) { + resume("next", arg); + }, function (arg) { + resume("throw", arg); + }); + } else { + settle(result.done ? "return" : "normal", result.value); + } + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + return { + wrap: function (fn) { + return function () { + return new AsyncGenerator(fn.apply(this, arguments)); + }; + }, + await: function (value) { + return new AwaitValue(value); + } + }; +}(); + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +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; + }; +}(); + +var _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; +}; + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; +}; + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; + +var Connector = function () { + function Connector(options) { + classCallCheck(this, Connector); + + this._defaultOptions = { + auth: { + headers: {} + }, + authEndpoint: '/broadcasting/auth', + broadcaster: 'pusher', + csrfToken: null, + host: null, + key: null, + namespace: 'App.Events' + }; + this.setOptions(options); + this.connect(); + } + + createClass(Connector, [{ + key: 'setOptions', + value: function setOptions(options) { + this.options = _extends(this._defaultOptions, options); + if (this.csrfToken()) { + this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken(); + } + return options; + } + }, { + key: 'csrfToken', + value: function csrfToken() { + var selector = void 0; + if (window && window['Laravel'] && window['Laravel'].csrfToken) { + return window['Laravel'].csrfToken; + } else if (this.options.csrfToken) { + return this.options.csrfToken; + } else if (typeof document !== 'undefined' && (selector = document.querySelector('meta[name="csrf-token"]'))) { + return selector.getAttribute('content'); + } + return null; + } + }]); + return Connector; +}(); + +var Channel = function () { + function Channel() { + classCallCheck(this, Channel); + } + + createClass(Channel, [{ + key: 'notification', + value: function notification(callback) { + return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback); + } + }, { + key: 'listenForWhisper', + value: function listenForWhisper(event, callback) { + return this.listen('.client-' + event, callback); + } + }]); + return Channel; +}(); + +var EventFormatter = function () { + function EventFormatter(namespace) { + classCallCheck(this, EventFormatter); + + this.setNamespace(namespace); + } + + createClass(EventFormatter, [{ + key: 'format', + value: function format(event) { + if (event.charAt(0) === '.' || event.charAt(0) === '\\') { + return event.substr(1); + } else if (this.namespace) { + event = this.namespace + '.' + event; + } + return event.replace(/\./g, '\\'); + } + }, { + key: 'setNamespace', + value: function setNamespace(value) { + this.namespace = value; + } + }]); + return EventFormatter; +}(); + +var PusherChannel = function (_Channel) { + inherits(PusherChannel, _Channel); + + function PusherChannel(pusher, name, options) { + classCallCheck(this, PusherChannel); + + var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this)); + + _this.name = name; + _this.pusher = pusher; + _this.options = options; + _this.eventFormatter = new EventFormatter(_this.options.namespace); + _this.subscribe(); + return _this; + } + + createClass(PusherChannel, [{ + key: 'subscribe', + value: function subscribe() { + this.subscription = this.pusher.subscribe(this.name); + } + }, { + key: 'unsubscribe', + value: function unsubscribe() { + this.pusher.unsubscribe(this.name); + } + }, { + key: 'listen', + value: function listen(event, callback) { + this.on(this.eventFormatter.format(event), callback); + return this; + } + }, { + key: 'stopListening', + value: function stopListening(event) { + this.subscription.unbind(this.eventFormatter.format(event)); + return this; + } + }, { + key: 'on', + value: function on(event, callback) { + this.subscription.bind(event, callback); + return this; + } + }]); + return PusherChannel; +}(Channel); + +var PusherPrivateChannel = function (_PusherChannel) { + inherits(PusherPrivateChannel, _PusherChannel); + + function PusherPrivateChannel() { + classCallCheck(this, PusherPrivateChannel); + return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments)); + } + + createClass(PusherPrivateChannel, [{ + key: 'whisper', + value: function whisper(eventName, data) { + this.pusher.channels.channels[this.name].trigger('client-' + eventName, data); + return this; + } + }]); + return PusherPrivateChannel; +}(PusherChannel); + +var PusherPresenceChannel = function (_PusherChannel) { + inherits(PusherPresenceChannel, _PusherChannel); + + function PusherPresenceChannel() { + classCallCheck(this, PusherPresenceChannel); + return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments)); + } + + createClass(PusherPresenceChannel, [{ + key: 'here', + value: function here(callback) { + this.on('pusher:subscription_succeeded', function (data) { + callback(Object.keys(data.members).map(function (k) { + return data.members[k]; + })); + }); + return this; + } + }, { + key: 'joining', + value: function joining(callback) { + this.on('pusher:member_added', function (member) { + callback(member.info); + }); + return this; + } + }, { + key: 'leaving', + value: function leaving(callback) { + this.on('pusher:member_removed', function (member) { + callback(member.info); + }); + return this; + } + }, { + key: 'whisper', + value: function whisper(eventName, data) { + this.pusher.channels.channels[this.name].trigger('client-' + eventName, data); + return this; + } + }]); + return PusherPresenceChannel; +}(PusherChannel); + +var SocketIoChannel = function (_Channel) { + inherits(SocketIoChannel, _Channel); + + function SocketIoChannel(socket, name, options) { + classCallCheck(this, SocketIoChannel); + + var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this)); + + _this.events = {}; + _this.name = name; + _this.socket = socket; + _this.options = options; + _this.eventFormatter = new EventFormatter(_this.options.namespace); + _this.subscribe(); + _this.configureReconnector(); + return _this; + } + + createClass(SocketIoChannel, [{ + key: 'subscribe', + value: function subscribe() { + this.socket.emit('subscribe', { + channel: this.name, + auth: this.options.auth || {} + }); + } + }, { + key: 'unsubscribe', + value: function unsubscribe() { + this.unbind(); + this.socket.emit('unsubscribe', { + channel: this.name, + auth: this.options.auth || {} + }); + } + }, { + key: 'listen', + value: function listen(event, callback) { + this.on(this.eventFormatter.format(event), callback); + return this; + } + }, { + key: 'on', + value: function on(event, callback) { + var _this2 = this; + + var listener = function listener(channel, data) { + if (_this2.name == channel) { + callback(data); + } + }; + this.socket.on(event, listener); + this.bind(event, listener); + } + }, { + key: 'configureReconnector', + value: function configureReconnector() { + var _this3 = this; + + var listener = function listener() { + _this3.subscribe(); + }; + this.socket.on('reconnect', listener); + this.bind('reconnect', listener); + } + }, { + key: 'bind', + value: function bind(event, callback) { + this.events[event] = this.events[event] || []; + this.events[event].push(callback); + } + }, { + key: 'unbind', + value: function unbind() { + var _this4 = this; + + Object.keys(this.events).forEach(function (event) { + _this4.events[event].forEach(function (callback) { + _this4.socket.removeListener(event, callback); + }); + delete _this4.events[event]; + }); + } + }]); + return SocketIoChannel; +}(Channel); + +var SocketIoPrivateChannel = function (_SocketIoChannel) { + inherits(SocketIoPrivateChannel, _SocketIoChannel); + + function SocketIoPrivateChannel() { + classCallCheck(this, SocketIoPrivateChannel); + return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments)); + } + + createClass(SocketIoPrivateChannel, [{ + key: 'whisper', + value: function whisper(eventName, data) { + this.socket.emit('client event', { + channel: this.name, + event: 'client-' + eventName, + data: data + }); + return this; + } + }]); + return SocketIoPrivateChannel; +}(SocketIoChannel); + +var SocketIoPresenceChannel = function (_SocketIoPrivateChann) { + inherits(SocketIoPresenceChannel, _SocketIoPrivateChann); + + function SocketIoPresenceChannel() { + classCallCheck(this, SocketIoPresenceChannel); + return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments)); + } + + createClass(SocketIoPresenceChannel, [{ + key: 'here', + value: function here(callback) { + this.on('presence:subscribed', function (members) { + callback(members.map(function (m) { + return m.user_info; + })); + }); + return this; + } + }, { + key: 'joining', + value: function joining(callback) { + this.on('presence:joining', function (member) { + return callback(member.user_info); + }); + return this; + } + }, { + key: 'leaving', + value: function leaving(callback) { + this.on('presence:leaving', function (member) { + return callback(member.user_info); + }); + return this; + } + }]); + return SocketIoPresenceChannel; +}(SocketIoPrivateChannel); + +var PusherConnector = function (_Connector) { + inherits(PusherConnector, _Connector); + + function PusherConnector() { + var _ref; + + classCallCheck(this, PusherConnector); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var _this = possibleConstructorReturn(this, (_ref = PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).call.apply(_ref, [this].concat(args))); + + _this.channels = {}; + return _this; + } + + createClass(PusherConnector, [{ + key: 'connect', + value: function connect() { + this.pusher = new Pusher(this.options.key, this.options); + } + }, { + key: 'listen', + value: function listen(name, event, callback) { + return this.channel(name).listen(event, callback); + } + }, { + key: 'channel', + value: function channel(name) { + if (!this.channels[name]) { + this.channels[name] = new PusherChannel(this.pusher, name, this.options); + } + return this.channels[name]; + } + }, { + key: 'privateChannel', + value: function privateChannel(name) { + if (!this.channels['private-' + name]) { + this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options); + } + return this.channels['private-' + name]; + } + }, { + key: 'presenceChannel', + value: function presenceChannel(name) { + if (!this.channels['presence-' + name]) { + this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options); + } + return this.channels['presence-' + name]; + } + }, { + key: 'leave', + value: function leave(name) { + var _this2 = this; + + var channels = [name, 'private-' + name, 'presence-' + name]; + channels.forEach(function (name, index) { + if (_this2.channels[name]) { + _this2.channels[name].unsubscribe(); + delete _this2.channels[name]; + } + }); + } + }, { + key: 'socketId', + value: function socketId() { + return this.pusher.connection.socket_id; + } + }, { + key: 'disconnect', + value: function disconnect() { + this.pusher.disconnect(); + } + }]); + return PusherConnector; +}(Connector); + +var SocketIoConnector = function (_Connector) { + inherits(SocketIoConnector, _Connector); + + function SocketIoConnector() { + var _ref; + + classCallCheck(this, SocketIoConnector); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var _this = possibleConstructorReturn(this, (_ref = SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).call.apply(_ref, [this].concat(args))); + + _this.channels = {}; + return _this; + } + + createClass(SocketIoConnector, [{ + key: 'connect', + value: function connect() { + this.socket = io(this.options.host, this.options); + return this.socket; + } + }, { + key: 'listen', + value: function listen(name, event, callback) { + return this.channel(name).listen(event, callback); + } + }, { + key: 'channel', + value: function channel(name) { + if (!this.channels[name]) { + this.channels[name] = new SocketIoChannel(this.socket, name, this.options); + } + return this.channels[name]; + } + }, { + key: 'privateChannel', + value: function privateChannel(name) { + if (!this.channels['private-' + name]) { + this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options); + } + return this.channels['private-' + name]; + } + }, { + key: 'presenceChannel', + value: function presenceChannel(name) { + if (!this.channels['presence-' + name]) { + this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options); + } + return this.channels['presence-' + name]; + } + }, { + key: 'leave', + value: function leave(name) { + var _this2 = this; + + var channels = [name, 'private-' + name, 'presence-' + name]; + channels.forEach(function (name) { + if (_this2.channels[name]) { + _this2.channels[name].unsubscribe(); + delete _this2.channels[name]; + } + }); + } + }, { + key: 'socketId', + value: function socketId() { + return this.socket.id; + } + }, { + key: 'disconnect', + value: function disconnect() { + this.socket.disconnect(); + } + }]); + return SocketIoConnector; +}(Connector); + +var Echo = function () { + function Echo(options) { + classCallCheck(this, Echo); + + this.options = options; + if (typeof Vue === 'function' && Vue.http) { + this.registerVueRequestInterceptor(); + } + if (typeof axios === 'function') { + this.registerAxiosRequestInterceptor(); + } + if (typeof jQuery === 'function') { + this.registerjQueryAjaxSetup(); + } + if (this.options.broadcaster == 'pusher') { + this.connector = new PusherConnector(this.options); + } else if (this.options.broadcaster == 'socket.io') { + this.connector = new SocketIoConnector(this.options); + } + } + + createClass(Echo, [{ + key: 'registerVueRequestInterceptor', + value: function registerVueRequestInterceptor() { + var _this = this; + + Vue.http.interceptors.push(function (request, next) { + if (_this.socketId()) { + request.headers.set('X-Socket-ID', _this.socketId()); + } + next(); + }); + } + }, { + key: 'registerAxiosRequestInterceptor', + value: function registerAxiosRequestInterceptor() { + var _this2 = this; + + axios.interceptors.request.use(function (config) { + if (_this2.socketId()) { + config.headers['X-Socket-Id'] = _this2.socketId(); + } + return config; + }); + } + }, { + key: 'registerjQueryAjaxSetup', + value: function registerjQueryAjaxSetup() { + var _this3 = this; + + if (typeof jQuery.ajax != 'undefined') { + jQuery.ajaxSetup({ + beforeSend: function beforeSend(xhr) { + if (_this3.socketId()) { + xhr.setRequestHeader('X-Socket-Id', _this3.socketId()); + } + } + }); + } + } + }, { + key: 'listen', + value: function listen(channel, event, callback) { + return this.connector.listen(channel, event, callback); + } + }, { + key: 'channel', + value: function channel(_channel) { + return this.connector.channel(_channel); + } + }, { + key: 'private', + value: function _private(channel) { + return this.connector.privateChannel(channel); + } + }, { + key: 'join', + value: function join(channel) { + return this.connector.presenceChannel(channel); + } + }, { + key: 'leave', + value: function leave(channel) { + this.connector.leave(channel); + } + }, { + key: 'socketId', + value: function socketId() { + return this.connector.socketId(); + } + }, { + key: 'disconnect', + value: function disconnect() { + this.connector.disconnect(); + } + }]); + return Echo; +}(); + +module.exports = Echo; + +/***/ }), + +/***/ "./node_modules/pusher-js/dist/web/pusher.js": +/***/ (function(module, exports, __webpack_require__) { + +/*! + * Pusher JavaScript Library v4.1.0 + * https://pusher.com/ + * + * Copyright 2017, Pusher + * Released under the MIT licence. + */ + +(function webpackUniversalModuleDefinition(root, factory) { + if(true) + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["Pusher"] = factory(); + else + root["Pusher"] = factory(); +})(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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var pusher_1 = __webpack_require__(1); + module.exports = pusher_1["default"]; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var Collections = __webpack_require__(9); + var dispatcher_1 = __webpack_require__(23); + var timeline_1 = __webpack_require__(38); + var level_1 = __webpack_require__(39); + var StrategyBuilder = __webpack_require__(40); + var timers_1 = __webpack_require__(12); + var defaults_1 = __webpack_require__(5); + var DefaultConfig = __webpack_require__(62); + var logger_1 = __webpack_require__(8); + var factory_1 = __webpack_require__(42); + var Pusher = (function () { + function Pusher(app_key, options) { + var _this = this; + checkAppKey(app_key); + options = options || {}; + this.key = app_key; + this.config = Collections.extend(DefaultConfig.getGlobalConfig(), options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, options); + this.channels = factory_1["default"].createChannels(); + this.global_emitter = new dispatcher_1["default"](); + this.sessionID = Math.floor(Math.random() * 1000000000); + this.timeline = new timeline_1["default"](this.key, this.sessionID, { + cluster: this.config.cluster, + features: Pusher.getClientFeatures(), + params: this.config.timelineParams || {}, + limit: 50, + level: level_1["default"].INFO, + version: defaults_1["default"].VERSION + }); + if (!this.config.disableStats) { + this.timelineSender = factory_1["default"].createTimelineSender(this.timeline, { + host: this.config.statsHost, + path: "/timeline/v2/" + runtime_1["default"].TimelineTransport.name + }); + } + var getStrategy = function (options) { + var config = Collections.extend({}, _this.config, options); + return StrategyBuilder.build(runtime_1["default"].getDefaultStrategy(config), config); + }; + this.connection = factory_1["default"].createConnectionManager(this.key, Collections.extend({ getStrategy: getStrategy, + timeline: this.timeline, + activityTimeout: this.config.activity_timeout, + pongTimeout: this.config.pong_timeout, + unavailableTimeout: this.config.unavailable_timeout + }, this.config, { encrypted: this.isEncrypted() })); + this.connection.bind('connected', function () { + _this.subscribeAll(); + if (_this.timelineSender) { + _this.timelineSender.send(_this.connection.isEncrypted()); + } + }); + this.connection.bind('message', function (params) { + var internal = (params.event.indexOf('pusher_internal:') === 0); + if (params.channel) { + var channel = _this.channel(params.channel); + if (channel) { + channel.handleEvent(params.event, params.data); + } + } + if (!internal) { + _this.global_emitter.emit(params.event, params.data); + } + }); + this.connection.bind('connecting', function () { + _this.channels.disconnect(); + }); + this.connection.bind('disconnected', function () { + _this.channels.disconnect(); + }); + this.connection.bind('error', function (err) { + logger_1["default"].warn('Error', err); + }); + Pusher.instances.push(this); + this.timeline.info({ instances: Pusher.instances.length }); + if (Pusher.isReady) { + this.connect(); + } + } + Pusher.ready = function () { + Pusher.isReady = true; + for (var i = 0, l = Pusher.instances.length; i < l; i++) { + Pusher.instances[i].connect(); + } + }; + Pusher.log = function (message) { + if (Pusher.logToConsole && (window).console && (window).console.log) { + (window).console.log(message); + } + }; + Pusher.getClientFeatures = function () { + return Collections.keys(Collections.filterObject({ "ws": runtime_1["default"].Transports.ws }, function (t) { return t.isSupported({}); })); + }; + Pusher.prototype.channel = function (name) { + return this.channels.find(name); + }; + Pusher.prototype.allChannels = function () { + return this.channels.all(); + }; + Pusher.prototype.connect = function () { + this.connection.connect(); + if (this.timelineSender) { + if (!this.timelineSenderTimer) { + var encrypted = this.connection.isEncrypted(); + var timelineSender = this.timelineSender; + this.timelineSenderTimer = new timers_1.PeriodicTimer(60000, function () { + timelineSender.send(encrypted); + }); + } + } + }; + Pusher.prototype.disconnect = function () { + this.connection.disconnect(); + if (this.timelineSenderTimer) { + this.timelineSenderTimer.ensureAborted(); + this.timelineSenderTimer = null; + } + }; + Pusher.prototype.bind = function (event_name, callback, context) { + this.global_emitter.bind(event_name, callback, context); + return this; + }; + Pusher.prototype.unbind = function (event_name, callback, context) { + this.global_emitter.unbind(event_name, callback, context); + return this; + }; + Pusher.prototype.bind_global = function (callback) { + this.global_emitter.bind_global(callback); + return this; + }; + Pusher.prototype.unbind_global = function (callback) { + this.global_emitter.unbind_global(callback); + return this; + }; + Pusher.prototype.unbind_all = function (callback) { + this.global_emitter.unbind_all(); + return this; + }; + Pusher.prototype.subscribeAll = function () { + var channelName; + for (channelName in this.channels.channels) { + if (this.channels.channels.hasOwnProperty(channelName)) { + this.subscribe(channelName); + } + } + }; + Pusher.prototype.subscribe = function (channel_name) { + var channel = this.channels.add(channel_name, this); + if (channel.subscriptionPending && channel.subscriptionCancelled) { + channel.reinstateSubscription(); + } + else if (!channel.subscriptionPending && this.connection.state === "connected") { + channel.subscribe(); + } + return channel; + }; + Pusher.prototype.unsubscribe = function (channel_name) { + var channel = this.channels.find(channel_name); + if (channel && channel.subscriptionPending) { + channel.cancelSubscription(); + } + else { + channel = this.channels.remove(channel_name); + if (channel && this.connection.state === "connected") { + channel.unsubscribe(); + } + } + }; + Pusher.prototype.send_event = function (event_name, data, channel) { + return this.connection.send_event(event_name, data, channel); + }; + Pusher.prototype.isEncrypted = function () { + if (runtime_1["default"].getProtocol() === "https:") { + return true; + } + else { + return Boolean(this.config.encrypted); + } + }; + Pusher.instances = []; + Pusher.isReady = false; + Pusher.logToConsole = false; + Pusher.Runtime = runtime_1["default"]; + Pusher.ScriptReceivers = runtime_1["default"].ScriptReceivers; + Pusher.DependenciesReceivers = runtime_1["default"].DependenciesReceivers; + Pusher.auth_callbacks = runtime_1["default"].auth_callbacks; + return Pusher; + }()); + exports.__esModule = true; + exports["default"] = Pusher; + function checkAppKey(key) { + if (key === null || key === undefined) { + throw "You must pass your app key when you instantiate Pusher."; + } + } + runtime_1["default"].setup(Pusher); + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var dependencies_1 = __webpack_require__(3); + var xhr_auth_1 = __webpack_require__(7); + var jsonp_auth_1 = __webpack_require__(14); + var script_request_1 = __webpack_require__(15); + var jsonp_request_1 = __webpack_require__(16); + var script_receiver_factory_1 = __webpack_require__(4); + var jsonp_timeline_1 = __webpack_require__(17); + var transports_1 = __webpack_require__(18); + var net_info_1 = __webpack_require__(25); + var default_strategy_1 = __webpack_require__(26); + var transport_connection_initializer_1 = __webpack_require__(27); + var http_1 = __webpack_require__(28); + var Runtime = { + nextAuthCallbackID: 1, + auth_callbacks: {}, + ScriptReceivers: script_receiver_factory_1.ScriptReceivers, + DependenciesReceivers: dependencies_1.DependenciesReceivers, + getDefaultStrategy: default_strategy_1["default"], + Transports: transports_1["default"], + transportConnectionInitializer: transport_connection_initializer_1["default"], + HTTPFactory: http_1["default"], + TimelineTransport: jsonp_timeline_1["default"], + getXHRAPI: function () { + return window.XMLHttpRequest; + }, + getWebSocketAPI: function () { + return window.WebSocket || window.MozWebSocket; + }, + setup: function (PusherClass) { + var _this = this; + window.Pusher = PusherClass; + var initializeOnDocumentBody = function () { + _this.onDocumentBody(PusherClass.ready); + }; + if (!window.JSON) { + dependencies_1.Dependencies.load("json2", {}, initializeOnDocumentBody); + } + else { + initializeOnDocumentBody(); + } + }, + getDocument: function () { + return document; + }, + getProtocol: function () { + return this.getDocument().location.protocol; + }, + getAuthorizers: function () { + return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] }; + }, + onDocumentBody: function (callback) { + var _this = this; + if (document.body) { + callback(); + } + else { + setTimeout(function () { + _this.onDocumentBody(callback); + }, 0); + } + }, + createJSONPRequest: function (url, data) { + return new jsonp_request_1["default"](url, data); + }, + createScriptRequest: function (src) { + return new script_request_1["default"](src); + }, + getLocalStorage: function () { + try { + return window.localStorage; + } + catch (e) { + return undefined; + } + }, + createXHR: function () { + if (this.getXHRAPI()) { + return this.createXMLHttpRequest(); + } + else { + return this.createMicrosoftXHR(); + } + }, + createXMLHttpRequest: function () { + var Constructor = this.getXHRAPI(); + return new Constructor(); + }, + createMicrosoftXHR: function () { + return new ActiveXObject("Microsoft.XMLHTTP"); + }, + getNetwork: function () { + return net_info_1.Network; + }, + createWebSocket: function (url) { + var Constructor = this.getWebSocketAPI(); + return new Constructor(url); + }, + createSocketRequest: function (method, url) { + if (this.isXHRSupported()) { + return this.HTTPFactory.createXHR(method, url); + } + else if (this.isXDRSupported(url.indexOf("https:") === 0)) { + return this.HTTPFactory.createXDR(method, url); + } + else { + throw "Cross-origin HTTP requests are not supported"; + } + }, + isXHRSupported: function () { + var Constructor = this.getXHRAPI(); + return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined; + }, + isXDRSupported: function (encrypted) { + var protocol = encrypted ? "https:" : "http:"; + var documentProtocol = this.getProtocol(); + return Boolean((window['XDomainRequest'])) && documentProtocol === protocol; + }, + addUnloadListener: function (listener) { + if (window.addEventListener !== undefined) { + window.addEventListener("unload", listener, false); + } + else if (window.attachEvent !== undefined) { + window.attachEvent("onunload", listener); + } + }, + removeUnloadListener: function (listener) { + if (window.addEventListener !== undefined) { + window.removeEventListener("unload", listener, false); + } + else if (window.detachEvent !== undefined) { + window.detachEvent("onunload", listener); + } + } + }; + exports.__esModule = true; + exports["default"] = Runtime; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var script_receiver_factory_1 = __webpack_require__(4); + var defaults_1 = __webpack_require__(5); + var dependency_loader_1 = __webpack_require__(6); + exports.DependenciesReceivers = new script_receiver_factory_1.ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers"); + exports.Dependencies = new dependency_loader_1["default"]({ + cdn_http: defaults_1["default"].cdn_http, + cdn_https: defaults_1["default"].cdn_https, + version: defaults_1["default"].VERSION, + suffix: defaults_1["default"].dependency_suffix, + receivers: exports.DependenciesReceivers + }); + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + + "use strict"; + var ScriptReceiverFactory = (function () { + function ScriptReceiverFactory(prefix, name) { + this.lastId = 0; + this.prefix = prefix; + this.name = name; + } + ScriptReceiverFactory.prototype.create = function (callback) { + this.lastId++; + var number = this.lastId; + var id = this.prefix + number; + var name = this.name + "[" + number + "]"; + var called = false; + var callbackWrapper = function () { + if (!called) { + callback.apply(null, arguments); + called = true; + } + }; + this[number] = callbackWrapper; + return { number: number, id: id, name: name, callback: callbackWrapper }; + }; + ScriptReceiverFactory.prototype.remove = function (receiver) { + delete this[receiver.number]; + }; + return ScriptReceiverFactory; + }()); + exports.ScriptReceiverFactory = ScriptReceiverFactory; + exports.ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers"); + + +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + + "use strict"; + var Defaults = { + VERSION: "4.1.0", + PROTOCOL: 7, + host: 'ws.pusherapp.com', + ws_port: 80, + wss_port: 443, + sockjs_host: 'sockjs.pusher.com', + sockjs_http_port: 80, + sockjs_https_port: 443, + sockjs_path: "/pusher", + stats_host: 'stats.pusher.com', + channel_auth_endpoint: '/pusher/auth', + channel_auth_transport: 'ajax', + activity_timeout: 120000, + pong_timeout: 30000, + unavailable_timeout: 10000, + cdn_http: 'http://js.pusher.com', + cdn_https: 'https://js.pusher.com', + dependency_suffix: '' + }; + exports.__esModule = true; + exports["default"] = Defaults; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var script_receiver_factory_1 = __webpack_require__(4); + var runtime_1 = __webpack_require__(2); + var DependencyLoader = (function () { + function DependencyLoader(options) { + this.options = options; + this.receivers = options.receivers || script_receiver_factory_1.ScriptReceivers; + this.loading = {}; + } + DependencyLoader.prototype.load = function (name, options, callback) { + var self = this; + if (self.loading[name] && self.loading[name].length > 0) { + self.loading[name].push(callback); + } + else { + self.loading[name] = [callback]; + var request = runtime_1["default"].createScriptRequest(self.getPath(name, options)); + var receiver = self.receivers.create(function (error) { + self.receivers.remove(receiver); + if (self.loading[name]) { + var callbacks = self.loading[name]; + delete self.loading[name]; + var successCallback = function (wasSuccessful) { + if (!wasSuccessful) { + request.cleanup(); + } + }; + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](error, successCallback); + } + } + }); + request.send(receiver); + } + }; + DependencyLoader.prototype.getRoot = function (options) { + var cdn; + var protocol = runtime_1["default"].getDocument().location.protocol; + if ((options && options.encrypted) || protocol === "https:") { + cdn = this.options.cdn_https; + } + else { + cdn = this.options.cdn_http; + } + return cdn.replace(/\/*$/, "") + "/" + this.options.version; + }; + DependencyLoader.prototype.getPath = function (name, options) { + return this.getRoot(options) + '/' + name + this.options.suffix + '.js'; + }; + ; + return DependencyLoader; + }()); + exports.__esModule = true; + exports["default"] = DependencyLoader; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var logger_1 = __webpack_require__(8); + var runtime_1 = __webpack_require__(2); + var ajax = function (context, socketId, callback) { + var self = this, xhr; + xhr = runtime_1["default"].createXHR(); + xhr.open("POST", self.options.authEndpoint, true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + for (var headerName in this.authOptions.headers) { + xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]); + } + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + var data, parsed = false; + try { + data = JSON.parse(xhr.responseText); + parsed = true; + } + catch (e) { + callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText); + } + if (parsed) { + callback(false, data); + } + } + else { + logger_1["default"].warn("Couldn't get auth info from your webapp", xhr.status); + callback(true, xhr.status); + } + } + }; + xhr.send(this.composeQuery(socketId)); + return xhr; + }; + exports.__esModule = true; + exports["default"] = ajax; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var collections_1 = __webpack_require__(9); + var pusher_1 = __webpack_require__(1); + var Logger = { + debug: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + if (!pusher_1["default"].log) { + return; + } + pusher_1["default"].log(collections_1.stringify.apply(this, arguments)); + }, + warn: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + var message = collections_1.stringify.apply(this, arguments); + if ((window).console) { + if ((window).console.warn) { + (window).console.warn(message); + } + else if ((window).console.log) { + (window).console.log(message); + } + } + if (pusher_1["default"].log) { + pusher_1["default"].log(message); + } + } + }; + exports.__esModule = true; + exports["default"] = Logger; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var base64_1 = __webpack_require__(10); + var util_1 = __webpack_require__(11); + function extend(target) { + var sources = []; + for (var _i = 1; _i < arguments.length; _i++) { + sources[_i - 1] = arguments[_i]; + } + for (var i = 0; i < sources.length; i++) { + var extensions = sources[i]; + for (var property in extensions) { + if (extensions[property] && extensions[property].constructor && + extensions[property].constructor === Object) { + target[property] = extend(target[property] || {}, extensions[property]); + } + else { + target[property] = extensions[property]; + } + } + } + return target; + } + exports.extend = extend; + function stringify() { + var m = ["Pusher"]; + for (var i = 0; i < arguments.length; i++) { + if (typeof arguments[i] === "string") { + m.push(arguments[i]); + } + else { + m.push(safeJSONStringify(arguments[i])); + } + } + return m.join(" : "); + } + exports.stringify = stringify; + function arrayIndexOf(array, item) { + var nativeIndexOf = Array.prototype.indexOf; + if (array === null) { + return -1; + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) { + return array.indexOf(item); + } + for (var i = 0, l = array.length; i < l; i++) { + if (array[i] === item) { + return i; + } + } + return -1; + } + exports.arrayIndexOf = arrayIndexOf; + function objectApply(object, f) { + for (var key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + f(object[key], key, object); + } + } + } + exports.objectApply = objectApply; + function keys(object) { + var keys = []; + objectApply(object, function (_, key) { + keys.push(key); + }); + return keys; + } + exports.keys = keys; + function values(object) { + var values = []; + objectApply(object, function (value) { + values.push(value); + }); + return values; + } + exports.values = values; + function apply(array, f, context) { + for (var i = 0; i < array.length; i++) { + f.call(context || (window), array[i], i, array); + } + } + exports.apply = apply; + function map(array, f) { + var result = []; + for (var i = 0; i < array.length; i++) { + result.push(f(array[i], i, array, result)); + } + return result; + } + exports.map = map; + function mapObject(object, f) { + var result = {}; + objectApply(object, function (value, key) { + result[key] = f(value); + }); + return result; + } + exports.mapObject = mapObject; + function filter(array, test) { + test = test || function (value) { return !!value; }; + var result = []; + for (var i = 0; i < array.length; i++) { + if (test(array[i], i, array, result)) { + result.push(array[i]); + } + } + return result; + } + exports.filter = filter; + function filterObject(object, test) { + var result = {}; + objectApply(object, function (value, key) { + if ((test && test(value, key, object, result)) || Boolean(value)) { + result[key] = value; + } + }); + return result; + } + exports.filterObject = filterObject; + function flatten(object) { + var result = []; + objectApply(object, function (value, key) { + result.push([key, value]); + }); + return result; + } + exports.flatten = flatten; + function any(array, test) { + for (var i = 0; i < array.length; i++) { + if (test(array[i], i, array)) { + return true; + } + } + return false; + } + exports.any = any; + function all(array, test) { + for (var i = 0; i < array.length; i++) { + if (!test(array[i], i, array)) { + return false; + } + } + return true; + } + exports.all = all; + function encodeParamsObject(data) { + return mapObject(data, function (value) { + if (typeof value === "object") { + value = safeJSONStringify(value); + } + return encodeURIComponent(base64_1["default"](value.toString())); + }); + } + exports.encodeParamsObject = encodeParamsObject; + function buildQueryString(data) { + var params = filterObject(data, function (value) { + return value !== undefined; + }); + var query = map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&"); + return query; + } + exports.buildQueryString = buildQueryString; + function decycleObject(object) { + var objects = [], paths = []; + return (function derez(value, path) { + var i, name, nu; + switch (typeof value) { + case 'object': + if (!value) { + return null; + } + for (i = 0; i < objects.length; i += 1) { + if (objects[i] === value) { + return { $ref: paths[i] }; + } + } + objects.push(value); + paths.push(path); + if (Object.prototype.toString.apply(value) === '[object Array]') { + nu = []; + for (i = 0; i < value.length; i += 1) { + nu[i] = derez(value[i], path + '[' + i + ']'); + } + } + else { + nu = {}; + for (name in value) { + if (Object.prototype.hasOwnProperty.call(value, name)) { + nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']'); + } + } + } + return nu; + case 'number': + case 'string': + case 'boolean': + return value; + } + }(object, '$')); + } + exports.decycleObject = decycleObject; + function safeJSONStringify(source) { + try { + return JSON.stringify(source); + } + catch (e) { + return JSON.stringify(decycleObject(source)); + } + } + exports.safeJSONStringify = safeJSONStringify; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + function encode(s) { + return btoa(utob(s)); + } + exports.__esModule = true; + exports["default"] = encode; + var fromCharCode = String.fromCharCode; + var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + var b64tab = {}; + for (var i = 0, l = b64chars.length; i < l; i++) { + b64tab[b64chars.charAt(i)] = i; + } + var cb_utob = function (c) { + var cc = c.charCodeAt(0); + return cc < 0x80 ? c + : cc < 0x800 ? fromCharCode(0xc0 | (cc >>> 6)) + + fromCharCode(0x80 | (cc & 0x3f)) + : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) + + fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + + fromCharCode(0x80 | (cc & 0x3f)); + }; + var utob = function (u) { + return u.replace(/[^\x00-\x7F]/g, cb_utob); + }; + var cb_encode = function (ccc) { + var padlen = [0, 2, 1][ccc.length % 3]; + var ord = ccc.charCodeAt(0) << 16 + | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) + | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)); + var chars = [ + b64chars.charAt(ord >>> 18), + b64chars.charAt((ord >>> 12) & 63), + padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63), + padlen >= 1 ? '=' : b64chars.charAt(ord & 63) + ]; + return chars.join(''); + }; + var btoa = (window).btoa || function (b) { + return b.replace(/[\s\S]{1,3}/g, cb_encode); + }; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var timers_1 = __webpack_require__(12); + var Util = { + now: function () { + if (Date.now) { + return Date.now(); + } + else { + return new Date().valueOf(); + } + }, + defer: function (callback) { + return new timers_1.OneOffTimer(0, callback); + }, + method: function (name) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var boundArguments = Array.prototype.slice.call(arguments, 1); + return function (object) { + return object[name].apply(object, boundArguments.concat(arguments)); + }; + } + }; + exports.__esModule = true; + exports["default"] = Util; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var abstract_timer_1 = __webpack_require__(13); + function clearTimeout(timer) { + (window).clearTimeout(timer); + } + function clearInterval(timer) { + (window).clearInterval(timer); + } + var OneOffTimer = (function (_super) { + __extends(OneOffTimer, _super); + function OneOffTimer(delay, callback) { + _super.call(this, setTimeout, clearTimeout, delay, function (timer) { + callback(); + return null; + }); + } + return OneOffTimer; + }(abstract_timer_1["default"])); + exports.OneOffTimer = OneOffTimer; + var PeriodicTimer = (function (_super) { + __extends(PeriodicTimer, _super); + function PeriodicTimer(delay, callback) { + _super.call(this, setInterval, clearInterval, delay, function (timer) { + callback(); + return timer; + }); + } + return PeriodicTimer; + }(abstract_timer_1["default"])); + exports.PeriodicTimer = PeriodicTimer; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + + "use strict"; + var Timer = (function () { + function Timer(set, clear, delay, callback) { + var _this = this; + this.clear = clear; + this.timer = set(function () { + if (_this.timer) { + _this.timer = callback(_this.timer); + } + }, delay); + } + Timer.prototype.isRunning = function () { + return this.timer !== null; + }; + Timer.prototype.ensureAborted = function () { + if (this.timer) { + this.clear(this.timer); + this.timer = null; + } + }; + return Timer; + }()); + exports.__esModule = true; + exports["default"] = Timer; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var logger_1 = __webpack_require__(8); + var jsonp = function (context, socketId, callback) { + if (this.authOptions.headers !== undefined) { + logger_1["default"].warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP."); + } + var callbackName = context.nextAuthCallbackID.toString(); + context.nextAuthCallbackID++; + var document = context.getDocument(); + var script = document.createElement("script"); + context.auth_callbacks[callbackName] = function (data) { + callback(false, data); + }; + var callback_name = "Pusher.auth_callbacks['" + callbackName + "']"; + script.src = this.options.authEndpoint + + '?callback=' + + encodeURIComponent(callback_name) + + '&' + + this.composeQuery(socketId); + var head = document.getElementsByTagName("head")[0] || document.documentElement; + head.insertBefore(script, head.firstChild); + }; + exports.__esModule = true; + exports["default"] = jsonp; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports) { + + "use strict"; + var ScriptRequest = (function () { + function ScriptRequest(src) { + this.src = src; + } + ScriptRequest.prototype.send = function (receiver) { + var self = this; + var errorString = "Error loading " + self.src; + self.script = document.createElement("script"); + self.script.id = receiver.id; + self.script.src = self.src; + self.script.type = "text/javascript"; + self.script.charset = "UTF-8"; + if (self.script.addEventListener) { + self.script.onerror = function () { + receiver.callback(errorString); + }; + self.script.onload = function () { + receiver.callback(null); + }; + } + else { + self.script.onreadystatechange = function () { + if (self.script.readyState === 'loaded' || + self.script.readyState === 'complete') { + receiver.callback(null); + } + }; + } + if (self.script.async === undefined && document.attachEvent && + /opera/i.test(navigator.userAgent)) { + self.errorScript = document.createElement("script"); + self.errorScript.id = receiver.id + "_error"; + self.errorScript.text = receiver.name + "('" + errorString + "');"; + self.script.async = self.errorScript.async = false; + } + else { + self.script.async = true; + } + var head = document.getElementsByTagName('head')[0]; + head.insertBefore(self.script, head.firstChild); + if (self.errorScript) { + head.insertBefore(self.errorScript, self.script.nextSibling); + } + }; + ScriptRequest.prototype.cleanup = function () { + if (this.script) { + this.script.onload = this.script.onerror = null; + this.script.onreadystatechange = null; + } + if (this.script && this.script.parentNode) { + this.script.parentNode.removeChild(this.script); + } + if (this.errorScript && this.errorScript.parentNode) { + this.errorScript.parentNode.removeChild(this.errorScript); + } + this.script = null; + this.errorScript = null; + }; + return ScriptRequest; + }()); + exports.__esModule = true; + exports["default"] = ScriptRequest; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var runtime_1 = __webpack_require__(2); + var JSONPRequest = (function () { + function JSONPRequest(url, data) { + this.url = url; + this.data = data; + } + JSONPRequest.prototype.send = function (receiver) { + if (this.request) { + return; + } + var query = Collections.buildQueryString(this.data); + var url = this.url + "/" + receiver.number + "?" + query; + this.request = runtime_1["default"].createScriptRequest(url); + this.request.send(receiver); + }; + JSONPRequest.prototype.cleanup = function () { + if (this.request) { + this.request.cleanup(); + } + }; + return JSONPRequest; + }()); + exports.__esModule = true; + exports["default"] = JSONPRequest; + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var script_receiver_factory_1 = __webpack_require__(4); + var getAgent = function (sender, encrypted) { + return function (data, callback) { + var scheme = "http" + (encrypted ? "s" : "") + "://"; + var url = scheme + (sender.host || sender.options.host) + sender.options.path; + var request = runtime_1["default"].createJSONPRequest(url, data); + var receiver = runtime_1["default"].ScriptReceivers.create(function (error, result) { + script_receiver_factory_1.ScriptReceivers.remove(receiver); + request.cleanup(); + if (result && result.host) { + sender.host = result.host; + } + if (callback) { + callback(error, result); + } + }); + request.send(receiver); + }; + }; + var jsonp = { + name: 'jsonp', + getAgent: getAgent + }; + exports.__esModule = true; + exports["default"] = jsonp; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var transports_1 = __webpack_require__(19); + var transport_1 = __webpack_require__(21); + var URLSchemes = __webpack_require__(20); + var runtime_1 = __webpack_require__(2); + var dependencies_1 = __webpack_require__(3); + var Collections = __webpack_require__(9); + var SockJSTransport = new transport_1["default"]({ + file: "sockjs", + urls: URLSchemes.sockjs, + handlesActivityChecks: true, + supportsPing: false, + isSupported: function () { + return true; + }, + isInitialized: function () { + return window.SockJS !== undefined; + }, + getSocket: function (url, options) { + return new window.SockJS(url, null, { + js_path: dependencies_1.Dependencies.getPath("sockjs", { + encrypted: options.encrypted + }), + ignore_null_origin: options.ignoreNullOrigin + }); + }, + beforeOpen: function (socket, path) { + socket.send(JSON.stringify({ + path: path + })); + } + }); + var xdrConfiguration = { + isSupported: function (environment) { + var yes = runtime_1["default"].isXDRSupported(environment.encrypted); + return yes; + } + }; + var XDRStreamingTransport = new transport_1["default"](Collections.extend({}, transports_1.streamingConfiguration, xdrConfiguration)); + var XDRPollingTransport = new transport_1["default"](Collections.extend({}, transports_1.pollingConfiguration, xdrConfiguration)); + transports_1["default"].xdr_streaming = XDRStreamingTransport; + transports_1["default"].xdr_polling = XDRPollingTransport; + transports_1["default"].sockjs = SockJSTransport; + exports.__esModule = true; + exports["default"] = transports_1["default"]; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var URLSchemes = __webpack_require__(20); + var transport_1 = __webpack_require__(21); + var Collections = __webpack_require__(9); + var runtime_1 = __webpack_require__(2); + var WSTransport = new transport_1["default"]({ + urls: URLSchemes.ws, + handlesActivityChecks: false, + supportsPing: false, + isInitialized: function () { + return Boolean(runtime_1["default"].getWebSocketAPI()); + }, + isSupported: function () { + return Boolean(runtime_1["default"].getWebSocketAPI()); + }, + getSocket: function (url) { + return runtime_1["default"].createWebSocket(url); + } + }); + var httpConfiguration = { + urls: URLSchemes.http, + handlesActivityChecks: false, + supportsPing: true, + isInitialized: function () { + return true; + } + }; + exports.streamingConfiguration = Collections.extend({ getSocket: function (url) { + return runtime_1["default"].HTTPFactory.createStreamingSocket(url); + } + }, httpConfiguration); + exports.pollingConfiguration = Collections.extend({ getSocket: function (url) { + return runtime_1["default"].HTTPFactory.createPollingSocket(url); + } + }, httpConfiguration); + var xhrConfiguration = { + isSupported: function () { + return runtime_1["default"].isXHRSupported(); + } + }; + var XHRStreamingTransport = new transport_1["default"](Collections.extend({}, exports.streamingConfiguration, xhrConfiguration)); + var XHRPollingTransport = new transport_1["default"](Collections.extend({}, exports.pollingConfiguration, xhrConfiguration)); + var Transports = { + ws: WSTransport, + xhr_streaming: XHRStreamingTransport, + xhr_polling: XHRPollingTransport + }; + exports.__esModule = true; + exports["default"] = Transports; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var defaults_1 = __webpack_require__(5); + function getGenericURL(baseScheme, params, path) { + var scheme = baseScheme + (params.encrypted ? "s" : ""); + var host = params.encrypted ? params.hostEncrypted : params.hostUnencrypted; + return scheme + "://" + host + path; + } + function getGenericPath(key, queryString) { + var path = "/app/" + key; + var query = "?protocol=" + defaults_1["default"].PROTOCOL + + "&client=js" + + "&version=" + defaults_1["default"].VERSION + + (queryString ? ("&" + queryString) : ""); + return path + query; + } + exports.ws = { + getInitial: function (key, params) { + return getGenericURL("ws", params, getGenericPath(key, "flash=false")); + } + }; + exports.http = { + getInitial: function (key, params) { + var path = (params.httpPath || "/pusher") + getGenericPath(key); + return getGenericURL("http", params, path); + } + }; + exports.sockjs = { + getInitial: function (key, params) { + return getGenericURL("http", params, params.httpPath || "/pusher"); + }, + getPath: function (key, params) { + return getGenericPath(key); + } + }; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var transport_connection_1 = __webpack_require__(22); + var Transport = (function () { + function Transport(hooks) { + this.hooks = hooks; + } + Transport.prototype.isSupported = function (environment) { + return this.hooks.isSupported(environment); + }; + Transport.prototype.createConnection = function (name, priority, key, options) { + return new transport_connection_1["default"](this.hooks, name, priority, key, options); + }; + return Transport; + }()); + exports.__esModule = true; + exports["default"] = Transport; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var util_1 = __webpack_require__(11); + var Collections = __webpack_require__(9); + var dispatcher_1 = __webpack_require__(23); + var logger_1 = __webpack_require__(8); + var runtime_1 = __webpack_require__(2); + var TransportConnection = (function (_super) { + __extends(TransportConnection, _super); + function TransportConnection(hooks, name, priority, key, options) { + _super.call(this); + this.initialize = runtime_1["default"].transportConnectionInitializer; + this.hooks = hooks; + this.name = name; + this.priority = priority; + this.key = key; + this.options = options; + this.state = "new"; + this.timeline = options.timeline; + this.activityTimeout = options.activityTimeout; + this.id = this.timeline.generateUniqueID(); + } + TransportConnection.prototype.handlesActivityChecks = function () { + return Boolean(this.hooks.handlesActivityChecks); + }; + TransportConnection.prototype.supportsPing = function () { + return Boolean(this.hooks.supportsPing); + }; + TransportConnection.prototype.connect = function () { + var _this = this; + if (this.socket || this.state !== "initialized") { + return false; + } + var url = this.hooks.urls.getInitial(this.key, this.options); + try { + this.socket = this.hooks.getSocket(url, this.options); + } + catch (e) { + util_1["default"].defer(function () { + _this.onError(e); + _this.changeState("closed"); + }); + return false; + } + this.bindListeners(); + logger_1["default"].debug("Connecting", { transport: this.name, url: url }); + this.changeState("connecting"); + return true; + }; + TransportConnection.prototype.close = function () { + if (this.socket) { + this.socket.close(); + return true; + } + else { + return false; + } + }; + TransportConnection.prototype.send = function (data) { + var _this = this; + if (this.state === "open") { + util_1["default"].defer(function () { + if (_this.socket) { + _this.socket.send(data); + } + }); + return true; + } + else { + return false; + } + }; + TransportConnection.prototype.ping = function () { + if (this.state === "open" && this.supportsPing()) { + this.socket.ping(); + } + }; + TransportConnection.prototype.onOpen = function () { + if (this.hooks.beforeOpen) { + this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options)); + } + this.changeState("open"); + this.socket.onopen = undefined; + }; + TransportConnection.prototype.onError = function (error) { + this.emit("error", { type: 'WebSocketError', error: error }); + this.timeline.error(this.buildTimelineMessage({ error: error.toString() })); + }; + TransportConnection.prototype.onClose = function (closeEvent) { + if (closeEvent) { + this.changeState("closed", { + code: closeEvent.code, + reason: closeEvent.reason, + wasClean: closeEvent.wasClean + }); + } + else { + this.changeState("closed"); + } + this.unbindListeners(); + this.socket = undefined; + }; + TransportConnection.prototype.onMessage = function (message) { + this.emit("message", message); + }; + TransportConnection.prototype.onActivity = function () { + this.emit("activity"); + }; + TransportConnection.prototype.bindListeners = function () { + var _this = this; + this.socket.onopen = function () { + _this.onOpen(); + }; + this.socket.onerror = function (error) { + _this.onError(error); + }; + this.socket.onclose = function (closeEvent) { + _this.onClose(closeEvent); + }; + this.socket.onmessage = function (message) { + _this.onMessage(message); + }; + if (this.supportsPing()) { + this.socket.onactivity = function () { _this.onActivity(); }; + } + }; + TransportConnection.prototype.unbindListeners = function () { + if (this.socket) { + this.socket.onopen = undefined; + this.socket.onerror = undefined; + this.socket.onclose = undefined; + this.socket.onmessage = undefined; + if (this.supportsPing()) { + this.socket.onactivity = undefined; + } + } + }; + TransportConnection.prototype.changeState = function (state, params) { + this.state = state; + this.timeline.info(this.buildTimelineMessage({ + state: state, + params: params + })); + this.emit(state, params); + }; + TransportConnection.prototype.buildTimelineMessage = function (message) { + return Collections.extend({ cid: this.id }, message); + }; + return TransportConnection; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = TransportConnection; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var callback_registry_1 = __webpack_require__(24); + var Dispatcher = (function () { + function Dispatcher(failThrough) { + this.callbacks = new callback_registry_1["default"](); + this.global_callbacks = []; + this.failThrough = failThrough; + } + Dispatcher.prototype.bind = function (eventName, callback, context) { + this.callbacks.add(eventName, callback, context); + return this; + }; + Dispatcher.prototype.bind_global = function (callback) { + this.global_callbacks.push(callback); + return this; + }; + Dispatcher.prototype.unbind = function (eventName, callback, context) { + this.callbacks.remove(eventName, callback, context); + return this; + }; + Dispatcher.prototype.unbind_global = function (callback) { + if (!callback) { + this.global_callbacks = []; + return this; + } + this.global_callbacks = Collections.filter(this.global_callbacks || [], function (c) { return c !== callback; }); + return this; + }; + Dispatcher.prototype.unbind_all = function () { + this.unbind(); + this.unbind_global(); + return this; + }; + Dispatcher.prototype.emit = function (eventName, data) { + var i; + for (i = 0; i < this.global_callbacks.length; i++) { + this.global_callbacks[i](eventName, data); + } + var callbacks = this.callbacks.get(eventName); + if (callbacks && callbacks.length > 0) { + for (i = 0; i < callbacks.length; i++) { + callbacks[i].fn.call(callbacks[i].context || (window), data); + } + } + else if (this.failThrough) { + this.failThrough(eventName, data); + } + return this; + }; + return Dispatcher; + }()); + exports.__esModule = true; + exports["default"] = Dispatcher; + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var CallbackRegistry = (function () { + function CallbackRegistry() { + this._callbacks = {}; + } + CallbackRegistry.prototype.get = function (name) { + return this._callbacks[prefix(name)]; + }; + CallbackRegistry.prototype.add = function (name, callback, context) { + var prefixedEventName = prefix(name); + this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || []; + this._callbacks[prefixedEventName].push({ + fn: callback, + context: context + }); + }; + CallbackRegistry.prototype.remove = function (name, callback, context) { + if (!name && !callback && !context) { + this._callbacks = {}; + return; + } + var names = name ? [prefix(name)] : Collections.keys(this._callbacks); + if (callback || context) { + this.removeCallback(names, callback, context); + } + else { + this.removeAllCallbacks(names); + } + }; + CallbackRegistry.prototype.removeCallback = function (names, callback, context) { + Collections.apply(names, function (name) { + this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (binding) { + return (callback && callback !== binding.fn) || + (context && context !== binding.context); + }); + if (this._callbacks[name].length === 0) { + delete this._callbacks[name]; + } + }, this); + }; + CallbackRegistry.prototype.removeAllCallbacks = function (names) { + Collections.apply(names, function (name) { + delete this._callbacks[name]; + }, this); + }; + return CallbackRegistry; + }()); + exports.__esModule = true; + exports["default"] = CallbackRegistry; + function prefix(name) { + return "_" + name; + } + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var dispatcher_1 = __webpack_require__(23); + var NetInfo = (function (_super) { + __extends(NetInfo, _super); + function NetInfo() { + _super.call(this); + var self = this; + if (window.addEventListener !== undefined) { + window.addEventListener("online", function () { + self.emit('online'); + }, false); + window.addEventListener("offline", function () { + self.emit('offline'); + }, false); + } + } + NetInfo.prototype.isOnline = function () { + if (window.navigator.onLine === undefined) { + return true; + } + else { + return window.navigator.onLine; + } + }; + return NetInfo; + }(dispatcher_1["default"])); + exports.NetInfo = NetInfo; + exports.Network = new NetInfo(); + + +/***/ }), +/* 26 */ +/***/ (function(module, exports) { + + "use strict"; + var getDefaultStrategy = function (config) { + var wsStrategy; + if (config.encrypted) { + wsStrategy = [ + ":best_connected_ever", + ":ws_loop", + [":delayed", 2000, [":http_fallback_loop"]] + ]; + } + else { + wsStrategy = [ + ":best_connected_ever", + ":ws_loop", + [":delayed", 2000, [":wss_loop"]], + [":delayed", 5000, [":http_fallback_loop"]] + ]; + } + return [ + [":def", "ws_options", { + hostUnencrypted: config.wsHost + ":" + config.wsPort, + hostEncrypted: config.wsHost + ":" + config.wssPort + }], + [":def", "wss_options", [":extend", ":ws_options", { + encrypted: true + }]], + [":def", "sockjs_options", { + hostUnencrypted: config.httpHost + ":" + config.httpPort, + hostEncrypted: config.httpHost + ":" + config.httpsPort, + httpPath: config.httpPath + }], + [":def", "timeouts", { + loop: true, + timeout: 15000, + timeoutLimit: 60000 + }], + [":def", "ws_manager", [":transport_manager", { + lives: 2, + minPingDelay: 10000, + maxPingDelay: config.activity_timeout + }]], + [":def", "streaming_manager", [":transport_manager", { + lives: 2, + minPingDelay: 10000, + maxPingDelay: config.activity_timeout + }]], + [":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"], + [":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"], + [":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"], + [":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"], + [":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"], + [":def_transport", "xhr_polling", "xhr_polling", 1, ":sockjs_options"], + [":def_transport", "xdr_polling", "xdr_polling", 1, ":sockjs_options"], + [":def", "ws_loop", [":sequential", ":timeouts", ":ws"]], + [":def", "wss_loop", [":sequential", ":timeouts", ":wss"]], + [":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]], + [":def", "streaming_loop", [":sequential", ":timeouts", + [":if", [":is_supported", ":xhr_streaming"], + ":xhr_streaming", + ":xdr_streaming" + ] + ]], + [":def", "polling_loop", [":sequential", ":timeouts", + [":if", [":is_supported", ":xhr_polling"], + ":xhr_polling", + ":xdr_polling" + ] + ]], + [":def", "http_loop", [":if", [":is_supported", ":streaming_loop"], [ + ":best_connected_ever", + ":streaming_loop", + [":delayed", 4000, [":polling_loop"]] + ], [ + ":polling_loop" + ]]], + [":def", "http_fallback_loop", + [":if", [":is_supported", ":http_loop"], [ + ":http_loop" + ], [ + ":sockjs_loop" + ]] + ], + [":def", "strategy", + [":cached", 1800000, + [":first_connected", + [":if", [":is_supported", ":ws"], + wsStrategy, + ":http_fallback_loop" + ] + ] + ] + ] + ]; + }; + exports.__esModule = true; + exports["default"] = getDefaultStrategy; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var dependencies_1 = __webpack_require__(3); + function default_1() { + var self = this; + self.timeline.info(self.buildTimelineMessage({ + transport: self.name + (self.options.encrypted ? "s" : "") + })); + if (self.hooks.isInitialized()) { + self.changeState("initialized"); + } + else if (self.hooks.file) { + self.changeState("initializing"); + dependencies_1.Dependencies.load(self.hooks.file, { encrypted: self.options.encrypted }, function (error, callback) { + if (self.hooks.isInitialized()) { + self.changeState("initialized"); + callback(true); + } + else { + if (error) { + self.onError(error); + } + self.onClose(); + callback(false); + } + }); + } + else { + self.onClose(); + } + } + exports.__esModule = true; + exports["default"] = default_1; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var http_xdomain_request_1 = __webpack_require__(29); + var http_1 = __webpack_require__(31); + http_1["default"].createXDR = function (method, url) { + return this.createRequest(http_xdomain_request_1["default"], method, url); + }; + exports.__esModule = true; + exports["default"] = http_1["default"]; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Errors = __webpack_require__(30); + var hooks = { + getRequest: function (socket) { + var xdr = new window.XDomainRequest(); + xdr.ontimeout = function () { + socket.emit("error", new Errors.RequestTimedOut()); + socket.close(); + }; + xdr.onerror = function (e) { + socket.emit("error", e); + socket.close(); + }; + xdr.onprogress = function () { + if (xdr.responseText && xdr.responseText.length > 0) { + socket.onChunk(200, xdr.responseText); + } + }; + xdr.onload = function () { + if (xdr.responseText && xdr.responseText.length > 0) { + socket.onChunk(200, xdr.responseText); + } + socket.emit("finished", 200); + socket.close(); + }; + return xdr; + }, + abortRequest: function (xdr) { + xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null; + xdr.abort(); + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var BadEventName = (function (_super) { + __extends(BadEventName, _super); + function BadEventName() { + _super.apply(this, arguments); + } + return BadEventName; + }(Error)); + exports.BadEventName = BadEventName; + var RequestTimedOut = (function (_super) { + __extends(RequestTimedOut, _super); + function RequestTimedOut() { + _super.apply(this, arguments); + } + return RequestTimedOut; + }(Error)); + exports.RequestTimedOut = RequestTimedOut; + var TransportPriorityTooLow = (function (_super) { + __extends(TransportPriorityTooLow, _super); + function TransportPriorityTooLow() { + _super.apply(this, arguments); + } + return TransportPriorityTooLow; + }(Error)); + exports.TransportPriorityTooLow = TransportPriorityTooLow; + var TransportClosed = (function (_super) { + __extends(TransportClosed, _super); + function TransportClosed() { + _super.apply(this, arguments); + } + return TransportClosed; + }(Error)); + exports.TransportClosed = TransportClosed; + var UnsupportedTransport = (function (_super) { + __extends(UnsupportedTransport, _super); + function UnsupportedTransport() { + _super.apply(this, arguments); + } + return UnsupportedTransport; + }(Error)); + exports.UnsupportedTransport = UnsupportedTransport; + var UnsupportedStrategy = (function (_super) { + __extends(UnsupportedStrategy, _super); + function UnsupportedStrategy() { + _super.apply(this, arguments); + } + return UnsupportedStrategy; + }(Error)); + exports.UnsupportedStrategy = UnsupportedStrategy; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var http_request_1 = __webpack_require__(32); + var http_socket_1 = __webpack_require__(33); + var http_streaming_socket_1 = __webpack_require__(35); + var http_polling_socket_1 = __webpack_require__(36); + var http_xhr_request_1 = __webpack_require__(37); + var HTTP = { + createStreamingSocket: function (url) { + return this.createSocket(http_streaming_socket_1["default"], url); + }, + createPollingSocket: function (url) { + return this.createSocket(http_polling_socket_1["default"], url); + }, + createSocket: function (hooks, url) { + return new http_socket_1["default"](hooks, url); + }, + createXHR: function (method, url) { + return this.createRequest(http_xhr_request_1["default"], method, url); + }, + createRequest: function (hooks, method, url) { + return new http_request_1["default"](hooks, method, url); + } + }; + exports.__esModule = true; + exports["default"] = HTTP; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var runtime_1 = __webpack_require__(2); + var dispatcher_1 = __webpack_require__(23); + var MAX_BUFFER_LENGTH = 256 * 1024; + var HTTPRequest = (function (_super) { + __extends(HTTPRequest, _super); + function HTTPRequest(hooks, method, url) { + _super.call(this); + this.hooks = hooks; + this.method = method; + this.url = url; + } + HTTPRequest.prototype.start = function (payload) { + var _this = this; + this.position = 0; + this.xhr = this.hooks.getRequest(this); + this.unloader = function () { + _this.close(); + }; + runtime_1["default"].addUnloadListener(this.unloader); + this.xhr.open(this.method, this.url, true); + if (this.xhr.setRequestHeader) { + this.xhr.setRequestHeader("Content-Type", "application/json"); + } + this.xhr.send(payload); + }; + HTTPRequest.prototype.close = function () { + if (this.unloader) { + runtime_1["default"].removeUnloadListener(this.unloader); + this.unloader = null; + } + if (this.xhr) { + this.hooks.abortRequest(this.xhr); + this.xhr = null; + } + }; + HTTPRequest.prototype.onChunk = function (status, data) { + while (true) { + var chunk = this.advanceBuffer(data); + if (chunk) { + this.emit("chunk", { status: status, data: chunk }); + } + else { + break; + } + } + if (this.isBufferTooLong(data)) { + this.emit("buffer_too_long"); + } + }; + HTTPRequest.prototype.advanceBuffer = function (buffer) { + var unreadData = buffer.slice(this.position); + var endOfLinePosition = unreadData.indexOf("\n"); + if (endOfLinePosition !== -1) { + this.position += endOfLinePosition + 1; + return unreadData.slice(0, endOfLinePosition); + } + else { + return null; + } + }; + HTTPRequest.prototype.isBufferTooLong = function (buffer) { + return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH; + }; + return HTTPRequest; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = HTTPRequest; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var state_1 = __webpack_require__(34); + var util_1 = __webpack_require__(11); + var runtime_1 = __webpack_require__(2); + var autoIncrement = 1; + var HTTPSocket = (function () { + function HTTPSocket(hooks, url) { + this.hooks = hooks; + this.session = randomNumber(1000) + "/" + randomString(8); + this.location = getLocation(url); + this.readyState = state_1["default"].CONNECTING; + this.openStream(); + } + HTTPSocket.prototype.send = function (payload) { + return this.sendRaw(JSON.stringify([payload])); + }; + HTTPSocket.prototype.ping = function () { + this.hooks.sendHeartbeat(this); + }; + HTTPSocket.prototype.close = function (code, reason) { + this.onClose(code, reason, true); + }; + HTTPSocket.prototype.sendRaw = function (payload) { + if (this.readyState === state_1["default"].OPEN) { + try { + runtime_1["default"].createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload); + return true; + } + catch (e) { + return false; + } + } + else { + return false; + } + }; + HTTPSocket.prototype.reconnect = function () { + this.closeStream(); + this.openStream(); + }; + ; + HTTPSocket.prototype.onClose = function (code, reason, wasClean) { + this.closeStream(); + this.readyState = state_1["default"].CLOSED; + if (this.onclose) { + this.onclose({ + code: code, + reason: reason, + wasClean: wasClean + }); + } + }; + HTTPSocket.prototype.onChunk = function (chunk) { + if (chunk.status !== 200) { + return; + } + if (this.readyState === state_1["default"].OPEN) { + this.onActivity(); + } + var payload; + var type = chunk.data.slice(0, 1); + switch (type) { + case 'o': + payload = JSON.parse(chunk.data.slice(1) || '{}'); + this.onOpen(payload); + break; + case 'a': + payload = JSON.parse(chunk.data.slice(1) || '[]'); + for (var i = 0; i < payload.length; i++) { + this.onEvent(payload[i]); + } + break; + case 'm': + payload = JSON.parse(chunk.data.slice(1) || 'null'); + this.onEvent(payload); + break; + case 'h': + this.hooks.onHeartbeat(this); + break; + case 'c': + payload = JSON.parse(chunk.data.slice(1) || '[]'); + this.onClose(payload[0], payload[1], true); + break; + } + }; + HTTPSocket.prototype.onOpen = function (options) { + if (this.readyState === state_1["default"].CONNECTING) { + if (options && options.hostname) { + this.location.base = replaceHost(this.location.base, options.hostname); + } + this.readyState = state_1["default"].OPEN; + if (this.onopen) { + this.onopen(); + } + } + else { + this.onClose(1006, "Server lost session", true); + } + }; + HTTPSocket.prototype.onEvent = function (event) { + if (this.readyState === state_1["default"].OPEN && this.onmessage) { + this.onmessage({ data: event }); + } + }; + HTTPSocket.prototype.onActivity = function () { + if (this.onactivity) { + this.onactivity(); + } + }; + HTTPSocket.prototype.onError = function (error) { + if (this.onerror) { + this.onerror(error); + } + }; + HTTPSocket.prototype.openStream = function () { + var _this = this; + this.stream = runtime_1["default"].createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))); + this.stream.bind("chunk", function (chunk) { + _this.onChunk(chunk); + }); + this.stream.bind("finished", function (status) { + _this.hooks.onFinished(_this, status); + }); + this.stream.bind("buffer_too_long", function () { + _this.reconnect(); + }); + try { + this.stream.start(); + } + catch (error) { + util_1["default"].defer(function () { + _this.onError(error); + _this.onClose(1006, "Could not start streaming", false); + }); + } + }; + HTTPSocket.prototype.closeStream = function () { + if (this.stream) { + this.stream.unbind_all(); + this.stream.close(); + this.stream = null; + } + }; + return HTTPSocket; + }()); + function getLocation(url) { + var parts = /([^\?]*)\/*(\??.*)/.exec(url); + return { + base: parts[1], + queryString: parts[2] + }; + } + function getSendURL(url, session) { + return url.base + "/" + session + "/xhr_send"; + } + function getUniqueURL(url) { + var separator = (url.indexOf('?') === -1) ? "?" : "&"; + return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++; + } + function replaceHost(url, hostname) { + var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url); + return urlParts[1] + hostname + urlParts[3]; + } + function randomNumber(max) { + return Math.floor(Math.random() * max); + } + function randomString(length) { + var result = []; + for (var i = 0; i < length; i++) { + result.push(randomNumber(32).toString(32)); + } + return result.join(''); + } + exports.__esModule = true; + exports["default"] = HTTPSocket; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports) { + + "use strict"; + var State; + (function (State) { + State[State["CONNECTING"] = 0] = "CONNECTING"; + State[State["OPEN"] = 1] = "OPEN"; + State[State["CLOSED"] = 3] = "CLOSED"; + })(State || (State = {})); + exports.__esModule = true; + exports["default"] = State; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + + "use strict"; + var hooks = { + getReceiveURL: function (url, session) { + return url.base + "/" + session + "/xhr_streaming" + url.queryString; + }, + onHeartbeat: function (socket) { + socket.sendRaw("[]"); + }, + sendHeartbeat: function (socket) { + socket.sendRaw("[]"); + }, + onFinished: function (socket, status) { + socket.onClose(1006, "Connection interrupted (" + status + ")", false); + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + + "use strict"; + var hooks = { + getReceiveURL: function (url, session) { + return url.base + "/" + session + "/xhr" + url.queryString; + }, + onHeartbeat: function () { + }, + sendHeartbeat: function (socket) { + socket.sendRaw("[]"); + }, + onFinished: function (socket, status) { + if (status === 200) { + socket.reconnect(); + } + else { + socket.onClose(1006, "Connection interrupted (" + status + ")", false); + } + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var hooks = { + getRequest: function (socket) { + var Constructor = runtime_1["default"].getXHRAPI(); + var xhr = new Constructor(); + xhr.onreadystatechange = xhr.onprogress = function () { + switch (xhr.readyState) { + case 3: + if (xhr.responseText && xhr.responseText.length > 0) { + socket.onChunk(xhr.status, xhr.responseText); + } + break; + case 4: + if (xhr.responseText && xhr.responseText.length > 0) { + socket.onChunk(xhr.status, xhr.responseText); + } + socket.emit("finished", xhr.status); + socket.close(); + break; + } + }; + return xhr; + }, + abortRequest: function (xhr) { + xhr.onreadystatechange = null; + xhr.abort(); + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var level_1 = __webpack_require__(39); + var Timeline = (function () { + function Timeline(key, session, options) { + this.key = key; + this.session = session; + this.events = []; + this.options = options || {}; + this.sent = 0; + this.uniqueID = 0; + } + Timeline.prototype.log = function (level, event) { + if (level <= this.options.level) { + this.events.push(Collections.extend({}, event, { timestamp: util_1["default"].now() })); + if (this.options.limit && this.events.length > this.options.limit) { + this.events.shift(); + } + } + }; + Timeline.prototype.error = function (event) { + this.log(level_1["default"].ERROR, event); + }; + Timeline.prototype.info = function (event) { + this.log(level_1["default"].INFO, event); + }; + Timeline.prototype.debug = function (event) { + this.log(level_1["default"].DEBUG, event); + }; + Timeline.prototype.isEmpty = function () { + return this.events.length === 0; + }; + Timeline.prototype.send = function (sendfn, callback) { + var _this = this; + var data = Collections.extend({ + session: this.session, + bundle: this.sent + 1, + key: this.key, + lib: "js", + version: this.options.version, + cluster: this.options.cluster, + features: this.options.features, + timeline: this.events + }, this.options.params); + this.events = []; + sendfn(data, function (error, result) { + if (!error) { + _this.sent++; + } + if (callback) { + callback(error, result); + } + }); + return true; + }; + Timeline.prototype.generateUniqueID = function () { + this.uniqueID++; + return this.uniqueID; + }; + return Timeline; + }()); + exports.__esModule = true; + exports["default"] = Timeline; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + + "use strict"; + var TimelineLevel; + (function (TimelineLevel) { + TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR"; + TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO"; + TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG"; + })(TimelineLevel || (TimelineLevel = {})); + exports.__esModule = true; + exports["default"] = TimelineLevel; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var transport_manager_1 = __webpack_require__(41); + var Errors = __webpack_require__(30); + var transport_strategy_1 = __webpack_require__(55); + var sequential_strategy_1 = __webpack_require__(56); + var best_connected_ever_strategy_1 = __webpack_require__(57); + var cached_strategy_1 = __webpack_require__(58); + var delayed_strategy_1 = __webpack_require__(59); + var if_strategy_1 = __webpack_require__(60); + var first_connected_strategy_1 = __webpack_require__(61); + var runtime_1 = __webpack_require__(2); + var Transports = runtime_1["default"].Transports; + exports.build = function (scheme, options) { + var context = Collections.extend({}, globalContext, options); + return evaluate(scheme, context)[1].strategy; + }; + var UnsupportedStrategy = { + isSupported: function () { + return false; + }, + connect: function (_, callback) { + var deferred = util_1["default"].defer(function () { + callback(new Errors.UnsupportedStrategy()); + }); + return { + abort: function () { + deferred.ensureAborted(); + }, + forceMinPriority: function () { } + }; + } + }; + function returnWithOriginalContext(f) { + return function (context) { + return [f.apply(this, arguments), context]; + }; + } + var globalContext = { + extend: function (context, first, second) { + return [Collections.extend({}, first, second), context]; + }, + def: function (context, name, value) { + if (context[name] !== undefined) { + throw "Redefining symbol " + name; + } + context[name] = value; + return [undefined, context]; + }, + def_transport: function (context, name, type, priority, options, manager) { + var transportClass = Transports[type]; + if (!transportClass) { + throw new Errors.UnsupportedTransport(type); + } + var enabled = (!context.enabledTransports || + Collections.arrayIndexOf(context.enabledTransports, name) !== -1) && + (!context.disabledTransports || + Collections.arrayIndexOf(context.disabledTransports, name) === -1); + var transport; + if (enabled) { + transport = new transport_strategy_1["default"](name, priority, manager ? manager.getAssistant(transportClass) : transportClass, Collections.extend({ + key: context.key, + encrypted: context.encrypted, + timeline: context.timeline, + ignoreNullOrigin: context.ignoreNullOrigin + }, options)); + } + else { + transport = UnsupportedStrategy; + } + var newContext = context.def(context, name, transport)[1]; + newContext.Transports = context.Transports || {}; + newContext.Transports[name] = transport; + return [undefined, newContext]; + }, + transport_manager: returnWithOriginalContext(function (_, options) { + return new transport_manager_1["default"](options); + }), + sequential: returnWithOriginalContext(function (_, options) { + var strategies = Array.prototype.slice.call(arguments, 2); + return new sequential_strategy_1["default"](strategies, options); + }), + cached: returnWithOriginalContext(function (context, ttl, strategy) { + return new cached_strategy_1["default"](strategy, context.Transports, { + ttl: ttl, + timeline: context.timeline, + encrypted: context.encrypted + }); + }), + first_connected: returnWithOriginalContext(function (_, strategy) { + return new first_connected_strategy_1["default"](strategy); + }), + best_connected_ever: returnWithOriginalContext(function () { + var strategies = Array.prototype.slice.call(arguments, 1); + return new best_connected_ever_strategy_1["default"](strategies); + }), + delayed: returnWithOriginalContext(function (_, delay, strategy) { + return new delayed_strategy_1["default"](strategy, { delay: delay }); + }), + "if": returnWithOriginalContext(function (_, test, trueBranch, falseBranch) { + return new if_strategy_1["default"](test, trueBranch, falseBranch); + }), + is_supported: returnWithOriginalContext(function (_, strategy) { + return function () { + return strategy.isSupported(); + }; + }) + }; + function isSymbol(expression) { + return (typeof expression === "string") && expression.charAt(0) === ":"; + } + function getSymbolValue(expression, context) { + return context[expression.slice(1)]; + } + function evaluateListOfExpressions(expressions, context) { + if (expressions.length === 0) { + return [[], context]; + } + var head = evaluate(expressions[0], context); + var tail = evaluateListOfExpressions(expressions.slice(1), head[1]); + return [[head[0]].concat(tail[0]), tail[1]]; + } + function evaluateString(expression, context) { + if (!isSymbol(expression)) { + return [expression, context]; + } + var value = getSymbolValue(expression, context); + if (value === undefined) { + throw "Undefined symbol " + expression; + } + return [value, context]; + } + function evaluateArray(expression, context) { + if (isSymbol(expression[0])) { + var f = getSymbolValue(expression[0], context); + if (expression.length > 1) { + if (typeof f !== "function") { + throw "Calling non-function " + expression[0]; + } + var args = [Collections.extend({}, context)].concat(Collections.map(expression.slice(1), function (arg) { + return evaluate(arg, Collections.extend({}, context))[0]; + })); + return f.apply(this, args); + } + else { + return [f, context]; + } + } + else { + return evaluateListOfExpressions(expression, context); + } + } + function evaluate(expression, context) { + if (typeof expression === "string") { + return evaluateString(expression, context); + } + else if (typeof expression === "object") { + if (expression instanceof Array && expression.length > 0) { + return evaluateArray(expression, context); + } + } + return [expression, context]; + } + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var factory_1 = __webpack_require__(42); + var TransportManager = (function () { + function TransportManager(options) { + this.options = options || {}; + this.livesLeft = this.options.lives || Infinity; + } + TransportManager.prototype.getAssistant = function (transport) { + return factory_1["default"].createAssistantToTheTransportManager(this, transport, { + minPingDelay: this.options.minPingDelay, + maxPingDelay: this.options.maxPingDelay + }); + }; + TransportManager.prototype.isAlive = function () { + return this.livesLeft > 0; + }; + TransportManager.prototype.reportDeath = function () { + this.livesLeft -= 1; + }; + return TransportManager; + }()); + exports.__esModule = true; + exports["default"] = TransportManager; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var assistant_to_the_transport_manager_1 = __webpack_require__(43); + var handshake_1 = __webpack_require__(44); + var pusher_authorizer_1 = __webpack_require__(47); + var timeline_sender_1 = __webpack_require__(48); + var presence_channel_1 = __webpack_require__(49); + var private_channel_1 = __webpack_require__(50); + var channel_1 = __webpack_require__(51); + var connection_manager_1 = __webpack_require__(53); + var channels_1 = __webpack_require__(54); + var Factory = { + createChannels: function () { + return new channels_1["default"](); + }, + createConnectionManager: function (key, options) { + return new connection_manager_1["default"](key, options); + }, + createChannel: function (name, pusher) { + return new channel_1["default"](name, pusher); + }, + createPrivateChannel: function (name, pusher) { + return new private_channel_1["default"](name, pusher); + }, + createPresenceChannel: function (name, pusher) { + return new presence_channel_1["default"](name, pusher); + }, + createTimelineSender: function (timeline, options) { + return new timeline_sender_1["default"](timeline, options); + }, + createAuthorizer: function (channel, options) { + if (options.authorizer) { + return options.authorizer(channel, options); + } + return new pusher_authorizer_1["default"](channel, options); + }, + createHandshake: function (transport, callback) { + return new handshake_1["default"](transport, callback); + }, + createAssistantToTheTransportManager: function (manager, transport, options) { + return new assistant_to_the_transport_manager_1["default"](manager, transport, options); + } + }; + exports.__esModule = true; + exports["default"] = Factory; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var util_1 = __webpack_require__(11); + var Collections = __webpack_require__(9); + var AssistantToTheTransportManager = (function () { + function AssistantToTheTransportManager(manager, transport, options) { + this.manager = manager; + this.transport = transport; + this.minPingDelay = options.minPingDelay; + this.maxPingDelay = options.maxPingDelay; + this.pingDelay = undefined; + } + AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) { + var _this = this; + options = Collections.extend({}, options, { + activityTimeout: this.pingDelay + }); + var connection = this.transport.createConnection(name, priority, key, options); + var openTimestamp = null; + var onOpen = function () { + connection.unbind("open", onOpen); + connection.bind("closed", onClosed); + openTimestamp = util_1["default"].now(); + }; + var onClosed = function (closeEvent) { + connection.unbind("closed", onClosed); + if (closeEvent.code === 1002 || closeEvent.code === 1003) { + _this.manager.reportDeath(); + } + else if (!closeEvent.wasClean && openTimestamp) { + var lifespan = util_1["default"].now() - openTimestamp; + if (lifespan < 2 * _this.maxPingDelay) { + _this.manager.reportDeath(); + _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay); + } + } + }; + connection.bind("open", onOpen); + return connection; + }; + AssistantToTheTransportManager.prototype.isSupported = function (environment) { + return this.manager.isAlive() && this.transport.isSupported(environment); + }; + return AssistantToTheTransportManager; + }()); + exports.__esModule = true; + exports["default"] = AssistantToTheTransportManager; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var Protocol = __webpack_require__(45); + var connection_1 = __webpack_require__(46); + var Handshake = (function () { + function Handshake(transport, callback) { + this.transport = transport; + this.callback = callback; + this.bindListeners(); + } + Handshake.prototype.close = function () { + this.unbindListeners(); + this.transport.close(); + }; + Handshake.prototype.bindListeners = function () { + var _this = this; + this.onMessage = function (m) { + _this.unbindListeners(); + var result; + try { + result = Protocol.processHandshake(m); + } + catch (e) { + _this.finish("error", { error: e }); + _this.transport.close(); + return; + } + if (result.action === "connected") { + _this.finish("connected", { + connection: new connection_1["default"](result.id, _this.transport), + activityTimeout: result.activityTimeout + }); + } + else { + _this.finish(result.action, { error: result.error }); + _this.transport.close(); + } + }; + this.onClosed = function (closeEvent) { + _this.unbindListeners(); + var action = Protocol.getCloseAction(closeEvent) || "backoff"; + var error = Protocol.getCloseError(closeEvent); + _this.finish(action, { error: error }); + }; + this.transport.bind("message", this.onMessage); + this.transport.bind("closed", this.onClosed); + }; + Handshake.prototype.unbindListeners = function () { + this.transport.unbind("message", this.onMessage); + this.transport.unbind("closed", this.onClosed); + }; + Handshake.prototype.finish = function (action, params) { + this.callback(Collections.extend({ transport: this.transport, action: action }, params)); + }; + return Handshake; + }()); + exports.__esModule = true; + exports["default"] = Handshake; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + + "use strict"; + exports.decodeMessage = function (message) { + try { + var params = JSON.parse(message.data); + if (typeof params.data === 'string') { + try { + params.data = JSON.parse(params.data); + } + catch (e) { + if (!(e instanceof SyntaxError)) { + throw e; + } + } + } + return params; + } + catch (e) { + throw { type: 'MessageParseError', error: e, data: message.data }; + } + }; + exports.encodeMessage = function (message) { + return JSON.stringify(message); + }; + exports.processHandshake = function (message) { + message = exports.decodeMessage(message); + if (message.event === "pusher:connection_established") { + if (!message.data.activity_timeout) { + throw "No activity timeout specified in handshake"; + } + return { + action: "connected", + id: message.data.socket_id, + activityTimeout: message.data.activity_timeout * 1000 + }; + } + else if (message.event === "pusher:error") { + return { + action: this.getCloseAction(message.data), + error: this.getCloseError(message.data) + }; + } + else { + throw "Invalid handshake"; + } + }; + exports.getCloseAction = function (closeEvent) { + if (closeEvent.code < 4000) { + if (closeEvent.code >= 1002 && closeEvent.code <= 1004) { + return "backoff"; + } + else { + return null; + } + } + else if (closeEvent.code === 4000) { + return "ssl_only"; + } + else if (closeEvent.code < 4100) { + return "refused"; + } + else if (closeEvent.code < 4200) { + return "backoff"; + } + else if (closeEvent.code < 4300) { + return "retry"; + } + else { + return "refused"; + } + }; + exports.getCloseError = function (closeEvent) { + if (closeEvent.code !== 1000 && closeEvent.code !== 1001) { + return { + type: 'PusherError', + data: { + code: closeEvent.code, + message: closeEvent.reason || closeEvent.message + } + }; + } + else { + return null; + } + }; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var Collections = __webpack_require__(9); + var dispatcher_1 = __webpack_require__(23); + var Protocol = __webpack_require__(45); + var logger_1 = __webpack_require__(8); + var Connection = (function (_super) { + __extends(Connection, _super); + function Connection(id, transport) { + _super.call(this); + this.id = id; + this.transport = transport; + this.activityTimeout = transport.activityTimeout; + this.bindListeners(); + } + Connection.prototype.handlesActivityChecks = function () { + return this.transport.handlesActivityChecks(); + }; + Connection.prototype.send = function (data) { + return this.transport.send(data); + }; + Connection.prototype.send_event = function (name, data, channel) { + var message = { event: name, data: data }; + if (channel) { + message.channel = channel; + } + logger_1["default"].debug('Event sent', message); + return this.send(Protocol.encodeMessage(message)); + }; + Connection.prototype.ping = function () { + if (this.transport.supportsPing()) { + this.transport.ping(); + } + else { + this.send_event('pusher:ping', {}); + } + }; + Connection.prototype.close = function () { + this.transport.close(); + }; + Connection.prototype.bindListeners = function () { + var _this = this; + var listeners = { + message: function (m) { + var message; + try { + message = Protocol.decodeMessage(m); + } + catch (e) { + _this.emit('error', { + type: 'MessageParseError', + error: e, + data: m.data + }); + } + if (message !== undefined) { + logger_1["default"].debug('Event recd', message); + switch (message.event) { + case 'pusher:error': + _this.emit('error', { type: 'PusherError', data: message.data }); + break; + case 'pusher:ping': + _this.emit("ping"); + break; + case 'pusher:pong': + _this.emit("pong"); + break; + } + _this.emit('message', message); + } + }, + activity: function () { + _this.emit("activity"); + }, + error: function (error) { + _this.emit("error", { type: "WebSocketError", error: error }); + }, + closed: function (closeEvent) { + unbindListeners(); + if (closeEvent && closeEvent.code) { + _this.handleCloseEvent(closeEvent); + } + _this.transport = null; + _this.emit("closed"); + } + }; + var unbindListeners = function () { + Collections.objectApply(listeners, function (listener, event) { + _this.transport.unbind(event, listener); + }); + }; + Collections.objectApply(listeners, function (listener, event) { + _this.transport.bind(event, listener); + }); + }; + Connection.prototype.handleCloseEvent = function (closeEvent) { + var action = Protocol.getCloseAction(closeEvent); + var error = Protocol.getCloseError(closeEvent); + if (error) { + this.emit('error', error); + } + if (action) { + this.emit(action); + } + }; + return Connection; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = Connection; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var PusherAuthorizer = (function () { + function PusherAuthorizer(channel, options) { + this.channel = channel; + var authTransport = options.authTransport; + if (typeof runtime_1["default"].getAuthorizers()[authTransport] === "undefined") { + throw "'" + authTransport + "' is not a recognized auth transport"; + } + this.type = authTransport; + this.options = options; + this.authOptions = (options || {}).auth || {}; + } + PusherAuthorizer.prototype.composeQuery = function (socketId) { + var query = 'socket_id=' + encodeURIComponent(socketId) + + '&channel_name=' + encodeURIComponent(this.channel.name); + for (var i in this.authOptions.params) { + query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]); + } + return query; + }; + PusherAuthorizer.prototype.authorize = function (socketId, callback) { + PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime_1["default"].getAuthorizers(); + return PusherAuthorizer.authorizers[this.type].call(this, runtime_1["default"], socketId, callback); + }; + return PusherAuthorizer; + }()); + exports.__esModule = true; + exports["default"] = PusherAuthorizer; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var TimelineSender = (function () { + function TimelineSender(timeline, options) { + this.timeline = timeline; + this.options = options || {}; + } + TimelineSender.prototype.send = function (encrypted, callback) { + if (this.timeline.isEmpty()) { + return; + } + this.timeline.send(runtime_1["default"].TimelineTransport.getAgent(this, encrypted), callback); + }; + return TimelineSender; + }()); + exports.__esModule = true; + exports["default"] = TimelineSender; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var private_channel_1 = __webpack_require__(50); + var logger_1 = __webpack_require__(8); + var members_1 = __webpack_require__(52); + var PresenceChannel = (function (_super) { + __extends(PresenceChannel, _super); + function PresenceChannel(name, pusher) { + _super.call(this, name, pusher); + this.members = new members_1["default"](); + } + PresenceChannel.prototype.authorize = function (socketId, callback) { + var _this = this; + _super.prototype.authorize.call(this, socketId, function (error, authData) { + if (!error) { + if (authData.channel_data === undefined) { + logger_1["default"].warn("Invalid auth response for channel '" + + _this.name + + "', expected 'channel_data' field"); + callback("Invalid auth response"); + return; + } + var channelData = JSON.parse(authData.channel_data); + _this.members.setMyID(channelData.user_id); + } + callback(error, authData); + }); + }; + PresenceChannel.prototype.handleEvent = function (event, data) { + switch (event) { + case "pusher_internal:subscription_succeeded": + this.subscriptionPending = false; + this.subscribed = true; + if (this.subscriptionCancelled) { + this.pusher.unsubscribe(this.name); + } + else { + this.members.onSubscription(data); + this.emit("pusher:subscription_succeeded", this.members); + } + break; + case "pusher_internal:member_added": + var addedMember = this.members.addMember(data); + this.emit('pusher:member_added', addedMember); + break; + case "pusher_internal:member_removed": + var removedMember = this.members.removeMember(data); + if (removedMember) { + this.emit('pusher:member_removed', removedMember); + } + break; + default: + private_channel_1["default"].prototype.handleEvent.call(this, event, data); + } + }; + PresenceChannel.prototype.disconnect = function () { + this.members.reset(); + _super.prototype.disconnect.call(this); + }; + return PresenceChannel; + }(private_channel_1["default"])); + exports.__esModule = true; + exports["default"] = PresenceChannel; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var factory_1 = __webpack_require__(42); + var channel_1 = __webpack_require__(51); + var PrivateChannel = (function (_super) { + __extends(PrivateChannel, _super); + function PrivateChannel() { + _super.apply(this, arguments); + } + PrivateChannel.prototype.authorize = function (socketId, callback) { + var authorizer = factory_1["default"].createAuthorizer(this, this.pusher.config); + return authorizer.authorize(socketId, callback); + }; + return PrivateChannel; + }(channel_1["default"])); + exports.__esModule = true; + exports["default"] = PrivateChannel; + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var dispatcher_1 = __webpack_require__(23); + var Errors = __webpack_require__(30); + var logger_1 = __webpack_require__(8); + var Channel = (function (_super) { + __extends(Channel, _super); + function Channel(name, pusher) { + _super.call(this, function (event, data) { + logger_1["default"].debug('No callbacks on ' + name + ' for ' + event); + }); + this.name = name; + this.pusher = pusher; + this.subscribed = false; + this.subscriptionPending = false; + this.subscriptionCancelled = false; + } + Channel.prototype.authorize = function (socketId, callback) { + return callback(false, {}); + }; + Channel.prototype.trigger = function (event, data) { + if (event.indexOf("client-") !== 0) { + throw new Errors.BadEventName("Event '" + event + "' does not start with 'client-'"); + } + return this.pusher.send_event(event, data, this.name); + }; + Channel.prototype.disconnect = function () { + this.subscribed = false; + }; + Channel.prototype.handleEvent = function (event, data) { + if (event.indexOf("pusher_internal:") === 0) { + if (event === "pusher_internal:subscription_succeeded") { + this.subscriptionPending = false; + this.subscribed = true; + if (this.subscriptionCancelled) { + this.pusher.unsubscribe(this.name); + } + else { + this.emit("pusher:subscription_succeeded", data); + } + } + } + else { + this.emit(event, data); + } + }; + Channel.prototype.subscribe = function () { + var _this = this; + if (this.subscribed) { + return; + } + this.subscriptionPending = true; + this.subscriptionCancelled = false; + this.authorize(this.pusher.connection.socket_id, function (error, data) { + if (error) { + _this.handleEvent('pusher:subscription_error', data); + } + else { + _this.pusher.send_event('pusher:subscribe', { + auth: data.auth, + channel_data: data.channel_data, + channel: _this.name + }); + } + }); + }; + Channel.prototype.unsubscribe = function () { + this.subscribed = false; + this.pusher.send_event('pusher:unsubscribe', { + channel: this.name + }); + }; + Channel.prototype.cancelSubscription = function () { + this.subscriptionCancelled = true; + }; + Channel.prototype.reinstateSubscription = function () { + this.subscriptionCancelled = false; + }; + return Channel; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = Channel; + + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var Members = (function () { + function Members() { + this.reset(); + } + Members.prototype.get = function (id) { + if (Object.prototype.hasOwnProperty.call(this.members, id)) { + return { + id: id, + info: this.members[id] + }; + } + else { + return null; + } + }; + Members.prototype.each = function (callback) { + var _this = this; + Collections.objectApply(this.members, function (member, id) { + callback(_this.get(id)); + }); + }; + Members.prototype.setMyID = function (id) { + this.myID = id; + }; + Members.prototype.onSubscription = function (subscriptionData) { + this.members = subscriptionData.presence.hash; + this.count = subscriptionData.presence.count; + this.me = this.get(this.myID); + }; + Members.prototype.addMember = function (memberData) { + if (this.get(memberData.user_id) === null) { + this.count++; + } + this.members[memberData.user_id] = memberData.user_info; + return this.get(memberData.user_id); + }; + Members.prototype.removeMember = function (memberData) { + var member = this.get(memberData.user_id); + if (member) { + delete this.members[memberData.user_id]; + this.count--; + } + return member; + }; + Members.prototype.reset = function () { + this.members = {}; + this.count = 0; + this.myID = null; + this.me = null; + }; + return Members; + }()); + exports.__esModule = true; + exports["default"] = Members; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var dispatcher_1 = __webpack_require__(23); + var timers_1 = __webpack_require__(12); + var logger_1 = __webpack_require__(8); + var Collections = __webpack_require__(9); + var runtime_1 = __webpack_require__(2); + var ConnectionManager = (function (_super) { + __extends(ConnectionManager, _super); + function ConnectionManager(key, options) { + var _this = this; + _super.call(this); + this.key = key; + this.options = options || {}; + this.state = "initialized"; + this.connection = null; + this.encrypted = !!options.encrypted; + this.timeline = this.options.timeline; + this.connectionCallbacks = this.buildConnectionCallbacks(); + this.errorCallbacks = this.buildErrorCallbacks(); + this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks); + var Network = runtime_1["default"].getNetwork(); + Network.bind("online", function () { + _this.timeline.info({ netinfo: "online" }); + if (_this.state === "connecting" || _this.state === "unavailable") { + _this.retryIn(0); + } + }); + Network.bind("offline", function () { + _this.timeline.info({ netinfo: "offline" }); + if (_this.connection) { + _this.sendActivityCheck(); + } + }); + this.updateStrategy(); + } + ConnectionManager.prototype.connect = function () { + if (this.connection || this.runner) { + return; + } + if (!this.strategy.isSupported()) { + this.updateState("failed"); + return; + } + this.updateState("connecting"); + this.startConnecting(); + this.setUnavailableTimer(); + }; + ; + ConnectionManager.prototype.send = function (data) { + if (this.connection) { + return this.connection.send(data); + } + else { + return false; + } + }; + ; + ConnectionManager.prototype.send_event = function (name, data, channel) { + if (this.connection) { + return this.connection.send_event(name, data, channel); + } + else { + return false; + } + }; + ; + ConnectionManager.prototype.disconnect = function () { + this.disconnectInternally(); + this.updateState("disconnected"); + }; + ; + ConnectionManager.prototype.isEncrypted = function () { + return this.encrypted; + }; + ; + ConnectionManager.prototype.startConnecting = function () { + var _this = this; + var callback = function (error, handshake) { + if (error) { + _this.runner = _this.strategy.connect(0, callback); + } + else { + if (handshake.action === "error") { + _this.emit("error", { type: "HandshakeError", error: handshake.error }); + _this.timeline.error({ handshakeError: handshake.error }); + } + else { + _this.abortConnecting(); + _this.handshakeCallbacks[handshake.action](handshake); + } + } + }; + this.runner = this.strategy.connect(0, callback); + }; + ; + ConnectionManager.prototype.abortConnecting = function () { + if (this.runner) { + this.runner.abort(); + this.runner = null; + } + }; + ; + ConnectionManager.prototype.disconnectInternally = function () { + this.abortConnecting(); + this.clearRetryTimer(); + this.clearUnavailableTimer(); + if (this.connection) { + var connection = this.abandonConnection(); + connection.close(); + } + }; + ; + ConnectionManager.prototype.updateStrategy = function () { + this.strategy = this.options.getStrategy({ + key: this.key, + timeline: this.timeline, + encrypted: this.encrypted + }); + }; + ; + ConnectionManager.prototype.retryIn = function (delay) { + var _this = this; + this.timeline.info({ action: "retry", delay: delay }); + if (delay > 0) { + this.emit("connecting_in", Math.round(delay / 1000)); + } + this.retryTimer = new timers_1.OneOffTimer(delay || 0, function () { + _this.disconnectInternally(); + _this.connect(); + }); + }; + ; + ConnectionManager.prototype.clearRetryTimer = function () { + if (this.retryTimer) { + this.retryTimer.ensureAborted(); + this.retryTimer = null; + } + }; + ; + ConnectionManager.prototype.setUnavailableTimer = function () { + var _this = this; + this.unavailableTimer = new timers_1.OneOffTimer(this.options.unavailableTimeout, function () { + _this.updateState("unavailable"); + }); + }; + ; + ConnectionManager.prototype.clearUnavailableTimer = function () { + if (this.unavailableTimer) { + this.unavailableTimer.ensureAborted(); + } + }; + ; + ConnectionManager.prototype.sendActivityCheck = function () { + var _this = this; + this.stopActivityCheck(); + this.connection.ping(); + this.activityTimer = new timers_1.OneOffTimer(this.options.pongTimeout, function () { + _this.timeline.error({ pong_timed_out: _this.options.pongTimeout }); + _this.retryIn(0); + }); + }; + ; + ConnectionManager.prototype.resetActivityCheck = function () { + var _this = this; + this.stopActivityCheck(); + if (!this.connection.handlesActivityChecks()) { + this.activityTimer = new timers_1.OneOffTimer(this.activityTimeout, function () { + _this.sendActivityCheck(); + }); + } + }; + ; + ConnectionManager.prototype.stopActivityCheck = function () { + if (this.activityTimer) { + this.activityTimer.ensureAborted(); + } + }; + ; + ConnectionManager.prototype.buildConnectionCallbacks = function () { + var _this = this; + return { + message: function (message) { + _this.resetActivityCheck(); + _this.emit('message', message); + }, + ping: function () { + _this.send_event('pusher:pong', {}); + }, + activity: function () { + _this.resetActivityCheck(); + }, + error: function (error) { + _this.emit("error", { type: "WebSocketError", error: error }); + }, + closed: function () { + _this.abandonConnection(); + if (_this.shouldRetry()) { + _this.retryIn(1000); + } + } + }; + }; + ; + ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) { + var _this = this; + return Collections.extend({}, errorCallbacks, { + connected: function (handshake) { + _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity); + _this.clearUnavailableTimer(); + _this.setConnection(handshake.connection); + _this.socket_id = _this.connection.id; + _this.updateState("connected", { socket_id: _this.socket_id }); + } + }); + }; + ; + ConnectionManager.prototype.buildErrorCallbacks = function () { + var _this = this; + var withErrorEmitted = function (callback) { + return function (result) { + if (result.error) { + _this.emit("error", { type: "WebSocketError", error: result.error }); + } + callback(result); + }; + }; + return { + ssl_only: withErrorEmitted(function () { + _this.encrypted = true; + _this.updateStrategy(); + _this.retryIn(0); + }), + refused: withErrorEmitted(function () { + _this.disconnect(); + }), + backoff: withErrorEmitted(function () { + _this.retryIn(1000); + }), + retry: withErrorEmitted(function () { + _this.retryIn(0); + }) + }; + }; + ; + ConnectionManager.prototype.setConnection = function (connection) { + this.connection = connection; + for (var event in this.connectionCallbacks) { + this.connection.bind(event, this.connectionCallbacks[event]); + } + this.resetActivityCheck(); + }; + ; + ConnectionManager.prototype.abandonConnection = function () { + if (!this.connection) { + return; + } + this.stopActivityCheck(); + for (var event in this.connectionCallbacks) { + this.connection.unbind(event, this.connectionCallbacks[event]); + } + var connection = this.connection; + this.connection = null; + return connection; + }; + ConnectionManager.prototype.updateState = function (newState, data) { + var previousState = this.state; + this.state = newState; + if (previousState !== newState) { + var newStateDescription = newState; + if (newStateDescription === "connected") { + newStateDescription += " with new socket ID " + data.socket_id; + } + logger_1["default"].debug('State changed', previousState + ' -> ' + newStateDescription); + this.timeline.info({ state: newState, params: data }); + this.emit('state_change', { previous: previousState, current: newState }); + this.emit(newState, data); + } + }; + ConnectionManager.prototype.shouldRetry = function () { + return this.state === "connecting" || this.state === "connected"; + }; + return ConnectionManager; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = ConnectionManager; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var factory_1 = __webpack_require__(42); + var Channels = (function () { + function Channels() { + this.channels = {}; + } + Channels.prototype.add = function (name, pusher) { + if (!this.channels[name]) { + this.channels[name] = createChannel(name, pusher); + } + return this.channels[name]; + }; + Channels.prototype.all = function () { + return Collections.values(this.channels); + }; + Channels.prototype.find = function (name) { + return this.channels[name]; + }; + Channels.prototype.remove = function (name) { + var channel = this.channels[name]; + delete this.channels[name]; + return channel; + }; + Channels.prototype.disconnect = function () { + Collections.objectApply(this.channels, function (channel) { + channel.disconnect(); + }); + }; + return Channels; + }()); + exports.__esModule = true; + exports["default"] = Channels; + function createChannel(name, pusher) { + if (name.indexOf('private-') === 0) { + return factory_1["default"].createPrivateChannel(name, pusher); + } + else if (name.indexOf('presence-') === 0) { + return factory_1["default"].createPresenceChannel(name, pusher); + } + else { + return factory_1["default"].createChannel(name, pusher); + } + } + + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var factory_1 = __webpack_require__(42); + var util_1 = __webpack_require__(11); + var Errors = __webpack_require__(30); + var Collections = __webpack_require__(9); + var TransportStrategy = (function () { + function TransportStrategy(name, priority, transport, options) { + this.name = name; + this.priority = priority; + this.transport = transport; + this.options = options || {}; + } + TransportStrategy.prototype.isSupported = function () { + return this.transport.isSupported({ + encrypted: this.options.encrypted + }); + }; + TransportStrategy.prototype.connect = function (minPriority, callback) { + var _this = this; + if (!this.isSupported()) { + return failAttempt(new Errors.UnsupportedStrategy(), callback); + } + else if (this.priority < minPriority) { + return failAttempt(new Errors.TransportPriorityTooLow(), callback); + } + var connected = false; + var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options); + var handshake = null; + var onInitialized = function () { + transport.unbind("initialized", onInitialized); + transport.connect(); + }; + var onOpen = function () { + handshake = factory_1["default"].createHandshake(transport, function (result) { + connected = true; + unbindListeners(); + callback(null, result); + }); + }; + var onError = function (error) { + unbindListeners(); + callback(error); + }; + var onClosed = function () { + unbindListeners(); + var serializedTransport; + serializedTransport = Collections.safeJSONStringify(transport); + callback(new Errors.TransportClosed(serializedTransport)); + }; + var unbindListeners = function () { + transport.unbind("initialized", onInitialized); + transport.unbind("open", onOpen); + transport.unbind("error", onError); + transport.unbind("closed", onClosed); + }; + transport.bind("initialized", onInitialized); + transport.bind("open", onOpen); + transport.bind("error", onError); + transport.bind("closed", onClosed); + transport.initialize(); + return { + abort: function () { + if (connected) { + return; + } + unbindListeners(); + if (handshake) { + handshake.close(); + } + else { + transport.close(); + } + }, + forceMinPriority: function (p) { + if (connected) { + return; + } + if (_this.priority < p) { + if (handshake) { + handshake.close(); + } + else { + transport.close(); + } + } + } + }; + }; + return TransportStrategy; + }()); + exports.__esModule = true; + exports["default"] = TransportStrategy; + function failAttempt(error, callback) { + util_1["default"].defer(function () { + callback(error); + }); + return { + abort: function () { }, + forceMinPriority: function () { } + }; + } + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var timers_1 = __webpack_require__(12); + var SequentialStrategy = (function () { + function SequentialStrategy(strategies, options) { + this.strategies = strategies; + this.loop = Boolean(options.loop); + this.failFast = Boolean(options.failFast); + this.timeout = options.timeout; + this.timeoutLimit = options.timeoutLimit; + } + SequentialStrategy.prototype.isSupported = function () { + return Collections.any(this.strategies, util_1["default"].method("isSupported")); + }; + SequentialStrategy.prototype.connect = function (minPriority, callback) { + var _this = this; + var strategies = this.strategies; + var current = 0; + var timeout = this.timeout; + var runner = null; + var tryNextStrategy = function (error, handshake) { + if (handshake) { + callback(null, handshake); + } + else { + current = current + 1; + if (_this.loop) { + current = current % strategies.length; + } + if (current < strategies.length) { + if (timeout) { + timeout = timeout * 2; + if (_this.timeoutLimit) { + timeout = Math.min(timeout, _this.timeoutLimit); + } + } + runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy); + } + else { + callback(true); + } + } + }; + runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy); + return { + abort: function () { + runner.abort(); + }, + forceMinPriority: function (p) { + minPriority = p; + if (runner) { + runner.forceMinPriority(p); + } + } + }; + }; + SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) { + var timer = null; + var runner = null; + if (options.timeout > 0) { + timer = new timers_1.OneOffTimer(options.timeout, function () { + runner.abort(); + callback(true); + }); + } + runner = strategy.connect(minPriority, function (error, handshake) { + if (error && timer && timer.isRunning() && !options.failFast) { + return; + } + if (timer) { + timer.ensureAborted(); + } + callback(error, handshake); + }); + return { + abort: function () { + if (timer) { + timer.ensureAborted(); + } + runner.abort(); + }, + forceMinPriority: function (p) { + runner.forceMinPriority(p); + } + }; + }; + return SequentialStrategy; + }()); + exports.__esModule = true; + exports["default"] = SequentialStrategy; + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var BestConnectedEverStrategy = (function () { + function BestConnectedEverStrategy(strategies) { + this.strategies = strategies; + } + BestConnectedEverStrategy.prototype.isSupported = function () { + return Collections.any(this.strategies, util_1["default"].method("isSupported")); + }; + BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) { + return connect(this.strategies, minPriority, function (i, runners) { + return function (error, handshake) { + runners[i].error = error; + if (error) { + if (allRunnersFailed(runners)) { + callback(true); + } + return; + } + Collections.apply(runners, function (runner) { + runner.forceMinPriority(handshake.transport.priority); + }); + callback(null, handshake); + }; + }); + }; + return BestConnectedEverStrategy; + }()); + exports.__esModule = true; + exports["default"] = BestConnectedEverStrategy; + function connect(strategies, minPriority, callbackBuilder) { + var runners = Collections.map(strategies, function (strategy, i, _, rs) { + return strategy.connect(minPriority, callbackBuilder(i, rs)); + }); + return { + abort: function () { + Collections.apply(runners, abortRunner); + }, + forceMinPriority: function (p) { + Collections.apply(runners, function (runner) { + runner.forceMinPriority(p); + }); + } + }; + } + function allRunnersFailed(runners) { + return Collections.all(runners, function (runner) { + return Boolean(runner.error); + }); + } + function abortRunner(runner) { + if (!runner.error && !runner.aborted) { + runner.abort(); + runner.aborted = true; + } + } + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var util_1 = __webpack_require__(11); + var runtime_1 = __webpack_require__(2); + var sequential_strategy_1 = __webpack_require__(56); + var Collections = __webpack_require__(9); + var CachedStrategy = (function () { + function CachedStrategy(strategy, transports, options) { + this.strategy = strategy; + this.transports = transports; + this.ttl = options.ttl || 1800 * 1000; + this.encrypted = options.encrypted; + this.timeline = options.timeline; + } + CachedStrategy.prototype.isSupported = function () { + return this.strategy.isSupported(); + }; + CachedStrategy.prototype.connect = function (minPriority, callback) { + var encrypted = this.encrypted; + var info = fetchTransportCache(encrypted); + var strategies = [this.strategy]; + if (info && info.timestamp + this.ttl >= util_1["default"].now()) { + var transport = this.transports[info.transport]; + if (transport) { + this.timeline.info({ + cached: true, + transport: info.transport, + latency: info.latency + }); + strategies.push(new sequential_strategy_1["default"]([transport], { + timeout: info.latency * 2 + 1000, + failFast: true + })); + } + } + var startTimestamp = util_1["default"].now(); + var runner = strategies.pop().connect(minPriority, function cb(error, handshake) { + if (error) { + flushTransportCache(encrypted); + if (strategies.length > 0) { + startTimestamp = util_1["default"].now(); + runner = strategies.pop().connect(minPriority, cb); + } + else { + callback(error); + } + } + else { + storeTransportCache(encrypted, handshake.transport.name, util_1["default"].now() - startTimestamp); + callback(null, handshake); + } + }); + return { + abort: function () { + runner.abort(); + }, + forceMinPriority: function (p) { + minPriority = p; + if (runner) { + runner.forceMinPriority(p); + } + } + }; + }; + return CachedStrategy; + }()); + exports.__esModule = true; + exports["default"] = CachedStrategy; + function getTransportCacheKey(encrypted) { + return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted"); + } + function fetchTransportCache(encrypted) { + var storage = runtime_1["default"].getLocalStorage(); + if (storage) { + try { + var serializedCache = storage[getTransportCacheKey(encrypted)]; + if (serializedCache) { + return JSON.parse(serializedCache); + } + } + catch (e) { + flushTransportCache(encrypted); + } + } + return null; + } + function storeTransportCache(encrypted, transport, latency) { + var storage = runtime_1["default"].getLocalStorage(); + if (storage) { + try { + storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({ + timestamp: util_1["default"].now(), + transport: transport, + latency: latency + }); + } + catch (e) { + } + } + } + function flushTransportCache(encrypted) { + var storage = runtime_1["default"].getLocalStorage(); + if (storage) { + try { + delete storage[getTransportCacheKey(encrypted)]; + } + catch (e) { + } + } + } + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var timers_1 = __webpack_require__(12); + var DelayedStrategy = (function () { + function DelayedStrategy(strategy, _a) { + var number = _a.delay; + this.strategy = strategy; + this.options = { delay: number }; + } + DelayedStrategy.prototype.isSupported = function () { + return this.strategy.isSupported(); + }; + DelayedStrategy.prototype.connect = function (minPriority, callback) { + var strategy = this.strategy; + var runner; + var timer = new timers_1.OneOffTimer(this.options.delay, function () { + runner = strategy.connect(minPriority, callback); + }); + return { + abort: function () { + timer.ensureAborted(); + if (runner) { + runner.abort(); + } + }, + forceMinPriority: function (p) { + minPriority = p; + if (runner) { + runner.forceMinPriority(p); + } + } + }; + }; + return DelayedStrategy; + }()); + exports.__esModule = true; + exports["default"] = DelayedStrategy; + + +/***/ }), +/* 60 */ +/***/ (function(module, exports) { + + "use strict"; + var IfStrategy = (function () { + function IfStrategy(test, trueBranch, falseBranch) { + this.test = test; + this.trueBranch = trueBranch; + this.falseBranch = falseBranch; + } + IfStrategy.prototype.isSupported = function () { + var branch = this.test() ? this.trueBranch : this.falseBranch; + return branch.isSupported(); + }; + IfStrategy.prototype.connect = function (minPriority, callback) { + var branch = this.test() ? this.trueBranch : this.falseBranch; + return branch.connect(minPriority, callback); + }; + return IfStrategy; + }()); + exports.__esModule = true; + exports["default"] = IfStrategy; + + +/***/ }), +/* 61 */ +/***/ (function(module, exports) { + + "use strict"; + var FirstConnectedStrategy = (function () { + function FirstConnectedStrategy(strategy) { + this.strategy = strategy; + } + FirstConnectedStrategy.prototype.isSupported = function () { + return this.strategy.isSupported(); + }; + FirstConnectedStrategy.prototype.connect = function (minPriority, callback) { + var runner = this.strategy.connect(minPriority, function (error, handshake) { + if (handshake) { + runner.abort(); + } + callback(error, handshake); + }); + return runner; + }; + return FirstConnectedStrategy; + }()); + exports.__esModule = true; + exports["default"] = FirstConnectedStrategy; + + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var defaults_1 = __webpack_require__(5); + exports.getGlobalConfig = function () { + return { + wsHost: defaults_1["default"].host, + wsPort: defaults_1["default"].ws_port, + wssPort: defaults_1["default"].wss_port, + httpHost: defaults_1["default"].sockjs_host, + httpPort: defaults_1["default"].sockjs_http_port, + httpsPort: defaults_1["default"].sockjs_https_port, + httpPath: defaults_1["default"].sockjs_path, + statsHost: defaults_1["default"].stats_host, + authEndpoint: defaults_1["default"].channel_auth_endpoint, + authTransport: defaults_1["default"].channel_auth_transport, + activity_timeout: defaults_1["default"].activity_timeout, + pong_timeout: defaults_1["default"].pong_timeout, + unavailable_timeout: defaults_1["default"].unavailable_timeout + }; + }; + exports.getClusterConfig = function (clusterName) { + return { + wsHost: "ws-" + clusterName + ".pusher.com", + httpHost: "sockjs-" + clusterName + ".pusher.com" + }; + }; + + +/***/ }) +/******/ ]) +}); +; + +/***/ }), + +/***/ "./node_modules/style-loader/addStyles.js": +/***/ (function(module, exports) { + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +var stylesInDom = {}, + memoize = function(fn) { + var memo; + return function () { + if (typeof memo === "undefined") memo = fn.apply(this, arguments); + return memo; + }; + }, + isOldIE = memoize(function() { + return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase()); + }), + getHeadElement = memoize(function () { + return document.head || document.getElementsByTagName("head")[0]; + }), + singletonElement = null, + singletonCounter = 0, + styleElementsInsertedAtTop = []; + +module.exports = function(list, options) { + if(typeof DEBUG !== "undefined" && DEBUG) { + if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); + } + + options = options || {}; + // Force single-tag solution on IE6-9, which has a hard limit on the # of