dashboard_widget.js
3 years ago
dashboard_widget.js.map
3 years ago
data-table.js
3 years ago
data-table.js.map
3 years ago
index.js
3 years ago
index.js.map
3 years ago
learn.js
3 years ago
learn.js.map
3 years ago
settings.js
3 years ago
settings.js.map
3 years ago
index.js
8529 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 _chartController = require("./controllers/chart_controller"); |
| 151 | var _chartControllerDefault = parcelHelpers.interopDefault(_chartController); |
| 152 | var _chartGeoController = require("./controllers/chart_geo_controller"); |
| 153 | var _chartGeoControllerDefault = parcelHelpers.interopDefault(_chartGeoController); |
| 154 | var _columnsController = require("./controllers/columns_controller"); |
| 155 | var _columnsControllerDefault = parcelHelpers.interopDefault(_columnsController); |
| 156 | var _datesController = require("./controllers/dates_controller"); |
| 157 | var _datesControllerDefault = parcelHelpers.interopDefault(_datesController); |
| 158 | var _deleteDataController = require("./controllers/delete_data_controller"); |
| 159 | var _deleteDataControllerDefault = parcelHelpers.interopDefault(_deleteDataController); |
| 160 | var _easepickController = require("./controllers/easepick_controller"); |
| 161 | var _easepickControllerDefault = parcelHelpers.interopDefault(_easepickController); |
| 162 | var _filtersController = require("./controllers/filters_controller"); |
| 163 | var _filtersControllerDefault = parcelHelpers.interopDefault(_filtersController); |
| 164 | var _migrationRedirectController = require("./controllers/migration_redirect_controller"); |
| 165 | var _migrationRedirectControllerDefault = parcelHelpers.interopDefault(_migrationRedirectController); |
| 166 | var _reportController = require("./controllers/report_controller"); |
| 167 | var _reportControllerDefault = parcelHelpers.interopDefault(_reportController); |
| 168 | var _sortController = require("./controllers/sort_controller"); |
| 169 | var _sortControllerDefault = parcelHelpers.interopDefault(_sortController); |
| 170 | document.addEventListener("DOMContentLoaded", function() { |
| 171 | return (0, _micromodalDefault.default).init(); |
| 172 | }); |
| 173 | window.Stimulus = (0, _stimulus.Application).start(); |
| 174 | Stimulus.register("chart", (0, _chartControllerDefault.default)); |
| 175 | Stimulus.register("chart-geo", (0, _chartGeoControllerDefault.default)); |
| 176 | Stimulus.register("columns", (0, _columnsControllerDefault.default)); |
| 177 | Stimulus.register("dates", (0, _datesControllerDefault.default)); |
| 178 | Stimulus.register("delete-data", (0, _deleteDataControllerDefault.default)); |
| 179 | Stimulus.register("easepick", (0, _easepickControllerDefault.default)); |
| 180 | Stimulus.register("filters", (0, _filtersControllerDefault.default)); |
| 181 | Stimulus.register("migration-redirect", (0, _migrationRedirectControllerDefault.default)); |
| 182 | Stimulus.register("report", (0, _reportControllerDefault.default)); |
| 183 | Stimulus.register("sort", (0, _sortControllerDefault.default)); |
| 184 | |
| 185 | },{"@hotwired/stimulus":"27q4D","micromodal":"dW4sP","./controllers/chart_controller":"hrjuy","./controllers/chart_geo_controller":"1zYz5","./controllers/columns_controller":"6VC2X","./controllers/dates_controller":"cVUgd","./controllers/delete_data_controller":"ibNcV","./controllers/easepick_controller":"8ZFae","./controllers/filters_controller":"hlRZI","./controllers/migration_redirect_controller":"70LeQ","./controllers/report_controller":"hn7Px","./controllers/sort_controller":"5eVCV","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"27q4D":[function(require,module,exports) { |
| 186 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 187 | parcelHelpers.defineInteropFlag(exports); |
| 188 | parcelHelpers.export(exports, "Application", function() { |
| 189 | return Application; |
| 190 | }); |
| 191 | parcelHelpers.export(exports, "AttributeObserver", function() { |
| 192 | return AttributeObserver; |
| 193 | }); |
| 194 | parcelHelpers.export(exports, "Context", function() { |
| 195 | return Context; |
| 196 | }); |
| 197 | parcelHelpers.export(exports, "Controller", function() { |
| 198 | return Controller; |
| 199 | }); |
| 200 | parcelHelpers.export(exports, "ElementObserver", function() { |
| 201 | return ElementObserver; |
| 202 | }); |
| 203 | parcelHelpers.export(exports, "IndexedMultimap", function() { |
| 204 | return IndexedMultimap; |
| 205 | }); |
| 206 | parcelHelpers.export(exports, "Multimap", function() { |
| 207 | return Multimap; |
| 208 | }); |
| 209 | parcelHelpers.export(exports, "StringMapObserver", function() { |
| 210 | return StringMapObserver; |
| 211 | }); |
| 212 | parcelHelpers.export(exports, "TokenListObserver", function() { |
| 213 | return TokenListObserver; |
| 214 | }); |
| 215 | parcelHelpers.export(exports, "ValueListObserver", function() { |
| 216 | return ValueListObserver; |
| 217 | }); |
| 218 | parcelHelpers.export(exports, "add", function() { |
| 219 | return add; |
| 220 | }); |
| 221 | parcelHelpers.export(exports, "defaultSchema", function() { |
| 222 | return defaultSchema; |
| 223 | }); |
| 224 | parcelHelpers.export(exports, "del", function() { |
| 225 | return del; |
| 226 | }); |
| 227 | parcelHelpers.export(exports, "fetch", function() { |
| 228 | return fetch; |
| 229 | }); |
| 230 | parcelHelpers.export(exports, "prune", function() { |
| 231 | return prune; |
| 232 | }); |
| 233 | var _asyncToGeneratorJs = require("@swc/helpers/lib/_async_to_generator.js"); |
| 234 | var _asyncToGeneratorJsDefault = parcelHelpers.interopDefault(_asyncToGeneratorJs); |
| 235 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 236 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 237 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 238 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 239 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 240 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 241 | var _getJs = require("@swc/helpers/lib/_get.js"); |
| 242 | var _getJsDefault = parcelHelpers.interopDefault(_getJs); |
| 243 | var _getPrototypeOfJs = require("@swc/helpers/lib/_get_prototype_of.js"); |
| 244 | var _getPrototypeOfJsDefault = parcelHelpers.interopDefault(_getPrototypeOfJs); |
| 245 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 246 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 247 | var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js"); |
| 248 | var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs); |
| 249 | var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js"); |
| 250 | var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs); |
| 251 | var _typeOfJs = require("@swc/helpers/lib/_type_of.js"); |
| 252 | var _typeOfJsDefault = parcelHelpers.interopDefault(_typeOfJs); |
| 253 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 254 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 255 | var _regeneratorRuntime = require("regenerator-runtime"); |
| 256 | var _regeneratorRuntimeDefault = parcelHelpers.interopDefault(_regeneratorRuntime); |
| 257 | /* |
| 258 | Stimulus 3.0.1 |
| 259 | Copyright © 2021 Basecamp, LLC |
| 260 | */ var EventListener = /*#__PURE__*/ function() { |
| 261 | "use strict"; |
| 262 | function EventListener(eventTarget, eventName, eventOptions) { |
| 263 | (0, _classCallCheckJsDefault.default)(this, EventListener); |
| 264 | this.eventTarget = eventTarget; |
| 265 | this.eventName = eventName; |
| 266 | this.eventOptions = eventOptions; |
| 267 | this.unorderedBindings = new Set(); |
| 268 | } |
| 269 | (0, _createClassJsDefault.default)(EventListener, [ |
| 270 | { |
| 271 | key: "connect", |
| 272 | value: function connect() { |
| 273 | this.eventTarget.addEventListener(this.eventName, this, this.eventOptions); |
| 274 | } |
| 275 | }, |
| 276 | { |
| 277 | key: "disconnect", |
| 278 | value: function disconnect() { |
| 279 | this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions); |
| 280 | } |
| 281 | }, |
| 282 | { |
| 283 | key: "bindingConnected", |
| 284 | value: function bindingConnected(binding) { |
| 285 | this.unorderedBindings.add(binding); |
| 286 | } |
| 287 | }, |
| 288 | { |
| 289 | key: "bindingDisconnected", |
| 290 | value: function bindingDisconnected(binding) { |
| 291 | this.unorderedBindings.delete(binding); |
| 292 | } |
| 293 | }, |
| 294 | { |
| 295 | key: "handleEvent", |
| 296 | value: function handleEvent(event) { |
| 297 | var extendedEvent = extendEvent(event); |
| 298 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 299 | try { |
| 300 | for(var _iterator = this.bindings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 301 | var binding = _step.value; |
| 302 | if (extendedEvent.immediatePropagationStopped) break; |
| 303 | else binding.handleEvent(extendedEvent); |
| 304 | } |
| 305 | } catch (err) { |
| 306 | _didIteratorError = true; |
| 307 | _iteratorError = err; |
| 308 | } finally{ |
| 309 | try { |
| 310 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 311 | _iterator.return(); |
| 312 | } |
| 313 | } finally{ |
| 314 | if (_didIteratorError) { |
| 315 | throw _iteratorError; |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | }, |
| 321 | { |
| 322 | key: "bindings", |
| 323 | get: function get() { |
| 324 | return Array.from(this.unorderedBindings).sort(function(left, right) { |
| 325 | var leftIndex = left.index, rightIndex = right.index; |
| 326 | return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0; |
| 327 | }); |
| 328 | } |
| 329 | } |
| 330 | ]); |
| 331 | return EventListener; |
| 332 | }(); |
| 333 | function extendEvent(event) { |
| 334 | if ("immediatePropagationStopped" in event) return event; |
| 335 | else { |
| 336 | var stopImmediatePropagation = event.stopImmediatePropagation; |
| 337 | return Object.assign(event, { |
| 338 | immediatePropagationStopped: false, |
| 339 | stopImmediatePropagation: function() { |
| 340 | this.immediatePropagationStopped = true; |
| 341 | stopImmediatePropagation.call(this); |
| 342 | } |
| 343 | }); |
| 344 | } |
| 345 | } |
| 346 | var Dispatcher = /*#__PURE__*/ function() { |
| 347 | "use strict"; |
| 348 | function Dispatcher(application) { |
| 349 | (0, _classCallCheckJsDefault.default)(this, Dispatcher); |
| 350 | this.application = application; |
| 351 | this.eventListenerMaps = new Map; |
| 352 | this.started = false; |
| 353 | } |
| 354 | (0, _createClassJsDefault.default)(Dispatcher, [ |
| 355 | { |
| 356 | key: "start", |
| 357 | value: function start() { |
| 358 | if (!this.started) { |
| 359 | this.started = true; |
| 360 | this.eventListeners.forEach(function(eventListener) { |
| 361 | return eventListener.connect(); |
| 362 | }); |
| 363 | } |
| 364 | } |
| 365 | }, |
| 366 | { |
| 367 | key: "stop", |
| 368 | value: function stop() { |
| 369 | if (this.started) { |
| 370 | this.started = false; |
| 371 | this.eventListeners.forEach(function(eventListener) { |
| 372 | return eventListener.disconnect(); |
| 373 | }); |
| 374 | } |
| 375 | } |
| 376 | }, |
| 377 | { |
| 378 | key: "eventListeners", |
| 379 | get: function get() { |
| 380 | return Array.from(this.eventListenerMaps.values()).reduce(function(listeners, map) { |
| 381 | return listeners.concat(Array.from(map.values())); |
| 382 | }, []); |
| 383 | } |
| 384 | }, |
| 385 | { |
| 386 | key: "bindingConnected", |
| 387 | value: function bindingConnected(binding) { |
| 388 | this.fetchEventListenerForBinding(binding).bindingConnected(binding); |
| 389 | } |
| 390 | }, |
| 391 | { |
| 392 | key: "bindingDisconnected", |
| 393 | value: function bindingDisconnected(binding) { |
| 394 | this.fetchEventListenerForBinding(binding).bindingDisconnected(binding); |
| 395 | } |
| 396 | }, |
| 397 | { |
| 398 | key: "handleError", |
| 399 | value: function handleError(error1, message) { |
| 400 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 401 | this.application.handleError(error1, "Error ".concat(message), detail); |
| 402 | } |
| 403 | }, |
| 404 | { |
| 405 | key: "fetchEventListenerForBinding", |
| 406 | value: function fetchEventListenerForBinding(binding) { |
| 407 | var eventTarget = binding.eventTarget, eventName = binding.eventName, eventOptions = binding.eventOptions; |
| 408 | return this.fetchEventListener(eventTarget, eventName, eventOptions); |
| 409 | } |
| 410 | }, |
| 411 | { |
| 412 | key: "fetchEventListener", |
| 413 | value: function fetchEventListener(eventTarget, eventName, eventOptions) { |
| 414 | var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); |
| 415 | var cacheKey = this.cacheKey(eventName, eventOptions); |
| 416 | var eventListener = eventListenerMap.get(cacheKey); |
| 417 | if (!eventListener) { |
| 418 | eventListener = this.createEventListener(eventTarget, eventName, eventOptions); |
| 419 | eventListenerMap.set(cacheKey, eventListener); |
| 420 | } |
| 421 | return eventListener; |
| 422 | } |
| 423 | }, |
| 424 | { |
| 425 | key: "createEventListener", |
| 426 | value: function createEventListener(eventTarget, eventName, eventOptions) { |
| 427 | var eventListener = new EventListener(eventTarget, eventName, eventOptions); |
| 428 | if (this.started) eventListener.connect(); |
| 429 | return eventListener; |
| 430 | } |
| 431 | }, |
| 432 | { |
| 433 | key: "fetchEventListenerMapForEventTarget", |
| 434 | value: function fetchEventListenerMapForEventTarget(eventTarget) { |
| 435 | var eventListenerMap = this.eventListenerMaps.get(eventTarget); |
| 436 | if (!eventListenerMap) { |
| 437 | eventListenerMap = new Map; |
| 438 | this.eventListenerMaps.set(eventTarget, eventListenerMap); |
| 439 | } |
| 440 | return eventListenerMap; |
| 441 | } |
| 442 | }, |
| 443 | { |
| 444 | key: "cacheKey", |
| 445 | value: function cacheKey(eventName, eventOptions) { |
| 446 | var parts = [ |
| 447 | eventName |
| 448 | ]; |
| 449 | Object.keys(eventOptions).sort().forEach(function(key) { |
| 450 | parts.push("".concat(eventOptions[key] ? "" : "!").concat(key)); |
| 451 | }); |
| 452 | return parts.join(":"); |
| 453 | } |
| 454 | } |
| 455 | ]); |
| 456 | return Dispatcher; |
| 457 | }(); |
| 458 | var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/; |
| 459 | function parseActionDescriptorString(descriptorString) { |
| 460 | var source = descriptorString.trim(); |
| 461 | var matches = source.match(descriptorPattern) || []; |
| 462 | return { |
| 463 | eventTarget: parseEventTarget(matches[4]), |
| 464 | eventName: matches[2], |
| 465 | eventOptions: matches[9] ? parseEventOptions(matches[9]) : {}, |
| 466 | identifier: matches[5], |
| 467 | methodName: matches[7] |
| 468 | }; |
| 469 | } |
| 470 | function parseEventTarget(eventTargetName) { |
| 471 | if (eventTargetName == "window") return window; |
| 472 | else if (eventTargetName == "document") return document; |
| 473 | } |
| 474 | function parseEventOptions(eventOptions) { |
| 475 | return eventOptions.split(":").reduce(function(options, token) { |
| 476 | return Object.assign(options, (0, _definePropertyJsDefault.default)({}, token.replace(/^!/, ""), !/^!/.test(token))); |
| 477 | }, {}); |
| 478 | } |
| 479 | function stringifyEventTarget(eventTarget) { |
| 480 | if (eventTarget == window) return "window"; |
| 481 | else if (eventTarget == document) return "document"; |
| 482 | } |
| 483 | function camelize(value) { |
| 484 | return value.replace(/(?:[_-])([a-z0-9])/g, function(_, char) { |
| 485 | return char.toUpperCase(); |
| 486 | }); |
| 487 | } |
| 488 | function capitalize(value) { |
| 489 | return value.charAt(0).toUpperCase() + value.slice(1); |
| 490 | } |
| 491 | function dasherize(value) { |
| 492 | return value.replace(/([A-Z])/g, function(_, char) { |
| 493 | return "-".concat(char.toLowerCase()); |
| 494 | }); |
| 495 | } |
| 496 | function tokenize(value) { |
| 497 | return value.match(/[^\s]+/g) || []; |
| 498 | } |
| 499 | var Action = /*#__PURE__*/ function() { |
| 500 | "use strict"; |
| 501 | function Action(element, index, descriptor) { |
| 502 | (0, _classCallCheckJsDefault.default)(this, Action); |
| 503 | this.element = element; |
| 504 | this.index = index; |
| 505 | this.eventTarget = descriptor.eventTarget || element; |
| 506 | this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name"); |
| 507 | this.eventOptions = descriptor.eventOptions || {}; |
| 508 | this.identifier = descriptor.identifier || error("missing identifier"); |
| 509 | this.methodName = descriptor.methodName || error("missing method name"); |
| 510 | } |
| 511 | (0, _createClassJsDefault.default)(Action, [ |
| 512 | { |
| 513 | key: "toString", |
| 514 | value: function toString() { |
| 515 | var eventNameSuffix = this.eventTargetName ? "@".concat(this.eventTargetName) : ""; |
| 516 | return "".concat(this.eventName).concat(eventNameSuffix, "->").concat(this.identifier, "#").concat(this.methodName); |
| 517 | } |
| 518 | }, |
| 519 | { |
| 520 | key: "params", |
| 521 | get: function get() { |
| 522 | if (this.eventTarget instanceof Element) return this.getParamsFromEventTargetAttributes(this.eventTarget); |
| 523 | else return {}; |
| 524 | } |
| 525 | }, |
| 526 | { |
| 527 | key: "getParamsFromEventTargetAttributes", |
| 528 | value: function getParamsFromEventTargetAttributes(eventTarget) { |
| 529 | var params = {}; |
| 530 | var pattern = new RegExp("^data-".concat(this.identifier, "-(.+)-param$")); |
| 531 | var attributes = Array.from(eventTarget.attributes); |
| 532 | attributes.forEach(function(param) { |
| 533 | var name = param.name, value = param.value; |
| 534 | var match = name.match(pattern); |
| 535 | var key = match && match[1]; |
| 536 | if (key) Object.assign(params, (0, _definePropertyJsDefault.default)({}, camelize(key), typecast(value))); |
| 537 | }); |
| 538 | return params; |
| 539 | } |
| 540 | }, |
| 541 | { |
| 542 | key: "eventTargetName", |
| 543 | get: function get() { |
| 544 | return stringifyEventTarget(this.eventTarget); |
| 545 | } |
| 546 | } |
| 547 | ], [ |
| 548 | { |
| 549 | key: "forToken", |
| 550 | value: function forToken(token) { |
| 551 | return new this(token.element, token.index, parseActionDescriptorString(token.content)); |
| 552 | } |
| 553 | } |
| 554 | ]); |
| 555 | return Action; |
| 556 | }(); |
| 557 | var defaultEventNames = { |
| 558 | "a": function(e) { |
| 559 | return "click"; |
| 560 | }, |
| 561 | "button": function(e) { |
| 562 | return "click"; |
| 563 | }, |
| 564 | "form": function(e) { |
| 565 | return "submit"; |
| 566 | }, |
| 567 | "details": function(e) { |
| 568 | return "toggle"; |
| 569 | }, |
| 570 | "input": function(e) { |
| 571 | return e.getAttribute("type") == "submit" ? "click" : "input"; |
| 572 | }, |
| 573 | "select": function(e) { |
| 574 | return "change"; |
| 575 | }, |
| 576 | "textarea": function(e) { |
| 577 | return "input"; |
| 578 | } |
| 579 | }; |
| 580 | function getDefaultEventNameForElement(element) { |
| 581 | var tagName = element.tagName.toLowerCase(); |
| 582 | if (tagName in defaultEventNames) return defaultEventNames[tagName](element); |
| 583 | } |
| 584 | function error(message) { |
| 585 | throw new Error(message); |
| 586 | } |
| 587 | function typecast(value) { |
| 588 | try { |
| 589 | return JSON.parse(value); |
| 590 | } catch (o_O) { |
| 591 | return value; |
| 592 | } |
| 593 | } |
| 594 | var Binding = /*#__PURE__*/ function() { |
| 595 | "use strict"; |
| 596 | function Binding(context, action) { |
| 597 | (0, _classCallCheckJsDefault.default)(this, Binding); |
| 598 | this.context = context; |
| 599 | this.action = action; |
| 600 | } |
| 601 | (0, _createClassJsDefault.default)(Binding, [ |
| 602 | { |
| 603 | key: "index", |
| 604 | get: function get() { |
| 605 | return this.action.index; |
| 606 | } |
| 607 | }, |
| 608 | { |
| 609 | key: "eventTarget", |
| 610 | get: function get() { |
| 611 | return this.action.eventTarget; |
| 612 | } |
| 613 | }, |
| 614 | { |
| 615 | key: "eventOptions", |
| 616 | get: function get() { |
| 617 | return this.action.eventOptions; |
| 618 | } |
| 619 | }, |
| 620 | { |
| 621 | key: "identifier", |
| 622 | get: function get() { |
| 623 | return this.context.identifier; |
| 624 | } |
| 625 | }, |
| 626 | { |
| 627 | key: "handleEvent", |
| 628 | value: function handleEvent(event) { |
| 629 | if (this.willBeInvokedByEvent(event)) this.invokeWithEvent(event); |
| 630 | } |
| 631 | }, |
| 632 | { |
| 633 | key: "eventName", |
| 634 | get: function get() { |
| 635 | return this.action.eventName; |
| 636 | } |
| 637 | }, |
| 638 | { |
| 639 | key: "method", |
| 640 | get: function get() { |
| 641 | var method = this.controller[this.methodName]; |
| 642 | if (typeof method == "function") return method; |
| 643 | throw new Error('Action "'.concat(this.action, '" references undefined method "').concat(this.methodName, '"')); |
| 644 | } |
| 645 | }, |
| 646 | { |
| 647 | key: "invokeWithEvent", |
| 648 | value: function invokeWithEvent(event) { |
| 649 | var target = event.target, currentTarget = event.currentTarget; |
| 650 | try { |
| 651 | var params = this.action.params; |
| 652 | var actionEvent = Object.assign(event, { |
| 653 | params: params |
| 654 | }); |
| 655 | this.method.call(this.controller, actionEvent); |
| 656 | this.context.logDebugActivity(this.methodName, { |
| 657 | event: event, |
| 658 | target: target, |
| 659 | currentTarget: currentTarget, |
| 660 | action: this.methodName |
| 661 | }); |
| 662 | } catch (error2) { |
| 663 | var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element, index = ref.index; |
| 664 | var detail = { |
| 665 | identifier: identifier, |
| 666 | controller: controller, |
| 667 | element: element, |
| 668 | index: index, |
| 669 | event: event |
| 670 | }; |
| 671 | this.context.handleError(error2, 'invoking action "'.concat(this.action, '"'), detail); |
| 672 | } |
| 673 | } |
| 674 | }, |
| 675 | { |
| 676 | key: "willBeInvokedByEvent", |
| 677 | value: function willBeInvokedByEvent(event) { |
| 678 | var eventTarget = event.target; |
| 679 | if (this.element === eventTarget) return true; |
| 680 | else if (eventTarget instanceof Element && this.element.contains(eventTarget)) return this.scope.containsElement(eventTarget); |
| 681 | else return this.scope.containsElement(this.action.element); |
| 682 | } |
| 683 | }, |
| 684 | { |
| 685 | key: "controller", |
| 686 | get: function get() { |
| 687 | return this.context.controller; |
| 688 | } |
| 689 | }, |
| 690 | { |
| 691 | key: "methodName", |
| 692 | get: function get() { |
| 693 | return this.action.methodName; |
| 694 | } |
| 695 | }, |
| 696 | { |
| 697 | key: "element", |
| 698 | get: function get() { |
| 699 | return this.scope.element; |
| 700 | } |
| 701 | }, |
| 702 | { |
| 703 | key: "scope", |
| 704 | get: function get() { |
| 705 | return this.context.scope; |
| 706 | } |
| 707 | } |
| 708 | ]); |
| 709 | return Binding; |
| 710 | }(); |
| 711 | var ElementObserver = /*#__PURE__*/ function() { |
| 712 | "use strict"; |
| 713 | function ElementObserver(element, delegate) { |
| 714 | var _this = this; |
| 715 | (0, _classCallCheckJsDefault.default)(this, ElementObserver); |
| 716 | this.mutationObserverInit = { |
| 717 | attributes: true, |
| 718 | childList: true, |
| 719 | subtree: true |
| 720 | }; |
| 721 | this.element = element; |
| 722 | this.started = false; |
| 723 | this.delegate = delegate; |
| 724 | this.elements = new Set; |
| 725 | this.mutationObserver = new MutationObserver(function(mutations) { |
| 726 | return _this.processMutations(mutations); |
| 727 | }); |
| 728 | } |
| 729 | (0, _createClassJsDefault.default)(ElementObserver, [ |
| 730 | { |
| 731 | key: "start", |
| 732 | value: function start() { |
| 733 | if (!this.started) { |
| 734 | this.started = true; |
| 735 | this.mutationObserver.observe(this.element, this.mutationObserverInit); |
| 736 | this.refresh(); |
| 737 | } |
| 738 | } |
| 739 | }, |
| 740 | { |
| 741 | key: "pause", |
| 742 | value: function pause(callback) { |
| 743 | if (this.started) { |
| 744 | this.mutationObserver.disconnect(); |
| 745 | this.started = false; |
| 746 | } |
| 747 | callback(); |
| 748 | if (!this.started) { |
| 749 | this.mutationObserver.observe(this.element, this.mutationObserverInit); |
| 750 | this.started = true; |
| 751 | } |
| 752 | } |
| 753 | }, |
| 754 | { |
| 755 | key: "stop", |
| 756 | value: function stop() { |
| 757 | if (this.started) { |
| 758 | this.mutationObserver.takeRecords(); |
| 759 | this.mutationObserver.disconnect(); |
| 760 | this.started = false; |
| 761 | } |
| 762 | } |
| 763 | }, |
| 764 | { |
| 765 | key: "refresh", |
| 766 | value: function refresh() { |
| 767 | if (this.started) { |
| 768 | var matches = new Set(this.matchElementsInTree()); |
| 769 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 770 | try { |
| 771 | for(var _iterator = Array.from(this.elements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 772 | var element = _step.value; |
| 773 | if (!matches.has(element)) this.removeElement(element); |
| 774 | } |
| 775 | } catch (err) { |
| 776 | _didIteratorError = true; |
| 777 | _iteratorError = err; |
| 778 | } finally{ |
| 779 | try { |
| 780 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 781 | _iterator.return(); |
| 782 | } |
| 783 | } finally{ |
| 784 | if (_didIteratorError) { |
| 785 | throw _iteratorError; |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined; |
| 790 | try { |
| 791 | for(var _iterator1 = Array.from(matches)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){ |
| 792 | var element1 = _step1.value; |
| 793 | this.addElement(element1); |
| 794 | } |
| 795 | } catch (err) { |
| 796 | _didIteratorError1 = true; |
| 797 | _iteratorError1 = err; |
| 798 | } finally{ |
| 799 | try { |
| 800 | if (!_iteratorNormalCompletion1 && _iterator1.return != null) { |
| 801 | _iterator1.return(); |
| 802 | } |
| 803 | } finally{ |
| 804 | if (_didIteratorError1) { |
| 805 | throw _iteratorError1; |
| 806 | } |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | }, |
| 812 | { |
| 813 | key: "processMutations", |
| 814 | value: function processMutations(mutations) { |
| 815 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 816 | if (this.started) try { |
| 817 | for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 818 | var mutation = _step.value; |
| 819 | this.processMutation(mutation); |
| 820 | } |
| 821 | } catch (err) { |
| 822 | _didIteratorError = true; |
| 823 | _iteratorError = err; |
| 824 | } finally{ |
| 825 | try { |
| 826 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 827 | _iterator.return(); |
| 828 | } |
| 829 | } finally{ |
| 830 | if (_didIteratorError) { |
| 831 | throw _iteratorError; |
| 832 | } |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | }, |
| 837 | { |
| 838 | key: "processMutation", |
| 839 | value: function processMutation(mutation) { |
| 840 | if (mutation.type == "attributes") this.processAttributeChange(mutation.target, mutation.attributeName); |
| 841 | else if (mutation.type == "childList") { |
| 842 | this.processRemovedNodes(mutation.removedNodes); |
| 843 | this.processAddedNodes(mutation.addedNodes); |
| 844 | } |
| 845 | } |
| 846 | }, |
| 847 | { |
| 848 | key: "processAttributeChange", |
| 849 | value: function processAttributeChange(node, attributeName) { |
| 850 | var element = node; |
| 851 | if (this.elements.has(element)) { |
| 852 | if (this.delegate.elementAttributeChanged && this.matchElement(element)) this.delegate.elementAttributeChanged(element, attributeName); |
| 853 | else this.removeElement(element); |
| 854 | } else if (this.matchElement(element)) this.addElement(element); |
| 855 | } |
| 856 | }, |
| 857 | { |
| 858 | key: "processRemovedNodes", |
| 859 | value: function processRemovedNodes(nodes) { |
| 860 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 861 | try { |
| 862 | for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 863 | var node = _step.value; |
| 864 | var element = this.elementFromNode(node); |
| 865 | if (element) this.processTree(element, this.removeElement); |
| 866 | } |
| 867 | } catch (err) { |
| 868 | _didIteratorError = true; |
| 869 | _iteratorError = err; |
| 870 | } finally{ |
| 871 | try { |
| 872 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 873 | _iterator.return(); |
| 874 | } |
| 875 | } finally{ |
| 876 | if (_didIteratorError) { |
| 877 | throw _iteratorError; |
| 878 | } |
| 879 | } |
| 880 | } |
| 881 | } |
| 882 | }, |
| 883 | { |
| 884 | key: "processAddedNodes", |
| 885 | value: function processAddedNodes(nodes) { |
| 886 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 887 | try { |
| 888 | for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 889 | var node = _step.value; |
| 890 | var element = this.elementFromNode(node); |
| 891 | if (element && this.elementIsActive(element)) this.processTree(element, this.addElement); |
| 892 | } |
| 893 | } catch (err) { |
| 894 | _didIteratorError = true; |
| 895 | _iteratorError = err; |
| 896 | } finally{ |
| 897 | try { |
| 898 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 899 | _iterator.return(); |
| 900 | } |
| 901 | } finally{ |
| 902 | if (_didIteratorError) { |
| 903 | throw _iteratorError; |
| 904 | } |
| 905 | } |
| 906 | } |
| 907 | } |
| 908 | }, |
| 909 | { |
| 910 | key: "matchElement", |
| 911 | value: function matchElement(element) { |
| 912 | return this.delegate.matchElement(element); |
| 913 | } |
| 914 | }, |
| 915 | { |
| 916 | key: "matchElementsInTree", |
| 917 | value: function matchElementsInTree() { |
| 918 | var tree = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.element; |
| 919 | return this.delegate.matchElementsInTree(tree); |
| 920 | } |
| 921 | }, |
| 922 | { |
| 923 | key: "processTree", |
| 924 | value: function processTree(tree, processor) { |
| 925 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 926 | try { |
| 927 | for(var _iterator = this.matchElementsInTree(tree)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 928 | var element = _step.value; |
| 929 | processor.call(this, element); |
| 930 | } |
| 931 | } catch (err) { |
| 932 | _didIteratorError = true; |
| 933 | _iteratorError = err; |
| 934 | } finally{ |
| 935 | try { |
| 936 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 937 | _iterator.return(); |
| 938 | } |
| 939 | } finally{ |
| 940 | if (_didIteratorError) { |
| 941 | throw _iteratorError; |
| 942 | } |
| 943 | } |
| 944 | } |
| 945 | } |
| 946 | }, |
| 947 | { |
| 948 | key: "elementFromNode", |
| 949 | value: function elementFromNode(node) { |
| 950 | if (node.nodeType == Node.ELEMENT_NODE) return node; |
| 951 | } |
| 952 | }, |
| 953 | { |
| 954 | key: "elementIsActive", |
| 955 | value: function elementIsActive(element) { |
| 956 | if (element.isConnected != this.element.isConnected) return false; |
| 957 | else return this.element.contains(element); |
| 958 | } |
| 959 | }, |
| 960 | { |
| 961 | key: "addElement", |
| 962 | value: function addElement(element) { |
| 963 | if (!this.elements.has(element)) { |
| 964 | if (this.elementIsActive(element)) { |
| 965 | this.elements.add(element); |
| 966 | if (this.delegate.elementMatched) this.delegate.elementMatched(element); |
| 967 | } |
| 968 | } |
| 969 | } |
| 970 | }, |
| 971 | { |
| 972 | key: "removeElement", |
| 973 | value: function removeElement(element) { |
| 974 | if (this.elements.has(element)) { |
| 975 | this.elements.delete(element); |
| 976 | if (this.delegate.elementUnmatched) this.delegate.elementUnmatched(element); |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | ]); |
| 981 | return ElementObserver; |
| 982 | }(); |
| 983 | var AttributeObserver = /*#__PURE__*/ function() { |
| 984 | "use strict"; |
| 985 | function AttributeObserver(element, attributeName, delegate) { |
| 986 | (0, _classCallCheckJsDefault.default)(this, AttributeObserver); |
| 987 | this.attributeName = attributeName; |
| 988 | this.delegate = delegate; |
| 989 | this.elementObserver = new ElementObserver(element, this); |
| 990 | } |
| 991 | (0, _createClassJsDefault.default)(AttributeObserver, [ |
| 992 | { |
| 993 | key: "element", |
| 994 | get: function get() { |
| 995 | return this.elementObserver.element; |
| 996 | } |
| 997 | }, |
| 998 | { |
| 999 | key: "selector", |
| 1000 | get: function get() { |
| 1001 | return "[".concat(this.attributeName, "]"); |
| 1002 | } |
| 1003 | }, |
| 1004 | { |
| 1005 | key: "start", |
| 1006 | value: function start() { |
| 1007 | this.elementObserver.start(); |
| 1008 | } |
| 1009 | }, |
| 1010 | { |
| 1011 | key: "pause", |
| 1012 | value: function pause(callback) { |
| 1013 | this.elementObserver.pause(callback); |
| 1014 | } |
| 1015 | }, |
| 1016 | { |
| 1017 | key: "stop", |
| 1018 | value: function stop() { |
| 1019 | this.elementObserver.stop(); |
| 1020 | } |
| 1021 | }, |
| 1022 | { |
| 1023 | key: "refresh", |
| 1024 | value: function refresh() { |
| 1025 | this.elementObserver.refresh(); |
| 1026 | } |
| 1027 | }, |
| 1028 | { |
| 1029 | key: "started", |
| 1030 | get: function get() { |
| 1031 | return this.elementObserver.started; |
| 1032 | } |
| 1033 | }, |
| 1034 | { |
| 1035 | key: "matchElement", |
| 1036 | value: function matchElement(element) { |
| 1037 | return element.hasAttribute(this.attributeName); |
| 1038 | } |
| 1039 | }, |
| 1040 | { |
| 1041 | key: "matchElementsInTree", |
| 1042 | value: function matchElementsInTree(tree) { |
| 1043 | var match = this.matchElement(tree) ? [ |
| 1044 | tree |
| 1045 | ] : []; |
| 1046 | var matches = Array.from(tree.querySelectorAll(this.selector)); |
| 1047 | return match.concat(matches); |
| 1048 | } |
| 1049 | }, |
| 1050 | { |
| 1051 | key: "elementMatched", |
| 1052 | value: function elementMatched(element) { |
| 1053 | if (this.delegate.elementMatchedAttribute) this.delegate.elementMatchedAttribute(element, this.attributeName); |
| 1054 | } |
| 1055 | }, |
| 1056 | { |
| 1057 | key: "elementUnmatched", |
| 1058 | value: function elementUnmatched(element) { |
| 1059 | if (this.delegate.elementUnmatchedAttribute) this.delegate.elementUnmatchedAttribute(element, this.attributeName); |
| 1060 | } |
| 1061 | }, |
| 1062 | { |
| 1063 | key: "elementAttributeChanged", |
| 1064 | value: function elementAttributeChanged(element, attributeName) { |
| 1065 | if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) this.delegate.elementAttributeValueChanged(element, attributeName); |
| 1066 | } |
| 1067 | } |
| 1068 | ]); |
| 1069 | return AttributeObserver; |
| 1070 | }(); |
| 1071 | var StringMapObserver = /*#__PURE__*/ function() { |
| 1072 | "use strict"; |
| 1073 | function StringMapObserver(element, delegate) { |
| 1074 | var _this = this; |
| 1075 | (0, _classCallCheckJsDefault.default)(this, StringMapObserver); |
| 1076 | this.element = element; |
| 1077 | this.delegate = delegate; |
| 1078 | this.started = false; |
| 1079 | this.stringMap = new Map; |
| 1080 | this.mutationObserver = new MutationObserver(function(mutations) { |
| 1081 | return _this.processMutations(mutations); |
| 1082 | }); |
| 1083 | } |
| 1084 | (0, _createClassJsDefault.default)(StringMapObserver, [ |
| 1085 | { |
| 1086 | key: "start", |
| 1087 | value: function start() { |
| 1088 | if (!this.started) { |
| 1089 | this.started = true; |
| 1090 | this.mutationObserver.observe(this.element, { |
| 1091 | attributes: true, |
| 1092 | attributeOldValue: true |
| 1093 | }); |
| 1094 | this.refresh(); |
| 1095 | } |
| 1096 | } |
| 1097 | }, |
| 1098 | { |
| 1099 | key: "stop", |
| 1100 | value: function stop() { |
| 1101 | if (this.started) { |
| 1102 | this.mutationObserver.takeRecords(); |
| 1103 | this.mutationObserver.disconnect(); |
| 1104 | this.started = false; |
| 1105 | } |
| 1106 | } |
| 1107 | }, |
| 1108 | { |
| 1109 | key: "refresh", |
| 1110 | value: function refresh() { |
| 1111 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1112 | if (this.started) try { |
| 1113 | for(var _iterator = this.knownAttributeNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1114 | var attributeName = _step.value; |
| 1115 | this.refreshAttribute(attributeName, null); |
| 1116 | } |
| 1117 | } catch (err) { |
| 1118 | _didIteratorError = true; |
| 1119 | _iteratorError = err; |
| 1120 | } finally{ |
| 1121 | try { |
| 1122 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1123 | _iterator.return(); |
| 1124 | } |
| 1125 | } finally{ |
| 1126 | if (_didIteratorError) { |
| 1127 | throw _iteratorError; |
| 1128 | } |
| 1129 | } |
| 1130 | } |
| 1131 | } |
| 1132 | }, |
| 1133 | { |
| 1134 | key: "processMutations", |
| 1135 | value: function processMutations(mutations) { |
| 1136 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1137 | if (this.started) try { |
| 1138 | for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1139 | var mutation = _step.value; |
| 1140 | this.processMutation(mutation); |
| 1141 | } |
| 1142 | } catch (err) { |
| 1143 | _didIteratorError = true; |
| 1144 | _iteratorError = err; |
| 1145 | } finally{ |
| 1146 | try { |
| 1147 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1148 | _iterator.return(); |
| 1149 | } |
| 1150 | } finally{ |
| 1151 | if (_didIteratorError) { |
| 1152 | throw _iteratorError; |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | }, |
| 1158 | { |
| 1159 | key: "processMutation", |
| 1160 | value: function processMutation(mutation) { |
| 1161 | var attributeName = mutation.attributeName; |
| 1162 | if (attributeName) this.refreshAttribute(attributeName, mutation.oldValue); |
| 1163 | } |
| 1164 | }, |
| 1165 | { |
| 1166 | key: "refreshAttribute", |
| 1167 | value: function refreshAttribute(attributeName, oldValue) { |
| 1168 | var key = this.delegate.getStringMapKeyForAttribute(attributeName); |
| 1169 | if (key != null) { |
| 1170 | if (!this.stringMap.has(attributeName)) this.stringMapKeyAdded(key, attributeName); |
| 1171 | var value = this.element.getAttribute(attributeName); |
| 1172 | if (this.stringMap.get(attributeName) != value) this.stringMapValueChanged(value, key, oldValue); |
| 1173 | if (value == null) { |
| 1174 | var _$oldValue = this.stringMap.get(attributeName); |
| 1175 | this.stringMap.delete(attributeName); |
| 1176 | if (_$oldValue) this.stringMapKeyRemoved(key, attributeName, _$oldValue); |
| 1177 | } else this.stringMap.set(attributeName, value); |
| 1178 | } |
| 1179 | } |
| 1180 | }, |
| 1181 | { |
| 1182 | key: "stringMapKeyAdded", |
| 1183 | value: function stringMapKeyAdded(key, attributeName) { |
| 1184 | if (this.delegate.stringMapKeyAdded) this.delegate.stringMapKeyAdded(key, attributeName); |
| 1185 | } |
| 1186 | }, |
| 1187 | { |
| 1188 | key: "stringMapValueChanged", |
| 1189 | value: function stringMapValueChanged(value, key, oldValue) { |
| 1190 | if (this.delegate.stringMapValueChanged) this.delegate.stringMapValueChanged(value, key, oldValue); |
| 1191 | } |
| 1192 | }, |
| 1193 | { |
| 1194 | key: "stringMapKeyRemoved", |
| 1195 | value: function stringMapKeyRemoved(key, attributeName, oldValue) { |
| 1196 | if (this.delegate.stringMapKeyRemoved) this.delegate.stringMapKeyRemoved(key, attributeName, oldValue); |
| 1197 | } |
| 1198 | }, |
| 1199 | { |
| 1200 | key: "knownAttributeNames", |
| 1201 | get: function get() { |
| 1202 | return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames))); |
| 1203 | } |
| 1204 | }, |
| 1205 | { |
| 1206 | key: "currentAttributeNames", |
| 1207 | get: function get() { |
| 1208 | return Array.from(this.element.attributes).map(function(attribute) { |
| 1209 | return attribute.name; |
| 1210 | }); |
| 1211 | } |
| 1212 | }, |
| 1213 | { |
| 1214 | key: "recordedAttributeNames", |
| 1215 | get: function get() { |
| 1216 | return Array.from(this.stringMap.keys()); |
| 1217 | } |
| 1218 | } |
| 1219 | ]); |
| 1220 | return StringMapObserver; |
| 1221 | }(); |
| 1222 | function add(map, key, value) { |
| 1223 | fetch(map, key).add(value); |
| 1224 | } |
| 1225 | function del(map, key, value) { |
| 1226 | fetch(map, key).delete(value); |
| 1227 | prune(map, key); |
| 1228 | } |
| 1229 | function fetch(map, key) { |
| 1230 | var values = map.get(key); |
| 1231 | if (!values) { |
| 1232 | values = new Set(); |
| 1233 | map.set(key, values); |
| 1234 | } |
| 1235 | return values; |
| 1236 | } |
| 1237 | function prune(map, key) { |
| 1238 | var values = map.get(key); |
| 1239 | if (values != null && values.size == 0) map.delete(key); |
| 1240 | } |
| 1241 | var Multimap = /*#__PURE__*/ function() { |
| 1242 | "use strict"; |
| 1243 | function Multimap() { |
| 1244 | (0, _classCallCheckJsDefault.default)(this, Multimap); |
| 1245 | this.valuesByKey = new Map(); |
| 1246 | } |
| 1247 | (0, _createClassJsDefault.default)(Multimap, [ |
| 1248 | { |
| 1249 | key: "keys", |
| 1250 | get: function get() { |
| 1251 | return Array.from(this.valuesByKey.keys()); |
| 1252 | } |
| 1253 | }, |
| 1254 | { |
| 1255 | key: "values", |
| 1256 | get: function get() { |
| 1257 | var sets = Array.from(this.valuesByKey.values()); |
| 1258 | return sets.reduce(function(values, set) { |
| 1259 | return values.concat(Array.from(set)); |
| 1260 | }, []); |
| 1261 | } |
| 1262 | }, |
| 1263 | { |
| 1264 | key: "size", |
| 1265 | get: function get() { |
| 1266 | var sets = Array.from(this.valuesByKey.values()); |
| 1267 | return sets.reduce(function(size, set) { |
| 1268 | return size + set.size; |
| 1269 | }, 0); |
| 1270 | } |
| 1271 | }, |
| 1272 | { |
| 1273 | key: "add", |
| 1274 | value: function add1(key, value) { |
| 1275 | add(this.valuesByKey, key, value); |
| 1276 | } |
| 1277 | }, |
| 1278 | { |
| 1279 | key: "delete", |
| 1280 | value: function _delete(key, value) { |
| 1281 | del(this.valuesByKey, key, value); |
| 1282 | } |
| 1283 | }, |
| 1284 | { |
| 1285 | key: "has", |
| 1286 | value: function has(key, value) { |
| 1287 | var values = this.valuesByKey.get(key); |
| 1288 | return values != null && values.has(value); |
| 1289 | } |
| 1290 | }, |
| 1291 | { |
| 1292 | key: "hasKey", |
| 1293 | value: function hasKey(key) { |
| 1294 | return this.valuesByKey.has(key); |
| 1295 | } |
| 1296 | }, |
| 1297 | { |
| 1298 | key: "hasValue", |
| 1299 | value: function hasValue(value) { |
| 1300 | var sets = Array.from(this.valuesByKey.values()); |
| 1301 | return sets.some(function(set) { |
| 1302 | return set.has(value); |
| 1303 | }); |
| 1304 | } |
| 1305 | }, |
| 1306 | { |
| 1307 | key: "getValuesForKey", |
| 1308 | value: function getValuesForKey(key) { |
| 1309 | var values = this.valuesByKey.get(key); |
| 1310 | return values ? Array.from(values) : []; |
| 1311 | } |
| 1312 | }, |
| 1313 | { |
| 1314 | key: "getKeysForValue", |
| 1315 | value: function getKeysForValue(value) { |
| 1316 | return Array.from(this.valuesByKey).filter(function(param) { |
| 1317 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1]; |
| 1318 | return values.has(value); |
| 1319 | }).map(function(param) { |
| 1320 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1]; |
| 1321 | return key; |
| 1322 | }); |
| 1323 | } |
| 1324 | } |
| 1325 | ]); |
| 1326 | return Multimap; |
| 1327 | }(); |
| 1328 | var IndexedMultimap = /*#__PURE__*/ function(Multimap) { |
| 1329 | "use strict"; |
| 1330 | (0, _inheritsJsDefault.default)(IndexedMultimap, Multimap); |
| 1331 | var _super = (0, _createSuperJsDefault.default)(IndexedMultimap); |
| 1332 | function IndexedMultimap() { |
| 1333 | (0, _classCallCheckJsDefault.default)(this, IndexedMultimap); |
| 1334 | var _this; |
| 1335 | _this = _super.call(this); |
| 1336 | _this.keysByValue = new Map; |
| 1337 | return _this; |
| 1338 | } |
| 1339 | (0, _createClassJsDefault.default)(IndexedMultimap, [ |
| 1340 | { |
| 1341 | key: "values", |
| 1342 | get: function get() { |
| 1343 | return Array.from(this.keysByValue.keys()); |
| 1344 | } |
| 1345 | }, |
| 1346 | { |
| 1347 | key: "add", |
| 1348 | value: function add1(key, value) { |
| 1349 | (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "add", this).call(this, key, value); |
| 1350 | add(this.keysByValue, value, key); |
| 1351 | } |
| 1352 | }, |
| 1353 | { |
| 1354 | key: "delete", |
| 1355 | value: function _delete(key, value) { |
| 1356 | (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "delete", this).call(this, key, value); |
| 1357 | del(this.keysByValue, value, key); |
| 1358 | } |
| 1359 | }, |
| 1360 | { |
| 1361 | key: "hasValue", |
| 1362 | value: function hasValue(value) { |
| 1363 | return this.keysByValue.has(value); |
| 1364 | } |
| 1365 | }, |
| 1366 | { |
| 1367 | key: "getKeysForValue", |
| 1368 | value: function getKeysForValue(value) { |
| 1369 | var set = this.keysByValue.get(value); |
| 1370 | return set ? Array.from(set) : []; |
| 1371 | } |
| 1372 | } |
| 1373 | ]); |
| 1374 | return IndexedMultimap; |
| 1375 | }(Multimap); |
| 1376 | var TokenListObserver = /*#__PURE__*/ function() { |
| 1377 | "use strict"; |
| 1378 | function TokenListObserver(element, attributeName, delegate) { |
| 1379 | (0, _classCallCheckJsDefault.default)(this, TokenListObserver); |
| 1380 | this.attributeObserver = new AttributeObserver(element, attributeName, this); |
| 1381 | this.delegate = delegate; |
| 1382 | this.tokensByElement = new Multimap; |
| 1383 | } |
| 1384 | (0, _createClassJsDefault.default)(TokenListObserver, [ |
| 1385 | { |
| 1386 | key: "started", |
| 1387 | get: function get() { |
| 1388 | return this.attributeObserver.started; |
| 1389 | } |
| 1390 | }, |
| 1391 | { |
| 1392 | key: "start", |
| 1393 | value: function start() { |
| 1394 | this.attributeObserver.start(); |
| 1395 | } |
| 1396 | }, |
| 1397 | { |
| 1398 | key: "pause", |
| 1399 | value: function pause(callback) { |
| 1400 | this.attributeObserver.pause(callback); |
| 1401 | } |
| 1402 | }, |
| 1403 | { |
| 1404 | key: "stop", |
| 1405 | value: function stop() { |
| 1406 | this.attributeObserver.stop(); |
| 1407 | } |
| 1408 | }, |
| 1409 | { |
| 1410 | key: "refresh", |
| 1411 | value: function refresh() { |
| 1412 | this.attributeObserver.refresh(); |
| 1413 | } |
| 1414 | }, |
| 1415 | { |
| 1416 | key: "element", |
| 1417 | get: function get() { |
| 1418 | return this.attributeObserver.element; |
| 1419 | } |
| 1420 | }, |
| 1421 | { |
| 1422 | key: "attributeName", |
| 1423 | get: function get() { |
| 1424 | return this.attributeObserver.attributeName; |
| 1425 | } |
| 1426 | }, |
| 1427 | { |
| 1428 | key: "elementMatchedAttribute", |
| 1429 | value: function elementMatchedAttribute(element) { |
| 1430 | this.tokensMatched(this.readTokensForElement(element)); |
| 1431 | } |
| 1432 | }, |
| 1433 | { |
| 1434 | key: "elementAttributeValueChanged", |
| 1435 | value: function elementAttributeValueChanged(element) { |
| 1436 | var ref = (0, _slicedToArrayJsDefault.default)(this.refreshTokensForElement(element), 2), unmatchedTokens = ref[0], matchedTokens = ref[1]; |
| 1437 | this.tokensUnmatched(unmatchedTokens); |
| 1438 | this.tokensMatched(matchedTokens); |
| 1439 | } |
| 1440 | }, |
| 1441 | { |
| 1442 | key: "elementUnmatchedAttribute", |
| 1443 | value: function elementUnmatchedAttribute(element) { |
| 1444 | this.tokensUnmatched(this.tokensByElement.getValuesForKey(element)); |
| 1445 | } |
| 1446 | }, |
| 1447 | { |
| 1448 | key: "tokensMatched", |
| 1449 | value: function tokensMatched(tokens) { |
| 1450 | var _this = this; |
| 1451 | tokens.forEach(function(token) { |
| 1452 | return _this.tokenMatched(token); |
| 1453 | }); |
| 1454 | } |
| 1455 | }, |
| 1456 | { |
| 1457 | key: "tokensUnmatched", |
| 1458 | value: function tokensUnmatched(tokens) { |
| 1459 | var _this = this; |
| 1460 | tokens.forEach(function(token) { |
| 1461 | return _this.tokenUnmatched(token); |
| 1462 | }); |
| 1463 | } |
| 1464 | }, |
| 1465 | { |
| 1466 | key: "tokenMatched", |
| 1467 | value: function tokenMatched(token) { |
| 1468 | this.delegate.tokenMatched(token); |
| 1469 | this.tokensByElement.add(token.element, token); |
| 1470 | } |
| 1471 | }, |
| 1472 | { |
| 1473 | key: "tokenUnmatched", |
| 1474 | value: function tokenUnmatched(token) { |
| 1475 | this.delegate.tokenUnmatched(token); |
| 1476 | this.tokensByElement.delete(token.element, token); |
| 1477 | } |
| 1478 | }, |
| 1479 | { |
| 1480 | key: "refreshTokensForElement", |
| 1481 | value: function refreshTokensForElement(element) { |
| 1482 | var previousTokens = this.tokensByElement.getValuesForKey(element); |
| 1483 | var currentTokens = this.readTokensForElement(element); |
| 1484 | var firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(function(param) { |
| 1485 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), previousToken = _param[0], currentToken = _param[1]; |
| 1486 | return !tokensAreEqual(previousToken, currentToken); |
| 1487 | }); |
| 1488 | if (firstDifferingIndex == -1) return [ |
| 1489 | [], |
| 1490 | [] |
| 1491 | ]; |
| 1492 | else return [ |
| 1493 | previousTokens.slice(firstDifferingIndex), |
| 1494 | currentTokens.slice(firstDifferingIndex) |
| 1495 | ]; |
| 1496 | } |
| 1497 | }, |
| 1498 | { |
| 1499 | key: "readTokensForElement", |
| 1500 | value: function readTokensForElement(element) { |
| 1501 | var attributeName = this.attributeName; |
| 1502 | var tokenString = element.getAttribute(attributeName) || ""; |
| 1503 | return parseTokenString(tokenString, element, attributeName); |
| 1504 | } |
| 1505 | } |
| 1506 | ]); |
| 1507 | return TokenListObserver; |
| 1508 | }(); |
| 1509 | function parseTokenString(tokenString, element, attributeName) { |
| 1510 | return tokenString.trim().split(/\s+/).filter(function(content) { |
| 1511 | return content.length; |
| 1512 | }).map(function(content, index) { |
| 1513 | return { |
| 1514 | element: element, |
| 1515 | attributeName: attributeName, |
| 1516 | content: content, |
| 1517 | index: index |
| 1518 | }; |
| 1519 | }); |
| 1520 | } |
| 1521 | function zip(left, right) { |
| 1522 | var length = Math.max(left.length, right.length); |
| 1523 | return Array.from({ |
| 1524 | length: length |
| 1525 | }, function(_, index) { |
| 1526 | return [ |
| 1527 | left[index], |
| 1528 | right[index] |
| 1529 | ]; |
| 1530 | }); |
| 1531 | } |
| 1532 | function tokensAreEqual(left, right) { |
| 1533 | return left && right && left.index == right.index && left.content == right.content; |
| 1534 | } |
| 1535 | var ValueListObserver = /*#__PURE__*/ function() { |
| 1536 | "use strict"; |
| 1537 | function ValueListObserver(element, attributeName, delegate) { |
| 1538 | (0, _classCallCheckJsDefault.default)(this, ValueListObserver); |
| 1539 | this.tokenListObserver = new TokenListObserver(element, attributeName, this); |
| 1540 | this.delegate = delegate; |
| 1541 | this.parseResultsByToken = new WeakMap; |
| 1542 | this.valuesByTokenByElement = new WeakMap; |
| 1543 | } |
| 1544 | (0, _createClassJsDefault.default)(ValueListObserver, [ |
| 1545 | { |
| 1546 | key: "started", |
| 1547 | get: function get() { |
| 1548 | return this.tokenListObserver.started; |
| 1549 | } |
| 1550 | }, |
| 1551 | { |
| 1552 | key: "start", |
| 1553 | value: function start() { |
| 1554 | this.tokenListObserver.start(); |
| 1555 | } |
| 1556 | }, |
| 1557 | { |
| 1558 | key: "stop", |
| 1559 | value: function stop() { |
| 1560 | this.tokenListObserver.stop(); |
| 1561 | } |
| 1562 | }, |
| 1563 | { |
| 1564 | key: "refresh", |
| 1565 | value: function refresh() { |
| 1566 | this.tokenListObserver.refresh(); |
| 1567 | } |
| 1568 | }, |
| 1569 | { |
| 1570 | key: "element", |
| 1571 | get: function get() { |
| 1572 | return this.tokenListObserver.element; |
| 1573 | } |
| 1574 | }, |
| 1575 | { |
| 1576 | key: "attributeName", |
| 1577 | get: function get() { |
| 1578 | return this.tokenListObserver.attributeName; |
| 1579 | } |
| 1580 | }, |
| 1581 | { |
| 1582 | key: "tokenMatched", |
| 1583 | value: function tokenMatched(token) { |
| 1584 | var element = token.element; |
| 1585 | var value = this.fetchParseResultForToken(token).value; |
| 1586 | if (value) { |
| 1587 | this.fetchValuesByTokenForElement(element).set(token, value); |
| 1588 | this.delegate.elementMatchedValue(element, value); |
| 1589 | } |
| 1590 | } |
| 1591 | }, |
| 1592 | { |
| 1593 | key: "tokenUnmatched", |
| 1594 | value: function tokenUnmatched(token) { |
| 1595 | var element = token.element; |
| 1596 | var value = this.fetchParseResultForToken(token).value; |
| 1597 | if (value) { |
| 1598 | this.fetchValuesByTokenForElement(element).delete(token); |
| 1599 | this.delegate.elementUnmatchedValue(element, value); |
| 1600 | } |
| 1601 | } |
| 1602 | }, |
| 1603 | { |
| 1604 | key: "fetchParseResultForToken", |
| 1605 | value: function fetchParseResultForToken(token) { |
| 1606 | var parseResult = this.parseResultsByToken.get(token); |
| 1607 | if (!parseResult) { |
| 1608 | parseResult = this.parseToken(token); |
| 1609 | this.parseResultsByToken.set(token, parseResult); |
| 1610 | } |
| 1611 | return parseResult; |
| 1612 | } |
| 1613 | }, |
| 1614 | { |
| 1615 | key: "fetchValuesByTokenForElement", |
| 1616 | value: function fetchValuesByTokenForElement(element) { |
| 1617 | var valuesByToken = this.valuesByTokenByElement.get(element); |
| 1618 | if (!valuesByToken) { |
| 1619 | valuesByToken = new Map; |
| 1620 | this.valuesByTokenByElement.set(element, valuesByToken); |
| 1621 | } |
| 1622 | return valuesByToken; |
| 1623 | } |
| 1624 | }, |
| 1625 | { |
| 1626 | key: "parseToken", |
| 1627 | value: function parseToken(token) { |
| 1628 | try { |
| 1629 | var value = this.delegate.parseValueForToken(token); |
| 1630 | return { |
| 1631 | value: value |
| 1632 | }; |
| 1633 | } catch (error3) { |
| 1634 | return { |
| 1635 | error: error3 |
| 1636 | }; |
| 1637 | } |
| 1638 | } |
| 1639 | } |
| 1640 | ]); |
| 1641 | return ValueListObserver; |
| 1642 | }(); |
| 1643 | var BindingObserver = /*#__PURE__*/ function() { |
| 1644 | "use strict"; |
| 1645 | function BindingObserver(context, delegate) { |
| 1646 | (0, _classCallCheckJsDefault.default)(this, BindingObserver); |
| 1647 | this.context = context; |
| 1648 | this.delegate = delegate; |
| 1649 | this.bindingsByAction = new Map; |
| 1650 | } |
| 1651 | (0, _createClassJsDefault.default)(BindingObserver, [ |
| 1652 | { |
| 1653 | key: "start", |
| 1654 | value: function start() { |
| 1655 | if (!this.valueListObserver) { |
| 1656 | this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this); |
| 1657 | this.valueListObserver.start(); |
| 1658 | } |
| 1659 | } |
| 1660 | }, |
| 1661 | { |
| 1662 | key: "stop", |
| 1663 | value: function stop() { |
| 1664 | if (this.valueListObserver) { |
| 1665 | this.valueListObserver.stop(); |
| 1666 | delete this.valueListObserver; |
| 1667 | this.disconnectAllActions(); |
| 1668 | } |
| 1669 | } |
| 1670 | }, |
| 1671 | { |
| 1672 | key: "element", |
| 1673 | get: function get() { |
| 1674 | return this.context.element; |
| 1675 | } |
| 1676 | }, |
| 1677 | { |
| 1678 | key: "identifier", |
| 1679 | get: function get() { |
| 1680 | return this.context.identifier; |
| 1681 | } |
| 1682 | }, |
| 1683 | { |
| 1684 | key: "actionAttribute", |
| 1685 | get: function get() { |
| 1686 | return this.schema.actionAttribute; |
| 1687 | } |
| 1688 | }, |
| 1689 | { |
| 1690 | key: "schema", |
| 1691 | get: function get() { |
| 1692 | return this.context.schema; |
| 1693 | } |
| 1694 | }, |
| 1695 | { |
| 1696 | key: "bindings", |
| 1697 | get: function get() { |
| 1698 | return Array.from(this.bindingsByAction.values()); |
| 1699 | } |
| 1700 | }, |
| 1701 | { |
| 1702 | key: "connectAction", |
| 1703 | value: function connectAction(action) { |
| 1704 | var binding = new Binding(this.context, action); |
| 1705 | this.bindingsByAction.set(action, binding); |
| 1706 | this.delegate.bindingConnected(binding); |
| 1707 | } |
| 1708 | }, |
| 1709 | { |
| 1710 | key: "disconnectAction", |
| 1711 | value: function disconnectAction(action) { |
| 1712 | var binding = this.bindingsByAction.get(action); |
| 1713 | if (binding) { |
| 1714 | this.bindingsByAction.delete(action); |
| 1715 | this.delegate.bindingDisconnected(binding); |
| 1716 | } |
| 1717 | } |
| 1718 | }, |
| 1719 | { |
| 1720 | key: "disconnectAllActions", |
| 1721 | value: function disconnectAllActions() { |
| 1722 | var _this = this; |
| 1723 | this.bindings.forEach(function(binding) { |
| 1724 | return _this.delegate.bindingDisconnected(binding); |
| 1725 | }); |
| 1726 | this.bindingsByAction.clear(); |
| 1727 | } |
| 1728 | }, |
| 1729 | { |
| 1730 | key: "parseValueForToken", |
| 1731 | value: function parseValueForToken(token) { |
| 1732 | var action = Action.forToken(token); |
| 1733 | if (action.identifier == this.identifier) return action; |
| 1734 | } |
| 1735 | }, |
| 1736 | { |
| 1737 | key: "elementMatchedValue", |
| 1738 | value: function elementMatchedValue(element, action) { |
| 1739 | this.connectAction(action); |
| 1740 | } |
| 1741 | }, |
| 1742 | { |
| 1743 | key: "elementUnmatchedValue", |
| 1744 | value: function elementUnmatchedValue(element, action) { |
| 1745 | this.disconnectAction(action); |
| 1746 | } |
| 1747 | } |
| 1748 | ]); |
| 1749 | return BindingObserver; |
| 1750 | }(); |
| 1751 | var ValueObserver = /*#__PURE__*/ function() { |
| 1752 | "use strict"; |
| 1753 | function ValueObserver(context, receiver) { |
| 1754 | (0, _classCallCheckJsDefault.default)(this, ValueObserver); |
| 1755 | this.context = context; |
| 1756 | this.receiver = receiver; |
| 1757 | this.stringMapObserver = new StringMapObserver(this.element, this); |
| 1758 | this.valueDescriptorMap = this.controller.valueDescriptorMap; |
| 1759 | this.invokeChangedCallbacksForDefaultValues(); |
| 1760 | } |
| 1761 | (0, _createClassJsDefault.default)(ValueObserver, [ |
| 1762 | { |
| 1763 | key: "start", |
| 1764 | value: function start() { |
| 1765 | this.stringMapObserver.start(); |
| 1766 | } |
| 1767 | }, |
| 1768 | { |
| 1769 | key: "stop", |
| 1770 | value: function stop() { |
| 1771 | this.stringMapObserver.stop(); |
| 1772 | } |
| 1773 | }, |
| 1774 | { |
| 1775 | key: "element", |
| 1776 | get: function get() { |
| 1777 | return this.context.element; |
| 1778 | } |
| 1779 | }, |
| 1780 | { |
| 1781 | key: "controller", |
| 1782 | get: function get() { |
| 1783 | return this.context.controller; |
| 1784 | } |
| 1785 | }, |
| 1786 | { |
| 1787 | key: "getStringMapKeyForAttribute", |
| 1788 | value: function getStringMapKeyForAttribute(attributeName) { |
| 1789 | if (attributeName in this.valueDescriptorMap) return this.valueDescriptorMap[attributeName].name; |
| 1790 | } |
| 1791 | }, |
| 1792 | { |
| 1793 | key: "stringMapKeyAdded", |
| 1794 | value: function stringMapKeyAdded(key, attributeName) { |
| 1795 | var descriptor = this.valueDescriptorMap[attributeName]; |
| 1796 | if (!this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue)); |
| 1797 | } |
| 1798 | }, |
| 1799 | { |
| 1800 | key: "stringMapValueChanged", |
| 1801 | value: function stringMapValueChanged(value, name, oldValue) { |
| 1802 | var descriptor = this.valueDescriptorNameMap[name]; |
| 1803 | if (value === null) return; |
| 1804 | if (oldValue === null) oldValue = descriptor.writer(descriptor.defaultValue); |
| 1805 | this.invokeChangedCallback(name, value, oldValue); |
| 1806 | } |
| 1807 | }, |
| 1808 | { |
| 1809 | key: "stringMapKeyRemoved", |
| 1810 | value: function stringMapKeyRemoved(key, attributeName, oldValue) { |
| 1811 | var descriptor = this.valueDescriptorNameMap[key]; |
| 1812 | if (this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue); |
| 1813 | else this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue); |
| 1814 | } |
| 1815 | }, |
| 1816 | { |
| 1817 | key: "invokeChangedCallbacksForDefaultValues", |
| 1818 | value: function invokeChangedCallbacksForDefaultValues() { |
| 1819 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 1820 | try { |
| 1821 | for(var _iterator = this.valueDescriptors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 1822 | var _value = _step.value, key = _value.key, name = _value.name, defaultValue = _value.defaultValue, writer = _value.writer; |
| 1823 | if (defaultValue != undefined && !this.controller.data.has(key)) this.invokeChangedCallback(name, writer(defaultValue), undefined); |
| 1824 | } |
| 1825 | } catch (err) { |
| 1826 | _didIteratorError = true; |
| 1827 | _iteratorError = err; |
| 1828 | } finally{ |
| 1829 | try { |
| 1830 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 1831 | _iterator.return(); |
| 1832 | } |
| 1833 | } finally{ |
| 1834 | if (_didIteratorError) { |
| 1835 | throw _iteratorError; |
| 1836 | } |
| 1837 | } |
| 1838 | } |
| 1839 | } |
| 1840 | }, |
| 1841 | { |
| 1842 | key: "invokeChangedCallback", |
| 1843 | value: function invokeChangedCallback(name, rawValue, rawOldValue) { |
| 1844 | var changedMethodName = "".concat(name, "Changed"); |
| 1845 | var changedMethod = this.receiver[changedMethodName]; |
| 1846 | if (typeof changedMethod == "function") { |
| 1847 | var descriptor = this.valueDescriptorNameMap[name]; |
| 1848 | var value = descriptor.reader(rawValue); |
| 1849 | var oldValue = rawOldValue; |
| 1850 | if (rawOldValue) oldValue = descriptor.reader(rawOldValue); |
| 1851 | changedMethod.call(this.receiver, value, oldValue); |
| 1852 | } |
| 1853 | } |
| 1854 | }, |
| 1855 | { |
| 1856 | key: "valueDescriptors", |
| 1857 | get: function get() { |
| 1858 | var valueDescriptorMap = this.valueDescriptorMap; |
| 1859 | return Object.keys(valueDescriptorMap).map(function(key) { |
| 1860 | return valueDescriptorMap[key]; |
| 1861 | }); |
| 1862 | } |
| 1863 | }, |
| 1864 | { |
| 1865 | key: "valueDescriptorNameMap", |
| 1866 | get: function get() { |
| 1867 | var _this = this; |
| 1868 | var descriptors = {}; |
| 1869 | Object.keys(this.valueDescriptorMap).forEach(function(key) { |
| 1870 | var descriptor = _this.valueDescriptorMap[key]; |
| 1871 | descriptors[descriptor.name] = descriptor; |
| 1872 | }); |
| 1873 | return descriptors; |
| 1874 | } |
| 1875 | }, |
| 1876 | { |
| 1877 | key: "hasValue", |
| 1878 | value: function hasValue(attributeName) { |
| 1879 | var descriptor = this.valueDescriptorNameMap[attributeName]; |
| 1880 | var hasMethodName = "has".concat(capitalize(descriptor.name)); |
| 1881 | return this.receiver[hasMethodName]; |
| 1882 | } |
| 1883 | } |
| 1884 | ]); |
| 1885 | return ValueObserver; |
| 1886 | }(); |
| 1887 | var TargetObserver = /*#__PURE__*/ function() { |
| 1888 | "use strict"; |
| 1889 | function TargetObserver(context, delegate) { |
| 1890 | (0, _classCallCheckJsDefault.default)(this, TargetObserver); |
| 1891 | this.context = context; |
| 1892 | this.delegate = delegate; |
| 1893 | this.targetsByName = new Multimap; |
| 1894 | } |
| 1895 | (0, _createClassJsDefault.default)(TargetObserver, [ |
| 1896 | { |
| 1897 | key: "start", |
| 1898 | value: function start() { |
| 1899 | if (!this.tokenListObserver) { |
| 1900 | this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this); |
| 1901 | this.tokenListObserver.start(); |
| 1902 | } |
| 1903 | } |
| 1904 | }, |
| 1905 | { |
| 1906 | key: "stop", |
| 1907 | value: function stop() { |
| 1908 | if (this.tokenListObserver) { |
| 1909 | this.disconnectAllTargets(); |
| 1910 | this.tokenListObserver.stop(); |
| 1911 | delete this.tokenListObserver; |
| 1912 | } |
| 1913 | } |
| 1914 | }, |
| 1915 | { |
| 1916 | key: "tokenMatched", |
| 1917 | value: function tokenMatched(param) { |
| 1918 | var element = param.element, name = param.content; |
| 1919 | if (this.scope.containsElement(element)) this.connectTarget(element, name); |
| 1920 | } |
| 1921 | }, |
| 1922 | { |
| 1923 | key: "tokenUnmatched", |
| 1924 | value: function tokenUnmatched(param) { |
| 1925 | var element = param.element, name = param.content; |
| 1926 | this.disconnectTarget(element, name); |
| 1927 | } |
| 1928 | }, |
| 1929 | { |
| 1930 | key: "connectTarget", |
| 1931 | value: function connectTarget(element, name) { |
| 1932 | var _a; |
| 1933 | if (!this.targetsByName.has(name, element)) { |
| 1934 | var _this = this; |
| 1935 | this.targetsByName.add(name, element); |
| 1936 | (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() { |
| 1937 | return _this.delegate.targetConnected(element, name); |
| 1938 | }); |
| 1939 | } |
| 1940 | } |
| 1941 | }, |
| 1942 | { |
| 1943 | key: "disconnectTarget", |
| 1944 | value: function disconnectTarget(element, name) { |
| 1945 | var _a; |
| 1946 | if (this.targetsByName.has(name, element)) { |
| 1947 | var _this = this; |
| 1948 | this.targetsByName.delete(name, element); |
| 1949 | (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() { |
| 1950 | return _this.delegate.targetDisconnected(element, name); |
| 1951 | }); |
| 1952 | } |
| 1953 | } |
| 1954 | }, |
| 1955 | { |
| 1956 | key: "disconnectAllTargets", |
| 1957 | value: function disconnectAllTargets() { |
| 1958 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined, _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined; |
| 1959 | try { |
| 1960 | for(var _iterator = this.targetsByName.keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion2 = (_step = _iterator.next()).done); _iteratorNormalCompletion2 = true){ |
| 1961 | var name = _step.value; |
| 1962 | try { |
| 1963 | for(var _iterator2 = this.targetsByName.getValuesForKey(name)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion = true){ |
| 1964 | var element = _step2.value; |
| 1965 | this.disconnectTarget(element, name); |
| 1966 | } |
| 1967 | } catch (err) { |
| 1968 | _didIteratorError = true; |
| 1969 | _iteratorError = err; |
| 1970 | } finally{ |
| 1971 | try { |
| 1972 | if (!_iteratorNormalCompletion && _iterator2.return != null) { |
| 1973 | _iterator2.return(); |
| 1974 | } |
| 1975 | } finally{ |
| 1976 | if (_didIteratorError) { |
| 1977 | throw _iteratorError; |
| 1978 | } |
| 1979 | } |
| 1980 | } |
| 1981 | } |
| 1982 | } catch (err) { |
| 1983 | _didIteratorError2 = true; |
| 1984 | _iteratorError2 = err; |
| 1985 | } finally{ |
| 1986 | try { |
| 1987 | if (!_iteratorNormalCompletion2 && _iterator.return != null) { |
| 1988 | _iterator.return(); |
| 1989 | } |
| 1990 | } finally{ |
| 1991 | if (_didIteratorError2) { |
| 1992 | throw _iteratorError2; |
| 1993 | } |
| 1994 | } |
| 1995 | } |
| 1996 | } |
| 1997 | }, |
| 1998 | { |
| 1999 | key: "attributeName", |
| 2000 | get: function get() { |
| 2001 | return "data-".concat(this.context.identifier, "-target"); |
| 2002 | } |
| 2003 | }, |
| 2004 | { |
| 2005 | key: "element", |
| 2006 | get: function get() { |
| 2007 | return this.context.element; |
| 2008 | } |
| 2009 | }, |
| 2010 | { |
| 2011 | key: "scope", |
| 2012 | get: function get() { |
| 2013 | return this.context.scope; |
| 2014 | } |
| 2015 | } |
| 2016 | ]); |
| 2017 | return TargetObserver; |
| 2018 | }(); |
| 2019 | var Context = /*#__PURE__*/ function() { |
| 2020 | "use strict"; |
| 2021 | function Context(module, scope) { |
| 2022 | var _this = this; |
| 2023 | (0, _classCallCheckJsDefault.default)(this, Context); |
| 2024 | this.logDebugActivity = function(functionName) { |
| 2025 | var detail = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; |
| 2026 | var identifier = _this.identifier, controller = _this.controller, element = _this.element; |
| 2027 | detail = Object.assign({ |
| 2028 | identifier: identifier, |
| 2029 | controller: controller, |
| 2030 | element: element |
| 2031 | }, detail); |
| 2032 | _this.application.logDebugActivity(_this.identifier, functionName, detail); |
| 2033 | }; |
| 2034 | this.module = module; |
| 2035 | this.scope = scope; |
| 2036 | this.controller = new module.controllerConstructor(this); |
| 2037 | this.bindingObserver = new BindingObserver(this, this.dispatcher); |
| 2038 | this.valueObserver = new ValueObserver(this, this.controller); |
| 2039 | this.targetObserver = new TargetObserver(this, this); |
| 2040 | try { |
| 2041 | this.controller.initialize(); |
| 2042 | this.logDebugActivity("initialize"); |
| 2043 | } catch (error4) { |
| 2044 | this.handleError(error4, "initializing controller"); |
| 2045 | } |
| 2046 | } |
| 2047 | (0, _createClassJsDefault.default)(Context, [ |
| 2048 | { |
| 2049 | key: "connect", |
| 2050 | value: function connect() { |
| 2051 | this.bindingObserver.start(); |
| 2052 | this.valueObserver.start(); |
| 2053 | this.targetObserver.start(); |
| 2054 | try { |
| 2055 | this.controller.connect(); |
| 2056 | this.logDebugActivity("connect"); |
| 2057 | } catch (error5) { |
| 2058 | this.handleError(error5, "connecting controller"); |
| 2059 | } |
| 2060 | } |
| 2061 | }, |
| 2062 | { |
| 2063 | key: "disconnect", |
| 2064 | value: function disconnect() { |
| 2065 | try { |
| 2066 | this.controller.disconnect(); |
| 2067 | this.logDebugActivity("disconnect"); |
| 2068 | } catch (error6) { |
| 2069 | this.handleError(error6, "disconnecting controller"); |
| 2070 | } |
| 2071 | this.targetObserver.stop(); |
| 2072 | this.valueObserver.stop(); |
| 2073 | this.bindingObserver.stop(); |
| 2074 | } |
| 2075 | }, |
| 2076 | { |
| 2077 | key: "application", |
| 2078 | get: function get() { |
| 2079 | return this.module.application; |
| 2080 | } |
| 2081 | }, |
| 2082 | { |
| 2083 | key: "identifier", |
| 2084 | get: function get() { |
| 2085 | return this.module.identifier; |
| 2086 | } |
| 2087 | }, |
| 2088 | { |
| 2089 | key: "schema", |
| 2090 | get: function get() { |
| 2091 | return this.application.schema; |
| 2092 | } |
| 2093 | }, |
| 2094 | { |
| 2095 | key: "dispatcher", |
| 2096 | get: function get() { |
| 2097 | return this.application.dispatcher; |
| 2098 | } |
| 2099 | }, |
| 2100 | { |
| 2101 | key: "element", |
| 2102 | get: function get() { |
| 2103 | return this.scope.element; |
| 2104 | } |
| 2105 | }, |
| 2106 | { |
| 2107 | key: "parentElement", |
| 2108 | get: function get() { |
| 2109 | return this.element.parentElement; |
| 2110 | } |
| 2111 | }, |
| 2112 | { |
| 2113 | key: "handleError", |
| 2114 | value: function handleError(error7, message) { |
| 2115 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2116 | var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element; |
| 2117 | detail = Object.assign({ |
| 2118 | identifier: identifier, |
| 2119 | controller: controller, |
| 2120 | element: element |
| 2121 | }, detail); |
| 2122 | this.application.handleError(error7, "Error ".concat(message), detail); |
| 2123 | } |
| 2124 | }, |
| 2125 | { |
| 2126 | key: "targetConnected", |
| 2127 | value: function targetConnected(element, name) { |
| 2128 | this.invokeControllerMethod("".concat(name, "TargetConnected"), element); |
| 2129 | } |
| 2130 | }, |
| 2131 | { |
| 2132 | key: "targetDisconnected", |
| 2133 | value: function targetDisconnected(element, name) { |
| 2134 | this.invokeControllerMethod("".concat(name, "TargetDisconnected"), element); |
| 2135 | } |
| 2136 | }, |
| 2137 | { |
| 2138 | key: "invokeControllerMethod", |
| 2139 | value: function invokeControllerMethod(methodName) { |
| 2140 | for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2141 | args[_key - 1] = arguments[_key]; |
| 2142 | } |
| 2143 | var _controller; |
| 2144 | var controller = this.controller; |
| 2145 | if (typeof controller[methodName] == "function") (_controller = controller)[methodName].apply(_controller, (0, _toConsumableArrayJsDefault.default)(args)); |
| 2146 | } |
| 2147 | } |
| 2148 | ]); |
| 2149 | return Context; |
| 2150 | }(); |
| 2151 | function readInheritableStaticArrayValues(constructor1, propertyName) { |
| 2152 | var ancestors = getAncestorsForConstructor(constructor1); |
| 2153 | return Array.from(ancestors.reduce(function(values, constructor) { |
| 2154 | getOwnStaticArrayValues(constructor, propertyName).forEach(function(name) { |
| 2155 | return values.add(name); |
| 2156 | }); |
| 2157 | return values; |
| 2158 | }, new Set)); |
| 2159 | } |
| 2160 | function readInheritableStaticObjectPairs(constructor2, propertyName) { |
| 2161 | var ancestors = getAncestorsForConstructor(constructor2); |
| 2162 | return ancestors.reduce(function(pairs, constructor) { |
| 2163 | var _pairs; |
| 2164 | (_pairs = pairs).push.apply(_pairs, (0, _toConsumableArrayJsDefault.default)(getOwnStaticObjectPairs(constructor, propertyName))); |
| 2165 | return pairs; |
| 2166 | }, []); |
| 2167 | } |
| 2168 | function getAncestorsForConstructor(constructor) { |
| 2169 | var ancestors = []; |
| 2170 | while(constructor){ |
| 2171 | ancestors.push(constructor); |
| 2172 | constructor = Object.getPrototypeOf(constructor); |
| 2173 | } |
| 2174 | return ancestors.reverse(); |
| 2175 | } |
| 2176 | function getOwnStaticArrayValues(constructor, propertyName) { |
| 2177 | var definition = constructor[propertyName]; |
| 2178 | return Array.isArray(definition) ? definition : []; |
| 2179 | } |
| 2180 | function getOwnStaticObjectPairs(constructor, propertyName) { |
| 2181 | var definition = constructor[propertyName]; |
| 2182 | return definition ? Object.keys(definition).map(function(key) { |
| 2183 | return [ |
| 2184 | key, |
| 2185 | definition[key] |
| 2186 | ]; |
| 2187 | }) : []; |
| 2188 | } |
| 2189 | function bless(constructor) { |
| 2190 | return shadow(constructor, getBlessedProperties(constructor)); |
| 2191 | } |
| 2192 | function shadow(constructor, properties) { |
| 2193 | var shadowConstructor = extend(constructor); |
| 2194 | var shadowProperties = getShadowProperties(constructor.prototype, properties); |
| 2195 | Object.defineProperties(shadowConstructor.prototype, shadowProperties); |
| 2196 | return shadowConstructor; |
| 2197 | } |
| 2198 | function getBlessedProperties(constructor) { |
| 2199 | var blessings = readInheritableStaticArrayValues(constructor, "blessings"); |
| 2200 | return blessings.reduce(function(blessedProperties, blessing) { |
| 2201 | var properties = blessing(constructor); |
| 2202 | for(var key in properties){ |
| 2203 | var descriptor = blessedProperties[key] || {}; |
| 2204 | blessedProperties[key] = Object.assign(descriptor, properties[key]); |
| 2205 | } |
| 2206 | return blessedProperties; |
| 2207 | }, {}); |
| 2208 | } |
| 2209 | function getShadowProperties(prototype, properties) { |
| 2210 | return getOwnKeys(properties).reduce(function(shadowProperties, key) { |
| 2211 | var descriptor = getShadowedDescriptor(prototype, properties, key); |
| 2212 | if (descriptor) Object.assign(shadowProperties, (0, _definePropertyJsDefault.default)({}, key, descriptor)); |
| 2213 | return shadowProperties; |
| 2214 | }, {}); |
| 2215 | } |
| 2216 | function getShadowedDescriptor(prototype, properties, key) { |
| 2217 | var shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key); |
| 2218 | var shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor; |
| 2219 | if (!shadowedByValue) { |
| 2220 | var descriptor = Object.getOwnPropertyDescriptor(properties, key).value; |
| 2221 | if (shadowingDescriptor) { |
| 2222 | descriptor.get = shadowingDescriptor.get || descriptor.get; |
| 2223 | descriptor.set = shadowingDescriptor.set || descriptor.set; |
| 2224 | } |
| 2225 | return descriptor; |
| 2226 | } |
| 2227 | } |
| 2228 | var getOwnKeys = function() { |
| 2229 | if (typeof Object.getOwnPropertySymbols == "function") return function(object) { |
| 2230 | return (0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertyNames(object)).concat((0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertySymbols(object))); |
| 2231 | }; |
| 2232 | else return Object.getOwnPropertyNames; |
| 2233 | }(); |
| 2234 | var extend = function _target() { |
| 2235 | var extendWithReflect = function extendWithReflect(constructor) { |
| 2236 | function extended() { |
| 2237 | return Reflect.construct(constructor, arguments, this instanceof extended ? this.constructor : void 0); |
| 2238 | } |
| 2239 | extended.prototype = Object.create(constructor.prototype, { |
| 2240 | constructor: { |
| 2241 | value: extended |
| 2242 | } |
| 2243 | }); |
| 2244 | Reflect.setPrototypeOf(extended, constructor); |
| 2245 | return extended; |
| 2246 | }; |
| 2247 | var testReflectExtension = function testReflectExtension() { |
| 2248 | var a = function a() { |
| 2249 | this.a.call(this); |
| 2250 | }; |
| 2251 | var b = extendWithReflect(a); |
| 2252 | b.prototype.a = function() {}; |
| 2253 | return new b; |
| 2254 | }; |
| 2255 | try { |
| 2256 | testReflectExtension(); |
| 2257 | return extendWithReflect; |
| 2258 | } catch (error) { |
| 2259 | return function(constructor3) { |
| 2260 | return /*#__PURE__*/ function(constructor) { |
| 2261 | "use strict"; |
| 2262 | (0, _inheritsJsDefault.default)(extended, constructor); |
| 2263 | var _super = (0, _createSuperJsDefault.default)(extended); |
| 2264 | function extended() { |
| 2265 | (0, _classCallCheckJsDefault.default)(this, extended); |
| 2266 | return _super.apply(this, arguments); |
| 2267 | } |
| 2268 | return extended; |
| 2269 | }(constructor3); |
| 2270 | }; |
| 2271 | } |
| 2272 | }(); |
| 2273 | function blessDefinition(definition) { |
| 2274 | return { |
| 2275 | identifier: definition.identifier, |
| 2276 | controllerConstructor: bless(definition.controllerConstructor) |
| 2277 | }; |
| 2278 | } |
| 2279 | var Module = /*#__PURE__*/ function() { |
| 2280 | "use strict"; |
| 2281 | function Module(application, definition) { |
| 2282 | (0, _classCallCheckJsDefault.default)(this, Module); |
| 2283 | this.application = application; |
| 2284 | this.definition = blessDefinition(definition); |
| 2285 | this.contextsByScope = new WeakMap; |
| 2286 | this.connectedContexts = new Set; |
| 2287 | } |
| 2288 | (0, _createClassJsDefault.default)(Module, [ |
| 2289 | { |
| 2290 | key: "identifier", |
| 2291 | get: function get() { |
| 2292 | return this.definition.identifier; |
| 2293 | } |
| 2294 | }, |
| 2295 | { |
| 2296 | key: "controllerConstructor", |
| 2297 | get: function get() { |
| 2298 | return this.definition.controllerConstructor; |
| 2299 | } |
| 2300 | }, |
| 2301 | { |
| 2302 | key: "contexts", |
| 2303 | get: function get() { |
| 2304 | return Array.from(this.connectedContexts); |
| 2305 | } |
| 2306 | }, |
| 2307 | { |
| 2308 | key: "connectContextForScope", |
| 2309 | value: function connectContextForScope(scope) { |
| 2310 | var context = this.fetchContextForScope(scope); |
| 2311 | this.connectedContexts.add(context); |
| 2312 | context.connect(); |
| 2313 | } |
| 2314 | }, |
| 2315 | { |
| 2316 | key: "disconnectContextForScope", |
| 2317 | value: function disconnectContextForScope(scope) { |
| 2318 | var context = this.contextsByScope.get(scope); |
| 2319 | if (context) { |
| 2320 | this.connectedContexts.delete(context); |
| 2321 | context.disconnect(); |
| 2322 | } |
| 2323 | } |
| 2324 | }, |
| 2325 | { |
| 2326 | key: "fetchContextForScope", |
| 2327 | value: function fetchContextForScope(scope) { |
| 2328 | var context = this.contextsByScope.get(scope); |
| 2329 | if (!context) { |
| 2330 | context = new Context(this, scope); |
| 2331 | this.contextsByScope.set(scope, context); |
| 2332 | } |
| 2333 | return context; |
| 2334 | } |
| 2335 | } |
| 2336 | ]); |
| 2337 | return Module; |
| 2338 | }(); |
| 2339 | var ClassMap = /*#__PURE__*/ function() { |
| 2340 | "use strict"; |
| 2341 | function ClassMap(scope) { |
| 2342 | (0, _classCallCheckJsDefault.default)(this, ClassMap); |
| 2343 | this.scope = scope; |
| 2344 | } |
| 2345 | (0, _createClassJsDefault.default)(ClassMap, [ |
| 2346 | { |
| 2347 | key: "has", |
| 2348 | value: function has(name) { |
| 2349 | return this.data.has(this.getDataKey(name)); |
| 2350 | } |
| 2351 | }, |
| 2352 | { |
| 2353 | key: "get", |
| 2354 | value: function get(name) { |
| 2355 | return this.getAll(name)[0]; |
| 2356 | } |
| 2357 | }, |
| 2358 | { |
| 2359 | key: "getAll", |
| 2360 | value: function getAll(name) { |
| 2361 | var tokenString = this.data.get(this.getDataKey(name)) || ""; |
| 2362 | return tokenize(tokenString); |
| 2363 | } |
| 2364 | }, |
| 2365 | { |
| 2366 | key: "getAttributeName", |
| 2367 | value: function getAttributeName(name) { |
| 2368 | return this.data.getAttributeNameForKey(this.getDataKey(name)); |
| 2369 | } |
| 2370 | }, |
| 2371 | { |
| 2372 | key: "getDataKey", |
| 2373 | value: function getDataKey(name) { |
| 2374 | return "".concat(name, "-class"); |
| 2375 | } |
| 2376 | }, |
| 2377 | { |
| 2378 | key: "data", |
| 2379 | get: function get() { |
| 2380 | return this.scope.data; |
| 2381 | } |
| 2382 | } |
| 2383 | ]); |
| 2384 | return ClassMap; |
| 2385 | }(); |
| 2386 | var DataMap = /*#__PURE__*/ function() { |
| 2387 | "use strict"; |
| 2388 | function DataMap(scope) { |
| 2389 | (0, _classCallCheckJsDefault.default)(this, DataMap); |
| 2390 | this.scope = scope; |
| 2391 | } |
| 2392 | (0, _createClassJsDefault.default)(DataMap, [ |
| 2393 | { |
| 2394 | key: "element", |
| 2395 | get: function get() { |
| 2396 | return this.scope.element; |
| 2397 | } |
| 2398 | }, |
| 2399 | { |
| 2400 | key: "identifier", |
| 2401 | get: function get() { |
| 2402 | return this.scope.identifier; |
| 2403 | } |
| 2404 | }, |
| 2405 | { |
| 2406 | key: "get", |
| 2407 | value: function get(key) { |
| 2408 | var name = this.getAttributeNameForKey(key); |
| 2409 | return this.element.getAttribute(name); |
| 2410 | } |
| 2411 | }, |
| 2412 | { |
| 2413 | key: "set", |
| 2414 | value: function set(key, value) { |
| 2415 | var name = this.getAttributeNameForKey(key); |
| 2416 | this.element.setAttribute(name, value); |
| 2417 | return this.get(key); |
| 2418 | } |
| 2419 | }, |
| 2420 | { |
| 2421 | key: "has", |
| 2422 | value: function has(key) { |
| 2423 | var name = this.getAttributeNameForKey(key); |
| 2424 | return this.element.hasAttribute(name); |
| 2425 | } |
| 2426 | }, |
| 2427 | { |
| 2428 | key: "delete", |
| 2429 | value: function _delete(key) { |
| 2430 | if (this.has(key)) { |
| 2431 | var name = this.getAttributeNameForKey(key); |
| 2432 | this.element.removeAttribute(name); |
| 2433 | return true; |
| 2434 | } else return false; |
| 2435 | } |
| 2436 | }, |
| 2437 | { |
| 2438 | key: "getAttributeNameForKey", |
| 2439 | value: function getAttributeNameForKey(key) { |
| 2440 | return "data-".concat(this.identifier, "-").concat(dasherize(key)); |
| 2441 | } |
| 2442 | } |
| 2443 | ]); |
| 2444 | return DataMap; |
| 2445 | }(); |
| 2446 | var Guide = /*#__PURE__*/ function() { |
| 2447 | "use strict"; |
| 2448 | function Guide(logger) { |
| 2449 | (0, _classCallCheckJsDefault.default)(this, Guide); |
| 2450 | this.warnedKeysByObject = new WeakMap; |
| 2451 | this.logger = logger; |
| 2452 | } |
| 2453 | (0, _createClassJsDefault.default)(Guide, [ |
| 2454 | { |
| 2455 | key: "warn", |
| 2456 | value: function warn(object, key, message) { |
| 2457 | var warnedKeys = this.warnedKeysByObject.get(object); |
| 2458 | if (!warnedKeys) { |
| 2459 | warnedKeys = new Set; |
| 2460 | this.warnedKeysByObject.set(object, warnedKeys); |
| 2461 | } |
| 2462 | if (!warnedKeys.has(key)) { |
| 2463 | warnedKeys.add(key); |
| 2464 | this.logger.warn(message, object); |
| 2465 | } |
| 2466 | } |
| 2467 | } |
| 2468 | ]); |
| 2469 | return Guide; |
| 2470 | }(); |
| 2471 | function attributeValueContainsToken(attributeName, token) { |
| 2472 | return "[".concat(attributeName, '~="').concat(token, '"]'); |
| 2473 | } |
| 2474 | var TargetSet = /*#__PURE__*/ function() { |
| 2475 | "use strict"; |
| 2476 | function TargetSet(scope) { |
| 2477 | (0, _classCallCheckJsDefault.default)(this, TargetSet); |
| 2478 | this.scope = scope; |
| 2479 | } |
| 2480 | (0, _createClassJsDefault.default)(TargetSet, [ |
| 2481 | { |
| 2482 | key: "element", |
| 2483 | get: function get() { |
| 2484 | return this.scope.element; |
| 2485 | } |
| 2486 | }, |
| 2487 | { |
| 2488 | key: "identifier", |
| 2489 | get: function get() { |
| 2490 | return this.scope.identifier; |
| 2491 | } |
| 2492 | }, |
| 2493 | { |
| 2494 | key: "schema", |
| 2495 | get: function get() { |
| 2496 | return this.scope.schema; |
| 2497 | } |
| 2498 | }, |
| 2499 | { |
| 2500 | key: "has", |
| 2501 | value: function has(targetName) { |
| 2502 | return this.find(targetName) != null; |
| 2503 | } |
| 2504 | }, |
| 2505 | { |
| 2506 | key: "find", |
| 2507 | value: function find() { |
| 2508 | for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){ |
| 2509 | targetNames[_key] = arguments[_key]; |
| 2510 | } |
| 2511 | var _this = this; |
| 2512 | return targetNames.reduce(function(target, targetName) { |
| 2513 | return target || _this.findTarget(targetName) || _this.findLegacyTarget(targetName); |
| 2514 | }, undefined); |
| 2515 | } |
| 2516 | }, |
| 2517 | { |
| 2518 | key: "findAll", |
| 2519 | value: function findAll() { |
| 2520 | for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){ |
| 2521 | targetNames[_key] = arguments[_key]; |
| 2522 | } |
| 2523 | var _this = this; |
| 2524 | return targetNames.reduce(function(targets, targetName) { |
| 2525 | return (0, _toConsumableArrayJsDefault.default)(targets).concat((0, _toConsumableArrayJsDefault.default)(_this.findAllTargets(targetName)), (0, _toConsumableArrayJsDefault.default)(_this.findAllLegacyTargets(targetName))); |
| 2526 | }, []); |
| 2527 | } |
| 2528 | }, |
| 2529 | { |
| 2530 | key: "findTarget", |
| 2531 | value: function findTarget(targetName) { |
| 2532 | var selector = this.getSelectorForTargetName(targetName); |
| 2533 | return this.scope.findElement(selector); |
| 2534 | } |
| 2535 | }, |
| 2536 | { |
| 2537 | key: "findAllTargets", |
| 2538 | value: function findAllTargets(targetName) { |
| 2539 | var selector = this.getSelectorForTargetName(targetName); |
| 2540 | return this.scope.findAllElements(selector); |
| 2541 | } |
| 2542 | }, |
| 2543 | { |
| 2544 | key: "getSelectorForTargetName", |
| 2545 | value: function getSelectorForTargetName(targetName) { |
| 2546 | var attributeName = this.schema.targetAttributeForScope(this.identifier); |
| 2547 | return attributeValueContainsToken(attributeName, targetName); |
| 2548 | } |
| 2549 | }, |
| 2550 | { |
| 2551 | key: "findLegacyTarget", |
| 2552 | value: function findLegacyTarget(targetName) { |
| 2553 | var selector = this.getLegacySelectorForTargetName(targetName); |
| 2554 | return this.deprecate(this.scope.findElement(selector), targetName); |
| 2555 | } |
| 2556 | }, |
| 2557 | { |
| 2558 | key: "findAllLegacyTargets", |
| 2559 | value: function findAllLegacyTargets(targetName) { |
| 2560 | var _this = this; |
| 2561 | var selector = this.getLegacySelectorForTargetName(targetName); |
| 2562 | return this.scope.findAllElements(selector).map(function(element) { |
| 2563 | return _this.deprecate(element, targetName); |
| 2564 | }); |
| 2565 | } |
| 2566 | }, |
| 2567 | { |
| 2568 | key: "getLegacySelectorForTargetName", |
| 2569 | value: function getLegacySelectorForTargetName(targetName) { |
| 2570 | var targetDescriptor = "".concat(this.identifier, ".").concat(targetName); |
| 2571 | return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor); |
| 2572 | } |
| 2573 | }, |
| 2574 | { |
| 2575 | key: "deprecate", |
| 2576 | value: function deprecate(element, targetName) { |
| 2577 | if (element) { |
| 2578 | var identifier = this.identifier; |
| 2579 | var attributeName = this.schema.targetAttribute; |
| 2580 | var revisedAttributeName = this.schema.targetAttributeForScope(identifier); |
| 2581 | 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.")); |
| 2582 | } |
| 2583 | return element; |
| 2584 | } |
| 2585 | }, |
| 2586 | { |
| 2587 | key: "guide", |
| 2588 | get: function get() { |
| 2589 | return this.scope.guide; |
| 2590 | } |
| 2591 | } |
| 2592 | ]); |
| 2593 | return TargetSet; |
| 2594 | }(); |
| 2595 | var Scope = /*#__PURE__*/ function() { |
| 2596 | "use strict"; |
| 2597 | function Scope(schema, element2, identifier, logger) { |
| 2598 | var _this = this; |
| 2599 | (0, _classCallCheckJsDefault.default)(this, Scope); |
| 2600 | this.targets = new TargetSet(this); |
| 2601 | this.classes = new ClassMap(this); |
| 2602 | this.data = new DataMap(this); |
| 2603 | this.containsElement = function(element) { |
| 2604 | return element.closest(_this.controllerSelector) === _this.element; |
| 2605 | }; |
| 2606 | this.schema = schema; |
| 2607 | this.element = element2; |
| 2608 | this.identifier = identifier; |
| 2609 | this.guide = new Guide(logger); |
| 2610 | } |
| 2611 | (0, _createClassJsDefault.default)(Scope, [ |
| 2612 | { |
| 2613 | key: "findElement", |
| 2614 | value: function findElement(selector) { |
| 2615 | return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement); |
| 2616 | } |
| 2617 | }, |
| 2618 | { |
| 2619 | key: "findAllElements", |
| 2620 | value: function findAllElements(selector) { |
| 2621 | return (0, _toConsumableArrayJsDefault.default)(this.element.matches(selector) ? [ |
| 2622 | this.element |
| 2623 | ] : []).concat((0, _toConsumableArrayJsDefault.default)(this.queryElements(selector).filter(this.containsElement))); |
| 2624 | } |
| 2625 | }, |
| 2626 | { |
| 2627 | key: "queryElements", |
| 2628 | value: function queryElements(selector) { |
| 2629 | return Array.from(this.element.querySelectorAll(selector)); |
| 2630 | } |
| 2631 | }, |
| 2632 | { |
| 2633 | key: "controllerSelector", |
| 2634 | get: function get() { |
| 2635 | return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier); |
| 2636 | } |
| 2637 | } |
| 2638 | ]); |
| 2639 | return Scope; |
| 2640 | }(); |
| 2641 | var ScopeObserver = /*#__PURE__*/ function() { |
| 2642 | "use strict"; |
| 2643 | function ScopeObserver(element, schema, delegate) { |
| 2644 | (0, _classCallCheckJsDefault.default)(this, ScopeObserver); |
| 2645 | this.element = element; |
| 2646 | this.schema = schema; |
| 2647 | this.delegate = delegate; |
| 2648 | this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this); |
| 2649 | this.scopesByIdentifierByElement = new WeakMap; |
| 2650 | this.scopeReferenceCounts = new WeakMap; |
| 2651 | } |
| 2652 | (0, _createClassJsDefault.default)(ScopeObserver, [ |
| 2653 | { |
| 2654 | key: "start", |
| 2655 | value: function start() { |
| 2656 | this.valueListObserver.start(); |
| 2657 | } |
| 2658 | }, |
| 2659 | { |
| 2660 | key: "stop", |
| 2661 | value: function stop() { |
| 2662 | this.valueListObserver.stop(); |
| 2663 | } |
| 2664 | }, |
| 2665 | { |
| 2666 | key: "controllerAttribute", |
| 2667 | get: function get() { |
| 2668 | return this.schema.controllerAttribute; |
| 2669 | } |
| 2670 | }, |
| 2671 | { |
| 2672 | key: "parseValueForToken", |
| 2673 | value: function parseValueForToken(token) { |
| 2674 | var element = token.element, identifier = token.content; |
| 2675 | var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element); |
| 2676 | var scope = scopesByIdentifier.get(identifier); |
| 2677 | if (!scope) { |
| 2678 | scope = this.delegate.createScopeForElementAndIdentifier(element, identifier); |
| 2679 | scopesByIdentifier.set(identifier, scope); |
| 2680 | } |
| 2681 | return scope; |
| 2682 | } |
| 2683 | }, |
| 2684 | { |
| 2685 | key: "elementMatchedValue", |
| 2686 | value: function elementMatchedValue(element, value) { |
| 2687 | var referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1; |
| 2688 | this.scopeReferenceCounts.set(value, referenceCount); |
| 2689 | if (referenceCount == 1) this.delegate.scopeConnected(value); |
| 2690 | } |
| 2691 | }, |
| 2692 | { |
| 2693 | key: "elementUnmatchedValue", |
| 2694 | value: function elementUnmatchedValue(element, value) { |
| 2695 | var referenceCount = this.scopeReferenceCounts.get(value); |
| 2696 | if (referenceCount) { |
| 2697 | this.scopeReferenceCounts.set(value, referenceCount - 1); |
| 2698 | if (referenceCount == 1) this.delegate.scopeDisconnected(value); |
| 2699 | } |
| 2700 | } |
| 2701 | }, |
| 2702 | { |
| 2703 | key: "fetchScopesByIdentifierForElement", |
| 2704 | value: function fetchScopesByIdentifierForElement(element) { |
| 2705 | var scopesByIdentifier = this.scopesByIdentifierByElement.get(element); |
| 2706 | if (!scopesByIdentifier) { |
| 2707 | scopesByIdentifier = new Map; |
| 2708 | this.scopesByIdentifierByElement.set(element, scopesByIdentifier); |
| 2709 | } |
| 2710 | return scopesByIdentifier; |
| 2711 | } |
| 2712 | } |
| 2713 | ]); |
| 2714 | return ScopeObserver; |
| 2715 | }(); |
| 2716 | var Router = /*#__PURE__*/ function() { |
| 2717 | "use strict"; |
| 2718 | function Router(application) { |
| 2719 | (0, _classCallCheckJsDefault.default)(this, Router); |
| 2720 | this.application = application; |
| 2721 | this.scopeObserver = new ScopeObserver(this.element, this.schema, this); |
| 2722 | this.scopesByIdentifier = new Multimap; |
| 2723 | this.modulesByIdentifier = new Map; |
| 2724 | } |
| 2725 | (0, _createClassJsDefault.default)(Router, [ |
| 2726 | { |
| 2727 | key: "element", |
| 2728 | get: function get() { |
| 2729 | return this.application.element; |
| 2730 | } |
| 2731 | }, |
| 2732 | { |
| 2733 | key: "schema", |
| 2734 | get: function get() { |
| 2735 | return this.application.schema; |
| 2736 | } |
| 2737 | }, |
| 2738 | { |
| 2739 | key: "logger", |
| 2740 | get: function get() { |
| 2741 | return this.application.logger; |
| 2742 | } |
| 2743 | }, |
| 2744 | { |
| 2745 | key: "controllerAttribute", |
| 2746 | get: function get() { |
| 2747 | return this.schema.controllerAttribute; |
| 2748 | } |
| 2749 | }, |
| 2750 | { |
| 2751 | key: "modules", |
| 2752 | get: function get() { |
| 2753 | return Array.from(this.modulesByIdentifier.values()); |
| 2754 | } |
| 2755 | }, |
| 2756 | { |
| 2757 | key: "contexts", |
| 2758 | get: function get() { |
| 2759 | return this.modules.reduce(function(contexts, module) { |
| 2760 | return contexts.concat(module.contexts); |
| 2761 | }, []); |
| 2762 | } |
| 2763 | }, |
| 2764 | { |
| 2765 | key: "start", |
| 2766 | value: function start() { |
| 2767 | this.scopeObserver.start(); |
| 2768 | } |
| 2769 | }, |
| 2770 | { |
| 2771 | key: "stop", |
| 2772 | value: function stop() { |
| 2773 | this.scopeObserver.stop(); |
| 2774 | } |
| 2775 | }, |
| 2776 | { |
| 2777 | key: "loadDefinition", |
| 2778 | value: function loadDefinition(definition) { |
| 2779 | this.unloadIdentifier(definition.identifier); |
| 2780 | var module = new Module(this.application, definition); |
| 2781 | this.connectModule(module); |
| 2782 | } |
| 2783 | }, |
| 2784 | { |
| 2785 | key: "unloadIdentifier", |
| 2786 | value: function unloadIdentifier(identifier) { |
| 2787 | var module = this.modulesByIdentifier.get(identifier); |
| 2788 | if (module) this.disconnectModule(module); |
| 2789 | } |
| 2790 | }, |
| 2791 | { |
| 2792 | key: "getContextForElementAndIdentifier", |
| 2793 | value: function getContextForElementAndIdentifier(element, identifier) { |
| 2794 | var module = this.modulesByIdentifier.get(identifier); |
| 2795 | if (module) return module.contexts.find(function(context) { |
| 2796 | return context.element == element; |
| 2797 | }); |
| 2798 | } |
| 2799 | }, |
| 2800 | { |
| 2801 | key: "handleError", |
| 2802 | value: function handleError(error8, message, detail) { |
| 2803 | this.application.handleError(error8, message, detail); |
| 2804 | } |
| 2805 | }, |
| 2806 | { |
| 2807 | key: "createScopeForElementAndIdentifier", |
| 2808 | value: function createScopeForElementAndIdentifier(element, identifier) { |
| 2809 | return new Scope(this.schema, element, identifier, this.logger); |
| 2810 | } |
| 2811 | }, |
| 2812 | { |
| 2813 | key: "scopeConnected", |
| 2814 | value: function scopeConnected(scope) { |
| 2815 | this.scopesByIdentifier.add(scope.identifier, scope); |
| 2816 | var module = this.modulesByIdentifier.get(scope.identifier); |
| 2817 | if (module) module.connectContextForScope(scope); |
| 2818 | } |
| 2819 | }, |
| 2820 | { |
| 2821 | key: "scopeDisconnected", |
| 2822 | value: function scopeDisconnected(scope) { |
| 2823 | this.scopesByIdentifier.delete(scope.identifier, scope); |
| 2824 | var module = this.modulesByIdentifier.get(scope.identifier); |
| 2825 | if (module) module.disconnectContextForScope(scope); |
| 2826 | } |
| 2827 | }, |
| 2828 | { |
| 2829 | key: "connectModule", |
| 2830 | value: function connectModule(module) { |
| 2831 | this.modulesByIdentifier.set(module.identifier, module); |
| 2832 | var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); |
| 2833 | scopes.forEach(function(scope) { |
| 2834 | return module.connectContextForScope(scope); |
| 2835 | }); |
| 2836 | } |
| 2837 | }, |
| 2838 | { |
| 2839 | key: "disconnectModule", |
| 2840 | value: function disconnectModule(module) { |
| 2841 | this.modulesByIdentifier.delete(module.identifier); |
| 2842 | var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); |
| 2843 | scopes.forEach(function(scope) { |
| 2844 | return module.disconnectContextForScope(scope); |
| 2845 | }); |
| 2846 | } |
| 2847 | } |
| 2848 | ]); |
| 2849 | return Router; |
| 2850 | }(); |
| 2851 | var defaultSchema = { |
| 2852 | controllerAttribute: "data-controller", |
| 2853 | actionAttribute: "data-action", |
| 2854 | targetAttribute: "data-target", |
| 2855 | targetAttributeForScope: function(identifier) { |
| 2856 | return "data-".concat(identifier, "-target"); |
| 2857 | } |
| 2858 | }; |
| 2859 | var Application = /*#__PURE__*/ function() { |
| 2860 | "use strict"; |
| 2861 | function Application() { |
| 2862 | var element = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : document.documentElement, schema = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultSchema; |
| 2863 | var _this = this; |
| 2864 | (0, _classCallCheckJsDefault.default)(this, Application); |
| 2865 | this.logger = console; |
| 2866 | this.debug = false; |
| 2867 | this.logDebugActivity = function(identifier, functionName) { |
| 2868 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2869 | if (_this.debug) _this.logFormattedMessage(identifier, functionName, detail); |
| 2870 | }; |
| 2871 | this.element = element; |
| 2872 | this.schema = schema; |
| 2873 | this.dispatcher = new Dispatcher(this); |
| 2874 | this.router = new Router(this); |
| 2875 | } |
| 2876 | (0, _createClassJsDefault.default)(Application, [ |
| 2877 | { |
| 2878 | key: "start", |
| 2879 | value: function start() { |
| 2880 | var _this = this; |
| 2881 | return (0, _asyncToGeneratorJsDefault.default)((0, _regeneratorRuntimeDefault.default).mark(function _callee() { |
| 2882 | return (0, _regeneratorRuntimeDefault.default).wrap(function _callee$(_ctx) { |
| 2883 | while(1)switch(_ctx.prev = _ctx.next){ |
| 2884 | case 0: |
| 2885 | _ctx.next = 2; |
| 2886 | return domReady(); |
| 2887 | case 2: |
| 2888 | _this.logDebugActivity("application", "starting"); |
| 2889 | _this.dispatcher.start(); |
| 2890 | _this.router.start(); |
| 2891 | _this.logDebugActivity("application", "start"); |
| 2892 | case 6: |
| 2893 | case "end": |
| 2894 | return _ctx.stop(); |
| 2895 | } |
| 2896 | }, _callee); |
| 2897 | }))(); |
| 2898 | } |
| 2899 | }, |
| 2900 | { |
| 2901 | key: "stop", |
| 2902 | value: function stop() { |
| 2903 | this.logDebugActivity("application", "stopping"); |
| 2904 | this.dispatcher.stop(); |
| 2905 | this.router.stop(); |
| 2906 | this.logDebugActivity("application", "stop"); |
| 2907 | } |
| 2908 | }, |
| 2909 | { |
| 2910 | key: "register", |
| 2911 | value: function register(identifier, controllerConstructor) { |
| 2912 | if (controllerConstructor.shouldLoad) this.load({ |
| 2913 | identifier: identifier, |
| 2914 | controllerConstructor: controllerConstructor |
| 2915 | }); |
| 2916 | } |
| 2917 | }, |
| 2918 | { |
| 2919 | key: "load", |
| 2920 | value: function load(head) { |
| 2921 | for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2922 | rest[_key - 1] = arguments[_key]; |
| 2923 | } |
| 2924 | var _this = this; |
| 2925 | var definitions = Array.isArray(head) ? head : [ |
| 2926 | head |
| 2927 | ].concat((0, _toConsumableArrayJsDefault.default)(rest)); |
| 2928 | definitions.forEach(function(definition) { |
| 2929 | return _this.router.loadDefinition(definition); |
| 2930 | }); |
| 2931 | } |
| 2932 | }, |
| 2933 | { |
| 2934 | key: "unload", |
| 2935 | value: function unload(head) { |
| 2936 | for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ |
| 2937 | rest[_key - 1] = arguments[_key]; |
| 2938 | } |
| 2939 | var _this = this; |
| 2940 | var identifiers = Array.isArray(head) ? head : [ |
| 2941 | head |
| 2942 | ].concat((0, _toConsumableArrayJsDefault.default)(rest)); |
| 2943 | identifiers.forEach(function(identifier) { |
| 2944 | return _this.router.unloadIdentifier(identifier); |
| 2945 | }); |
| 2946 | } |
| 2947 | }, |
| 2948 | { |
| 2949 | key: "controllers", |
| 2950 | get: function get() { |
| 2951 | return this.router.contexts.map(function(context) { |
| 2952 | return context.controller; |
| 2953 | }); |
| 2954 | } |
| 2955 | }, |
| 2956 | { |
| 2957 | key: "getControllerForElementAndIdentifier", |
| 2958 | value: function getControllerForElementAndIdentifier(element, identifier) { |
| 2959 | var context = this.router.getContextForElementAndIdentifier(element, identifier); |
| 2960 | return context ? context.controller : null; |
| 2961 | } |
| 2962 | }, |
| 2963 | { |
| 2964 | key: "handleError", |
| 2965 | value: function handleError(error9, message, detail) { |
| 2966 | var _a; |
| 2967 | this.logger.error("%s\n\n%o\n\n%o", message, error9, detail); |
| 2968 | (_a = window.onerror) === null || _a === void 0 || _a.call(window, message, "", 0, 0, error9); |
| 2969 | } |
| 2970 | }, |
| 2971 | { |
| 2972 | key: "logFormattedMessage", |
| 2973 | value: function logFormattedMessage(identifier, functionName) { |
| 2974 | var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 2975 | detail = Object.assign({ |
| 2976 | application: this |
| 2977 | }, detail); |
| 2978 | this.logger.groupCollapsed("".concat(identifier, " #").concat(functionName)); |
| 2979 | this.logger.log("details:", Object.assign({}, detail)); |
| 2980 | this.logger.groupEnd(); |
| 2981 | } |
| 2982 | } |
| 2983 | ], [ |
| 2984 | { |
| 2985 | key: "start", |
| 2986 | value: function start(element, schema) { |
| 2987 | var application = new Application(element, schema); |
| 2988 | application.start(); |
| 2989 | return application; |
| 2990 | } |
| 2991 | } |
| 2992 | ]); |
| 2993 | return Application; |
| 2994 | }(); |
| 2995 | function domReady() { |
| 2996 | return new Promise(function(resolve) { |
| 2997 | if (document.readyState == "loading") document.addEventListener("DOMContentLoaded", function() { |
| 2998 | return resolve(); |
| 2999 | }); |
| 3000 | else resolve(); |
| 3001 | }); |
| 3002 | } |
| 3003 | function ClassPropertiesBlessing(constructor) { |
| 3004 | var classes = readInheritableStaticArrayValues(constructor, "classes"); |
| 3005 | return classes.reduce(function(properties, classDefinition) { |
| 3006 | return Object.assign(properties, propertiesForClassDefinition(classDefinition)); |
| 3007 | }, {}); |
| 3008 | } |
| 3009 | function propertiesForClassDefinition(key) { |
| 3010 | var _obj; |
| 3011 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Class"), { |
| 3012 | get: function() { |
| 3013 | var classes = this.classes; |
| 3014 | if (classes.has(key)) return classes.get(key); |
| 3015 | else { |
| 3016 | var attribute = classes.getAttributeName(key); |
| 3017 | throw new Error('Missing attribute "'.concat(attribute, '"')); |
| 3018 | } |
| 3019 | } |
| 3020 | }), (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Classes"), { |
| 3021 | get: function() { |
| 3022 | return this.classes.getAll(key); |
| 3023 | } |
| 3024 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(key), "Class"), { |
| 3025 | get: function() { |
| 3026 | return this.classes.has(key); |
| 3027 | } |
| 3028 | }), _obj; |
| 3029 | } |
| 3030 | function TargetPropertiesBlessing(constructor) { |
| 3031 | var targets = readInheritableStaticArrayValues(constructor, "targets"); |
| 3032 | return targets.reduce(function(properties, targetDefinition) { |
| 3033 | return Object.assign(properties, propertiesForTargetDefinition(targetDefinition)); |
| 3034 | }, {}); |
| 3035 | } |
| 3036 | function propertiesForTargetDefinition(name) { |
| 3037 | var _obj; |
| 3038 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Target"), { |
| 3039 | get: function() { |
| 3040 | var target = this.targets.find(name); |
| 3041 | if (target) return target; |
| 3042 | else throw new Error('Missing target element "'.concat(name, '" for "').concat(this.identifier, '" controller')); |
| 3043 | } |
| 3044 | }), (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Targets"), { |
| 3045 | get: function() { |
| 3046 | return this.targets.findAll(name); |
| 3047 | } |
| 3048 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name), "Target"), { |
| 3049 | get: function() { |
| 3050 | return this.targets.has(name); |
| 3051 | } |
| 3052 | }), _obj; |
| 3053 | } |
| 3054 | function ValuePropertiesBlessing(constructor) { |
| 3055 | var valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values"); |
| 3056 | var propertyDescriptorMap = { |
| 3057 | valueDescriptorMap: { |
| 3058 | get: function() { |
| 3059 | var _this = this; |
| 3060 | return valueDefinitionPairs.reduce(function(result, valueDefinitionPair) { |
| 3061 | var valueDescriptor = parseValueDefinitionPair(valueDefinitionPair); |
| 3062 | var attributeName = _this.data.getAttributeNameForKey(valueDescriptor.key); |
| 3063 | return Object.assign(result, (0, _definePropertyJsDefault.default)({}, attributeName, valueDescriptor)); |
| 3064 | }, {}); |
| 3065 | } |
| 3066 | } |
| 3067 | }; |
| 3068 | return valueDefinitionPairs.reduce(function(properties, valueDefinitionPair) { |
| 3069 | return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair)); |
| 3070 | }, propertyDescriptorMap); |
| 3071 | } |
| 3072 | function propertiesForValueDefinitionPair(valueDefinitionPair) { |
| 3073 | var definition = parseValueDefinitionPair(valueDefinitionPair); |
| 3074 | var key = definition.key, name = definition.name, read = definition.reader, write = definition.writer; |
| 3075 | var _obj; |
| 3076 | return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, name, { |
| 3077 | get: function() { |
| 3078 | var value = this.data.get(key); |
| 3079 | if (value !== null) return read(value); |
| 3080 | else return definition.defaultValue; |
| 3081 | }, |
| 3082 | set: function(value) { |
| 3083 | if (value === undefined) this.data.delete(key); |
| 3084 | else this.data.set(key, write(value)); |
| 3085 | } |
| 3086 | }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name)), { |
| 3087 | get: function() { |
| 3088 | return this.data.has(key) || definition.hasCustomDefaultValue; |
| 3089 | } |
| 3090 | }), _obj; |
| 3091 | } |
| 3092 | function parseValueDefinitionPair(param) { |
| 3093 | var _param = (0, _slicedToArrayJsDefault.default)(param, 2), token = _param[0], typeDefinition = _param[1]; |
| 3094 | return valueDescriptorForTokenAndTypeDefinition(token, typeDefinition); |
| 3095 | } |
| 3096 | function parseValueTypeConstant(constant) { |
| 3097 | switch(constant){ |
| 3098 | case Array: |
| 3099 | return "array"; |
| 3100 | case Boolean: |
| 3101 | return "boolean"; |
| 3102 | case Number: |
| 3103 | return "number"; |
| 3104 | case Object: |
| 3105 | return "object"; |
| 3106 | case String: |
| 3107 | return "string"; |
| 3108 | } |
| 3109 | } |
| 3110 | function parseValueTypeDefault(defaultValue) { |
| 3111 | switch(typeof defaultValue === "undefined" ? "undefined" : (0, _typeOfJsDefault.default)(defaultValue)){ |
| 3112 | case "boolean": |
| 3113 | return "boolean"; |
| 3114 | case "number": |
| 3115 | return "number"; |
| 3116 | case "string": |
| 3117 | return "string"; |
| 3118 | } |
| 3119 | if (Array.isArray(defaultValue)) return "array"; |
| 3120 | if (Object.prototype.toString.call(defaultValue) === "[object Object]") return "object"; |
| 3121 | } |
| 3122 | function parseValueTypeObject(typeObject) { |
| 3123 | var typeFromObject = parseValueTypeConstant(typeObject.type); |
| 3124 | if (typeFromObject) { |
| 3125 | var defaultValueType = parseValueTypeDefault(typeObject.default); |
| 3126 | 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, '"')); |
| 3127 | return typeFromObject; |
| 3128 | } |
| 3129 | } |
| 3130 | function parseValueTypeDefinition(typeDefinition) { |
| 3131 | var typeFromObject = parseValueTypeObject(typeDefinition); |
| 3132 | var typeFromDefaultValue = parseValueTypeDefault(typeDefinition); |
| 3133 | var typeFromConstant = parseValueTypeConstant(typeDefinition); |
| 3134 | var type = typeFromObject || typeFromDefaultValue || typeFromConstant; |
| 3135 | if (type) return type; |
| 3136 | throw new Error('Unknown value type "'.concat(typeDefinition, '"')); |
| 3137 | } |
| 3138 | function defaultValueForDefinition(typeDefinition) { |
| 3139 | var constant = parseValueTypeConstant(typeDefinition); |
| 3140 | if (constant) return defaultValuesByType[constant]; |
| 3141 | var defaultValue = typeDefinition.default; |
| 3142 | if (defaultValue !== undefined) return defaultValue; |
| 3143 | return typeDefinition; |
| 3144 | } |
| 3145 | function valueDescriptorForTokenAndTypeDefinition(token, typeDefinition) { |
| 3146 | var key = "".concat(dasherize(token), "-value"); |
| 3147 | var type = parseValueTypeDefinition(typeDefinition); |
| 3148 | return { |
| 3149 | type: type, |
| 3150 | key: key, |
| 3151 | name: camelize(key), |
| 3152 | get defaultValue () { |
| 3153 | return defaultValueForDefinition(typeDefinition); |
| 3154 | }, |
| 3155 | get hasCustomDefaultValue () { |
| 3156 | return parseValueTypeDefault(typeDefinition) !== undefined; |
| 3157 | }, |
| 3158 | reader: readers[type], |
| 3159 | writer: writers[type] || writers.default |
| 3160 | }; |
| 3161 | } |
| 3162 | var defaultValuesByType = { |
| 3163 | get array () { |
| 3164 | return []; |
| 3165 | }, |
| 3166 | boolean: false, |
| 3167 | number: 0, |
| 3168 | get object () { |
| 3169 | return {}; |
| 3170 | }, |
| 3171 | string: "" |
| 3172 | }; |
| 3173 | var readers = { |
| 3174 | array: function(value) { |
| 3175 | var array = JSON.parse(value); |
| 3176 | if (!Array.isArray(array)) throw new TypeError("Expected array"); |
| 3177 | return array; |
| 3178 | }, |
| 3179 | boolean: function(value) { |
| 3180 | return !(value == "0" || value == "false"); |
| 3181 | }, |
| 3182 | number: function(value) { |
| 3183 | return Number(value); |
| 3184 | }, |
| 3185 | object: function(value) { |
| 3186 | var object = JSON.parse(value); |
| 3187 | if (object === null || typeof object != "object" || Array.isArray(object)) throw new TypeError("Expected object"); |
| 3188 | return object; |
| 3189 | }, |
| 3190 | string: function(value) { |
| 3191 | return value; |
| 3192 | } |
| 3193 | }; |
| 3194 | var writers = { |
| 3195 | default: writeString, |
| 3196 | array: writeJSON, |
| 3197 | object: writeJSON |
| 3198 | }; |
| 3199 | function writeJSON(value) { |
| 3200 | return JSON.stringify(value); |
| 3201 | } |
| 3202 | function writeString(value) { |
| 3203 | return "".concat(value); |
| 3204 | } |
| 3205 | var Controller = /*#__PURE__*/ function() { |
| 3206 | "use strict"; |
| 3207 | function Controller(context) { |
| 3208 | (0, _classCallCheckJsDefault.default)(this, Controller); |
| 3209 | this.context = context; |
| 3210 | } |
| 3211 | (0, _createClassJsDefault.default)(Controller, [ |
| 3212 | { |
| 3213 | key: "application", |
| 3214 | get: function get() { |
| 3215 | return this.context.application; |
| 3216 | } |
| 3217 | }, |
| 3218 | { |
| 3219 | key: "scope", |
| 3220 | get: function get() { |
| 3221 | return this.context.scope; |
| 3222 | } |
| 3223 | }, |
| 3224 | { |
| 3225 | key: "element", |
| 3226 | get: function get() { |
| 3227 | return this.scope.element; |
| 3228 | } |
| 3229 | }, |
| 3230 | { |
| 3231 | key: "identifier", |
| 3232 | get: function get() { |
| 3233 | return this.scope.identifier; |
| 3234 | } |
| 3235 | }, |
| 3236 | { |
| 3237 | key: "targets", |
| 3238 | get: function get() { |
| 3239 | return this.scope.targets; |
| 3240 | } |
| 3241 | }, |
| 3242 | { |
| 3243 | key: "classes", |
| 3244 | get: function get() { |
| 3245 | return this.scope.classes; |
| 3246 | } |
| 3247 | }, |
| 3248 | { |
| 3249 | key: "data", |
| 3250 | get: function get() { |
| 3251 | return this.scope.data; |
| 3252 | } |
| 3253 | }, |
| 3254 | { |
| 3255 | key: "initialize", |
| 3256 | value: function initialize() {} |
| 3257 | }, |
| 3258 | { |
| 3259 | key: "connect", |
| 3260 | value: function connect() {} |
| 3261 | }, |
| 3262 | { |
| 3263 | key: "disconnect", |
| 3264 | value: function disconnect() {} |
| 3265 | }, |
| 3266 | { |
| 3267 | key: "dispatch", |
| 3268 | value: function dispatch(eventName) { |
| 3269 | 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; |
| 3270 | var type = prefix ? "".concat(prefix, ":").concat(eventName) : eventName; |
| 3271 | var event = new CustomEvent(type, { |
| 3272 | detail: detail, |
| 3273 | bubbles: bubbles, |
| 3274 | cancelable: cancelable |
| 3275 | }); |
| 3276 | target.dispatchEvent(event); |
| 3277 | return event; |
| 3278 | } |
| 3279 | } |
| 3280 | ], [ |
| 3281 | { |
| 3282 | key: "shouldLoad", |
| 3283 | get: function get() { |
| 3284 | return true; |
| 3285 | } |
| 3286 | } |
| 3287 | ]); |
| 3288 | return Controller; |
| 3289 | }(); |
| 3290 | Controller.blessings = [ |
| 3291 | ClassPropertiesBlessing, |
| 3292 | TargetPropertiesBlessing, |
| 3293 | ValuePropertiesBlessing |
| 3294 | ]; |
| 3295 | Controller.targets = []; |
| 3296 | Controller.values = {}; |
| 3297 | |
| 3298 | },{"@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) { |
| 3299 | "use strict"; |
| 3300 | Object.defineProperty(exports, "__esModule", { |
| 3301 | value: true |
| 3302 | }); |
| 3303 | exports.default = _asyncToGenerator; |
| 3304 | function _asyncToGenerator(fn) { |
| 3305 | return function() { |
| 3306 | var self = this, args = arguments; |
| 3307 | return new Promise(function(resolve, reject) { |
| 3308 | var gen = fn.apply(self, args); |
| 3309 | function _next(value) { |
| 3310 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
| 3311 | } |
| 3312 | function _throw(err) { |
| 3313 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
| 3314 | } |
| 3315 | _next(undefined); |
| 3316 | }); |
| 3317 | }; |
| 3318 | } |
| 3319 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
| 3320 | try { |
| 3321 | var info = gen[key](arg); |
| 3322 | var value = info.value; |
| 3323 | } catch (error) { |
| 3324 | reject(error); |
| 3325 | return; |
| 3326 | } |
| 3327 | if (info.done) resolve(value); |
| 3328 | else Promise.resolve(value).then(_next, _throw); |
| 3329 | } |
| 3330 | |
| 3331 | },{}],"gNxF8":[function(require,module,exports) { |
| 3332 | "use strict"; |
| 3333 | Object.defineProperty(exports, "__esModule", { |
| 3334 | value: true |
| 3335 | }); |
| 3336 | exports.default = _classCallCheck; |
| 3337 | function _classCallCheck(instance, Constructor) { |
| 3338 | if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); |
| 3339 | } |
| 3340 | |
| 3341 | },{}],"iyoaN":[function(require,module,exports) { |
| 3342 | "use strict"; |
| 3343 | Object.defineProperty(exports, "__esModule", { |
| 3344 | value: true |
| 3345 | }); |
| 3346 | exports.default = _createClass; |
| 3347 | function _createClass(Constructor, protoProps, staticProps) { |
| 3348 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
| 3349 | if (staticProps) _defineProperties(Constructor, staticProps); |
| 3350 | return Constructor; |
| 3351 | } |
| 3352 | function _defineProperties(target, props) { |
| 3353 | for(var i = 0; i < props.length; i++){ |
| 3354 | var descriptor = props[i]; |
| 3355 | descriptor.enumerable = descriptor.enumerable || false; |
| 3356 | descriptor.configurable = true; |
| 3357 | if ("value" in descriptor) descriptor.writable = true; |
| 3358 | Object.defineProperty(target, descriptor.key, descriptor); |
| 3359 | } |
| 3360 | } |
| 3361 | |
| 3362 | },{}],"6IXzf":[function(require,module,exports) { |
| 3363 | "use strict"; |
| 3364 | Object.defineProperty(exports, "__esModule", { |
| 3365 | value: true |
| 3366 | }); |
| 3367 | exports.default = _defineProperty; |
| 3368 | function _defineProperty(obj, key, value) { |
| 3369 | if (key in obj) Object.defineProperty(obj, key, { |
| 3370 | value: value, |
| 3371 | enumerable: true, |
| 3372 | configurable: true, |
| 3373 | writable: true |
| 3374 | }); |
| 3375 | else obj[key] = value; |
| 3376 | return obj; |
| 3377 | } |
| 3378 | |
| 3379 | },{}],"5g4pb":[function(require,module,exports) { |
| 3380 | "use strict"; |
| 3381 | Object.defineProperty(exports, "__esModule", { |
| 3382 | value: true |
| 3383 | }); |
| 3384 | exports.default = _get; |
| 3385 | var _superPropBase = _interopRequireDefault(require("./_super_prop_base")); |
| 3386 | function _get(target, property, receiver) { |
| 3387 | return get(target, property, receiver); |
| 3388 | } |
| 3389 | function _interopRequireDefault(obj) { |
| 3390 | return obj && obj.__esModule ? obj : { |
| 3391 | default: obj |
| 3392 | }; |
| 3393 | } |
| 3394 | function get(target1, property1, receiver1) { |
| 3395 | if (typeof Reflect !== "undefined" && Reflect.get) get = Reflect.get; |
| 3396 | else get = function get(target, property, receiver) { |
| 3397 | var base = _superPropBase.default(target, property); |
| 3398 | if (!base) return; |
| 3399 | var desc = Object.getOwnPropertyDescriptor(base, property); |
| 3400 | if (desc.get) return desc.get.call(receiver || target); |
| 3401 | return desc.value; |
| 3402 | }; |
| 3403 | return get(target1, property1, receiver1); |
| 3404 | } |
| 3405 | |
| 3406 | },{"./_super_prop_base":"cT49D"}],"cT49D":[function(require,module,exports) { |
| 3407 | "use strict"; |
| 3408 | Object.defineProperty(exports, "__esModule", { |
| 3409 | value: true |
| 3410 | }); |
| 3411 | exports.default = _superPropBase; |
| 3412 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 3413 | function _superPropBase(object, property) { |
| 3414 | while(!Object.prototype.hasOwnProperty.call(object, property)){ |
| 3415 | object = _getPrototypeOf.default(object); |
| 3416 | if (object === null) break; |
| 3417 | } |
| 3418 | return object; |
| 3419 | } |
| 3420 | function _interopRequireDefault(obj) { |
| 3421 | return obj && obj.__esModule ? obj : { |
| 3422 | default: obj |
| 3423 | }; |
| 3424 | } |
| 3425 | |
| 3426 | },{"./_get_prototype_of":"7Gb6H"}],"7Gb6H":[function(require,module,exports) { |
| 3427 | "use strict"; |
| 3428 | Object.defineProperty(exports, "__esModule", { |
| 3429 | value: true |
| 3430 | }); |
| 3431 | exports.default = _getPrototypeOf; |
| 3432 | function _getPrototypeOf(o) { |
| 3433 | return getPrototypeOf(o); |
| 3434 | } |
| 3435 | function getPrototypeOf(o1) { |
| 3436 | getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { |
| 3437 | return o.__proto__ || Object.getPrototypeOf(o); |
| 3438 | }; |
| 3439 | return getPrototypeOf(o1); |
| 3440 | } |
| 3441 | |
| 3442 | },{}],"atvDk":[function(require,module,exports) { |
| 3443 | "use strict"; |
| 3444 | Object.defineProperty(exports, "__esModule", { |
| 3445 | value: true |
| 3446 | }); |
| 3447 | exports.default = _inherits; |
| 3448 | var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of")); |
| 3449 | function _inherits(subClass, superClass) { |
| 3450 | if (typeof superClass !== "function" && superClass !== null) throw new TypeError("Super expression must either be null or a function"); |
| 3451 | subClass.prototype = Object.create(superClass && superClass.prototype, { |
| 3452 | constructor: { |
| 3453 | value: subClass, |
| 3454 | writable: true, |
| 3455 | configurable: true |
| 3456 | } |
| 3457 | }); |
| 3458 | if (superClass) _setPrototypeOf.default(subClass, superClass); |
| 3459 | } |
| 3460 | function _interopRequireDefault(obj) { |
| 3461 | return obj && obj.__esModule ? obj : { |
| 3462 | default: obj |
| 3463 | }; |
| 3464 | } |
| 3465 | |
| 3466 | },{"./_set_prototype_of":"1rATD"}],"1rATD":[function(require,module,exports) { |
| 3467 | "use strict"; |
| 3468 | Object.defineProperty(exports, "__esModule", { |
| 3469 | value: true |
| 3470 | }); |
| 3471 | exports.default = _setPrototypeOf; |
| 3472 | function _setPrototypeOf(o, p) { |
| 3473 | return setPrototypeOf(o, p); |
| 3474 | } |
| 3475 | function setPrototypeOf(o1, p1) { |
| 3476 | setPrototypeOf = Object.setPrototypeOf || function setPrototypeOf(o, p) { |
| 3477 | o.__proto__ = p; |
| 3478 | return o; |
| 3479 | }; |
| 3480 | return setPrototypeOf(o1, p1); |
| 3481 | } |
| 3482 | |
| 3483 | },{}],"4IWLM":[function(require,module,exports) { |
| 3484 | "use strict"; |
| 3485 | Object.defineProperty(exports, "__esModule", { |
| 3486 | value: true |
| 3487 | }); |
| 3488 | exports.default = _slicedToArray; |
| 3489 | var _arrayWithHoles = _interopRequireDefault(require("./_array_with_holes")); |
| 3490 | var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array")); |
| 3491 | var _nonIterableRest = _interopRequireDefault(require("./_non_iterable_rest")); |
| 3492 | var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array")); |
| 3493 | function _slicedToArray(arr, i) { |
| 3494 | return _arrayWithHoles.default(arr) || _iterableToArray.default(arr, i) || _unsupportedIterableToArray.default(arr, i) || _nonIterableRest.default(); |
| 3495 | } |
| 3496 | function _interopRequireDefault(obj) { |
| 3497 | return obj && obj.__esModule ? obj : { |
| 3498 | default: obj |
| 3499 | }; |
| 3500 | } |
| 3501 | |
| 3502 | },{"./_array_with_holes":"kAkr9","./_iterable_to_array":"d0B07","./_non_iterable_rest":"bXNgi","./_unsupported_iterable_to_array":"jhPJb"}],"kAkr9":[function(require,module,exports) { |
| 3503 | "use strict"; |
| 3504 | Object.defineProperty(exports, "__esModule", { |
| 3505 | value: true |
| 3506 | }); |
| 3507 | exports.default = _arrayWithHoles; |
| 3508 | function _arrayWithHoles(arr) { |
| 3509 | if (Array.isArray(arr)) return arr; |
| 3510 | } |
| 3511 | |
| 3512 | },{}],"d0B07":[function(require,module,exports) { |
| 3513 | "use strict"; |
| 3514 | Object.defineProperty(exports, "__esModule", { |
| 3515 | value: true |
| 3516 | }); |
| 3517 | exports.default = _iterableToArray; |
| 3518 | function _iterableToArray(iter) { |
| 3519 | if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); |
| 3520 | } |
| 3521 | |
| 3522 | },{}],"bXNgi":[function(require,module,exports) { |
| 3523 | "use strict"; |
| 3524 | Object.defineProperty(exports, "__esModule", { |
| 3525 | value: true |
| 3526 | }); |
| 3527 | exports.default = _nonIterableRest; |
| 3528 | function _nonIterableRest() { |
| 3529 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 3530 | } |
| 3531 | |
| 3532 | },{}],"jhPJb":[function(require,module,exports) { |
| 3533 | "use strict"; |
| 3534 | Object.defineProperty(exports, "__esModule", { |
| 3535 | value: true |
| 3536 | }); |
| 3537 | exports.default = _unsupportedIterableToArray; |
| 3538 | var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array")); |
| 3539 | function _unsupportedIterableToArray(o, minLen) { |
| 3540 | if (!o) return; |
| 3541 | if (typeof o === "string") return _arrayLikeToArray.default(o, minLen); |
| 3542 | var n = Object.prototype.toString.call(o).slice(8, -1); |
| 3543 | if (n === "Object" && o.constructor) n = o.constructor.name; |
| 3544 | if (n === "Map" || n === "Set") return Array.from(n); |
| 3545 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray.default(o, minLen); |
| 3546 | } |
| 3547 | function _interopRequireDefault(obj) { |
| 3548 | return obj && obj.__esModule ? obj : { |
| 3549 | default: obj |
| 3550 | }; |
| 3551 | } |
| 3552 | |
| 3553 | },{"./_array_like_to_array":"4K9fh"}],"4K9fh":[function(require,module,exports) { |
| 3554 | "use strict"; |
| 3555 | Object.defineProperty(exports, "__esModule", { |
| 3556 | value: true |
| 3557 | }); |
| 3558 | exports.default = _arrayLikeToArray; |
| 3559 | function _arrayLikeToArray(arr, len) { |
| 3560 | if (len == null || len > arr.length) len = arr.length; |
| 3561 | for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; |
| 3562 | return arr2; |
| 3563 | } |
| 3564 | |
| 3565 | },{}],"cccKv":[function(require,module,exports) { |
| 3566 | "use strict"; |
| 3567 | Object.defineProperty(exports, "__esModule", { |
| 3568 | value: true |
| 3569 | }); |
| 3570 | exports.default = _toConsumableArray; |
| 3571 | var _arrayWithoutHoles = _interopRequireDefault(require("./_array_without_holes")); |
| 3572 | var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array")); |
| 3573 | var _nonIterableSpread = _interopRequireDefault(require("./_non_iterable_spread")); |
| 3574 | var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array")); |
| 3575 | function _toConsumableArray(arr) { |
| 3576 | return _arrayWithoutHoles.default(arr) || _iterableToArray.default(arr) || _unsupportedIterableToArray.default(arr) || _nonIterableSpread.default(); |
| 3577 | } |
| 3578 | function _interopRequireDefault(obj) { |
| 3579 | return obj && obj.__esModule ? obj : { |
| 3580 | default: obj |
| 3581 | }; |
| 3582 | } |
| 3583 | |
| 3584 | },{"./_array_without_holes":"26osg","./_iterable_to_array":"d0B07","./_non_iterable_spread":"nlNPL","./_unsupported_iterable_to_array":"jhPJb"}],"26osg":[function(require,module,exports) { |
| 3585 | "use strict"; |
| 3586 | Object.defineProperty(exports, "__esModule", { |
| 3587 | value: true |
| 3588 | }); |
| 3589 | exports.default = _arrayWithoutHoles; |
| 3590 | var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array")); |
| 3591 | function _arrayWithoutHoles(arr) { |
| 3592 | if (Array.isArray(arr)) return _arrayLikeToArray.default(arr); |
| 3593 | } |
| 3594 | function _interopRequireDefault(obj) { |
| 3595 | return obj && obj.__esModule ? obj : { |
| 3596 | default: obj |
| 3597 | }; |
| 3598 | } |
| 3599 | |
| 3600 | },{"./_array_like_to_array":"4K9fh"}],"nlNPL":[function(require,module,exports) { |
| 3601 | "use strict"; |
| 3602 | Object.defineProperty(exports, "__esModule", { |
| 3603 | value: true |
| 3604 | }); |
| 3605 | exports.default = _nonIterableSpread; |
| 3606 | function _nonIterableSpread() { |
| 3607 | throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 3608 | } |
| 3609 | |
| 3610 | },{}],"9FF45":[function(require,module,exports) { |
| 3611 | "use strict"; |
| 3612 | Object.defineProperty(exports, "__esModule", { |
| 3613 | value: true |
| 3614 | }); |
| 3615 | exports.default = _typeof; |
| 3616 | function _typeof(obj) { |
| 3617 | "@swc/helpers - typeof"; |
| 3618 | return obj && obj.constructor === Symbol ? "symbol" : typeof obj; |
| 3619 | } |
| 3620 | |
| 3621 | },{}],"5rW3S":[function(require,module,exports) { |
| 3622 | "use strict"; |
| 3623 | Object.defineProperty(exports, "__esModule", { |
| 3624 | value: true |
| 3625 | }); |
| 3626 | exports.default = _createSuper; |
| 3627 | var _isNativeReflectConstruct = _interopRequireDefault(require("./_is_native_reflect_construct")); |
| 3628 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 3629 | var _possibleConstructorReturn = _interopRequireDefault(require("./_possible_constructor_return")); |
| 3630 | function _createSuper(Derived) { |
| 3631 | var hasNativeReflectConstruct = _isNativeReflectConstruct.default(); |
| 3632 | return function _createSuperInternal() { |
| 3633 | var Super = _getPrototypeOf.default(Derived), result; |
| 3634 | if (hasNativeReflectConstruct) { |
| 3635 | var NewTarget = _getPrototypeOf.default(this).constructor; |
| 3636 | result = Reflect.construct(Super, arguments, NewTarget); |
| 3637 | } else result = Super.apply(this, arguments); |
| 3638 | return _possibleConstructorReturn.default(this, result); |
| 3639 | }; |
| 3640 | } |
| 3641 | function _interopRequireDefault(obj) { |
| 3642 | return obj && obj.__esModule ? obj : { |
| 3643 | default: obj |
| 3644 | }; |
| 3645 | } |
| 3646 | |
| 3647 | },{"./_is_native_reflect_construct":"aPH71","./_get_prototype_of":"7Gb6H","./_possible_constructor_return":"hAvqf"}],"aPH71":[function(require,module,exports) { |
| 3648 | "use strict"; |
| 3649 | Object.defineProperty(exports, "__esModule", { |
| 3650 | value: true |
| 3651 | }); |
| 3652 | exports.default = _isNativeReflectConstruct; |
| 3653 | function _isNativeReflectConstruct() { |
| 3654 | if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
| 3655 | if (Reflect.construct.sham) return false; |
| 3656 | if (typeof Proxy === "function") return true; |
| 3657 | try { |
| 3658 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); |
| 3659 | return true; |
| 3660 | } catch (e) { |
| 3661 | return false; |
| 3662 | } |
| 3663 | } |
| 3664 | |
| 3665 | },{}],"hAvqf":[function(require,module,exports) { |
| 3666 | "use strict"; |
| 3667 | Object.defineProperty(exports, "__esModule", { |
| 3668 | value: true |
| 3669 | }); |
| 3670 | exports.default = _possibleConstructorReturn; |
| 3671 | var _assertThisInitialized = _interopRequireDefault(require("./_assert_this_initialized")); |
| 3672 | var _typeOf = _interopRequireDefault(require("./_type_of")); |
| 3673 | function _possibleConstructorReturn(self, call) { |
| 3674 | if (call && (_typeOf.default(call) === "object" || typeof call === "function")) return call; |
| 3675 | return _assertThisInitialized.default(self); |
| 3676 | } |
| 3677 | function _interopRequireDefault(obj) { |
| 3678 | return obj && obj.__esModule ? obj : { |
| 3679 | default: obj |
| 3680 | }; |
| 3681 | } |
| 3682 | |
| 3683 | },{"./_assert_this_initialized":"l7nF8","./_type_of":"9FF45"}],"l7nF8":[function(require,module,exports) { |
| 3684 | "use strict"; |
| 3685 | Object.defineProperty(exports, "__esModule", { |
| 3686 | value: true |
| 3687 | }); |
| 3688 | exports.default = _assertThisInitialized; |
| 3689 | function _assertThisInitialized(self) { |
| 3690 | if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
| 3691 | return self; |
| 3692 | } |
| 3693 | |
| 3694 | },{}],"7j2bv":[function(require,module,exports) { |
| 3695 | /** |
| 3696 | * Copyright (c) 2014-present, Facebook, Inc. |
| 3697 | * |
| 3698 | * This source code is licensed under the MIT license found in the |
| 3699 | * LICENSE file in the root directory of this source tree. |
| 3700 | */ var runtime = function(exports) { |
| 3701 | "use strict"; |
| 3702 | var define = function define(obj, key, value) { |
| 3703 | Object.defineProperty(obj, key, { |
| 3704 | value: value, |
| 3705 | enumerable: true, |
| 3706 | configurable: true, |
| 3707 | writable: true |
| 3708 | }); |
| 3709 | return obj[key]; |
| 3710 | }; |
| 3711 | var wrap = function wrap(innerFn, outerFn, self, tryLocsList) { |
| 3712 | // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
| 3713 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
| 3714 | var generator = Object.create(protoGenerator.prototype); |
| 3715 | var context = new Context(tryLocsList || []); |
| 3716 | // The ._invoke method unifies the implementations of the .next, |
| 3717 | // .throw, and .return methods. |
| 3718 | generator._invoke = makeInvokeMethod(innerFn, self, context); |
| 3719 | return generator; |
| 3720 | }; |
| 3721 | var tryCatch = // Try/catch helper to minimize deoptimizations. Returns a completion |
| 3722 | // record like context.tryEntries[i].completion. This interface could |
| 3723 | // have been (and was previously) designed to take a closure to be |
| 3724 | // invoked without arguments, but in all the cases we care about we |
| 3725 | // already have an existing method we want to call, so there's no need |
| 3726 | // to create a new function object. We can even get away with assuming |
| 3727 | // the method takes exactly one argument, since that happens to be true |
| 3728 | // in every case, so we don't have to touch the arguments object. The |
| 3729 | // only additional allocation required is the completion record, which |
| 3730 | // has a stable shape and so hopefully should be cheap to allocate. |
| 3731 | function tryCatch(fn, obj, arg) { |
| 3732 | try { |
| 3733 | return { |
| 3734 | type: "normal", |
| 3735 | arg: fn.call(obj, arg) |
| 3736 | }; |
| 3737 | } catch (err) { |
| 3738 | return { |
| 3739 | type: "throw", |
| 3740 | arg: err |
| 3741 | }; |
| 3742 | } |
| 3743 | }; |
| 3744 | var Generator = // Dummy constructor functions that we use as the .constructor and |
| 3745 | // .constructor.prototype properties for functions that return Generator |
| 3746 | // objects. For full spec compliance, you may wish to configure your |
| 3747 | // minifier not to mangle the names of these two functions. |
| 3748 | function Generator() {}; |
| 3749 | var GeneratorFunction = function GeneratorFunction() {}; |
| 3750 | var GeneratorFunctionPrototype = function GeneratorFunctionPrototype() {}; |
| 3751 | var defineIteratorMethods = // Helper for defining the .next, .throw, and .return methods of the |
| 3752 | // Iterator interface in terms of a single ._invoke method. |
| 3753 | function defineIteratorMethods(prototype) { |
| 3754 | [ |
| 3755 | "next", |
| 3756 | "throw", |
| 3757 | "return" |
| 3758 | ].forEach(function(method) { |
| 3759 | define(prototype, method, function(arg) { |
| 3760 | return this._invoke(method, arg); |
| 3761 | }); |
| 3762 | }); |
| 3763 | }; |
| 3764 | var AsyncIterator = function AsyncIterator(generator, PromiseImpl) { |
| 3765 | function invoke(method, arg, resolve, reject) { |
| 3766 | var record = tryCatch(generator[method], generator, arg); |
| 3767 | if (record.type === "throw") reject(record.arg); |
| 3768 | else { |
| 3769 | var result = record.arg; |
| 3770 | var value1 = result.value; |
| 3771 | if (value1 && typeof value1 === "object" && hasOwn.call(value1, "__await")) return PromiseImpl.resolve(value1.__await).then(function(value) { |
| 3772 | invoke("next", value, resolve, reject); |
| 3773 | }, function(err) { |
| 3774 | invoke("throw", err, resolve, reject); |
| 3775 | }); |
| 3776 | return PromiseImpl.resolve(value1).then(function(unwrapped) { |
| 3777 | // When a yielded Promise is resolved, its final value becomes |
| 3778 | // the .value of the Promise<{value,done}> result for the |
| 3779 | // current iteration. |
| 3780 | result.value = unwrapped; |
| 3781 | resolve(result); |
| 3782 | }, function(error) { |
| 3783 | // If a rejected Promise was yielded, throw the rejection back |
| 3784 | // into the async generator function so it can be handled there. |
| 3785 | return invoke("throw", error, resolve, reject); |
| 3786 | }); |
| 3787 | } |
| 3788 | } |
| 3789 | var previousPromise; |
| 3790 | function enqueue(method, arg) { |
| 3791 | function callInvokeWithMethodAndArg() { |
| 3792 | return new PromiseImpl(function(resolve, reject) { |
| 3793 | invoke(method, arg, resolve, reject); |
| 3794 | }); |
| 3795 | } |
| 3796 | return previousPromise = // If enqueue has been called before, then we want to wait until |
| 3797 | // all previous Promises have been resolved before calling invoke, |
| 3798 | // so that results are always delivered in the correct order. If |
| 3799 | // enqueue has not been called before, then it is important to |
| 3800 | // call invoke immediately, without waiting on a callback to fire, |
| 3801 | // so that the async generator function has the opportunity to do |
| 3802 | // any necessary setup in a predictable way. This predictability |
| 3803 | // is why the Promise constructor synchronously invokes its |
| 3804 | // executor callback, and why async functions synchronously |
| 3805 | // execute code before the first await. Since we implement simple |
| 3806 | // async functions in terms of async generators, it is especially |
| 3807 | // important to get this right, even though it requires care. |
| 3808 | previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later |
| 3809 | // invocations of the iterator. |
| 3810 | callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); |
| 3811 | } |
| 3812 | // Define the unified helper method that is used to implement .next, |
| 3813 | // .throw, and .return (see defineIteratorMethods). |
| 3814 | this._invoke = enqueue; |
| 3815 | }; |
| 3816 | var makeInvokeMethod = function makeInvokeMethod(innerFn, self, context) { |
| 3817 | var state = GenStateSuspendedStart; |
| 3818 | return function invoke(method, arg) { |
| 3819 | if (state === GenStateExecuting) throw new Error("Generator is already running"); |
| 3820 | if (state === GenStateCompleted) { |
| 3821 | if (method === "throw") throw arg; |
| 3822 | // Be forgiving, per 25.3.3.3.3 of the spec: |
| 3823 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
| 3824 | return doneResult(); |
| 3825 | } |
| 3826 | context.method = method; |
| 3827 | context.arg = arg; |
| 3828 | while(true){ |
| 3829 | var delegate = context.delegate; |
| 3830 | if (delegate) { |
| 3831 | var delegateResult = maybeInvokeDelegate(delegate, context); |
| 3832 | if (delegateResult) { |
| 3833 | if (delegateResult === ContinueSentinel) continue; |
| 3834 | return delegateResult; |
| 3835 | } |
| 3836 | } |
| 3837 | if (context.method === "next") // Setting context._sent for legacy support of Babel's |
| 3838 | // function.sent implementation. |
| 3839 | context.sent = context._sent = context.arg; |
| 3840 | else if (context.method === "throw") { |
| 3841 | if (state === GenStateSuspendedStart) { |
| 3842 | state = GenStateCompleted; |
| 3843 | throw context.arg; |
| 3844 | } |
| 3845 | context.dispatchException(context.arg); |
| 3846 | } else if (context.method === "return") context.abrupt("return", context.arg); |
| 3847 | state = GenStateExecuting; |
| 3848 | var record = tryCatch(innerFn, self, context); |
| 3849 | if (record.type === "normal") { |
| 3850 | // If an exception is thrown from innerFn, we leave state === |
| 3851 | // GenStateExecuting and loop back for another invocation. |
| 3852 | state = context.done ? GenStateCompleted : GenStateSuspendedYield; |
| 3853 | if (record.arg === ContinueSentinel) continue; |
| 3854 | return { |
| 3855 | value: record.arg, |
| 3856 | done: context.done |
| 3857 | }; |
| 3858 | } else if (record.type === "throw") { |
| 3859 | state = GenStateCompleted; |
| 3860 | // Dispatch the exception by looping back around to the |
| 3861 | // context.dispatchException(context.arg) call above. |
| 3862 | context.method = "throw"; |
| 3863 | context.arg = record.arg; |
| 3864 | } |
| 3865 | } |
| 3866 | }; |
| 3867 | }; |
| 3868 | var pushTryEntry = function pushTryEntry(locs) { |
| 3869 | var entry = { |
| 3870 | tryLoc: locs[0] |
| 3871 | }; |
| 3872 | if (1 in locs) entry.catchLoc = locs[1]; |
| 3873 | if (2 in locs) { |
| 3874 | entry.finallyLoc = locs[2]; |
| 3875 | entry.afterLoc = locs[3]; |
| 3876 | } |
| 3877 | this.tryEntries.push(entry); |
| 3878 | }; |
| 3879 | var resetTryEntry = function resetTryEntry(entry) { |
| 3880 | var record = entry.completion || {}; |
| 3881 | record.type = "normal"; |
| 3882 | delete record.arg; |
| 3883 | entry.completion = record; |
| 3884 | }; |
| 3885 | var Context = function Context(tryLocsList) { |
| 3886 | // The root entry object (effectively a try statement without a catch |
| 3887 | // or a finally block) gives us a place to store values thrown from |
| 3888 | // locations where there is no enclosing try statement. |
| 3889 | this.tryEntries = [ |
| 3890 | { |
| 3891 | tryLoc: "root" |
| 3892 | } |
| 3893 | ]; |
| 3894 | tryLocsList.forEach(pushTryEntry, this); |
| 3895 | this.reset(true); |
| 3896 | }; |
| 3897 | var values = function values(iterable) { |
| 3898 | if (iterable) { |
| 3899 | var iteratorMethod = iterable[iteratorSymbol]; |
| 3900 | if (iteratorMethod) return iteratorMethod.call(iterable); |
| 3901 | if (typeof iterable.next === "function") return iterable; |
| 3902 | if (!isNaN(iterable.length)) { |
| 3903 | var i = -1, next1 = function next() { |
| 3904 | while(++i < iterable.length)if (hasOwn.call(iterable, i)) { |
| 3905 | next.value = iterable[i]; |
| 3906 | next.done = false; |
| 3907 | return next; |
| 3908 | } |
| 3909 | next.value = undefined; |
| 3910 | next.done = true; |
| 3911 | return next; |
| 3912 | }; |
| 3913 | return next1.next = next1; |
| 3914 | } |
| 3915 | } |
| 3916 | // Return an iterator with no values. |
| 3917 | return { |
| 3918 | next: doneResult |
| 3919 | }; |
| 3920 | }; |
| 3921 | var doneResult = function doneResult() { |
| 3922 | return { |
| 3923 | value: undefined, |
| 3924 | done: true |
| 3925 | }; |
| 3926 | }; |
| 3927 | var Op = Object.prototype; |
| 3928 | var hasOwn = Op.hasOwnProperty; |
| 3929 | var undefined; // More compressible than void 0. |
| 3930 | var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
| 3931 | var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
| 3932 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
| 3933 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
| 3934 | try { |
| 3935 | // IE 8 has a broken Object.defineProperty that only works on DOM objects. |
| 3936 | define({}, ""); |
| 3937 | } catch (err) { |
| 3938 | define = function define(obj, key, value) { |
| 3939 | return obj[key] = value; |
| 3940 | }; |
| 3941 | } |
| 3942 | exports.wrap = wrap; |
| 3943 | var GenStateSuspendedStart = "suspendedStart"; |
| 3944 | var GenStateSuspendedYield = "suspendedYield"; |
| 3945 | var GenStateExecuting = "executing"; |
| 3946 | var GenStateCompleted = "completed"; |
| 3947 | // Returning this object from the innerFn has the same effect as |
| 3948 | // breaking out of the dispatch switch statement. |
| 3949 | var ContinueSentinel = {}; |
| 3950 | // This is a polyfill for %IteratorPrototype% for environments that |
| 3951 | // don't natively support it. |
| 3952 | var IteratorPrototype = {}; |
| 3953 | define(IteratorPrototype, iteratorSymbol, function() { |
| 3954 | return this; |
| 3955 | }); |
| 3956 | var getProto = Object.getPrototypeOf; |
| 3957 | var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
| 3958 | if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) // This environment has a native %IteratorPrototype%; use it instead |
| 3959 | // of the polyfill. |
| 3960 | IteratorPrototype = NativeIteratorPrototype; |
| 3961 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); |
| 3962 | GeneratorFunction.prototype = GeneratorFunctionPrototype; |
| 3963 | define(Gp, "constructor", GeneratorFunctionPrototype); |
| 3964 | define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); |
| 3965 | GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); |
| 3966 | exports.isGeneratorFunction = function(genFun) { |
| 3967 | var ctor = typeof genFun === "function" && genFun.constructor; |
| 3968 | return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can |
| 3969 | // do is to check its .name property. |
| 3970 | (ctor.displayName || ctor.name) === "GeneratorFunction" : false; |
| 3971 | }; |
| 3972 | exports.mark = function(genFun) { |
| 3973 | if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
| 3974 | else { |
| 3975 | genFun.__proto__ = GeneratorFunctionPrototype; |
| 3976 | define(genFun, toStringTagSymbol, "GeneratorFunction"); |
| 3977 | } |
| 3978 | genFun.prototype = Object.create(Gp); |
| 3979 | return genFun; |
| 3980 | }; |
| 3981 | // Within the body of any async function, `await x` is transformed to |
| 3982 | // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
| 3983 | // `hasOwn.call(value, "__await")` to determine if the yielded value is |
| 3984 | // meant to be awaited. |
| 3985 | exports.awrap = function(arg) { |
| 3986 | return { |
| 3987 | __await: arg |
| 3988 | }; |
| 3989 | }; |
| 3990 | defineIteratorMethods(AsyncIterator.prototype); |
| 3991 | define(AsyncIterator.prototype, asyncIteratorSymbol, function() { |
| 3992 | return this; |
| 3993 | }); |
| 3994 | exports.AsyncIterator = AsyncIterator; |
| 3995 | // Note that simple async functions are implemented on top of |
| 3996 | // AsyncIterator objects; they just return a Promise for the value of |
| 3997 | // the final result produced by the iterator. |
| 3998 | exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { |
| 3999 | if (PromiseImpl === void 0) PromiseImpl = Promise; |
| 4000 | var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); |
| 4001 | return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. |
| 4002 | : iter.next().then(function(result) { |
| 4003 | return result.done ? result.value : iter.next(); |
| 4004 | }); |
| 4005 | }; |
| 4006 | // Call delegate.iterator[context.method](context.arg) and handle the |
| 4007 | // result, either by returning a { value, done } result from the |
| 4008 | // delegate iterator, or by modifying context.method and context.arg, |
| 4009 | // setting context.delegate to null, and returning the ContinueSentinel. |
| 4010 | function maybeInvokeDelegate(delegate, context) { |
| 4011 | var method = delegate.iterator[context.method]; |
| 4012 | if (method === undefined) { |
| 4013 | // A .throw or .return when the delegate iterator has no .throw |
| 4014 | // method always terminates the yield* loop. |
| 4015 | context.delegate = null; |
| 4016 | if (context.method === "throw") { |
| 4017 | // Note: ["return"] must be used for ES3 parsing compatibility. |
| 4018 | if (delegate.iterator["return"]) { |
| 4019 | // If the delegate iterator has a return method, give it a |
| 4020 | // chance to clean up. |
| 4021 | context.method = "return"; |
| 4022 | context.arg = undefined; |
| 4023 | maybeInvokeDelegate(delegate, context); |
| 4024 | if (context.method === "throw") // If maybeInvokeDelegate(context) changed context.method from |
| 4025 | // "return" to "throw", let that override the TypeError below. |
| 4026 | return ContinueSentinel; |
| 4027 | } |
| 4028 | context.method = "throw"; |
| 4029 | context.arg = new TypeError("The iterator does not provide a 'throw' method"); |
| 4030 | } |
| 4031 | return ContinueSentinel; |
| 4032 | } |
| 4033 | var record = tryCatch(method, delegate.iterator, context.arg); |
| 4034 | if (record.type === "throw") { |
| 4035 | context.method = "throw"; |
| 4036 | context.arg = record.arg; |
| 4037 | context.delegate = null; |
| 4038 | return ContinueSentinel; |
| 4039 | } |
| 4040 | var info = record.arg; |
| 4041 | if (!info) { |
| 4042 | context.method = "throw"; |
| 4043 | context.arg = new TypeError("iterator result is not an object"); |
| 4044 | context.delegate = null; |
| 4045 | return ContinueSentinel; |
| 4046 | } |
| 4047 | if (info.done) { |
| 4048 | // Assign the result of the finished delegate to the temporary |
| 4049 | // variable specified by delegate.resultName (see delegateYield). |
| 4050 | context[delegate.resultName] = info.value; |
| 4051 | // Resume execution at the desired location (see delegateYield). |
| 4052 | context.next = delegate.nextLoc; |
| 4053 | // If context.method was "throw" but the delegate handled the |
| 4054 | // exception, let the outer generator proceed normally. If |
| 4055 | // context.method was "next", forget context.arg since it has been |
| 4056 | // "consumed" by the delegate iterator. If context.method was |
| 4057 | // "return", allow the original .return call to continue in the |
| 4058 | // outer generator. |
| 4059 | if (context.method !== "return") { |
| 4060 | context.method = "next"; |
| 4061 | context.arg = undefined; |
| 4062 | } |
| 4063 | } else // Re-yield the result returned by the delegate method. |
| 4064 | return info; |
| 4065 | // The delegate iterator is finished, so forget it and continue with |
| 4066 | // the outer generator. |
| 4067 | context.delegate = null; |
| 4068 | return ContinueSentinel; |
| 4069 | } |
| 4070 | // Define Generator.prototype.{next,throw,return} in terms of the |
| 4071 | // unified ._invoke helper method. |
| 4072 | defineIteratorMethods(Gp); |
| 4073 | define(Gp, toStringTagSymbol, "Generator"); |
| 4074 | // A Generator should always return itself as the iterator object when the |
| 4075 | // @@iterator function is called on it. Some browsers' implementations of the |
| 4076 | // iterator prototype chain incorrectly implement this, causing the Generator |
| 4077 | // object to not be returned from this call. This ensures that doesn't happen. |
| 4078 | // See https://github.com/facebook/regenerator/issues/274 for more details. |
| 4079 | define(Gp, iteratorSymbol, function() { |
| 4080 | return this; |
| 4081 | }); |
| 4082 | define(Gp, "toString", function() { |
| 4083 | return "[object Generator]"; |
| 4084 | }); |
| 4085 | exports.keys = function(object) { |
| 4086 | var keys = []; |
| 4087 | for(var key1 in object)keys.push(key1); |
| 4088 | keys.reverse(); |
| 4089 | // Rather than returning an object with a next method, we keep |
| 4090 | // things simple and return the next function itself. |
| 4091 | return function next() { |
| 4092 | while(keys.length){ |
| 4093 | var key = keys.pop(); |
| 4094 | if (key in object) { |
| 4095 | next.value = key; |
| 4096 | next.done = false; |
| 4097 | return next; |
| 4098 | } |
| 4099 | } |
| 4100 | // To avoid creating an additional object, we just hang the .value |
| 4101 | // and .done properties off the next function object itself. This |
| 4102 | // also ensures that the minifier will not anonymize the function. |
| 4103 | next.done = true; |
| 4104 | return next; |
| 4105 | }; |
| 4106 | }; |
| 4107 | exports.values = values; |
| 4108 | Context.prototype = { |
| 4109 | constructor: Context, |
| 4110 | reset: function reset(skipTempReset) { |
| 4111 | this.prev = 0; |
| 4112 | this.next = 0; |
| 4113 | // Resetting context._sent for legacy support of Babel's |
| 4114 | // function.sent implementation. |
| 4115 | this.sent = this._sent = undefined; |
| 4116 | this.done = false; |
| 4117 | this.delegate = null; |
| 4118 | this.method = "next"; |
| 4119 | this.arg = undefined; |
| 4120 | this.tryEntries.forEach(resetTryEntry); |
| 4121 | if (!skipTempReset) { |
| 4122 | for(var name in this)// Not sure about the optimal order of these conditions: |
| 4123 | if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined; |
| 4124 | } |
| 4125 | }, |
| 4126 | stop: function stop() { |
| 4127 | this.done = true; |
| 4128 | var rootEntry = this.tryEntries[0]; |
| 4129 | var rootRecord = rootEntry.completion; |
| 4130 | if (rootRecord.type === "throw") throw rootRecord.arg; |
| 4131 | return this.rval; |
| 4132 | }, |
| 4133 | dispatchException: function dispatchException(exception) { |
| 4134 | var handle = function handle(loc, caught) { |
| 4135 | record.type = "throw"; |
| 4136 | record.arg = exception; |
| 4137 | context.next = loc; |
| 4138 | if (caught) { |
| 4139 | // If the dispatched exception was caught by a catch block, |
| 4140 | // then let that catch block handle the exception normally. |
| 4141 | context.method = "next"; |
| 4142 | context.arg = undefined; |
| 4143 | } |
| 4144 | return !!caught; |
| 4145 | }; |
| 4146 | if (this.done) throw exception; |
| 4147 | var context = this; |
| 4148 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4149 | var entry = this.tryEntries[i]; |
| 4150 | var record = entry.completion; |
| 4151 | if (entry.tryLoc === "root") // Exception thrown outside of any try block that could handle |
| 4152 | // it, so set the completion value of the entire function to |
| 4153 | // throw the exception. |
| 4154 | return handle("end"); |
| 4155 | if (entry.tryLoc <= this.prev) { |
| 4156 | var hasCatch = hasOwn.call(entry, "catchLoc"); |
| 4157 | var hasFinally = hasOwn.call(entry, "finallyLoc"); |
| 4158 | if (hasCatch && hasFinally) { |
| 4159 | if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true); |
| 4160 | else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); |
| 4161 | } else if (hasCatch) { |
| 4162 | if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true); |
| 4163 | } else if (hasFinally) { |
| 4164 | if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); |
| 4165 | } else throw new Error("try statement without catch or finally"); |
| 4166 | } |
| 4167 | } |
| 4168 | }, |
| 4169 | abrupt: function abrupt(type, arg) { |
| 4170 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4171 | var entry = this.tryEntries[i]; |
| 4172 | if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { |
| 4173 | var finallyEntry = entry; |
| 4174 | break; |
| 4175 | } |
| 4176 | } |
| 4177 | if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) // Ignore the finally entry if control is not jumping to a |
| 4178 | // location outside the try/catch block. |
| 4179 | finallyEntry = null; |
| 4180 | var record = finallyEntry ? finallyEntry.completion : {}; |
| 4181 | record.type = type; |
| 4182 | record.arg = arg; |
| 4183 | if (finallyEntry) { |
| 4184 | this.method = "next"; |
| 4185 | this.next = finallyEntry.finallyLoc; |
| 4186 | return ContinueSentinel; |
| 4187 | } |
| 4188 | return this.complete(record); |
| 4189 | }, |
| 4190 | complete: function complete(record, afterLoc) { |
| 4191 | if (record.type === "throw") throw record.arg; |
| 4192 | if (record.type === "break" || record.type === "continue") this.next = record.arg; |
| 4193 | else if (record.type === "return") { |
| 4194 | this.rval = this.arg = record.arg; |
| 4195 | this.method = "return"; |
| 4196 | this.next = "end"; |
| 4197 | } else if (record.type === "normal" && afterLoc) this.next = afterLoc; |
| 4198 | return ContinueSentinel; |
| 4199 | }, |
| 4200 | finish: function finish(finallyLoc) { |
| 4201 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4202 | var entry = this.tryEntries[i]; |
| 4203 | if (entry.finallyLoc === finallyLoc) { |
| 4204 | this.complete(entry.completion, entry.afterLoc); |
| 4205 | resetTryEntry(entry); |
| 4206 | return ContinueSentinel; |
| 4207 | } |
| 4208 | } |
| 4209 | }, |
| 4210 | "catch": function(tryLoc) { |
| 4211 | for(var i = this.tryEntries.length - 1; i >= 0; --i){ |
| 4212 | var entry = this.tryEntries[i]; |
| 4213 | if (entry.tryLoc === tryLoc) { |
| 4214 | var record = entry.completion; |
| 4215 | if (record.type === "throw") { |
| 4216 | var thrown = record.arg; |
| 4217 | resetTryEntry(entry); |
| 4218 | } |
| 4219 | return thrown; |
| 4220 | } |
| 4221 | } |
| 4222 | // The context.catch method must only be called with a location |
| 4223 | // argument that corresponds to a known catch block. |
| 4224 | throw new Error("illegal catch attempt"); |
| 4225 | }, |
| 4226 | delegateYield: function delegateYield(iterable, resultName, nextLoc) { |
| 4227 | this.delegate = { |
| 4228 | iterator: values(iterable), |
| 4229 | resultName: resultName, |
| 4230 | nextLoc: nextLoc |
| 4231 | }; |
| 4232 | if (this.method === "next") // Deliberately forget the last sent value so that we don't |
| 4233 | // accidentally pass it on to the delegate. |
| 4234 | this.arg = undefined; |
| 4235 | return ContinueSentinel; |
| 4236 | } |
| 4237 | }; |
| 4238 | // Regardless of whether this script is executing as a CommonJS module |
| 4239 | // or not, return the runtime object so that we can declare the variable |
| 4240 | // regeneratorRuntime in the outer scope, which allows this module to be |
| 4241 | // injected easily by `bin/regenerator --include-runtime script.js`. |
| 4242 | return exports; |
| 4243 | }(module.exports); |
| 4244 | try { |
| 4245 | regeneratorRuntime = runtime; |
| 4246 | } catch (accidentalStrictMode) { |
| 4247 | // This module should not be running in strict mode, so the above |
| 4248 | // assignment should always work unless something is misconfigured. Just |
| 4249 | // in case runtime.js accidentally runs in strict mode, in modern engines |
| 4250 | // we can explicitly access globalThis. In older engines we can escape |
| 4251 | // strict mode using a global Function call. This could conceivably fail |
| 4252 | // if a Content Security Policy forbids using Function, but in that case |
| 4253 | // the proper solution is to fix the accidental strict mode problem. If |
| 4254 | // you've misconfigured your bundler to force strict mode and applied a |
| 4255 | // CSP to forbid Function, and you're not willing to fix either of those |
| 4256 | // problems, please detail your unique predicament in a GitHub issue. |
| 4257 | if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime; |
| 4258 | else Function("r", "regeneratorRuntime = r")(runtime); |
| 4259 | } |
| 4260 | |
| 4261 | },{}],"jIm8e":[function(require,module,exports) { |
| 4262 | exports.interopDefault = function(a) { |
| 4263 | return a && a.__esModule ? a : { |
| 4264 | default: a |
| 4265 | }; |
| 4266 | }; |
| 4267 | exports.defineInteropFlag = function(a) { |
| 4268 | Object.defineProperty(a, "__esModule", { |
| 4269 | value: true |
| 4270 | }); |
| 4271 | }; |
| 4272 | exports.exportAll = function(source, dest) { |
| 4273 | Object.keys(source).forEach(function(key) { |
| 4274 | if (key === "default" || key === "__esModule" || dest.hasOwnProperty(key)) return; |
| 4275 | Object.defineProperty(dest, key, { |
| 4276 | enumerable: true, |
| 4277 | get: function get() { |
| 4278 | return source[key]; |
| 4279 | } |
| 4280 | }); |
| 4281 | }); |
| 4282 | return dest; |
| 4283 | }; |
| 4284 | exports.export = function(dest, destName, get) { |
| 4285 | Object.defineProperty(dest, destName, { |
| 4286 | enumerable: true, |
| 4287 | get: get |
| 4288 | }); |
| 4289 | }; |
| 4290 | |
| 4291 | },{}],"dW4sP":[function(require,module,exports) { |
| 4292 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4293 | parcelHelpers.defineInteropFlag(exports); |
| 4294 | function e(e1, t1) { |
| 4295 | for(var o1 = 0; o1 < t1.length; o1++){ |
| 4296 | var n1 = t1[o1]; |
| 4297 | n1.enumerable = n1.enumerable || !1, n1.configurable = !0, "value" in n1 && (n1.writable = !0), Object.defineProperty(e1, n1.key, n1); |
| 4298 | } |
| 4299 | } |
| 4300 | function t(e2) { |
| 4301 | return function(e3) { |
| 4302 | if (Array.isArray(e3)) return o(e3); |
| 4303 | }(e2) || function(e4) { |
| 4304 | if ("undefined" != typeof Symbol && Symbol.iterator in Object(e4)) return Array.from(e4); |
| 4305 | }(e2) || function(e5, t2) { |
| 4306 | if (!e5) return; |
| 4307 | if ("string" == typeof e5) return o(e5, t2); |
| 4308 | var n2 = Object.prototype.toString.call(e5).slice(8, -1); |
| 4309 | "Object" === n2 && e5.constructor && (n2 = e5.constructor.name); |
| 4310 | if ("Map" === n2 || "Set" === n2) return Array.from(e5); |
| 4311 | if ("Arguments" === n2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return o(e5, t2); |
| 4312 | }(e2) || function() { |
| 4313 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 4314 | }(); |
| 4315 | } |
| 4316 | function o(e6, t3) { |
| 4317 | (null == t3 || t3 > e6.length) && (t3 = e6.length); |
| 4318 | for(var o2 = 0, n3 = new Array(t3); o2 < t3; o2++)n3[o2] = e6[o2]; |
| 4319 | return n3; |
| 4320 | } |
| 4321 | var n, i, a, r, s1, l = (n = [ |
| 4322 | "a[href]", |
| 4323 | "area[href]", |
| 4324 | 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', |
| 4325 | "select:not([disabled]):not([aria-hidden])", |
| 4326 | "textarea:not([disabled]):not([aria-hidden])", |
| 4327 | "button:not([disabled]):not([aria-hidden])", |
| 4328 | "iframe", |
| 4329 | "object", |
| 4330 | "embed", |
| 4331 | "[contenteditable]", |
| 4332 | '[tabindex]:not([tabindex^="-"])' |
| 4333 | ], i = function() { |
| 4334 | function o3(e7) { |
| 4335 | 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; |
| 4336 | !function(e8, t4) { |
| 4337 | if (!(e8 instanceof t4)) throw new TypeError("Cannot call a class as a function"); |
| 4338 | }(this, o3), this.modal = document.getElementById(n4), this.config = { |
| 4339 | debugMode: C, |
| 4340 | disableScroll: b, |
| 4341 | openTrigger: u, |
| 4342 | closeTrigger: h, |
| 4343 | openClass: g, |
| 4344 | onShow: s, |
| 4345 | onClose: c, |
| 4346 | awaitCloseAnimation: E, |
| 4347 | awaitOpenAnimation: M, |
| 4348 | disableFocus: p |
| 4349 | }, a2.length > 0 && this.registerTriggers.apply(this, t(a2)), this.onClick = this.onClick.bind(this), this.onKeydown = this.onKeydown.bind(this); |
| 4350 | } |
| 4351 | var i1, a1, r1; |
| 4352 | return i1 = o3, a1 = [ |
| 4353 | { |
| 4354 | key: "registerTriggers", |
| 4355 | value: function value() { |
| 4356 | for(var _$e = this, t5 = arguments.length, _$o = new Array(t5), n5 = 0; n5 < t5; n5++)_$o[n5] = arguments[n5]; |
| 4357 | _$o.filter(Boolean).forEach(function(t6) { |
| 4358 | t6.addEventListener("click", function(t7) { |
| 4359 | return _$e.showModal(t7); |
| 4360 | }); |
| 4361 | }); |
| 4362 | } |
| 4363 | }, |
| 4364 | { |
| 4365 | key: "showModal", |
| 4366 | value: function value() { |
| 4367 | var _$e = this, t8 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null; |
| 4368 | 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) { |
| 4369 | var _$o = function t9() { |
| 4370 | _$e.modal.removeEventListener("animationend", t9, !1), _$e.setFocusToFirstNode(); |
| 4371 | }; |
| 4372 | this.modal.addEventListener("animationend", _$o, !1); |
| 4373 | } else this.setFocusToFirstNode(); |
| 4374 | this.config.onShow(this.modal, this.activeElement, t8); |
| 4375 | } |
| 4376 | }, |
| 4377 | { |
| 4378 | key: "closeModal", |
| 4379 | value: function value() { |
| 4380 | var _$e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null, t10 = this.modal; |
| 4381 | 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) { |
| 4382 | var _$o = this.config.openClass; |
| 4383 | this.modal.addEventListener("animationend", function e9() { |
| 4384 | t10.classList.remove(_$o), t10.removeEventListener("animationend", e9, !1); |
| 4385 | }, !1); |
| 4386 | } else t10.classList.remove(this.config.openClass); |
| 4387 | } |
| 4388 | }, |
| 4389 | { |
| 4390 | key: "closeModalById", |
| 4391 | value: function value(e10) { |
| 4392 | this.modal = document.getElementById(e10), this.modal && this.closeModal(); |
| 4393 | } |
| 4394 | }, |
| 4395 | { |
| 4396 | key: "scrollBehaviour", |
| 4397 | value: function value(e11) { |
| 4398 | if (this.config.disableScroll) { |
| 4399 | var t11 = document.querySelector("body"); |
| 4400 | switch(e11){ |
| 4401 | case "enable": |
| 4402 | Object.assign(t11.style, { |
| 4403 | overflow: "" |
| 4404 | }); |
| 4405 | break; |
| 4406 | case "disable": |
| 4407 | Object.assign(t11.style, { |
| 4408 | overflow: "hidden" |
| 4409 | }); |
| 4410 | } |
| 4411 | } |
| 4412 | } |
| 4413 | }, |
| 4414 | { |
| 4415 | key: "addEventListeners", |
| 4416 | value: function value() { |
| 4417 | this.modal.addEventListener("touchstart", this.onClick), this.modal.addEventListener("click", this.onClick), document.addEventListener("keydown", this.onKeydown); |
| 4418 | } |
| 4419 | }, |
| 4420 | { |
| 4421 | key: "removeEventListeners", |
| 4422 | value: function value() { |
| 4423 | this.modal.removeEventListener("touchstart", this.onClick), this.modal.removeEventListener("click", this.onClick), document.removeEventListener("keydown", this.onKeydown); |
| 4424 | } |
| 4425 | }, |
| 4426 | { |
| 4427 | key: "onClick", |
| 4428 | value: function value(e12) { |
| 4429 | (e12.target.hasAttribute(this.config.closeTrigger) || e12.target.parentNode.hasAttribute(this.config.closeTrigger)) && (e12.preventDefault(), e12.stopPropagation(), this.closeModal(e12)); |
| 4430 | } |
| 4431 | }, |
| 4432 | { |
| 4433 | key: "onKeydown", |
| 4434 | value: function value(e13) { |
| 4435 | 27 === e13.keyCode && this.closeModal(e13), 9 === e13.keyCode && this.retainFocus(e13); |
| 4436 | } |
| 4437 | }, |
| 4438 | { |
| 4439 | key: "getFocusableNodes", |
| 4440 | value: function value() { |
| 4441 | var _$e = this.modal.querySelectorAll(n); |
| 4442 | return Array.apply(void 0, t(_$e)); |
| 4443 | } |
| 4444 | }, |
| 4445 | { |
| 4446 | key: "setFocusToFirstNode", |
| 4447 | value: function value() { |
| 4448 | var _$e = this; |
| 4449 | if (!this.config.disableFocus) { |
| 4450 | var t12 = this.getFocusableNodes(); |
| 4451 | if (0 !== t12.length) { |
| 4452 | var _$o = t12.filter(function(t13) { |
| 4453 | return !t13.hasAttribute(_$e.config.closeTrigger); |
| 4454 | }); |
| 4455 | _$o.length > 0 && _$o[0].focus(), 0 === _$o.length && t12[0].focus(); |
| 4456 | } |
| 4457 | } |
| 4458 | } |
| 4459 | }, |
| 4460 | { |
| 4461 | key: "retainFocus", |
| 4462 | value: function value(e14) { |
| 4463 | var t14 = this.getFocusableNodes(); |
| 4464 | if (0 !== t14.length) { |
| 4465 | if (t14 = t14.filter(function(e15) { |
| 4466 | return null !== e15.offsetParent; |
| 4467 | }), this.modal.contains(document.activeElement)) { |
| 4468 | var _$o = t14.indexOf(document.activeElement); |
| 4469 | 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()); |
| 4470 | } else t14[0].focus(); |
| 4471 | } |
| 4472 | } |
| 4473 | } |
| 4474 | ], e(i1.prototype, a1), r1 && e(i1, r1), o3; |
| 4475 | }(), a = null, r = function r(e16) { |
| 4476 | 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; |
| 4477 | }, s1 = function s1(e17, t15) { |
| 4478 | if (function(e18) { |
| 4479 | 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>')); |
| 4480 | }(e17), !t15) return !0; |
| 4481 | for(var o4 in t15)r(o4); |
| 4482 | return !0; |
| 4483 | }, { |
| 4484 | init: function init(e19) { |
| 4485 | var o5 = Object.assign({}, { |
| 4486 | openTrigger: "data-micromodal-trigger" |
| 4487 | }, e19), n6 = t(document.querySelectorAll("[".concat(o5.openTrigger, "]"))), r = function(e20, t16) { |
| 4488 | var o6 = []; |
| 4489 | return e20.forEach(function(e21) { |
| 4490 | var n7 = e21.attributes[t16].value; |
| 4491 | void 0 === o6[n7] && (o6[n7] = []), o6[n7].push(e21); |
| 4492 | }), o6; |
| 4493 | }(n6, o5.openTrigger); |
| 4494 | if (!0 !== o5.debugMode || !1 !== s1(n6, r)) for(var l2 in r){ |
| 4495 | var c = r[l2]; |
| 4496 | o5.targetModal = l2, o5.triggers = t(c), a = new i(o5); |
| 4497 | } |
| 4498 | }, |
| 4499 | show: function show(e22, t17) { |
| 4500 | var o7 = t17 || {}; |
| 4501 | o7.targetModal = e22, !0 === o7.debugMode && !1 === r(e22) || (a && a.removeEventListeners(), (a = new i(o7)).showModal()); |
| 4502 | }, |
| 4503 | close: function close(e23) { |
| 4504 | e23 ? a.closeModalById(e23) : a.closeModal(); |
| 4505 | } |
| 4506 | }); |
| 4507 | "undefined" != typeof window && (window.MicroModal = l); |
| 4508 | exports.default = l; |
| 4509 | |
| 4510 | },{"@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"hrjuy":[function(require,module,exports) { |
| 4511 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4512 | parcelHelpers.defineInteropFlag(exports); |
| 4513 | parcelHelpers.export(exports, "default", function() { |
| 4514 | return _class; |
| 4515 | }); |
| 4516 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 4517 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 4518 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 4519 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 4520 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 4521 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 4522 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 4523 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 4524 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 4525 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 4526 | var _stimulus = require("@hotwired/stimulus"); |
| 4527 | var _corsairPlugin = require("../chart_plugins/corsair_plugin"); |
| 4528 | var _corsairPluginDefault = parcelHelpers.interopDefault(_corsairPlugin); |
| 4529 | var _htmlLegendPlugin = require("../chart_plugins/html_legend_plugin"); |
| 4530 | var _htmlLegendPluginDefault = parcelHelpers.interopDefault(_htmlLegendPlugin); |
| 4531 | var _class = /*#__PURE__*/ function(Controller) { |
| 4532 | "use strict"; |
| 4533 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 4534 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 4535 | function _class() { |
| 4536 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 4537 | return _super.apply(this, arguments); |
| 4538 | } |
| 4539 | (0, _createClassJsDefault.default)(_class, [ |
| 4540 | { |
| 4541 | key: "connect", |
| 4542 | value: function connect() { |
| 4543 | Chart.defaults.font.family = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'; |
| 4544 | var labels = this.labelsValue; |
| 4545 | var data = { |
| 4546 | labels: labels, |
| 4547 | datasets: [ |
| 4548 | { |
| 4549 | label: "Views", |
| 4550 | data: this.viewsValue, |
| 4551 | borderColor: "rgba(108,70,174,1)", |
| 4552 | fill: true, |
| 4553 | backgroundColor: "rgba(108,70,174,0.2)", |
| 4554 | pointBackgroundColor: "rgba(108,70,174,1)", |
| 4555 | tension: 0.4 |
| 4556 | }, |
| 4557 | { |
| 4558 | label: "Visitors", |
| 4559 | data: this.visitorsValue, |
| 4560 | borderColor: "rgba(246,157,10,1)", |
| 4561 | fill: true, |
| 4562 | backgroundColor: "rgba(246,157,10,0.2)", |
| 4563 | pointBackgroundColor: "rgba(246,157,10,1)", |
| 4564 | tension: 0.4 |
| 4565 | } |
| 4566 | ] |
| 4567 | }; |
| 4568 | var options = { |
| 4569 | animation: { |
| 4570 | duration: 0 |
| 4571 | }, |
| 4572 | interaction: { |
| 4573 | intersect: false, |
| 4574 | mode: "index" |
| 4575 | }, |
| 4576 | scales: { |
| 4577 | y: { |
| 4578 | grid: { |
| 4579 | borderColor: "#DEDAE6", |
| 4580 | tickColor: "#DEDAE6", |
| 4581 | display: true, |
| 4582 | drawOnChartArea: true, |
| 4583 | borderDash: [ |
| 4584 | 2, |
| 4585 | 4 |
| 4586 | ] |
| 4587 | }, |
| 4588 | beginAtZero: true, |
| 4589 | suggestedMax: 10, |
| 4590 | // grace: '26%', |
| 4591 | ticks: { |
| 4592 | color: this.modeValue === "dark" ? "#ffffff" : "#6D6A73", |
| 4593 | font: { |
| 4594 | size: 14, |
| 4595 | weight: 400 |
| 4596 | }, |
| 4597 | precision: 0 |
| 4598 | } |
| 4599 | }, |
| 4600 | x: { |
| 4601 | grid: { |
| 4602 | borderColor: "#DEDAE6", |
| 4603 | tickColor: "#DEDAE6", |
| 4604 | display: true, |
| 4605 | drawOnChartArea: false |
| 4606 | }, |
| 4607 | ticks: { |
| 4608 | color: this.modeValue === "dark" ? "#ffffff" : "#6D6A73", |
| 4609 | autoSkip: true, |
| 4610 | autoSkipPadding: 16, |
| 4611 | maxRotation: 0, |
| 4612 | // maxTicksLimit: 20, |
| 4613 | font: { |
| 4614 | size: 14, |
| 4615 | weight: 400 |
| 4616 | }, |
| 4617 | callback: function callback(value, index, values) { |
| 4618 | var label = this.getLabelForValue(value); |
| 4619 | return label.split(" - ")[0]; |
| 4620 | } |
| 4621 | } |
| 4622 | } |
| 4623 | }, |
| 4624 | plugins: { |
| 4625 | mode: String, |
| 4626 | htmlLegend: { |
| 4627 | // ID of the container to put the legend in |
| 4628 | containerID: "legend-container" |
| 4629 | }, |
| 4630 | legend: { |
| 4631 | display: false |
| 4632 | }, |
| 4633 | corsair: { |
| 4634 | // disabled: true, |
| 4635 | dash: [ |
| 4636 | 2, |
| 4637 | 4 |
| 4638 | ], |
| 4639 | color: "#777", |
| 4640 | width: 1 |
| 4641 | } |
| 4642 | }, |
| 4643 | elements: { |
| 4644 | point: { |
| 4645 | radius: 4 |
| 4646 | } |
| 4647 | } |
| 4648 | }; |
| 4649 | var config = { |
| 4650 | type: "line", |
| 4651 | data: data, |
| 4652 | options: options, |
| 4653 | plugins: [ |
| 4654 | (0, _htmlLegendPluginDefault.default), |
| 4655 | (0, _corsairPluginDefault.default) |
| 4656 | ] |
| 4657 | }; |
| 4658 | var canvas = document.getElementById("myChart"); |
| 4659 | var myChart = new Chart(canvas, config); |
| 4660 | } |
| 4661 | } |
| 4662 | ]); |
| 4663 | return _class; |
| 4664 | }((0, _stimulus.Controller)); |
| 4665 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 4666 | mode: String, |
| 4667 | labels: Array, |
| 4668 | views: Array, |
| 4669 | visitors: Array |
| 4670 | }); |
| 4671 | |
| 4672 | },{"@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) { |
| 4673 | module.exports = { |
| 4674 | id: "corsair", |
| 4675 | afterInit: function(chart, _, opts) { |
| 4676 | if (opts.disabled) return; |
| 4677 | chart.corsair = { |
| 4678 | x: 0, |
| 4679 | y: 0 |
| 4680 | }; |
| 4681 | }, |
| 4682 | afterEvent: function(chart, evt, opts) { |
| 4683 | if (opts.disabled) return; |
| 4684 | var _chartArea = chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom, left = _chartArea.left, right = _chartArea.right; |
| 4685 | var _event = evt.event, x = _event.x, y = _event.y; |
| 4686 | if (x < left || x > right || y < top || y > bottom) { |
| 4687 | chart.corsair = { |
| 4688 | x: x, |
| 4689 | y: y, |
| 4690 | draw: false |
| 4691 | }; |
| 4692 | chart.draw(); |
| 4693 | return; |
| 4694 | } |
| 4695 | chart.corsair = { |
| 4696 | x: x, |
| 4697 | y: y, |
| 4698 | draw: true |
| 4699 | }; |
| 4700 | chart.draw(); |
| 4701 | }, |
| 4702 | afterDatasetsDraw: function(chart, _, opts) { |
| 4703 | if (opts.disabled) return; |
| 4704 | var ctx = chart.ctx, _chartArea = chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom, left = _chartArea.left, right = _chartArea.right; |
| 4705 | var _corsair = chart.corsair, x = _corsair.x, y = _corsair.y, draw = _corsair.draw; |
| 4706 | if (!draw) return; |
| 4707 | // console.log(chart); |
| 4708 | x = chart.tooltip.caretX; |
| 4709 | ctx.lineWidth = opts.width || 0; |
| 4710 | // // Todo - Why does dash fuck up dots? |
| 4711 | ctx.setLineDash(opts.dash || []); |
| 4712 | ctx.strokeStyle = opts.color || "black"; |
| 4713 | ctx.save(); |
| 4714 | ctx.beginPath(); |
| 4715 | ctx.moveTo(x, bottom); |
| 4716 | ctx.lineTo(x, top); |
| 4717 | // Uncomment these 2 lines to add horizontal line |
| 4718 | // ctx.moveTo(left, y); |
| 4719 | // ctx.lineTo(right, y); |
| 4720 | ctx.stroke(); |
| 4721 | ctx.restore(); |
| 4722 | ctx.setLineDash([]); |
| 4723 | } |
| 4724 | }; |
| 4725 | |
| 4726 | },{}],"dVdIk":[function(require,module,exports) { |
| 4727 | module.exports = { |
| 4728 | id: "htmlLegend", |
| 4729 | afterUpdate: function(chart, args, options) { |
| 4730 | var legendContainer = document.getElementById(options.containerID); |
| 4731 | var legendList = legendContainer.querySelector("ul"); |
| 4732 | // Create a list as needed |
| 4733 | if (!legendList) { |
| 4734 | legendList = document.createElement("ul"); |
| 4735 | legendList.classList.add("legend-list"); |
| 4736 | legendContainer.appendChild(legendList); |
| 4737 | } |
| 4738 | // Remove old legend items |
| 4739 | while(legendList.firstChild)legendList.firstChild.remove(); |
| 4740 | // Reuse the built-in legendItems generator |
| 4741 | var items = chart.options.plugins.legend.labels.generateLabels(chart); |
| 4742 | items.forEach(function(legendData) { |
| 4743 | var legendID = legendData.text.toLowerCase(); |
| 4744 | var li = document.createElement("li"); |
| 4745 | li.onclick = function() { |
| 4746 | var type = chart.config.type; |
| 4747 | if (type === "pie" || type === "doughnut") // Pie and doughnut charts only have a single dataset and visibility is per item |
| 4748 | chart.toggleDataVisibility(legendData.index); |
| 4749 | else chart.setDatasetVisibility(legendData.datasetIndex, !chart.isDatasetVisible(legendData.datasetIndex)); |
| 4750 | chart.update(); |
| 4751 | }; |
| 4752 | li.classList.add("legend-item", "legend-item-for-".concat(legendID)); |
| 4753 | if (legendData.hidden) li.classList.add("hidden"); |
| 4754 | // Color box |
| 4755 | var boxSpan = document.createElement("span"); |
| 4756 | // Text |
| 4757 | var textContainer = document.createElement("p"); |
| 4758 | textContainer.textContent = legendData.text; |
| 4759 | li.appendChild(boxSpan); |
| 4760 | li.appendChild(textContainer); |
| 4761 | legendList.appendChild(li); |
| 4762 | }); |
| 4763 | } |
| 4764 | }; |
| 4765 | |
| 4766 | },{}],"1zYz5":[function(require,module,exports) { |
| 4767 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4768 | parcelHelpers.defineInteropFlag(exports); |
| 4769 | parcelHelpers.export(exports, "default", function() { |
| 4770 | return _class; |
| 4771 | }); |
| 4772 | var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js"); |
| 4773 | var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs); |
| 4774 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 4775 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 4776 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 4777 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 4778 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 4779 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 4780 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 4781 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 4782 | var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js"); |
| 4783 | var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs); |
| 4784 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 4785 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 4786 | var _stimulus = require("@hotwired/stimulus"); |
| 4787 | var _class = /*#__PURE__*/ function(Controller) { |
| 4788 | "use strict"; |
| 4789 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 4790 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 4791 | function _class() { |
| 4792 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 4793 | var _this; |
| 4794 | _this = _super.apply(this, arguments); |
| 4795 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "drawChart", function() { |
| 4796 | // Empty the element to fix glitch where chart height wouldn't be resized |
| 4797 | _this.chartTarget.innerHTML = ""; |
| 4798 | var columns = [ |
| 4799 | "Country", |
| 4800 | "Views", |
| 4801 | "Visitors" |
| 4802 | ]; |
| 4803 | // Google Charts doesn't like the extra tooltip data column if there is no data to show |
| 4804 | // The solution is to check if there is no geo data and just limit it to two columns if so |
| 4805 | if (_this.dataValue.length === 0) columns = [ |
| 4806 | "Country", |
| 4807 | "Views" |
| 4808 | ]; |
| 4809 | var data = google.visualization.arrayToDataTable([ |
| 4810 | columns, |
| 4811 | ].concat((0, _toConsumableArrayJsDefault.default)(_this.dataValue))); |
| 4812 | var options = { |
| 4813 | backgroundColor: _this.darkModeValue ? "#373040" : "#FFFFFF", |
| 4814 | datalessRegionColor: _this.darkModeValue ? "#695C7A" : undefined, |
| 4815 | colorAxis: { |
| 4816 | colors: _this.darkModeValue ? [ |
| 4817 | "#AC9CC9", |
| 4818 | "#9E66FF" |
| 4819 | ] : [ |
| 4820 | "#C4ABED", |
| 4821 | "#5223A0" |
| 4822 | ] |
| 4823 | }, |
| 4824 | legend: { |
| 4825 | numberFormat: "Views: #", |
| 4826 | textStyle: { |
| 4827 | color: _this.darkModeValue ? "#FFFFFF" : "#000000", |
| 4828 | strokeWidth: 0 |
| 4829 | } |
| 4830 | } |
| 4831 | }; |
| 4832 | var chart = new google.visualization.GeoChart(_this.chartTarget); |
| 4833 | chart.draw(data, options); |
| 4834 | }); |
| 4835 | return _this; |
| 4836 | } |
| 4837 | (0, _createClassJsDefault.default)(_class, [ |
| 4838 | { |
| 4839 | key: "connect", |
| 4840 | value: function connect() { |
| 4841 | var _this = this; |
| 4842 | google.charts.load("current", { |
| 4843 | "packages": [ |
| 4844 | "geochart" |
| 4845 | ] |
| 4846 | }); |
| 4847 | google.charts.setOnLoadCallback(function() { |
| 4848 | _this.drawChart(); |
| 4849 | }); |
| 4850 | window.addEventListener("resize", this.drawChart); |
| 4851 | } |
| 4852 | }, |
| 4853 | { |
| 4854 | key: "disconnect", |
| 4855 | value: function disconnect() { |
| 4856 | window.removeEventListener("resize", this.drawChart); |
| 4857 | } |
| 4858 | } |
| 4859 | ]); |
| 4860 | return _class; |
| 4861 | }((0, _stimulus.Controller)); |
| 4862 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 4863 | "chart" |
| 4864 | ]); |
| 4865 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 4866 | data: Array, |
| 4867 | darkMode: Boolean |
| 4868 | }); |
| 4869 | |
| 4870 | },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@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/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"6VC2X":[function(require,module,exports) { |
| 4871 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4872 | parcelHelpers.defineInteropFlag(exports); |
| 4873 | parcelHelpers.export(exports, "default", function() { |
| 4874 | return _class; |
| 4875 | }); |
| 4876 | var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js"); |
| 4877 | var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs); |
| 4878 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 4879 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 4880 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 4881 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 4882 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 4883 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 4884 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 4885 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 4886 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 4887 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 4888 | var _stimulus = require("@hotwired/stimulus"); |
| 4889 | var _class = /*#__PURE__*/ function(Controller) { |
| 4890 | "use strict"; |
| 4891 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 4892 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 4893 | function _class() { |
| 4894 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 4895 | var _this; |
| 4896 | _this = _super.apply(this, arguments); |
| 4897 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "maybeClose", function(event) { |
| 4898 | var isOpen = _this.modalTarget.classList.contains("show"); |
| 4899 | var isInComponent = _this.element.contains(event.target); |
| 4900 | if (isOpen && !isInComponent) _this.closeModal(); |
| 4901 | }); |
| 4902 | return _this; |
| 4903 | } |
| 4904 | (0, _createClassJsDefault.default)(_class, [ |
| 4905 | { |
| 4906 | key: "connect", |
| 4907 | value: function connect() { |
| 4908 | this.updateUserInterface(); |
| 4909 | document.addEventListener("click", this.maybeClose); |
| 4910 | } |
| 4911 | }, |
| 4912 | { |
| 4913 | key: "disconnect", |
| 4914 | value: function disconnect() { |
| 4915 | document.removeEventListener("click", this.maybeClose); |
| 4916 | } |
| 4917 | }, |
| 4918 | { |
| 4919 | key: "toggleModal", |
| 4920 | value: function toggleModal(e) { |
| 4921 | var isOpen = this.modalTarget.classList.contains("show"); |
| 4922 | isOpen ? this.closeModal() : this.openModal(); |
| 4923 | } |
| 4924 | }, |
| 4925 | { |
| 4926 | key: "openModal", |
| 4927 | value: function openModal() { |
| 4928 | this.modalTarget.classList.add("show"); |
| 4929 | } |
| 4930 | }, |
| 4931 | { |
| 4932 | key: "closeModal", |
| 4933 | value: function closeModal() { |
| 4934 | this.modalTarget.classList.remove("show"); |
| 4935 | } |
| 4936 | }, |
| 4937 | { |
| 4938 | key: "check", |
| 4939 | value: function check() { |
| 4940 | this.updateUserInterface(); |
| 4941 | } |
| 4942 | }, |
| 4943 | { |
| 4944 | key: "updateUserInterface", |
| 4945 | value: function updateUserInterface() { |
| 4946 | var _this = this; |
| 4947 | this.selectedCheckboxes = this.checkboxTargets.filter(function(checkbox) { |
| 4948 | return checkbox.checked; |
| 4949 | }); |
| 4950 | // If none selected, select first |
| 4951 | if (this.selectedCheckboxes.length === 0) { |
| 4952 | this.checkboxTarget.checked = true; |
| 4953 | this.selectedCheckboxes = [ |
| 4954 | this.checkboxTarget |
| 4955 | ]; |
| 4956 | } |
| 4957 | // Enable all checkboxes |
| 4958 | this.checkboxTargets.forEach(function(checkbox) { |
| 4959 | checkbox.removeAttribute("disabled"); |
| 4960 | }); |
| 4961 | // If only one selected, disable it |
| 4962 | if (this.selectedCheckboxes.length === 1) this.selectedCheckboxes.at(0).setAttribute("disabled", "disabled"); |
| 4963 | // Hide and show cells as needed |
| 4964 | this.checkboxTargets.forEach(function(checkbox) { |
| 4965 | var column = checkbox.name; |
| 4966 | var isSelected = _this.selectedCheckboxes.includes(checkbox); |
| 4967 | var columnTableCells = document.querySelectorAll(".cell[data-column=".concat(column, "]")); |
| 4968 | columnTableCells.forEach(function(cell) { |
| 4969 | cell.classList.toggle("hide", !isSelected); |
| 4970 | }); |
| 4971 | }); |
| 4972 | // Update data-column-count so table knows how many columns are showing |
| 4973 | document.getElementById("data-table").setAttribute("data-column-count", this.selectedCheckboxes.length.toString()); |
| 4974 | document.dispatchEvent(new CustomEvent("iawp:changeColumns", { |
| 4975 | detail: { |
| 4976 | columns: this.selectedCheckboxes.map(function(checkbox) { |
| 4977 | return checkbox.name; |
| 4978 | }) |
| 4979 | } |
| 4980 | })); |
| 4981 | } |
| 4982 | } |
| 4983 | ]); |
| 4984 | return _class; |
| 4985 | }((0, _stimulus.Controller)); |
| 4986 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 4987 | "modal", |
| 4988 | "checkbox" |
| 4989 | ]); |
| 4990 | |
| 4991 | },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@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","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"cVUgd":[function(require,module,exports) { |
| 4992 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 4993 | parcelHelpers.defineInteropFlag(exports); |
| 4994 | /** |
| 4995 | * This controller is designed to work with either a relative range or an |
| 4996 | * exact range. |
| 4997 | * |
| 4998 | * You can use a relative range by supplying a relativeRangeId value. |
| 4999 | * |
| 5000 | * You can use an exact range by supplying an exactStart and exactEnd value. |
| 5001 | */ parcelHelpers.export(exports, "default", function() { |
| 5002 | return _class; |
| 5003 | }); |
| 5004 | var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js"); |
| 5005 | var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs); |
| 5006 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 5007 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 5008 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 5009 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 5010 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 5011 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 5012 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 5013 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 5014 | var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js"); |
| 5015 | var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs); |
| 5016 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 5017 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 5018 | var _stimulus = require("@hotwired/stimulus"); |
| 5019 | var _bundle = require("@easepick/bundle"); |
| 5020 | var _class = /*#__PURE__*/ function(Controller) { |
| 5021 | "use strict"; |
| 5022 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 5023 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 5024 | function _class() { |
| 5025 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 5026 | var _this; |
| 5027 | _this = _super.apply(this, arguments); |
| 5028 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "easepicker", undefined); |
| 5029 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "exactStart", undefined); |
| 5030 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "exactEnd", undefined); |
| 5031 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "relativeRangeId", undefined); |
| 5032 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "maybeClose", function(event) { |
| 5033 | var isOpen = _this.modalTarget.classList.contains("show"); |
| 5034 | var isInComponent = _this.element.contains(event.target); |
| 5035 | if (isOpen && !isInComponent) _this.closeModal(); |
| 5036 | }); |
| 5037 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "relativeRangeSelected", function(e) { |
| 5038 | _this.exactStart = undefined; |
| 5039 | _this.exactEnd = undefined; |
| 5040 | _this.relativeRangeId = e.target.dataset.relativeRangeId; |
| 5041 | _this.updateUserInterface(); |
| 5042 | }); |
| 5043 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "exactRangeSelected", function(e) { |
| 5044 | _this.exactStart = e.detail.start; |
| 5045 | _this.exactEnd = e.detail.end; |
| 5046 | _this.relativeRangeId = undefined; |
| 5047 | _this.updateUserInterface(); |
| 5048 | }); |
| 5049 | return _this; |
| 5050 | } |
| 5051 | (0, _createClassJsDefault.default)(_class, [ |
| 5052 | { |
| 5053 | key: "connect", |
| 5054 | value: function connect() { |
| 5055 | this.setFromValues(); |
| 5056 | this.enableEasepick(); |
| 5057 | this.updateUserInterface(); |
| 5058 | document.addEventListener("click", this.maybeClose); |
| 5059 | } |
| 5060 | }, |
| 5061 | { |
| 5062 | key: "disconnect", |
| 5063 | value: function disconnect() { |
| 5064 | document.removeEventListener("click", this.maybeClose); |
| 5065 | } |
| 5066 | }, |
| 5067 | { |
| 5068 | key: "setFromValues", |
| 5069 | value: function setFromValues() { |
| 5070 | // If any values are empty strings, set them equal to undefined instead |
| 5071 | this.exactStart = this.exactStartValue === "" ? undefined : new _bundle.DateTime(this.exactStartValue); |
| 5072 | this.exactEnd = this.exactEndValue === "" ? undefined : new _bundle.DateTime(this.exactEndValue); |
| 5073 | this.relativeRangeId = this.relativeRangeIdValue === "" ? undefined : this.relativeRangeIdValue; |
| 5074 | } |
| 5075 | }, |
| 5076 | { |
| 5077 | key: "toggleModal", |
| 5078 | value: function toggleModal(e) { |
| 5079 | var isOpen = this.modalTarget.classList.contains("show"); |
| 5080 | isOpen ? this.closeModal() : this.openModal(); |
| 5081 | } |
| 5082 | }, |
| 5083 | { |
| 5084 | key: "apply", |
| 5085 | value: function apply() { |
| 5086 | var detail = {}; |
| 5087 | if (this.relativeRangeId) detail = { |
| 5088 | relativeRangeId: this.relativeRangeId |
| 5089 | }; |
| 5090 | else detail = { |
| 5091 | exactStart: this.exactStart.format("YYYY-MM-DD"), |
| 5092 | exactEnd: this.exactEnd.format("YYYY-MM-DD") |
| 5093 | }; |
| 5094 | document.dispatchEvent(new CustomEvent("iawp:changeDates", { |
| 5095 | detail: detail |
| 5096 | })); |
| 5097 | // Update values so future resets reset to the last applied state |
| 5098 | this.relativeRangeIdValue = detail.relativeRangeId; |
| 5099 | this.exactStartValue = detail.exactStart; |
| 5100 | this.exactEndValue = detail.exactEnd; |
| 5101 | // Todo - This should happen in a central place from report_controller |
| 5102 | this.closeModal(); |
| 5103 | } |
| 5104 | }, |
| 5105 | { |
| 5106 | key: "openModal", |
| 5107 | value: function openModal() { |
| 5108 | this.modalTarget.classList.add("show"); |
| 5109 | } |
| 5110 | }, |
| 5111 | { |
| 5112 | key: "closeModal", |
| 5113 | value: function closeModal() { |
| 5114 | this.modalTarget.classList.remove("show"); |
| 5115 | this.setFromValues(); |
| 5116 | this.updateUserInterface(); |
| 5117 | } |
| 5118 | }, |
| 5119 | { |
| 5120 | key: "updateUserInterface", |
| 5121 | value: function updateUserInterface() { |
| 5122 | var _this = this; |
| 5123 | var isExact = this.exactStart && this.exactEnd; |
| 5124 | // Select the correct relative range button, if any |
| 5125 | this.relativeRangeTargets.forEach(function(button) { |
| 5126 | var match = button.dataset.relativeRangeId === _this.relativeRangeId; |
| 5127 | button.classList.toggle("ghost-purple", !match); |
| 5128 | button.classList.toggle("purple", match); |
| 5129 | }); |
| 5130 | if (isExact) { |
| 5131 | this.easepicker.setDateRange(this.exactStart, this.exactEnd); |
| 5132 | this.applyTarget.textContent = "Apply Exact Dates"; |
| 5133 | } else { |
| 5134 | var ref = (0, _slicedToArrayJsDefault.default)(this.relativeRangeDates(), 2), start = ref[0], end = ref[1]; |
| 5135 | this.easepicker.setDateRange(start, end); |
| 5136 | this.applyTarget.textContent = "Apply Relative Dates"; |
| 5137 | } |
| 5138 | } |
| 5139 | }, |
| 5140 | { |
| 5141 | key: "relativeRangeDates", |
| 5142 | value: function relativeRangeDates() { |
| 5143 | var _this = this; |
| 5144 | var button1 = this.relativeRangeTargets.find(function(button) { |
| 5145 | return button.dataset.relativeRangeId === _this.relativeRangeId; |
| 5146 | }); |
| 5147 | var start = new _bundle.DateTime(button1.dataset.relativeRangeStart); |
| 5148 | var end = new _bundle.DateTime(button1.dataset.relativeRangeEnd); |
| 5149 | return [ |
| 5150 | start, |
| 5151 | end |
| 5152 | ]; |
| 5153 | } |
| 5154 | }, |
| 5155 | { |
| 5156 | key: "enableEasepick", |
| 5157 | value: function enableEasepick() { |
| 5158 | var _this = this; |
| 5159 | var start, end; |
| 5160 | var ref; |
| 5161 | if (this.relativeRangeId) ref = (0, _slicedToArrayJsDefault.default)(this.relativeRangeDates(), 2), start = ref[0], end = ref[1], ref; |
| 5162 | else { |
| 5163 | start = this.exactStart; |
| 5164 | end = this.exactEnd; |
| 5165 | } |
| 5166 | this.easepicker = new _bundle.create({ |
| 5167 | element: this.easepickTarget, |
| 5168 | css: [ |
| 5169 | this.cssUrlValue |
| 5170 | ], |
| 5171 | inline: true, |
| 5172 | firstDay: this.firstDayOfWeekValue, |
| 5173 | format: this.formatValue, |
| 5174 | calendars: 2, |
| 5175 | grid: 2, |
| 5176 | autoApply: true, |
| 5177 | plugins: [ |
| 5178 | _bundle.RangePlugin |
| 5179 | ], |
| 5180 | RangePlugin: { |
| 5181 | startDate: start.format(this.formatValue), |
| 5182 | endDate: end.format(this.formatValue) |
| 5183 | }, |
| 5184 | setup: function(picker) { |
| 5185 | picker.on("select", _this.exactRangeSelected); |
| 5186 | } |
| 5187 | }); |
| 5188 | } |
| 5189 | } |
| 5190 | ]); |
| 5191 | return _class; |
| 5192 | }((0, _stimulus.Controller)); |
| 5193 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 5194 | relativeRangeId: String, |
| 5195 | exactStart: String, |
| 5196 | exactEnd: String, |
| 5197 | firstDayOfWeek: Number, |
| 5198 | cssUrl: String, |
| 5199 | format: String |
| 5200 | }); |
| 5201 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 5202 | "modal", |
| 5203 | "easepick", |
| 5204 | "apply", |
| 5205 | "relativeRange" |
| 5206 | ]); |
| 5207 | |
| 5208 | },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@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/_sliced_to_array.js":"4IWLM","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","@easepick/bundle":"boi5E","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"boi5E":[function(require,module,exports) { |
| 5209 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 5210 | parcelHelpers.defineInteropFlag(exports); |
| 5211 | parcelHelpers.export(exports, "AmpPlugin", function() { |
| 5212 | return d; |
| 5213 | }); |
| 5214 | parcelHelpers.export(exports, "DateTime", function() { |
| 5215 | return t1; |
| 5216 | }); |
| 5217 | parcelHelpers.export(exports, "KbdPlugin", function() { |
| 5218 | return h; |
| 5219 | }); |
| 5220 | parcelHelpers.export(exports, "LockPlugin", function() { |
| 5221 | return a5; |
| 5222 | }); |
| 5223 | parcelHelpers.export(exports, "PresetPlugin", function() { |
| 5224 | return r; |
| 5225 | }); |
| 5226 | parcelHelpers.export(exports, "RangePlugin", function() { |
| 5227 | return c; |
| 5228 | }); |
| 5229 | parcelHelpers.export(exports, "TimePlugin", function() { |
| 5230 | return l; |
| 5231 | }); |
| 5232 | parcelHelpers.export(exports, "create", function() { |
| 5233 | return n12; |
| 5234 | }); |
| 5235 | parcelHelpers.export(exports, "easepick", function() { |
| 5236 | return s; |
| 5237 | }); |
| 5238 | var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js"); |
| 5239 | var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs); |
| 5240 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 5241 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 5242 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 5243 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 5244 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 5245 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 5246 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 5247 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 5248 | var _objectSpreadJs = require("@swc/helpers/lib/_object_spread.js"); |
| 5249 | var _objectSpreadJsDefault = parcelHelpers.interopDefault(_objectSpreadJs); |
| 5250 | var _possibleConstructorReturnJs = require("@swc/helpers/lib/_possible_constructor_return.js"); |
| 5251 | var _possibleConstructorReturnJsDefault = parcelHelpers.interopDefault(_possibleConstructorReturnJs); |
| 5252 | var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js"); |
| 5253 | var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs); |
| 5254 | var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js"); |
| 5255 | var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs); |
| 5256 | var _wrapNativeSuperJs = require("@swc/helpers/lib/_wrap_native_super.js"); |
| 5257 | var _wrapNativeSuperJsDefault = parcelHelpers.interopDefault(_wrapNativeSuperJs); |
| 5258 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 5259 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 5260 | var t1 = /*#__PURE__*/ function(Date1) { |
| 5261 | "use strict"; |
| 5262 | (0, _inheritsJsDefault.default)(t1, Date1); |
| 5263 | var _super = (0, _createSuperJsDefault.default)(t1); |
| 5264 | function t1() { |
| 5265 | var e1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, i1 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "YYYY-MM-DD", n1 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "en-US"; |
| 5266 | (0, _classCallCheckJsDefault.default)(this, t1); |
| 5267 | var _this; |
| 5268 | var _temp; |
| 5269 | _temp = _this = _super.call(this, t1.parseDateTime(e1, i1, n1)), (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "lang", void 0), _temp, _this.lang = n1; |
| 5270 | return (0, _possibleConstructorReturnJsDefault.default)(_this); |
| 5271 | } |
| 5272 | (0, _createClassJsDefault.default)(t1, [ |
| 5273 | { |
| 5274 | key: "getWeek", |
| 5275 | value: function getWeek(t2) { |
| 5276 | var e2 = new Date(this.midnight_ts(this)), i2 = (this.getDay() + (7 - t2)) % 7; |
| 5277 | e2.setDate(e2.getDate() - i2); |
| 5278 | var n2 = e2.getTime(); |
| 5279 | return e2.setMonth(0, 1), e2.getDay() !== t2 && e2.setMonth(0, 1 + (4 - e2.getDay() + 7) % 7), 1 + Math.ceil((n2 - e2.getTime()) / 6048e5); |
| 5280 | } |
| 5281 | }, |
| 5282 | { |
| 5283 | key: "clone", |
| 5284 | value: function clone() { |
| 5285 | return new t1(this); |
| 5286 | } |
| 5287 | }, |
| 5288 | { |
| 5289 | key: "toJSDate", |
| 5290 | value: function toJSDate() { |
| 5291 | return new Date(this); |
| 5292 | } |
| 5293 | }, |
| 5294 | { |
| 5295 | key: "inArray", |
| 5296 | value: function inArray(t3) { |
| 5297 | var e3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "[]"; |
| 5298 | var _this = this; |
| 5299 | return t3.some(function(t) { |
| 5300 | return t instanceof Array ? _this.isBetween(t[0], t[1], e3) : _this.isSame(t, "day"); |
| 5301 | }); |
| 5302 | } |
| 5303 | }, |
| 5304 | { |
| 5305 | key: "isBetween", |
| 5306 | value: function isBetween(t, e4) { |
| 5307 | var i3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "()"; |
| 5308 | switch(i3){ |
| 5309 | default: |
| 5310 | case "()": |
| 5311 | return this.midnight_ts(this) > this.midnight_ts(t) && this.midnight_ts(this) < this.midnight_ts(e4); |
| 5312 | case "[)": |
| 5313 | return this.midnight_ts(this) >= this.midnight_ts(t) && this.midnight_ts(this) < this.midnight_ts(e4); |
| 5314 | case "(]": |
| 5315 | return this.midnight_ts(this) > this.midnight_ts(t) && this.midnight_ts(this) <= this.midnight_ts(e4); |
| 5316 | case "[]": |
| 5317 | return this.midnight_ts() >= this.midnight_ts(t) && this.midnight_ts() <= this.midnight_ts(e4); |
| 5318 | } |
| 5319 | } |
| 5320 | }, |
| 5321 | { |
| 5322 | key: "isBefore", |
| 5323 | value: function isBefore(t) { |
| 5324 | var e5 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5325 | switch(e5){ |
| 5326 | case "day": |
| 5327 | case "days": |
| 5328 | return new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime() > new Date(this.getFullYear(), this.getMonth(), this.getDate()).getTime(); |
| 5329 | case "month": |
| 5330 | case "months": |
| 5331 | return new Date(t.getFullYear(), t.getMonth(), 1).getTime() > new Date(this.getFullYear(), this.getMonth(), 1).getTime(); |
| 5332 | case "year": |
| 5333 | case "years": |
| 5334 | return t.getFullYear() > this.getFullYear(); |
| 5335 | } |
| 5336 | throw new Error("isBefore: Invalid unit!"); |
| 5337 | } |
| 5338 | }, |
| 5339 | { |
| 5340 | key: "isSameOrBefore", |
| 5341 | value: function isSameOrBefore(t) { |
| 5342 | var e6 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5343 | switch(e6){ |
| 5344 | case "day": |
| 5345 | case "days": |
| 5346 | return new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime() >= new Date(this.getFullYear(), this.getMonth(), this.getDate()).getTime(); |
| 5347 | case "month": |
| 5348 | case "months": |
| 5349 | return new Date(t.getFullYear(), t.getMonth(), 1).getTime() >= new Date(this.getFullYear(), this.getMonth(), 1).getTime(); |
| 5350 | } |
| 5351 | throw new Error("isSameOrBefore: Invalid unit!"); |
| 5352 | } |
| 5353 | }, |
| 5354 | { |
| 5355 | key: "isAfter", |
| 5356 | value: function isAfter(t) { |
| 5357 | var e7 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5358 | switch(e7){ |
| 5359 | case "day": |
| 5360 | case "days": |
| 5361 | return new Date(this.getFullYear(), this.getMonth(), this.getDate()).getTime() > new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(); |
| 5362 | case "month": |
| 5363 | case "months": |
| 5364 | return new Date(this.getFullYear(), this.getMonth(), 1).getTime() > new Date(t.getFullYear(), t.getMonth(), 1).getTime(); |
| 5365 | case "year": |
| 5366 | case "years": |
| 5367 | return this.getFullYear() > t.getFullYear(); |
| 5368 | } |
| 5369 | throw new Error("isAfter: Invalid unit!"); |
| 5370 | } |
| 5371 | }, |
| 5372 | { |
| 5373 | key: "isSameOrAfter", |
| 5374 | value: function isSameOrAfter(t) { |
| 5375 | var e8 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5376 | switch(e8){ |
| 5377 | case "day": |
| 5378 | case "days": |
| 5379 | return new Date(this.getFullYear(), this.getMonth(), this.getDate()).getTime() >= new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(); |
| 5380 | case "month": |
| 5381 | case "months": |
| 5382 | return new Date(this.getFullYear(), this.getMonth(), 1).getTime() >= new Date(t.getFullYear(), t.getMonth(), 1).getTime(); |
| 5383 | } |
| 5384 | throw new Error("isSameOrAfter: Invalid unit!"); |
| 5385 | } |
| 5386 | }, |
| 5387 | { |
| 5388 | key: "isSame", |
| 5389 | value: function isSame(t) { |
| 5390 | var e9 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5391 | switch(e9){ |
| 5392 | case "day": |
| 5393 | case "days": |
| 5394 | return new Date(this.getFullYear(), this.getMonth(), this.getDate()).getTime() === new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(); |
| 5395 | case "month": |
| 5396 | case "months": |
| 5397 | return new Date(this.getFullYear(), this.getMonth(), 1).getTime() === new Date(t.getFullYear(), t.getMonth(), 1).getTime(); |
| 5398 | } |
| 5399 | throw new Error("isSame: Invalid unit!"); |
| 5400 | } |
| 5401 | }, |
| 5402 | { |
| 5403 | key: "add", |
| 5404 | value: function add(t) { |
| 5405 | var e10 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5406 | switch(e10){ |
| 5407 | case "day": |
| 5408 | case "days": |
| 5409 | this.setDate(this.getDate() + t); |
| 5410 | break; |
| 5411 | case "month": |
| 5412 | case "months": |
| 5413 | this.setMonth(this.getMonth() + t); |
| 5414 | } |
| 5415 | return this; |
| 5416 | } |
| 5417 | }, |
| 5418 | { |
| 5419 | key: "subtract", |
| 5420 | value: function subtract(t) { |
| 5421 | var e11 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5422 | switch(e11){ |
| 5423 | case "day": |
| 5424 | case "days": |
| 5425 | this.setDate(this.getDate() - t); |
| 5426 | break; |
| 5427 | case "month": |
| 5428 | case "months": |
| 5429 | this.setMonth(this.getMonth() - t); |
| 5430 | } |
| 5431 | return this; |
| 5432 | } |
| 5433 | }, |
| 5434 | { |
| 5435 | key: "diff", |
| 5436 | value: function diff(t) { |
| 5437 | var e13 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "days"; |
| 5438 | switch(e13){ |
| 5439 | default: |
| 5440 | case "day": |
| 5441 | case "days": |
| 5442 | return Math.round((this.midnight_ts() - this.midnight_ts(t)) / 864e5); |
| 5443 | case "month": |
| 5444 | case "months": |
| 5445 | var e12 = 12 * (t.getFullYear() - this.getFullYear()); |
| 5446 | return e12 -= t.getMonth(), e12 += this.getMonth(), e12; |
| 5447 | } |
| 5448 | } |
| 5449 | }, |
| 5450 | { |
| 5451 | key: "format", |
| 5452 | value: function format(e14) { |
| 5453 | var i4 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "en-US"; |
| 5454 | var n3 = ""; |
| 5455 | var s1 = []; |
| 5456 | var o2 = null; |
| 5457 | for(; null != (o2 = t1.regex.exec(e14));)"\\" !== o2[1] && s1.push(o2); |
| 5458 | if (s1.length) { |
| 5459 | s1[0].index > 0 && (n3 += e14.substring(0, s1[0].index)); |
| 5460 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 5461 | try { |
| 5462 | for(var _iterator = Object.entries(s1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 5463 | var _value = (0, _slicedToArrayJsDefault.default)(_step.value, 2), t = _value[0], o1 = _value[1]; |
| 5464 | var a1 = Number(t); |
| 5465 | n3 += this.formatTokens(o1[0], i4), s1[a1 + 1] && (n3 += e14.substring(o1.index + o1[0].length, s1[a1 + 1].index)), a1 === s1.length - 1 && (n3 += e14.substring(o1.index + o1[0].length)); |
| 5466 | } |
| 5467 | } catch (err) { |
| 5468 | _didIteratorError = true; |
| 5469 | _iteratorError = err; |
| 5470 | } finally{ |
| 5471 | try { |
| 5472 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 5473 | _iterator.return(); |
| 5474 | } |
| 5475 | } finally{ |
| 5476 | if (_didIteratorError) { |
| 5477 | throw _iteratorError; |
| 5478 | } |
| 5479 | } |
| 5480 | } |
| 5481 | } |
| 5482 | return n3.replace(/\\/g, ""); |
| 5483 | } |
| 5484 | }, |
| 5485 | { |
| 5486 | key: "midnight_ts", |
| 5487 | value: function midnight_ts(t) { |
| 5488 | return t ? new Date(t.getFullYear(), t.getMonth(), t.getDate(), 0, 0, 0, 0).getTime() : new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0, 0).getTime(); |
| 5489 | } |
| 5490 | }, |
| 5491 | { |
| 5492 | key: "formatTokens", |
| 5493 | value: function formatTokens(e15, i5) { |
| 5494 | switch(e15){ |
| 5495 | case "YY": |
| 5496 | return String(this.getFullYear()).slice(-2); |
| 5497 | case "YYYY": |
| 5498 | return String(this.getFullYear()); |
| 5499 | case "M": |
| 5500 | return String(this.getMonth() + 1); |
| 5501 | case "MM": |
| 5502 | return "0".concat(this.getMonth() + 1).slice(-2); |
| 5503 | case "MMM": |
| 5504 | return t1.shortMonths(i5)[this.getMonth()]; |
| 5505 | case "MMMM": |
| 5506 | return t1.longMonths(i5)[this.getMonth()]; |
| 5507 | case "D": |
| 5508 | return String(this.getDate()); |
| 5509 | case "DD": |
| 5510 | return "0".concat(this.getDate()).slice(-2); |
| 5511 | case "H": |
| 5512 | return String(this.getHours()); |
| 5513 | case "HH": |
| 5514 | return "0".concat(this.getHours()).slice(-2); |
| 5515 | case "h": |
| 5516 | return String(this.getHours() % 12 || 12); |
| 5517 | case "hh": |
| 5518 | return "0".concat(this.getHours() % 12 || 12).slice(-2); |
| 5519 | case "m": |
| 5520 | return String(this.getMinutes()); |
| 5521 | case "mm": |
| 5522 | return "0".concat(this.getMinutes()).slice(-2); |
| 5523 | case "s": |
| 5524 | return String(this.getSeconds()); |
| 5525 | case "ss": |
| 5526 | return "0".concat(this.getSeconds()).slice(-2); |
| 5527 | case "a": |
| 5528 | return this.getHours() < 12 || 24 === this.getHours() ? "am" : "pm"; |
| 5529 | case "A": |
| 5530 | return this.getHours() < 12 || 24 === this.getHours() ? "AM" : "PM"; |
| 5531 | default: |
| 5532 | return ""; |
| 5533 | } |
| 5534 | } |
| 5535 | } |
| 5536 | ], [ |
| 5537 | { |
| 5538 | key: "parseDateTime", |
| 5539 | value: function parseDateTime(e16) { |
| 5540 | var i7 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "YYYY-MM-DD", n4 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "en-US"; |
| 5541 | if (!e16) return new Date((new Date).setHours(0, 0, 0, 0)); |
| 5542 | if (e16 instanceof t1) return e16.toJSDate(); |
| 5543 | if (e16 instanceof Date) return e16; |
| 5544 | if (/^-?\d{10,}$/.test(String(e16))) return new Date(Number(e16)); |
| 5545 | if ("string" == typeof e16) { |
| 5546 | var s4 = []; |
| 5547 | var o5 = null; |
| 5548 | for(; null != (o5 = t1.regex.exec(i7));)"\\" !== o5[1] && s4.push(o5); |
| 5549 | if (s4.length) { |
| 5550 | var i6 = { |
| 5551 | year: null, |
| 5552 | month: null, |
| 5553 | shortMonth: null, |
| 5554 | longMonth: null, |
| 5555 | day: null, |
| 5556 | hour: 0, |
| 5557 | minute: 0, |
| 5558 | second: 0, |
| 5559 | ampm: null, |
| 5560 | value: "" |
| 5561 | }; |
| 5562 | s4[0].index > 0 && (i6.value += ".*?"); |
| 5563 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 5564 | try { |
| 5565 | for(var _iterator = Object.entries(s4)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ |
| 5566 | var _value = (0, _slicedToArrayJsDefault.default)(_step.value, 2), _$e = _value[0], o3 = _value[1]; |
| 5567 | var s2 = Number(_$e), ref = t1.formatPatterns(o3[0], n4), a3 = ref.group, r2 = ref.pattern; |
| 5568 | i6[a3] = s2 + 1, i6.value += r2, i6.value += ".*?"; |
| 5569 | } |
| 5570 | } catch (err) { |
| 5571 | _didIteratorError = true; |
| 5572 | _iteratorError = err; |
| 5573 | } finally{ |
| 5574 | try { |
| 5575 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 5576 | _iterator.return(); |
| 5577 | } |
| 5578 | } finally{ |
| 5579 | if (_didIteratorError) { |
| 5580 | throw _iteratorError; |
| 5581 | } |
| 5582 | } |
| 5583 | } |
| 5584 | var o4 = new RegExp("^".concat(i6.value, "$")); |
| 5585 | if (o4.test(e16)) { |
| 5586 | var s3 = o4.exec(e16), a2 = Number(s3[i6.year]); |
| 5587 | var r1 = null; |
| 5588 | i6.month ? r1 = Number(s3[i6.month]) - 1 : i6.shortMonth ? r1 = t1.shortMonths(n4).indexOf(s3[i6.shortMonth]) : i6.longMonth && (r1 = t1.longMonths(n4).indexOf(s3[i6.longMonth])); |
| 5589 | var c1 = Number(s3[i6.day]) || 1, l1 = Number(s3[i6.hour]); |
| 5590 | var h1 = Number.isNaN(l1) ? 0 : l1; |
| 5591 | var d1 = Number(s3[i6.minute]), p = Number.isNaN(d1) ? 0 : d1, u = Number(s3[i6.second]), g = Number.isNaN(u) ? 0 : u, m = s3[i6.ampm]; |
| 5592 | return m && "PM" === m && (h1 += 12, 24 === h1 && (h1 = 0)), new Date(a2, r1, c1, h1, p, g, 0); |
| 5593 | } |
| 5594 | } |
| 5595 | } |
| 5596 | return new Date((new Date).setHours(0, 0, 0, 0)); |
| 5597 | } |
| 5598 | }, |
| 5599 | { |
| 5600 | key: "shortMonths", |
| 5601 | value: function shortMonths(e17) { |
| 5602 | return t1.MONTH_JS.map(function(t) { |
| 5603 | return new Date(2019, t).toLocaleString(e17, { |
| 5604 | month: "short" |
| 5605 | }); |
| 5606 | }); |
| 5607 | } |
| 5608 | }, |
| 5609 | { |
| 5610 | key: "longMonths", |
| 5611 | value: function longMonths(e18) { |
| 5612 | return t1.MONTH_JS.map(function(t) { |
| 5613 | return new Date(2019, t).toLocaleString(e18, { |
| 5614 | month: "long" |
| 5615 | }); |
| 5616 | }); |
| 5617 | } |
| 5618 | }, |
| 5619 | { |
| 5620 | key: "formatPatterns", |
| 5621 | value: function formatPatterns(e19, i8) { |
| 5622 | switch(e19){ |
| 5623 | case "YY": |
| 5624 | case "YYYY": |
| 5625 | return { |
| 5626 | group: "year", |
| 5627 | pattern: "(\\d{".concat(e19.length, "})") |
| 5628 | }; |
| 5629 | case "M": |
| 5630 | return { |
| 5631 | group: "month", |
| 5632 | pattern: "(\\d{1,2})" |
| 5633 | }; |
| 5634 | case "MM": |
| 5635 | return { |
| 5636 | group: "month", |
| 5637 | pattern: "(\\d{2})" |
| 5638 | }; |
| 5639 | case "MMM": |
| 5640 | return { |
| 5641 | group: "shortMonth", |
| 5642 | pattern: "(".concat(t1.shortMonths(i8).join("|"), ")") |
| 5643 | }; |
| 5644 | case "MMMM": |
| 5645 | return { |
| 5646 | group: "longMonth", |
| 5647 | pattern: "(".concat(t1.longMonths(i8).join("|"), ")") |
| 5648 | }; |
| 5649 | case "D": |
| 5650 | return { |
| 5651 | group: "day", |
| 5652 | pattern: "(\\d{1,2})" |
| 5653 | }; |
| 5654 | case "DD": |
| 5655 | return { |
| 5656 | group: "day", |
| 5657 | pattern: "(\\d{2})" |
| 5658 | }; |
| 5659 | case "h": |
| 5660 | case "H": |
| 5661 | return { |
| 5662 | group: "hour", |
| 5663 | pattern: "(\\d{1,2})" |
| 5664 | }; |
| 5665 | case "hh": |
| 5666 | case "HH": |
| 5667 | return { |
| 5668 | group: "hour", |
| 5669 | pattern: "(\\d{2})" |
| 5670 | }; |
| 5671 | case "m": |
| 5672 | return { |
| 5673 | group: "minute", |
| 5674 | pattern: "(\\d{1,2})" |
| 5675 | }; |
| 5676 | case "mm": |
| 5677 | return { |
| 5678 | group: "minute", |
| 5679 | pattern: "(\\d{2})" |
| 5680 | }; |
| 5681 | case "s": |
| 5682 | return { |
| 5683 | group: "second", |
| 5684 | pattern: "(\\d{1,2})" |
| 5685 | }; |
| 5686 | case "ss": |
| 5687 | return { |
| 5688 | group: "second", |
| 5689 | pattern: "(\\d{2})" |
| 5690 | }; |
| 5691 | case "a": |
| 5692 | case "A": |
| 5693 | return { |
| 5694 | group: "ampm", |
| 5695 | pattern: "(AM|PM|am|pm)" |
| 5696 | }; |
| 5697 | } |
| 5698 | } |
| 5699 | } |
| 5700 | ]); |
| 5701 | return t1; |
| 5702 | }((0, _wrapNativeSuperJsDefault.default)(Date)); |
| 5703 | (0, _definePropertyJsDefault.default)(t1, "regex", /(\\)?(Y{2,4}|M{1,4}|D{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|A|a)/g); |
| 5704 | (0, _definePropertyJsDefault.default)(t1, "MONTH_JS", [ |
| 5705 | 0, |
| 5706 | 1, |
| 5707 | 2, |
| 5708 | 3, |
| 5709 | 4, |
| 5710 | 5, |
| 5711 | 6, |
| 5712 | 7, |
| 5713 | 8, |
| 5714 | 9, |
| 5715 | 10, |
| 5716 | 11 |
| 5717 | ]); |
| 5718 | var e20 = /*#__PURE__*/ function() { |
| 5719 | "use strict"; |
| 5720 | function e20(t) { |
| 5721 | (0, _classCallCheckJsDefault.default)(this, e20); |
| 5722 | (0, _definePropertyJsDefault.default)(this, "picker", void 0); |
| 5723 | this.picker = t; |
| 5724 | } |
| 5725 | (0, _createClassJsDefault.default)(e20, [ |
| 5726 | { |
| 5727 | key: "render", |
| 5728 | value: function render(e21, i9) { |
| 5729 | e21 || (e21 = new t1), e21.setDate(1), e21.setHours(0, 0, 0, 0), "function" == typeof this["get".concat(i9, "View")] && this["get".concat(i9, "View")](e21); |
| 5730 | } |
| 5731 | }, |
| 5732 | { |
| 5733 | key: "getContainerView", |
| 5734 | value: function getContainerView(t) { |
| 5735 | this.picker.ui.container.innerHTML = "", this.picker.options.header && this.picker.trigger("render", { |
| 5736 | date: t.clone(), |
| 5737 | view: "Header" |
| 5738 | }), this.picker.trigger("render", { |
| 5739 | date: t.clone(), |
| 5740 | view: "Main" |
| 5741 | }), this.picker.options.autoApply || this.picker.trigger("render", { |
| 5742 | date: t.clone(), |
| 5743 | view: "Footer" |
| 5744 | }); |
| 5745 | } |
| 5746 | }, |
| 5747 | { |
| 5748 | key: "getHeaderView", |
| 5749 | value: function getHeaderView(t) { |
| 5750 | var e = document.createElement("header"); |
| 5751 | this.picker.options.header instanceof HTMLElement && e.appendChild(this.picker.options.header), "string" == typeof this.picker.options.header && (e.innerHTML = this.picker.options.header), this.picker.ui.container.appendChild(e), this.picker.trigger("view", { |
| 5752 | target: e, |
| 5753 | date: t.clone(), |
| 5754 | view: "Header" |
| 5755 | }); |
| 5756 | } |
| 5757 | }, |
| 5758 | { |
| 5759 | key: "getMainView", |
| 5760 | value: function getMainView(t) { |
| 5761 | var e = document.createElement("main"); |
| 5762 | this.picker.ui.container.appendChild(e); |
| 5763 | var i10 = document.createElement("div"); |
| 5764 | i10.className = "calendars grid-".concat(this.picker.options.grid); |
| 5765 | for(var e22 = 0; e22 < this.picker.options.calendars; e22++){ |
| 5766 | var n5 = document.createElement("div"); |
| 5767 | n5.className = "calendar", i10.appendChild(n5); |
| 5768 | var s5 = this.getCalendarHeaderView(t.clone()); |
| 5769 | n5.appendChild(s5), this.picker.trigger("view", { |
| 5770 | date: t.clone(), |
| 5771 | view: "CalendarHeader", |
| 5772 | index: e22, |
| 5773 | target: s5 |
| 5774 | }); |
| 5775 | var o6 = this.getCalendarDayNamesView(); |
| 5776 | n5.appendChild(o6), this.picker.trigger("view", { |
| 5777 | date: t.clone(), |
| 5778 | view: "CalendarDayNames", |
| 5779 | index: e22, |
| 5780 | target: o6 |
| 5781 | }); |
| 5782 | var a4 = this.getCalendarDaysView(t.clone()); |
| 5783 | n5.appendChild(a4), this.picker.trigger("view", { |
| 5784 | date: t.clone(), |
| 5785 | view: "CalendarDays", |
| 5786 | index: e22, |
| 5787 | target: a4 |
| 5788 | }); |
| 5789 | var r3 = this.getCalendarFooterView(this.picker.options.lang, t.clone()); |
| 5790 | n5.appendChild(r3), this.picker.trigger("view", { |
| 5791 | date: t.clone(), |
| 5792 | view: "CalendarFooter", |
| 5793 | index: e22, |
| 5794 | target: r3 |
| 5795 | }), this.picker.trigger("view", { |
| 5796 | date: t.clone(), |
| 5797 | view: "CalendarItem", |
| 5798 | index: e22, |
| 5799 | target: n5 |
| 5800 | }), t.add(1, "month"); |
| 5801 | } |
| 5802 | e.appendChild(i10), this.picker.trigger("view", { |
| 5803 | date: t.clone(), |
| 5804 | view: "Calendars", |
| 5805 | target: i10 |
| 5806 | }), this.picker.trigger("view", { |
| 5807 | date: t.clone(), |
| 5808 | view: "Main", |
| 5809 | target: e |
| 5810 | }); |
| 5811 | } |
| 5812 | }, |
| 5813 | { |
| 5814 | key: "getFooterView", |
| 5815 | value: function getFooterView(t) { |
| 5816 | var e = document.createElement("footer"), i11 = document.createElement("div"); |
| 5817 | i11.className = "footer-buttons"; |
| 5818 | var n6 = document.createElement("button"); |
| 5819 | n6.className = "cancel-button unit", n6.innerHTML = this.picker.options.locale.cancel, i11.appendChild(n6); |
| 5820 | var s6 = document.createElement("button"); |
| 5821 | s6.className = "apply-button unit", s6.innerHTML = this.picker.options.locale.apply, s6.disabled = !0, i11.appendChild(s6), e.appendChild(i11), this.picker.ui.container.appendChild(e), this.picker.trigger("view", { |
| 5822 | date: t, |
| 5823 | target: e, |
| 5824 | view: "Footer" |
| 5825 | }); |
| 5826 | } |
| 5827 | }, |
| 5828 | { |
| 5829 | key: "getCalendarHeaderView", |
| 5830 | value: function getCalendarHeaderView(t) { |
| 5831 | var e = document.createElement("div"); |
| 5832 | e.className = "header"; |
| 5833 | var i12 = document.createElement("div"); |
| 5834 | i12.className = "month-name", i12.innerHTML = "<span>".concat(t.toLocaleString(this.picker.options.lang, { |
| 5835 | month: "long" |
| 5836 | }), "</span> ").concat(t.format("YYYY")), e.appendChild(i12); |
| 5837 | var n7 = document.createElement("button"); |
| 5838 | n7.className = "previous-button unit", n7.innerHTML = this.picker.options.locale.previousMonth, e.appendChild(n7); |
| 5839 | var s7 = document.createElement("button"); |
| 5840 | return s7.className = "next-button unit", s7.innerHTML = this.picker.options.locale.nextMonth, e.appendChild(s7), e; |
| 5841 | } |
| 5842 | }, |
| 5843 | { |
| 5844 | key: "getCalendarDayNamesView", |
| 5845 | value: function getCalendarDayNamesView() { |
| 5846 | var t = document.createElement("div"); |
| 5847 | t.className = "daynames-row"; |
| 5848 | for(var e = 1; e <= 7; e++){ |
| 5849 | var i13 = 3 + this.picker.options.firstDay + e, n8 = document.createElement("div"); |
| 5850 | n8.className = "dayname", n8.innerHTML = new Date(1970, 0, i13, 12, 0, 0, 0).toLocaleString(this.picker.options.lang, { |
| 5851 | weekday: "short" |
| 5852 | }), n8.title = new Date(1970, 0, i13, 12, 0, 0, 0).toLocaleString(this.picker.options.lang, { |
| 5853 | weekday: "long" |
| 5854 | }), t.appendChild(n8), this.picker.trigger("view", { |
| 5855 | dayIdx: i13, |
| 5856 | view: "CalendarDayName", |
| 5857 | target: n8 |
| 5858 | }); |
| 5859 | } |
| 5860 | return t; |
| 5861 | } |
| 5862 | }, |
| 5863 | { |
| 5864 | key: "getCalendarDaysView", |
| 5865 | value: function getCalendarDaysView(t) { |
| 5866 | var e = document.createElement("div"); |
| 5867 | e.className = "days-grid"; |
| 5868 | var i15 = this.calcOffsetDays(t, this.picker.options.firstDay), n10 = 32 - new Date(t.getFullYear(), t.getMonth(), 32).getDate(); |
| 5869 | for(var _$t = 0; _$t < i15; _$t++){ |
| 5870 | var _$t1 = document.createElement("div"); |
| 5871 | _$t1.className = "offset", e.appendChild(_$t1); |
| 5872 | } |
| 5873 | for(var i14 = 1; i14 <= n10; i14++){ |
| 5874 | t.setDate(i14); |
| 5875 | var n9 = this.getCalendarDayView(t); |
| 5876 | e.appendChild(n9), this.picker.trigger("view", { |
| 5877 | date: t, |
| 5878 | view: "CalendarDay", |
| 5879 | target: n9 |
| 5880 | }); |
| 5881 | } |
| 5882 | return e; |
| 5883 | } |
| 5884 | }, |
| 5885 | { |
| 5886 | key: "getCalendarDayView", |
| 5887 | value: function getCalendarDayView(e) { |
| 5888 | var i16 = this.picker.options.date ? new t1(this.picker.options.date) : null, n11 = new t1, s8 = document.createElement("div"); |
| 5889 | return s8.className = "day unit", s8.innerHTML = e.format("D"), s8.dataset.time = String(e.getTime()), e.isSame(n11, "day") && s8.classList.add("today"), [ |
| 5890 | 0, |
| 5891 | 6 |
| 5892 | ].includes(e.getDay()) && s8.classList.add("weekend"), this.picker.datePicked.length ? this.picker.datePicked[0].isSame(e, "day") && s8.classList.add("selected") : i16 && e.isSame(i16, "day") && s8.classList.add("selected"), this.picker.trigger("view", { |
| 5893 | date: e, |
| 5894 | view: "CalendarDay", |
| 5895 | target: s8 |
| 5896 | }), s8; |
| 5897 | } |
| 5898 | }, |
| 5899 | { |
| 5900 | key: "getCalendarFooterView", |
| 5901 | value: function getCalendarFooterView(t, e) { |
| 5902 | var i17 = document.createElement("div"); |
| 5903 | return i17.className = "footer", i17; |
| 5904 | } |
| 5905 | }, |
| 5906 | { |
| 5907 | key: "calcOffsetDays", |
| 5908 | value: function calcOffsetDays(t, e) { |
| 5909 | var i18 = t.getDay() - e; |
| 5910 | return i18 < 0 && (i18 += 7), i18; |
| 5911 | } |
| 5912 | } |
| 5913 | ]); |
| 5914 | return e20; |
| 5915 | }(); |
| 5916 | var i = /*#__PURE__*/ function() { |
| 5917 | "use strict"; |
| 5918 | function i(t) { |
| 5919 | (0, _classCallCheckJsDefault.default)(this, i); |
| 5920 | (0, _definePropertyJsDefault.default)(this, "picker", void 0); |
| 5921 | (0, _definePropertyJsDefault.default)(this, "instances", {}); |
| 5922 | this.picker = t; |
| 5923 | } |
| 5924 | (0, _createClassJsDefault.default)(i, [ |
| 5925 | { |
| 5926 | key: "initialize", |
| 5927 | value: function initialize() { |
| 5928 | var _this = this; |
| 5929 | var t4 = []; |
| 5930 | this.picker.options.plugins.forEach(function(e) { |
| 5931 | "function" == typeof e ? t4.push(new e) : "string" == typeof e && "undefined" != typeof easepick && Object.prototype.hasOwnProperty.call(easepick, e) ? t4.push(new easepick[e]) : console.warn("easepick: ".concat(e, " not found.")); |
| 5932 | }), t4.sort(function(t, e) { |
| 5933 | return t.priority > e.priority ? -1 : t.priority < e.priority || t.dependencies.length > e.dependencies.length ? 1 : t.dependencies.length < e.dependencies.length ? -1 : 0; |
| 5934 | }), t4.forEach(function(t) { |
| 5935 | t.attach(_this.picker), _this.instances[t.getName()] = t; |
| 5936 | }); |
| 5937 | } |
| 5938 | }, |
| 5939 | { |
| 5940 | key: "getInstance", |
| 5941 | value: function getInstance(t) { |
| 5942 | return this.instances[t]; |
| 5943 | } |
| 5944 | }, |
| 5945 | { |
| 5946 | key: "addInstance", |
| 5947 | value: function addInstance(t) { |
| 5948 | if (Object.prototype.hasOwnProperty.call(this.instances, t)) console.warn("easepick: ".concat(t, " already added.")); |
| 5949 | else { |
| 5950 | if ("undefined" != typeof easepick && Object.prototype.hasOwnProperty.call(easepick, t)) { |
| 5951 | var e = new easepick[t]; |
| 5952 | return e.attach(this.picker), this.instances[e.getName()] = e, e; |
| 5953 | } |
| 5954 | if ("undefined" !== this.getPluginFn(t)) { |
| 5955 | var e23 = new (this.getPluginFn(t)); |
| 5956 | return e23.attach(this.picker), this.instances[e23.getName()] = e23, e23; |
| 5957 | } |
| 5958 | console.warn("easepick: ".concat(t, " not found.")); |
| 5959 | } |
| 5960 | return null; |
| 5961 | } |
| 5962 | }, |
| 5963 | { |
| 5964 | key: "removeInstance", |
| 5965 | value: function removeInstance(t) { |
| 5966 | return t in this.instances && this.instances[t].detach(), delete this.instances[t]; |
| 5967 | } |
| 5968 | }, |
| 5969 | { |
| 5970 | key: "reloadInstance", |
| 5971 | value: function reloadInstance(t) { |
| 5972 | return this.removeInstance(t), this.addInstance(t); |
| 5973 | } |
| 5974 | }, |
| 5975 | { |
| 5976 | key: "getPluginFn", |
| 5977 | value: function getPluginFn(t) { |
| 5978 | return (0, _toConsumableArrayJsDefault.default)(this.picker.options.plugins).filter(function(e) { |
| 5979 | return "function" == typeof e && (new e).getName() === t; |
| 5980 | }).shift(); |
| 5981 | } |
| 5982 | } |
| 5983 | ]); |
| 5984 | return i; |
| 5985 | }(); |
| 5986 | var n12 = /*#__PURE__*/ function() { |
| 5987 | "use strict"; |
| 5988 | function n12(t) { |
| 5989 | (0, _classCallCheckJsDefault.default)(this, n12); |
| 5990 | (0, _definePropertyJsDefault.default)(this, "Calendar", new e20(this)); |
| 5991 | (0, _definePropertyJsDefault.default)(this, "PluginManager", new i(this)); |
| 5992 | (0, _definePropertyJsDefault.default)(this, "calendars", []); |
| 5993 | (0, _definePropertyJsDefault.default)(this, "datePicked", []); |
| 5994 | (0, _definePropertyJsDefault.default)(this, "cssLoaded", 0); |
| 5995 | (0, _definePropertyJsDefault.default)(this, "binds", { |
| 5996 | hidePicker: this.hidePicker.bind(this), |
| 5997 | show: this.show.bind(this) |
| 5998 | }); |
| 5999 | (0, _definePropertyJsDefault.default)(this, "options", { |
| 6000 | doc: document, |
| 6001 | css: [], |
| 6002 | element: null, |
| 6003 | firstDay: 1, |
| 6004 | grid: 1, |
| 6005 | calendars: 1, |
| 6006 | lang: "en-US", |
| 6007 | date: null, |
| 6008 | format: "YYYY-MM-DD", |
| 6009 | readonly: !0, |
| 6010 | autoApply: !0, |
| 6011 | header: !1, |
| 6012 | inline: !1, |
| 6013 | scrollToDate: !0, |
| 6014 | locale: { |
| 6015 | nextMonth: '<svg width="11" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M2.748 16L0 13.333 5.333 8 0 2.667 2.748 0l7.919 8z" fill-rule="nonzero"/></svg>', |
| 6016 | previousMonth: '<svg width="11" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M7.919 0l2.748 2.667L5.333 8l5.334 5.333L7.919 16 0 8z" fill-rule="nonzero"/></svg>', |
| 6017 | cancel: "Cancel", |
| 6018 | apply: "Apply" |
| 6019 | }, |
| 6020 | documentClick: this.binds.hidePicker, |
| 6021 | plugins: [] |
| 6022 | }); |
| 6023 | (0, _definePropertyJsDefault.default)(this, "ui", { |
| 6024 | container: null, |
| 6025 | shadowRoot: null, |
| 6026 | wrapper: null |
| 6027 | }); |
| 6028 | (0, _definePropertyJsDefault.default)(this, "version", "1.2.0"); |
| 6029 | var e = (0, _objectSpreadJsDefault.default)({}, this.options.locale, t.locale); |
| 6030 | this.options = (0, _objectSpreadJsDefault.default)({}, this.options, t), this.options.locale = e, this.handleOptions(), this.ui.wrapper = document.createElement("span"), this.ui.wrapper.style.display = "none", this.ui.wrapper.style.position = "absolute", this.ui.wrapper.style.pointerEvents = "none", this.ui.wrapper.className = "easepick-wrapper", this.ui.wrapper.attachShadow({ |
| 6031 | mode: "open" |
| 6032 | }), this.ui.shadowRoot = this.ui.wrapper.shadowRoot, this.ui.container = document.createElement("div"), this.ui.container.className = "container", this.options.zIndex && (this.ui.container.style.zIndex = String(this.options.zIndex)), this.options.inline && (this.ui.wrapper.style.position = "relative", this.ui.container.classList.add("inline")), this.ui.shadowRoot.appendChild(this.ui.container), this.options.element.after(this.ui.wrapper), this.handleCSS(), this.options.element.addEventListener("click", this.binds.show), this.on("view", this.onView.bind(this)), this.on("render", this.onRender.bind(this)), this.PluginManager.initialize(), this.parseValues(), "function" == typeof this.options.setup && this.options.setup(this), this.on("click", this.onClick.bind(this)); |
| 6033 | var i19 = this.options.scrollToDate ? this.getDate() : null; |
| 6034 | this.renderAll(i19); |
| 6035 | } |
| 6036 | (0, _createClassJsDefault.default)(n12, [ |
| 6037 | { |
| 6038 | key: "on", |
| 6039 | value: function on(t, e) { |
| 6040 | var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 6041 | this.ui.container.addEventListener(t, e, i); |
| 6042 | } |
| 6043 | }, |
| 6044 | { |
| 6045 | key: "off", |
| 6046 | value: function off(t, e) { |
| 6047 | var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; |
| 6048 | this.ui.container.removeEventListener(t, e, i); |
| 6049 | } |
| 6050 | }, |
| 6051 | { |
| 6052 | key: "trigger", |
| 6053 | value: function trigger(t) { |
| 6054 | var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; |
| 6055 | return this.ui.container.dispatchEvent(new CustomEvent(t, { |
| 6056 | detail: e |
| 6057 | })); |
| 6058 | } |
| 6059 | }, |
| 6060 | { |
| 6061 | key: "destroy", |
| 6062 | value: function destroy() { |
| 6063 | var _this = this; |
| 6064 | this.options.element.removeEventListener("click", this.binds.show), "function" == typeof this.options.documentClick && document.removeEventListener("click", this.options.documentClick, !0), Object.keys(this.PluginManager.instances).forEach(function(t) { |
| 6065 | _this.PluginManager.removeInstance(t); |
| 6066 | }), this.ui.wrapper.remove(); |
| 6067 | } |
| 6068 | }, |
| 6069 | { |
| 6070 | key: "onRender", |
| 6071 | value: function onRender(t) { |
| 6072 | var _detail = t.detail, e = _detail.view, i = _detail.date; |
| 6073 | this.Calendar.render(i, e); |
| 6074 | } |
| 6075 | }, |
| 6076 | { |
| 6077 | key: "onView", |
| 6078 | value: function onView(t) { |
| 6079 | var _detail = t.detail, e = _detail.view, i = _detail.target; |
| 6080 | "Footer" === e && this.datePicked.length && (i.querySelector(".apply-button").disabled = !1); |
| 6081 | } |
| 6082 | }, |
| 6083 | { |
| 6084 | key: "onClickHeaderButton", |
| 6085 | value: function onClickHeaderButton(t) { |
| 6086 | this.isCalendarHeaderButton(t) && (t.classList.contains("next-button") ? this.calendars[0].add(1, "month") : this.calendars[0].subtract(1, "month"), this.renderAll(this.calendars[0])); |
| 6087 | } |
| 6088 | }, |
| 6089 | { |
| 6090 | key: "onClickCalendarDay", |
| 6091 | value: function onClickCalendarDay(e) { |
| 6092 | if (this.isCalendarDay(e)) { |
| 6093 | var i = new t1(e.dataset.time); |
| 6094 | this.options.autoApply ? (this.setDate(i), this.trigger("select", { |
| 6095 | date: this.getDate() |
| 6096 | }), this.hide()) : (this.datePicked[0] = i, this.trigger("preselect", { |
| 6097 | date: this.getDate() |
| 6098 | }), this.renderAll()); |
| 6099 | } |
| 6100 | } |
| 6101 | }, |
| 6102 | { |
| 6103 | key: "onClickApplyButton", |
| 6104 | value: function onClickApplyButton(t) { |
| 6105 | if (this.isApplyButton(t)) { |
| 6106 | if (this.datePicked[0] instanceof Date) { |
| 6107 | var _$t = this.datePicked[0].clone(); |
| 6108 | this.setDate(_$t); |
| 6109 | } |
| 6110 | this.hide(), this.trigger("select", { |
| 6111 | date: this.getDate() |
| 6112 | }); |
| 6113 | } |
| 6114 | } |
| 6115 | }, |
| 6116 | { |
| 6117 | key: "onClickCancelButton", |
| 6118 | value: function onClickCancelButton(t) { |
| 6119 | this.isCancelButton(t) && this.hide(); |
| 6120 | } |
| 6121 | }, |
| 6122 | { |
| 6123 | key: "onClick", |
| 6124 | value: function onClick(t) { |
| 6125 | var e = t.target; |
| 6126 | if (e instanceof HTMLElement) { |
| 6127 | var _$t = e.closest(".unit"); |
| 6128 | if (!(_$t instanceof HTMLElement)) return; |
| 6129 | this.onClickHeaderButton(_$t), this.onClickCalendarDay(_$t), this.onClickApplyButton(_$t), this.onClickCancelButton(_$t); |
| 6130 | } |
| 6131 | } |
| 6132 | }, |
| 6133 | { |
| 6134 | key: "isShown", |
| 6135 | value: function isShown() { |
| 6136 | return this.ui.container.classList.contains("inline") || this.ui.container.classList.contains("show"); |
| 6137 | } |
| 6138 | }, |
| 6139 | { |
| 6140 | key: "show", |
| 6141 | value: function show(t) { |
| 6142 | if (this.isShown()) return; |
| 6143 | var e = t && "target" in t ? t.target : this.options.element, ref = this.adjustPosition(e), i = ref.top, n13 = ref.left; |
| 6144 | this.ui.container.style.top = "".concat(i, "px"), this.ui.container.style.left = "".concat(n13, "px"), this.ui.container.classList.add("show"), this.trigger("show", { |
| 6145 | target: e |
| 6146 | }); |
| 6147 | } |
| 6148 | }, |
| 6149 | { |
| 6150 | key: "hide", |
| 6151 | value: function hide() { |
| 6152 | this.ui.container.classList.remove("show"), this.datePicked.length = 0, this.renderAll(), this.trigger("hide"); |
| 6153 | } |
| 6154 | }, |
| 6155 | { |
| 6156 | key: "setDate", |
| 6157 | value: function setDate(e) { |
| 6158 | var i = new t1(e, this.options.format); |
| 6159 | this.options.date = i.clone(), this.updateValues(), this.calendars.length && this.renderAll(); |
| 6160 | } |
| 6161 | }, |
| 6162 | { |
| 6163 | key: "getDate", |
| 6164 | value: function getDate() { |
| 6165 | return this.options.date instanceof t1 ? this.options.date.clone() : null; |
| 6166 | } |
| 6167 | }, |
| 6168 | { |
| 6169 | key: "parseValues", |
| 6170 | value: function parseValues() { |
| 6171 | this.options.date ? this.setDate(this.options.date) : this.options.element instanceof HTMLInputElement && this.options.element.value.length && this.setDate(this.options.element.value), this.options.date instanceof Date || (this.options.date = null); |
| 6172 | } |
| 6173 | }, |
| 6174 | { |
| 6175 | key: "updateValues", |
| 6176 | value: function updateValues() { |
| 6177 | var t = this.getDate(), e = t instanceof Date ? t.format(this.options.format, this.options.lang) : "", i = this.options.element; |
| 6178 | i instanceof HTMLInputElement ? i.value = e : i instanceof HTMLElement && (i.innerText = e); |
| 6179 | } |
| 6180 | }, |
| 6181 | { |
| 6182 | key: "hidePicker", |
| 6183 | value: function hidePicker(t) { |
| 6184 | var e = t.target, i = null; |
| 6185 | e.shadowRoot && (e = t.composedPath()[0], i = e.getRootNode().host), this.isShown() && i !== this.ui.wrapper && e !== this.options.element && this.hide(); |
| 6186 | } |
| 6187 | }, |
| 6188 | { |
| 6189 | key: "renderAll", |
| 6190 | value: function renderAll(t) { |
| 6191 | this.trigger("render", { |
| 6192 | view: "Container", |
| 6193 | date: (t || this.calendars[0]).clone() |
| 6194 | }); |
| 6195 | } |
| 6196 | }, |
| 6197 | { |
| 6198 | key: "isCalendarHeaderButton", |
| 6199 | value: function isCalendarHeaderButton(t) { |
| 6200 | return [ |
| 6201 | "previous-button", |
| 6202 | "next-button" |
| 6203 | ].some(function(e) { |
| 6204 | return t.classList.contains(e); |
| 6205 | }); |
| 6206 | } |
| 6207 | }, |
| 6208 | { |
| 6209 | key: "isCalendarDay", |
| 6210 | value: function isCalendarDay(t) { |
| 6211 | return t.classList.contains("day"); |
| 6212 | } |
| 6213 | }, |
| 6214 | { |
| 6215 | key: "isApplyButton", |
| 6216 | value: function isApplyButton(t) { |
| 6217 | return t.classList.contains("apply-button"); |
| 6218 | } |
| 6219 | }, |
| 6220 | { |
| 6221 | key: "isCancelButton", |
| 6222 | value: function isCancelButton(t) { |
| 6223 | return t.classList.contains("cancel-button"); |
| 6224 | } |
| 6225 | }, |
| 6226 | { |
| 6227 | key: "gotoDate", |
| 6228 | value: function gotoDate(e) { |
| 6229 | var i = new t1(e, this.options.format); |
| 6230 | i.setDate(1), this.calendars[0] = i.clone(), this.renderAll(); |
| 6231 | } |
| 6232 | }, |
| 6233 | { |
| 6234 | key: "clear", |
| 6235 | value: function clear() { |
| 6236 | this.options.date = null, this.datePicked.length = 0, this.updateValues(), this.renderAll(), this.trigger("clear"); |
| 6237 | } |
| 6238 | }, |
| 6239 | { |
| 6240 | key: "handleOptions", |
| 6241 | value: function handleOptions() { |
| 6242 | this.options.element instanceof HTMLElement || (this.options.element = this.options.doc.querySelector(this.options.element)), "function" == typeof this.options.documentClick && document.addEventListener("click", this.options.documentClick, !0), this.options.element instanceof HTMLInputElement && (this.options.element.readOnly = this.options.readonly), this.options.date ? this.calendars[0] = new t1(this.options.date, this.options.format) : this.calendars[0] = new t1; |
| 6243 | } |
| 6244 | }, |
| 6245 | { |
| 6246 | key: "handleCSS", |
| 6247 | value: function handleCSS() { |
| 6248 | var _this = this; |
| 6249 | if (Array.isArray(this.options.css)) this.options.css.forEach(function(t) { |
| 6250 | var _this1 = _this; |
| 6251 | var e = document.createElement("link"); |
| 6252 | e.href = t, e.rel = "stylesheet"; |
| 6253 | var i = function() { |
| 6254 | _this1.cssLoaded++, _this1.cssLoaded === _this1.options.css.length && (_this1.ui.wrapper.style.display = ""); |
| 6255 | }; |
| 6256 | e.addEventListener("load", i), e.addEventListener("error", i), _this.ui.shadowRoot.append(e); |
| 6257 | }); |
| 6258 | else if ("string" == typeof this.options.css) { |
| 6259 | var t5 = document.createElement("style"), e24 = document.createTextNode(this.options.css); |
| 6260 | t5.appendChild(e24), this.ui.shadowRoot.append(t5), this.ui.wrapper.style.display = ""; |
| 6261 | } else "function" == typeof this.options.css && (this.options.css.call(this, this), this.ui.wrapper.style.display = ""); |
| 6262 | } |
| 6263 | }, |
| 6264 | { |
| 6265 | key: "adjustPosition", |
| 6266 | value: function adjustPosition(t) { |
| 6267 | var e = t.getBoundingClientRect(), i = this.ui.wrapper.getBoundingClientRect(); |
| 6268 | this.ui.container.classList.add("calc"); |
| 6269 | var n = this.ui.container.getBoundingClientRect(); |
| 6270 | this.ui.container.classList.remove("calc"); |
| 6271 | var s9 = e.bottom - i.bottom, o7 = e.left - i.left; |
| 6272 | return "undefined" != typeof window && (window.innerHeight < s9 + n.height && s9 - n.height >= 0 && (s9 = e.top - i.top - n.height), window.innerWidth < o7 + n.width && e.right - n.width >= 0 && (o7 = e.right - i.right - n.width)), { |
| 6273 | left: o7, |
| 6274 | top: s9 |
| 6275 | }; |
| 6276 | } |
| 6277 | } |
| 6278 | ]); |
| 6279 | return n12; |
| 6280 | }(); |
| 6281 | var s = Object.freeze({ |
| 6282 | __proto__: null, |
| 6283 | Core: n12, |
| 6284 | create: n12 |
| 6285 | }); |
| 6286 | var o = /*#__PURE__*/ function() { |
| 6287 | "use strict"; |
| 6288 | function o() { |
| 6289 | (0, _classCallCheckJsDefault.default)(this, o); |
| 6290 | (0, _definePropertyJsDefault.default)(this, "picker", void 0); |
| 6291 | (0, _definePropertyJsDefault.default)(this, "options", void 0); |
| 6292 | (0, _definePropertyJsDefault.default)(this, "priority", 0); |
| 6293 | (0, _definePropertyJsDefault.default)(this, "dependencies", []); |
| 6294 | } |
| 6295 | (0, _createClassJsDefault.default)(o, [ |
| 6296 | { |
| 6297 | key: "attach", |
| 6298 | value: function attach(t6) { |
| 6299 | var e = this.getName(), i = (0, _objectSpreadJsDefault.default)({}, this.options); |
| 6300 | this.options = (0, _objectSpreadJsDefault.default)({}, this.options, t6.options[e] || {}); |
| 6301 | var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; |
| 6302 | try { |
| 6303 | var _this = this, _loop = function(_iterator, _step) { |
| 6304 | var n = _step.value; |
| 6305 | if (null !== i[n] && "object" == typeof i[n] && Object.keys(i[n]).length && e in t6.options && n in t6.options[e]) { |
| 6306 | var s10 = (0, _objectSpreadJsDefault.default)({}, t6.options[e][n]); |
| 6307 | null !== s10 && "object" == typeof s10 && Object.keys(s10).length && Object.keys(s10).every(function(t) { |
| 6308 | return Object.keys(i[n]).includes(t); |
| 6309 | }) && (_this.options[n] = (0, _objectSpreadJsDefault.default)({}, i[n], s10)); |
| 6310 | } |
| 6311 | }; |
| 6312 | for(var _iterator = Object.keys(i)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop(_iterator, _step); |
| 6313 | } catch (err) { |
| 6314 | _didIteratorError = true; |
| 6315 | _iteratorError = err; |
| 6316 | } finally{ |
| 6317 | try { |
| 6318 | if (!_iteratorNormalCompletion && _iterator.return != null) { |
| 6319 | _iterator.return(); |
| 6320 | } |
| 6321 | } finally{ |
| 6322 | if (_didIteratorError) { |
| 6323 | throw _iteratorError; |
| 6324 | } |
| 6325 | } |
| 6326 | } |
| 6327 | if (this.picker = t6, this.dependenciesNotFound()) { |
| 6328 | var _this2 = this; |
| 6329 | var _$t = this.dependencies.filter(function(t) { |
| 6330 | return !_this2.pluginsAsStringArray().includes(t); |
| 6331 | }); |
| 6332 | return void console.warn("".concat(this.getName(), ": required dependencies (").concat(_$t.join(", "), ").")); |
| 6333 | } |
| 6334 | var n14 = this.camelCaseToKebab(this.getName()); |
| 6335 | this.picker.ui.container.classList.add(n14), this.onAttach(); |
| 6336 | } |
| 6337 | }, |
| 6338 | { |
| 6339 | key: "detach", |
| 6340 | value: function detach() { |
| 6341 | var t = this.camelCaseToKebab(this.getName()); |
| 6342 | this.picker.ui.container.classList.remove(t), "function" == typeof this.onDetach && this.onDetach(); |
| 6343 | } |
| 6344 | }, |
| 6345 | { |
| 6346 | key: "dependenciesNotFound", |
| 6347 | value: function dependenciesNotFound() { |
| 6348 | var _this = this; |
| 6349 | return this.dependencies.length && !this.dependencies.every(function(t) { |
| 6350 | return _this.pluginsAsStringArray().includes(t); |
| 6351 | }); |
| 6352 | } |
| 6353 | }, |
| 6354 | { |
| 6355 | key: "pluginsAsStringArray", |
| 6356 | value: function pluginsAsStringArray() { |
| 6357 | return this.picker.options.plugins.map(function(t) { |
| 6358 | return "function" == typeof t ? (new t).getName() : t; |
| 6359 | }); |
| 6360 | } |
| 6361 | }, |
| 6362 | { |
| 6363 | key: "camelCaseToKebab", |
| 6364 | value: function camelCaseToKebab(t) { |
| 6365 | return t.replace(/([a-zA-Z])(?=[A-Z])/g, "$1-").toLowerCase(); |
| 6366 | } |
| 6367 | } |
| 6368 | ]); |
| 6369 | return o; |
| 6370 | }(); |
| 6371 | var a5 = /*#__PURE__*/ function(o) { |
| 6372 | "use strict"; |
| 6373 | (0, _inheritsJsDefault.default)(a5, o); |
| 6374 | var _super = (0, _createSuperJsDefault.default)(a5); |
| 6375 | function a5() { |
| 6376 | (0, _classCallCheckJsDefault.default)(this, a5); |
| 6377 | var _this; |
| 6378 | _this = _super.apply(this, arguments); |
| 6379 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "priority", 1); |
| 6380 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "binds", { |
| 6381 | onView: _this.onView.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 6382 | }); |
| 6383 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "options", { |
| 6384 | minDate: null, |
| 6385 | maxDate: null, |
| 6386 | minDays: null, |
| 6387 | maxDays: null, |
| 6388 | selectForward: null, |
| 6389 | selectBackward: null, |
| 6390 | presets: !0, |
| 6391 | inseparable: !1, |
| 6392 | filter: null |
| 6393 | }); |
| 6394 | return _this; |
| 6395 | } |
| 6396 | (0, _createClassJsDefault.default)(a5, [ |
| 6397 | { |
| 6398 | key: "getName", |
| 6399 | value: function getName() { |
| 6400 | return "LockPlugin"; |
| 6401 | } |
| 6402 | }, |
| 6403 | { |
| 6404 | key: "onAttach", |
| 6405 | value: function onAttach() { |
| 6406 | if (this.options.minDate && (this.options.minDate = new t1(this.options.minDate, this.picker.options.format, this.picker.options.lang)), this.options.maxDate && (this.options.maxDate = new t1(this.options.maxDate, this.picker.options.format, this.picker.options.lang), this.options.maxDate instanceof t1 && this.picker.options.calendars > 1 && this.picker.calendars[0].isSame(this.options.maxDate, "month"))) { |
| 6407 | var t = this.picker.calendars[0].clone().subtract(1, "month"); |
| 6408 | this.picker.gotoDate(t); |
| 6409 | } |
| 6410 | if ((this.options.minDays || this.options.maxDays || this.options.selectForward || this.options.selectBackward) && !this.picker.options.plugins.includes("RangePlugin")) { |
| 6411 | var t7 = [ |
| 6412 | "minDays", |
| 6413 | "maxDays", |
| 6414 | "selectForward", |
| 6415 | "selectBackward" |
| 6416 | ]; |
| 6417 | console.warn("".concat(this.getName(), ": options ").concat(t7.join(", "), " required RangePlugin.")); |
| 6418 | } |
| 6419 | this.picker.on("view", this.binds.onView); |
| 6420 | } |
| 6421 | }, |
| 6422 | { |
| 6423 | key: "onDetach", |
| 6424 | value: function onDetach() { |
| 6425 | this.picker.off("view", this.binds.onView); |
| 6426 | } |
| 6427 | }, |
| 6428 | { |
| 6429 | key: "onView", |
| 6430 | value: function onView(e) { |
| 6431 | var _detail = e.detail, i = _detail.view, n = _detail.target, s12 = _detail.date; |
| 6432 | if ("CalendarHeader" === i && (this.options.minDate instanceof t1 && s12.isSameOrBefore(this.options.minDate, "month") && n.classList.add("no-previous-month"), this.options.maxDate instanceof t1 && s12.isSameOrAfter(this.options.maxDate, "month") && n.classList.add("no-next-month")), "CalendarDay" === i) { |
| 6433 | var t = this.picker.datePicked.length ? this.picker.datePicked[0] : null; |
| 6434 | if (this.testFilter(s12)) return void n.classList.add("locked"); |
| 6435 | if (this.options.inseparable) { |
| 6436 | if (this.options.minDays) { |
| 6437 | var t8 = s12.clone().subtract(this.options.minDays - 1, "day"), _$e = s12.clone().add(this.options.minDays - 1, "day"); |
| 6438 | var i20 = !1, _$o = !1; |
| 6439 | for(; t8.isBefore(s12, "day");){ |
| 6440 | if (this.testFilter(t8)) { |
| 6441 | i20 = !0; |
| 6442 | break; |
| 6443 | } |
| 6444 | t8.add(1, "day"); |
| 6445 | } |
| 6446 | for(; _$e.isAfter(s12, "day");){ |
| 6447 | if (this.testFilter(_$e)) { |
| 6448 | _$o = !0; |
| 6449 | break; |
| 6450 | } |
| 6451 | _$e.subtract(1, "day"); |
| 6452 | } |
| 6453 | i20 && _$o && n.classList.add("not-available"); |
| 6454 | } |
| 6455 | this.rangeIsNotAvailable(s12, t) && n.classList.add("not-available"); |
| 6456 | } |
| 6457 | this.dateIsNotAvailable(s12, t) && n.classList.add("not-available"); |
| 6458 | } |
| 6459 | if (this.options.presets && "PresetPluginButton" === i) { |
| 6460 | var _$e1 = new t1(Number(n.dataset.start)), i21 = new t1(Number(n.dataset.end)), s11 = i21.diff(_$e1, "day"), _$o1 = this.options.minDays && s11 < this.options.minDays, a6 = this.options.maxDays && s11 > this.options.maxDays; |
| 6461 | (_$o1 || a6 || this.lockMinDate(_$e1) || this.lockMaxDate(_$e1) || this.lockMinDate(i21) || this.lockMaxDate(i21) || this.rangeIsNotAvailable(_$e1, i21)) && n.setAttribute("disabled", "disabled"); |
| 6462 | } |
| 6463 | } |
| 6464 | }, |
| 6465 | { |
| 6466 | key: "dateIsNotAvailable", |
| 6467 | value: function dateIsNotAvailable(t, e) { |
| 6468 | return this.lockMinDate(t) || this.lockMaxDate(t) || this.lockMinDays(t, e) || this.lockMaxDays(t, e) || this.lockSelectForward(t) || this.lockSelectBackward(t); |
| 6469 | } |
| 6470 | }, |
| 6471 | { |
| 6472 | key: "rangeIsNotAvailable", |
| 6473 | value: function rangeIsNotAvailable(t, e) { |
| 6474 | if (!t || !e) return !1; |
| 6475 | var i = (t.isSameOrBefore(e, "day") ? t : e).clone(), n = (e.isSameOrAfter(t, "day") ? e : t).clone(); |
| 6476 | for(; i.isSameOrBefore(n, "day");){ |
| 6477 | if (this.testFilter(i)) return !0; |
| 6478 | i.add(1, "day"); |
| 6479 | } |
| 6480 | return !1; |
| 6481 | } |
| 6482 | }, |
| 6483 | { |
| 6484 | key: "lockMinDate", |
| 6485 | value: function lockMinDate(e) { |
| 6486 | return this.options.minDate instanceof t1 && e.isBefore(this.options.minDate, "day"); |
| 6487 | } |
| 6488 | }, |
| 6489 | { |
| 6490 | key: "lockMaxDate", |
| 6491 | value: function lockMaxDate(e) { |
| 6492 | return this.options.maxDate instanceof t1 && e.isAfter(this.options.maxDate, "day"); |
| 6493 | } |
| 6494 | }, |
| 6495 | { |
| 6496 | key: "lockMinDays", |
| 6497 | value: function lockMinDays(t, e) { |
| 6498 | if (this.options.minDays && e) { |
| 6499 | var i = e.clone().subtract(this.options.minDays - 1, "day"), n = e.clone().add(this.options.minDays - 1, "day"); |
| 6500 | return t.isBetween(i, n); |
| 6501 | } |
| 6502 | return !1; |
| 6503 | } |
| 6504 | }, |
| 6505 | { |
| 6506 | key: "lockMaxDays", |
| 6507 | value: function lockMaxDays(t, e) { |
| 6508 | if (this.options.maxDays && e) { |
| 6509 | var i = e.clone().subtract(this.options.maxDays, "day"), n = e.clone().add(this.options.maxDays, "day"); |
| 6510 | return !t.isBetween(i, n); |
| 6511 | } |
| 6512 | return !1; |
| 6513 | } |
| 6514 | }, |
| 6515 | { |
| 6516 | key: "lockSelectForward", |
| 6517 | value: function lockSelectForward(t) { |
| 6518 | if (1 === this.picker.datePicked.length && this.options.selectForward) { |
| 6519 | var e = this.picker.datePicked[0].clone(); |
| 6520 | return t.isBefore(e, "day"); |
| 6521 | } |
| 6522 | return !1; |
| 6523 | } |
| 6524 | }, |
| 6525 | { |
| 6526 | key: "lockSelectBackward", |
| 6527 | value: function lockSelectBackward(t) { |
| 6528 | if (1 === this.picker.datePicked.length && this.options.selectBackward) { |
| 6529 | var e = this.picker.datePicked[0].clone(); |
| 6530 | return t.isAfter(e, "day"); |
| 6531 | } |
| 6532 | return !1; |
| 6533 | } |
| 6534 | }, |
| 6535 | { |
| 6536 | key: "testFilter", |
| 6537 | value: function testFilter(t) { |
| 6538 | return "function" == typeof this.options.filter && this.options.filter(t, this.picker.datePicked); |
| 6539 | } |
| 6540 | } |
| 6541 | ]); |
| 6542 | return a5; |
| 6543 | }(o); |
| 6544 | var r = /*#__PURE__*/ function(o) { |
| 6545 | "use strict"; |
| 6546 | (0, _inheritsJsDefault.default)(r, o); |
| 6547 | var _super = (0, _createSuperJsDefault.default)(r); |
| 6548 | function r() { |
| 6549 | (0, _classCallCheckJsDefault.default)(this, r); |
| 6550 | var _this; |
| 6551 | _this = _super.apply(this, arguments); |
| 6552 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "dependencies", [ |
| 6553 | "RangePlugin" |
| 6554 | ]); |
| 6555 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "binds", { |
| 6556 | onView: _this.onView.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6557 | onClick: _this.onClick.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 6558 | }); |
| 6559 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "options", { |
| 6560 | customLabels: [ |
| 6561 | "Today", |
| 6562 | "Yesterday", |
| 6563 | "Last 7 Days", |
| 6564 | "Last 30 Days", |
| 6565 | "This Month", |
| 6566 | "Last Month" |
| 6567 | ], |
| 6568 | customPreset: {}, |
| 6569 | position: "left" |
| 6570 | }); |
| 6571 | return _this; |
| 6572 | } |
| 6573 | (0, _createClassJsDefault.default)(r, [ |
| 6574 | { |
| 6575 | key: "getName", |
| 6576 | value: function getName() { |
| 6577 | return "PresetPlugin"; |
| 6578 | } |
| 6579 | }, |
| 6580 | { |
| 6581 | key: "onAttach", |
| 6582 | value: function onAttach() { |
| 6583 | if (!Object.keys(this.options.customPreset).length) { |
| 6584 | var _this = this; |
| 6585 | var e25 = new t1, i22 = function() { |
| 6586 | var i = e25.clone(); |
| 6587 | i.setDate(1); |
| 6588 | var n = new Date(e25.getFullYear(), e25.getMonth() + 1, 0); |
| 6589 | return [ |
| 6590 | new t1(i), |
| 6591 | new t1(n) |
| 6592 | ]; |
| 6593 | }, n15 = function() { |
| 6594 | var i = e25.clone(); |
| 6595 | i.setMonth(i.getMonth() - 1), i.setDate(1); |
| 6596 | var n = new Date(e25.getFullYear(), e25.getMonth(), 0); |
| 6597 | return [ |
| 6598 | new t1(i), |
| 6599 | new t1(n) |
| 6600 | ]; |
| 6601 | }, s13 = [ |
| 6602 | [ |
| 6603 | e25.clone(), |
| 6604 | e25.clone() |
| 6605 | ], |
| 6606 | [ |
| 6607 | e25.clone().subtract(1, "day"), |
| 6608 | e25.clone().subtract(1, "day") |
| 6609 | ], |
| 6610 | [ |
| 6611 | e25.clone().subtract(6, "day"), |
| 6612 | e25.clone() |
| 6613 | ], |
| 6614 | [ |
| 6615 | e25.clone().subtract(29, "day"), |
| 6616 | e25.clone() |
| 6617 | ], |
| 6618 | i22(), |
| 6619 | n15() |
| 6620 | ]; |
| 6621 | Object.values(this.options.customLabels).forEach(function(t, e) { |
| 6622 | _this.options.customPreset[t] = s13[e]; |
| 6623 | }); |
| 6624 | } |
| 6625 | this.picker.on("view", this.binds.onView), this.picker.on("click", this.binds.onClick); |
| 6626 | } |
| 6627 | }, |
| 6628 | { |
| 6629 | key: "onDetach", |
| 6630 | value: function onDetach() { |
| 6631 | this.picker.off("view", this.binds.onView), this.picker.off("click", this.binds.onClick); |
| 6632 | } |
| 6633 | }, |
| 6634 | { |
| 6635 | key: "onView", |
| 6636 | value: function onView(t) { |
| 6637 | var _detail = t.detail, e27 = _detail.view, i24 = _detail.target; |
| 6638 | if ("Main" === e27) { |
| 6639 | var _this = this; |
| 6640 | var _$t = document.createElement("div"); |
| 6641 | _$t.className = "preset-plugin-container", Object.keys(this.options.customPreset).forEach(function(e) { |
| 6642 | if (Object.prototype.hasOwnProperty.call(_this.options.customPreset, e)) { |
| 6643 | var i = _this.options.customPreset[e], n = document.createElement("button"); |
| 6644 | n.className = "preset-button unit", n.innerHTML = e, n.dataset.start = i[0].getTime(), n.dataset.end = i[1].getTime(), _$t.appendChild(n), _this.picker.trigger("view", { |
| 6645 | view: "PresetPluginButton", |
| 6646 | target: n |
| 6647 | }); |
| 6648 | } |
| 6649 | }), i24.appendChild(_$t), i24.classList.add("preset-".concat(this.options.position)), this.picker.trigger("view", { |
| 6650 | view: "PresetPluginContainer", |
| 6651 | target: _$t |
| 6652 | }); |
| 6653 | } |
| 6654 | } |
| 6655 | }, |
| 6656 | { |
| 6657 | key: "onClick", |
| 6658 | value: function onClick(e) { |
| 6659 | var i = e.target; |
| 6660 | if (i instanceof HTMLElement) { |
| 6661 | var _$e = i.closest(".unit"); |
| 6662 | if (!(_$e instanceof HTMLElement)) return; |
| 6663 | if (this.isPresetButton(_$e)) { |
| 6664 | var i25 = new t1(Number(_$e.dataset.start)), n = new t1(Number(_$e.dataset.end)); |
| 6665 | this.picker.options.autoApply ? (this.picker.setDateRange(i25, n), this.picker.trigger("select", { |
| 6666 | start: this.picker.getStartDate(), |
| 6667 | end: this.picker.getEndDate() |
| 6668 | }), this.picker.hide()) : (this.picker.datePicked = [ |
| 6669 | i25, |
| 6670 | n |
| 6671 | ], this.picker.renderAll()); |
| 6672 | } |
| 6673 | } |
| 6674 | } |
| 6675 | }, |
| 6676 | { |
| 6677 | key: "isPresetButton", |
| 6678 | value: function isPresetButton(t) { |
| 6679 | return t.classList.contains("preset-button"); |
| 6680 | } |
| 6681 | } |
| 6682 | ]); |
| 6683 | return r; |
| 6684 | }(o); |
| 6685 | var c = /*#__PURE__*/ function(o8) { |
| 6686 | "use strict"; |
| 6687 | (0, _inheritsJsDefault.default)(c, o8); |
| 6688 | var _super = (0, _createSuperJsDefault.default)(c); |
| 6689 | function c() { |
| 6690 | (0, _classCallCheckJsDefault.default)(this, c); |
| 6691 | var _this; |
| 6692 | _this = _super.apply(this, arguments); |
| 6693 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "tooltipElement", void 0); |
| 6694 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "triggerElement", void 0); |
| 6695 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "binds", { |
| 6696 | setStartDate: _this.setStartDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6697 | setEndDate: _this.setEndDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6698 | setDateRange: _this.setDateRange.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6699 | getStartDate: _this.getStartDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6700 | getEndDate: _this.getEndDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6701 | onView: _this.onView.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6702 | onShow: _this.onShow.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6703 | onMouseEnter: _this.onMouseEnter.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6704 | onMouseLeave: _this.onMouseLeave.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6705 | onClickCalendarDay: _this.onClickCalendarDay.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6706 | onClickApplyButton: _this.onClickApplyButton.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6707 | parseValues: _this.parseValues.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6708 | updateValues: _this.updateValues.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 6709 | clear: _this.clear.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 6710 | }); |
| 6711 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "options", { |
| 6712 | elementEnd: null, |
| 6713 | startDate: null, |
| 6714 | endDate: null, |
| 6715 | repick: !1, |
| 6716 | strict: !0, |
| 6717 | delimiter: " - ", |
| 6718 | tooltip: !0, |
| 6719 | tooltipNumber: function(t) { |
| 6720 | return t; |
| 6721 | }, |
| 6722 | locale: { |
| 6723 | zero: "", |
| 6724 | one: "day", |
| 6725 | two: "", |
| 6726 | few: "", |
| 6727 | many: "", |
| 6728 | other: "days" |
| 6729 | }, |
| 6730 | documentClick: _this.hidePicker.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 6731 | }); |
| 6732 | return _this; |
| 6733 | } |
| 6734 | (0, _createClassJsDefault.default)(c, [ |
| 6735 | { |
| 6736 | key: "getName", |
| 6737 | value: function getName() { |
| 6738 | return "RangePlugin"; |
| 6739 | } |
| 6740 | }, |
| 6741 | { |
| 6742 | key: "onAttach", |
| 6743 | value: function onAttach() { |
| 6744 | this.binds._setStartDate = this.picker.setStartDate, this.binds._setEndDate = this.picker.setEndDate, this.binds._setDateRange = this.picker.setDateRange, this.binds._getStartDate = this.picker.getStartDate, this.binds._getEndDate = this.picker.getEndDate, this.binds._parseValues = this.picker.parseValues, this.binds._updateValues = this.picker.updateValues, this.binds._clear = this.picker.clear, this.binds._onClickCalendarDay = this.picker.onClickCalendarDay, this.binds._onClickApplyButton = this.picker.onClickApplyButton, Object.defineProperties(this.picker, { |
| 6745 | setStartDate: { |
| 6746 | configurable: !0, |
| 6747 | value: this.binds.setStartDate |
| 6748 | }, |
| 6749 | setEndDate: { |
| 6750 | configurable: !0, |
| 6751 | value: this.binds.setEndDate |
| 6752 | }, |
| 6753 | setDateRange: { |
| 6754 | configurable: !0, |
| 6755 | value: this.binds.setDateRange |
| 6756 | }, |
| 6757 | getStartDate: { |
| 6758 | configurable: !0, |
| 6759 | value: this.binds.getStartDate |
| 6760 | }, |
| 6761 | getEndDate: { |
| 6762 | configurable: !0, |
| 6763 | value: this.binds.getEndDate |
| 6764 | }, |
| 6765 | parseValues: { |
| 6766 | configurable: !0, |
| 6767 | value: this.binds.parseValues |
| 6768 | }, |
| 6769 | updateValues: { |
| 6770 | configurable: !0, |
| 6771 | value: this.binds.updateValues |
| 6772 | }, |
| 6773 | clear: { |
| 6774 | configurable: !0, |
| 6775 | value: this.binds.clear |
| 6776 | }, |
| 6777 | onClickCalendarDay: { |
| 6778 | configurable: !0, |
| 6779 | value: this.binds.onClickCalendarDay |
| 6780 | }, |
| 6781 | onClickApplyButton: { |
| 6782 | configurable: !0, |
| 6783 | value: this.binds.onClickApplyButton |
| 6784 | } |
| 6785 | }), this.options.elementEnd && (this.options.elementEnd instanceof HTMLElement || (this.options.elementEnd = this.picker.options.doc.querySelector(this.options.elementEnd)), this.options.elementEnd instanceof HTMLInputElement && (this.options.elementEnd.readOnly = this.picker.options.readonly), "function" == typeof this.picker.options.documentClick && (document.removeEventListener("click", this.picker.options.documentClick, !0), "function" == typeof this.options.documentClick && document.addEventListener("click", this.options.documentClick, !0)), this.options.elementEnd.addEventListener("click", this.picker.show.bind(this.picker))), this.options.repick = this.options.repick && this.options.elementEnd instanceof HTMLElement, this.picker.options.date = null, this.picker.on("view", this.binds.onView), this.picker.on("show", this.binds.onShow), this.picker.on("mouseenter", this.binds.onMouseEnter, !0), this.picker.on("mouseleave", this.binds.onMouseLeave, !0), this.checkIntlPluralLocales(); |
| 6786 | } |
| 6787 | }, |
| 6788 | { |
| 6789 | key: "onDetach", |
| 6790 | value: function onDetach() { |
| 6791 | Object.defineProperties(this.picker, { |
| 6792 | setStartDate: { |
| 6793 | configurable: !0, |
| 6794 | value: this.binds._setStartDate |
| 6795 | }, |
| 6796 | setEndDate: { |
| 6797 | configurable: !0, |
| 6798 | value: this.binds._setEndDate |
| 6799 | }, |
| 6800 | setDateRange: { |
| 6801 | configurable: !0, |
| 6802 | value: this.binds._setDateRange |
| 6803 | }, |
| 6804 | getStartDate: { |
| 6805 | configurable: !0, |
| 6806 | value: this.binds._getStartDate |
| 6807 | }, |
| 6808 | getEndDate: { |
| 6809 | configurable: !0, |
| 6810 | value: this.binds._getEndDate |
| 6811 | }, |
| 6812 | parseValues: { |
| 6813 | configurable: !0, |
| 6814 | value: this.binds._parseValues |
| 6815 | }, |
| 6816 | updateValues: { |
| 6817 | configurable: !0, |
| 6818 | value: this.binds._updateValues |
| 6819 | }, |
| 6820 | clear: { |
| 6821 | configurable: !0, |
| 6822 | value: this.binds._clear |
| 6823 | }, |
| 6824 | onClickCalendarDay: { |
| 6825 | configurable: !0, |
| 6826 | value: this.binds._onClickCalendarDay |
| 6827 | }, |
| 6828 | onClickApplyButton: { |
| 6829 | configurable: !0, |
| 6830 | value: this.binds._onClickApplyButton |
| 6831 | } |
| 6832 | }), this.picker.off("view", this.binds.onView), this.picker.off("show", this.binds.onShow), this.picker.off("mouseenter", this.binds.onMouseEnter, !0), this.picker.off("mouseleave", this.binds.onMouseLeave, !0); |
| 6833 | } |
| 6834 | }, |
| 6835 | { |
| 6836 | key: "parseValues", |
| 6837 | value: function parseValues() { |
| 6838 | if (this.options.startDate || this.options.endDate) this.options.strict ? this.options.startDate && this.options.endDate ? this.setDateRange(this.options.startDate, this.options.endDate) : (this.options.startDate = null, this.options.endDate = null) : (this.options.startDate && this.setStartDate(this.options.startDate), this.options.endDate && this.setEndDate(this.options.endDate)); |
| 6839 | else if (this.options.elementEnd) this.options.strict ? this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length && this.options.elementEnd instanceof HTMLInputElement && this.options.elementEnd.value.length && this.setDateRange(this.picker.options.element.value, this.options.elementEnd.value) : (this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length && this.setStartDate(this.picker.options.element.value), this.options.elementEnd instanceof HTMLInputElement && this.options.elementEnd.value.length && this.setEndDate(this.options.elementEnd.value)); |
| 6840 | else if (this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length) { |
| 6841 | var ref = (0, _slicedToArrayJsDefault.default)(this.picker.options.element.value.split(this.options.delimiter), 2), t = ref[0], e = ref[1]; |
| 6842 | this.options.strict ? t && e && this.setDateRange(t, e) : (t && this.setStartDate(t), e && this.setEndDate(e)); |
| 6843 | } |
| 6844 | } |
| 6845 | }, |
| 6846 | { |
| 6847 | key: "updateValues", |
| 6848 | value: function updateValues() { |
| 6849 | var t = this.picker.options.element, e = this.options.elementEnd, i = this.picker.getStartDate(), n = this.picker.getEndDate(), s14 = i instanceof Date ? i.format(this.picker.options.format, this.picker.options.lang) : "", _$o = n instanceof Date ? n.format(this.picker.options.format, this.picker.options.lang) : ""; |
| 6850 | if (e) t instanceof HTMLInputElement ? t.value = s14 : t instanceof HTMLElement && (t.innerText = s14), e instanceof HTMLInputElement ? e.value = _$o : e instanceof HTMLElement && (e.innerText = _$o); |
| 6851 | else { |
| 6852 | var e28 = "".concat(s14).concat(s14 || _$o ? this.options.delimiter : "").concat(_$o); |
| 6853 | t instanceof HTMLInputElement ? t.value = e28 : t instanceof HTMLElement && (t.innerText = e28); |
| 6854 | } |
| 6855 | } |
| 6856 | }, |
| 6857 | { |
| 6858 | key: "clear", |
| 6859 | value: function clear() { |
| 6860 | this.options.startDate = null, this.options.endDate = null, this.picker.datePicked.length = 0, this.updateValues(), this.picker.renderAll(), this.picker.trigger("clear"); |
| 6861 | } |
| 6862 | }, |
| 6863 | { |
| 6864 | key: "onShow", |
| 6865 | value: function onShow(t) { |
| 6866 | var _detail = t.detail, e = _detail.target; |
| 6867 | this.triggerElement = e, this.picker.options.scrollToDate && this.getStartDate() instanceof Date && this.picker.gotoDate(this.getStartDate()), this.initializeRepick(); |
| 6868 | } |
| 6869 | }, |
| 6870 | { |
| 6871 | key: "onView", |
| 6872 | value: function onView(e) { |
| 6873 | var _detail = e.detail, i = _detail.view, n = _detail.target; |
| 6874 | if ("Main" === i && (this.tooltipElement = document.createElement("span"), this.tooltipElement.className = "range-plugin-tooltip", n.appendChild(this.tooltipElement)), "CalendarDay" === i) { |
| 6875 | var _$e = new t1(n.dataset.time), i26 = this.picker.datePicked, s15 = i26.length ? this.picker.datePicked[0] : this.getStartDate(), _$o = i26.length ? this.picker.datePicked[1] : this.getEndDate(); |
| 6876 | s15 && s15.isSame(_$e, "day") && n.classList.add("start"), s15 && _$o && (_$o.isSame(_$e, "day") && n.classList.add("end"), _$e.isBetween(s15, _$o) && n.classList.add("in-range")); |
| 6877 | } |
| 6878 | if ("Footer" === i) { |
| 6879 | var t = 1 === this.picker.datePicked.length && !this.options.strict || 2 === this.picker.datePicked.length; |
| 6880 | n.querySelector(".apply-button").disabled = !t; |
| 6881 | } |
| 6882 | } |
| 6883 | }, |
| 6884 | { |
| 6885 | key: "hidePicker", |
| 6886 | value: function hidePicker(t) { |
| 6887 | var e = t.target, i = null; |
| 6888 | e.shadowRoot && (e = t.composedPath()[0], i = e.getRootNode().host), this.picker.isShown() && i !== this.picker.ui.wrapper && e !== this.picker.options.element && e !== this.options.elementEnd && this.picker.hide(); |
| 6889 | } |
| 6890 | }, |
| 6891 | { |
| 6892 | key: "setStartDate", |
| 6893 | value: function setStartDate(e) { |
| 6894 | var i = new t1(e, this.picker.options.format); |
| 6895 | this.options.startDate = i ? i.clone() : null, this.updateValues(), this.picker.renderAll(); |
| 6896 | } |
| 6897 | }, |
| 6898 | { |
| 6899 | key: "setEndDate", |
| 6900 | value: function setEndDate(e) { |
| 6901 | var i = new t1(e, this.picker.options.format); |
| 6902 | this.options.endDate = i ? i.clone() : null, this.updateValues(), this.picker.renderAll(); |
| 6903 | } |
| 6904 | }, |
| 6905 | { |
| 6906 | key: "setDateRange", |
| 6907 | value: function setDateRange(e, i) { |
| 6908 | var n = new t1(e, this.picker.options.format), s16 = new t1(i, this.picker.options.format); |
| 6909 | this.options.startDate = n ? n.clone() : null, this.options.endDate = s16 ? s16.clone() : null, this.updateValues(), this.picker.renderAll(); |
| 6910 | } |
| 6911 | }, |
| 6912 | { |
| 6913 | key: "getStartDate", |
| 6914 | value: function getStartDate() { |
| 6915 | return this.options.startDate instanceof Date ? this.options.startDate.clone() : null; |
| 6916 | } |
| 6917 | }, |
| 6918 | { |
| 6919 | key: "getEndDate", |
| 6920 | value: function getEndDate() { |
| 6921 | return this.options.endDate instanceof Date ? this.options.endDate.clone() : null; |
| 6922 | } |
| 6923 | }, |
| 6924 | { |
| 6925 | key: "onMouseEnter", |
| 6926 | value: function onMouseEnter(e) { |
| 6927 | var i = e.target; |
| 6928 | if (i instanceof HTMLElement) { |
| 6929 | this.isContainer(i) && this.initializeRepick(); |
| 6930 | var _$e = i.closest(".unit"); |
| 6931 | if (!(_$e instanceof HTMLElement)) return; |
| 6932 | if (this.picker.isCalendarDay(_$e)) { |
| 6933 | var _this = this; |
| 6934 | if (1 !== this.picker.datePicked.length) return; |
| 6935 | var i27 = this.picker.datePicked[0].clone(), n = new t1(_$e.dataset.time), s17 = !1; |
| 6936 | if (i27.isAfter(n, "day")) { |
| 6937 | var t = i27.clone(); |
| 6938 | i27 = n.clone(), n = t.clone(), s17 = !0; |
| 6939 | } |
| 6940 | if ((0, _toConsumableArrayJsDefault.default)(this.picker.ui.container.querySelectorAll(".day")).forEach(function(o) { |
| 6941 | var a = new t1(o.dataset.time), r = _this.picker.Calendar.getCalendarDayView(a); |
| 6942 | a.isBetween(i27, n) && r.classList.add("in-range"), a.isSame(_this.picker.datePicked[0], "day") && (r.classList.add("start"), r.classList.toggle("flipped", s17)), o === _$e && (r.classList.add("end"), r.classList.toggle("flipped", s17)), o.className = r.className; |
| 6943 | }), this.options.tooltip) { |
| 6944 | var t9 = this.options.tooltipNumber(n.diff(i27, "day") + 1); |
| 6945 | if (t9 > 0) { |
| 6946 | var i28 = new Intl.PluralRules(this.picker.options.lang).select(t9), n17 = "".concat(t9, " ").concat(this.options.locale[i28]); |
| 6947 | this.showTooltip(_$e, n17); |
| 6948 | } else this.hideTooltip(); |
| 6949 | } |
| 6950 | } |
| 6951 | } |
| 6952 | } |
| 6953 | }, |
| 6954 | { |
| 6955 | key: "onMouseLeave", |
| 6956 | value: function onMouseLeave(t) { |
| 6957 | if (this.isContainer(t.target) && this.options.repick) { |
| 6958 | var _$t = this.getStartDate(), e = this.getEndDate(); |
| 6959 | _$t && e && (this.picker.datePicked.length = 0, this.picker.renderAll()); |
| 6960 | } |
| 6961 | } |
| 6962 | }, |
| 6963 | { |
| 6964 | key: "onClickCalendarDay", |
| 6965 | value: function onClickCalendarDay(e) { |
| 6966 | if (this.picker.isCalendarDay(e)) { |
| 6967 | 2 === this.picker.datePicked.length && (this.picker.datePicked.length = 0); |
| 6968 | var i = new t1(e.dataset.time); |
| 6969 | if (this.picker.datePicked[this.picker.datePicked.length] = i, 2 === this.picker.datePicked.length && this.picker.datePicked[0].isAfter(this.picker.datePicked[1])) { |
| 6970 | var t = this.picker.datePicked[1].clone(); |
| 6971 | this.picker.datePicked[1] = this.picker.datePicked[0].clone(), this.picker.datePicked[0] = t.clone(); |
| 6972 | } |
| 6973 | 1 !== this.picker.datePicked.length && this.picker.options.autoApply || this.picker.trigger("preselect", { |
| 6974 | start: this.picker.datePicked[0] instanceof Date ? this.picker.datePicked[0].clone() : null, |
| 6975 | end: this.picker.datePicked[1] instanceof Date ? this.picker.datePicked[1].clone() : null |
| 6976 | }), 1 === this.picker.datePicked.length && (!this.options.strict && this.picker.options.autoApply && (this.picker.options.element === this.triggerElement && this.setStartDate(this.picker.datePicked[0]), this.options.elementEnd === this.triggerElement && this.setEndDate(this.picker.datePicked[0]), this.picker.trigger("select", { |
| 6977 | start: this.picker.getStartDate(), |
| 6978 | end: this.picker.getEndDate() |
| 6979 | })), this.picker.renderAll()), 2 === this.picker.datePicked.length && (this.picker.options.autoApply ? (this.setDateRange(this.picker.datePicked[0], this.picker.datePicked[1]), this.picker.trigger("select", { |
| 6980 | start: this.picker.getStartDate(), |
| 6981 | end: this.picker.getEndDate() |
| 6982 | }), this.picker.hide()) : (this.hideTooltip(), this.picker.renderAll())); |
| 6983 | } |
| 6984 | } |
| 6985 | }, |
| 6986 | { |
| 6987 | key: "onClickApplyButton", |
| 6988 | value: function onClickApplyButton(t) { |
| 6989 | this.picker.isApplyButton(t) && (1 !== this.picker.datePicked.length || this.options.strict || (this.picker.options.element === this.triggerElement && (this.options.endDate = null, this.setStartDate(this.picker.datePicked[0])), this.options.elementEnd === this.triggerElement && (this.options.startDate = null, this.setEndDate(this.picker.datePicked[0]))), 2 === this.picker.datePicked.length && this.setDateRange(this.picker.datePicked[0], this.picker.datePicked[1]), this.picker.trigger("select", { |
| 6990 | start: this.picker.getStartDate(), |
| 6991 | end: this.picker.getEndDate() |
| 6992 | }), this.picker.hide()); |
| 6993 | } |
| 6994 | }, |
| 6995 | { |
| 6996 | key: "showTooltip", |
| 6997 | value: function showTooltip(t, e) { |
| 6998 | this.tooltipElement.style.visibility = "visible", this.tooltipElement.innerHTML = e; |
| 6999 | var i = this.picker.ui.container.getBoundingClientRect(), n = this.tooltipElement.getBoundingClientRect(), s18 = t.getBoundingClientRect(); |
| 7000 | var _$o = s18.top, a = s18.left; |
| 7001 | _$o -= i.top, a -= i.left, _$o -= n.height, a -= n.width / 2, a += s18.width / 2, this.tooltipElement.style.top = "".concat(_$o, "px"), this.tooltipElement.style.left = "".concat(a, "px"); |
| 7002 | } |
| 7003 | }, |
| 7004 | { |
| 7005 | key: "hideTooltip", |
| 7006 | value: function hideTooltip() { |
| 7007 | this.tooltipElement.style.visibility = "hidden"; |
| 7008 | } |
| 7009 | }, |
| 7010 | { |
| 7011 | key: "checkIntlPluralLocales", |
| 7012 | value: function checkIntlPluralLocales() { |
| 7013 | if (!this.options.tooltip) return; |
| 7014 | var t10 = (0, _toConsumableArrayJsDefault.default)(new Set([ |
| 7015 | new Intl.PluralRules(this.picker.options.lang).select(0), |
| 7016 | new Intl.PluralRules(this.picker.options.lang).select(1), |
| 7017 | new Intl.PluralRules(this.picker.options.lang).select(2), |
| 7018 | new Intl.PluralRules(this.picker.options.lang).select(6), |
| 7019 | new Intl.PluralRules(this.picker.options.lang).select(18) |
| 7020 | ])), e = Object.keys(this.options.locale); |
| 7021 | t10.every(function(t) { |
| 7022 | return e.includes(t); |
| 7023 | }) || console.warn("".concat(this.getName(), ": provide locales (").concat(t10.join(", "), ") for correct tooltip text.")); |
| 7024 | } |
| 7025 | }, |
| 7026 | { |
| 7027 | key: "initializeRepick", |
| 7028 | value: function initializeRepick() { |
| 7029 | if (!this.options.repick) return; |
| 7030 | var t = this.getStartDate(), e = this.getEndDate(); |
| 7031 | e && this.triggerElement === this.picker.options.element && (this.picker.datePicked[0] = e), t && this.triggerElement === this.options.elementEnd && (this.picker.datePicked[0] = t); |
| 7032 | } |
| 7033 | }, |
| 7034 | { |
| 7035 | key: "isContainer", |
| 7036 | value: function isContainer(t) { |
| 7037 | return t === this.picker.ui.container; |
| 7038 | } |
| 7039 | } |
| 7040 | ]); |
| 7041 | return c; |
| 7042 | }(o); |
| 7043 | var l = /*#__PURE__*/ function(o) { |
| 7044 | "use strict"; |
| 7045 | (0, _inheritsJsDefault.default)(l, o); |
| 7046 | var _super = (0, _createSuperJsDefault.default)(l); |
| 7047 | function l() { |
| 7048 | (0, _classCallCheckJsDefault.default)(this, l); |
| 7049 | var _this; |
| 7050 | _this = _super.apply(this, arguments); |
| 7051 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "options", { |
| 7052 | native: !1, |
| 7053 | seconds: !1, |
| 7054 | stepHours: 1, |
| 7055 | stepMinutes: 5, |
| 7056 | stepSeconds: 5, |
| 7057 | format12: !1 |
| 7058 | }); |
| 7059 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "rangePlugin", void 0); |
| 7060 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "timePicked", { |
| 7061 | input: null, |
| 7062 | start: null, |
| 7063 | end: null |
| 7064 | }); |
| 7065 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "timePrePicked", { |
| 7066 | input: null, |
| 7067 | start: null, |
| 7068 | end: null |
| 7069 | }); |
| 7070 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "binds", { |
| 7071 | getDate: _this.getDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7072 | getStartDate: _this.getStartDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7073 | getEndDate: _this.getEndDate.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7074 | onView: _this.onView.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7075 | onInput: _this.onInput.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7076 | onChange: _this.onChange.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7077 | onClick: _this.onClick.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7078 | setTime: _this.setTime.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7079 | setStartTime: _this.setStartTime.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7080 | setEndTime: _this.setEndTime.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 7081 | }); |
| 7082 | return _this; |
| 7083 | } |
| 7084 | (0, _createClassJsDefault.default)(l, [ |
| 7085 | { |
| 7086 | key: "getName", |
| 7087 | value: function getName() { |
| 7088 | return "TimePlugin"; |
| 7089 | } |
| 7090 | }, |
| 7091 | { |
| 7092 | key: "onAttach", |
| 7093 | value: function onAttach() { |
| 7094 | this.binds._getDate = this.picker.getDate, this.binds._getStartDate = this.picker.getStartDate, this.binds._getEndDate = this.picker.getEndDate, Object.defineProperties(this.picker, { |
| 7095 | getDate: { |
| 7096 | configurable: !0, |
| 7097 | value: this.binds.getDate |
| 7098 | }, |
| 7099 | getStartDate: { |
| 7100 | configurable: !0, |
| 7101 | value: this.binds.getStartDate |
| 7102 | }, |
| 7103 | getEndDate: { |
| 7104 | configurable: !0, |
| 7105 | value: this.binds.getEndDate |
| 7106 | }, |
| 7107 | setTime: { |
| 7108 | configurable: !0, |
| 7109 | value: this.binds.setTime |
| 7110 | }, |
| 7111 | setStartTime: { |
| 7112 | configurable: !0, |
| 7113 | value: this.binds.setStartTime |
| 7114 | }, |
| 7115 | setEndTime: { |
| 7116 | configurable: !0, |
| 7117 | value: this.binds.setEndTime |
| 7118 | } |
| 7119 | }), this.rangePlugin = this.picker.PluginManager.getInstance("RangePlugin"), this.parseValues(), this.picker.on("view", this.binds.onView), this.picker.on("input", this.binds.onInput), this.picker.on("change", this.binds.onChange), this.picker.on("click", this.binds.onClick); |
| 7120 | } |
| 7121 | }, |
| 7122 | { |
| 7123 | key: "onDetach", |
| 7124 | value: function onDetach() { |
| 7125 | delete this.picker.setTime, delete this.picker.setStartTime, delete this.picker.setEndTime, Object.defineProperties(this.picker, { |
| 7126 | getDate: { |
| 7127 | configurable: !0, |
| 7128 | value: this.binds._getDate |
| 7129 | }, |
| 7130 | getStartDate: { |
| 7131 | configurable: !0, |
| 7132 | value: this.binds._getStartDate |
| 7133 | }, |
| 7134 | getEndDate: { |
| 7135 | configurable: !0, |
| 7136 | value: this.binds._getEndDate |
| 7137 | } |
| 7138 | }), this.picker.off("view", this.binds.onView), this.picker.off("input", this.binds.onInput), this.picker.off("change", this.binds.onChange), this.picker.off("click", this.binds.onClick); |
| 7139 | } |
| 7140 | }, |
| 7141 | { |
| 7142 | key: "onView", |
| 7143 | value: function onView(t) { |
| 7144 | var _detail = t.detail, e = _detail.view, i = _detail.target; |
| 7145 | if ("Main" === e) { |
| 7146 | this.rangePlugin = this.picker.PluginManager.getInstance("RangePlugin"); |
| 7147 | var _$t = document.createElement("div"); |
| 7148 | if (_$t.className = "time-plugin-container", this.rangePlugin) { |
| 7149 | var e29 = this.getStartInput(); |
| 7150 | _$t.appendChild(e29), this.picker.trigger("view", { |
| 7151 | view: "TimePluginInput", |
| 7152 | target: e29 |
| 7153 | }); |
| 7154 | var i29 = this.getEndInput(); |
| 7155 | _$t.appendChild(i29), this.picker.trigger("view", { |
| 7156 | view: "TimePluginInput", |
| 7157 | target: i29 |
| 7158 | }); |
| 7159 | } else { |
| 7160 | var e30 = this.getSingleInput(); |
| 7161 | _$t.appendChild(e30), this.picker.trigger("view", { |
| 7162 | view: "TimePluginInput", |
| 7163 | target: e30 |
| 7164 | }); |
| 7165 | } |
| 7166 | i.appendChild(_$t), this.picker.trigger("view", { |
| 7167 | view: "TimePluginContainer", |
| 7168 | target: _$t |
| 7169 | }); |
| 7170 | } |
| 7171 | } |
| 7172 | }, |
| 7173 | { |
| 7174 | key: "onInput", |
| 7175 | value: function onInput(e) { |
| 7176 | var i = e.target; |
| 7177 | if (i instanceof HTMLInputElement && i.classList.contains("time-plugin-input")) { |
| 7178 | var _$e = this.timePicked[i.name] || new t1, ref = (0, _slicedToArrayJsDefault.default)(i.value.split(":"), 2), n = ref[0], s19 = ref[1]; |
| 7179 | _$e.setHours(Number(n) || 0, Number(s19) || 0, 0, 0), this.picker.options.autoApply ? (this.timePicked[i.name] = _$e, this.picker.updateValues()) : this.timePrePicked[i.name] = _$e; |
| 7180 | } |
| 7181 | } |
| 7182 | }, |
| 7183 | { |
| 7184 | key: "onChange", |
| 7185 | value: function onChange(e) { |
| 7186 | var i = e.target; |
| 7187 | if (i instanceof HTMLSelectElement && i.classList.contains("time-plugin-custom-input")) { |
| 7188 | var _$e = /(\w+)\[(\w+)\]/, ref = (0, _slicedToArrayJsDefault.default)(i.name.match(_$e), 3), n = ref[1], s20 = ref[2], _$o = Number(i.value); |
| 7189 | var a = new t1; |
| 7190 | switch(!this.picker.options.autoApply && this.timePrePicked[n] instanceof Date ? a = this.timePrePicked[n].clone() : this.timePicked[n] instanceof Date && (a = this.timePicked[n].clone()), s20){ |
| 7191 | case "HH": |
| 7192 | if (this.options.format12) { |
| 7193 | var t = i.closest(".time-plugin-custom-block").querySelector('select[name="'.concat(n, '[period]"]')).value, _$e2 = this.handleFormat12(t, a, _$o); |
| 7194 | a.setHours(_$e2.getHours(), _$e2.getMinutes(), _$e2.getSeconds(), 0); |
| 7195 | } else a.setHours(_$o, a.getMinutes(), a.getSeconds(), 0); |
| 7196 | break; |
| 7197 | case "mm": |
| 7198 | a.setHours(a.getHours(), _$o, a.getSeconds(), 0); |
| 7199 | break; |
| 7200 | case "ss": |
| 7201 | a.setHours(a.getHours(), a.getMinutes(), _$o, 0); |
| 7202 | break; |
| 7203 | case "period": |
| 7204 | if (this.options.format12) { |
| 7205 | var t11 = i.closest(".time-plugin-custom-block").querySelector('select[name="'.concat(n, '[HH]"]')).value, _$e3 = this.handleFormat12(i.value, a, Number(t11)); |
| 7206 | a.setHours(_$e3.getHours(), _$e3.getMinutes(), _$e3.getSeconds(), 0); |
| 7207 | } |
| 7208 | } |
| 7209 | if (this.picker.options.autoApply) this.timePicked[n] = a, this.picker.updateValues(); |
| 7210 | else { |
| 7211 | this.timePrePicked[n] = a; |
| 7212 | var t12 = this.picker.ui.container.querySelector(".apply-button"); |
| 7213 | if (this.rangePlugin) { |
| 7214 | var _$e4 = this.rangePlugin.options, i30 = this.picker.datePicked, n18 = _$e4.strict && 2 === i30.length || !_$e4.strict && i30.length > 0 || !i30.length && _$e4.strict && _$e4.startDate instanceof Date && _$e4.endDate instanceof Date || !i30.length && !_$e4.strict && (_$e4.startDate instanceof Date || _$e4.endDate instanceof Date); |
| 7215 | t12.disabled = !n18; |
| 7216 | } else this.picker.datePicked.length && (t12.disabled = !1); |
| 7217 | } |
| 7218 | } |
| 7219 | } |
| 7220 | }, |
| 7221 | { |
| 7222 | key: "onClick", |
| 7223 | value: function onClick(t13) { |
| 7224 | var e = t13.target; |
| 7225 | if (e instanceof HTMLElement) { |
| 7226 | var _this = this; |
| 7227 | var _$t = e.closest(".unit"); |
| 7228 | if (!(_$t instanceof HTMLElement)) return; |
| 7229 | this.picker.isApplyButton(_$t) && (Object.keys(this.timePicked).forEach(function(t) { |
| 7230 | _this.timePrePicked[t] instanceof Date && (_this.timePicked[t] = _this.timePrePicked[t].clone()); |
| 7231 | }), this.picker.updateValues(), this.timePrePicked = { |
| 7232 | input: null, |
| 7233 | start: null, |
| 7234 | end: null |
| 7235 | }), this.picker.isCancelButton(_$t) && (this.timePrePicked = { |
| 7236 | input: null, |
| 7237 | start: null, |
| 7238 | end: null |
| 7239 | }, this.picker.renderAll()); |
| 7240 | } |
| 7241 | } |
| 7242 | }, |
| 7243 | { |
| 7244 | key: "setTime", |
| 7245 | value: function setTime(t) { |
| 7246 | var e = this.handleTimeString(t); |
| 7247 | this.timePicked.input = e.clone(), this.picker.renderAll(), this.picker.updateValues(); |
| 7248 | } |
| 7249 | }, |
| 7250 | { |
| 7251 | key: "setStartTime", |
| 7252 | value: function setStartTime(t) { |
| 7253 | var e = this.handleTimeString(t); |
| 7254 | this.timePicked.start = e.clone(), this.picker.renderAll(), this.picker.updateValues(); |
| 7255 | } |
| 7256 | }, |
| 7257 | { |
| 7258 | key: "setEndTime", |
| 7259 | value: function setEndTime(t) { |
| 7260 | var e = this.handleTimeString(t); |
| 7261 | this.timePicked.end = e.clone(), this.picker.renderAll(), this.picker.updateValues(); |
| 7262 | } |
| 7263 | }, |
| 7264 | { |
| 7265 | key: "handleTimeString", |
| 7266 | value: function handleTimeString(e) { |
| 7267 | var i = new t1, ref = (0, _slicedToArrayJsDefault.default)(e.split(":").map(function(t) { |
| 7268 | return Number(t); |
| 7269 | }), 3), n = ref[0], s21 = ref[1], _$o = ref[2], a = n && !Number.isNaN(n) ? n : 0, r = s21 && !Number.isNaN(s21) ? s21 : 0, c = _$o && !Number.isNaN(_$o) ? _$o : 0; |
| 7270 | return i.setHours(a, r, c, 0), i; |
| 7271 | } |
| 7272 | }, |
| 7273 | { |
| 7274 | key: "getDate", |
| 7275 | value: function getDate() { |
| 7276 | if (this.picker.options.date instanceof Date) { |
| 7277 | var e = new t1(this.picker.options.date, this.picker.options.format); |
| 7278 | if (this.timePicked.input instanceof Date) { |
| 7279 | var t = this.timePicked.input; |
| 7280 | e.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), 0); |
| 7281 | } |
| 7282 | return e; |
| 7283 | } |
| 7284 | return null; |
| 7285 | } |
| 7286 | }, |
| 7287 | { |
| 7288 | key: "getStartDate", |
| 7289 | value: function getStartDate() { |
| 7290 | if (this.rangePlugin.options.startDate instanceof Date) { |
| 7291 | var e = new t1(this.rangePlugin.options.startDate, this.picker.options.format); |
| 7292 | if (this.timePicked.start instanceof Date) { |
| 7293 | var t = this.timePicked.start; |
| 7294 | e.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), 0); |
| 7295 | } |
| 7296 | return e; |
| 7297 | } |
| 7298 | return null; |
| 7299 | } |
| 7300 | }, |
| 7301 | { |
| 7302 | key: "getEndDate", |
| 7303 | value: function getEndDate() { |
| 7304 | if (this.rangePlugin.options.endDate instanceof Date) { |
| 7305 | var e = new t1(this.rangePlugin.options.endDate, this.picker.options.format); |
| 7306 | if (this.timePicked.end instanceof Date) { |
| 7307 | var t = this.timePicked.end; |
| 7308 | e.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), 0); |
| 7309 | } |
| 7310 | return e; |
| 7311 | } |
| 7312 | return null; |
| 7313 | } |
| 7314 | }, |
| 7315 | { |
| 7316 | key: "getSingleInput", |
| 7317 | value: function getSingleInput() { |
| 7318 | return this.options.native ? this.getNativeInput("input") : this.getCustomInput("input"); |
| 7319 | } |
| 7320 | }, |
| 7321 | { |
| 7322 | key: "getStartInput", |
| 7323 | value: function getStartInput() { |
| 7324 | return this.options.native ? this.getNativeInput("start") : this.getCustomInput("start"); |
| 7325 | } |
| 7326 | }, |
| 7327 | { |
| 7328 | key: "getEndInput", |
| 7329 | value: function getEndInput() { |
| 7330 | return this.options.native ? this.getNativeInput("end") : this.getCustomInput("end"); |
| 7331 | } |
| 7332 | }, |
| 7333 | { |
| 7334 | key: "getNativeInput", |
| 7335 | value: function getNativeInput(t) { |
| 7336 | var e = document.createElement("input"); |
| 7337 | e.type = "time", e.name = t, e.className = "time-plugin-input unit"; |
| 7338 | var i = this.timePicked[t]; |
| 7339 | if (i) { |
| 7340 | var _$t = "0".concat(i.getHours()).slice(-2), n = "0".concat(i.getMinutes()).slice(-2); |
| 7341 | e.value = "".concat(_$t, ":").concat(n); |
| 7342 | } |
| 7343 | return e; |
| 7344 | } |
| 7345 | }, |
| 7346 | { |
| 7347 | key: "getCustomInput", |
| 7348 | value: function getCustomInput(t14) { |
| 7349 | var e34 = document.createElement("div"); |
| 7350 | e34.className = "time-plugin-custom-block"; |
| 7351 | var i = document.createElement("select"); |
| 7352 | i.className = "time-plugin-custom-input unit", i.name = "".concat(t14, "[HH]"); |
| 7353 | var n = this.options.format12 ? 1 : 0, s22 = this.options.format12 ? 13 : 24; |
| 7354 | var _$o = null; |
| 7355 | !this.picker.options.autoApply && this.timePrePicked[t14] instanceof Date ? _$o = this.timePrePicked[t14].clone() : this.timePicked[t14] instanceof Date && (_$o = this.timePicked[t14].clone()); |
| 7356 | for(var _$t = n; _$t < s22; _$t += this.options.stepHours){ |
| 7357 | var e31 = document.createElement("option"); |
| 7358 | e31.value = String(_$t), e31.text = String(_$t), _$o && (this.options.format12 ? (_$o.getHours() % 12 ? _$o.getHours() % 12 : 12) === _$t && (e31.selected = !0) : _$o.getHours() === _$t && (e31.selected = !0)), i.appendChild(e31); |
| 7359 | } |
| 7360 | e34.appendChild(i); |
| 7361 | var a = document.createElement("select"); |
| 7362 | a.className = "time-plugin-custom-input unit", a.name = "".concat(t14, "[mm]"); |
| 7363 | for(var _$t2 = 0; _$t2 < 60; _$t2 += this.options.stepMinutes){ |
| 7364 | var e32 = document.createElement("option"); |
| 7365 | e32.value = "0".concat(String(_$t2)).slice(-2), e32.text = "0".concat(String(_$t2)).slice(-2), _$o && _$o.getMinutes() === _$t2 && (e32.selected = !0), a.appendChild(e32); |
| 7366 | } |
| 7367 | if (e34.appendChild(a), this.options.seconds) { |
| 7368 | var i31 = document.createElement("select"); |
| 7369 | i31.className = "time-plugin-custom-input unit", i31.name = "".concat(t14, "[ss]"); |
| 7370 | var n19 = 60; |
| 7371 | for(var _$t3 = 0; _$t3 < n19; _$t3 += this.options.stepSeconds){ |
| 7372 | var e33 = document.createElement("option"); |
| 7373 | e33.value = "0".concat(String(_$t3)).slice(-2), e33.text = "0".concat(String(_$t3)).slice(-2), _$o && _$o.getSeconds() === _$t3 && (e33.selected = !0), i31.appendChild(e33); |
| 7374 | } |
| 7375 | e34.appendChild(i31); |
| 7376 | } |
| 7377 | if (this.options.format12) { |
| 7378 | var i32 = document.createElement("select"); |
| 7379 | i32.className = "time-plugin-custom-input unit", i32.name = "".concat(t14, "[period]"), [ |
| 7380 | "AM", |
| 7381 | "PM" |
| 7382 | ].forEach(function(t) { |
| 7383 | var e = document.createElement("option"); |
| 7384 | e.value = t, e.text = t, _$o && "PM" === t && _$o.getHours() >= 12 && (e.selected = !0), i32.appendChild(e); |
| 7385 | }), e34.appendChild(i32); |
| 7386 | } |
| 7387 | return e34; |
| 7388 | } |
| 7389 | }, |
| 7390 | { |
| 7391 | key: "handleFormat12", |
| 7392 | value: function handleFormat12(t, e, i) { |
| 7393 | var n = e.clone(); |
| 7394 | switch(t){ |
| 7395 | case "AM": |
| 7396 | 12 === i ? n.setHours(0, n.getMinutes(), n.getSeconds(), 0) : n.setHours(i, n.getMinutes(), n.getSeconds(), 0); |
| 7397 | break; |
| 7398 | case "PM": |
| 7399 | 12 !== i ? n.setHours(i + 12, n.getMinutes(), n.getSeconds(), 0) : n.setHours(i, n.getMinutes(), n.getSeconds(), 0); |
| 7400 | } |
| 7401 | return n; |
| 7402 | } |
| 7403 | }, |
| 7404 | { |
| 7405 | key: "parseValues", |
| 7406 | value: function parseValues() { |
| 7407 | if (this.rangePlugin) { |
| 7408 | if (this.rangePlugin.options.strict) { |
| 7409 | if (this.rangePlugin.options.startDate && this.rangePlugin.options.endDate) { |
| 7410 | var e = new t1(this.rangePlugin.options.startDate, this.picker.options.format), i = new t1(this.rangePlugin.options.endDate, this.picker.options.format); |
| 7411 | this.timePicked.start = e.clone(), this.timePicked.end = i.clone(); |
| 7412 | } |
| 7413 | } else { |
| 7414 | if (this.rangePlugin.options.startDate) { |
| 7415 | var e35 = new t1(this.rangePlugin.options.startDate, this.picker.options.format); |
| 7416 | this.timePicked.start = e35.clone(); |
| 7417 | } |
| 7418 | if (this.rangePlugin.options.endDate) { |
| 7419 | var e36 = new t1(this.rangePlugin.options.endDate, this.picker.options.format); |
| 7420 | this.timePicked.end = e36.clone(); |
| 7421 | } |
| 7422 | } |
| 7423 | if (this.rangePlugin.options.elementEnd) { |
| 7424 | if (this.rangePlugin.options.strict) { |
| 7425 | if (this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length && this.rangePlugin.options.elementEnd instanceof HTMLInputElement && this.rangePlugin.options.elementEnd.value.length) { |
| 7426 | var e37 = new t1(this.picker.options.element.value, this.picker.options.format), i33 = new t1(this.rangePlugin.options.elementEnd.value, this.picker.options.format); |
| 7427 | this.timePicked.start = e37.clone(), this.timePicked.end = i33.clone(); |
| 7428 | } |
| 7429 | } else { |
| 7430 | if (this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length) { |
| 7431 | var e38 = new t1(this.picker.options.element.value, this.picker.options.format); |
| 7432 | this.timePicked.start = e38.clone(); |
| 7433 | } |
| 7434 | if (this.rangePlugin.options.elementEnd instanceof HTMLInputElement && this.rangePlugin.options.elementEnd.value.length) { |
| 7435 | var e39 = new t1(this.rangePlugin.options.elementEnd.value, this.picker.options.format); |
| 7436 | this.timePicked.start = e39.clone(); |
| 7437 | } |
| 7438 | } |
| 7439 | } else if (this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length) { |
| 7440 | var ref = (0, _slicedToArrayJsDefault.default)(this.picker.options.element.value.split(this.rangePlugin.options.delimiter), 2), e40 = ref[0], i34 = ref[1]; |
| 7441 | if (this.rangePlugin.options.strict) { |
| 7442 | if (e40 && i34) { |
| 7443 | var n = new t1(e40, this.picker.options.format), s23 = new t1(i34, this.picker.options.format); |
| 7444 | this.timePicked.start = n.clone(), this.timePicked.end = s23.clone(); |
| 7445 | } |
| 7446 | } else { |
| 7447 | if (e40) { |
| 7448 | var i35 = new t1(e40, this.picker.options.format); |
| 7449 | this.timePicked.start = i35.clone(); |
| 7450 | } |
| 7451 | if (i34) { |
| 7452 | var e41 = new t1(i34, this.picker.options.format); |
| 7453 | this.timePicked.start = e41.clone(); |
| 7454 | } |
| 7455 | } |
| 7456 | } |
| 7457 | } else { |
| 7458 | if (this.picker.options.date) { |
| 7459 | var e42 = new t1(this.picker.options.date, this.picker.options.format); |
| 7460 | this.timePicked.input = e42.clone(); |
| 7461 | } |
| 7462 | if (this.picker.options.element instanceof HTMLInputElement && this.picker.options.element.value.length) { |
| 7463 | var e43 = new t1(this.picker.options.element.value, this.picker.options.format); |
| 7464 | this.timePicked.input = e43.clone(); |
| 7465 | } |
| 7466 | } |
| 7467 | } |
| 7468 | } |
| 7469 | ]); |
| 7470 | return l; |
| 7471 | }(o); |
| 7472 | var h = /*#__PURE__*/ function(o) { |
| 7473 | "use strict"; |
| 7474 | (0, _inheritsJsDefault.default)(h, o); |
| 7475 | var _super = (0, _createSuperJsDefault.default)(h); |
| 7476 | function h() { |
| 7477 | (0, _classCallCheckJsDefault.default)(this, h); |
| 7478 | var _this; |
| 7479 | _this = _super.apply(this, arguments); |
| 7480 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "docElement", null); |
| 7481 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "rangePlugin", void 0); |
| 7482 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "binds", { |
| 7483 | onView: _this.onView.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7484 | onKeydown: _this.onKeydown.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 7485 | }); |
| 7486 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "options", { |
| 7487 | unitIndex: 1, |
| 7488 | dayIndex: 2 |
| 7489 | }); |
| 7490 | return _this; |
| 7491 | } |
| 7492 | (0, _createClassJsDefault.default)(h, [ |
| 7493 | { |
| 7494 | key: "getName", |
| 7495 | value: function getName() { |
| 7496 | return "KbdPlugin"; |
| 7497 | } |
| 7498 | }, |
| 7499 | { |
| 7500 | key: "onAttach", |
| 7501 | value: function onAttach() { |
| 7502 | var _this = this; |
| 7503 | var t16 = this.picker.options.element, e = t16.getBoundingClientRect(); |
| 7504 | if (this.docElement = document.createElement("span"), this.docElement.style.position = "absolute", this.docElement.style.top = "".concat(t16.offsetTop, "px"), this.docElement.style.left = t16.offsetLeft + e.width - 25 + "px", this.docElement.attachShadow({ |
| 7505 | mode: "open" |
| 7506 | }), this.options.html) this.docElement.shadowRoot.innerHTML = this.options.html; |
| 7507 | else { |
| 7508 | var t15 = "\n <style>\n button {\n border: none;\n background: transparent;\n font-size: ".concat(window.getComputedStyle(this.picker.options.element).fontSize, ";\n }\n </style>\n\n <button>📅</button>\n "); |
| 7509 | this.docElement.shadowRoot.innerHTML = t15; |
| 7510 | } |
| 7511 | var i = this.docElement.shadowRoot.querySelector("button"); |
| 7512 | i && (i.addEventListener("click", function(t) { |
| 7513 | t.preventDefault(), _this.picker.show({ |
| 7514 | target: _this.picker.options.element |
| 7515 | }); |
| 7516 | }, { |
| 7517 | capture: !0 |
| 7518 | }), i.addEventListener("keydown", function(t) { |
| 7519 | "Escape" === t.code && _this.picker.hide(); |
| 7520 | }, { |
| 7521 | capture: !0 |
| 7522 | })), this.picker.options.element.after(this.docElement), this.picker.on("view", this.binds.onView), this.picker.on("keydown", this.binds.onKeydown); |
| 7523 | } |
| 7524 | }, |
| 7525 | { |
| 7526 | key: "onDetach", |
| 7527 | value: function onDetach() { |
| 7528 | this.docElement && this.docElement.isConnected && this.docElement.remove(), this.picker.off("view", this.binds.onView), this.picker.off("keydown", this.binds.onKeydown); |
| 7529 | } |
| 7530 | }, |
| 7531 | { |
| 7532 | key: "onView", |
| 7533 | value: function onView(t17) { |
| 7534 | var _this = this; |
| 7535 | var _detail = t17.detail, e = _detail.view, i = _detail.target; |
| 7536 | i && "querySelector" in i && ("CalendarDay" !== e || [ |
| 7537 | "locked", |
| 7538 | "not-available" |
| 7539 | ].some(function(t) { |
| 7540 | return i.classList.contains(t); |
| 7541 | }) ? (0, _toConsumableArrayJsDefault.default)(i.querySelectorAll(".unit:not(.day)")).forEach(function(t) { |
| 7542 | return t.tabIndex = _this.options.unitIndex; |
| 7543 | }) : i.tabIndex = this.options.dayIndex); |
| 7544 | } |
| 7545 | }, |
| 7546 | { |
| 7547 | key: "onKeydown", |
| 7548 | value: function onKeydown(t) { |
| 7549 | switch(this.onMouseEnter(t), t.code){ |
| 7550 | case "ArrowUp": |
| 7551 | case "ArrowDown": |
| 7552 | this.verticalMove(t); |
| 7553 | break; |
| 7554 | case "ArrowLeft": |
| 7555 | case "ArrowRight": |
| 7556 | this.horizontalMove(t); |
| 7557 | break; |
| 7558 | case "Enter": |
| 7559 | case "Space": |
| 7560 | this.handleEnter(t); |
| 7561 | break; |
| 7562 | case "Escape": |
| 7563 | this.picker.hide(); |
| 7564 | } |
| 7565 | } |
| 7566 | }, |
| 7567 | { |
| 7568 | key: "findAllowableDaySibling", |
| 7569 | value: function findAllowableDaySibling(t18, e44, i) { |
| 7570 | var _this = this; |
| 7571 | var n = Array.from(t18.querySelectorAll('.day[tabindex="'.concat(this.options.dayIndex, '"]'))), s24 = n.indexOf(e44); |
| 7572 | return n.filter(function(t, e) { |
| 7573 | return i(e, s24) && t.tabIndex === _this.options.dayIndex; |
| 7574 | })[0]; |
| 7575 | } |
| 7576 | }, |
| 7577 | { |
| 7578 | key: "changeMonth", |
| 7579 | value: function changeMonth(t) { |
| 7580 | var _this = this; |
| 7581 | var e45 = { |
| 7582 | ArrowLeft: "previous", |
| 7583 | ArrowRight: "next" |
| 7584 | }, i = this.picker.ui.container.querySelector(".".concat(e45[t.code], '-button[tabindex="').concat(this.options.unitIndex, '"]')); |
| 7585 | i && !i.parentElement.classList.contains("no-".concat(e45[t.code], "-month")) && (i.dispatchEvent(new Event("click", { |
| 7586 | bubbles: !0 |
| 7587 | })), setTimeout(function() { |
| 7588 | var e = null; |
| 7589 | switch(t.code){ |
| 7590 | case "ArrowLeft": |
| 7591 | var _$t = _this.picker.ui.container.querySelectorAll('.day[tabindex="'.concat(_this.options.dayIndex, '"]')); |
| 7592 | e = _$t[_$t.length - 1]; |
| 7593 | break; |
| 7594 | case "ArrowRight": |
| 7595 | e = _this.picker.ui.container.querySelector('.day[tabindex="'.concat(_this.options.dayIndex, '"]')); |
| 7596 | } |
| 7597 | e && e.focus(); |
| 7598 | })); |
| 7599 | } |
| 7600 | }, |
| 7601 | { |
| 7602 | key: "verticalMove", |
| 7603 | value: function verticalMove(t) { |
| 7604 | var e46 = t.target; |
| 7605 | if (e46.classList.contains("day")) { |
| 7606 | t.preventDefault(); |
| 7607 | var i36 = this.findAllowableDaySibling(this.picker.ui.container, e46, function(e, i) { |
| 7608 | return e === ("ArrowUp" === t.code ? i - 7 : i + 7); |
| 7609 | }); |
| 7610 | i36 && i36.focus(); |
| 7611 | } |
| 7612 | } |
| 7613 | }, |
| 7614 | { |
| 7615 | key: "horizontalMove", |
| 7616 | value: function horizontalMove(t) { |
| 7617 | var e47 = t.target; |
| 7618 | if (e47.classList.contains("day")) { |
| 7619 | t.preventDefault(); |
| 7620 | var i38 = this.findAllowableDaySibling(this.picker.ui.container, e47, function(e, i) { |
| 7621 | return e === ("ArrowLeft" === t.code ? i - 1 : i + 1); |
| 7622 | }); |
| 7623 | i38 ? i38.focus() : this.changeMonth(t); |
| 7624 | } |
| 7625 | } |
| 7626 | }, |
| 7627 | { |
| 7628 | key: "handleEnter", |
| 7629 | value: function handleEnter(t) { |
| 7630 | var _this = this; |
| 7631 | var e = t.target; |
| 7632 | e.classList.contains("day") && (t.preventDefault(), e.dispatchEvent(new Event("click", { |
| 7633 | bubbles: !0 |
| 7634 | })), setTimeout(function() { |
| 7635 | if (_this.rangePlugin = _this.picker.PluginManager.getInstance("RangePlugin"), _this.rangePlugin || !_this.picker.options.autoApply) { |
| 7636 | var _$t = _this.picker.ui.container.querySelector(".day.selected"); |
| 7637 | _$t && setTimeout(function() { |
| 7638 | _$t.focus(); |
| 7639 | }); |
| 7640 | } |
| 7641 | })); |
| 7642 | } |
| 7643 | }, |
| 7644 | { |
| 7645 | key: "onMouseEnter", |
| 7646 | value: function onMouseEnter(t) { |
| 7647 | var _this = this; |
| 7648 | t.target.classList.contains("day") && setTimeout(function() { |
| 7649 | var _$t = _this.picker.ui.shadowRoot.activeElement; |
| 7650 | _$t && _$t.dispatchEvent(new Event("mouseenter", { |
| 7651 | bubbles: !0 |
| 7652 | })); |
| 7653 | }); |
| 7654 | } |
| 7655 | } |
| 7656 | ]); |
| 7657 | return h; |
| 7658 | }(o); |
| 7659 | var d = /*#__PURE__*/ function(o) { |
| 7660 | "use strict"; |
| 7661 | (0, _inheritsJsDefault.default)(d, o); |
| 7662 | var _super = (0, _createSuperJsDefault.default)(d); |
| 7663 | function d() { |
| 7664 | (0, _classCallCheckJsDefault.default)(this, d); |
| 7665 | var _this; |
| 7666 | _this = _super.apply(this, arguments); |
| 7667 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "rangePlugin", void 0); |
| 7668 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "lockPlugin", void 0); |
| 7669 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "priority", 10); |
| 7670 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "binds", { |
| 7671 | onView: _this.onView.bind((0, _assertThisInitializedJsDefault.default)(_this)), |
| 7672 | onColorScheme: _this.onColorScheme.bind((0, _assertThisInitializedJsDefault.default)(_this)) |
| 7673 | }); |
| 7674 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "options", { |
| 7675 | dropdown: { |
| 7676 | months: !1, |
| 7677 | years: !1, |
| 7678 | minYear: 1950, |
| 7679 | maxYear: null |
| 7680 | }, |
| 7681 | darkMode: !0, |
| 7682 | locale: { |
| 7683 | resetButton: '<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"/></svg>' |
| 7684 | } |
| 7685 | }); |
| 7686 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "matchMedia", void 0); |
| 7687 | return _this; |
| 7688 | } |
| 7689 | (0, _createClassJsDefault.default)(d, [ |
| 7690 | { |
| 7691 | key: "getName", |
| 7692 | value: function getName() { |
| 7693 | return "AmpPlugin"; |
| 7694 | } |
| 7695 | }, |
| 7696 | { |
| 7697 | key: "onAttach", |
| 7698 | value: function onAttach() { |
| 7699 | this.options.darkMode && window && "matchMedia" in window && (this.matchMedia = window.matchMedia("(prefers-color-scheme: dark)"), this.matchMedia.matches && (this.picker.ui.container.dataset.theme = "dark"), this.matchMedia.addEventListener("change", this.binds.onColorScheme)), this.options.weekNumbers && this.picker.ui.container.classList.add("week-numbers"), this.picker.on("view", this.binds.onView); |
| 7700 | } |
| 7701 | }, |
| 7702 | { |
| 7703 | key: "onDetach", |
| 7704 | value: function onDetach() { |
| 7705 | this.options.darkMode && window && "matchMedia" in window && this.matchMedia.removeEventListener("change", this.binds.onColorScheme), this.picker.ui.container.removeAttribute("data-theme"), this.picker.ui.container.classList.remove("week-numbers"), this.picker.off("view", this.binds.onView); |
| 7706 | } |
| 7707 | }, |
| 7708 | { |
| 7709 | key: "onView", |
| 7710 | value: function onView(t) { |
| 7711 | this.lockPlugin = this.picker.PluginManager.getInstance("LockPlugin"), this.rangePlugin = this.picker.PluginManager.getInstance("RangePlugin"), this.handleDropdown(t), this.handleResetButton(t), this.handleWeekNumbers(t); |
| 7712 | } |
| 7713 | }, |
| 7714 | { |
| 7715 | key: "onColorScheme", |
| 7716 | value: function onColorScheme(t) { |
| 7717 | var e = t.matches ? "dark" : "light"; |
| 7718 | this.picker.ui.container.dataset.theme = e; |
| 7719 | } |
| 7720 | }, |
| 7721 | { |
| 7722 | key: "handleDropdown", |
| 7723 | value: function handleDropdown(e) { |
| 7724 | var _detail = e.detail, i = _detail.view, n = _detail.target, s25 = _detail.date, _$o = _detail.index; |
| 7725 | if ("CalendarHeader" === i) { |
| 7726 | var _$e7 = n.querySelector(".month-name"); |
| 7727 | if (this.options.dropdown.months) { |
| 7728 | var _this = this; |
| 7729 | _$e7.childNodes[0].remove(); |
| 7730 | var i40 = document.createElement("select"); |
| 7731 | i40.className = "month-name--select month-name--dropdown"; |
| 7732 | for(var _$e5 = 0; _$e5 < 12; _$e5 += 1){ |
| 7733 | var n20 = document.createElement("option"), _$o2 = new t1(new Date(s25.getFullYear(), _$e5, 2, 0, 0, 0)), a = new t1(new Date(s25.getFullYear(), _$e5, 1, 0, 0, 0)); |
| 7734 | n20.value = String(_$e5), n20.text = _$o2.toLocaleString(this.picker.options.lang, { |
| 7735 | month: "long" |
| 7736 | }), this.lockPlugin && (n20.disabled = this.lockPlugin.options.minDate && a.isBefore(new t1(this.lockPlugin.options.minDate), "month") || this.lockPlugin.options.maxDate && a.isAfter(new t1(this.lockPlugin.options.maxDate), "month")), n20.selected = a.getMonth() === s25.getMonth(), i40.appendChild(n20); |
| 7737 | } |
| 7738 | i40.addEventListener("change", function(t) { |
| 7739 | var _$e = t.target; |
| 7740 | _this.picker.calendars[0].setDate(1), _this.picker.calendars[0].setMonth(Number(_$e.value)), _this.picker.renderAll(); |
| 7741 | }), _$e7.prepend(i40); |
| 7742 | } |
| 7743 | if (this.options.dropdown.years) { |
| 7744 | var _this3 = this; |
| 7745 | _$e7.childNodes[1].remove(); |
| 7746 | var i41 = document.createElement("select"); |
| 7747 | i41.className = "month-name--select"; |
| 7748 | var n21 = this.options.dropdown.minYear, _$o3 = this.options.dropdown.maxYear ? this.options.dropdown.maxYear : (new Date).getFullYear(); |
| 7749 | if (s25.getFullYear() > _$o3) { |
| 7750 | var t21 = document.createElement("option"); |
| 7751 | t21.value = String(s25.getFullYear()), t21.text = String(s25.getFullYear()), t21.selected = !0, t21.disabled = !0, i41.appendChild(t21); |
| 7752 | } |
| 7753 | for(var _$e6 = _$o3; _$e6 >= n21; _$e6 -= 1){ |
| 7754 | var n22 = document.createElement("option"), _$o4 = new t1(new Date(_$e6, 0, 1, 0, 0, 0)); |
| 7755 | n22.value = String(_$e6), n22.text = String(_$e6), this.lockPlugin && (n22.disabled = this.lockPlugin.options.minDate && _$o4.isBefore(new t1(this.lockPlugin.options.minDate), "year") || this.lockPlugin.options.maxDate && _$o4.isAfter(new t1(this.lockPlugin.options.maxDate), "year")), n22.selected = s25.getFullYear() === _$e6, i41.appendChild(n22); |
| 7756 | } |
| 7757 | if (s25.getFullYear() < n21) { |
| 7758 | var t19 = document.createElement("option"); |
| 7759 | t19.value = String(s25.getFullYear()), t19.text = String(s25.getFullYear()), t19.selected = !0, t19.disabled = !0, i41.appendChild(t19); |
| 7760 | } |
| 7761 | if ("asc" === this.options.dropdown.years) { |
| 7762 | var t20 = Array.prototype.slice.call(i41.childNodes).reverse(); |
| 7763 | i41.innerHTML = "", t20.forEach(function(t) { |
| 7764 | t.innerHTML = t.value, i41.appendChild(t); |
| 7765 | }); |
| 7766 | } |
| 7767 | i41.addEventListener("change", function(t) { |
| 7768 | var _$e = t.target; |
| 7769 | _this3.picker.calendars[0].setFullYear(Number(_$e.value)), _this3.picker.renderAll(); |
| 7770 | }), _$e7.appendChild(i41); |
| 7771 | } |
| 7772 | } |
| 7773 | } |
| 7774 | }, |
| 7775 | { |
| 7776 | key: "handleResetButton", |
| 7777 | value: function handleResetButton(t23) { |
| 7778 | var _detail = t23.detail, e48 = _detail.view, i = _detail.target; |
| 7779 | if ("CalendarHeader" === e48 && this.options.resetButton) { |
| 7780 | var _this = this; |
| 7781 | var _$t = document.createElement("button"); |
| 7782 | _$t.className = "reset-button unit", _$t.innerHTML = this.options.locale.resetButton, _$t.addEventListener("click", function(t) { |
| 7783 | t.preventDefault(); |
| 7784 | var e = !0; |
| 7785 | "function" == typeof _this.options.resetButton && (e = _this.options.resetButton.call(_this)), e && _this.picker.clear(); |
| 7786 | }), i.appendChild(_$t); |
| 7787 | } |
| 7788 | } |
| 7789 | }, |
| 7790 | { |
| 7791 | key: "handleWeekNumbers", |
| 7792 | value: function handleWeekNumbers(e49) { |
| 7793 | if (this.options.weekNumbers) { |
| 7794 | var _this = this; |
| 7795 | var _detail = e49.detail, i42 = _detail.view, n = _detail.target; |
| 7796 | if ("CalendarDayNames" === i42) { |
| 7797 | var t = document.createElement("div"); |
| 7798 | t.className = "wnum-header", t.innerHTML = "Wk", n.prepend(t); |
| 7799 | } |
| 7800 | "CalendarDays" === i42 && (0, _toConsumableArrayJsDefault.default)(n.children).forEach(function(e, i) { |
| 7801 | if (0 === i || i % 7 == 0) { |
| 7802 | var _$i; |
| 7803 | if (e.classList.contains("day")) _$i = new t1(e.dataset.time); |
| 7804 | else { |
| 7805 | var _$e = n.querySelector(".day"); |
| 7806 | _$i = new t1(_$e.dataset.time); |
| 7807 | } |
| 7808 | var s26 = _$i.getWeek(_this.picker.options.firstDay); |
| 7809 | 53 === s26 && 0 === _$i.getMonth() && (s26 = "53/1"); |
| 7810 | var _$o = document.createElement("div"); |
| 7811 | _$o.className = "wnum-item", _$o.innerHTML = String(s26), n.insertBefore(_$o, e); |
| 7812 | } |
| 7813 | }); |
| 7814 | } |
| 7815 | } |
| 7816 | } |
| 7817 | ]); |
| 7818 | return d; |
| 7819 | }(o); |
| 7820 | |
| 7821 | },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@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/_object_spread.js":"d5EJT","@swc/helpers/lib/_possible_constructor_return.js":"hAvqf","@swc/helpers/lib/_sliced_to_array.js":"4IWLM","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_wrap_native_super.js":"4U7ja","@swc/helpers/lib/_create_super.js":"5rW3S","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"d5EJT":[function(require,module,exports) { |
| 7822 | "use strict"; |
| 7823 | Object.defineProperty(exports, "__esModule", { |
| 7824 | value: true |
| 7825 | }); |
| 7826 | exports.default = _objectSpread; |
| 7827 | var _defineProperty = _interopRequireDefault(require("./_define_property")); |
| 7828 | function _objectSpread(target) { |
| 7829 | for(var i = 1; i < arguments.length; i++){ |
| 7830 | var source = arguments[i] != null ? arguments[i] : {}; |
| 7831 | var ownKeys = Object.keys(source); |
| 7832 | if (typeof Object.getOwnPropertySymbols === "function") ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { |
| 7833 | return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
| 7834 | })); |
| 7835 | ownKeys.forEach(function(key) { |
| 7836 | _defineProperty.default(target, key, source[key]); |
| 7837 | }); |
| 7838 | } |
| 7839 | return target; |
| 7840 | } |
| 7841 | function _interopRequireDefault(obj) { |
| 7842 | return obj && obj.__esModule ? obj : { |
| 7843 | default: obj |
| 7844 | }; |
| 7845 | } |
| 7846 | |
| 7847 | },{"./_define_property":"6IXzf"}],"4U7ja":[function(require,module,exports) { |
| 7848 | "use strict"; |
| 7849 | Object.defineProperty(exports, "__esModule", { |
| 7850 | value: true |
| 7851 | }); |
| 7852 | exports.default = _wrapNativeSuper; |
| 7853 | var _construct = _interopRequireDefault(require("./_construct")); |
| 7854 | var _isNativeFunction = _interopRequireDefault(require("./_is_native_function")); |
| 7855 | var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of")); |
| 7856 | var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of")); |
| 7857 | function _wrapNativeSuper(Class) { |
| 7858 | return wrapNativeSuper(Class); |
| 7859 | } |
| 7860 | function _interopRequireDefault(obj) { |
| 7861 | return obj && obj.__esModule ? obj : { |
| 7862 | default: obj |
| 7863 | }; |
| 7864 | } |
| 7865 | function wrapNativeSuper(Class1) { |
| 7866 | var _cache = typeof Map === "function" ? new Map() : undefined; |
| 7867 | wrapNativeSuper = function wrapNativeSuper(Class) { |
| 7868 | if (Class === null || !_isNativeFunction.default(Class)) return Class; |
| 7869 | if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function"); |
| 7870 | if (typeof _cache !== "undefined") { |
| 7871 | if (_cache.has(Class)) return _cache.get(Class); |
| 7872 | _cache.set(Class, Wrapper); |
| 7873 | } |
| 7874 | function Wrapper() { |
| 7875 | return _construct.default(Class, arguments, _getPrototypeOf.default(this).constructor); |
| 7876 | } |
| 7877 | Wrapper.prototype = Object.create(Class.prototype, { |
| 7878 | constructor: { |
| 7879 | value: Wrapper, |
| 7880 | enumerable: false, |
| 7881 | writable: true, |
| 7882 | configurable: true |
| 7883 | } |
| 7884 | }); |
| 7885 | return _setPrototypeOf.default(Wrapper, Class); |
| 7886 | }; |
| 7887 | return wrapNativeSuper(Class1); |
| 7888 | } |
| 7889 | |
| 7890 | },{"./_construct":"597Bk","./_is_native_function":"9evrd","./_get_prototype_of":"7Gb6H","./_set_prototype_of":"1rATD"}],"597Bk":[function(require,module,exports) { |
| 7891 | "use strict"; |
| 7892 | Object.defineProperty(exports, "__esModule", { |
| 7893 | value: true |
| 7894 | }); |
| 7895 | exports.default = _construct; |
| 7896 | var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of")); |
| 7897 | function _construct(Parent, args, Class) { |
| 7898 | return construct.apply(null, arguments); |
| 7899 | } |
| 7900 | function _interopRequireDefault(obj) { |
| 7901 | return obj && obj.__esModule ? obj : { |
| 7902 | default: obj |
| 7903 | }; |
| 7904 | } |
| 7905 | function isNativeReflectConstruct() { |
| 7906 | if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
| 7907 | if (Reflect.construct.sham) return false; |
| 7908 | if (typeof Proxy === "function") return true; |
| 7909 | try { |
| 7910 | Date.prototype.toString.call(Reflect.construct(Date, [], function() {})); |
| 7911 | return true; |
| 7912 | } catch (e) { |
| 7913 | return false; |
| 7914 | } |
| 7915 | } |
| 7916 | function construct(Parent1, args1, Class1) { |
| 7917 | if (isNativeReflectConstruct()) construct = Reflect.construct; |
| 7918 | else construct = function construct(Parent, args, Class) { |
| 7919 | var a = [ |
| 7920 | null |
| 7921 | ]; |
| 7922 | a.push.apply(a, args); |
| 7923 | var Constructor = Function.bind.apply(Parent, a); |
| 7924 | var instance = new Constructor(); |
| 7925 | if (Class) _setPrototypeOf.default(instance, Class.prototype); |
| 7926 | return instance; |
| 7927 | }; |
| 7928 | return construct.apply(null, arguments); |
| 7929 | } |
| 7930 | |
| 7931 | },{"./_set_prototype_of":"1rATD"}],"9evrd":[function(require,module,exports) { |
| 7932 | "use strict"; |
| 7933 | Object.defineProperty(exports, "__esModule", { |
| 7934 | value: true |
| 7935 | }); |
| 7936 | exports.default = _isNativeFunction; |
| 7937 | function _isNativeFunction(fn) { |
| 7938 | return Function.toString.call(fn).indexOf("[native code]") !== -1; |
| 7939 | } |
| 7940 | |
| 7941 | },{}],"ibNcV":[function(require,module,exports) { |
| 7942 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 7943 | parcelHelpers.defineInteropFlag(exports); |
| 7944 | parcelHelpers.export(exports, "default", function() { |
| 7945 | return _class; |
| 7946 | }); |
| 7947 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 7948 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 7949 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 7950 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 7951 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 7952 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 7953 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 7954 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 7955 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 7956 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 7957 | var _stimulus = require("@hotwired/stimulus"); |
| 7958 | var _micromodal = require("micromodal"); |
| 7959 | var _micromodalDefault = parcelHelpers.interopDefault(_micromodal); |
| 7960 | document.addEventListener("DOMContentLoaded", function() { |
| 7961 | return (0, _micromodalDefault.default).init(); |
| 7962 | }); |
| 7963 | var _class = /*#__PURE__*/ function(Controller) { |
| 7964 | "use strict"; |
| 7965 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 7966 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 7967 | function _class() { |
| 7968 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 7969 | return _super.apply(this, arguments); |
| 7970 | } |
| 7971 | (0, _createClassJsDefault.default)(_class, [ |
| 7972 | { |
| 7973 | key: "isValidConfirmation", |
| 7974 | value: function isValidConfirmation(confirmationValue) { |
| 7975 | return confirmationValue.toLowerCase() === "delete all data"; |
| 7976 | } |
| 7977 | }, |
| 7978 | { |
| 7979 | key: "confirmationValueChanged", |
| 7980 | value: function confirmationValueChanged(confirmationValue) { |
| 7981 | this.inputTarget.value = confirmationValue; |
| 7982 | var disable = !this.isValidConfirmation(confirmationValue); |
| 7983 | this.submitTarget.toggleAttribute("disabled", disable); |
| 7984 | } |
| 7985 | }, |
| 7986 | { |
| 7987 | key: "updateConfirmation", |
| 7988 | value: function updateConfirmation(e) { |
| 7989 | this.confirmationValue = e.target.value; |
| 7990 | } |
| 7991 | }, |
| 7992 | { |
| 7993 | key: "open", |
| 7994 | value: function open() { |
| 7995 | this.confirmationValue = ""; |
| 7996 | (0, _micromodalDefault.default).show("delete-data-modal"); |
| 7997 | } |
| 7998 | }, |
| 7999 | { |
| 8000 | key: "close", |
| 8001 | value: function close(e) { |
| 8002 | if (e.target !== e.currentTarget) return; |
| 8003 | (0, _micromodalDefault.default).close("delete-data-modal"); |
| 8004 | } |
| 8005 | }, |
| 8006 | { |
| 8007 | key: "submit", |
| 8008 | value: function submit(e) { |
| 8009 | e.preventDefault(); |
| 8010 | if (!this.isValidConfirmation(this.confirmationValue)) return; |
| 8011 | var data = { |
| 8012 | action: "iawp_delete_data", |
| 8013 | iawp_delete_data_nonce: IAWP_DELETE_DATA_NONCE, |
| 8014 | confirmation: this.confirmationValue |
| 8015 | }; |
| 8016 | this.submitTarget.setAttribute("disabled", "disabled"); |
| 8017 | this.submitTarget.textContent = "Deleting data..."; |
| 8018 | jQuery.post(ajaxurl, data, function(response) { |
| 8019 | setTimeout(function() { |
| 8020 | document.location.reload(); |
| 8021 | }, 500); |
| 8022 | }); |
| 8023 | } |
| 8024 | } |
| 8025 | ]); |
| 8026 | return _class; |
| 8027 | }((0, _stimulus.Controller)); |
| 8028 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 8029 | confirmation: String |
| 8030 | }); |
| 8031 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 8032 | "submit", |
| 8033 | "input" |
| 8034 | ]); |
| 8035 | |
| 8036 | },{"@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"}],"8ZFae":[function(require,module,exports) { |
| 8037 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 8038 | parcelHelpers.defineInteropFlag(exports); |
| 8039 | parcelHelpers.export(exports, "default", function() { |
| 8040 | return _class; |
| 8041 | }); |
| 8042 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 8043 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 8044 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 8045 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 8046 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 8047 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 8048 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 8049 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 8050 | var _stimulus = require("@hotwired/stimulus"); |
| 8051 | var _bundle = require("@easepick/bundle"); |
| 8052 | var _class = /*#__PURE__*/ function(Controller) { |
| 8053 | "use strict"; |
| 8054 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 8055 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 8056 | function _class() { |
| 8057 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 8058 | return _super.apply(this, arguments); |
| 8059 | } |
| 8060 | (0, _createClassJsDefault.default)(_class, [ |
| 8061 | { |
| 8062 | key: "connect", |
| 8063 | value: function connect() { |
| 8064 | new _bundle.create({ |
| 8065 | element: this.element, |
| 8066 | css: [ |
| 8067 | this.element.dataset.css |
| 8068 | ], |
| 8069 | zIndex: 99, |
| 8070 | date: new Date(), |
| 8071 | format: this.element.dataset.format, |
| 8072 | autoApply: true, |
| 8073 | firstDay: parseInt(this.element.dataset.dow) |
| 8074 | }); |
| 8075 | } |
| 8076 | } |
| 8077 | ]); |
| 8078 | return _class; |
| 8079 | }((0, _stimulus.Controller)); |
| 8080 | |
| 8081 | },{"@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","@easepick/bundle":"boi5E","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"hlRZI":[function(require,module,exports) { |
| 8082 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 8083 | parcelHelpers.defineInteropFlag(exports); |
| 8084 | parcelHelpers.export(exports, "default", function() { |
| 8085 | return _class; |
| 8086 | }); |
| 8087 | var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js"); |
| 8088 | var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs); |
| 8089 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 8090 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 8091 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 8092 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 8093 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 8094 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 8095 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 8096 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 8097 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 8098 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 8099 | var _stimulus = require("@hotwired/stimulus"); |
| 8100 | var _class = /*#__PURE__*/ function(Controller) { |
| 8101 | "use strict"; |
| 8102 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 8103 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 8104 | function _class() { |
| 8105 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 8106 | var _this; |
| 8107 | _this = _super.apply(this, arguments); |
| 8108 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "appliedConditions", 0); |
| 8109 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "maybeClose", function(event) { |
| 8110 | var isOpen = _this.modalTarget.classList.contains("show"); |
| 8111 | var isInComponent = _this.element.contains(event.target); |
| 8112 | if (isOpen && !isInComponent) _this.closeModal(); |
| 8113 | }); |
| 8114 | return _this; |
| 8115 | } |
| 8116 | (0, _createClassJsDefault.default)(_class, [ |
| 8117 | { |
| 8118 | key: "connect", |
| 8119 | value: function connect() { |
| 8120 | document.addEventListener("click", this.maybeClose); |
| 8121 | } |
| 8122 | }, |
| 8123 | { |
| 8124 | key: "disconnect", |
| 8125 | value: function disconnect() { |
| 8126 | document.removeEventListener("click", this.maybeClose); |
| 8127 | } |
| 8128 | }, |
| 8129 | { |
| 8130 | key: "toggleModal", |
| 8131 | value: function toggleModal(e) { |
| 8132 | var isOpen = this.modalTarget.classList.contains("show"); |
| 8133 | isOpen ? this.closeModal() : this.openModal(); |
| 8134 | } |
| 8135 | }, |
| 8136 | { |
| 8137 | key: "openModal", |
| 8138 | value: function openModal() { |
| 8139 | this.modalTarget.classList.add("show"); |
| 8140 | } |
| 8141 | }, |
| 8142 | { |
| 8143 | key: "closeModal", |
| 8144 | value: function closeModal() { |
| 8145 | this.modalTarget.classList.remove("show"); |
| 8146 | } |
| 8147 | }, |
| 8148 | { |
| 8149 | key: "addCondition", |
| 8150 | value: function addCondition() { |
| 8151 | this.filtersTarget.append(this.blueprintTarget.content.cloneNode(true)); |
| 8152 | this.setResetEnabled(true); |
| 8153 | } |
| 8154 | }, |
| 8155 | { |
| 8156 | key: "removeCondition", |
| 8157 | value: function removeCondition(e) { |
| 8158 | e.stopPropagation(); |
| 8159 | this.conditionTargets.forEach(function(condition) { |
| 8160 | if (condition.contains(e.target)) condition.remove(); |
| 8161 | }); |
| 8162 | if (this.conditionTargets.length === 0) { |
| 8163 | this.addCondition(); |
| 8164 | document.dispatchEvent(new CustomEvent("iawp:changeFilters", { |
| 8165 | detail: { |
| 8166 | filters: [] |
| 8167 | } |
| 8168 | })); |
| 8169 | this.setResetEnabled(false); |
| 8170 | } |
| 8171 | if (this.conditionTargets.length === 1) this.setResetEnabled(false); |
| 8172 | if (this.conditionTargets.length === 0) this.addCondition(); |
| 8173 | if (this.appliedConditions > 1) this.apply(); |
| 8174 | } |
| 8175 | }, |
| 8176 | { |
| 8177 | key: "apply", |
| 8178 | value: function apply() { |
| 8179 | var _this = this; |
| 8180 | var errors = false; |
| 8181 | this.conditionTargets.forEach(function(condition) { |
| 8182 | var columnTarget = _this.columnTargets.find(function(column) { |
| 8183 | return condition.contains(column); |
| 8184 | }); |
| 8185 | var operandTarget = _this.operandTargets.find(function(operand) { |
| 8186 | return condition.contains(operand) && operand.classList.contains("show"); |
| 8187 | }); |
| 8188 | if (columnTarget.value === "") { |
| 8189 | columnTarget.classList.add("error"); |
| 8190 | errors = true; |
| 8191 | } |
| 8192 | if (operandTarget && operandTarget.value === "") { |
| 8193 | operandTarget.classList.add("error"); |
| 8194 | errors = true; |
| 8195 | } |
| 8196 | }); |
| 8197 | if (errors) return; |
| 8198 | var filters = this.conditionTargets.map(function(condition) { |
| 8199 | var inclusionTarget = _this.inclusionTargets.find(function(inclusion) { |
| 8200 | return condition.contains(inclusion); |
| 8201 | }); |
| 8202 | var columnTarget = _this.columnTargets.find(function(column) { |
| 8203 | return condition.contains(column); |
| 8204 | }); |
| 8205 | var operatorTarget = _this.operatorTargets.find(function(operator) { |
| 8206 | return condition.contains(operator) && operator.classList.contains("show"); |
| 8207 | }); |
| 8208 | var operandTarget = _this.operandTargets.find(function(operand) { |
| 8209 | return condition.contains(operand) && operand.classList.contains("show"); |
| 8210 | }); |
| 8211 | return { |
| 8212 | inclusion: inclusionTarget.value, |
| 8213 | column: columnTarget.value, |
| 8214 | operator: operatorTarget.value, |
| 8215 | operand: operandTarget.value |
| 8216 | }; |
| 8217 | }); |
| 8218 | this.appliedConditions = filters.length; |
| 8219 | this.setResetEnabled(true); |
| 8220 | this.setCount(filters.length); |
| 8221 | this.closeModal(); |
| 8222 | document.dispatchEvent(new CustomEvent("iawp:changeFilters", { |
| 8223 | detail: { |
| 8224 | filters: filters |
| 8225 | } |
| 8226 | })); |
| 8227 | } |
| 8228 | }, |
| 8229 | { |
| 8230 | key: "reset", |
| 8231 | value: function reset() { |
| 8232 | this.conditionTargets.forEach(function(condition) { |
| 8233 | condition.remove(); |
| 8234 | }); |
| 8235 | this.addCondition(); |
| 8236 | this.setResetEnabled(false); |
| 8237 | this.appliedConditions = 0; |
| 8238 | this.setCount(0); |
| 8239 | this.closeModal(); |
| 8240 | document.dispatchEvent(new CustomEvent("iawp:changeFilters", { |
| 8241 | detail: { |
| 8242 | filters: [] |
| 8243 | } |
| 8244 | })); |
| 8245 | } |
| 8246 | }, |
| 8247 | { |
| 8248 | key: "setCount", |
| 8249 | value: function setCount() { |
| 8250 | var count = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0; |
| 8251 | if (count > 0) this.filterCountTarget.innerHTML = count; |
| 8252 | else this.filterCountTarget.innerHTML = ""; |
| 8253 | } |
| 8254 | }, |
| 8255 | { |
| 8256 | key: "setResetEnabled", |
| 8257 | value: function setResetEnabled() { |
| 8258 | var enable = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; |
| 8259 | if (enable) this.resetTarget.removeAttribute("disabled"); |
| 8260 | else this.resetTarget.setAttribute("disabled", "disabled"); |
| 8261 | } |
| 8262 | }, |
| 8263 | { |
| 8264 | // Todo - Need to clear anything that's been hidden |
| 8265 | key: "columnSelect", |
| 8266 | value: function columnSelect(e) { |
| 8267 | var condition1 = this.conditionTargets.find(function(condition) { |
| 8268 | return condition.contains(e.target); |
| 8269 | }); |
| 8270 | var column = e.target.value; |
| 8271 | var type = e.target.options[e.target.selectedIndex].dataset.type; |
| 8272 | // Remove error class |
| 8273 | e.target.classList.remove("error"); |
| 8274 | // Show the correct operator |
| 8275 | this.operatorTargets.filter(function(operator) { |
| 8276 | return condition1.contains(operator); |
| 8277 | }).forEach(function(operator) { |
| 8278 | var matchingType = operator.dataset.type === type; |
| 8279 | operator.classList.toggle("show", matchingType); |
| 8280 | }); |
| 8281 | // Show the correct operand field |
| 8282 | this.operandTargets.filter(function(operand) { |
| 8283 | return condition1.contains(operand); |
| 8284 | }).forEach(function(operand) { |
| 8285 | var matchingColumn = operand.dataset.column === column; |
| 8286 | operand.classList.toggle("show", matchingColumn); |
| 8287 | }); |
| 8288 | } |
| 8289 | }, |
| 8290 | { |
| 8291 | key: "operandChange", |
| 8292 | value: function operandChange(e) { |
| 8293 | e.target.classList.remove("error"); |
| 8294 | } |
| 8295 | } |
| 8296 | ]); |
| 8297 | return _class; |
| 8298 | }((0, _stimulus.Controller)); |
| 8299 | (0, _definePropertyJsDefault.default)(_class, "targets", [ |
| 8300 | "modal", |
| 8301 | "blueprint", |
| 8302 | "filters", |
| 8303 | "filterCount", |
| 8304 | "condition", |
| 8305 | "reset", |
| 8306 | "inclusion", |
| 8307 | "column", |
| 8308 | "operator", |
| 8309 | "operand" |
| 8310 | ]); |
| 8311 | |
| 8312 | },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@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","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"70LeQ":[function(require,module,exports) { |
| 8313 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 8314 | parcelHelpers.defineInteropFlag(exports); |
| 8315 | parcelHelpers.export(exports, "default", function() { |
| 8316 | return _class; |
| 8317 | }); |
| 8318 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 8319 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 8320 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 8321 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 8322 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 8323 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 8324 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 8325 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 8326 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 8327 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 8328 | var _stimulus = require("@hotwired/stimulus"); |
| 8329 | var _class = /*#__PURE__*/ function(Controller) { |
| 8330 | "use strict"; |
| 8331 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 8332 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 8333 | function _class() { |
| 8334 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 8335 | return _super.apply(this, arguments); |
| 8336 | } |
| 8337 | (0, _createClassJsDefault.default)(_class, [ |
| 8338 | { |
| 8339 | key: "connect", |
| 8340 | value: function connect() { |
| 8341 | var _this = this; |
| 8342 | // Run an initial check |
| 8343 | this.check(); |
| 8344 | setTimeout(function() { |
| 8345 | var _this1 = _this; |
| 8346 | // Run a check every second |
| 8347 | setInterval(function() { |
| 8348 | _this1.check(); |
| 8349 | }, 1000); |
| 8350 | }, 5000); |
| 8351 | } |
| 8352 | }, |
| 8353 | { |
| 8354 | /** |
| 8355 | * Check if a migration is running and reload the page if it's done |
| 8356 | */ key: "check", |
| 8357 | value: function check() { |
| 8358 | var data = { |
| 8359 | "action": "iawp_migration_status", |
| 8360 | "iawp_migration_status_nonce": this.nonceValue |
| 8361 | }; |
| 8362 | jQuery.post(ajaxurl, data, function(response, a, b) { |
| 8363 | if (!response.data.isMigrating) document.location.reload(); |
| 8364 | }); |
| 8365 | } |
| 8366 | } |
| 8367 | ]); |
| 8368 | return _class; |
| 8369 | }((0, _stimulus.Controller)); |
| 8370 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 8371 | nonce: String |
| 8372 | }); |
| 8373 | |
| 8374 | },{"@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","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"hn7Px":[function(require,module,exports) { |
| 8375 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 8376 | parcelHelpers.defineInteropFlag(exports); |
| 8377 | parcelHelpers.export(exports, "default", function() { |
| 8378 | return _class; |
| 8379 | }); |
| 8380 | var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js"); |
| 8381 | var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs); |
| 8382 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 8383 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 8384 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 8385 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 8386 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 8387 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 8388 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 8389 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 8390 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 8391 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 8392 | var _stimulus = require("@hotwired/stimulus"); |
| 8393 | var _bundle = require("@easepick/bundle"); |
| 8394 | var _class = /*#__PURE__*/ function(Controller) { |
| 8395 | "use strict"; |
| 8396 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 8397 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 8398 | function _class() { |
| 8399 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 8400 | var _this; |
| 8401 | _this = _super.apply(this, arguments); |
| 8402 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "exactStart", undefined); |
| 8403 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "exactEnd", undefined); |
| 8404 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "relativeRangeId", undefined); |
| 8405 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "columns", undefined); |
| 8406 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "filters", []); |
| 8407 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "datesChanged", function(e) { |
| 8408 | _this.exactStart = e.detail.exactStart; |
| 8409 | _this.exactEnd = e.detail.exactEnd; |
| 8410 | _this.relativeRangeId = e.detail.relativeRangeId; |
| 8411 | _this.fetch(); |
| 8412 | }); |
| 8413 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "columnsChanged", function(e) { |
| 8414 | _this.columns = e.detail.columns; |
| 8415 | }); |
| 8416 | (0, _definePropertyJsDefault.default)((0, _assertThisInitializedJsDefault.default)(_this), "filtersChanged", function(e) { |
| 8417 | _this.filters = e.detail.filters; |
| 8418 | _this.fetch(); |
| 8419 | }); |
| 8420 | return _this; |
| 8421 | } |
| 8422 | (0, _createClassJsDefault.default)(_class, [ |
| 8423 | { |
| 8424 | key: "connect", |
| 8425 | value: function connect() { |
| 8426 | // If any values are empty strings, set them equal to undefined instead |
| 8427 | this.exactStart = this.exactStartValue === "" ? undefined : new _bundle.DateTime(this.exactStartValue); |
| 8428 | this.exactEnd = this.exactEndValue === "" ? undefined : new _bundle.DateTime(this.exactEndValue); |
| 8429 | this.relativeRangeId = this.relativeRangeIdValue === "" ? undefined : this.relativeRangeIdValue; |
| 8430 | this.columns = this.columnsValue; |
| 8431 | document.addEventListener("iawp:changeDates", this.datesChanged); |
| 8432 | document.addEventListener("iawp:changeColumns", this.columnsChanged); |
| 8433 | document.addEventListener("iawp:changeFilters", this.filtersChanged); |
| 8434 | } |
| 8435 | }, |
| 8436 | { |
| 8437 | key: "disconnect", |
| 8438 | value: function disconnect() { |
| 8439 | document.removeEventListener("iawp:changeDates", this.datesChanged); |
| 8440 | document.removeEventListener("iawp:changeColumns", this.columnsChanged); |
| 8441 | document.removeEventListener("iawp:changeFilters", this.filtersChanged); |
| 8442 | } |
| 8443 | }, |
| 8444 | { |
| 8445 | key: "fetch", |
| 8446 | value: function fetch() { |
| 8447 | var data = { |
| 8448 | "action": "iawp_filter", |
| 8449 | "filters": this.filters, |
| 8450 | "exact_start": this.exactStart, |
| 8451 | "exact_end": this.exactEnd, |
| 8452 | "relative_range_id": this.relativeRangeId, |
| 8453 | "table_type": jQuery("#data-table").data("table-name"), |
| 8454 | "columns": this.columns, |
| 8455 | "iawp_filter_nonce": IAWP_AJAX.filter_nonce |
| 8456 | }; |
| 8457 | jQuery("#iawp-parent").addClass("loading"); |
| 8458 | jQuery.post(ajaxurl, data, function(response) { |
| 8459 | response = response.data; |
| 8460 | jQuery("#rows").replaceWith(response.rows); |
| 8461 | jQuery("#dates-button span:last-child").text(response.label); |
| 8462 | jQuery("#myChart").closest(".chart-container").replaceWith(response.chart); |
| 8463 | jQuery("#quick-stats").replaceWith(response.stats); |
| 8464 | jQuery("#iawp-parent").removeClass("loading"); |
| 8465 | jQuery("#columns .row-number").text(jQuery("#rows .row").length); |
| 8466 | }); |
| 8467 | } |
| 8468 | } |
| 8469 | ]); |
| 8470 | return _class; |
| 8471 | }((0, _stimulus.Controller)); |
| 8472 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 8473 | relativeRangeId: String, |
| 8474 | exactStart: String, |
| 8475 | exactEnd: String, |
| 8476 | columns: Array |
| 8477 | }); |
| 8478 | |
| 8479 | },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@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","@easepick/bundle":"boi5E","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"5eVCV":[function(require,module,exports) { |
| 8480 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
| 8481 | parcelHelpers.defineInteropFlag(exports); |
| 8482 | parcelHelpers.export(exports, "default", function() { |
| 8483 | return _class; |
| 8484 | }); |
| 8485 | var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js"); |
| 8486 | var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs); |
| 8487 | var _createClassJs = require("@swc/helpers/lib/_create_class.js"); |
| 8488 | var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs); |
| 8489 | var _definePropertyJs = require("@swc/helpers/lib/_define_property.js"); |
| 8490 | var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs); |
| 8491 | var _inheritsJs = require("@swc/helpers/lib/_inherits.js"); |
| 8492 | var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs); |
| 8493 | var _createSuperJs = require("@swc/helpers/lib/_create_super.js"); |
| 8494 | var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs); |
| 8495 | var _stimulus = require("@hotwired/stimulus"); |
| 8496 | var _class = /*#__PURE__*/ function(Controller) { |
| 8497 | "use strict"; |
| 8498 | (0, _inheritsJsDefault.default)(_class, Controller); |
| 8499 | var _super = (0, _createSuperJsDefault.default)(_class); |
| 8500 | function _class() { |
| 8501 | (0, _classCallCheckJsDefault.default)(this, _class); |
| 8502 | return _super.apply(this, arguments); |
| 8503 | } |
| 8504 | (0, _createClassJsDefault.default)(_class, [ |
| 8505 | { |
| 8506 | key: "connect", |
| 8507 | value: function connect() { |
| 8508 | // console.log('sort running') |
| 8509 | // console.log(this.columnValue); |
| 8510 | } |
| 8511 | }, |
| 8512 | { |
| 8513 | key: "sortByColumn", |
| 8514 | value: function sortByColumn() { |
| 8515 | // Todo - This is not used just yet |
| 8516 | // console.log('sorting by', this.columnValue) |
| 8517 | } |
| 8518 | } |
| 8519 | ]); |
| 8520 | return _class; |
| 8521 | }((0, _stimulus.Controller)); |
| 8522 | (0, _definePropertyJsDefault.default)(_class, "values", { |
| 8523 | column: String |
| 8524 | }); |
| 8525 | |
| 8526 | },{"@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","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}]},["2CYCe"], "2CYCe", "parcelRequirec571") |
| 8527 | |
| 8528 | //# sourceMappingURL=index.js.map |
| 8529 |