Advertisement
Guest User

NattyAlisha.user.js

a guest
Jun 21st, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 267.09 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Advanced Flagging
  3. // @namespace https://github.com/SOBotics
  4. // @version 0.5.55
  5. // @author Robert Rudman
  6. // @match *://*.stackexchange.com/*
  7. // @match *://*.stackoverflow.com/*
  8. // @match *://*.superuser.com/*
  9. // @match *://*.serverfault.com/*
  10. // @match *://*.askubuntu.com/*
  11. // @match *://*.stackapps.com/*
  12. // @match *://*.mathoverflow.net/*
  13. // @exclude *://chat.stackexchange.com/*
  14. // @exclude *://chat.meta.stackexchange.com/*
  15. // @exclude *://chat.stackoverflow.com/*
  16. // @exclude *://blog.stackoverflow.com/*
  17. // @exclude *://*.area51.stackexchange.com/*
  18. // @require https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js
  19. // @grant GM_xmlhttpRequest
  20. // ==/UserScript==
  21. /******/ (function(modules) { // webpackBootstrap
  22. /******/ // The module cache
  23. /******/ var installedModules = {};
  24. /******/
  25. /******/ // The require function
  26. /******/ function __webpack_require__(moduleId) {
  27. /******/
  28. /******/ // Check if module is in cache
  29. /******/ if(installedModules[moduleId]) {
  30. /******/ return installedModules[moduleId].exports;
  31. /******/ }
  32. /******/ // Create a new module (and put it into the cache)
  33. /******/ var module = installedModules[moduleId] = {
  34. /******/ i: moduleId,
  35. /******/ l: false,
  36. /******/ exports: {}
  37. /******/ };
  38. /******/
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  41. /******/
  42. /******/ // Flag the module as loaded
  43. /******/ module.l = true;
  44. /******/
  45. /******/ // Return the exports of the module
  46. /******/ return module.exports;
  47. /******/ }
  48. /******/
  49. /******/
  50. /******/ // expose the modules object (__webpack_modules__)
  51. /******/ __webpack_require__.m = modules;
  52. /******/
  53. /******/ // expose the module cache
  54. /******/ __webpack_require__.c = installedModules;
  55. /******/
  56. /******/ // define getter function for harmony exports
  57. /******/ __webpack_require__.d = function(exports, name, getter) {
  58. /******/ if(!__webpack_require__.o(exports, name)) {
  59. /******/ Object.defineProperty(exports, name, {
  60. /******/ configurable: false,
  61. /******/ enumerable: true,
  62. /******/ get: getter
  63. /******/ });
  64. /******/ }
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "";
  81. /******/
  82. /******/ // Load entry module and return exports
  83. /******/ return __webpack_require__(__webpack_require__.s = 11);
  84. /******/ })
  85. /************************************************************************/
  86. /******/ ([
  87. /* 0 */
  88. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89.  
  90. "use strict";
  91. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  92. /* harmony export (immutable) */ __webpack_exports__["__extends"] = __extends;
  93. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  94. /* harmony export (immutable) */ __webpack_exports__["__rest"] = __rest;
  95. /* harmony export (immutable) */ __webpack_exports__["__decorate"] = __decorate;
  96. /* harmony export (immutable) */ __webpack_exports__["__param"] = __param;
  97. /* harmony export (immutable) */ __webpack_exports__["__metadata"] = __metadata;
  98. /* harmony export (immutable) */ __webpack_exports__["__awaiter"] = __awaiter;
  99. /* harmony export (immutable) */ __webpack_exports__["__generator"] = __generator;
  100. /* harmony export (immutable) */ __webpack_exports__["__exportStar"] = __exportStar;
  101. /* harmony export (immutable) */ __webpack_exports__["__values"] = __values;
  102. /* harmony export (immutable) */ __webpack_exports__["__read"] = __read;
  103. /* harmony export (immutable) */ __webpack_exports__["__spread"] = __spread;
  104. /* harmony export (immutable) */ __webpack_exports__["__await"] = __await;
  105. /* harmony export (immutable) */ __webpack_exports__["__asyncGenerator"] = __asyncGenerator;
  106. /* harmony export (immutable) */ __webpack_exports__["__asyncDelegator"] = __asyncDelegator;
  107. /* harmony export (immutable) */ __webpack_exports__["__asyncValues"] = __asyncValues;
  108. /* harmony export (immutable) */ __webpack_exports__["__makeTemplateObject"] = __makeTemplateObject;
  109. /*! *****************************************************************************
  110. Copyright (c) Microsoft Corporation. All rights reserved.
  111. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  112. this file except in compliance with the License. You may obtain a copy of the
  113. License at http://www.apache.org/licenses/LICENSE-2.0
  114.  
  115. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  116. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  117. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  118. MERCHANTABLITY OR NON-INFRINGEMENT.
  119.  
  120. See the Apache Version 2.0 License for specific language governing permissions
  121. and limitations under the License.
  122. ***************************************************************************** */
  123. /* global Reflect, Promise */
  124.  
  125. var extendStatics = Object.setPrototypeOf ||
  126. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  127. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  128.  
  129. function __extends(d, b) {
  130. extendStatics(d, b);
  131. function __() { this.constructor = d; }
  132. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  133. }
  134.  
  135. var __assign = Object.assign || function __assign(t) {
  136. for (var s, i = 1, n = arguments.length; i < n; i++) {
  137. s = arguments[i];
  138. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  139. }
  140. return t;
  141. }
  142.  
  143. function __rest(s, e) {
  144. var t = {};
  145. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  146. t[p] = s[p];
  147. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  148. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  149. t[p[i]] = s[p[i]];
  150. return t;
  151. }
  152.  
  153. function __decorate(decorators, target, key, desc) {
  154. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  155. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  156. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  157. return c > 3 && r && Object.defineProperty(target, key, r), r;
  158. }
  159.  
  160. function __param(paramIndex, decorator) {
  161. return function (target, key) { decorator(target, key, paramIndex); }
  162. }
  163.  
  164. function __metadata(metadataKey, metadataValue) {
  165. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  166. }
  167.  
  168. function __awaiter(thisArg, _arguments, P, generator) {
  169. return new (P || (P = Promise))(function (resolve, reject) {
  170. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  171. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  172. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  173. step((generator = generator.apply(thisArg, _arguments || [])).next());
  174. });
  175. }
  176.  
  177. function __generator(thisArg, body) {
  178. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  179. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  180. function verb(n) { return function (v) { return step([n, v]); }; }
  181. function step(op) {
  182. if (f) throw new TypeError("Generator is already executing.");
  183. while (_) try {
  184. if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
  185. if (y = 0, t) op = [0, t.value];
  186. switch (op[0]) {
  187. case 0: case 1: t = op; break;
  188. case 4: _.label++; return { value: op[1], done: false };
  189. case 5: _.label++; y = op[1]; op = [0]; continue;
  190. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  191. default:
  192. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  193. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  194. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  195. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  196. if (t[2]) _.ops.pop();
  197. _.trys.pop(); continue;
  198. }
  199. op = body.call(thisArg, _);
  200. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  201. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  202. }
  203. }
  204.  
  205. function __exportStar(m, exports) {
  206. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  207. }
  208.  
  209. function __values(o) {
  210. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  211. if (m) return m.call(o);
  212. return {
  213. next: function () {
  214. if (o && i >= o.length) o = void 0;
  215. return { value: o && o[i++], done: !o };
  216. }
  217. };
  218. }
  219.  
  220. function __read(o, n) {
  221. var m = typeof Symbol === "function" && o[Symbol.iterator];
  222. if (!m) return o;
  223. var i = m.call(o), r, ar = [], e;
  224. try {
  225. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  226. }
  227. catch (error) { e = { error: error }; }
  228. finally {
  229. try {
  230. if (r && !r.done && (m = i["return"])) m.call(i);
  231. }
  232. finally { if (e) throw e.error; }
  233. }
  234. return ar;
  235. }
  236.  
  237. function __spread() {
  238. for (var ar = [], i = 0; i < arguments.length; i++)
  239. ar = ar.concat(__read(arguments[i]));
  240. return ar;
  241. }
  242.  
  243. function __await(v) {
  244. return this instanceof __await ? (this.v = v, this) : new __await(v);
  245. }
  246.  
  247. function __asyncGenerator(thisArg, _arguments, generator) {
  248. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  249. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  250. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  251. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  252. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  253. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  254. function fulfill(value) { resume("next", value); }
  255. function reject(value) { resume("throw", value); }
  256. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  257. }
  258.  
  259. function __asyncDelegator(o) {
  260. var i, p;
  261. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  262. function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
  263. }
  264.  
  265. function __asyncValues(o) {
  266. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  267. var m = o[Symbol.asyncIterator];
  268. return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
  269. }
  270.  
  271. function __makeTemplateObject(cooked, raw) {
  272. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  273. return cooked;
  274. };
  275.  
  276.  
  277. /***/ }),
  278. /* 1 */
  279. /***/ (function(module, exports, __webpack_require__) {
  280.  
  281. "use strict";
  282.  
  283. var root_1 = __webpack_require__(6);
  284. var toSubscriber_1 = __webpack_require__(23);
  285. var observable_1 = __webpack_require__(28);
  286. var pipe_1 = __webpack_require__(29);
  287. /**
  288. * A representation of any set of values over any amount of time. This is the most basic building block
  289. * of RxJS.
  290. *
  291. * @class Observable<T>
  292. */
  293. var Observable = (function () {
  294. /**
  295. * @constructor
  296. * @param {Function} subscribe the function that is called when the Observable is
  297. * initially subscribed to. This function is given a Subscriber, to which new values
  298. * can be `next`ed, or an `error` method can be called to raise an error, or
  299. * `complete` can be called to notify of a successful completion.
  300. */
  301. function Observable(subscribe) {
  302. this._isScalar = false;
  303. if (subscribe) {
  304. this._subscribe = subscribe;
  305. }
  306. }
  307. /**
  308. * Creates a new Observable, with this Observable as the source, and the passed
  309. * operator defined as the new observable's operator.
  310. * @method lift
  311. * @param {Operator} operator the operator defining the operation to take on the observable
  312. * @return {Observable} a new observable with the Operator applied
  313. */
  314. Observable.prototype.lift = function (operator) {
  315. var observable = new Observable();
  316. observable.source = this;
  317. observable.operator = operator;
  318. return observable;
  319. };
  320. /**
  321. * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.
  322. *
  323. * <span class="informal">Use it when you have all these Observables, but still nothing is happening.</span>
  324. *
  325. * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It
  326. * might be for example a function that you passed to a {@link create} static factory, but most of the time it is
  327. * a library implementation, which defines what and when will be emitted by an Observable. This means that calling
  328. * `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often
  329. * thought.
  330. *
  331. * Apart from starting the execution of an Observable, this method allows you to listen for values
  332. * that an Observable emits, as well as for when it completes or errors. You can achieve this in two
  333. * following ways.
  334. *
  335. * The first way is creating an object that implements {@link Observer} interface. It should have methods
  336. * defined by that interface, but note that it should be just a regular JavaScript object, which you can create
  337. * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular do
  338. * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also
  339. * that your object does not have to implement all methods. If you find yourself creating a method that doesn't
  340. * do anything, you can simply omit it. Note however, that if `error` method is not provided, all errors will
  341. * be left uncaught.
  342. *
  343. * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.
  344. * This means you can provide three functions as arguments to `subscribe`, where first function is equivalent
  345. * of a `next` method, second of an `error` method and third of a `complete` method. Just as in case of Observer,
  346. * if you do not need to listen for something, you can omit a function, preferably by passing `undefined` or `null`,
  347. * since `subscribe` recognizes these functions by where they were placed in function call. When it comes
  348. * to `error` function, just as before, if not provided, errors emitted by an Observable will be thrown.
  349. *
  350. * Whatever style of calling `subscribe` you use, in both cases it returns a Subscription object.
  351. * This object allows you to call `unsubscribe` on it, which in turn will stop work that an Observable does and will clean
  352. * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback
  353. * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.
  354. *
  355. * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.
  356. * It is an Observable itself that decides when these functions will be called. For example {@link of}
  357. * by default emits all its values synchronously. Always check documentation for how given Observable
  358. * will behave when subscribed and if its default behavior can be modified with a {@link Scheduler}.
  359. *
  360. * @example <caption>Subscribe with an Observer</caption>
  361. * const sumObserver = {
  362. * sum: 0,
  363. * next(value) {
  364. * console.log('Adding: ' + value);
  365. * this.sum = this.sum + value;
  366. * },
  367. * error() { // We actually could just remove this method,
  368. * }, // since we do not really care about errors right now.
  369. * complete() {
  370. * console.log('Sum equals: ' + this.sum);
  371. * }
  372. * };
  373. *
  374. * Rx.Observable.of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.
  375. * .subscribe(sumObserver);
  376. *
  377. * // Logs:
  378. * // "Adding: 1"
  379. * // "Adding: 2"
  380. * // "Adding: 3"
  381. * // "Sum equals: 6"
  382. *
  383. *
  384. * @example <caption>Subscribe with functions</caption>
  385. * let sum = 0;
  386. *
  387. * Rx.Observable.of(1, 2, 3)
  388. * .subscribe(
  389. * function(value) {
  390. * console.log('Adding: ' + value);
  391. * sum = sum + value;
  392. * },
  393. * undefined,
  394. * function() {
  395. * console.log('Sum equals: ' + sum);
  396. * }
  397. * );
  398. *
  399. * // Logs:
  400. * // "Adding: 1"
  401. * // "Adding: 2"
  402. * // "Adding: 3"
  403. * // "Sum equals: 6"
  404. *
  405. *
  406. * @example <caption>Cancel a subscription</caption>
  407. * const subscription = Rx.Observable.interval(1000).subscribe(
  408. * num => console.log(num),
  409. * undefined,
  410. * () => console.log('completed!') // Will not be called, even
  411. * ); // when cancelling subscription
  412. *
  413. *
  414. * setTimeout(() => {
  415. * subscription.unsubscribe();
  416. * console.log('unsubscribed!');
  417. * }, 2500);
  418. *
  419. * // Logs:
  420. * // 0 after 1s
  421. * // 1 after 2s
  422. * // "unsubscribed!" after 2.5s
  423. *
  424. *
  425. * @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called,
  426. * or the first of three possible handlers, which is the handler for each value emitted from the subscribed
  427. * Observable.
  428. * @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided,
  429. * the error will be thrown as unhandled.
  430. * @param {Function} complete (optional) A handler for a terminal event resulting from successful completion.
  431. * @return {ISubscription} a subscription reference to the registered handlers
  432. * @method subscribe
  433. */
  434. Observable.prototype.subscribe = function (observerOrNext, error, complete) {
  435. var operator = this.operator;
  436. var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
  437. if (operator) {
  438. operator.call(sink, this.source);
  439. }
  440. else {
  441. sink.add(this.source ? this._subscribe(sink) : this._trySubscribe(sink));
  442. }
  443. if (sink.syncErrorThrowable) {
  444. sink.syncErrorThrowable = false;
  445. if (sink.syncErrorThrown) {
  446. throw sink.syncErrorValue;
  447. }
  448. }
  449. return sink;
  450. };
  451. Observable.prototype._trySubscribe = function (sink) {
  452. try {
  453. return this._subscribe(sink);
  454. }
  455. catch (err) {
  456. sink.syncErrorThrown = true;
  457. sink.syncErrorValue = err;
  458. sink.error(err);
  459. }
  460. };
  461. /**
  462. * @method forEach
  463. * @param {Function} next a handler for each value emitted by the observable
  464. * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise
  465. * @return {Promise} a promise that either resolves on observable completion or
  466. * rejects with the handled error
  467. */
  468. Observable.prototype.forEach = function (next, PromiseCtor) {
  469. var _this = this;
  470. if (!PromiseCtor) {
  471. if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
  472. PromiseCtor = root_1.root.Rx.config.Promise;
  473. }
  474. else if (root_1.root.Promise) {
  475. PromiseCtor = root_1.root.Promise;
  476. }
  477. }
  478. if (!PromiseCtor) {
  479. throw new Error('no Promise impl found');
  480. }
  481. return new PromiseCtor(function (resolve, reject) {
  482. // Must be declared in a separate statement to avoid a RefernceError when
  483. // accessing subscription below in the closure due to Temporal Dead Zone.
  484. var subscription;
  485. subscription = _this.subscribe(function (value) {
  486. if (subscription) {
  487. // if there is a subscription, then we can surmise
  488. // the next handling is asynchronous. Any errors thrown
  489. // need to be rejected explicitly and unsubscribe must be
  490. // called manually
  491. try {
  492. next(value);
  493. }
  494. catch (err) {
  495. reject(err);
  496. subscription.unsubscribe();
  497. }
  498. }
  499. else {
  500. // if there is NO subscription, then we're getting a nexted
  501. // value synchronously during subscription. We can just call it.
  502. // If it errors, Observable's `subscribe` will ensure the
  503. // unsubscription logic is called, then synchronously rethrow the error.
  504. // After that, Promise will trap the error and send it
  505. // down the rejection path.
  506. next(value);
  507. }
  508. }, reject, resolve);
  509. });
  510. };
  511. Observable.prototype._subscribe = function (subscriber) {
  512. return this.source.subscribe(subscriber);
  513. };
  514. /**
  515. * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
  516. * @method Symbol.observable
  517. * @return {Observable} this instance of the observable
  518. */
  519. Observable.prototype[observable_1.observable] = function () {
  520. return this;
  521. };
  522. /* tslint:enable:max-line-length */
  523. /**
  524. * Used to stitch together functional operators into a chain.
  525. * @method pipe
  526. * @return {Observable} the Observable result of all of the operators having
  527. * been called in the order they were passed in.
  528. *
  529. * @example
  530. *
  531. * import { map, filter, scan } from 'rxjs/operators';
  532. *
  533. * Rx.Observable.interval(1000)
  534. * .pipe(
  535. * filter(x => x % 2 === 0),
  536. * map(x => x + x),
  537. * scan((acc, x) => acc + x)
  538. * )
  539. * .subscribe(x => console.log(x))
  540. */
  541. Observable.prototype.pipe = function () {
  542. var operations = [];
  543. for (var _i = 0; _i < arguments.length; _i++) {
  544. operations[_i - 0] = arguments[_i];
  545. }
  546. if (operations.length === 0) {
  547. return this;
  548. }
  549. return pipe_1.pipeFromArray(operations)(this);
  550. };
  551. /* tslint:enable:max-line-length */
  552. Observable.prototype.toPromise = function (PromiseCtor) {
  553. var _this = this;
  554. if (!PromiseCtor) {
  555. if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
  556. PromiseCtor = root_1.root.Rx.config.Promise;
  557. }
  558. else if (root_1.root.Promise) {
  559. PromiseCtor = root_1.root.Promise;
  560. }
  561. }
  562. if (!PromiseCtor) {
  563. throw new Error('no Promise impl found');
  564. }
  565. return new PromiseCtor(function (resolve, reject) {
  566. var value;
  567. _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
  568. });
  569. };
  570. // HACK: Since TypeScript inherits static properties too, we have to
  571. // fight against TypeScript here so Subject can have a different static create signature
  572. /**
  573. * Creates a new cold Observable by calling the Observable constructor
  574. * @static true
  575. * @owner Observable
  576. * @method create
  577. * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
  578. * @return {Observable} a new cold observable
  579. */
  580. Observable.create = function (subscribe) {
  581. return new Observable(subscribe);
  582. };
  583. return Observable;
  584. }());
  585. exports.Observable = Observable;
  586. //# sourceMappingURL=Observable.js.map
  587.  
  588. /***/ }),
  589. /* 2 */
  590. /***/ (function(module, exports, __webpack_require__) {
  591.  
  592. "use strict";
  593.  
  594. var __extends = (this && this.__extends) || function (d, b) {
  595. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  596. function __() { this.constructor = d; }
  597. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  598. };
  599. var isFunction_1 = __webpack_require__(13);
  600. var Subscription_1 = __webpack_require__(4);
  601. var Observer_1 = __webpack_require__(15);
  602. var rxSubscriber_1 = __webpack_require__(8);
  603. /**
  604. * Implements the {@link Observer} interface and extends the
  605. * {@link Subscription} class. While the {@link Observer} is the public API for
  606. * consuming the values of an {@link Observable}, all Observers get converted to
  607. * a Subscriber, in order to provide Subscription-like capabilities such as
  608. * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
  609. * implementing operators, but it is rarely used as a public API.
  610. *
  611. * @class Subscriber<T>
  612. */
  613. var Subscriber = (function (_super) {
  614. __extends(Subscriber, _super);
  615. /**
  616. * @param {Observer|function(value: T): void} [destinationOrNext] A partially
  617. * defined Observer or a `next` callback function.
  618. * @param {function(e: ?any): void} [error] The `error` callback of an
  619. * Observer.
  620. * @param {function(): void} [complete] The `complete` callback of an
  621. * Observer.
  622. */
  623. function Subscriber(destinationOrNext, error, complete) {
  624. _super.call(this);
  625. this.syncErrorValue = null;
  626. this.syncErrorThrown = false;
  627. this.syncErrorThrowable = false;
  628. this.isStopped = false;
  629. switch (arguments.length) {
  630. case 0:
  631. this.destination = Observer_1.empty;
  632. break;
  633. case 1:
  634. if (!destinationOrNext) {
  635. this.destination = Observer_1.empty;
  636. break;
  637. }
  638. if (typeof destinationOrNext === 'object') {
  639. if (destinationOrNext instanceof Subscriber) {
  640. this.destination = destinationOrNext;
  641. this.destination.add(this);
  642. }
  643. else {
  644. this.syncErrorThrowable = true;
  645. this.destination = new SafeSubscriber(this, destinationOrNext);
  646. }
  647. break;
  648. }
  649. default:
  650. this.syncErrorThrowable = true;
  651. this.destination = new SafeSubscriber(this, destinationOrNext, error, complete);
  652. break;
  653. }
  654. }
  655. Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () { return this; };
  656. /**
  657. * A static factory for a Subscriber, given a (potentially partial) definition
  658. * of an Observer.
  659. * @param {function(x: ?T): void} [next] The `next` callback of an Observer.
  660. * @param {function(e: ?any): void} [error] The `error` callback of an
  661. * Observer.
  662. * @param {function(): void} [complete] The `complete` callback of an
  663. * Observer.
  664. * @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
  665. * Observer represented by the given arguments.
  666. */
  667. Subscriber.create = function (next, error, complete) {
  668. var subscriber = new Subscriber(next, error, complete);
  669. subscriber.syncErrorThrowable = false;
  670. return subscriber;
  671. };
  672. /**
  673. * The {@link Observer} callback to receive notifications of type `next` from
  674. * the Observable, with a value. The Observable may call this method 0 or more
  675. * times.
  676. * @param {T} [value] The `next` value.
  677. * @return {void}
  678. */
  679. Subscriber.prototype.next = function (value) {
  680. if (!this.isStopped) {
  681. this._next(value);
  682. }
  683. };
  684. /**
  685. * The {@link Observer} callback to receive notifications of type `error` from
  686. * the Observable, with an attached {@link Error}. Notifies the Observer that
  687. * the Observable has experienced an error condition.
  688. * @param {any} [err] The `error` exception.
  689. * @return {void}
  690. */
  691. Subscriber.prototype.error = function (err) {
  692. if (!this.isStopped) {
  693. this.isStopped = true;
  694. this._error(err);
  695. }
  696. };
  697. /**
  698. * The {@link Observer} callback to receive a valueless notification of type
  699. * `complete` from the Observable. Notifies the Observer that the Observable
  700. * has finished sending push-based notifications.
  701. * @return {void}
  702. */
  703. Subscriber.prototype.complete = function () {
  704. if (!this.isStopped) {
  705. this.isStopped = true;
  706. this._complete();
  707. }
  708. };
  709. Subscriber.prototype.unsubscribe = function () {
  710. if (this.closed) {
  711. return;
  712. }
  713. this.isStopped = true;
  714. _super.prototype.unsubscribe.call(this);
  715. };
  716. Subscriber.prototype._next = function (value) {
  717. this.destination.next(value);
  718. };
  719. Subscriber.prototype._error = function (err) {
  720. this.destination.error(err);
  721. this.unsubscribe();
  722. };
  723. Subscriber.prototype._complete = function () {
  724. this.destination.complete();
  725. this.unsubscribe();
  726. };
  727. Subscriber.prototype._unsubscribeAndRecycle = function () {
  728. var _a = this, _parent = _a._parent, _parents = _a._parents;
  729. this._parent = null;
  730. this._parents = null;
  731. this.unsubscribe();
  732. this.closed = false;
  733. this.isStopped = false;
  734. this._parent = _parent;
  735. this._parents = _parents;
  736. return this;
  737. };
  738. return Subscriber;
  739. }(Subscription_1.Subscription));
  740. exports.Subscriber = Subscriber;
  741. /**
  742. * We need this JSDoc comment for affecting ESDoc.
  743. * @ignore
  744. * @extends {Ignored}
  745. */
  746. var SafeSubscriber = (function (_super) {
  747. __extends(SafeSubscriber, _super);
  748. function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
  749. _super.call(this);
  750. this._parentSubscriber = _parentSubscriber;
  751. var next;
  752. var context = this;
  753. if (isFunction_1.isFunction(observerOrNext)) {
  754. next = observerOrNext;
  755. }
  756. else if (observerOrNext) {
  757. next = observerOrNext.next;
  758. error = observerOrNext.error;
  759. complete = observerOrNext.complete;
  760. if (observerOrNext !== Observer_1.empty) {
  761. context = Object.create(observerOrNext);
  762. if (isFunction_1.isFunction(context.unsubscribe)) {
  763. this.add(context.unsubscribe.bind(context));
  764. }
  765. context.unsubscribe = this.unsubscribe.bind(this);
  766. }
  767. }
  768. this._context = context;
  769. this._next = next;
  770. this._error = error;
  771. this._complete = complete;
  772. }
  773. SafeSubscriber.prototype.next = function (value) {
  774. if (!this.isStopped && this._next) {
  775. var _parentSubscriber = this._parentSubscriber;
  776. if (!_parentSubscriber.syncErrorThrowable) {
  777. this.__tryOrUnsub(this._next, value);
  778. }
  779. else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
  780. this.unsubscribe();
  781. }
  782. }
  783. };
  784. SafeSubscriber.prototype.error = function (err) {
  785. if (!this.isStopped) {
  786. var _parentSubscriber = this._parentSubscriber;
  787. if (this._error) {
  788. if (!_parentSubscriber.syncErrorThrowable) {
  789. this.__tryOrUnsub(this._error, err);
  790. this.unsubscribe();
  791. }
  792. else {
  793. this.__tryOrSetError(_parentSubscriber, this._error, err);
  794. this.unsubscribe();
  795. }
  796. }
  797. else if (!_parentSubscriber.syncErrorThrowable) {
  798. this.unsubscribe();
  799. throw err;
  800. }
  801. else {
  802. _parentSubscriber.syncErrorValue = err;
  803. _parentSubscriber.syncErrorThrown = true;
  804. this.unsubscribe();
  805. }
  806. }
  807. };
  808. SafeSubscriber.prototype.complete = function () {
  809. var _this = this;
  810. if (!this.isStopped) {
  811. var _parentSubscriber = this._parentSubscriber;
  812. if (this._complete) {
  813. var wrappedComplete = function () { return _this._complete.call(_this._context); };
  814. if (!_parentSubscriber.syncErrorThrowable) {
  815. this.__tryOrUnsub(wrappedComplete);
  816. this.unsubscribe();
  817. }
  818. else {
  819. this.__tryOrSetError(_parentSubscriber, wrappedComplete);
  820. this.unsubscribe();
  821. }
  822. }
  823. else {
  824. this.unsubscribe();
  825. }
  826. }
  827. };
  828. SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
  829. try {
  830. fn.call(this._context, value);
  831. }
  832. catch (err) {
  833. this.unsubscribe();
  834. throw err;
  835. }
  836. };
  837. SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
  838. try {
  839. fn.call(this._context, value);
  840. }
  841. catch (err) {
  842. parent.syncErrorValue = err;
  843. parent.syncErrorThrown = true;
  844. return true;
  845. }
  846. return false;
  847. };
  848. SafeSubscriber.prototype._unsubscribe = function () {
  849. var _parentSubscriber = this._parentSubscriber;
  850. this._context = null;
  851. this._parentSubscriber = null;
  852. _parentSubscriber.unsubscribe();
  853. };
  854. return SafeSubscriber;
  855. }(Subscriber));
  856. //# sourceMappingURL=Subscriber.js.map
  857.  
  858. /***/ }),
  859. /* 3 */
  860. /***/ (function(module, exports, __webpack_require__) {
  861.  
  862. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1) {
  863. "use strict";
  864. Object.defineProperty(exports, "__esModule", { value: true });
  865. var SimpleCache = /** @class */ (function () {
  866. function SimpleCache() {
  867. }
  868. SimpleCache.GetAndCache = function (cacheKey, getterPromise, expiresAt) {
  869. return tslib_1.__awaiter(this, void 0, void 0, function () {
  870. var cachedItem, result;
  871. return tslib_1.__generator(this, function (_a) {
  872. switch (_a.label) {
  873. case 0:
  874. cachedItem = SimpleCache.GetFromCache(cacheKey);
  875. if (cachedItem !== undefined) {
  876. return [2 /*return*/, cachedItem];
  877. }
  878. return [4 /*yield*/, getterPromise()];
  879. case 1:
  880. result = _a.sent();
  881. SimpleCache.StoreInCache(cacheKey, result, expiresAt);
  882. return [2 /*return*/, result];
  883. }
  884. });
  885. });
  886. };
  887. SimpleCache.ClearCache = function () {
  888. localStorage.clear();
  889. };
  890. SimpleCache.ClearExpiredKeys = function (regex) {
  891. var len = localStorage.length;
  892. for (var i = len - 1; i >= 0; i--) {
  893. var key = localStorage.key(i);
  894. if (key) {
  895. if (!regex || key.match(regex)) {
  896. var jsonItem = localStorage.getItem(key);
  897. if (jsonItem) {
  898. try {
  899. var dataItem = JSON.parse(jsonItem);
  900. if ((dataItem.Expires && new Date(dataItem.Expires) < new Date())) {
  901. localStorage.removeItem(key);
  902. }
  903. }
  904. catch (_a) {
  905. // Don't care
  906. }
  907. }
  908. }
  909. }
  910. }
  911. };
  912. SimpleCache.ClearAll = function (regex, condition) {
  913. var len = localStorage.length;
  914. for (var i = len - 1; i >= 0; i--) {
  915. var key = localStorage.key(i);
  916. if (key) {
  917. if (key.match(regex)) {
  918. if (condition) {
  919. var val = localStorage.getItem(key);
  920. if (condition(val)) {
  921. localStorage.removeItem(key);
  922. }
  923. }
  924. else {
  925. localStorage.removeItem(key);
  926. }
  927. }
  928. }
  929. }
  930. };
  931. SimpleCache.GetFromCache = function (cacheKey) {
  932. var jsonItem = localStorage.getItem(cacheKey);
  933. if (!jsonItem) {
  934. return undefined;
  935. }
  936. var dataItem = JSON.parse(jsonItem);
  937. if ((dataItem.Expires && new Date(dataItem.Expires) < new Date())) {
  938. return undefined;
  939. }
  940. return dataItem.Data;
  941. };
  942. SimpleCache.StoreInCache = function (cacheKey, item, expiresAt) {
  943. var jsonStr = JSON.stringify({ Expires: expiresAt, Data: item });
  944. localStorage.setItem(cacheKey, jsonStr);
  945. };
  946. SimpleCache.Unset = function (cacheKey) {
  947. localStorage.removeItem(cacheKey);
  948. };
  949. return SimpleCache;
  950. }());
  951. exports.SimpleCache = SimpleCache;
  952. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  953. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  954.  
  955.  
  956. /***/ }),
  957. /* 4 */
  958. /***/ (function(module, exports, __webpack_require__) {
  959.  
  960. "use strict";
  961.  
  962. var isArray_1 = __webpack_require__(24);
  963. var isObject_1 = __webpack_require__(25);
  964. var isFunction_1 = __webpack_require__(13);
  965. var tryCatch_1 = __webpack_require__(26);
  966. var errorObject_1 = __webpack_require__(14);
  967. var UnsubscriptionError_1 = __webpack_require__(27);
  968. /**
  969. * Represents a disposable resource, such as the execution of an Observable. A
  970. * Subscription has one important method, `unsubscribe`, that takes no argument
  971. * and just disposes the resource held by the subscription.
  972. *
  973. * Additionally, subscriptions may be grouped together through the `add()`
  974. * method, which will attach a child Subscription to the current Subscription.
  975. * When a Subscription is unsubscribed, all its children (and its grandchildren)
  976. * will be unsubscribed as well.
  977. *
  978. * @class Subscription
  979. */
  980. var Subscription = (function () {
  981. /**
  982. * @param {function(): void} [unsubscribe] A function describing how to
  983. * perform the disposal of resources when the `unsubscribe` method is called.
  984. */
  985. function Subscription(unsubscribe) {
  986. /**
  987. * A flag to indicate whether this Subscription has already been unsubscribed.
  988. * @type {boolean}
  989. */
  990. this.closed = false;
  991. this._parent = null;
  992. this._parents = null;
  993. this._subscriptions = null;
  994. if (unsubscribe) {
  995. this._unsubscribe = unsubscribe;
  996. }
  997. }
  998. /**
  999. * Disposes the resources held by the subscription. May, for instance, cancel
  1000. * an ongoing Observable execution or cancel any other type of work that
  1001. * started when the Subscription was created.
  1002. * @return {void}
  1003. */
  1004. Subscription.prototype.unsubscribe = function () {
  1005. var hasErrors = false;
  1006. var errors;
  1007. if (this.closed) {
  1008. return;
  1009. }
  1010. var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
  1011. this.closed = true;
  1012. this._parent = null;
  1013. this._parents = null;
  1014. // null out _subscriptions first so any child subscriptions that attempt
  1015. // to remove themselves from this subscription will noop
  1016. this._subscriptions = null;
  1017. var index = -1;
  1018. var len = _parents ? _parents.length : 0;
  1019. // if this._parent is null, then so is this._parents, and we
  1020. // don't have to remove ourselves from any parent subscriptions.
  1021. while (_parent) {
  1022. _parent.remove(this);
  1023. // if this._parents is null or index >= len,
  1024. // then _parent is set to null, and the loop exits
  1025. _parent = ++index < len && _parents[index] || null;
  1026. }
  1027. if (isFunction_1.isFunction(_unsubscribe)) {
  1028. var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
  1029. if (trial === errorObject_1.errorObject) {
  1030. hasErrors = true;
  1031. errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
  1032. flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]);
  1033. }
  1034. }
  1035. if (isArray_1.isArray(_subscriptions)) {
  1036. index = -1;
  1037. len = _subscriptions.length;
  1038. while (++index < len) {
  1039. var sub = _subscriptions[index];
  1040. if (isObject_1.isObject(sub)) {
  1041. var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
  1042. if (trial === errorObject_1.errorObject) {
  1043. hasErrors = true;
  1044. errors = errors || [];
  1045. var err = errorObject_1.errorObject.e;
  1046. if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
  1047. errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
  1048. }
  1049. else {
  1050. errors.push(err);
  1051. }
  1052. }
  1053. }
  1054. }
  1055. }
  1056. if (hasErrors) {
  1057. throw new UnsubscriptionError_1.UnsubscriptionError(errors);
  1058. }
  1059. };
  1060. /**
  1061. * Adds a tear down to be called during the unsubscribe() of this
  1062. * Subscription.
  1063. *
  1064. * If the tear down being added is a subscription that is already
  1065. * unsubscribed, is the same reference `add` is being called on, or is
  1066. * `Subscription.EMPTY`, it will not be added.
  1067. *
  1068. * If this subscription is already in an `closed` state, the passed
  1069. * tear down logic will be executed immediately.
  1070. *
  1071. * @param {TeardownLogic} teardown The additional logic to execute on
  1072. * teardown.
  1073. * @return {Subscription} Returns the Subscription used or created to be
  1074. * added to the inner subscriptions list. This Subscription can be used with
  1075. * `remove()` to remove the passed teardown logic from the inner subscriptions
  1076. * list.
  1077. */
  1078. Subscription.prototype.add = function (teardown) {
  1079. if (!teardown || (teardown === Subscription.EMPTY)) {
  1080. return Subscription.EMPTY;
  1081. }
  1082. if (teardown === this) {
  1083. return this;
  1084. }
  1085. var subscription = teardown;
  1086. switch (typeof teardown) {
  1087. case 'function':
  1088. subscription = new Subscription(teardown);
  1089. case 'object':
  1090. if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
  1091. return subscription;
  1092. }
  1093. else if (this.closed) {
  1094. subscription.unsubscribe();
  1095. return subscription;
  1096. }
  1097. else if (typeof subscription._addParent !== 'function' /* quack quack */) {
  1098. var tmp = subscription;
  1099. subscription = new Subscription();
  1100. subscription._subscriptions = [tmp];
  1101. }
  1102. break;
  1103. default:
  1104. throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
  1105. }
  1106. var subscriptions = this._subscriptions || (this._subscriptions = []);
  1107. subscriptions.push(subscription);
  1108. subscription._addParent(this);
  1109. return subscription;
  1110. };
  1111. /**
  1112. * Removes a Subscription from the internal list of subscriptions that will
  1113. * unsubscribe during the unsubscribe process of this Subscription.
  1114. * @param {Subscription} subscription The subscription to remove.
  1115. * @return {void}
  1116. */
  1117. Subscription.prototype.remove = function (subscription) {
  1118. var subscriptions = this._subscriptions;
  1119. if (subscriptions) {
  1120. var subscriptionIndex = subscriptions.indexOf(subscription);
  1121. if (subscriptionIndex !== -1) {
  1122. subscriptions.splice(subscriptionIndex, 1);
  1123. }
  1124. }
  1125. };
  1126. Subscription.prototype._addParent = function (parent) {
  1127. var _a = this, _parent = _a._parent, _parents = _a._parents;
  1128. if (!_parent || _parent === parent) {
  1129. // If we don't have a parent, or the new parent is the same as the
  1130. // current parent, then set this._parent to the new parent.
  1131. this._parent = parent;
  1132. }
  1133. else if (!_parents) {
  1134. // If there's already one parent, but not multiple, allocate an Array to
  1135. // store the rest of the parent Subscriptions.
  1136. this._parents = [parent];
  1137. }
  1138. else if (_parents.indexOf(parent) === -1) {
  1139. // Only add the new parent to the _parents list if it's not already there.
  1140. _parents.push(parent);
  1141. }
  1142. };
  1143. Subscription.EMPTY = (function (empty) {
  1144. empty.closed = true;
  1145. return empty;
  1146. }(new Subscription()));
  1147. return Subscription;
  1148. }());
  1149. exports.Subscription = Subscription;
  1150. function flattenUnsubscriptionErrors(errors) {
  1151. return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
  1152. }
  1153. //# sourceMappingURL=Subscription.js.map
  1154.  
  1155. /***/ }),
  1156. /* 5 */
  1157. /***/ (function(module, exports, __webpack_require__) {
  1158.  
  1159. "use strict";
  1160.  
  1161. var __extends = (this && this.__extends) || function (d, b) {
  1162. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1163. function __() { this.constructor = d; }
  1164. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1165. };
  1166. var Observable_1 = __webpack_require__(1);
  1167. var Subscriber_1 = __webpack_require__(2);
  1168. var Subscription_1 = __webpack_require__(4);
  1169. var ObjectUnsubscribedError_1 = __webpack_require__(16);
  1170. var SubjectSubscription_1 = __webpack_require__(17);
  1171. var rxSubscriber_1 = __webpack_require__(8);
  1172. /**
  1173. * @class SubjectSubscriber<T>
  1174. */
  1175. var SubjectSubscriber = (function (_super) {
  1176. __extends(SubjectSubscriber, _super);
  1177. function SubjectSubscriber(destination) {
  1178. _super.call(this, destination);
  1179. this.destination = destination;
  1180. }
  1181. return SubjectSubscriber;
  1182. }(Subscriber_1.Subscriber));
  1183. exports.SubjectSubscriber = SubjectSubscriber;
  1184. /**
  1185. * @class Subject<T>
  1186. */
  1187. var Subject = (function (_super) {
  1188. __extends(Subject, _super);
  1189. function Subject() {
  1190. _super.call(this);
  1191. this.observers = [];
  1192. this.closed = false;
  1193. this.isStopped = false;
  1194. this.hasError = false;
  1195. this.thrownError = null;
  1196. }
  1197. Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
  1198. return new SubjectSubscriber(this);
  1199. };
  1200. Subject.prototype.lift = function (operator) {
  1201. var subject = new AnonymousSubject(this, this);
  1202. subject.operator = operator;
  1203. return subject;
  1204. };
  1205. Subject.prototype.next = function (value) {
  1206. if (this.closed) {
  1207. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1208. }
  1209. if (!this.isStopped) {
  1210. var observers = this.observers;
  1211. var len = observers.length;
  1212. var copy = observers.slice();
  1213. for (var i = 0; i < len; i++) {
  1214. copy[i].next(value);
  1215. }
  1216. }
  1217. };
  1218. Subject.prototype.error = function (err) {
  1219. if (this.closed) {
  1220. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1221. }
  1222. this.hasError = true;
  1223. this.thrownError = err;
  1224. this.isStopped = true;
  1225. var observers = this.observers;
  1226. var len = observers.length;
  1227. var copy = observers.slice();
  1228. for (var i = 0; i < len; i++) {
  1229. copy[i].error(err);
  1230. }
  1231. this.observers.length = 0;
  1232. };
  1233. Subject.prototype.complete = function () {
  1234. if (this.closed) {
  1235. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1236. }
  1237. this.isStopped = true;
  1238. var observers = this.observers;
  1239. var len = observers.length;
  1240. var copy = observers.slice();
  1241. for (var i = 0; i < len; i++) {
  1242. copy[i].complete();
  1243. }
  1244. this.observers.length = 0;
  1245. };
  1246. Subject.prototype.unsubscribe = function () {
  1247. this.isStopped = true;
  1248. this.closed = true;
  1249. this.observers = null;
  1250. };
  1251. Subject.prototype._trySubscribe = function (subscriber) {
  1252. if (this.closed) {
  1253. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1254. }
  1255. else {
  1256. return _super.prototype._trySubscribe.call(this, subscriber);
  1257. }
  1258. };
  1259. Subject.prototype._subscribe = function (subscriber) {
  1260. if (this.closed) {
  1261. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1262. }
  1263. else if (this.hasError) {
  1264. subscriber.error(this.thrownError);
  1265. return Subscription_1.Subscription.EMPTY;
  1266. }
  1267. else if (this.isStopped) {
  1268. subscriber.complete();
  1269. return Subscription_1.Subscription.EMPTY;
  1270. }
  1271. else {
  1272. this.observers.push(subscriber);
  1273. return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
  1274. }
  1275. };
  1276. Subject.prototype.asObservable = function () {
  1277. var observable = new Observable_1.Observable();
  1278. observable.source = this;
  1279. return observable;
  1280. };
  1281. Subject.create = function (destination, source) {
  1282. return new AnonymousSubject(destination, source);
  1283. };
  1284. return Subject;
  1285. }(Observable_1.Observable));
  1286. exports.Subject = Subject;
  1287. /**
  1288. * @class AnonymousSubject<T>
  1289. */
  1290. var AnonymousSubject = (function (_super) {
  1291. __extends(AnonymousSubject, _super);
  1292. function AnonymousSubject(destination, source) {
  1293. _super.call(this);
  1294. this.destination = destination;
  1295. this.source = source;
  1296. }
  1297. AnonymousSubject.prototype.next = function (value) {
  1298. var destination = this.destination;
  1299. if (destination && destination.next) {
  1300. destination.next(value);
  1301. }
  1302. };
  1303. AnonymousSubject.prototype.error = function (err) {
  1304. var destination = this.destination;
  1305. if (destination && destination.error) {
  1306. this.destination.error(err);
  1307. }
  1308. };
  1309. AnonymousSubject.prototype.complete = function () {
  1310. var destination = this.destination;
  1311. if (destination && destination.complete) {
  1312. this.destination.complete();
  1313. }
  1314. };
  1315. AnonymousSubject.prototype._subscribe = function (subscriber) {
  1316. var source = this.source;
  1317. if (source) {
  1318. return this.source.subscribe(subscriber);
  1319. }
  1320. else {
  1321. return Subscription_1.Subscription.EMPTY;
  1322. }
  1323. };
  1324. return AnonymousSubject;
  1325. }(Subject));
  1326. exports.AnonymousSubject = AnonymousSubject;
  1327. //# sourceMappingURL=Subject.js.map
  1328.  
  1329. /***/ }),
  1330. /* 6 */
  1331. /***/ (function(module, exports, __webpack_require__) {
  1332.  
  1333. "use strict";
  1334.  
  1335. // CommonJS / Node have global context exposed as "global" variable.
  1336. // We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
  1337. // the global "global" var for now.
  1338. var __window = typeof window !== 'undefined' && window;
  1339. var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
  1340. self instanceof WorkerGlobalScope && self;
  1341. var __global = typeof global !== 'undefined' && global;
  1342. var _root = __window || __global || __self;
  1343. exports.root = _root;
  1344. // Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
  1345. // This is needed when used with angular/tsickle which inserts a goog.module statement.
  1346. // Wrap in IIFE
  1347. (function () {
  1348. if (!_root) {
  1349. throw new Error('RxJS could not find any global context (window, self, global)');
  1350. }
  1351. })();
  1352. //# sourceMappingURL=root.js.map
  1353.  
  1354. /***/ }),
  1355. /* 7 */
  1356. /***/ (function(module, exports, __webpack_require__) {
  1357.  
  1358. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) {
  1359. "use strict";
  1360. Object.defineProperty(exports, "__esModule", { value: true });
  1361. $.event.special.destroyed = {
  1362. remove: function (o) {
  1363. if (o.handler) {
  1364. o.handler();
  1365. }
  1366. }
  1367. };
  1368. function IsStackOverflow() {
  1369. return !!window.location.href.match(/^https:\/\/stackoverflow.com/);
  1370. }
  1371. exports.IsStackOverflow = IsStackOverflow;
  1372. function isNatoPage() {
  1373. return !!window.location.href.match(/\/tools\/new-answers-old-questions/);
  1374. }
  1375. exports.isNatoPage = isNatoPage;
  1376. function parseNatoPage(callback) {
  1377. var nodes = $('.answer-hyperlink').parent().parent();
  1378. for (var i = 0; i < nodes.length; i++) {
  1379. var node = $(nodes[i]);
  1380. var postId = parseInt(node.find('.answer-hyperlink').attr('href').split('#')[1], 10);
  1381. var answerTime = parseActionDate(node.find('.user-action-time'));
  1382. var questionTime = parseActionDate(node.find('td .relativetime'));
  1383. var authorReputation = parseReputation(node.find('.reputation-score'));
  1384. var _a = parseAuthorDetails(node.find('.user-details')), authorName = _a.authorName, authorId = _a.authorId;
  1385. callback({
  1386. type: 'Answer',
  1387. element: node,
  1388. page: 'NATO',
  1389. postId: postId,
  1390. answerTime: answerTime,
  1391. questionTime: questionTime,
  1392. authorReputation: authorReputation,
  1393. authorName: authorName,
  1394. authorId: authorId,
  1395. });
  1396. }
  1397. }
  1398. function isQuestionPage() {
  1399. return !!window.location.href.match(/\/questions\/\d+.*/);
  1400. }
  1401. exports.isQuestionPage = isQuestionPage;
  1402. function parseQuestionPage(callback) {
  1403. function getPostDetails(node) {
  1404. var score = parseInt(node.find('.vote-count-post').text(), 10);
  1405. var authorReputation = parseReputation(node.find('.post-signature .reputation-score').last());
  1406. var _a = parseAuthorDetails(node.find('.post-signature .user-details').last()), authorName = _a.authorName, authorId = _a.authorId;
  1407. var postTime = parseActionDate(node.find('.post-signature .relativetime').last());
  1408. return { score: score, authorReputation: authorReputation, authorName: authorName, authorId: authorId, postTime: postTime };
  1409. }
  1410. var question;
  1411. var parseQuestionDetails = function (qNode) {
  1412. var postId = parseInt(qNode.attr('data-questionid'), 10);
  1413. var postDetails = getPostDetails(qNode);
  1414. qNode.find('.postcell').bind('destroyed', function () {
  1415. setTimeout(function () {
  1416. var updatedQuestionNode = $("[data-questionid=\"" + postId + "\"]");
  1417. parseQuestionDetails(updatedQuestionNode);
  1418. });
  1419. });
  1420. question = {
  1421. type: 'Question',
  1422. element: qNode,
  1423. page: 'Question',
  1424. postId: postId,
  1425. postTime: postDetails.postTime,
  1426. score: postDetails.score,
  1427. authorReputation: postDetails.authorReputation,
  1428. authorName: postDetails.authorName,
  1429. authorId: postDetails.authorId
  1430. };
  1431. callback(question);
  1432. };
  1433. var questionNode = $('.question');
  1434. parseQuestionDetails(questionNode);
  1435. var answerNodes = $('.answer');
  1436. var _loop_1 = function (i) {
  1437. var parseAnswerDetails = function (aNode) {
  1438. var answerId = parseInt(aNode.attr('data-answerid'), 10);
  1439. var postDetails = getPostDetails(aNode);
  1440. aNode.find('.answercell').bind('destroyed', function () {
  1441. setTimeout(function () {
  1442. var updatedAnswerNode = $("#answer-" + answerId);
  1443. parseAnswerDetails(updatedAnswerNode);
  1444. });
  1445. });
  1446. callback({
  1447. type: 'Answer',
  1448. element: aNode,
  1449. page: 'Question',
  1450. postId: answerId,
  1451. question: question,
  1452. postTime: postDetails.postTime,
  1453. score: postDetails.score,
  1454. authorReputation: postDetails.authorReputation,
  1455. authorName: postDetails.authorName,
  1456. authorId: postDetails.authorId
  1457. });
  1458. };
  1459. var answerNode = $(answerNodes[i]);
  1460. parseAnswerDetails(answerNode);
  1461. };
  1462. for (var i = 0; i < answerNodes.length; i++) {
  1463. _loop_1(i);
  1464. }
  1465. }
  1466. function isFlagsPage() {
  1467. return !!window.location.href.match(/\/users\/flag-summary\//);
  1468. }
  1469. exports.isFlagsPage = isFlagsPage;
  1470. function parseFlagsPage(callback) {
  1471. var nodes = $('.flagged-post');
  1472. for (var i = 0; i < nodes.length; i++) {
  1473. var node = $(nodes[i]);
  1474. var type = node.find('.answer-hyperlink').length
  1475. ? 'Answer'
  1476. : 'Question';
  1477. var postId = parseInt(type === 'Answer'
  1478. ? node.find('.answer-hyperlink').attr('href').split('#')[1]
  1479. : node.find('.question-hyperlink').attr('href').split('/')[2], 10);
  1480. var score = parseInt(node.find('.answer-votes').text(), 10);
  1481. var _a = parseAuthorDetails(node.find('.post-user-info')), authorName = _a.authorName, authorId = _a.authorId;
  1482. var postTime = parseActionDate(node.find('.post-user-info .relativetime'));
  1483. var handledTime = parseActionDate(node.find('.mod-flag .relativetime'));
  1484. var fullHandledResult = node.find('.flag-outcome').text().trim().split(' - ');
  1485. var handledResult = fullHandledResult[0].trim();
  1486. var handledComment = fullHandledResult.slice(1).join(' - ').trim();
  1487. callback({
  1488. type: type,
  1489. element: node,
  1490. page: 'Flags',
  1491. postId: postId,
  1492. score: score,
  1493. postTime: postTime,
  1494. handledTime: handledTime,
  1495. handledResult: handledResult,
  1496. handledComment: handledComment,
  1497. authorName: authorName,
  1498. authorId: authorId
  1499. });
  1500. }
  1501. }
  1502. function parseGenericPage(callback) {
  1503. var questionNodes = $('.question-hyperlink');
  1504. for (var i = 0; i < questionNodes.length; i++) {
  1505. var questionNode = $(questionNodes[i]);
  1506. var fragment = questionNode.attr('href').split('/')[2];
  1507. if (fragment.indexOf('_') >= 0) {
  1508. fragment = fragment.split('_')[1];
  1509. }
  1510. var postId = parseInt(fragment, 10);
  1511. callback({
  1512. type: 'Question',
  1513. element: questionNode,
  1514. page: 'Unknown',
  1515. postId: postId
  1516. });
  1517. }
  1518. var answerNodes = $('.answer-hyperlink');
  1519. for (var i = 0; i < answerNodes.length; i++) {
  1520. var answerNode = $(answerNodes[i]);
  1521. var fragment = answerNode.attr('href').split('#')[1];
  1522. if (fragment.indexOf('_') >= 0) {
  1523. fragment = fragment.split('_')[1];
  1524. }
  1525. var postId = parseInt(fragment, 10);
  1526. callback({
  1527. type: 'Answer',
  1528. element: answerNode,
  1529. page: 'Unknown',
  1530. postId: postId
  1531. });
  1532. }
  1533. }
  1534. function parseQuestionsAndAnswers(callback) {
  1535. if (isNatoPage()) {
  1536. parseNatoPage(callback);
  1537. return;
  1538. }
  1539. if (isQuestionPage()) {
  1540. parseQuestionPage(callback);
  1541. return;
  1542. }
  1543. if (isFlagsPage()) {
  1544. parseFlagsPage(callback);
  1545. return;
  1546. }
  1547. parseGenericPage(callback);
  1548. }
  1549. exports.parseQuestionsAndAnswers = parseQuestionsAndAnswers;
  1550. function parseReputation(reputationDiv) {
  1551. var reputationText = reputationDiv.text();
  1552. if (reputationText.indexOf('k') !== -1) {
  1553. reputationText = reputationDiv.attr('title').substr('reputation score '.length);
  1554. }
  1555. reputationText = reputationText.replace(',', '');
  1556. if (reputationText.trim() !== '') {
  1557. return parseInt(reputationText, 10);
  1558. }
  1559. return undefined;
  1560. }
  1561. function parseAuthorDetails(authorDiv) {
  1562. var userLink = authorDiv.find('a');
  1563. var authorName = userLink.text();
  1564. var userLinkRef = userLink.attr('href');
  1565. var authorId;
  1566. // Users can be deleted, and thus have no link to their profile.
  1567. if (userLinkRef) {
  1568. authorId = parseInt(userLinkRef.split('/')[2], 10);
  1569. }
  1570. return { authorName: authorName, authorId: authorId };
  1571. }
  1572. function parseActionDate(actionDiv) {
  1573. if (!actionDiv.hasClass('relativetime')) {
  1574. actionDiv = actionDiv.find('.relativetime');
  1575. }
  1576. var answerTime = parseDate(actionDiv.attr('title'));
  1577. return answerTime;
  1578. }
  1579. function parseDate(dateStr) {
  1580. // Fix for safari
  1581. return new Date(dateStr.replace(' ', 'T'));
  1582. }
  1583. exports.parseDate = parseDate;
  1584. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  1585. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1586.  
  1587.  
  1588. /***/ }),
  1589. /* 8 */
  1590. /***/ (function(module, exports, __webpack_require__) {
  1591.  
  1592. "use strict";
  1593.  
  1594. var root_1 = __webpack_require__(6);
  1595. var Symbol = root_1.root.Symbol;
  1596. exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
  1597. Symbol.for('rxSubscriber') : '@@rxSubscriber';
  1598. /**
  1599. * @deprecated use rxSubscriber instead
  1600. */
  1601. exports.$$rxSubscriber = exports.rxSubscriber;
  1602. //# sourceMappingURL=rxSubscriber.js.map
  1603.  
  1604. /***/ }),
  1605. /* 9 */
  1606. /***/ (function(module, exports, __webpack_require__) {
  1607.  
  1608. "use strict";
  1609.  
  1610. var __extends = (this && this.__extends) || function (d, b) {
  1611. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1612. function __() { this.constructor = d; }
  1613. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1614. };
  1615. var Subject_1 = __webpack_require__(5);
  1616. var queue_1 = __webpack_require__(31);
  1617. var Subscription_1 = __webpack_require__(4);
  1618. var observeOn_1 = __webpack_require__(38);
  1619. var ObjectUnsubscribedError_1 = __webpack_require__(16);
  1620. var SubjectSubscription_1 = __webpack_require__(17);
  1621. /**
  1622. * @class ReplaySubject<T>
  1623. */
  1624. var ReplaySubject = (function (_super) {
  1625. __extends(ReplaySubject, _super);
  1626. function ReplaySubject(bufferSize, windowTime, scheduler) {
  1627. if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
  1628. if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
  1629. _super.call(this);
  1630. this.scheduler = scheduler;
  1631. this._events = [];
  1632. this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
  1633. this._windowTime = windowTime < 1 ? 1 : windowTime;
  1634. }
  1635. ReplaySubject.prototype.next = function (value) {
  1636. var now = this._getNow();
  1637. this._events.push(new ReplayEvent(now, value));
  1638. this._trimBufferThenGetEvents();
  1639. _super.prototype.next.call(this, value);
  1640. };
  1641. ReplaySubject.prototype._subscribe = function (subscriber) {
  1642. var _events = this._trimBufferThenGetEvents();
  1643. var scheduler = this.scheduler;
  1644. var subscription;
  1645. if (this.closed) {
  1646. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1647. }
  1648. else if (this.hasError) {
  1649. subscription = Subscription_1.Subscription.EMPTY;
  1650. }
  1651. else if (this.isStopped) {
  1652. subscription = Subscription_1.Subscription.EMPTY;
  1653. }
  1654. else {
  1655. this.observers.push(subscriber);
  1656. subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber);
  1657. }
  1658. if (scheduler) {
  1659. subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler));
  1660. }
  1661. var len = _events.length;
  1662. for (var i = 0; i < len && !subscriber.closed; i++) {
  1663. subscriber.next(_events[i].value);
  1664. }
  1665. if (this.hasError) {
  1666. subscriber.error(this.thrownError);
  1667. }
  1668. else if (this.isStopped) {
  1669. subscriber.complete();
  1670. }
  1671. return subscription;
  1672. };
  1673. ReplaySubject.prototype._getNow = function () {
  1674. return (this.scheduler || queue_1.queue).now();
  1675. };
  1676. ReplaySubject.prototype._trimBufferThenGetEvents = function () {
  1677. var now = this._getNow();
  1678. var _bufferSize = this._bufferSize;
  1679. var _windowTime = this._windowTime;
  1680. var _events = this._events;
  1681. var eventsCount = _events.length;
  1682. var spliceCount = 0;
  1683. // Trim events that fall out of the time window.
  1684. // Start at the front of the list. Break early once
  1685. // we encounter an event that falls within the window.
  1686. while (spliceCount < eventsCount) {
  1687. if ((now - _events[spliceCount].time) < _windowTime) {
  1688. break;
  1689. }
  1690. spliceCount++;
  1691. }
  1692. if (eventsCount > _bufferSize) {
  1693. spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
  1694. }
  1695. if (spliceCount > 0) {
  1696. _events.splice(0, spliceCount);
  1697. }
  1698. return _events;
  1699. };
  1700. return ReplaySubject;
  1701. }(Subject_1.Subject));
  1702. exports.ReplaySubject = ReplaySubject;
  1703. var ReplayEvent = (function () {
  1704. function ReplayEvent(time, value) {
  1705. this.time = time;
  1706. this.value = value;
  1707. }
  1708. return ReplayEvent;
  1709. }());
  1710. //# sourceMappingURL=ReplaySubject.js.map
  1711.  
  1712. /***/ }),
  1713. /* 10 */
  1714. /***/ (function(module, exports, __webpack_require__) {
  1715.  
  1716. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(44)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, xdLocalStorage_1) {
  1717. "use strict";
  1718. Object.defineProperty(exports, "__esModule", { value: true });
  1719. var CrossDomainCache = /** @class */ (function () {
  1720. function CrossDomainCache() {
  1721. }
  1722. CrossDomainCache.InitializeCache = function (iframeUrl) {
  1723. var _this = this;
  1724. CrossDomainCache.xdLocalStorageInitialized = new Promise(function (resolve, reject) {
  1725. try {
  1726. xdLocalStorage_1.XdLocalStorage.init({
  1727. iframeUrl: iframeUrl,
  1728. initCallback: function () {
  1729. _this.cacheFailed = false;
  1730. resolve();
  1731. }
  1732. });
  1733. }
  1734. catch (e) {
  1735. _this.cacheFailed = true;
  1736. resolve();
  1737. }
  1738. });
  1739. };
  1740. CrossDomainCache.GetAndCache = function (cacheKey, getterPromise, expiresAt) {
  1741. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1742. var cachedItem, result;
  1743. return tslib_1.__generator(this, function (_a) {
  1744. switch (_a.label) {
  1745. case 0: return [4 /*yield*/, this.GetFromCache(cacheKey)];
  1746. case 1:
  1747. cachedItem = _a.sent();
  1748. if (cachedItem !== undefined) {
  1749. return [2 /*return*/, cachedItem];
  1750. }
  1751. return [4 /*yield*/, getterPromise()];
  1752. case 2:
  1753. result = _a.sent();
  1754. this.StoreInCache(cacheKey, result, expiresAt);
  1755. return [2 /*return*/, result];
  1756. }
  1757. });
  1758. });
  1759. };
  1760. CrossDomainCache.ClearCache = function () {
  1761. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1762. return tslib_1.__generator(this, function (_a) {
  1763. switch (_a.label) {
  1764. case 0: return [4 /*yield*/, CrossDomainCache.AwaitInitialization()];
  1765. case 1:
  1766. _a.sent();
  1767. return [4 /*yield*/, CrossDomainCache.CacheFailed()];
  1768. case 2:
  1769. if (_a.sent()) {
  1770. return [2 /*return*/];
  1771. }
  1772. xdLocalStorage_1.XdLocalStorage.clear();
  1773. return [2 /*return*/];
  1774. }
  1775. });
  1776. });
  1777. };
  1778. CrossDomainCache.GetFromCache = function (cacheKey) {
  1779. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1780. return tslib_1.__generator(this, function (_a) {
  1781. switch (_a.label) {
  1782. case 0: return [4 /*yield*/, CrossDomainCache.AwaitInitialization()];
  1783. case 1:
  1784. _a.sent();
  1785. return [4 /*yield*/, CrossDomainCache.CacheFailed()];
  1786. case 2:
  1787. if (_a.sent()) {
  1788. return [2 /*return*/, undefined];
  1789. }
  1790. return [2 /*return*/, new Promise(function (resolve, reject) {
  1791. xdLocalStorage_1.XdLocalStorage.getItem(cacheKey, function (data) {
  1792. if (data.value === undefined) {
  1793. resolve();
  1794. }
  1795. var actualItem = JSON.parse(data.value);
  1796. if (actualItem === null || actualItem.Expires && new Date(actualItem.Expires) < new Date()) {
  1797. resolve();
  1798. return;
  1799. }
  1800. return resolve(actualItem.Data);
  1801. });
  1802. })];
  1803. }
  1804. });
  1805. });
  1806. };
  1807. CrossDomainCache.StoreInCache = function (cacheKey, item, expiresAt) {
  1808. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1809. var jsonStr;
  1810. return tslib_1.__generator(this, function (_a) {
  1811. switch (_a.label) {
  1812. case 0: return [4 /*yield*/, CrossDomainCache.AwaitInitialization()];
  1813. case 1:
  1814. _a.sent();
  1815. return [4 /*yield*/, CrossDomainCache.CacheFailed()];
  1816. case 2:
  1817. if (_a.sent()) {
  1818. return [2 /*return*/];
  1819. }
  1820. jsonStr = JSON.stringify({ Expires: expiresAt, Data: item });
  1821. return [2 /*return*/, new Promise(function (resolve, reject) {
  1822. xdLocalStorage_1.XdLocalStorage.setItem(cacheKey, jsonStr, function () {
  1823. resolve();
  1824. });
  1825. })];
  1826. }
  1827. });
  1828. });
  1829. };
  1830. CrossDomainCache.Unset = function (cacheKey) {
  1831. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1832. return tslib_1.__generator(this, function (_a) {
  1833. switch (_a.label) {
  1834. case 0: return [4 /*yield*/, CrossDomainCache.AwaitInitialization()];
  1835. case 1:
  1836. _a.sent();
  1837. return [4 /*yield*/, CrossDomainCache.CacheFailed()];
  1838. case 2:
  1839. if (_a.sent()) {
  1840. return [2 /*return*/];
  1841. }
  1842. return [2 /*return*/, new Promise(function (resolve, reject) {
  1843. xdLocalStorage_1.XdLocalStorage.removeItem(cacheKey, function () {
  1844. resolve();
  1845. });
  1846. })];
  1847. }
  1848. });
  1849. });
  1850. };
  1851. CrossDomainCache.CacheFailed = function () {
  1852. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1853. return tslib_1.__generator(this, function (_a) {
  1854. switch (_a.label) {
  1855. case 0: return [4 /*yield*/, CrossDomainCache.AwaitInitialization()];
  1856. case 1:
  1857. _a.sent();
  1858. return [2 /*return*/, this.cacheFailed];
  1859. }
  1860. });
  1861. });
  1862. };
  1863. CrossDomainCache.AwaitInitialization = function () {
  1864. return tslib_1.__awaiter(this, void 0, void 0, function () {
  1865. return tslib_1.__generator(this, function (_a) {
  1866. switch (_a.label) {
  1867. case 0:
  1868. if (CrossDomainCache.xdLocalStorageInitialized === null) {
  1869. throw Error('Cache must be initialized before use');
  1870. }
  1871. return [4 /*yield*/, CrossDomainCache.xdLocalStorageInitialized];
  1872. case 1:
  1873. _a.sent();
  1874. return [2 /*return*/];
  1875. }
  1876. });
  1877. });
  1878. };
  1879. return CrossDomainCache;
  1880. }());
  1881. exports.CrossDomainCache = CrossDomainCache;
  1882. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  1883. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1884.  
  1885.  
  1886. /***/ }),
  1887. /* 11 */
  1888. /***/ (function(module, exports, __webpack_require__) {
  1889.  
  1890. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(12), __webpack_require__(3), __webpack_require__(7), __webpack_require__(22), __webpack_require__(21), __webpack_require__(20), __webpack_require__(10), __webpack_require__(45), __webpack_require__(49), __webpack_require__(53)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, FlagTypes_1, SimpleCache_1, sotools_1, NattyApi_1, GenericBotAPI_1, MetaSmokeAPI_1, CrossDomainCache_1, CopyPastorAPI_1, RequestWatcher_1, Configuration_1) {
  1891. "use strict";
  1892. var _this = this;
  1893. Object.defineProperty(exports, "__esModule", { value: true });
  1894. exports.metaSmokeKey = '0a946b9419b5842f99b052d19c956302aa6c6dd5a420b043b20072ad2efc29e0';
  1895. var copyPastorKey = 'wgixsmuiz8q8px9kyxgwf8l71h7a41uugfh5rkyj';
  1896. exports.ConfigurationOpenOnHover = 'AdvancedFlagging.Configuration.OpenOnHover';
  1897. exports.ConfigurationWatchFlags = 'AdvancedFlagging.Configuration.WatchFlags';
  1898. exports.ConfigurationWatchQueues = 'AdvancedFlagging.Configuration.WatchQueues';
  1899. exports.ConfigurationDetectAudits = 'AdvancedFlagging.Configuration.DetectAudits';
  1900. exports.ConfigurationEnabledFlags = 'AdvancedFlagging.Configuration.EnabledFlags';
  1901. exports.ConfigurationLinkDisabled = 'AdvancedFlagging.Configuration.LinkDisabled';
  1902. function SetupStyles() {
  1903. var scriptNode = document.createElement('style');
  1904. scriptNode.type = 'text/css';
  1905. scriptNode.textContent = "\n#snackbar {\n min-width: 250px;\n margin-left: -125px;\n color: #fff;\n text-align: center;\n border-radius: 2px;\n padding: 16px;\n position: fixed;\n z-index: 2000;\n left: 50%;\n top: 30px;\n font-size: 17px;\n}\n\n#snackbar.show {\n opacity: 1;\n transition: opacity 1s ease-out;\n -ms-transition: opacity 1s ease-out;\n -moz-transition: opacity 1s ease-out;\n -webkit-transition: opacity 1s ease-out;\n}\n\n#snackbar.hide {\n opacity: 0;\n transition: opacity 1s ease-in;\n -ms-transition: opacity 1s ease-in;\n -moz-transition: opacity 1s ease-in;\n -webkit-transition: opacity 1s ease-in;\n}\n";
  1906. var target = document.getElementsByTagName('head')[0] || document.body || document.documentElement;
  1907. target.appendChild(scriptNode);
  1908. }
  1909. function handleFlagAndComment(postId, flag, flagRequired, commentText, copyPastorPromise) {
  1910. var result = {};
  1911. if (commentText) {
  1912. result.CommentPromise = new Promise(function (resolve, reject) {
  1913. $.ajax({
  1914. url: "//stackoverflow.com/posts/" + postId + "/comments",
  1915. type: 'POST',
  1916. data: { fkey: StackExchange.options.user.fkey, comment: commentText }
  1917. }).done(function (data) {
  1918. resolve(data);
  1919. }).fail(function (jqXHR, textStatus, errorThrown) {
  1920. reject({ jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown });
  1921. });
  1922. });
  1923. }
  1924. if (flagRequired) {
  1925. if (flag.ReportType !== 'NoFlag') {
  1926. var wasFlagged = SimpleCache_1.SimpleCache.GetFromCache("AdvancedFlagging.Flagged." + postId);
  1927. if (!wasFlagged) {
  1928. if (flag.ReportType === 'PostOther') {
  1929. // Do something here
  1930. result.FlagPromise = new Promise(function (resolve, reject) {
  1931. copyPastorPromise.then(function (copyPastorResults) {
  1932. if (flag.GetCustomFlagText && copyPastorResults.length > 0) {
  1933. var flagText = flag.GetCustomFlagText(copyPastorResults[0]);
  1934. autoFlagging = true;
  1935. $.ajax({
  1936. url: "//" + window.location.hostname + "/flags/posts/" + postId + "/add/" + flag.ReportType,
  1937. type: 'POST',
  1938. data: { fkey: StackExchange.options.user.fkey, otherText: flagText }
  1939. }).done(function (data) {
  1940. setTimeout(function () { return autoFlagging = false; }, 500);
  1941. resolve(data);
  1942. }).fail(function (jqXHR, textStatus, errorThrown) {
  1943. reject({ jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown });
  1944. });
  1945. }
  1946. });
  1947. });
  1948. }
  1949. else {
  1950. result.FlagPromise = new Promise(function (resolve, reject) {
  1951. autoFlagging = true;
  1952. $.ajax({
  1953. url: "//" + window.location.hostname + "/flags/posts/" + postId + "/add/" + flag.ReportType,
  1954. type: 'POST',
  1955. data: { fkey: StackExchange.options.user.fkey, otherText: '' }
  1956. }).done(function (data) {
  1957. setTimeout(function () { return autoFlagging = false; }, 500);
  1958. resolve(data);
  1959. }).fail(function (jqXHR, textStatus, errorThrown) {
  1960. reject({ jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown });
  1961. });
  1962. });
  1963. }
  1964. }
  1965. }
  1966. }
  1967. return result;
  1968. }
  1969. var popupWrapper = $('<div>').addClass('hide').hide().attr('id', 'snackbar');
  1970. var popupDelay = 2000;
  1971. var toasterTimeout = null;
  1972. var toasterFadeTimeout = null;
  1973. function displayToaster(message, colour, textColour, duration) {
  1974. var div = $('<div>')
  1975. .css({
  1976. 'background-color': colour,
  1977. 'padding': '10px'
  1978. })
  1979. .text(message);
  1980. if (textColour) {
  1981. div.css('color', textColour);
  1982. }
  1983. popupWrapper.append(div);
  1984. popupWrapper.removeClass('hide').addClass('show').show();
  1985. function hidePopup() {
  1986. popupWrapper.removeClass('show').addClass('hide');
  1987. toasterFadeTimeout = setTimeout(function () {
  1988. popupWrapper.empty().hide();
  1989. }, 1000);
  1990. }
  1991. if (toasterFadeTimeout) {
  1992. clearTimeout(toasterFadeTimeout);
  1993. }
  1994. if (toasterTimeout) {
  1995. clearTimeout(toasterTimeout);
  1996. }
  1997. toasterTimeout = setTimeout(hidePopup, duration === undefined ? popupDelay : duration);
  1998. }
  1999. function displaySuccess(message) {
  2000. displayToaster(message, '#00690c');
  2001. }
  2002. exports.displaySuccess = displaySuccess;
  2003. function displayError(message) {
  2004. displayToaster(message, '#ba1701');
  2005. }
  2006. function BuildFlaggingDialog(element, postId, postType, reputation, authorName, answerTime, questionTime, deleted, reportedIcon, performedActionIcon, reporters, copyPastorPromise) {
  2007. return tslib_1.__awaiter(this, void 0, void 0, function () {
  2008. var getDivider, linkStyle, dropDown, checkboxName, leaveCommentBox, flagBox, isStackOverflow, comments, enabledFlagIds, hasCommentOptions, firstCategory, commentBoxLabel, commentingRow, flagBoxLabel, flaggingRow;
  2009. return tslib_1.__generator(this, function (_a) {
  2010. switch (_a.label) {
  2011. case 0:
  2012. getDivider = function () { return $('<hr />').css({ 'margin-bottom': '10px', 'margin-top': '10px' }); };
  2013. linkStyle = { 'display': 'inline-block', 'margin-top': '5px', 'width': 'auto' };
  2014. dropDown = $('<dl />').css({
  2015. 'margin': '0',
  2016. 'z-index': '1',
  2017. 'position': 'absolute',
  2018. 'white-space': 'nowrap',
  2019. 'background': '#FFF',
  2020. 'padding': '5px',
  2021. 'border': '1px solid #9fa6ad',
  2022. 'box-shadow': '0 2px 4px rgba(36,39,41,0.3)',
  2023. 'cursor': 'default'
  2024. }).hide();
  2025. checkboxName = "comment_checkbox_" + postId;
  2026. leaveCommentBox = $('<input />')
  2027. .attr('type', 'checkbox')
  2028. .attr('name', checkboxName);
  2029. flagBox = $('<input />')
  2030. .attr('type', 'checkbox')
  2031. .attr('name', checkboxName)
  2032. .prop('checked', true);
  2033. isStackOverflow = sotools_1.IsStackOverflow();
  2034. comments = element.find('.comment-body');
  2035. if (comments.length === 0 && isStackOverflow) {
  2036. leaveCommentBox.prop('checked', true);
  2037. }
  2038. return [4 /*yield*/, getFromCaches(exports.ConfigurationEnabledFlags)];
  2039. case 1:
  2040. enabledFlagIds = _a.sent();
  2041. hasCommentOptions = false;
  2042. firstCategory = true;
  2043. FlagTypes_1.flagCategories.forEach(function (flagCategory) {
  2044. if (flagCategory.AppliesTo.indexOf(postType) === -1) {
  2045. return;
  2046. }
  2047. var divider = getDivider();
  2048. if (!firstCategory) {
  2049. dropDown.append(divider);
  2050. }
  2051. var activeLinks = flagCategory.FlagTypes.length;
  2052. flagCategory.FlagTypes.forEach(function (flagType) {
  2053. if (flagType.GetComment) {
  2054. hasCommentOptions = true;
  2055. }
  2056. var dropdownItem = $('<dd />');
  2057. if (flagCategory.BoxStyle) {
  2058. dropdownItem.css(flagCategory.BoxStyle);
  2059. }
  2060. var reportLink = $('<a />').css(linkStyle);
  2061. var disableLink = function () {
  2062. activeLinks--;
  2063. reportLink.hide();
  2064. if (divider && activeLinks <= 0) {
  2065. divider.hide();
  2066. }
  2067. };
  2068. var enableLink = function () {
  2069. activeLinks++;
  2070. reportLink.show();
  2071. if (divider && activeLinks > 0) {
  2072. divider.show();
  2073. }
  2074. };
  2075. disableLink();
  2076. if (!enabledFlagIds || enabledFlagIds.indexOf(flagType.Id) > -1) {
  2077. if (flagType.Enabled) {
  2078. copyPastorPromise.then(function (items) {
  2079. // If it somehow changed within the promise, check again
  2080. if (flagType.Enabled) {
  2081. var hasItems = items.length > 0;
  2082. var isEnabled = flagType.Enabled(hasItems);
  2083. if (isEnabled) {
  2084. enableLink();
  2085. }
  2086. }
  2087. else {
  2088. enableLink();
  2089. }
  2090. });
  2091. }
  2092. else {
  2093. enableLink();
  2094. }
  2095. }
  2096. var commentText;
  2097. if (flagType.GetComment) {
  2098. commentText = flagType.GetComment({ Reputation: reputation, AuthorName: authorName });
  2099. reportLink.attr('title', commentText);
  2100. }
  2101. reportLink.click(function () {
  2102. if (!deleted) {
  2103. try {
  2104. if (!leaveCommentBox.is(':checked')) {
  2105. // Now we need to investigate the existing comments to upvote them.
  2106. var commentTextItems = element.find('.comment-body .comment-copy').map(function (i, ele) { return $(ele).text(); });
  2107. if (commentText) {
  2108. // Match [some text](http://somehyperlink.com)
  2109. var strippedComment_1 = commentText.replace(/\[([^\]]+)\]\(([^\]]+)\)/g, '$1');
  2110. // Match [edit]
  2111. strippedComment_1 = strippedComment_1.replace(/\[([^\]]+)\][^\(]*?/g, '$1');
  2112. // Strip out italics. _thanks_ => thanks
  2113. strippedComment_1 = strippedComment_1.replace(/_([^_]+)_/g, '$1');
  2114. // Strip out bolds. **thanks** => thanks
  2115. strippedComment_1 = strippedComment_1.replace(/\*\*([^\*]+)\*\*/g, '$1');
  2116. // Strip out italics. *thanks* => thanks
  2117. strippedComment_1 = strippedComment_1.replace(/\*([^\*]+)\*/g, '$1');
  2118. element.find('.comment-body .comment-copy').each(function (i, ele) {
  2119. var jEle = $(ele);
  2120. var text = jEle.text();
  2121. var fromReviewText = ' - From Review';
  2122. if (text.endsWith(fromReviewText)) {
  2123. text = text.substring(0, text.length - fromReviewText.length);
  2124. }
  2125. if (text === strippedComment_1) {
  2126. jEle.closest('li').find('a.comment-up.comment-up-off').trigger('click');
  2127. }
  2128. });
  2129. }
  2130. commentText = undefined;
  2131. }
  2132. var result = handleFlagAndComment(postId, flagType, flagBox.is(':checked'), commentText, copyPastorPromise);
  2133. if (result.CommentPromise) {
  2134. result.CommentPromise.then(function (data) {
  2135. var commentUI = StackExchange.comments.uiForPost($('#comments-' + postId));
  2136. commentUI.addShow(true, false);
  2137. commentUI.showComments(data, null, false, true);
  2138. $(document).trigger('comment', postId);
  2139. }).catch(function (err) {
  2140. displayError('Failed to comment on post');
  2141. // tslint:disable-next-line:no-console
  2142. console.log(err);
  2143. });
  2144. }
  2145. if (result.FlagPromise) {
  2146. result.FlagPromise.then(function () {
  2147. var expiryDate = new Date();
  2148. expiryDate.setDate(expiryDate.getDate() + 30);
  2149. SimpleCache_1.SimpleCache.StoreInCache("AdvancedFlagging.Flagged." + postId, flagType, expiryDate);
  2150. reportedIcon.attr('title', "Flagged as " + flagType.ReportType);
  2151. reportedIcon.show();
  2152. displaySuccess('Flagged');
  2153. }).catch(function (err) {
  2154. displayError('Failed to flag post');
  2155. // tslint:disable-next-line:no-console
  2156. console.log(err);
  2157. });
  2158. }
  2159. }
  2160. catch (err) {
  2161. displayError(err);
  2162. }
  2163. }
  2164. var noFlag = flagType.ReportType === 'NoFlag';
  2165. if (noFlag) {
  2166. var expiryDate = new Date();
  2167. expiryDate.setDate(expiryDate.getDate() + 30);
  2168. SimpleCache_1.SimpleCache.StoreInCache("AdvancedFlagging.PerformedAction." + postId, flagType, expiryDate);
  2169. performedActionIcon.attr('title', "Performed action: " + flagType.DisplayName);
  2170. performedActionIcon.show();
  2171. }
  2172. handleFlag(flagType, reporters, answerTime, questionTime);
  2173. dropDown.hide();
  2174. });
  2175. reportLink.text(flagType.DisplayName);
  2176. dropdownItem.append(reportLink);
  2177. dropDown.append(dropdownItem);
  2178. });
  2179. firstCategory = false;
  2180. });
  2181. if (!isStackOverflow) {
  2182. hasCommentOptions = false;
  2183. }
  2184. dropDown.append(getDivider());
  2185. if (hasCommentOptions) {
  2186. commentBoxLabel = $('<label />').text('Leave comment')
  2187. .attr('for', checkboxName)
  2188. .css({
  2189. 'margin-right': '5px',
  2190. 'margin-left': '4px',
  2191. });
  2192. commentBoxLabel.click(function () { return leaveCommentBox.click(); });
  2193. commentingRow = $('<dd />');
  2194. commentingRow.append(commentBoxLabel);
  2195. commentingRow.append(leaveCommentBox);
  2196. dropDown.append(commentingRow);
  2197. }
  2198. flagBoxLabel = $('<label />').text('Flag')
  2199. .attr('for', checkboxName)
  2200. .css({
  2201. 'margin-right': '5px',
  2202. 'margin-left': '4px',
  2203. });
  2204. flagBoxLabel.click(function () { return flagBox.click(); });
  2205. flaggingRow = $('<dd />');
  2206. flaggingRow.append(flagBoxLabel);
  2207. flaggingRow.append(flagBox);
  2208. dropDown.append(flaggingRow);
  2209. return [2 /*return*/, dropDown];
  2210. }
  2211. });
  2212. });
  2213. }
  2214. function handleFlag(flagType, reporters, answerTime, questionTime) {
  2215. var rudeFlag = flagType.ReportType === 'PostSpam' || flagType.ReportType === 'PostOffensive';
  2216. var naaFlag = flagType.ReportType === 'AnswerNotAnAnswer';
  2217. var customFlag = flagType.ReportType === 'PostOther';
  2218. var noFlag = flagType.ReportType === 'NoFlag';
  2219. var _loop_1 = function (i) {
  2220. var reporter = reporters[i];
  2221. var promise = null;
  2222. if (rudeFlag) {
  2223. promise = reporter.ReportRedFlag();
  2224. }
  2225. else if (naaFlag) {
  2226. promise = reporter.ReportNaa(answerTime, questionTime);
  2227. }
  2228. else if (noFlag) {
  2229. switch (flagType.DisplayName) {
  2230. case 'Needs Editing':
  2231. promise = reporter.ReportNeedsEditing();
  2232. break;
  2233. case 'Vandalism':
  2234. promise = reporter.ReportVandalism();
  2235. break;
  2236. default:
  2237. promise = reporter.ReportLooksFine();
  2238. break;
  2239. }
  2240. }
  2241. else if (customFlag) {
  2242. switch (flagType.DisplayName) {
  2243. case 'Duplicate answer':
  2244. promise = reporter.ReportDuplicateAnswer();
  2245. break;
  2246. case 'Plagiarism':
  2247. promise = reporter.ReportPlagiarism();
  2248. break;
  2249. default:
  2250. throw new Error('Could not find custom flag type: ' + flagType.DisplayName);
  2251. }
  2252. }
  2253. if (promise) {
  2254. promise.then(function (didReport) {
  2255. if (didReport) {
  2256. displaySuccess("Feedback sent to " + reporter.name);
  2257. }
  2258. }).catch(function (error) {
  2259. displayError("Failed to send feedback to " + reporter.name + ".");
  2260. });
  2261. }
  2262. };
  2263. for (var i = 0; i < reporters.length; i++) {
  2264. _loop_1(i);
  2265. }
  2266. }
  2267. var autoFlagging = false;
  2268. function SetupPostPage() {
  2269. return tslib_1.__awaiter(this, void 0, void 0, function () {
  2270. var _this = this;
  2271. return tslib_1.__generator(this, function (_a) {
  2272. sotools_1.parseQuestionsAndAnswers(function (post) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  2273. var iconLocation, advancedFlaggingLink, nattyIcon, showFunc, copyPastorIcon, copyPastorApi, copyPastorObservable, smokeyIcon, reporters, nattyApi_1, genericBotAPI_1, metaSmoke, performedActionIcon, reportedIcon, questionTime_1, answerTime_1, deleted, linkDisabled, dropDown_1, link_1, previousFlag, previousAction;
  2274. return tslib_1.__generator(this, function (_a) {
  2275. switch (_a.label) {
  2276. case 0:
  2277. advancedFlaggingLink = null;
  2278. nattyIcon = getNattyIcon().click(function () {
  2279. window.open("https://sentinel.erwaysoftware.com/posts/aid/" + post.postId, '_blank');
  2280. });
  2281. showFunc = function (element) { return element.css('display', 'inline-block'); };
  2282. copyPastorIcon = getGuttenbergIcon();
  2283. copyPastorApi = new CopyPastorAPI_1.CopyPastorAPI(post.postId, copyPastorKey);
  2284. copyPastorObservable = copyPastorApi.Watch();
  2285. smokeyIcon = getSmokeyIcon();
  2286. reporters = [];
  2287. if (post.type === 'Answer') {
  2288. nattyApi_1 = new NattyApi_1.NattyAPI(post.postId);
  2289. nattyApi_1.Watch()
  2290. .subscribe(function (reported) {
  2291. if (reported) {
  2292. showFunc(nattyIcon);
  2293. }
  2294. else {
  2295. nattyIcon.hide();
  2296. }
  2297. });
  2298. reporters.push({
  2299. name: 'Natty',
  2300. ReportNaa: function (answerDate, questionDate) { return nattyApi_1.ReportNaa(answerDate, questionDate); },
  2301. ReportRedFlag: function () { return nattyApi_1.ReportRedFlag(); },
  2302. ReportLooksFine: function () { return nattyApi_1.ReportLooksFine(); },
  2303. ReportNeedsEditing: function () { return nattyApi_1.ReportNeedsEditing(); },
  2304. ReportVandalism: function () { return Promise.resolve(false); },
  2305. ReportDuplicateAnswer: function () { return Promise.resolve(false); },
  2306. ReportPlagiarism: function () { return Promise.resolve(false); }
  2307. });
  2308. copyPastorObservable.subscribe(function (items) {
  2309. if (items.length) {
  2310. copyPastorIcon.attr('Title', "Reported by CopyPastor - " + items.length);
  2311. showFunc(copyPastorIcon);
  2312. copyPastorIcon.click(function () {
  2313. return items.forEach(function (item) {
  2314. window.open('http://copypastor.sobotics.org/posts/' + item.post_id);
  2315. });
  2316. });
  2317. }
  2318. else {
  2319. copyPastorIcon.hide();
  2320. }
  2321. });
  2322. reporters.push({
  2323. name: 'Guttenberg',
  2324. ReportNaa: function (answerDate, questionDate) { return copyPastorApi.ReportFalsePositive(); },
  2325. ReportRedFlag: function () { return Promise.resolve(false); },
  2326. ReportLooksFine: function () { return copyPastorApi.ReportFalsePositive(); },
  2327. ReportNeedsEditing: function () { return copyPastorApi.ReportFalsePositive(); },
  2328. ReportVandalism: function () { return copyPastorApi.ReportFalsePositive(); },
  2329. ReportDuplicateAnswer: function () { return copyPastorApi.ReportTruePositive(); },
  2330. ReportPlagiarism: function () { return copyPastorApi.ReportTruePositive(); }
  2331. });
  2332. genericBotAPI_1 = new GenericBotAPI_1.GenericBotAPI(post.postId);
  2333. reporters.push({
  2334. name: 'Generic Bot',
  2335. ReportNaa: function (answerDate, questionDate) { return genericBotAPI_1.ReportNaa(); },
  2336. ReportRedFlag: function () { return Promise.resolve(false); },
  2337. ReportLooksFine: function () { return genericBotAPI_1.ReportLooksFine(); },
  2338. ReportNeedsEditing: function () { return genericBotAPI_1.ReportNeedsEditing(); },
  2339. ReportVandalism: function () { return Promise.resolve(true); },
  2340. ReportDuplicateAnswer: function () { return Promise.resolve(false); },
  2341. ReportPlagiarism: function () { return Promise.resolve(false); }
  2342. });
  2343. }
  2344. metaSmoke = new MetaSmokeAPI_1.MetaSmokeAPI();
  2345. metaSmoke.Watch(post.postId, post.type)
  2346. .subscribe(function (id) {
  2347. if (id !== null) {
  2348. smokeyIcon.click(function () {
  2349. window.open("https://metasmoke.erwaysoftware.com/post/" + id, '_blank');
  2350. });
  2351. showFunc(smokeyIcon);
  2352. }
  2353. else {
  2354. smokeyIcon.hide();
  2355. }
  2356. });
  2357. reporters.push({
  2358. name: 'Smokey',
  2359. ReportNaa: function (answerDate, questionDate) { return metaSmoke.ReportNaa(post.postId, post.type); },
  2360. ReportRedFlag: function () { return metaSmoke.ReportRedFlag(post.postId, post.type); },
  2361. ReportLooksFine: function () { return metaSmoke.ReportLooksFine(post.postId, post.type); },
  2362. ReportNeedsEditing: function () { return metaSmoke.ReportNeedsEditing(post.postId, post.type); },
  2363. ReportVandalism: function () { return metaSmoke.ReportVandalism(post.postId, post.type); },
  2364. ReportDuplicateAnswer: function () { return Promise.resolve(false); },
  2365. ReportPlagiarism: function () { return Promise.resolve(false); }
  2366. });
  2367. performedActionIcon = getPerformedActionIcon();
  2368. reportedIcon = getReportedIcon();
  2369. if (!(post.page === 'Question')) return [3 /*break*/, 4];
  2370. // Now we setup the flagging dialog
  2371. iconLocation = post.element.find('.post-menu');
  2372. advancedFlaggingLink = $('<a />').text('Advanced Flagging');
  2373. if (post.type === 'Answer') {
  2374. questionTime_1 = post.question.postTime;
  2375. answerTime_1 = post.postTime;
  2376. }
  2377. else {
  2378. questionTime_1 = post.postTime;
  2379. answerTime_1 = post.postTime;
  2380. }
  2381. deleted = post.element.hasClass('deleted-answer');
  2382. getFromCaches(exports.ConfigurationWatchFlags).then(function (isEnabled) {
  2383. RequestWatcher_1.WatchFlags().subscribe(function (xhr) {
  2384. if (isEnabled && !autoFlagging) {
  2385. var matches = new RegExp("/flags/posts/" + post.postId + "/add/(AnswerNotAnAnswer|PostOffensive|PostSpam|NoFlag|PostOther)").exec(xhr.responseURL);
  2386. if (matches !== null && xhr.status === 200) {
  2387. var flagType = {
  2388. Id: 0,
  2389. ReportType: matches[1],
  2390. DisplayName: matches[1]
  2391. };
  2392. handleFlag(flagType, reporters, answerTime_1, questionTime_1);
  2393. var expiryDate = new Date();
  2394. expiryDate.setDate(expiryDate.getDate() + 30);
  2395. SimpleCache_1.SimpleCache.StoreInCache("AdvancedFlagging.Flagged." + post.postId, flagType, expiryDate);
  2396. reportedIcon.attr('title', "Flagged as " + flagType.ReportType);
  2397. reportedIcon.show();
  2398. displaySuccess('Flagged');
  2399. }
  2400. }
  2401. });
  2402. });
  2403. return [4 /*yield*/, getFromCaches(exports.ConfigurationLinkDisabled)];
  2404. case 1:
  2405. linkDisabled = _a.sent();
  2406. if (!!linkDisabled) return [3 /*break*/, 3];
  2407. return [4 /*yield*/, BuildFlaggingDialog(post.element, post.postId, post.type, post.authorReputation, post.authorName, answerTime_1, questionTime_1, deleted, reportedIcon, performedActionIcon, reporters, copyPastorApi.Promise())];
  2408. case 2:
  2409. dropDown_1 = _a.sent();
  2410. advancedFlaggingLink.append(dropDown_1);
  2411. $(window).click(function () {
  2412. dropDown_1.hide();
  2413. });
  2414. link_1 = advancedFlaggingLink;
  2415. getFromCaches(exports.ConfigurationOpenOnHover)
  2416. .then(function (openOnHover) {
  2417. if (openOnHover) {
  2418. link_1.hover(function (e) {
  2419. e.stopPropagation();
  2420. if (e.target === link_1.get(0)) {
  2421. dropDown_1.show();
  2422. }
  2423. });
  2424. link_1.mouseleave(function (e) {
  2425. e.stopPropagation();
  2426. dropDown_1.hide();
  2427. });
  2428. }
  2429. else {
  2430. link_1.click(function (e) {
  2431. e.stopPropagation();
  2432. if (e.target === link_1.get(0)) {
  2433. dropDown_1.toggle();
  2434. }
  2435. });
  2436. }
  2437. });
  2438. iconLocation.append(advancedFlaggingLink);
  2439. _a.label = 3;
  2440. case 3:
  2441. iconLocation.append(performedActionIcon);
  2442. iconLocation.append(reportedIcon);
  2443. iconLocation.append(nattyIcon);
  2444. iconLocation.append(copyPastorIcon);
  2445. iconLocation.append(smokeyIcon);
  2446. return [3 /*break*/, 5];
  2447. case 4:
  2448. iconLocation = post.element.find('a.answer-hyperlink');
  2449. iconLocation.after(smokeyIcon);
  2450. iconLocation.after(copyPastorIcon);
  2451. iconLocation.after(nattyIcon);
  2452. iconLocation.after(reportedIcon);
  2453. iconLocation.after(performedActionIcon);
  2454. _a.label = 5;
  2455. case 5:
  2456. previousFlag = SimpleCache_1.SimpleCache.GetFromCache("AdvancedFlagging.Flagged." + post.postId);
  2457. if (previousFlag) {
  2458. reportedIcon.attr('title', "Previously flagged as " + previousFlag.ReportType);
  2459. showFunc(reportedIcon);
  2460. }
  2461. previousAction = SimpleCache_1.SimpleCache.GetFromCache("AdvancedFlagging.PerformedAction." + post.postId);
  2462. if (previousAction && previousAction.ReportType === 'NoFlag') {
  2463. performedActionIcon.attr('title', "Previously performed action: " + previousAction.DisplayName);
  2464. showFunc(performedActionIcon);
  2465. }
  2466. return [2 /*return*/];
  2467. }
  2468. });
  2469. }); });
  2470. return [2 /*return*/];
  2471. });
  2472. });
  2473. }
  2474. function getPerformedActionIcon() {
  2475. return $('<div>').addClass('comment-flag')
  2476. .css({ 'margin-left': '5px', 'background-position': '-61px -320px', 'visibility': 'visible' })
  2477. .css({ 'width': '15px', 'height': '15px', 'background-position': '-20px -320px' })
  2478. .css({ cursor: 'default' })
  2479. .hide();
  2480. }
  2481. function getReportedIcon() {
  2482. return $('<div>').addClass('comment-flag')
  2483. .css({ 'margin-left': '5px', 'background-position': '-61px -320px', 'visibility': 'visible' })
  2484. .css({ cursor: 'default' })
  2485. .hide();
  2486. }
  2487. function getNattyIcon() {
  2488. return $('<div>')
  2489. .css({
  2490. 'width': '15px', 'height': '16px', 'margin-left': '5px', 'vertical-align': 'text-bottom', 'cursor': 'pointer',
  2491. 'background': 'url("https://i.stack.imgur.com/aMUMt.jpg?s=128&g=1"', 'background-size': '100%'
  2492. })
  2493. .attr('title', 'Reported by Natty')
  2494. .hide();
  2495. }
  2496. function getGuttenbergIcon() {
  2497. return $('<div>')
  2498. .css({
  2499. 'width': '15px', 'height': '16px', 'margin-left': '5px', 'vertical-align': 'text-bottom', 'cursor': 'pointer',
  2500. 'background': 'url("https://i.stack.imgur.com/A0JRA.png?s=128&g=1"', 'background-size': '100%'
  2501. })
  2502. .attr('title', 'Reported by Guttenberg')
  2503. .hide();
  2504. }
  2505. function getSmokeyIcon() {
  2506. return $('<div>')
  2507. .css({
  2508. 'width': '15px', 'height': '16px', 'margin-left': '5px', 'vertical-align': 'text-bottom', 'cursor': 'pointer',
  2509. 'background': 'url("https://i.stack.imgur.com/7cmCt.png?s=128&g=1"', 'background-size': '100%'
  2510. })
  2511. .attr('title', 'Reported by Smokey')
  2512. .hide();
  2513. }
  2514. function getDropdown() {
  2515. $('<dl />').css({
  2516. 'margin': '0',
  2517. 'z-index': '1',
  2518. 'position': 'absolute',
  2519. 'white-space': 'nowrap',
  2520. 'background': '#FFF',
  2521. 'padding': '5px',
  2522. 'border': '1px solid #9fa6ad',
  2523. 'box-shadow': '0 2px 4px rgba(36,39,41,0.3)',
  2524. 'cursor': 'default'
  2525. }).hide();
  2526. }
  2527. var metaSmokeManualKey = 'MetaSmoke.ManualKey';
  2528. // First attempt to retrieve the value from the local cache.
  2529. // If it doesn't exist, check the cross domain cache, and store it locally
  2530. function getFromCaches(key) {
  2531. return tslib_1.__awaiter(this, void 0, void 0, function () {
  2532. return tslib_1.__generator(this, function (_a) {
  2533. return [2 /*return*/, SimpleCache_1.SimpleCache.GetAndCache(key, function () {
  2534. return CrossDomainCache_1.CrossDomainCache.GetFromCache(key);
  2535. })];
  2536. });
  2537. });
  2538. }
  2539. exports.getFromCaches = getFromCaches;
  2540. // Store the value in both the local and global cache
  2541. function storeInCaches(key, item) {
  2542. return tslib_1.__awaiter(this, void 0, void 0, function () {
  2543. return tslib_1.__generator(this, function (_a) {
  2544. switch (_a.label) {
  2545. case 0: return [4 /*yield*/, SimpleCache_1.SimpleCache.StoreInCache(key, item)];
  2546. case 1:
  2547. _a.sent();
  2548. return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.StoreInCache(key, item)];
  2549. case 2:
  2550. _a.sent();
  2551. return [2 /*return*/];
  2552. }
  2553. });
  2554. });
  2555. }
  2556. exports.storeInCaches = storeInCaches;
  2557. $(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  2558. var _this = this;
  2559. var clearUnexpirying, manualKey_1;
  2560. return tslib_1.__generator(this, function (_a) {
  2561. switch (_a.label) {
  2562. case 0:
  2563. SimpleCache_1.SimpleCache.ClearExpiredKeys(/^AdvancedFlagging\./);
  2564. clearUnexpirying = function (val) {
  2565. if (!val) {
  2566. return true;
  2567. }
  2568. try {
  2569. var jsonObj = JSON.parse(val);
  2570. if (!jsonObj.Expires) {
  2571. return true;
  2572. }
  2573. else {
  2574. return false;
  2575. }
  2576. }
  2577. catch (_a) {
  2578. // Don't care
  2579. }
  2580. return true;
  2581. };
  2582. SimpleCache_1.SimpleCache.ClearAll(/^AdvancedFlagging\.Flagged\.\d+/, clearUnexpirying);
  2583. SimpleCache_1.SimpleCache.ClearAll(/^AdvancedFlagging\.PerformedAction\.\d+/, clearUnexpirying);
  2584. SimpleCache_1.SimpleCache.ClearAll(/^CopyPastor\.FindTarget\.\d+/, clearUnexpirying);
  2585. SimpleCache_1.SimpleCache.ClearAll(/^MetaSmoke.WasReported/, clearUnexpirying);
  2586. SimpleCache_1.SimpleCache.ClearAll(/^NattyApi.Feedback\.\d+/, clearUnexpirying);
  2587. return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.InitializeCache('https://metasmoke.erwaysoftware.com/xdom_storage.html')];
  2588. case 1:
  2589. _a.sent();
  2590. return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.CacheFailed()];
  2591. case 2:
  2592. if (!!(_a.sent())) return [3 /*break*/, 6];
  2593. manualKey_1 = localStorage.getItem(metaSmokeManualKey);
  2594. if (!manualKey_1) return [3 /*break*/, 4];
  2595. localStorage.removeItem(metaSmokeManualKey);
  2596. return [4 /*yield*/, MetaSmokeAPI_1.MetaSmokeAPI.Setup(exports.metaSmokeKey, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
  2597. return [2 /*return*/, manualKey_1];
  2598. }); }); })];
  2599. case 3:
  2600. _a.sent();
  2601. return [3 /*break*/, 6];
  2602. case 4: return [4 /*yield*/, MetaSmokeAPI_1.MetaSmokeAPI.Setup(exports.metaSmokeKey)];
  2603. case 5:
  2604. _a.sent();
  2605. _a.label = 6;
  2606. case 6: return [4 /*yield*/, Configuration_1.SetupConfiguration()];
  2607. case 7:
  2608. _a.sent();
  2609. return [4 /*yield*/, SetupPostPage()];
  2610. case 8:
  2611. _a.sent();
  2612. SetupStyles();
  2613. getFromCaches(exports.ConfigurationDetectAudits).then(function (isEnabled) {
  2614. RequestWatcher_1.WatchRequests().subscribe(function (xhr) {
  2615. var isReviewItem = /(\/review\/next-task)|(\/review\/task-reviewed\/)/.exec(xhr.responseURL);
  2616. if (isReviewItem !== null && xhr.status === 200) {
  2617. var review = JSON.parse(xhr.responseText);
  2618. if (isEnabled && review.isAudit) {
  2619. displayToaster('Beware! This is an audit!', '#cce5ff', '#004085', 5000);
  2620. $('.review-actions').hide();
  2621. setTimeout(function () {
  2622. $('.review-actions').show();
  2623. }, 5000);
  2624. }
  2625. }
  2626. });
  2627. });
  2628. document.body.appendChild(popupWrapper.get(0));
  2629. getFromCaches(exports.ConfigurationWatchQueues).then(function (isEnabled) {
  2630. var postDetails = [];
  2631. RequestWatcher_1.WatchRequests().subscribe(function (xhr) {
  2632. if (isEnabled) {
  2633. var parseReviewDetails = function (review) {
  2634. var postId = review.postId;
  2635. var content = $(review.content);
  2636. postDetails[postId] = {
  2637. questionTime: sotools_1.parseDate($('.post-signature.owner .user-action-time span', content).attr('title')),
  2638. answerTime: sotools_1.parseDate($('.post-signature .user-action-time span', content).attr('title'))
  2639. };
  2640. };
  2641. // We can't just parse the page after a recommend/delete request, as the page will have sometimes already updated
  2642. // This means we're actually grabbing the information for the following review
  2643. // So, we watch the next-task requests and remember which post we were looking at for when a delete/recommend-delete vote comes through.
  2644. // next-task is invoked when visiting the review queue
  2645. // task-reviewed is invoked when making a response
  2646. var isReviewItem = /(\/review\/next-task)|(\/review\/task-reviewed\/)/.exec(xhr.responseURL);
  2647. if (isReviewItem !== null && xhr.status === 200) {
  2648. var review = JSON.parse(xhr.responseText);
  2649. parseReviewDetails(review);
  2650. return;
  2651. }
  2652. var matches = /(\d+)\/vote\/10|(\d+)\/recommend-delete/.exec(xhr.responseURL);
  2653. if (matches !== null && xhr.status === 200) {
  2654. var postIdStr = matches[1] || matches[2];
  2655. var postId = parseInt(postIdStr, 10);
  2656. var currentPostDetails = postDetails[postId];
  2657. if (currentPostDetails && $('.answers-subheader').length > 0) {
  2658. var nattyApi_2 = new NattyApi_1.NattyAPI(postId);
  2659. nattyApi_2.Watch();
  2660. handleFlag({ Id: 0, ReportType: 'AnswerNotAnAnswer', DisplayName: 'AnswerNotAnAnswer' }, [
  2661. {
  2662. name: 'Natty',
  2663. ReportNaa: function (answerDate, questionDate) { return nattyApi_2.ReportNaa(answerDate, questionDate); },
  2664. ReportRedFlag: function () { return nattyApi_2.ReportRedFlag(); },
  2665. ReportLooksFine: function () { return nattyApi_2.ReportLooksFine(); },
  2666. ReportNeedsEditing: function () { return nattyApi_2.ReportNeedsEditing(); },
  2667. ReportVandalism: function () { return Promise.resolve(false); },
  2668. ReportDuplicateAnswer: function () { return Promise.resolve(false); },
  2669. ReportPlagiarism: function () { return Promise.resolve(false); }
  2670. }
  2671. ], currentPostDetails.answerTime, currentPostDetails.questionTime);
  2672. }
  2673. }
  2674. }
  2675. });
  2676. });
  2677. return [2 /*return*/];
  2678. }
  2679. });
  2680. }); });
  2681. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  2682. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  2683.  
  2684.  
  2685. /***/ }),
  2686. /* 12 */
  2687. /***/ (function(module, exports, __webpack_require__) {
  2688.  
  2689. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) {
  2690. "use strict";
  2691. Object.defineProperty(exports, "__esModule", { value: true });
  2692. exports.flagCategories = [
  2693. {
  2694. BoxStyle: { 'padding-left': '5px', 'padding-right': '5px', 'background-color': 'rgba(241, 148, 148, 0.6)' },
  2695. AppliesTo: ['Answer', 'Question'],
  2696. FlagTypes: [
  2697. {
  2698. Id: 1,
  2699. DisplayName: 'Spam',
  2700. ReportType: 'PostSpam'
  2701. },
  2702. {
  2703. Id: 2,
  2704. DisplayName: 'Rude or Abusive',
  2705. ReportType: 'PostOffensive'
  2706. }
  2707. ]
  2708. },
  2709. {
  2710. BoxStyle: { 'padding-left': '5px', 'padding-right': '5px', 'background-color': 'rgba(241, 148, 148, 0.6)' },
  2711. AppliesTo: ['Answer'],
  2712. FlagTypes: [
  2713. {
  2714. Id: 3,
  2715. DisplayName: 'Plagiarism',
  2716. ReportType: 'PostOther',
  2717. Enabled: function (hasDuplicatePostLinks) { return hasDuplicatePostLinks; },
  2718. GetCustomFlagText: function (copyPastorItem) { return "Possible plagiarism of another answer https:" + copyPastorItem.target_url + ", as can be seen here http://copypastor.sobotics.org/posts/" + copyPastorItem.post_id; }
  2719. },
  2720. {
  2721. Id: 4,
  2722. DisplayName: 'Duplicate answer',
  2723. ReportType: 'PostOther',
  2724. Enabled: function (hasDuplicatePostLinks) { return hasDuplicatePostLinks; },
  2725. GetComment: function () { return 'Please don\'t add the [same answer to multiple questions](http://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questions). Answer the best one and flag the rest as duplicates, once you earn enough reputation. If it is not a duplicate, [edit] the answer and tailor the post to the question.'; },
  2726. GetCustomFlagText: function (copyPastorItem) { return "The answer is a repost of their other answer https:" + copyPastorItem.target_url + ", but as there are slight differences as seen here http://copypastor.sobotics.org/posts/" + copyPastorItem.post_id + ", an auto flag wouldn't be raised."; }
  2727. }
  2728. ]
  2729. },
  2730. {
  2731. BoxStyle: { 'padding-left': '5px', 'padding-right': '5px' },
  2732. AppliesTo: ['Answer'],
  2733. FlagTypes: [
  2734. {
  2735. Id: 5,
  2736. DisplayName: 'Link Only',
  2737. ReportType: 'AnswerNotAnAnswer',
  2738. GetComment: function () { return 'A link to a solution is welcome, but please ensure your answer is useful without it: ' +
  2739. '[add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will ' +
  2740. 'have some idea what it is and why it’s there, then quote the most relevant part of the ' +
  2741. 'page you\'re linking to in case the target page is unavailable. ' +
  2742. '[Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers)'; }
  2743. },
  2744. {
  2745. Id: 6,
  2746. DisplayName: 'Not an answer',
  2747. ReportType: 'AnswerNotAnAnswer',
  2748. GetComment: function (userDetails) { return userDetails.Reputation < 50
  2749. ? 'This does not provide an answer to the question. You can [search for similar questions](//stackoverflow.com/search), ' +
  2750. 'or refer to the related and linked questions on the right-hand side of the page to find an answer. ' +
  2751. 'If you have a related but different question, [ask a new question](//stackoverflow.com/questions/ask), ' +
  2752. 'and include a link to this one to help provide context. ' +
  2753. 'See: [Ask questions, get answers, no distractions](//stackoverflow.com/tour)'
  2754. : 'This post doesn\'t look like an attempt to answer this question. Every post here is expected to be ' +
  2755. 'an explicit attempt to *answer* this question; if you have a critique or need a clarification of ' +
  2756. 'the question or another answer, you can [post a comment](//stackoverflow.com/help/privileges/comment) ' +
  2757. '(like this one) directly below it. Please remove this answer and create either a comment or a new question. ' +
  2758. 'See: [Ask questions, get answers, no distractions](//stackoverflow.com/tour)'; }
  2759. },
  2760. {
  2761. Id: 7,
  2762. DisplayName: 'Thanks',
  2763. ReportType: 'AnswerNotAnAnswer',
  2764. GetComment: function (userDetails) { return userDetails.Reputation < 15
  2765. ? 'Please don\'t add _"thanks"_ as answers. They don\'t actually provide an answer to the question, ' +
  2766. 'and can be perceived as noise by its future visitors. Once you [earn](http://meta.stackoverflow.com/q/146472) ' +
  2767. 'enough [reputation](http://stackoverflow.com/help/whats-reputation), you will gain privileges to ' +
  2768. '[upvote answers](http://stackoverflow.com/help/privileges/vote-up) you like. This way future visitors of the question ' +
  2769. 'will see a higher vote count on that answer, and the answerer will also be rewarded with reputation points. ' +
  2770. 'See [Why is voting important](http://stackoverflow.com/help/why-vote).'
  2771. :
  2772. 'Please don\'t add _"thanks"_ as answers. They don\'t actually provide an answer to the question, ' +
  2773. 'and can be perceived as noise by its future visitors. ' +
  2774. 'Instead, [upvote answers](http://stackoverflow.com/help/privileges/vote-up) you like. This way future visitors of the question ' +
  2775. 'will see a higher vote count on that answer, and the answerer will also be rewarded with reputation points. ' +
  2776. 'See [Why is voting important](http://stackoverflow.com/help/why-vote).'; }
  2777. },
  2778. {
  2779. Id: 8,
  2780. DisplayName: 'Me too',
  2781. ReportType: 'AnswerNotAnAnswer',
  2782. GetComment: function () { return 'Please don\'t add *"Me too"* as answers. It doesn\'t actually provide an answer to the question. ' +
  2783. "If you have a different but related question, then [ask](//stackoverflow.com/questions/ask) it " +
  2784. '(reference this one if it will help provide context). If you\'re interested in this specific question, ' +
  2785. 'you can [upvote](//stackoverflow.com/help/privileges/vote-up) it, leave a [comment](//stackoverflow.com/help/privileges/comment), ' +
  2786. 'or start a [bounty](//stackoverflow.com/help/privileges/set-bounties) ' +
  2787. 'once you have enough [reputation](//stackoverflow.com/help/whats-reputation).'; },
  2788. },
  2789. {
  2790. Id: 9,
  2791. DisplayName: 'Library',
  2792. ReportType: 'AnswerNotAnAnswer',
  2793. GetComment: function () { return 'Please don\'t just post some tool or library as an answer. At least demonstrate [how it solves the problem](http://meta.stackoverflow.com/a/251605) in the answer itself.'; }
  2794. },
  2795. {
  2796. Id: 10,
  2797. DisplayName: 'Comment',
  2798. ReportType: 'AnswerNotAnAnswer',
  2799. GetComment: function () { return 'This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don\'t require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead).'; }
  2800. },
  2801. {
  2802. Id: 14,
  2803. DisplayName: 'Duplicate',
  2804. ReportType: 'AnswerNotAnAnswer',
  2805. GetComment: function () { return 'Instead of posting an answer which merely links to another answer, please instead [flag the question](https://stackoverflow.com/help/privileges/flag-posts) as a duplicate.'; }
  2806. },
  2807. {
  2808. Id: 17,
  2809. DisplayName: 'Non English',
  2810. ReportType: 'AnswerNotAnAnswer',
  2811. GetComment: function () { return 'Welcome to Stack Overflow. Please write your answer in English, as Stack Overflow is an [English only site](https://meta.stackoverflow.com/a/297680).'; }
  2812. }
  2813. ]
  2814. },
  2815. {
  2816. BoxStyle: { 'padding-left': '5px', 'padding-right': '5px' },
  2817. AppliesTo: ['Answer', 'Question'],
  2818. FlagTypes: [
  2819. {
  2820. Id: 11,
  2821. DisplayName: 'Looks Fine',
  2822. ReportType: 'NoFlag'
  2823. },
  2824. {
  2825. Id: 12,
  2826. DisplayName: 'Needs Editing',
  2827. ReportType: 'NoFlag'
  2828. },
  2829. {
  2830. Id: 13,
  2831. DisplayName: 'Vandalism',
  2832. ReportType: 'NoFlag'
  2833. }
  2834. ]
  2835. }
  2836. ];
  2837. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  2838. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  2839.  
  2840.  
  2841. /***/ }),
  2842. /* 13 */
  2843. /***/ (function(module, exports, __webpack_require__) {
  2844.  
  2845. "use strict";
  2846.  
  2847. function isFunction(x) {
  2848. return typeof x === 'function';
  2849. }
  2850. exports.isFunction = isFunction;
  2851. //# sourceMappingURL=isFunction.js.map
  2852.  
  2853. /***/ }),
  2854. /* 14 */
  2855. /***/ (function(module, exports, __webpack_require__) {
  2856.  
  2857. "use strict";
  2858.  
  2859. // typeof any so that it we don't have to cast when comparing a result to the error object
  2860. exports.errorObject = { e: {} };
  2861. //# sourceMappingURL=errorObject.js.map
  2862.  
  2863. /***/ }),
  2864. /* 15 */
  2865. /***/ (function(module, exports, __webpack_require__) {
  2866.  
  2867. "use strict";
  2868.  
  2869. exports.empty = {
  2870. closed: true,
  2871. next: function (value) { },
  2872. error: function (err) { throw err; },
  2873. complete: function () { }
  2874. };
  2875. //# sourceMappingURL=Observer.js.map
  2876.  
  2877. /***/ }),
  2878. /* 16 */
  2879. /***/ (function(module, exports, __webpack_require__) {
  2880.  
  2881. "use strict";
  2882.  
  2883. var __extends = (this && this.__extends) || function (d, b) {
  2884. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2885. function __() { this.constructor = d; }
  2886. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2887. };
  2888. /**
  2889. * An error thrown when an action is invalid because the object has been
  2890. * unsubscribed.
  2891. *
  2892. * @see {@link Subject}
  2893. * @see {@link BehaviorSubject}
  2894. *
  2895. * @class ObjectUnsubscribedError
  2896. */
  2897. var ObjectUnsubscribedError = (function (_super) {
  2898. __extends(ObjectUnsubscribedError, _super);
  2899. function ObjectUnsubscribedError() {
  2900. var err = _super.call(this, 'object unsubscribed');
  2901. this.name = err.name = 'ObjectUnsubscribedError';
  2902. this.stack = err.stack;
  2903. this.message = err.message;
  2904. }
  2905. return ObjectUnsubscribedError;
  2906. }(Error));
  2907. exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
  2908. //# sourceMappingURL=ObjectUnsubscribedError.js.map
  2909.  
  2910. /***/ }),
  2911. /* 17 */
  2912. /***/ (function(module, exports, __webpack_require__) {
  2913.  
  2914. "use strict";
  2915.  
  2916. var __extends = (this && this.__extends) || function (d, b) {
  2917. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2918. function __() { this.constructor = d; }
  2919. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2920. };
  2921. var Subscription_1 = __webpack_require__(4);
  2922. /**
  2923. * We need this JSDoc comment for affecting ESDoc.
  2924. * @ignore
  2925. * @extends {Ignored}
  2926. */
  2927. var SubjectSubscription = (function (_super) {
  2928. __extends(SubjectSubscription, _super);
  2929. function SubjectSubscription(subject, subscriber) {
  2930. _super.call(this);
  2931. this.subject = subject;
  2932. this.subscriber = subscriber;
  2933. this.closed = false;
  2934. }
  2935. SubjectSubscription.prototype.unsubscribe = function () {
  2936. if (this.closed) {
  2937. return;
  2938. }
  2939. this.closed = true;
  2940. var subject = this.subject;
  2941. var observers = subject.observers;
  2942. this.subject = null;
  2943. if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
  2944. return;
  2945. }
  2946. var subscriberIndex = observers.indexOf(this.subscriber);
  2947. if (subscriberIndex !== -1) {
  2948. observers.splice(subscriberIndex, 1);
  2949. }
  2950. };
  2951. return SubjectSubscription;
  2952. }(Subscription_1.Subscription));
  2953. exports.SubjectSubscription = SubjectSubscription;
  2954. //# sourceMappingURL=SubjectSubscription.js.map
  2955.  
  2956. /***/ }),
  2957. /* 18 */
  2958. /***/ (function(module, exports, __webpack_require__) {
  2959.  
  2960. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(3)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, SimpleCache_1) {
  2961. "use strict";
  2962. Object.defineProperty(exports, "__esModule", { value: true });
  2963. var ChatApi = /** @class */ (function () {
  2964. function ChatApi(chatUrl) {
  2965. if (chatUrl === void 0) { chatUrl = 'https://chat.stackoverflow.com'; }
  2966. this.chatRoomUrl = "" + chatUrl;
  2967. }
  2968. ChatApi.prototype.GetChannelFKey = function (roomId) {
  2969. return tslib_1.__awaiter(this, void 0, void 0, function () {
  2970. var _this = this;
  2971. var cachingKey, getterPromise, expiryDate;
  2972. return tslib_1.__generator(this, function (_a) {
  2973. cachingKey = "StackExchange.ChatApi.FKey_" + roomId;
  2974. getterPromise = new Promise(function (resolve, reject) {
  2975. _this.GetChannelPage(roomId).then(function (channelPage) {
  2976. var fkeyElement = $(channelPage).filter('#fkey');
  2977. if (fkeyElement.length > 0) {
  2978. var fkey = fkeyElement.val();
  2979. resolve(fkey);
  2980. return;
  2981. }
  2982. reject('Could not find fkey');
  2983. });
  2984. });
  2985. expiryDate = new Date();
  2986. expiryDate.setDate(expiryDate.getDate() + 1);
  2987. return [2 /*return*/, SimpleCache_1.SimpleCache.GetAndCache(cachingKey, function () { return getterPromise; }, expiryDate)];
  2988. });
  2989. });
  2990. };
  2991. ChatApi.prototype.GetChatUserId = function (roomId) {
  2992. return tslib_1.__awaiter(this, void 0, void 0, function () {
  2993. var _this = this;
  2994. var cachingKey, getterPromise, expiryDate;
  2995. return tslib_1.__generator(this, function (_a) {
  2996. cachingKey = "StackExchange.ChatApi.UserId_" + roomId;
  2997. getterPromise = new Promise(function (resolve, reject) {
  2998. _this.GetChannelPage(roomId).then(function (channelPage) {
  2999. var activeUserDiv = $('#active-user', $(channelPage));
  3000. var classAtr = activeUserDiv.attr('class');
  3001. var match = classAtr.match(/user-(\d+)/);
  3002. if (match && match.length) {
  3003. resolve(parseInt(match[1], 10));
  3004. }
  3005. reject('Could not find user id');
  3006. });
  3007. });
  3008. expiryDate = new Date();
  3009. expiryDate.setDate(expiryDate.getDate() + 1);
  3010. return [2 /*return*/, SimpleCache_1.SimpleCache.GetAndCache(cachingKey, function () { return getterPromise; }, expiryDate)];
  3011. });
  3012. });
  3013. };
  3014. ChatApi.prototype.SendMessage = function (roomId, message, providedFkey) {
  3015. var _this = this;
  3016. var fkeyPromise = providedFkey
  3017. ? Promise.resolve(providedFkey)
  3018. : this.GetChannelFKey(roomId);
  3019. return fkeyPromise.then(function (fKey) {
  3020. return new Promise(function (resolve, reject) {
  3021. GM_xmlhttpRequest({
  3022. method: 'POST',
  3023. url: _this.chatRoomUrl + "/chats/" + roomId + "/messages/new",
  3024. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  3025. data: 'text=' + encodeURIComponent(message) + '&fkey=' + fKey,
  3026. onload: function (response) {
  3027. if (response.status !== 200) {
  3028. reject(response.statusText);
  3029. }
  3030. else {
  3031. resolve();
  3032. }
  3033. },
  3034. onerror: function (response) {
  3035. reject(response);
  3036. },
  3037. });
  3038. });
  3039. });
  3040. };
  3041. ChatApi.prototype.GetChannelPage = function (roomId) {
  3042. var _this = this;
  3043. var cachingKey = "StackExchange.ChatApi.ChannelData_" + roomId;
  3044. var getterPromise = new Promise(function (resolve, reject) {
  3045. GM_xmlhttpRequest({
  3046. method: 'GET',
  3047. url: _this.chatRoomUrl + "/rooms/" + roomId,
  3048. onload: function (response) {
  3049. if (response.status !== 200) {
  3050. reject(response.statusText);
  3051. }
  3052. else {
  3053. resolve(response.responseText);
  3054. }
  3055. },
  3056. onerror: function (data) { return reject(data); }
  3057. });
  3058. });
  3059. var expiryDate = new Date();
  3060. expiryDate.setDate(expiryDate.getDate() + 1);
  3061. return SimpleCache_1.SimpleCache.GetAndCache(cachingKey, function () { return getterPromise; }, expiryDate);
  3062. };
  3063. return ChatApi;
  3064. }());
  3065. exports.ChatApi = ChatApi;
  3066. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  3067. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3068.  
  3069.  
  3070. /***/ }),
  3071. /* 19 */
  3072. /***/ (function(module, exports, __webpack_require__) {
  3073.  
  3074. "use strict";
  3075.  
  3076. var Observable_1 = __webpack_require__(1);
  3077. var take_1 = __webpack_require__(40);
  3078. Observable_1.Observable.prototype.take = take_1.take;
  3079. //# sourceMappingURL=take.js.map
  3080.  
  3081. /***/ }),
  3082. /* 20 */
  3083. /***/ (function(module, exports, __webpack_require__) {
  3084.  
  3085. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(9), __webpack_require__(10), __webpack_require__(3), __webpack_require__(19)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, ReplaySubject_1, CrossDomainCache_1, SimpleCache_1) {
  3086. "use strict";
  3087. Object.defineProperty(exports, "__esModule", { value: true });
  3088. exports.MetaSmokeDisabledConfig = 'MetaSmoke.Disabled';
  3089. exports.MetaSmokeUserKeyConfig = 'MetaSmoke.UserKey';
  3090. exports.MetaSmokeWasReportedConfig = 'MetaSmoke.WasReported';
  3091. function Delay(milliseconds) {
  3092. return new Promise(function (resolve) {
  3093. setTimeout(function () {
  3094. resolve();
  3095. }, milliseconds);
  3096. });
  3097. }
  3098. var MetaSmokeAPI = /** @class */ (function () {
  3099. function MetaSmokeAPI() {
  3100. }
  3101. MetaSmokeAPI.Reset = function () {
  3102. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3103. return tslib_1.__generator(this, function (_a) {
  3104. switch (_a.label) {
  3105. case 0: return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.Unset(exports.MetaSmokeDisabledConfig)];
  3106. case 1:
  3107. _a.sent();
  3108. return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.Unset(exports.MetaSmokeUserKeyConfig)];
  3109. case 2:
  3110. _a.sent();
  3111. SimpleCache_1.SimpleCache.Unset(exports.MetaSmokeDisabledConfig);
  3112. SimpleCache_1.SimpleCache.Unset(exports.MetaSmokeUserKeyConfig);
  3113. return [2 /*return*/];
  3114. }
  3115. });
  3116. });
  3117. };
  3118. MetaSmokeAPI.IsDisabled = function () {
  3119. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3120. var cachedDisabled;
  3121. return tslib_1.__generator(this, function (_a) {
  3122. switch (_a.label) {
  3123. case 0: return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.GetFromCache(exports.MetaSmokeDisabledConfig)];
  3124. case 1:
  3125. cachedDisabled = _a.sent();
  3126. if (cachedDisabled === undefined) {
  3127. return [2 /*return*/, false];
  3128. }
  3129. return [2 /*return*/, cachedDisabled];
  3130. }
  3131. });
  3132. });
  3133. };
  3134. MetaSmokeAPI.Setup = function (appKey, codeGetter) {
  3135. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3136. var _this = this;
  3137. return tslib_1.__generator(this, function (_a) {
  3138. if (!codeGetter) {
  3139. codeGetter = function (metaSmokeOAuthUrl) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  3140. var isDisabled, returnCode;
  3141. return tslib_1.__generator(this, function (_a) {
  3142. switch (_a.label) {
  3143. case 0: return [4 /*yield*/, MetaSmokeAPI.IsDisabled()];
  3144. case 1:
  3145. isDisabled = _a.sent();
  3146. if (isDisabled) {
  3147. return [2 /*return*/];
  3148. }
  3149. if (!confirm('Setting up MetaSmoke... If you do not wish to connect, press cancel. This will not show again if you press cancel. To reset configuration, see footer of Stack Overflow.')) {
  3150. CrossDomainCache_1.CrossDomainCache.StoreInCache(exports.MetaSmokeDisabledConfig, true);
  3151. return [2 /*return*/];
  3152. }
  3153. window.open(metaSmokeOAuthUrl, '_blank');
  3154. return [4 /*yield*/, Delay(100)];
  3155. case 2:
  3156. _a.sent();
  3157. return [4 /*yield*/, new Promise(function (resolve) {
  3158. var handleFDSCCode = function () {
  3159. $(window).off('focus', handleFDSCCode);
  3160. var code = window.prompt('Once you\'ve authenticated FDSC with metasmoke, you\'ll be given a code; enter it here.');
  3161. if (!code) {
  3162. resolve();
  3163. }
  3164. else {
  3165. return resolve(code);
  3166. }
  3167. };
  3168. $(window).focus(handleFDSCCode);
  3169. })];
  3170. case 3:
  3171. returnCode = _a.sent();
  3172. return [2 /*return*/, returnCode];
  3173. }
  3174. });
  3175. }); };
  3176. }
  3177. MetaSmokeAPI.codeGetter = codeGetter;
  3178. MetaSmokeAPI.appKey = appKey;
  3179. MetaSmokeAPI.getUserKey(); // Make sure we request it immediately
  3180. return [2 /*return*/];
  3181. });
  3182. });
  3183. };
  3184. MetaSmokeAPI.QueryMetaSmoke = function (postId, postType) {
  3185. var url = MetaSmokeAPI.GetQueryUrl(postId, postType);
  3186. var existingResult = SimpleCache_1.SimpleCache.GetFromCache(exports.MetaSmokeWasReportedConfig + "." + url);
  3187. if (existingResult !== undefined) {
  3188. var key = MetaSmokeAPI.GetObservableKey(postId, postType);
  3189. var obs = MetaSmokeAPI.ObservableLookup[key];
  3190. if (obs) {
  3191. obs.next(existingResult);
  3192. // setTimeout(() => obs.next(existingResult), 100);
  3193. }
  3194. return;
  3195. }
  3196. if (this.pendingTimeout) {
  3197. clearTimeout(this.pendingTimeout);
  3198. }
  3199. this.pendingPosts.push({ postId: postId, postType: postType });
  3200. this.pendingTimeout = setTimeout(MetaSmokeAPI.QueryMetaSmokeInternal, 1000);
  3201. };
  3202. MetaSmokeAPI.QueryMetaSmokeInternal = function () {
  3203. var pendingPostLookup = {};
  3204. var urls = [];
  3205. try {
  3206. for (var _a = tslib_1.__values(MetaSmokeAPI.pendingPosts), _b = _a.next(); !_b.done; _b = _a.next()) {
  3207. var pendingPost = _b.value;
  3208. var url = MetaSmokeAPI.GetQueryUrl(pendingPost.postId, pendingPost.postType);
  3209. pendingPostLookup[url] = { postId: pendingPost.postId, postType: pendingPost.postType };
  3210. urls.push(url);
  3211. }
  3212. }
  3213. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  3214. finally {
  3215. try {
  3216. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  3217. }
  3218. finally { if (e_1) throw e_1.error; }
  3219. }
  3220. MetaSmokeAPI.pendingPosts = [];
  3221. var urlStr = urls.join();
  3222. var expiryDate = new Date();
  3223. expiryDate.setDate(expiryDate.getDate() + 30);
  3224. MetaSmokeAPI.IsDisabled().then(function (isDisabled) {
  3225. if (isDisabled) {
  3226. return;
  3227. }
  3228. $.ajax({
  3229. type: 'GET',
  3230. url: 'https://metasmoke.erwaysoftware.com/api/v2.0/posts/urls',
  3231. data: {
  3232. urls: urlStr,
  3233. key: "" + MetaSmokeAPI.appKey
  3234. }
  3235. }).done(function (metaSmokeResult) {
  3236. try {
  3237. for (var _a = tslib_1.__values(metaSmokeResult.items), _b = _a.next(); !_b.done; _b = _a.next()) {
  3238. var item = _b.value;
  3239. var pendingPost = pendingPostLookup[item.link];
  3240. if (pendingPost) {
  3241. var key = MetaSmokeAPI.GetObservableKey(pendingPost.postId, pendingPost.postType);
  3242. var obs = MetaSmokeAPI.ObservableLookup[key];
  3243. if (obs) {
  3244. obs.next(item.id);
  3245. SimpleCache_1.SimpleCache.StoreInCache(exports.MetaSmokeWasReportedConfig + "." + item.link, item.id, expiryDate);
  3246. }
  3247. delete pendingPostLookup[item.link];
  3248. }
  3249. }
  3250. }
  3251. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  3252. finally {
  3253. try {
  3254. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  3255. }
  3256. finally { if (e_2) throw e_2.error; }
  3257. }
  3258. for (var url in pendingPostLookup) {
  3259. if (pendingPostLookup.hasOwnProperty(url)) {
  3260. var pendingPost = pendingPostLookup[url];
  3261. var key = MetaSmokeAPI.GetObservableKey(pendingPost.postId, pendingPost.postType);
  3262. var obs = MetaSmokeAPI.ObservableLookup[key];
  3263. if (obs) {
  3264. obs.next(null);
  3265. SimpleCache_1.SimpleCache.StoreInCache(exports.MetaSmokeWasReportedConfig + "." + url, null, expiryDate);
  3266. }
  3267. }
  3268. }
  3269. var e_2, _c;
  3270. }).fail(function (error) {
  3271. for (var url in pendingPostLookup) {
  3272. if (pendingPostLookup.hasOwnProperty(url)) {
  3273. var pendingPost = pendingPostLookup[url];
  3274. var key = MetaSmokeAPI.GetObservableKey(pendingPost.postId, pendingPost.postType);
  3275. var obs = MetaSmokeAPI.ObservableLookup[key];
  3276. if (obs) {
  3277. obs.error(error);
  3278. }
  3279. }
  3280. }
  3281. });
  3282. });
  3283. var e_1, _c;
  3284. };
  3285. MetaSmokeAPI.GetQueryUrl = function (postId, postType) {
  3286. return postType === 'Answer'
  3287. ? "//" + window.location.hostname + "/a/" + postId
  3288. : "//" + window.location.hostname + "/questions/" + postId;
  3289. };
  3290. MetaSmokeAPI.GetSmokeyId = function (postId, postType) {
  3291. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3292. var observableKey, observable;
  3293. return tslib_1.__generator(this, function (_a) {
  3294. observableKey = this.GetObservableKey(postId, postType);
  3295. observable = MetaSmokeAPI.ObservableLookup[observableKey];
  3296. if (observable) {
  3297. return [2 /*return*/, observable.take(1).toPromise()];
  3298. }
  3299. return [2 /*return*/, null];
  3300. });
  3301. });
  3302. };
  3303. MetaSmokeAPI.GetObservableKey = function (postId, postType) {
  3304. return JSON.stringify({ postId: postId, postType: postType });
  3305. };
  3306. MetaSmokeAPI.getUserKey = function () {
  3307. var _this = this;
  3308. return SimpleCache_1.SimpleCache.GetAndCache(exports.MetaSmokeUserKeyConfig, function () {
  3309. return CrossDomainCache_1.CrossDomainCache.GetAndCache(exports.MetaSmokeUserKeyConfig, function () { return new Promise(function (resolve, reject) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  3310. var prom, code;
  3311. return tslib_1.__generator(this, function (_a) {
  3312. switch (_a.label) {
  3313. case 0:
  3314. prom = MetaSmokeAPI.actualPromise;
  3315. if (prom === undefined) {
  3316. prom = MetaSmokeAPI.codeGetter("https://metasmoke.erwaysoftware.com/oauth/request?key=" + MetaSmokeAPI.appKey);
  3317. MetaSmokeAPI.actualPromise = prom;
  3318. }
  3319. return [4 /*yield*/, prom];
  3320. case 1:
  3321. code = _a.sent();
  3322. if (code) {
  3323. $.ajax({
  3324. url: 'https://metasmoke.erwaysoftware.com/oauth/token?key=' + MetaSmokeAPI.appKey + '&code=' + code,
  3325. method: 'GET'
  3326. }).done(function (data) { return resolve(data.token); })
  3327. .fail(function (err) { return reject(err); });
  3328. }
  3329. return [2 /*return*/];
  3330. }
  3331. });
  3332. }); }); });
  3333. });
  3334. };
  3335. MetaSmokeAPI.prototype.Watch = function (postId, postType) {
  3336. var key = MetaSmokeAPI.GetObservableKey(postId, postType);
  3337. if (!MetaSmokeAPI.ObservableLookup[key]) {
  3338. var replaySubject = new ReplaySubject_1.ReplaySubject(1);
  3339. MetaSmokeAPI.ObservableLookup[key] = replaySubject;
  3340. }
  3341. MetaSmokeAPI.QueryMetaSmoke(postId, postType);
  3342. return MetaSmokeAPI.ObservableLookup[key];
  3343. };
  3344. MetaSmokeAPI.prototype.ReportNaa = function (postId, postType) {
  3345. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3346. var smokeyid;
  3347. return tslib_1.__generator(this, function (_a) {
  3348. switch (_a.label) {
  3349. case 0: return [4 /*yield*/, MetaSmokeAPI.GetSmokeyId(postId, postType)];
  3350. case 1:
  3351. smokeyid = _a.sent();
  3352. if (!(smokeyid != null)) return [3 /*break*/, 3];
  3353. return [4 /*yield*/, this.SendFeedback(smokeyid, 'naa-')];
  3354. case 2:
  3355. _a.sent();
  3356. return [2 /*return*/, true];
  3357. case 3: return [2 /*return*/, false];
  3358. }
  3359. });
  3360. });
  3361. };
  3362. MetaSmokeAPI.prototype.ReportRedFlag = function (postId, postType) {
  3363. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3364. var _this = this;
  3365. var smokeyid, urlStr_1, promise, result, queryUrlStr;
  3366. return tslib_1.__generator(this, function (_a) {
  3367. switch (_a.label) {
  3368. case 0: return [4 /*yield*/, MetaSmokeAPI.GetSmokeyId(postId, postType)];
  3369. case 1:
  3370. smokeyid = _a.sent();
  3371. if (!(smokeyid != null)) return [3 /*break*/, 3];
  3372. return [4 /*yield*/, this.SendFeedback(smokeyid, 'tpu-')];
  3373. case 2:
  3374. _a.sent();
  3375. return [2 /*return*/, true];
  3376. case 3:
  3377. urlStr_1 = postType === 'Answer'
  3378. ? "//" + window.location.hostname + "/a/" + postId
  3379. : "//" + window.location.hostname + "/q/" + postId;
  3380. promise = new Promise(function (resolve, reject) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  3381. var userKey;
  3382. return tslib_1.__generator(this, function (_a) {
  3383. switch (_a.label) {
  3384. case 0: return [4 /*yield*/, MetaSmokeAPI.getUserKey()];
  3385. case 1:
  3386. userKey = _a.sent();
  3387. if (userKey) {
  3388. $.ajax({
  3389. type: 'POST',
  3390. url: 'https://metasmoke.erwaysoftware.com/api/w/post/report',
  3391. data: {
  3392. post_link: urlStr_1,
  3393. key: MetaSmokeAPI.appKey,
  3394. token: userKey
  3395. }
  3396. }).done(function () { return resolve(true); })
  3397. .fail(function () { return reject(); });
  3398. }
  3399. return [2 /*return*/];
  3400. }
  3401. });
  3402. }); });
  3403. return [4 /*yield*/, promise];
  3404. case 4:
  3405. result = _a.sent();
  3406. queryUrlStr = MetaSmokeAPI.GetQueryUrl(postId, postType);
  3407. SimpleCache_1.SimpleCache.Unset(exports.MetaSmokeWasReportedConfig + "." + queryUrlStr);
  3408. return [4 /*yield*/, Delay(1000)];
  3409. case 5:
  3410. _a.sent();
  3411. MetaSmokeAPI.QueryMetaSmoke(postId, postType);
  3412. return [2 /*return*/, result];
  3413. }
  3414. });
  3415. });
  3416. };
  3417. MetaSmokeAPI.prototype.ReportLooksFine = function (postId, postType) {
  3418. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3419. var smokeyid;
  3420. return tslib_1.__generator(this, function (_a) {
  3421. switch (_a.label) {
  3422. case 0: return [4 /*yield*/, MetaSmokeAPI.GetSmokeyId(postId, postType)];
  3423. case 1:
  3424. smokeyid = _a.sent();
  3425. if (!(smokeyid != null)) return [3 /*break*/, 3];
  3426. return [4 /*yield*/, this.SendFeedback(smokeyid, 'fp-')];
  3427. case 2:
  3428. _a.sent();
  3429. return [2 /*return*/, true];
  3430. case 3: return [2 /*return*/, false];
  3431. }
  3432. });
  3433. });
  3434. };
  3435. MetaSmokeAPI.prototype.ReportNeedsEditing = function (postId, postType) {
  3436. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3437. var smokeyid;
  3438. return tslib_1.__generator(this, function (_a) {
  3439. switch (_a.label) {
  3440. case 0: return [4 /*yield*/, MetaSmokeAPI.GetSmokeyId(postId, postType)];
  3441. case 1:
  3442. smokeyid = _a.sent();
  3443. if (!(smokeyid != null)) return [3 /*break*/, 3];
  3444. return [4 /*yield*/, this.SendFeedback(smokeyid, 'fp-')];
  3445. case 2:
  3446. _a.sent();
  3447. return [2 /*return*/, true];
  3448. case 3: return [2 /*return*/, false];
  3449. }
  3450. });
  3451. });
  3452. };
  3453. MetaSmokeAPI.prototype.ReportVandalism = function (postId, postType) {
  3454. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3455. var smokeyid;
  3456. return tslib_1.__generator(this, function (_a) {
  3457. switch (_a.label) {
  3458. case 0: return [4 /*yield*/, MetaSmokeAPI.GetSmokeyId(postId, postType)];
  3459. case 1:
  3460. smokeyid = _a.sent();
  3461. if (!(smokeyid != null)) return [3 /*break*/, 3];
  3462. return [4 /*yield*/, this.SendFeedback(smokeyid, 'tp-')];
  3463. case 2:
  3464. _a.sent();
  3465. return [2 /*return*/, true];
  3466. case 3: return [2 /*return*/, false];
  3467. }
  3468. });
  3469. });
  3470. };
  3471. MetaSmokeAPI.prototype.SendFeedback = function (metaSmokeId, feedbackType) {
  3472. return new Promise(function (resolve, reject) {
  3473. MetaSmokeAPI.getUserKey().then(function (userKey) {
  3474. $.ajax({
  3475. type: 'POST',
  3476. url: "https://metasmoke.erwaysoftware.com/api/w/post/" + metaSmokeId + "/feedback",
  3477. data: {
  3478. type: feedbackType,
  3479. key: MetaSmokeAPI.appKey,
  3480. token: userKey
  3481. }
  3482. }).done(function () { return resolve(); })
  3483. .fail(function () { return reject(); });
  3484. });
  3485. });
  3486. };
  3487. MetaSmokeAPI.ObservableLookup = {};
  3488. MetaSmokeAPI.pendingPosts = [];
  3489. MetaSmokeAPI.pendingTimeout = null;
  3490. return MetaSmokeAPI;
  3491. }());
  3492. exports.MetaSmokeAPI = MetaSmokeAPI;
  3493. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  3494. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3495.  
  3496.  
  3497. /***/ }),
  3498. /* 21 */
  3499. /***/ (function(module, exports, __webpack_require__) {
  3500.  
  3501. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(7)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, sotools_1) {
  3502. "use strict";
  3503. Object.defineProperty(exports, "__esModule", { value: true });
  3504. var genericBotUrl = 'https://so.floern.com/api/trackpost.php';
  3505. var genericBotKey = 'Cm45BSrt51FR3ju';
  3506. var GenericBotAPI = /** @class */ (function () {
  3507. function GenericBotAPI(answerId) {
  3508. this.answerId = answerId;
  3509. }
  3510. GenericBotAPI.prototype.ReportNaa = function () {
  3511. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3512. var response;
  3513. return tslib_1.__generator(this, function (_a) {
  3514. switch (_a.label) {
  3515. case 0: return [4 /*yield*/, this.makeTrackRequest()];
  3516. case 1:
  3517. response = _a.sent();
  3518. return [2 /*return*/, response];
  3519. }
  3520. });
  3521. });
  3522. };
  3523. GenericBotAPI.prototype.ReportRedFlag = function () {
  3524. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3525. var response;
  3526. return tslib_1.__generator(this, function (_a) {
  3527. switch (_a.label) {
  3528. case 0: return [4 /*yield*/, this.makeTrackRequest()];
  3529. case 1:
  3530. response = _a.sent();
  3531. return [2 /*return*/, response];
  3532. }
  3533. });
  3534. });
  3535. };
  3536. GenericBotAPI.prototype.ReportLooksFine = function () {
  3537. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3538. return tslib_1.__generator(this, function (_a) {
  3539. return [2 /*return*/, false];
  3540. });
  3541. });
  3542. };
  3543. GenericBotAPI.prototype.ReportNeedsEditing = function () {
  3544. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3545. return tslib_1.__generator(this, function (_a) {
  3546. return [2 /*return*/, false];
  3547. });
  3548. });
  3549. };
  3550. GenericBotAPI.prototype.computeContentHash = function (postContent) {
  3551. if (!postContent) {
  3552. return 0;
  3553. }
  3554. var hash = 0;
  3555. for (var i = 0; i < postContent.length; ++i) {
  3556. hash = ((hash << 5) - hash) + postContent.charCodeAt(i);
  3557. hash = hash & hash;
  3558. }
  3559. return hash;
  3560. };
  3561. GenericBotAPI.prototype.makeTrackRequest = function () {
  3562. var _this = this;
  3563. var promise = new Promise(function (resolve, reject) {
  3564. if (!sotools_1.IsStackOverflow()) {
  3565. resolve(false);
  3566. }
  3567. if ($('#answer-' + _this.answerId + ' .post-text').length === 0) {
  3568. resolve(false);
  3569. }
  3570. if ($('.top-bar .my-profile .gravatar-wrapper-24').length === 0) {
  3571. reject('Flag Tracker: Could not find username.');
  3572. }
  3573. var flaggerName = $('.top-bar .my-profile .gravatar-wrapper-24').attr('title');
  3574. var contentHash = _this.computeContentHash($('#answer-' + _this.answerId + ' .post-text').html().trim());
  3575. GM_xmlhttpRequest({
  3576. method: 'POST',
  3577. url: 'https://so.floern.com/api/trackpost.php',
  3578. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  3579. data: "key=" + genericBotKey
  3580. + '&postId=' + _this.answerId
  3581. + '&contentHash=' + contentHash
  3582. + '&flagger=' + encodeURIComponent(flaggerName),
  3583. onload: function (response) {
  3584. if (response.status !== 200) {
  3585. reject('Flag Tracker Error: Status ' + response.status);
  3586. }
  3587. resolve(true);
  3588. },
  3589. onerror: function (response) {
  3590. reject('Flag Tracker Error: ' + response.responseText);
  3591. }
  3592. });
  3593. });
  3594. return promise;
  3595. };
  3596. return GenericBotAPI;
  3597. }());
  3598. exports.GenericBotAPI = GenericBotAPI;
  3599. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  3600. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3601.  
  3602.  
  3603. /***/ }),
  3604. /* 22 */
  3605. /***/ (function(module, exports, __webpack_require__) {
  3606.  
  3607. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(5), __webpack_require__(9), __webpack_require__(7), __webpack_require__(3), __webpack_require__(18), __webpack_require__(19)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, Subject_1, ReplaySubject_1, sotools_1, SimpleCache_1, ChatApi_1) {
  3608. "use strict";
  3609. Object.defineProperty(exports, "__esModule", { value: true });
  3610. var nattyFeedbackUrl = 'http://logs.sobotics.org/napi/api/feedback';
  3611. var soboticsRoomId = 111347;
  3612. var NattyAPI = /** @class */ (function () {
  3613. function NattyAPI(answerId) {
  3614. this.chat = new ChatApi_1.ChatApi();
  3615. this.subject = new Subject_1.Subject();
  3616. this.replaySubject = new ReplaySubject_1.ReplaySubject();
  3617. this.answerId = answerId;
  3618. }
  3619. NattyAPI.prototype.Watch = function () {
  3620. var _this = this;
  3621. this.subject.subscribe(this.replaySubject);
  3622. if (sotools_1.IsStackOverflow()) {
  3623. var expiryDate = new Date();
  3624. expiryDate.setDate(expiryDate.getDate() + 30);
  3625. SimpleCache_1.SimpleCache.GetAndCache("NattyApi.Feedback." + this.answerId, function () { return new Promise(function (resolve, reject) {
  3626. GM_xmlhttpRequest({
  3627. method: 'GET',
  3628. url: nattyFeedbackUrl + "/" + _this.answerId,
  3629. onload: function (response) {
  3630. if (response.status === 200) {
  3631. var nattyResult = JSON.parse(response.responseText);
  3632. if (nattyResult.items && nattyResult.items[0]) {
  3633. resolve(true);
  3634. }
  3635. else {
  3636. resolve(false);
  3637. }
  3638. }
  3639. else {
  3640. reject('Failed to retrieve natty report: ' + response.responseText);
  3641. }
  3642. },
  3643. onerror: function (response) {
  3644. reject(response);
  3645. },
  3646. });
  3647. }); }, expiryDate)
  3648. .then(function (r) { return _this.subject.next(r); })
  3649. .catch(function (err) { return _this.subject.error(err); });
  3650. }
  3651. return this.subject;
  3652. };
  3653. NattyAPI.prototype.ReportNaa = function (answerDate, questionDate) {
  3654. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3655. var _this = this;
  3656. var answerAge, daysPostedAfterQuestion, promise;
  3657. return tslib_1.__generator(this, function (_a) {
  3658. switch (_a.label) {
  3659. case 0:
  3660. if (answerDate < questionDate) {
  3661. throw new Error('Answer must be posted after the question');
  3662. }
  3663. if (!sotools_1.IsStackOverflow()) {
  3664. return [2 /*return*/, false];
  3665. }
  3666. return [4 /*yield*/, this.WasReported()];
  3667. case 1:
  3668. if (!_a.sent()) return [3 /*break*/, 3];
  3669. return [4 /*yield*/, this.chat.SendMessage(soboticsRoomId, "@Alisha feedback http://stackoverflow.com/a/" + this.answerId + " tp")];
  3670. case 2:
  3671. _a.sent();
  3672. return [2 /*return*/, true];
  3673. case 3:
  3674. answerAge = this.DaysBetween(answerDate, new Date());
  3675. daysPostedAfterQuestion = this.DaysBetween(questionDate, answerDate);
  3676. if (isNaN(answerAge)) {
  3677. throw new Error('Invalid answerDate provided');
  3678. }
  3679. if (isNaN(daysPostedAfterQuestion)) {
  3680. throw new Error('Invalid questionDate provided');
  3681. }
  3682. if (answerAge > 30 || daysPostedAfterQuestion < 30) {
  3683. return [2 /*return*/, false];
  3684. }
  3685. promise = this.chat.SendMessage(soboticsRoomId, "@Alisha report http://stackoverflow.com/a/" + this.answerId);
  3686. return [4 /*yield*/, promise.then(function () {
  3687. var expiryDate = new Date();
  3688. expiryDate.setDate(expiryDate.getDate() + 30);
  3689. SimpleCache_1.SimpleCache.StoreInCache("NattyApi.Feedback." + _this.answerId, true, expiryDate);
  3690. _this.subject.next(true);
  3691. })];
  3692. case 4:
  3693. _a.sent();
  3694. return [2 /*return*/, true];
  3695. }
  3696. });
  3697. });
  3698. };
  3699. NattyAPI.prototype.ReportRedFlag = function () {
  3700. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3701. return tslib_1.__generator(this, function (_a) {
  3702. switch (_a.label) {
  3703. case 0:
  3704. if (!sotools_1.IsStackOverflow()) {
  3705. return [2 /*return*/, false];
  3706. }
  3707. return [4 /*yield*/, this.WasReported()];
  3708. case 1:
  3709. if (!_a.sent()) return [3 /*break*/, 3];
  3710. return [4 /*yield*/, this.chat.SendMessage(soboticsRoomId, "@Alisha feedback http://stackoverflow.com/a/" + this.answerId + " tp")];
  3711. case 2:
  3712. _a.sent();
  3713. return [2 /*return*/, true];
  3714. case 3: return [2 /*return*/, false];
  3715. }
  3716. });
  3717. });
  3718. };
  3719. NattyAPI.prototype.ReportLooksFine = function () {
  3720. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3721. return tslib_1.__generator(this, function (_a) {
  3722. switch (_a.label) {
  3723. case 0:
  3724. if (!sotools_1.IsStackOverflow()) {
  3725. return [2 /*return*/, false];
  3726. }
  3727. return [4 /*yield*/, this.WasReported()];
  3728. case 1:
  3729. if (!_a.sent()) return [3 /*break*/, 3];
  3730. return [4 /*yield*/, this.chat.SendMessage(soboticsRoomId, "@Alisha feedback http://stackoverflow.com/a/" + this.answerId + " fp")];
  3731. case 2:
  3732. _a.sent();
  3733. return [2 /*return*/, true];
  3734. case 3: return [2 /*return*/, false];
  3735. }
  3736. });
  3737. });
  3738. };
  3739. NattyAPI.prototype.ReportNeedsEditing = function () {
  3740. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3741. return tslib_1.__generator(this, function (_a) {
  3742. switch (_a.label) {
  3743. case 0:
  3744. if (!sotools_1.IsStackOverflow()) {
  3745. return [2 /*return*/, false];
  3746. }
  3747. return [4 /*yield*/, this.WasReported()];
  3748. case 1:
  3749. if (!_a.sent()) return [3 /*break*/, 3];
  3750. return [4 /*yield*/, this.chat.SendMessage(soboticsRoomId, "@Alisha feedback http://stackoverflow.com/a/" + this.answerId + " ne")];
  3751. case 2:
  3752. _a.sent();
  3753. return [2 /*return*/, true];
  3754. case 3: return [2 /*return*/, false];
  3755. }
  3756. });
  3757. });
  3758. };
  3759. NattyAPI.prototype.WasReported = function () {
  3760. return tslib_1.__awaiter(this, void 0, void 0, function () {
  3761. return tslib_1.__generator(this, function (_a) {
  3762. return [2 /*return*/, this.replaySubject.take(1).toPromise()];
  3763. });
  3764. });
  3765. };
  3766. NattyAPI.prototype.DaysBetween = function (first, second) {
  3767. return (second - first) / (1000 * 60 * 60 * 24);
  3768. };
  3769. return NattyAPI;
  3770. }());
  3771. exports.NattyAPI = NattyAPI;
  3772. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  3773. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3774.  
  3775.  
  3776. /***/ }),
  3777. /* 23 */
  3778. /***/ (function(module, exports, __webpack_require__) {
  3779.  
  3780. "use strict";
  3781.  
  3782. var Subscriber_1 = __webpack_require__(2);
  3783. var rxSubscriber_1 = __webpack_require__(8);
  3784. var Observer_1 = __webpack_require__(15);
  3785. function toSubscriber(nextOrObserver, error, complete) {
  3786. if (nextOrObserver) {
  3787. if (nextOrObserver instanceof Subscriber_1.Subscriber) {
  3788. return nextOrObserver;
  3789. }
  3790. if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
  3791. return nextOrObserver[rxSubscriber_1.rxSubscriber]();
  3792. }
  3793. }
  3794. if (!nextOrObserver && !error && !complete) {
  3795. return new Subscriber_1.Subscriber(Observer_1.empty);
  3796. }
  3797. return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
  3798. }
  3799. exports.toSubscriber = toSubscriber;
  3800. //# sourceMappingURL=toSubscriber.js.map
  3801.  
  3802. /***/ }),
  3803. /* 24 */
  3804. /***/ (function(module, exports, __webpack_require__) {
  3805.  
  3806. "use strict";
  3807.  
  3808. exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
  3809. //# sourceMappingURL=isArray.js.map
  3810.  
  3811. /***/ }),
  3812. /* 25 */
  3813. /***/ (function(module, exports, __webpack_require__) {
  3814.  
  3815. "use strict";
  3816.  
  3817. function isObject(x) {
  3818. return x != null && typeof x === 'object';
  3819. }
  3820. exports.isObject = isObject;
  3821. //# sourceMappingURL=isObject.js.map
  3822.  
  3823. /***/ }),
  3824. /* 26 */
  3825. /***/ (function(module, exports, __webpack_require__) {
  3826.  
  3827. "use strict";
  3828.  
  3829. var errorObject_1 = __webpack_require__(14);
  3830. var tryCatchTarget;
  3831. function tryCatcher() {
  3832. try {
  3833. return tryCatchTarget.apply(this, arguments);
  3834. }
  3835. catch (e) {
  3836. errorObject_1.errorObject.e = e;
  3837. return errorObject_1.errorObject;
  3838. }
  3839. }
  3840. function tryCatch(fn) {
  3841. tryCatchTarget = fn;
  3842. return tryCatcher;
  3843. }
  3844. exports.tryCatch = tryCatch;
  3845. ;
  3846. //# sourceMappingURL=tryCatch.js.map
  3847.  
  3848. /***/ }),
  3849. /* 27 */
  3850. /***/ (function(module, exports, __webpack_require__) {
  3851.  
  3852. "use strict";
  3853.  
  3854. var __extends = (this && this.__extends) || function (d, b) {
  3855. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3856. function __() { this.constructor = d; }
  3857. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3858. };
  3859. /**
  3860. * An error thrown when one or more errors have occurred during the
  3861. * `unsubscribe` of a {@link Subscription}.
  3862. */
  3863. var UnsubscriptionError = (function (_super) {
  3864. __extends(UnsubscriptionError, _super);
  3865. function UnsubscriptionError(errors) {
  3866. _super.call(this);
  3867. this.errors = errors;
  3868. var err = Error.call(this, errors ?
  3869. errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : '');
  3870. this.name = err.name = 'UnsubscriptionError';
  3871. this.stack = err.stack;
  3872. this.message = err.message;
  3873. }
  3874. return UnsubscriptionError;
  3875. }(Error));
  3876. exports.UnsubscriptionError = UnsubscriptionError;
  3877. //# sourceMappingURL=UnsubscriptionError.js.map
  3878.  
  3879. /***/ }),
  3880. /* 28 */
  3881. /***/ (function(module, exports, __webpack_require__) {
  3882.  
  3883. "use strict";
  3884.  
  3885. var root_1 = __webpack_require__(6);
  3886. function getSymbolObservable(context) {
  3887. var $$observable;
  3888. var Symbol = context.Symbol;
  3889. if (typeof Symbol === 'function') {
  3890. if (Symbol.observable) {
  3891. $$observable = Symbol.observable;
  3892. }
  3893. else {
  3894. $$observable = Symbol('observable');
  3895. Symbol.observable = $$observable;
  3896. }
  3897. }
  3898. else {
  3899. $$observable = '@@observable';
  3900. }
  3901. return $$observable;
  3902. }
  3903. exports.getSymbolObservable = getSymbolObservable;
  3904. exports.observable = getSymbolObservable(root_1.root);
  3905. /**
  3906. * @deprecated use observable instead
  3907. */
  3908. exports.$$observable = exports.observable;
  3909. //# sourceMappingURL=observable.js.map
  3910.  
  3911. /***/ }),
  3912. /* 29 */
  3913. /***/ (function(module, exports, __webpack_require__) {
  3914.  
  3915. "use strict";
  3916.  
  3917. var noop_1 = __webpack_require__(30);
  3918. /* tslint:enable:max-line-length */
  3919. function pipe() {
  3920. var fns = [];
  3921. for (var _i = 0; _i < arguments.length; _i++) {
  3922. fns[_i - 0] = arguments[_i];
  3923. }
  3924. return pipeFromArray(fns);
  3925. }
  3926. exports.pipe = pipe;
  3927. /* @internal */
  3928. function pipeFromArray(fns) {
  3929. if (!fns) {
  3930. return noop_1.noop;
  3931. }
  3932. if (fns.length === 1) {
  3933. return fns[0];
  3934. }
  3935. return function piped(input) {
  3936. return fns.reduce(function (prev, fn) { return fn(prev); }, input);
  3937. };
  3938. }
  3939. exports.pipeFromArray = pipeFromArray;
  3940. //# sourceMappingURL=pipe.js.map
  3941.  
  3942. /***/ }),
  3943. /* 30 */
  3944. /***/ (function(module, exports, __webpack_require__) {
  3945.  
  3946. "use strict";
  3947.  
  3948. /* tslint:disable:no-empty */
  3949. function noop() { }
  3950. exports.noop = noop;
  3951. //# sourceMappingURL=noop.js.map
  3952.  
  3953. /***/ }),
  3954. /* 31 */
  3955. /***/ (function(module, exports, __webpack_require__) {
  3956.  
  3957. "use strict";
  3958.  
  3959. var QueueAction_1 = __webpack_require__(32);
  3960. var QueueScheduler_1 = __webpack_require__(35);
  3961. /**
  3962. *
  3963. * Queue Scheduler
  3964. *
  3965. * <span class="informal">Put every next task on a queue, instead of executing it immediately</span>
  3966. *
  3967. * `queue` scheduler, when used with delay, behaves the same as {@link async} scheduler.
  3968. *
  3969. * When used without delay, it schedules given task synchronously - executes it right when
  3970. * it is scheduled. However when called recursively, that is when inside the scheduled task,
  3971. * another task is scheduled with queue scheduler, instead of executing immediately as well,
  3972. * that task will be put on a queue and wait for current one to finish.
  3973. *
  3974. * This means that when you execute task with `queue` scheduler, you are sure it will end
  3975. * before any other task scheduled with that scheduler will start.
  3976. *
  3977. * @examples <caption>Schedule recursively first, then do something</caption>
  3978. *
  3979. * Rx.Scheduler.queue.schedule(() => {
  3980. * Rx.Scheduler.queue.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
  3981. *
  3982. * console.log('first');
  3983. * });
  3984. *
  3985. * // Logs:
  3986. * // "first"
  3987. * // "second"
  3988. *
  3989. *
  3990. * @example <caption>Reschedule itself recursively</caption>
  3991. *
  3992. * Rx.Scheduler.queue.schedule(function(state) {
  3993. * if (state !== 0) {
  3994. * console.log('before', state);
  3995. * this.schedule(state - 1); // `this` references currently executing Action,
  3996. * // which we reschedule with new state
  3997. * console.log('after', state);
  3998. * }
  3999. * }, 0, 3);
  4000. *
  4001. * // In scheduler that runs recursively, you would expect:
  4002. * // "before", 3
  4003. * // "before", 2
  4004. * // "before", 1
  4005. * // "after", 1
  4006. * // "after", 2
  4007. * // "after", 3
  4008. *
  4009. * // But with queue it logs:
  4010. * // "before", 3
  4011. * // "after", 3
  4012. * // "before", 2
  4013. * // "after", 2
  4014. * // "before", 1
  4015. * // "after", 1
  4016. *
  4017. *
  4018. * @static true
  4019. * @name queue
  4020. * @owner Scheduler
  4021. */
  4022. exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
  4023. //# sourceMappingURL=queue.js.map
  4024.  
  4025. /***/ }),
  4026. /* 32 */
  4027. /***/ (function(module, exports, __webpack_require__) {
  4028.  
  4029. "use strict";
  4030.  
  4031. var __extends = (this && this.__extends) || function (d, b) {
  4032. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4033. function __() { this.constructor = d; }
  4034. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4035. };
  4036. var AsyncAction_1 = __webpack_require__(33);
  4037. /**
  4038. * We need this JSDoc comment for affecting ESDoc.
  4039. * @ignore
  4040. * @extends {Ignored}
  4041. */
  4042. var QueueAction = (function (_super) {
  4043. __extends(QueueAction, _super);
  4044. function QueueAction(scheduler, work) {
  4045. _super.call(this, scheduler, work);
  4046. this.scheduler = scheduler;
  4047. this.work = work;
  4048. }
  4049. QueueAction.prototype.schedule = function (state, delay) {
  4050. if (delay === void 0) { delay = 0; }
  4051. if (delay > 0) {
  4052. return _super.prototype.schedule.call(this, state, delay);
  4053. }
  4054. this.delay = delay;
  4055. this.state = state;
  4056. this.scheduler.flush(this);
  4057. return this;
  4058. };
  4059. QueueAction.prototype.execute = function (state, delay) {
  4060. return (delay > 0 || this.closed) ?
  4061. _super.prototype.execute.call(this, state, delay) :
  4062. this._execute(state, delay);
  4063. };
  4064. QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  4065. if (delay === void 0) { delay = 0; }
  4066. // If delay exists and is greater than 0, or if the delay is null (the
  4067. // action wasn't rescheduled) but was originally scheduled as an async
  4068. // action, then recycle as an async action.
  4069. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  4070. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  4071. }
  4072. // Otherwise flush the scheduler starting with this action.
  4073. return scheduler.flush(this);
  4074. };
  4075. return QueueAction;
  4076. }(AsyncAction_1.AsyncAction));
  4077. exports.QueueAction = QueueAction;
  4078. //# sourceMappingURL=QueueAction.js.map
  4079.  
  4080. /***/ }),
  4081. /* 33 */
  4082. /***/ (function(module, exports, __webpack_require__) {
  4083.  
  4084. "use strict";
  4085.  
  4086. var __extends = (this && this.__extends) || function (d, b) {
  4087. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4088. function __() { this.constructor = d; }
  4089. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4090. };
  4091. var root_1 = __webpack_require__(6);
  4092. var Action_1 = __webpack_require__(34);
  4093. /**
  4094. * We need this JSDoc comment for affecting ESDoc.
  4095. * @ignore
  4096. * @extends {Ignored}
  4097. */
  4098. var AsyncAction = (function (_super) {
  4099. __extends(AsyncAction, _super);
  4100. function AsyncAction(scheduler, work) {
  4101. _super.call(this, scheduler, work);
  4102. this.scheduler = scheduler;
  4103. this.work = work;
  4104. this.pending = false;
  4105. }
  4106. AsyncAction.prototype.schedule = function (state, delay) {
  4107. if (delay === void 0) { delay = 0; }
  4108. if (this.closed) {
  4109. return this;
  4110. }
  4111. // Always replace the current state with the new state.
  4112. this.state = state;
  4113. // Set the pending flag indicating that this action has been scheduled, or
  4114. // has recursively rescheduled itself.
  4115. this.pending = true;
  4116. var id = this.id;
  4117. var scheduler = this.scheduler;
  4118. //
  4119. // Important implementation note:
  4120. //
  4121. // Actions only execute once by default, unless rescheduled from within the
  4122. // scheduled callback. This allows us to implement single and repeat
  4123. // actions via the same code path, without adding API surface area, as well
  4124. // as mimic traditional recursion but across asynchronous boundaries.
  4125. //
  4126. // However, JS runtimes and timers distinguish between intervals achieved by
  4127. // serial `setTimeout` calls vs. a single `setInterval` call. An interval of
  4128. // serial `setTimeout` calls can be individually delayed, which delays
  4129. // scheduling the next `setTimeout`, and so on. `setInterval` attempts to
  4130. // guarantee the interval callback will be invoked more precisely to the
  4131. // interval period, regardless of load.
  4132. //
  4133. // Therefore, we use `setInterval` to schedule single and repeat actions.
  4134. // If the action reschedules itself with the same delay, the interval is not
  4135. // canceled. If the action doesn't reschedule, or reschedules with a
  4136. // different delay, the interval will be canceled after scheduled callback
  4137. // execution.
  4138. //
  4139. if (id != null) {
  4140. this.id = this.recycleAsyncId(scheduler, id, delay);
  4141. }
  4142. this.delay = delay;
  4143. // If this action has already an async Id, don't request a new one.
  4144. this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
  4145. return this;
  4146. };
  4147. AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  4148. if (delay === void 0) { delay = 0; }
  4149. return root_1.root.setInterval(scheduler.flush.bind(scheduler, this), delay);
  4150. };
  4151. AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  4152. if (delay === void 0) { delay = 0; }
  4153. // If this action is rescheduled with the same delay time, don't clear the interval id.
  4154. if (delay !== null && this.delay === delay && this.pending === false) {
  4155. return id;
  4156. }
  4157. // Otherwise, if the action's delay time is different from the current delay,
  4158. // or the action has been rescheduled before it's executed, clear the interval id
  4159. return root_1.root.clearInterval(id) && undefined || undefined;
  4160. };
  4161. /**
  4162. * Immediately executes this action and the `work` it contains.
  4163. * @return {any}
  4164. */
  4165. AsyncAction.prototype.execute = function (state, delay) {
  4166. if (this.closed) {
  4167. return new Error('executing a cancelled action');
  4168. }
  4169. this.pending = false;
  4170. var error = this._execute(state, delay);
  4171. if (error) {
  4172. return error;
  4173. }
  4174. else if (this.pending === false && this.id != null) {
  4175. // Dequeue if the action didn't reschedule itself. Don't call
  4176. // unsubscribe(), because the action could reschedule later.
  4177. // For example:
  4178. // ```
  4179. // scheduler.schedule(function doWork(counter) {
  4180. // /* ... I'm a busy worker bee ... */
  4181. // var originalAction = this;
  4182. // /* wait 100ms before rescheduling the action */
  4183. // setTimeout(function () {
  4184. // originalAction.schedule(counter + 1);
  4185. // }, 100);
  4186. // }, 1000);
  4187. // ```
  4188. this.id = this.recycleAsyncId(this.scheduler, this.id, null);
  4189. }
  4190. };
  4191. AsyncAction.prototype._execute = function (state, delay) {
  4192. var errored = false;
  4193. var errorValue = undefined;
  4194. try {
  4195. this.work(state);
  4196. }
  4197. catch (e) {
  4198. errored = true;
  4199. errorValue = !!e && e || new Error(e);
  4200. }
  4201. if (errored) {
  4202. this.unsubscribe();
  4203. return errorValue;
  4204. }
  4205. };
  4206. AsyncAction.prototype._unsubscribe = function () {
  4207. var id = this.id;
  4208. var scheduler = this.scheduler;
  4209. var actions = scheduler.actions;
  4210. var index = actions.indexOf(this);
  4211. this.work = null;
  4212. this.state = null;
  4213. this.pending = false;
  4214. this.scheduler = null;
  4215. if (index !== -1) {
  4216. actions.splice(index, 1);
  4217. }
  4218. if (id != null) {
  4219. this.id = this.recycleAsyncId(scheduler, id, null);
  4220. }
  4221. this.delay = null;
  4222. };
  4223. return AsyncAction;
  4224. }(Action_1.Action));
  4225. exports.AsyncAction = AsyncAction;
  4226. //# sourceMappingURL=AsyncAction.js.map
  4227.  
  4228. /***/ }),
  4229. /* 34 */
  4230. /***/ (function(module, exports, __webpack_require__) {
  4231.  
  4232. "use strict";
  4233.  
  4234. var __extends = (this && this.__extends) || function (d, b) {
  4235. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4236. function __() { this.constructor = d; }
  4237. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4238. };
  4239. var Subscription_1 = __webpack_require__(4);
  4240. /**
  4241. * A unit of work to be executed in a {@link Scheduler}. An action is typically
  4242. * created from within a Scheduler and an RxJS user does not need to concern
  4243. * themselves about creating and manipulating an Action.
  4244. *
  4245. * ```ts
  4246. * class Action<T> extends Subscription {
  4247. * new (scheduler: Scheduler, work: (state?: T) => void);
  4248. * schedule(state?: T, delay: number = 0): Subscription;
  4249. * }
  4250. * ```
  4251. *
  4252. * @class Action<T>
  4253. */
  4254. var Action = (function (_super) {
  4255. __extends(Action, _super);
  4256. function Action(scheduler, work) {
  4257. _super.call(this);
  4258. }
  4259. /**
  4260. * Schedules this action on its parent Scheduler for execution. May be passed
  4261. * some context object, `state`. May happen at some point in the future,
  4262. * according to the `delay` parameter, if specified.
  4263. * @param {T} [state] Some contextual data that the `work` function uses when
  4264. * called by the Scheduler.
  4265. * @param {number} [delay] Time to wait before executing the work, where the
  4266. * time unit is implicit and defined by the Scheduler.
  4267. * @return {void}
  4268. */
  4269. Action.prototype.schedule = function (state, delay) {
  4270. if (delay === void 0) { delay = 0; }
  4271. return this;
  4272. };
  4273. return Action;
  4274. }(Subscription_1.Subscription));
  4275. exports.Action = Action;
  4276. //# sourceMappingURL=Action.js.map
  4277.  
  4278. /***/ }),
  4279. /* 35 */
  4280. /***/ (function(module, exports, __webpack_require__) {
  4281.  
  4282. "use strict";
  4283.  
  4284. var __extends = (this && this.__extends) || function (d, b) {
  4285. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4286. function __() { this.constructor = d; }
  4287. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4288. };
  4289. var AsyncScheduler_1 = __webpack_require__(36);
  4290. var QueueScheduler = (function (_super) {
  4291. __extends(QueueScheduler, _super);
  4292. function QueueScheduler() {
  4293. _super.apply(this, arguments);
  4294. }
  4295. return QueueScheduler;
  4296. }(AsyncScheduler_1.AsyncScheduler));
  4297. exports.QueueScheduler = QueueScheduler;
  4298. //# sourceMappingURL=QueueScheduler.js.map
  4299.  
  4300. /***/ }),
  4301. /* 36 */
  4302. /***/ (function(module, exports, __webpack_require__) {
  4303.  
  4304. "use strict";
  4305.  
  4306. var __extends = (this && this.__extends) || function (d, b) {
  4307. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4308. function __() { this.constructor = d; }
  4309. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4310. };
  4311. var Scheduler_1 = __webpack_require__(37);
  4312. var AsyncScheduler = (function (_super) {
  4313. __extends(AsyncScheduler, _super);
  4314. function AsyncScheduler() {
  4315. _super.apply(this, arguments);
  4316. this.actions = [];
  4317. /**
  4318. * A flag to indicate whether the Scheduler is currently executing a batch of
  4319. * queued actions.
  4320. * @type {boolean}
  4321. */
  4322. this.active = false;
  4323. /**
  4324. * An internal ID used to track the latest asynchronous task such as those
  4325. * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and
  4326. * others.
  4327. * @type {any}
  4328. */
  4329. this.scheduled = undefined;
  4330. }
  4331. AsyncScheduler.prototype.flush = function (action) {
  4332. var actions = this.actions;
  4333. if (this.active) {
  4334. actions.push(action);
  4335. return;
  4336. }
  4337. var error;
  4338. this.active = true;
  4339. do {
  4340. if (error = action.execute(action.state, action.delay)) {
  4341. break;
  4342. }
  4343. } while (action = actions.shift()); // exhaust the scheduler queue
  4344. this.active = false;
  4345. if (error) {
  4346. while (action = actions.shift()) {
  4347. action.unsubscribe();
  4348. }
  4349. throw error;
  4350. }
  4351. };
  4352. return AsyncScheduler;
  4353. }(Scheduler_1.Scheduler));
  4354. exports.AsyncScheduler = AsyncScheduler;
  4355. //# sourceMappingURL=AsyncScheduler.js.map
  4356.  
  4357. /***/ }),
  4358. /* 37 */
  4359. /***/ (function(module, exports, __webpack_require__) {
  4360.  
  4361. "use strict";
  4362.  
  4363. /**
  4364. * An execution context and a data structure to order tasks and schedule their
  4365. * execution. Provides a notion of (potentially virtual) time, through the
  4366. * `now()` getter method.
  4367. *
  4368. * Each unit of work in a Scheduler is called an {@link Action}.
  4369. *
  4370. * ```ts
  4371. * class Scheduler {
  4372. * now(): number;
  4373. * schedule(work, delay?, state?): Subscription;
  4374. * }
  4375. * ```
  4376. *
  4377. * @class Scheduler
  4378. */
  4379. var Scheduler = (function () {
  4380. function Scheduler(SchedulerAction, now) {
  4381. if (now === void 0) { now = Scheduler.now; }
  4382. this.SchedulerAction = SchedulerAction;
  4383. this.now = now;
  4384. }
  4385. /**
  4386. * Schedules a function, `work`, for execution. May happen at some point in
  4387. * the future, according to the `delay` parameter, if specified. May be passed
  4388. * some context object, `state`, which will be passed to the `work` function.
  4389. *
  4390. * The given arguments will be processed an stored as an Action object in a
  4391. * queue of actions.
  4392. *
  4393. * @param {function(state: ?T): ?Subscription} work A function representing a
  4394. * task, or some unit of work to be executed by the Scheduler.
  4395. * @param {number} [delay] Time to wait before executing the work, where the
  4396. * time unit is implicit and defined by the Scheduler itself.
  4397. * @param {T} [state] Some contextual data that the `work` function uses when
  4398. * called by the Scheduler.
  4399. * @return {Subscription} A subscription in order to be able to unsubscribe
  4400. * the scheduled work.
  4401. */
  4402. Scheduler.prototype.schedule = function (work, delay, state) {
  4403. if (delay === void 0) { delay = 0; }
  4404. return new this.SchedulerAction(this, work).schedule(state, delay);
  4405. };
  4406. Scheduler.now = Date.now ? Date.now : function () { return +new Date(); };
  4407. return Scheduler;
  4408. }());
  4409. exports.Scheduler = Scheduler;
  4410. //# sourceMappingURL=Scheduler.js.map
  4411.  
  4412. /***/ }),
  4413. /* 38 */
  4414. /***/ (function(module, exports, __webpack_require__) {
  4415.  
  4416. "use strict";
  4417.  
  4418. var __extends = (this && this.__extends) || function (d, b) {
  4419. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4420. function __() { this.constructor = d; }
  4421. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4422. };
  4423. var Subscriber_1 = __webpack_require__(2);
  4424. var Notification_1 = __webpack_require__(39);
  4425. /**
  4426. *
  4427. * Re-emits all notifications from source Observable with specified scheduler.
  4428. *
  4429. * <span class="informal">Ensure a specific scheduler is used, from outside of an Observable.</span>
  4430. *
  4431. * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule
  4432. * notifications emitted by the source Observable. It might be useful, if you do not have control over
  4433. * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless.
  4434. *
  4435. * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable,
  4436. * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal
  4437. * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits
  4438. * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`.
  4439. * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split
  4440. * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source
  4441. * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a
  4442. * little bit more, to ensure that they are emitted at expected moments.
  4443. *
  4444. * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications
  4445. * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn`
  4446. * will delay all notifications - including error notifications - while `delay` will pass through error
  4447. * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator
  4448. * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used
  4449. * for notification emissions in general.
  4450. *
  4451. * @example <caption>Ensure values in subscribe are called just before browser repaint.</caption>
  4452. * const intervals = Rx.Observable.interval(10); // Intervals are scheduled
  4453. * // with async scheduler by default...
  4454. *
  4455. * intervals
  4456. * .observeOn(Rx.Scheduler.animationFrame) // ...but we will observe on animationFrame
  4457. * .subscribe(val => { // scheduler to ensure smooth animation.
  4458. * someDiv.style.height = val + 'px';
  4459. * });
  4460. *
  4461. * @see {@link delay}
  4462. *
  4463. * @param {IScheduler} scheduler Scheduler that will be used to reschedule notifications from source Observable.
  4464. * @param {number} [delay] Number of milliseconds that states with what delay every notification should be rescheduled.
  4465. * @return {Observable<T>} Observable that emits the same notifications as the source Observable,
  4466. * but with provided scheduler.
  4467. *
  4468. * @method observeOn
  4469. * @owner Observable
  4470. */
  4471. function observeOn(scheduler, delay) {
  4472. if (delay === void 0) { delay = 0; }
  4473. return function observeOnOperatorFunction(source) {
  4474. return source.lift(new ObserveOnOperator(scheduler, delay));
  4475. };
  4476. }
  4477. exports.observeOn = observeOn;
  4478. var ObserveOnOperator = (function () {
  4479. function ObserveOnOperator(scheduler, delay) {
  4480. if (delay === void 0) { delay = 0; }
  4481. this.scheduler = scheduler;
  4482. this.delay = delay;
  4483. }
  4484. ObserveOnOperator.prototype.call = function (subscriber, source) {
  4485. return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
  4486. };
  4487. return ObserveOnOperator;
  4488. }());
  4489. exports.ObserveOnOperator = ObserveOnOperator;
  4490. /**
  4491. * We need this JSDoc comment for affecting ESDoc.
  4492. * @ignore
  4493. * @extends {Ignored}
  4494. */
  4495. var ObserveOnSubscriber = (function (_super) {
  4496. __extends(ObserveOnSubscriber, _super);
  4497. function ObserveOnSubscriber(destination, scheduler, delay) {
  4498. if (delay === void 0) { delay = 0; }
  4499. _super.call(this, destination);
  4500. this.scheduler = scheduler;
  4501. this.delay = delay;
  4502. }
  4503. ObserveOnSubscriber.dispatch = function (arg) {
  4504. var notification = arg.notification, destination = arg.destination;
  4505. notification.observe(destination);
  4506. this.unsubscribe();
  4507. };
  4508. ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
  4509. this.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
  4510. };
  4511. ObserveOnSubscriber.prototype._next = function (value) {
  4512. this.scheduleMessage(Notification_1.Notification.createNext(value));
  4513. };
  4514. ObserveOnSubscriber.prototype._error = function (err) {
  4515. this.scheduleMessage(Notification_1.Notification.createError(err));
  4516. };
  4517. ObserveOnSubscriber.prototype._complete = function () {
  4518. this.scheduleMessage(Notification_1.Notification.createComplete());
  4519. };
  4520. return ObserveOnSubscriber;
  4521. }(Subscriber_1.Subscriber));
  4522. exports.ObserveOnSubscriber = ObserveOnSubscriber;
  4523. var ObserveOnMessage = (function () {
  4524. function ObserveOnMessage(notification, destination) {
  4525. this.notification = notification;
  4526. this.destination = destination;
  4527. }
  4528. return ObserveOnMessage;
  4529. }());
  4530. exports.ObserveOnMessage = ObserveOnMessage;
  4531. //# sourceMappingURL=observeOn.js.map
  4532.  
  4533. /***/ }),
  4534. /* 39 */
  4535. /***/ (function(module, exports, __webpack_require__) {
  4536.  
  4537. "use strict";
  4538.  
  4539. var Observable_1 = __webpack_require__(1);
  4540. /**
  4541. * Represents a push-based event or value that an {@link Observable} can emit.
  4542. * This class is particularly useful for operators that manage notifications,
  4543. * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
  4544. * others. Besides wrapping the actual delivered value, it also annotates it
  4545. * with metadata of, for instance, what type of push message it is (`next`,
  4546. * `error`, or `complete`).
  4547. *
  4548. * @see {@link materialize}
  4549. * @see {@link dematerialize}
  4550. * @see {@link observeOn}
  4551. *
  4552. * @class Notification<T>
  4553. */
  4554. var Notification = (function () {
  4555. function Notification(kind, value, error) {
  4556. this.kind = kind;
  4557. this.value = value;
  4558. this.error = error;
  4559. this.hasValue = kind === 'N';
  4560. }
  4561. /**
  4562. * Delivers to the given `observer` the value wrapped by this Notification.
  4563. * @param {Observer} observer
  4564. * @return
  4565. */
  4566. Notification.prototype.observe = function (observer) {
  4567. switch (this.kind) {
  4568. case 'N':
  4569. return observer.next && observer.next(this.value);
  4570. case 'E':
  4571. return observer.error && observer.error(this.error);
  4572. case 'C':
  4573. return observer.complete && observer.complete();
  4574. }
  4575. };
  4576. /**
  4577. * Given some {@link Observer} callbacks, deliver the value represented by the
  4578. * current Notification to the correctly corresponding callback.
  4579. * @param {function(value: T): void} next An Observer `next` callback.
  4580. * @param {function(err: any): void} [error] An Observer `error` callback.
  4581. * @param {function(): void} [complete] An Observer `complete` callback.
  4582. * @return {any}
  4583. */
  4584. Notification.prototype.do = function (next, error, complete) {
  4585. var kind = this.kind;
  4586. switch (kind) {
  4587. case 'N':
  4588. return next && next(this.value);
  4589. case 'E':
  4590. return error && error(this.error);
  4591. case 'C':
  4592. return complete && complete();
  4593. }
  4594. };
  4595. /**
  4596. * Takes an Observer or its individual callback functions, and calls `observe`
  4597. * or `do` methods accordingly.
  4598. * @param {Observer|function(value: T): void} nextOrObserver An Observer or
  4599. * the `next` callback.
  4600. * @param {function(err: any): void} [error] An Observer `error` callback.
  4601. * @param {function(): void} [complete] An Observer `complete` callback.
  4602. * @return {any}
  4603. */
  4604. Notification.prototype.accept = function (nextOrObserver, error, complete) {
  4605. if (nextOrObserver && typeof nextOrObserver.next === 'function') {
  4606. return this.observe(nextOrObserver);
  4607. }
  4608. else {
  4609. return this.do(nextOrObserver, error, complete);
  4610. }
  4611. };
  4612. /**
  4613. * Returns a simple Observable that just delivers the notification represented
  4614. * by this Notification instance.
  4615. * @return {any}
  4616. */
  4617. Notification.prototype.toObservable = function () {
  4618. var kind = this.kind;
  4619. switch (kind) {
  4620. case 'N':
  4621. return Observable_1.Observable.of(this.value);
  4622. case 'E':
  4623. return Observable_1.Observable.throw(this.error);
  4624. case 'C':
  4625. return Observable_1.Observable.empty();
  4626. }
  4627. throw new Error('unexpected notification kind value');
  4628. };
  4629. /**
  4630. * A shortcut to create a Notification instance of the type `next` from a
  4631. * given value.
  4632. * @param {T} value The `next` value.
  4633. * @return {Notification<T>} The "next" Notification representing the
  4634. * argument.
  4635. */
  4636. Notification.createNext = function (value) {
  4637. if (typeof value !== 'undefined') {
  4638. return new Notification('N', value);
  4639. }
  4640. return Notification.undefinedValueNotification;
  4641. };
  4642. /**
  4643. * A shortcut to create a Notification instance of the type `error` from a
  4644. * given error.
  4645. * @param {any} [err] The `error` error.
  4646. * @return {Notification<T>} The "error" Notification representing the
  4647. * argument.
  4648. */
  4649. Notification.createError = function (err) {
  4650. return new Notification('E', undefined, err);
  4651. };
  4652. /**
  4653. * A shortcut to create a Notification instance of the type `complete`.
  4654. * @return {Notification<any>} The valueless "complete" Notification.
  4655. */
  4656. Notification.createComplete = function () {
  4657. return Notification.completeNotification;
  4658. };
  4659. Notification.completeNotification = new Notification('C');
  4660. Notification.undefinedValueNotification = new Notification('N', undefined);
  4661. return Notification;
  4662. }());
  4663. exports.Notification = Notification;
  4664. //# sourceMappingURL=Notification.js.map
  4665.  
  4666. /***/ }),
  4667. /* 40 */
  4668. /***/ (function(module, exports, __webpack_require__) {
  4669.  
  4670. "use strict";
  4671.  
  4672. var take_1 = __webpack_require__(41);
  4673. /**
  4674. * Emits only the first `count` values emitted by the source Observable.
  4675. *
  4676. * <span class="informal">Takes the first `count` values from the source, then
  4677. * completes.</span>
  4678. *
  4679. * <img src="./img/take.png" width="100%">
  4680. *
  4681. * `take` returns an Observable that emits only the first `count` values emitted
  4682. * by the source Observable. If the source emits fewer than `count` values then
  4683. * all of its values are emitted. After that, it completes, regardless if the
  4684. * source completes.
  4685. *
  4686. * @example <caption>Take the first 5 seconds of an infinite 1-second interval Observable</caption>
  4687. * var interval = Rx.Observable.interval(1000);
  4688. * var five = interval.take(5);
  4689. * five.subscribe(x => console.log(x));
  4690. *
  4691. * @see {@link takeLast}
  4692. * @see {@link takeUntil}
  4693. * @see {@link takeWhile}
  4694. * @see {@link skip}
  4695. *
  4696. * @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
  4697. * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
  4698. *
  4699. * @param {number} count The maximum number of `next` values to emit.
  4700. * @return {Observable<T>} An Observable that emits only the first `count`
  4701. * values emitted by the source Observable, or all of the values from the source
  4702. * if the source emits fewer than `count` values.
  4703. * @method take
  4704. * @owner Observable
  4705. */
  4706. function take(count) {
  4707. return take_1.take(count)(this);
  4708. }
  4709. exports.take = take;
  4710. //# sourceMappingURL=take.js.map
  4711.  
  4712. /***/ }),
  4713. /* 41 */
  4714. /***/ (function(module, exports, __webpack_require__) {
  4715.  
  4716. "use strict";
  4717.  
  4718. var __extends = (this && this.__extends) || function (d, b) {
  4719. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4720. function __() { this.constructor = d; }
  4721. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4722. };
  4723. var Subscriber_1 = __webpack_require__(2);
  4724. var ArgumentOutOfRangeError_1 = __webpack_require__(42);
  4725. var EmptyObservable_1 = __webpack_require__(43);
  4726. /**
  4727. * Emits only the first `count` values emitted by the source Observable.
  4728. *
  4729. * <span class="informal">Takes the first `count` values from the source, then
  4730. * completes.</span>
  4731. *
  4732. * <img src="./img/take.png" width="100%">
  4733. *
  4734. * `take` returns an Observable that emits only the first `count` values emitted
  4735. * by the source Observable. If the source emits fewer than `count` values then
  4736. * all of its values are emitted. After that, it completes, regardless if the
  4737. * source completes.
  4738. *
  4739. * @example <caption>Take the first 5 seconds of an infinite 1-second interval Observable</caption>
  4740. * var interval = Rx.Observable.interval(1000);
  4741. * var five = interval.take(5);
  4742. * five.subscribe(x => console.log(x));
  4743. *
  4744. * @see {@link takeLast}
  4745. * @see {@link takeUntil}
  4746. * @see {@link takeWhile}
  4747. * @see {@link skip}
  4748. *
  4749. * @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
  4750. * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
  4751. *
  4752. * @param {number} count The maximum number of `next` values to emit.
  4753. * @return {Observable<T>} An Observable that emits only the first `count`
  4754. * values emitted by the source Observable, or all of the values from the source
  4755. * if the source emits fewer than `count` values.
  4756. * @method take
  4757. * @owner Observable
  4758. */
  4759. function take(count) {
  4760. return function (source) {
  4761. if (count === 0) {
  4762. return new EmptyObservable_1.EmptyObservable();
  4763. }
  4764. else {
  4765. return source.lift(new TakeOperator(count));
  4766. }
  4767. };
  4768. }
  4769. exports.take = take;
  4770. var TakeOperator = (function () {
  4771. function TakeOperator(total) {
  4772. this.total = total;
  4773. if (this.total < 0) {
  4774. throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
  4775. }
  4776. }
  4777. TakeOperator.prototype.call = function (subscriber, source) {
  4778. return source.subscribe(new TakeSubscriber(subscriber, this.total));
  4779. };
  4780. return TakeOperator;
  4781. }());
  4782. /**
  4783. * We need this JSDoc comment for affecting ESDoc.
  4784. * @ignore
  4785. * @extends {Ignored}
  4786. */
  4787. var TakeSubscriber = (function (_super) {
  4788. __extends(TakeSubscriber, _super);
  4789. function TakeSubscriber(destination, total) {
  4790. _super.call(this, destination);
  4791. this.total = total;
  4792. this.count = 0;
  4793. }
  4794. TakeSubscriber.prototype._next = function (value) {
  4795. var total = this.total;
  4796. var count = ++this.count;
  4797. if (count <= total) {
  4798. this.destination.next(value);
  4799. if (count === total) {
  4800. this.destination.complete();
  4801. this.unsubscribe();
  4802. }
  4803. }
  4804. };
  4805. return TakeSubscriber;
  4806. }(Subscriber_1.Subscriber));
  4807. //# sourceMappingURL=take.js.map
  4808.  
  4809. /***/ }),
  4810. /* 42 */
  4811. /***/ (function(module, exports, __webpack_require__) {
  4812.  
  4813. "use strict";
  4814.  
  4815. var __extends = (this && this.__extends) || function (d, b) {
  4816. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4817. function __() { this.constructor = d; }
  4818. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4819. };
  4820. /**
  4821. * An error thrown when an element was queried at a certain index of an
  4822. * Observable, but no such index or position exists in that sequence.
  4823. *
  4824. * @see {@link elementAt}
  4825. * @see {@link take}
  4826. * @see {@link takeLast}
  4827. *
  4828. * @class ArgumentOutOfRangeError
  4829. */
  4830. var ArgumentOutOfRangeError = (function (_super) {
  4831. __extends(ArgumentOutOfRangeError, _super);
  4832. function ArgumentOutOfRangeError() {
  4833. var err = _super.call(this, 'argument out of range');
  4834. this.name = err.name = 'ArgumentOutOfRangeError';
  4835. this.stack = err.stack;
  4836. this.message = err.message;
  4837. }
  4838. return ArgumentOutOfRangeError;
  4839. }(Error));
  4840. exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
  4841. //# sourceMappingURL=ArgumentOutOfRangeError.js.map
  4842.  
  4843. /***/ }),
  4844. /* 43 */
  4845. /***/ (function(module, exports, __webpack_require__) {
  4846.  
  4847. "use strict";
  4848.  
  4849. var __extends = (this && this.__extends) || function (d, b) {
  4850. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4851. function __() { this.constructor = d; }
  4852. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4853. };
  4854. var Observable_1 = __webpack_require__(1);
  4855. /**
  4856. * We need this JSDoc comment for affecting ESDoc.
  4857. * @extends {Ignored}
  4858. * @hide true
  4859. */
  4860. var EmptyObservable = (function (_super) {
  4861. __extends(EmptyObservable, _super);
  4862. function EmptyObservable(scheduler) {
  4863. _super.call(this);
  4864. this.scheduler = scheduler;
  4865. }
  4866. /**
  4867. * Creates an Observable that emits no items to the Observer and immediately
  4868. * emits a complete notification.
  4869. *
  4870. * <span class="informal">Just emits 'complete', and nothing else.
  4871. * </span>
  4872. *
  4873. * <img src="./img/empty.png" width="100%">
  4874. *
  4875. * This static operator is useful for creating a simple Observable that only
  4876. * emits the complete notification. It can be used for composing with other
  4877. * Observables, such as in a {@link mergeMap}.
  4878. *
  4879. * @example <caption>Emit the number 7, then complete.</caption>
  4880. * var result = Rx.Observable.empty().startWith(7);
  4881. * result.subscribe(x => console.log(x));
  4882. *
  4883. * @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
  4884. * var interval = Rx.Observable.interval(1000);
  4885. * var result = interval.mergeMap(x =>
  4886. * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
  4887. * );
  4888. * result.subscribe(x => console.log(x));
  4889. *
  4890. * // Results in the following to the console:
  4891. * // x is equal to the count on the interval eg(0,1,2,3,...)
  4892. * // x will occur every 1000ms
  4893. * // if x % 2 is equal to 1 print abc
  4894. * // if x % 2 is not equal to 1 nothing will be output
  4895. *
  4896. * @see {@link create}
  4897. * @see {@link never}
  4898. * @see {@link of}
  4899. * @see {@link throw}
  4900. *
  4901. * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
  4902. * the emission of the complete notification.
  4903. * @return {Observable} An "empty" Observable: emits only the complete
  4904. * notification.
  4905. * @static true
  4906. * @name empty
  4907. * @owner Observable
  4908. */
  4909. EmptyObservable.create = function (scheduler) {
  4910. return new EmptyObservable(scheduler);
  4911. };
  4912. EmptyObservable.dispatch = function (arg) {
  4913. var subscriber = arg.subscriber;
  4914. subscriber.complete();
  4915. };
  4916. EmptyObservable.prototype._subscribe = function (subscriber) {
  4917. var scheduler = this.scheduler;
  4918. if (scheduler) {
  4919. return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
  4920. }
  4921. else {
  4922. subscriber.complete();
  4923. }
  4924. };
  4925. return EmptyObservable;
  4926. }(Observable_1.Observable));
  4927. exports.EmptyObservable = EmptyObservable;
  4928. //# sourceMappingURL=EmptyObservable.js.map
  4929.  
  4930. /***/ }),
  4931. /* 44 */
  4932. /***/ (function(module, exports, __webpack_require__) {
  4933.  
  4934. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
  4935. * xdLocalStorage is a port of https://github.com/ofirdagan/cross-domain-local-storage to typescript using modules
  4936. */
  4937. /**
  4938. * Created by dagan on 07/04/2014.
  4939. */
  4940. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1) {
  4941. "use strict";
  4942. Object.defineProperty(exports, "__esModule", { value: true });
  4943. var XdLocalStorage = /** @class */ (function () {
  4944. function XdLocalStorage() {
  4945. }
  4946. XdLocalStorage.init = function (customOptions) {
  4947. if (!customOptions.iframeUrl) {
  4948. throw Error('You must specify iframeUrl');
  4949. }
  4950. var validatedOptions = {
  4951. iframeId: customOptions.iframeId,
  4952. iframeUrl: customOptions.iframeUrl,
  4953. initCallback: customOptions.initCallback
  4954. };
  4955. if (XdLocalStorage.wasInitFlag) {
  4956. return;
  4957. }
  4958. XdLocalStorage.wasInitFlag = true;
  4959. if (XdLocalStorage.isDomReady()) {
  4960. XdLocalStorage.internalInit(validatedOptions);
  4961. }
  4962. else {
  4963. if (document.addEventListener) {
  4964. // All browsers expect IE < 9
  4965. document.addEventListener('readystatechange', function () {
  4966. if (XdLocalStorage.isDomReady()) {
  4967. XdLocalStorage.internalInit(validatedOptions);
  4968. }
  4969. });
  4970. }
  4971. else {
  4972. // IE < 9
  4973. document.attachEvent('readystatechange', function () {
  4974. if (XdLocalStorage.isDomReady()) {
  4975. XdLocalStorage.internalInit(validatedOptions);
  4976. }
  4977. });
  4978. }
  4979. }
  4980. };
  4981. XdLocalStorage.setItem = function (key, value, callback) {
  4982. if (!XdLocalStorage.isApiReady()) {
  4983. return;
  4984. }
  4985. XdLocalStorage.buildMessage('set', key, value, callback);
  4986. };
  4987. XdLocalStorage.getItem = function (key, callback) {
  4988. if (!XdLocalStorage.isApiReady()) {
  4989. return;
  4990. }
  4991. XdLocalStorage.buildMessage('get', key, null, callback);
  4992. };
  4993. XdLocalStorage.removeItem = function (key, callback) {
  4994. if (!XdLocalStorage.isApiReady()) {
  4995. return;
  4996. }
  4997. XdLocalStorage.buildMessage('remove', key, null, callback);
  4998. };
  4999. XdLocalStorage.key = function (index, callback) {
  5000. if (!XdLocalStorage.isApiReady()) {
  5001. return;
  5002. }
  5003. XdLocalStorage.buildMessage('key', index, null, callback);
  5004. };
  5005. XdLocalStorage.getSize = function (callback) {
  5006. if (!XdLocalStorage.isApiReady()) {
  5007. return;
  5008. }
  5009. XdLocalStorage.buildMessage('size', null, null, callback);
  5010. };
  5011. XdLocalStorage.getLength = function (callback) {
  5012. if (!XdLocalStorage.isApiReady()) {
  5013. return;
  5014. }
  5015. XdLocalStorage.buildMessage('length', null, null, callback);
  5016. };
  5017. XdLocalStorage.clear = function (callback) {
  5018. if (!XdLocalStorage.isApiReady()) {
  5019. return;
  5020. }
  5021. XdLocalStorage.buildMessage('clear', null, null, callback);
  5022. };
  5023. XdLocalStorage.wasInit = function () {
  5024. return XdLocalStorage.wasInitFlag;
  5025. };
  5026. XdLocalStorage.applyCallback = function (data) {
  5027. if (XdLocalStorage.requests[data.id]) {
  5028. XdLocalStorage.requests[data.id](data);
  5029. delete XdLocalStorage.requests[data.id];
  5030. }
  5031. };
  5032. XdLocalStorage.receiveMessage = function (event) {
  5033. var data;
  5034. try {
  5035. data = JSON.parse(event.data);
  5036. }
  5037. catch (err) {
  5038. // not our message, can ignore
  5039. }
  5040. if (data && data.namespace === XdLocalStorage.MESSAGE_NAMESPACE) {
  5041. if (data.id === 'iframe-ready') {
  5042. XdLocalStorage.iframeReady = true;
  5043. XdLocalStorage.options.initCallback();
  5044. }
  5045. else {
  5046. XdLocalStorage.applyCallback(data);
  5047. }
  5048. }
  5049. };
  5050. XdLocalStorage.buildMessage = function (action, key, value, callback) {
  5051. XdLocalStorage.requestId++;
  5052. XdLocalStorage.requests[XdLocalStorage.requestId] = callback;
  5053. var data = {
  5054. namespace: XdLocalStorage.MESSAGE_NAMESPACE,
  5055. id: XdLocalStorage.requestId,
  5056. action: action,
  5057. key: key,
  5058. value: value
  5059. };
  5060. XdLocalStorage.iframe.contentWindow.postMessage(JSON.stringify(data), '*');
  5061. };
  5062. XdLocalStorage.internalInit = function (customOptions) {
  5063. XdLocalStorage.options = tslib_1.__assign({}, XdLocalStorage.defaultOptions, customOptions);
  5064. var temp = document.createElement('div');
  5065. if (window.addEventListener) {
  5066. window.addEventListener('message', XdLocalStorage.receiveMessage, false);
  5067. }
  5068. else {
  5069. window.attachEvent('onmessage', XdLocalStorage.receiveMessage);
  5070. }
  5071. temp.innerHTML = '<iframe id="' + XdLocalStorage.options.iframeId + '" src=' + XdLocalStorage.options.iframeUrl + ' style="display: none;"></iframe>';
  5072. document.body.appendChild(temp);
  5073. var element = document.getElementById(XdLocalStorage.options.iframeId);
  5074. if (element) {
  5075. XdLocalStorage.iframe = element;
  5076. }
  5077. };
  5078. XdLocalStorage.isApiReady = function () {
  5079. if (!XdLocalStorage.wasInitFlag) {
  5080. return false;
  5081. }
  5082. if (!XdLocalStorage.iframeReady) {
  5083. return false;
  5084. }
  5085. return true;
  5086. };
  5087. XdLocalStorage.isDomReady = function () {
  5088. return (document.readyState === 'complete');
  5089. };
  5090. XdLocalStorage.MESSAGE_NAMESPACE = 'cross-domain-local-message';
  5091. XdLocalStorage.defaultOptions = {
  5092. iframeId: 'cross-domain-iframe',
  5093. // tslint:disable-next-line:no-empty
  5094. initCallback: function () { }
  5095. };
  5096. XdLocalStorage.requestId = 1;
  5097. XdLocalStorage.requests = {};
  5098. XdLocalStorage.wasInitFlag = false;
  5099. XdLocalStorage.iframeReady = true;
  5100. return XdLocalStorage;
  5101. }());
  5102. exports.XdLocalStorage = XdLocalStorage;
  5103. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  5104. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  5105.  
  5106.  
  5107. /***/ }),
  5108. /* 45 */
  5109. /***/ (function(module, exports, __webpack_require__) {
  5110.  
  5111. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(3), __webpack_require__(9), __webpack_require__(5), __webpack_require__(18), __webpack_require__(46)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, SimpleCache_1, ReplaySubject_1, Subject_1, ChatApi_1) {
  5112. "use strict";
  5113. Object.defineProperty(exports, "__esModule", { value: true });
  5114. var copyPastorServer = 'http://copypastor.sobotics.org';
  5115. var soboticsRoomId = 111347;
  5116. var CopyPastorAPI = /** @class */ (function () {
  5117. function CopyPastorAPI(answerId, key) {
  5118. this.answerId = answerId;
  5119. this.key = key;
  5120. }
  5121. CopyPastorAPI.prototype.Watch = function () {
  5122. var _this = this;
  5123. this.subject = new Subject_1.Subject();
  5124. this.replaySubject = new ReplaySubject_1.ReplaySubject(1);
  5125. this.subject.subscribe(this.replaySubject);
  5126. var expiryDate = new Date();
  5127. expiryDate.setDate(expiryDate.getDate() + 30);
  5128. SimpleCache_1.SimpleCache.GetAndCache("CopyPastor.FindTarget." + this.answerId, function () { return new Promise(function (resolve, reject) {
  5129. var url = copyPastorServer + "/posts/findTarget?url=//" + window.location.hostname + "/a/" + _this.answerId;
  5130. GM_xmlhttpRequest({
  5131. method: 'GET',
  5132. url: url,
  5133. onload: function (response) {
  5134. var responseObject = JSON.parse(response.responseText);
  5135. if (responseObject.status === 'success') {
  5136. resolve(responseObject.posts);
  5137. }
  5138. else {
  5139. reject(responseObject.message);
  5140. }
  5141. },
  5142. onerror: function (response) {
  5143. reject(response);
  5144. },
  5145. });
  5146. }); }, expiryDate)
  5147. .then(function (r) { return _this.subject.next(r); })
  5148. .catch(function (err) { return _this.subject.error(err); });
  5149. return this.subject;
  5150. };
  5151. CopyPastorAPI.prototype.Promise = function () {
  5152. return this.replaySubject.take(1).toPromise();
  5153. };
  5154. CopyPastorAPI.prototype.ReportTruePositive = function () {
  5155. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5156. return tslib_1.__generator(this, function (_a) {
  5157. return [2 /*return*/, this.SendFeedback('tp')];
  5158. });
  5159. });
  5160. };
  5161. CopyPastorAPI.prototype.ReportFalsePositive = function () {
  5162. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5163. return tslib_1.__generator(this, function (_a) {
  5164. return [2 /*return*/, this.SendFeedback('fp')];
  5165. });
  5166. });
  5167. };
  5168. CopyPastorAPI.prototype.SendFeedback = function (type) {
  5169. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5170. var _this = this;
  5171. var username, chatApi, chatId, results, payloads, promises, allResults, i;
  5172. return tslib_1.__generator(this, function (_a) {
  5173. switch (_a.label) {
  5174. case 0:
  5175. username = $('.top-bar .my-profile .gravatar-wrapper-24').attr('title');
  5176. chatApi = new ChatApi_1.ChatApi();
  5177. return [4 /*yield*/, chatApi.GetChatUserId(soboticsRoomId)];
  5178. case 1:
  5179. chatId = _a.sent();
  5180. return [4 /*yield*/, this.Promise()];
  5181. case 2:
  5182. results = _a.sent();
  5183. payloads = results.map(function (result) {
  5184. var postId = result.post_id;
  5185. var payload = {
  5186. post_id: postId,
  5187. feedback_type: type,
  5188. username: username,
  5189. link: "https://chat.stackoverflow.com/users/" + chatId,
  5190. key: _this.key,
  5191. };
  5192. return payload;
  5193. });
  5194. promises = payloads.map(function (payload) {
  5195. return new Promise(function (resolve, reject) {
  5196. var payloadString = JSON.stringify(payload);
  5197. GM_xmlhttpRequest({
  5198. method: 'POST',
  5199. url: copyPastorServer + "/feedback/create",
  5200. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  5201. data: 'post_id=' + payload.post_id
  5202. + '&feedback_type=' + payload.feedback_type
  5203. + '&username=' + payload.username
  5204. + '&link=' + payload.link
  5205. + '&key=' + payload.key,
  5206. onload: function (response) {
  5207. if (response.status !== 200) {
  5208. reject(JSON.parse(response.responseText));
  5209. }
  5210. else {
  5211. resolve(true);
  5212. }
  5213. },
  5214. onerror: function (response) {
  5215. reject(response);
  5216. },
  5217. });
  5218. });
  5219. });
  5220. return [4 /*yield*/, Promise.all(promises)];
  5221. case 3:
  5222. allResults = _a.sent();
  5223. if (allResults.length <= 0) {
  5224. return [2 /*return*/, false];
  5225. }
  5226. for (i = 0; i < allResults.length; i++) {
  5227. if (!allResults[i]) {
  5228. return [2 /*return*/, false];
  5229. }
  5230. }
  5231. return [2 /*return*/, true];
  5232. }
  5233. });
  5234. });
  5235. };
  5236. return CopyPastorAPI;
  5237. }());
  5238. exports.CopyPastorAPI = CopyPastorAPI;
  5239. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  5240. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  5241.  
  5242.  
  5243. /***/ }),
  5244. /* 46 */
  5245. /***/ (function(module, exports, __webpack_require__) {
  5246.  
  5247. "use strict";
  5248.  
  5249. var Observable_1 = __webpack_require__(1);
  5250. var map_1 = __webpack_require__(47);
  5251. Observable_1.Observable.prototype.map = map_1.map;
  5252. //# sourceMappingURL=map.js.map
  5253.  
  5254. /***/ }),
  5255. /* 47 */
  5256. /***/ (function(module, exports, __webpack_require__) {
  5257.  
  5258. "use strict";
  5259.  
  5260. var map_1 = __webpack_require__(48);
  5261. /**
  5262. * Applies a given `project` function to each value emitted by the source
  5263. * Observable, and emits the resulting values as an Observable.
  5264. *
  5265. * <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
  5266. * it passes each source value through a transformation function to get
  5267. * corresponding output values.</span>
  5268. *
  5269. * <img src="./img/map.png" width="100%">
  5270. *
  5271. * Similar to the well known `Array.prototype.map` function, this operator
  5272. * applies a projection to each value and emits that projection in the output
  5273. * Observable.
  5274. *
  5275. * @example <caption>Map every click to the clientX position of that click</caption>
  5276. * var clicks = Rx.Observable.fromEvent(document, 'click');
  5277. * var positions = clicks.map(ev => ev.clientX);
  5278. * positions.subscribe(x => console.log(x));
  5279. *
  5280. * @see {@link mapTo}
  5281. * @see {@link pluck}
  5282. *
  5283. * @param {function(value: T, index: number): R} project The function to apply
  5284. * to each `value` emitted by the source Observable. The `index` parameter is
  5285. * the number `i` for the i-th emission that has happened since the
  5286. * subscription, starting from the number `0`.
  5287. * @param {any} [thisArg] An optional argument to define what `this` is in the
  5288. * `project` function.
  5289. * @return {Observable<R>} An Observable that emits the values from the source
  5290. * Observable transformed by the given `project` function.
  5291. * @method map
  5292. * @owner Observable
  5293. */
  5294. function map(project, thisArg) {
  5295. return map_1.map(project, thisArg)(this);
  5296. }
  5297. exports.map = map;
  5298. //# sourceMappingURL=map.js.map
  5299.  
  5300. /***/ }),
  5301. /* 48 */
  5302. /***/ (function(module, exports, __webpack_require__) {
  5303.  
  5304. "use strict";
  5305.  
  5306. var __extends = (this && this.__extends) || function (d, b) {
  5307. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  5308. function __() { this.constructor = d; }
  5309. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5310. };
  5311. var Subscriber_1 = __webpack_require__(2);
  5312. /**
  5313. * Applies a given `project` function to each value emitted by the source
  5314. * Observable, and emits the resulting values as an Observable.
  5315. *
  5316. * <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
  5317. * it passes each source value through a transformation function to get
  5318. * corresponding output values.</span>
  5319. *
  5320. * <img src="./img/map.png" width="100%">
  5321. *
  5322. * Similar to the well known `Array.prototype.map` function, this operator
  5323. * applies a projection to each value and emits that projection in the output
  5324. * Observable.
  5325. *
  5326. * @example <caption>Map every click to the clientX position of that click</caption>
  5327. * var clicks = Rx.Observable.fromEvent(document, 'click');
  5328. * var positions = clicks.map(ev => ev.clientX);
  5329. * positions.subscribe(x => console.log(x));
  5330. *
  5331. * @see {@link mapTo}
  5332. * @see {@link pluck}
  5333. *
  5334. * @param {function(value: T, index: number): R} project The function to apply
  5335. * to each `value` emitted by the source Observable. The `index` parameter is
  5336. * the number `i` for the i-th emission that has happened since the
  5337. * subscription, starting from the number `0`.
  5338. * @param {any} [thisArg] An optional argument to define what `this` is in the
  5339. * `project` function.
  5340. * @return {Observable<R>} An Observable that emits the values from the source
  5341. * Observable transformed by the given `project` function.
  5342. * @method map
  5343. * @owner Observable
  5344. */
  5345. function map(project, thisArg) {
  5346. return function mapOperation(source) {
  5347. if (typeof project !== 'function') {
  5348. throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
  5349. }
  5350. return source.lift(new MapOperator(project, thisArg));
  5351. };
  5352. }
  5353. exports.map = map;
  5354. var MapOperator = (function () {
  5355. function MapOperator(project, thisArg) {
  5356. this.project = project;
  5357. this.thisArg = thisArg;
  5358. }
  5359. MapOperator.prototype.call = function (subscriber, source) {
  5360. return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
  5361. };
  5362. return MapOperator;
  5363. }());
  5364. exports.MapOperator = MapOperator;
  5365. /**
  5366. * We need this JSDoc comment for affecting ESDoc.
  5367. * @ignore
  5368. * @extends {Ignored}
  5369. */
  5370. var MapSubscriber = (function (_super) {
  5371. __extends(MapSubscriber, _super);
  5372. function MapSubscriber(destination, project, thisArg) {
  5373. _super.call(this, destination);
  5374. this.project = project;
  5375. this.count = 0;
  5376. this.thisArg = thisArg || this;
  5377. }
  5378. // NOTE: This looks unoptimized, but it's actually purposefully NOT
  5379. // using try/catch optimizations.
  5380. MapSubscriber.prototype._next = function (value) {
  5381. var result;
  5382. try {
  5383. result = this.project.call(this.thisArg, value, this.count++);
  5384. }
  5385. catch (err) {
  5386. this.destination.error(err);
  5387. return;
  5388. }
  5389. this.destination.next(result);
  5390. };
  5391. return MapSubscriber;
  5392. }(Subscriber_1.Subscriber));
  5393. //# sourceMappingURL=map.js.map
  5394.  
  5395. /***/ }),
  5396. /* 49 */
  5397. /***/ (function(module, exports, __webpack_require__) {
  5398.  
  5399. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(5), __webpack_require__(50)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, Subject_1) {
  5400. "use strict";
  5401. Object.defineProperty(exports, "__esModule", { value: true });
  5402. function WatchFlags() {
  5403. return WatchRequests().filter(function (request) { return !!(/flags\/posts\/\d+\/add\/[a-zA-Z]+/.exec(request.responseURL)); });
  5404. }
  5405. exports.WatchFlags = WatchFlags;
  5406. function WatchRequests() {
  5407. var obs = new Subject_1.Subject();
  5408. addXHRListener(function (xhr) {
  5409. obs.next(xhr);
  5410. });
  5411. return obs;
  5412. }
  5413. exports.WatchRequests = WatchRequests;
  5414. // Credits: https://github.com/SOBotics/Userscripts/blob/master/Natty/NattyReporter.user.js#L101
  5415. var initialized = false;
  5416. var callbacks = [];
  5417. function addXHRListener(callback) {
  5418. callbacks.push(callback);
  5419. if (initialized) {
  5420. return;
  5421. }
  5422. var open = XMLHttpRequest.prototype.open;
  5423. XMLHttpRequest.prototype.open = function () {
  5424. var _this = this;
  5425. this.addEventListener('load', function () {
  5426. callbacks.forEach(function (cb) { return cb(_this); });
  5427. }, false);
  5428. open.apply(this, arguments);
  5429. };
  5430. initialized = true;
  5431. }
  5432. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  5433. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  5434.  
  5435.  
  5436. /***/ }),
  5437. /* 50 */
  5438. /***/ (function(module, exports, __webpack_require__) {
  5439.  
  5440. "use strict";
  5441.  
  5442. var Observable_1 = __webpack_require__(1);
  5443. var filter_1 = __webpack_require__(51);
  5444. Observable_1.Observable.prototype.filter = filter_1.filter;
  5445. //# sourceMappingURL=filter.js.map
  5446.  
  5447. /***/ }),
  5448. /* 51 */
  5449. /***/ (function(module, exports, __webpack_require__) {
  5450.  
  5451. "use strict";
  5452.  
  5453. var filter_1 = __webpack_require__(52);
  5454. /* tslint:enable:max-line-length */
  5455. /**
  5456. * Filter items emitted by the source Observable by only emitting those that
  5457. * satisfy a specified predicate.
  5458. *
  5459. * <span class="informal">Like
  5460. * [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
  5461. * it only emits a value from the source if it passes a criterion function.</span>
  5462. *
  5463. * <img src="./img/filter.png" width="100%">
  5464. *
  5465. * Similar to the well-known `Array.prototype.filter` method, this operator
  5466. * takes values from the source Observable, passes them through a `predicate`
  5467. * function and only emits those values that yielded `true`.
  5468. *
  5469. * @example <caption>Emit only click events whose target was a DIV element</caption>
  5470. * var clicks = Rx.Observable.fromEvent(document, 'click');
  5471. * var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV');
  5472. * clicksOnDivs.subscribe(x => console.log(x));
  5473. *
  5474. * @see {@link distinct}
  5475. * @see {@link distinctUntilChanged}
  5476. * @see {@link distinctUntilKeyChanged}
  5477. * @see {@link ignoreElements}
  5478. * @see {@link partition}
  5479. * @see {@link skip}
  5480. *
  5481. * @param {function(value: T, index: number): boolean} predicate A function that
  5482. * evaluates each value emitted by the source Observable. If it returns `true`,
  5483. * the value is emitted, if `false` the value is not passed to the output
  5484. * Observable. The `index` parameter is the number `i` for the i-th source
  5485. * emission that has happened since the subscription, starting from the number
  5486. * `0`.
  5487. * @param {any} [thisArg] An optional argument to determine the value of `this`
  5488. * in the `predicate` function.
  5489. * @return {Observable} An Observable of values from the source that were
  5490. * allowed by the `predicate` function.
  5491. * @method filter
  5492. * @owner Observable
  5493. */
  5494. function filter(predicate, thisArg) {
  5495. return filter_1.filter(predicate, thisArg)(this);
  5496. }
  5497. exports.filter = filter;
  5498. //# sourceMappingURL=filter.js.map
  5499.  
  5500. /***/ }),
  5501. /* 52 */
  5502. /***/ (function(module, exports, __webpack_require__) {
  5503.  
  5504. "use strict";
  5505.  
  5506. var __extends = (this && this.__extends) || function (d, b) {
  5507. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  5508. function __() { this.constructor = d; }
  5509. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5510. };
  5511. var Subscriber_1 = __webpack_require__(2);
  5512. /* tslint:enable:max-line-length */
  5513. /**
  5514. * Filter items emitted by the source Observable by only emitting those that
  5515. * satisfy a specified predicate.
  5516. *
  5517. * <span class="informal">Like
  5518. * [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
  5519. * it only emits a value from the source if it passes a criterion function.</span>
  5520. *
  5521. * <img src="./img/filter.png" width="100%">
  5522. *
  5523. * Similar to the well-known `Array.prototype.filter` method, this operator
  5524. * takes values from the source Observable, passes them through a `predicate`
  5525. * function and only emits those values that yielded `true`.
  5526. *
  5527. * @example <caption>Emit only click events whose target was a DIV element</caption>
  5528. * var clicks = Rx.Observable.fromEvent(document, 'click');
  5529. * var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV');
  5530. * clicksOnDivs.subscribe(x => console.log(x));
  5531. *
  5532. * @see {@link distinct}
  5533. * @see {@link distinctUntilChanged}
  5534. * @see {@link distinctUntilKeyChanged}
  5535. * @see {@link ignoreElements}
  5536. * @see {@link partition}
  5537. * @see {@link skip}
  5538. *
  5539. * @param {function(value: T, index: number): boolean} predicate A function that
  5540. * evaluates each value emitted by the source Observable. If it returns `true`,
  5541. * the value is emitted, if `false` the value is not passed to the output
  5542. * Observable. The `index` parameter is the number `i` for the i-th source
  5543. * emission that has happened since the subscription, starting from the number
  5544. * `0`.
  5545. * @param {any} [thisArg] An optional argument to determine the value of `this`
  5546. * in the `predicate` function.
  5547. * @return {Observable} An Observable of values from the source that were
  5548. * allowed by the `predicate` function.
  5549. * @method filter
  5550. * @owner Observable
  5551. */
  5552. function filter(predicate, thisArg) {
  5553. return function filterOperatorFunction(source) {
  5554. return source.lift(new FilterOperator(predicate, thisArg));
  5555. };
  5556. }
  5557. exports.filter = filter;
  5558. var FilterOperator = (function () {
  5559. function FilterOperator(predicate, thisArg) {
  5560. this.predicate = predicate;
  5561. this.thisArg = thisArg;
  5562. }
  5563. FilterOperator.prototype.call = function (subscriber, source) {
  5564. return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
  5565. };
  5566. return FilterOperator;
  5567. }());
  5568. /**
  5569. * We need this JSDoc comment for affecting ESDoc.
  5570. * @ignore
  5571. * @extends {Ignored}
  5572. */
  5573. var FilterSubscriber = (function (_super) {
  5574. __extends(FilterSubscriber, _super);
  5575. function FilterSubscriber(destination, predicate, thisArg) {
  5576. _super.call(this, destination);
  5577. this.predicate = predicate;
  5578. this.thisArg = thisArg;
  5579. this.count = 0;
  5580. }
  5581. // the try catch block below is left specifically for
  5582. // optimization and perf reasons. a tryCatcher is not necessary here.
  5583. FilterSubscriber.prototype._next = function (value) {
  5584. var result;
  5585. try {
  5586. result = this.predicate.call(this.thisArg, value, this.count++);
  5587. }
  5588. catch (err) {
  5589. this.destination.error(err);
  5590. return;
  5591. }
  5592. if (result) {
  5593. this.destination.next(value);
  5594. }
  5595. };
  5596. return FilterSubscriber;
  5597. }(Subscriber_1.Subscriber));
  5598. //# sourceMappingURL=filter.js.map
  5599.  
  5600. /***/ }),
  5601. /* 53 */
  5602. /***/ (function(module, exports, __webpack_require__) {
  5603.  
  5604. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0), __webpack_require__(11), __webpack_require__(20), __webpack_require__(10), __webpack_require__(12)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, tslib_1, AdvancedFlagging_1, MetaSmokeAPI_1, CrossDomainCache_1, FlagTypes_1) {
  5605. "use strict";
  5606. Object.defineProperty(exports, "__esModule", { value: true });
  5607. function SetupConfiguration() {
  5608. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5609. var bottomBox, configurationDiv, cacheDisabledMessage, configurationLink;
  5610. return tslib_1.__generator(this, function (_a) {
  5611. switch (_a.label) {
  5612. case 0:
  5613. bottomBox = $('.site-footer--copyright').children('.-list');
  5614. configurationDiv = $('<div>')
  5615. .css('line-height', '18px')
  5616. .css('text-align', 'left')
  5617. .css('padding', '5px');
  5618. return [4 /*yield*/, CrossDomainCache_1.CrossDomainCache.CacheFailed()];
  5619. case 1:
  5620. if (!_a.sent()) return [3 /*break*/, 2];
  5621. cacheDisabledMessage = $('<p>Cache failed to initialize. AdvancedFlagging configuration disabled</p>');
  5622. configurationDiv.append(cacheDisabledMessage);
  5623. return [3 /*break*/, 4];
  5624. case 2: return [4 /*yield*/, SetupDefaults()];
  5625. case 3:
  5626. _a.sent();
  5627. configurationLink = $('<a href="javascript:void(0);">AdvancedFlagging configuration</a>');
  5628. configurationLink.click(function () { return BuildConfigurationOverlay(); });
  5629. configurationDiv.append(configurationLink);
  5630. _a.label = 4;
  5631. case 4:
  5632. configurationDiv.insertAfter(bottomBox);
  5633. return [2 /*return*/];
  5634. }
  5635. });
  5636. });
  5637. }
  5638. exports.SetupConfiguration = SetupConfiguration;
  5639. function getFlagTypes() {
  5640. var flagTypes = [];
  5641. FlagTypes_1.flagCategories.forEach(function (flagCategory) {
  5642. flagCategory.FlagTypes.forEach(function (flagType) {
  5643. flagTypes.push({
  5644. Id: flagType.Id,
  5645. DisplayName: flagType.DisplayName
  5646. });
  5647. });
  5648. });
  5649. return flagTypes;
  5650. }
  5651. function SetupDefaults() {
  5652. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5653. var configurationEnabledFlags, flagTypeIds;
  5654. return tslib_1.__generator(this, function (_a) {
  5655. switch (_a.label) {
  5656. case 0: return [4 /*yield*/, AdvancedFlagging_1.getFromCaches(AdvancedFlagging_1.ConfigurationEnabledFlags)];
  5657. case 1:
  5658. configurationEnabledFlags = _a.sent();
  5659. if (!configurationEnabledFlags) {
  5660. flagTypeIds = getFlagTypes().map(function (f) { return f.Id; });
  5661. AdvancedFlagging_1.storeInCaches(AdvancedFlagging_1.ConfigurationEnabledFlags, flagTypeIds);
  5662. }
  5663. return [2 /*return*/];
  5664. }
  5665. });
  5666. });
  5667. }
  5668. function BuildConfigurationOverlay() {
  5669. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5670. var overlay, overlayContent, configElements, sections, _a, _b, _c, _d, firstSection, submitButtons, okayButton, cancelButton;
  5671. return tslib_1.__generator(this, function (_e) {
  5672. switch (_e.label) {
  5673. case 0:
  5674. overlay = $('<div>')
  5675. .css('position', 'fixed')
  5676. .css('padding-top', '100px')
  5677. .css('left', 0)
  5678. .css('top', 0)
  5679. .css('width', '100%')
  5680. .css('height', '100%')
  5681. .css('overflow', 'auto')
  5682. .css('background-color', '#cccccc')
  5683. .css('background-color', 'rgba(0,0,0,0.4)');
  5684. overlayContent = $('<div>')
  5685. .css('background-color', '#fefefe')
  5686. .css('margin', 'auto')
  5687. .css('padding', '20px')
  5688. .css('border', '1px solid #888')
  5689. .css('width', '80%');
  5690. configElements = [];
  5691. overlayContent.append('<h1>AdvancedFlagging configuration</h1>');
  5692. _a = {
  5693. SectionName: 'General'
  5694. };
  5695. return [4 /*yield*/, GetGeneralConfigItems()];
  5696. case 1:
  5697. _b = [
  5698. (_a.Items = _e.sent(),
  5699. _a)
  5700. ];
  5701. _c = {
  5702. SectionName: 'Flags'
  5703. };
  5704. return [4 /*yield*/, GetFlagSettings()];
  5705. case 2:
  5706. _b = _b.concat([
  5707. (_c.Items = _e.sent(),
  5708. _c)
  5709. ]);
  5710. _d = {
  5711. SectionName: 'Admin'
  5712. };
  5713. return [4 /*yield*/, GetAdminConfigItems()];
  5714. case 3:
  5715. sections = _b.concat([
  5716. (_d.Items = _e.sent(),
  5717. _d)
  5718. ]);
  5719. firstSection = true;
  5720. sections.forEach(function (section) {
  5721. if (!firstSection) {
  5722. overlayContent.append('<hr />');
  5723. }
  5724. overlayContent.append("<h2>" + section.SectionName + "</h2>");
  5725. firstSection = false;
  5726. var sectionWrapper = $('<ul>').css('list-style', 'none');
  5727. overlayContent.append(sectionWrapper);
  5728. section.Items.forEach(function (item) {
  5729. configElements.push(item);
  5730. if (item.element) {
  5731. var listItem = $('<li>').css('line-height', '18px');
  5732. listItem.append(item.element);
  5733. sectionWrapper.append(listItem);
  5734. }
  5735. });
  5736. });
  5737. submitButtons = $('<div>')
  5738. .css('text-align', 'right');
  5739. okayButton = $('<input type="button" value="Save changes">');
  5740. cancelButton = $('<a href="#">Cancel</a>')
  5741. .css('margin-right', '15px');
  5742. okayButton.click(function (event) {
  5743. event.preventDefault();
  5744. var requiresReload = false;
  5745. configElements.forEach(function (configElement) {
  5746. if (configElement.onSave) {
  5747. configElement.onSave();
  5748. }
  5749. requiresReload = !!configElement.requiresReload;
  5750. });
  5751. overlay.remove();
  5752. AdvancedFlagging_1.displaySuccess('Configuration saved');
  5753. if (requiresReload) {
  5754. setTimeout(function () {
  5755. window.location.reload();
  5756. }, 500);
  5757. }
  5758. });
  5759. cancelButton.click(function (event) {
  5760. event.preventDefault();
  5761. overlay.remove();
  5762. });
  5763. submitButtons.append(cancelButton);
  5764. submitButtons.append(okayButton);
  5765. overlayContent.append(submitButtons);
  5766. overlay.append(overlayContent);
  5767. $(document.body).append(overlay);
  5768. return [2 /*return*/];
  5769. }
  5770. });
  5771. });
  5772. }
  5773. function GetGeneralConfigItems() {
  5774. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5775. return tslib_1.__generator(this, function (_a) {
  5776. return [2 /*return*/, Promise.all([
  5777. createConfigCheckbox('Open dropdown on hover', AdvancedFlagging_1.ConfigurationOpenOnHover),
  5778. createConfigCheckbox('Watch for manual flags', AdvancedFlagging_1.ConfigurationWatchFlags),
  5779. createConfigCheckbox('Watch for queue responses', AdvancedFlagging_1.ConfigurationWatchQueues),
  5780. createConfigCheckbox('Disable AdvancedFlagging link', AdvancedFlagging_1.ConfigurationLinkDisabled),
  5781. ])];
  5782. });
  5783. });
  5784. }
  5785. function GetFlagSettings() {
  5786. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5787. var _this = this;
  5788. var checkBoxes, flagTypeIds, returnArr;
  5789. return tslib_1.__generator(this, function (_a) {
  5790. switch (_a.label) {
  5791. case 0:
  5792. checkBoxes = [];
  5793. return [4 /*yield*/, AdvancedFlagging_1.getFromCaches(AdvancedFlagging_1.ConfigurationEnabledFlags)];
  5794. case 1:
  5795. flagTypeIds = (_a.sent()) || [];
  5796. getFlagTypes().forEach(function (f) {
  5797. var checkBox = $('<input type="checkbox">');
  5798. var label = $('<label />')
  5799. .append(checkBox)
  5800. .append(f.DisplayName);
  5801. var storedValue = flagTypeIds.indexOf(f.Id) > -1;
  5802. if (storedValue) {
  5803. checkBox.prop('checked', true);
  5804. }
  5805. checkBoxes.push({
  5806. label: label,
  5807. checkBox: checkBox,
  5808. Id: f.Id
  5809. });
  5810. });
  5811. returnArr = checkBoxes.map(function (f) { return ({ element: f.label }); });
  5812. returnArr.push({
  5813. onSave: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  5814. var updatedFlagTypes;
  5815. return tslib_1.__generator(this, function (_a) {
  5816. switch (_a.label) {
  5817. case 0:
  5818. updatedFlagTypes = checkBoxes.filter(function (cb) { return !!cb.checkBox.prop('checked'); }).map(function (cb) { return cb.Id; });
  5819. return [4 /*yield*/, AdvancedFlagging_1.storeInCaches(AdvancedFlagging_1.ConfigurationEnabledFlags, updatedFlagTypes)];
  5820. case 1:
  5821. _a.sent();
  5822. return [2 /*return*/];
  5823. }
  5824. });
  5825. }); },
  5826. requiresReload: true
  5827. });
  5828. return [2 /*return*/, returnArr];
  5829. }
  5830. });
  5831. });
  5832. }
  5833. function GetAdminConfigItems() {
  5834. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5835. var _this = this;
  5836. return tslib_1.__generator(this, function (_a) {
  5837. return [2 /*return*/, [
  5838. {
  5839. element: $('<a />').text('Clear Metasmoke Configuration')
  5840. .click(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  5841. return tslib_1.__generator(this, function (_a) {
  5842. switch (_a.label) {
  5843. case 0: return [4 /*yield*/, MetaSmokeAPI_1.MetaSmokeAPI.Reset()];
  5844. case 1:
  5845. _a.sent();
  5846. return [2 /*return*/];
  5847. }
  5848. });
  5849. }); }),
  5850. requiresReload: true
  5851. },
  5852. {
  5853. element: $('<a />').text('Get MetaSmoke key')
  5854. .attr('href', "https://metasmoke.erwaysoftware.com/oauth/request?key=" + AdvancedFlagging_1.metaSmokeKey)
  5855. },
  5856. {
  5857. element: $('<a />').text('Manually register MetaSmoke key')
  5858. .click(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  5859. var prompt;
  5860. return tslib_1.__generator(this, function (_a) {
  5861. prompt = window.prompt('Enter metasmoke key');
  5862. if (prompt) {
  5863. CrossDomainCache_1.CrossDomainCache.StoreInCache(MetaSmokeAPI_1.MetaSmokeDisabledConfig, false);
  5864. localStorage.setItem('MetaSmoke.ManualKey', prompt);
  5865. }
  5866. return [2 /*return*/];
  5867. });
  5868. }); }),
  5869. requiresReload: true
  5870. }
  5871. ]];
  5872. });
  5873. });
  5874. }
  5875. function createConfigCheckbox(text, configValue) {
  5876. return tslib_1.__awaiter(this, void 0, void 0, function () {
  5877. var _this = this;
  5878. var checkBox, label, storedValue;
  5879. return tslib_1.__generator(this, function (_a) {
  5880. switch (_a.label) {
  5881. case 0:
  5882. checkBox = $('<input type="checkbox">');
  5883. label = $('<label />')
  5884. .append(checkBox)
  5885. .append(text);
  5886. return [4 /*yield*/, AdvancedFlagging_1.getFromCaches(configValue)];
  5887. case 1:
  5888. storedValue = _a.sent();
  5889. if (storedValue) {
  5890. checkBox.prop('checked', true);
  5891. }
  5892. return [2 /*return*/, {
  5893. element: label,
  5894. onSave: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
  5895. var isChecked;
  5896. return tslib_1.__generator(this, function (_a) {
  5897. switch (_a.label) {
  5898. case 0:
  5899. isChecked = !!checkBox.prop('checked');
  5900. return [4 /*yield*/, AdvancedFlagging_1.storeInCaches(configValue, isChecked)];
  5901. case 1:
  5902. _a.sent();
  5903. return [2 /*return*/];
  5904. }
  5905. });
  5906. }); }
  5907. }];
  5908. }
  5909. });
  5910. });
  5911. }
  5912. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  5913. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  5914.  
  5915.  
  5916. /***/ })
  5917. /******/ ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement