@webqit/webflo 0.11.61 → 0.20.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.github/workflows/publish.yml +48 -0
  3. package/.gitignore +2 -0
  4. package/LICENSE +2 -2
  5. package/README.md +71 -2050
  6. package/package.json +28 -13
  7. package/site/-/_.md +139 -0
  8. package/site/-/docs.old.md +2010 -0
  9. package/site/.vitepress/cache/deps/@braintree_sanitize-url 2.js +93 -0
  10. package/site/.vitepress/cache/deps/@braintree_sanitize-url.js +93 -0
  11. package/site/.vitepress/cache/deps/@braintree_sanitize-url.js 2.map +7 -0
  12. package/site/.vitepress/cache/deps/@braintree_sanitize-url.js.map +7 -0
  13. package/site/.vitepress/cache/deps/_metadata 2.json +85 -0
  14. package/site/.vitepress/cache/deps/_metadata.json +85 -0
  15. package/site/.vitepress/cache/deps/chunk-BUSYA2B4 2.js +9 -0
  16. package/site/.vitepress/cache/deps/chunk-BUSYA2B4.js +9 -0
  17. package/site/.vitepress/cache/deps/chunk-BUSYA2B4.js 2.map +7 -0
  18. package/site/.vitepress/cache/deps/chunk-BUSYA2B4.js.map +7 -0
  19. package/site/.vitepress/cache/deps/chunk-Q2AYPHVK 2.js +9719 -0
  20. package/site/.vitepress/cache/deps/chunk-Q2AYPHVK.js +9719 -0
  21. package/site/.vitepress/cache/deps/chunk-Q2AYPHVK.js 2.map +7 -0
  22. package/site/.vitepress/cache/deps/chunk-Q2AYPHVK.js.map +7 -0
  23. package/site/.vitepress/cache/deps/chunk-QAXAIFA7 2.js +12705 -0
  24. package/site/.vitepress/cache/deps/chunk-QAXAIFA7.js +12705 -0
  25. package/site/.vitepress/cache/deps/chunk-QAXAIFA7.js 2.map +7 -0
  26. package/site/.vitepress/cache/deps/chunk-QAXAIFA7.js.map +7 -0
  27. package/site/.vitepress/cache/deps/cytoscape 2.js +30278 -0
  28. package/site/.vitepress/cache/deps/cytoscape-cose-bilkent 2.js +4710 -0
  29. package/site/.vitepress/cache/deps/cytoscape-cose-bilkent.js +4710 -0
  30. package/site/.vitepress/cache/deps/cytoscape-cose-bilkent.js 2.map +7 -0
  31. package/site/.vitepress/cache/deps/cytoscape-cose-bilkent.js.map +7 -0
  32. package/site/.vitepress/cache/deps/cytoscape.js +30278 -0
  33. package/site/.vitepress/cache/deps/cytoscape.js 2.map +7 -0
  34. package/site/.vitepress/cache/deps/cytoscape.js.map +7 -0
  35. package/site/.vitepress/cache/deps/dayjs 2.js +285 -0
  36. package/site/.vitepress/cache/deps/dayjs.js +285 -0
  37. package/site/.vitepress/cache/deps/dayjs.js 2.map +7 -0
  38. package/site/.vitepress/cache/deps/dayjs.js.map +7 -0
  39. package/site/.vitepress/cache/deps/debug 2.js +453 -0
  40. package/site/.vitepress/cache/deps/debug.js +453 -0
  41. package/site/.vitepress/cache/deps/debug.js 2.map +7 -0
  42. package/site/.vitepress/cache/deps/debug.js.map +7 -0
  43. package/site/.vitepress/cache/deps/package 2.json +3 -0
  44. package/site/.vitepress/cache/deps/package.json +3 -0
  45. package/site/.vitepress/cache/deps/vitepress___@vue_devtools-api 2.js +4507 -0
  46. package/site/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4507 -0
  47. package/site/.vitepress/cache/deps/vitepress___@vue_devtools-api.js 2.map +7 -0
  48. package/site/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  49. package/site/.vitepress/cache/deps/vitepress___@vueuse_core 2.js +584 -0
  50. package/site/.vitepress/cache/deps/vitepress___@vueuse_core.js +584 -0
  51. package/site/.vitepress/cache/deps/vitepress___@vueuse_core.js 2.map +7 -0
  52. package/site/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  53. package/site/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap 2.js +1166 -0
  54. package/site/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1166 -0
  55. package/site/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js 2.map +7 -0
  56. package/site/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
  57. package/site/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js 2.js +1667 -0
  58. package/site/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1667 -0
  59. package/site/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js 2.map +7 -0
  60. package/site/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
  61. package/site/.vitepress/cache/deps/vitepress___minisearch 2.js +1815 -0
  62. package/site/.vitepress/cache/deps/vitepress___minisearch.js +1815 -0
  63. package/site/.vitepress/cache/deps/vitepress___minisearch.js 2.map +7 -0
  64. package/site/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
  65. package/site/.vitepress/cache/deps/vue 2.js +344 -0
  66. package/site/.vitepress/cache/deps/vue.js +344 -0
  67. package/site/.vitepress/cache/deps/vue.js 2.map +7 -0
  68. package/site/.vitepress/cache/deps/vue.js.map +7 -0
  69. package/site/.vitepress/config.ts +147 -0
  70. package/site/.vitepress/theme/custom.css +50 -0
  71. package/site/.vitepress/theme/index.ts +6 -0
  72. package/site/api/webflo-fetch/FormData.md +0 -0
  73. package/site/api/webflo-fetch/Headers.md +0 -0
  74. package/site/api/webflo-fetch/LiveResponse.md +0 -0
  75. package/site/api/webflo-fetch/Request.md +0 -0
  76. package/site/api/webflo-fetch/Response.md +0 -0
  77. package/site/api/webflo-fetch/fetch.md +0 -0
  78. package/site/api/webflo-routing/HttpCookies.md +0 -0
  79. package/site/api/webflo-routing/HttpEvent/respondWith.md +1 -0
  80. package/site/api/webflo-routing/HttpEvent/waitUntil.md +1 -0
  81. package/site/api/webflo-routing/HttpEvent/waitUntilNavigate.md +1 -0
  82. package/site/api/webflo-routing/HttpEvent.md +30 -0
  83. package/site/api/webflo-routing/HttpSession.md +0 -0
  84. package/site/api/webflo-routing/HttpState.md +0 -0
  85. package/site/api/webflo-routing/HttpUser.md +0 -0
  86. package/site/api/webflo-routing/handler/fetch.md +42 -0
  87. package/site/api/webflo-routing/handler/next.md +54 -0
  88. package/site/api/webflo-routing/handler.md +119 -0
  89. package/site/api.md +26 -0
  90. package/site/contributing.md +16 -0
  91. package/site/docs/advanced/lifecycles.md +20 -0
  92. package/site/docs/advanced/redirects.md +0 -0
  93. package/site/docs/advanced/routing.md +1 -0
  94. package/site/docs/advanced.md +9 -0
  95. package/site/docs/concepts/realtime.md +637 -0
  96. package/site/docs/concepts/rendering.md +60 -0
  97. package/site/docs/concepts/request-response.md +47 -0
  98. package/site/docs/concepts/routing.md +656 -0
  99. package/site/docs/concepts/state.md +44 -0
  100. package/site/docs/concepts/templates.md +48 -0
  101. package/site/docs/concepts.md +97 -0
  102. package/site/docs/getting-started.md +378 -0
  103. package/site/docs/tech-stack.md +56 -0
  104. package/site/docs.md +100 -0
  105. package/site/examples/pwa.md +10 -0
  106. package/site/examples/web.md +11 -0
  107. package/site/examples.md +10 -0
  108. package/site/faq.md +13 -0
  109. package/site/guides/guide-auth.md +13 -0
  110. package/site/guides/guide-file-upload.md +11 -0
  111. package/site/guides/guide-service-worker.md +10 -0
  112. package/site/guides/tutorial-1-todo.md +24 -0
  113. package/site/guides.md +15 -0
  114. package/site/index.md +39 -0
  115. package/site/public/img/brand/logo-670x670.png +0 -0
  116. package/site/recipes/realtime.md +11 -0
  117. package/site/recipes/streaming.md +15 -0
  118. package/site/reference/cli.md +11 -0
  119. package/site/reference/config.md +13 -0
  120. package/site/reference/tools.md +9 -0
  121. package/src/Context.js +3 -11
  122. package/src/config-pi/deployment/Env.js +6 -19
  123. package/src/config-pi/deployment/Layout.js +11 -3
  124. package/src/config-pi/runtime/Client.js +40 -48
  125. package/src/config-pi/runtime/Server.js +52 -20
  126. package/src/config-pi/runtime/client/Worker.js +22 -20
  127. package/src/config-pi/static/Init.js +57 -0
  128. package/src/config-pi/static/index.js +2 -0
  129. package/src/deployment-pi/origins/index.js +1 -1
  130. package/src/deployment-pi/util.js +161 -0
  131. package/src/index.js +3 -9
  132. package/src/init-pi/index.js +117 -0
  133. package/src/init-pi/templates/pwa/app/handler.server.js +8 -0
  134. package/src/init-pi/templates/pwa/app/page.html +7 -0
  135. package/src/init-pi/templates/pwa/package.json +19 -0
  136. package/src/init-pi/templates/pwa/public/assets/app.css +16 -0
  137. package/src/init-pi/templates/pwa/public/index.html +39 -0
  138. package/src/init-pi/templates/pwa/public/manifest.json +29 -0
  139. package/src/init-pi/templates/web/app/handler.server.js +8 -0
  140. package/src/init-pi/templates/web/app/page.html +7 -0
  141. package/src/init-pi/templates/web/package.json +19 -0
  142. package/src/init-pi/templates/web/public/assets/app.css +16 -0
  143. package/src/init-pi/templates/web/public/index.html +39 -0
  144. package/src/runtime-pi/WebfloRuntime.js +350 -0
  145. package/src/runtime-pi/index.js +3 -10
  146. package/src/runtime-pi/webflo-client/ClientSideCookies.js +17 -0
  147. package/src/runtime-pi/webflo-client/ClientSideWorkport.js +63 -0
  148. package/src/runtime-pi/webflo-client/DeviceCapabilities.js +213 -0
  149. package/src/runtime-pi/webflo-client/WebfloClient.js +500 -0
  150. package/src/runtime-pi/webflo-client/WebfloRootClient1.js +206 -0
  151. package/src/runtime-pi/webflo-client/WebfloRootClient2.js +113 -0
  152. package/src/runtime-pi/webflo-client/WebfloSubClient.js +118 -0
  153. package/src/runtime-pi/webflo-client/index.js +17 -0
  154. package/src/runtime-pi/webflo-client/webflo-codegen.js +469 -0
  155. package/src/runtime-pi/webflo-client/webflo-devmode.js +243 -0
  156. package/src/runtime-pi/webflo-client/webflo-embedded.js +50 -0
  157. package/src/runtime-pi/webflo-fetch/LiveResponse.js +437 -0
  158. package/src/runtime-pi/webflo-fetch/cookies.js +10 -0
  159. package/src/runtime-pi/webflo-fetch/fetch.js +16 -0
  160. package/src/runtime-pi/webflo-fetch/formdata.js +54 -0
  161. package/src/runtime-pi/webflo-fetch/headers.js +151 -0
  162. package/src/runtime-pi/webflo-fetch/index.js +5 -0
  163. package/src/runtime-pi/webflo-fetch/message.js +49 -0
  164. package/src/runtime-pi/webflo-fetch/request.js +62 -0
  165. package/src/runtime-pi/webflo-fetch/response.js +110 -0
  166. package/src/runtime-pi/webflo-fetch/util.js +28 -0
  167. package/src/runtime-pi/webflo-messaging/WQBroadcastChannel.js +10 -0
  168. package/src/runtime-pi/webflo-messaging/WQMessageChannel.js +26 -0
  169. package/src/runtime-pi/webflo-messaging/WQMessageEvent.js +87 -0
  170. package/src/runtime-pi/webflo-messaging/WQMessagePort.js +38 -0
  171. package/src/runtime-pi/webflo-messaging/WQRelayPort.js +47 -0
  172. package/src/runtime-pi/webflo-messaging/WQSockPort.js +113 -0
  173. package/src/runtime-pi/webflo-messaging/WQStarPort.js +104 -0
  174. package/src/runtime-pi/webflo-messaging/wq-message-port.js +404 -0
  175. package/src/runtime-pi/webflo-routing/HttpCookies.js +42 -0
  176. package/src/runtime-pi/webflo-routing/HttpEvent.js +112 -0
  177. package/src/runtime-pi/webflo-routing/HttpSession.js +11 -0
  178. package/src/runtime-pi/webflo-routing/HttpState.js +153 -0
  179. package/src/runtime-pi/webflo-routing/HttpUser.js +54 -0
  180. package/src/runtime-pi/webflo-routing/WebfloRouter.js +245 -0
  181. package/src/runtime-pi/webflo-server/ServerSideCookies.js +19 -0
  182. package/src/runtime-pi/webflo-server/ServerSideSession.js +38 -0
  183. package/src/runtime-pi/webflo-server/WebfloServer.js +937 -0
  184. package/src/runtime-pi/webflo-server/index.js +11 -0
  185. package/src/runtime-pi/webflo-server/messaging/Client.js +27 -0
  186. package/src/runtime-pi/webflo-server/messaging/ClientRequestRealtime.js +50 -0
  187. package/src/runtime-pi/webflo-server/messaging/Clients.js +25 -0
  188. package/src/runtime-pi/webflo-server/webflo-devmode.js +326 -0
  189. package/src/runtime-pi/{client → webflo-url}/Url.js +27 -76
  190. package/src/runtime-pi/webflo-url/index.js +1 -0
  191. package/src/runtime-pi/webflo-url/urlpattern.js +38 -0
  192. package/src/runtime-pi/{util-url.js → webflo-url/util.js} +5 -43
  193. package/src/runtime-pi/webflo-url/xURL.js +94 -0
  194. package/src/runtime-pi/webflo-worker/WebfloWorker.js +234 -0
  195. package/src/runtime-pi/webflo-worker/WorkerSideCookies.js +19 -0
  196. package/src/runtime-pi/webflo-worker/WorkerSideWorkport.js +18 -0
  197. package/src/runtime-pi/webflo-worker/index.js +11 -0
  198. package/src/services-pi/index.js +2 -0
  199. package/src/services-pi/push/index.js +23 -0
  200. package/src/util.js +10 -0
  201. package/src/{webflo.js → webflo-cli.js} +4 -4
  202. package/src/runtime-pi/Application.js +0 -29
  203. package/src/runtime-pi/Cookies.js +0 -82
  204. package/src/runtime-pi/HttpEvent.js +0 -107
  205. package/src/runtime-pi/Router.js +0 -130
  206. package/src/runtime-pi/Runtime.js +0 -21
  207. package/src/runtime-pi/client/Application.js +0 -76
  208. package/src/runtime-pi/client/Context.js +0 -7
  209. package/src/runtime-pi/client/Router.js +0 -48
  210. package/src/runtime-pi/client/Runtime.js +0 -525
  211. package/src/runtime-pi/client/Workport.js +0 -190
  212. package/src/runtime-pi/client/createStorage.js +0 -58
  213. package/src/runtime-pi/client/generate.js +0 -481
  214. package/src/runtime-pi/client/index.js +0 -21
  215. package/src/runtime-pi/client/worker/Application.js +0 -44
  216. package/src/runtime-pi/client/worker/Context.js +0 -7
  217. package/src/runtime-pi/client/worker/Runtime.js +0 -275
  218. package/src/runtime-pi/client/worker/Workport.js +0 -78
  219. package/src/runtime-pi/client/worker/index.js +0 -21
  220. package/src/runtime-pi/server/Application.js +0 -101
  221. package/src/runtime-pi/server/Context.js +0 -16
  222. package/src/runtime-pi/server/Router.js +0 -159
  223. package/src/runtime-pi/server/Runtime.js +0 -558
  224. package/src/runtime-pi/server/index.js +0 -21
  225. package/src/runtime-pi/util-http.js +0 -86
  226. package/src/runtime-pi/xFormData.js +0 -24
  227. package/src/runtime-pi/xHeaders.js +0 -146
  228. package/src/runtime-pi/xRequest.js +0 -46
  229. package/src/runtime-pi/xRequestHeaders.js +0 -109
  230. package/src/runtime-pi/xResponse.js +0 -33
  231. package/src/runtime-pi/xResponseHeaders.js +0 -117
  232. package/src/runtime-pi/xURL.js +0 -105
  233. package/src/runtime-pi/xfetch.js +0 -23
  234. package/src/runtime-pi/xxHttpMessage.js +0 -102
  235. package/src/static-pi/index.js +0 -11
@@ -0,0 +1,1166 @@
1
+ import {
2
+ notNullish,
3
+ toArray,
4
+ tryOnScopeDispose,
5
+ unrefElement
6
+ } from "./chunk-Q2AYPHVK.js";
7
+ import {
8
+ computed,
9
+ shallowRef,
10
+ toValue,
11
+ watch
12
+ } from "./chunk-QAXAIFA7.js";
13
+ import "./chunk-BUSYA2B4.js";
14
+
15
+ // node_modules/tabbable/dist/index.esm.js
16
+ var candidateSelectors = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"];
17
+ var candidateSelector = candidateSelectors.join(",");
18
+ var NoElement = typeof Element === "undefined";
19
+ var matches = NoElement ? function() {
20
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
21
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
22
+ var _element$getRootNode;
23
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
24
+ } : function(element) {
25
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
26
+ };
27
+ var _isInert = function isInert(node, lookUp) {
28
+ var _node$getAttribute;
29
+ if (lookUp === void 0) {
30
+ lookUp = true;
31
+ }
32
+ var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
33
+ var inert = inertAtt === "" || inertAtt === "true";
34
+ var result = inert || lookUp && node && _isInert(node.parentNode);
35
+ return result;
36
+ };
37
+ var isContentEditable = function isContentEditable2(node) {
38
+ var _node$getAttribute2;
39
+ var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
40
+ return attValue === "" || attValue === "true";
41
+ };
42
+ var getCandidates = function getCandidates2(el, includeContainer, filter) {
43
+ if (_isInert(el)) {
44
+ return [];
45
+ }
46
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
47
+ if (includeContainer && matches.call(el, candidateSelector)) {
48
+ candidates.unshift(el);
49
+ }
50
+ candidates = candidates.filter(filter);
51
+ return candidates;
52
+ };
53
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
54
+ var candidates = [];
55
+ var elementsToCheck = Array.from(elements);
56
+ while (elementsToCheck.length) {
57
+ var element = elementsToCheck.shift();
58
+ if (_isInert(element, false)) {
59
+ continue;
60
+ }
61
+ if (element.tagName === "SLOT") {
62
+ var assigned = element.assignedElements();
63
+ var content = assigned.length ? assigned : element.children;
64
+ var nestedCandidates = _getCandidatesIteratively(content, true, options);
65
+ if (options.flatten) {
66
+ candidates.push.apply(candidates, nestedCandidates);
67
+ } else {
68
+ candidates.push({
69
+ scopeParent: element,
70
+ candidates: nestedCandidates
71
+ });
72
+ }
73
+ } else {
74
+ var validCandidate = matches.call(element, candidateSelector);
75
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
76
+ candidates.push(element);
77
+ }
78
+ var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
79
+ typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
80
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
81
+ if (shadowRoot && validShadowRoot) {
82
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
83
+ if (options.flatten) {
84
+ candidates.push.apply(candidates, _nestedCandidates);
85
+ } else {
86
+ candidates.push({
87
+ scopeParent: element,
88
+ candidates: _nestedCandidates
89
+ });
90
+ }
91
+ } else {
92
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
93
+ }
94
+ }
95
+ }
96
+ return candidates;
97
+ };
98
+ var hasTabIndex = function hasTabIndex2(node) {
99
+ return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
100
+ };
101
+ var getTabIndex = function getTabIndex2(node) {
102
+ if (!node) {
103
+ throw new Error("No node provided");
104
+ }
105
+ if (node.tabIndex < 0) {
106
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
107
+ return 0;
108
+ }
109
+ }
110
+ return node.tabIndex;
111
+ };
112
+ var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
113
+ var tabIndex = getTabIndex(node);
114
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
115
+ return 0;
116
+ }
117
+ return tabIndex;
118
+ };
119
+ var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
120
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
121
+ };
122
+ var isInput = function isInput2(node) {
123
+ return node.tagName === "INPUT";
124
+ };
125
+ var isHiddenInput = function isHiddenInput2(node) {
126
+ return isInput(node) && node.type === "hidden";
127
+ };
128
+ var isDetailsWithSummary = function isDetailsWithSummary2(node) {
129
+ var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
130
+ return child.tagName === "SUMMARY";
131
+ });
132
+ return r;
133
+ };
134
+ var getCheckedRadio = function getCheckedRadio2(nodes, form) {
135
+ for (var i = 0; i < nodes.length; i++) {
136
+ if (nodes[i].checked && nodes[i].form === form) {
137
+ return nodes[i];
138
+ }
139
+ }
140
+ };
141
+ var isTabbableRadio = function isTabbableRadio2(node) {
142
+ if (!node.name) {
143
+ return true;
144
+ }
145
+ var radioScope = node.form || getRootNode(node);
146
+ var queryRadios = function queryRadios2(name) {
147
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
148
+ };
149
+ var radioSet;
150
+ if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
151
+ radioSet = queryRadios(window.CSS.escape(node.name));
152
+ } else {
153
+ try {
154
+ radioSet = queryRadios(node.name);
155
+ } catch (err) {
156
+ console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
157
+ return false;
158
+ }
159
+ }
160
+ var checked = getCheckedRadio(radioSet, node.form);
161
+ return !checked || checked === node;
162
+ };
163
+ var isRadio = function isRadio2(node) {
164
+ return isInput(node) && node.type === "radio";
165
+ };
166
+ var isNonTabbableRadio = function isNonTabbableRadio2(node) {
167
+ return isRadio(node) && !isTabbableRadio(node);
168
+ };
169
+ var isNodeAttached = function isNodeAttached2(node) {
170
+ var _nodeRoot;
171
+ var nodeRoot = node && getRootNode(node);
172
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
173
+ var attached = false;
174
+ if (nodeRoot && nodeRoot !== node) {
175
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
176
+ attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
177
+ while (!attached && nodeRootHost) {
178
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
179
+ nodeRoot = getRootNode(nodeRootHost);
180
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
181
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
182
+ }
183
+ }
184
+ return attached;
185
+ };
186
+ var isZeroArea = function isZeroArea2(node) {
187
+ var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
188
+ return width === 0 && height === 0;
189
+ };
190
+ var isHidden = function isHidden2(node, _ref) {
191
+ var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
192
+ if (displayCheck === "full-native") {
193
+ if ("checkVisibility" in node) {
194
+ var visible = node.checkVisibility({
195
+ // Checking opacity might be desirable for some use cases, but natively,
196
+ // opacity zero elements _are_ focusable and tabbable.
197
+ checkOpacity: false,
198
+ opacityProperty: false,
199
+ contentVisibilityAuto: true,
200
+ visibilityProperty: true,
201
+ // This is an alias for `visibilityProperty`. Contemporary browsers
202
+ // support both. However, this alias has wider browser support (Chrome
203
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
204
+ // we include it anyway.
205
+ checkVisibilityCSS: true
206
+ });
207
+ return !visible;
208
+ }
209
+ }
210
+ if (getComputedStyle(node).visibility === "hidden") {
211
+ return true;
212
+ }
213
+ var isDirectSummary = matches.call(node, "details>summary:first-of-type");
214
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
215
+ if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
216
+ return true;
217
+ }
218
+ if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
219
+ // Element#checkVisibility is unsupported
220
+ displayCheck === "full-native" || displayCheck === "legacy-full") {
221
+ if (typeof getShadowRoot === "function") {
222
+ var originalNode = node;
223
+ while (node) {
224
+ var parentElement = node.parentElement;
225
+ var rootNode = getRootNode(node);
226
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
227
+ return isZeroArea(node);
228
+ } else if (node.assignedSlot) {
229
+ node = node.assignedSlot;
230
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
231
+ node = rootNode.host;
232
+ } else {
233
+ node = parentElement;
234
+ }
235
+ }
236
+ node = originalNode;
237
+ }
238
+ if (isNodeAttached(node)) {
239
+ return !node.getClientRects().length;
240
+ }
241
+ if (displayCheck !== "legacy-full") {
242
+ return true;
243
+ }
244
+ } else if (displayCheck === "non-zero-area") {
245
+ return isZeroArea(node);
246
+ }
247
+ return false;
248
+ };
249
+ var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
250
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
251
+ var parentNode = node.parentElement;
252
+ while (parentNode) {
253
+ if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
254
+ for (var i = 0; i < parentNode.children.length; i++) {
255
+ var child = parentNode.children.item(i);
256
+ if (child.tagName === "LEGEND") {
257
+ return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
258
+ }
259
+ }
260
+ return true;
261
+ }
262
+ parentNode = parentNode.parentElement;
263
+ }
264
+ }
265
+ return false;
266
+ };
267
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
268
+ if (node.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
269
+ // because we're limited in the type of selectors we can use in JSDom (see related
270
+ // note related to `candidateSelectors`)
271
+ _isInert(node) || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
272
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
273
+ return false;
274
+ }
275
+ return true;
276
+ };
277
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
278
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
279
+ return false;
280
+ }
281
+ return true;
282
+ };
283
+ var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
284
+ var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
285
+ if (isNaN(tabIndex) || tabIndex >= 0) {
286
+ return true;
287
+ }
288
+ return false;
289
+ };
290
+ var _sortByOrder = function sortByOrder(candidates) {
291
+ var regularTabbables = [];
292
+ var orderedTabbables = [];
293
+ candidates.forEach(function(item, i) {
294
+ var isScope = !!item.scopeParent;
295
+ var element = isScope ? item.scopeParent : item;
296
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
297
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
298
+ if (candidateTabindex === 0) {
299
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
300
+ } else {
301
+ orderedTabbables.push({
302
+ documentOrder: i,
303
+ tabIndex: candidateTabindex,
304
+ item,
305
+ isScope,
306
+ content: elements
307
+ });
308
+ }
309
+ });
310
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
311
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
312
+ return acc;
313
+ }, []).concat(regularTabbables);
314
+ };
315
+ var tabbable = function tabbable2(container, options) {
316
+ options = options || {};
317
+ var candidates;
318
+ if (options.getShadowRoot) {
319
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
320
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
321
+ flatten: false,
322
+ getShadowRoot: options.getShadowRoot,
323
+ shadowRootFilter: isShadowRootTabbable
324
+ });
325
+ } else {
326
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
327
+ }
328
+ return _sortByOrder(candidates);
329
+ };
330
+ var focusable = function focusable2(container, options) {
331
+ options = options || {};
332
+ var candidates;
333
+ if (options.getShadowRoot) {
334
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
335
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
336
+ flatten: true,
337
+ getShadowRoot: options.getShadowRoot
338
+ });
339
+ } else {
340
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
341
+ }
342
+ return candidates;
343
+ };
344
+ var isTabbable = function isTabbable2(node, options) {
345
+ options = options || {};
346
+ if (!node) {
347
+ throw new Error("No node provided");
348
+ }
349
+ if (matches.call(node, candidateSelector) === false) {
350
+ return false;
351
+ }
352
+ return isNodeMatchingSelectorTabbable(options, node);
353
+ };
354
+ var focusableCandidateSelector = candidateSelectors.concat("iframe").join(",");
355
+ var isFocusable = function isFocusable2(node, options) {
356
+ options = options || {};
357
+ if (!node) {
358
+ throw new Error("No node provided");
359
+ }
360
+ if (matches.call(node, focusableCandidateSelector) === false) {
361
+ return false;
362
+ }
363
+ return isNodeMatchingSelectorFocusable(options, node);
364
+ };
365
+
366
+ // node_modules/focus-trap/dist/focus-trap.esm.js
367
+ function _arrayLikeToArray(r, a) {
368
+ (null == a || a > r.length) && (a = r.length);
369
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
370
+ return n;
371
+ }
372
+ function _arrayWithoutHoles(r) {
373
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
374
+ }
375
+ function _defineProperty(e, r, t) {
376
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
377
+ value: t,
378
+ enumerable: true,
379
+ configurable: true,
380
+ writable: true
381
+ }) : e[r] = t, e;
382
+ }
383
+ function _iterableToArray(r) {
384
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
385
+ }
386
+ function _nonIterableSpread() {
387
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
388
+ }
389
+ function ownKeys(e, r) {
390
+ var t = Object.keys(e);
391
+ if (Object.getOwnPropertySymbols) {
392
+ var o = Object.getOwnPropertySymbols(e);
393
+ r && (o = o.filter(function(r2) {
394
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
395
+ })), t.push.apply(t, o);
396
+ }
397
+ return t;
398
+ }
399
+ function _objectSpread2(e) {
400
+ for (var r = 1; r < arguments.length; r++) {
401
+ var t = null != arguments[r] ? arguments[r] : {};
402
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
403
+ _defineProperty(e, r2, t[r2]);
404
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
405
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
406
+ });
407
+ }
408
+ return e;
409
+ }
410
+ function _toConsumableArray(r) {
411
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
412
+ }
413
+ function _toPrimitive(t, r) {
414
+ if ("object" != typeof t || !t) return t;
415
+ var e = t[Symbol.toPrimitive];
416
+ if (void 0 !== e) {
417
+ var i = e.call(t, r);
418
+ if ("object" != typeof i) return i;
419
+ throw new TypeError("@@toPrimitive must return a primitive value.");
420
+ }
421
+ return ("string" === r ? String : Number)(t);
422
+ }
423
+ function _toPropertyKey(t) {
424
+ var i = _toPrimitive(t, "string");
425
+ return "symbol" == typeof i ? i : i + "";
426
+ }
427
+ function _unsupportedIterableToArray(r, a) {
428
+ if (r) {
429
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
430
+ var t = {}.toString.call(r).slice(8, -1);
431
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
432
+ }
433
+ }
434
+ var activeFocusTraps = {
435
+ activateTrap: function activateTrap(trapStack, trap) {
436
+ if (trapStack.length > 0) {
437
+ var activeTrap = trapStack[trapStack.length - 1];
438
+ if (activeTrap !== trap) {
439
+ activeTrap._setPausedState(true);
440
+ }
441
+ }
442
+ var trapIndex = trapStack.indexOf(trap);
443
+ if (trapIndex === -1) {
444
+ trapStack.push(trap);
445
+ } else {
446
+ trapStack.splice(trapIndex, 1);
447
+ trapStack.push(trap);
448
+ }
449
+ },
450
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
451
+ var trapIndex = trapStack.indexOf(trap);
452
+ if (trapIndex !== -1) {
453
+ trapStack.splice(trapIndex, 1);
454
+ }
455
+ if (trapStack.length > 0 && !trapStack[trapStack.length - 1]._isManuallyPaused()) {
456
+ trapStack[trapStack.length - 1]._setPausedState(false);
457
+ }
458
+ }
459
+ };
460
+ var isSelectableInput = function isSelectableInput2(node) {
461
+ return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function";
462
+ };
463
+ var isEscapeEvent = function isEscapeEvent2(e) {
464
+ return (e === null || e === void 0 ? void 0 : e.key) === "Escape" || (e === null || e === void 0 ? void 0 : e.key) === "Esc" || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
465
+ };
466
+ var isTabEvent = function isTabEvent2(e) {
467
+ return (e === null || e === void 0 ? void 0 : e.key) === "Tab" || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
468
+ };
469
+ var isKeyForward = function isKeyForward2(e) {
470
+ return isTabEvent(e) && !e.shiftKey;
471
+ };
472
+ var isKeyBackward = function isKeyBackward2(e) {
473
+ return isTabEvent(e) && e.shiftKey;
474
+ };
475
+ var delay = function delay2(fn) {
476
+ return setTimeout(fn, 0);
477
+ };
478
+ var valueOrHandler = function valueOrHandler2(value) {
479
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
480
+ params[_key - 1] = arguments[_key];
481
+ }
482
+ return typeof value === "function" ? value.apply(void 0, params) : value;
483
+ };
484
+ var getActualTarget = function getActualTarget2(event) {
485
+ return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target;
486
+ };
487
+ var internalTrapStack = [];
488
+ var createFocusTrap = function createFocusTrap2(elements, userOptions) {
489
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
490
+ var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
491
+ var config = _objectSpread2({
492
+ returnFocusOnDeactivate: true,
493
+ escapeDeactivates: true,
494
+ delayInitialFocus: true,
495
+ isKeyForward,
496
+ isKeyBackward
497
+ }, userOptions);
498
+ var state = {
499
+ // containers given to createFocusTrap()
500
+ // @type {Array<HTMLElement>}
501
+ containers: [],
502
+ // list of objects identifying tabbable nodes in `containers` in the trap
503
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
504
+ // is active, but the trap should never get to a state where there isn't at least one group
505
+ // with at least one tabbable node in it (that would lead to an error condition that would
506
+ // result in an error being thrown)
507
+ // @type {Array<{
508
+ // container: HTMLElement,
509
+ // tabbableNodes: Array<HTMLElement>, // empty if none
510
+ // focusableNodes: Array<HTMLElement>, // empty if none
511
+ // posTabIndexesFound: boolean,
512
+ // firstTabbableNode: HTMLElement|undefined,
513
+ // lastTabbableNode: HTMLElement|undefined,
514
+ // firstDomTabbableNode: HTMLElement|undefined,
515
+ // lastDomTabbableNode: HTMLElement|undefined,
516
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
517
+ // }>}
518
+ containerGroups: [],
519
+ // same order/length as `containers` list
520
+ // references to objects in `containerGroups`, but only those that actually have
521
+ // tabbable nodes in them
522
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
523
+ // the same length
524
+ tabbableGroups: [],
525
+ nodeFocusedBeforeActivation: null,
526
+ mostRecentlyFocusedNode: null,
527
+ active: false,
528
+ paused: false,
529
+ manuallyPaused: false,
530
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
531
+ // has been delayed during activation
532
+ delayInitialFocusTimer: void 0,
533
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
534
+ recentNavEvent: void 0
535
+ };
536
+ var trap;
537
+ var getOption = function getOption2(configOverrideOptions, optionName, configOptionName) {
538
+ return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName];
539
+ };
540
+ var findContainerIndex = function findContainerIndex2(element, event) {
541
+ var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === "function" ? event.composedPath() : void 0;
542
+ return state.containerGroups.findIndex(function(_ref) {
543
+ var container = _ref.container, tabbableNodes = _ref.tabbableNodes;
544
+ return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
545
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
546
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
547
+ // look inside web components even if open)
548
+ (composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function(node) {
549
+ return node === element;
550
+ });
551
+ });
552
+ };
553
+ var getNodeForOption = function getNodeForOption2(optionName) {
554
+ var _ref2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref2$hasFallback = _ref2.hasFallback, hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback, _ref2$params = _ref2.params, params = _ref2$params === void 0 ? [] : _ref2$params;
555
+ var optionValue = config[optionName];
556
+ if (typeof optionValue === "function") {
557
+ optionValue = optionValue.apply(void 0, _toConsumableArray(params));
558
+ }
559
+ if (optionValue === true) {
560
+ optionValue = void 0;
561
+ }
562
+ if (!optionValue) {
563
+ if (optionValue === void 0 || optionValue === false) {
564
+ return optionValue;
565
+ }
566
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
567
+ }
568
+ var node = optionValue;
569
+ if (typeof optionValue === "string") {
570
+ try {
571
+ node = doc.querySelector(optionValue);
572
+ } catch (err) {
573
+ throw new Error("`".concat(optionName, '` appears to be an invalid selector; error="').concat(err.message, '"'));
574
+ }
575
+ if (!node) {
576
+ if (!hasFallback) {
577
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
578
+ }
579
+ }
580
+ }
581
+ return node;
582
+ };
583
+ var getInitialFocusNode = function getInitialFocusNode2() {
584
+ var node = getNodeForOption("initialFocus", {
585
+ hasFallback: true
586
+ });
587
+ if (node === false) {
588
+ return false;
589
+ }
590
+ if (node === void 0 || node && !isFocusable(node, config.tabbableOptions)) {
591
+ if (findContainerIndex(doc.activeElement) >= 0) {
592
+ node = doc.activeElement;
593
+ } else {
594
+ var firstTabbableGroup = state.tabbableGroups[0];
595
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
596
+ node = firstTabbableNode || getNodeForOption("fallbackFocus");
597
+ }
598
+ } else if (node === null) {
599
+ node = getNodeForOption("fallbackFocus");
600
+ }
601
+ if (!node) {
602
+ throw new Error("Your focus-trap needs to have at least one focusable element");
603
+ }
604
+ return node;
605
+ };
606
+ var updateTabbableNodes = function updateTabbableNodes2() {
607
+ state.containerGroups = state.containers.map(function(container) {
608
+ var tabbableNodes = tabbable(container, config.tabbableOptions);
609
+ var focusableNodes = focusable(container, config.tabbableOptions);
610
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : void 0;
611
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : void 0;
612
+ var firstDomTabbableNode = focusableNodes.find(function(node) {
613
+ return isTabbable(node);
614
+ });
615
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function(node) {
616
+ return isTabbable(node);
617
+ });
618
+ var posTabIndexesFound = !!tabbableNodes.find(function(node) {
619
+ return getTabIndex(node) > 0;
620
+ });
621
+ return {
622
+ container,
623
+ tabbableNodes,
624
+ focusableNodes,
625
+ /** True if at least one node with positive `tabindex` was found in this container. */
626
+ posTabIndexesFound,
627
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
628
+ firstTabbableNode,
629
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
630
+ lastTabbableNode,
631
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
632
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
633
+ // because that API doesn't work with Shadow DOM as well as it should (@see
634
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
635
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
636
+ // "close enough most of the time" alternative for positive tabindexes which should generally
637
+ // be avoided anyway...
638
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
639
+ firstDomTabbableNode,
640
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
641
+ lastDomTabbableNode,
642
+ /**
643
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
644
+ * in this container, if any.
645
+ * @param {HTMLElement} node
646
+ * @param {boolean} [forward] True if going in forward tab order; false if going
647
+ * in reverse.
648
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
649
+ */
650
+ nextTabbableNode: function nextTabbableNode(node) {
651
+ var forward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
652
+ var nodeIdx = tabbableNodes.indexOf(node);
653
+ if (nodeIdx < 0) {
654
+ if (forward) {
655
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function(el) {
656
+ return isTabbable(el);
657
+ });
658
+ }
659
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function(el) {
660
+ return isTabbable(el);
661
+ });
662
+ }
663
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
664
+ }
665
+ };
666
+ });
667
+ state.tabbableGroups = state.containerGroups.filter(function(group) {
668
+ return group.tabbableNodes.length > 0;
669
+ });
670
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) {
671
+ throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
672
+ }
673
+ if (state.containerGroups.find(function(g) {
674
+ return g.posTabIndexesFound;
675
+ }) && state.containerGroups.length > 1) {
676
+ throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
677
+ }
678
+ };
679
+ var _getActiveElement = function getActiveElement(el) {
680
+ var activeElement = el.activeElement;
681
+ if (!activeElement) {
682
+ return;
683
+ }
684
+ if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
685
+ return _getActiveElement(activeElement.shadowRoot);
686
+ }
687
+ return activeElement;
688
+ };
689
+ var _tryFocus = function tryFocus(node) {
690
+ if (node === false) {
691
+ return;
692
+ }
693
+ if (node === _getActiveElement(document)) {
694
+ return;
695
+ }
696
+ if (!node || !node.focus) {
697
+ _tryFocus(getInitialFocusNode());
698
+ return;
699
+ }
700
+ node.focus({
701
+ preventScroll: !!config.preventScroll
702
+ });
703
+ state.mostRecentlyFocusedNode = node;
704
+ if (isSelectableInput(node)) {
705
+ node.select();
706
+ }
707
+ };
708
+ var getReturnFocusNode = function getReturnFocusNode2(previousActiveElement) {
709
+ var node = getNodeForOption("setReturnFocus", {
710
+ params: [previousActiveElement]
711
+ });
712
+ return node ? node : node === false ? false : previousActiveElement;
713
+ };
714
+ var findNextNavNode = function findNextNavNode2(_ref3) {
715
+ var target = _ref3.target, event = _ref3.event, _ref3$isBackward = _ref3.isBackward, isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward;
716
+ target = target || getActualTarget(event);
717
+ updateTabbableNodes();
718
+ var destinationNode = null;
719
+ if (state.tabbableGroups.length > 0) {
720
+ var containerIndex = findContainerIndex(target, event);
721
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : void 0;
722
+ if (containerIndex < 0) {
723
+ if (isBackward) {
724
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
725
+ } else {
726
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
727
+ }
728
+ } else if (isBackward) {
729
+ var startOfGroupIndex = state.tabbableGroups.findIndex(function(_ref4) {
730
+ var firstTabbableNode = _ref4.firstTabbableNode;
731
+ return target === firstTabbableNode;
732
+ });
733
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
734
+ startOfGroupIndex = containerIndex;
735
+ }
736
+ if (startOfGroupIndex >= 0) {
737
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
738
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
739
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
740
+ } else if (!isTabEvent(event)) {
741
+ destinationNode = containerGroup.nextTabbableNode(target, false);
742
+ }
743
+ } else {
744
+ var lastOfGroupIndex = state.tabbableGroups.findIndex(function(_ref5) {
745
+ var lastTabbableNode = _ref5.lastTabbableNode;
746
+ return target === lastTabbableNode;
747
+ });
748
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
749
+ lastOfGroupIndex = containerIndex;
750
+ }
751
+ if (lastOfGroupIndex >= 0) {
752
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
753
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
754
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
755
+ } else if (!isTabEvent(event)) {
756
+ destinationNode = containerGroup.nextTabbableNode(target);
757
+ }
758
+ }
759
+ } else {
760
+ destinationNode = getNodeForOption("fallbackFocus");
761
+ }
762
+ return destinationNode;
763
+ };
764
+ var checkPointerDown = function checkPointerDown2(e) {
765
+ var target = getActualTarget(e);
766
+ if (findContainerIndex(target, e) >= 0) {
767
+ return;
768
+ }
769
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
770
+ trap.deactivate({
771
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
772
+ // which will result in the outside click setting focus to the node
773
+ // that was clicked (and if not focusable, to "nothing"); by setting
774
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
775
+ // on activation (or the configured `setReturnFocus` node), whether the
776
+ // outside click was on a focusable node or not
777
+ returnFocus: config.returnFocusOnDeactivate
778
+ });
779
+ return;
780
+ }
781
+ if (valueOrHandler(config.allowOutsideClick, e)) {
782
+ return;
783
+ }
784
+ e.preventDefault();
785
+ };
786
+ var checkFocusIn = function checkFocusIn2(event) {
787
+ var target = getActualTarget(event);
788
+ var targetContained = findContainerIndex(target, event) >= 0;
789
+ if (targetContained || target instanceof Document) {
790
+ if (targetContained) {
791
+ state.mostRecentlyFocusedNode = target;
792
+ }
793
+ } else {
794
+ event.stopImmediatePropagation();
795
+ var nextNode;
796
+ var navAcrossContainers = true;
797
+ if (state.mostRecentlyFocusedNode) {
798
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
799
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
800
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
801
+ if (tabbableNodes.length > 0) {
802
+ var mruTabIdx = tabbableNodes.findIndex(function(node) {
803
+ return node === state.mostRecentlyFocusedNode;
804
+ });
805
+ if (mruTabIdx >= 0) {
806
+ if (config.isKeyForward(state.recentNavEvent)) {
807
+ if (mruTabIdx + 1 < tabbableNodes.length) {
808
+ nextNode = tabbableNodes[mruTabIdx + 1];
809
+ navAcrossContainers = false;
810
+ }
811
+ } else {
812
+ if (mruTabIdx - 1 >= 0) {
813
+ nextNode = tabbableNodes[mruTabIdx - 1];
814
+ navAcrossContainers = false;
815
+ }
816
+ }
817
+ }
818
+ }
819
+ } else {
820
+ if (!state.containerGroups.some(function(g) {
821
+ return g.tabbableNodes.some(function(n) {
822
+ return getTabIndex(n) > 0;
823
+ });
824
+ })) {
825
+ navAcrossContainers = false;
826
+ }
827
+ }
828
+ } else {
829
+ navAcrossContainers = false;
830
+ }
831
+ if (navAcrossContainers) {
832
+ nextNode = findNextNavNode({
833
+ // move FROM the MRU node, not event-related node (which will be the node that is
834
+ // outside the trap causing the focus escape we're trying to fix)
835
+ target: state.mostRecentlyFocusedNode,
836
+ isBackward: config.isKeyBackward(state.recentNavEvent)
837
+ });
838
+ }
839
+ if (nextNode) {
840
+ _tryFocus(nextNode);
841
+ } else {
842
+ _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
843
+ }
844
+ }
845
+ state.recentNavEvent = void 0;
846
+ };
847
+ var checkKeyNav = function checkKeyNav2(event) {
848
+ var isBackward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
849
+ state.recentNavEvent = event;
850
+ var destinationNode = findNextNavNode({
851
+ event,
852
+ isBackward
853
+ });
854
+ if (destinationNode) {
855
+ if (isTabEvent(event)) {
856
+ event.preventDefault();
857
+ }
858
+ _tryFocus(destinationNode);
859
+ }
860
+ };
861
+ var checkTabKey = function checkTabKey2(event) {
862
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) {
863
+ checkKeyNav(event, config.isKeyBackward(event));
864
+ }
865
+ };
866
+ var checkEscapeKey = function checkEscapeKey2(event) {
867
+ if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
868
+ event.preventDefault();
869
+ trap.deactivate();
870
+ }
871
+ };
872
+ var checkClick = function checkClick2(e) {
873
+ var target = getActualTarget(e);
874
+ if (findContainerIndex(target, e) >= 0) {
875
+ return;
876
+ }
877
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
878
+ return;
879
+ }
880
+ if (valueOrHandler(config.allowOutsideClick, e)) {
881
+ return;
882
+ }
883
+ e.preventDefault();
884
+ e.stopImmediatePropagation();
885
+ };
886
+ var addListeners = function addListeners2() {
887
+ if (!state.active) {
888
+ return;
889
+ }
890
+ activeFocusTraps.activateTrap(trapStack, trap);
891
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function() {
892
+ _tryFocus(getInitialFocusNode());
893
+ }) : _tryFocus(getInitialFocusNode());
894
+ doc.addEventListener("focusin", checkFocusIn, true);
895
+ doc.addEventListener("mousedown", checkPointerDown, {
896
+ capture: true,
897
+ passive: false
898
+ });
899
+ doc.addEventListener("touchstart", checkPointerDown, {
900
+ capture: true,
901
+ passive: false
902
+ });
903
+ doc.addEventListener("click", checkClick, {
904
+ capture: true,
905
+ passive: false
906
+ });
907
+ doc.addEventListener("keydown", checkTabKey, {
908
+ capture: true,
909
+ passive: false
910
+ });
911
+ doc.addEventListener("keydown", checkEscapeKey);
912
+ return trap;
913
+ };
914
+ var removeListeners = function removeListeners2() {
915
+ if (!state.active) {
916
+ return;
917
+ }
918
+ doc.removeEventListener("focusin", checkFocusIn, true);
919
+ doc.removeEventListener("mousedown", checkPointerDown, true);
920
+ doc.removeEventListener("touchstart", checkPointerDown, true);
921
+ doc.removeEventListener("click", checkClick, true);
922
+ doc.removeEventListener("keydown", checkTabKey, true);
923
+ doc.removeEventListener("keydown", checkEscapeKey);
924
+ return trap;
925
+ };
926
+ var checkDomRemoval = function checkDomRemoval2(mutations) {
927
+ var isFocusedNodeRemoved = mutations.some(function(mutation) {
928
+ var removedNodes = Array.from(mutation.removedNodes);
929
+ return removedNodes.some(function(node) {
930
+ return node === state.mostRecentlyFocusedNode;
931
+ });
932
+ });
933
+ if (isFocusedNodeRemoved) {
934
+ _tryFocus(getInitialFocusNode());
935
+ }
936
+ };
937
+ var mutationObserver = typeof window !== "undefined" && "MutationObserver" in window ? new MutationObserver(checkDomRemoval) : void 0;
938
+ var updateObservedNodes = function updateObservedNodes2() {
939
+ if (!mutationObserver) {
940
+ return;
941
+ }
942
+ mutationObserver.disconnect();
943
+ if (state.active && !state.paused) {
944
+ state.containers.map(function(container) {
945
+ mutationObserver.observe(container, {
946
+ subtree: true,
947
+ childList: true
948
+ });
949
+ });
950
+ }
951
+ };
952
+ trap = {
953
+ get active() {
954
+ return state.active;
955
+ },
956
+ get paused() {
957
+ return state.paused;
958
+ },
959
+ activate: function activate(activateOptions) {
960
+ if (state.active) {
961
+ return this;
962
+ }
963
+ var onActivate = getOption(activateOptions, "onActivate");
964
+ var onPostActivate = getOption(activateOptions, "onPostActivate");
965
+ var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap");
966
+ if (!checkCanFocusTrap) {
967
+ updateTabbableNodes();
968
+ }
969
+ state.active = true;
970
+ state.paused = false;
971
+ state.nodeFocusedBeforeActivation = _getActiveElement(doc);
972
+ onActivate === null || onActivate === void 0 || onActivate();
973
+ var finishActivation = function finishActivation2() {
974
+ if (checkCanFocusTrap) {
975
+ updateTabbableNodes();
976
+ }
977
+ addListeners();
978
+ updateObservedNodes();
979
+ onPostActivate === null || onPostActivate === void 0 || onPostActivate();
980
+ };
981
+ if (checkCanFocusTrap) {
982
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
983
+ return this;
984
+ }
985
+ finishActivation();
986
+ return this;
987
+ },
988
+ deactivate: function deactivate(deactivateOptions) {
989
+ if (!state.active) {
990
+ return this;
991
+ }
992
+ var options = _objectSpread2({
993
+ onDeactivate: config.onDeactivate,
994
+ onPostDeactivate: config.onPostDeactivate,
995
+ checkCanReturnFocus: config.checkCanReturnFocus
996
+ }, deactivateOptions);
997
+ clearTimeout(state.delayInitialFocusTimer);
998
+ state.delayInitialFocusTimer = void 0;
999
+ removeListeners();
1000
+ state.active = false;
1001
+ state.paused = false;
1002
+ updateObservedNodes();
1003
+ activeFocusTraps.deactivateTrap(trapStack, trap);
1004
+ var onDeactivate = getOption(options, "onDeactivate");
1005
+ var onPostDeactivate = getOption(options, "onPostDeactivate");
1006
+ var checkCanReturnFocus = getOption(options, "checkCanReturnFocus");
1007
+ var returnFocus = getOption(options, "returnFocus", "returnFocusOnDeactivate");
1008
+ onDeactivate === null || onDeactivate === void 0 || onDeactivate();
1009
+ var finishDeactivation = function finishDeactivation2() {
1010
+ delay(function() {
1011
+ if (returnFocus) {
1012
+ _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1013
+ }
1014
+ onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
1015
+ });
1016
+ };
1017
+ if (returnFocus && checkCanReturnFocus) {
1018
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1019
+ return this;
1020
+ }
1021
+ finishDeactivation();
1022
+ return this;
1023
+ },
1024
+ pause: function pause(pauseOptions) {
1025
+ if (!state.active) {
1026
+ return this;
1027
+ }
1028
+ state.manuallyPaused = true;
1029
+ return this._setPausedState(true, pauseOptions);
1030
+ },
1031
+ unpause: function unpause(unpauseOptions) {
1032
+ if (!state.active) {
1033
+ return this;
1034
+ }
1035
+ state.manuallyPaused = false;
1036
+ if (trapStack[trapStack.length - 1] !== this) {
1037
+ return this;
1038
+ }
1039
+ return this._setPausedState(false, unpauseOptions);
1040
+ },
1041
+ updateContainerElements: function updateContainerElements(containerElements) {
1042
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
1043
+ state.containers = elementsAsArray.map(function(element) {
1044
+ return typeof element === "string" ? doc.querySelector(element) : element;
1045
+ });
1046
+ if (state.active) {
1047
+ updateTabbableNodes();
1048
+ }
1049
+ updateObservedNodes();
1050
+ return this;
1051
+ }
1052
+ };
1053
+ Object.defineProperties(trap, {
1054
+ _isManuallyPaused: {
1055
+ value: function value() {
1056
+ return state.manuallyPaused;
1057
+ }
1058
+ },
1059
+ _setPausedState: {
1060
+ value: function value(paused, options) {
1061
+ if (state.paused === paused) {
1062
+ return this;
1063
+ }
1064
+ state.paused = paused;
1065
+ if (paused) {
1066
+ var onPause = getOption(options, "onPause");
1067
+ var onPostPause = getOption(options, "onPostPause");
1068
+ onPause === null || onPause === void 0 || onPause();
1069
+ removeListeners();
1070
+ updateObservedNodes();
1071
+ onPostPause === null || onPostPause === void 0 || onPostPause();
1072
+ } else {
1073
+ var onUnpause = getOption(options, "onUnpause");
1074
+ var onPostUnpause = getOption(options, "onPostUnpause");
1075
+ onUnpause === null || onUnpause === void 0 || onUnpause();
1076
+ updateTabbableNodes();
1077
+ addListeners();
1078
+ updateObservedNodes();
1079
+ onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
1080
+ }
1081
+ return this;
1082
+ }
1083
+ }
1084
+ });
1085
+ trap.updateContainerElements(elements);
1086
+ return trap;
1087
+ };
1088
+
1089
+ // node_modules/@vueuse/integrations/useFocusTrap.mjs
1090
+ function useFocusTrap(target, options = {}) {
1091
+ let trap;
1092
+ const { immediate, ...focusTrapOptions } = options;
1093
+ const hasFocus = shallowRef(false);
1094
+ const isPaused = shallowRef(false);
1095
+ const activate = (opts) => trap && trap.activate(opts);
1096
+ const deactivate = (opts) => trap && trap.deactivate(opts);
1097
+ const pause = () => {
1098
+ if (trap) {
1099
+ trap.pause();
1100
+ isPaused.value = true;
1101
+ }
1102
+ };
1103
+ const unpause = () => {
1104
+ if (trap) {
1105
+ trap.unpause();
1106
+ isPaused.value = false;
1107
+ }
1108
+ };
1109
+ const targets = computed(() => {
1110
+ const _targets = toValue(target);
1111
+ return toArray(_targets).map((el) => {
1112
+ const _el = toValue(el);
1113
+ return typeof _el === "string" ? _el : unrefElement(_el);
1114
+ }).filter(notNullish);
1115
+ });
1116
+ watch(
1117
+ targets,
1118
+ (els) => {
1119
+ if (!els.length)
1120
+ return;
1121
+ trap = createFocusTrap(els, {
1122
+ ...focusTrapOptions,
1123
+ onActivate() {
1124
+ hasFocus.value = true;
1125
+ if (options.onActivate)
1126
+ options.onActivate();
1127
+ },
1128
+ onDeactivate() {
1129
+ hasFocus.value = false;
1130
+ if (options.onDeactivate)
1131
+ options.onDeactivate();
1132
+ }
1133
+ });
1134
+ if (immediate)
1135
+ activate();
1136
+ },
1137
+ { flush: "post" }
1138
+ );
1139
+ tryOnScopeDispose(() => deactivate());
1140
+ return {
1141
+ hasFocus,
1142
+ isPaused,
1143
+ activate,
1144
+ deactivate,
1145
+ pause,
1146
+ unpause
1147
+ };
1148
+ }
1149
+ export {
1150
+ useFocusTrap
1151
+ };
1152
+ /*! Bundled license information:
1153
+
1154
+ tabbable/dist/index.esm.js:
1155
+ (*!
1156
+ * tabbable 6.3.0
1157
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
1158
+ *)
1159
+
1160
+ focus-trap/dist/focus-trap.esm.js:
1161
+ (*!
1162
+ * focus-trap 7.6.6
1163
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
1164
+ *)
1165
+ */
1166
+ //# sourceMappingURL=vitepress___@vueuse_integrations_useFocusTrap.js.map