orbital_ui 0.3.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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +224 -0
- data/app/assets/config/orbital_ui_manifest.js +2 -0
- data/app/assets/javascripts/orbital_ui/index.js +6 -0
- data/app/assets/javascripts/orbital_ui/index.js.map +1 -0
- data/app/assets/stylesheets/orbital_ui/index.css +3 -0
- data/app/assets/stylesheets/orbital_ui/index.css.map +1 -0
- data/app/assets/stylesheets/orbital_ui/theme.css +113 -0
- data/app/assets/stylesheets/orbital_ui/themes/blue.css +43 -0
- data/app/assets/stylesheets/orbital_ui/themes/green.css +43 -0
- data/app/assets/stylesheets/orbital_ui/themes/orange.css +43 -0
- data/app/assets/stylesheets/orbital_ui/themes/rose.css +43 -0
- data/app/assets/stylesheets/orbital_ui/themes/violet.css +43 -0
- data/app/components/orbital_ui/accordion/item.rb +32 -0
- data/app/components/orbital_ui/accordion.rb +23 -0
- data/app/components/orbital_ui/alert.rb +80 -0
- data/app/components/orbital_ui/avatar.rb +87 -0
- data/app/components/orbital_ui/badge.rb +28 -0
- data/app/components/orbital_ui/button.rb +46 -0
- data/app/components/orbital_ui/button_group.rb +20 -0
- data/app/components/orbital_ui/card/action.rb +17 -0
- data/app/components/orbital_ui/card/content.rb +17 -0
- data/app/components/orbital_ui/card/description.rb +17 -0
- data/app/components/orbital_ui/card/footer.rb +17 -0
- data/app/components/orbital_ui/card/header.rb +25 -0
- data/app/components/orbital_ui/card/title.rb +17 -0
- data/app/components/orbital_ui/card.rb +30 -0
- data/app/components/orbital_ui/check_box.rb +59 -0
- data/app/components/orbital_ui/component.rb +12 -0
- data/app/components/orbital_ui/concerns/icon_prop.rb +14 -0
- data/app/components/orbital_ui/confirmation_dialog.rb +142 -0
- data/app/components/orbital_ui/delete_dialog.rb +143 -0
- data/app/components/orbital_ui/dialog.rb +46 -0
- data/app/components/orbital_ui/dialog_frame.rb +17 -0
- data/app/components/orbital_ui/dropdown.rb +58 -0
- data/app/components/orbital_ui/expander.rb +20 -0
- data/app/components/orbital_ui/grid.rb +22 -0
- data/app/components/orbital_ui/heading.rb +65 -0
- data/app/components/orbital_ui/icon.rb +21 -0
- data/app/components/orbital_ui/image.rb +26 -0
- data/app/components/orbital_ui/inline_stack.rb +31 -0
- data/app/components/orbital_ui/kbd.rb +15 -0
- data/app/components/orbital_ui/kbd_group.rb +15 -0
- data/app/components/orbital_ui/menu/item.rb +74 -0
- data/app/components/orbital_ui/menu/label.rb +20 -0
- data/app/components/orbital_ui/menu/separator.rb +21 -0
- data/app/components/orbital_ui/menu/sub.rb +68 -0
- data/app/components/orbital_ui/menu.rb +36 -0
- data/app/components/orbital_ui/modal.rb +36 -0
- data/app/components/orbital_ui/modal_frame.rb +17 -0
- data/app/components/orbital_ui/navigation_menu.rb +51 -0
- data/app/components/orbital_ui/popcard.rb +18 -0
- data/app/components/orbital_ui/popover.rb +50 -0
- data/app/components/orbital_ui/progress_bar.rb +33 -0
- data/app/components/orbital_ui/prose.rb +15 -0
- data/app/components/orbital_ui/select.rb +140 -0
- data/app/components/orbital_ui/separator.rb +22 -0
- data/app/components/orbital_ui/spinner.rb +14 -0
- data/app/components/orbital_ui/stack.rb +29 -0
- data/app/components/orbital_ui/text.rb +41 -0
- data/app/components/orbital_ui/text_field.rb +132 -0
- data/app/components/orbital_ui/tooltip.rb +42 -0
- data/app/components/orbital_ui/typography.rb +38 -0
- data/lib/orbital_ui/attribute_utils.rb +152 -0
- data/lib/orbital_ui/components/attributes.rb +164 -0
- data/lib/orbital_ui/components/styles.rb +40 -0
- data/lib/orbital_ui/engine.rb +7 -0
- data/lib/orbital_ui/icons.rb +17312 -0
- data/lib/orbital_ui/type/any.rb +17 -0
- data/lib/orbital_ui/type/array.rb +27 -0
- data/lib/orbital_ui/type/breakpoints.rb +46 -0
- data/lib/orbital_ui/type/symbol.rb +17 -0
- data/lib/orbital_ui/version.rb +5 -0
- data/lib/orbital_ui.rb +49 -0
- metadata +162 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b8490164081567496527d6313c849f55a41a96b259cfcaa90a981ea18f75ff2f
|
|
4
|
+
data.tar.gz: 1633a7fa7ca770f9c41d157ae521358fe9098485e34f2dd541442c512affa26b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: aa4a1fa7acf48810c408a776241b28f3474da0f3152684b086eb4246a1032ae3cd3aa2d009da8044c37e8e266e7901e6c5875ad78f3d012c1b8a8de21d0756f7
|
|
7
|
+
data.tar.gz: 51ed4a23a4181d31666b1a43e0e86563eb312593ad2ad110447501364e6a5e739383264fd0a82a4de78c9bd7fbd83c32884da7e798a379c91efa47fa295c6952
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 KUY.io Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Orbital
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A modern design system and component library for Ruby on Rails, built with [ViewComponent](https://viewcomponent.org/), the [ORB Template Language](https://github.com/kuyio/orb_template) and [Tailwind CSS v4](https://tailwindcss.com/). Ship polished interfaces without leaving Rails.
|
|
6
|
+
|
|
7
|
+
- **Themable:** customize colors, typography and spacing with CSS variables
|
|
8
|
+
- **Dark mode:** built in, using a class toggle
|
|
9
|
+
- **Accessible:** components follow accessibility best practices
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add the gem to your application's Gemfile:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bundle add orbital_ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The gem is named `orbital_ui` because the `Orbital` gem on rubygems.org is an unrelated project.
|
|
20
|
+
|
|
21
|
+
Orbital requires Ruby 3.4 or newer and Rails 7.1 or newer.
|
|
22
|
+
|
|
23
|
+
To use Orbital components, you must add `OrbitalUi` to `ORB.namespaces` in an initializer, even if your own views only use ERB:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
# config/initializers/orb.rb
|
|
27
|
+
ORB.namespaces += %w[OrbitalUi]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Orbital's own templates use this setting to find each other. Without it, components such as `Alert`, `Dialog`, `Select` and `Spinner` raise a `NameError`.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Include Orbital's CSS and JavaScript in your layout:
|
|
35
|
+
|
|
36
|
+
```erb
|
|
37
|
+
<%= stylesheet_link_tag "orbital_ui/index" %>
|
|
38
|
+
<%= javascript_include_tag "orbital_ui/index", type: "module" %>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then use components in your views:
|
|
42
|
+
|
|
43
|
+
```erb
|
|
44
|
+
<%= render OrbitalUi::Button.new(variant: :primary) do %>
|
|
45
|
+
Click me
|
|
46
|
+
<% end %>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
In ORB templates, use components as tags:
|
|
50
|
+
|
|
51
|
+
```orb
|
|
52
|
+
<Button variant="outline" class="w-full">Full Width</Button>
|
|
53
|
+
<Card class="border-primary">Highlighted Card</Card>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Every component accepts a `class` attribute for one-off adjustments.
|
|
57
|
+
|
|
58
|
+
## Components
|
|
59
|
+
|
|
60
|
+
### Layout & Structure
|
|
61
|
+
- **Accordion:** Collapsible content sections with keyboard navigation
|
|
62
|
+
- **Card:** Content containers with optional header and footer slots
|
|
63
|
+
- **Expander:** Flexible spacer for distributing space in flex layouts
|
|
64
|
+
- **Grid:** CSS Grid container with column and span control
|
|
65
|
+
- **Inline Stack:** Horizontal flex container with spacing and alignment
|
|
66
|
+
- **Separator:** Horizontal or vertical dividers between content sections
|
|
67
|
+
- **Stack:** Vertical flex container with spacing and alignment
|
|
68
|
+
|
|
69
|
+
### Navigation
|
|
70
|
+
- **Navigation Menu:** Responsive site navigation with mobile drawer
|
|
71
|
+
- **Dropdown:** Trigger/content pattern for menus and popovers
|
|
72
|
+
- **Menu:** Structured menu with items, labels, separators, and submenus
|
|
73
|
+
|
|
74
|
+
### Data Display
|
|
75
|
+
- **Avatar:** User avatars with initials or Gravatar integration
|
|
76
|
+
- **Badge:** Small status indicators and labels
|
|
77
|
+
- **Icon:** Inline SVG icons from Lucide and Font Awesome brands, with size variants
|
|
78
|
+
- **Image:** Images from the asset pipeline (`asset`) or a URL (`src`)
|
|
79
|
+
- **Kbd:** Keyboard shortcut display
|
|
80
|
+
- **Progress Bar:** Horizontal bar with value/max fill calculation
|
|
81
|
+
- **Spinner:** Loading indicators
|
|
82
|
+
- **Tooltip:** Contextual information on hover
|
|
83
|
+
|
|
84
|
+
### Typography
|
|
85
|
+
- **Heading:** Semantic headings with size scale (xs–4xl)
|
|
86
|
+
- **Text:** Body text with size, weight, tone, and alignment control
|
|
87
|
+
- **Prose:** Long-form content styling
|
|
88
|
+
- **Typography:** Display type for marketing pages
|
|
89
|
+
|
|
90
|
+
### Forms
|
|
91
|
+
- **Button:** Primary, secondary, outline, ghost, and destructive variants
|
|
92
|
+
- **Button Group:** Visually connected button sets
|
|
93
|
+
- **Check Box:** Toggle inputs with labels and help text
|
|
94
|
+
- **Select:** Custom dropdown select with search
|
|
95
|
+
- **Text Field:** Inputs and textareas with icons, prefix/suffix, and validation
|
|
96
|
+
|
|
97
|
+
### Feedback
|
|
98
|
+
- **Alert:** Contextual messages with tone variants
|
|
99
|
+
- **Dialog:** Modal dialogs with header, body, and footer
|
|
100
|
+
- **Confirmation Dialog:** Confirm/cancel pattern
|
|
101
|
+
- **Delete Dialog:** Destructive action confirmation
|
|
102
|
+
|
|
103
|
+
### Overlay
|
|
104
|
+
- **Modal:** Full-screen overlay container
|
|
105
|
+
- **Popcard:** Hover card previews
|
|
106
|
+
- **Popover:** Anchored floating content
|
|
107
|
+
|
|
108
|
+
## Theming
|
|
109
|
+
|
|
110
|
+
Orbital uses a semantic color system powered by CSS custom properties. Override any variable after Orbital's CSS, either in a separate stylesheet or in your main one:
|
|
111
|
+
|
|
112
|
+
```css
|
|
113
|
+
@import "orbital_ui/index.css";
|
|
114
|
+
|
|
115
|
+
:root {
|
|
116
|
+
--primary: hotpink;
|
|
117
|
+
--primary-foreground: white;
|
|
118
|
+
--radius: 0.25rem;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Colors, surfaces and radii are defined in `app/assets/stylesheets/orbital_ui/theme.css`. The full set includes:
|
|
123
|
+
|
|
124
|
+
- **Surfaces:** `--background`, `--card`, `--popover`, `--muted`, `--accent`
|
|
125
|
+
- **Interactive:** `--primary`, `--secondary`, `--destructive`
|
|
126
|
+
- **Semantic tones:** `--tone-success`, `--tone-warning`, `--tone-danger`, `--tone-info`, `--tone-magic`
|
|
127
|
+
- **Borders & inputs:** `--border`, `--input`, `--ring`
|
|
128
|
+
- **Typography:** `--font-weight-normal`, `--font-weight-medium`, `--font-weight-semibold`, `--font-weight-bold`, `--text-body-*`, `--text-heading-*`
|
|
129
|
+
- **Shape:** `--radius`
|
|
130
|
+
|
|
131
|
+
See the [theming guide](https://github.com/kuyio/orbital_ui/blob/main/theming/README.md) and its [example theme](https://github.com/kuyio/orbital_ui/blob/main/theming/custom-theme.css).
|
|
132
|
+
|
|
133
|
+
### Dark Mode
|
|
134
|
+
|
|
135
|
+
Add the `dark` class to your `<html>` or `<body>` element. All theme variables swap automatically. To customize dark mode colors, override them under `.dark`.
|
|
136
|
+
|
|
137
|
+
### Host Application Responsibilities
|
|
138
|
+
|
|
139
|
+
Orbital **only styles** `.Orbital-*` components. Your application is responsible for page backgrounds and layouts, body text colors and fonts, global margins and padding, and any other styling. Orbital's shipped CSS doesn't provide general Tailwind utility classes for your own markup, so build those in your application's Tailwind setup.
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
The gem is at the repository root, and `test/dummy` is a Rails app that documents every component.
|
|
144
|
+
|
|
145
|
+
You'll need Ruby (see `.ruby-version`), [Bun](https://bun.sh/) and, for the full test run, [Trivy](https://trivy.dev/).
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
bin/setup # Install dependencies and build the docs app's assets
|
|
149
|
+
bin/dev # Run the docs app on http://localhost:3000, with asset watchers
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`bin/dev` rebuilds the gem's committed assets in development mode, so run `make assets` before committing them.
|
|
153
|
+
|
|
154
|
+
| Command | What it does |
|
|
155
|
+
|---|---|
|
|
156
|
+
| `make test` | RuboCop, Minitest, Trivy, bundler-audit and Brakeman |
|
|
157
|
+
| `make test-rubies` | Minitest on every supported Ruby (needs rbenv) |
|
|
158
|
+
| `make build` | Builds the `.gem` |
|
|
159
|
+
| `make lint-js`, `make typecheck`, `make bun-audit` | Biome, TypeScript and npm dependency checks |
|
|
160
|
+
| `make assets`, `make assets-dummy`, `make icons` | Rebuild the gem's assets, the docs app's assets, or the icons |
|
|
161
|
+
|
|
162
|
+
To run the docs site in a container, see the `Dockerfile`.
|
|
163
|
+
|
|
164
|
+
## Contributing
|
|
165
|
+
|
|
166
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/kuyio/orbital_ui). Everyone interacting in the project is expected to follow the [code of conduct](https://github.com/kuyio/orbital_ui/blob/main/CODE_OF_CONDUCT.md).
|
|
167
|
+
|
|
168
|
+
1. Fork the repository
|
|
169
|
+
2. Create a feature branch
|
|
170
|
+
3. Make your changes
|
|
171
|
+
4. Test with the docs app and `make test`
|
|
172
|
+
5. Submit a pull request
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
Orbital is available as open source under the terms of the [MIT License](LICENSE).
|
|
177
|
+
|
|
178
|
+
### Third-party licenses
|
|
179
|
+
|
|
180
|
+
Orbital bundles icons from these projects. `lib/orbital_ui/icons.rb` lists the same notices.
|
|
181
|
+
|
|
182
|
+
**Lucide** is distributed under the ISC License:
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
186
|
+
|
|
187
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
188
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
189
|
+
copyright notice and this permission notice appear in all copies.
|
|
190
|
+
|
|
191
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
192
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
193
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
194
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
195
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
196
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
197
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Feather:** some Lucide icons are derived from Feather, listed in `lib/orbital_ui/icons.rb`. Those icons are distributed under the MIT License:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
Copyright (c) 2013-present Cole Bemis
|
|
204
|
+
|
|
205
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
206
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
207
|
+
in the Software without restriction, including without limitation the rights
|
|
208
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
209
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
210
|
+
furnished to do so, subject to the following conditions:
|
|
211
|
+
|
|
212
|
+
The above copyright notice and this permission notice shall be included in all
|
|
213
|
+
copies or substantial portions of the Software.
|
|
214
|
+
|
|
215
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
216
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
217
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
218
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
219
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
220
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
221
|
+
SOFTWARE.
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Font Awesome Free** brand icons by Fonticons, Inc. are licensed under [CC BY 4.0](https://fontawesome.com/license/free). Each icon in `lib/orbital_ui/icons.rb` keeps its attribution comment.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
!function(){let e,t;class r{constructor(e,t,r){this.eventTarget=e,this.eventName=t,this.eventOptions=r,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){let t=function(e){if("immediatePropagationStopped"in e)return e;{let{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(let e of this.bindings)if(t.immediatePropagationStopped)break;else e.handleEvent(t)}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{let r=e.index,i=t.index;return r<i?-1:+(r>i)})}}class i{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,r={}){this.application.handleError(e,`Error ${t}`,r)}clearEventListenersForBinding(e){let t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){let{eventTarget:t,eventName:r,eventOptions:i}=e,n=this.fetchEventListenerMapForEventTarget(t),s=this.cacheKey(r,i);n.delete(s),0==n.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:r,eventOptions:i}=e;return this.fetchEventListener(t,r,i)}fetchEventListener(e,t,r){let i=this.fetchEventListenerMapForEventTarget(e),n=this.cacheKey(t,r),s=i.get(n);return s||(s=this.createEventListener(e,t,r),i.set(n,s)),s}createEventListener(e,t,i){let n=new r(e,t,i);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){let r=[e];return Object.keys(t).sort().forEach(e=>{r.push(`${t[e]?"":"!"}${e}`)}),r.join(":")}}let n={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:r})=>!t||r===e.target},s=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function o(e){return e.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function a(e){return o(e.replace(/--/g,"-").replace(/__/g,"_"))}function l(e){return e.charAt(0).toUpperCase()+e.slice(1)}function c(e){return e.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}let u=["meta","ctrl","alt","shift"];class d{constructor(e,t,r,i){this.element=e,this.index=t,this.eventTarget=r.eventTarget||e,this.eventName=r.eventName||function(e){let t=e.tagName.toLowerCase();if(t in m)return m[t](e)}(e)||g("missing event name"),this.eventOptions=r.eventOptions||{},this.identifier=r.identifier||g("missing identifier"),this.methodName=r.methodName||g("missing method name"),this.keyFilter=r.keyFilter||"",this.schema=i}static forToken(e,t){var r;let i,n,o;return new this(e.element,e.index,(n=(i=e.content.trim().match(s)||[])[2],(o=i[3])&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${o}`,o=""),{eventTarget:"window"==(r=i[4])?window:"document"==r?document:void 0,eventName:n,eventOptions:i[7]?i[7].split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{}):{},identifier:i[5],methodName:i[6],keyFilter:i[1]||o}),t)}toString(){let 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;let t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;let r=t.filter(e=>!u.includes(e))[0];return!!r&&(h(this.keyMappings,r)||g(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[r].toLowerCase()!==e.key.toLowerCase())}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;let t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){let e={},t=RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:r,value:i}of Array.from(this.element.attributes)){let n=r.match(t),s=n&&n[1];s&&(e[o(s)]=function(e){try{return JSON.parse(e)}catch(t){return e}}(i))}return e}get eventTargetName(){var e;return(e=this.eventTarget)==window?"window":e==document?"document":void 0}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){let[r,i,n,s]=u.map(e=>t.includes(e));return e.metaKey!==r||e.ctrlKey!==i||e.altKey!==n||e.shiftKey!==s}}let m={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function g(e){throw Error(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){let t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){let e=this.controller[this.methodName];if("function"==typeof e)return e;throw Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){let{element:t}=this.action,{actionDescriptorFilters:r}=this.context.application,{controller:i}=this.context,n=!0;for(let[s,o]of Object.entries(this.eventOptions))if(!(s in r))continue;else{let a=r[s];n=n&&a({name:s,value:o,event:e,element:t,controller:i})}return n}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){let{target:t,currentTarget:r}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:r,action:this.methodName})}catch(s){let{identifier:t,controller:r,element:i,index:n}=this;this.context.handleError(s,`invoking action "${this.action}"`,{identifier:t,controller:r,element:i,index:n,event:e})}}willBeInvokedByEvent(e){let 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){let e=new Set(this.matchElementsInTree());for(let t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(let t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(let 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(let t of Array.from(e)){let e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(let t of Array.from(e)){let 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(let r of this.matchElementsInTree(e))t.call(this,r)}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,r){this.attributeName=t,this.delegate=r,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){let t=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(this.selector));return t.concat(r)}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){let r=e.get(t);return r||(r=new Set,e.set(t,r)),r}class y{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){var r;r=this.valuesByKey,v(r,e).add(t)}delete(e,t){var r,i,n;let s;r=this.valuesByKey,v(r,e).delete(t),i=r,n=e,null!=(s=i.get(n))&&0==s.size&&i.delete(n)}has(e,t){let r=this.valuesByKey.get(e);return null!=r&&r.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(t=>t.has(e))}getValuesForKey(e){let t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,r])=>r.has(e)).map(([e,t])=>e)}}class w{constructor(e,t,r,i){this._selector=t,this.details=i,this.elementObserver=new f(e,this),this.delegate=r,this.matchesByElement=new y}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){let{selector:t}=this;if(!t)return!1;{let r=e.matches(t);return this.delegate.selectorMatchElement?r&&this.delegate.selectorMatchElement(e,this.details):r}}matchElementsInTree(e){let{selector:t}=this;if(!t)return[];{let r=this.matchElement(e)?[e]:[],i=Array.from(e.querySelectorAll(t)).filter(e=>this.matchElement(e));return r.concat(i)}}elementMatched(e){let{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){for(let t of this.matchesByElement.getKeysForValue(e))this.selectorUnmatched(e,t)}elementAttributeChanged(e,t){let{selector:r}=this;if(r){let t=this.matchElement(e),i=this.matchesByElement.has(r,e);t&&!i?this.selectorMatched(e,r):!t&&i&&this.selectorUnmatched(e,r)}}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 E{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(let e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){let t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){let r=this.delegate.getStringMapKeyForAttribute(e);if(null!=r){this.stringMap.has(e)||this.stringMapKeyAdded(r,e);let i=this.element.getAttribute(e);if(this.stringMap.get(e)!=i&&this.stringMapValueChanged(i,r,t),null==i){let t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(r,e,t)}else this.stringMap.set(e,i)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,r){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,r)}stringMapKeyRemoved(e,t,r){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,r)}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 A{constructor(e,t,r){this.attributeObserver=new b(e,t,this),this.delegate=r,this.tokensByElement=new y}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){let[t,r]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(r)}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){var t,r;let i=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),s=(t=i,r=n,Array.from({length:Math.max(t.length,r.length)},(e,i)=>[t[i],r[i]])).findIndex(([e,t])=>{var r,i;return r=e,i=t,!r||!i||r.index!=i.index||r.content!=i.content});return -1==s?[[],[]]:[i.slice(s),n.slice(s)]}readTokensForElement(e){var t,r,i;let n=this.attributeName;return t=e.getAttribute(n)||"",r=e,i=n,t.trim().split(/\s+/).filter(e=>e.length).map((e,t)=>({element:r,attributeName:i,content:e,index:t}))}}class O{constructor(e,t,r){this.tokenListObserver=new A(e,t,this),this.delegate=r,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){let{element:t}=e,{value:r}=this.fetchParseResultForToken(e);r&&(this.fetchValuesByTokenForElement(t).set(e,r),this.delegate.elementMatchedValue(t,r))}tokenUnmatched(e){let{element:t}=e,{value:r}=this.fetchParseResultForToken(e);r&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,r))}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 T{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new O(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){let t=new p(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){let 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){let t=d.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class x{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new E(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){let r=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,r.writer(this.receiver[e]),r.writer(r.defaultValue))}stringMapValueChanged(e,t,r){let i=this.valueDescriptorNameMap[t];null!==e&&(null===r&&(r=i.writer(i.defaultValue)),this.invokeChangedCallback(t,e,r))}stringMapKeyRemoved(e,t,r){let i=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,i.writer(this.receiver[e]),r):this.invokeChangedCallback(e,i.writer(i.defaultValue),r)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:r,writer:i}of this.valueDescriptors)void 0==r||this.controller.data.has(e)||this.invokeChangedCallback(t,i(r),void 0)}invokeChangedCallback(e,t,r){let i=`${e}Changed`,n=this.receiver[i];if("function"==typeof n){let i=this.valueDescriptorNameMap[e];try{let e=i.reader(t),s=r;r&&(s=i.reader(r)),n.call(this.receiver,e,s)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${i.name}" - ${e.message}`),e}}}get valueDescriptors(){let{valueDescriptorMap:e}=this;return Object.keys(e).map(t=>e[t])}get valueDescriptorNameMap(){let e={};return Object.keys(this.valueDescriptorMap).forEach(t=>{let r=this.valueDescriptorMap[t];e[r.name]=r}),e}hasValue(e){let t=this.valueDescriptorNameMap[e],r=`has${l(t.name)}`;return this.receiver[r]}}class k{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new y}start(){this.tokenListObserver||(this.tokenListObserver=new A(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 r;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null==(r=this.tokenListObserver)||r.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var r;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null==(r=this.tokenListObserver)||r.pause(()=>this.delegate.targetDisconnected(e,t)))}disconnectAllTargets(){for(let e of this.targetsByName.keys)for(let 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 M(e,t){return Array.from(C(e).reduce((e,r)=>{let i;return(Array.isArray(i=r[t])?i:[]).forEach(t=>e.add(t)),e},new Set))}function C(e){let t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class F{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new y,this.outletElementsByName=new y,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:r}){let i=this.getOutlet(e,r);i&&this.connectOutlet(i,e,r)}selectorUnmatched(e,t,{outletName:r}){let i=this.getOutletFromMap(e,r);i&&this.disconnectOutlet(i,e,r)}selectorMatchElement(e,{outletName:t}){let r=this.selector(t),i=this.hasOutlet(e,t),n=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return!!r&&i&&n&&e.matches(r)}elementMatchedAttribute(e,t){let r=this.getOutletNameFromOutletAttributeName(t);r&&this.updateSelectorObserverForOutlet(r)}elementAttributeValueChanged(e,t){let r=this.getOutletNameFromOutletAttributeName(t);r&&this.updateSelectorObserverForOutlet(r)}elementUnmatchedAttribute(e,t){let r=this.getOutletNameFromOutletAttributeName(t);r&&this.updateSelectorObserverForOutlet(r)}connectOutlet(e,t,r){var i;this.outletElementsByName.has(r,t)||(this.outletsByName.add(r,e),this.outletElementsByName.add(r,t),null==(i=this.selectorObserverMap.get(r))||i.pause(()=>this.delegate.outletConnected(e,t,r)))}disconnectOutlet(e,t,r){var i;this.outletElementsByName.has(r,t)&&(this.outletsByName.delete(r,e),this.outletElementsByName.delete(r,t),null==(i=this.selectorObserverMap.get(r))||i.pause(()=>this.delegate.outletDisconnected(e,t,r)))}disconnectAllOutlets(){for(let e of this.outletElementsByName.keys)for(let t of this.outletElementsByName.getValuesForKey(e))for(let r of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(r,t,e)}updateSelectorObserverForOutlet(e){let t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){let t=this.selector(e),r=new w(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,r),r.start()}setupAttributeObserverForOutlet(e){let t=this.attributeNameForOutletName(e),r=new b(this.scope.element,t,this);this.attributeObserverMap.set(e,r),r.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(){let e=new y;return this.router.modules.forEach(t=>{M(t.definition.controllerConstructor,"outlets").forEach(r=>e.add(r,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){let 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 S{constructor(e,t){this.logDebugActivity=(e,t={})=>{let{identifier:r,controller:i,element:n}=this;t=Object.assign({identifier:r,controller:i,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 T(this,this.dispatcher),this.valueObserver=new x(this,this.controller),this.targetObserver=new k(this,this),this.outletObserver=new F(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,r={}){let{identifier:i,controller:n,element:s}=this;r=Object.assign({identifier:i,controller:n,element:s},r),this.application.handleError(e,`Error ${t}`,r)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,r){this.invokeControllerMethod(`${a(r)}OutletConnected`,e,t)}outletDisconnected(e,t,r){this.invokeControllerMethod(`${a(r)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let r=this.controller;"function"==typeof r[e]&&r[e](...t)}}let L="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,N=(()=>{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{let t;return(t=e(function(){this.a.call(this)})).prototype.a=function(){},new t,e}catch(e){return e=>class extends e{}}})();class D{constructor(e,t){var r,i,n,s,o,a;let l,c;this.application=e,this.definition={identifier:t.identifier,controllerConstructor:(n=r=t.controllerConstructor,s=M(i=r,"blessings").reduce((e,t)=>{let r=t(i);for(let t in r){let i=e[t]||{};e[t]=Object.assign(i,r[t])}return e},{}),l=N(n),c=(o=n.prototype,L(a=s).reduce((e,t)=>{let r=function(e,t,r){let i=Object.getOwnPropertyDescriptor(e,r);if(!(i&&"value"in i)){let e=Object.getOwnPropertyDescriptor(t,r).value;return i&&(e.get=i.get||e.get,e.set=i.set||e.set),e}}(o,a,t);return r&&Object.assign(e,{[t]:r}),e},{})),Object.defineProperties(l.prototype,c),l)},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){let t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){let t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new S(this,e),this.contextsByScope.set(e,t)),t}}class B{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){return(this.data.get(this.getDataKey(e))||"").match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class ${constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){let t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){let r=this.getAttributeNameForKey(e);return this.element.setAttribute(r,t),this.get(e)}has(e){let t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(!this.has(e))return!1;{let t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}}getAttributeNameForKey(e){return`data-${this.identifier}-${c(e)}`}}class P{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,r){let i=this.warnedKeysByObject.get(e);i||(i=new Set,this.warnedKeysByObject.set(e,i)),i.has(t)||(i.add(t),this.logger.warn(r,e))}}function I(e,t){return`[${e}~="${t}"]`}class V{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){let t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){let t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return I(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){let t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){let t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map(t=>this.deprecate(t,e))}getLegacySelectorForTargetName(e){let t=`${this.identifier}.${e}`;return I(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:r}=this,i=this.schema.targetAttribute,n=this.schema.targetAttributeForScope(r);this.guide.warn(e,`target:${t}`,`Please replace ${i}="${r}.${t}" with ${n}="${t}". The ${i} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class K{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){let t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){let t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){let t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter(r=>this.matchesElement(r,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(r=>this.matchesElement(r,e,t))}matchesElement(e,t,r){let i=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&i.split(" ").includes(r)}}class R{constructor(e,t,r,i){this.targets=new V(this),this.classes=new B(this),this.data=new $(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=r,this.guide=new P(i),this.outlets=new K(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 I(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new R(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class j{constructor(e,t,r){this.element=e,this.schema=t,this.delegate=r,this.valueListObserver=new O(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){let{element:t,content:r}=e;return this.parseValueForElementAndIdentifier(t,r)}parseValueForElementAndIdentifier(e,t){let r=this.fetchScopesByIdentifierForElement(e),i=r.get(t);return i||(i=this.delegate.createScopeForElementAndIdentifier(e,t),r.set(t,i)),i}elementMatchedValue(e,t){let r=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,r),1==r&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){let r=this.scopeReferenceCounts.get(t);r&&(this.scopeReferenceCounts.set(t,r-1),1==r&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class _{constructor(e){this.application=e,this.scopeObserver=new j(this.element,this.schema,this),this.scopesByIdentifier=new y,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);let t=new D(this.application,e);this.connectModule(t);let r=e.controllerConstructor.afterLoad;r&&r.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){let t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){let r=this.modulesByIdentifier.get(t);if(r)return r.contexts.find(t=>t.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){let r=this.scopeObserver.parseValueForElementAndIdentifier(e,t);r?this.scopeObserver.elementMatchedValue(r.element,r):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,r){this.application.handleError(e,t,r)}createScopeForElementAndIdentifier(e,t){return new R(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);let 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))}}let U={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"},H("abcdefghijklmnopqrstuvwxyz".split("").map(e=>[e,e]))),H("0123456789".split("").map(e=>[e,e])))};function H(e){return e.reduce((e,[t,r])=>Object.assign(Object.assign({},e),{[t]:r}),{})}function W(e,t,r){return e.application.getControllerForElementAndIdentifier(t,r)}function q(e,t,r){let i=W(e,t,r);return i||(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,r),i=W(e,t,r))?i:void 0}function z([e,t],r){return function(e){let{token:t,typeDefinition:r}=e,i=`${c(t)}-value`,n=function(e){let{controller:t,token:r,typeDefinition:i}=e,n=function(e){let{controller:t,token:r,typeObject:i}=e,n=null!=i.type,s=null!=i.default,o=Y(i.type),a=J(e.typeObject.default);if(n&&!s)return o;if(!n&&s)return a;if(o!==a){let e=t?`${t}.${r}`:r;throw Error(`The specified default value for the Stimulus Value "${e}" must match the defined type "${o}". The provided default value of "${i.default}" is of type "${a}".`)}if(n&&s)return o}({controller:t,token:r,typeObject:i}),s=J(i),o=Y(i),a=n||s||o;if(a)return a;let l=t?`${t}.${i}`:r;throw Error(`Unknown value type "${l}" for "${r}" value`)}(e);return{type:n,key:i,name:o(i),get defaultValue(){return function(e){let t=Y(e);if(t)return G[t];let r=h(e,"default"),i=h(e,"type");if(r)return e.default;if(i){let{type:t}=e,r=Y(t);if(r)return G[r]}return e}(r)},get hasCustomDefaultValue(){return void 0!==J(r)},reader:X[n],writer:Z[n]||Z.default}}({controller:r,token:e,typeDefinition:t})}function Y(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function J(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}let G={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},X={array(e){let t=JSON.parse(e);if(!Array.isArray(t))throw TypeError(`expected value of type "array" but instead got value "${e}" of type "${J(t)}"`);return t},boolean:e=>"0"!=e&&"false"!=String(e).toLowerCase(),number:e=>Number(e.replace(/_/g,"")),object(e){let t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw TypeError(`expected value of type "object" but instead got value "${e}" of type "${J(t)}"`);return t},string:e=>e},Z={default:function(e){return`${e}`},array:Q,object:Q};function Q(e){return JSON.stringify(e)}class ee{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:r={},prefix:i=this.identifier,bubbles:n=!0,cancelable:s=!0}={}){let o=new CustomEvent(i?`${i}:${e}`:e,{detail:r,bubbles:n,cancelable:s});return t.dispatchEvent(o),o}}ee.blessings=[function(e){return M(e,"classes").reduce((e,t)=>{var r;return Object.assign(e,(r=t,{[`${r}Class`]:{get(){let{classes:e}=this;if(e.has(r))return e.get(r);{let t=e.getAttributeName(r);throw Error(`Missing attribute "${t}"`)}}},[`${r}Classes`]:{get(){return this.classes.getAll(r)}},[`has${l(r)}Class`]:{get(){return this.classes.has(r)}}}))},{})},function(e){return M(e,"targets").reduce((e,t)=>{var r;return Object.assign(e,(r=t,{[`${r}Target`]:{get(){let e=this.targets.find(r);if(e)return e;throw Error(`Missing target element "${r}" for "${this.identifier}" controller`)}},[`${r}Targets`]:{get(){return this.targets.findAll(r)}},[`has${l(r)}Target`]:{get(){return this.targets.has(r)}}}))},{})},function(e){let t=C(e).reduce((e,t)=>{let r;return e.push(...(r=t.values)?Object.keys(r).map(e=>[e,r[e]]):[]),e},[]);return t.reduce((e,t)=>Object.assign(e,function(e){let t=z(e,void 0),{key:r,name:i,reader:n,writer:s}=t;return{[i]:{get(){let e=this.data.get(r);return null!==e?n(e):t.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,s(e))}},[`has${l(i)}`]:{get(){return this.data.has(r)||t.hasCustomDefaultValue}}}}(t)),{valueDescriptorMap:{get(){return t.reduce((e,t)=>{let r=z(t,this.identifier);return Object.assign(e,{[this.data.getAttributeNameForKey(r.key)]:r})},{})}}})},function(e){return M(e,"outlets").reduce((e,t)=>{var r;let i;return Object.assign(e,(i=a(r=t),{[`${i}Outlet`]:{get(){let e=this.outlets.find(r),t=this.outlets.getSelectorForOutletName(r);if(e){let t=q(this,e,r);if(t)return t;throw Error(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`)}throw Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${t}".`)}},[`${i}Outlets`]:{get(){let e=this.outlets.findAll(r);return e.length>0?e.map(e=>{let t=q(this,e,r);if(t)return t;console.warn(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`,e)}).filter(e=>e):[]}},[`${i}OutletElement`]:{get(){let e=this.outlets.find(r),t=this.outlets.getSelectorForOutletName(r);if(e)return e;throw Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${t}".`)}},[`${i}OutletElements`]:{get(){return this.outlets.findAll(r)}},[`has${l(i)}Outlet`]:{get(){return this.outlets.has(r)}}}))},{})}],ee.targets=[],ee.outlets=[],ee.values={};let et=["top","right","bottom","left"].reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]),er=Math.min,ei=Math.max,en=Math.round,es=e=>({x:e,y:e}),eo={left:"right",right:"left",bottom:"top",top:"bottom"};function ea(e,t){return"function"==typeof e?e(t):e}function el(e){return e.split("-")[0]}function ec(e){return e.split("-")[1]}function eh(e){return"x"===e?"y":"x"}function eu(e){return"y"===e?"height":"width"}function ed(e){let t=e[0];return"t"===t||"b"===t?"y":"x"}function em(e,t,r){void 0===r&&(r=!1);let i=ec(e),n=eh(ed(e)),s=eu(n),o="x"===n?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=ey(o)),[o,ey(o)]}function eg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}let ep=["left","right"],ef=["right","left"],eb=["top","bottom"],ev=["bottom","top"];function ey(e){let t=el(e);return eo[t]+e.slice(t.length)}function ew(e){let{x:t,y:r,width:i,height:n}=e;return{width:i,height:n,top:r,left:t,right:t+i,bottom:r+n,x:t,y:r}}function eE(e,t,r){let i,{reference:n,floating:s}=e,o=ed(t),a=eh(ed(t)),l=eu(a),c=el(t),h=n.x+n.width/2-s.width/2,u=n.y+n.height/2-s.height/2,d=n[l]/2-s[l]/2;switch(c){case"top":i={x:h,y:n.y-s.height};break;case"bottom":i={x:h,y:n.y+n.height};break;case"right":i={x:n.x+n.width,y:u};break;case"left":i={x:n.x-s.width,y:u};break;default:i={x:n.x,y:n.y}}let m=ec(t);return m&&(i[a]+=d*("end"===m?1:-1)*(r&&"y"===o?-1:1)),i}async function eA(e,t){var r,i,n,s,o;void 0===t&&(t={});let{x:a,y:l,platform:c,rects:h,elements:u,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:g="viewport",elementContext:p="floating",altBoundary:f=!1,padding:b=0}=ea(t,e),v="number"!=typeof b?{top:null!=(i=b.top)?i:0,right:null!=(n=b.right)?n:0,bottom:null!=(s=b.bottom)?s:0,left:null!=(o=b.left)?o:0}:{top:b,right:b,bottom:b,left:b},y=u[f?"floating"===p?"reference":"floating":p],w=ew(await c.getClippingRect({element:null==(r=await (null==c.isElement?void 0:c.isElement(y)))||r?y:y.contextElement||await (null==c.getDocumentElement?void 0:c.getDocumentElement(u.floating)),boundary:m,rootBoundary:g,strategy:d})),E="floating"===p?{x:a,y:l,width:h.floating.width,height:h.floating.height}:h.reference,A=await (null==c.getOffsetParent?void 0:c.getOffsetParent(u.floating)),O=await (null==c.isElement?void 0:c.isElement(A))&&await (null==c.getScale?void 0:c.getScale(A))||{x:1,y:1},T=ew(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:E,offsetParent:A,strategy:d}):E);return{top:(w.top-T.top+v.top)/O.y,bottom:(T.bottom-w.bottom+v.bottom)/O.y,left:(w.left-T.left+v.left)/O.x,right:(T.right-w.right+v.right)/O.x}}let eO=new Set(["left","top"]);function eT(){return"u">typeof window}function ex(e){return eC(e)?(e.nodeName||"").toLowerCase():"#document"}function ek(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function eM(e){var t;return null==(t=(eC(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function eC(e){return!!eT()&&(e instanceof Node||e instanceof ek(e).Node)}function eF(e){return!!eT()&&(e instanceof Element||e instanceof ek(e).Element)}function eS(e){return!!eT()&&(e instanceof HTMLElement||e instanceof ek(e).HTMLElement)}function eL(e){return!(!eT()||"u"<typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof ek(e).ShadowRoot)}function eN(e){let{overflow:t,overflowX:r,overflowY:i,display:n}=eR(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+r)&&"inline"!==n&&"contents"!==n}function eD(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}let eB=/transform|translate|scale|rotate|perspective|filter/,e$=/paint|layout|strict|content/,eP=e=>!!e&&"none"!==e;function eI(e){let t=eF(e)?eR(e):e;return eP(t.transform)||eP(t.translate)||eP(t.scale)||eP(t.rotate)||eP(t.perspective)||!eV()&&(eP(t.backdropFilter)||eP(t.filter))||eB.test(t.willChange||"")||e$.test(t.contain||"")}function eV(){return null==e&&(e="u">typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),e}function eK(e){return/^(html|body|#document)$/.test(ex(e))}function eR(e){return ek(e).getComputedStyle(e)}function ej(e){return eF(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function e_(e){if("html"===ex(e))return e;let t=e.assignedSlot||e.parentNode||eL(e)&&e.host||eM(e);return eL(t)?t.host:t}function eU(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function eH(e){let t=eR(e),r=parseFloat(t.width)||0,i=parseFloat(t.height)||0,n=eS(e),s=n?e.offsetWidth:r,o=n?e.offsetHeight:i,a=en(r)!==s||en(i)!==o;return a&&(r=s,i=o),{width:r,height:i,$:a}}function eW(e){return eF(e)?e:e.contextElement}function eq(e){let t=eW(e);if(!eS(t))return es(1);let r=t.getBoundingClientRect(),{width:i,height:n,$:s}=eH(t),o=(s?en(r.width):r.width)/i,a=(s?en(r.height):r.height)/n;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}let ez=es(0);function eY(e){let t=ek(e);return eV()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ez}function eJ(e,t,r,i){var n;void 0===t&&(t=!1),void 0===r&&(r=!1);let s=e.getBoundingClientRect(),o=eW(e),a=es(1);t&&(i?eF(i)&&(a=eq(i)):a=eq(e));let l=(void 0===(n=r)&&(n=!1),i&&n&&i===ek(o))?eY(o):es(0),c=(s.left+l.x)/a.x,h=(s.top+l.y)/a.y,u=s.width/a.x,d=s.height/a.y;if(o&&i){let e=ek(o),t=eF(i)?ek(i):i,r=e,n=eU(r);for(;n&&t!==r;){let e=eq(n),t=n.getBoundingClientRect(),i=eR(n),s=t.left+(n.clientLeft+parseFloat(i.paddingLeft))*e.x,o=t.top+(n.clientTop+parseFloat(i.paddingTop))*e.y;c*=e.x,h*=e.y,u*=e.x,d*=e.y,c+=s,h+=o,n=eU(r=ek(n))}}return ew({width:u,height:d,x:c,y:h})}function eG(e,t){let r=ej(e).scrollLeft;return t?t.left+r:eJ(eM(e)).left+r}function eX(e,t){let r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-eG(e,r),y:r.top+t.scrollTop}}function eZ(e,t,r){var i;let n;if("viewport"===t||"layoutViewport"===t)n=function(e,t,r){void 0===r&&(r="viewport");let i="layoutViewport"===r,n=ek(e),s=eM(e),o=n.visualViewport,a=s.clientWidth,l=s.clientHeight,c=0,h=0;if(o){let e=!eV()||"fixed"===t;i?e||(c=-o.offsetLeft,h=-o.offsetTop):(a=o.width,l=o.height,e&&(c=o.offsetLeft,h=o.offsetTop))}if(0>=eG(s)){let e=s.ownerDocument,t=e.body,r=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,n=Math.abs(s.clientWidth-t.clientWidth-i),o="stable both-edges"===getComputedStyle(s).scrollbarGutter?n/2:n;o<=25&&(a-=o)}return{width:a,height:l,x:c,y:h}}(e,r,t);else if("document"===t){let t,r,s,o,a,l;t=ej(i=eM(e)),r=i.ownerDocument.body,s=ei(i.scrollWidth,i.clientWidth,r.scrollWidth,r.clientWidth),o=ei(i.scrollHeight,i.clientHeight,r.scrollHeight,r.clientHeight),a=-t.scrollLeft+eG(i),l=-t.scrollTop,"rtl"===eR(r).direction&&(a+=ei(i.clientWidth,r.clientWidth)-s),n={width:s,height:o,x:a,y:l}}else if(eF(t)){let e,i,s,o,a,l;i=(e=eJ(t,!0,"fixed"===r)).top+t.clientTop,s=e.left+t.clientLeft,o=eq(t),a=t.clientWidth*o.x,l=t.clientHeight*o.y,n={width:a,height:l,x:s*o.x,y:i*o.y}}else{let r=eY(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ew(n)}function eQ(e){return"static"===eR(e).position}function e0(e,t){if(!eS(e)||"fixed"===eR(e).position)return null;if(t)return t(e);let r=e.offsetParent;return eM(e)===r&&(r=r.ownerDocument.body),r}function e1(e,t){var r;let i=ek(e);if(eD(e))return i;if(!eS(e)){let t=e_(e);for(;t&&!eK(t);){if(eF(t)&&!eQ(t))return t;t=e_(t)}return i}let n=e0(e,t);for(;n&&(r=n,/^(table|td|th)$/.test(ex(r)))&&eQ(n);)n=e0(n,t);return n&&eK(n)&&eQ(n)&&!eI(n)?i:n||function(e){let t=e_(e);for(;eS(t)&&!eK(t);){if(eI(t))return t;if(eD(t))break;t=e_(t)}return null}(e)||i}let e2={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:i,strategy:n}=e,s="fixed"===n,o=eM(i),a=!!t&&eD(t.floating);if(i===o||a&&s)return r;let l={scrollLeft:0,scrollTop:0},c=es(1),h=es(0),u=eS(i);if((u||!s)&&(("body"!==ex(i)||eN(o))&&(l=ej(i)),u)){let e=eJ(i);c=eq(i),h.x=e.x+i.clientLeft,h.y=e.y+i.clientTop}let d=!o||u||s?es(0):eX(o,l);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-l.scrollLeft*c.x+h.x+d.x,y:r.y*c.y-l.scrollTop*c.y+h.y+d.y}},getDocumentElement:eM,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:i,strategy:n}=e,s=[..."clippingAncestors"===r?eD(t)?[]:function(e,t){let r=t.get(e);if(r)return r;let i=(function e(t,r,i){var n;void 0===r&&(r=[]),void 0===i&&(i=!0);let s=function e(t){let r=e_(t);return eK(r)?(t.ownerDocument||t).body:eS(r)&&eN(r)?r:e(r)}(t),o=s===(null==(n=t.ownerDocument)?void 0:n.body),a=ek(s);if(!o)return r.concat(s,e(s,[],i));{let t=eU(a);return r.concat(a,a.visualViewport||[],eN(s)?s:[],t&&i?e(t):[])}})(e,[],!1).filter(e=>eF(e)&&"body"!==ex(e)),n=null,s="fixed"===eR(e).position,o=s?e_(e):e;for(;eF(o)&&!eK(o);){let e=eR(o),t=eI(o),r=n?n.position:s?"fixed":"";t||"fixed"!==r&&("absolute"!==r||"static"!==e.position)?n=e:i=i.filter(e=>e!==o),o=e_(o)}return t.set(e,i),i}(t,this._c):[].concat(r),i],o=eZ(t,s[0],n),a=o.top,l=o.right,c=o.bottom,h=o.left;for(let e=1;e<s.length;e++){let r=eZ(t,s[e],n);a=ei(r.top,a),l=er(r.right,l),c=er(r.bottom,c),h=ei(r.left,h)}return{width:l-h,height:c-a,x:h,y:a}},getOffsetParent:e1,getElementRects:async function(e){let t=this.getOffsetParent||e1,r=this.getDimensions,i=await r(e.floating);return{reference:function(e,t,r){let i=eS(t),n=eM(t),s="fixed"===r,o=eJ(e,!0,s,t),a={scrollLeft:0,scrollTop:0},l=es(0);if((i||!s)&&(("body"!==ex(t)||eN(n))&&(a=ej(t)),i)){let e=eJ(t,!0,s,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}!i&&n&&(l.x=eG(n));let c=!n||i||s?es(0):eX(n,a);return{x:o.left+a.scrollLeft-l.x-c.x,y:o.top+a.scrollTop-l.y-c.y,width:o.width,height:o.height}}(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){let{width:t,height:r}=eH(e);return{width:t,height:r}},getScale:eq,isElement:eF,isRTL:function(e){return"rtl"===eR(e).direction}},e8=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,i;let{x:n,y:s,placement:o,middlewareData:a}=t,l=await async function(e,t){let{placement:r,platform:i,elements:n}=e,s=await (null==i.isRTL?void 0:i.isRTL(n.floating)),o=el(r),a=ec(r),l="y"===ed(r),c=eO.has(o)?-1:1,h=s&&l?-1:1,u=ea(t,e),{mainAxis:d,crossAxis:m,alignmentAxis:g}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof g&&(m="end"===a?-1*g:g),l?{x:m*h,y:d*c}:{x:d*c,y:m*h}}(t,e);return o===(null==(r=a.offset)?void 0:r.placement)&&null!=(i=a.arrow)&&i.alignmentOffset?{}:{x:n+l.x,y:s+l.y,data:{...l,placement:o}}}}},e5=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){let{x:r,y:i,placement:n,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...c}=ea(e,t),h={x:r,y:i},u=await s.detectOverflow(t,c),d=ed(n),m=eh(d),g=h[m],p=h[d],f=(e,t)=>ei(t+u["y"===e?"top":"left"],er(t,t-u["y"===e?"bottom":"right"]));o&&(g=f(m,g)),a&&(p=f(d,p));let b=l.fn({...t,[m]:g,[d]:p});return{...b,data:{x:b.x-r,y:b.y-i,enabled:{[m]:o,[d]:a}}}}}};window.Stimulus?t=window.Stimulus:((t=(class{constructor(e=document.documentElement,t=U){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,r={})=>{this.debug&&this.logFormattedMessage(e,t,r)},this.element=e,this.schema=t,this.dispatcher=new i(this),this.router=new _(this),this.actionDescriptorFilters=Object.assign({},n)}static start(e,t){let r=new this(e,t);return r.start(),r}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){let r=this.router.getContextForElementAndIdentifier(e,t);return r?r.controller:null}handleError(e,t,r){var i;this.logger.error(`%s
|
|
2
|
+
|
|
3
|
+
%o
|
|
4
|
+
|
|
5
|
+
%o`,t,e,r),null==(i=window.onerror)||i.call(window,t,"",0,0,e)}logFormattedMessage(e,t,r={}){r=Object.assign({application:this},r),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},r)),this.logger.groupEnd()}}).start()).debug=!1,window.Stimulus=t),t.register("orbital-avatar",class extends ee{static targets=["image","fallback"];imageError(){this.hasImageTarget&&(this.imageTarget.style.display="none"),this.hasFallbackTarget&&(this.fallbackTarget.style.display="flex")}}),t.register("o-accordion",class extends ee{connect(){this.element.querySelectorAll("[data-accordion-trigger]").forEach(e=>{e.addEventListener("click",this.toggle.bind(this))})}toggle(e){let t=e.currentTarget.closest(".Orbital-Accordion-Item");if(!t)return;let r=t.querySelector(".Orbital-Accordion-Item-Content");r&&("open"===r.dataset.state?(r.style.height=`${r.scrollHeight}px`,r.offsetHeight,r.style.height="0px",r.addEventListener("transitionend",()=>{r.dataset.state="closed",r.style.height=""},{once:!0})):(r.dataset.state="open",r.style.height="0px",r.offsetHeight,r.style.height=`${r.scrollHeight}px`,r.addEventListener("transitionend",()=>{r.style.height=""},{once:!0})))}}),t.register("orbital-modal",class extends ee{static values={open:{type:Boolean,default:!1},dismissible:{type:Boolean,default:!0}};static targets=["panel"];connect(){this._handleKeydown=this.handleKeydown.bind(this),this._previouslyFocused=null,this._originalStyles=null,this._scrollY=0,this.openValue&&requestAnimationFrame(()=>this.show())}disconnect(){this._restoreScrollLock(),document.removeEventListener("keydown",this._handleKeydown)}show(){"open"!==this.element.dataset.state&&(this._previouslyFocused=document.activeElement,this.element.setAttribute("data-state","open"),this._applyScrollLock(),document.addEventListener("keydown",this._handleKeydown),requestAnimationFrame(()=>this._focusFirst()),this.element.dispatchEvent(new CustomEvent("orbital:modal:open",{bubbles:!0})))}close(){"closed"!==this.element.dataset.state&&(this.element.setAttribute("data-state","closed"),this._restoreScrollLock(),document.removeEventListener("keydown",this._handleKeydown),this._previouslyFocused&&"function"==typeof this._previouslyFocused.focus&&(this._previouslyFocused.focus(),this._previouslyFocused=null),this.element.dispatchEvent(new CustomEvent("orbital:modal:close",{bubbles:!0})),this._clearTurboFrame())}backdropClick(e){e.target===e.currentTarget&&this.dismissibleValue&&this.close()}handleKeydown(e){if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),this.dismissibleValue&&this.close();return}"Tab"===e.key&&this._trapFocus(e)}_applyScrollLock(){if(document.body.dataset.orbitalScrollLocked)return;this._scrollY=window.scrollY;let e=getComputedStyle(document.documentElement),t=e.scrollbarGutter?.includes("stable");if(this._originalStyles={overflow:document.body.style.overflow,paddingRight:document.body.style.paddingRight},document.body.style.overflow="hidden",!t){let e=window.innerWidth-document.documentElement.clientWidth;e>0&&(document.body.style.paddingRight=`${e}px`)}document.body.dataset.orbitalScrollLocked="true"}_restoreScrollLock(){this._originalStyles&&(document.body.style.overflow=this._originalStyles.overflow,document.body.style.paddingRight=this._originalStyles.paddingRight,delete document.body.dataset.orbitalScrollLocked,this._originalStyles=null)}_focusableElements(){return this.hasPanelTarget?[...this.panelTarget.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]):not([type='hidden']), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1']), [contenteditable]")].filter(e=>!e.closest("[hidden]")&&!e.closest("[aria-hidden='true']")):[]}_focusFirst(){let e=this._focusableElements();e.length>0?e[0].focus({preventScroll:!0}):this.hasPanelTarget&&(this.panelTarget.setAttribute("tabindex","-1"),this.panelTarget.focus({preventScroll:!0}))}_trapFocus(e){let t=this._focusableElements();if(0===t.length)return;let r=t[0],i=t[t.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),i.focus({preventScroll:!0})):document.activeElement===i&&(e.preventDefault(),r.focus({preventScroll:!0}))}_clearTurboFrame(){let e=this.element.closest("turbo-frame");e&&(e.innerHTML="",e.removeAttribute("src"),e.removeAttribute("complete"))}}),t.register("orbital-popover",class extends ee{static values={trigger:{type:String,default:"click"},position:{type:String,default:"auto"},showDelay:{type:Number,default:0},hideDelay:{type:Number,default:100}};static targets=["trigger","content"];connect(){this.boundShow=this.show.bind(this),this.boundHide=this.hide.bind(this),this.boundDelayedHide=this.delayedHide.bind(this),this.boundUpdatePosition=this.updatePosition.bind(this),this.boundOnNativeToggle=this.onNativeToggle.bind(this),this.hideTimeout=null,"hover"===this.triggerValue?this.setupHoverTrigger():this.setupClickTrigger(),this.hasContentTarget&&this.contentTarget.addEventListener("toggle",this.boundOnNativeToggle)}disconnect(){this.teardownTrigger(),this.teardownPositioning(),this.cancelShowTimeout(),this.hideTimeout&&clearTimeout(this.hideTimeout),this.hasContentTarget&&this.contentTarget.removeEventListener("toggle",this.boundOnNativeToggle)}onNativeToggle(e){"closed"===e.newState&&"open"===this.element.getAttribute("data-state")&&(this.element.setAttribute("data-state","closed"),this.contentTarget.removeAttribute("data-positioned"),this.teardownPositioning())}async show(){if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),"open"!==this.element.getAttribute("data-state")&&this.hasContentTarget)try{this.contentTarget.removeAttribute("data-positioned"),this.contentTarget.showPopover(),this.element.setAttribute("data-state","open");let{x:e,y:t,placement:r}=await this.calculatePosition();this.contentTarget.style.left=`${e}px`,this.contentTarget.style.top=`${t}px`,this.contentTarget.dataset.placement=r,this.contentTarget.setAttribute("data-positioned","true"),this.setupPositioning(),this.element.dispatchEvent(new CustomEvent("orbital:popover:shown",{bubbles:!0,detail:{popover:this.contentTarget}}))}catch(e){console.warn("Popover API not supported:",e)}}hide(){if(this.hasContentTarget)try{this.contentTarget.hidePopover(),this.element.setAttribute("data-state","closed"),this.contentTarget.removeAttribute("data-positioned"),this.teardownPositioning(),this.element.dispatchEvent(new CustomEvent("orbital:popover:hidden",{bubbles:!0,detail:{popover:this.contentTarget}}))}catch(e){console.warn("Popover API not supported:",e)}}delayedHide(){0===this.hideDelayValue?this.hide():this.hideTimeout=setTimeout(()=>{this.hide()},this.hideDelayValue)}async toggle(){if(this.hasContentTarget)try{if("open"===this.element.getAttribute("data-state"))this.contentTarget.hidePopover(),this.element.setAttribute("data-state","closed"),this.contentTarget.removeAttribute("data-positioned"),this.teardownPositioning();else{this.contentTarget.removeAttribute("data-positioned"),this.contentTarget.showPopover(),this.element.setAttribute("data-state","open");let{x:e,y:t,placement:r}=await this.calculatePosition();this.contentTarget.style.left=`${e}px`,this.contentTarget.style.top=`${t}px`,this.contentTarget.dataset.placement=r,this.contentTarget.setAttribute("data-positioned","true"),this.setupPositioning()}}catch(e){console.warn("Popover API not supported:",e)}}static COMPASS_TO_PLACEMENT={n:"top",ne:"top-end",e:"right",se:"bottom-end",s:"bottom",sw:"bottom-start",w:"left",nw:"top-start"};async calculatePosition(){var e,t,r;let i,n;if(!this.hasTriggerTarget||!this.hasContentTarget)return{x:0,y:0,placement:"bottom"};let s=this.triggerTarget,o=this.contentTarget;"auto"===this.positionValue?i=[e8(8),(void 0===e&&(e={}),{name:"autoPlacement",options:e,async fn(t){var r,i,n,s;let{rects:o,middlewareData:a,placement:l,platform:c,elements:h}=t,{crossAxis:u=!1,alignment:d,allowedPlacements:m=et,autoAlignment:g=!0,...p}=ea(e,t),f=void 0!==d||m===et?((s=d||null)?[...m.filter(e=>ec(e)===s),...m.filter(e=>ec(e)!==s)]:m.filter(e=>el(e)===e)).filter(e=>!s||ec(e)===s||!!g&&eg(e)!==e):m,b=(null==(r=a.autoPlacement)?void 0:r.index)||0,v=f[b];if(null==v)return{};if(l!==v)return{reset:{placement:f[0]}};let y=await c.detectOverflow(t,p),w=em(v,o,await (null==c.isRTL?void 0:c.isRTL(h.floating))),E=[y[el(v)],y[w[0]],y[w[1]]],A=[...(null==(i=a.autoPlacement)?void 0:i.overflows)||[],{placement:v,overflows:E}],O=f[b+1];if(O)return{data:{index:b+1,overflows:A},reset:{placement:O}};let T=A.map(e=>{let t=ec(e.placement);return[e.placement,t&&u?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),x=(null==(n=T.filter(e=>e[2].slice(0,ec(e[0])?2:3).every(e=>e<=0))[0])?void 0:n[0])||T[0][0];return x!==l?{data:{index:b+1,overflows:A},reset:{placement:x}}:{}}}),e5({padding:8})]:(n=this.constructor.COMPASS_TO_PLACEMENT[this.positionValue]||this.positionValue,i=[e8(8),(void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r,i,n,s,o;let a,l,c,{placement:h,middlewareData:u,rects:d,initialPlacement:m,platform:g,elements:p}=e,{mainAxis:f=!0,crossAxis:b=!0,fallbackPlacements:v,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:E=!0,...A}=ea(t,e);if(null!=(r=u.arrow)&&r.alignmentOffset)return{};let O=el(h),T=ed(m),x=el(m)===m,k=await (null==g.isRTL?void 0:g.isRTL(p.floating)),M=v||(x||!E?[ey(m)]:(a=ey(m),[eg(m),a,eg(a)])),C="none"!==w;!v&&C&&M.push(...(l=ec(m),c=function(e,t,r){switch(e){case"top":case"bottom":if(r)return t?ef:ep;return t?ep:ef;case"left":case"right":return t?eb:ev;default:return[]}}(el(m),"start"===w,k),l&&(c=c.map(e=>e+"-"+l),E&&(c=c.concat(c.map(eg)))),c));let F=[m,...M],S=await g.detectOverflow(e,A),L=[],N=(null==(i=u.flip)?void 0:i.overflows)||[];if(f&&L.push(S[O]),b){let e=em(h,d,k);L.push(S[e[0]],S[e[1]])}if(N=[...N,{placement:h,overflows:L}],!L.every(e=>e<=0)){let e=((null==(n=u.flip)?void 0:n.index)||0)+1,t=F[e];if(t&&("alignment"!==b||T===ed(t)||N.every(e=>ed(e.placement)!==T||e.overflows[0]>0)))return{data:{index:e,overflows:N},reset:{placement:t}};let r=null==(s=N.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:s.placement;if(!r)switch(y){case"bestFit":{let e=null==(o=N.filter(e=>{if(C){let t=ed(e.placement);return t===T||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:o[0];e&&(r=e);break}case"initialPlacement":r=m}if(h!==r)return{reset:{placement:r}}}return{}}}),e5({padding:8})]);try{let e,t,a,l=await (r={placement:n,middleware:i},e=new Map,t=null!=r?r:{},a={...e2,...t.platform,_c:e},(async(e,t,r)=>{let{placement:i="bottom",strategy:n="absolute",middleware:s=[],platform:o}=r,a=o.detectOverflow?o:{...o,detectOverflow:eA},l=await (null==o.isRTL?void 0:o.isRTL(t)),c=await o.getElementRects({reference:e,floating:t,strategy:n}),{x:h,y:u}=eE(c,i,l),d=i,m=0,g={};for(let r=0;r<s.length;r++){let p=s[r];if(!p)continue;let{name:f,fn:b}=p,{x:v,y:y,data:w,reset:E}=await b({x:h,y:u,initialPlacement:i,placement:d,strategy:n,middlewareData:g,rects:c,platform:a,elements:{reference:e,floating:t}});h=null!=v?v:h,u=null!=y?y:u,g[f]={...g[f],...w},E&&m<50&&(m++,"object"==typeof E&&(E.placement&&(d=E.placement),E.rects&&(c=!0===E.rects?await o.getElementRects({reference:e,floating:t,strategy:n}):E.rects),{x:h,y:u}=eE(c,d,l)),r=-1)}return{x:h,y:u,placement:d,strategy:n,middlewareData:g}})(s,o,{...t,platform:a}));return{x:l.x,y:l.y,placement:l.placement||n||"bottom"}}catch(e){return console.warn("Failed to compute position:",e),{x:0,y:0,placement:"bottom"}}}async updatePosition(){let{x:e,y:t,placement:r}=await this.calculatePosition();this.hasContentTarget&&(Object.assign(this.contentTarget.style,{left:`${e}px`,top:`${t}px`}),this.contentTarget.dataset.placement=r)}setupPositioning(){window.addEventListener("scroll",this.boundUpdatePosition,!0),window.addEventListener("resize",this.boundUpdatePosition)}teardownPositioning(){window.removeEventListener("scroll",this.boundUpdatePosition,!0),window.removeEventListener("resize",this.boundUpdatePosition)}positionValueChanged(){"open"===this.element.getAttribute("data-state")&&this.updatePosition()}setupHoverTrigger(){this.boundCancelHide=()=>{this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)},this.boundDelayedShow=()=>{this.cancelShowTimeout(),0===this.showDelayValue?this.show():this.showTimeout=setTimeout(()=>this.show(),this.showDelayValue)},this.boundCancelShow=()=>{this.cancelShowTimeout()},this.hasTriggerTarget&&(this.triggerTarget.addEventListener("mouseenter",this.boundDelayedShow),this.triggerTarget.addEventListener("mouseleave",this.boundDelayedHide),this.triggerTarget.addEventListener("mouseleave",this.boundCancelShow)),this.hasContentTarget&&(this.contentTarget.addEventListener("mouseenter",this.boundCancelHide),this.contentTarget.addEventListener("mouseleave",this.boundDelayedHide))}cancelShowTimeout(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null)}setupClickTrigger(){this.hasTriggerTarget&&this.triggerTarget.addEventListener("click",this.handleClick.bind(this))}teardownTrigger(){this.hasTriggerTarget&&(this.triggerTarget.removeEventListener("mouseenter",this.boundDelayedShow),this.triggerTarget.removeEventListener("mouseleave",this.boundDelayedHide),this.triggerTarget.removeEventListener("mouseleave",this.boundCancelShow),this.triggerTarget.removeEventListener("click",this.handleClick.bind(this))),this.hasContentTarget&&(this.contentTarget.removeEventListener("mouseenter",this.boundCancelHide),this.contentTarget.removeEventListener("mouseleave",this.boundDelayedHide))}handleClick(e){!this.hasContentTarget||this.triggerTarget.closest('[data-disabled="true"]')||this.triggerTarget.querySelector('[data-disabled="true"], [disabled], [aria-disabled="true"]')||(e.preventDefault(),this.toggle())}async handleToggle(e){let t=e.newState;if(this.element.setAttribute("data-state",t),"open"===t){this.contentTarget.removeAttribute("data-positioned");let{x:e,y:t,placement:r}=await this.calculatePosition();this.contentTarget.style.left=`${e}px`,this.contentTarget.style.top=`${t}px`,this.contentTarget.dataset.placement=r,this.contentTarget.setAttribute("data-positioned","true"),this.setupPositioning(),requestAnimationFrame(()=>{let e=this.contentTarget.querySelector('[role="menuitem"]:not([aria-disabled="true"])');e&&e.focus()})}else this.teardownPositioning();this.element.dispatchEvent(new CustomEvent("open"===t?"orbital:popover:shown":"orbital:popover:hidden",{bubbles:!0,detail:{popover:this.contentTarget}}))}}),t.register("orbital-menu",class extends ee{static targets=["item"];connect(){this.currentIndex=-1}handleKeydown(e){let t=this.getEnabledItems();if(0!==t.length)switch(e.key){case"ArrowDown":e.preventDefault(),this.focusNext(t);break;case"ArrowUp":e.preventDefault(),this.focusPrevious(t);break;case"Home":e.preventDefault(),this.focusFirst(t);break;case"End":e.preventDefault(),this.focusLast(t);break;case"ArrowRight":e.target.hasAttribute("aria-haspopup")&&(e.preventDefault(),this.activateItem(e.target));break;case"Enter":case" ":e.preventDefault(),this.activateItem(e.target);break;case"Escape":e.preventDefault(),this.closeMenu();break;default:1===e.key.length&&/^[a-z0-9]$/i.test(e.key)&&this.focusItemStartingWith(t,e.key)}}getEnabledItems(){let e=[];for(let t of this.element.children)if("menuitem"!==t.getAttribute("role")||t.hasAttribute("data-disabled")||"true"===t.getAttribute("aria-disabled")){if(t.classList.contains("Orbital-Menu-Sub")){let r=t.querySelector(":scope > .Orbital-Menu-Sub-Trigger");r&&e.push(r)}}else e.push(t);return e}focusNext(e){let t=e.indexOf(document.activeElement);this.currentIndex=t<e.length-1?t+1:0,this.updateFocus(e)}focusPrevious(e){let t=e.indexOf(document.activeElement);this.currentIndex=t>0?t-1:e.length-1,this.updateFocus(e)}focusFirst(e){this.currentIndex=0,this.updateFocus(e)}focusLast(e){this.currentIndex=e.length-1,this.updateFocus(e)}updateFocus(e=null){let t=e||this.getEnabledItems();0!==t.length&&(this.currentIndex=Math.max(0,Math.min(this.currentIndex,t.length-1)),t.forEach((e,t)=>{t===this.currentIndex?(e.setAttribute("tabindex","0"),e.focus()):e.setAttribute("tabindex","-1")}))}activateItem(e){if(e.hasAttribute("aria-haspopup")){let t=this.application.getControllerForElementAndIdentifier(e.closest('[data-controller*="orbital-menu-sub"]'),"orbital-menu-sub");t&&t.toggle()}else e.click()}focusItemStartingWith(e,t){let r=t.toLowerCase(),i=(this.currentIndex+1)%e.length;for(let t=0;t<e.length;t++){let n=(i+t)%e.length;if(e[n].textContent.trim().toLowerCase().startsWith(r)){this.currentIndex=n,this.updateFocus(e);return}}}closeMenu(){let e=this.element.closest("[popover]");e&&e.hidePopover();let t=this.element.closest(".Orbital-Menu-Sub");if(t){let e=this.application.getControllerForElementAndIdentifier(t,"orbital-menu-sub");e&&e.close()}}}),t.register("orbital-menu-sub",class extends ee{static targets=["trigger","content"];connect(){this._onClickOutside=e=>{"open"!==this.element.getAttribute("data-state")||this.element.contains(e.target)||this.close(!1)}}disconnect(){document.removeEventListener("click",this._onClickOutside)}toggle(){"open"===this.element.getAttribute("data-state")?this.close():this.open()}open(){this.element.setAttribute("data-state","open"),this.triggerTarget.setAttribute("aria-expanded","true"),document.addEventListener("click",this._onClickOutside),requestAnimationFrame(()=>{let e=this.contentTarget.querySelector('[role="menuitem"]');e&&e.focus()})}close(e=!0){this.element.setAttribute("data-state","closed"),this.triggerTarget.setAttribute("aria-expanded","false"),document.removeEventListener("click",this._onClickOutside),e&&this.triggerTarget.focus()}handleKeydown(e){let t=[...this.contentTarget.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')];if(!t.length)return;let r=t.indexOf(document.activeElement);switch(e.key){case"ArrowDown":e.preventDefault(),e.stopPropagation(),t[r<t.length-1?r+1:0].focus();break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),t[r>0?r-1:t.length-1].focus();break;case"ArrowLeft":case"Escape":e.preventDefault(),e.stopPropagation(),this.close();break;case"Enter":case" ":e.stopPropagation()}}}),t.register("orbital-select",class extends ee{static targets=["input","label"];static values={selected:String};connect(){this.updateMenuStates(this.selectedValue)}handleItemClick(e){e.preventDefault();let t=e.currentTarget;if("true"===t.dataset.disabled||"true"===t.getAttribute("aria-disabled"))return;let r=t.dataset.value,i=t.dataset.label;this.selectOption(r,i),this.closeDropdown()}selectOption(e,t){this.hasInputTarget&&(this.inputTarget.value=e),this.hasLabelTarget&&(this.labelTarget.textContent=t,this.labelTarget.classList.remove("Orbital-Select-Placeholder"),this.labelTarget.classList.add("Orbital-Select-Label")),this.selectedValue=e,this.updateMenuStates(e),this.element.dispatchEvent(new CustomEvent("orbital:select:changed",{bubbles:!0,detail:{value:e,label:t}})),this.hasInputTarget&&this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0}))}updateMenuStates(e){this.element.querySelectorAll(".Orbital-Menu-Item").forEach(t=>{t.dataset.value===e?(t.setAttribute("data-selected","true"),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.setAttribute("aria-selected","false"))})}closeDropdown(){let e=this.element.querySelector('[data-controller="orbital-popover"]');if(!e)return;let t=this.application.getControllerForElementAndIdentifier(e,"orbital-popover");t&&t.hide()}selectedValueChanged(){this.updateMenuStates(this.selectedValue)}}),document.addEventListener("click",e=>{let r=e.target.closest("[data-open-modal], [data-open-dialog]");if(!r)return;e.preventDefault();let i=r.dataset.openModal||r.dataset.openDialog,n=document.getElementById(i);if(!n)return;let s=t.getControllerForElementAndIdentifier(n,"orbital-modal");s&&s.show()})}();
|
|
6
|
+
//# sourceMappingURL=index.js.map
|