{"version":3,"file":"js/vendors~application-e10e127e7f26058ff78c.chunk.js","sources":["webpack:///./node_modules/@hotwired/stimulus/dist/stimulus.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable_stream_source_element.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/form_submissions.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/index.js","webpack:///./node_modules/@hotwired/turbo-rails/app/javascript/turbo/snakeize.js","webpack:///./node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js","webpack:///./node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js","webpack:///./node_modules/@stimulus/webpack-helpers/dist/index.js","webpack:///./node_modules/stimulus-chartjs/dist/stimulus-chartjs.es.js","webpack:///./node_modules/stimulus-password-visibility/dist/stimulus-password-visibility.es.js","webpack:///./node_modules/stimulus/webpack-helpers.js"],"sourcesContent":["function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n/*\nStimulus 3.2.1\nCopyright © 2023 Basecamp, LLC\n */\nclass EventListener {\n constructor(eventTarget, eventName, eventOptions) {\n this.eventTarget = eventTarget;\n this.eventName = eventName;\n this.eventOptions = eventOptions;\n this.unorderedBindings = new Set();\n }\n\n connect() {\n this.eventTarget.addEventListener(this.eventName, this, this.eventOptions);\n }\n\n disconnect() {\n this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions);\n }\n\n bindingConnected(binding) {\n this.unorderedBindings.add(binding);\n }\n\n bindingDisconnected(binding) {\n this.unorderedBindings.delete(binding);\n }\n\n handleEvent(event) {\n const extendedEvent = extendEvent(event);\n\n for (const binding of this.bindings) {\n if (extendedEvent.immediatePropagationStopped) {\n break;\n } else {\n binding.handleEvent(extendedEvent);\n }\n }\n }\n\n hasBindings() {\n return this.unorderedBindings.size > 0;\n }\n\n get bindings() {\n return Array.from(this.unorderedBindings).sort((left, right) => {\n const leftIndex = left.index,\n rightIndex = right.index;\n return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0;\n });\n }\n\n}\n\nfunction extendEvent(event) {\n if (\"immediatePropagationStopped\" in event) {\n return event;\n } else {\n const stopImmediatePropagation = event.stopImmediatePropagation;\n return Object.assign(event, {\n immediatePropagationStopped: false,\n\n stopImmediatePropagation() {\n this.immediatePropagationStopped = true;\n stopImmediatePropagation.call(this);\n }\n\n });\n }\n}\n\nclass Dispatcher {\n constructor(application) {\n this.application = application;\n this.eventListenerMaps = new Map();\n this.started = false;\n }\n\n start() {\n if (!this.started) {\n this.started = true;\n this.eventListeners.forEach(eventListener => eventListener.connect());\n }\n }\n\n stop() {\n if (this.started) {\n this.started = false;\n this.eventListeners.forEach(eventListener => eventListener.disconnect());\n }\n }\n\n get eventListeners() {\n return Array.from(this.eventListenerMaps.values()).reduce((listeners, map) => listeners.concat(Array.from(map.values())), []);\n }\n\n bindingConnected(binding) {\n this.fetchEventListenerForBinding(binding).bindingConnected(binding);\n }\n\n bindingDisconnected(binding) {\n let clearEventListeners = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n this.fetchEventListenerForBinding(binding).bindingDisconnected(binding);\n if (clearEventListeners) this.clearEventListenersForBinding(binding);\n }\n\n handleError(error, message) {\n let detail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n this.application.handleError(error, \"Error \".concat(message), detail);\n }\n\n clearEventListenersForBinding(binding) {\n const eventListener = this.fetchEventListenerForBinding(binding);\n\n if (!eventListener.hasBindings()) {\n eventListener.disconnect();\n this.removeMappedEventListenerFor(binding);\n }\n }\n\n removeMappedEventListenerFor(binding) {\n const eventTarget = binding.eventTarget,\n eventName = binding.eventName,\n eventOptions = binding.eventOptions;\n const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);\n const cacheKey = this.cacheKey(eventName, eventOptions);\n eventListenerMap.delete(cacheKey);\n if (eventListenerMap.size == 0) this.eventListenerMaps.delete(eventTarget);\n }\n\n fetchEventListenerForBinding(binding) {\n const eventTarget = binding.eventTarget,\n eventName = binding.eventName,\n eventOptions = binding.eventOptions;\n return this.fetchEventListener(eventTarget, eventName, eventOptions);\n }\n\n fetchEventListener(eventTarget, eventName, eventOptions) {\n const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);\n const cacheKey = this.cacheKey(eventName, eventOptions);\n let eventListener = eventListenerMap.get(cacheKey);\n\n if (!eventListener) {\n eventListener = this.createEventListener(eventTarget, eventName, eventOptions);\n eventListenerMap.set(cacheKey, eventListener);\n }\n\n return eventListener;\n }\n\n createEventListener(eventTarget, eventName, eventOptions) {\n const eventListener = new EventListener(eventTarget, eventName, eventOptions);\n\n if (this.started) {\n eventListener.connect();\n }\n\n return eventListener;\n }\n\n fetchEventListenerMapForEventTarget(eventTarget) {\n let eventListenerMap = this.eventListenerMaps.get(eventTarget);\n\n if (!eventListenerMap) {\n eventListenerMap = new Map();\n this.eventListenerMaps.set(eventTarget, eventListenerMap);\n }\n\n return eventListenerMap;\n }\n\n cacheKey(eventName, eventOptions) {\n const parts = [eventName];\n Object.keys(eventOptions).sort().forEach(key => {\n parts.push(\"\".concat(eventOptions[key] ? \"\" : \"!\").concat(key));\n });\n return parts.join(\":\");\n }\n\n}\n\nconst defaultActionDescriptorFilters = {\n stop(_ref) {\n let event = _ref.event,\n value = _ref.value;\n if (value) event.stopPropagation();\n return true;\n },\n\n prevent(_ref2) {\n let event = _ref2.event,\n value = _ref2.value;\n if (value) event.preventDefault();\n return true;\n },\n\n self(_ref3) {\n let event = _ref3.event,\n value = _ref3.value,\n element = _ref3.element;\n\n if (value) {\n return element === event.target;\n } else {\n return true;\n }\n }\n\n};\nconst descriptorPattern = /^(?:(?:([^.]+?)\\+)?(.+?)(?:\\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;\n\nfunction parseActionDescriptorString(descriptorString) {\n const source = descriptorString.trim();\n const matches = source.match(descriptorPattern) || [];\n let eventName = matches[2];\n let keyFilter = matches[3];\n\n if (keyFilter && ![\"keydown\", \"keyup\", \"keypress\"].includes(eventName)) {\n eventName += \".\".concat(keyFilter);\n keyFilter = \"\";\n }\n\n return {\n eventTarget: parseEventTarget(matches[4]),\n eventName,\n eventOptions: matches[7] ? parseEventOptions(matches[7]) : {},\n identifier: matches[5],\n methodName: matches[6],\n keyFilter: matches[1] || keyFilter\n };\n}\n\nfunction parseEventTarget(eventTargetName) {\n if (eventTargetName == \"window\") {\n return window;\n } else if (eventTargetName == \"document\") {\n return document;\n }\n}\n\nfunction parseEventOptions(eventOptions) {\n return eventOptions.split(\":\").reduce((options, token) => Object.assign(options, {\n [token.replace(/^!/, \"\")]: !/^!/.test(token)\n }), {});\n}\n\nfunction stringifyEventTarget(eventTarget) {\n if (eventTarget == window) {\n return \"window\";\n } else if (eventTarget == document) {\n return \"document\";\n }\n}\n\nfunction camelize(value) {\n return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase());\n}\n\nfunction namespaceCamelize(value) {\n return camelize(value.replace(/--/g, \"-\").replace(/__/g, \"_\"));\n}\n\nfunction capitalize(value) {\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\n\nfunction dasherize(value) {\n return value.replace(/([A-Z])/g, (_, char) => \"-\".concat(char.toLowerCase()));\n}\n\nfunction tokenize(value) {\n return value.match(/[^\\s]+/g) || [];\n}\n\nfunction isSomething(object) {\n return object !== null && object !== undefined;\n}\n\nfunction hasProperty(object, property) {\n return Object.prototype.hasOwnProperty.call(object, property);\n}\n\nconst allModifiers = [\"meta\", \"ctrl\", \"alt\", \"shift\"];\n\nclass Action {\n constructor(element, index, descriptor, schema) {\n this.element = element;\n this.index = index;\n this.eventTarget = descriptor.eventTarget || element;\n this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error(\"missing event name\");\n this.eventOptions = descriptor.eventOptions || {};\n this.identifier = descriptor.identifier || error(\"missing identifier\");\n this.methodName = descriptor.methodName || error(\"missing method name\");\n this.keyFilter = descriptor.keyFilter || \"\";\n this.schema = schema;\n }\n\n static forToken(token, schema) {\n return new this(token.element, token.index, parseActionDescriptorString(token.content), schema);\n }\n\n toString() {\n const eventFilter = this.keyFilter ? \".\".concat(this.keyFilter) : \"\";\n const eventTarget = this.eventTargetName ? \"@\".concat(this.eventTargetName) : \"\";\n return \"\".concat(this.eventName).concat(eventFilter).concat(eventTarget, \"->\").concat(this.identifier, \"#\").concat(this.methodName);\n }\n\n shouldIgnoreKeyboardEvent(event) {\n if (!this.keyFilter) {\n return false;\n }\n\n const filters = this.keyFilter.split(\"+\");\n\n if (this.keyFilterDissatisfied(event, filters)) {\n return true;\n }\n\n const standardFilter = filters.filter(key => !allModifiers.includes(key))[0];\n\n if (!standardFilter) {\n return false;\n }\n\n if (!hasProperty(this.keyMappings, standardFilter)) {\n error(\"contains unknown key filter: \".concat(this.keyFilter));\n }\n\n return this.keyMappings[standardFilter].toLowerCase() !== event.key.toLowerCase();\n }\n\n shouldIgnoreMouseEvent(event) {\n if (!this.keyFilter) {\n return false;\n }\n\n const filters = [this.keyFilter];\n\n if (this.keyFilterDissatisfied(event, filters)) {\n return true;\n }\n\n return false;\n }\n\n get params() {\n const params = {};\n const pattern = new RegExp(\"^data-\".concat(this.identifier, \"-(.+)-param$\"), \"i\");\n\n for (const _ref4 of Array.from(this.element.attributes)) {\n const name = _ref4.name;\n const value = _ref4.value;\n const match = name.match(pattern);\n const key = match && match[1];\n\n if (key) {\n params[camelize(key)] = typecast(value);\n }\n }\n\n return params;\n }\n\n get eventTargetName() {\n return stringifyEventTarget(this.eventTarget);\n }\n\n get keyMappings() {\n return this.schema.keyMappings;\n }\n\n keyFilterDissatisfied(event, filters) {\n const _allModifiers$map = allModifiers.map(modifier => filters.includes(modifier)),\n _allModifiers$map2 = _slicedToArray(_allModifiers$map, 4),\n meta = _allModifiers$map2[0],\n ctrl = _allModifiers$map2[1],\n alt = _allModifiers$map2[2],\n shift = _allModifiers$map2[3];\n\n return event.metaKey !== meta || event.ctrlKey !== ctrl || event.altKey !== alt || event.shiftKey !== shift;\n }\n\n}\n\nconst defaultEventNames = {\n a: () => \"click\",\n button: () => \"click\",\n form: () => \"submit\",\n details: () => \"toggle\",\n input: e => e.getAttribute(\"type\") == \"submit\" ? \"click\" : \"input\",\n select: () => \"change\",\n textarea: () => \"input\"\n};\n\nfunction getDefaultEventNameForElement(element) {\n const tagName = element.tagName.toLowerCase();\n\n if (tagName in defaultEventNames) {\n return defaultEventNames[tagName](element);\n }\n}\n\nfunction error(message) {\n throw new Error(message);\n}\n\nfunction typecast(value) {\n try {\n return JSON.parse(value);\n } catch (o_O) {\n return value;\n }\n}\n\nclass Binding {\n constructor(context, action) {\n this.context = context;\n this.action = action;\n }\n\n get index() {\n return this.action.index;\n }\n\n get eventTarget() {\n return this.action.eventTarget;\n }\n\n get eventOptions() {\n return this.action.eventOptions;\n }\n\n get identifier() {\n return this.context.identifier;\n }\n\n handleEvent(event) {\n const actionEvent = this.prepareActionEvent(event);\n\n if (this.willBeInvokedByEvent(event) && this.applyEventModifiers(actionEvent)) {\n this.invokeWithEvent(actionEvent);\n }\n }\n\n get eventName() {\n return this.action.eventName;\n }\n\n get method() {\n const method = this.controller[this.methodName];\n\n if (typeof method == \"function\") {\n return method;\n }\n\n throw new Error(\"Action \\\"\".concat(this.action, \"\\\" references undefined method \\\"\").concat(this.methodName, \"\\\"\"));\n }\n\n applyEventModifiers(event) {\n const element = this.action.element;\n const actionDescriptorFilters = this.context.application.actionDescriptorFilters;\n const controller = this.context.controller;\n let passes = true;\n\n for (const _ref5 of Object.entries(this.eventOptions)) {\n var _ref6 = _slicedToArray(_ref5, 2);\n\n const name = _ref6[0];\n const value = _ref6[1];\n\n if (name in actionDescriptorFilters) {\n const filter = actionDescriptorFilters[name];\n passes = passes && filter({\n name,\n value,\n event,\n element,\n controller\n });\n } else {\n continue;\n }\n }\n\n return passes;\n }\n\n prepareActionEvent(event) {\n return Object.assign(event, {\n params: this.action.params\n });\n }\n\n invokeWithEvent(event) {\n const target = event.target,\n currentTarget = event.currentTarget;\n\n try {\n this.method.call(this.controller, event);\n this.context.logDebugActivity(this.methodName, {\n event,\n target,\n currentTarget,\n action: this.methodName\n });\n } catch (error) {\n const identifier = this.identifier,\n controller = this.controller,\n element = this.element,\n index = this.index;\n const detail = {\n identifier,\n controller,\n element,\n index,\n event\n };\n this.context.handleError(error, \"invoking action \\\"\".concat(this.action, \"\\\"\"), detail);\n }\n }\n\n willBeInvokedByEvent(event) {\n const eventTarget = event.target;\n\n if (event instanceof KeyboardEvent && this.action.shouldIgnoreKeyboardEvent(event)) {\n return false;\n }\n\n if (event instanceof MouseEvent && this.action.shouldIgnoreMouseEvent(event)) {\n return false;\n }\n\n if (this.element === eventTarget) {\n return true;\n } else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {\n return this.scope.containsElement(eventTarget);\n } else {\n return this.scope.containsElement(this.action.element);\n }\n }\n\n get controller() {\n return this.context.controller;\n }\n\n get methodName() {\n return this.action.methodName;\n }\n\n get element() {\n return this.scope.element;\n }\n\n get scope() {\n return this.context.scope;\n }\n\n}\n\nclass ElementObserver {\n constructor(element, delegate) {\n this.mutationObserverInit = {\n attributes: true,\n childList: true,\n subtree: true\n };\n this.element = element;\n this.started = false;\n this.delegate = delegate;\n this.elements = new Set();\n this.mutationObserver = new MutationObserver(mutations => this.processMutations(mutations));\n }\n\n start() {\n if (!this.started) {\n this.started = true;\n this.mutationObserver.observe(this.element, this.mutationObserverInit);\n this.refresh();\n }\n }\n\n pause(callback) {\n if (this.started) {\n this.mutationObserver.disconnect();\n this.started = false;\n }\n\n callback();\n\n if (!this.started) {\n this.mutationObserver.observe(this.element, this.mutationObserverInit);\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n this.mutationObserver.takeRecords();\n this.mutationObserver.disconnect();\n this.started = false;\n }\n }\n\n refresh() {\n if (this.started) {\n const matches = new Set(this.matchElementsInTree());\n\n for (const element of Array.from(this.elements)) {\n if (!matches.has(element)) {\n this.removeElement(element);\n }\n }\n\n for (const element of Array.from(matches)) {\n this.addElement(element);\n }\n }\n }\n\n processMutations(mutations) {\n if (this.started) {\n for (const mutation of mutations) {\n this.processMutation(mutation);\n }\n }\n }\n\n processMutation(mutation) {\n if (mutation.type == \"attributes\") {\n this.processAttributeChange(mutation.target, mutation.attributeName);\n } else if (mutation.type == \"childList\") {\n this.processRemovedNodes(mutation.removedNodes);\n this.processAddedNodes(mutation.addedNodes);\n }\n }\n\n processAttributeChange(element, attributeName) {\n if (this.elements.has(element)) {\n if (this.delegate.elementAttributeChanged && this.matchElement(element)) {\n this.delegate.elementAttributeChanged(element, attributeName);\n } else {\n this.removeElement(element);\n }\n } else if (this.matchElement(element)) {\n this.addElement(element);\n }\n }\n\n processRemovedNodes(nodes) {\n for (const node of Array.from(nodes)) {\n const element = this.elementFromNode(node);\n\n if (element) {\n this.processTree(element, this.removeElement);\n }\n }\n }\n\n processAddedNodes(nodes) {\n for (const node of Array.from(nodes)) {\n const element = this.elementFromNode(node);\n\n if (element && this.elementIsActive(element)) {\n this.processTree(element, this.addElement);\n }\n }\n }\n\n matchElement(element) {\n return this.delegate.matchElement(element);\n }\n\n matchElementsInTree() {\n let tree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.element;\n return this.delegate.matchElementsInTree(tree);\n }\n\n processTree(tree, processor) {\n for (const element of this.matchElementsInTree(tree)) {\n processor.call(this, element);\n }\n }\n\n elementFromNode(node) {\n if (node.nodeType == Node.ELEMENT_NODE) {\n return node;\n }\n }\n\n elementIsActive(element) {\n if (element.isConnected != this.element.isConnected) {\n return false;\n } else {\n return this.element.contains(element);\n }\n }\n\n addElement(element) {\n if (!this.elements.has(element)) {\n if (this.elementIsActive(element)) {\n this.elements.add(element);\n\n if (this.delegate.elementMatched) {\n this.delegate.elementMatched(element);\n }\n }\n }\n }\n\n removeElement(element) {\n if (this.elements.has(element)) {\n this.elements.delete(element);\n\n if (this.delegate.elementUnmatched) {\n this.delegate.elementUnmatched(element);\n }\n }\n }\n\n}\n\nclass AttributeObserver {\n constructor(element, attributeName, delegate) {\n this.attributeName = attributeName;\n this.delegate = delegate;\n this.elementObserver = new ElementObserver(element, this);\n }\n\n get element() {\n return this.elementObserver.element;\n }\n\n get selector() {\n return \"[\".concat(this.attributeName, \"]\");\n }\n\n start() {\n this.elementObserver.start();\n }\n\n pause(callback) {\n this.elementObserver.pause(callback);\n }\n\n stop() {\n this.elementObserver.stop();\n }\n\n refresh() {\n this.elementObserver.refresh();\n }\n\n get started() {\n return this.elementObserver.started;\n }\n\n matchElement(element) {\n return element.hasAttribute(this.attributeName);\n }\n\n matchElementsInTree(tree) {\n const match = this.matchElement(tree) ? [tree] : [];\n const matches = Array.from(tree.querySelectorAll(this.selector));\n return match.concat(matches);\n }\n\n elementMatched(element) {\n if (this.delegate.elementMatchedAttribute) {\n this.delegate.elementMatchedAttribute(element, this.attributeName);\n }\n }\n\n elementUnmatched(element) {\n if (this.delegate.elementUnmatchedAttribute) {\n this.delegate.elementUnmatchedAttribute(element, this.attributeName);\n }\n }\n\n elementAttributeChanged(element, attributeName) {\n if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) {\n this.delegate.elementAttributeValueChanged(element, attributeName);\n }\n }\n\n}\n\nfunction add(map, key, value) {\n fetch(map, key).add(value);\n}\n\nfunction del(map, key, value) {\n fetch(map, key).delete(value);\n prune(map, key);\n}\n\nfunction fetch(map, key) {\n let values = map.get(key);\n\n if (!values) {\n values = new Set();\n map.set(key, values);\n }\n\n return values;\n}\n\nfunction prune(map, key) {\n const values = map.get(key);\n\n if (values != null && values.size == 0) {\n map.delete(key);\n }\n}\n\nclass Multimap {\n constructor() {\n this.valuesByKey = new Map();\n }\n\n get keys() {\n return Array.from(this.valuesByKey.keys());\n }\n\n get values() {\n const sets = Array.from(this.valuesByKey.values());\n return sets.reduce((values, set) => values.concat(Array.from(set)), []);\n }\n\n get size() {\n const sets = Array.from(this.valuesByKey.values());\n return sets.reduce((size, set) => size + set.size, 0);\n }\n\n add(key, value) {\n add(this.valuesByKey, key, value);\n }\n\n delete(key, value) {\n del(this.valuesByKey, key, value);\n }\n\n has(key, value) {\n const values = this.valuesByKey.get(key);\n return values != null && values.has(value);\n }\n\n hasKey(key) {\n return this.valuesByKey.has(key);\n }\n\n hasValue(value) {\n const sets = Array.from(this.valuesByKey.values());\n return sets.some(set => set.has(value));\n }\n\n getValuesForKey(key) {\n const values = this.valuesByKey.get(key);\n return values ? Array.from(values) : [];\n }\n\n getKeysForValue(value) {\n return Array.from(this.valuesByKey).filter(_ref7 => {\n let _ref8 = _slicedToArray(_ref7, 2),\n _key = _ref8[0],\n values = _ref8[1];\n\n return values.has(value);\n }).map(_ref9 => {\n let _ref10 = _slicedToArray(_ref9, 2),\n key = _ref10[0],\n _values = _ref10[1];\n\n return key;\n });\n }\n\n}\n\nclass IndexedMultimap extends Multimap {\n constructor() {\n super();\n this.keysByValue = new Map();\n }\n\n get values() {\n return Array.from(this.keysByValue.keys());\n }\n\n add(key, value) {\n super.add(key, value);\n add(this.keysByValue, value, key);\n }\n\n delete(key, value) {\n super.delete(key, value);\n del(this.keysByValue, value, key);\n }\n\n hasValue(value) {\n return this.keysByValue.has(value);\n }\n\n getKeysForValue(value) {\n const set = this.keysByValue.get(value);\n return set ? Array.from(set) : [];\n }\n\n}\n\nclass SelectorObserver {\n constructor(element, selector, delegate, details) {\n this._selector = selector;\n this.details = details;\n this.elementObserver = new ElementObserver(element, this);\n this.delegate = delegate;\n this.matchesByElement = new Multimap();\n }\n\n get started() {\n return this.elementObserver.started;\n }\n\n get selector() {\n return this._selector;\n }\n\n set selector(selector) {\n this._selector = selector;\n this.refresh();\n }\n\n start() {\n this.elementObserver.start();\n }\n\n pause(callback) {\n this.elementObserver.pause(callback);\n }\n\n stop() {\n this.elementObserver.stop();\n }\n\n refresh() {\n this.elementObserver.refresh();\n }\n\n get element() {\n return this.elementObserver.element;\n }\n\n matchElement(element) {\n const selector = this.selector;\n\n if (selector) {\n const matches = element.matches(selector);\n\n if (this.delegate.selectorMatchElement) {\n return matches && this.delegate.selectorMatchElement(element, this.details);\n }\n\n return matches;\n } else {\n return false;\n }\n }\n\n matchElementsInTree(tree) {\n const selector = this.selector;\n\n if (selector) {\n const match = this.matchElement(tree) ? [tree] : [];\n const matches = Array.from(tree.querySelectorAll(selector)).filter(match => this.matchElement(match));\n return match.concat(matches);\n } else {\n return [];\n }\n }\n\n elementMatched(element) {\n const selector = this.selector;\n\n if (selector) {\n this.selectorMatched(element, selector);\n }\n }\n\n elementUnmatched(element) {\n const selectors = this.matchesByElement.getKeysForValue(element);\n\n for (const selector of selectors) {\n this.selectorUnmatched(element, selector);\n }\n }\n\n elementAttributeChanged(element, _attributeName) {\n const selector = this.selector;\n\n if (selector) {\n const matches = this.matchElement(element);\n const matchedBefore = this.matchesByElement.has(selector, element);\n\n if (matches && !matchedBefore) {\n this.selectorMatched(element, selector);\n } else if (!matches && matchedBefore) {\n this.selectorUnmatched(element, selector);\n }\n }\n }\n\n selectorMatched(element, selector) {\n this.delegate.selectorMatched(element, selector, this.details);\n this.matchesByElement.add(selector, element);\n }\n\n selectorUnmatched(element, selector) {\n this.delegate.selectorUnmatched(element, selector, this.details);\n this.matchesByElement.delete(selector, element);\n }\n\n}\n\nclass StringMapObserver {\n constructor(element, delegate) {\n this.element = element;\n this.delegate = delegate;\n this.started = false;\n this.stringMap = new Map();\n this.mutationObserver = new MutationObserver(mutations => this.processMutations(mutations));\n }\n\n start() {\n if (!this.started) {\n this.started = true;\n this.mutationObserver.observe(this.element, {\n attributes: true,\n attributeOldValue: true\n });\n this.refresh();\n }\n }\n\n stop() {\n if (this.started) {\n this.mutationObserver.takeRecords();\n this.mutationObserver.disconnect();\n this.started = false;\n }\n }\n\n refresh() {\n if (this.started) {\n for (const attributeName of this.knownAttributeNames) {\n this.refreshAttribute(attributeName, null);\n }\n }\n }\n\n processMutations(mutations) {\n if (this.started) {\n for (const mutation of mutations) {\n this.processMutation(mutation);\n }\n }\n }\n\n processMutation(mutation) {\n const attributeName = mutation.attributeName;\n\n if (attributeName) {\n this.refreshAttribute(attributeName, mutation.oldValue);\n }\n }\n\n refreshAttribute(attributeName, oldValue) {\n const key = this.delegate.getStringMapKeyForAttribute(attributeName);\n\n if (key != null) {\n if (!this.stringMap.has(attributeName)) {\n this.stringMapKeyAdded(key, attributeName);\n }\n\n const value = this.element.getAttribute(attributeName);\n\n if (this.stringMap.get(attributeName) != value) {\n this.stringMapValueChanged(value, key, oldValue);\n }\n\n if (value == null) {\n const oldValue = this.stringMap.get(attributeName);\n this.stringMap.delete(attributeName);\n if (oldValue) this.stringMapKeyRemoved(key, attributeName, oldValue);\n } else {\n this.stringMap.set(attributeName, value);\n }\n }\n }\n\n stringMapKeyAdded(key, attributeName) {\n if (this.delegate.stringMapKeyAdded) {\n this.delegate.stringMapKeyAdded(key, attributeName);\n }\n }\n\n stringMapValueChanged(value, key, oldValue) {\n if (this.delegate.stringMapValueChanged) {\n this.delegate.stringMapValueChanged(value, key, oldValue);\n }\n }\n\n stringMapKeyRemoved(key, attributeName, oldValue) {\n if (this.delegate.stringMapKeyRemoved) {\n this.delegate.stringMapKeyRemoved(key, attributeName, oldValue);\n }\n }\n\n get knownAttributeNames() {\n return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)));\n }\n\n get currentAttributeNames() {\n return Array.from(this.element.attributes).map(attribute => attribute.name);\n }\n\n get recordedAttributeNames() {\n return Array.from(this.stringMap.keys());\n }\n\n}\n\nclass TokenListObserver {\n constructor(element, attributeName, delegate) {\n this.attributeObserver = new AttributeObserver(element, attributeName, this);\n this.delegate = delegate;\n this.tokensByElement = new Multimap();\n }\n\n get started() {\n return this.attributeObserver.started;\n }\n\n start() {\n this.attributeObserver.start();\n }\n\n pause(callback) {\n this.attributeObserver.pause(callback);\n }\n\n stop() {\n this.attributeObserver.stop();\n }\n\n refresh() {\n this.attributeObserver.refresh();\n }\n\n get element() {\n return this.attributeObserver.element;\n }\n\n get attributeName() {\n return this.attributeObserver.attributeName;\n }\n\n elementMatchedAttribute(element) {\n this.tokensMatched(this.readTokensForElement(element));\n }\n\n elementAttributeValueChanged(element) {\n const _this$refreshTokensFo = this.refreshTokensForElement(element),\n _this$refreshTokensFo2 = _slicedToArray(_this$refreshTokensFo, 2),\n unmatchedTokens = _this$refreshTokensFo2[0],\n matchedTokens = _this$refreshTokensFo2[1];\n\n this.tokensUnmatched(unmatchedTokens);\n this.tokensMatched(matchedTokens);\n }\n\n elementUnmatchedAttribute(element) {\n this.tokensUnmatched(this.tokensByElement.getValuesForKey(element));\n }\n\n tokensMatched(tokens) {\n tokens.forEach(token => this.tokenMatched(token));\n }\n\n tokensUnmatched(tokens) {\n tokens.forEach(token => this.tokenUnmatched(token));\n }\n\n tokenMatched(token) {\n this.delegate.tokenMatched(token);\n this.tokensByElement.add(token.element, token);\n }\n\n tokenUnmatched(token) {\n this.delegate.tokenUnmatched(token);\n this.tokensByElement.delete(token.element, token);\n }\n\n refreshTokensForElement(element) {\n const previousTokens = this.tokensByElement.getValuesForKey(element);\n const currentTokens = this.readTokensForElement(element);\n const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(_ref11 => {\n let _ref12 = _slicedToArray(_ref11, 2),\n previousToken = _ref12[0],\n currentToken = _ref12[1];\n\n return !tokensAreEqual(previousToken, currentToken);\n });\n\n if (firstDifferingIndex == -1) {\n return [[], []];\n } else {\n return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)];\n }\n }\n\n readTokensForElement(element) {\n const attributeName = this.attributeName;\n const tokenString = element.getAttribute(attributeName) || \"\";\n return parseTokenString(tokenString, element, attributeName);\n }\n\n}\n\nfunction parseTokenString(tokenString, element, attributeName) {\n return tokenString.trim().split(/\\s+/).filter(content => content.length).map((content, index) => ({\n element,\n attributeName,\n content,\n index\n }));\n}\n\nfunction zip(left, right) {\n const length = Math.max(left.length, right.length);\n return Array.from({\n length\n }, (_, index) => [left[index], right[index]]);\n}\n\nfunction tokensAreEqual(left, right) {\n return left && right && left.index == right.index && left.content == right.content;\n}\n\nclass ValueListObserver {\n constructor(element, attributeName, delegate) {\n this.tokenListObserver = new TokenListObserver(element, attributeName, this);\n this.delegate = delegate;\n this.parseResultsByToken = new WeakMap();\n this.valuesByTokenByElement = new WeakMap();\n }\n\n get started() {\n return this.tokenListObserver.started;\n }\n\n start() {\n this.tokenListObserver.start();\n }\n\n stop() {\n this.tokenListObserver.stop();\n }\n\n refresh() {\n this.tokenListObserver.refresh();\n }\n\n get element() {\n return this.tokenListObserver.element;\n }\n\n get attributeName() {\n return this.tokenListObserver.attributeName;\n }\n\n tokenMatched(token) {\n const element = token.element;\n\n const _this$fetchParseResul = this.fetchParseResultForToken(token),\n value = _this$fetchParseResul.value;\n\n if (value) {\n this.fetchValuesByTokenForElement(element).set(token, value);\n this.delegate.elementMatchedValue(element, value);\n }\n }\n\n tokenUnmatched(token) {\n const element = token.element;\n\n const _this$fetchParseResul2 = this.fetchParseResultForToken(token),\n value = _this$fetchParseResul2.value;\n\n if (value) {\n this.fetchValuesByTokenForElement(element).delete(token);\n this.delegate.elementUnmatchedValue(element, value);\n }\n }\n\n fetchParseResultForToken(token) {\n let parseResult = this.parseResultsByToken.get(token);\n\n if (!parseResult) {\n parseResult = this.parseToken(token);\n this.parseResultsByToken.set(token, parseResult);\n }\n\n return parseResult;\n }\n\n fetchValuesByTokenForElement(element) {\n let valuesByToken = this.valuesByTokenByElement.get(element);\n\n if (!valuesByToken) {\n valuesByToken = new Map();\n this.valuesByTokenByElement.set(element, valuesByToken);\n }\n\n return valuesByToken;\n }\n\n parseToken(token) {\n try {\n const value = this.delegate.parseValueForToken(token);\n return {\n value\n };\n } catch (error) {\n return {\n error\n };\n }\n }\n\n}\n\nclass BindingObserver {\n constructor(context, delegate) {\n this.context = context;\n this.delegate = delegate;\n this.bindingsByAction = new Map();\n }\n\n start() {\n if (!this.valueListObserver) {\n this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this);\n this.valueListObserver.start();\n }\n }\n\n stop() {\n if (this.valueListObserver) {\n this.valueListObserver.stop();\n delete this.valueListObserver;\n this.disconnectAllActions();\n }\n }\n\n get element() {\n return this.context.element;\n }\n\n get identifier() {\n return this.context.identifier;\n }\n\n get actionAttribute() {\n return this.schema.actionAttribute;\n }\n\n get schema() {\n return this.context.schema;\n }\n\n get bindings() {\n return Array.from(this.bindingsByAction.values());\n }\n\n connectAction(action) {\n const binding = new Binding(this.context, action);\n this.bindingsByAction.set(action, binding);\n this.delegate.bindingConnected(binding);\n }\n\n disconnectAction(action) {\n const binding = this.bindingsByAction.get(action);\n\n if (binding) {\n this.bindingsByAction.delete(action);\n this.delegate.bindingDisconnected(binding);\n }\n }\n\n disconnectAllActions() {\n this.bindings.forEach(binding => this.delegate.bindingDisconnected(binding, true));\n this.bindingsByAction.clear();\n }\n\n parseValueForToken(token) {\n const action = Action.forToken(token, this.schema);\n\n if (action.identifier == this.identifier) {\n return action;\n }\n }\n\n elementMatchedValue(element, action) {\n this.connectAction(action);\n }\n\n elementUnmatchedValue(element, action) {\n this.disconnectAction(action);\n }\n\n}\n\nclass ValueObserver {\n constructor(context, receiver) {\n this.context = context;\n this.receiver = receiver;\n this.stringMapObserver = new StringMapObserver(this.element, this);\n this.valueDescriptorMap = this.controller.valueDescriptorMap;\n }\n\n start() {\n this.stringMapObserver.start();\n this.invokeChangedCallbacksForDefaultValues();\n }\n\n stop() {\n this.stringMapObserver.stop();\n }\n\n get element() {\n return this.context.element;\n }\n\n get controller() {\n return this.context.controller;\n }\n\n getStringMapKeyForAttribute(attributeName) {\n if (attributeName in this.valueDescriptorMap) {\n return this.valueDescriptorMap[attributeName].name;\n }\n }\n\n stringMapKeyAdded(key, attributeName) {\n const descriptor = this.valueDescriptorMap[attributeName];\n\n if (!this.hasValue(key)) {\n this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue));\n }\n }\n\n stringMapValueChanged(value, name, oldValue) {\n const descriptor = this.valueDescriptorNameMap[name];\n if (value === null) return;\n\n if (oldValue === null) {\n oldValue = descriptor.writer(descriptor.defaultValue);\n }\n\n this.invokeChangedCallback(name, value, oldValue);\n }\n\n stringMapKeyRemoved(key, attributeName, oldValue) {\n const descriptor = this.valueDescriptorNameMap[key];\n\n if (this.hasValue(key)) {\n this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue);\n } else {\n this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue);\n }\n }\n\n invokeChangedCallbacksForDefaultValues() {\n for (const _ref13 of this.valueDescriptors) {\n const key = _ref13.key;\n const name = _ref13.name;\n const defaultValue = _ref13.defaultValue;\n const writer = _ref13.writer;\n\n if (defaultValue != undefined && !this.controller.data.has(key)) {\n this.invokeChangedCallback(name, writer(defaultValue), undefined);\n }\n }\n }\n\n invokeChangedCallback(name, rawValue, rawOldValue) {\n const changedMethodName = \"\".concat(name, \"Changed\");\n const changedMethod = this.receiver[changedMethodName];\n\n if (typeof changedMethod == \"function\") {\n const descriptor = this.valueDescriptorNameMap[name];\n\n try {\n const value = descriptor.reader(rawValue);\n let oldValue = rawOldValue;\n\n if (rawOldValue) {\n oldValue = descriptor.reader(rawOldValue);\n }\n\n changedMethod.call(this.receiver, value, oldValue);\n } catch (error) {\n if (error instanceof TypeError) {\n error.message = \"Stimulus Value \\\"\".concat(this.context.identifier, \".\").concat(descriptor.name, \"\\\" - \").concat(error.message);\n }\n\n throw error;\n }\n }\n }\n\n get valueDescriptors() {\n const valueDescriptorMap = this.valueDescriptorMap;\n return Object.keys(valueDescriptorMap).map(key => valueDescriptorMap[key]);\n }\n\n get valueDescriptorNameMap() {\n const descriptors = {};\n Object.keys(this.valueDescriptorMap).forEach(key => {\n const descriptor = this.valueDescriptorMap[key];\n descriptors[descriptor.name] = descriptor;\n });\n return descriptors;\n }\n\n hasValue(attributeName) {\n const descriptor = this.valueDescriptorNameMap[attributeName];\n const hasMethodName = \"has\".concat(capitalize(descriptor.name));\n return this.receiver[hasMethodName];\n }\n\n}\n\nclass TargetObserver {\n constructor(context, delegate) {\n this.context = context;\n this.delegate = delegate;\n this.targetsByName = new Multimap();\n }\n\n start() {\n if (!this.tokenListObserver) {\n this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this);\n this.tokenListObserver.start();\n }\n }\n\n stop() {\n if (this.tokenListObserver) {\n this.disconnectAllTargets();\n this.tokenListObserver.stop();\n delete this.tokenListObserver;\n }\n }\n\n tokenMatched(_ref14) {\n let element = _ref14.element,\n name = _ref14.content;\n\n if (this.scope.containsElement(element)) {\n this.connectTarget(element, name);\n }\n }\n\n tokenUnmatched(_ref15) {\n let element = _ref15.element,\n name = _ref15.content;\n this.disconnectTarget(element, name);\n }\n\n connectTarget(element, name) {\n var _a;\n\n if (!this.targetsByName.has(name, element)) {\n this.targetsByName.add(name, element);\n (_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetConnected(element, name));\n }\n }\n\n disconnectTarget(element, name) {\n var _a;\n\n if (this.targetsByName.has(name, element)) {\n this.targetsByName.delete(name, element);\n (_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetDisconnected(element, name));\n }\n }\n\n disconnectAllTargets() {\n for (const name of this.targetsByName.keys) {\n for (const element of this.targetsByName.getValuesForKey(name)) {\n this.disconnectTarget(element, name);\n }\n }\n }\n\n get attributeName() {\n return \"data-\".concat(this.context.identifier, \"-target\");\n }\n\n get element() {\n return this.context.element;\n }\n\n get scope() {\n return this.context.scope;\n }\n\n}\n\nfunction readInheritableStaticArrayValues(constructor, propertyName) {\n const ancestors = getAncestorsForConstructor(constructor);\n return Array.from(ancestors.reduce((values, constructor) => {\n getOwnStaticArrayValues(constructor, propertyName).forEach(name => values.add(name));\n return values;\n }, new Set()));\n}\n\nfunction readInheritableStaticObjectPairs(constructor, propertyName) {\n const ancestors = getAncestorsForConstructor(constructor);\n return ancestors.reduce((pairs, constructor) => {\n pairs.push(...getOwnStaticObjectPairs(constructor, propertyName));\n return pairs;\n }, []);\n}\n\nfunction getAncestorsForConstructor(constructor) {\n const ancestors = [];\n\n while (constructor) {\n ancestors.push(constructor);\n constructor = Object.getPrototypeOf(constructor);\n }\n\n return ancestors.reverse();\n}\n\nfunction getOwnStaticArrayValues(constructor, propertyName) {\n const definition = constructor[propertyName];\n return Array.isArray(definition) ? definition : [];\n}\n\nfunction getOwnStaticObjectPairs(constructor, propertyName) {\n const definition = constructor[propertyName];\n return definition ? Object.keys(definition).map(key => [key, definition[key]]) : [];\n}\n\nclass OutletObserver {\n constructor(context, delegate) {\n this.started = false;\n this.context = context;\n this.delegate = delegate;\n this.outletsByName = new Multimap();\n this.outletElementsByName = new Multimap();\n this.selectorObserverMap = new Map();\n this.attributeObserverMap = new Map();\n }\n\n start() {\n if (!this.started) {\n this.outletDefinitions.forEach(outletName => {\n this.setupSelectorObserverForOutlet(outletName);\n this.setupAttributeObserverForOutlet(outletName);\n });\n this.started = true;\n this.dependentContexts.forEach(context => context.refresh());\n }\n }\n\n refresh() {\n this.selectorObserverMap.forEach(observer => observer.refresh());\n this.attributeObserverMap.forEach(observer => observer.refresh());\n }\n\n stop() {\n if (this.started) {\n this.started = false;\n this.disconnectAllOutlets();\n this.stopSelectorObservers();\n this.stopAttributeObservers();\n }\n }\n\n stopSelectorObservers() {\n if (this.selectorObserverMap.size > 0) {\n this.selectorObserverMap.forEach(observer => observer.stop());\n this.selectorObserverMap.clear();\n }\n }\n\n stopAttributeObservers() {\n if (this.attributeObserverMap.size > 0) {\n this.attributeObserverMap.forEach(observer => observer.stop());\n this.attributeObserverMap.clear();\n }\n }\n\n selectorMatched(element, _selector, _ref16) {\n let outletName = _ref16.outletName;\n const outlet = this.getOutlet(element, outletName);\n\n if (outlet) {\n this.connectOutlet(outlet, element, outletName);\n }\n }\n\n selectorUnmatched(element, _selector, _ref17) {\n let outletName = _ref17.outletName;\n const outlet = this.getOutletFromMap(element, outletName);\n\n if (outlet) {\n this.disconnectOutlet(outlet, element, outletName);\n }\n }\n\n selectorMatchElement(element, _ref18) {\n let outletName = _ref18.outletName;\n const selector = this.selector(outletName);\n const hasOutlet = this.hasOutlet(element, outletName);\n const hasOutletController = element.matches(\"[\".concat(this.schema.controllerAttribute, \"~=\").concat(outletName, \"]\"));\n\n if (selector) {\n return hasOutlet && hasOutletController && element.matches(selector);\n } else {\n return false;\n }\n }\n\n elementMatchedAttribute(_element, attributeName) {\n const outletName = this.getOutletNameFromOutletAttributeName(attributeName);\n\n if (outletName) {\n this.updateSelectorObserverForOutlet(outletName);\n }\n }\n\n elementAttributeValueChanged(_element, attributeName) {\n const outletName = this.getOutletNameFromOutletAttributeName(attributeName);\n\n if (outletName) {\n this.updateSelectorObserverForOutlet(outletName);\n }\n }\n\n elementUnmatchedAttribute(_element, attributeName) {\n const outletName = this.getOutletNameFromOutletAttributeName(attributeName);\n\n if (outletName) {\n this.updateSelectorObserverForOutlet(outletName);\n }\n }\n\n connectOutlet(outlet, element, outletName) {\n var _a;\n\n if (!this.outletElementsByName.has(outletName, element)) {\n this.outletsByName.add(outletName, outlet);\n this.outletElementsByName.add(outletName, element);\n (_a = this.selectorObserverMap.get(outletName)) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.outletConnected(outlet, element, outletName));\n }\n }\n\n disconnectOutlet(outlet, element, outletName) {\n var _a;\n\n if (this.outletElementsByName.has(outletName, element)) {\n this.outletsByName.delete(outletName, outlet);\n this.outletElementsByName.delete(outletName, element);\n (_a = this.selectorObserverMap.get(outletName)) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.outletDisconnected(outlet, element, outletName));\n }\n }\n\n disconnectAllOutlets() {\n for (const outletName of this.outletElementsByName.keys) {\n for (const element of this.outletElementsByName.getValuesForKey(outletName)) {\n for (const outlet of this.outletsByName.getValuesForKey(outletName)) {\n this.disconnectOutlet(outlet, element, outletName);\n }\n }\n }\n }\n\n updateSelectorObserverForOutlet(outletName) {\n const observer = this.selectorObserverMap.get(outletName);\n\n if (observer) {\n observer.selector = this.selector(outletName);\n }\n }\n\n setupSelectorObserverForOutlet(outletName) {\n const selector = this.selector(outletName);\n const selectorObserver = new SelectorObserver(document.body, selector, this, {\n outletName\n });\n this.selectorObserverMap.set(outletName, selectorObserver);\n selectorObserver.start();\n }\n\n setupAttributeObserverForOutlet(outletName) {\n const attributeName = this.attributeNameForOutletName(outletName);\n const attributeObserver = new AttributeObserver(this.scope.element, attributeName, this);\n this.attributeObserverMap.set(outletName, attributeObserver);\n attributeObserver.start();\n }\n\n selector(outletName) {\n return this.scope.outlets.getSelectorForOutletName(outletName);\n }\n\n attributeNameForOutletName(outletName) {\n return this.scope.schema.outletAttributeForScope(this.identifier, outletName);\n }\n\n getOutletNameFromOutletAttributeName(attributeName) {\n return this.outletDefinitions.find(outletName => this.attributeNameForOutletName(outletName) === attributeName);\n }\n\n get outletDependencies() {\n const dependencies = new Multimap();\n this.router.modules.forEach(module => {\n const constructor = module.definition.controllerConstructor;\n const outlets = readInheritableStaticArrayValues(constructor, \"outlets\");\n outlets.forEach(outlet => dependencies.add(outlet, module.identifier));\n });\n return dependencies;\n }\n\n get outletDefinitions() {\n return this.outletDependencies.getKeysForValue(this.identifier);\n }\n\n get dependentControllerIdentifiers() {\n return this.outletDependencies.getValuesForKey(this.identifier);\n }\n\n get dependentContexts() {\n const identifiers = this.dependentControllerIdentifiers;\n return this.router.contexts.filter(context => identifiers.includes(context.identifier));\n }\n\n hasOutlet(element, outletName) {\n return !!this.getOutlet(element, outletName) || !!this.getOutletFromMap(element, outletName);\n }\n\n getOutlet(element, outletName) {\n return this.application.getControllerForElementAndIdentifier(element, outletName);\n }\n\n getOutletFromMap(element, outletName) {\n return this.outletsByName.getValuesForKey(outletName).find(outlet => outlet.element === element);\n }\n\n get scope() {\n return this.context.scope;\n }\n\n get schema() {\n return this.context.schema;\n }\n\n get identifier() {\n return this.context.identifier;\n }\n\n get application() {\n return this.context.application;\n }\n\n get router() {\n return this.application.router;\n }\n\n}\n\nclass Context {\n constructor(module, scope) {\n var _this = this;\n\n this.logDebugActivity = function (functionName) {\n let detail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const identifier = _this.identifier,\n controller = _this.controller,\n element = _this.element;\n detail = Object.assign({\n identifier,\n controller,\n element\n }, detail);\n\n _this.application.logDebugActivity(_this.identifier, functionName, detail);\n };\n\n this.module = module;\n this.scope = scope;\n this.controller = new module.controllerConstructor(this);\n this.bindingObserver = new BindingObserver(this, this.dispatcher);\n this.valueObserver = new ValueObserver(this, this.controller);\n this.targetObserver = new TargetObserver(this, this);\n this.outletObserver = new OutletObserver(this, this);\n\n try {\n this.controller.initialize();\n this.logDebugActivity(\"initialize\");\n } catch (error) {\n this.handleError(error, \"initializing controller\");\n }\n }\n\n connect() {\n this.bindingObserver.start();\n this.valueObserver.start();\n this.targetObserver.start();\n this.outletObserver.start();\n\n try {\n this.controller.connect();\n this.logDebugActivity(\"connect\");\n } catch (error) {\n this.handleError(error, \"connecting controller\");\n }\n }\n\n refresh() {\n this.outletObserver.refresh();\n }\n\n disconnect() {\n try {\n this.controller.disconnect();\n this.logDebugActivity(\"disconnect\");\n } catch (error) {\n this.handleError(error, \"disconnecting controller\");\n }\n\n this.outletObserver.stop();\n this.targetObserver.stop();\n this.valueObserver.stop();\n this.bindingObserver.stop();\n }\n\n get application() {\n return this.module.application;\n }\n\n get identifier() {\n return this.module.identifier;\n }\n\n get schema() {\n return this.application.schema;\n }\n\n get dispatcher() {\n return this.application.dispatcher;\n }\n\n get element() {\n return this.scope.element;\n }\n\n get parentElement() {\n return this.element.parentElement;\n }\n\n handleError(error, message) {\n let detail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n const identifier = this.identifier,\n controller = this.controller,\n element = this.element;\n detail = Object.assign({\n identifier,\n controller,\n element\n }, detail);\n this.application.handleError(error, \"Error \".concat(message), detail);\n }\n\n targetConnected(element, name) {\n this.invokeControllerMethod(\"\".concat(name, \"TargetConnected\"), element);\n }\n\n targetDisconnected(element, name) {\n this.invokeControllerMethod(\"\".concat(name, \"TargetDisconnected\"), element);\n }\n\n outletConnected(outlet, element, name) {\n this.invokeControllerMethod(\"\".concat(namespaceCamelize(name), \"OutletConnected\"), outlet, element);\n }\n\n outletDisconnected(outlet, element, name) {\n this.invokeControllerMethod(\"\".concat(namespaceCamelize(name), \"OutletDisconnected\"), outlet, element);\n }\n\n invokeControllerMethod(methodName) {\n const controller = this.controller;\n\n if (typeof controller[methodName] == \"function\") {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key2 = 1; _key2 < _len; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n controller[methodName](...args);\n }\n }\n\n}\n\nfunction bless(constructor) {\n return shadow(constructor, getBlessedProperties(constructor));\n}\n\nfunction shadow(constructor, properties) {\n const shadowConstructor = extend(constructor);\n const shadowProperties = getShadowProperties(constructor.prototype, properties);\n Object.defineProperties(shadowConstructor.prototype, shadowProperties);\n return shadowConstructor;\n}\n\nfunction getBlessedProperties(constructor) {\n const blessings = readInheritableStaticArrayValues(constructor, \"blessings\");\n return blessings.reduce((blessedProperties, blessing) => {\n const properties = blessing(constructor);\n\n for (const key in properties) {\n const descriptor = blessedProperties[key] || {};\n blessedProperties[key] = Object.assign(descriptor, properties[key]);\n }\n\n return blessedProperties;\n }, {});\n}\n\nfunction getShadowProperties(prototype, properties) {\n return getOwnKeys(properties).reduce((shadowProperties, key) => {\n const descriptor = getShadowedDescriptor(prototype, properties, key);\n\n if (descriptor) {\n Object.assign(shadowProperties, {\n [key]: descriptor\n });\n }\n\n return shadowProperties;\n }, {});\n}\n\nfunction getShadowedDescriptor(prototype, properties, key) {\n const shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key);\n const shadowedByValue = shadowingDescriptor && \"value\" in shadowingDescriptor;\n\n if (!shadowedByValue) {\n const descriptor = Object.getOwnPropertyDescriptor(properties, key).value;\n\n if (shadowingDescriptor) {\n descriptor.get = shadowingDescriptor.get || descriptor.get;\n descriptor.set = shadowingDescriptor.set || descriptor.set;\n }\n\n return descriptor;\n }\n}\n\nconst getOwnKeys = (() => {\n if (typeof Object.getOwnPropertySymbols == \"function\") {\n return object => [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];\n } else {\n return Object.getOwnPropertyNames;\n }\n})();\n\nconst extend = (() => {\n function extendWithReflect(constructor) {\n function extended() {\n return Reflect.construct(constructor, arguments, new.target);\n }\n\n extended.prototype = Object.create(constructor.prototype, {\n constructor: {\n value: extended\n }\n });\n Reflect.setPrototypeOf(extended, constructor);\n return extended;\n }\n\n function testReflectExtension() {\n const a = function () {\n this.a.call(this);\n };\n\n const b = extendWithReflect(a);\n\n b.prototype.a = function () {};\n\n return new b();\n }\n\n try {\n testReflectExtension();\n return extendWithReflect;\n } catch (error) {\n return constructor => class extended extends constructor {};\n }\n})();\n\nfunction blessDefinition(definition) {\n return {\n identifier: definition.identifier,\n controllerConstructor: bless(definition.controllerConstructor)\n };\n}\n\nclass Module {\n constructor(application, definition) {\n this.application = application;\n this.definition = blessDefinition(definition);\n this.contextsByScope = new WeakMap();\n this.connectedContexts = new Set();\n }\n\n get identifier() {\n return this.definition.identifier;\n }\n\n get controllerConstructor() {\n return this.definition.controllerConstructor;\n }\n\n get contexts() {\n return Array.from(this.connectedContexts);\n }\n\n connectContextForScope(scope) {\n const context = this.fetchContextForScope(scope);\n this.connectedContexts.add(context);\n context.connect();\n }\n\n disconnectContextForScope(scope) {\n const context = this.contextsByScope.get(scope);\n\n if (context) {\n this.connectedContexts.delete(context);\n context.disconnect();\n }\n }\n\n fetchContextForScope(scope) {\n let context = this.contextsByScope.get(scope);\n\n if (!context) {\n context = new Context(this, scope);\n this.contextsByScope.set(scope, context);\n }\n\n return context;\n }\n\n}\n\nclass ClassMap {\n constructor(scope) {\n this.scope = scope;\n }\n\n has(name) {\n return this.data.has(this.getDataKey(name));\n }\n\n get(name) {\n return this.getAll(name)[0];\n }\n\n getAll(name) {\n const tokenString = this.data.get(this.getDataKey(name)) || \"\";\n return tokenize(tokenString);\n }\n\n getAttributeName(name) {\n return this.data.getAttributeNameForKey(this.getDataKey(name));\n }\n\n getDataKey(name) {\n return \"\".concat(name, \"-class\");\n }\n\n get data() {\n return this.scope.data;\n }\n\n}\n\nclass DataMap {\n constructor(scope) {\n this.scope = scope;\n }\n\n get element() {\n return this.scope.element;\n }\n\n get identifier() {\n return this.scope.identifier;\n }\n\n get(key) {\n const name = this.getAttributeNameForKey(key);\n return this.element.getAttribute(name);\n }\n\n set(key, value) {\n const name = this.getAttributeNameForKey(key);\n this.element.setAttribute(name, value);\n return this.get(key);\n }\n\n has(key) {\n const name = this.getAttributeNameForKey(key);\n return this.element.hasAttribute(name);\n }\n\n delete(key) {\n if (this.has(key)) {\n const name = this.getAttributeNameForKey(key);\n this.element.removeAttribute(name);\n return true;\n } else {\n return false;\n }\n }\n\n getAttributeNameForKey(key) {\n return \"data-\".concat(this.identifier, \"-\").concat(dasherize(key));\n }\n\n}\n\nclass Guide {\n constructor(logger) {\n this.warnedKeysByObject = new WeakMap();\n this.logger = logger;\n }\n\n warn(object, key, message) {\n let warnedKeys = this.warnedKeysByObject.get(object);\n\n if (!warnedKeys) {\n warnedKeys = new Set();\n this.warnedKeysByObject.set(object, warnedKeys);\n }\n\n if (!warnedKeys.has(key)) {\n warnedKeys.add(key);\n this.logger.warn(message, object);\n }\n }\n\n}\n\nfunction attributeValueContainsToken(attributeName, token) {\n return \"[\".concat(attributeName, \"~=\\\"\").concat(token, \"\\\"]\");\n}\n\nclass TargetSet {\n constructor(scope) {\n this.scope = scope;\n }\n\n get element() {\n return this.scope.element;\n }\n\n get identifier() {\n return this.scope.identifier;\n }\n\n get schema() {\n return this.scope.schema;\n }\n\n has(targetName) {\n return this.find(targetName) != null;\n }\n\n find() {\n for (var _len2 = arguments.length, targetNames = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {\n targetNames[_key3] = arguments[_key3];\n }\n\n return targetNames.reduce((target, targetName) => target || this.findTarget(targetName) || this.findLegacyTarget(targetName), undefined);\n }\n\n findAll() {\n for (var _len3 = arguments.length, targetNames = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {\n targetNames[_key4] = arguments[_key4];\n }\n\n return targetNames.reduce((targets, targetName) => [...targets, ...this.findAllTargets(targetName), ...this.findAllLegacyTargets(targetName)], []);\n }\n\n findTarget(targetName) {\n const selector = this.getSelectorForTargetName(targetName);\n return this.scope.findElement(selector);\n }\n\n findAllTargets(targetName) {\n const selector = this.getSelectorForTargetName(targetName);\n return this.scope.findAllElements(selector);\n }\n\n getSelectorForTargetName(targetName) {\n const attributeName = this.schema.targetAttributeForScope(this.identifier);\n return attributeValueContainsToken(attributeName, targetName);\n }\n\n findLegacyTarget(targetName) {\n const selector = this.getLegacySelectorForTargetName(targetName);\n return this.deprecate(this.scope.findElement(selector), targetName);\n }\n\n findAllLegacyTargets(targetName) {\n const selector = this.getLegacySelectorForTargetName(targetName);\n return this.scope.findAllElements(selector).map(element => this.deprecate(element, targetName));\n }\n\n getLegacySelectorForTargetName(targetName) {\n const targetDescriptor = \"\".concat(this.identifier, \".\").concat(targetName);\n return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor);\n }\n\n deprecate(element, targetName) {\n if (element) {\n const identifier = this.identifier;\n const attributeName = this.schema.targetAttribute;\n const revisedAttributeName = this.schema.targetAttributeForScope(identifier);\n 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.\"));\n }\n\n return element;\n }\n\n get guide() {\n return this.scope.guide;\n }\n\n}\n\nclass OutletSet {\n constructor(scope, controllerElement) {\n this.scope = scope;\n this.controllerElement = controllerElement;\n }\n\n get element() {\n return this.scope.element;\n }\n\n get identifier() {\n return this.scope.identifier;\n }\n\n get schema() {\n return this.scope.schema;\n }\n\n has(outletName) {\n return this.find(outletName) != null;\n }\n\n find() {\n for (var _len4 = arguments.length, outletNames = new Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {\n outletNames[_key5] = arguments[_key5];\n }\n\n return outletNames.reduce((outlet, outletName) => outlet || this.findOutlet(outletName), undefined);\n }\n\n findAll() {\n for (var _len5 = arguments.length, outletNames = new Array(_len5), _key6 = 0; _key6 < _len5; _key6++) {\n outletNames[_key6] = arguments[_key6];\n }\n\n return outletNames.reduce((outlets, outletName) => [...outlets, ...this.findAllOutlets(outletName)], []);\n }\n\n getSelectorForOutletName(outletName) {\n const attributeName = this.schema.outletAttributeForScope(this.identifier, outletName);\n return this.controllerElement.getAttribute(attributeName);\n }\n\n findOutlet(outletName) {\n const selector = this.getSelectorForOutletName(outletName);\n if (selector) return this.findElement(selector, outletName);\n }\n\n findAllOutlets(outletName) {\n const selector = this.getSelectorForOutletName(outletName);\n return selector ? this.findAllElements(selector, outletName) : [];\n }\n\n findElement(selector, outletName) {\n const elements = this.scope.queryElements(selector);\n return elements.filter(element => this.matchesElement(element, selector, outletName))[0];\n }\n\n findAllElements(selector, outletName) {\n const elements = this.scope.queryElements(selector);\n return elements.filter(element => this.matchesElement(element, selector, outletName));\n }\n\n matchesElement(element, selector, outletName) {\n const controllerAttribute = element.getAttribute(this.scope.schema.controllerAttribute) || \"\";\n return element.matches(selector) && controllerAttribute.split(\" \").includes(outletName);\n }\n\n}\n\nclass Scope {\n constructor(schema, element, identifier, logger) {\n this.targets = new TargetSet(this);\n this.classes = new ClassMap(this);\n this.data = new DataMap(this);\n\n this.containsElement = element => {\n return element.closest(this.controllerSelector) === this.element;\n };\n\n this.schema = schema;\n this.element = element;\n this.identifier = identifier;\n this.guide = new Guide(logger);\n this.outlets = new OutletSet(this.documentScope, element);\n }\n\n findElement(selector) {\n return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement);\n }\n\n findAllElements(selector) {\n return [...(this.element.matches(selector) ? [this.element] : []), ...this.queryElements(selector).filter(this.containsElement)];\n }\n\n queryElements(selector) {\n return Array.from(this.element.querySelectorAll(selector));\n }\n\n get controllerSelector() {\n return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier);\n }\n\n get isDocumentScope() {\n return this.element === document.documentElement;\n }\n\n get documentScope() {\n return this.isDocumentScope ? this : new Scope(this.schema, document.documentElement, this.identifier, this.guide.logger);\n }\n\n}\n\nclass ScopeObserver {\n constructor(element, schema, delegate) {\n this.element = element;\n this.schema = schema;\n this.delegate = delegate;\n this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this);\n this.scopesByIdentifierByElement = new WeakMap();\n this.scopeReferenceCounts = new WeakMap();\n }\n\n start() {\n this.valueListObserver.start();\n }\n\n stop() {\n this.valueListObserver.stop();\n }\n\n get controllerAttribute() {\n return this.schema.controllerAttribute;\n }\n\n parseValueForToken(token) {\n const element = token.element,\n identifier = token.content;\n return this.parseValueForElementAndIdentifier(element, identifier);\n }\n\n parseValueForElementAndIdentifier(element, identifier) {\n const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element);\n let scope = scopesByIdentifier.get(identifier);\n\n if (!scope) {\n scope = this.delegate.createScopeForElementAndIdentifier(element, identifier);\n scopesByIdentifier.set(identifier, scope);\n }\n\n return scope;\n }\n\n elementMatchedValue(element, value) {\n const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1;\n this.scopeReferenceCounts.set(value, referenceCount);\n\n if (referenceCount == 1) {\n this.delegate.scopeConnected(value);\n }\n }\n\n elementUnmatchedValue(element, value) {\n const referenceCount = this.scopeReferenceCounts.get(value);\n\n if (referenceCount) {\n this.scopeReferenceCounts.set(value, referenceCount - 1);\n\n if (referenceCount == 1) {\n this.delegate.scopeDisconnected(value);\n }\n }\n }\n\n fetchScopesByIdentifierForElement(element) {\n let scopesByIdentifier = this.scopesByIdentifierByElement.get(element);\n\n if (!scopesByIdentifier) {\n scopesByIdentifier = new Map();\n this.scopesByIdentifierByElement.set(element, scopesByIdentifier);\n }\n\n return scopesByIdentifier;\n }\n\n}\n\nclass Router {\n constructor(application) {\n this.application = application;\n this.scopeObserver = new ScopeObserver(this.element, this.schema, this);\n this.scopesByIdentifier = new Multimap();\n this.modulesByIdentifier = new Map();\n }\n\n get element() {\n return this.application.element;\n }\n\n get schema() {\n return this.application.schema;\n }\n\n get logger() {\n return this.application.logger;\n }\n\n get controllerAttribute() {\n return this.schema.controllerAttribute;\n }\n\n get modules() {\n return Array.from(this.modulesByIdentifier.values());\n }\n\n get contexts() {\n return this.modules.reduce((contexts, module) => contexts.concat(module.contexts), []);\n }\n\n start() {\n this.scopeObserver.start();\n }\n\n stop() {\n this.scopeObserver.stop();\n }\n\n loadDefinition(definition) {\n this.unloadIdentifier(definition.identifier);\n const module = new Module(this.application, definition);\n this.connectModule(module);\n const afterLoad = definition.controllerConstructor.afterLoad;\n\n if (afterLoad) {\n afterLoad.call(definition.controllerConstructor, definition.identifier, this.application);\n }\n }\n\n unloadIdentifier(identifier) {\n const module = this.modulesByIdentifier.get(identifier);\n\n if (module) {\n this.disconnectModule(module);\n }\n }\n\n getContextForElementAndIdentifier(element, identifier) {\n const module = this.modulesByIdentifier.get(identifier);\n\n if (module) {\n return module.contexts.find(context => context.element == element);\n }\n }\n\n proposeToConnectScopeForElementAndIdentifier(element, identifier) {\n const scope = this.scopeObserver.parseValueForElementAndIdentifier(element, identifier);\n\n if (scope) {\n this.scopeObserver.elementMatchedValue(scope.element, scope);\n } else {\n console.error(\"Couldn't find or create scope for identifier: \\\"\".concat(identifier, \"\\\" and element:\"), element);\n }\n }\n\n handleError(error, message, detail) {\n this.application.handleError(error, message, detail);\n }\n\n createScopeForElementAndIdentifier(element, identifier) {\n return new Scope(this.schema, element, identifier, this.logger);\n }\n\n scopeConnected(scope) {\n this.scopesByIdentifier.add(scope.identifier, scope);\n const module = this.modulesByIdentifier.get(scope.identifier);\n\n if (module) {\n module.connectContextForScope(scope);\n }\n }\n\n scopeDisconnected(scope) {\n this.scopesByIdentifier.delete(scope.identifier, scope);\n const module = this.modulesByIdentifier.get(scope.identifier);\n\n if (module) {\n module.disconnectContextForScope(scope);\n }\n }\n\n connectModule(module) {\n this.modulesByIdentifier.set(module.identifier, module);\n const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);\n scopes.forEach(scope => module.connectContextForScope(scope));\n }\n\n disconnectModule(module) {\n this.modulesByIdentifier.delete(module.identifier);\n const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);\n scopes.forEach(scope => module.disconnectContextForScope(scope));\n }\n\n}\n\nconst defaultSchema = {\n controllerAttribute: \"data-controller\",\n actionAttribute: \"data-action\",\n targetAttribute: \"data-target\",\n targetAttributeForScope: identifier => \"data-\".concat(identifier, \"-target\"),\n outletAttributeForScope: (identifier, outlet) => \"data-\".concat(identifier, \"-\").concat(outlet, \"-outlet\"),\n keyMappings: Object.assign(Object.assign({\n enter: \"Enter\",\n tab: \"Tab\",\n esc: \"Escape\",\n space: \" \",\n up: \"ArrowUp\",\n down: \"ArrowDown\",\n left: \"ArrowLeft\",\n right: \"ArrowRight\",\n home: \"Home\",\n end: \"End\",\n page_up: \"PageUp\",\n page_down: \"PageDown\"\n }, objectFromEntries(\"abcdefghijklmnopqrstuvwxyz\".split(\"\").map(c => [c, c]))), objectFromEntries(\"0123456789\".split(\"\").map(n => [n, n])))\n};\n\nfunction objectFromEntries(array) {\n return array.reduce((memo, _ref19) => {\n let _ref20 = _slicedToArray(_ref19, 2),\n k = _ref20[0],\n v = _ref20[1];\n\n return Object.assign(Object.assign({}, memo), {\n [k]: v\n });\n }, {});\n}\n\nclass Application {\n constructor() {\n var _this2 = this;\n\n let element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.documentElement;\n let schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultSchema;\n this.logger = console;\n this.debug = false;\n\n this.logDebugActivity = function (identifier, functionName) {\n let detail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n if (_this2.debug) {\n _this2.logFormattedMessage(identifier, functionName, detail);\n }\n };\n\n this.element = element;\n this.schema = schema;\n this.dispatcher = new Dispatcher(this);\n this.router = new Router(this);\n this.actionDescriptorFilters = Object.assign({}, defaultActionDescriptorFilters);\n }\n\n static start(element, schema) {\n const application = new this(element, schema);\n application.start();\n return application;\n }\n\n async start() {\n await domReady();\n this.logDebugActivity(\"application\", \"starting\");\n this.dispatcher.start();\n this.router.start();\n this.logDebugActivity(\"application\", \"start\");\n }\n\n stop() {\n this.logDebugActivity(\"application\", \"stopping\");\n this.dispatcher.stop();\n this.router.stop();\n this.logDebugActivity(\"application\", \"stop\");\n }\n\n register(identifier, controllerConstructor) {\n this.load({\n identifier,\n controllerConstructor\n });\n }\n\n registerActionOption(name, filter) {\n this.actionDescriptorFilters[name] = filter;\n }\n\n load(head) {\n for (var _len6 = arguments.length, rest = new Array(_len6 > 1 ? _len6 - 1 : 0), _key7 = 1; _key7 < _len6; _key7++) {\n rest[_key7 - 1] = arguments[_key7];\n }\n\n const definitions = Array.isArray(head) ? head : [head, ...rest];\n definitions.forEach(definition => {\n if (definition.controllerConstructor.shouldLoad) {\n this.router.loadDefinition(definition);\n }\n });\n }\n\n unload(head) {\n for (var _len7 = arguments.length, rest = new Array(_len7 > 1 ? _len7 - 1 : 0), _key8 = 1; _key8 < _len7; _key8++) {\n rest[_key8 - 1] = arguments[_key8];\n }\n\n const identifiers = Array.isArray(head) ? head : [head, ...rest];\n identifiers.forEach(identifier => this.router.unloadIdentifier(identifier));\n }\n\n get controllers() {\n return this.router.contexts.map(context => context.controller);\n }\n\n getControllerForElementAndIdentifier(element, identifier) {\n const context = this.router.getContextForElementAndIdentifier(element, identifier);\n return context ? context.controller : null;\n }\n\n handleError(error, message, detail) {\n var _a;\n\n this.logger.error(\"%s\\n\\n%o\\n\\n%o\", message, error, detail);\n (_a = window.onerror) === null || _a === void 0 ? void 0 : _a.call(window, message, \"\", 0, 0, error);\n }\n\n logFormattedMessage(identifier, functionName) {\n let detail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n detail = Object.assign({\n application: this\n }, detail);\n this.logger.groupCollapsed(\"\".concat(identifier, \" #\").concat(functionName));\n this.logger.log(\"details:\", Object.assign({}, detail));\n this.logger.groupEnd();\n }\n\n}\n\nfunction domReady() {\n return new Promise(resolve => {\n if (document.readyState == \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => resolve());\n } else {\n resolve();\n }\n });\n}\n\nfunction ClassPropertiesBlessing(constructor) {\n const classes = readInheritableStaticArrayValues(constructor, \"classes\");\n return classes.reduce((properties, classDefinition) => {\n return Object.assign(properties, propertiesForClassDefinition(classDefinition));\n }, {});\n}\n\nfunction propertiesForClassDefinition(key) {\n return {\n [\"\".concat(key, \"Class\")]: {\n get() {\n const classes = this.classes;\n\n if (classes.has(key)) {\n return classes.get(key);\n } else {\n const attribute = classes.getAttributeName(key);\n throw new Error(\"Missing attribute \\\"\".concat(attribute, \"\\\"\"));\n }\n }\n\n },\n [\"\".concat(key, \"Classes\")]: {\n get() {\n return this.classes.getAll(key);\n }\n\n },\n [\"has\".concat(capitalize(key), \"Class\")]: {\n get() {\n return this.classes.has(key);\n }\n\n }\n };\n}\n\nfunction OutletPropertiesBlessing(constructor) {\n const outlets = readInheritableStaticArrayValues(constructor, \"outlets\");\n return outlets.reduce((properties, outletDefinition) => {\n return Object.assign(properties, propertiesForOutletDefinition(outletDefinition));\n }, {});\n}\n\nfunction getOutletController(controller, element, identifier) {\n return controller.application.getControllerForElementAndIdentifier(element, identifier);\n}\n\nfunction getControllerAndEnsureConnectedScope(controller, element, outletName) {\n let outletController = getOutletController(controller, element, outletName);\n if (outletController) return outletController;\n controller.application.router.proposeToConnectScopeForElementAndIdentifier(element, outletName);\n outletController = getOutletController(controller, element, outletName);\n if (outletController) return outletController;\n}\n\nfunction propertiesForOutletDefinition(name) {\n const camelizedName = namespaceCamelize(name);\n return {\n [\"\".concat(camelizedName, \"Outlet\")]: {\n get() {\n const outletElement = this.outlets.find(name);\n const selector = this.outlets.getSelectorForOutletName(name);\n\n if (outletElement) {\n const outletController = getControllerAndEnsureConnectedScope(this, outletElement, name);\n if (outletController) return outletController;\n throw new Error(\"The provided outlet element is missing an outlet controller \\\"\".concat(name, \"\\\" instance for host controller \\\"\").concat(this.identifier, \"\\\"\"));\n }\n\n throw new Error(\"Missing outlet element \\\"\".concat(name, \"\\\" for host controller \\\"\").concat(this.identifier, \"\\\". Stimulus couldn't find a matching outlet element using selector \\\"\").concat(selector, \"\\\".\"));\n }\n\n },\n [\"\".concat(camelizedName, \"Outlets\")]: {\n get() {\n const outlets = this.outlets.findAll(name);\n\n if (outlets.length > 0) {\n return outlets.map(outletElement => {\n const outletController = getControllerAndEnsureConnectedScope(this, outletElement, name);\n if (outletController) return outletController;\n console.warn(\"The provided outlet element is missing an outlet controller \\\"\".concat(name, \"\\\" instance for host controller \\\"\").concat(this.identifier, \"\\\"\"), outletElement);\n }).filter(controller => controller);\n }\n\n return [];\n }\n\n },\n [\"\".concat(camelizedName, \"OutletElement\")]: {\n get() {\n const outletElement = this.outlets.find(name);\n const selector = this.outlets.getSelectorForOutletName(name);\n\n if (outletElement) {\n return outletElement;\n } else {\n throw new Error(\"Missing outlet element \\\"\".concat(name, \"\\\" for host controller \\\"\").concat(this.identifier, \"\\\". Stimulus couldn't find a matching outlet element using selector \\\"\").concat(selector, \"\\\".\"));\n }\n }\n\n },\n [\"\".concat(camelizedName, \"OutletElements\")]: {\n get() {\n return this.outlets.findAll(name);\n }\n\n },\n [\"has\".concat(capitalize(camelizedName), \"Outlet\")]: {\n get() {\n return this.outlets.has(name);\n }\n\n }\n };\n}\n\nfunction TargetPropertiesBlessing(constructor) {\n const targets = readInheritableStaticArrayValues(constructor, \"targets\");\n return targets.reduce((properties, targetDefinition) => {\n return Object.assign(properties, propertiesForTargetDefinition(targetDefinition));\n }, {});\n}\n\nfunction propertiesForTargetDefinition(name) {\n return {\n [\"\".concat(name, \"Target\")]: {\n get() {\n const target = this.targets.find(name);\n\n if (target) {\n return target;\n } else {\n throw new Error(\"Missing target element \\\"\".concat(name, \"\\\" for \\\"\").concat(this.identifier, \"\\\" controller\"));\n }\n }\n\n },\n [\"\".concat(name, \"Targets\")]: {\n get() {\n return this.targets.findAll(name);\n }\n\n },\n [\"has\".concat(capitalize(name), \"Target\")]: {\n get() {\n return this.targets.has(name);\n }\n\n }\n };\n}\n\nfunction ValuePropertiesBlessing(constructor) {\n const valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, \"values\");\n const propertyDescriptorMap = {\n valueDescriptorMap: {\n get() {\n return valueDefinitionPairs.reduce((result, valueDefinitionPair) => {\n const valueDescriptor = parseValueDefinitionPair(valueDefinitionPair, this.identifier);\n const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key);\n return Object.assign(result, {\n [attributeName]: valueDescriptor\n });\n }, {});\n }\n\n }\n };\n return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => {\n return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair));\n }, propertyDescriptorMap);\n}\n\nfunction propertiesForValueDefinitionPair(valueDefinitionPair, controller) {\n const definition = parseValueDefinitionPair(valueDefinitionPair, controller);\n const key = definition.key,\n name = definition.name,\n read = definition.reader,\n write = definition.writer;\n return {\n [name]: {\n get() {\n const value = this.data.get(key);\n\n if (value !== null) {\n return read(value);\n } else {\n return definition.defaultValue;\n }\n },\n\n set(value) {\n if (value === undefined) {\n this.data.delete(key);\n } else {\n this.data.set(key, write(value));\n }\n }\n\n },\n [\"has\".concat(capitalize(name))]: {\n get() {\n return this.data.has(key) || definition.hasCustomDefaultValue;\n }\n\n }\n };\n}\n\nfunction parseValueDefinitionPair(_ref21, controller) {\n let _ref22 = _slicedToArray(_ref21, 2),\n token = _ref22[0],\n typeDefinition = _ref22[1];\n\n return valueDescriptorForTokenAndTypeDefinition({\n controller,\n token,\n typeDefinition\n });\n}\n\nfunction parseValueTypeConstant(constant) {\n switch (constant) {\n case Array:\n return \"array\";\n\n case Boolean:\n return \"boolean\";\n\n case Number:\n return \"number\";\n\n case Object:\n return \"object\";\n\n case String:\n return \"string\";\n }\n}\n\nfunction parseValueTypeDefault(defaultValue) {\n switch (typeof defaultValue) {\n case \"boolean\":\n return \"boolean\";\n\n case \"number\":\n return \"number\";\n\n case \"string\":\n return \"string\";\n }\n\n if (Array.isArray(defaultValue)) return \"array\";\n if (Object.prototype.toString.call(defaultValue) === \"[object Object]\") return \"object\";\n}\n\nfunction parseValueTypeObject(payload) {\n const controller = payload.controller,\n token = payload.token,\n typeObject = payload.typeObject;\n const hasType = isSomething(typeObject.type);\n const hasDefault = isSomething(typeObject.default);\n const fullObject = hasType && hasDefault;\n const onlyType = hasType && !hasDefault;\n const onlyDefault = !hasType && hasDefault;\n const typeFromObject = parseValueTypeConstant(typeObject.type);\n const typeFromDefaultValue = parseValueTypeDefault(payload.typeObject.default);\n if (onlyType) return typeFromObject;\n if (onlyDefault) return typeFromDefaultValue;\n\n if (typeFromObject !== typeFromDefaultValue) {\n const propertyPath = controller ? \"\".concat(controller, \".\").concat(token) : token;\n throw new Error(\"The specified default value for the Stimulus Value \\\"\".concat(propertyPath, \"\\\" must match the defined type \\\"\").concat(typeFromObject, \"\\\". The provided default value of \\\"\").concat(typeObject.default, \"\\\" is of type \\\"\").concat(typeFromDefaultValue, \"\\\".\"));\n }\n\n if (fullObject) return typeFromObject;\n}\n\nfunction parseValueTypeDefinition(payload) {\n const controller = payload.controller,\n token = payload.token,\n typeDefinition = payload.typeDefinition;\n const typeObject = {\n controller,\n token,\n typeObject: typeDefinition\n };\n const typeFromObject = parseValueTypeObject(typeObject);\n const typeFromDefaultValue = parseValueTypeDefault(typeDefinition);\n const typeFromConstant = parseValueTypeConstant(typeDefinition);\n const type = typeFromObject || typeFromDefaultValue || typeFromConstant;\n if (type) return type;\n const propertyPath = controller ? \"\".concat(controller, \".\").concat(typeDefinition) : token;\n throw new Error(\"Unknown value type \\\"\".concat(propertyPath, \"\\\" for \\\"\").concat(token, \"\\\" value\"));\n}\n\nfunction defaultValueForDefinition(typeDefinition) {\n const constant = parseValueTypeConstant(typeDefinition);\n if (constant) return defaultValuesByType[constant];\n const hasDefault = hasProperty(typeDefinition, \"default\");\n const hasType = hasProperty(typeDefinition, \"type\");\n const typeObject = typeDefinition;\n if (hasDefault) return typeObject.default;\n\n if (hasType) {\n const type = typeObject.type;\n const constantFromType = parseValueTypeConstant(type);\n if (constantFromType) return defaultValuesByType[constantFromType];\n }\n\n return typeDefinition;\n}\n\nfunction valueDescriptorForTokenAndTypeDefinition(payload) {\n const token = payload.token,\n typeDefinition = payload.typeDefinition;\n const key = \"\".concat(dasherize(token), \"-value\");\n const type = parseValueTypeDefinition(payload);\n return {\n type,\n key,\n name: camelize(key),\n\n get defaultValue() {\n return defaultValueForDefinition(typeDefinition);\n },\n\n get hasCustomDefaultValue() {\n return parseValueTypeDefault(typeDefinition) !== undefined;\n },\n\n reader: readers[type],\n writer: writers[type] || writers.default\n };\n}\n\nconst defaultValuesByType = {\n get array() {\n return [];\n },\n\n boolean: false,\n number: 0,\n\n get object() {\n return {};\n },\n\n string: \"\"\n};\nconst readers = {\n array(value) {\n const array = JSON.parse(value);\n\n if (!Array.isArray(array)) {\n throw new TypeError(\"expected value of type \\\"array\\\" but instead got value \\\"\".concat(value, \"\\\" of type \\\"\").concat(parseValueTypeDefault(array), \"\\\"\"));\n }\n\n return array;\n },\n\n boolean(value) {\n return !(value == \"0\" || String(value).toLowerCase() == \"false\");\n },\n\n number(value) {\n return Number(value.replace(/_/g, \"\"));\n },\n\n object(value) {\n const object = JSON.parse(value);\n\n if (object === null || typeof object != \"object\" || Array.isArray(object)) {\n throw new TypeError(\"expected value of type \\\"object\\\" but instead got value \\\"\".concat(value, \"\\\" of type \\\"\").concat(parseValueTypeDefault(object), \"\\\"\"));\n }\n\n return object;\n },\n\n string(value) {\n return value;\n }\n\n};\nconst writers = {\n default: writeString,\n array: writeJSON,\n object: writeJSON\n};\n\nfunction writeJSON(value) {\n return JSON.stringify(value);\n}\n\nfunction writeString(value) {\n return \"\".concat(value);\n}\n\nclass Controller {\n constructor(context) {\n this.context = context;\n }\n\n static get shouldLoad() {\n return true;\n }\n\n static afterLoad(_identifier, _application) {\n return;\n }\n\n get application() {\n return this.context.application;\n }\n\n get scope() {\n return this.context.scope;\n }\n\n get element() {\n return this.scope.element;\n }\n\n get identifier() {\n return this.scope.identifier;\n }\n\n get targets() {\n return this.scope.targets;\n }\n\n get outlets() {\n return this.scope.outlets;\n }\n\n get classes() {\n return this.scope.classes;\n }\n\n get data() {\n return this.scope.data;\n }\n\n initialize() {}\n\n connect() {}\n\n disconnect() {}\n\n dispatch(eventName) {\n let _ref23 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref23$target = _ref23.target,\n target = _ref23$target === void 0 ? this.element : _ref23$target,\n _ref23$detail = _ref23.detail,\n detail = _ref23$detail === void 0 ? {} : _ref23$detail,\n _ref23$prefix = _ref23.prefix,\n prefix = _ref23$prefix === void 0 ? this.identifier : _ref23$prefix,\n _ref23$bubbles = _ref23.bubbles,\n bubbles = _ref23$bubbles === void 0 ? true : _ref23$bubbles,\n _ref23$cancelable = _ref23.cancelable,\n cancelable = _ref23$cancelable === void 0 ? true : _ref23$cancelable;\n\n const type = prefix ? \"\".concat(prefix, \":\").concat(eventName) : eventName;\n const event = new CustomEvent(type, {\n detail,\n bubbles,\n cancelable\n });\n target.dispatchEvent(event);\n return event;\n }\n\n}\n\nController.blessings = [ClassPropertiesBlessing, TargetPropertiesBlessing, ValuePropertiesBlessing, OutletPropertiesBlessing];\nController.targets = [];\nController.outlets = [];\nController.values = {};\nexport { Application, AttributeObserver, Context, Controller, ElementObserver, IndexedMultimap, Multimap, SelectorObserver, StringMapObserver, TokenListObserver, ValueListObserver, add, defaultSchema, del, fetch, prune };","let consumer;\nexport async function getConsumer() {\n return consumer || setConsumer(createConsumer().then(setConsumer));\n}\nexport function setConsumer(newConsumer) {\n return consumer = newConsumer;\n}\nexport async function createConsumer() {\n const _await$import = await import(\n /* webpackChunkName: \"actioncable\" */\n \"@rails/actioncable/src\"),\n createConsumer = _await$import.createConsumer;\n\n return createConsumer();\n}\nexport async function subscribeTo(channel, mixin) {\n const _await$getConsumer = await getConsumer(),\n subscriptions = _await$getConsumer.subscriptions;\n\n return subscriptions.create(channel, mixin);\n}","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport { connectStreamSource, disconnectStreamSource } from \"@hotwired/turbo\";\nimport { subscribeTo } from \"./cable\";\nimport snakeize from \"./snakeize\";\n\nclass TurboCableStreamSourceElement extends HTMLElement {\n async connectedCallback() {\n connectStreamSource(this);\n this.subscription = await subscribeTo(this.channel, {\n received: this.dispatchMessageEvent.bind(this)\n });\n }\n\n disconnectedCallback() {\n disconnectStreamSource(this);\n if (this.subscription) this.subscription.unsubscribe();\n }\n\n dispatchMessageEvent(data) {\n const event = new MessageEvent(\"message\", {\n data\n });\n return this.dispatchEvent(event);\n }\n\n get channel() {\n const channel = this.getAttribute(\"channel\");\n const signed_stream_name = this.getAttribute(\"signed-stream-name\");\n return _objectSpread({\n channel,\n signed_stream_name\n }, snakeize(_objectSpread({}, this.dataset)));\n }\n\n}\n\ncustomElements.define(\"turbo-cable-stream-source\", TurboCableStreamSourceElement);","export function overrideMethodWithFormmethod(_ref) {\n let _ref$detail$formSubmi = _ref.detail.formSubmission,\n fetchRequest = _ref$detail$formSubmi.fetchRequest,\n submitter = _ref$detail$formSubmi.submitter;\n\n if (submitter && submitter.formMethod && fetchRequest.body.has(\"_method\")) {\n fetchRequest.body.set(\"_method\", submitter.formMethod);\n }\n}","import \"./cable_stream_source_element\";\nimport { overrideMethodWithFormmethod } from \"./form_submissions\";\nimport * as Turbo from \"@hotwired/turbo\";\nexport { Turbo };\nimport * as cable from \"./cable\";\nexport { cable };\naddEventListener(\"turbo:submit-start\", overrideMethodWithFormmethod);","// Based on https://github.com/nathan7/snakeize\n//\n// This software is released under the MIT license:\n// Permission is hereby granted, free of charge, to any person obtaining a copy of\n// this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to\n// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n// the Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\nexport default function walk(obj) {\n if (!obj || typeof obj !== 'object') return obj;\n if (obj instanceof Date || obj instanceof RegExp) return obj;\n if (Array.isArray(obj)) return obj.map(walk);\n return Object.keys(obj).reduce(function (acc, key) {\n var camel = key[0].toLowerCase() + key.slice(1).replace(/([A-Z]+)/g, function (m, x) {\n return '_' + x.toLowerCase();\n });\n acc[camel] = walk(obj[key]);\n return acc;\n }, {});\n}\n;","var _templateObject, _templateObject2;\n\nfunction _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n/*\nTurbo 7.1.0\nCopyright © 2021 Basecamp, LLC\n */\n(function () {\n if (window.Reflect === undefined || window.customElements === undefined || window.customElements.polyfillWrapFlushCallback) {\n return;\n }\n\n const BuiltInHTMLElement = HTMLElement;\n const wrapperForTheName = {\n 'HTMLElement': function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\n }\n };\n window.HTMLElement = wrapperForTheName['HTMLElement'];\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\n HTMLElement.prototype.constructor = HTMLElement;\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\n})();\n/**\n * The MIT License (MIT)\n * \n * Copyright (c) 2019 Javan Makhmali\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n\n(function (prototype) {\n if (typeof prototype.requestSubmit == \"function\") return;\n\n prototype.requestSubmit = function (submitter) {\n if (submitter) {\n validateSubmitter(submitter, this);\n submitter.click();\n } else {\n submitter = document.createElement(\"input\");\n submitter.type = \"submit\";\n submitter.hidden = true;\n this.appendChild(submitter);\n submitter.click();\n this.removeChild(submitter);\n }\n };\n\n function validateSubmitter(submitter, form) {\n submitter instanceof HTMLElement || raise(TypeError, \"parameter 1 is not of type 'HTMLElement'\");\n submitter.type == \"submit\" || raise(TypeError, \"The specified element is not a submit button\");\n submitter.form == form || raise(DOMException, \"The specified element is not owned by this form element\", \"NotFoundError\");\n }\n\n function raise(errorConstructor, message, name) {\n throw new errorConstructor(\"Failed to execute 'requestSubmit' on 'HTMLFormElement': \" + message + \".\", name);\n }\n})(HTMLFormElement.prototype);\n\nconst submittersByForm = new WeakMap();\n\nfunction findSubmitterFromClickTarget(target) {\n const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n const candidate = element ? element.closest(\"input, button\") : null;\n return (candidate === null || candidate === void 0 ? void 0 : candidate.type) == \"submit\" ? candidate : null;\n}\n\nfunction clickCaptured(event) {\n const submitter = findSubmitterFromClickTarget(event.target);\n\n if (submitter && submitter.form) {\n submittersByForm.set(submitter.form, submitter);\n }\n}\n\n(function () {\n if (\"submitter\" in Event.prototype) return;\n let prototype;\n\n if (\"SubmitEvent\" in window && /Apple Computer/.test(navigator.vendor)) {\n prototype = window.SubmitEvent.prototype;\n } else if (\"SubmitEvent\" in window) {\n return;\n } else {\n prototype = window.Event.prototype;\n }\n\n addEventListener(\"click\", clickCaptured, true);\n Object.defineProperty(prototype, \"submitter\", {\n get() {\n if (this.type == \"submit\" && this.target instanceof HTMLFormElement) {\n return submittersByForm.get(this.target);\n }\n }\n\n });\n})();\n\nvar FrameLoadingStyle;\n\n(function (FrameLoadingStyle) {\n FrameLoadingStyle[\"eager\"] = \"eager\";\n FrameLoadingStyle[\"lazy\"] = \"lazy\";\n})(FrameLoadingStyle || (FrameLoadingStyle = {}));\n\nclass FrameElement extends HTMLElement {\n constructor() {\n super();\n this.loaded = Promise.resolve();\n this.delegate = new FrameElement.delegateConstructor(this);\n }\n\n static get observedAttributes() {\n return [\"disabled\", \"loading\", \"src\"];\n }\n\n connectedCallback() {\n this.delegate.connect();\n }\n\n disconnectedCallback() {\n this.delegate.disconnect();\n }\n\n reload() {\n const src = this.src;\n this.src = null;\n this.src = src;\n }\n\n attributeChangedCallback(name) {\n if (name == \"loading\") {\n this.delegate.loadingStyleChanged();\n } else if (name == \"src\") {\n this.delegate.sourceURLChanged();\n } else {\n this.delegate.disabledChanged();\n }\n }\n\n get src() {\n return this.getAttribute(\"src\");\n }\n\n set src(value) {\n if (value) {\n this.setAttribute(\"src\", value);\n } else {\n this.removeAttribute(\"src\");\n }\n }\n\n get loading() {\n return frameLoadingStyleFromString(this.getAttribute(\"loading\") || \"\");\n }\n\n set loading(value) {\n if (value) {\n this.setAttribute(\"loading\", value);\n } else {\n this.removeAttribute(\"loading\");\n }\n }\n\n get disabled() {\n return this.hasAttribute(\"disabled\");\n }\n\n set disabled(value) {\n if (value) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n }\n\n get autoscroll() {\n return this.hasAttribute(\"autoscroll\");\n }\n\n set autoscroll(value) {\n if (value) {\n this.setAttribute(\"autoscroll\", \"\");\n } else {\n this.removeAttribute(\"autoscroll\");\n }\n }\n\n get complete() {\n return !this.delegate.isLoading;\n }\n\n get isActive() {\n return this.ownerDocument === document && !this.isPreview;\n }\n\n get isPreview() {\n var _a, _b;\n\n return (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.documentElement) === null || _b === void 0 ? void 0 : _b.hasAttribute(\"data-turbo-preview\");\n }\n\n}\n\nfunction frameLoadingStyleFromString(style) {\n switch (style.toLowerCase()) {\n case \"lazy\":\n return FrameLoadingStyle.lazy;\n\n default:\n return FrameLoadingStyle.eager;\n }\n}\n\nfunction expandURL(locatable) {\n return new URL(locatable.toString(), document.baseURI);\n}\n\nfunction getAnchor(url) {\n let anchorMatch;\n\n if (url.hash) {\n return url.hash.slice(1);\n } else if (anchorMatch = url.href.match(/#(.*)$/)) {\n return anchorMatch[1];\n }\n}\n\nfunction getAction(form, submitter) {\n const action = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"formaction\")) || form.getAttribute(\"action\") || form.action;\n return expandURL(action);\n}\n\nfunction getExtension(url) {\n return (getLastPathComponent(url).match(/\\.[^.]*$/) || [])[0] || \"\";\n}\n\nfunction isHTML(url) {\n return !!getExtension(url).match(/^(?:|\\.(?:htm|html|xhtml))$/);\n}\n\nfunction isPrefixedBy(baseURL, url) {\n const prefix = getPrefix(url);\n return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix);\n}\n\nfunction locationIsVisitable(location, rootLocation) {\n return isPrefixedBy(location, rootLocation) && isHTML(location);\n}\n\nfunction getRequestURL(url) {\n const anchor = getAnchor(url);\n return anchor != null ? url.href.slice(0, -(anchor.length + 1)) : url.href;\n}\n\nfunction toCacheKey(url) {\n return getRequestURL(url);\n}\n\nfunction urlsAreEqual(left, right) {\n return expandURL(left).href == expandURL(right).href;\n}\n\nfunction getPathComponents(url) {\n return url.pathname.split(\"/\").slice(1);\n}\n\nfunction getLastPathComponent(url) {\n return getPathComponents(url).slice(-1)[0];\n}\n\nfunction getPrefix(url) {\n return addTrailingSlash(url.origin + url.pathname);\n}\n\nfunction addTrailingSlash(value) {\n return value.endsWith(\"/\") ? value : value + \"/\";\n}\n\nclass FetchResponse {\n constructor(response) {\n this.response = response;\n }\n\n get succeeded() {\n return this.response.ok;\n }\n\n get failed() {\n return !this.succeeded;\n }\n\n get clientError() {\n return this.statusCode >= 400 && this.statusCode <= 499;\n }\n\n get serverError() {\n return this.statusCode >= 500 && this.statusCode <= 599;\n }\n\n get redirected() {\n return this.response.redirected;\n }\n\n get location() {\n return expandURL(this.response.url);\n }\n\n get isHTML() {\n return this.contentType && this.contentType.match(/^(?:text\\/([^\\s;,]+\\b)?html|application\\/xhtml\\+xml)\\b/);\n }\n\n get statusCode() {\n return this.response.status;\n }\n\n get contentType() {\n return this.header(\"Content-Type\");\n }\n\n get responseText() {\n return this.response.clone().text();\n }\n\n get responseHTML() {\n if (this.isHTML) {\n return this.response.clone().text();\n } else {\n return Promise.resolve(undefined);\n }\n }\n\n header(name) {\n return this.response.headers.get(name);\n }\n\n}\n\nfunction dispatch(eventName) {\n let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n target = _ref.target,\n cancelable = _ref.cancelable,\n detail = _ref.detail;\n\n const event = new CustomEvent(eventName, {\n cancelable,\n bubbles: true,\n detail\n });\n\n if (target && target.isConnected) {\n target.dispatchEvent(event);\n } else {\n document.documentElement.dispatchEvent(event);\n }\n\n return event;\n}\n\nfunction nextAnimationFrame() {\n return new Promise(resolve => requestAnimationFrame(() => resolve()));\n}\n\nfunction nextEventLoopTick() {\n return new Promise(resolve => setTimeout(() => resolve(), 0));\n}\n\nfunction nextMicrotask() {\n return Promise.resolve();\n}\n\nfunction parseHTMLDocument() {\n let html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"\";\n return new DOMParser().parseFromString(html, \"text/html\");\n}\n\nfunction unindent(strings) {\n for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n values[_key - 1] = arguments[_key];\n }\n\n const lines = interpolate(strings, values).replace(/^\\n/, \"\").split(\"\\n\");\n const match = lines[0].match(/^\\s+/);\n const indent = match ? match[0].length : 0;\n return lines.map(line => line.slice(indent)).join(\"\\n\");\n}\n\nfunction interpolate(strings, values) {\n return strings.reduce((result, string, i) => {\n const value = values[i] == undefined ? \"\" : values[i];\n return result + string + value;\n }, \"\");\n}\n\nfunction uuid() {\n return Array.apply(null, {\n length: 36\n }).map((_, i) => {\n if (i == 8 || i == 13 || i == 18 || i == 23) {\n return \"-\";\n } else if (i == 14) {\n return \"4\";\n } else if (i == 19) {\n return (Math.floor(Math.random() * 4) + 8).toString(16);\n } else {\n return Math.floor(Math.random() * 15).toString(16);\n }\n }).join(\"\");\n}\n\nfunction getAttribute(attributeName) {\n for (var _len2 = arguments.length, elements = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n elements[_key2 - 1] = arguments[_key2];\n }\n\n for (const value of elements.map(element => element === null || element === void 0 ? void 0 : element.getAttribute(attributeName))) {\n if (typeof value == \"string\") return value;\n }\n\n return null;\n}\n\nfunction markAsBusy() {\n for (var _len3 = arguments.length, elements = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n elements[_key3] = arguments[_key3];\n }\n\n for (const element of elements) {\n if (element.localName == \"turbo-frame\") {\n element.setAttribute(\"busy\", \"\");\n }\n\n element.setAttribute(\"aria-busy\", \"true\");\n }\n}\n\nfunction clearBusyState() {\n for (var _len4 = arguments.length, elements = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n elements[_key4] = arguments[_key4];\n }\n\n for (const element of elements) {\n if (element.localName == \"turbo-frame\") {\n element.removeAttribute(\"busy\");\n }\n\n element.removeAttribute(\"aria-busy\");\n }\n}\n\nvar FetchMethod;\n\n(function (FetchMethod) {\n FetchMethod[FetchMethod[\"get\"] = 0] = \"get\";\n FetchMethod[FetchMethod[\"post\"] = 1] = \"post\";\n FetchMethod[FetchMethod[\"put\"] = 2] = \"put\";\n FetchMethod[FetchMethod[\"patch\"] = 3] = \"patch\";\n FetchMethod[FetchMethod[\"delete\"] = 4] = \"delete\";\n})(FetchMethod || (FetchMethod = {}));\n\nfunction fetchMethodFromString(method) {\n switch (method.toLowerCase()) {\n case \"get\":\n return FetchMethod.get;\n\n case \"post\":\n return FetchMethod.post;\n\n case \"put\":\n return FetchMethod.put;\n\n case \"patch\":\n return FetchMethod.patch;\n\n case \"delete\":\n return FetchMethod.delete;\n }\n}\n\nclass FetchRequest {\n constructor(delegate, method, location) {\n let body = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new URLSearchParams();\n let target = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;\n this.abortController = new AbortController();\n\n this.resolveRequestPromise = value => {};\n\n this.delegate = delegate;\n this.method = method;\n this.headers = this.defaultHeaders;\n this.body = body;\n this.url = location;\n this.target = target;\n }\n\n get location() {\n return this.url;\n }\n\n get params() {\n return this.url.searchParams;\n }\n\n get entries() {\n return this.body ? Array.from(this.body.entries()) : [];\n }\n\n cancel() {\n this.abortController.abort();\n }\n\n async perform() {\n var _a, _b;\n\n const fetchOptions = this.fetchOptions;\n (_b = (_a = this.delegate).prepareHeadersForRequest) === null || _b === void 0 ? void 0 : _b.call(_a, this.headers, this);\n await this.allowRequestToBeIntercepted(fetchOptions);\n\n try {\n this.delegate.requestStarted(this);\n const response = await fetch(this.url.href, fetchOptions);\n return await this.receive(response);\n } catch (error) {\n if (error.name !== 'AbortError') {\n this.delegate.requestErrored(this, error);\n throw error;\n }\n } finally {\n this.delegate.requestFinished(this);\n }\n }\n\n async receive(response) {\n const fetchResponse = new FetchResponse(response);\n const event = dispatch(\"turbo:before-fetch-response\", {\n cancelable: true,\n detail: {\n fetchResponse\n },\n target: this.target\n });\n\n if (event.defaultPrevented) {\n this.delegate.requestPreventedHandlingResponse(this, fetchResponse);\n } else if (fetchResponse.succeeded) {\n this.delegate.requestSucceededWithResponse(this, fetchResponse);\n } else {\n this.delegate.requestFailedWithResponse(this, fetchResponse);\n }\n\n return fetchResponse;\n }\n\n get fetchOptions() {\n var _a;\n\n return {\n method: FetchMethod[this.method].toUpperCase(),\n credentials: \"same-origin\",\n headers: this.headers,\n redirect: \"follow\",\n body: this.isIdempotent ? null : this.body,\n signal: this.abortSignal,\n referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href\n };\n }\n\n get defaultHeaders() {\n return {\n \"Accept\": \"text/html, application/xhtml+xml\"\n };\n }\n\n get isIdempotent() {\n return this.method == FetchMethod.get;\n }\n\n get abortSignal() {\n return this.abortController.signal;\n }\n\n async allowRequestToBeIntercepted(fetchOptions) {\n const requestInterception = new Promise(resolve => this.resolveRequestPromise = resolve);\n const event = dispatch(\"turbo:before-fetch-request\", {\n cancelable: true,\n detail: {\n fetchOptions,\n url: this.url,\n resume: this.resolveRequestPromise\n },\n target: this.target\n });\n if (event.defaultPrevented) await requestInterception;\n }\n\n}\n\nclass AppearanceObserver {\n constructor(delegate, element) {\n this.started = false;\n\n this.intersect = entries => {\n const lastEntry = entries.slice(-1)[0];\n\n if (lastEntry === null || lastEntry === void 0 ? void 0 : lastEntry.isIntersecting) {\n this.delegate.elementAppearedInViewport(this.element);\n }\n };\n\n this.delegate = delegate;\n this.element = element;\n this.intersectionObserver = new IntersectionObserver(this.intersect);\n }\n\n start() {\n if (!this.started) {\n this.started = true;\n this.intersectionObserver.observe(this.element);\n }\n }\n\n stop() {\n if (this.started) {\n this.started = false;\n this.intersectionObserver.unobserve(this.element);\n }\n }\n\n}\n\nclass StreamMessage {\n constructor(html) {\n this.templateElement = document.createElement(\"template\");\n this.templateElement.innerHTML = html;\n }\n\n static wrap(message) {\n if (typeof message == \"string\") {\n return new this(message);\n } else {\n return message;\n }\n }\n\n get fragment() {\n const fragment = document.createDocumentFragment();\n\n for (const element of this.foreignElements) {\n fragment.appendChild(document.importNode(element, true));\n }\n\n return fragment;\n }\n\n get foreignElements() {\n return this.templateChildren.reduce((streamElements, child) => {\n if (child.tagName.toLowerCase() == \"turbo-stream\") {\n return [...streamElements, child];\n } else {\n return streamElements;\n }\n }, []);\n }\n\n get templateChildren() {\n return Array.from(this.templateElement.content.children);\n }\n\n}\n\nStreamMessage.contentType = \"text/vnd.turbo-stream.html\";\nvar FormSubmissionState;\n\n(function (FormSubmissionState) {\n FormSubmissionState[FormSubmissionState[\"initialized\"] = 0] = \"initialized\";\n FormSubmissionState[FormSubmissionState[\"requesting\"] = 1] = \"requesting\";\n FormSubmissionState[FormSubmissionState[\"waiting\"] = 2] = \"waiting\";\n FormSubmissionState[FormSubmissionState[\"receiving\"] = 3] = \"receiving\";\n FormSubmissionState[FormSubmissionState[\"stopping\"] = 4] = \"stopping\";\n FormSubmissionState[FormSubmissionState[\"stopped\"] = 5] = \"stopped\";\n})(FormSubmissionState || (FormSubmissionState = {}));\n\nvar FormEnctype;\n\n(function (FormEnctype) {\n FormEnctype[\"urlEncoded\"] = \"application/x-www-form-urlencoded\";\n FormEnctype[\"multipart\"] = \"multipart/form-data\";\n FormEnctype[\"plain\"] = \"text/plain\";\n})(FormEnctype || (FormEnctype = {}));\n\nfunction formEnctypeFromString(encoding) {\n switch (encoding.toLowerCase()) {\n case FormEnctype.multipart:\n return FormEnctype.multipart;\n\n case FormEnctype.plain:\n return FormEnctype.plain;\n\n default:\n return FormEnctype.urlEncoded;\n }\n}\n\nclass FormSubmission {\n constructor(delegate, formElement, submitter) {\n let mustRedirect = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n this.state = FormSubmissionState.initialized;\n this.delegate = delegate;\n this.formElement = formElement;\n this.submitter = submitter;\n this.formData = buildFormData(formElement, submitter);\n this.location = expandURL(this.action);\n\n if (this.method == FetchMethod.get) {\n mergeFormDataEntries(this.location, [...this.body.entries()]);\n }\n\n this.fetchRequest = new FetchRequest(this, this.method, this.location, this.body, this.formElement);\n this.mustRedirect = mustRedirect;\n }\n\n static confirmMethod(message, element) {\n return confirm(message);\n }\n\n get method() {\n var _a;\n\n const method = ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute(\"formmethod\")) || this.formElement.getAttribute(\"method\") || \"\";\n return fetchMethodFromString(method.toLowerCase()) || FetchMethod.get;\n }\n\n get action() {\n var _a;\n\n const formElementAction = typeof this.formElement.action === 'string' ? this.formElement.action : null;\n return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute(\"formaction\")) || this.formElement.getAttribute(\"action\") || formElementAction || \"\";\n }\n\n get body() {\n if (this.enctype == FormEnctype.urlEncoded || this.method == FetchMethod.get) {\n return new URLSearchParams(this.stringFormData);\n } else {\n return this.formData;\n }\n }\n\n get enctype() {\n var _a;\n\n return formEnctypeFromString(((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute(\"formenctype\")) || this.formElement.enctype);\n }\n\n get isIdempotent() {\n return this.fetchRequest.isIdempotent;\n }\n\n get stringFormData() {\n return [...this.formData].reduce((entries, _ref2) => {\n let _ref3 = _slicedToArray(_ref2, 2),\n name = _ref3[0],\n value = _ref3[1];\n\n return entries.concat(typeof value == \"string\" ? [[name, value]] : []);\n }, []);\n }\n\n get confirmationMessage() {\n return this.formElement.getAttribute(\"data-turbo-confirm\");\n }\n\n get needsConfirmation() {\n return this.confirmationMessage !== null;\n }\n\n async start() {\n const _FormSubmissionState = FormSubmissionState,\n initialized = _FormSubmissionState.initialized,\n requesting = _FormSubmissionState.requesting;\n\n if (this.needsConfirmation) {\n const answer = FormSubmission.confirmMethod(this.confirmationMessage, this.formElement);\n\n if (!answer) {\n return;\n }\n }\n\n if (this.state == initialized) {\n this.state = requesting;\n return this.fetchRequest.perform();\n }\n }\n\n stop() {\n const _FormSubmissionState2 = FormSubmissionState,\n stopping = _FormSubmissionState2.stopping,\n stopped = _FormSubmissionState2.stopped;\n\n if (this.state != stopping && this.state != stopped) {\n this.state = stopping;\n this.fetchRequest.cancel();\n return true;\n }\n }\n\n prepareHeadersForRequest(headers, request) {\n if (!request.isIdempotent) {\n const token = getCookieValue(getMetaContent(\"csrf-param\")) || getMetaContent(\"csrf-token\");\n\n if (token) {\n headers[\"X-CSRF-Token\"] = token;\n }\n\n headers[\"Accept\"] = [StreamMessage.contentType, headers[\"Accept\"]].join(\", \");\n }\n }\n\n requestStarted(request) {\n var _a;\n\n this.state = FormSubmissionState.waiting;\n (_a = this.submitter) === null || _a === void 0 ? void 0 : _a.setAttribute(\"disabled\", \"\");\n dispatch(\"turbo:submit-start\", {\n target: this.formElement,\n detail: {\n formSubmission: this\n }\n });\n this.delegate.formSubmissionStarted(this);\n }\n\n requestPreventedHandlingResponse(request, response) {\n this.result = {\n success: response.succeeded,\n fetchResponse: response\n };\n }\n\n requestSucceededWithResponse(request, response) {\n if (response.clientError || response.serverError) {\n this.delegate.formSubmissionFailedWithResponse(this, response);\n } else if (this.requestMustRedirect(request) && responseSucceededWithoutRedirect(response)) {\n const error = new Error(\"Form responses must redirect to another location\");\n this.delegate.formSubmissionErrored(this, error);\n } else {\n this.state = FormSubmissionState.receiving;\n this.result = {\n success: true,\n fetchResponse: response\n };\n this.delegate.formSubmissionSucceededWithResponse(this, response);\n }\n }\n\n requestFailedWithResponse(request, response) {\n this.result = {\n success: false,\n fetchResponse: response\n };\n this.delegate.formSubmissionFailedWithResponse(this, response);\n }\n\n requestErrored(request, error) {\n this.result = {\n success: false,\n error\n };\n this.delegate.formSubmissionErrored(this, error);\n }\n\n requestFinished(request) {\n var _a;\n\n this.state = FormSubmissionState.stopped;\n (_a = this.submitter) === null || _a === void 0 ? void 0 : _a.removeAttribute(\"disabled\");\n dispatch(\"turbo:submit-end\", {\n target: this.formElement,\n detail: Object.assign({\n formSubmission: this\n }, this.result)\n });\n this.delegate.formSubmissionFinished(this);\n }\n\n requestMustRedirect(request) {\n return !request.isIdempotent && this.mustRedirect;\n }\n\n}\n\nfunction buildFormData(formElement, submitter) {\n const formData = new FormData(formElement);\n const name = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"name\");\n const value = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"value\");\n\n if (name && value != null && formData.get(name) != value) {\n formData.append(name, value);\n }\n\n return formData;\n}\n\nfunction getCookieValue(cookieName) {\n if (cookieName != null) {\n const cookies = document.cookie ? document.cookie.split(\"; \") : [];\n const cookie = cookies.find(cookie => cookie.startsWith(cookieName));\n\n if (cookie) {\n const value = cookie.split(\"=\").slice(1).join(\"=\");\n return value ? decodeURIComponent(value) : undefined;\n }\n }\n}\n\nfunction getMetaContent(name) {\n const element = document.querySelector(\"meta[name=\\\"\".concat(name, \"\\\"]\"));\n return element && element.content;\n}\n\nfunction responseSucceededWithoutRedirect(response) {\n return response.statusCode == 200 && !response.redirected;\n}\n\nfunction mergeFormDataEntries(url, entries) {\n const searchParams = new URLSearchParams();\n\n for (const _ref4 of entries) {\n var _ref5 = _slicedToArray(_ref4, 2);\n\n const name = _ref5[0];\n const value = _ref5[1];\n if (value instanceof File) continue;\n searchParams.append(name, value);\n }\n\n url.search = searchParams.toString();\n return url;\n}\n\nclass Snapshot {\n constructor(element) {\n this.element = element;\n }\n\n get children() {\n return [...this.element.children];\n }\n\n hasAnchor(anchor) {\n return this.getElementForAnchor(anchor) != null;\n }\n\n getElementForAnchor(anchor) {\n return anchor ? this.element.querySelector(\"[id='\".concat(anchor, \"'], a[name='\").concat(anchor, \"']\")) : null;\n }\n\n get isConnected() {\n return this.element.isConnected;\n }\n\n get firstAutofocusableElement() {\n return this.element.querySelector(\"[autofocus]\");\n }\n\n get permanentElements() {\n return [...this.element.querySelectorAll(\"[id][data-turbo-permanent]\")];\n }\n\n getPermanentElementById(id) {\n return this.element.querySelector(\"#\".concat(id, \"[data-turbo-permanent]\"));\n }\n\n getPermanentElementMapForSnapshot(snapshot) {\n const permanentElementMap = {};\n\n for (const currentPermanentElement of this.permanentElements) {\n const id = currentPermanentElement.id;\n const newPermanentElement = snapshot.getPermanentElementById(id);\n\n if (newPermanentElement) {\n permanentElementMap[id] = [currentPermanentElement, newPermanentElement];\n }\n }\n\n return permanentElementMap;\n }\n\n}\n\nclass FormInterceptor {\n constructor(delegate, element) {\n this.submitBubbled = event => {\n const form = event.target;\n\n if (!event.defaultPrevented && form instanceof HTMLFormElement && form.closest(\"turbo-frame, html\") == this.element) {\n const submitter = event.submitter || undefined;\n const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"formmethod\")) || form.method;\n\n if (method != \"dialog\" && this.delegate.shouldInterceptFormSubmission(form, submitter)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n this.delegate.formSubmissionIntercepted(form, submitter);\n }\n }\n };\n\n this.delegate = delegate;\n this.element = element;\n }\n\n start() {\n this.element.addEventListener(\"submit\", this.submitBubbled);\n }\n\n stop() {\n this.element.removeEventListener(\"submit\", this.submitBubbled);\n }\n\n}\n\nclass View {\n constructor(delegate, element) {\n this.resolveRenderPromise = value => {};\n\n this.resolveInterceptionPromise = value => {};\n\n this.delegate = delegate;\n this.element = element;\n }\n\n scrollToAnchor(anchor) {\n const element = this.snapshot.getElementForAnchor(anchor);\n\n if (element) {\n this.scrollToElement(element);\n this.focusElement(element);\n } else {\n this.scrollToPosition({\n x: 0,\n y: 0\n });\n }\n }\n\n scrollToAnchorFromLocation(location) {\n this.scrollToAnchor(getAnchor(location));\n }\n\n scrollToElement(element) {\n element.scrollIntoView();\n }\n\n focusElement(element) {\n if (element instanceof HTMLElement) {\n if (element.hasAttribute(\"tabindex\")) {\n element.focus();\n } else {\n element.setAttribute(\"tabindex\", \"-1\");\n element.focus();\n element.removeAttribute(\"tabindex\");\n }\n }\n }\n\n scrollToPosition(_ref6) {\n let x = _ref6.x,\n y = _ref6.y;\n this.scrollRoot.scrollTo(x, y);\n }\n\n scrollToTop() {\n this.scrollToPosition({\n x: 0,\n y: 0\n });\n }\n\n get scrollRoot() {\n return window;\n }\n\n async render(renderer) {\n const isPreview = renderer.isPreview,\n shouldRender = renderer.shouldRender,\n snapshot = renderer.newSnapshot;\n\n if (shouldRender) {\n try {\n this.renderPromise = new Promise(resolve => this.resolveRenderPromise = resolve);\n this.renderer = renderer;\n this.prepareToRenderSnapshot(renderer);\n const renderInterception = new Promise(resolve => this.resolveInterceptionPromise = resolve);\n const immediateRender = this.delegate.allowsImmediateRender(snapshot, this.resolveInterceptionPromise);\n if (!immediateRender) await renderInterception;\n await this.renderSnapshot(renderer);\n this.delegate.viewRenderedSnapshot(snapshot, isPreview);\n this.finishRenderingSnapshot(renderer);\n } finally {\n delete this.renderer;\n this.resolveRenderPromise(undefined);\n delete this.renderPromise;\n }\n } else {\n this.invalidate();\n }\n }\n\n invalidate() {\n this.delegate.viewInvalidated();\n }\n\n prepareToRenderSnapshot(renderer) {\n this.markAsPreview(renderer.isPreview);\n renderer.prepareToRender();\n }\n\n markAsPreview(isPreview) {\n if (isPreview) {\n this.element.setAttribute(\"data-turbo-preview\", \"\");\n } else {\n this.element.removeAttribute(\"data-turbo-preview\");\n }\n }\n\n async renderSnapshot(renderer) {\n await renderer.render();\n }\n\n finishRenderingSnapshot(renderer) {\n renderer.finishRendering();\n }\n\n}\n\nclass FrameView extends View {\n invalidate() {\n this.element.innerHTML = \"\";\n }\n\n get snapshot() {\n return new Snapshot(this.element);\n }\n\n}\n\nclass LinkInterceptor {\n constructor(delegate, element) {\n this.clickBubbled = event => {\n if (this.respondsToEventTarget(event.target)) {\n this.clickEvent = event;\n } else {\n delete this.clickEvent;\n }\n };\n\n this.linkClicked = event => {\n if (this.clickEvent && this.respondsToEventTarget(event.target) && event.target instanceof Element) {\n if (this.delegate.shouldInterceptLinkClick(event.target, event.detail.url)) {\n this.clickEvent.preventDefault();\n event.preventDefault();\n this.delegate.linkClickIntercepted(event.target, event.detail.url);\n }\n }\n\n delete this.clickEvent;\n };\n\n this.willVisit = () => {\n delete this.clickEvent;\n };\n\n this.delegate = delegate;\n this.element = element;\n }\n\n start() {\n this.element.addEventListener(\"click\", this.clickBubbled);\n document.addEventListener(\"turbo:click\", this.linkClicked);\n document.addEventListener(\"turbo:before-visit\", this.willVisit);\n }\n\n stop() {\n this.element.removeEventListener(\"click\", this.clickBubbled);\n document.removeEventListener(\"turbo:click\", this.linkClicked);\n document.removeEventListener(\"turbo:before-visit\", this.willVisit);\n }\n\n respondsToEventTarget(target) {\n const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n return element && element.closest(\"turbo-frame, html\") == this.element;\n }\n\n}\n\nclass Bardo {\n constructor(permanentElementMap) {\n this.permanentElementMap = permanentElementMap;\n }\n\n static preservingPermanentElements(permanentElementMap, callback) {\n const bardo = new this(permanentElementMap);\n bardo.enter();\n callback();\n bardo.leave();\n }\n\n enter() {\n for (const id in this.permanentElementMap) {\n const _this$permanentElemen = _slicedToArray(this.permanentElementMap[id], 2),\n newPermanentElement = _this$permanentElemen[1];\n\n this.replaceNewPermanentElementWithPlaceholder(newPermanentElement);\n }\n }\n\n leave() {\n for (const id in this.permanentElementMap) {\n const _this$permanentElemen2 = _slicedToArray(this.permanentElementMap[id], 1),\n currentPermanentElement = _this$permanentElemen2[0];\n\n this.replaceCurrentPermanentElementWithClone(currentPermanentElement);\n this.replacePlaceholderWithPermanentElement(currentPermanentElement);\n }\n }\n\n replaceNewPermanentElementWithPlaceholder(permanentElement) {\n const placeholder = createPlaceholderForPermanentElement(permanentElement);\n permanentElement.replaceWith(placeholder);\n }\n\n replaceCurrentPermanentElementWithClone(permanentElement) {\n const clone = permanentElement.cloneNode(true);\n permanentElement.replaceWith(clone);\n }\n\n replacePlaceholderWithPermanentElement(permanentElement) {\n const placeholder = this.getPlaceholderById(permanentElement.id);\n placeholder === null || placeholder === void 0 ? void 0 : placeholder.replaceWith(permanentElement);\n }\n\n getPlaceholderById(id) {\n return this.placeholders.find(element => element.content == id);\n }\n\n get placeholders() {\n return [...document.querySelectorAll(\"meta[name=turbo-permanent-placeholder][content]\")];\n }\n\n}\n\nfunction createPlaceholderForPermanentElement(permanentElement) {\n const element = document.createElement(\"meta\");\n element.setAttribute(\"name\", \"turbo-permanent-placeholder\");\n element.setAttribute(\"content\", permanentElement.id);\n return element;\n}\n\nclass Renderer {\n constructor(currentSnapshot, newSnapshot, isPreview) {\n let willRender = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;\n this.currentSnapshot = currentSnapshot;\n this.newSnapshot = newSnapshot;\n this.isPreview = isPreview;\n this.willRender = willRender;\n this.promise = new Promise((resolve, reject) => this.resolvingFunctions = {\n resolve,\n reject\n });\n }\n\n get shouldRender() {\n return true;\n }\n\n prepareToRender() {\n return;\n }\n\n finishRendering() {\n if (this.resolvingFunctions) {\n this.resolvingFunctions.resolve();\n delete this.resolvingFunctions;\n }\n }\n\n createScriptElement(element) {\n if (element.getAttribute(\"data-turbo-eval\") == \"false\") {\n return element;\n } else {\n const createdScriptElement = document.createElement(\"script\");\n\n if (this.cspNonce) {\n createdScriptElement.nonce = this.cspNonce;\n }\n\n createdScriptElement.textContent = element.textContent;\n createdScriptElement.async = false;\n copyElementAttributes(createdScriptElement, element);\n return createdScriptElement;\n }\n }\n\n preservingPermanentElements(callback) {\n Bardo.preservingPermanentElements(this.permanentElementMap, callback);\n }\n\n focusFirstAutofocusableElement() {\n const element = this.connectedSnapshot.firstAutofocusableElement;\n\n if (elementIsFocusable(element)) {\n element.focus();\n }\n }\n\n get connectedSnapshot() {\n return this.newSnapshot.isConnected ? this.newSnapshot : this.currentSnapshot;\n }\n\n get currentElement() {\n return this.currentSnapshot.element;\n }\n\n get newElement() {\n return this.newSnapshot.element;\n }\n\n get permanentElementMap() {\n return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot);\n }\n\n get cspNonce() {\n var _a;\n\n return (_a = document.head.querySelector('meta[name=\"csp-nonce\"]')) === null || _a === void 0 ? void 0 : _a.getAttribute(\"content\");\n }\n\n}\n\nfunction copyElementAttributes(destinationElement, sourceElement) {\n for (const _ref7 of [...sourceElement.attributes]) {\n const name = _ref7.name;\n const value = _ref7.value;\n destinationElement.setAttribute(name, value);\n }\n}\n\nfunction elementIsFocusable(element) {\n return element && typeof element.focus == \"function\";\n}\n\nclass FrameRenderer extends Renderer {\n get shouldRender() {\n return true;\n }\n\n async render() {\n await nextAnimationFrame();\n this.preservingPermanentElements(() => {\n this.loadFrameElement();\n });\n this.scrollFrameIntoView();\n await nextAnimationFrame();\n this.focusFirstAutofocusableElement();\n await nextAnimationFrame();\n this.activateScriptElements();\n }\n\n loadFrameElement() {\n var _a;\n\n const destinationRange = document.createRange();\n destinationRange.selectNodeContents(this.currentElement);\n destinationRange.deleteContents();\n const frameElement = this.newElement;\n const sourceRange = (_a = frameElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.createRange();\n\n if (sourceRange) {\n sourceRange.selectNodeContents(frameElement);\n this.currentElement.appendChild(sourceRange.extractContents());\n }\n }\n\n scrollFrameIntoView() {\n if (this.currentElement.autoscroll || this.newElement.autoscroll) {\n const element = this.currentElement.firstElementChild;\n const block = readScrollLogicalPosition(this.currentElement.getAttribute(\"data-autoscroll-block\"), \"end\");\n\n if (element) {\n element.scrollIntoView({\n block\n });\n return true;\n }\n }\n\n return false;\n }\n\n activateScriptElements() {\n for (const inertScriptElement of this.newScriptElements) {\n const activatedScriptElement = this.createScriptElement(inertScriptElement);\n inertScriptElement.replaceWith(activatedScriptElement);\n }\n }\n\n get newScriptElements() {\n return this.currentElement.querySelectorAll(\"script\");\n }\n\n}\n\nfunction readScrollLogicalPosition(value, defaultValue) {\n if (value == \"end\" || value == \"start\" || value == \"center\" || value == \"nearest\") {\n return value;\n } else {\n return defaultValue;\n }\n}\n\nclass ProgressBar {\n constructor() {\n this.hiding = false;\n this.value = 0;\n this.visible = false;\n\n this.trickle = () => {\n this.setValue(this.value + Math.random() / 100);\n };\n\n this.stylesheetElement = this.createStylesheetElement();\n this.progressElement = this.createProgressElement();\n this.installStylesheetElement();\n this.setValue(0);\n }\n\n static get defaultCSS() {\n return unindent(_templateObject || (_templateObject = _taggedTemplateLiteral([\"\\n .turbo-progress-bar {\\n position: fixed;\\n display: block;\\n top: 0;\\n left: 0;\\n height: 3px;\\n background: #0076ff;\\n z-index: 9999;\\n transition:\\n width \", \"ms ease-out,\\n opacity \", \"ms \", \"ms ease-in;\\n transform: translate3d(0, 0, 0);\\n }\\n \"])), ProgressBar.animationDuration, ProgressBar.animationDuration / 2, ProgressBar.animationDuration / 2);\n }\n\n show() {\n if (!this.visible) {\n this.visible = true;\n this.installProgressElement();\n this.startTrickling();\n }\n }\n\n hide() {\n if (this.visible && !this.hiding) {\n this.hiding = true;\n this.fadeProgressElement(() => {\n this.uninstallProgressElement();\n this.stopTrickling();\n this.visible = false;\n this.hiding = false;\n });\n }\n }\n\n setValue(value) {\n this.value = value;\n this.refresh();\n }\n\n installStylesheetElement() {\n document.head.insertBefore(this.stylesheetElement, document.head.firstChild);\n }\n\n installProgressElement() {\n this.progressElement.style.width = \"0\";\n this.progressElement.style.opacity = \"1\";\n document.documentElement.insertBefore(this.progressElement, document.body);\n this.refresh();\n }\n\n fadeProgressElement(callback) {\n this.progressElement.style.opacity = \"0\";\n setTimeout(callback, ProgressBar.animationDuration * 1.5);\n }\n\n uninstallProgressElement() {\n if (this.progressElement.parentNode) {\n document.documentElement.removeChild(this.progressElement);\n }\n }\n\n startTrickling() {\n if (!this.trickleInterval) {\n this.trickleInterval = window.setInterval(this.trickle, ProgressBar.animationDuration);\n }\n }\n\n stopTrickling() {\n window.clearInterval(this.trickleInterval);\n delete this.trickleInterval;\n }\n\n refresh() {\n requestAnimationFrame(() => {\n this.progressElement.style.width = \"\".concat(10 + this.value * 90, \"%\");\n });\n }\n\n createStylesheetElement() {\n const element = document.createElement(\"style\");\n element.type = \"text/css\";\n element.textContent = ProgressBar.defaultCSS;\n return element;\n }\n\n createProgressElement() {\n const element = document.createElement(\"div\");\n element.className = \"turbo-progress-bar\";\n return element;\n }\n\n}\n\nProgressBar.animationDuration = 300;\n\nclass HeadSnapshot extends Snapshot {\n constructor() {\n super(...arguments);\n this.detailsByOuterHTML = this.children.filter(element => !elementIsNoscript(element)).map(element => elementWithoutNonce(element)).reduce((result, element) => {\n const outerHTML = element.outerHTML;\n const details = outerHTML in result ? result[outerHTML] : {\n type: elementType(element),\n tracked: elementIsTracked(element),\n elements: []\n };\n return Object.assign(Object.assign({}, result), {\n [outerHTML]: Object.assign(Object.assign({}, details), {\n elements: [...details.elements, element]\n })\n });\n }, {});\n }\n\n get trackedElementSignature() {\n return Object.keys(this.detailsByOuterHTML).filter(outerHTML => this.detailsByOuterHTML[outerHTML].tracked).join(\"\");\n }\n\n getScriptElementsNotInSnapshot(snapshot) {\n return this.getElementsMatchingTypeNotInSnapshot(\"script\", snapshot);\n }\n\n getStylesheetElementsNotInSnapshot(snapshot) {\n return this.getElementsMatchingTypeNotInSnapshot(\"stylesheet\", snapshot);\n }\n\n getElementsMatchingTypeNotInSnapshot(matchedType, snapshot) {\n return Object.keys(this.detailsByOuterHTML).filter(outerHTML => !(outerHTML in snapshot.detailsByOuterHTML)).map(outerHTML => this.detailsByOuterHTML[outerHTML]).filter(_ref8 => {\n let type = _ref8.type;\n return type == matchedType;\n }).map(_ref9 => {\n let _ref9$elements = _slicedToArray(_ref9.elements, 1),\n element = _ref9$elements[0];\n\n return element;\n });\n }\n\n get provisionalElements() {\n return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => {\n const _this$detailsByOuterH = this.detailsByOuterHTML[outerHTML],\n type = _this$detailsByOuterH.type,\n tracked = _this$detailsByOuterH.tracked,\n elements = _this$detailsByOuterH.elements;\n\n if (type == null && !tracked) {\n return [...result, ...elements];\n } else if (elements.length > 1) {\n return [...result, ...elements.slice(1)];\n } else {\n return result;\n }\n }, []);\n }\n\n getMetaValue(name) {\n const element = this.findMetaElementByName(name);\n return element ? element.getAttribute(\"content\") : null;\n }\n\n findMetaElementByName(name) {\n return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => {\n const _this$detailsByOuterH2 = _slicedToArray(this.detailsByOuterHTML[outerHTML].elements, 1),\n element = _this$detailsByOuterH2[0];\n\n return elementIsMetaElementWithName(element, name) ? element : result;\n }, undefined);\n }\n\n}\n\nfunction elementType(element) {\n if (elementIsScript(element)) {\n return \"script\";\n } else if (elementIsStylesheet(element)) {\n return \"stylesheet\";\n }\n}\n\nfunction elementIsTracked(element) {\n return element.getAttribute(\"data-turbo-track\") == \"reload\";\n}\n\nfunction elementIsScript(element) {\n const tagName = element.tagName.toLowerCase();\n return tagName == \"script\";\n}\n\nfunction elementIsNoscript(element) {\n const tagName = element.tagName.toLowerCase();\n return tagName == \"noscript\";\n}\n\nfunction elementIsStylesheet(element) {\n const tagName = element.tagName.toLowerCase();\n return tagName == \"style\" || tagName == \"link\" && element.getAttribute(\"rel\") == \"stylesheet\";\n}\n\nfunction elementIsMetaElementWithName(element, name) {\n const tagName = element.tagName.toLowerCase();\n return tagName == \"meta\" && element.getAttribute(\"name\") == name;\n}\n\nfunction elementWithoutNonce(element) {\n if (element.hasAttribute(\"nonce\")) {\n element.setAttribute(\"nonce\", \"\");\n }\n\n return element;\n}\n\nclass PageSnapshot extends Snapshot {\n constructor(element, headSnapshot) {\n super(element);\n this.headSnapshot = headSnapshot;\n }\n\n static fromHTMLString() {\n let html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"\";\n return this.fromDocument(parseHTMLDocument(html));\n }\n\n static fromElement(element) {\n return this.fromDocument(element.ownerDocument);\n }\n\n static fromDocument(_ref10) {\n let head = _ref10.head,\n body = _ref10.body;\n return new this(body, new HeadSnapshot(head));\n }\n\n clone() {\n return new PageSnapshot(this.element.cloneNode(true), this.headSnapshot);\n }\n\n get headElement() {\n return this.headSnapshot.element;\n }\n\n get rootLocation() {\n var _a;\n\n const root = (_a = this.getSetting(\"root\")) !== null && _a !== void 0 ? _a : \"/\";\n return expandURL(root);\n }\n\n get cacheControlValue() {\n return this.getSetting(\"cache-control\");\n }\n\n get isPreviewable() {\n return this.cacheControlValue != \"no-preview\";\n }\n\n get isCacheable() {\n return this.cacheControlValue != \"no-cache\";\n }\n\n get isVisitable() {\n return this.getSetting(\"visit-control\") != \"reload\";\n }\n\n getSetting(name) {\n return this.headSnapshot.getMetaValue(\"turbo-\".concat(name));\n }\n\n}\n\nvar TimingMetric;\n\n(function (TimingMetric) {\n TimingMetric[\"visitStart\"] = \"visitStart\";\n TimingMetric[\"requestStart\"] = \"requestStart\";\n TimingMetric[\"requestEnd\"] = \"requestEnd\";\n TimingMetric[\"visitEnd\"] = \"visitEnd\";\n})(TimingMetric || (TimingMetric = {}));\n\nvar VisitState;\n\n(function (VisitState) {\n VisitState[\"initialized\"] = \"initialized\";\n VisitState[\"started\"] = \"started\";\n VisitState[\"canceled\"] = \"canceled\";\n VisitState[\"failed\"] = \"failed\";\n VisitState[\"completed\"] = \"completed\";\n})(VisitState || (VisitState = {}));\n\nconst defaultOptions = {\n action: \"advance\",\n historyChanged: false,\n visitCachedSnapshot: () => {},\n willRender: true\n};\nvar SystemStatusCode;\n\n(function (SystemStatusCode) {\n SystemStatusCode[SystemStatusCode[\"networkFailure\"] = 0] = \"networkFailure\";\n SystemStatusCode[SystemStatusCode[\"timeoutFailure\"] = -1] = \"timeoutFailure\";\n SystemStatusCode[SystemStatusCode[\"contentTypeMismatch\"] = -2] = \"contentTypeMismatch\";\n})(SystemStatusCode || (SystemStatusCode = {}));\n\nclass Visit {\n constructor(delegate, location, restorationIdentifier) {\n let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n this.identifier = uuid();\n this.timingMetrics = {};\n this.followedRedirect = false;\n this.historyChanged = false;\n this.scrolled = false;\n this.snapshotCached = false;\n this.state = VisitState.initialized;\n this.delegate = delegate;\n this.location = location;\n this.restorationIdentifier = restorationIdentifier || uuid();\n\n const _Object$assign = Object.assign(Object.assign({}, defaultOptions), options),\n action = _Object$assign.action,\n historyChanged = _Object$assign.historyChanged,\n referrer = _Object$assign.referrer,\n snapshotHTML = _Object$assign.snapshotHTML,\n response = _Object$assign.response,\n visitCachedSnapshot = _Object$assign.visitCachedSnapshot,\n willRender = _Object$assign.willRender;\n\n this.action = action;\n this.historyChanged = historyChanged;\n this.referrer = referrer;\n this.snapshotHTML = snapshotHTML;\n this.response = response;\n this.isSamePage = this.delegate.locationWithActionIsSamePage(this.location, this.action);\n this.visitCachedSnapshot = visitCachedSnapshot;\n this.willRender = willRender;\n this.scrolled = !willRender;\n }\n\n get adapter() {\n return this.delegate.adapter;\n }\n\n get view() {\n return this.delegate.view;\n }\n\n get history() {\n return this.delegate.history;\n }\n\n get restorationData() {\n return this.history.getRestorationDataForIdentifier(this.restorationIdentifier);\n }\n\n get silent() {\n return this.isSamePage;\n }\n\n start() {\n if (this.state == VisitState.initialized) {\n this.recordTimingMetric(TimingMetric.visitStart);\n this.state = VisitState.started;\n this.adapter.visitStarted(this);\n this.delegate.visitStarted(this);\n }\n }\n\n cancel() {\n if (this.state == VisitState.started) {\n if (this.request) {\n this.request.cancel();\n }\n\n this.cancelRender();\n this.state = VisitState.canceled;\n }\n }\n\n complete() {\n if (this.state == VisitState.started) {\n this.recordTimingMetric(TimingMetric.visitEnd);\n this.state = VisitState.completed;\n this.adapter.visitCompleted(this);\n this.delegate.visitCompleted(this);\n this.followRedirect();\n }\n }\n\n fail() {\n if (this.state == VisitState.started) {\n this.state = VisitState.failed;\n this.adapter.visitFailed(this);\n }\n }\n\n changeHistory() {\n var _a;\n\n if (!this.historyChanged) {\n const actionForHistory = this.location.href === ((_a = this.referrer) === null || _a === void 0 ? void 0 : _a.href) ? \"replace\" : this.action;\n const method = this.getHistoryMethodForAction(actionForHistory);\n this.history.update(method, this.location, this.restorationIdentifier);\n this.historyChanged = true;\n }\n }\n\n issueRequest() {\n if (this.hasPreloadedResponse()) {\n this.simulateRequest();\n } else if (this.shouldIssueRequest() && !this.request) {\n this.request = new FetchRequest(this, FetchMethod.get, this.location);\n this.request.perform();\n }\n }\n\n simulateRequest() {\n if (this.response) {\n this.startRequest();\n this.recordResponse();\n this.finishRequest();\n }\n }\n\n startRequest() {\n this.recordTimingMetric(TimingMetric.requestStart);\n this.adapter.visitRequestStarted(this);\n }\n\n recordResponse() {\n let response = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.response;\n this.response = response;\n\n if (response) {\n const statusCode = response.statusCode;\n\n if (isSuccessful(statusCode)) {\n this.adapter.visitRequestCompleted(this);\n } else {\n this.adapter.visitRequestFailedWithStatusCode(this, statusCode);\n }\n }\n }\n\n finishRequest() {\n this.recordTimingMetric(TimingMetric.requestEnd);\n this.adapter.visitRequestFinished(this);\n }\n\n loadResponse() {\n if (this.response) {\n const _this$response = this.response,\n statusCode = _this$response.statusCode,\n responseHTML = _this$response.responseHTML;\n this.render(async () => {\n this.cacheSnapshot();\n if (this.view.renderPromise) await this.view.renderPromise;\n\n if (isSuccessful(statusCode) && responseHTML != null) {\n await this.view.renderPage(PageSnapshot.fromHTMLString(responseHTML), false, this.willRender);\n this.adapter.visitRendered(this);\n this.complete();\n } else {\n await this.view.renderError(PageSnapshot.fromHTMLString(responseHTML));\n this.adapter.visitRendered(this);\n this.fail();\n }\n });\n }\n }\n\n getCachedSnapshot() {\n const snapshot = this.view.getCachedSnapshotForLocation(this.location) || this.getPreloadedSnapshot();\n\n if (snapshot && (!getAnchor(this.location) || snapshot.hasAnchor(getAnchor(this.location)))) {\n if (this.action == \"restore\" || snapshot.isPreviewable) {\n return snapshot;\n }\n }\n }\n\n getPreloadedSnapshot() {\n if (this.snapshotHTML) {\n return PageSnapshot.fromHTMLString(this.snapshotHTML);\n }\n }\n\n hasCachedSnapshot() {\n return this.getCachedSnapshot() != null;\n }\n\n loadCachedSnapshot() {\n const snapshot = this.getCachedSnapshot();\n\n if (snapshot) {\n const isPreview = this.shouldIssueRequest();\n this.render(async () => {\n this.cacheSnapshot();\n\n if (this.isSamePage) {\n this.adapter.visitRendered(this);\n } else {\n if (this.view.renderPromise) await this.view.renderPromise;\n await this.view.renderPage(snapshot, isPreview, this.willRender);\n this.adapter.visitRendered(this);\n\n if (!isPreview) {\n this.complete();\n }\n }\n });\n }\n }\n\n followRedirect() {\n var _a;\n\n if (this.redirectedToLocation && !this.followedRedirect && ((_a = this.response) === null || _a === void 0 ? void 0 : _a.redirected)) {\n this.adapter.visitProposedToLocation(this.redirectedToLocation, {\n action: 'replace',\n response: this.response\n });\n this.followedRedirect = true;\n }\n }\n\n goToSamePageAnchor() {\n if (this.isSamePage) {\n this.render(async () => {\n this.cacheSnapshot();\n this.adapter.visitRendered(this);\n });\n }\n }\n\n requestStarted() {\n this.startRequest();\n }\n\n requestPreventedHandlingResponse(request, response) {}\n\n async requestSucceededWithResponse(request, response) {\n const responseHTML = await response.responseHTML;\n const redirected = response.redirected,\n statusCode = response.statusCode;\n\n if (responseHTML == undefined) {\n this.recordResponse({\n statusCode: SystemStatusCode.contentTypeMismatch,\n redirected\n });\n } else {\n this.redirectedToLocation = response.redirected ? response.location : undefined;\n this.recordResponse({\n statusCode: statusCode,\n responseHTML,\n redirected\n });\n }\n }\n\n async requestFailedWithResponse(request, response) {\n const responseHTML = await response.responseHTML;\n const redirected = response.redirected,\n statusCode = response.statusCode;\n\n if (responseHTML == undefined) {\n this.recordResponse({\n statusCode: SystemStatusCode.contentTypeMismatch,\n redirected\n });\n } else {\n this.recordResponse({\n statusCode: statusCode,\n responseHTML,\n redirected\n });\n }\n }\n\n requestErrored(request, error) {\n this.recordResponse({\n statusCode: SystemStatusCode.networkFailure,\n redirected: false\n });\n }\n\n requestFinished() {\n this.finishRequest();\n }\n\n performScroll() {\n if (!this.scrolled) {\n if (this.action == \"restore\") {\n this.scrollToRestoredPosition() || this.scrollToAnchor() || this.view.scrollToTop();\n } else {\n this.scrollToAnchor() || this.view.scrollToTop();\n }\n\n if (this.isSamePage) {\n this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation, this.location);\n }\n\n this.scrolled = true;\n }\n }\n\n scrollToRestoredPosition() {\n const scrollPosition = this.restorationData.scrollPosition;\n\n if (scrollPosition) {\n this.view.scrollToPosition(scrollPosition);\n return true;\n }\n }\n\n scrollToAnchor() {\n const anchor = getAnchor(this.location);\n\n if (anchor != null) {\n this.view.scrollToAnchor(anchor);\n return true;\n }\n }\n\n recordTimingMetric(metric) {\n this.timingMetrics[metric] = new Date().getTime();\n }\n\n getTimingMetrics() {\n return Object.assign({}, this.timingMetrics);\n }\n\n getHistoryMethodForAction(action) {\n switch (action) {\n case \"replace\":\n return history.replaceState;\n\n case \"advance\":\n case \"restore\":\n return history.pushState;\n }\n }\n\n hasPreloadedResponse() {\n return typeof this.response == \"object\";\n }\n\n shouldIssueRequest() {\n if (this.isSamePage) {\n return false;\n } else if (this.action == \"restore\") {\n return !this.hasCachedSnapshot();\n } else {\n return this.willRender;\n }\n }\n\n cacheSnapshot() {\n if (!this.snapshotCached) {\n this.view.cacheSnapshot().then(snapshot => snapshot && this.visitCachedSnapshot(snapshot));\n this.snapshotCached = true;\n }\n }\n\n async render(callback) {\n this.cancelRender();\n await new Promise(resolve => {\n this.frame = requestAnimationFrame(() => resolve());\n });\n await callback();\n delete this.frame;\n this.performScroll();\n }\n\n cancelRender() {\n if (this.frame) {\n cancelAnimationFrame(this.frame);\n delete this.frame;\n }\n }\n\n}\n\nfunction isSuccessful(statusCode) {\n return statusCode >= 200 && statusCode < 300;\n}\n\nclass BrowserAdapter {\n constructor(session) {\n this.progressBar = new ProgressBar();\n\n this.showProgressBar = () => {\n this.progressBar.show();\n };\n\n this.session = session;\n }\n\n visitProposedToLocation(location, options) {\n this.navigator.startVisit(location, uuid(), options);\n }\n\n visitStarted(visit) {\n visit.loadCachedSnapshot();\n visit.issueRequest();\n visit.changeHistory();\n visit.goToSamePageAnchor();\n }\n\n visitRequestStarted(visit) {\n this.progressBar.setValue(0);\n\n if (visit.hasCachedSnapshot() || visit.action != \"restore\") {\n this.showVisitProgressBarAfterDelay();\n } else {\n this.showProgressBar();\n }\n }\n\n visitRequestCompleted(visit) {\n visit.loadResponse();\n }\n\n visitRequestFailedWithStatusCode(visit, statusCode) {\n switch (statusCode) {\n case SystemStatusCode.networkFailure:\n case SystemStatusCode.timeoutFailure:\n case SystemStatusCode.contentTypeMismatch:\n return this.reload();\n\n default:\n return visit.loadResponse();\n }\n }\n\n visitRequestFinished(visit) {\n this.progressBar.setValue(1);\n this.hideVisitProgressBar();\n }\n\n visitCompleted(visit) {}\n\n pageInvalidated() {\n this.reload();\n }\n\n visitFailed(visit) {}\n\n visitRendered(visit) {}\n\n formSubmissionStarted(formSubmission) {\n this.progressBar.setValue(0);\n this.showFormProgressBarAfterDelay();\n }\n\n formSubmissionFinished(formSubmission) {\n this.progressBar.setValue(1);\n this.hideFormProgressBar();\n }\n\n showVisitProgressBarAfterDelay() {\n this.visitProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);\n }\n\n hideVisitProgressBar() {\n this.progressBar.hide();\n\n if (this.visitProgressBarTimeout != null) {\n window.clearTimeout(this.visitProgressBarTimeout);\n delete this.visitProgressBarTimeout;\n }\n }\n\n showFormProgressBarAfterDelay() {\n if (this.formProgressBarTimeout == null) {\n this.formProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);\n }\n }\n\n hideFormProgressBar() {\n this.progressBar.hide();\n\n if (this.formProgressBarTimeout != null) {\n window.clearTimeout(this.formProgressBarTimeout);\n delete this.formProgressBarTimeout;\n }\n }\n\n reload() {\n window.location.reload();\n }\n\n get navigator() {\n return this.session.navigator;\n }\n\n}\n\nclass CacheObserver {\n constructor() {\n this.started = false;\n }\n\n start() {\n if (!this.started) {\n this.started = true;\n addEventListener(\"turbo:before-cache\", this.removeStaleElements, false);\n }\n }\n\n stop() {\n if (this.started) {\n this.started = false;\n removeEventListener(\"turbo:before-cache\", this.removeStaleElements, false);\n }\n }\n\n removeStaleElements() {\n const staleElements = [...document.querySelectorAll('[data-turbo-cache=\"false\"]')];\n\n for (const element of staleElements) {\n element.remove();\n }\n }\n\n}\n\nclass FormSubmitObserver {\n constructor(delegate) {\n this.started = false;\n\n this.submitCaptured = () => {\n removeEventListener(\"submit\", this.submitBubbled, false);\n addEventListener(\"submit\", this.submitBubbled, false);\n };\n\n this.submitBubbled = event => {\n if (!event.defaultPrevented) {\n const form = event.target instanceof HTMLFormElement ? event.target : undefined;\n const submitter = event.submitter || undefined;\n\n if (form) {\n const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"formmethod\")) || form.getAttribute(\"method\");\n\n if (method != \"dialog\" && this.delegate.willSubmitForm(form, submitter)) {\n event.preventDefault();\n this.delegate.formSubmitted(form, submitter);\n }\n }\n }\n };\n\n this.delegate = delegate;\n }\n\n start() {\n if (!this.started) {\n addEventListener(\"submit\", this.submitCaptured, true);\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n removeEventListener(\"submit\", this.submitCaptured, true);\n this.started = false;\n }\n }\n\n}\n\nclass FrameRedirector {\n constructor(element) {\n this.element = element;\n this.linkInterceptor = new LinkInterceptor(this, element);\n this.formInterceptor = new FormInterceptor(this, element);\n }\n\n start() {\n this.linkInterceptor.start();\n this.formInterceptor.start();\n }\n\n stop() {\n this.linkInterceptor.stop();\n this.formInterceptor.stop();\n }\n\n shouldInterceptLinkClick(element, url) {\n return this.shouldRedirect(element);\n }\n\n linkClickIntercepted(element, url) {\n const frame = this.findFrameElement(element);\n\n if (frame) {\n frame.delegate.linkClickIntercepted(element, url);\n }\n }\n\n shouldInterceptFormSubmission(element, submitter) {\n return this.shouldSubmit(element, submitter);\n }\n\n formSubmissionIntercepted(element, submitter) {\n const frame = this.findFrameElement(element, submitter);\n\n if (frame) {\n frame.removeAttribute(\"reloadable\");\n frame.delegate.formSubmissionIntercepted(element, submitter);\n }\n }\n\n shouldSubmit(form, submitter) {\n var _a;\n\n const action = getAction(form, submitter);\n const meta = this.element.ownerDocument.querySelector(\"meta[name=\\\"turbo-root\\\"]\");\n const rootLocation = expandURL((_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : \"/\");\n return this.shouldRedirect(form, submitter) && locationIsVisitable(action, rootLocation);\n }\n\n shouldRedirect(element, submitter) {\n const frame = this.findFrameElement(element, submitter);\n return frame ? frame != element.closest(\"turbo-frame\") : false;\n }\n\n findFrameElement(element, submitter) {\n const id = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute(\"data-turbo-frame\")) || element.getAttribute(\"data-turbo-frame\");\n\n if (id && id != \"_top\") {\n const frame = this.element.querySelector(\"#\".concat(id, \":not([disabled])\"));\n\n if (frame instanceof FrameElement) {\n return frame;\n }\n }\n }\n\n}\n\nclass History {\n constructor(delegate) {\n this.restorationIdentifier = uuid();\n this.restorationData = {};\n this.started = false;\n this.pageLoaded = false;\n\n this.onPopState = event => {\n if (this.shouldHandlePopState()) {\n const _ref11 = event.state || {},\n turbo = _ref11.turbo;\n\n if (turbo) {\n this.location = new URL(window.location.href);\n const restorationIdentifier = turbo.restorationIdentifier;\n this.restorationIdentifier = restorationIdentifier;\n this.delegate.historyPoppedToLocationWithRestorationIdentifier(this.location, restorationIdentifier);\n }\n }\n };\n\n this.onPageLoad = async event => {\n await nextMicrotask();\n this.pageLoaded = true;\n };\n\n this.delegate = delegate;\n }\n\n start() {\n if (!this.started) {\n addEventListener(\"popstate\", this.onPopState, false);\n addEventListener(\"load\", this.onPageLoad, false);\n this.started = true;\n this.replace(new URL(window.location.href));\n }\n }\n\n stop() {\n if (this.started) {\n removeEventListener(\"popstate\", this.onPopState, false);\n removeEventListener(\"load\", this.onPageLoad, false);\n this.started = false;\n }\n }\n\n push(location, restorationIdentifier) {\n this.update(history.pushState, location, restorationIdentifier);\n }\n\n replace(location, restorationIdentifier) {\n this.update(history.replaceState, location, restorationIdentifier);\n }\n\n update(method, location) {\n let restorationIdentifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : uuid();\n const state = {\n turbo: {\n restorationIdentifier\n }\n };\n method.call(history, state, \"\", location.href);\n this.location = location;\n this.restorationIdentifier = restorationIdentifier;\n }\n\n getRestorationDataForIdentifier(restorationIdentifier) {\n return this.restorationData[restorationIdentifier] || {};\n }\n\n updateRestorationData(additionalData) {\n const restorationIdentifier = this.restorationIdentifier;\n const restorationData = this.restorationData[restorationIdentifier];\n this.restorationData[restorationIdentifier] = Object.assign(Object.assign({}, restorationData), additionalData);\n }\n\n assumeControlOfScrollRestoration() {\n var _a;\n\n if (!this.previousScrollRestoration) {\n this.previousScrollRestoration = (_a = history.scrollRestoration) !== null && _a !== void 0 ? _a : \"auto\";\n history.scrollRestoration = \"manual\";\n }\n }\n\n relinquishControlOfScrollRestoration() {\n if (this.previousScrollRestoration) {\n history.scrollRestoration = this.previousScrollRestoration;\n delete this.previousScrollRestoration;\n }\n }\n\n shouldHandlePopState() {\n return this.pageIsLoaded();\n }\n\n pageIsLoaded() {\n return this.pageLoaded || document.readyState == \"complete\";\n }\n\n}\n\nclass LinkClickObserver {\n constructor(delegate) {\n this.started = false;\n\n this.clickCaptured = () => {\n removeEventListener(\"click\", this.clickBubbled, false);\n addEventListener(\"click\", this.clickBubbled, false);\n };\n\n this.clickBubbled = event => {\n if (this.clickEventIsSignificant(event)) {\n const target = event.composedPath && event.composedPath()[0] || event.target;\n const link = this.findLinkFromClickTarget(target);\n\n if (link) {\n const location = this.getLocationForLink(link);\n\n if (this.delegate.willFollowLinkToLocation(link, location)) {\n event.preventDefault();\n this.delegate.followedLinkToLocation(link, location);\n }\n }\n }\n };\n\n this.delegate = delegate;\n }\n\n start() {\n if (!this.started) {\n addEventListener(\"click\", this.clickCaptured, true);\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n removeEventListener(\"click\", this.clickCaptured, true);\n this.started = false;\n }\n }\n\n clickEventIsSignificant(event) {\n return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);\n }\n\n findLinkFromClickTarget(target) {\n if (target instanceof Element) {\n return target.closest(\"a[href]:not([target^=_]):not([download])\");\n }\n }\n\n getLocationForLink(link) {\n return expandURL(link.getAttribute(\"href\") || \"\");\n }\n\n}\n\nfunction isAction(action) {\n return action == \"advance\" || action == \"replace\" || action == \"restore\";\n}\n\nclass Navigator {\n constructor(delegate) {\n this.delegate = delegate;\n }\n\n proposeVisit(location) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (this.delegate.allowsVisitingLocationWithAction(location, options.action)) {\n if (locationIsVisitable(location, this.view.snapshot.rootLocation)) {\n this.delegate.visitProposedToLocation(location, options);\n } else {\n window.location.href = location.toString();\n }\n }\n }\n\n startVisit(locatable, restorationIdentifier) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n this.stop();\n this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, Object.assign({\n referrer: this.location\n }, options));\n this.currentVisit.start();\n }\n\n submitForm(form, submitter) {\n this.stop();\n this.formSubmission = new FormSubmission(this, form, submitter, true);\n this.formSubmission.start();\n }\n\n stop() {\n if (this.formSubmission) {\n this.formSubmission.stop();\n delete this.formSubmission;\n }\n\n if (this.currentVisit) {\n this.currentVisit.cancel();\n delete this.currentVisit;\n }\n }\n\n get adapter() {\n return this.delegate.adapter;\n }\n\n get view() {\n return this.delegate.view;\n }\n\n get history() {\n return this.delegate.history;\n }\n\n formSubmissionStarted(formSubmission) {\n if (typeof this.adapter.formSubmissionStarted === 'function') {\n this.adapter.formSubmissionStarted(formSubmission);\n }\n }\n\n async formSubmissionSucceededWithResponse(formSubmission, fetchResponse) {\n if (formSubmission == this.formSubmission) {\n const responseHTML = await fetchResponse.responseHTML;\n\n if (responseHTML) {\n if (formSubmission.method != FetchMethod.get) {\n this.view.clearSnapshotCache();\n }\n\n const statusCode = fetchResponse.statusCode,\n redirected = fetchResponse.redirected;\n const action = this.getActionForFormSubmission(formSubmission);\n const visitOptions = {\n action,\n response: {\n statusCode,\n responseHTML,\n redirected\n }\n };\n this.proposeVisit(fetchResponse.location, visitOptions);\n }\n }\n }\n\n async formSubmissionFailedWithResponse(formSubmission, fetchResponse) {\n const responseHTML = await fetchResponse.responseHTML;\n\n if (responseHTML) {\n const snapshot = PageSnapshot.fromHTMLString(responseHTML);\n\n if (fetchResponse.serverError) {\n await this.view.renderError(snapshot);\n } else {\n await this.view.renderPage(snapshot);\n }\n\n this.view.scrollToTop();\n this.view.clearSnapshotCache();\n }\n }\n\n formSubmissionErrored(formSubmission, error) {\n console.error(error);\n }\n\n formSubmissionFinished(formSubmission) {\n if (typeof this.adapter.formSubmissionFinished === 'function') {\n this.adapter.formSubmissionFinished(formSubmission);\n }\n }\n\n visitStarted(visit) {\n this.delegate.visitStarted(visit);\n }\n\n visitCompleted(visit) {\n this.delegate.visitCompleted(visit);\n }\n\n locationWithActionIsSamePage(location, action) {\n const anchor = getAnchor(location);\n const currentAnchor = getAnchor(this.view.lastRenderedLocation);\n const isRestorationToTop = action === 'restore' && typeof anchor === 'undefined';\n return action !== \"replace\" && getRequestURL(location) === getRequestURL(this.view.lastRenderedLocation) && (isRestorationToTop || anchor != null && anchor !== currentAnchor);\n }\n\n visitScrolledToSamePageLocation(oldURL, newURL) {\n this.delegate.visitScrolledToSamePageLocation(oldURL, newURL);\n }\n\n get location() {\n return this.history.location;\n }\n\n get restorationIdentifier() {\n return this.history.restorationIdentifier;\n }\n\n getActionForFormSubmission(formSubmission) {\n const formElement = formSubmission.formElement,\n submitter = formSubmission.submitter;\n const action = getAttribute(\"data-turbo-action\", submitter, formElement);\n return isAction(action) ? action : \"advance\";\n }\n\n}\n\nvar PageStage;\n\n(function (PageStage) {\n PageStage[PageStage[\"initial\"] = 0] = \"initial\";\n PageStage[PageStage[\"loading\"] = 1] = \"loading\";\n PageStage[PageStage[\"interactive\"] = 2] = \"interactive\";\n PageStage[PageStage[\"complete\"] = 3] = \"complete\";\n})(PageStage || (PageStage = {}));\n\nclass PageObserver {\n constructor(delegate) {\n this.stage = PageStage.initial;\n this.started = false;\n\n this.interpretReadyState = () => {\n const readyState = this.readyState;\n\n if (readyState == \"interactive\") {\n this.pageIsInteractive();\n } else if (readyState == \"complete\") {\n this.pageIsComplete();\n }\n };\n\n this.pageWillUnload = () => {\n this.delegate.pageWillUnload();\n };\n\n this.delegate = delegate;\n }\n\n start() {\n if (!this.started) {\n if (this.stage == PageStage.initial) {\n this.stage = PageStage.loading;\n }\n\n document.addEventListener(\"readystatechange\", this.interpretReadyState, false);\n addEventListener(\"pagehide\", this.pageWillUnload, false);\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n document.removeEventListener(\"readystatechange\", this.interpretReadyState, false);\n removeEventListener(\"pagehide\", this.pageWillUnload, false);\n this.started = false;\n }\n }\n\n pageIsInteractive() {\n if (this.stage == PageStage.loading) {\n this.stage = PageStage.interactive;\n this.delegate.pageBecameInteractive();\n }\n }\n\n pageIsComplete() {\n this.pageIsInteractive();\n\n if (this.stage == PageStage.interactive) {\n this.stage = PageStage.complete;\n this.delegate.pageLoaded();\n }\n }\n\n get readyState() {\n return document.readyState;\n }\n\n}\n\nclass ScrollObserver {\n constructor(delegate) {\n this.started = false;\n\n this.onScroll = () => {\n this.updatePosition({\n x: window.pageXOffset,\n y: window.pageYOffset\n });\n };\n\n this.delegate = delegate;\n }\n\n start() {\n if (!this.started) {\n addEventListener(\"scroll\", this.onScroll, false);\n this.onScroll();\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n removeEventListener(\"scroll\", this.onScroll, false);\n this.started = false;\n }\n }\n\n updatePosition(position) {\n this.delegate.scrollPositionChanged(position);\n }\n\n}\n\nclass StreamObserver {\n constructor(delegate) {\n this.sources = new Set();\n this.started = false;\n\n this.inspectFetchResponse = event => {\n const response = fetchResponseFromEvent(event);\n\n if (response && fetchResponseIsStream(response)) {\n event.preventDefault();\n this.receiveMessageResponse(response);\n }\n };\n\n this.receiveMessageEvent = event => {\n if (this.started && typeof event.data == \"string\") {\n this.receiveMessageHTML(event.data);\n }\n };\n\n this.delegate = delegate;\n }\n\n start() {\n if (!this.started) {\n this.started = true;\n addEventListener(\"turbo:before-fetch-response\", this.inspectFetchResponse, false);\n }\n }\n\n stop() {\n if (this.started) {\n this.started = false;\n removeEventListener(\"turbo:before-fetch-response\", this.inspectFetchResponse, false);\n }\n }\n\n connectStreamSource(source) {\n if (!this.streamSourceIsConnected(source)) {\n this.sources.add(source);\n source.addEventListener(\"message\", this.receiveMessageEvent, false);\n }\n }\n\n disconnectStreamSource(source) {\n if (this.streamSourceIsConnected(source)) {\n this.sources.delete(source);\n source.removeEventListener(\"message\", this.receiveMessageEvent, false);\n }\n }\n\n streamSourceIsConnected(source) {\n return this.sources.has(source);\n }\n\n async receiveMessageResponse(response) {\n const html = await response.responseHTML;\n\n if (html) {\n this.receiveMessageHTML(html);\n }\n }\n\n receiveMessageHTML(html) {\n this.delegate.receivedMessageFromStream(new StreamMessage(html));\n }\n\n}\n\nfunction fetchResponseFromEvent(event) {\n var _a;\n\n const fetchResponse = (_a = event.detail) === null || _a === void 0 ? void 0 : _a.fetchResponse;\n\n if (fetchResponse instanceof FetchResponse) {\n return fetchResponse;\n }\n}\n\nfunction fetchResponseIsStream(response) {\n var _a;\n\n const contentType = (_a = response.contentType) !== null && _a !== void 0 ? _a : \"\";\n return contentType.startsWith(StreamMessage.contentType);\n}\n\nclass ErrorRenderer extends Renderer {\n async render() {\n this.replaceHeadAndBody();\n this.activateScriptElements();\n }\n\n replaceHeadAndBody() {\n const _document = document,\n documentElement = _document.documentElement,\n head = _document.head,\n body = _document.body;\n documentElement.replaceChild(this.newHead, head);\n documentElement.replaceChild(this.newElement, body);\n }\n\n activateScriptElements() {\n for (const replaceableElement of this.scriptElements) {\n const parentNode = replaceableElement.parentNode;\n\n if (parentNode) {\n const element = this.createScriptElement(replaceableElement);\n parentNode.replaceChild(element, replaceableElement);\n }\n }\n }\n\n get newHead() {\n return this.newSnapshot.headSnapshot.element;\n }\n\n get scriptElements() {\n return [...document.documentElement.querySelectorAll(\"script\")];\n }\n\n}\n\nclass PageRenderer extends Renderer {\n get shouldRender() {\n return this.newSnapshot.isVisitable && this.trackedElementsAreIdentical;\n }\n\n prepareToRender() {\n this.mergeHead();\n }\n\n async render() {\n if (this.willRender) {\n this.replaceBody();\n }\n }\n\n finishRendering() {\n super.finishRendering();\n\n if (!this.isPreview) {\n this.focusFirstAutofocusableElement();\n }\n }\n\n get currentHeadSnapshot() {\n return this.currentSnapshot.headSnapshot;\n }\n\n get newHeadSnapshot() {\n return this.newSnapshot.headSnapshot;\n }\n\n get newElement() {\n return this.newSnapshot.element;\n }\n\n mergeHead() {\n this.copyNewHeadStylesheetElements();\n this.copyNewHeadScriptElements();\n this.removeCurrentHeadProvisionalElements();\n this.copyNewHeadProvisionalElements();\n }\n\n replaceBody() {\n this.preservingPermanentElements(() => {\n this.activateNewBody();\n this.assignNewBody();\n });\n }\n\n get trackedElementsAreIdentical() {\n return this.currentHeadSnapshot.trackedElementSignature == this.newHeadSnapshot.trackedElementSignature;\n }\n\n copyNewHeadStylesheetElements() {\n for (const element of this.newHeadStylesheetElements) {\n document.head.appendChild(element);\n }\n }\n\n copyNewHeadScriptElements() {\n for (const element of this.newHeadScriptElements) {\n document.head.appendChild(this.createScriptElement(element));\n }\n }\n\n removeCurrentHeadProvisionalElements() {\n for (const element of this.currentHeadProvisionalElements) {\n document.head.removeChild(element);\n }\n }\n\n copyNewHeadProvisionalElements() {\n for (const element of this.newHeadProvisionalElements) {\n document.head.appendChild(element);\n }\n }\n\n activateNewBody() {\n document.adoptNode(this.newElement);\n this.activateNewBodyScriptElements();\n }\n\n activateNewBodyScriptElements() {\n for (const inertScriptElement of this.newBodyScriptElements) {\n const activatedScriptElement = this.createScriptElement(inertScriptElement);\n inertScriptElement.replaceWith(activatedScriptElement);\n }\n }\n\n assignNewBody() {\n if (document.body && this.newElement instanceof HTMLBodyElement) {\n document.body.replaceWith(this.newElement);\n } else {\n document.documentElement.appendChild(this.newElement);\n }\n }\n\n get newHeadStylesheetElements() {\n return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot);\n }\n\n get newHeadScriptElements() {\n return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot);\n }\n\n get currentHeadProvisionalElements() {\n return this.currentHeadSnapshot.provisionalElements;\n }\n\n get newHeadProvisionalElements() {\n return this.newHeadSnapshot.provisionalElements;\n }\n\n get newBodyScriptElements() {\n return this.newElement.querySelectorAll(\"script\");\n }\n\n}\n\nclass SnapshotCache {\n constructor(size) {\n this.keys = [];\n this.snapshots = {};\n this.size = size;\n }\n\n has(location) {\n return toCacheKey(location) in this.snapshots;\n }\n\n get(location) {\n if (this.has(location)) {\n const snapshot = this.read(location);\n this.touch(location);\n return snapshot;\n }\n }\n\n put(location, snapshot) {\n this.write(location, snapshot);\n this.touch(location);\n return snapshot;\n }\n\n clear() {\n this.snapshots = {};\n }\n\n read(location) {\n return this.snapshots[toCacheKey(location)];\n }\n\n write(location, snapshot) {\n this.snapshots[toCacheKey(location)] = snapshot;\n }\n\n touch(location) {\n const key = toCacheKey(location);\n const index = this.keys.indexOf(key);\n if (index > -1) this.keys.splice(index, 1);\n this.keys.unshift(key);\n this.trim();\n }\n\n trim() {\n for (const key of this.keys.splice(this.size)) {\n delete this.snapshots[key];\n }\n }\n\n}\n\nclass PageView extends View {\n constructor() {\n super(...arguments);\n this.snapshotCache = new SnapshotCache(10);\n this.lastRenderedLocation = new URL(location.href);\n }\n\n renderPage(snapshot) {\n let isPreview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n let willRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n const renderer = new PageRenderer(this.snapshot, snapshot, isPreview, willRender);\n return this.render(renderer);\n }\n\n renderError(snapshot) {\n const renderer = new ErrorRenderer(this.snapshot, snapshot, false);\n return this.render(renderer);\n }\n\n clearSnapshotCache() {\n this.snapshotCache.clear();\n }\n\n async cacheSnapshot() {\n if (this.shouldCacheSnapshot) {\n this.delegate.viewWillCacheSnapshot();\n const snapshot = this.snapshot,\n location = this.lastRenderedLocation;\n await nextEventLoopTick();\n const cachedSnapshot = snapshot.clone();\n this.snapshotCache.put(location, cachedSnapshot);\n return cachedSnapshot;\n }\n }\n\n getCachedSnapshotForLocation(location) {\n return this.snapshotCache.get(location);\n }\n\n get snapshot() {\n return PageSnapshot.fromElement(this.element);\n }\n\n get shouldCacheSnapshot() {\n return this.snapshot.isCacheable;\n }\n\n}\n\nclass Session {\n constructor() {\n this.navigator = new Navigator(this);\n this.history = new History(this);\n this.view = new PageView(this, document.documentElement);\n this.adapter = new BrowserAdapter(this);\n this.pageObserver = new PageObserver(this);\n this.cacheObserver = new CacheObserver();\n this.linkClickObserver = new LinkClickObserver(this);\n this.formSubmitObserver = new FormSubmitObserver(this);\n this.scrollObserver = new ScrollObserver(this);\n this.streamObserver = new StreamObserver(this);\n this.frameRedirector = new FrameRedirector(document.documentElement);\n this.drive = true;\n this.enabled = true;\n this.progressBarDelay = 500;\n this.started = false;\n }\n\n start() {\n if (!this.started) {\n this.pageObserver.start();\n this.cacheObserver.start();\n this.linkClickObserver.start();\n this.formSubmitObserver.start();\n this.scrollObserver.start();\n this.streamObserver.start();\n this.frameRedirector.start();\n this.history.start();\n this.started = true;\n this.enabled = true;\n }\n }\n\n disable() {\n this.enabled = false;\n }\n\n stop() {\n if (this.started) {\n this.pageObserver.stop();\n this.cacheObserver.stop();\n this.linkClickObserver.stop();\n this.formSubmitObserver.stop();\n this.scrollObserver.stop();\n this.streamObserver.stop();\n this.frameRedirector.stop();\n this.history.stop();\n this.started = false;\n }\n }\n\n registerAdapter(adapter) {\n this.adapter = adapter;\n }\n\n visit(location) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.navigator.proposeVisit(expandURL(location), options);\n }\n\n connectStreamSource(source) {\n this.streamObserver.connectStreamSource(source);\n }\n\n disconnectStreamSource(source) {\n this.streamObserver.disconnectStreamSource(source);\n }\n\n renderStreamMessage(message) {\n document.documentElement.appendChild(StreamMessage.wrap(message).fragment);\n }\n\n clearCache() {\n this.view.clearSnapshotCache();\n }\n\n setProgressBarDelay(delay) {\n this.progressBarDelay = delay;\n }\n\n get location() {\n return this.history.location;\n }\n\n get restorationIdentifier() {\n return this.history.restorationIdentifier;\n }\n\n historyPoppedToLocationWithRestorationIdentifier(location, restorationIdentifier) {\n if (this.enabled) {\n this.navigator.startVisit(location, restorationIdentifier, {\n action: \"restore\",\n historyChanged: true\n });\n } else {\n this.adapter.pageInvalidated();\n }\n }\n\n scrollPositionChanged(position) {\n this.history.updateRestorationData({\n scrollPosition: position\n });\n }\n\n willFollowLinkToLocation(link, location) {\n return this.elementDriveEnabled(link) && locationIsVisitable(location, this.snapshot.rootLocation) && this.applicationAllowsFollowingLinkToLocation(link, location);\n }\n\n followedLinkToLocation(link, location) {\n const action = this.getActionForLink(link);\n this.convertLinkWithMethodClickToFormSubmission(link) || this.visit(location.href, {\n action\n });\n }\n\n convertLinkWithMethodClickToFormSubmission(link) {\n const linkMethod = link.getAttribute(\"data-turbo-method\");\n\n if (linkMethod) {\n const form = document.createElement(\"form\");\n form.method = linkMethod;\n form.action = link.getAttribute(\"href\") || \"undefined\";\n form.hidden = true;\n\n if (link.hasAttribute(\"data-turbo-confirm\")) {\n form.setAttribute(\"data-turbo-confirm\", link.getAttribute(\"data-turbo-confirm\"));\n }\n\n const frame = this.getTargetFrameForLink(link);\n\n if (frame) {\n form.setAttribute(\"data-turbo-frame\", frame);\n form.addEventListener(\"turbo:submit-start\", () => form.remove());\n } else {\n form.addEventListener(\"submit\", () => form.remove());\n }\n\n document.body.appendChild(form);\n return dispatch(\"submit\", {\n cancelable: true,\n target: form\n });\n } else {\n return false;\n }\n }\n\n allowsVisitingLocationWithAction(location, action) {\n return this.locationWithActionIsSamePage(location, action) || this.applicationAllowsVisitingLocation(location);\n }\n\n visitProposedToLocation(location, options) {\n extendURLWithDeprecatedProperties(location);\n this.adapter.visitProposedToLocation(location, options);\n }\n\n visitStarted(visit) {\n extendURLWithDeprecatedProperties(visit.location);\n\n if (!visit.silent) {\n this.notifyApplicationAfterVisitingLocation(visit.location, visit.action);\n }\n }\n\n visitCompleted(visit) {\n this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());\n }\n\n locationWithActionIsSamePage(location, action) {\n return this.navigator.locationWithActionIsSamePage(location, action);\n }\n\n visitScrolledToSamePageLocation(oldURL, newURL) {\n this.notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL);\n }\n\n willSubmitForm(form, submitter) {\n const action = getAction(form, submitter);\n return this.elementDriveEnabled(form) && (!submitter || this.elementDriveEnabled(submitter)) && locationIsVisitable(expandURL(action), this.snapshot.rootLocation);\n }\n\n formSubmitted(form, submitter) {\n this.navigator.submitForm(form, submitter);\n }\n\n pageBecameInteractive() {\n this.view.lastRenderedLocation = this.location;\n this.notifyApplicationAfterPageLoad();\n }\n\n pageLoaded() {\n this.history.assumeControlOfScrollRestoration();\n }\n\n pageWillUnload() {\n this.history.relinquishControlOfScrollRestoration();\n }\n\n receivedMessageFromStream(message) {\n this.renderStreamMessage(message);\n }\n\n viewWillCacheSnapshot() {\n var _a;\n\n if (!((_a = this.navigator.currentVisit) === null || _a === void 0 ? void 0 : _a.silent)) {\n this.notifyApplicationBeforeCachingSnapshot();\n }\n }\n\n allowsImmediateRender(_ref12, resume) {\n let element = _ref12.element;\n const event = this.notifyApplicationBeforeRender(element, resume);\n return !event.defaultPrevented;\n }\n\n viewRenderedSnapshot(snapshot, isPreview) {\n this.view.lastRenderedLocation = this.history.location;\n this.notifyApplicationAfterRender();\n }\n\n viewInvalidated() {\n this.adapter.pageInvalidated();\n }\n\n frameLoaded(frame) {\n this.notifyApplicationAfterFrameLoad(frame);\n }\n\n frameRendered(fetchResponse, frame) {\n this.notifyApplicationAfterFrameRender(fetchResponse, frame);\n }\n\n applicationAllowsFollowingLinkToLocation(link, location) {\n const event = this.notifyApplicationAfterClickingLinkToLocation(link, location);\n return !event.defaultPrevented;\n }\n\n applicationAllowsVisitingLocation(location) {\n const event = this.notifyApplicationBeforeVisitingLocation(location);\n return !event.defaultPrevented;\n }\n\n notifyApplicationAfterClickingLinkToLocation(link, location) {\n return dispatch(\"turbo:click\", {\n target: link,\n detail: {\n url: location.href\n },\n cancelable: true\n });\n }\n\n notifyApplicationBeforeVisitingLocation(location) {\n return dispatch(\"turbo:before-visit\", {\n detail: {\n url: location.href\n },\n cancelable: true\n });\n }\n\n notifyApplicationAfterVisitingLocation(location, action) {\n markAsBusy(document.documentElement);\n return dispatch(\"turbo:visit\", {\n detail: {\n url: location.href,\n action\n }\n });\n }\n\n notifyApplicationBeforeCachingSnapshot() {\n return dispatch(\"turbo:before-cache\");\n }\n\n notifyApplicationBeforeRender(newBody, resume) {\n return dispatch(\"turbo:before-render\", {\n detail: {\n newBody,\n resume\n },\n cancelable: true\n });\n }\n\n notifyApplicationAfterRender() {\n return dispatch(\"turbo:render\");\n }\n\n notifyApplicationAfterPageLoad() {\n let timing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n clearBusyState(document.documentElement);\n return dispatch(\"turbo:load\", {\n detail: {\n url: this.location.href,\n timing\n }\n });\n }\n\n notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL) {\n dispatchEvent(new HashChangeEvent(\"hashchange\", {\n oldURL: oldURL.toString(),\n newURL: newURL.toString()\n }));\n }\n\n notifyApplicationAfterFrameLoad(frame) {\n return dispatch(\"turbo:frame-load\", {\n target: frame\n });\n }\n\n notifyApplicationAfterFrameRender(fetchResponse, frame) {\n return dispatch(\"turbo:frame-render\", {\n detail: {\n fetchResponse\n },\n target: frame,\n cancelable: true\n });\n }\n\n elementDriveEnabled(element) {\n const container = element === null || element === void 0 ? void 0 : element.closest(\"[data-turbo]\");\n\n if (this.drive) {\n if (container) {\n return container.getAttribute(\"data-turbo\") != \"false\";\n } else {\n return true;\n }\n } else {\n if (container) {\n return container.getAttribute(\"data-turbo\") == \"true\";\n } else {\n return false;\n }\n }\n }\n\n getActionForLink(link) {\n const action = link.getAttribute(\"data-turbo-action\");\n return isAction(action) ? action : \"advance\";\n }\n\n getTargetFrameForLink(link) {\n const frame = link.getAttribute(\"data-turbo-frame\");\n\n if (frame) {\n return frame;\n } else {\n const container = link.closest(\"turbo-frame\");\n\n if (container) {\n return container.id;\n }\n }\n }\n\n get snapshot() {\n return this.view.snapshot;\n }\n\n}\n\nfunction extendURLWithDeprecatedProperties(url) {\n Object.defineProperties(url, deprecatedLocationPropertyDescriptors);\n}\n\nconst deprecatedLocationPropertyDescriptors = {\n absoluteURL: {\n get() {\n return this.toString();\n }\n\n }\n};\nconst session = new Session();\nconst navigator$1 = session.navigator;\n\nfunction start() {\n session.start();\n}\n\nfunction registerAdapter(adapter) {\n session.registerAdapter(adapter);\n}\n\nfunction visit(location, options) {\n session.visit(location, options);\n}\n\nfunction connectStreamSource(source) {\n session.connectStreamSource(source);\n}\n\nfunction disconnectStreamSource(source) {\n session.disconnectStreamSource(source);\n}\n\nfunction renderStreamMessage(message) {\n session.renderStreamMessage(message);\n}\n\nfunction clearCache() {\n session.clearCache();\n}\n\nfunction setProgressBarDelay(delay) {\n session.setProgressBarDelay(delay);\n}\n\nfunction setConfirmMethod(confirmMethod) {\n FormSubmission.confirmMethod = confirmMethod;\n}\n\nvar Turbo = /*#__PURE__*/Object.freeze({\n __proto__: null,\n navigator: navigator$1,\n session: session,\n PageRenderer: PageRenderer,\n PageSnapshot: PageSnapshot,\n start: start,\n registerAdapter: registerAdapter,\n visit: visit,\n connectStreamSource: connectStreamSource,\n disconnectStreamSource: disconnectStreamSource,\n renderStreamMessage: renderStreamMessage,\n clearCache: clearCache,\n setProgressBarDelay: setProgressBarDelay,\n setConfirmMethod: setConfirmMethod\n});\n\nclass FrameController {\n constructor(element) {\n this.fetchResponseLoaded = fetchResponse => {};\n\n this.currentFetchRequest = null;\n\n this.resolveVisitPromise = () => {};\n\n this.connected = false;\n this.hasBeenLoaded = false;\n this.settingSourceURL = false;\n this.element = element;\n this.view = new FrameView(this, this.element);\n this.appearanceObserver = new AppearanceObserver(this, this.element);\n this.linkInterceptor = new LinkInterceptor(this, this.element);\n this.formInterceptor = new FormInterceptor(this, this.element);\n }\n\n connect() {\n if (!this.connected) {\n this.connected = true;\n this.reloadable = false;\n\n if (this.loadingStyle == FrameLoadingStyle.lazy) {\n this.appearanceObserver.start();\n }\n\n this.linkInterceptor.start();\n this.formInterceptor.start();\n this.sourceURLChanged();\n }\n }\n\n disconnect() {\n if (this.connected) {\n this.connected = false;\n this.appearanceObserver.stop();\n this.linkInterceptor.stop();\n this.formInterceptor.stop();\n }\n }\n\n disabledChanged() {\n if (this.loadingStyle == FrameLoadingStyle.eager) {\n this.loadSourceURL();\n }\n }\n\n sourceURLChanged() {\n if (this.loadingStyle == FrameLoadingStyle.eager || this.hasBeenLoaded) {\n this.loadSourceURL();\n }\n }\n\n loadingStyleChanged() {\n if (this.loadingStyle == FrameLoadingStyle.lazy) {\n this.appearanceObserver.start();\n } else {\n this.appearanceObserver.stop();\n this.loadSourceURL();\n }\n }\n\n async loadSourceURL() {\n if (!this.settingSourceURL && this.enabled && this.isActive && (this.reloadable || this.sourceURL != this.currentURL)) {\n const previousURL = this.currentURL;\n this.currentURL = this.sourceURL;\n\n if (this.sourceURL) {\n try {\n this.element.loaded = this.visit(expandURL(this.sourceURL));\n this.appearanceObserver.stop();\n await this.element.loaded;\n this.hasBeenLoaded = true;\n } catch (error) {\n this.currentURL = previousURL;\n throw error;\n }\n }\n }\n }\n\n async loadResponse(fetchResponse) {\n if (fetchResponse.redirected || fetchResponse.succeeded && fetchResponse.isHTML) {\n this.sourceURL = fetchResponse.response.url;\n }\n\n try {\n const html = await fetchResponse.responseHTML;\n\n if (html) {\n const _parseHTMLDocument = parseHTMLDocument(html),\n body = _parseHTMLDocument.body;\n\n const snapshot = new Snapshot(await this.extractForeignFrameElement(body));\n const renderer = new FrameRenderer(this.view.snapshot, snapshot, false, false);\n if (this.view.renderPromise) await this.view.renderPromise;\n await this.view.render(renderer);\n session.frameRendered(fetchResponse, this.element);\n session.frameLoaded(this.element);\n this.fetchResponseLoaded(fetchResponse);\n }\n } catch (error) {\n console.error(error);\n this.view.invalidate();\n } finally {\n this.fetchResponseLoaded = () => {};\n }\n }\n\n elementAppearedInViewport(element) {\n this.loadSourceURL();\n }\n\n shouldInterceptLinkClick(element, url) {\n if (element.hasAttribute(\"data-turbo-method\")) {\n return false;\n } else {\n return this.shouldInterceptNavigation(element);\n }\n }\n\n linkClickIntercepted(element, url) {\n this.reloadable = true;\n this.navigateFrame(element, url);\n }\n\n shouldInterceptFormSubmission(element, submitter) {\n return this.shouldInterceptNavigation(element, submitter);\n }\n\n formSubmissionIntercepted(element, submitter) {\n if (this.formSubmission) {\n this.formSubmission.stop();\n }\n\n this.reloadable = false;\n this.formSubmission = new FormSubmission(this, element, submitter);\n const fetchRequest = this.formSubmission.fetchRequest;\n this.prepareHeadersForRequest(fetchRequest.headers, fetchRequest);\n this.formSubmission.start();\n }\n\n prepareHeadersForRequest(headers, request) {\n headers[\"Turbo-Frame\"] = this.id;\n }\n\n requestStarted(request) {\n markAsBusy(this.element);\n }\n\n requestPreventedHandlingResponse(request, response) {\n this.resolveVisitPromise();\n }\n\n async requestSucceededWithResponse(request, response) {\n await this.loadResponse(response);\n this.resolveVisitPromise();\n }\n\n requestFailedWithResponse(request, response) {\n console.error(response);\n this.resolveVisitPromise();\n }\n\n requestErrored(request, error) {\n console.error(error);\n this.resolveVisitPromise();\n }\n\n requestFinished(request) {\n clearBusyState(this.element);\n }\n\n formSubmissionStarted(_ref13) {\n let formElement = _ref13.formElement;\n markAsBusy(formElement, this.findFrameElement(formElement));\n }\n\n formSubmissionSucceededWithResponse(formSubmission, response) {\n const frame = this.findFrameElement(formSubmission.formElement, formSubmission.submitter);\n this.proposeVisitIfNavigatedWithAction(frame, formSubmission.formElement, formSubmission.submitter);\n frame.delegate.loadResponse(response);\n }\n\n formSubmissionFailedWithResponse(formSubmission, fetchResponse) {\n this.element.delegate.loadResponse(fetchResponse);\n }\n\n formSubmissionErrored(formSubmission, error) {\n console.error(error);\n }\n\n formSubmissionFinished(_ref14) {\n let formElement = _ref14.formElement;\n clearBusyState(formElement, this.findFrameElement(formElement));\n }\n\n allowsImmediateRender(snapshot, resume) {\n return true;\n }\n\n viewRenderedSnapshot(snapshot, isPreview) {}\n\n viewInvalidated() {}\n\n async visit(url) {\n var _a;\n\n const request = new FetchRequest(this, FetchMethod.get, url, new URLSearchParams(), this.element);\n (_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel();\n this.currentFetchRequest = request;\n return new Promise(resolve => {\n this.resolveVisitPromise = () => {\n this.resolveVisitPromise = () => {};\n\n this.currentFetchRequest = null;\n resolve();\n };\n\n request.perform();\n });\n }\n\n navigateFrame(element, url, submitter) {\n const frame = this.findFrameElement(element, submitter);\n this.proposeVisitIfNavigatedWithAction(frame, element, submitter);\n frame.setAttribute(\"reloadable\", \"\");\n frame.src = url;\n }\n\n proposeVisitIfNavigatedWithAction(frame, element, submitter) {\n const action = getAttribute(\"data-turbo-action\", submitter, element, frame);\n\n if (isAction(action)) {\n const _SnapshotSubstitution = new SnapshotSubstitution(frame),\n visitCachedSnapshot = _SnapshotSubstitution.visitCachedSnapshot;\n\n frame.delegate.fetchResponseLoaded = fetchResponse => {\n if (frame.src) {\n const statusCode = fetchResponse.statusCode,\n redirected = fetchResponse.redirected;\n const responseHTML = frame.ownerDocument.documentElement.outerHTML;\n const response = {\n statusCode,\n redirected,\n responseHTML\n };\n session.visit(frame.src, {\n action,\n response,\n visitCachedSnapshot,\n willRender: false\n });\n }\n };\n }\n }\n\n findFrameElement(element, submitter) {\n var _a;\n\n const id = getAttribute(\"data-turbo-frame\", submitter, element) || this.element.getAttribute(\"target\");\n return (_a = getFrameElementById(id)) !== null && _a !== void 0 ? _a : this.element;\n }\n\n async extractForeignFrameElement(container) {\n let element;\n const id = CSS.escape(this.id);\n\n try {\n if (element = activateElement(container.querySelector(\"turbo-frame#\".concat(id)), this.currentURL)) {\n return element;\n }\n\n if (element = activateElement(container.querySelector(\"turbo-frame[src][recurse~=\".concat(id, \"]\")), this.currentURL)) {\n await element.loaded;\n return await this.extractForeignFrameElement(element);\n }\n\n console.error(\"Response has no matching element\"));\n } catch (error) {\n console.error(error);\n }\n\n return new FrameElement();\n }\n\n formActionIsVisitable(form, submitter) {\n const action = getAction(form, submitter);\n return locationIsVisitable(expandURL(action), this.rootLocation);\n }\n\n shouldInterceptNavigation(element, submitter) {\n const id = getAttribute(\"data-turbo-frame\", submitter, element) || this.element.getAttribute(\"target\");\n\n if (element instanceof HTMLFormElement && !this.formActionIsVisitable(element, submitter)) {\n return false;\n }\n\n if (!this.enabled || id == \"_top\") {\n return false;\n }\n\n if (id) {\n const frameElement = getFrameElementById(id);\n\n if (frameElement) {\n return !frameElement.disabled;\n }\n }\n\n if (!session.elementDriveEnabled(element)) {\n return false;\n }\n\n if (submitter && !session.elementDriveEnabled(submitter)) {\n return false;\n }\n\n return true;\n }\n\n get id() {\n return this.element.id;\n }\n\n get enabled() {\n return !this.element.disabled;\n }\n\n get sourceURL() {\n if (this.element.src) {\n return this.element.src;\n }\n }\n\n get reloadable() {\n const frame = this.findFrameElement(this.element);\n return frame.hasAttribute(\"reloadable\");\n }\n\n set reloadable(value) {\n const frame = this.findFrameElement(this.element);\n\n if (value) {\n frame.setAttribute(\"reloadable\", \"\");\n } else {\n frame.removeAttribute(\"reloadable\");\n }\n }\n\n set sourceURL(sourceURL) {\n this.settingSourceURL = true;\n this.element.src = sourceURL !== null && sourceURL !== void 0 ? sourceURL : null;\n this.currentURL = this.element.src;\n this.settingSourceURL = false;\n }\n\n get loadingStyle() {\n return this.element.loading;\n }\n\n get isLoading() {\n return this.formSubmission !== undefined || this.resolveVisitPromise() !== undefined;\n }\n\n get isActive() {\n return this.element.isActive && this.connected;\n }\n\n get rootLocation() {\n var _a;\n\n const meta = this.element.ownerDocument.querySelector(\"meta[name=\\\"turbo-root\\\"]\");\n const root = (_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : \"/\";\n return expandURL(root);\n }\n\n}\n\nclass SnapshotSubstitution {\n constructor(element) {\n this.visitCachedSnapshot = _ref15 => {\n let element = _ref15.element;\n\n var _a;\n\n const id = this.id,\n clone = this.clone;\n (_a = element.querySelector(\"#\" + id)) === null || _a === void 0 ? void 0 : _a.replaceWith(clone);\n };\n\n this.clone = element.cloneNode(true);\n this.id = element.id;\n }\n\n}\n\nfunction getFrameElementById(id) {\n if (id != null) {\n const element = document.getElementById(id);\n\n if (element instanceof FrameElement) {\n return element;\n }\n }\n}\n\nfunction activateElement(element, currentURL) {\n if (element) {\n const src = element.getAttribute(\"src\");\n\n if (src != null && currentURL != null && urlsAreEqual(src, currentURL)) {\n throw new Error(\"Matching element has a source URL which references itself\"));\n }\n\n if (element.ownerDocument !== document) {\n element = document.importNode(element, true);\n }\n\n if (element instanceof FrameElement) {\n element.connectedCallback();\n element.disconnectedCallback();\n return element;\n }\n }\n}\n\nconst StreamActions = {\n after() {\n this.targetElements.forEach(e => {\n var _a;\n\n return (_a = e.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.templateContent, e.nextSibling);\n });\n },\n\n append() {\n this.removeDuplicateTargetChildren();\n this.targetElements.forEach(e => e.append(this.templateContent));\n },\n\n before() {\n this.targetElements.forEach(e => {\n var _a;\n\n return (_a = e.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.templateContent, e);\n });\n },\n\n prepend() {\n this.removeDuplicateTargetChildren();\n this.targetElements.forEach(e => e.prepend(this.templateContent));\n },\n\n remove() {\n this.targetElements.forEach(e => e.remove());\n },\n\n replace() {\n this.targetElements.forEach(e => e.replaceWith(this.templateContent));\n },\n\n update() {\n this.targetElements.forEach(e => {\n e.innerHTML = \"\";\n e.append(this.templateContent);\n });\n }\n\n};\n\nclass StreamElement extends HTMLElement {\n async connectedCallback() {\n try {\n await this.render();\n } catch (error) {\n console.error(error);\n } finally {\n this.disconnect();\n }\n }\n\n async render() {\n var _a;\n\n return (_a = this.renderPromise) !== null && _a !== void 0 ? _a : this.renderPromise = (async () => {\n if (this.dispatchEvent(this.beforeRenderEvent)) {\n await nextAnimationFrame();\n this.performAction();\n }\n })();\n }\n\n disconnect() {\n try {\n this.remove();\n } catch (_a) {}\n }\n\n removeDuplicateTargetChildren() {\n this.duplicateChildren.forEach(c => c.remove());\n }\n\n get duplicateChildren() {\n var _a;\n\n const existingChildren = this.targetElements.flatMap(e => [...e.children]).filter(c => !!c.id);\n const newChildrenIds = [...((_a = this.templateContent) === null || _a === void 0 ? void 0 : _a.children)].filter(c => !!c.id).map(c => c.id);\n return existingChildren.filter(c => newChildrenIds.includes(c.id));\n }\n\n get performAction() {\n if (this.action) {\n const actionFunction = StreamActions[this.action];\n\n if (actionFunction) {\n return actionFunction;\n }\n\n this.raise(\"unknown action\");\n }\n\n this.raise(\"action attribute is missing\");\n }\n\n get targetElements() {\n if (this.target) {\n return this.targetElementsById;\n } else if (this.targets) {\n return this.targetElementsByQuery;\n } else {\n this.raise(\"target or targets attribute is missing\");\n }\n }\n\n get templateContent() {\n return this.templateElement.content.cloneNode(true);\n }\n\n get templateElement() {\n if (this.firstElementChild instanceof HTMLTemplateElement) {\n return this.firstElementChild;\n }\n\n this.raise(\"first child element must be a