rails_devtools 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +92 -0
  3. data/Rakefile +8 -0
  4. data/app/assets/config/devtools_manifest.js +1 -0
  5. data/app/assets/stylesheets/devtools/application.css +15 -0
  6. data/app/controllers/rails_devtools/application_controller.rb +4 -0
  7. data/app/controllers/rails_devtools/base_controller.rb +7 -0
  8. data/app/controllers/rails_devtools/database_tables_controller.rb +16 -0
  9. data/app/controllers/rails_devtools/frontend/modules_controller.rb +18 -0
  10. data/app/controllers/rails_devtools/gems_controller.rb +16 -0
  11. data/app/controllers/rails_devtools/host_app_images_controller.rb +35 -0
  12. data/app/controllers/rails_devtools/image_assets_controller.rb +43 -0
  13. data/app/controllers/rails_devtools/routes/route_path_inputs_controller.rb +23 -0
  14. data/app/controllers/rails_devtools/routes_controller.rb +21 -0
  15. data/app/forms/rails_devtools/database_table_search_form.rb +51 -0
  16. data/app/forms/rails_devtools/gem_search_form.rb +86 -0
  17. data/app/forms/rails_devtools/image_search_form.rb +30 -0
  18. data/app/forms/rails_devtools/route_search_form.rb +17 -0
  19. data/app/helpers/rails_devtools/application_helper.rb +4 -0
  20. data/app/javascript/application.js +4 -0
  21. data/app/javascript/controllers/application.js +10 -0
  22. data/app/javascript/controllers/checkbox_controller.js +9 -0
  23. data/app/javascript/controllers/index.js +11 -0
  24. data/app/javascript/controllers/search_reset_controller.js +7 -0
  25. data/app/javascript/controllers/turbo_form_controller.js +9 -0
  26. data/app/jobs/rails_devtools/application_job.rb +4 -0
  27. data/app/mailers/rails_devtools/application_mailer.rb +6 -0
  28. data/app/models/rails_devtools/application_record.rb +5 -0
  29. data/app/models/rails_devtools/image_assets/image_info.rb +85 -0
  30. data/app/models/rails_devtools/routes/collection.rb +83 -0
  31. data/app/models/rails_devtools/routes/controller_info.rb +30 -0
  32. data/app/models/rails_devtools/routes/engine_info.rb +33 -0
  33. data/app/models/rails_devtools/routes/route_info.rb +120 -0
  34. data/app/views/rails_devtools/application_layout.rb +90 -0
  35. data/app/views/rails_devtools/application_view.rb +6 -0
  36. data/app/views/rails_devtools/components/application_component.rb +24 -0
  37. data/app/views/rails_devtools/components/flash_message.rb +29 -0
  38. data/app/views/rails_devtools/components/lucide/base.rb +18 -0
  39. data/app/views/rails_devtools/components/lucide/close.rb +25 -0
  40. data/app/views/rails_devtools/components/lucide/database.rb +26 -0
  41. data/app/views/rails_devtools/components/lucide/external_link.rb +26 -0
  42. data/app/views/rails_devtools/components/lucide/images.rb +27 -0
  43. data/app/views/rails_devtools/components/lucide/menu.rb +26 -0
  44. data/app/views/rails_devtools/components/lucide/package.rb +30 -0
  45. data/app/views/rails_devtools/components/lucide/pocket_knife.rb +28 -0
  46. data/app/views/rails_devtools/components/lucide/sign_post.rb +29 -0
  47. data/app/views/rails_devtools/components/lucide/trash.rb +26 -0
  48. data/app/views/rails_devtools/components/lucide/triangle_alert.rb +29 -0
  49. data/app/views/rails_devtools/components/page_content.rb +27 -0
  50. data/app/views/rails_devtools/components/ui/drawer.rb +49 -0
  51. data/app/views/rails_devtools/components/ui/menu.rb +81 -0
  52. data/app/views/rails_devtools/components/ui/search_form.rb +65 -0
  53. data/app/views/rails_devtools/components.rb +5 -0
  54. data/app/views/rails_devtools/database_tables/index.rb +32 -0
  55. data/app/views/rails_devtools/database_tables/table_card.rb +61 -0
  56. data/app/views/rails_devtools/gems/gem_card.rb +74 -0
  57. data/app/views/rails_devtools/gems/index.rb +32 -0
  58. data/app/views/rails_devtools/image_assets/image_card.rb +37 -0
  59. data/app/views/rails_devtools/image_assets/image_details.rb +82 -0
  60. data/app/views/rails_devtools/image_assets/index.rb +39 -0
  61. data/app/views/rails_devtools/routes/index.rb +37 -0
  62. data/app/views/rails_devtools/routes/route_card.rb +70 -0
  63. data/app/views/rails_devtools/routes/route_details/controller_card.rb +87 -0
  64. data/app/views/rails_devtools/routes/route_details/route_path_input.rb +46 -0
  65. data/app/views/rails_devtools/routes/route_details.rb +171 -0
  66. data/config/routes.rb +24 -0
  67. data/lib/rails_devtools/asset_config.rb +52 -0
  68. data/lib/rails_devtools/asset_providers/jsbundling_rails_config.rb +21 -0
  69. data/lib/rails_devtools/asset_providers/propshaft_config.rb +19 -0
  70. data/lib/rails_devtools/asset_providers/shakapacker_config.rb +26 -0
  71. data/lib/rails_devtools/asset_providers/sprocket_config.rb +19 -0
  72. data/lib/rails_devtools/asset_providers/vite_rails_config.rb +19 -0
  73. data/lib/rails_devtools/engine.rb +22 -0
  74. data/lib/rails_devtools/importmap.rb +16 -0
  75. data/lib/rails_devtools/importmaps/base.rb +82 -0
  76. data/lib/rails_devtools/version.rb +3 -0
  77. data/lib/rails_devtools.rb +20 -0
  78. data/lib/tasks/rails_devtools_tasks.rake +4 -0
  79. data/vendor/javascript/@stimulus-components--clipboard.js +4 -0
  80. data/vendor/javascript/@stimulus-components--notification.js +4 -0
  81. data/vendor/javascript/@stimulus-components--reveal.js +4 -0
  82. data/vendor/javascript/stimulus-autoloader.js +54 -0
  83. data/vendor/javascript/stimulus-importmap-autoloader.js +27 -0
  84. data/vendor/javascript/stimulus-loading.js +93 -0
  85. data/vendor/javascript/stimulus-use.js +4 -0
  86. data/vendor/javascript/stimulus.min.js +5 -0
  87. data/vendor/javascript/turbo.min.js +36 -0
  88. metadata +241 -0
@@ -0,0 +1,82 @@
1
+ module RailsDevtools
2
+ module Importmaps
3
+ class Base
4
+ def self.pin(name, to: nil, preload: true, vendor: false)
5
+ to = "#{name}.js" if to.nil?
6
+ pins << Pin.new(name, to, preload, vendor)
7
+ end
8
+
9
+ def self.pin_all_from(directory, under:, preload: true)
10
+ Dir.glob("#{directory}/**/*.js").each do |file|
11
+ path = Pathname.new(file)
12
+ if path.basename.to_s == "index.js"
13
+ pin(under, to: "#{under}/index.js", preload: preload)
14
+ else
15
+ name = file.sub("#{directory}/", "").sub(/\.js$/, "")
16
+ to = "#{under}/#{name}"
17
+ pin(to, to: "#{to}.js", preload: preload)
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.pins
23
+ @pins ||= []
24
+ end
25
+
26
+ def preloads
27
+ pins.select(&:preload)
28
+ end
29
+
30
+ def pins
31
+ self.class.pins
32
+ end
33
+
34
+ def to_json(**)
35
+ imports = self.class.pins.each_with_object({}) do |pin, memo|
36
+ memo[pin.name] = pin.path
37
+ end
38
+
39
+ JSON.pretty_generate({ imports: imports })
40
+ end
41
+
42
+ def find(item)
43
+ pins.find { |p| p.to == "#{item}.js" }
44
+ end
45
+ end
46
+ end
47
+
48
+ class Pin
49
+ include RailsDevtools::Engine.routes.url_helpers
50
+
51
+ attr_reader :name, :to, :preload, :vendor
52
+
53
+ def initialize(name, to, preload, vendor)
54
+ @name = name
55
+ @to = to
56
+ @preload = preload
57
+ @vendor = vendor
58
+ end
59
+
60
+ def file_path
61
+ @file_path ||= @vendor ? vendor_path_to(to) : local_javascript_path_to(to)
62
+ end
63
+
64
+ def path
65
+ @path ||= frontend_path(to)
66
+ end
67
+
68
+ private
69
+
70
+ def engine_path_to(*)
71
+ RailsDevtools::Engine.root.join(*)
72
+ end
73
+
74
+ def vendor_path_to(filename)
75
+ engine_path_to("vendor", "javascript", filename)
76
+ end
77
+
78
+ def local_javascript_path_to(filename)
79
+ engine_path_to("app", "javascript", filename)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,3 @@
1
+ module RailsDevtools
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ require "rails_devtools/version"
2
+ require "rails_devtools/engine"
3
+
4
+ module RailsDevtools
5
+ def self.importmap
6
+ @importmap ||= Importmap.new
7
+ end
8
+
9
+ def self.asset_config
10
+ @asset_config ||= AssetConfig.find
11
+ end
12
+ end
13
+
14
+ require "zeitwerk"
15
+
16
+ loader = Zeitwerk::Loader.for_gem
17
+ loader.ignore("#{__dir__}/active_resource")
18
+ loader.setup
19
+
20
+ loader.eager_load
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rails_devtools do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,4 @@
1
+ // @stimulus-components/clipboard@5.0.0 downloaded from https://ga.jspm.io/npm:@stimulus-components/clipboard@5.0.0/dist/stimulus-clipboard.mjs
2
+
3
+ import{Controller as t}from"@hotwired/stimulus";const e=class _Clipboard extends t{connect(){this.hasButtonTarget&&(this.originalContent=this.buttonTarget.innerHTML)}copy(t){t.preventDefault();const e=this.sourceTarget.innerHTML||this.sourceTarget.value;navigator.clipboard.writeText(e).then((()=>this.copied()))}copied(){this.hasButtonTarget&&(this.timeout&&clearTimeout(this.timeout),this.buttonTarget.innerHTML=this.successContentValue,this.timeout=setTimeout((()=>{this.buttonTarget.innerHTML=this.originalContent}),this.successDurationValue))}};e.targets=["button","source"],e.values={successContent:String,successDuration:{type:Number,default:2e3}};let s=e;export{s as default};
4
+
@@ -0,0 +1,4 @@
1
+ // @stimulus-components/notification@3.0.0 downloaded from https://ga.jspm.io/npm:@stimulus-components/notification@3.0.0/dist/stimulus-notification.mjs
2
+
3
+ import{Controller as t}from"@hotwired/stimulus";import{useTransition as e}from"stimulus-use";const i=class _Notification extends t{initialize(){this.hide=this.hide.bind(this)}connect(){e(this),this.hiddenValue===!1&&this.show()}show(){this.enter(),this.timeout=setTimeout(this.hide,this.delayValue)}async hide(){this.timeout&&clearTimeout(this.timeout),await this.leave(),this.element.remove()}};i.values={delay:{type:Number,default:3e3},hidden:{type:Boolean,default:!1}};let s=i;export{s as default};
4
+
@@ -0,0 +1,4 @@
1
+ // @stimulus-components/reveal@5.0.0 downloaded from https://ga.jspm.io/npm:@stimulus-components/reveal@5.0.0/dist/stimulus-reveal-controller.mjs
2
+
3
+ import{Controller as s}from"@hotwired/stimulus";const t=class _Reveal extends s{connect(){this.class=this.hasHiddenClass?this.hiddenClass:"hidden"}toggle(){this.itemTargets.forEach((s=>{s.classList.toggle(this.class)}))}show(){this.itemTargets.forEach((s=>{s.classList.remove(this.class)}))}hide(){this.itemTargets.forEach((s=>{s.classList.add(this.class)}))}};t.targets=["item"],t.classes=["hidden"];let e=t;export{e as default};
4
+
@@ -0,0 +1,54 @@
1
+ import { Application } from "@hotwired/stimulus"
2
+
3
+ const application = Application.start()
4
+ const { controllerAttribute } = application.schema
5
+ const registeredControllers = {}
6
+
7
+ function autoloadControllersWithin(element) {
8
+ queryControllerNamesWithin(element).forEach(loadController)
9
+ }
10
+
11
+ function queryControllerNamesWithin(element) {
12
+ return Array.from(element.querySelectorAll(`[${controllerAttribute}]`)).map(extractControllerNamesFrom).flat()
13
+ }
14
+
15
+ function extractControllerNamesFrom(element) {
16
+ return element.getAttribute(controllerAttribute).split(/\s+/).filter(content => content.length)
17
+ }
18
+
19
+ function loadController(name) {
20
+ import(controllerFilename(name))
21
+ .then(module => registerController(name, module))
22
+ .catch(error => console.error(`Failed to autoload controller: ${name}`, error))
23
+ }
24
+
25
+ function controllerFilename(name) {
26
+ return `controllers/${name.replace(/--/g, "/").replace(/-/g, "_")}_controller`
27
+ }
28
+
29
+ function registerController(name, module) {
30
+ if (name in registeredControllers) return
31
+
32
+ application.register(name, module.default)
33
+ registeredControllers[name] = true
34
+ }
35
+
36
+
37
+ new MutationObserver((mutationsList) => {
38
+ for (const { attributeName, target, type } of mutationsList) {
39
+ switch (type) {
40
+ case "attributes": {
41
+ if (attributeName == controllerAttribute && target.getAttribute(controllerAttribute)) {
42
+ extractControllerNamesFrom(target).forEach(loadController)
43
+ }
44
+ }
45
+ case "childList": {
46
+ autoloadControllersWithin(target)
47
+ }
48
+ }
49
+ }
50
+ }).observe(document, { attributeFilter: [controllerAttribute], subtree: true, childList: true })
51
+
52
+ autoloadControllersWithin(document)
53
+
54
+ console.warn("stimulus-autoload.js has been deprecated in favor of stimulus-loading.js")
@@ -0,0 +1,27 @@
1
+ // FIXME: es-module-shim won't shim the dynamic import without this explicit import
2
+ import "@hotwired/stimulus"
3
+
4
+ export function registerControllersFrom(under, application) {
5
+ const paths = Object.keys(parseImportmapJson())
6
+ .filter(path => path.match(new RegExp(`^${under}/.*_controller$`)))
7
+
8
+ paths.forEach(path => registerControllerFromPath(path, under, application))
9
+ }
10
+
11
+ export function parseImportmapJson() {
12
+ return JSON.parse(document.querySelector("script[type=importmap]").text).imports
13
+ }
14
+
15
+ function registerControllerFromPath(path, under, application) {
16
+ const name = path
17
+ .replace(new RegExp(`^${under}/`), "")
18
+ .replace("_controller", "")
19
+ .replace(/\//g, "--")
20
+ .replace(/_/g, "-")
21
+
22
+ import(path)
23
+ .then(module => application.register(name, module.default))
24
+ .catch(error => console.error(`Failed to register controller: ${name} (${path})`, error))
25
+ }
26
+
27
+ console.warn("stimulus-importmap-autoload.js has been deprecated in favor of stimulus-loading.js")
@@ -0,0 +1,93 @@
1
+ // FIXME: es-module-shim won't shim the dynamic import without this explicit import
2
+ import "@hotwired/stimulus"
3
+
4
+ const controllerAttribute = "data-controller"
5
+
6
+ // Eager load all controllers registered beneath the `under` path in the import map to the passed application instance.
7
+ export function eagerLoadControllersFrom(under, application) {
8
+ const paths = Object.keys(parseImportmapJson()).filter(path => path.match(new RegExp(`^${under}/.*_controller$`)))
9
+ paths.forEach(path => registerControllerFromPath(path, under, application))
10
+ }
11
+
12
+ function parseImportmapJson() {
13
+ return JSON.parse(document.querySelector("script[type=importmap]").text).imports
14
+ }
15
+
16
+ function registerControllerFromPath(path, under, application) {
17
+ const name = path
18
+ .replace(new RegExp(`^${under}/`), "")
19
+ .replace("_controller", "")
20
+ .replace(/\//g, "--")
21
+ .replace(/_/g, "-")
22
+
23
+ if (canRegisterController(name, application)) {
24
+ import(path)
25
+ .then(module => registerController(name, module, application))
26
+ .catch(error => {
27
+ if (error instanceof TypeError) {
28
+ error.message = `Failed to register controller: ${name} (${path})`
29
+ }
30
+
31
+ throw error
32
+ })
33
+ }
34
+ }
35
+
36
+
37
+ // Lazy load controllers registered beneath the `under` path in the import map to the passed application instance.
38
+ export function lazyLoadControllersFrom(under, application, element = document) {
39
+ lazyLoadExistingControllers(under, application, element)
40
+ lazyLoadNewControllers(under, application, element)
41
+ }
42
+
43
+ function lazyLoadExistingControllers(under, application, element) {
44
+ queryControllerNamesWithin(element).forEach(controllerName => loadController(controllerName, under, application))
45
+ }
46
+
47
+ function lazyLoadNewControllers(under, application, element) {
48
+ new MutationObserver((mutationsList) => {
49
+ for (const { attributeName, target, type } of mutationsList) {
50
+ switch (type) {
51
+ case "attributes": {
52
+ if (attributeName == controllerAttribute && target.getAttribute(controllerAttribute)) {
53
+ extractControllerNamesFrom(target).forEach(controllerName => loadController(controllerName, under, application))
54
+ }
55
+ }
56
+
57
+ case "childList": {
58
+ lazyLoadExistingControllers(under, application, target)
59
+ }
60
+ }
61
+ }
62
+ }).observe(element, { attributeFilter: [controllerAttribute], subtree: true, childList: true })
63
+ }
64
+
65
+ function queryControllerNamesWithin(element) {
66
+ return Array.from(element.querySelectorAll(`[${controllerAttribute}]`)).map(extractControllerNamesFrom).flat()
67
+ }
68
+
69
+ function extractControllerNamesFrom(element) {
70
+ return element.getAttribute(controllerAttribute).split(/\s+/).filter(content => content.length)
71
+ }
72
+
73
+ function loadController(name, under, application) {
74
+ if (canRegisterController(name, application)) {
75
+ import(controllerFilename(name, under))
76
+ .then(module => registerController(name, module, application))
77
+ .catch(error => console.error(`Failed to autoload controller: ${name}`, error))
78
+ }
79
+ }
80
+
81
+ function controllerFilename(name, under) {
82
+ return `${under}/${name.replace(/--/g, "/").replace(/-/g, "_")}_controller`
83
+ }
84
+
85
+ function registerController(name, module, application) {
86
+ if (canRegisterController(name, application)) {
87
+ application.register(name, module.default)
88
+ }
89
+ }
90
+
91
+ function canRegisterController(name, application) {
92
+ return !application.router.modulesByIdentifier.has(name)
93
+ }
@@ -0,0 +1,4 @@
1
+ // stimulus-use@0.52.2 downloaded from https://ga.jspm.io/npm:stimulus-use@0.52.2/dist/index.js
2
+
3
+ import{Controller as e}from"@hotwired/stimulus";const method=(e,t)=>{const s=e[t];return typeof s=="function"?s:(...e)=>{}};const composeEventName=(e,t,s)=>{let n=e;s===true?n=`${t.identifier}:${e}`:typeof s==="string"&&(n=`${s}:${e}`);return n};const extendedEvent=(e,t,s)=>{const{bubbles:n,cancelable:o,composed:i}=t||{bubbles:true,cancelable:true,composed:true};t&&Object.assign(s,{originalEvent:t});const r=new CustomEvent(e,{bubbles:n,cancelable:o,composed:i,detail:s});return r};function isElementInViewport(e){const t=e.getBoundingClientRect();const s=window.innerHeight||document.documentElement.clientHeight;const n=window.innerWidth||document.documentElement.clientWidth;const o=t.top<=s&&t.top+t.height>0;const i=t.left<=n&&t.left+t.width>0;return o&&i}function camelize(e){return e.replace(/(?:[_-])([a-z0-9])/g,((e,t)=>t.toUpperCase()))}function __rest(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols==="function"){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(s[n[o]]=e[n[o]])}return s}const t={debug:false,logger:console,dispatchEvent:true,eventPrefix:true};class StimulusUse{constructor(e,s={}){var n,o,i;this.log=(e,t)=>{if(this.debug){this.logger.groupCollapsed(`%c${this.controller.identifier} %c#${e}`,"color: #3B82F6","color: unset");this.logger.log(Object.assign({controllerId:this.controllerId},t));this.logger.groupEnd()}};this.warn=e=>{this.logger.warn(`%c${this.controller.identifier} %c${e}`,"color: #3B82F6; font-weight: bold","color: unset")};this.dispatch=(e,t={})=>{if(this.dispatchEvent){const{event:s}=t,n=__rest(t,["event"]);const o=this.extendedEvent(e,s||null,n);this.targetElement.dispatchEvent(o);this.log("dispatchEvent",Object.assign({eventName:o.type},n))}};this.call=(e,t={})=>{const s=this.controller[e];if(typeof s=="function")return s.call(this.controller,t)};this.extendedEvent=(e,t,s)=>{const{bubbles:n,cancelable:o,composed:i}=t||{bubbles:true,cancelable:true,composed:true};t&&Object.assign(s,{originalEvent:t});const r=new CustomEvent(this.composeEventName(e),{bubbles:n,cancelable:o,composed:i,detail:s});return r};this.composeEventName=e=>{let t=e;this.eventPrefix===true?t=`${this.controller.identifier}:${e}`:typeof this.eventPrefix==="string"&&(t=`${this.eventPrefix}:${e}`);return t};this.debug=(o=(n=s===null||s===void 0?void 0:s.debug)!==null&&n!==void 0?n:e.application.stimulusUseDebug)!==null&&o!==void 0?o:t.debug;this.logger=(i=s===null||s===void 0?void 0:s.logger)!==null&&i!==void 0?i:t.logger;this.controller=e;this.controllerId=e.element.id||e.element.dataset.id;this.targetElement=(s===null||s===void 0?void 0:s.element)||e.element;const{dispatchEvent:r,eventPrefix:l}=Object.assign({},t,s);Object.assign(this,{dispatchEvent:r,eventPrefix:l});this.controllerInitialize=e.initialize.bind(e);this.controllerConnect=e.connect.bind(e);this.controllerDisconnect=e.disconnect.bind(e)}}const s={eventPrefix:true,bubbles:true,cancelable:true};class UseDispatch extends StimulusUse{constructor(e,t={}){var n,o,i,r;super(e,t);this.dispatch=(e,t={})=>{const{controller:s,targetElement:n,eventPrefix:o,bubbles:i,cancelable:r,log:l,warn:c}=this;Object.assign(t,{controller:s});const a=composeEventName(e,this.controller,o);const u=new CustomEvent(a,{detail:t,bubbles:i,cancelable:r});n.dispatchEvent(u);c("`useDispatch()` is deprecated. Please use the built-in `this.dispatch()` function from Stimulus. You can find more information on how to upgrade at: https://stimulus-use.github.io/stimulus-use/#/use-dispatch");l("dispatch",{eventName:a,detail:t,bubbles:i,cancelable:r});return u};this.targetElement=(n=t.element)!==null&&n!==void 0?n:e.element;this.eventPrefix=(o=t.eventPrefix)!==null&&o!==void 0?o:s.eventPrefix;this.bubbles=(i=t.bubbles)!==null&&i!==void 0?i:s.bubbles;this.cancelable=(r=t.cancelable)!==null&&r!==void 0?r:s.cancelable;this.enhanceController()}enhanceController(){Object.assign(this.controller,{dispatch:this.dispatch})}}const useDispatch=(e,t={})=>new UseDispatch(e,t);const n={overwriteDispatch:true};const useApplication=(e,t={})=>{const{overwriteDispatch:s}=Object.assign({},n,t);Object.defineProperty(e,"isPreview",{get(){return document.documentElement.hasAttribute("data-turbolinks-preview")||document.documentElement.hasAttribute("data-turbo-preview")}});Object.defineProperty(e,"isConnected",{get(){return!!Array.from(this.context.module.connectedContexts).find((e=>e===this.context))}});Object.defineProperty(e,"csrfToken",{get(){return this.metaValue("csrf-token")}});s&&useDispatch(e,t);Object.assign(e,{metaValue(e){const t=document.head.querySelector(`meta[name="${e}"]`);return t&&t.getAttribute("content")}})};class ApplicationController extends e{constructor(e){super(e);this.isPreview=false;this.isConnected=false;this.csrfToken="";useApplication(this,this.options)}}const o={events:["click","touchend"],onlyVisible:true,dispatchEvent:true,eventPrefix:true};const useClickOutside=(e,t={})=>{const s=e;const{onlyVisible:n,dispatchEvent:i,events:r,eventPrefix:l}=Object.assign({},o,t);const onEvent=e=>{const o=(t===null||t===void 0?void 0:t.element)||s.element;if(!(o.contains(e.target)||!isElementInViewport(o)&&n)){s.clickOutside&&s.clickOutside(e);if(i){const t=composeEventName("click:outside",s,l);const n=extendedEvent(t,e,{controller:s});o.dispatchEvent(n)}}};const observe=()=>{r===null||r===void 0?void 0:r.forEach((e=>{window.addEventListener(e,onEvent,true)}))};const unobserve=()=>{r===null||r===void 0?void 0:r.forEach((e=>{window.removeEventListener(e,onEvent,true)}))};const c=s.disconnect.bind(s);Object.assign(s,{disconnect(){unobserve();c()}});observe();return[observe,unobserve]};class ClickOutsideComposableController extends e{}class ClickOutsideController extends ClickOutsideComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useClickOutside(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}class DebounceController extends e{}DebounceController.debounces=[];const i=200;const debounce=(e,t=i)=>{let s=null;return function(){const n=Array.from(arguments);const o=this;const i=n.map((e=>e.params));const callback=()=>{n.forEach(((e,t)=>e.params=i[t]));return e.apply(o,n)};s&&clearTimeout(s);s=setTimeout(callback,t)}};const useDebounce=(e,t)=>{const s=e;const n=s.constructor;n.debounces.forEach((e=>{typeof e==="string"&&(s[e]=debounce(s[e],t===null||t===void 0?void 0:t.wait));if(typeof e==="object"){const{name:n,wait:o}=e;if(!n)return;s[n]=debounce(s[n],o||(t===null||t===void 0?void 0:t.wait))}}))};class UseHover extends StimulusUse{constructor(e,t={}){super(e,t);this.observe=()=>{this.targetElement.addEventListener("mouseenter",this.onEnter);this.targetElement.addEventListener("mouseleave",this.onLeave)};this.unobserve=()=>{this.targetElement.removeEventListener("mouseenter",this.onEnter);this.targetElement.removeEventListener("mouseleave",this.onLeave)};this.onEnter=e=>{this.call("mouseEnter",e);this.log("mouseEnter",{hover:true});this.dispatch("mouseEnter",{hover:false})};this.onLeave=e=>{this.call("mouseLeave",e);this.log("mouseLeave",{hover:false});this.dispatch("mouseLeave",{hover:false})};this.controller=e;this.enhanceController();this.observe()}enhanceController(){const e=this.controller.disconnect.bind(this.controller);const disconnect=()=>{this.unobserve();e()};Object.assign(this.controller,{disconnect:disconnect})}}const useHover=(e,t={})=>{const s=e;const n=new UseHover(s,t);return[n.observe,n.unobserve]};class HoverComposableController extends e{}class HoverController extends HoverComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useHover(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}const r=["mousemove","mousedown","resize","keydown","touchstart","wheel"];const l=6e4;const c={ms:l,initialState:false,events:r,dispatchEvent:true,eventPrefix:true};const useIdle=(e,t={})=>{const s=e;const{ms:n,initialState:o,events:i,dispatchEvent:r,eventPrefix:l}=Object.assign({},c,t);let a=o;let u=setTimeout((()=>{a=true;dispatchAway()}),n);const dispatchAway=e=>{const t=composeEventName("away",s,l);s.isIdle=true;method(s,"away").call(s,e);if(r){const n=extendedEvent(t,e||null,{controller:s});s.element.dispatchEvent(n)}};const dispatchBack=e=>{const t=composeEventName("back",s,l);s.isIdle=false;method(s,"back").call(s,e);if(r){const n=extendedEvent(t,e||null,{controller:s});s.element.dispatchEvent(n)}};const onEvent=e=>{a&&dispatchBack(e);a=false;clearTimeout(u);u=setTimeout((()=>{a=true;dispatchAway(e)}),n)};const onVisibility=e=>{document.hidden||onEvent(e)};a?dispatchAway():dispatchBack();const h=s.disconnect.bind(s);const observe=()=>{i.forEach((e=>{window.addEventListener(e,onEvent)}));document.addEventListener("visibilitychange",onVisibility)};const unobserve=()=>{clearTimeout(u);i.forEach((e=>{window.removeEventListener(e,onEvent)}));document.removeEventListener("visibilitychange",onVisibility)};Object.assign(s,{disconnect(){unobserve();h()}});observe();return[observe,unobserve]};class IdleComposableController extends e{constructor(){super(...arguments);this.isIdle=false}}class IdleController extends IdleComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useIdle(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}const a={dispatchEvent:true,eventPrefix:true,visibleAttribute:"isVisible"};const useIntersection=(e,t={})=>{const s=e;const{dispatchEvent:n,eventPrefix:o,visibleAttribute:i}=Object.assign({},a,t);const r=(t===null||t===void 0?void 0:t.element)||s.element;s.intersectionElements||(s.intersectionElements=[]);s.intersectionElements.push(r);const callback=e=>{const[t]=e;t.isIntersecting?dispatchAppear(t):r.hasAttribute(i)&&dispatchDisappear(t)};const l=new IntersectionObserver(callback,t);const dispatchAppear=e=>{r.setAttribute(i,"true");method(s,"appear").call(s,e,l);if(n){const t=composeEventName("appear",s,o);const n=extendedEvent(t,null,{controller:s,entry:e,observer:l});r.dispatchEvent(n)}};const dispatchDisappear=e=>{r.removeAttribute(i);method(s,"disappear").call(s,e,l);if(n){const t=composeEventName("disappear",s,o);const n=extendedEvent(t,null,{controller:s,entry:e,observer:l});r.dispatchEvent(n)}};const c=s.disconnect.bind(s);const disconnect=()=>{unobserve();c()};const observe=()=>{l.observe(r)};const unobserve=()=>{l.unobserve(r)};const noneVisible=()=>s.intersectionElements.filter((e=>e.hasAttribute(i))).length===0;const oneVisible=()=>s.intersectionElements.filter((e=>e.hasAttribute(i))).length===1;const atLeastOneVisible=()=>s.intersectionElements.some((e=>e.hasAttribute(i)));const allVisible=()=>s.intersectionElements.every((e=>e.hasAttribute(i)));const u=allVisible;Object.assign(s,{isVisible:u,noneVisible:noneVisible,oneVisible:oneVisible,atLeastOneVisible:atLeastOneVisible,allVisible:allVisible,disconnect:disconnect});observe();return[observe,unobserve]};class IntersectionComposableController extends e{}class IntersectionController extends IntersectionComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useIntersection(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}const useLazyLoad=(e,t)=>{const callback=t=>{const[s]=t;s.isIntersecting&&!e.isLoaded&&handleAppear()};const handleAppear=t=>{const s=e.data.get("src");if(!s)return;const n=e.element;e.isLoading=true;method(e,"loading").call(e,s);n.onload=()=>{handleLoaded(s)};n.src=s};const handleLoaded=t=>{e.isLoading=false;e.isLoaded=true;method(e,"loaded").call(e,t)};const s=e.disconnect.bind(e);const n=new IntersectionObserver(callback,t);const observe=()=>{n.observe(e.element)};const unobserve=()=>{n.unobserve(e.element)};Object.assign(e,{isVisible:false,disconnect(){unobserve();s()}});observe();return[observe,unobserve]};class LazyLoadComposableController extends e{constructor(){super(...arguments);this.isLoading=false;this.isLoaded=false}}class LazyLoadController extends LazyLoadComposableController{constructor(e){super(e);this.options={rootMargin:"10%"};requestAnimationFrame((()=>{const[e,t]=useLazyLoad(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}const u={mediaQueries:{},dispatchEvent:true,eventPrefix:true,debug:false};class UseMatchMedia extends StimulusUse{constructor(e,t={}){var s,n,o,i;super(e,t);this.matches=[];this.callback=e=>{const t=Object.keys(this.mediaQueries).find((t=>this.mediaQueries[t]===e.media));if(!t)return;const{media:s,matches:n}=e;this.changed({name:t,media:s,matches:n,event:e})};this.changed=e=>{const{name:t}=e;if(e.event){this.call(camelize(`${t}_changed`),e);this.dispatch(`${t}:changed`,e);this.log(`media query "${t}" changed`,e)}if(e.matches){this.call(camelize(`is_${t}`),e);this.dispatch(`is:${t}`,e)}else{this.call(camelize(`not_${t}`),e);this.dispatch(`not:${t}`,e)}};this.observe=()=>{Object.keys(this.mediaQueries).forEach((e=>{const t=this.mediaQueries[e];const s=window.matchMedia(t);s.addListener(this.callback);this.matches.push(s);this.changed({name:e,media:t,matches:s.matches})}))};this.unobserve=()=>{this.matches.forEach((e=>e.removeListener(this.callback)))};this.controller=e;this.mediaQueries=(s=t.mediaQueries)!==null&&s!==void 0?s:u.mediaQueries;this.dispatchEvent=(n=t.dispatchEvent)!==null&&n!==void 0?n:u.dispatchEvent;this.eventPrefix=(o=t.eventPrefix)!==null&&o!==void 0?o:u.eventPrefix;this.debug=(i=t.debug)!==null&&i!==void 0?i:u.debug;if(window.matchMedia){this.enhanceController();this.observe()}else console.error("window.matchMedia() is not available")}enhanceController(){const e=this.controller.disconnect.bind(this.controller);const disconnect=()=>{this.unobserve();e()};Object.assign(this.controller,{disconnect:disconnect})}}const useMatchMedia=(e,t={})=>{const s=new UseMatchMedia(e,t);return[s.observe,s.unobserve]};const memoize=(e,t,s)=>{Object.defineProperty(e,t,{value:s});return s};const useMemo=e=>{var t;(t=e.constructor.memos)===null||t===void 0?void 0:t.forEach((t=>{memoize(e,t,e[t])}))};const defineMetaGetter=(e,t,s)=>{const n=s?`${camelize(t)}Meta`:camelize(t);Object.defineProperty(e,n,{get(){return typeCast(metaValue(t))}})};function metaValue(e){const t=document.head.querySelector(`meta[name="${e}"]`);return t&&t.getAttribute("content")}function typeCast(e){try{return JSON.parse(e)}catch(t){return e}}const useMeta=(e,t={suffix:true})=>{const s=e.constructor.metaNames;const n=t.suffix;s===null||s===void 0?void 0:s.forEach((t=>{defineMetaGetter(e,t,n)}));Object.defineProperty(e,"metas",{get(){const e={};s===null||s===void 0?void 0:s.forEach((t=>{const s=typeCast(metaValue(t));s!==void 0&&s!==null&&(e[camelize(t)]=s)}));return e}})};class UseMutation extends StimulusUse{constructor(e,t={}){super(e,t);this.observe=()=>{try{this.observer.observe(this.targetElement,this.options)}catch(e){this.controller.application.handleError(e,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}};this.unobserve=()=>{this.observer.disconnect()};this.mutation=e=>{this.call("mutate",e);this.log("mutate",{entries:e});this.dispatch("mutate",{entries:e})};this.targetElement=(t===null||t===void 0?void 0:t.element)||e.element;this.controller=e;this.options=t;this.observer=new MutationObserver(this.mutation);this.enhanceController();this.observe()}enhanceController(){const e=this.controller.disconnect.bind(this.controller);const disconnect=()=>{this.unobserve();e()};Object.assign(this.controller,{disconnect:disconnect})}}const useMutation=(e,t={})=>{const s=new UseMutation(e,t);return[s.observe,s.unobserve]};class MutationComposableController extends e{}class MutationController extends MutationComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useMutation(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}const h={dispatchEvent:true,eventPrefix:true};const useResize=(e,t={})=>{const s=e;const{dispatchEvent:n,eventPrefix:o}=Object.assign({},h,t);const i=(t===null||t===void 0?void 0:t.element)||s.element;const callback=e=>{const[t]=e;method(s,"resize").call(s,t.contentRect);if(n){const e=composeEventName("resize",s,o);const n=extendedEvent(e,null,{controller:s,entry:t});i.dispatchEvent(n)}};const r=s.disconnect.bind(s);const l=new ResizeObserver(callback);const observe=()=>{l.observe(i)};const unobserve=()=>{l.unobserve(i)};Object.assign(s,{disconnect(){unobserve();r()}});observe();return[observe,unobserve]};class ResizeComposableController extends e{}class ResizeController extends ResizeComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useResize(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}class UseTargetMutation extends StimulusUse{constructor(e,t={}){super(e,t);this.observe=()=>{this.observer.observe(this.targetElement,{subtree:true,characterData:true,childList:true,attributes:true,attributeOldValue:true,attributeFilter:[this.targetSelector,this.scopedTargetSelector]})};this.unobserve=()=>{this.observer.disconnect()};this.mutation=e=>{for(const t of e)switch(t.type){case"attributes":let e=t.target.getAttribute(t.attributeName);let s=t.oldValue;if(t.attributeName===this.targetSelector||t.attributeName===this.scopedTargetSelector){let n=this.targetsUsedByThisController(s);let o=this.targetsUsedByThisController(e);let i=n.filter((e=>!o.includes(e)));let r=o.filter((e=>!n.includes(e)));i.forEach((e=>this.targetRemoved(this.stripIdentifierPrefix(e),t.target,"attributeChange")));r.forEach((e=>this.targetAdded(this.stripIdentifierPrefix(e),t.target,"attributeChange")))}break;case"characterData":let n=this.findTargetInAncestry(t.target);if(n==null)return;{let e=this.targetsUsedByThisControllerFromNode(n);e.forEach((e=>{this.targetChanged(this.stripIdentifierPrefix(e),n,"domMutation")}))}break;case"childList":let{addedNodes:o,removedNodes:i}=t;o.forEach((e=>this.processNodeDOMMutation(e,this.targetAdded)));i.forEach((e=>this.processNodeDOMMutation(e,this.targetRemoved)));break}};this.controller=e;this.options=t;this.targetElement=e.element;this.identifier=e.scope.identifier;this.identifierPrefix=`${this.identifier}.`;this.targetSelector=e.scope.schema.targetAttribute;this.scopedTargetSelector=`data-${this.identifier}-target`;this.targets=t.targets||e.constructor.targets;this.prefixedTargets=this.targets.map((e=>`${this.identifierPrefix}${e}`));this.observer=new MutationObserver(this.mutation);this.enhanceController();this.observe()}processNodeDOMMutation(e,t){let s=e;let n=t;let o=[];if(s.nodeName=="#text"||this.targetsUsedByThisControllerFromNode(s).length==0){n=this.targetChanged;s=this.findTargetInAncestry(e)}else o=this.targetsUsedByThisControllerFromNode(s);if(s!=null){o.length==0&&(o=this.targetsUsedByThisControllerFromNode(s));o.forEach((e=>{n.call(this,this.stripIdentifierPrefix(e),s,"domMutation")}))}}findTargetInAncestry(e){let t=e;let s=[];t.nodeName!="#text"&&(s=this.targetsUsedByThisControllerFromNode(t));while(t.parentNode!==null&&t.parentNode!=this.targetElement&&s.length==0){t=t.parentNode;if(t.nodeName!=="#text"){let e=this.targetsUsedByThisControllerFromNode(t);if(e.length>0)return t}}return t.nodeName=="#text"||t.parentNode==null?null:t.parentNode==this.targetElement&&this.targetsUsedByThisControllerFromNode(t).length>0?t:null}targetAdded(e,t,s){let n=`${e}TargetAdded`;this.controller[n]&&method(this.controller,n).call(this.controller,t);this.log("targetAdded",{target:e,node:t,trigger:s})}targetRemoved(e,t,s){let n=`${e}TargetRemoved`;this.controller[n]&&method(this.controller,n).call(this.controller,t);this.log("targetRemoved",{target:e,node:t,trigger:s})}targetChanged(e,t,s){let n=`${e}TargetChanged`;this.controller[n]&&method(this.controller,n).call(this.controller,t);this.log("targetChanged",{target:e,node:t,trigger:s})}targetsUsedByThisControllerFromNode(e){if(e.nodeName=="#text"||e.nodeName=="#comment")return[];let t=e;return this.targetsUsedByThisController(t.getAttribute(this.scopedTargetSelector)||t.getAttribute(this.targetSelector))}targetsUsedByThisController(e){e=e||"";let t=this.stripIdentifierPrefix(e).split(" ");return this.targets.filter((e=>t.indexOf(e)!==-1))}stripIdentifierPrefix(e){return e.replace(new RegExp(this.identifierPrefix,"g"),"")}enhanceController(){const e=this.controller.disconnect.bind(this.controller);const disconnect=()=>{this.unobserve();e()};Object.assign(this.controller,{disconnect:disconnect})}}const useTargetMutation=(e,t={})=>{const s=e;const n=new UseTargetMutation(s,t);return[n.observe,n.unobserve]};class TargetMutationComposableController extends e{}class TargetMutationController extends TargetMutationComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useTargetMutation(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}class ThrottleController extends e{}ThrottleController.throttles=[];const d=200;function throttle(e,t=d){let s;return function(){const n=arguments;const o=this;if(!s){s=true;e.apply(o,n);setTimeout((()=>s=false),t)}}}const useThrottle=(e,t={})=>{var s;const n=e;const o=n.constructor;(s=o.throttles)===null||s===void 0?void 0:s.forEach((e=>{typeof e==="string"&&(n[e]=throttle(n[e],t===null||t===void 0?void 0:t.wait));if(typeof e==="object"){const{name:s,wait:o}=e;if(!s)return;n[s]=throttle(n[s],o||(t===null||t===void 0?void 0:t.wait))}}))};const b={enterFromClass:"enter",enterActiveClass:"enterStart",enterToClass:"enterEnd",leaveFromClass:"leave",leaveActiveClass:"leaveStart",leaveToClass:"leaveEnd"};const m={transitioned:false,hiddenClass:"hidden",preserveOriginalClass:true,removeToClasses:true};const useTransition=(e,t={})=>{var s,n,o;const i=e;const r=i.element.dataset.transitionTarget;let l;r&&(l=i[`${r}Target`]);const c=(t===null||t===void 0?void 0:t.element)||l||i.element;if(!(c instanceof HTMLElement||c instanceof SVGElement))return;const a=c.dataset;const u=parseInt(a.leaveAfter||"")||t.leaveAfter||0;const{transitioned:h,hiddenClass:d,preserveOriginalClass:b,removeToClasses:v}=Object.assign({},m,t);const g=(s=i.enter)===null||s===void 0?void 0:s.bind(i);const p=(n=i.leave)===null||n===void 0?void 0:n.bind(i);const f=(o=i.toggleTransition)===null||o===void 0?void 0:o.bind(i);async function enter(e){if(i.transitioned)return;i.transitioned=true;g&&g(e);const s=getAttribute("enterFrom",t,a);const n=getAttribute("enterActive",t,a);const o=getAttribute("enterTo",t,a);const r=getAttribute("leaveTo",t,a);!d||c.classList.remove(d);v||removeClasses(c,r);await transition(c,s,n,o,d,b,v);u>0&&setTimeout((()=>{leave(e)}),u)}async function leave(e){if(!i.transitioned)return;i.transitioned=false;p&&p(e);const s=getAttribute("leaveFrom",t,a);const n=getAttribute("leaveActive",t,a);const o=getAttribute("leaveTo",t,a);const r=getAttribute("enterTo",t,a);v||removeClasses(c,r);await transition(c,s,n,o,d,b,v);!d||c.classList.add(d)}function toggleTransition(e){f&&f(e);i.transitioned?leave():enter()}async function transition(e,t,s,n,o,i,r){const l=[];if(i){t.forEach((t=>e.classList.contains(t)&&t!==o&&l.push(t)));s.forEach((t=>e.classList.contains(t)&&t!==o&&l.push(t)));n.forEach((t=>e.classList.contains(t)&&t!==o&&l.push(t)))}addClasses(e,t);removeClasses(e,l);addClasses(e,s);await nextAnimationFrame();removeClasses(e,t);addClasses(e,n);await afterTransition(e);removeClasses(e,s);r&&removeClasses(e,n);addClasses(e,l)}function initialState(){i.transitioned=h;if(h){!d||c.classList.remove(d);enter()}else{!d||c.classList.add(d);leave()}}function addClasses(e,t){t.length>0&&e.classList.add(...t)}function removeClasses(e,t){t.length>0&&e.classList.remove(...t)}initialState();Object.assign(i,{enter:enter,leave:leave,toggleTransition:toggleTransition});return[enter,leave,toggleTransition]};function getAttribute(e,t,s){const n=`transition${e[0].toUpperCase()}${e.substr(1)}`;const o=b[e];const i=t[e]||s[n]||s[o]||" ";return isEmpty(i)?[]:i.split(" ")}async function afterTransition(e){return new Promise((t=>{const s=Number(getComputedStyle(e).transitionDuration.split(",")[0].replace("s",""))*1e3;setTimeout((()=>{t(s)}),s)}))}async function nextAnimationFrame(){return new Promise((e=>{requestAnimationFrame((()=>{requestAnimationFrame(e)}))}))}function isEmpty(e){return e.length===0||!e.trim()}class TransitionComposableController extends e{constructor(){super(...arguments);this.transitioned=false}}class TransitionController extends TransitionComposableController{constructor(e){super(e);requestAnimationFrame((()=>{useTransition(this,this.options)}))}}class UseVisibility extends StimulusUse{constructor(e,t={}){super(e,t);this.observe=()=>{this.controller.isVisible=!document.hidden;document.addEventListener("visibilitychange",this.handleVisibilityChange);this.handleVisibilityChange()};this.unobserve=()=>{document.removeEventListener("visibilitychange",this.handleVisibilityChange)};this.becomesInvisible=e=>{this.controller.isVisible=false;this.call("invisible",e);this.log("invisible",{isVisible:false});this.dispatch("invisible",{event:e,isVisible:false})};this.becomesVisible=e=>{this.controller.isVisible=true;this.call("visible",e);this.log("visible",{isVisible:true});this.dispatch("visible",{event:e,isVisible:true})};this.handleVisibilityChange=e=>{document.hidden?this.becomesInvisible(e):this.becomesVisible(e)};this.controller=e;this.enhanceController();this.observe()}enhanceController(){const e=this.controllerDisconnect;const disconnect=()=>{this.unobserve();e()};Object.assign(this.controller,{disconnect:disconnect})}}const useVisibility=(e,t={})=>{const s=e;const n=new UseVisibility(s,t);return[n.observe,n.unobserve]};class VisibilityComposableController extends e{constructor(){super(...arguments);this.isVisible=false}}class VisibilityController extends VisibilityComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useVisibility(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}class UseWindowFocus extends StimulusUse{constructor(e,t={}){super(e,t);this.observe=()=>{document.hasFocus()?this.becomesFocused():this.becomesUnfocused();this.interval=setInterval((()=>{this.handleWindowFocusChange()}),this.intervalDuration)};this.unobserve=()=>{clearInterval(this.interval)};this.becomesUnfocused=e=>{this.controller.hasFocus=false;this.call("unfocus",e);this.log("unfocus",{hasFocus:false});this.dispatch("unfocus",{event:e,hasFocus:false})};this.becomesFocused=e=>{this.controller.hasFocus=true;this.call("focus",e);this.log("focus",{hasFocus:true});this.dispatch("focus",{event:e,hasFocus:true})};this.handleWindowFocusChange=e=>{document.hasFocus()&&!this.controller.hasFocus?this.becomesFocused(e):!document.hasFocus()&&this.controller.hasFocus&&this.becomesUnfocused(e)};this.controller=e;this.intervalDuration=t.interval||200;this.enhanceController();this.observe()}enhanceController(){const e=this.controllerDisconnect;const disconnect=()=>{this.unobserve();e()};Object.assign(this.controller,{disconnect:disconnect})}}const useWindowFocus=(e,t={})=>{const s=e;const n=new UseWindowFocus(s,t);return[n.observe,n.unobserve]};class WindowFocusComposableController extends e{constructor(){super(...arguments);this.hasFocus=false}}class WindowFocusController extends WindowFocusComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useWindowFocus(this,this.options);Object.assign(this,{observe:e,unobserve:t})}))}}const useWindowResize=e=>{const t=e;const callback=e=>{const{innerWidth:s,innerHeight:n}=window;const o={height:n||Infinity,width:s||Infinity,event:e};method(t,"windowResize").call(t,o)};const s=t.disconnect.bind(t);const observe=()=>{window.addEventListener("resize",callback);callback()};const unobserve=()=>{window.removeEventListener("resize",callback)};Object.assign(t,{disconnect(){unobserve();s()}});observe();return[observe,unobserve]};class WindowResizeComposableController extends e{}class WindowResizeController extends WindowResizeComposableController{constructor(e){super(e);requestAnimationFrame((()=>{const[e,t]=useWindowResize(this);Object.assign(this,{observe:e,unobserve:t})}))}}function useHotkeys(){throw"[stimulus-use] Notice: The import for `useHotkeys()` has been moved from `stimulus-use` to `stimulus-use/hotkeys`. \nPlease change the import accordingly and add `hotkey-js` as a dependency to your project. \n\nFor more information see: https://stimulus-use.github.io/stimulus-use/#/use-hotkeys?id=importing-the-behavior"}export{ApplicationController,ClickOutsideController,HoverController,IdleController,IntersectionController,LazyLoadController,MutationController,ResizeController,TargetMutationController,TransitionController,UseHover,UseMutation,UseTargetMutation,UseVisibility,UseWindowFocus,VisibilityController,WindowFocusController,WindowResizeController,debounce,useApplication,useClickOutside,useDebounce,useDispatch,useHotkeys,useHover,useIdle,useIntersection,useLazyLoad,useMatchMedia,useMemo,useMeta,useMutation,useResize,useTargetMutation,useThrottle,useTransition,useVisibility,useWindowFocus,useWindowResize};
4
+
@@ -0,0 +1,5 @@
1
+ //= link ./stimulus-autoloader.js
2
+ //= link ./stimulus-importmap-autoloader.js
3
+ //= link ./stimulus-loading.js
4
+ class e { constructor(e, t, s) { this.eventTarget = e, this.eventName = t, this.eventOptions = s, this.unorderedBindings = new Set } connect() { this.eventTarget.addEventListener(this.eventName, this, this.eventOptions) } disconnect() { this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions) } bindingConnected(e) { this.unorderedBindings.add(e) } bindingDisconnected(e) { this.unorderedBindings.delete(e) } handleEvent(e) { const t = function (e) { if ("immediatePropagationStopped" in e) return e; { const { stopImmediatePropagation: t } = e; return Object.assign(e, { immediatePropagationStopped: !1, stopImmediatePropagation() { this.immediatePropagationStopped = !0, t.call(this) } }) } }(e); for (const e of this.bindings) { if (t.immediatePropagationStopped) break; e.handleEvent(t) } } hasBindings() { return this.unorderedBindings.size > 0 } get bindings() { return Array.from(this.unorderedBindings).sort(((e, t) => { const s = e.index, r = t.index; return s < r ? -1 : s > r ? 1 : 0 })) } } class t { constructor(e) { this.application = e, this.eventListenerMaps = new Map, this.started = !1 } start() { this.started || (this.started = !0, this.eventListeners.forEach((e => e.connect()))) } stop() { this.started && (this.started = !1, this.eventListeners.forEach((e => e.disconnect()))) } get eventListeners() { return Array.from(this.eventListenerMaps.values()).reduce(((e, t) => e.concat(Array.from(t.values()))), []) } bindingConnected(e) { this.fetchEventListenerForBinding(e).bindingConnected(e) } bindingDisconnected(e, t = !1) { this.fetchEventListenerForBinding(e).bindingDisconnected(e), t && this.clearEventListenersForBinding(e) } handleError(e, t, s = {}) { this.application.handleError(e, `Error ${t}`, s) } clearEventListenersForBinding(e) { const t = this.fetchEventListenerForBinding(e); t.hasBindings() || (t.disconnect(), this.removeMappedEventListenerFor(e)) } removeMappedEventListenerFor(e) { const { eventTarget: t, eventName: s, eventOptions: r } = e, n = this.fetchEventListenerMapForEventTarget(t), i = this.cacheKey(s, r); n.delete(i), 0 == n.size && this.eventListenerMaps.delete(t) } fetchEventListenerForBinding(e) { const { eventTarget: t, eventName: s, eventOptions: r } = e; return this.fetchEventListener(t, s, r) } fetchEventListener(e, t, s) { const r = this.fetchEventListenerMapForEventTarget(e), n = this.cacheKey(t, s); let i = r.get(n); return i || (i = this.createEventListener(e, t, s), r.set(n, i)), i } createEventListener(t, s, r) { const n = new e(t, s, r); return this.started && n.connect(), n } fetchEventListenerMapForEventTarget(e) { let t = this.eventListenerMaps.get(e); return t || (t = new Map, this.eventListenerMaps.set(e, t)), t } cacheKey(e, t) { const s = [e]; return Object.keys(t).sort().forEach((e => { s.push(`${t[e] ? "" : "!"}${e}`) })), s.join(":") } } const s = { stop: ({ event: e, value: t }) => (t && e.stopPropagation(), !0), prevent: ({ event: e, value: t }) => (t && e.preventDefault(), !0), self: ({ event: e, value: t, element: s }) => !t || s === e.target }, r = /^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/; function n(e) { return "window" == e ? window : "document" == e ? document : void 0 } function i(e) { return e.replace(/(?:[_-])([a-z0-9])/g, ((e, t) => t.toUpperCase())) } function o(e) { return i(e.replace(/--/g, "-").replace(/__/g, "_")) } function a(e) { return e.charAt(0).toUpperCase() + e.slice(1) } function c(e) { return e.replace(/([A-Z])/g, ((e, t) => `-${t.toLowerCase()}`)) } function l(e) { return null != e } function h(e, t) { return Object.prototype.hasOwnProperty.call(e, t) } const u = ["meta", "ctrl", "alt", "shift"]; const d = { a: () => "click", button: () => "click", form: () => "submit", details: () => "toggle", input: e => "submit" == e.getAttribute("type") ? "click" : "input", select: () => "change", textarea: () => "input" }; function m(e) { throw new Error(e) } function g(e) { try { return JSON.parse(e) } catch (t) { return e } } class p { constructor(e, t) { this.context = e, this.action = t } get index() { return this.action.index } get eventTarget() { return this.action.eventTarget } get eventOptions() { return this.action.eventOptions } get identifier() { return this.context.identifier } handleEvent(e) { const t = this.prepareActionEvent(e); this.willBeInvokedByEvent(e) && this.applyEventModifiers(t) && this.invokeWithEvent(t) } get eventName() { return this.action.eventName } get method() { const e = this.controller[this.methodName]; if ("function" == typeof e) return e; throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`) } applyEventModifiers(e) { const { element: t } = this.action, { actionDescriptorFilters: s } = this.context.application, { controller: r } = this.context; let n = !0; for (const [i, o] of Object.entries(this.eventOptions)) if (i in s) { const a = s[i]; n = n && a({ name: i, value: o, event: e, element: t, controller: r }) } return n } prepareActionEvent(e) { return Object.assign(e, { params: this.action.params }) } invokeWithEvent(e) { const { target: t, currentTarget: s } = e; try { this.method.call(this.controller, e), this.context.logDebugActivity(this.methodName, { event: e, target: t, currentTarget: s, action: this.methodName }) } catch (t) { const { identifier: s, controller: r, element: n, index: i } = this, o = { identifier: s, controller: r, element: n, index: i, event: e }; this.context.handleError(t, `invoking action "${this.action}"`, o) } } willBeInvokedByEvent(e) { const t = e.target; return !(e instanceof KeyboardEvent && this.action.shouldIgnoreKeyboardEvent(e)) && (!(e instanceof MouseEvent && this.action.shouldIgnoreMouseEvent(e)) && (this.element === t || (t instanceof Element && this.element.contains(t) ? this.scope.containsElement(t) : this.scope.containsElement(this.action.element)))) } get controller() { return this.context.controller } get methodName() { return this.action.methodName } get element() { return this.scope.element } get scope() { return this.context.scope } } class f { constructor(e, t) { this.mutationObserverInit = { attributes: !0, childList: !0, subtree: !0 }, this.element = e, this.started = !1, this.delegate = t, this.elements = new Set, this.mutationObserver = new MutationObserver((e => this.processMutations(e))) } start() { this.started || (this.started = !0, this.mutationObserver.observe(this.element, this.mutationObserverInit), this.refresh()) } pause(e) { this.started && (this.mutationObserver.disconnect(), this.started = !1), e(), this.started || (this.mutationObserver.observe(this.element, this.mutationObserverInit), this.started = !0) } stop() { this.started && (this.mutationObserver.takeRecords(), this.mutationObserver.disconnect(), this.started = !1) } refresh() { if (this.started) { const e = new Set(this.matchElementsInTree()); for (const t of Array.from(this.elements)) e.has(t) || this.removeElement(t); for (const t of Array.from(e)) this.addElement(t) } } processMutations(e) { if (this.started) for (const t of e) this.processMutation(t) } processMutation(e) { "attributes" == e.type ? this.processAttributeChange(e.target, e.attributeName) : "childList" == e.type && (this.processRemovedNodes(e.removedNodes), this.processAddedNodes(e.addedNodes)) } processAttributeChange(e, t) { this.elements.has(e) ? this.delegate.elementAttributeChanged && this.matchElement(e) ? this.delegate.elementAttributeChanged(e, t) : this.removeElement(e) : this.matchElement(e) && this.addElement(e) } processRemovedNodes(e) { for (const t of Array.from(e)) { const e = this.elementFromNode(t); e && this.processTree(e, this.removeElement) } } processAddedNodes(e) { for (const t of Array.from(e)) { const e = this.elementFromNode(t); e && this.elementIsActive(e) && this.processTree(e, this.addElement) } } matchElement(e) { return this.delegate.matchElement(e) } matchElementsInTree(e = this.element) { return this.delegate.matchElementsInTree(e) } processTree(e, t) { for (const s of this.matchElementsInTree(e)) t.call(this, s) } elementFromNode(e) { if (e.nodeType == Node.ELEMENT_NODE) return e } elementIsActive(e) { return e.isConnected == this.element.isConnected && this.element.contains(e) } addElement(e) { this.elements.has(e) || this.elementIsActive(e) && (this.elements.add(e), this.delegate.elementMatched && this.delegate.elementMatched(e)) } removeElement(e) { this.elements.has(e) && (this.elements.delete(e), this.delegate.elementUnmatched && this.delegate.elementUnmatched(e)) } } class b { constructor(e, t, s) { this.attributeName = t, this.delegate = s, this.elementObserver = new f(e, this) } get element() { return this.elementObserver.element } get selector() { return `[${this.attributeName}]` } start() { this.elementObserver.start() } pause(e) { this.elementObserver.pause(e) } stop() { this.elementObserver.stop() } refresh() { this.elementObserver.refresh() } get started() { return this.elementObserver.started } matchElement(e) { return e.hasAttribute(this.attributeName) } matchElementsInTree(e) { const t = this.matchElement(e) ? [e] : [], s = Array.from(e.querySelectorAll(this.selector)); return t.concat(s) } elementMatched(e) { this.delegate.elementMatchedAttribute && this.delegate.elementMatchedAttribute(e, this.attributeName) } elementUnmatched(e) { this.delegate.elementUnmatchedAttribute && this.delegate.elementUnmatchedAttribute(e, this.attributeName) } elementAttributeChanged(e, t) { this.delegate.elementAttributeValueChanged && this.attributeName == t && this.delegate.elementAttributeValueChanged(e, t) } } function v(e, t, s) { O(e, t).add(s) } function y(e, t, s) { O(e, t).delete(s), A(e, t) } function O(e, t) { let s = e.get(t); return s || (s = new Set, e.set(t, s)), s } function A(e, t) { const s = e.get(t); null != s && 0 == s.size && e.delete(t) } class E { constructor() { this.valuesByKey = new Map } get keys() { return Array.from(this.valuesByKey.keys()) } get values() { return Array.from(this.valuesByKey.values()).reduce(((e, t) => e.concat(Array.from(t))), []) } get size() { return Array.from(this.valuesByKey.values()).reduce(((e, t) => e + t.size), 0) } add(e, t) { v(this.valuesByKey, e, t) } delete(e, t) { y(this.valuesByKey, e, t) } has(e, t) { const s = this.valuesByKey.get(e); return null != s && s.has(t) } hasKey(e) { return this.valuesByKey.has(e) } hasValue(e) { return Array.from(this.valuesByKey.values()).some((t => t.has(e))) } getValuesForKey(e) { const t = this.valuesByKey.get(e); return t ? Array.from(t) : [] } getKeysForValue(e) { return Array.from(this.valuesByKey).filter((([t, s]) => s.has(e))).map((([e, t]) => e)) } } class w extends E { constructor() { super(), this.keysByValue = new Map } get values() { return Array.from(this.keysByValue.keys()) } add(e, t) { super.add(e, t), v(this.keysByValue, t, e) } delete(e, t) { super.delete(e, t), y(this.keysByValue, t, e) } hasValue(e) { return this.keysByValue.has(e) } getKeysForValue(e) { const t = this.keysByValue.get(e); return t ? Array.from(t) : [] } } class M { constructor(e, t, s, r) { this._selector = t, this.details = r, this.elementObserver = new f(e, this), this.delegate = s, this.matchesByElement = new E } get started() { return this.elementObserver.started } get selector() { return this._selector } set selector(e) { this._selector = e, this.refresh() } start() { this.elementObserver.start() } pause(e) { this.elementObserver.pause(e) } stop() { this.elementObserver.stop() } refresh() { this.elementObserver.refresh() } get element() { return this.elementObserver.element } matchElement(e) { const { selector: t } = this; if (t) { const s = e.matches(t); return this.delegate.selectorMatchElement ? s && this.delegate.selectorMatchElement(e, this.details) : s } return !1 } matchElementsInTree(e) { const { selector: t } = this; if (t) { const s = this.matchElement(e) ? [e] : [], r = Array.from(e.querySelectorAll(t)).filter((e => this.matchElement(e))); return s.concat(r) } return [] } elementMatched(e) { const { selector: t } = this; t && this.selectorMatched(e, t) } elementUnmatched(e) { const t = this.matchesByElement.getKeysForValue(e); for (const s of t) this.selectorUnmatched(e, s) } elementAttributeChanged(e, t) { const { selector: s } = this; if (s) { const t = this.matchElement(e), r = this.matchesByElement.has(s, e); t && !r ? this.selectorMatched(e, s) : !t && r && this.selectorUnmatched(e, s) } } selectorMatched(e, t) { this.delegate.selectorMatched(e, t, this.details), this.matchesByElement.add(t, e) } selectorUnmatched(e, t) { this.delegate.selectorUnmatched(e, t, this.details), this.matchesByElement.delete(t, e) } } class k { constructor(e, t) { this.element = e, this.delegate = t, this.started = !1, this.stringMap = new Map, this.mutationObserver = new MutationObserver((e => this.processMutations(e))) } start() { this.started || (this.started = !0, this.mutationObserver.observe(this.element, { attributes: !0, attributeOldValue: !0 }), this.refresh()) } stop() { this.started && (this.mutationObserver.takeRecords(), this.mutationObserver.disconnect(), this.started = !1) } refresh() { if (this.started) for (const e of this.knownAttributeNames) this.refreshAttribute(e, null) } processMutations(e) { if (this.started) for (const t of e) this.processMutation(t) } processMutation(e) { const t = e.attributeName; t && this.refreshAttribute(t, e.oldValue) } refreshAttribute(e, t) { const s = this.delegate.getStringMapKeyForAttribute(e); if (null != s) { this.stringMap.has(e) || this.stringMapKeyAdded(s, e); const r = this.element.getAttribute(e); if (this.stringMap.get(e) != r && this.stringMapValueChanged(r, s, t), null == r) { const t = this.stringMap.get(e); this.stringMap.delete(e), t && this.stringMapKeyRemoved(s, e, t) } else this.stringMap.set(e, r) } } stringMapKeyAdded(e, t) { this.delegate.stringMapKeyAdded && this.delegate.stringMapKeyAdded(e, t) } stringMapValueChanged(e, t, s) { this.delegate.stringMapValueChanged && this.delegate.stringMapValueChanged(e, t, s) } stringMapKeyRemoved(e, t, s) { this.delegate.stringMapKeyRemoved && this.delegate.stringMapKeyRemoved(e, t, s) } get knownAttributeNames() { return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames))) } get currentAttributeNames() { return Array.from(this.element.attributes).map((e => e.name)) } get recordedAttributeNames() { return Array.from(this.stringMap.keys()) } } class N { constructor(e, t, s) { this.attributeObserver = new b(e, t, this), this.delegate = s, this.tokensByElement = new E } get started() { return this.attributeObserver.started } start() { this.attributeObserver.start() } pause(e) { this.attributeObserver.pause(e) } stop() { this.attributeObserver.stop() } refresh() { this.attributeObserver.refresh() } get element() { return this.attributeObserver.element } get attributeName() { return this.attributeObserver.attributeName } elementMatchedAttribute(e) { this.tokensMatched(this.readTokensForElement(e)) } elementAttributeValueChanged(e) { const [t, s] = this.refreshTokensForElement(e); this.tokensUnmatched(t), this.tokensMatched(s) } elementUnmatchedAttribute(e) { this.tokensUnmatched(this.tokensByElement.getValuesForKey(e)) } tokensMatched(e) { e.forEach((e => this.tokenMatched(e))) } tokensUnmatched(e) { e.forEach((e => this.tokenUnmatched(e))) } tokenMatched(e) { this.delegate.tokenMatched(e), this.tokensByElement.add(e.element, e) } tokenUnmatched(e) { this.delegate.tokenUnmatched(e), this.tokensByElement.delete(e.element, e) } refreshTokensForElement(e) { const t = this.tokensByElement.getValuesForKey(e), s = this.readTokensForElement(e), r = function (e, t) { const s = Math.max(e.length, t.length); return Array.from({ length: s }, ((s, r) => [e[r], t[r]])) }(t, s).findIndex((([e, t]) => { return r = t, !((s = e) && r && s.index == r.index && s.content == r.content); var s, r })); return -1 == r ? [[], []] : [t.slice(r), s.slice(r)] } readTokensForElement(e) { const t = this.attributeName; return function (e, t, s) { return e.trim().split(/\s+/).filter((e => e.length)).map(((e, r) => ({ element: t, attributeName: s, content: e, index: r }))) }(e.getAttribute(t) || "", e, t) } } class F { constructor(e, t, s) { this.tokenListObserver = new N(e, t, this), this.delegate = s, this.parseResultsByToken = new WeakMap, this.valuesByTokenByElement = new WeakMap } get started() { return this.tokenListObserver.started } start() { this.tokenListObserver.start() } stop() { this.tokenListObserver.stop() } refresh() { this.tokenListObserver.refresh() } get element() { return this.tokenListObserver.element } get attributeName() { return this.tokenListObserver.attributeName } tokenMatched(e) { const { element: t } = e, { value: s } = this.fetchParseResultForToken(e); s && (this.fetchValuesByTokenForElement(t).set(e, s), this.delegate.elementMatchedValue(t, s)) } tokenUnmatched(e) { const { element: t } = e, { value: s } = this.fetchParseResultForToken(e); s && (this.fetchValuesByTokenForElement(t).delete(e), this.delegate.elementUnmatchedValue(t, s)) } fetchParseResultForToken(e) { let t = this.parseResultsByToken.get(e); return t || (t = this.parseToken(e), this.parseResultsByToken.set(e, t)), t } fetchValuesByTokenForElement(e) { let t = this.valuesByTokenByElement.get(e); return t || (t = new Map, this.valuesByTokenByElement.set(e, t)), t } parseToken(e) { try { return { value: this.delegate.parseValueForToken(e) } } catch (e) { return { error: e } } } } class B { constructor(e, t) { this.context = e, this.delegate = t, this.bindingsByAction = new Map } start() { this.valueListObserver || (this.valueListObserver = new F(this.element, this.actionAttribute, this), this.valueListObserver.start()) } stop() { this.valueListObserver && (this.valueListObserver.stop(), delete this.valueListObserver, this.disconnectAllActions()) } get element() { return this.context.element } get identifier() { return this.context.identifier } get actionAttribute() { return this.schema.actionAttribute } get schema() { return this.context.schema } get bindings() { return Array.from(this.bindingsByAction.values()) } connectAction(e) { const t = new p(this.context, e); this.bindingsByAction.set(e, t), this.delegate.bindingConnected(t) } disconnectAction(e) { const t = this.bindingsByAction.get(e); t && (this.bindingsByAction.delete(e), this.delegate.bindingDisconnected(t)) } disconnectAllActions() { this.bindings.forEach((e => this.delegate.bindingDisconnected(e, !0))), this.bindingsByAction.clear() } parseValueForToken(e) { const t = class { constructor(e, t, s, r) { this.element = e, this.index = t, this.eventTarget = s.eventTarget || e, this.eventName = s.eventName || function (e) { const t = e.tagName.toLowerCase(); if (t in d) return d[t](e) }(e) || m("missing event name"), this.eventOptions = s.eventOptions || {}, this.identifier = s.identifier || m("missing identifier"), this.methodName = s.methodName || m("missing method name"), this.keyFilter = s.keyFilter || "", this.schema = r } static forToken(e, t) { return new this(e.element, e.index, function (e) { const t = e.trim().match(r) || []; let s = t[2], i = t[3]; return i && !["keydown", "keyup", "keypress"].includes(s) && (s += `.${i}`, i = ""), { eventTarget: n(t[4]), eventName: s, eventOptions: t[7] ? (o = t[7], o.split(":").reduce(((e, t) => Object.assign(e, { [t.replace(/^!/, "")]: !/^!/.test(t) })), {})) : {}, identifier: t[5], methodName: t[6], keyFilter: t[1] || i }; var o }(e.content), t) } toString() { const e = this.keyFilter ? `.${this.keyFilter}` : "", t = this.eventTargetName ? `@${this.eventTargetName}` : ""; return `${this.eventName}${e}${t}->${this.identifier}#${this.methodName}` } shouldIgnoreKeyboardEvent(e) { if (!this.keyFilter) return !1; const t = this.keyFilter.split("+"); if (this.keyFilterDissatisfied(e, t)) return !0; const s = t.filter((e => !u.includes(e)))[0]; return !!s && (h(this.keyMappings, s) || m(`contains unknown key filter: ${this.keyFilter}`), this.keyMappings[s].toLowerCase() !== e.key.toLowerCase()) } shouldIgnoreMouseEvent(e) { if (!this.keyFilter) return !1; const t = [this.keyFilter]; return !!this.keyFilterDissatisfied(e, t) } get params() { const e = {}, t = new RegExp(`^data-${this.identifier}-(.+)-param$`, "i"); for (const { name: s, value: r } of Array.from(this.element.attributes)) { const n = s.match(t), o = n && n[1]; o && (e[i(o)] = g(r)) } return e } get eventTargetName() { return (e = this.eventTarget) == window ? "window" : e == document ? "document" : void 0; var e } get keyMappings() { return this.schema.keyMappings } keyFilterDissatisfied(e, t) { const [s, r, n, i] = u.map((e => t.includes(e))); return e.metaKey !== s || e.ctrlKey !== r || e.altKey !== n || e.shiftKey !== i } }.forToken(e, this.schema); if (t.identifier == this.identifier) return t } elementMatchedValue(e, t) { this.connectAction(t) } elementUnmatchedValue(e, t) { this.disconnectAction(t) } } class C { constructor(e, t) { this.context = e, this.receiver = t, this.stringMapObserver = new k(this.element, this), this.valueDescriptorMap = this.controller.valueDescriptorMap } start() { this.stringMapObserver.start(), this.invokeChangedCallbacksForDefaultValues() } stop() { this.stringMapObserver.stop() } get element() { return this.context.element } get controller() { return this.context.controller } getStringMapKeyForAttribute(e) { if (e in this.valueDescriptorMap) return this.valueDescriptorMap[e].name } stringMapKeyAdded(e, t) { const s = this.valueDescriptorMap[t]; this.hasValue(e) || this.invokeChangedCallback(e, s.writer(this.receiver[e]), s.writer(s.defaultValue)) } stringMapValueChanged(e, t, s) { const r = this.valueDescriptorNameMap[t]; null !== e && (null === s && (s = r.writer(r.defaultValue)), this.invokeChangedCallback(t, e, s)) } stringMapKeyRemoved(e, t, s) { const r = this.valueDescriptorNameMap[e]; this.hasValue(e) ? this.invokeChangedCallback(e, r.writer(this.receiver[e]), s) : this.invokeChangedCallback(e, r.writer(r.defaultValue), s) } invokeChangedCallbacksForDefaultValues() { for (const { key: e, name: t, defaultValue: s, writer: r } of this.valueDescriptors) null == s || this.controller.data.has(e) || this.invokeChangedCallback(t, r(s), void 0) } invokeChangedCallback(e, t, s) { const r = `${e}Changed`, n = this.receiver[r]; if ("function" == typeof n) { const r = this.valueDescriptorNameMap[e]; try { const e = r.reader(t); let i = s; s && (i = r.reader(s)), n.call(this.receiver, e, i) } catch (e) { throw e instanceof TypeError && (e.message = `Stimulus Value "${this.context.identifier}.${r.name}" - ${e.message}`), e } } } get valueDescriptors() { const { valueDescriptorMap: e } = this; return Object.keys(e).map((t => e[t])) } get valueDescriptorNameMap() { const e = {}; return Object.keys(this.valueDescriptorMap).forEach((t => { const s = this.valueDescriptorMap[t]; e[s.name] = s })), e } hasValue(e) { const t = `has${a(this.valueDescriptorNameMap[e].name)}`; return this.receiver[t] } } class $ { constructor(e, t) { this.context = e, this.delegate = t, this.targetsByName = new E } start() { this.tokenListObserver || (this.tokenListObserver = new N(this.element, this.attributeName, this), this.tokenListObserver.start()) } stop() { this.tokenListObserver && (this.disconnectAllTargets(), this.tokenListObserver.stop(), delete this.tokenListObserver) } tokenMatched({ element: e, content: t }) { this.scope.containsElement(e) && this.connectTarget(e, t) } tokenUnmatched({ element: e, content: t }) { this.disconnectTarget(e, t) } connectTarget(e, t) { var s; this.targetsByName.has(t, e) || (this.targetsByName.add(t, e), null === (s = this.tokenListObserver) || void 0 === s || s.pause((() => this.delegate.targetConnected(e, t)))) } disconnectTarget(e, t) { var s; this.targetsByName.has(t, e) && (this.targetsByName.delete(t, e), null === (s = this.tokenListObserver) || void 0 === s || s.pause((() => this.delegate.targetDisconnected(e, t)))) } disconnectAllTargets() { for (const e of this.targetsByName.keys) for (const t of this.targetsByName.getValuesForKey(e)) this.disconnectTarget(t, e) } get attributeName() { return `data-${this.context.identifier}-target` } get element() { return this.context.element } get scope() { return this.context.scope } } function T(e, t) { const s = x(e); return Array.from(s.reduce(((e, s) => (function (e, t) { const s = e[t]; return Array.isArray(s) ? s : [] }(s, t).forEach((t => e.add(t))), e)), new Set)) } function S(e, t) { return x(e).reduce(((e, s) => (e.push(...function (e, t) { const s = e[t]; return s ? Object.keys(s).map((e => [e, s[e]])) : [] }(s, t)), e)), []) } function x(e) { const t = []; for (; e;)t.push(e), e = Object.getPrototypeOf(e); return t.reverse() } class D { constructor(e, t) { this.started = !1, this.context = e, this.delegate = t, this.outletsByName = new E, this.outletElementsByName = new E, this.selectorObserverMap = new Map, this.attributeObserverMap = new Map } start() { this.started || (this.outletDefinitions.forEach((e => { this.setupSelectorObserverForOutlet(e), this.setupAttributeObserverForOutlet(e) })), this.started = !0, this.dependentContexts.forEach((e => e.refresh()))) } refresh() { this.selectorObserverMap.forEach((e => e.refresh())), this.attributeObserverMap.forEach((e => e.refresh())) } stop() { this.started && (this.started = !1, this.disconnectAllOutlets(), this.stopSelectorObservers(), this.stopAttributeObservers()) } stopSelectorObservers() { this.selectorObserverMap.size > 0 && (this.selectorObserverMap.forEach((e => e.stop())), this.selectorObserverMap.clear()) } stopAttributeObservers() { this.attributeObserverMap.size > 0 && (this.attributeObserverMap.forEach((e => e.stop())), this.attributeObserverMap.clear()) } selectorMatched(e, t, { outletName: s }) { const r = this.getOutlet(e, s); r && this.connectOutlet(r, e, s) } selectorUnmatched(e, t, { outletName: s }) { const r = this.getOutletFromMap(e, s); r && this.disconnectOutlet(r, e, s) } selectorMatchElement(e, { outletName: t }) { const s = this.selector(t), r = this.hasOutlet(e, t), n = e.matches(`[${this.schema.controllerAttribute}~=${t}]`); return !!s && (r && n && e.matches(s)) } elementMatchedAttribute(e, t) { const s = this.getOutletNameFromOutletAttributeName(t); s && this.updateSelectorObserverForOutlet(s) } elementAttributeValueChanged(e, t) { const s = this.getOutletNameFromOutletAttributeName(t); s && this.updateSelectorObserverForOutlet(s) } elementUnmatchedAttribute(e, t) { const s = this.getOutletNameFromOutletAttributeName(t); s && this.updateSelectorObserverForOutlet(s) } connectOutlet(e, t, s) { var r; this.outletElementsByName.has(s, t) || (this.outletsByName.add(s, e), this.outletElementsByName.add(s, t), null === (r = this.selectorObserverMap.get(s)) || void 0 === r || r.pause((() => this.delegate.outletConnected(e, t, s)))) } disconnectOutlet(e, t, s) { var r; this.outletElementsByName.has(s, t) && (this.outletsByName.delete(s, e), this.outletElementsByName.delete(s, t), null === (r = this.selectorObserverMap.get(s)) || void 0 === r || r.pause((() => this.delegate.outletDisconnected(e, t, s)))) } disconnectAllOutlets() { for (const e of this.outletElementsByName.keys) for (const t of this.outletElementsByName.getValuesForKey(e)) for (const s of this.outletsByName.getValuesForKey(e)) this.disconnectOutlet(s, t, e) } updateSelectorObserverForOutlet(e) { const t = this.selectorObserverMap.get(e); t && (t.selector = this.selector(e)) } setupSelectorObserverForOutlet(e) { const t = this.selector(e), s = new M(document.body, t, this, { outletName: e }); this.selectorObserverMap.set(e, s), s.start() } setupAttributeObserverForOutlet(e) { const t = this.attributeNameForOutletName(e), s = new b(this.scope.element, t, this); this.attributeObserverMap.set(e, s), s.start() } selector(e) { return this.scope.outlets.getSelectorForOutletName(e) } attributeNameForOutletName(e) { return this.scope.schema.outletAttributeForScope(this.identifier, e) } getOutletNameFromOutletAttributeName(e) { return this.outletDefinitions.find((t => this.attributeNameForOutletName(t) === e)) } get outletDependencies() { const e = new E; return this.router.modules.forEach((t => { T(t.definition.controllerConstructor, "outlets").forEach((s => e.add(s, t.identifier))) })), e } get outletDefinitions() { return this.outletDependencies.getKeysForValue(this.identifier) } get dependentControllerIdentifiers() { return this.outletDependencies.getValuesForKey(this.identifier) } get dependentContexts() { const e = this.dependentControllerIdentifiers; return this.router.contexts.filter((t => e.includes(t.identifier))) } hasOutlet(e, t) { return !!this.getOutlet(e, t) || !!this.getOutletFromMap(e, t) } getOutlet(e, t) { return this.application.getControllerForElementAndIdentifier(e, t) } getOutletFromMap(e, t) { return this.outletsByName.getValuesForKey(t).find((t => t.element === e)) } get scope() { return this.context.scope } get schema() { return this.context.schema } get identifier() { return this.context.identifier } get application() { return this.context.application } get router() { return this.application.router } } class L { constructor(e, t) { this.logDebugActivity = (e, t = {}) => { const { identifier: s, controller: r, element: n } = this; t = Object.assign({ identifier: s, controller: r, element: n }, t), this.application.logDebugActivity(this.identifier, e, t) }, this.module = e, this.scope = t, this.controller = new e.controllerConstructor(this), this.bindingObserver = new B(this, this.dispatcher), this.valueObserver = new C(this, this.controller), this.targetObserver = new $(this, this), this.outletObserver = new D(this, this); try { this.controller.initialize(), this.logDebugActivity("initialize") } catch (e) { this.handleError(e, "initializing controller") } } connect() { this.bindingObserver.start(), this.valueObserver.start(), this.targetObserver.start(), this.outletObserver.start(); try { this.controller.connect(), this.logDebugActivity("connect") } catch (e) { this.handleError(e, "connecting controller") } } refresh() { this.outletObserver.refresh() } disconnect() { try { this.controller.disconnect(), this.logDebugActivity("disconnect") } catch (e) { this.handleError(e, "disconnecting controller") } this.outletObserver.stop(), this.targetObserver.stop(), this.valueObserver.stop(), this.bindingObserver.stop() } get application() { return this.module.application } get identifier() { return this.module.identifier } get schema() { return this.application.schema } get dispatcher() { return this.application.dispatcher } get element() { return this.scope.element } get parentElement() { return this.element.parentElement } handleError(e, t, s = {}) { const { identifier: r, controller: n, element: i } = this; s = Object.assign({ identifier: r, controller: n, element: i }, s), this.application.handleError(e, `Error ${t}`, s) } targetConnected(e, t) { this.invokeControllerMethod(`${t}TargetConnected`, e) } targetDisconnected(e, t) { this.invokeControllerMethod(`${t}TargetDisconnected`, e) } outletConnected(e, t, s) { this.invokeControllerMethod(`${o(s)}OutletConnected`, e, t) } outletDisconnected(e, t, s) { this.invokeControllerMethod(`${o(s)}OutletDisconnected`, e, t) } invokeControllerMethod(e, ...t) { const s = this.controller; "function" == typeof s[e] && s[e](...t) } } function V(e) { return function (e, t) { const s = I(e), r = function (e, t) { return K(t).reduce(((s, r) => { const n = function (e, t, s) { const r = Object.getOwnPropertyDescriptor(e, s); if (!r || !("value" in r)) { const e = Object.getOwnPropertyDescriptor(t, s).value; return r && (e.get = r.get || e.get, e.set = r.set || e.set), e } }(e, t, r); return n && Object.assign(s, { [r]: n }), s }), {}) }(e.prototype, t); return Object.defineProperties(s.prototype, r), s }(e, function (e) { return T(e, "blessings").reduce(((t, s) => { const r = s(e); for (const e in r) { const s = t[e] || {}; t[e] = Object.assign(s, r[e]) } return t }), {}) }(e)) } const K = "function" == typeof Object.getOwnPropertySymbols ? e => [...Object.getOwnPropertyNames(e), ...Object.getOwnPropertySymbols(e)] : Object.getOwnPropertyNames, I = (() => { function e(e) { function t() { return Reflect.construct(e, arguments, new.target) } return t.prototype = Object.create(e.prototype, { constructor: { value: t } }), Reflect.setPrototypeOf(t, e), t } try { return function () { const t = e((function () { this.a.call(this) })); t.prototype.a = function () { }, new t }(), e } catch (e) { return e => class extends e { } } })(); class j { constructor(e, t) { this.application = e, this.definition = function (e) { return { identifier: e.identifier, controllerConstructor: V(e.controllerConstructor) } }(t), this.contextsByScope = new WeakMap, this.connectedContexts = new Set } get identifier() { return this.definition.identifier } get controllerConstructor() { return this.definition.controllerConstructor } get contexts() { return Array.from(this.connectedContexts) } connectContextForScope(e) { const t = this.fetchContextForScope(e); this.connectedContexts.add(t), t.connect() } disconnectContextForScope(e) { const t = this.contextsByScope.get(e); t && (this.connectedContexts.delete(t), t.disconnect()) } fetchContextForScope(e) { let t = this.contextsByScope.get(e); return t || (t = new L(this, e), this.contextsByScope.set(e, t)), t } } class U { constructor(e) { this.scope = e } has(e) { return this.data.has(this.getDataKey(e)) } get(e) { return this.getAll(e)[0] } getAll(e) { const t = this.data.get(this.getDataKey(e)) || ""; return t.match(/[^\s]+/g) || [] } getAttributeName(e) { return this.data.getAttributeNameForKey(this.getDataKey(e)) } getDataKey(e) { return `${e}-class` } get data() { return this.scope.data } } class P { constructor(e) { this.scope = e } get element() { return this.scope.element } get identifier() { return this.scope.identifier } get(e) { const t = this.getAttributeNameForKey(e); return this.element.getAttribute(t) } set(e, t) { const s = this.getAttributeNameForKey(e); return this.element.setAttribute(s, t), this.get(e) } has(e) { const t = this.getAttributeNameForKey(e); return this.element.hasAttribute(t) } delete(e) { if (this.has(e)) { const t = this.getAttributeNameForKey(e); return this.element.removeAttribute(t), !0 } return !1 } getAttributeNameForKey(e) { return `data-${this.identifier}-${c(e)}` } } class R { constructor(e) { this.warnedKeysByObject = new WeakMap, this.logger = e } warn(e, t, s) { let r = this.warnedKeysByObject.get(e); r || (r = new Set, this.warnedKeysByObject.set(e, r)), r.has(t) || (r.add(t), this.logger.warn(s, e)) } } function z(e, t) { return `[${e}~="${t}"]` } class _ { constructor(e) { this.scope = e } get element() { return this.scope.element } get identifier() { return this.scope.identifier } get schema() { return this.scope.schema } has(e) { return null != this.find(e) } find(...e) { return e.reduce(((e, t) => e || this.findTarget(t) || this.findLegacyTarget(t)), void 0) } findAll(...e) { return e.reduce(((e, t) => [...e, ...this.findAllTargets(t), ...this.findAllLegacyTargets(t)]), []) } findTarget(e) { const t = this.getSelectorForTargetName(e); return this.scope.findElement(t) } findAllTargets(e) { const t = this.getSelectorForTargetName(e); return this.scope.findAllElements(t) } getSelectorForTargetName(e) { return z(this.schema.targetAttributeForScope(this.identifier), e) } findLegacyTarget(e) { const t = this.getLegacySelectorForTargetName(e); return this.deprecate(this.scope.findElement(t), e) } findAllLegacyTargets(e) { const t = this.getLegacySelectorForTargetName(e); return this.scope.findAllElements(t).map((t => this.deprecate(t, e))) } getLegacySelectorForTargetName(e) { const t = `${this.identifier}.${e}`; return z(this.schema.targetAttribute, t) } deprecate(e, t) { if (e) { const { identifier: s } = this, r = this.schema.targetAttribute, n = this.schema.targetAttributeForScope(s); this.guide.warn(e, `target:${t}`, `Please replace ${r}="${s}.${t}" with ${n}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`) } return e } get guide() { return this.scope.guide } } class q { constructor(e, t) { this.scope = e, this.controllerElement = t } get element() { return this.scope.element } get identifier() { return this.scope.identifier } get schema() { return this.scope.schema } has(e) { return null != this.find(e) } find(...e) { return e.reduce(((e, t) => e || this.findOutlet(t)), void 0) } findAll(...e) { return e.reduce(((e, t) => [...e, ...this.findAllOutlets(t)]), []) } getSelectorForOutletName(e) { const t = this.schema.outletAttributeForScope(this.identifier, e); return this.controllerElement.getAttribute(t) } findOutlet(e) { const t = this.getSelectorForOutletName(e); if (t) return this.findElement(t, e) } findAllOutlets(e) { const t = this.getSelectorForOutletName(e); return t ? this.findAllElements(t, e) : [] } findElement(e, t) { return this.scope.queryElements(e).filter((s => this.matchesElement(s, e, t)))[0] } findAllElements(e, t) { return this.scope.queryElements(e).filter((s => this.matchesElement(s, e, t))) } matchesElement(e, t, s) { const r = e.getAttribute(this.scope.schema.controllerAttribute) || ""; return e.matches(t) && r.split(" ").includes(s) } } class W { constructor(e, t, s, r) { this.targets = new _(this), this.classes = new U(this), this.data = new P(this), this.containsElement = e => e.closest(this.controllerSelector) === this.element, this.schema = e, this.element = t, this.identifier = s, this.guide = new R(r), this.outlets = new q(this.documentScope, t) } findElement(e) { return this.element.matches(e) ? this.element : this.queryElements(e).find(this.containsElement) } findAllElements(e) { return [...this.element.matches(e) ? [this.element] : [], ...this.queryElements(e).filter(this.containsElement)] } queryElements(e) { return Array.from(this.element.querySelectorAll(e)) } get controllerSelector() { return z(this.schema.controllerAttribute, this.identifier) } get isDocumentScope() { return this.element === document.documentElement } get documentScope() { return this.isDocumentScope ? this : new W(this.schema, document.documentElement, this.identifier, this.guide.logger) } } class J { constructor(e, t, s) { this.element = e, this.schema = t, this.delegate = s, this.valueListObserver = new F(this.element, this.controllerAttribute, this), this.scopesByIdentifierByElement = new WeakMap, this.scopeReferenceCounts = new WeakMap } start() { this.valueListObserver.start() } stop() { this.valueListObserver.stop() } get controllerAttribute() { return this.schema.controllerAttribute } parseValueForToken(e) { const { element: t, content: s } = e; return this.parseValueForElementAndIdentifier(t, s) } parseValueForElementAndIdentifier(e, t) { const s = this.fetchScopesByIdentifierForElement(e); let r = s.get(t); return r || (r = this.delegate.createScopeForElementAndIdentifier(e, t), s.set(t, r)), r } elementMatchedValue(e, t) { const s = (this.scopeReferenceCounts.get(t) || 0) + 1; this.scopeReferenceCounts.set(t, s), 1 == s && this.delegate.scopeConnected(t) } elementUnmatchedValue(e, t) { const s = this.scopeReferenceCounts.get(t); s && (this.scopeReferenceCounts.set(t, s - 1), 1 == s && this.delegate.scopeDisconnected(t)) } fetchScopesByIdentifierForElement(e) { let t = this.scopesByIdentifierByElement.get(e); return t || (t = new Map, this.scopesByIdentifierByElement.set(e, t)), t } } class H { constructor(e) { this.application = e, this.scopeObserver = new J(this.element, this.schema, this), this.scopesByIdentifier = new E, this.modulesByIdentifier = new Map } get element() { return this.application.element } get schema() { return this.application.schema } get logger() { return this.application.logger } get controllerAttribute() { return this.schema.controllerAttribute } get modules() { return Array.from(this.modulesByIdentifier.values()) } get contexts() { return this.modules.reduce(((e, t) => e.concat(t.contexts)), []) } start() { this.scopeObserver.start() } stop() { this.scopeObserver.stop() } loadDefinition(e) { this.unloadIdentifier(e.identifier); const t = new j(this.application, e); this.connectModule(t); const s = e.controllerConstructor.afterLoad; s && s.call(e.controllerConstructor, e.identifier, this.application) } unloadIdentifier(e) { const t = this.modulesByIdentifier.get(e); t && this.disconnectModule(t) } getContextForElementAndIdentifier(e, t) { const s = this.modulesByIdentifier.get(t); if (s) return s.contexts.find((t => t.element == e)) } proposeToConnectScopeForElementAndIdentifier(e, t) { const s = this.scopeObserver.parseValueForElementAndIdentifier(e, t); s ? this.scopeObserver.elementMatchedValue(s.element, s) : console.error(`Couldn't find or create scope for identifier: "${t}" and element:`, e) } handleError(e, t, s) { this.application.handleError(e, t, s) } createScopeForElementAndIdentifier(e, t) { return new W(this.schema, e, t, this.logger) } scopeConnected(e) { this.scopesByIdentifier.add(e.identifier, e); const t = this.modulesByIdentifier.get(e.identifier); t && t.connectContextForScope(e) } scopeDisconnected(e) { this.scopesByIdentifier.delete(e.identifier, e); const t = this.modulesByIdentifier.get(e.identifier); t && t.disconnectContextForScope(e) } connectModule(e) { this.modulesByIdentifier.set(e.identifier, e); this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t => e.connectContextForScope(t))) } disconnectModule(e) { this.modulesByIdentifier.delete(e.identifier); this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t => e.disconnectContextForScope(t))) } } const Z = { controllerAttribute: "data-controller", actionAttribute: "data-action", targetAttribute: "data-target", targetAttributeForScope: e => `data-${e}-target`, outletAttributeForScope: (e, t) => `data-${e}-${t}-outlet`, keyMappings: Object.assign(Object.assign({ enter: "Enter", tab: "Tab", esc: "Escape", space: " ", up: "ArrowUp", down: "ArrowDown", left: "ArrowLeft", right: "ArrowRight", home: "Home", end: "End", page_up: "PageUp", page_down: "PageDown" }, G("abcdefghijklmnopqrstuvwxyz".split("").map((e => [e, e])))), G("0123456789".split("").map((e => [e, e])))) }; function G(e) { return e.reduce(((e, [t, s]) => Object.assign(Object.assign({}, e), { [t]: s })), {}) } class Q { constructor(e = document.documentElement, r = Z) { this.logger = console, this.debug = !1, this.logDebugActivity = (e, t, s = {}) => { this.debug && this.logFormattedMessage(e, t, s) }, this.element = e, this.schema = r, this.dispatcher = new t(this), this.router = new H(this), this.actionDescriptorFilters = Object.assign({}, s) } static start(e, t) { const s = new this(e, t); return s.start(), s } async start() { await new Promise((e => { "loading" == document.readyState ? document.addEventListener("DOMContentLoaded", (() => e())) : e() })), this.logDebugActivity("application", "starting"), this.dispatcher.start(), this.router.start(), this.logDebugActivity("application", "start") } stop() { this.logDebugActivity("application", "stopping"), this.dispatcher.stop(), this.router.stop(), this.logDebugActivity("application", "stop") } register(e, t) { this.load({ identifier: e, controllerConstructor: t }) } registerActionOption(e, t) { this.actionDescriptorFilters[e] = t } load(e, ...t) { (Array.isArray(e) ? e : [e, ...t]).forEach((e => { e.controllerConstructor.shouldLoad && this.router.loadDefinition(e) })) } unload(e, ...t) { (Array.isArray(e) ? e : [e, ...t]).forEach((e => this.router.unloadIdentifier(e))) } get controllers() { return this.router.contexts.map((e => e.controller)) } getControllerForElementAndIdentifier(e, t) { const s = this.router.getContextForElementAndIdentifier(e, t); return s ? s.controller : null } handleError(e, t, s) { var r; this.logger.error("%s\n\n%o\n\n%o", t, e, s), null === (r = window.onerror) || void 0 === r || r.call(window, t, "", 0, 0, e) } logFormattedMessage(e, t, s = {}) { s = Object.assign({ application: this }, s), this.logger.groupCollapsed(`${e} #${t}`), this.logger.log("details:", Object.assign({}, s)), this.logger.groupEnd() } } function X(e, t, s) { return e.application.getControllerForElementAndIdentifier(t, s) } function Y(e, t, s) { let r = X(e, t, s); return r || (e.application.router.proposeToConnectScopeForElementAndIdentifier(t, s), r = X(e, t, s), r || void 0) } function ee([e, t], s) { return function (e) { const { token: t, typeDefinition: s } = e, r = `${c(t)}-value`, n = function (e) { const { controller: t, token: s, typeDefinition: r } = e, n = function (e) { const { controller: t, token: s, typeObject: r } = e, n = l(r.type), i = l(r.default), o = n && i, a = n && !i, c = !n && i, h = te(r.type), u = se(e.typeObject.default); if (a) return h; if (c) return u; if (h !== u) { throw new Error(`The specified default value for the Stimulus Value "${t ? `${t}.${s}` : s}" must match the defined type "${h}". The provided default value of "${r.default}" is of type "${u}".`) } if (o) return h }({ controller: t, token: s, typeObject: r }), i = se(r), o = te(r), a = n || i || o; if (a) return a; throw new Error(`Unknown value type "${t ? `${t}.${r}` : s}" for "${s}" value`) }(e); return { type: n, key: r, name: i(r), get defaultValue() { return function (e) { const t = te(e); if (t) return re[t]; const s = h(e, "default"), r = h(e, "type"), n = e; if (s) return n.default; if (r) { const { type: e } = n, t = te(e); if (t) return re[t] } return e }(s) }, get hasCustomDefaultValue() { return void 0 !== se(s) }, reader: ne[n], writer: ie[n] || ie.default } }({ controller: s, token: e, typeDefinition: t }) } function te(e) { switch (e) { case Array: return "array"; case Boolean: return "boolean"; case Number: return "number"; case Object: return "object"; case String: return "string" } } function se(e) { switch (typeof e) { case "boolean": return "boolean"; case "number": return "number"; case "string": return "string" }return Array.isArray(e) ? "array" : "[object Object]" === Object.prototype.toString.call(e) ? "object" : void 0 } const re = { get array() { return [] }, boolean: !1, number: 0, get object() { return {} }, string: "" }, ne = { array(e) { const t = JSON.parse(e); if (!Array.isArray(t)) throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${se(t)}"`); return t }, boolean: e => !("0" == e || "false" == String(e).toLowerCase()), number: e => Number(e.replace(/_/g, "")), object(e) { const t = JSON.parse(e); if (null === t || "object" != typeof t || Array.isArray(t)) throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${se(t)}"`); return t }, string: e => e }, ie = { default: function (e) { return `${e}` }, array: oe, object: oe }; function oe(e) { return JSON.stringify(e) } class ae { constructor(e) { this.context = e } static get shouldLoad() { return !0 } static afterLoad(e, t) { } get application() { return this.context.application } get scope() { return this.context.scope } get element() { return this.scope.element } get identifier() { return this.scope.identifier } get targets() { return this.scope.targets } get outlets() { return this.scope.outlets } get classes() { return this.scope.classes } get data() { return this.scope.data } initialize() { } connect() { } disconnect() { } dispatch(e, { target: t = this.element, detail: s = {}, prefix: r = this.identifier, bubbles: n = !0, cancelable: i = !0 } = {}) { const o = new CustomEvent(r ? `${r}:${e}` : e, { detail: s, bubbles: n, cancelable: i }); return t.dispatchEvent(o), o } } ae.blessings = [function (e) { return T(e, "classes").reduce(((e, t) => { return Object.assign(e, { [`${s = t}Class`]: { get() { const { classes: e } = this; if (e.has(s)) return e.get(s); { const t = e.getAttributeName(s); throw new Error(`Missing attribute "${t}"`) } } }, [`${s}Classes`]: { get() { return this.classes.getAll(s) } }, [`has${a(s)}Class`]: { get() { return this.classes.has(s) } } }); var s }), {}) }, function (e) { return T(e, "targets").reduce(((e, t) => { return Object.assign(e, { [`${s = t}Target`]: { get() { const e = this.targets.find(s); if (e) return e; throw new Error(`Missing target element "${s}" for "${this.identifier}" controller`) } }, [`${s}Targets`]: { get() { return this.targets.findAll(s) } }, [`has${a(s)}Target`]: { get() { return this.targets.has(s) } } }); var s }), {}) }, function (e) { const t = S(e, "values"), s = { valueDescriptorMap: { get() { return t.reduce(((e, t) => { const s = ee(t, this.identifier), r = this.data.getAttributeNameForKey(s.key); return Object.assign(e, { [r]: s }) }), {}) } } }; return t.reduce(((e, t) => Object.assign(e, function (e, t) { const s = ee(e, t), { key: r, name: n, reader: i, writer: o } = s; return { [n]: { get() { const e = this.data.get(r); return null !== e ? i(e) : s.defaultValue }, set(e) { void 0 === e ? this.data.delete(r) : this.data.set(r, o(e)) } }, [`has${a(n)}`]: { get() { return this.data.has(r) || s.hasCustomDefaultValue } } } }(t))), s) }, function (e) { return T(e, "outlets").reduce(((e, t) => Object.assign(e, function (e) { const t = o(e); return { [`${t}Outlet`]: { get() { const t = this.outlets.find(e), s = this.outlets.getSelectorForOutletName(e); if (t) { const s = Y(this, t, e); if (s) return s; throw new Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`) } throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`) } }, [`${t}Outlets`]: { get() { const t = this.outlets.findAll(e); return t.length > 0 ? t.map((t => { const s = Y(this, t, e); if (s) return s; console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`, t) })).filter((e => e)) : [] } }, [`${t}OutletElement`]: { get() { const t = this.outlets.find(e), s = this.outlets.getSelectorForOutletName(e); if (t) return t; throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`) } }, [`${t}OutletElements`]: { get() { return this.outlets.findAll(e) } }, [`has${a(t)}Outlet`]: { get() { return this.outlets.has(e) } } } }(t))), {}) }], ae.targets = [], ae.outlets = [], ae.values = {}; export { Q as Application, b as AttributeObserver, L as Context, ae as Controller, f as ElementObserver, w as IndexedMultimap, E as Multimap, M as SelectorObserver, k as StringMapObserver, N as TokenListObserver, F as ValueListObserver, v as add, Z as defaultSchema, y as del, O as fetch, A as prune };
5
+ //# sourceMappingURL=stimulus.min.js.map