data-table.js
4 years ago
data-table.js.map
4 years ago
index.js
4 years ago
index.js.map
4 years ago
settings.js
4 years ago
settings.js.map
4 years ago
index.js
4840 lines
| 1 | // modules are defined as an array |
| 2 | // [ module function, map of requires ] |
| 3 | // |
| 4 | // map of requires is short require name -> numeric require |
| 5 | // |
| 6 | // anything defined in a previous bundle is accessed via the |
| 7 | // orig method which is the require for previous bundles |
| 8 | |
| 9 | (function (modules, entry, mainEntry, parcelRequireName, globalName) { |
| 10 | /* eslint-disable no-undef */ |
| 11 | var globalObject = |
| 12 | typeof globalThis !== 'undefined' |
| 13 | ? globalThis |
| 14 | : typeof self !== 'undefined' |
| 15 | ? self |
| 16 | : typeof window !== 'undefined' |
| 17 | ? window |
| 18 | : typeof global !== 'undefined' |
| 19 | ? global |
| 20 | : {}; |
| 21 | /* eslint-enable no-undef */ |
| 22 | |
| 23 | // Save the require from previous bundle to this closure if any |
| 24 | var previousRequire = |
| 25 | typeof globalObject[parcelRequireName] === 'function' && |
| 26 | globalObject[parcelRequireName]; |
| 27 | |
| 28 | var cache = previousRequire.cache || {}; |
| 29 | // Do not use `require` to prevent Webpack from trying to bundle this call |
| 30 | var nodeRequire = |
| 31 | typeof module !== 'undefined' && |
| 32 | typeof module.require === 'function' && |
| 33 | module.require.bind(module); |
| 34 | |
| 35 | function newRequire(name, jumped) { |
| 36 | if (!cache[name]) { |
| 37 | if (!modules[name]) { |
| 38 | // if we cannot find the module within our internal map or |
| 39 | // cache jump to the current global require ie. the last bundle |
| 40 | // that was added to the page. |
| 41 | var currentRequire = |
| 42 | typeof globalObject[parcelRequireName] === 'function' && |
| 43 | globalObject[parcelRequireName]; |
| 44 | if (!jumped && currentRequire) { |
| 45 | return currentRequire(name, true); |
| 46 | } |
| 47 | |
| 48 | // If there are other bundles on this page the require from the |
| 49 | // previous one is saved to 'previousRequire'. Repeat this as |
| 50 | // many times as there are bundles until the module is found or |
| 51 | // we exhaust the require chain. |
| 52 | if (previousRequire) { |
| 53 | return previousRequire(name, true); |
| 54 | } |
| 55 | |
| 56 | // Try the node require function if it exists. |
| 57 | if (nodeRequire && typeof name === 'string') { |
| 58 | return nodeRequire(name); |
| 59 | } |
| 60 | |
| 61 | var err = new Error("Cannot find module '" + name + "'"); |
| 62 | err.code = 'MODULE_NOT_FOUND'; |
| 63 | throw err; |
| 64 | } |
| 65 | |
| 66 | localRequire.resolve = resolve; |
| 67 | localRequire.cache = {}; |
| 68 | |
| 69 | var module = (cache[name] = new newRequire.Module(name)); |
| 70 | |
| 71 | modules[name][0].call( |
| 72 | module.exports, |
| 73 | localRequire, |
| 74 | module, |
| 75 | module.exports, |
| 76 | this |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | return cache[name].exports; |
| 81 | |
| 82 | function localRequire(x) { |
| 83 | var res = localRequire.resolve(x); |
| 84 | return res === false ? {} : newRequire(res); |
| 85 | } |
| 86 | |
| 87 | function resolve(x) { |
| 88 | var id = modules[name][1][x]; |
| 89 | return id != null ? id : x; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function Module(moduleName) { |
| 94 | this.id = moduleName; |
| 95 | this.bundle = newRequire; |
| 96 | this.exports = {}; |
| 97 | } |
| 98 | |
| 99 | newRequire.isParcelRequire = true; |
| 100 | newRequire.Module = Module; |
| 101 | newRequire.modules = modules; |
| 102 | newRequire.cache = cache; |
| 103 | newRequire.parent = previousRequire; |
| 104 | newRequire.register = function (id, exports) { |
| 105 | modules[id] = [ |
| 106 | function (require, module) { |
| 107 | module.exports = exports; |
| 108 | }, |
| 109 | {}, |
| 110 | ]; |
| 111 | }; |
| 112 | |
| 113 | Object.defineProperty(newRequire, 'root', { |
| 114 | get: function () { |
| 115 | return globalObject[parcelRequireName]; |
| 116 | }, |
| 117 | }); |
| 118 | |
| 119 | globalObject[parcelRequireName] = newRequire; |
| 120 | |
| 121 | for (var i = 0; i < entry.length; i++) { |
| 122 | newRequire(entry[i]); |
| 123 | } |
| 124 | |
| 125 | if (mainEntry) { |
| 126 | // Expose entry point to Node, AMD or browser globals |
| 127 | // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js |
| 128 | var mainExports = newRequire(mainEntry); |
| 129 | |
| 130 | // CommonJS |
| 131 | if (typeof exports === 'object' && typeof module !== 'undefined') { |
| 132 | module.exports = mainExports; |
| 133 | |
| 134 | // RequireJS |
| 135 | } else if (typeof define === 'function' && define.amd) { |
| 136 | define(function () { |
| 137 | return mainExports; |
| 138 | }); |
| 139 | |
| 140 | // <script> |
| 141 | } else if (globalName) { |
| 142 | this[globalName] = mainExports; |
| 143 | } |
| 144 | } |
| 145 | })({"2CYCe":[function(require,module,exports) { |
| 146 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 147 | var _stimulus = require("@hotwired/stimulus"); |
| 148 | var _micromodal = require("micromodal"); |
| 149 | var _micromodalDefault = parcelHelpers.interopDefault(_micromodal); |
| 150 | var _deleteDataController = require("./controllers/delete_data_controller"); |
| 151 | var _deleteDataControllerDefault = parcelHelpers.interopDefault(_deleteDataController); |
| 152 | var _chartController = require("./controllers/chart_controller"); |
| 153 | var _chartControllerDefault = parcelHelpers.interopDefault(_chartController); |
| 154 | document.addEventListener("DOMContentLoaded", function() { |
| 155 | return (0, _micromodalDefault.default).init(); |
| 156 | }); |
| 157 | window.Stimulus = (0, _stimulus.Application).start(); |
| 158 | Stimulus.register("delete-data", (0, _deleteDataControllerDefault.default)); |
| 159 | Stimulus.register("chart", (0, _chartControllerDefault.default)); |
| 160 | |
| 161 | },{"@hotwired/stimulus":"27q4D","micromodal":"dW4sP","./controllers/delete_data_controller":"ibNcV","./controllers/chart_controller":"hrjuy","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"27q4D":[function(require,module,exports) { |
| 162 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 163 | parcelHelpers.defineInteropFlag(exports); |
| 164 | parcelHelpers.export(exports, "Application", function() { |
| 165 | return Application; |
| 166 | }); |
| 167 | parcelHelpers.export(exports, "AttributeObserver", function() { |
| 168 | return AttributeObserver; |
| 169 | }); |
| 170 | parcelHelpers.export(exports, "Context", function() { |
| 171 | return Context; |
| 172 | }); |
| 173 | parcelHelpers.export(exports, "Controller", function() { |
| 174 | return Controller; |
| 175 | }); |
| 176 | parcelHelpers.export(exports, "ElementObserver", function() { |
| 177 | return ElementObserver; |
| 178 | }); |
| 179 | parcelHelpers.export(exports, "IndexedMultimap", function() { |
| 180 | return IndexedMultimap; |
| 181 | }); |
| 182 | parcelHelpers.export(exports, "Multimap", function() { |
| 183 | return Multimap; |
| 184 | }); |
| 185 | parcelHelpers.export(exports, "StringMapObserver", function() { |
| 186 | return StringMapObserver; |
| 187 | }); |
| 188 | parcelHelpers.export(exports, "TokenListObserver", function() { |
| 189 | return TokenListObserver; |
| 190 | }); |
| 191 | parcelHelpers.export(exports, "ValueListObserver", function() { |
| 192 | return ValueListObserver; |
| 193 | }); |
| 194 | parcelHelpers.export(exports, "add", function() { |
| 195 | return add; |
| 196 | }); |
| 197 | parcelHelpers.export(exports, "defaultSchema", function() { |
| 198 | return defaultSchema; |
| 199 | }); |
| 200 | parcelHelpers.export(exports, "del", function() { |
| 201 | return del; |
| 202 | }); |
| 203 | parcelHelpers.export(exports, "fetch", function() { |
| 204 | return fetch; |
| 205 | }); |
| 206 | parcelHelpers.export(exports, "prune", function() { |
| 207 | return prune; |
| 208 | }); |
| 209 | var _asyncToGeneratorJs = require("@swc/helpers/lib/_async_to_generator.js"); |
| 210 | var _asyncToGeneratorJsDefault = parcelHelpers.interopDefault(_asyncToGeneratorJs); |
| 211 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 212 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 213 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 214 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 215 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 216 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 217 | var _getJs = require("@swc/helpers/lib/_get.js"); |
| 218 | var _getJsDefault = parcelHelpers.interopDefault(_getJs); |
| 219 | var _getPrototypeOfJs = require("@swc/helpers/lib/_get_prototype_of.js"); |
| 220 | var _getPrototypeOfJsDefault = parcelHelpers.interopDefault(_getPrototypeOfJs); |
| 221 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 222 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 223 | var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js"); |
| 224 | var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs); |
| 225 | var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js"); |
| 226 | var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs); |
| 227 | var _typeOfJs = require("@swc/helpers/lib/_type_of.js"); |
| 228 | var _typeOfJsDefault = parcelHelpers.interopDefault(_typeOfJs); |
| 229 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 230 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 231 | var _regeneratorRuntime = require("regenerator-runtime"); |
| 232 | var _regeneratorRuntimeDefault = parcelHelpers.interopDefault(_regeneratorRuntime); |
| 233 | /* |
| 234 | Stimulus 3.0.1 |
| 235 | Copyright © 2021 Basecamp, LLC |
| 236 | */ var EventListener = /*#__PURE__*/ function() { |
| 237 | "use strict"; |
| 238 | function EventListener(eventTarget, eventName, eventOptions) { |
| 239 | (0, _classCallCheckJsDefault.default)(this, EventListener); |
| 240 | this.eventTarget = eventTarget; |
| 241 | this.eventName = eventName; |
| 242 | this.eventOptions = eventOptions; |
| 243 | this.unorderedBindings = new Set(); |
| 244 | } |
| 245 | (0, _createClassJsDefault.default)(EventListener, [ |
| 246 | { |
| 247 | key: "connect", |
| 248 | value: function connect() { |
| 249 | this.eventTarget.addEventListener(this.eventName, this, this.eventOptions); |
| 250 | } |
| 251 | }, |
| 252 | { |
| 253 | key: "disconnect", |
| 254 | value: function disconnect() { |
| 255 | this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions); |
| 256 | } |
| 257 | }, |
| 258 | { |
| 259 | key: "bindingConnected", |
| 260 | value: function bindingConnected(binding) { |
| 261 | this.unorderedBindings.add(binding); |
| 262 | } |
| 263 | }, |
| 264 | { |
| 265 | key: "bindingDisconnected", |
| 266 | value: function bindingDisconnected(binding) { |
| 267 | this.unorderedBindings.delete(binding); |
| 268 | } |
| 269 | }, |
| 270 | { |
| 271 | key: "handleEvent", |
| 272 | value: function handleEvent(event) { |
| 273 | var extendedEvent = extendEvent(event); |
| 274 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 275 | try { |
| 276 | for(var _iterator = this.bindings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 277 | var binding = _step.value; |
| 278 | if (extendedEvent.immediatePropagationStopped) break; |
| 279 | else binding.handleEvent(extendedEvent); |
| 280 | } |
| 281 | } catch (err) { |
| 282 | _didIteratorError = true; |
| 283 | _iteratorError = err; |
| 284 | } finally{ |
| 285 | try { |
| 286 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 287 | _iterator.return(); |
| 288 | } |
| 289 | } finally{ |
| 290 | if (_didIteratorError) { |
| 291 | throw _iteratorError; |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | }, |
| 297 | { |
| 298 | key: "bindings", |
| 299 | get: function get() { |
| 300 | return Array.from(this.unorderedBindings).sort(function(left, right) { |
| 301 | var leftIndex = left.index, rightIndex = right.index; |
| 302 | return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0; |
| 303 | }); |
| 304 | } |
| 305 | } |
| 306 | ]); |
| 307 | return EventListener; |
| 308 | }(); |
| 309 | function extendEvent(event) { |
| 310 | if ("immediatePropagationStopped" in event) return event; |
| 311 | else { |
| 312 | var stopImmediatePropagation = event.stopImmediatePropagation; |
| 313 | return Object.assign(event, { |
| 314 | immediatePropagationStopped: false, |
| 315 | stopImmediatePropagation: function() { |
| 316 | this.immediatePropagationStopped = true; |
| 317 | stopImmediatePropagation.call(this); |
| 318 | } |
| 319 | }); |
| 320 | } |
| 321 | } |
| 322 | var Dispatcher = /*#__PURE__*/ function() { |
| 323 | "use strict"; |
| 324 | function Dispatcher(application) { |
| 325 | (0, _classCallCheckJsDefault.default)(this, Dispatcher); |
| 326 | this.application = application; |
| 327 | this.eventListenerMaps = new Map; |
| 328 | this.started = false; |
| 329 | } |
| 330 | (0, _createClassJsDefault.default)(Dispatcher, [ |
| 331 | { |
| 332 | key: "start", |
| 333 | value: function start() { |
| 334 | if (!this.started) { |
| 335 | this.started = true; |
| 336 | this.eventListeners.forEach(function(eventListener) { |
| 337 | return eventListener.connect(); |
| 338 | }); |
| 339 | } |
| 340 | } |
| 341 | }, |
| 342 | { |
| 343 | key: "stop", |
| 344 | value: function stop() { |
| 345 | if (this.started) { |
| 346 | this.started = false; |
| 347 | this.eventListeners.forEach(function(eventListener) { |
| 348 | return eventListener.disconnect(); |
| 349 | }); |
| 350 | } |
| 351 | } |
| 352 | }, |
| 353 | { |
| 354 | key: "eventListeners", |
| 355 | get: function get() { |
| 356 | return Array.from(this.eventListenerMaps.values()).reduce(function(listeners, map) { |
| 357 | return listeners.concat(Array.from(map.values())); |
| 358 | }, []); |
| 359 | } |
| 360 | }, |
| 361 | { |
| 362 | key: "bindingConnected", |
| 363 | value: function bindingConnected(binding) { |
| 364 | this.fetchEventListenerForBinding(binding).bindingConnected(binding); |
| 365 | } |
| 366 | }, |
| 367 | { |
| 368 | key: "bindingDisconnected", |
| 369 | value: function bindingDisconnected(binding) { |
| 370 | this.fetchEventListenerForBinding(binding).bindingDisconnected(binding); |
| 371 | } |
| 372 | }, |
| 373 | { |
| 374 | key: "handleError", |
| 375 | value: function handleError(error1, message) { |
| 376 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 377 | this.application.handleError(error1, "Error ".concat(message), detail); |
| 378 | } |
| 379 | }, |
| 380 | { |
| 381 | key: "fetchEventListenerForBinding", |
| 382 | value: function fetchEventListenerForBinding(binding) { |
| 383 | var eventTarget = binding.eventTarget, eventName = binding.eventName, eventOptions = binding.eventOptions; |
| 384 | return this.fetchEventListener(eventTarget, eventName, eventOptions); |
| 385 | } |
| 386 | }, |
| 387 | { |
| 388 | key: "fetchEventListener", |
| 389 | value: function fetchEventListener(eventTarget, eventName, eventOptions) { |
| 390 | var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); |
| 391 | var cacheKey = this.cacheKey(eventName, eventOptions); |
| 392 | var eventListener = eventListenerMap.get(cacheKey); |
| 393 | if (!eventListener) { |
| 394 | eventListener = this.createEventListener(eventTarget, eventName, eventOptions); |
| 395 | eventListenerMap.set(cacheKey, eventListener); |
| 396 | } |
| 397 | return eventListener; |
| 398 | } |
| 399 | }, |
| 400 | { |
| 401 | key: "createEventListener", |
| 402 | value: function createEventListener(eventTarget, eventName, eventOptions) { |
| 403 | var eventListener = new EventListener(eventTarget, eventName, eventOptions); |
| 404 | if (this.started) eventListener.connect(); |
| 405 | return eventListener; |
| 406 | } |
| 407 | }, |
| 408 | { |
| 409 | key: "fetchEventListenerMapForEventTarget", |
| 410 | value: function fetchEventListenerMapForEventTarget(eventTarget) { |
| 411 | var eventListenerMap = this.eventListenerMaps.get(eventTarget); |
| 412 | if (!eventListenerMap) { |
| 413 | eventListenerMap = new Map; |
| 414 | this.eventListenerMaps.set(eventTarget, eventListenerMap); |
| 415 | } |
| 416 | return eventListenerMap; |
| 417 | } |
| 418 | }, |
| 419 | { |
| 420 | key: "cacheKey", |
| 421 | value: function cacheKey(eventName, eventOptions) { |
| 422 | var parts = [ |
| 423 | eventName |
| 424 | ]; |
| 425 | Object.keys(eventOptions).sort().forEach(function(key) { |
| 426 | parts.push("".concat(eventOptions[key] ? "" : "!").concat(key)); |
| 427 | }); |
| 428 | return parts.join(":"); |
| 429 | } |
| 430 | } |
| 431 | ]); |
| 432 | return Dispatcher; |
| 433 | }(); |
| 434 | var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/; |
| 435 | function parseActionDescriptorString(descriptorString) { |
| 436 | var source = descriptorString.trim(); |
| 437 | var matches = source.match(descriptorPattern) || []; |
| 438 | return { |
| 439 | eventTarget: parseEventTarget(matches[4]), |
| 440 | eventName: matches[2], |
| 441 | eventOptions: matches[9] ? parseEventOptions(matches[9]) : {}, |
| 442 | identifier: matches[5], |
| 443 | methodName: matches[7] |
| 444 | }; |
| 445 | } |
| 446 | function parseEventTarget(eventTargetName) { |
| 447 | if (eventTargetName == "window") return window; |
| 448 | else if (eventTargetName == "document") return document; |
| 449 | } |
| 450 | function parseEventOptions(eventOptions) { |
| 451 | return eventOptions.split(":").reduce(function(options, token) { |
| 452 | return Object.assign(options, (0, _definePropertyJsDefault.default)({}, token.replace(/^!/, ""), !/^!/.test(token))); |
| 453 | }, {}); |
| 454 | } |
| 455 | function stringifyEventTarget(eventTarget) { |
| 456 | if (eventTarget == window) return "window"; |
| 457 | else if (eventTarget == document) return "document"; |
| 458 | } |
| 459 | function camelize(value) { |
| 460 | return value.replace(/(?:[_-])([a-z0-9])/g, function(_, char) { |
| 461 | return char.toUpperCase(); |
| 462 | }); |
| 463 | } |
| 464 | function capitalize(value) { |
| 465 | return value.charAt(0).toUpperCase() + value.slice(1); |
| 466 | } |
| 467 | function dasherize(value) { |
| 468 | return value.replace(/([A-Z])/g, function(_, char) { |
| 469 | return "-".concat(char.toLowerCase()); |
| 470 | }); |
| 471 | } |
| 472 | function tokenize(value) { |
| 473 | return value.match(/[^\s]+/g) || []; |
| 474 | } |
| 475 | var Action = /*#__PURE__*/ function() { |
| 476 | "use strict"; |
| 477 | function Action(element, index, descriptor) { |
| 478 | (0, _classCallCheckJsDefault.default)(this, Action); |
| 479 | this.element = element; |
| 480 | this.index = index; |
| 481 | this.eventTarget = descriptor.eventTarget || element; |
| 482 | this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name"); |
| 483 | this.eventOptions = descriptor.eventOptions || {}; |
| 484 | this.identifier = descriptor.identifier || error("missing identifier"); |
| 485 | this.methodName = descriptor.methodName || error("missing method name"); |
| 486 | } |
| 487 | (0, _createClassJsDefault.default)(Action, [ |
| 488 | { |
| 489 | key: "toString", |
| 490 | value: function toString() { |
| 491 | var eventNameSuffix = this.eventTargetName ? "@".concat(this.eventTargetName) : ""; |
| 492 | return "".concat(this.eventName).concat(eventNameSuffix, "->").concat(this.identifier, "#").concat(this.methodName); |
| 493 | } |
| 494 | }, |
| 495 | { |
| 496 | key: "params", |
| 497 | get: function get() { |
| 498 | if (this.eventTarget instanceof Element) return this.getParamsFromEventTargetAttributes(this.eventTarget); |
| 499 | else return {}; |
| 500 | } |
| 501 | }, |
| 502 | { |
| 503 | key: "getParamsFromEventTargetAttributes", |
| 504 | value: function getParamsFromEventTargetAttributes(eventTarget) { |
| 505 | var params = {}; |
| 506 | var pattern = new RegExp("^data-".concat(this.identifier, "-(.+)-param$")); |
| 507 | var attributes = Array.from(eventTarget.attributes); |
| 508 | attributes.forEach(function(param) { |
| 509 | var name = param.name, value = param.value; |
| 510 | var match = name.match(pattern); |
| 511 | var key = match && match[1]; |
| 512 | if (key) Object.assign(params, (0, _definePropertyJsDefault.default)({}, camelize(key), typecast(value))); |
| 513 | }); |
| 514 | return params; |
| 515 | } |
| 516 | }, |
| 517 | { |
| 518 | key: "eventTargetName", |
| 519 | get: function get() { |
| 520 | return stringifyEventTarget(this.eventTarget); |
| 521 | } |
| 522 | } |
| 523 | ], [ |
| 524 | { |
| 525 | key: "forToken", |
| 526 | value: function forToken(token) { |
| 527 | return new this(token.element, token.index, parseActionDescriptorString(token.content)); |
| 528 | } |
| 529 | } |
| 530 | ]); |
| 531 | return Action; |
| 532 | }(); |
| 533 | var defaultEventNames = { |
| 534 | "a": function(e) { |
| 535 | return "click"; |
| 536 | }, |
| 537 | "button": function(e) { |
| 538 | return "click"; |
| 539 | }, |
| 540 | "form": function(e) { |
| 541 | return "submit"; |
| 542 | }, |
| 543 | "details": function(e) { |
| 544 | return "toggle"; |
| 545 | }, |
| 546 | "input": function(e) { |
| 547 | return e.getAttribute("type") == "submit" ? "click" : "input"; |
| 548 | }, |
| 549 | "select": function(e) { |
| 550 | return "change"; |
| 551 | }, |
| 552 | "textarea": function(e) { |
| 553 | return "input"; |
| 554 | } |
| 555 | }; |
| 556 | function getDefaultEventNameForElement(element) { |
| 557 | var tagName = element.tagName.toLowerCase(); |
| 558 | if (tagName in defaultEventNames) return defaultEventNames[tagName](element); |
| 559 | } |
| 560 | function error(message) { |
| 561 | throw new Error(message); |
| 562 | } |
| 563 | function typecast(value) { |
| 564 | try { |
| 565 | return JSON.parse(value); |
| 566 | } catch (o_O) { |
| 567 | return value; |
| 568 | } |
| 569 | } |
| 570 | var Binding = /*#__PURE__*/ function() { |
| 571 | "use strict"; |
| 572 | function Binding(context, action) { |
| 573 | (0, _classCallCheckJsDefault.default)(this, Binding); |
| 574 | this.context = context; |
| 575 | this.action = action; |
| 576 | } |
| 577 | (0, _createClassJsDefault.default)(Binding, [ |
| 578 | { |
| 579 | key: "index", |
| 580 | get: function get() { |
| 581 | return this.action.index; |
| 582 | } |
| 583 | }, |
| 584 | { |
| 585 | key: "eventTarget", |
| 586 | get: function get() { |
| 587 | return this.action.eventTarget; |
| 588 | } |
| 589 | }, |
| 590 | { |
| 591 | key: "eventOptions", |
| 592 | get: function get() { |
| 593 | return this.action.eventOptions; |
| 594 | } |
| 595 | }, |
| 596 | { |
| 597 | key: "identifier", |
| 598 | get: function get() { |
| 599 | return this.context.identifier; |
| 600 | } |
| 601 | }, |
| 602 | { |
| 603 | key: "handleEvent", |
| 604 | value: function handleEvent(event) { |
| 605 | if (this.willBeInvokedByEvent(event)) this.invokeWithEvent(event); |
| 606 | } |
| 607 | }, |
| 608 | { |
| 609 | key: "eventName", |
| 610 | get: function get() { |
| 611 | return this.action.eventName; |
| 612 | } |
| 613 | }, |
| 614 | { |
| 615 | key: "method", |
| 616 | get: function get() { |
| 617 | var method = this.controller[this.methodName]; |
| 618 | if (typeof method == "function") return method; |
| 619 | throw new Error('Action "'.concat(this.action, '" references undefined method "').concat(this.methodName, '"')); |
| 620 | } |
| 621 | }, |
| 622 | { |
| 623 | key: "invokeWithEvent", |
| 624 | value: function invokeWithEvent(event) { |
| 625 | var target = event.target, currentTarget = event.currentTarget; |
| 626 | try { |
| 627 | var params = this.action.params; |
| 628 | var actionEvent = Object.assign(event, { |
| 629 | params: params |
| 630 | }); |
| 631 | this.method.call(this.controller, actionEvent); |
| 632 | this.context.logDebugActivity(this.methodName, { |
| 633 | event: event, |
| 634 | target: target, |
| 635 | currentTarget: currentTarget, |
| 636 | action: this.methodName |
| 637 | }); |
| 638 | } catch (error2) { |
| 639 | var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element, index = ref.index; |
| 640 | var detail = { |
| 641 | identifier: identifier, |
| 642 | controller: controller, |
| 643 | element: element, |
| 644 | index: index, |
| 645 | event: event |
| 646 | }; |
| 647 | this.context.handleError(error2, 'invoking action "'.concat(this.action, '"'), detail); |
| 648 | } |
| 649 | } |
| 650 | }, |
| 651 | { |
| 652 | key: "willBeInvokedByEvent", |
| 653 | value: function willBeInvokedByEvent(event) { |
| 654 | var eventTarget = event.target; |
| 655 | if (this.element === eventTarget) return true; |
| 656 | else if (eventTarget instanceof Element && this.element.contains(eventTarget)) return this.scope.containsElement(eventTarget); |
| 657 | else return this.scope.containsElement(this.action.element); |
| 658 | } |
| 659 | }, |
| 660 | { |
| 661 | key: "controller", |
| 662 | get: function get() { |
| 663 | return this.context.controller; |
| 664 | } |
| 665 | }, |
| 666 | { |
| 667 | key: "methodName", |
| 668 | get: function get() { |
| 669 | return this.action.methodName; |
| 670 | } |
| 671 | }, |
| 672 | { |
| 673 | key: "element", |
| 674 | get: function get() { |
| 675 | return this.scope.element; |
| 676 | } |
| 677 | }, |
| 678 | { |
| 679 | key: "scope", |
| 680 | get: function get() { |
| 681 | return this.context.scope; |
| 682 | } |
| 683 | } |
| 684 | ]); |
| 685 | return Binding; |
| 686 | }(); |
| 687 | var ElementObserver = /*#__PURE__*/ function() { |
| 688 | "use strict"; |
| 689 | function ElementObserver(element, delegate) { |
| 690 | var _this = this; |
| 691 | (0, _classCallCheckJsDefault.default)(this, ElementObserver); |
| 692 | this.mutationObserverInit = { |
| 693 | attributes: true, |
| 694 | childList: true, |
| 695 | subtree: true |
| 696 | }; |
| 697 | this.element = element; |
| 698 | this.started = false; |
| 699 | this.delegate = delegate; |
| 700 | this.elements = new Set; |
| 701 | this.mutationObserver = new MutationObserver(function(mutations) { |
| 702 | return _this.processMutations(mutations); |
| 703 | }); |
| 704 | } |
| 705 | (0, _createClassJsDefault.default)(ElementObserver, [ |
| 706 | { |
| 707 | key: "start", |
| 708 | value: function start() { |
| 709 | if (!this.started) { |
| 710 | this.started = true; |
| 711 | this.mutationObserver.observe(this.element, this.mutationObserverInit); |
| 712 | this.refresh(); |
| 713 | } |
| 714 | } |
| 715 | }, |
| 716 | { |
| 717 | key: "pause", |
| 718 | value: function pause(callback) { |
| 719 | if (this.started) { |
| 720 | this.mutationObserver.disconnect(); |
| 721 | this.started = false; |
| 722 | } |
| 723 | callback(); |
| 724 | if (!this.started) { |
| 725 | this.mutationObserver.observe(this.element, this.mutationObserverInit); |
| 726 | this.started = true; |
| 727 | } |
| 728 | } |
| 729 | }, |
| 730 | { |
| 731 | key: "stop", |
| 732 | value: function stop() { |
| 733 | if (this.started) { |
| 734 | this.mutationObserver.takeRecords(); |
| 735 | this.mutationObserver.disconnect(); |
| 736 | this.started = false; |
| 737 | } |
| 738 | } |
| 739 | }, |
| 740 | { |
| 741 | key: "refresh", |
| 742 | value: function refresh() { |
| 743 | if (this.started) { |
| 744 | var matches = new Set(this.matchElementsInTree()); |
| 745 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 746 | try { |
| 747 | for(var _iterator = Array.from(this.elements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 748 | var element = _step.value; |
| 749 | if (!matches.has(element)) this.removeElement(element); |
| 750 | } |
| 751 | } catch (err) { |
| 752 | _didIteratorError = true; |
| 753 | _iteratorError = err; |
| 754 | } finally{ |
| 755 | try { |
| 756 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 757 | _iterator.return(); |
| 758 | } |
| 759 | } finally{ |
| 760 | if (_didIteratorError) { |
| 761 | throw _iteratorError; |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined; |
| 766 | try { |
| 767 | for(var _iterator1 = Array.from(matches)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){ |
| 768 | var element1 = _step1.value; |
| 769 | this.addElement(element1); |
| 770 | } |
| 771 | } catch (err) { |
| 772 | _didIteratorError1 = true; |
| 773 | _iteratorError1 = err; |
| 774 | } finally{ |
| 775 | try { |
| 776 | if (!_iteratorNormalCompletion1 && _iterator1.return != null) { |
| 777 | _iterator1.return(); |
| 778 | } |
| 779 | } finally{ |
| 780 | if (_didIteratorError1) { |
| 781 | throw _iteratorError1; |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | }, |
| 788 | { |
| 789 | key: "processMutations", |
| 790 | value: function processMutations(mutations) { |
| 791 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 792 | if (this.started) try { |
| 793 | for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 794 | var mutation = _step.value; |
| 795 | this.processMutation(mutation); |
| 796 | } |
| 797 | } catch (err) { |
| 798 | _didIteratorError = true; |
| 799 | _iteratorError = err; |
| 800 | } finally{ |
| 801 | try { |
| 802 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 803 | _iterator.return(); |
| 804 | } |
| 805 | } finally{ |
| 806 | if (_didIteratorError) { |
| 807 | throw _iteratorError; |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | } |
| 812 | }, |
| 813 | { |
| 814 | key: "processMutation", |
| 815 | value: function processMutation(mutation) { |
| 816 | if (mutation.type == "attributes") this.processAttributeChange(mutation.target, mutation.attributeName); |
| 817 | else if (mutation.type == "childList") { |
| 818 | this.processRemovedNodes(mutation.removedNodes); |
| 819 | this.processAddedNodes(mutation.addedNodes); |
| 820 | } |
| 821 | } |
| 822 | }, |
| 823 | { |
| 824 | key: "processAttributeChange", |
| 825 | value: function processAttributeChange(node, attributeName) { |
| 826 | var element = node; |
| 827 | if (this.elements.has(element)) { |
| 828 | if (this.delegate.elementAttributeChanged && this.matchElement(element)) this.delegate.elementAttributeChanged(element, attributeName); |
| 829 | else this.removeElement(element); |
| 830 | } else if (this.matchElement(element)) this.addElement(element); |
| 831 | } |
| 832 | }, |
| 833 | { |
| 834 | key: "processRemovedNodes", |
| 835 | value: function processRemovedNodes(nodes) { |
| 836 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 837 | try { |
| 838 | for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 839 | var node = _step.value; |
| 840 | var element = this.elementFromNode(node); |
| 841 | if (element) this.processTree(element, this.removeElement); |
| 842 | } |
| 843 | } catch (err) { |
| 844 | _didIteratorError = true; |
| 845 | _iteratorError = err; |
| 846 | } finally{ |
| 847 | try { |
| 848 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 849 | _iterator.return(); |
| 850 | } |
| 851 | } finally{ |
| 852 | if (_didIteratorError) { |
| 853 | throw _iteratorError; |
| 854 | } |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | }, |
| 859 | { |
| 860 | key: "processAddedNodes", |
| 861 | value: function processAddedNodes(nodes) { |
| 862 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 863 | try { |
| 864 | for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 865 | var node = _step.value; |
| 866 | var element = this.elementFromNode(node); |
| 867 | if (element && this.elementIsActive(element)) this.processTree(element, this.addElement); |
| 868 | } |
| 869 | } catch (err) { |
| 870 | _didIteratorError = true; |
| 871 | _iteratorError = err; |
| 872 | } finally{ |
| 873 | try { |
| 874 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 875 | _iterator.return(); |
| 876 | } |
| 877 | } finally{ |
| 878 | if (_didIteratorError) { |
| 879 | throw _iteratorError; |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | }, |
| 885 | { |
| 886 | key: "matchElement", |
| 887 | value: function matchElement(element) { |
| 888 | return this.delegate.matchElement(element); |
| 889 | } |
| 890 | }, |
| 891 | { |
| 892 | key: "matchElementsInTree", |
| 893 | value: function matchElementsInTree() { |
| 894 | var tree = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.element; |
| 895 | return this.delegate.matchElementsInTree(tree); |
| 896 | } |
| 897 | }, |
| 898 | { |
| 899 | key: "processTree", |
| 900 | value: function processTree(tree, processor) { |
| 901 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 902 | try { |
| 903 | for(var _iterator = this.matchElementsInTree(tree)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 904 | var element = _step.value; |
| 905 | processor.call(this, element); |
| 906 | } |
| 907 | } catch (err) { |
| 908 | _didIteratorError = true; |
| 909 | _iteratorError = err; |
| 910 | } finally{ |
| 911 | try { |
| 912 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 913 | _iterator.return(); |
| 914 | } |
| 915 | } finally{ |
| 916 | if (_didIteratorError) { |
| 917 | throw _iteratorError; |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | }, |
| 923 | { |
| 924 | key: "elementFromNode", |
| 925 | value: function elementFromNode(node) { |
| 926 | if (node.nodeType == Node.ELEMENT_NODE) return node; |
| 927 | } |
| 928 | }, |
| 929 | { |
| 930 | key: "elementIsActive", |
| 931 | value: function elementIsActive(element) { |
| 932 | if (element.isConnected != this.element.isConnected) return false; |
| 933 | else return this.element.contains(element); |
| 934 | } |
| 935 | }, |
| 936 | { |
| 937 | key: "addElement", |
| 938 | value: function addElement(element) { |
| 939 | if (!this.elements.has(element)) { |
| 940 | if (this.elementIsActive(element)) { |
| 941 | this.elements.add(element); |
| 942 | if (this.delegate.elementMatched) this.delegate.elementMatched(element); |
| 943 | } |
| 944 | } |
| 945 | } |
| 946 | }, |
| 947 | { |
| 948 | key: "removeElement", |
| 949 | value: function removeElement(element) { |
| 950 | if (this.elements.has(element)) { |
| 951 | this.elements.delete(element); |
| 952 | if (this.delegate.elementUnmatched) this.delegate.elementUnmatched(element); |
| 953 | } |
| 954 | } |
| 955 | } |
| 956 | ]); |
| 957 | return ElementObserver; |
| 958 | }(); |
| 959 | var AttributeObserver = /*#__PURE__*/ function() { |
| 960 | "use strict"; |
| 961 | function AttributeObserver(element, attributeName, delegate) { |
| 962 | (0, _classCallCheckJsDefault.default)(this, AttributeObserver); |
| 963 | this.attributeName = attributeName; |
| 964 | this.delegate = delegate; |
| 965 | this.elementObserver = new ElementObserver(element, this); |
| 966 | } |
| 967 | (0, _createClassJsDefault.default)(AttributeObserver, [ |
| 968 | { |
| 969 | key: "element", |
| 970 | get: function get() { |
| 971 | return this.elementObserver.element; |
| 972 | } |
| 973 | }, |
| 974 | { |
| 975 | key: "selector", |
| 976 | get: function get() { |
| 977 | return "[".concat(this.attributeName, "]"); |
| 978 | } |
| 979 | }, |
| 980 | { |
| 981 | key: "start", |
| 982 | value: function start() { |
| 983 | this.elementObserver.start(); |
| 984 | } |
| 985 | }, |
| 986 | { |
| 987 | key: "pause", |
| 988 | value: function pause(callback) { |
| 989 | this.elementObserver.pause(callback); |
| 990 | } |
| 991 | }, |
| 992 | { |
| 993 | key: "stop", |
| 994 | value: function stop() { |
| 995 | this.elementObserver.stop(); |
| 996 | } |
| 997 | }, |
| 998 | { |
| 999 | key: "refresh", |
| 1000 | value: function refresh() { |
| 1001 | this.elementObserver.refresh(); |
| 1002 | } |
| 1003 | }, |
| 1004 | { |
| 1005 | key: "started", |
| 1006 | get: function get() { |
| 1007 | return this.elementObserver.started; |
| 1008 | } |
| 1009 | }, |
| 1010 | { |
| 1011 | key: "matchElement", |
| 1012 | value: function matchElement(element) { |
| 1013 | return element.hasAttribute(this.attributeName); |
| 1014 | } |
| 1015 | }, |
| 1016 | { |
| 1017 | key: "matchElementsInTree", |
| 1018 | value: function matchElementsInTree(tree) { |
| 1019 | var match = this.matchElement(tree) ? [ |
| 1020 | tree |
| 1021 | ] : []; |
| 1022 | var matches = Array.from(tree.querySelectorAll(this.selector)); |
| 1023 | return match.concat(matches); |
| 1024 | } |
| 1025 | }, |
| 1026 | { |
| 1027 | key: "elementMatched", |
| 1028 | value: function elementMatched(element) { |
| 1029 | if (this.delegate.elementMatchedAttribute) this.delegate.elementMatchedAttribute(element, this.attributeName); |
| 1030 | } |
| 1031 | }, |
| 1032 | { |
| 1033 | key: "elementUnmatched", |
| 1034 | value: function elementUnmatched(element) { |
| 1035 | if (this.delegate.elementUnmatchedAttribute) this.delegate.elementUnmatchedAttribute(element, this.attributeName); |
| 1036 | } |
| 1037 | }, |
| 1038 | { |
| 1039 | key: "elementAttributeChanged", |
| 1040 | value: function elementAttributeChanged(element, attributeName) { |
| 1041 | if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) this.delegate.elementAttributeValueChanged(element, attributeName); |
| 1042 | } |
| 1043 | } |
| 1044 | ]); |
| 1045 | return AttributeObserver; |
| 1046 | }(); |
| 1047 | var StringMapObserver = /*#__PURE__*/ function() { |
| 1048 | "use strict"; |
| 1049 | function StringMapObserver(element, delegate) { |
| 1050 | var _this = this; |
| 1051 | (0, _classCallCheckJsDefault.default)(this, StringMapObserver); |
| 1052 | this.element = element; |
| 1053 | this.delegate = delegate; |
| 1054 | this.started = false; |
| 1055 | this.stringMap = new Map; |
| 1056 | this.mutationObserver = new MutationObserver(function(mutations) { |
| 1057 | return _this.processMutations(mutations); |
| 1058 | }); |
| 1059 | } |
| 1060 | (0, _createClassJsDefault.default)(StringMapObserver, [ |
| 1061 | { |
| 1062 | key: "start", |
| 1063 | value: function start() { |
| 1064 | if (!this.started) { |
| 1065 | this.started = true; |
| 1066 | this.mutationObserver.observe(this.element, { |
| 1067 | attributes: true, |
| 1068 | attributeOldValue: true |
| 1069 | }); |
| 1070 | this.refresh(); |
| 1071 | } |
| 1072 | } |
| 1073 | }, |
| 1074 | { |
| 1075 | key: "stop", |
| 1076 | value: function stop() { |
| 1077 | if (this.started) { |
| 1078 | this.mutationObserver.takeRecords(); |
| 1079 | this.mutationObserver.disconnect(); |
| 1080 | this.started = false; |
| 1081 | } |
| 1082 | } |
| 1083 | }, |
| 1084 | { |
| 1085 | key: "refresh", |
| 1086 | value: function refresh() { |
| 1087 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1088 | if (this.started) try { |
| 1089 | for(var _iterator = this.knownAttributeNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1090 | var attributeName = _step.value; |
| 1091 | this.refreshAttribute(attributeName, null); |
| 1092 | } |
| 1093 | } catch (err) { |
| 1094 | _didIteratorError = true; |
| 1095 | _iteratorError = err; |
| 1096 | } finally{ |
| 1097 | try { |
| 1098 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1099 | _iterator.return(); |
| 1100 | } |
| 1101 | } finally{ |
| 1102 | if (_didIteratorError) { |
| 1103 | throw _iteratorError; |
| 1104 | } |
| 1105 | } |
| 1106 | } |
| 1107 | } |
| 1108 | }, |
| 1109 | { |
| 1110 | key: "processMutations", |
| 1111 | value: function processMutations(mutations) { |
| 1112 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1113 | if (this.started) try { |
| 1114 | for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1115 | var mutation = _step.value; |
| 1116 | this.processMutation(mutation); |
| 1117 | } |
| 1118 | } catch (err) { |
| 1119 | _didIteratorError = true; |
| 1120 | _iteratorError = err; |
| 1121 | } finally{ |
| 1122 | try { |
| 1123 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1124 | _iterator.return(); |
| 1125 | } |
| 1126 | } finally{ |
| 1127 | if (_didIteratorError) { |
| 1128 | throw _iteratorError; |
| 1129 | } |
| 1130 | } |
| 1131 | } |
| 1132 | } |
| 1133 | }, |
| 1134 | { |
| 1135 | key: "processMutation", |
| 1136 | value: function processMutation(mutation) { |
| 1137 | var attributeName = mutation.attributeName; |
| 1138 | if (attributeName) this.refreshAttribute(attributeName, mutation.oldValue); |
| 1139 | } |
| 1140 | }, |
| 1141 | { |
| 1142 | key: "refreshAttribute", |
| 1143 | value: function refreshAttribute(attributeName, oldValue) { |
| 1144 | var key = this.delegate.getStringMapKeyForAttribute(attributeName); |
| 1145 | if (key != null) { |
| 1146 | if (!this.stringMap.has(attributeName)) this.stringMapKeyAdded(key, attributeName); |
| 1147 | var value = this.element.getAttribute(attributeName); |
| 1148 | if (this.stringMap.get(attributeName) != value) this.stringMapValueChanged(value, key, oldValue); |
| 1149 | if (value == null) { |
| 1150 | var _$oldValue = this.stringMap.get(attributeName); |
| 1151 | this.stringMap.delete(attributeName); |
| 1152 | if (_$oldValue) this.stringMapKeyRemoved(key, attributeName, _$oldValue); |
| 1153 | } else this.stringMap.set(attributeName, value); |
| 1154 | } |
| 1155 | } |
| 1156 | }, |
| 1157 | { |
| 1158 | key: "stringMapKeyAdded", |
| 1159 | value: function stringMapKeyAdded(key, attributeName) { |
| 1160 | if (this.delegate.stringMapKeyAdded) this.delegate.stringMapKeyAdded(key, attributeName); |
| 1161 | } |
| 1162 | }, |
| 1163 | { |
| 1164 | key: "stringMapValueChanged", |
| 1165 | value: function stringMapValueChanged(value, key, oldValue) { |
| 1166 | if (this.delegate.stringMapValueChanged) this.delegate.stringMapValueChanged(value, key, oldValue); |
| 1167 | } |
| 1168 | }, |
| 1169 | { |
| 1170 | key: "stringMapKeyRemoved", |
| 1171 | value: function stringMapKeyRemoved(key, attributeName, oldValue) { |
| 1172 | if (this.delegate.stringMapKeyRemoved) this.delegate.stringMapKeyRemoved(key, attributeName, oldValue); |
| 1173 | } |
| 1174 | }, |
| 1175 | { |
| 1176 | key: "knownAttributeNames", |
| 1177 | get: function get() { |
| 1178 | return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames))); |
| 1179 | } |
| 1180 | }, |
| 1181 | { |
| 1182 | key: "currentAttributeNames", |
| 1183 | get: function get() { |
| 1184 | return Array.from(this.element.attributes).map(function(attribute) { |
| 1185 | return attribute.name; |
| 1186 | }); |
| 1187 | } |
| 1188 | }, |
| 1189 | { |
| 1190 | key: "recordedAttributeNames", |
| 1191 | get: function get() { |
| 1192 | return Array.from(this.stringMap.keys()); |
| 1193 | } |
| 1194 | } |
| 1195 | ]); |
| 1196 | return StringMapObserver; |
| 1197 | }(); |
| 1198 | function add(map, key, value) { |
| 1199 | fetch(map, key).add(value); |
| 1200 | } |
| 1201 | function del(map, key, value) { |
| 1202 | fetch(map, key).delete(value); |
| 1203 | prune(map, key); |
| 1204 | } |
| 1205 | function fetch(map, key) { |
| 1206 | var values = map.get(key); |
| 1207 | if (!values) { |
| 1208 | values = new Set(); |
| 1209 | map.set(key, values); |
| 1210 | } |
| 1211 | return values; |
| 1212 | } |
| 1213 | function prune(map, key) { |
| 1214 | var values = map.get(key); |
| 1215 | if (values != null && values.size == 0) map.delete(key); |
| 1216 | } |
| 1217 | var Multimap = /*#__PURE__*/ function() { |
| 1218 | "use strict"; |
| 1219 | function Multimap() { |
| 1220 | (0, _classCallCheckJsDefault.default)(this, Multimap); |
| 1221 | this.valuesByKey = new Map(); |
| 1222 | } |
| 1223 | (0, _createClassJsDefault.default)(Multimap, [ |
| 1224 | { |
| 1225 | key: "keys", |
| 1226 | get: function get() { |
| 1227 | return Array.from(this.valuesByKey.keys()); |
| 1228 | } |
| 1229 | }, |
| 1230 | { |
| 1231 | key: "values", |
| 1232 | get: function get() { |
| 1233 | var sets = Array.from(this.valuesByKey.values()); |
| 1234 | return sets.reduce(function(values, set) { |
| 1235 | return values.concat(Array.from(set)); |
| 1236 | }, []); |
| 1237 | } |
| 1238 | }, |
| 1239 | { |
| 1240 | key: "size", |
| 1241 | get: function get() { |
| 1242 | var sets = Array.from(this.valuesByKey.values()); |
| 1243 | return sets.reduce(function(size, set) { |
| 1244 | return size + set.size; |
| 1245 | }, 0); |
| 1246 | } |
| 1247 | }, |
| 1248 | { |
| 1249 | key: "add", |
| 1250 | value: function add1(key, value) { |
| 1251 | add(this.valuesByKey, key, value); |
| 1252 | } |
| 1253 | }, |
| 1254 | { |
| 1255 | key: "delete", |
| 1256 | value: function _delete(key, value) { |
| 1257 | del(this.valuesByKey, key, value); |
| 1258 | } |
| 1259 | }, |
| 1260 | { |
| 1261 | key: "has", |
| 1262 | value: function has(key, value) { |
| 1263 | var values = this.valuesByKey.get(key); |
| 1264 | return values != null && values.has(value); |
| 1265 | } |
| 1266 | }, |
| 1267 | { |
| 1268 | key: "hasKey", |
| 1269 | value: function hasKey(key) { |
| 1270 | return this.valuesByKey.has(key); |
| 1271 | } |
| 1272 | }, |
| 1273 | { |
| 1274 | key: "hasValue", |
| 1275 | value: function hasValue(value) { |
| 1276 | var sets = Array.from(this.valuesByKey.values()); |
| 1277 | return sets.some(function(set) { |
| 1278 | return set.has(value); |
| 1279 | }); |
| 1280 | } |
| 1281 | }, |
| 1282 | { |
| 1283 | key: "getValuesForKey", |
| 1284 | value: function getValuesForKey(key) { |
| 1285 | var values = this.valuesByKey.get(key); |
| 1286 | return values ? Array.from(values) : []; |
| 1287 | } |
| 1288 | }, |
| 1289 | { |
| 1290 | key: "getKeysForValue", |
| 1291 | value: function getKeysForValue(value) { |
| 1292 | return Array.from(this.valuesByKey).filter(function(param) { |
| 1293 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1]; |
| 1294 | return values.has(value); |
| 1295 | }).map(function(param) { |
| 1296 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1]; |
| 1297 | return key; |
| 1298 | }); |
| 1299 | } |
| 1300 | } |
| 1301 | ]); |
| 1302 | return Multimap; |
| 1303 | }(); |
| 1304 | var IndexedMultimap = /*#__PURE__*/ function(Multimap) { |
| 1305 | "use strict"; |
| 1306 | (0, _inheritsJsDefault.default)(IndexedMultimap, Multimap); |
| 1307 | var _super = (0, _createSuperJsDefault.default)(IndexedMultimap); |
| 1308 | function IndexedMultimap() { |
| 1309 | (0, _classCallCheckJsDefault.default)(this, IndexedMultimap); |
| 1310 | var _this; |
| 1311 | _this = _super.call(this); |
| 1312 | _this.keysByValue = new Map; |
| 1313 | return _this; |
| 1314 | } |
| 1315 | (0, _createClassJsDefault.default)(IndexedMultimap, [ |
| 1316 | { |
| 1317 | key: "values", |
| 1318 | get: function get() { |
| 1319 | return Array.from(this.keysByValue.keys()); |
| 1320 | } |
| 1321 | }, |
| 1322 | { |
| 1323 | key: "add", |
| 1324 | value: function add1(key, value) { |
| 1325 | (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "add", this).call(this, key, value); |
| 1326 | add(this.keysByValue, value, key); |
| 1327 | } |
| 1328 | }, |
| 1329 | { |
| 1330 | key: "delete", |
| 1331 | value: function _delete(key, value) { |
| 1332 | (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "delete", this).call(this, key, value); |
| 1333 | del(this.keysByValue, value, key); |
| 1334 | } |
| 1335 | }, |
| 1336 | { |
| 1337 | key: "hasValue", |
| 1338 | value: function hasValue(value) { |
| 1339 | return this.keysByValue.has(value); |
| 1340 | } |
| 1341 | }, |
| 1342 | { |
| 1343 | key: "getKeysForValue", |
| 1344 | value: function getKeysForValue(value) { |
| 1345 | var set = this.keysByValue.get(value); |
| 1346 | return set ? Array.from(set) : []; |
| 1347 | } |
| 1348 | } |
| 1349 | ]); |
| 1350 | return IndexedMultimap; |
| 1351 | }(Multimap); |
| 1352 | var TokenListObserver = /*#__PURE__*/ function() { |
| 1353 | "use strict"; |
| 1354 | function TokenListObserver(element, attributeName, delegate) { |
| 1355 | (0, _classCallCheckJsDefault.default)(this, TokenListObserver); |
| 1356 | this.attributeObserver = new AttributeObserver(element, attributeName, this); |
| 1357 | this.delegate = delegate; |
| 1358 | this.tokensByElement = new Multimap; |
| 1359 | } |
| 1360 | (0, _createClassJsDefault.default)(TokenListObserver, [ |
| 1361 | { |
| 1362 | key: "started", |
| 1363 | get: function get() { |
| 1364 | return this.attributeObserver.started; |
| 1365 | } |
| 1366 | }, |
| 1367 | { |
| 1368 | key: "start", |
| 1369 | value: function start() { |
| 1370 | this.attributeObserver.start(); |
| 1371 | } |
| 1372 | }, |
| 1373 | { |
| 1374 | key: "pause", |
| 1375 | value: function pause(callback) { |
| 1376 | this.attributeObserver.pause(callback); |
| 1377 | } |
| 1378 | }, |
| 1379 | { |
| 1380 | key: "stop", |
| 1381 | value: function stop() { |
| 1382 | this.attributeObserver.stop(); |
| 1383 | } |
| 1384 | }, |
| 1385 | { |
| 1386 | key: "refresh", |
| 1387 | value: function refresh() { |
| 1388 | this.attributeObserver.refresh(); |
| 1389 | } |
| 1390 | }, |
| 1391 | { |
| 1392 | key: "element", |
| 1393 | get: function get() { |
| 1394 | return this.attributeObserver.element; |
| 1395 | } |
| 1396 | }, |
| 1397 | { |
| 1398 | key: "attributeName", |
| 1399 | get: function get() { |
| 1400 | return this.attributeObserver.attributeName; |
| 1401 | } |
| 1402 | }, |
| 1403 | { |
| 1404 | key: "elementMatchedAttribute", |
| 1405 | value: function elementMatchedAttribute(element) { |
| 1406 | this.tokensMatched(this.readTokensForElement(element)); |
| 1407 | } |
| 1408 | }, |
| 1409 | { |
| 1410 | key: "elementAttributeValueChanged", |
| 1411 | value: function elementAttributeValueChanged(element) { |
| 1412 | var ref = (0, _slicedToArrayJsDefault.default)(this.refreshTokensForElement(element), 2), unmatchedTokens = ref[0], matchedTokens = ref[1]; |
| 1413 | this.tokensUnmatched(unmatchedTokens); |
| 1414 | this.tokensMatched(matchedTokens); |
| 1415 | } |
| 1416 | }, |
| 1417 | { |
| 1418 | key: "elementUnmatchedAttribute", |
| 1419 | value: function elementUnmatchedAttribute(element) { |
| 1420 | this.tokensUnmatched(this.tokensByElement.getValuesForKey(element)); |
| 1421 | } |
| 1422 | }, |
| 1423 | { |
| 1424 | key: "tokensMatched", |
| 1425 | value: function tokensMatched(tokens) { |
| 1426 | var _this = this; |
| 1427 | tokens.forEach(function(token) { |
| 1428 | return _this.tokenMatched(token); |
| 1429 | }); |
| 1430 | } |
| 1431 | }, |
| 1432 | { |
| 1433 | key: "tokensUnmatched", |
| 1434 | value: function tokensUnmatched(tokens) { |
| 1435 | var _this = this; |
| 1436 | tokens.forEach(function(token) { |
| 1437 | return _this.tokenUnmatched(token); |
| 1438 | }); |
| 1439 | } |
| 1440 | }, |
| 1441 | { |
| 1442 | key: "tokenMatched", |
| 1443 | value: function tokenMatched(token) { |
| 1444 | this.delegate.tokenMatched(token); |
| 1445 | this.tokensByElement.add(token.element, token); |
| 1446 | } |
| 1447 | }, |
| 1448 | { |
| 1449 | key: "tokenUnmatched", |
| 1450 | value: function tokenUnmatched(token) { |
| 1451 | this.delegate.tokenUnmatched(token); |
| 1452 | this.tokensByElement.delete(token.element, token); |
| 1453 | } |
| 1454 | }, |
| 1455 | { |
| 1456 | key: "refreshTokensForElement", |
| 1457 | value: function refreshTokensForElement(element) { |
| 1458 | var previousTokens = this.tokensByElement.getValuesForKey(element); |
| 1459 | var currentTokens = this.readTokensForElement(element); |
| 1460 | var firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(function(param) { |
| 1461 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), previousToken = _param[0], currentToken = _param[1]; |
| 1462 | return !tokensAreEqual(previousToken, currentToken); |
| 1463 | }); |
| 1464 | if (firstDifferingIndex == -1) return [ |
| 1465 | [], |
| 1466 | [] |
| 1467 | ]; |
| 1468 | else return [ |
| 1469 | previousTokens.slice(firstDifferingIndex), |
| 1470 | currentTokens.slice(firstDifferingIndex) |
| 1471 | ]; |
| 1472 | } |
| 1473 | }, |
| 1474 | { |
| 1475 | key: "readTokensForElement", |
| 1476 | value: function readTokensForElement(element) { |
| 1477 | var attributeName = this.attributeName; |
| 1478 | var tokenString = element.getAttribute(attributeName) || ""; |
| 1479 | return parseTokenString(tokenString, element, attributeName); |
| 1480 | } |
| 1481 | } |
| 1482 | ]); |
| 1483 | return TokenListObserver; |
| 1484 | }(); |
| 1485 | function parseTokenString(tokenString, element, attributeName) { |
| 1486 | return tokenString.trim().split(/\s+/).filter(function(content) { |
| 1487 | return content.length; |
| 1488 | }).map(function(content, index) { |
| 1489 | return { |
| 1490 | element: element, |
| 1491 | attributeName: attributeName, |
| 1492 | content: content, |
| 1493 | index: index |
| 1494 | }; |
| 1495 | }); |
| 1496 | } |
| 1497 | function zip(left, right) { |
| 1498 | var length = Math.max(left.length, right.length); |
| 1499 | return Array.from({ |
| 1500 | length: length |
| 1501 | }, function(_, index) { |
| 1502 | return [ |
| 1503 | left[index], |
| 1504 | right[index] |
| 1505 | ]; |
| 1506 | }); |
| 1507 | } |
| 1508 | function tokensAreEqual(left, right) { |
| 1509 | return left && right && left.index == right.index && left.content == right.content; |
| 1510 | } |
| 1511 | var ValueListObserver = /*#__PURE__*/ function() { |
| 1512 | "use strict"; |
| 1513 | function ValueListObserver(element, attributeName, delegate) { |
| 1514 | (0, _classCallCheckJsDefault.default)(this, ValueListObserver); |
| 1515 | this.tokenListObserver = new TokenListObserver(element, attributeName, this); |
| 1516 | this.delegate = delegate; |
| 1517 | this.parseResultsByToken = new WeakMap; |
| 1518 | this.valuesByTokenByElement = new WeakMap; |
| 1519 | } |
| 1520 | (0, _createClassJsDefault.default)(ValueListObserver, [ |
| 1521 | { |
| 1522 | key: "started", |
| 1523 | get: function get() { |
| 1524 | return this.tokenListObserver.started; |
| 1525 | } |
| 1526 | }, |
| 1527 | { |
| 1528 | key: "start", |
| 1529 | value: function start() { |
| 1530 | this.tokenListObserver.start(); |
| 1531 | } |
| 1532 | }, |
| 1533 | { |
| 1534 | key: "stop", |
| 1535 | value: function stop() { |
| 1536 | this.tokenListObserver.stop(); |
| 1537 | } |
| 1538 | }, |
| 1539 | { |
| 1540 | key: "refresh", |
| 1541 | value: function refresh() { |
| 1542 | this.tokenListObserver.refresh(); |
| 1543 | } |
| 1544 | }, |
| 1545 | { |
| 1546 | key: "element", |
| 1547 | get: function get() { |
| 1548 | return this.tokenListObserver.element; |
| 1549 | } |
| 1550 | }, |
| 1551 | { |
| 1552 | key: "attributeName", |
| 1553 | get: function get() { |
| 1554 | return this.tokenListObserver.attributeName; |
| 1555 | } |
| 1556 | }, |
| 1557 | { |
| 1558 | key: "tokenMatched", |
| 1559 | value: function tokenMatched(token) { |
| 1560 | var element = token.element; |
| 1561 | var value = this.fetchParseResultForToken(token).value; |
| 1562 | if (value) { |
| 1563 | this.fetchValuesByTokenForElement(element).set(token, value); |
| 1564 | this.delegate.elementMatchedValue(element, value); |
| 1565 | } |
| 1566 | } |
| 1567 | }, |
| 1568 | { |
| 1569 | key: "tokenUnmatched", |
| 1570 | value: function tokenUnmatched(token) { |
| 1571 | var element = token.element; |
| 1572 | var value = this.fetchParseResultForToken(token).value; |
| 1573 | if (value) { |
| 1574 | this.fetchValuesByTokenForElement(element).delete(token); |
| 1575 | this.delegate.elementUnmatchedValue(element, value); |
| 1576 | } |
| 1577 | } |
| 1578 | }, |
| 1579 | { |
| 1580 | key: "fetchParseResultForToken", |
| 1581 | value: function fetchParseResultForToken(token) { |
| 1582 | var parseResult = this.parseResultsByToken.get(token); |
| 1583 | if (!parseResult) { |
| 1584 | parseResult = this.parseToken(token); |
| 1585 | this.parseResultsByToken.set(token, parseResult); |
| 1586 | } |
| 1587 | return parseResult; |
| 1588 | } |
| 1589 | }, |
| 1590 | { |
| 1591 | key: "fetchValuesByTokenForElement", |
| 1592 | value: function fetchValuesByTokenForElement(element) { |
| 1593 | var valuesByToken = this.valuesByTokenByElement.get(element); |
| 1594 | if (!valuesByToken) { |
| 1595 | valuesByToken = new Map; |
| 1596 | this.valuesByTokenByElement.set(element, valuesByToken); |
| 1597 | } |
| 1598 | return valuesByToken; |
| 1599 | } |
| 1600 | }, |
| 1601 | { |
| 1602 | key: "parseToken", |
| 1603 | value: function parseToken(token) { |
| 1604 | try { |
| 1605 | var value = this.delegate.parseValueForToken(token); |
| 1606 | return { |
| 1607 | value: value |
| 1608 | }; |
| 1609 | } catch (error3) { |
| 1610 | return { |
| 1611 | error: error3 |
| 1612 | }; |
| 1613 | } |
| 1614 | } |
| 1615 | } |
| 1616 | ]); |
| 1617 | return ValueListObserver; |
| 1618 | }(); |
| 1619 | var BindingObserver = /*#__PURE__*/ function() { |
| 1620 | "use strict"; |
| 1621 | function BindingObserver(context, delegate) { |
| 1622 | (0, _classCallCheckJsDefault.default)(this, BindingObserver); |
| 1623 | this.context = context; |
| 1624 | this.delegate = delegate; |
| 1625 | this.bindingsByAction = new Map; |
| 1626 | } |
| 1627 | (0, _createClassJsDefault.default)(BindingObserver, [ |
| 1628 | { |
| 1629 | key: "start", |
| 1630 | value: function start() { |
| 1631 | if (!this.valueListObserver) { |
| 1632 | this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this); |
| 1633 | this.valueListObserver.start(); |
| 1634 | } |
| 1635 | } |
| 1636 | }, |
| 1637 | { |
| 1638 | key: "stop", |
| 1639 | value: function stop() { |
| 1640 | if (this.valueListObserver) { |
| 1641 | this.valueListObserver.stop(); |
| 1642 | delete this.valueListObserver; |
| 1643 | this.disconnectAllActions(); |
| 1644 | } |
| 1645 | } |
| 1646 | }, |
| 1647 | { |
| 1648 | key: "element", |
| 1649 | get: function get() { |
| 1650 | return this.context.element; |
| 1651 | } |
| 1652 | }, |
| 1653 | { |
| 1654 | key: "identifier", |
| 1655 | get: function get() { |
| 1656 | return this.context.identifier; |
| 1657 | } |
| 1658 | }, |
| 1659 | { |
| 1660 | key: "actionAttribute", |
| 1661 | get: function get() { |
| 1662 | return this.schema.actionAttribute; |
| 1663 | } |
| 1664 | }, |
| 1665 | { |
| 1666 | key: "schema", |
| 1667 | get: function get() { |
| 1668 | return this.context.schema; |
| 1669 | } |
| 1670 | }, |
| 1671 | { |
| 1672 | key: "bindings", |
| 1673 | get: function get() { |
| 1674 | return Array.from(this.bindingsByAction.values()); |
| 1675 | } |
| 1676 | }, |
| 1677 | { |
| 1678 | key: "connectAction", |
| 1679 | value: function connectAction(action) { |
| 1680 | var binding = new Binding(this.context, action); |
| 1681 | this.bindingsByAction.set(action, binding); |
| 1682 | this.delegate.bindingConnected(binding); |
| 1683 | } |
| 1684 | }, |
| 1685 | { |
| 1686 | key: "disconnectAction", |
| 1687 | value: function disconnectAction(action) { |
| 1688 | var binding = this.bindingsByAction.get(action); |
| 1689 | if (binding) { |
| 1690 | this.bindingsByAction.delete(action); |
| 1691 | this.delegate.bindingDisconnected(binding); |
| 1692 | } |
| 1693 | } |
| 1694 | }, |
| 1695 | { |
| 1696 | key: "disconnectAllActions", |
| 1697 | value: function disconnectAllActions() { |
| 1698 | var _this = this; |
| 1699 | this.bindings.forEach(function(binding) { |
| 1700 | return _this.delegate.bindingDisconnected(binding); |
| 1701 | }); |
| 1702 | this.bindingsByAction.clear(); |
| 1703 | } |
| 1704 | }, |
| 1705 | { |
| 1706 | key: "parseValueForToken", |
| 1707 | value: function parseValueForToken(token) { |
| 1708 | var action = Action.forToken(token); |
| 1709 | if (action.identifier == this.identifier) return action; |
| 1710 | } |
| 1711 | }, |
| 1712 | { |
| 1713 | key: "elementMatchedValue", |
| 1714 | value: function elementMatchedValue(element, action) { |
| 1715 | this.connectAction(action); |
| 1716 | } |
| 1717 | }, |
| 1718 | { |
| 1719 | key: "elementUnmatchedValue", |
| 1720 | value: function elementUnmatchedValue(element, action) { |
| 1721 | this.disconnectAction(action); |
| 1722 | } |
| 1723 | } |
| 1724 | ]); |
| 1725 | return BindingObserver; |
| 1726 | }(); |
| 1727 | var ValueObserver = /*#__PURE__*/ function() { |
| 1728 | "use strict"; |
| 1729 | function ValueObserver(context, receiver) { |
| 1730 | (0, _classCallCheckJsDefault.default)(this, ValueObserver); |
| 1731 | this.context = context; |
| 1732 | this.receiver = receiver; |
| 1733 | this.stringMapObserver = new StringMapObserver(this.element, this); |
| 1734 | this.valueDescriptorMap = this.controller.valueDescriptorMap; |
| 1735 | this.invokeChangedCallbacksForDefaultValues(); |
| 1736 | } |
| 1737 | (0, _createClassJsDefault.default)(ValueObserver, [ |
| 1738 | { |
| 1739 | key: "start", |
| 1740 | value: function start() { |
| 1741 | this.stringMapObserver.start(); |
| 1742 | } |
| 1743 | }, |
| 1744 | { |
| 1745 | key: "stop", |
| 1746 | value: function stop() { |
| 1747 | this.stringMapObserver.stop(); |
| 1748 | } |
| 1749 | }, |
| 1750 | { |
| 1751 | key: "element", |
| 1752 | get: function get() { |
| 1753 | return this.context.element; |
| 1754 | } |
| 1755 | }, |
| 1756 | { |
| 1757 | key: "controller", |
| 1758 | get: function get() { |
| 1759 | return this.context.controller; |
| 1760 | } |
| 1761 | }, |
| 1762 | { |
| 1763 | key: "getStringMapKeyForAttribute", |
| 1764 | value: function getStringMapKeyForAttribute(attributeName) { |
| 1765 | if (attributeName in this.valueDescriptorMap) return this.valueDescriptorMap[attributeName].name; |
| 1766 | } |
| 1767 | }, |
| 1768 | { |
| 1769 | key: "stringMapKeyAdded", |
| 1770 | value: function stringMapKeyAdded(key, attributeName) { |
| 1771 | var descriptor = this.valueDescriptorMap[attributeName]; |
| 1772 | if (!this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue)); |
| 1773 | } |
| 1774 | }, |
| 1775 | { |
| 1776 | key: "stringMapValueChanged", |
| 1777 | value: function stringMapValueChanged(value, name, oldValue) { |
| 1778 | var descriptor = this.valueDescriptorNameMap[name]; |
| 1779 | if (value === null) return; |
| 1780 | if (oldValue === null) oldValue = descriptor.writer(descriptor.defaultValue); |
| 1781 | this.invokeChangedCallback(name, value, oldValue); |
| 1782 | } |
| 1783 | }, |
| 1784 | { |
| 1785 | key: "stringMapKeyRemoved", |
| 1786 | value: function stringMapKeyRemoved(key, attributeName, oldValue) { |
| 1787 | var descriptor = this.valueDescriptorNameMap[key]; |
| 1788 | if (this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue); |
| 1789 | else this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue); |
| 1790 | } |
| 1791 | }, |
| 1792 | { |
| 1793 | key: "invokeChangedCallbacksForDefaultValues", |
| 1794 | value: function invokeChangedCallbacksForDefaultValues() { |
| 1795 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1796 | try { |
| 1797 | for(var _iterator = this.valueDescriptors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1798 | var _value = _step.value, key = _value.key, name = _value.name, defaultValue = _value.defaultValue, writer = _value.writer; |
| 1799 | if (defaultValue != undefined && !this.controller.data.has(key)) this.invokeChangedCallback(name, writer(defaultValue), undefined); |
| 1800 | } |
| 1801 | } catch (err) { |
| 1802 | _didIteratorError = true; |
| 1803 | _iteratorError = err; |
| 1804 | } finally{ |
| 1805 | try { |
| 1806 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1807 | _iterator.return(); |
| 1808 | } |
| 1809 | } finally{ |
| 1810 | if (_didIteratorError) { |
| 1811 | throw _iteratorError; |
| 1812 | } |
| 1813 | } |
| 1814 | } |
| 1815 | } |
| 1816 | }, |
| 1817 | { |
| 1818 | key: "invokeChangedCallback", |
| 1819 | value: function invokeChangedCallback(name, rawValue, rawOldValue) { |
| 1820 | var changedMethodName = "".concat(name, "Changed"); |
| 1821 | var changedMethod = this.receiver[changedMethodName]; |
| 1822 | if (typeof changedMethod == "function") { |
| 1823 | var descriptor = this.valueDescriptorNameMap[name]; |
| 1824 | var value = descriptor.reader(rawValue); |
| 1825 | var oldValue = rawOldValue; |
| 1826 | if (rawOldValue) oldValue = descriptor.reader(rawOldValue); |
| 1827 | changedMethod.call(this.receiver, value, oldValue); |
| 1828 | } |
| 1829 | } |
| 1830 | }, |
| 1831 | { |
| 1832 | key: "valueDescriptors", |
| 1833 | get: function get() { |
| 1834 | var valueDescriptorMap = this.valueDescriptorMap; |
| 1835 | return Object.keys(valueDescriptorMap).map(function(key) { |
| 1836 | return valueDescriptorMap[key]; |
| 1837 | }); |
| 1838 | } |
| 1839 | }, |
| 1840 | { |
| 1841 | key: "valueDescriptorNameMap", |
| 1842 | get: function get() { |
| 1843 | var _this = this; |
| 1844 | var descriptors = {}; |
| 1845 | Object.keys(this.valueDescriptorMap).forEach(function(key) { |
| 1846 | var descriptor = _this.valueDescriptorMap[key]; |
| 1847 | descriptors[descriptor.name] = descriptor; |
| 1848 | }); |
| 1849 | return descriptors; |
| 1850 | } |
| 1851 | }, |
| 1852 | { |
| 1853 | key: "hasValue", |
| 1854 | value: function hasValue(attributeName) { |
| 1855 | var descriptor = this.valueDescriptorNameMap[attributeName]; |
| 1856 | var hasMethodName = "has".concat(capitalize(descriptor.name)); |
| 1857 | return this.receiver[hasMethodName]; |
| 1858 | } |
| 1859 | } |
| 1860 | ]); |
| 1861 | return ValueObserver; |
| 1862 | }(); |
| 1863 | var TargetObserver = /*#__PURE__*/ function() { |
| 1864 | "use strict"; |
| 1865 | function TargetObserver(context, delegate) { |
| 1866 | (0, _classCallCheckJsDefault.default)(this, TargetObserver); |
| 1867 | this.context = context; |
| 1868 | this.delegate = delegate; |
| 1869 | this.targetsByName = new Multimap; |
| 1870 | } |
| 1871 | (0, _createClassJsDefault.default)(TargetObserver, [ |
| 1872 | { |
| 1873 | key: "start", |
| 1874 | value: function start() { |
| 1875 | if (!this.tokenListObserver) { |
| 1876 | this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this); |
| 1877 | this.tokenListObserver.start(); |
| 1878 | } |
| 1879 | } |
| 1880 | }, |
| 1881 | { |
| 1882 | key: "stop", |
| 1883 | value: function stop() { |
| 1884 | if (this.tokenListObserver) { |
| 1885 | this.disconnectAllTargets(); |
| 1886 | this.tokenListObserver.stop(); |
| 1887 | delete this.tokenListObserver; |
| 1888 | } |
| 1889 | } |
| 1890 | }, |
| 1891 | { |
| 1892 | key: "tokenMatched", |
| 1893 | value: function tokenMatched(param) { |
| 1894 | var element = param.element, name = param.content; |
| 1895 | if (this.scope.containsElement(element)) this.connectTarget(element, name); |
| 1896 | } |
| 1897 | }, |
| 1898 | { |
| 1899 | key: "tokenUnmatched", |
| 1900 | value: function tokenUnmatched(param) { |
| 1901 | var element = param.element, name = param.content; |
| 1902 | this.disconnectTarget(element, name); |
| 1903 | } |
| 1904 | }, |
| 1905 | { |
| 1906 | key: "connectTarget", |
| 1907 | value: function connectTarget(element, name) { |
| 1908 | var _a; |
| 1909 | if (!this.targetsByName.has(name, element)) { |
| 1910 | var _this = this; |
| 1911 | this.targetsByName.add(name, element); |
| 1912 | (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() { |
| 1913 | return _this.delegate.targetConnected(element, name); |
| 1914 | }); |
| 1915 | } |
| 1916 | } |
| 1917 | }, |
| 1918 | { |
| 1919 | key: "disconnectTarget", |
| 1920 | value: function disconnectTarget(element, name) { |
| 1921 | var _a; |
| 1922 | if (this.targetsByName.has(name, element)) { |
| 1923 | var _this = this; |
| 1924 | this.targetsByName.delete(name, element); |
| 1925 | (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() { |
| 1926 | return _this.delegate.targetDisconnected(element, name); |
| 1927 | }); |
| 1928 | } |
| 1929 | } |
| 1930 | }, |
| 1931 | { |
| 1932 | key: "disconnectAllTargets", |
| 1933 | value: function disconnectAllTargets() { |
| 1934 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined, _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined; |
| 1935 | try { |
| 1936 | for(var _iterator = this.targetsByName.keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion2 = (_step = _iterator.next()).done); _iteratorNormalCompletion2 = true){ |
| 1937 | var name = _step.value; |
| 1938 | try { |
| 1939 | for(var _iterator2 = this.targetsByName.getValuesForKey(name)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion = true){ |
| 1940 | var element = _step2.value; |
| 1941 | this.disconnectTarget(element, name); |
| 1942 | } |
| 1943 | } catch (err) { |
| 1944 | _didIteratorError = true; |
| 1945 | _iteratorError = err; |
| 1946 | } finally{ |
| 1947 | try { |
| 1948 | if (!_iteratorNormalCompletion && _iterator2.return != null) { |
| 1949 | _iterator2.return(); |
| 1950 | } |
| 1951 | } finally{ |
| 1952 | if (_didIteratorError) { |
| 1953 | throw _iteratorError; |
| 1954 | } |
| 1955 | } |
| 1956 | } |
| 1957 | } |
| 1958 | } catch (err) { |
| 1959 | _didIteratorError2 = true; |
| 1960 | _iteratorError2 = err; |
| 1961 | } finally{ |
| 1962 | try { |
| 1963 | if (!_iteratorNormalCompletion2 && _iterator.return != null) { |
| 1964 | _iterator.return(); |
| 1965 | } |
| 1966 | } finally{ |
| 1967 | if (_didIteratorError2) { |
| 1968 | throw _iteratorError2; |
| 1969 | } |
| 1970 | } |
| 1971 | } |
| 1972 | } |
| 1973 | }, |
| 1974 | { |
| 1975 | key: "attributeName", |
| 1976 | get: function get() { |
| 1977 | return "data-".concat(this.context.identifier, "-target"); |
| 1978 | } |
| 1979 | }, |
| 1980 | { |
| 1981 | key: "element", |
| 1982 | get: function get() { |
| 1983 | return this.context.element; |
| 1984 | } |
| 1985 | }, |
| 1986 | { |
| 1987 | key: "scope", |
| 1988 | get: function get() { |
| 1989 | return this.context.scope; |
| 1990 | } |
| 1991 | } |
| 1992 | ]); |
| 1993 | return TargetObserver; |
| 1994 | }(); |
| 1995 | var Context = /*#__PURE__*/ function() { |
| 1996 | "use strict"; |
| 1997 | function Context(module, scope) { |
| 1998 | var _this = this; |
| 1999 | (0, _classCallCheckJsDefault.default)(this, Context); |
| 2000 | this.logDebugActivity = function(functionName) { |
| 2001 | var detail = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; |
| 2002 | var identifier = _this.identifier, controller = _this.controller, element = _this.element; |
| 2003 | detail = Object.assign({ |
| 2004 | identifier: identifier, |
| 2005 | controller: controller, |
| 2006 | element: element |
| 2007 | }, detail); |
| 2008 | _this.application.logDebugActivity(_this.identifier, functionName, detail); |
| 2009 | }; |
| 2010 | this.module = module; |
| 2011 | this.scope = scope; |
| 2012 | this.controller = new module.controllerConstructor(this); |
| 2013 | this.bindingObserver = new BindingObserver(this, this.dispatcher); |
| 2014 | this.valueObserver = new ValueObserver(this, this.controller); |
| 2015 | this.targetObserver = new TargetObserver(this, this); |
| 2016 | try { |
| 2017 | this.controller.initialize(); |
| 2018 | this.logDebugActivity("initialize"); |
| 2019 | } catch (error4) { |
| 2020 | this.handleError(error4, "initializing controller"); |
| 2021 | } |
| 2022 | } |
| 2023 | (0, _createClassJsDefault.default)(Context, [ |
| 2024 | { |
| 2025 | key: "connect", |
| 2026 | value: function connect() { |
| 2027 | this.bindingObserver.start(); |
| 2028 | this.valueObserver.start(); |
| 2029 | this.targetObserver.start(); |
| 2030 | try { |
| 2031 | this.controller.connect(); |
| 2032 | this.logDebugActivity("connect"); |
| 2033 | } catch (error5) { |
| 2034 | this.handleError(error5, "connecting controller"); |
| 2035 | } |
| 2036 | } |
| 2037 | }, |
| 2038 | { |
| 2039 | key: "disconnect", |
| 2040 | value: function disconnect() { |
| 2041 | try { |
| 2042 | this.controller.disconnect(); |
| 2043 | this.logDebugActivity("disconnect"); |
| 2044 | } catch (error6) { |
| 2045 | this.handleError(error6, "disconnecting controller"); |
| 2046 | } |
| 2047 | this.targetObserver.stop(); |
| 2048 | this.valueObserver.stop(); |
| 2049 | this.bindingObserver.stop(); |
| 2050 | } |
| 2051 | }, |
| 2052 | { |
| 2053 | key: "application", |
| 2054 | get: function get() { |
| 2055 | return this.module.application; |
| 2056 | } |
| 2057 | }, |
| 2058 | { |
| 2059 | key: "identifier", |
| 2060 | get: function get() { |
| 2061 | return this.module.identifier; |
| 2062 | } |
| 2063 | }, |
| 2064 | { |
| 2065 | key: "schema", |
| 2066 | get: function get() { |
| 2067 | return this.application.schema; |
| 2068 | } |
| 2069 | }, |
| 2070 | { |
| 2071 | key: "dispatcher", |
| 2072 | get: function get() { |
| 2073 | return this.application.dispatcher; |
| 2074 | } |
| 2075 | }, |
| 2076 | { |
| 2077 | key: "element", |
| 2078 | get: function get() { |
| 2079 | return this.scope.element; |
| 2080 | } |
| 2081 | }, |
| 2082 | { |
| 2083 | key: "parentElement", |
| 2084 | get: function get() { |
| 2085 | return this.element.parentElement; |
| 2086 | } |
| 2087 | }, |
| 2088 | { |
| 2089 | key: "handleError", |
| 2090 | value: function handleError(error7, message) { |
| 2091 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2092 | var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element; |
| 2093 | detail = Object.assign({ |
| 2094 | identifier: identifier, |
| 2095 | controller: controller, |
| 2096 | element: element |
| 2097 | }, detail); |
| 2098 | this.application.handleError(error7, "Error ".concat(message), detail); |
| 2099 | } |
| 2100 | }, |
| 2101 | { |
| 2102 | key: "targetConnected", |
| 2103 | value: function targetConnected(element, name) { |
| 2104 | this.invokeControllerMethod("".concat(name, "TargetConnected"), element); |
| 2105 | } |
| 2106 | }, |
| 2107 | { |
| 2108 | key: "targetDisconnected", |
| 2109 | value: function targetDisconnected(element, name) { |
| 2110 | this.invokeControllerMethod("".concat(name, "TargetDisconnected"), element); |
| 2111 | } |
| 2112 | }, |
| 2113 | { |
| 2114 | key: "invokeControllerMethod", |
| 2115 | value: function invokeControllerMethod(methodName) { |
| 2116 | for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2117 | args[_key - 1] = arguments[_key]; |
| 2118 | } |
| 2119 | var _controller; |
| 2120 | var controller = this.controller; |
| 2121 | if (typeof controller[methodName] == "function") (_controller = controller)[methodName].apply(_controller, (0, _toConsumableArrayJsDefault.default)(args)); |
| 2122 | } |
| 2123 | } |
| 2124 | ]); |
| 2125 | return Context; |
| 2126 | }(); |
| 2127 | function readInheritableStaticArrayValues(constructor1, propertyName) { |
| 2128 | var ancestors = getAncestorsForConstructor(constructor1); |
| 2129 | return Array.from(ancestors.reduce(function(values, constructor) { |
| 2130 | getOwnStaticArrayValues(constructor, propertyName).forEach(function(name) { |
| 2131 | return values.add(name); |
| 2132 | }); |
| 2133 | return values; |
| 2134 | }, new Set)); |
| 2135 | } |
| 2136 | function readInheritableStaticObjectPairs(constructor2, propertyName) { |
| 2137 | var ancestors = getAncestorsForConstructor(constructor2); |
| 2138 | return ancestors.reduce(function(pairs, constructor) { |
| 2139 | var _pairs; |
| 2140 | (_pairs = pairs).push.apply(_pairs, (0, _toConsumableArrayJsDefault.default)(getOwnStaticObjectPairs(constructor, propertyName))); |
| 2141 | return pairs; |
| 2142 | }, []); |
| 2143 | } |
| 2144 | function getAncestorsForConstructor(constructor) { |
| 2145 | var ancestors = []; |
| 2146 | while(constructor){ |
| 2147 | ancestors.push(constructor); |
| 2148 | constructor = Object.getPrototypeOf(constructor); |
| 2149 | } |
| 2150 | return ancestors.reverse(); |
| 2151 | } |
| 2152 | function getOwnStaticArrayValues(constructor, propertyName) { |
| 2153 | var definition = constructor[propertyName]; |
| 2154 | return Array.isArray(definition) ? definition : []; |
| 2155 | } |
| 2156 | function getOwnStaticObjectPairs(constructor, propertyName) { |
| 2157 | var definition = constructor[propertyName]; |
| 2158 | return definition ? Object.keys(definition).map(function(key) { |
| 2159 | return [ |
| 2160 | key, |
| 2161 | definition[key] |
| 2162 | ]; |
| 2163 | }) : []; |
| 2164 | } |
| 2165 | function bless(constructor) { |
| 2166 | return shadow(constructor, getBlessedProperties(constructor)); |
| 2167 | } |
| 2168 | function shadow(constructor, properties) { |
| 2169 | var shadowConstructor = extend(constructor); |
| 2170 | var shadowProperties = getShadowProperties(constructor.prototype, properties); |
| 2171 | Object.defineProperties(shadowConstructor.prototype, shadowProperties); |
| 2172 | return shadowConstructor; |
| 2173 | } |
| 2174 | function getBlessedProperties(constructor) { |
| 2175 | var blessings = readInheritableStaticArrayValues(constructor, "blessings"); |
| 2176 | return blessings.reduce(function(blessedProperties, blessing) { |
| 2177 | var properties = blessing(constructor); |
| 2178 | for(var key in properties){ |
| 2179 | var descriptor = blessedProperties[key] || {}; |
| 2180 | blessedProperties[key] = Object.assign(descriptor, properties[key]); |
| 2181 | } |
| 2182 | return blessedProperties; |
| 2183 | }, {}); |
| 2184 | } |
| 2185 | function getShadowProperties(prototype, properties) { |
| 2186 | return getOwnKeys(properties).reduce(function(shadowProperties, key) { |
| 2187 | var descriptor = getShadowedDescriptor(prototype, properties, key); |
| 2188 | if (descriptor) Object.assign(shadowProperties, (0, _definePropertyJsDefault.default)({}, key, descriptor)); |
| 2189 | return shadowProperties; |
| 2190 | }, {}); |
| 2191 | } |
| 2192 | function getShadowedDescriptor(prototype, properties, key) { |
| 2193 | var shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key); |
| 2194 | var shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor; |
| 2195 | if (!shadowedByValue) { |
| 2196 | var descriptor = Object.getOwnPropertyDescriptor(properties, key).value; |
| 2197 | if (shadowingDescriptor) { |
| 2198 | descriptor.get = shadowingDescriptor.get || descriptor.get; |
| 2199 | descriptor.set = shadowingDescriptor.set || descriptor.set; |
| 2200 | } |
| 2201 | return descriptor; |
| 2202 | } |
| 2203 | } |
| 2204 | var getOwnKeys = function() { |
| 2205 | if (typeof Object.getOwnPropertySymbols == "function") return function(object) { |
| 2206 | return (0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertyNames(object)).concat((0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertySymbols(object))); |
| 2207 | }; |
| 2208 | else return Object.getOwnPropertyNames; |
| 2209 | }(); |
| 2210 | var extend = function _target() { |
| 2211 | var extendWithReflect = function extendWithReflect(constructor) { |
| 2212 | function extended() { |
| 2213 | return Reflect.construct(constructor, arguments, this instanceof extended ? this.constructor : void 0); |
| 2214 | } |
| 2215 | extended.prototype = Object.create(constructor.prototype, { |
| 2216 | constructor: { |
| 2217 | value: extended |
| 2218 | } |
| 2219 | }); |
| 2220 | Reflect.setPrototypeOf(extended, constructor); |
| 2221 | return extended; |
| 2222 | }; |
| 2223 | var testReflectExtension = function testReflectExtension() { |
| 2224 | var a = function a() { |
| 2225 | this.a.call(this); |
| 2226 | }; |
| 2227 | var b = extendWithReflect(a); |
| 2228 | b.prototype.a = function() {}; |
| 2229 | return new b; |
| 2230 | }; |
| 2231 | try { |
| 2232 | testReflectExtension(); |
| 2233 | return extendWithReflect; |
| 2234 | } catch (error) { |
| 2235 | return function(constructor3) { |
| 2236 | return /*#__PURE__*/ function(constructor) { |
| 2237 | "use strict"; |
| 2238 | (0, _inheritsJsDefault.default)(extended, constructor); |
| 2239 | var _super = (0, _createSuperJsDefault.default)(extended); |
| 2240 | function extended() { |
| 2241 | (0, _classCallCheckJsDefault.default)(this, extended); |
| 2242 | return _super.apply(this, arguments); |
| 2243 | } |
| 2244 | return extended; |
| 2245 | }(constructor3); |
| 2246 | }; |
| 2247 | } |
| 2248 | }(); |
| 2249 | function blessDefinition(definition) { |
| 2250 | return { |
| 2251 | identifier: definition.identifier, |
| 2252 | controllerConstructor: bless(definition.controllerConstructor) |
| 2253 | }; |
| 2254 | } |
| 2255 | var Module = /*#__PURE__*/ function() { |
| 2256 | "use strict"; |
| 2257 | function Module(application, definition) { |
| 2258 | (0, _classCallCheckJsDefault.default)(this, Module); |
| 2259 | this.application = application; |
| 2260 | this.definition = blessDefinition(definition); |
| 2261 | this.contextsByScope = new WeakMap; |
| 2262 | this.connectedContexts = new Set; |
| 2263 | } |
| 2264 | (0, _createClassJsDefault.default)(Module, [ |
| 2265 | { |
| 2266 | key: "identifier", |
| 2267 | get: function get() { |
| 2268 | return this.definition.identifier; |
| 2269 | } |
| 2270 | }, |
| 2271 | { |
| 2272 | key: "controllerConstructor", |
| 2273 | get: function get() { |
| 2274 | return this.definition.controllerConstructor; |
| 2275 | } |
| 2276 | }, |
| 2277 | { |
| 2278 | key: "contexts", |
| 2279 | get: function get() { |
| 2280 | return Array.from(this.connectedContexts); |
| 2281 | } |
| 2282 | }, |
| 2283 | { |
| 2284 | key: "connectContextForScope", |
| 2285 | value: function connectContextForScope(scope) { |
| 2286 | var context = this.fetchContextForScope(scope); |
| 2287 | this.connectedContexts.add(context); |
| 2288 | context.connect(); |
| 2289 | } |
| 2290 | }, |
| 2291 | { |
| 2292 | key: "disconnectContextForScope", |
| 2293 | value: function disconnectContextForScope(scope) { |
| 2294 | var context = this.contextsByScope.get(scope); |
| 2295 | if (context) { |
| 2296 | this.connectedContexts.delete(context); |
| 2297 | context.disconnect(); |
| 2298 | } |
| 2299 | } |
| 2300 | }, |
| 2301 | { |
| 2302 | key: "fetchContextForScope", |
| 2303 | value: function fetchContextForScope(scope) { |
| 2304 | var context = this.contextsByScope.get(scope); |
| 2305 | if (!context) { |
| 2306 | context = new Context(this, scope); |
| 2307 | this.contextsByScope.set(scope, context); |
| 2308 | } |
| 2309 | return context; |
| 2310 | } |
| 2311 | } |
| 2312 | ]); |
| 2313 | return Module; |
| 2314 | }(); |
| 2315 | var ClassMap = /*#__PURE__*/ function() { |
| 2316 | "use strict"; |
| 2317 | function ClassMap(scope) { |
| 2318 | (0, _classCallCheckJsDefault.default)(this, ClassMap); |
| 2319 | this.scope = scope; |
| 2320 | } |
| 2321 | (0, _createClassJsDefault.default)(ClassMap, [ |
| 2322 | { |
| 2323 | key: "has", |
| 2324 | value: function has(name) { |
| 2325 | return this.data.has(this.getDataKey(name)); |
| 2326 | } |
| 2327 | }, |
| 2328 | { |
| 2329 | key: "get", |
| 2330 | value: function get(name) { |
| 2331 | return this.getAll(name)[0]; |
| 2332 | } |
| 2333 | }, |
| 2334 | { |
| 2335 | key: "getAll", |
| 2336 | value: function getAll(name) { |
| 2337 | var tokenString = this.data.get(this.getDataKey(name)) || ""; |
| 2338 | return tokenize(tokenString); |
| 2339 | } |
| 2340 | }, |
| 2341 | { |
| 2342 | key: "getAttributeName", |
| 2343 | value: function getAttributeName(name) { |
| 2344 | return this.data.getAttributeNameForKey(this.getDataKey(name)); |
| 2345 | } |
| 2346 | }, |
| 2347 | { |
| 2348 | key: "getDataKey", |
| 2349 | value: function getDataKey(name) { |
| 2350 | return "".concat(name, "-class"); |
| 2351 | } |
| 2352 | }, |
| 2353 | { |
| 2354 | key: "data", |
| 2355 | get: function get() { |
| 2356 | return this.scope.data; |
| 2357 | } |
| 2358 | } |
| 2359 | ]); |
| 2360 | return ClassMap; |
| 2361 | }(); |
| 2362 | var DataMap = /*#__PURE__*/ function() { |
| 2363 | "use strict"; |
| 2364 | function DataMap(scope) { |
| 2365 | (0, _classCallCheckJsDefault.default)(this, DataMap); |
| 2366 | this.scope = scope; |
| 2367 | } |
| 2368 | (0, _createClassJsDefault.default)(DataMap, [ |
| 2369 | { |
| 2370 | key: "element", |
| 2371 | get: function get() { |
| 2372 | return this.scope.element; |
| 2373 | } |
| 2374 | }, |
| 2375 | { |
| 2376 | key: "identifier", |
| 2377 | get: function get() { |
| 2378 | return this.scope.identifier; |
| 2379 | } |
| 2380 | }, |
| 2381 | { |
| 2382 | key: "get", |
| 2383 | value: function get(key) { |
| 2384 | var name = this.getAttributeNameForKey(key); |
| 2385 | return this.element.getAttribute(name); |
| 2386 | } |
| 2387 | }, |
| 2388 | { |
| 2389 | key: "set", |
| 2390 | value: function set(key, value) { |
| 2391 | var name = this.getAttributeNameForKey(key); |
| 2392 | this.element.setAttribute(name, value); |
| 2393 | return this.get(key); |
| 2394 | } |
| 2395 | }, |
| 2396 | { |
| 2397 | key: "has", |
| 2398 | value: function has(key) { |
| 2399 | var name = this.getAttributeNameForKey(key); |
| 2400 | return this.element.hasAttribute(name); |
| 2401 | } |
| 2402 | }, |
| 2403 | { |
| 2404 | key: "delete", |
| 2405 | value: function _delete(key) { |
| 2406 | if (this.has(key)) { |
| 2407 | var name = this.getAttributeNameForKey(key); |
| 2408 | this.element.removeAttribute(name); |
| 2409 | return true; |
| 2410 | } else return false; |
| 2411 | } |
| 2412 | }, |
| 2413 | { |
| 2414 | key: "getAttributeNameForKey", |
| 2415 | value: function getAttributeNameForKey(key) { |
| 2416 | return "data-".concat(this.identifier, "-").concat(dasherize(key)); |
| 2417 | } |
| 2418 | } |
| 2419 | ]); |
| 2420 | return DataMap; |
| 2421 | }(); |
| 2422 | var Guide = /*#__PURE__*/ function() { |
| 2423 | "use strict"; |
| 2424 | function Guide(logger) { |
| 2425 | (0, _classCallCheckJsDefault.default)(this, Guide); |
| 2426 | this.warnedKeysByObject = new WeakMap; |
| 2427 | this.logger = logger; |
| 2428 | } |
| 2429 | (0, _createClassJsDefault.default)(Guide, [ |
| 2430 | { |
| 2431 | key: "warn", |
| 2432 | value: function warn(object, key, message) { |
| 2433 | var warnedKeys = this.warnedKeysByObject.get(object); |
| 2434 | if (!warnedKeys) { |
| 2435 | warnedKeys = new Set; |
| 2436 | this.warnedKeysByObject.set(object, warnedKeys); |
| 2437 | } |
| 2438 | if (!warnedKeys.has(key)) { |
| 2439 | warnedKeys.add(key); |
| 2440 | this.logger.warn(message, object); |
| 2441 | } |
| 2442 | } |
| 2443 | } |
| 2444 | ]); |
| 2445 | return Guide; |
| 2446 | }(); |
| 2447 | function attributeValueContainsToken(attributeName, token) { |
| 2448 | return "[".concat(attributeName, '~="').concat(token, '"]'); |
| 2449 | } |
| 2450 | var TargetSet = /*#__PURE__*/ function() { |
| 2451 | "use strict"; |
| 2452 | function TargetSet(scope) { |
| 2453 | (0, _classCallCheckJsDefault.default)(this, TargetSet); |
| 2454 | this.scope = scope; |
| 2455 | } |
| 2456 | (0, _createClassJsDefault.default)(TargetSet, [ |
| 2457 | { |
| 2458 | key: "element", |
| 2459 | get: function get() { |
| 2460 | return this.scope.element; |
| 2461 | } |
| 2462 | }, |
| 2463 | { |
| 2464 | key: "identifier", |
| 2465 | get: function get() { |
| 2466 | return this.scope.identifier; |
| 2467 | } |
| 2468 | }, |
| 2469 | { |
| 2470 | key: "schema", |
| 2471 | get: function get() { |
| 2472 | return this.scope.schema; |
| 2473 | } |
| 2474 | }, |
| 2475 | { |
| 2476 | key: "has", |
| 2477 | value: function has(targetName) { |
| 2478 | return this.find(targetName) != null; |
| 2479 | } |
| 2480 | }, |
| 2481 | { |
| 2482 | key: "find", |
| 2483 | value: function find() { |
| 2484 | for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){ |
| 2485 | targetNames[_key] = arguments[_key]; |
| 2486 | } |
| 2487 | var _this = this; |
| 2488 | return targetNames.reduce(function(target, targetName) { |
| 2489 | return target || _this.findTarget(targetName) || _this.findLegacyTarget(targetName); |
| 2490 | }, undefined); |
| 2491 | } |
| 2492 | }, |
| 2493 | { |
| 2494 | key: "findAll", |
| 2495 | value: function findAll() { |
| 2496 | for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){ |
| 2497 | targetNames[_key] = arguments[_key]; |
| 2498 | } |
| 2499 | var _this = this; |
| 2500 | return targetNames.reduce(function(targets, targetName) { |
| 2501 | return (0, _toConsumableArrayJsDefault.default)(targets).concat((0, _toConsumableArrayJsDefault.default)(_this.findAllTargets(targetName)), (0, _toConsumableArrayJsDefault.default)(_this.findAllLegacyTargets(targetName))); |
| 2502 | }, []); |
| 2503 | } |
| 2504 | }, |
| 2505 | { |
| 2506 | key: "findTarget", |
| 2507 | value: function findTarget(targetName) { |
| 2508 | var selector = this.getSelectorForTargetName(targetName); |
| 2509 | return this.scope.findElement(selector); |
| 2510 | } |
| 2511 | }, |
| 2512 | { |
| 2513 | key: "findAllTargets", |
| 2514 | value: function findAllTargets(targetName) { |
| 2515 | var selector = this.getSelectorForTargetName(targetName); |
| 2516 | return this.scope.findAllElements(selector); |
| 2517 | } |
| 2518 | }, |
| 2519 | { |
| 2520 | key: "getSelectorForTargetName", |
| 2521 | value: function getSelectorForTargetName(targetName) { |
| 2522 | var attributeName = this.schema.targetAttributeForScope(this.identifier); |
| 2523 | return attributeValueContainsToken(attributeName, targetName); |
| 2524 | } |
| 2525 | }, |
| 2526 | { |
| 2527 | key: "findLegacyTarget", |
| 2528 | value: function findLegacyTarget(targetName) { |
| 2529 | var selector = this.getLegacySelectorForTargetName(targetName); |
| 2530 | return this.deprecate(this.scope.findElement(selector), targetName); |
| 2531 | } |
| 2532 | }, |
| 2533 | { |
| 2534 | key: "findAllLegacyTargets", |
| 2535 | value: function findAllLegacyTargets(targetName) { |
| 2536 | var _this = this; |
| 2537 | var selector = this.getLegacySelectorForTargetName(targetName); |
| 2538 | return this.scope.findAllElements(selector).map(function(element) { |
| 2539 | return _this.deprecate(element, targetName); |
| 2540 | }); |
| 2541 | } |
| 2542 | }, |
| 2543 | { |
| 2544 | key: "getLegacySelectorForTargetName", |
| 2545 | value: function getLegacySelectorForTargetName(targetName) { |
| 2546 | var targetDescriptor = "".concat(this.identifier, ".").concat(targetName); |
| 2547 | return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor); |
| 2548 | } |
| 2549 | }, |
| 2550 | { |
| 2551 | key: "deprecate", |
| 2552 | value: function deprecate(element, targetName) { |
| 2553 | if (element) { |
| 2554 | var identifier = this.identifier; |
| 2555 | var attributeName = this.schema.targetAttribute; |
| 2556 | var revisedAttributeName = this.schema.targetAttributeForScope(identifier); |
| 2557 | this.guide.warn(element, "target:".concat(targetName), "Please replace ".concat(attributeName, '="').concat(identifier, ".").concat(targetName, '" with ').concat(revisedAttributeName, '="').concat(targetName, '". ') + "The ".concat(attributeName, " attribute is deprecated and will be removed in a future version of Stimulus.")); |
| 2558 | } |
| 2559 | return element; |
| 2560 | } |
| 2561 | }, |
| 2562 | { |
| 2563 | key: "guide", |
| 2564 | get: function get() { |
| 2565 | return this.scope.guide; |
| 2566 | } |
| 2567 | } |
| 2568 | ]); |
| 2569 | return TargetSet; |
| 2570 | }(); |
| 2571 | var Scope = /*#__PURE__*/ function() { |
| 2572 | "use strict"; |
| 2573 | function Scope(schema, element2, identifier, logger) { |
| 2574 | var _this = this; |
| 2575 | (0, _classCallCheckJsDefault.default)(this, Scope); |
| 2576 | this.targets = new TargetSet(this); |
| 2577 | this.classes = new ClassMap(this); |
| 2578 | this.data = new DataMap(this); |
| 2579 | this.containsElement = function(element) { |
| 2580 | return element.closest(_this.controllerSelector) === _this.element; |
| 2581 | }; |
| 2582 | this.schema = schema; |
| 2583 | this.element = element2; |
| 2584 | this.identifier = identifier; |
| 2585 | this.guide = new Guide(logger); |
| 2586 | } |
| 2587 | (0, _createClassJsDefault.default)(Scope, [ |
| 2588 | { |
| 2589 | key: "findElement", |
| 2590 | value: function findElement(selector) { |
| 2591 | return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement); |
| 2592 | } |
| 2593 | }, |
| 2594 | { |
| 2595 | key: "findAllElements", |
| 2596 | value: function findAllElements(selector) { |
| 2597 | return (0, _toConsumableArrayJsDefault.default)(this.element.matches(selector) ? [ |
| 2598 | this.element |
| 2599 | ] : []).concat((0, _toConsumableArrayJsDefault.default)(this.queryElements(selector).filter(this.containsElement))); |
| 2600 | } |
| 2601 | }, |
| 2602 | { |
| 2603 | key: "queryElements", |
| 2604 | value: function queryElements(selector) { |
| 2605 | return Array.from(this.element.querySelectorAll(selector)); |
| 2606 | } |
| 2607 | }, |
| 2608 | { |
| 2609 | key: "controllerSelector", |
| 2610 | get: function get() { |
| 2611 | return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier); |
| 2612 | } |
| 2613 | } |
| 2614 | ]); |
| 2615 | return Scope; |
| 2616 | }(); |
| 2617 | var ScopeObserver = /*#__PURE__*/ function() { |
| 2618 | "use strict"; |
| 2619 | function ScopeObserver(element, schema, delegate) { |
| 2620 | (0, _classCallCheckJsDefault.default)(this, ScopeObserver); |
| 2621 | this.element = element; |
| 2622 | this.schema = schema; |
| 2623 | this.delegate = delegate; |
| 2624 | this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this); |
| 2625 | this.scopesByIdentifierByElement = new WeakMap; |
| 2626 | this.scopeReferenceCounts = new WeakMap; |
| 2627 | } |
| 2628 | (0, _createClassJsDefault.default)(ScopeObserver, [ |
| 2629 | { |
| 2630 | key: "start", |
| 2631 | value: function start() { |
| 2632 | this.valueListObserver.start(); |
| 2633 | } |
| 2634 | }, |
| 2635 | { |
| 2636 | key: "stop", |
| 2637 | value: function stop() { |
| 2638 | this.valueListObserver.stop(); |
| 2639 | } |
| 2640 | }, |
| 2641 | { |
| 2642 | key: "controllerAttribute", |
| 2643 | get: function get() { |
| 2644 | return this.schema.controllerAttribute; |
| 2645 | } |
| 2646 | }, |
| 2647 | { |
| 2648 | key: "parseValueForToken", |
| 2649 | value: function parseValueForToken(token) { |
| 2650 | var element = token.element, identifier = token.content; |
| 2651 | var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element); |
| 2652 | var scope = scopesByIdentifier.get(identifier); |
| 2653 | if (!scope) { |
| 2654 | scope = this.delegate.createScopeForElementAndIdentifier(element, identifier); |
| 2655 | scopesByIdentifier.set(identifier, scope); |
| 2656 | } |
| 2657 | return scope; |
| 2658 | } |
| 2659 | }, |
| 2660 | { |
| 2661 | key: "elementMatchedValue", |
| 2662 | value: function elementMatchedValue(element, value) { |
| 2663 | var referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1; |
| 2664 | this.scopeReferenceCounts.set(value, referenceCount); |
| 2665 | if (referenceCount == 1) this.delegate.scopeConnected(value); |
| 2666 | } |
| 2667 | }, |
| 2668 | { |
| 2669 | key: "elementUnmatchedValue", |
| 2670 | value: function elementUnmatchedValue(element, value) { |
| 2671 | var referenceCount = this.scopeReferenceCounts.get(value); |
| 2672 | if (referenceCount) { |
| 2673 | this.scopeReferenceCounts.set(value, referenceCount - 1); |
| 2674 | if (referenceCount == 1) this.delegate.scopeDisconnected(value); |
| 2675 | } |
| 2676 | } |
| 2677 | }, |
| 2678 | { |
| 2679 | key: "fetchScopesByIdentifierForElement", |
| 2680 | value: function fetchScopesByIdentifierForElement(element) { |
| 2681 | var scopesByIdentifier = this.scopesByIdentifierByElement.get(element); |
| 2682 | if (!scopesByIdentifier) { |
| 2683 | scopesByIdentifier = new Map; |
| 2684 | this.scopesByIdentifierByElement.set(element, scopesByIdentifier); |
| 2685 | } |
| 2686 | return scopesByIdentifier; |
| 2687 | } |
| 2688 | } |
| 2689 | ]); |
| 2690 | return ScopeObserver; |
| 2691 | }(); |
| 2692 | var Router = /*#__PURE__*/ function() { |
| 2693 | "use strict"; |
| 2694 | function Router(application) { |
| 2695 | (0, _classCallCheckJsDefault.default)(this, Router); |
| 2696 | this.application = application; |
| 2697 | this.scopeObserver = new ScopeObserver(this.element, this.schema, this); |
| 2698 | this.scopesByIdentifier = new Multimap; |
| 2699 | this.modulesByIdentifier = new Map; |
| 2700 | } |
| 2701 | (0, _createClassJsDefault.default)(Router, [ |
| 2702 | { |
| 2703 | key: "element", |
| 2704 | get: function get() { |
| 2705 | return this.application.element; |
| 2706 | } |
| 2707 | }, |
| 2708 | { |
| 2709 | key: "schema", |
| 2710 | get: function get() { |
| 2711 | return this.application.schema; |
| 2712 | } |
| 2713 | }, |
| 2714 | { |
| 2715 | key: "logger", |
| 2716 | get: function get() { |
| 2717 | return this.application.logger; |
| 2718 | } |
| 2719 | }, |
| 2720 | { |
| 2721 | key: "controllerAttribute", |
| 2722 | get: function get() { |
| 2723 | return this.schema.controllerAttribute; |
| 2724 | } |
| 2725 | }, |
| 2726 | { |
| 2727 | key: "modules", |
| 2728 | get: function get() { |
| 2729 | return Array.from(this.modulesByIdentifier.values()); |
| 2730 | } |
| 2731 | }, |
| 2732 | { |
| 2733 | key: "contexts", |
| 2734 | get: function get() { |
| 2735 | return this.modules.reduce(function(contexts, module) { |
| 2736 | return contexts.concat(module.contexts); |
| 2737 | }, []); |
| 2738 | } |
| 2739 | }, |
| 2740 | { |
| 2741 | key: "start", |
| 2742 | value: function start() { |
| 2743 | this.scopeObserver.start(); |
| 2744 | } |
| 2745 | }, |
| 2746 | { |
| 2747 | key: "stop", |
| 2748 | value: function stop() { |
| 2749 | this.scopeObserver.stop(); |
| 2750 | } |
| 2751 | }, |
| 2752 | { |
| 2753 | key: "loadDefinition", |
| 2754 | value: function loadDefinition(definition) { |
| 2755 | this.unloadIdentifier(definition.identifier); |
| 2756 | var module = new Module(this.application, definition); |
| 2757 | this.connectModule(module); |
| 2758 | } |
| 2759 | }, |
| 2760 | { |
| 2761 | key: "unloadIdentifier", |
| 2762 | value: function unloadIdentifier(identifier) { |
| 2763 | var module = this.modulesByIdentifier.get(identifier); |
| 2764 | if (module) this.disconnectModule(module); |
| 2765 | } |
| 2766 | }, |
| 2767 | { |
| 2768 | key: "getContextForElementAndIdentifier", |
| 2769 | value: function getContextForElementAndIdentifier(element, identifier) { |
| 2770 | var module = this.modulesByIdentifier.get(identifier); |
| 2771 | if (module) return module.contexts.find(function(context) { |
| 2772 | return context.element == element; |
| 2773 | }); |
| 2774 | } |
| 2775 | }, |
| 2776 | { |
| 2777 | key: "handleError", |
| 2778 | value: function handleError(error8, message, detail) { |
| 2779 | this.application.handleError(error8, message, detail); |
| 2780 | } |
| 2781 | }, |
| 2782 | { |
| 2783 | key: "createScopeForElementAndIdentifier", |
| 2784 | value: function createScopeForElementAndIdentifier(element, identifier) { |
| 2785 | return new Scope(this.schema, element, identifier, this.logger); |
| 2786 | } |
| 2787 | }, |
| 2788 | { |
| 2789 | key: "scopeConnected", |
| 2790 | value: function scopeConnected(scope) { |
| 2791 | this.scopesByIdentifier.add(scope.identifier, scope); |
| 2792 | var module = this.modulesByIdentifier.get(scope.identifier); |
| 2793 | if (module) module.connectContextForScope(scope); |
| 2794 | } |
| 2795 | }, |
| 2796 | { |
| 2797 | key: "scopeDisconnected", |
| 2798 | value: function scopeDisconnected(scope) { |
| 2799 | this.scopesByIdentifier.delete(scope.identifier, scope); |
| 2800 | var module = this.modulesByIdentifier.get(scope.identifier); |
| 2801 | if (module) module.disconnectContextForScope(scope); |
| 2802 | } |
| 2803 | }, |
| 2804 | { |
| 2805 | key: "connectModule", |
| 2806 | value: function connectModule(module) { |
| 2807 | this.modulesByIdentifier.set(module.identifier, module); |
| 2808 | var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); |
| 2809 | scopes.forEach(function(scope) { |
| 2810 | return module.connectContextForScope(scope); |
| 2811 | }); |
| 2812 | } |
| 2813 | }, |
| 2814 | { |
| 2815 | key: "disconnectModule", |
| 2816 | value: function disconnectModule(module) { |
| 2817 | this.modulesByIdentifier.delete(module.identifier); |
| 2818 | var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); |
| 2819 | scopes.forEach(function(scope) { |
| 2820 | return module.disconnectContextForScope(scope); |
| 2821 | }); |
| 2822 | } |
| 2823 | } |
| 2824 | ]); |
| 2825 | return Router; |
| 2826 | }(); |
| 2827 | var defaultSchema = { |
| 2828 | controllerAttribute: "data-controller", |
| 2829 | actionAttribute: "data-action", |
| 2830 | targetAttribute: "data-target", |
| 2831 | targetAttributeForScope: function(identifier) { |
| 2832 | return "data-".concat(identifier, "-target"); |
| 2833 | } |
| 2834 | }; |
| 2835 | var Application = /*#__PURE__*/ function() { |
| 2836 | "use strict"; |
| 2837 | function Application() { |
| 2838 | var element = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : document.documentElement, schema = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultSchema; |
| 2839 | var _this = this; |
| 2840 | (0, _classCallCheckJsDefault.default)(this, Application); |
| 2841 | this.logger = console; |
| 2842 | this.debug = false; |
| 2843 | this.logDebugActivity = function(identifier, functionName) { |
| 2844 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2845 | if (_this.debug) _this.logFormattedMessage(identifier, functionName, detail); |
| 2846 | }; |
| 2847 | this.element = element; |
| 2848 | this.schema = schema; |
| 2849 | this.dispatcher = new Dispatcher(this); |
| 2850 | this.router = new Router(this); |
| 2851 | } |
| 2852 | (0, _createClassJsDefault.default)(Application, [ |
| 2853 | { |
| 2854 | key: "start", |
| 2855 | value: function start() { |
| 2856 | var _this = this; |
| 2857 | return (0, _asyncToGeneratorJsDefault.default)((0, _regeneratorRuntimeDefault.default).mark(function _callee() { |
| 2858 | return (0, _regeneratorRuntimeDefault.default).wrap(function _callee$(_ctx) { |
| 2859 | while(1)switch(_ctx.prev = _ctx.next){ |
| 2860 | case 0: |
| 2861 | _ctx.next = 2; |
| 2862 | return domReady(); |
| 2863 | case 2: |
| 2864 | _this.logDebugActivity("application", "starting"); |
| 2865 | _this.dispatcher.start(); |
| 2866 | _this.router.start(); |
| 2867 | _this.logDebugActivity("application", "start"); |
| 2868 | case 6: |
| 2869 | case "end": |
| 2870 | return _ctx.stop(); |
| 2871 | } |
| 2872 | }, _callee); |
| 2873 | }))(); |
| 2874 | } |
| 2875 | }, |
| 2876 | { |
| 2877 | key: "stop", |
| 2878 | value: function stop() { |
| 2879 | this.logDebugActivity("application", "stopping"); |
| 2880 | this.dispatcher.stop(); |
| 2881 | this.router.stop(); |
| 2882 | this.logDebugActivity("application", "stop"); |
| 2883 | } |
| 2884 | }, |
| 2885 | { |
| 2886 | key: "register", |
| 2887 | value: function register(identifier, controllerConstructor) { |
| 2888 | if (controllerConstructor.shouldLoad) this.load({ |
| 2889 | identifier: identifier, |
| 2890 | controllerConstructor: controllerConstructor |
| 2891 | }); |
| 2892 | } |
| 2893 | }, |
| 2894 | { |
| 2895 | key: "load", |
| 2896 | value: function load(head) { |
| 2897 | for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2898 | rest[_key - 1] = arguments[_key]; |
| 2899 | } |
| 2900 | var _this = this; |
| 2901 | var definitions = Array.isArray(head) ? head : [ |
| 2902 | head |
| 2903 | ].concat((0, _toConsumableArrayJsDefault.default)(rest)); |
| 2904 | definitions.forEach(function(definition) { |
| 2905 | return _this.router.loadDefinition(definition); |
| 2906 | }); |
| 2907 | } |
| 2908 | }, |
| 2909 | { |
| 2910 | key: "unload", |
| 2911 | value: function unload(head) { |
| 2912 | for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2913 | rest[_key - 1] = arguments[_key]; |
| 2914 | } |
| 2915 | var _this = this; |
| 2916 | var identifiers = Array.isArray(head) ? head : [ |
| 2917 | head |
| 2918 | ].concat((0, _toConsumableArrayJsDefault.default)(rest)); |
| 2919 | identifiers.forEach(function(identifier) { |
| 2920 | return _this.router.unloadIdentifier(identifier); |
| 2921 | }); |
| 2922 | } |
| 2923 | }, |
| 2924 | { |
| 2925 | key: "controllers", |
| 2926 | get: function get() { |
| 2927 | return this.router.contexts.map(function(context) { |
| 2928 | return context.controller; |
| 2929 | }); |
| 2930 | } |
| 2931 | }, |
| 2932 | { |
| 2933 | key: "getControllerForElementAndIdentifier", |
| 2934 | value: function getControllerForElementAndIdentifier(element, identifier) { |
| 2935 | var context = this.router.getContextForElementAndIdentifier(element, identifier); |
| 2936 | return context ? context.controller : null; |
| 2937 | } |
| 2938 | }, |
| 2939 | { |
| 2940 | key: "handleError", |
| 2941 | value: function handleError(error9, message, detail) { |
| 2942 | var _a; |
| 2943 | this.logger.error("%s\n\n%o\n\n%o", message, error9, detail); |
| 2944 | (_a = window.onerror) === null || _a === void 0 || _a.call(window, message, "", 0, 0, error9); |
| 2945 | } |
| 2946 | }, |
| 2947 | { |
| 2948 | key: "logFormattedMessage", |
| 2949 | value: function logFormattedMessage(identifier, functionName) { |
| 2950 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2951 | detail = Object.assign({ |
| 2952 | application: this |
| 2953 | }, detail); |
| 2954 | this.logger.groupCollapsed("".concat(identifier, " #").concat(functionName)); |
| 2955 | this.logger.log("details:", Object.assign({}, detail)); |
| 2956 | this.logger.groupEnd(); |
| 2957 | } |
| 2958 | } |
| 2959 | ], [ |
| 2960 | { |
| 2961 | key: "start", |
| 2962 | value: function start(element, schema) { |
| 2963 | var application = new Application(element, schema); |
| 2964 | application.start(); |
| 2965 | return application; |
| 2966 | } |
| 2967 | } |
| 2968 | ]); |
| 2969 | return Application; |
| 2970 | }(); |
| 2971 | function domReady() { |
| 2972 | return new Promise(function(resolve) { |
| 2973 | if (document.readyState == "loading") document.addEventListener("DOMContentLoaded", function() { |
| 2974 | return resolve(); |
| 2975 | }); |
| 2976 | else resolve(); |
| 2977 | }); |
| 2978 | } |
| 2979 | function ClassPropertiesBlessing(constructor) { |
| 2980 | var classes = readInheritableStaticArrayValues(constructor, "classes"); |
| 2981 | return classes.reduce(function(properties, classDefinition) { |
| 2982 | return Object.assign(properties, propertiesForClassDefinition(classDefinition)); |
| 2983 | }, {}); |
| 2984 | } |
| 2985 | function propertiesForClassDefinition(key) { |
| 2986 | var _obj; |
| 2987 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Class"), { |
| 2988 | get: function() { |
| 2989 | var classes = this.classes; |
| 2990 | if (classes.has(key)) return classes.get(key); |
| 2991 | else { |
| 2992 | var attribute = classes.getAttributeName(key); |
| 2993 | throw new Error('Missing attribute "'.concat(attribute, '"')); |
| 2994 | } |
| 2995 | } |
| 2996 | }), (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Classes"), { |
| 2997 | get: function() { |
| 2998 | return this.classes.getAll(key); |
| 2999 | } |
| 3000 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(key), "Class"), { |
| 3001 | get: function() { |
| 3002 | return this.classes.has(key); |
| 3003 | } |
| 3004 | }), _obj; |
| 3005 | } |
| 3006 | function TargetPropertiesBlessing(constructor) { |
| 3007 | var targets = readInheritableStaticArrayValues(constructor, "targets"); |
| 3008 | return targets.reduce(function(properties, targetDefinition) { |
| 3009 | return Object.assign(properties, propertiesForTargetDefinition(targetDefinition)); |
| 3010 | }, {}); |
| 3011 | } |
| 3012 | function propertiesForTargetDefinition(name) { |
| 3013 | var _obj; |
| 3014 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Target"), { |
| 3015 | get: function() { |
| 3016 | var target = this.targets.find(name); |
| 3017 | if (target) return target; |
| 3018 | else throw new Error('Missing target element "'.concat(name, '" for "').concat(this.identifier, '" controller')); |
| 3019 | } |
| 3020 | }), (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Targets"), { |
| 3021 | get: function() { |
| 3022 | return this.targets.findAll(name); |
| 3023 | } |
| 3024 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name), "Target"), { |
| 3025 | get: function() { |
| 3026 | return this.targets.has(name); |
| 3027 | } |
| 3028 | }), _obj; |
| 3029 | } |
| 3030 | function ValuePropertiesBlessing(constructor) { |
| 3031 | var valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values"); |
| 3032 | var propertyDescriptorMap = { |
| 3033 | valueDescriptorMap: { |
| 3034 | get: function() { |
| 3035 | var _this = this; |
| 3036 | return valueDefinitionPairs.reduce(function(result, valueDefinitionPair) { |
| 3037 | var valueDescriptor = parseValueDefinitionPair(valueDefinitionPair); |
| 3038 | var attributeName = _this.data.getAttributeNameForKey(valueDescriptor.key); |
| 3039 | return Object.assign(result, (0, _definePropertyJsDefault.default)({}, attributeName, valueDescriptor)); |
| 3040 | }, {}); |
| 3041 | } |
| 3042 | } |
| 3043 | }; |
| 3044 | return valueDefinitionPairs.reduce(function(properties, valueDefinitionPair) { |
| 3045 | return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair)); |
| 3046 | }, propertyDescriptorMap); |
| 3047 | } |
| 3048 | function propertiesForValueDefinitionPair(valueDefinitionPair) { |
| 3049 | var definition = parseValueDefinitionPair(valueDefinitionPair); |
| 3050 | var key = definition.key, name = definition.name, read = definition.reader, write = definition.writer; |
| 3051 | var _obj; |
| 3052 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, name, { |
| 3053 | get: function() { |
| 3054 | var value = this.data.get(key); |
| 3055 | if (value !== null) return read(value); |
| 3056 | else return definition.defaultValue; |
| 3057 | }, |
| 3058 | set: function(value) { |
| 3059 | if (value === undefined) this.data.delete(key); |
| 3060 | else this.data.set(key, write(value)); |
| 3061 | } |
| 3062 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name)), { |
| 3063 | get: function() { |
| 3064 | return this.data.has(key) || definition.hasCustomDefaultValue; |
| 3065 | } |
| 3066 | }), _obj; |
| 3067 | } |
| 3068 | function parseValueDefinitionPair(param) { |
| 3069 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), token = _param[0], typeDefinition = _param[1]; |
| 3070 | return valueDescriptorForTokenAndTypeDefinition(token, typeDefinition); |
| 3071 | } |
| 3072 | function parseValueTypeConstant(constant) { |
| 3073 | switch(constant){ |
| 3074 | case Array: |
| 3075 | return "array"; |
| 3076 | case Boolean: |
| 3077 | return "boolean"; |
| 3078 | case Number: |
| 3079 | return "number"; |
| 3080 | case Object: |
| 3081 | return "object"; |
| 3082 | case String: |
| 3083 | return "string"; |
| 3084 | } |
| 3085 | } |
| 3086 | function parseValueTypeDefault(defaultValue) { |
| 3087 | switch(typeof defaultValue === "undefined" ? "undefined" : (0, _typeOfJsDefault.default)(defaultValue)){ |
| 3088 | case "boolean": |
| 3089 | return "boolean"; |
| 3090 | case "number": |
| 3091 | return "number"; |
| 3092 | case "string": |
| 3093 | return "string"; |
| 3094 | } |
| 3095 | if (Array.isArray(defaultValue)) return "array"; |
| 3096 | if (Object.prototype.toString.call(defaultValue) === "[object Object]") return "object"; |
| 3097 | } |
| 3098 | function parseValueTypeObject(typeObject) { |
| 3099 | var typeFromObject = parseValueTypeConstant(typeObject.type); |
| 3100 | if (typeFromObject) { |
| 3101 | var defaultValueType = parseValueTypeDefault(typeObject.default); |
| 3102 | if (typeFromObject !== defaultValueType) throw new Error('Type "'.concat(typeFromObject, '" must match the type of the default value. Given default value: "').concat(typeObject.default, '" as "').concat(defaultValueType, '"')); |
| 3103 | return typeFromObject; |
| 3104 | } |
| 3105 | } |
| 3106 | function parseValueTypeDefinition(typeDefinition) { |
| 3107 | var typeFromObject = parseValueTypeObject(typeDefinition); |
| 3108 | var typeFromDefaultValue = parseValueTypeDefault(typeDefinition); |
| 3109 | var typeFromConstant = parseValueTypeConstant(typeDefinition); |
| 3110 | var type = typeFromObject || typeFromDefaultValue || typeFromConstant; |
| 3111 | if (type) return type; |
| 3112 | throw new Error('Unknown value type "'.concat(typeDefinition, '"')); |
| 3113 | } |
| 3114 | function defaultValueForDefinition(typeDefinition) { |
| 3115 | var constant = parseValueTypeConstant(typeDefinition); |
| 3116 | if (constant) return defaultValuesByType[constant]; |
| 3117 | var defaultValue = typeDefinition.default; |
| 3118 | if (defaultValue !== undefined) return defaultValue; |
| 3119 | return typeDefinition; |
| 3120 | } |
| 3121 | function valueDescriptorForTokenAndTypeDefinition(token, typeDefinition) { |
| 3122 | var key = "".concat(dasherize(token), "-value"); |
| 3123 | var type = parseValueTypeDefinition(typeDefinition); |
| 3124 | return { |
| 3125 | type: type, |
| 3126 | key: key, |
| 3127 | name: camelize(key), |
| 3128 | get defaultValue () { |
| 3129 | return defaultValueForDefinition(typeDefinition); |
| 3130 | }, |
| 3131 | get hasCustomDefaultValue () { |
| 3132 | return parseValueTypeDefault(typeDefinition) !== undefined; |
| 3133 | }, |
| 3134 | reader: readers[type], |
| 3135 | writer: writers[type] || writers.default |
| 3136 | }; |
| 3137 | } |
| 3138 | var defaultValuesByType = { |
| 3139 | get array () { |
| 3140 | return []; |
| 3141 | }, |
| 3142 | boolean: false, |
| 3143 | number: 0, |
| 3144 | get object () { |
| 3145 | return {}; |
| 3146 | }, |
| 3147 | string: "" |
| 3148 | }; |
| 3149 | var readers = { |
| 3150 | array: function(value) { |
| 3151 | var array = JSON.parse(value); |
| 3152 | if (!Array.isArray(array)) throw new TypeError("Expected array"); |
| 3153 | return array; |
| 3154 | }, |
| 3155 | boolean: function(value) { |
| 3156 | return !(value == "0" || value == "false"); |
| 3157 | }, |
| 3158 | number: function(value) { |
| 3159 | return Number(value); |
| 3160 | }, |
| 3161 | object: function(value) { |
| 3162 | var object = JSON.parse(value); |
| 3163 | if (object === null || typeof object != "object" || Array.isArray(object)) throw new TypeError("Expected object"); |
| 3164 | return object; |
| 3165 | }, |
| 3166 | string: function(value) { |
| 3167 | return value; |
| 3168 | } |
| 3169 | }; |
| 3170 | var writers = { |
| 3171 | default: writeString, |
| 3172 | array: writeJSON, |
| 3173 | object: writeJSON |
| 3174 | }; |
| 3175 | function writeJSON(value) { |
| 3176 | return JSON.stringify(value); |
| 3177 | } |
| 3178 | function writeString(value) { |
| 3179 | return "".concat(value); |
| 3180 | } |
| 3181 | var Controller = /*#__PURE__*/ function() { |
| 3182 | "use strict"; |
| 3183 | function Controller(context) { |
| 3184 | (0, _classCallCheckJsDefault.default)(this, Controller); |
| 3185 | this.context = context; |
| 3186 | } |
| 3187 | (0, _createClassJsDefault.default)(Controller, [ |
| 3188 | { |
| 3189 | key: "application", |
| 3190 | get: function get() { |
| 3191 | return this.context.application; |
| 3192 | } |
| 3193 | }, |
| 3194 | { |
| 3195 | key: "scope", |
| 3196 | get: function get() { |
| 3197 | return this.context.scope; |
| 3198 | } |
| 3199 | }, |
| 3200 | { |
| 3201 | key: "element", |
| 3202 | get: function get() { |
| 3203 | return this.scope.element; |
| 3204 | } |
| 3205 | }, |
| 3206 | { |
| 3207 | key: "identifier", |
| 3208 | get: function get() { |
| 3209 | return this.scope.identifier; |
| 3210 | } |
| 3211 | }, |
| 3212 | { |
| 3213 | key: "targets", |
| 3214 | get: function get() { |
| 3215 | return this.scope.targets; |
| 3216 | } |
| 3217 | }, |
| 3218 | { |
| 3219 | key: "classes", |
| 3220 | get: function get() { |
| 3221 | return this.scope.classes; |
| 3222 | } |
| 3223 | }, |
| 3224 | { |
| 3225 | key: "data", |
| 3226 | get: function get() { |
| 3227 | return this.scope.data; |
| 3228 | } |
| 3229 | }, |
| 3230 | { |
| 3231 | key: "initialize", |
| 3232 | value: function initialize() {} |
| 3233 | }, |
| 3234 | { |
| 3235 | key: "connect", |
| 3236 | value: function connect() {} |
| 3237 | }, |
| 3238 | { |
| 3239 | key: "disconnect", |
| 3240 | value: function disconnect() {} |
| 3241 | }, |
| 3242 | { |
| 3243 | key: "dispatch", |
| 3244 | value: function dispatch(eventName) { |
| 3245 | var ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _target = ref.target, target = _target === void 0 ? this.element : _target, _detail = ref.detail, detail = _detail === void 0 ? {} : _detail, _prefix = ref.prefix, prefix = _prefix === void 0 ? this.identifier : _prefix, _bubbles = ref.bubbles, bubbles = _bubbles === void 0 ? true : _bubbles, _cancelable = ref.cancelable, cancelable = _cancelable === void 0 ? true : _cancelable; |
| 3246 | var type = prefix ? "".concat(prefix, ":").concat(eventName) : eventName; |
| 3247 | var event = new CustomEvent(type, { |
| 3248 | detail: detail, |
| 3249 | bubbles: bubbles, |
| 3250 | cancelable: cancelable |
| 3251 | }); |
| 3252 | target.dispatchEvent(event); |
| 3253 | return event; |
| 3254 | } |
| 3255 | } |
| 3256 | ], [ |
| 3257 | { |
| 3258 | key: "shouldLoad", |
| 3259 | get: function get() { |
| 3260 | return true; |
| 3261 | } |
| 3262 | } |
| 3263 | ]); |
| 3264 | return Controller; |
| 3265 | }(); |
| 3266 | Controller.blessings = [ |
| 3267 | ClassPropertiesBlessing, |
| 3268 | TargetPropertiesBlessing, |
| 3269 | ValuePropertiesBlessing |
| 3270 | ]; |
| 3271 | Controller.targets = []; |
| 3272 | Controller.values = {}; |
| 3273 | |
| 3274 | },{"@swc/helpers/lib/_async_to_generator.js":"fKf1r","@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_get.js":"5g4pb","@swc/helpers/lib/_get_prototype_of.js":"7Gb6H","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_sliced_to_array.js":"4IWLM","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_type_of.js":"9FF45","@swc/helpers/lib/_create_super.js":"5rW3S","regenerator-runtime":"7j2bv","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"fKf1r":[function(require,module,exports) { |
| 3275 | "use strict"; |
| 3276 | Object.defineProperty(exports, "__esModule", { |
| 3277 | value: true |
| 3278 | }); |
| 3279 | exports.default = _asyncToGenerator; |
| 3280 | function _asyncToGenerator(fn) { |
| 3281 | return function() { |
| 3282 | var self = this, args = arguments; |
| 3283 | return new Promise(function(resolve, reject) { |
| 3284 | var gen = fn.apply(self, args); |
| 3285 | function _next(value) { |
| 3286 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
| 3287 | } |
| 3288 | function _throw(err) { |
| 3289 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
| 3290 | } |
| 3291 | _next(undefined); |
| 3292 | }); |
| 3293 | }; |
| 3294 | } |
| 3295 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
| 3296 | try { |
| 3297 | var info = gen[key](arg); |
| 3298 | var value = info.value; |
| 3299 | } catch (error) { |
| 3300 | reject(error); |
| 3301 | return; |
| 3302 | } |
| 3303 | if (info.done) resolve(value); |
| 3304 | else Promise.resolve(value).then(_next, _throw); |
| 3305 | } |
| 3306 | |
| 3307 | },{}],"gNxF8":[function(require,module,exports) { |
| 3308 | "use strict"; |
| 3309 | Object.defineProperty(exports, "__esModule", { |
| 3310 | value: true |
| 3311 | }); |
| 3312 | exports.default = _classCallCheck; |
| 3313 | function _classCallCheck(instance, Constructor) { |
| 3314 | if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); |
| 3315 | } |
| 3316 | |
| 3317 | },{}],"iyoaN":[function(require,module,exports) { |
| 3318 | "use strict"; |
| 3319 | Object.defineProperty(exports, "__esModule", { |
| 3320 | value: true |
| 3321 | }); |
| 3322 | exports.default = _createClass; |
| 3323 | function _createClass(Constructor, protoProps, staticProps) { |
| 3324 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
| 3325 | if (staticProps) _defineProperties(Constructor, staticProps); |
| 3326 | return Constructor; |
| 3327 | } |
| 3328 | function _defineProperties(target, props) { |
| 3329 | for(var i = 0; i < props.length; i++){ |
| 3330 | var descriptor = props[i]; |
| 3331 | descriptor.enumerable = descriptor.enumerable || false; |
| 3332 | descriptor.configurable = true; |
| 3333 | if ("value" in descriptor) descriptor.writable = true; |
| 3334 | Object.defineProperty(target, descriptor.key, descriptor); |
| 3335 | } |
| 3336 | } |
| 3337 | |
| 3338 | },{}],"6IXzf":[function(require,module,exports) { |
| 3339 | "use strict"; |
| 3340 | Object.defineProperty(exports, "__esModule", { |
| 3341 | value: true |
| 3342 | }); |
| 3343 | exports.default = _defineProperty; |
| 3344 | function _defineProperty(obj, key, value) { |
| 3345 | if (key in obj) Object.defineProperty(obj, key, { |
| 3346 | value: value, |
| 3347 | enumerable: true, |
| 3348 | configurable: true, |
| 3349 | writable: true |
| 3350 | }); |
| 3351 | else obj[key] = value; |
| 3352 | return obj; |
| 3353 | } |
| 3354 | |
| 3355 | },{}],"5g4pb":[function(require,module,exports) { |
| 3356 | "use strict"; |
| 3357 | Object.defineProperty(exports, "__esModule", { |
| 3358 | value: true |
| 3359 | }); |
| 3360 | exports.default = _get; |
| 3361 | var _superPropBase = _interopRequireDefault(require("./_super_prop_base")); |
| 3362 | function _get(target, property, receiver) { |
| 3363 | return get(target, property, receiver); |
| 3364 | } |
| 3365 | function _interopRequireDefault(obj) { |
| 3366 | return obj && obj.__esModule ? obj : { |
| 3367 | default: obj |
| 3368 | }; |
| 3369 | } |
| 3370 | function get(target1, property1, receiver1) { |
| 3371 | if (typeof Reflect !== "undefined" && Reflect.get) get = Reflect.get; |
| 3372 | else get = function get(target, property, receiver) { |
| 3373 | var base = _superPropBase.default(target, property); |
| 3374 | if (!base) return; |
| 3375 | var desc = Object.getOwnPropertyDescriptor(base, property); |
| 3376 | if (desc.get) return desc.get.call(receiver || target); |
| 3377 | return desc.value; |
| 3378 | }; |
| 3379 | return get(target1, property1, receiver1); |
| 3380 | } |
| 3381 | |
| 3382 | },{"./_super_prop_base":"cT49D"}],"cT49D":[function(require,module,exports) { |
| 3383 | "use strict"; |
| 3384 | Object.defineProperty(exports, "__esModule", { |
| 3385 | value: true |
| 3386 | }); |
| 3387 | exports.default = _superPropBase; |
| 3388 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 3389 | function _superPropBase(object, property) { |
| 3390 | while(!Object.prototype.hasOwnProperty.call(object, property)){ |
| 3391 | object = _getPrototypeOf.default(object); |
| 3392 | if (object === null) break; |
| 3393 | } |
| 3394 | return object; |
| 3395 | } |
| 3396 | function _interopRequireDefault(obj) { |
| 3397 | return obj && obj.__esModule ? obj : { |
| 3398 | default: obj |
| 3399 | }; |
| 3400 | } |
| 3401 | |
| 3402 | },{"./_get_prototype_of":"7Gb6H"}],"7Gb6H":[function(require,module,exports) { |
| 3403 | "use strict"; |
| 3404 | Object.defineProperty(exports, "__esModule", { |
| 3405 | value: true |
| 3406 | }); |
| 3407 | exports.default = _getPrototypeOf; |
| 3408 | function _getPrototypeOf(o) { |
| 3409 | return getPrototypeOf(o); |
| 3410 | } |
| 3411 | function getPrototypeOf(o1) { |
| 3412 | getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { |
| 3413 | return o.__proto__ || Object.getPrototypeOf(o); |
| 3414 | }; |
| 3415 | return getPrototypeOf(o1); |
| 3416 | } |
| 3417 | |
| 3418 | },{}],"atvDk":[function(require,module,exports) { |
| 3419 | "use strict"; |
| 3420 | Object.defineProperty(exports, "__esModule", { |
| 3421 | value: true |
| 3422 | }); |
| 3423 | exports.default = _inherits; |
| 3424 | var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of")); |
| 3425 | function _inherits(subClass, superClass) { |
| 3426 | if (typeof superClass !== "function" && superClass !== null) throw new TypeError("Super expression must either be null or a function"); |
| 3427 | subClass.prototype = Object.create(superClass && superClass.prototype, { |
| 3428 | constructor: { |
| 3429 | value: subClass, |
| 3430 | writable: true, |
| 3431 | configurable: true |
| 3432 | } |
| 3433 | }); |
| 3434 | if (superClass) _setPrototypeOf.default(subClass, superClass); |
| 3435 | } |
| 3436 | function _interopRequireDefault(obj) { |
| 3437 | return obj && obj.__esModule ? obj : { |
| 3438 | default: obj |
| 3439 | }; |
| 3440 | } |
| 3441 | |
| 3442 | },{"./_set_prototype_of":"1rATD"}],"1rATD":[function(require,module,exports) { |
| 3443 | "use strict"; |
| 3444 | Object.defineProperty(exports, "__esModule", { |
| 3445 | value: true |
| 3446 | }); |
| 3447 | exports.default = _setPrototypeOf; |
| 3448 | function _setPrototypeOf(o, p) { |
| 3449 | return setPrototypeOf(o, p); |
| 3450 | } |
| 3451 | function setPrototypeOf(o1, p1) { |
| 3452 | setPrototypeOf = Object.setPrototypeOf || function setPrototypeOf(o, p) { |
| 3453 | o.__proto__ = p; |
| 3454 | return o; |
| 3455 | }; |
| 3456 | return setPrototypeOf(o1, p1); |
| 3457 | } |
| 3458 | |
| 3459 | },{}],"4IWLM":[function(require,module,exports) { |
| 3460 | "use strict"; |
| 3461 | Object.defineProperty(exports, "__esModule", { |
| 3462 | value: true |
| 3463 | }); |
| 3464 | exports.default = _slicedToArray; |
| 3465 | var _arrayWithHoles = _interopRequireDefault(require("./_array_with_holes")); |
| 3466 | var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array")); |
| 3467 | var _nonIterableRest = _interopRequireDefault(require("./_non_iterable_rest")); |
| 3468 | var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array")); |
| 3469 | function _slicedToArray(arr, i) { |
| 3470 | return _arrayWithHoles.default(arr) || _iterableToArray.default(arr, i) || _unsupportedIterableToArray.default(arr, i) || _nonIterableRest.default(); |
| 3471 | } |
| 3472 | function _interopRequireDefault(obj) { |
| 3473 | return obj && obj.__esModule ? obj : { |
| 3474 | default: obj |
| 3475 | }; |
| 3476 | } |
| 3477 | |
| 3478 | },{"./_array_with_holes":"kAkr9","./_iterable_to_array":"d0B07","./_non_iterable_rest":"bXNgi","./_unsupported_iterable_to_array":"jhPJb"}],"kAkr9":[function(require,module,exports) { |
| 3479 | "use strict"; |
| 3480 | Object.defineProperty(exports, "__esModule", { |
| 3481 | value: true |
| 3482 | }); |
| 3483 | exports.default = _arrayWithHoles; |
| 3484 | function _arrayWithHoles(arr) { |
| 3485 | if (Array.isArray(arr)) return arr; |
| 3486 | } |
| 3487 | |
| 3488 | },{}],"d0B07":[function(require,module,exports) { |
| 3489 | "use strict"; |
| 3490 | Object.defineProperty(exports, "__esModule", { |
| 3491 | value: true |
| 3492 | }); |
| 3493 | exports.default = _iterableToArray; |
| 3494 | function _iterableToArray(iter) { |
| 3495 | if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); |
| 3496 | } |
| 3497 | |
| 3498 | },{}],"bXNgi":[function(require,module,exports) { |
| 3499 | "use strict"; |
| 3500 | Object.defineProperty(exports, "__esModule", { |
| 3501 | value: true |
| 3502 | }); |
| 3503 | exports.default = _nonIterableRest; |
| 3504 | function _nonIterableRest() { |
| 3505 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 3506 | } |
| 3507 | |
| 3508 | },{}],"jhPJb":[function(require,module,exports) { |
| 3509 | "use strict"; |
| 3510 | Object.defineProperty(exports, "__esModule", { |
| 3511 | value: true |
| 3512 | }); |
| 3513 | exports.default = _unsupportedIterableToArray; |
| 3514 | var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array")); |
| 3515 | function _unsupportedIterableToArray(o, minLen) { |
| 3516 | if (!o) return; |
| 3517 | if (typeof o === "string") return _arrayLikeToArray.default(o, minLen); |
| 3518 | var n = Object.prototype.toString.call(o).slice(8, -1); |
| 3519 | if (n === "Object" && o.constructor) n = o.constructor.name; |
| 3520 | if (n === "Map" || n === "Set") return Array.from(n); |
| 3521 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray.default(o, minLen); |
| 3522 | } |
| 3523 | function _interopRequireDefault(obj) { |
| 3524 | return obj && obj.__esModule ? obj : { |
| 3525 | default: obj |
| 3526 | }; |
| 3527 | } |
| 3528 | |
| 3529 | },{"./_array_like_to_array":"4K9fh"}],"4K9fh":[function(require,module,exports) { |
| 3530 | "use strict"; |
| 3531 | Object.defineProperty(exports, "__esModule", { |
| 3532 | value: true |
| 3533 | }); |
| 3534 | exports.default = _arrayLikeToArray; |
| 3535 | function _arrayLikeToArray(arr, len) { |
| 3536 | if (len == null || len > arr.length) len = arr.length; |
| 3537 | for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; |
| 3538 | return arr2; |
| 3539 | } |
| 3540 | |
| 3541 | },{}],"cccKv":[function(require,module,exports) { |
| 3542 | "use strict"; |
| 3543 | Object.defineProperty(exports, "__esModule", { |
| 3544 | value: true |
| 3545 | }); |
| 3546 | exports.default = _toConsumableArray; |
| 3547 | var _arrayWithoutHoles = _interopRequireDefault(require("./_array_without_holes")); |
| 3548 | var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array")); |
| 3549 | var _nonIterableSpread = _interopRequireDefault(require("./_non_iterable_spread")); |
| 3550 | var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array")); |
| 3551 | function _toConsumableArray(arr) { |
| 3552 | return _arrayWithoutHoles.default(arr) || _iterableToArray.default(arr) || _unsupportedIterableToArray.default(arr) || _nonIterableSpread.default(); |
| 3553 | } |
| 3554 | function _interopRequireDefault(obj) { |
| 3555 | return obj && obj.__esModule ? obj : { |
| 3556 | default: obj |
| 3557 | }; |
| 3558 | } |
| 3559 | |
| 3560 | },{"./_array_without_holes":"26osg","./_iterable_to_array":"d0B07","./_non_iterable_spread":"nlNPL","./_unsupported_iterable_to_array":"jhPJb"}],"26osg":[function(require,module,exports) { |
| 3561 | "use strict"; |
| 3562 | Object.defineProperty(exports, "__esModule", { |
| 3563 | value: true |
| 3564 | }); |
| 3565 | exports.default = _arrayWithoutHoles; |
| 3566 | var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array")); |
| 3567 | function _arrayWithoutHoles(arr) { |
| 3568 | if (Array.isArray(arr)) return _arrayLikeToArray.default(arr); |
| 3569 | } |
| 3570 | function _interopRequireDefault(obj) { |
| 3571 | return obj && obj.__esModule ? obj : { |
| 3572 | default: obj |
| 3573 | }; |
| 3574 | } |
| 3575 | |
| 3576 | },{"./_array_like_to_array":"4K9fh"}],"nlNPL":[function(require,module,exports) { |
| 3577 | "use strict"; |
| 3578 | Object.defineProperty(exports, "__esModule", { |
| 3579 | value: true |
| 3580 | }); |
| 3581 | exports.default = _nonIterableSpread; |
| 3582 | function _nonIterableSpread() { |
| 3583 | throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 3584 | } |
| 3585 | |
| 3586 | },{}],"9FF45":[function(require,module,exports) { |
| 3587 | "use strict"; |
| 3588 | Object.defineProperty(exports, "__esModule", { |
| 3589 | value: true |
| 3590 | }); |
| 3591 | exports.default = _typeof; |
| 3592 | function _typeof(obj) { |
| 3593 | "@swc/helpers - typeof"; |
| 3594 | return obj && obj.constructor === Symbol ? "symbol" : typeof obj; |
| 3595 | } |
| 3596 | |
| 3597 | },{}],"5rW3S":[function(require,module,exports) { |
| 3598 | "use strict"; |
| 3599 | Object.defineProperty(exports, "__esModule", { |
| 3600 | value: true |
| 3601 | }); |
| 3602 | exports.default = _createSuper; |
| 3603 | var _isNativeReflectConstruct = _interopRequireDefault(require("./_is_native_reflect_construct")); |
| 3604 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 3605 | var _possibleConstructorReturn = _interopRequireDefault(require("./_possible_constructor_return")); |
| 3606 | function _createSuper(Derived) { |
| 3607 | var hasNativeReflectConstruct = _isNativeReflectConstruct.default(); |
| 3608 | return function _createSuperInternal() { |
| 3609 | var Super = _getPrototypeOf.default(Derived), result; |
| 3610 | if (hasNativeReflectConstruct) { |
| 3611 | var NewTarget = _getPrototypeOf.default(this).constructor; |
| 3612 | result = Reflect.construct(Super, arguments, NewTarget); |
| 3613 | } else result = Super.apply(this, arguments); |
| 3614 | return _possibleConstructorReturn.default(this, result); |
| 3615 | }; |
| 3616 | } |
| 3617 | function _interopRequireDefault(obj) { |
| 3618 | return obj && obj.__esModule ? obj : { |
| 3619 | default: obj |
| 3620 | }; |
| 3621 | } |
| 3622 | |
| 3623 | },{"./_is_native_reflect_construct":"aPH71","./_get_prototype_of":"7Gb6H","./_possible_constructor_return":"hAvqf"}],"aPH71":[function(require,module,exports) { |
| 3624 | "use strict"; |
| 3625 | Object.defineProperty(exports, "__esModule", { |
| 3626 | value: true |
| 3627 | }); |
| 3628 | exports.default = _isNativeReflectConstruct; |
| 3629 | function _isNativeReflectConstruct() { |
| 3630 | if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
| 3631 | if (Reflect.construct.sham) return false; |
| 3632 | if (typeof Proxy === "function") return true; |
| 3633 | try { |
| 3634 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); |
| 3635 | return true; |
| 3636 | } catch (e) { |
| 3637 | return false; |
| 3638 | } |
| 3639 | } |
| 3640 | |
| 3641 | },{}],"hAvqf":[function(require,module,exports) { |
| 3642 | "use strict"; |
| 3643 | Object.defineProperty(exports, "__esModule", { |
| 3644 | value: true |
| 3645 | }); |
| 3646 | exports.default = _possibleConstructorReturn; |
| 3647 | var _assertThisInitialized = _interopRequireDefault(require("./_assert_this_initialized")); |
| 3648 | var _typeOf = _interopRequireDefault(require("./_type_of")); |
| 3649 | function _possibleConstructorReturn(self, call) { |
| 3650 | if (call && (_typeOf.default(call) === "object" || typeof call === "function")) return call; |
| 3651 | return _assertThisInitialized.default(self); |
| 3652 | } |
| 3653 | function _interopRequireDefault(obj) { |
| 3654 | return obj && obj.__esModule ? obj : { |
| 3655 | default: obj |
| 3656 | }; |
| 3657 | } |
| 3658 | |
| 3659 | },{"./_assert_this_initialized":"l7nF8","./_type_of":"9FF45"}],"l7nF8":[function(require,module,exports) { |
| 3660 | "use strict"; |
| 3661 | Object.defineProperty(exports, "__esModule", { |
| 3662 | value: true |
| 3663 | }); |
| 3664 | exports.default = _assertThisInitialized; |
| 3665 | function _assertThisInitialized(self) { |
| 3666 | if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
| 3667 | return self; |
| 3668 | } |
| 3669 | |
| 3670 | },{}],"7j2bv":[function(require,module,exports) { |
| 3671 | /** |
| 3672 | * Copyright (c) 2014-present, Facebook, Inc. |
| 3673 | * |
| 3674 | * This source code is licensed under the MIT license found in the |
| 3675 | * LICENSE file in the root directory of this source tree. |
| 3676 | */ var runtime = function(exports) { |
| 3677 | "use strict"; |
| 3678 | var define = function define(obj, key, value) { |
| 3679 | Object.defineProperty(obj, key, { |
| 3680 | value: value, |
| 3681 | enumerable: true, |
| 3682 | configurable: true, |
| 3683 | writable: true |
| 3684 | }); |
| 3685 | return obj[key]; |
| 3686 | }; |
| 3687 | var wrap = function wrap(innerFn, outerFn, self, tryLocsList) { |
| 3688 | // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
| 3689 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
| 3690 | var generator = Object.create(protoGenerator.prototype); |
| 3691 | var context = new Context(tryLocsList || []); |
| 3692 | // The ._invoke method unifies the implementations of the .next, |
| 3693 | // .throw, and .return methods. |
| 3694 | generator._invoke = makeInvokeMethod(innerFn, self, context); |
| 3695 | return generator; |
| 3696 | }; |
| 3697 | var tryCatch = // Try/catch helper to minimize deoptimizations. Returns a completion |
| 3698 | // record like context.tryEntries[i].completion. This interface could |
| 3699 | // have been (and was previously) designed to take a closure to be |
| 3700 | // invoked without arguments, but in all the cases we care about we |
| 3701 | // already have an existing method we want to call, so there's no need |
| 3702 | // to create a new function object. We can even get away with assuming |
| 3703 | // the method takes exactly one argument, since that happens to be true |
| 3704 | // in every case, so we don't have to touch the arguments object. The |
| 3705 | // only additional allocation required is the completion record, which |
| 3706 | // has a stable shape and so hopefully should be cheap to allocate. |
| 3707 | function tryCatch(fn, obj, arg) { |
| 3708 | try { |
| 3709 | return { |
| 3710 | type: "normal", |
| 3711 | arg: fn.call(obj, arg) |
| 3712 | }; |
| 3713 | } catch (err) { |
| 3714 | return { |
| 3715 | type: "throw", |
| 3716 | arg: err |
| 3717 | }; |
| 3718 | } |
| 3719 | }; |
| 3720 | var Generator = // Dummy constructor functions that we use as the .constructor and |
| 3721 | // .constructor.prototype properties for functions that return Generator |
| 3722 | // objects. For full spec compliance, you may wish to configure your |
| 3723 | // minifier not to mangle the names of these two functions. |
| 3724 | function Generator() {}; |
| 3725 | var GeneratorFunction = function GeneratorFunction() {}; |
| 3726 | var GeneratorFunctionPrototype = function GeneratorFunctionPrototype() {}; |
| 3727 | var defineIteratorMethods = // Helper for defining the .next, .throw, and .return methods of the |
| 3728 | // Iterator interface in terms of a single ._invoke method. |
| 3729 | function defineIteratorMethods(prototype) { |
| 3730 | [ |
| 3731 | "next", |
| 3732 | "throw", |
| 3733 | "return" |
| 3734 | ].forEach(function(method) { |
| 3735 | define(prototype, method, function(arg) { |
| 3736 | return this._invoke(method, arg); |
| 3737 | }); |
| 3738 | }); |
| 3739 | }; |
| 3740 | var AsyncIterator = function AsyncIterator(generator, PromiseImpl) { |
| 3741 | function invoke(method, arg, resolve, reject) { |
| 3742 | var record = tryCatch(generator[method], generator, arg); |
| 3743 | if (record.type === "throw") reject(record.arg); |
| 3744 | else { |
| 3745 | var result = record.arg; |
| 3746 | var value1 = result.value; |
| 3747 | if (value1 && typeof value1 === "object" && hasOwn.call(value1, "__await")) return PromiseImpl.resolve(value1.__await).then(function(value) { |
| 3748 | invoke("next", value, resolve, reject); |
| 3749 | }, function(err) { |
| 3750 | invoke("throw", err, resolve, reject); |
| 3751 | }); |
| 3752 | return PromiseImpl.resolve(value1).then(function(unwrapped) { |
| 3753 | // When a yielded Promise is resolved, its final value becomes |
| 3754 | // the .value of the Promise<{value,done}> result for the |
| 3755 | // current iteration. |
| 3756 | result.value = unwrapped; |
| 3757 | resolve(result); |
| 3758 | }, function(error) { |
| 3759 | // If a rejected Promise was yielded, throw the rejection back |
| 3760 | // into the async generator function so it can be handled there. |
| 3761 | return invoke("throw", error, resolve, reject); |
| 3762 | }); |
| 3763 | } |
| 3764 | } |
| 3765 | var previousPromise; |
| 3766 | function enqueue(method, arg) { |
| 3767 | function callInvokeWithMethodAndArg() { |
| 3768 | return new PromiseImpl(function(resolve, reject) { |
| 3769 | invoke(method, arg, resolve, reject); |
| 3770 | }); |
| 3771 | } |
| 3772 | return previousPromise = // If enqueue has been called before, then we want to wait until |
| 3773 | // all previous Promises have been resolved before calling invoke, |
| 3774 | // so that results are always delivered in the correct order. If |
| 3775 | // enqueue has not been called before, then it is important to |
| 3776 | // call invoke immediately, without waiting on a callback to fire, |
| 3777 | // so that the async generator function has the opportunity to do |
| 3778 | // any necessary setup in a predictable way. This predictability |
| 3779 | // is why the Promise constructor synchronously invokes its |
| 3780 | // executor callback, and why async functions synchronously |
| 3781 | // execute code before the first await. Since we implement simple |
| 3782 | // async functions in terms of async generators, it is especially |
| 3783 | // important to get this right, even though it requires care. |
| 3784 | previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later |
| 3785 | // invocations of the iterator. |
| 3786 | callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); |
| 3787 | } |
| 3788 | // Define the unified helper method that is used to implement .next, |
| 3789 | // .throw, and .return (see defineIteratorMethods). |
| 3790 | this._invoke = enqueue; |
| 3791 | }; |
| 3792 | var makeInvokeMethod = function makeInvokeMethod(innerFn, self, context) { |
| 3793 | var state = GenStateSuspendedStart; |
| 3794 | return function invoke(method, arg) { |
| 3795 | if (state === GenStateExecuting) throw new Error("Generator is already running"); |
| 3796 | if (state === GenStateCompleted) { |
| 3797 | if (method === "throw") throw arg; |
| 3798 | // Be forgiving, per 25.3.3.3.3 of the spec: |
| 3799 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
| 3800 | return doneResult(); |
| 3801 | } |
| 3802 | context.method = method; |
| 3803 | context.arg = arg; |
| 3804 | while(true){ |
| 3805 | var delegate = context.delegate; |
| 3806 | if (delegate) { |
| 3807 | var delegateResult = maybeInvokeDelegate(delegate, context); |
| 3808 | if (delegateResult) { |
| 3809 | if (delegateResult === ContinueSentinel) continue; |
| 3810 | return delegateResult; |
| 3811 | } |
| 3812 | } |
| 3813 | if (context.method === "next") // Setting context._sent for legacy support of Babel's |
| 3814 | // function.sent implementation. |
| 3815 | context.sent = context._sent = context.arg; |
| 3816 | else if (context.method === "throw") { |
| 3817 | if (state === GenStateSuspendedStart) { |
| 3818 | state = GenStateCompleted; |
| 3819 | throw context.arg; |
| 3820 | } |
| 3821 | context.dispatchException(context.arg); |
| 3822 | } else if (context.method === "return") context.abrupt("return", context.arg); |
| 3823 | state = GenStateExecuting; |
| 3824 | var record = tryCatch(innerFn, self, context); |
| 3825 | if (record.type === "normal") { |
| 3826 | // If an exception is thrown from innerFn, we leave state === |
| 3827 | // GenStateExecuting and loop back for another invocation. |
| 3828 | state = context.done ? GenStateCompleted : GenStateSuspendedYield; |
| 3829 | if (record.arg === ContinueSentinel) continue; |
| 3830 | return { |
| 3831 | value: record.arg, |
| 3832 | done: context.done |
| 3833 | }; |
| 3834 | } else if (record.type === "throw") { |
| 3835 | state = GenStateCompleted; |
| 3836 | // Dispatch the exception by looping back around to the |
| 3837 | // context.dispatchException(context.arg) call above. |
| 3838 | context.method = "throw"; |
| 3839 | context.arg = record.arg; |
| 3840 | } |
| 3841 | } |
| 3842 | }; |
| 3843 | }; |
| 3844 | var pushTryEntry = function pushTryEntry(locs) { |
| 3845 | var entry = { |
| 3846 | tryLoc: locs[0] |
| 3847 | }; |
| 3848 | if (1 in locs) entry.catchLoc = locs[1]; |
| 3849 | if (2 in locs) { |
| 3850 | entry.finallyLoc = locs[2]; |
| 3851 | entry.afterLoc = locs[3]; |
| 3852 | } |
| 3853 | this.tryEntries.push(entry); |
| 3854 | }; |
| 3855 | var resetTryEntry = function resetTryEntry(entry) { |
| 3856 | var record = entry.completion || {}; |
| 3857 | record.type = "normal"; |
| 3858 | delete record.arg; |
| 3859 | entry.completion = record; |
| 3860 | }; |
| 3861 | var Context = function Context(tryLocsList) { |
| 3862 | // The root entry object (effectively a try statement without a catch |
| 3863 | // or a finally block) gives us a place to store values thrown from |
| 3864 | // locations where there is no enclosing try statement. |
| 3865 | this.tryEntries = [ |
| 3866 | { |
| 3867 | tryLoc: "root" |
| 3868 | } |
| 3869 | ]; |
| 3870 | tryLocsList.forEach(pushTryEntry, this); |
| 3871 | this.reset(true); |
| 3872 | }; |
| 3873 | var values = function values(iterable) { |
| 3874 | if (iterable) { |
| 3875 | var iteratorMethod = iterable[iteratorSymbol]; |
| 3876 | if (iteratorMethod) return iteratorMethod.call(iterable); |
| 3877 | if (typeof iterable.next === "function") return iterable; |
| 3878 | if (!isNaN(iterable.length)) { |
| 3879 | var i = -1, next1 = function next() { |
| 3880 | while(++i < iterable.length)if (hasOwn.call(iterable, i)) { |
| 3881 | next.value = iterable[i]; |
| 3882 | next.done = false; |
| 3883 | return next; |
| 3884 | } |
| 3885 | next.value = undefined; |
| 3886 | next.done = true; |
| 3887 | return next; |
| 3888 | }; |
| 3889 | return next1.next = next1; |
| 3890 | } |
| 3891 | } |
| 3892 | // Return an iterator with no values. |
| 3893 | return { |
| 3894 | next: doneResult |
| 3895 | }; |
| 3896 | }; |
| 3897 | var doneResult = function doneResult() { |
| 3898 | return { |
| 3899 | value: undefined, |
| 3900 | done: true |
| 3901 | }; |
| 3902 | }; |
| 3903 | var Op = Object.prototype; |
| 3904 | var hasOwn = Op.hasOwnProperty; |
| 3905 | var undefined; // More compressible than void 0. |
| 3906 | var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
| 3907 | var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
| 3908 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
| 3909 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
| 3910 | try { |
| 3911 | // IE 8 has a broken Object.defineProperty that only works on DOM objects. |
| 3912 | define({}, ""); |
| 3913 | } catch (err) { |
| 3914 | define = function define(obj, key, value) { |
| 3915 | return obj[key] = value; |
| 3916 | }; |
| 3917 | } |
| 3918 | exports.wrap = wrap; |
| 3919 | var GenStateSuspendedStart = "suspendedStart"; |
| 3920 | var GenStateSuspendedYield = "suspendedYield"; |
| 3921 | var GenStateExecuting = "executing"; |
| 3922 | var GenStateCompleted = "completed"; |
| 3923 | // Returning this object from the innerFn has the same effect as |
| 3924 | // breaking out of the dispatch switch statement. |
| 3925 | var ContinueSentinel = {}; |
| 3926 | // This is a polyfill for %IteratorPrototype% for environments that |
| 3927 | // don't natively support it. |
| 3928 | var IteratorPrototype = {}; |
| 3929 | define(IteratorPrototype, iteratorSymbol, function() { |
| 3930 | return this; |
| 3931 | }); |
| 3932 | var getProto = Object.getPrototypeOf; |
| 3933 | var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
| 3934 | if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) // This environment has a native %IteratorPrototype%; use it instead |
| 3935 | // of the polyfill. |
| 3936 | IteratorPrototype = NativeIteratorPrototype; |
| 3937 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); |
| 3938 | GeneratorFunction.prototype = GeneratorFunctionPrototype; |
| 3939 | define(Gp, "constructor", GeneratorFunctionPrototype); |
| 3940 | define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); |
| 3941 | GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); |
| 3942 | exports.isGeneratorFunction = function(genFun) { |
| 3943 | var ctor = typeof genFun === "function" && genFun.constructor; |
| 3944 | return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can |
| 3945 | // do is to check its .name property. |
| 3946 | (ctor.displayName || ctor.name) === "GeneratorFunction" : false; |
| 3947 | }; |
| 3948 | exports.mark = function(genFun) { |
| 3949 | if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
| 3950 | else { |
| 3951 | genFun.__proto__ = GeneratorFunctionPrototype; |
| 3952 | define(genFun, toStringTagSymbol, "GeneratorFunction"); |
| 3953 | } |
| 3954 | genFun.prototype = Object.create(Gp); |
| 3955 | return genFun; |
| 3956 | }; |
| 3957 | // Within the body of any async function, `await x` is transformed to |
| 3958 | // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
| 3959 | // `hasOwn.call(value, "__await")` to determine if the yielded value is |
| 3960 | // meant to be awaited. |
| 3961 | exports.awrap = function(arg) { |
| 3962 | return { |
| 3963 | __await: arg |
| 3964 | }; |
| 3965 | }; |
| 3966 | defineIteratorMethods(AsyncIterator.prototype); |
| 3967 | define(AsyncIterator.prototype, asyncIteratorSymbol, function() { |
| 3968 | return this; |
| 3969 | }); |
| 3970 | exports.AsyncIterator = AsyncIterator; |
| 3971 | // Note that simple async functions are implemented on top of |
| 3972 | // AsyncIterator objects; they just return a Promise for the value of |
| 3973 | // the final result produced by the iterator. |
| 3974 | exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { |
| 3975 | if (PromiseImpl === void 0) PromiseImpl = Promise; |
| 3976 | var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); |
| 3977 | return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. |
| 3978 | : iter.next().then(function(result) { |
| 3979 | return result.done ? result.value : iter.next(); |
| 3980 | }); |
| 3981 | }; |
| 3982 | // Call delegate.iterator[context.method](context.arg) and handle the |
| 3983 | // result, either by returning a { value, done } result from the |
| 3984 | // delegate iterator, or by modifying context.method and context.arg, |
| 3985 | // setting context.delegate to null, and returning the ContinueSentinel. |
| 3986 | function maybeInvokeDelegate(delegate, context) { |
| 3987 | var method = delegate.iterator[context.method]; |
| 3988 | if (method === undefined) { |
| 3989 | // A .throw or .return when the delegate iterator has no .throw |
| 3990 | // method always terminates the yield* loop. |
| 3991 | context.delegate = null; |
| 3992 | if (context.method === "throw") { |
| 3993 | // Note: ["return"] must be used for ES3 parsing compatibility. |
| 3994 | if (delegate.iterator["return"]) { |
| 3995 | // If the delegate iterator has a return method, give it a |
| 3996 | // chance to clean up. |
| 3997 | context.method = "return"; |
| 3998 | context.arg = undefined; |
| 3999 | maybeInvokeDelegate(delegate, context); |
| 4000 | if (context.method === "throw") // If maybeInvokeDelegate(context) changed context.method from |
| 4001 | // "return" to "throw", let that override the TypeError below. |
| 4002 | return ContinueSentinel; |
| 4003 | } |
| 4004 | context.method = "throw"; |
| 4005 | context.arg = new TypeError("The iterator does not provide a 'throw' method"); |
| 4006 | } |
| 4007 | return ContinueSentinel; |
| 4008 | } |
| 4009 | var record = tryCatch(method, delegate.iterator, context.arg); |
| 4010 | if (record.type === "throw") { |
| 4011 | context.method = "throw"; |
| 4012 | context.arg = record.arg; |
| 4013 | context.delegate = null; |
| 4014 | return ContinueSentinel; |
| 4015 | } |
| 4016 | var info = record.arg; |
| 4017 | if (!info) { |
| 4018 | context.method = "throw"; |
| 4019 | context.arg = new TypeError("iterator result is not an object"); |
| 4020 | context.delegate = null; |
| 4021 | return ContinueSentinel; |
| 4022 | } |
| 4023 | if (info.done) { |
| 4024 | // Assign the result of the finished delegate to the temporary |
| 4025 | // variable specified by delegate.resultName (see delegateYield). |
| 4026 | context[delegate.resultName] = info.value; |
| 4027 | // Resume execution at the desired location (see delegateYield). |
| 4028 | context.next = delegate.nextLoc; |
| 4029 | // If context.method was "throw" but the delegate handled the |
| 4030 | // exception, let the outer generator proceed normally. If |
| 4031 | // context.method was "next", forget context.arg since it has been |
| 4032 | // "consumed" by the delegate iterator. If context.method was |
| 4033 | // "return", allow the original .return call to continue in the |
| 4034 | // outer generator. |
| 4035 | if (context.method !== "return") { |
| 4036 | context.method = "next"; |
| 4037 | context.arg = undefined; |
| 4038 | } |
| 4039 | } else // Re-yield the result returned by the delegate method. |
| 4040 | return info; |
| 4041 | // The delegate iterator is finished, so forget it and continue with |
| 4042 | // the outer generator. |
| 4043 | context.delegate = null; |
| 4044 | return ContinueSentinel; |
| 4045 | } |
| 4046 | // Define Generator.prototype.{next,throw,return} in terms of the |
| 4047 | // unified ._invoke helper method. |
| 4048 | defineIteratorMethods(Gp); |
| 4049 | define(Gp, toStringTagSymbol, "Generator"); |
| 4050 | // A Generator should always return itself as the iterator object when the |
| 4051 | // @@iterator function is called on it. Some browsers' implementations of the |
| 4052 | // iterator prototype chain incorrectly implement this, causing the Generator |
| 4053 | // object to not be returned from this call. This ensures that doesn't happen. |
| 4054 | // See https://github.com/facebook/regenerator/issues/274 for more details. |
| 4055 | define(Gp, iteratorSymbol, function() { |
| 4056 | return this; |
| 4057 | }); |
| 4058 | define(Gp, "toString", function() { |
| 4059 | return "[object Generator]"; |
| 4060 | }); |
| 4061 | exports.keys = function(object) { |
| 4062 | var keys = []; |
| 4063 | for(var key1 in object)keys.push(key1); |
| 4064 | keys.reverse(); |
| 4065 | // Rather than returning an object with a next method, we keep |
| 4066 | // things simple and return the next function itself. |
| 4067 | return function next() { |
| 4068 | while(keys.length){ |
| 4069 | var key = keys.pop(); |
| 4070 | if (key in object) { |
| 4071 | next.value = key; |
| 4072 | next.done = false; |
| 4073 | return next; |
| 4074 | } |
| 4075 | } |
| 4076 | // To avoid creating an additional object, we just hang the .value |
| 4077 | // and .done properties off the next function object itself. This |
| 4078 | // also ensures that the minifier will not anonymize the function. |
| 4079 | next.done = true; |
| 4080 | return next; |
| 4081 | }; |
| 4082 | }; |
| 4083 | exports.values = values; |
| 4084 | Context.prototype = { |
| 4085 | constructor: Context, |
| 4086 | reset: function reset(skipTempReset) { |
| 4087 | this.prev = 0; |
| 4088 | this.next = 0; |
| 4089 | // Resetting context._sent for legacy support of Babel's |
| 4090 | // function.sent implementation. |
| 4091 | this.sent = this._sent = undefined; |
| 4092 | this.done = false; |
| 4093 | this.delegate = null; |
| 4094 | this.method = "next"; |
| 4095 | this.arg = undefined; |
| 4096 | this.tryEntries.forEach(resetTryEntry); |
| 4097 | if (!skipTempReset) { |
| 4098 | for(var name in this)// Not sure about the optimal order of these conditions: |
| 4099 | if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined; |
| 4100 | } |
| 4101 | }, |
| 4102 | stop: function stop() { |
| 4103 | this.done = true; |
| 4104 | var rootEntry = this.tryEntries[0]; |
| 4105 | var rootRecord = rootEntry.completion; |
| 4106 | if (rootRecord.type === "throw") throw rootRecord.arg; |
| 4107 | return this.rval; |
| 4108 | }, |
| 4109 | dispatchException: function dispatchException(exception) { |
| 4110 | var handle = function handle(loc, caught) { |
| 4111 | record.type = "throw"; |
| 4112 | record.arg = exception; |
| 4113 | context.next = loc; |
| 4114 | if (caught) { |
| 4115 | // If the dispatched exception was caught by a catch block, |
| 4116 | // then let that catch block handle the exception normally. |
| 4117 | context.method = "next"; |
| 4118 | context.arg = undefined; |
| 4119 | } |
| 4120 | return !!caught; |
| 4121 | }; |
| 4122 | if (this.done) throw exception; |
| 4123 | var context = this; |
| 4124 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4125 | var entry = this.tryEntries[i]; |
| 4126 | var record = entry.completion; |
| 4127 | if (entry.tryLoc === "root") // Exception thrown outside of any try block that could handle |
| 4128 | // it, so set the completion value of the entire function to |
| 4129 | // throw the exception. |
| 4130 | return handle("end"); |
| 4131 | if (entry.tryLoc <= this.prev) { |
| 4132 | var hasCatch = hasOwn.call(entry, "catchLoc"); |
| 4133 | var hasFinally = hasOwn.call(entry, "finallyLoc"); |
| 4134 | if (hasCatch && hasFinally) { |
| 4135 | if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true); |
| 4136 | else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); |
| 4137 | } else if (hasCatch) { |
| 4138 | if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true); |
| 4139 | } else if (hasFinally) { |
| 4140 | if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); |
| 4141 | } else throw new Error("try statement without catch or finally"); |
| 4142 | } |
| 4143 | } |
| 4144 | }, |
| 4145 | abrupt: function abrupt(type, arg) { |
| 4146 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4147 | var entry = this.tryEntries[i]; |
| 4148 | if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { |
| 4149 | var finallyEntry = entry; |
| 4150 | break; |
| 4151 | } |
| 4152 | } |
| 4153 | if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) // Ignore the finally entry if control is not jumping to a |
| 4154 | // location outside the try/catch block. |
| 4155 | finallyEntry = null; |
| 4156 | var record = finallyEntry ? finallyEntry.completion : {}; |
| 4157 | record.type = type; |
| 4158 | record.arg = arg; |
| 4159 | if (finallyEntry) { |
| 4160 | this.method = "next"; |
| 4161 | this.next = finallyEntry.finallyLoc; |
| 4162 | return ContinueSentinel; |
| 4163 | } |
| 4164 | return this.complete(record); |
| 4165 | }, |
| 4166 | complete: function complete(record, afterLoc) { |
| 4167 | if (record.type === "throw") throw record.arg; |
| 4168 | if (record.type === "break" || record.type === "continue") this.next = record.arg; |
| 4169 | else if (record.type === "return") { |
| 4170 | this.rval = this.arg = record.arg; |
| 4171 | this.method = "return"; |
| 4172 | this.next = "end"; |
| 4173 | } else if (record.type === "normal" && afterLoc) this.next = afterLoc; |
| 4174 | return ContinueSentinel; |
| 4175 | }, |
| 4176 | finish: function finish(finallyLoc) { |
| 4177 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4178 | var entry = this.tryEntries[i]; |
| 4179 | if (entry.finallyLoc === finallyLoc) { |
| 4180 | this.complete(entry.completion, entry.afterLoc); |
| 4181 | resetTryEntry(entry); |
| 4182 | return ContinueSentinel; |
| 4183 | } |
| 4184 | } |
| 4185 | }, |
| 4186 | "catch": function(tryLoc) { |
| 4187 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4188 | var entry = this.tryEntries[i]; |
| 4189 | if (entry.tryLoc === tryLoc) { |
| 4190 | var record = entry.completion; |
| 4191 | if (record.type === "throw") { |
| 4192 | var thrown = record.arg; |
| 4193 | resetTryEntry(entry); |
| 4194 | } |
| 4195 | return thrown; |
| 4196 | } |
| 4197 | } |
| 4198 | // The context.catch method must only be called with a location |
| 4199 | // argument that corresponds to a known catch block. |
| 4200 | throw new Error("illegal catch attempt"); |
| 4201 | }, |
| 4202 | delegateYield: function delegateYield(iterable, resultName, nextLoc) { |
| 4203 | this.delegate = { |
| 4204 | iterator: values(iterable), |
| 4205 | resultName: resultName, |
| 4206 | nextLoc: nextLoc |
| 4207 | }; |
| 4208 | if (this.method === "next") // Deliberately forget the last sent value so that we don't |
| 4209 | // accidentally pass it on to the delegate. |
| 4210 | this.arg = undefined; |
| 4211 | return ContinueSentinel; |
| 4212 | } |
| 4213 | }; |
| 4214 | // Regardless of whether this script is executing as a CommonJS module |
| 4215 | // or not, return the runtime object so that we can declare the variable |
| 4216 | // regeneratorRuntime in the outer scope, which allows this module to be |
| 4217 | // injected easily by `bin/regenerator --include-runtime script.js`. |
| 4218 | return exports; |
| 4219 | }(module.exports); |
| 4220 | try { |
| 4221 | regeneratorRuntime = runtime; |
| 4222 | } catch (accidentalStrictMode) { |
| 4223 | // This module should not be running in strict mode, so the above |
| 4224 | // assignment should always work unless something is misconfigured. Just |
| 4225 | // in case runtime.js accidentally runs in strict mode, in modern engines |
| 4226 | // we can explicitly access globalThis. In older engines we can escape |
| 4227 | // strict mode using a global Function call. This could conceivably fail |
| 4228 | // if a Content Security Policy forbids using Function, but in that case |
| 4229 | // the proper solution is to fix the accidental strict mode problem. If |
| 4230 | // you've misconfigured your bundler to force strict mode and applied a |
| 4231 | // CSP to forbid Function, and you're not willing to fix either of those |
| 4232 | // problems, please detail your unique predicament in a GitHub issue. |
| 4233 | if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime; |
| 4234 | else Function("r", "regeneratorRuntime = r")(runtime); |
| 4235 | } |
| 4236 | |
| 4237 | },{}],"jIm8e":[function(require,module,exports) { |
| 4238 | exports.interopDefault = function(a) { |
| 4239 | return a && a.__esModule ? a : { |
| 4240 | default: a |
| 4241 | }; |
| 4242 | }; |
| 4243 | exports.defineInteropFlag = function(a) { |
| 4244 | Object.defineProperty(a, "__esModule", { |
| 4245 | value: true |
| 4246 | }); |
| 4247 | }; |
| 4248 | exports.exportAll = function(source, dest) { |
| 4249 | Object.keys(source).forEach(function(key) { |
| 4250 | if (key === "default" || key === "__esModule" || dest.hasOwnProperty(key)) return; |
| 4251 | Object.defineProperty(dest, key, { |
| 4252 | enumerable: true, |
| 4253 | get: function get() { |
| 4254 | return source[key]; |
| 4255 | } |
| 4256 | }); |
| 4257 | }); |
| 4258 | return dest; |
| 4259 | }; |
| 4260 | exports.export = function(dest, destName, get) { |
| 4261 | Object.defineProperty(dest, destName, { |
| 4262 | enumerable: true, |
| 4263 | get: get |
| 4264 | }); |
| 4265 | }; |
| 4266 | |
| 4267 | },{}],"dW4sP":[function(require,module,exports) { |
| 4268 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4269 | parcelHelpers.defineInteropFlag(exports); |
| 4270 | function e(e1, t1) { |
| 4271 | for(var o1 = 0; o1 < t1.length; o1++){ |
| 4272 | var n1 = t1[o1]; |
| 4273 | n1.enumerable = n1.enumerable || !1, n1.configurable = !0, "value" in n1 && (n1.writable = !0), Object.defineProperty(e1, n1.key, n1); |
| 4274 | } |
| 4275 | } |
| 4276 | function t(e2) { |
| 4277 | return function(e3) { |
| 4278 | if (Array.isArray(e3)) return o(e3); |
| 4279 | }(e2) || function(e4) { |
| 4280 | if ("undefined" != typeof Symbol && Symbol.iterator in Object(e4)) return Array.from(e4); |
| 4281 | }(e2) || function(e5, t2) { |
| 4282 | if (!e5) return; |
| 4283 | if ("string" == typeof e5) return o(e5, t2); |
| 4284 | var n2 = Object.prototype.toString.call(e5).slice(8, -1); |
| 4285 | "Object" === n2 && e5.constructor && (n2 = e5.constructor.name); |
| 4286 | if ("Map" === n2 || "Set" === n2) return Array.from(e5); |
| 4287 | if ("Arguments" === n2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return o(e5, t2); |
| 4288 | }(e2) || function() { |
| 4289 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 4290 | }(); |
| 4291 | } |
| 4292 | function o(e6, t3) { |
| 4293 | (null == t3 || t3 > e6.length) && (t3 = e6.length); |
| 4294 | for(var o2 = 0, n3 = new Array(t3); o2 < t3; o2++)n3[o2] = e6[o2]; |
| 4295 | return n3; |
| 4296 | } |
| 4297 | var n, i, a, r, s1, l = (n = [ |
| 4298 | "a[href]", |
| 4299 | "area[href]", |
| 4300 | 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', |
| 4301 | "select:not([disabled]):not([aria-hidden])", |
| 4302 | "textarea:not([disabled]):not([aria-hidden])", |
| 4303 | "button:not([disabled]):not([aria-hidden])", |
| 4304 | "iframe", |
| 4305 | "object", |
| 4306 | "embed", |
| 4307 | "[contenteditable]", |
| 4308 | '[tabindex]:not([tabindex^="-"])' |
| 4309 | ], i = function() { |
| 4310 | function o3(e7) { |
| 4311 | var n4 = e7.targetModal, i2 = e7.triggers, a2 = void 0 === i2 ? [] : i2, r2 = e7.onShow, s = void 0 === r2 ? function s() {} : r2, l1 = e7.onClose, c = void 0 === l1 ? function c() {} : l1, d = e7.openTrigger, u = void 0 === d ? "data-micromodal-trigger" : d, f = e7.closeTrigger, h = void 0 === f ? "data-micromodal-close" : f, v = e7.openClass, g = void 0 === v ? "is-open" : v, m = e7.disableScroll, b = void 0 !== m && m, y = e7.disableFocus, p = void 0 !== y && y, w = e7.awaitCloseAnimation, E = void 0 !== w && w, k = e7.awaitOpenAnimation, M = void 0 !== k && k, A = e7.debugMode, C = void 0 !== A && A; |
| 4312 | !function(e8, t4) { |
| 4313 | if (!(e8 instanceof t4)) throw new TypeError("Cannot call a class as a function"); |
| 4314 | }(this, o3), this.modal = document.getElementById(n4), this.config = { |
| 4315 | debugMode: C, |
| 4316 | disableScroll: b, |
| 4317 | openTrigger: u, |
| 4318 | closeTrigger: h, |
| 4319 | openClass: g, |
| 4320 | onShow: s, |
| 4321 | onClose: c, |
| 4322 | awaitCloseAnimation: E, |
| 4323 | awaitOpenAnimation: M, |
| 4324 | disableFocus: p |
| 4325 | }, a2.length > 0 && this.registerTriggers.apply(this, t(a2)), this.onClick = this.onClick.bind(this), this.onKeydown = this.onKeydown.bind(this); |
| 4326 | } |
| 4327 | var i1, a1, r1; |
| 4328 | return i1 = o3, a1 = [ |
| 4329 | { |
| 4330 | key: "registerTriggers", |
| 4331 | value: function value() { |
| 4332 | for(var _$e = this, t5 = arguments.length, _$o = new Array(t5), n5 = 0; n5 < t5; n5++)_$o[n5] = arguments[n5]; |
| 4333 | _$o.filter(Boolean).forEach(function(t6) { |
| 4334 | t6.addEventListener("click", function(t7) { |
| 4335 | return _$e.showModal(t7); |
| 4336 | }); |
| 4337 | }); |
| 4338 | } |
| 4339 | }, |
| 4340 | { |
| 4341 | key: "showModal", |
| 4342 | value: function value() { |
| 4343 | var _$e = this, t8 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null; |
| 4344 | if (this.activeElement = document.activeElement, this.modal.setAttribute("aria-hidden", "false"), this.modal.classList.add(this.config.openClass), this.scrollBehaviour("disable"), this.addEventListeners(), this.config.awaitOpenAnimation) { |
| 4345 | var _$o = function t9() { |
| 4346 | _$e.modal.removeEventListener("animationend", t9, !1), _$e.setFocusToFirstNode(); |
| 4347 | }; |
| 4348 | this.modal.addEventListener("animationend", _$o, !1); |
| 4349 | } else this.setFocusToFirstNode(); |
| 4350 | this.config.onShow(this.modal, this.activeElement, t8); |
| 4351 | } |
| 4352 | }, |
| 4353 | { |
| 4354 | key: "closeModal", |
| 4355 | value: function value() { |
| 4356 | var _$e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null, t10 = this.modal; |
| 4357 | if (this.modal.setAttribute("aria-hidden", "true"), this.removeEventListeners(), this.scrollBehaviour("enable"), this.activeElement && this.activeElement.focus && this.activeElement.focus(), this.config.onClose(this.modal, this.activeElement, _$e), this.config.awaitCloseAnimation) { |
| 4358 | var _$o = this.config.openClass; |
| 4359 | this.modal.addEventListener("animationend", function e9() { |
| 4360 | t10.classList.remove(_$o), t10.removeEventListener("animationend", e9, !1); |
| 4361 | }, !1); |
| 4362 | } else t10.classList.remove(this.config.openClass); |
| 4363 | } |
| 4364 | }, |
| 4365 | { |
| 4366 | key: "closeModalById", |
| 4367 | value: function value(e10) { |
| 4368 | this.modal = document.getElementById(e10), this.modal && this.closeModal(); |
| 4369 | } |
| 4370 | }, |
| 4371 | { |
| 4372 | key: "scrollBehaviour", |
| 4373 | value: function value(e11) { |
| 4374 | if (this.config.disableScroll) { |
| 4375 | var t11 = document.querySelector("body"); |
| 4376 | switch(e11){ |
| 4377 | case "enable": |
| 4378 | Object.assign(t11.style, { |
| 4379 | overflow: "" |
| 4380 | }); |
| 4381 | break; |
| 4382 | case "disable": |
| 4383 | Object.assign(t11.style, { |
| 4384 | overflow: "hidden" |
| 4385 | }); |
| 4386 | } |
| 4387 | } |
| 4388 | } |
| 4389 | }, |
| 4390 | { |
| 4391 | key: "addEventListeners", |
| 4392 | value: function value() { |
| 4393 | this.modal.addEventListener("touchstart", this.onClick), this.modal.addEventListener("click", this.onClick), document.addEventListener("keydown", this.onKeydown); |
| 4394 | } |
| 4395 | }, |
| 4396 | { |
| 4397 | key: "removeEventListeners", |
| 4398 | value: function value() { |
| 4399 | this.modal.removeEventListener("touchstart", this.onClick), this.modal.removeEventListener("click", this.onClick), document.removeEventListener("keydown", this.onKeydown); |
| 4400 | } |
| 4401 | }, |
| 4402 | { |
| 4403 | key: "onClick", |
| 4404 | value: function value(e12) { |
| 4405 | (e12.target.hasAttribute(this.config.closeTrigger) || e12.target.parentNode.hasAttribute(this.config.closeTrigger)) && (e12.preventDefault(), e12.stopPropagation(), this.closeModal(e12)); |
| 4406 | } |
| 4407 | }, |
| 4408 | { |
| 4409 | key: "onKeydown", |
| 4410 | value: function value(e13) { |
| 4411 | 27 === e13.keyCode && this.closeModal(e13), 9 === e13.keyCode && this.retainFocus(e13); |
| 4412 | } |
| 4413 | }, |
| 4414 | { |
| 4415 | key: "getFocusableNodes", |
| 4416 | value: function value() { |
| 4417 | var _$e = this.modal.querySelectorAll(n); |
| 4418 | return Array.apply(void 0, t(_$e)); |
| 4419 | } |
| 4420 | }, |
| 4421 | { |
| 4422 | key: "setFocusToFirstNode", |
| 4423 | value: function value() { |
| 4424 | var _$e = this; |
| 4425 | if (!this.config.disableFocus) { |
| 4426 | var t12 = this.getFocusableNodes(); |
| 4427 | if (0 !== t12.length) { |
| 4428 | var _$o = t12.filter(function(t13) { |
| 4429 | return !t13.hasAttribute(_$e.config.closeTrigger); |
| 4430 | }); |
| 4431 | _$o.length > 0 && _$o[0].focus(), 0 === _$o.length && t12[0].focus(); |
| 4432 | } |
| 4433 | } |
| 4434 | } |
| 4435 | }, |
| 4436 | { |
| 4437 | key: "retainFocus", |
| 4438 | value: function value(e14) { |
| 4439 | var t14 = this.getFocusableNodes(); |
| 4440 | if (0 !== t14.length) { |
| 4441 | if (t14 = t14.filter(function(e15) { |
| 4442 | return null !== e15.offsetParent; |
| 4443 | }), this.modal.contains(document.activeElement)) { |
| 4444 | var _$o = t14.indexOf(document.activeElement); |
| 4445 | e14.shiftKey && 0 === _$o && (t14[t14.length - 1].focus(), e14.preventDefault()), !e14.shiftKey && t14.length > 0 && _$o === t14.length - 1 && (t14[0].focus(), e14.preventDefault()); |
| 4446 | } else t14[0].focus(); |
| 4447 | } |
| 4448 | } |
| 4449 | } |
| 4450 | ], e(i1.prototype, a1), r1 && e(i1, r1), o3; |
| 4451 | }(), a = null, r = function r(e16) { |
| 4452 | if (!document.getElementById(e16)) return console.warn("MicroModal: \u2757Seems like you have missed %c'".concat(e16, "'"), "background-color: #f8f9fa;color: #50596c;font-weight: bold;", "ID somewhere in your code. Refer example below to resolve it."), console.warn("%cExample:", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", '<div class="modal" id="'.concat(e16, '"></div>')), !1; |
| 4453 | }, s1 = function s1(e17, t15) { |
| 4454 | if (function(e18) { |
| 4455 | e18.length <= 0 && (console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", "data attribute."), console.warn("%cExample:", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", '<a href="#" data-micromodal-trigger="my-modal"></a>')); |
| 4456 | }(e17), !t15) return !0; |
| 4457 | for(var o4 in t15)r(o4); |
| 4458 | return !0; |
| 4459 | }, { |
| 4460 | init: function init(e19) { |
| 4461 | var o5 = Object.assign({}, { |
| 4462 | openTrigger: "data-micromodal-trigger" |
| 4463 | }, e19), n6 = t(document.querySelectorAll("[".concat(o5.openTrigger, "]"))), r = function(e20, t16) { |
| 4464 | var o6 = []; |
| 4465 | return e20.forEach(function(e21) { |
| 4466 | var n7 = e21.attributes[t16].value; |
| 4467 | void 0 === o6[n7] && (o6[n7] = []), o6[n7].push(e21); |
| 4468 | }), o6; |
| 4469 | }(n6, o5.openTrigger); |
| 4470 | if (!0 !== o5.debugMode || !1 !== s1(n6, r)) for(var l2 in r){ |
| 4471 | var c = r[l2]; |
| 4472 | o5.targetModal = l2, o5.triggers = t(c), a = new i(o5); |
| 4473 | } |
| 4474 | }, |
| 4475 | show: function show(e22, t17) { |
| 4476 | var o7 = t17 || {}; |
| 4477 | o7.targetModal = e22, !0 === o7.debugMode && !1 === r(e22) || (a && a.removeEventListeners(), (a = new i(o7)).showModal()); |
| 4478 | }, |
| 4479 | close: function close(e23) { |
| 4480 | e23 ? a.closeModalById(e23) : a.closeModal(); |
| 4481 | } |
| 4482 | }); |
| 4483 | "undefined" != typeof window && (window.MicroModal = l); |
| 4484 | exports.default = l; |
| 4485 | |
| 4486 | },{"@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"ibNcV":[function(require,module,exports) { |
| 4487 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4488 | parcelHelpers.defineInteropFlag(exports); |
| 4489 | parcelHelpers.export(exports, "default", function() { |
| 4490 | return _class; |
| 4491 | }); |
| 4492 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 4493 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 4494 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 4495 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 4496 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 4497 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 4498 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 4499 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 4500 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 4501 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 4502 | var _stimulus = require("@hotwired/stimulus"); |
| 4503 | var _micromodal = require("micromodal"); |
| 4504 | var _micromodalDefault = parcelHelpers.interopDefault(_micromodal); |
| 4505 | document.addEventListener("DOMContentLoaded", function() { |
| 4506 | return (0, _micromodalDefault.default).init(); |
| 4507 | }); |
| 4508 | var _class = /*#__PURE__*/ function(Controller) { |
| 4509 | "use strict"; |
| 4510 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 4511 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 4512 | function _class() { |
| 4513 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 4514 | return _super.apply(this, arguments); |
| 4515 | } |
| 4516 | (0, _createClassJsDefault.default)(_class, [ |
| 4517 | { |
| 4518 | key: "isValidConfirmation", |
| 4519 | value: function isValidConfirmation(confirmationValue) { |
| 4520 | return confirmationValue.toLowerCase() === "delete all data"; |
| 4521 | } |
| 4522 | }, |
| 4523 | { |
| 4524 | key: "confirmationValueChanged", |
| 4525 | value: function confirmationValueChanged(confirmationValue) { |
| 4526 | this.inputTarget.value = confirmationValue; |
| 4527 | var disable = !this.isValidConfirmation(confirmationValue); |
| 4528 | this.submitTarget.toggleAttribute("disabled", disable); |
| 4529 | } |
| 4530 | }, |
| 4531 | { |
| 4532 | key: "updateConfirmation", |
| 4533 | value: function updateConfirmation(e) { |
| 4534 | this.confirmationValue = e.target.value; |
| 4535 | } |
| 4536 | }, |
| 4537 | { |
| 4538 | key: "open", |
| 4539 | value: function open() { |
| 4540 | this.confirmationValue = ""; |
| 4541 | (0, _micromodalDefault.default).show("delete-data-modal"); |
| 4542 | } |
| 4543 | }, |
| 4544 | { |
| 4545 | key: "close", |
| 4546 | value: function close(e) { |
| 4547 | if (e.target !== e.currentTarget) return; |
| 4548 | (0, _micromodalDefault.default).close("delete-data-modal"); |
| 4549 | } |
| 4550 | }, |
| 4551 | { |
| 4552 | key: "submit", |
| 4553 | value: function submit(e) { |
| 4554 | e.preventDefault(); |
| 4555 | if (!this.isValidConfirmation(this.confirmationValue)) return; |
| 4556 | var data = { |
| 4557 | action: "iawp_delete_data", |
| 4558 | delete_data_nonce: IAWP_DELETE_DATA_NONCE, |
| 4559 | confirmation: this.confirmationValue |
| 4560 | }; |
| 4561 | this.submitTarget.setAttribute("disabled", "disabled"); |
| 4562 | this.submitTarget.textContent = "Deleting data..."; |
| 4563 | jQuery.post(ajaxurl, data, function(response) { |
| 4564 | setTimeout(function() { |
| 4565 | document.location.reload(); |
| 4566 | }, 500); |
| 4567 | }); |
| 4568 | } |
| 4569 | } |
| 4570 | ]); |
| 4571 | return _class; |
| 4572 | }((0, _stimulus.Controller)); |
| 4573 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 4574 | confirmation: String |
| 4575 | }); |
| 4576 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 4577 | "submit", |
| 4578 | "input" |
| 4579 | ]); |
| 4580 | |
| 4581 | },{"@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","micromodal":"dW4sP","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"hrjuy":[function(require,module,exports) { |
| 4582 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4583 | parcelHelpers.defineInteropFlag(exports); |
| 4584 | parcelHelpers.export(exports, "default", function() { |
| 4585 | return _class; |
| 4586 | }); |
| 4587 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 4588 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 4589 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 4590 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 4591 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 4592 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 4593 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 4594 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 4595 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 4596 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 4597 | var _stimulus = require("@hotwired/stimulus"); |
| 4598 | var _corsairPlugin = require("../chart_plugins/corsair_plugin"); |
| 4599 | var _corsairPluginDefault = parcelHelpers.interopDefault(_corsairPlugin); |
| 4600 | var _htmlLegendPlugin = require("../chart_plugins/html_legend_plugin"); |
| 4601 | var _htmlLegendPluginDefault = parcelHelpers.interopDefault(_htmlLegendPlugin); |
| 4602 | var _class = /*#__PURE__*/ function(Controller) { |
| 4603 | "use strict"; |
| 4604 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 4605 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 4606 | function _class() { |
| 4607 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 4608 | return _super.apply(this, arguments); |
| 4609 | } |
| 4610 | (0, _createClassJsDefault.default)(_class, [ |
| 4611 | { |
| 4612 | key: "connect", |
| 4613 | value: function connect() { |
| 4614 | Chart.defaults.font.family = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'; |
| 4615 | var labels = this.labelsValue; |
| 4616 | var data = { |
| 4617 | labels: labels, |
| 4618 | datasets: [ |
| 4619 | { |
| 4620 | label: "Views", |
| 4621 | data: this.viewsValue, |
| 4622 | borderColor: "rgba(108,70,174,1)", |
| 4623 | fill: true, |
| 4624 | backgroundColor: "rgba(108,70,174,0.2)", |
| 4625 | pointBackgroundColor: "rgba(108,70,174,1)", |
| 4626 | tension: 0.4 |
| 4627 | }, |
| 4628 | { |
| 4629 | label: "Visitors", |
| 4630 | data: this.visitorsValue, |
| 4631 | borderColor: "rgba(246,157,10,1)", |
| 4632 | fill: true, |
| 4633 | backgroundColor: "rgba(246,157,10,0.2)", |
| 4634 | pointBackgroundColor: "rgba(246,157,10,1)", |
| 4635 | tension: 0.4 |
| 4636 | } |
| 4637 | ] |
| 4638 | }; |
| 4639 | var options = { |
| 4640 | animation: { |
| 4641 | duration: 0 |
| 4642 | }, |
| 4643 | interaction: { |
| 4644 | intersect: false, |
| 4645 | mode: "index" |
| 4646 | }, |
| 4647 | scales: { |
| 4648 | y: { |
| 4649 | grid: { |
| 4650 | borderColor: "#DEDAE6", |
| 4651 | tickColor: "#DEDAE6", |
| 4652 | display: true, |
| 4653 | drawOnChartArea: true, |
| 4654 | borderDash: [ |
| 4655 | 2, |
| 4656 | 4 |
| 4657 | ] |
| 4658 | }, |
| 4659 | beginAtZero: true, |
| 4660 | suggestedMax: 10, |
| 4661 | // grace: '26%', |
| 4662 | ticks: { |
| 4663 | color: this.modeValue === "dark" ? "#ffffff" : "#6D6A73", |
| 4664 | font: { |
| 4665 | size: 14, |
| 4666 | weight: 400 |
| 4667 | }, |
| 4668 | precision: 0 |
| 4669 | } |
| 4670 | }, |
| 4671 | x: { |
| 4672 | grid: { |
| 4673 | borderColor: "#DEDAE6", |
| 4674 | tickColor: "#DEDAE6", |
| 4675 | display: true, |
| 4676 | drawOnChartArea: false |
| 4677 | }, |
| 4678 | ticks: { |
| 4679 | color: this.modeValue === "dark" ? "#ffffff" : "#6D6A73", |
| 4680 | autoSkip: true, |
| 4681 | autoSkipPadding: 16, |
| 4682 | maxRotation: 0, |
| 4683 | // maxTicksLimit: 20, |
| 4684 | font: { |
| 4685 | size: 14, |
| 4686 | weight: 400 |
| 4687 | }, |
| 4688 | callback: function callback(value, index, values) { |
| 4689 | var label = this.getLabelForValue(value); |
| 4690 | return label.split(" - ")[0]; |
| 4691 | } |
| 4692 | } |
| 4693 | } |
| 4694 | }, |
| 4695 | plugins: { |
| 4696 | mode: String, |
| 4697 | htmlLegend: { |
| 4698 | // ID of the container to put the legend in |
| 4699 | containerID: "legend-container" |
| 4700 | }, |
| 4701 | legend: { |
| 4702 | display: false |
| 4703 | }, |
| 4704 | corsair: { |
| 4705 | // disabled: true, |
| 4706 | dash: [ |
| 4707 | 2, |
| 4708 | 4 |
| 4709 | ], |
| 4710 | color: "#777", |
| 4711 | width: 1 |
| 4712 | } |
| 4713 | }, |
| 4714 | elements: { |
| 4715 | point: { |
| 4716 | radius: 4 |
| 4717 | } |
| 4718 | } |
| 4719 | }; |
| 4720 | var config = { |
| 4721 | type: "line", |
| 4722 | data: data, |
| 4723 | options: options, |
| 4724 | plugins: [ |
| 4725 | (0, _htmlLegendPluginDefault.default), |
| 4726 | (0, _corsairPluginDefault.default) |
| 4727 | ] |
| 4728 | }; |
| 4729 | var canvas = document.getElementById("myChart"); |
| 4730 | var myChart = new Chart(canvas, config); |
| 4731 | } |
| 4732 | } |
| 4733 | ]); |
| 4734 | return _class; |
| 4735 | }((0, _stimulus.Controller)); |
| 4736 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 4737 | mode: String, |
| 4738 | labels: Array, |
| 4739 | views: Array, |
| 4740 | visitors: Array |
| 4741 | }); |
| 4742 | |
| 4743 | },{"@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","../chart_plugins/corsair_plugin":"8YKyT","../chart_plugins/html_legend_plugin":"dVdIk","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"8YKyT":[function(require,module,exports) { |
| 4744 | module.exports = { |
| 4745 | id: "corsair", |
| 4746 | afterInit: function(chart, _, opts) { |
| 4747 | if (opts.disabled) return; |
| 4748 | chart.corsair = { |
| 4749 | x: 0, |
| 4750 | y: 0 |
| 4751 | }; |
| 4752 | }, |
| 4753 | afterEvent: function(chart, evt, opts) { |
| 4754 | if (opts.disabled) return; |
| 4755 | var _chartArea = chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom, left = _chartArea.left, right = _chartArea.right; |
| 4756 | var _event = evt.event, x = _event.x, y = _event.y; |
| 4757 | if (x < left || x > right || y < top || y > bottom) { |
| 4758 | chart.corsair = { |
| 4759 | x: x, |
| 4760 | y: y, |
| 4761 | draw: false |
| 4762 | }; |
| 4763 | chart.draw(); |
| 4764 | return; |
| 4765 | } |
| 4766 | chart.corsair = { |
| 4767 | x: x, |
| 4768 | y: y, |
| 4769 | draw: true |
| 4770 | }; |
| 4771 | chart.draw(); |
| 4772 | }, |
| 4773 | afterDatasetsDraw: function(chart, _, opts) { |
| 4774 | if (opts.disabled) return; |
| 4775 | var ctx = chart.ctx, _chartArea = chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom, left = _chartArea.left, right = _chartArea.right; |
| 4776 | var _corsair = chart.corsair, x = _corsair.x, y = _corsair.y, draw = _corsair.draw; |
| 4777 | if (!draw) return; |
| 4778 | // console.log(chart); |
| 4779 | x = chart.tooltip.caretX; |
| 4780 | ctx.lineWidth = opts.width || 0; |
| 4781 | // // Todo - Why does dash fuck up dots? |
| 4782 | ctx.setLineDash(opts.dash || []); |
| 4783 | ctx.strokeStyle = opts.color || "black"; |
| 4784 | ctx.save(); |
| 4785 | ctx.beginPath(); |
| 4786 | ctx.moveTo(x, bottom); |
| 4787 | ctx.lineTo(x, top); |
| 4788 | // Uncomment these 2 lines to add horizontal line |
| 4789 | // ctx.moveTo(left, y); |
| 4790 | // ctx.lineTo(right, y); |
| 4791 | ctx.stroke(); |
| 4792 | ctx.restore(); |
| 4793 | ctx.setLineDash([]); |
| 4794 | } |
| 4795 | }; |
| 4796 | |
| 4797 | },{}],"dVdIk":[function(require,module,exports) { |
| 4798 | module.exports = { |
| 4799 | id: "htmlLegend", |
| 4800 | afterUpdate: function(chart, args, options) { |
| 4801 | var legendContainer = document.getElementById(options.containerID); |
| 4802 | var legendList = legendContainer.querySelector("ul"); |
| 4803 | // Create a list as needed |
| 4804 | if (!legendList) { |
| 4805 | legendList = document.createElement("ul"); |
| 4806 | legendList.classList.add("legend-list"); |
| 4807 | legendContainer.appendChild(legendList); |
| 4808 | } |
| 4809 | // Remove old legend items |
| 4810 | while(legendList.firstChild)legendList.firstChild.remove(); |
| 4811 | // Reuse the built-in legendItems generator |
| 4812 | var items = chart.options.plugins.legend.labels.generateLabels(chart); |
| 4813 | items.forEach(function(legendData) { |
| 4814 | var legendID = legendData.text.toLowerCase(); |
| 4815 | var li = document.createElement("li"); |
| 4816 | li.onclick = function() { |
| 4817 | var type = chart.config.type; |
| 4818 | if (type === "pie" || type === "doughnut") // Pie and doughnut charts only have a single dataset and visibility is per item |
| 4819 | chart.toggleDataVisibility(legendData.index); |
| 4820 | else chart.setDatasetVisibility(legendData.datasetIndex, !chart.isDatasetVisible(legendData.datasetIndex)); |
| 4821 | chart.update(); |
| 4822 | }; |
| 4823 | li.classList.add("legend-item", "legend-item-for-".concat(legendID)); |
| 4824 | if (legendData.hidden) li.classList.add("hidden"); |
| 4825 | // Color box |
| 4826 | var boxSpan = document.createElement("span"); |
| 4827 | // Text |
| 4828 | var textContainer = document.createElement("p"); |
| 4829 | textContainer.textContent = legendData.text; |
| 4830 | li.appendChild(boxSpan); |
| 4831 | li.appendChild(textContainer); |
| 4832 | legendList.appendChild(li); |
| 4833 | }); |
| 4834 | } |
| 4835 | }; |
| 4836 | |
| 4837 | },{}]},["2CYCe"], "2CYCe", "parcelRequirec571") |
| 4838 | |
| 4839 | //# sourceMappingURL=index.js.map |
| 4840 |