| @@ -1,4316 +1,3643 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 2 | -/******/ "use strict"; | |
| 3 | -/******/ var __webpack_modules__ = ({ | |
| 1 | +(function() { | |
| 4 | 2 | |
| 5 | -/***/ "./node_modules/@alpinejs/csp/dist/module.esm.js": | |
| 6 | -/*!*******************************************************!*\ | |
| 7 | - !*** ./node_modules/@alpinejs/csp/dist/module.esm.js ***! | |
| 8 | - \*******************************************************/ | |
| 9 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 3 | +//#region \0rolldown/runtime.js | |
| 4 | + var __defProp = Object.defineProperty; | |
| 5 | + var __name = (target, value) => __defProp(target, "name", { | |
| 6 | + value, | |
| 7 | + configurable: true | |
| 8 | + }); | |
| 9 | + var __exportAll = (all, no_symbols) => { | |
| 10 | + let target = {}; | |
| 11 | + for (var name in all) { | |
| 12 | + __defProp(target, name, { | |
| 13 | + get: all[name], | |
| 14 | + enumerable: true | |
| 15 | + }); | |
| 16 | + } | |
| 17 | + if (!no_symbols) { | |
| 18 | + __defProp(target, Symbol.toStringTag, { value: "Module" }); | |
| 19 | + } | |
| 20 | + return target; | |
| 21 | + }; | |
| 10 | 22 | |
| 11 | -__webpack_require__.r(__webpack_exports__); | |
| 12 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 13 | -/* harmony export */ Alpine: function() { return /* binding */ src_default; }, | |
| 14 | -/* harmony export */ "default": function() { return /* binding */ module_default; } | |
| 15 | -/* harmony export */ }); | |
| 16 | -// packages/alpinejs/src/scheduler.js | |
| 17 | -var flushPending = false; | |
| 18 | -var flushing = false; | |
| 19 | -var queue = []; | |
| 20 | -var lastFlushedIndex = -1; | |
| 21 | -function scheduler(callback) { | |
| 22 | - queueJob(callback); | |
| 23 | -} | |
| 24 | -function queueJob(job) { | |
| 25 | - if (!queue.includes(job)) | |
| 26 | - queue.push(job); | |
| 27 | - queueFlush(); | |
| 28 | -} | |
| 29 | -function dequeueJob(job) { | |
| 30 | - let index = queue.indexOf(job); | |
| 31 | - if (index !== -1 && index > lastFlushedIndex) | |
| 32 | - queue.splice(index, 1); | |
| 33 | -} | |
| 34 | -function queueFlush() { | |
| 35 | - if (!flushing && !flushPending) { | |
| 36 | - flushPending = true; | |
| 37 | - queueMicrotask(flushJobs); | |
| 38 | - } | |
| 39 | -} | |
| 40 | -function flushJobs() { | |
| 41 | - flushPending = false; | |
| 42 | - flushing = true; | |
| 43 | - for (let i = 0; i < queue.length; i++) { | |
| 44 | - queue[i](); | |
| 45 | - lastFlushedIndex = i; | |
| 46 | - } | |
| 47 | - queue.length = 0; | |
| 48 | - lastFlushedIndex = -1; | |
| 49 | - flushing = false; | |
| 50 | -} | |
| 23 | +//#endregion | |
| 51 | 24 | |
| 52 | -// packages/alpinejs/src/reactivity.js | |
| 53 | -var reactive; | |
| 54 | -var effect; | |
| 55 | -var release; | |
| 56 | -var raw; | |
| 57 | -var shouldSchedule = true; | |
| 58 | -function disableEffectScheduling(callback) { | |
| 59 | - shouldSchedule = false; | |
| 60 | - callback(); | |
| 61 | - shouldSchedule = true; | |
| 62 | -} | |
| 63 | -function setReactivityEngine(engine) { | |
| 64 | - reactive = engine.reactive; | |
| 65 | - release = engine.release; | |
| 66 | - effect = (callback) => engine.effect(callback, { scheduler: (task) => { | |
| 67 | - if (shouldSchedule) { | |
| 68 | - scheduler(task); | |
| 69 | - } else { | |
| 70 | - task(); | |
| 71 | - } | |
| 72 | - } }); | |
| 73 | - raw = engine.raw; | |
| 74 | -} | |
| 75 | -function overrideEffect(override) { | |
| 76 | - effect = override; | |
| 77 | -} | |
| 78 | -function elementBoundEffect(el) { | |
| 79 | - let cleanup2 = () => { | |
| 80 | - }; | |
| 81 | - let wrappedEffect = (callback) => { | |
| 82 | - let effectReference = effect(callback); | |
| 83 | - if (!el._x_effects) { | |
| 84 | - el._x_effects = /* @__PURE__ */ new Set(); | |
| 85 | - el._x_runEffects = () => { | |
| 86 | - el._x_effects.forEach((i) => i()); | |
| 87 | - }; | |
| 88 | - } | |
| 89 | - el._x_effects.add(effectReference); | |
| 90 | - cleanup2 = () => { | |
| 91 | - if (effectReference === void 0) | |
| 92 | - return; | |
| 93 | - el._x_effects.delete(effectReference); | |
| 94 | - release(effectReference); | |
| 95 | - }; | |
| 96 | - return effectReference; | |
| 97 | - }; | |
| 98 | - return [wrappedEffect, () => { | |
| 99 | - cleanup2(); | |
| 100 | - }]; | |
| 101 | -} | |
| 102 | -function watch(getter, callback) { | |
| 103 | - let firstTime = true; | |
| 104 | - let oldValue; | |
| 105 | - let effectReference = effect(() => { | |
| 106 | - let value = getter(); | |
| 107 | - JSON.stringify(value); | |
| 108 | - if (!firstTime) { | |
| 109 | - queueMicrotask(() => { | |
| 110 | - callback(value, oldValue); | |
| 111 | - oldValue = value; | |
| 112 | - }); | |
| 113 | - } else { | |
| 114 | - oldValue = value; | |
| 115 | - } | |
| 116 | - firstTime = false; | |
| 117 | - }); | |
| 118 | - return () => release(effectReference); | |
| 119 | -} | |
| 25 | +//#region node_modules/@alpinejs/csp/dist/module.esm.js | |
| 26 | + var flushPending = false; | |
| 27 | + var flushing = false; | |
| 28 | + var queue = []; | |
| 29 | + var lastFlushedIndex = -1; | |
| 30 | + function scheduler(callback) { | |
| 31 | + queueJob(callback); | |
| 32 | + } | |
| 33 | + function queueJob(job) { | |
| 34 | + if (!queue.includes(job)) queue.push(job); | |
| 35 | + queueFlush(); | |
| 36 | + } | |
| 37 | + function dequeueJob(job) { | |
| 38 | + let index = queue.indexOf(job); | |
| 39 | + if (index !== -1 && index > lastFlushedIndex) queue.splice(index, 1); | |
| 40 | + } | |
| 41 | + function queueFlush() { | |
| 42 | + if (!flushing && !flushPending) { | |
| 43 | + flushPending = true; | |
| 44 | + queueMicrotask(flushJobs); | |
| 45 | + } | |
| 46 | + } | |
| 47 | + function flushJobs() { | |
| 48 | + flushPending = false; | |
| 49 | + flushing = true; | |
| 50 | + for (let i = 0; i < queue.length; i++) { | |
| 51 | + queue[i](); | |
| 52 | + lastFlushedIndex = i; | |
| 53 | + } | |
| 54 | + queue.length = 0; | |
| 55 | + lastFlushedIndex = -1; | |
| 56 | + flushing = false; | |
| 57 | + } | |
| 58 | + var reactive; | |
| 59 | + var effect; | |
| 60 | + var release; | |
| 61 | + var raw; | |
| 62 | + var shouldSchedule = true; | |
| 63 | + function disableEffectScheduling(callback) { | |
| 64 | + shouldSchedule = false; | |
| 65 | + callback(); | |
| 66 | + shouldSchedule = true; | |
| 67 | + } | |
| 68 | + function setReactivityEngine(engine) { | |
| 69 | + reactive = engine.reactive; | |
| 70 | + release = engine.release; | |
| 71 | + effect = (callback) => engine.effect(callback, { scheduler: (task) => { | |
| 72 | + if (shouldSchedule) scheduler(task); | |
| 73 | + else task(); | |
| 74 | + } }); | |
| 75 | + raw = engine.raw; | |
| 76 | + } | |
| 77 | + function overrideEffect(override) { | |
| 78 | + effect = override; | |
| 79 | + } | |
| 80 | + function elementBoundEffect(el) { | |
| 81 | + let cleanup2 = () => {}; | |
| 82 | + let wrappedEffect = (callback) => { | |
| 83 | + let effectReference = effect(callback); | |
| 84 | + if (!el._x_effects) { | |
| 85 | + el._x_effects = /* @__PURE__ */ new Set(); | |
| 86 | + el._x_runEffects = () => { | |
| 87 | + el._x_effects.forEach((i) => i()); | |
| 88 | + }; | |
| 89 | + } | |
| 90 | + el._x_effects.add(effectReference); | |
| 91 | + cleanup2 = () => { | |
| 92 | + if (effectReference === void 0) return; | |
| 93 | + el._x_effects.delete(effectReference); | |
| 94 | + release(effectReference); | |
| 95 | + }; | |
| 96 | + return effectReference; | |
| 97 | + }; | |
| 98 | + return [wrappedEffect, () => { | |
| 99 | + cleanup2(); | |
| 100 | + }]; | |
| 101 | + } | |
| 102 | + function watch(getter, callback) { | |
| 103 | + let firstTime = true; | |
| 104 | + let oldValue; | |
| 105 | + let effectReference = effect(() => { | |
| 106 | + let value = getter(); | |
| 107 | + JSON.stringify(value); | |
| 108 | + if (!firstTime) queueMicrotask(() => { | |
| 109 | + callback(value, oldValue); | |
| 110 | + oldValue = value; | |
| 111 | + }); | |
| 112 | + else oldValue = value; | |
| 113 | + firstTime = false; | |
| 114 | + }); | |
| 115 | + return () => release(effectReference); | |
| 116 | + } | |
| 117 | + var onAttributeAddeds = []; | |
| 118 | + var onElRemoveds = []; | |
| 119 | + var onElAddeds = []; | |
| 120 | + function onElAdded(callback) { | |
| 121 | + onElAddeds.push(callback); | |
| 122 | + } | |
| 123 | + function onElRemoved(el, callback) { | |
| 124 | + if (typeof callback === "function") { | |
| 125 | + if (!el._x_cleanups) el._x_cleanups = []; | |
| 126 | + el._x_cleanups.push(callback); | |
| 127 | + } else { | |
| 128 | + callback = el; | |
| 129 | + onElRemoveds.push(callback); | |
| 130 | + } | |
| 131 | + } | |
| 132 | + function onAttributesAdded(callback) { | |
| 133 | + onAttributeAddeds.push(callback); | |
| 134 | + } | |
| 135 | + function onAttributeRemoved(el, name, callback) { | |
| 136 | + if (!el._x_attributeCleanups) el._x_attributeCleanups = {}; | |
| 137 | + if (!el._x_attributeCleanups[name]) el._x_attributeCleanups[name] = []; | |
| 138 | + el._x_attributeCleanups[name].push(callback); | |
| 139 | + } | |
| 140 | + function cleanupAttributes(el, names) { | |
| 141 | + if (!el._x_attributeCleanups) return; | |
| 142 | + Object.entries(el._x_attributeCleanups).forEach(([name, value]) => { | |
| 143 | + if (names === void 0 || names.includes(name)) { | |
| 144 | + value.forEach((i) => i()); | |
| 145 | + delete el._x_attributeCleanups[name]; | |
| 146 | + } | |
| 147 | + }); | |
| 148 | + } | |
| 149 | + function cleanupElement(el) { | |
| 150 | + el._x_effects?.forEach(dequeueJob); | |
| 151 | + while (el._x_cleanups?.length) el._x_cleanups.pop()(); | |
| 152 | + } | |
| 153 | + var observer = new MutationObserver(onMutate); | |
| 154 | + var currentlyObserving = false; | |
| 155 | + function startObservingMutations() { | |
| 156 | + observer.observe(document, { | |
| 157 | + subtree: true, | |
| 158 | + childList: true, | |
| 159 | + attributes: true, | |
| 160 | + attributeOldValue: true | |
| 161 | + }); | |
| 162 | + currentlyObserving = true; | |
| 163 | + } | |
| 164 | + function stopObservingMutations() { | |
| 165 | + flushObserver(); | |
| 166 | + observer.disconnect(); | |
| 167 | + currentlyObserving = false; | |
| 168 | + } | |
| 169 | + var queuedMutations = []; | |
| 170 | + function flushObserver() { | |
| 171 | + let records = observer.takeRecords(); | |
| 172 | + queuedMutations.push(() => records.length > 0 && onMutate(records)); | |
| 173 | + let queueLengthWhenTriggered = queuedMutations.length; | |
| 174 | + queueMicrotask(() => { | |
| 175 | + if (queuedMutations.length === queueLengthWhenTriggered) while (queuedMutations.length > 0) queuedMutations.shift()(); | |
| 176 | + }); | |
| 177 | + } | |
| 178 | + function mutateDom(callback) { | |
| 179 | + if (!currentlyObserving) return callback(); | |
| 180 | + stopObservingMutations(); | |
| 181 | + let result = callback(); | |
| 182 | + startObservingMutations(); | |
| 183 | + return result; | |
| 184 | + } | |
| 185 | + var isCollecting = false; | |
| 186 | + var deferredMutations = []; | |
| 187 | + function deferMutations() { | |
| 188 | + isCollecting = true; | |
| 189 | + } | |
| 190 | + function flushAndStopDeferringMutations() { | |
| 191 | + isCollecting = false; | |
| 192 | + onMutate(deferredMutations); | |
| 193 | + deferredMutations = []; | |
| 194 | + } | |
| 195 | + function onMutate(mutations) { | |
| 196 | + if (isCollecting) { | |
| 197 | + deferredMutations = deferredMutations.concat(mutations); | |
| 198 | + return; | |
| 199 | + } | |
| 200 | + let addedNodes = []; | |
| 201 | + let removedNodes = /* @__PURE__ */ new Set(); | |
| 202 | + let addedAttributes = /* @__PURE__ */ new Map(); | |
| 203 | + let removedAttributes = /* @__PURE__ */ new Map(); | |
| 204 | + for (let i = 0; i < mutations.length; i++) { | |
| 205 | + if (mutations[i].target._x_ignoreMutationObserver) continue; | |
| 206 | + if (mutations[i].type === "childList") { | |
| 207 | + mutations[i].removedNodes.forEach((node) => { | |
| 208 | + if (node.nodeType !== 1) return; | |
| 209 | + if (!node._x_marker) return; | |
| 210 | + removedNodes.add(node); | |
| 211 | + }); | |
| 212 | + mutations[i].addedNodes.forEach((node) => { | |
| 213 | + if (node.nodeType !== 1) return; | |
| 214 | + if (removedNodes.has(node)) { | |
| 215 | + removedNodes.delete(node); | |
| 216 | + return; | |
| 217 | + } | |
| 218 | + if (node._x_marker) return; | |
| 219 | + addedNodes.push(node); | |
| 220 | + }); | |
| 221 | + } | |
| 222 | + if (mutations[i].type === "attributes") { | |
| 223 | + let el = mutations[i].target; | |
| 224 | + let name = mutations[i].attributeName; | |
| 225 | + let oldValue = mutations[i].oldValue; | |
| 226 | + let add2 = () => { | |
| 227 | + if (!addedAttributes.has(el)) addedAttributes.set(el, []); | |
| 228 | + addedAttributes.get(el).push({ | |
| 229 | + name, | |
| 230 | + value: el.getAttribute(name) | |
| 231 | + }); | |
| 232 | + }; | |
| 233 | + let remove = () => { | |
| 234 | + if (!removedAttributes.has(el)) removedAttributes.set(el, []); | |
| 235 | + removedAttributes.get(el).push(name); | |
| 236 | + }; | |
| 237 | + if (el.hasAttribute(name) && oldValue === null) add2(); | |
| 238 | + else if (el.hasAttribute(name)) { | |
| 239 | + remove(); | |
| 240 | + add2(); | |
| 241 | + } else remove(); | |
| 242 | + } | |
| 243 | + } | |
| 244 | + removedAttributes.forEach((attrs, el) => { | |
| 245 | + cleanupAttributes(el, attrs); | |
| 246 | + }); | |
| 247 | + addedAttributes.forEach((attrs, el) => { | |
| 248 | + onAttributeAddeds.forEach((i) => i(el, attrs)); | |
| 249 | + }); | |
| 250 | + for (let node of removedNodes) { | |
| 251 | + if (addedNodes.some((i) => i.contains(node))) continue; | |
| 252 | + onElRemoveds.forEach((i) => i(node)); | |
| 253 | + } | |
| 254 | + for (let node of addedNodes) { | |
| 255 | + if (!node.isConnected) continue; | |
| 256 | + onElAddeds.forEach((i) => i(node)); | |
| 257 | + } | |
| 258 | + addedNodes = null; | |
| 259 | + removedNodes = null; | |
| 260 | + addedAttributes = null; | |
| 261 | + removedAttributes = null; | |
| 262 | + } | |
| 263 | + function scope(node) { | |
| 264 | + return mergeProxies(closestDataStack(node)); | |
| 265 | + } | |
| 266 | + function addScopeToNode(node, data2, referenceNode) { | |
| 267 | + node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)]; | |
| 268 | + return () => { | |
| 269 | + node._x_dataStack = node._x_dataStack.filter((i) => i !== data2); | |
| 270 | + }; | |
| 271 | + } | |
| 272 | + function closestDataStack(node) { | |
| 273 | + if (node._x_dataStack) return node._x_dataStack; | |
| 274 | + if (typeof ShadowRoot === "function" && node instanceof ShadowRoot) return closestDataStack(node.host); | |
| 275 | + if (!node.parentNode) return []; | |
| 276 | + return closestDataStack(node.parentNode); | |
| 277 | + } | |
| 278 | + function mergeProxies(objects) { | |
| 279 | + return new Proxy({ objects }, mergeProxyTrap); | |
| 280 | + } | |
| 281 | + var mergeProxyTrap = { | |
| 282 | + ownKeys({ objects }) { | |
| 283 | + return Array.from(new Set(objects.flatMap((i) => Object.keys(i)))); | |
| 284 | + }, | |
| 285 | + has({ objects }, name) { | |
| 286 | + if (name == Symbol.unscopables) return false; | |
| 287 | + return objects.some((obj) => Object.prototype.hasOwnProperty.call(obj, name) || Reflect.has(obj, name)); | |
| 288 | + }, | |
| 289 | + get({ objects }, name, thisProxy) { | |
| 290 | + if (name == "toJSON") return collapseProxies; | |
| 291 | + return Reflect.get(objects.find((obj) => Reflect.has(obj, name)) || {}, name, thisProxy); | |
| 292 | + }, | |
| 293 | + set({ objects }, name, value, thisProxy) { | |
| 294 | + const target = objects.find((obj) => Object.prototype.hasOwnProperty.call(obj, name)) || objects[objects.length - 1]; | |
| 295 | + const descriptor = Object.getOwnPropertyDescriptor(target, name); | |
| 296 | + if (descriptor?.set && descriptor?.get) return descriptor.set.call(thisProxy, value) || true; | |
| 297 | + return Reflect.set(target, name, value); | |
| 298 | + } | |
| 299 | + }; | |
| 300 | + function collapseProxies() { | |
| 301 | + return Reflect.ownKeys(this).reduce((acc, key) => { | |
| 302 | + acc[key] = Reflect.get(this, key); | |
| 303 | + return acc; | |
| 304 | + }, {}); | |
| 305 | + } | |
| 306 | + function initInterceptors(data2) { | |
| 307 | + let isObject2 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null; | |
| 308 | + let recurse = (obj, basePath = "") => { | |
| 309 | + Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, { value, enumerable }]) => { | |
| 310 | + if (enumerable === false || value === void 0) return; | |
| 311 | + if (typeof value === "object" && value !== null && value.__v_skip) return; | |
| 312 | + let path = basePath === "" ? key : `${basePath}.${key}`; | |
| 313 | + if (typeof value === "object" && value !== null && value._x_interceptor) obj[key] = value.initialize(data2, path, key); | |
| 314 | + else if (isObject2(value) && value !== obj && !(value instanceof Element)) recurse(value, path); | |
| 315 | + }); | |
| 316 | + }; | |
| 317 | + return recurse(data2); | |
| 318 | + } | |
| 319 | + function interceptor(callback, mutateObj = () => {}) { | |
| 320 | + let obj = { | |
| 321 | + initialValue: void 0, | |
| 322 | + _x_interceptor: true, | |
| 323 | + initialize(data2, path, key) { | |
| 324 | + return callback(this.initialValue, () => get(data2, path), (value) => set(data2, path, value), path, key); | |
| 325 | + } | |
| 326 | + }; | |
| 327 | + mutateObj(obj); | |
| 328 | + return (initialValue) => { | |
| 329 | + if (typeof initialValue === "object" && initialValue !== null && initialValue._x_interceptor) { | |
| 330 | + let initialize = obj.initialize.bind(obj); | |
| 331 | + obj.initialize = (data2, path, key) => { | |
| 332 | + let innerValue = initialValue.initialize(data2, path, key); | |
| 333 | + obj.initialValue = innerValue; | |
| 334 | + return initialize(data2, path, key); | |
| 335 | + }; | |
| 336 | + } else obj.initialValue = initialValue; | |
| 337 | + return obj; | |
| 338 | + }; | |
| 339 | + } | |
| 340 | + function get(obj, path) { | |
| 341 | + return path.split(".").reduce((carry, segment) => carry[segment], obj); | |
| 342 | + } | |
| 343 | + function set(obj, path, value) { | |
| 344 | + if (typeof path === "string") path = path.split("."); | |
| 345 | + if (path.length === 1) obj[path[0]] = value; | |
| 346 | + else if (path.length === 0) throw error; | |
| 347 | + else if (obj[path[0]]) return set(obj[path[0]], path.slice(1), value); | |
| 348 | + else { | |
| 349 | + obj[path[0]] = {}; | |
| 350 | + return set(obj[path[0]], path.slice(1), value); | |
| 351 | + } | |
| 352 | + } | |
| 353 | + var magics = {}; | |
| 354 | + function magic(name, callback) { | |
| 355 | + magics[name] = callback; | |
| 356 | + } | |
| 357 | + function injectMagics(obj, el) { | |
| 358 | + let memoizedUtilities = getUtilities(el); | |
| 359 | + Object.entries(magics).forEach(([name, callback]) => { | |
| 360 | + Object.defineProperty(obj, `$${name}`, { | |
| 361 | + get() { | |
| 362 | + return callback(el, memoizedUtilities); | |
| 363 | + }, | |
| 364 | + enumerable: false | |
| 365 | + }); | |
| 366 | + }); | |
| 367 | + return obj; | |
| 368 | + } | |
| 369 | + function getUtilities(el) { | |
| 370 | + let [utilities, cleanup2] = getElementBoundUtilities(el); | |
| 371 | + let utils = { | |
| 372 | + interceptor, | |
| 373 | + ...utilities | |
| 374 | + }; | |
| 375 | + onElRemoved(el, cleanup2); | |
| 376 | + return utils; | |
| 377 | + } | |
| 378 | + function tryCatch(el, expression, callback, ...args) { | |
| 379 | + try { | |
| 380 | + return callback(...args); | |
| 381 | + } catch (e) { | |
| 382 | + handleError(e, el, expression); | |
| 383 | + } | |
| 384 | + } | |
| 385 | + function handleError(error2, el, expression = void 0) { | |
| 386 | + error2 = Object.assign(error2 ?? { message: "No error message given." }, { | |
| 387 | + el, | |
| 388 | + expression | |
| 389 | + }); | |
| 390 | + console.warn(`Alpine Expression Error: ${error2.message} | |
| 120 | 391 | |
| 121 | -// packages/alpinejs/src/mutation.js | |
| 122 | -var onAttributeAddeds = []; | |
| 123 | -var onElRemoveds = []; | |
| 124 | -var onElAddeds = []; | |
| 125 | -function onElAdded(callback) { | |
| 126 | - onElAddeds.push(callback); | |
| 127 | -} | |
| 128 | -function onElRemoved(el, callback) { | |
| 129 | - if (typeof callback === "function") { | |
| 130 | - if (!el._x_cleanups) | |
| 131 | - el._x_cleanups = []; | |
| 132 | - el._x_cleanups.push(callback); | |
| 133 | - } else { | |
| 134 | - callback = el; | |
| 135 | - onElRemoveds.push(callback); | |
| 136 | - } | |
| 137 | -} | |
| 138 | -function onAttributesAdded(callback) { | |
| 139 | - onAttributeAddeds.push(callback); | |
| 140 | -} | |
| 141 | -function onAttributeRemoved(el, name, callback) { | |
| 142 | - if (!el._x_attributeCleanups) | |
| 143 | - el._x_attributeCleanups = {}; | |
| 144 | - if (!el._x_attributeCleanups[name]) | |
| 145 | - el._x_attributeCleanups[name] = []; | |
| 146 | - el._x_attributeCleanups[name].push(callback); | |
| 147 | -} | |
| 148 | -function cleanupAttributes(el, names) { | |
| 149 | - if (!el._x_attributeCleanups) | |
| 150 | - return; | |
| 151 | - Object.entries(el._x_attributeCleanups).forEach(([name, value]) => { | |
| 152 | - if (names === void 0 || names.includes(name)) { | |
| 153 | - value.forEach((i) => i()); | |
| 154 | - delete el._x_attributeCleanups[name]; | |
| 155 | - } | |
| 156 | - }); | |
| 157 | -} | |
| 158 | -function cleanupElement(el) { | |
| 159 | - el._x_effects?.forEach(dequeueJob); | |
| 160 | - while (el._x_cleanups?.length) | |
| 161 | - el._x_cleanups.pop()(); | |
| 162 | -} | |
| 163 | -var observer = new MutationObserver(onMutate); | |
| 164 | -var currentlyObserving = false; | |
| 165 | -function startObservingMutations() { | |
| 166 | - observer.observe(document, { subtree: true, childList: true, attributes: true, attributeOldValue: true }); | |
| 167 | - currentlyObserving = true; | |
| 168 | -} | |
| 169 | -function stopObservingMutations() { | |
| 170 | - flushObserver(); | |
| 171 | - observer.disconnect(); | |
| 172 | - currentlyObserving = false; | |
| 173 | -} | |
| 174 | -var queuedMutations = []; | |
| 175 | -function flushObserver() { | |
| 176 | - let records = observer.takeRecords(); | |
| 177 | - queuedMutations.push(() => records.length > 0 && onMutate(records)); | |
| 178 | - let queueLengthWhenTriggered = queuedMutations.length; | |
| 179 | - queueMicrotask(() => { | |
| 180 | - if (queuedMutations.length === queueLengthWhenTriggered) { | |
| 181 | - while (queuedMutations.length > 0) | |
| 182 | - queuedMutations.shift()(); | |
| 183 | - } | |
| 184 | - }); | |
| 185 | -} | |
| 186 | -function mutateDom(callback) { | |
| 187 | - if (!currentlyObserving) | |
| 188 | - return callback(); | |
| 189 | - stopObservingMutations(); | |
| 190 | - let result = callback(); | |
| 191 | - startObservingMutations(); | |
| 192 | - return result; | |
| 193 | -} | |
| 194 | -var isCollecting = false; | |
| 195 | -var deferredMutations = []; | |
| 196 | -function deferMutations() { | |
| 197 | - isCollecting = true; | |
| 198 | -} | |
| 199 | -function flushAndStopDeferringMutations() { | |
| 200 | - isCollecting = false; | |
| 201 | - onMutate(deferredMutations); | |
| 202 | - deferredMutations = []; | |
| 203 | -} | |
| 204 | -function onMutate(mutations) { | |
| 205 | - if (isCollecting) { | |
| 206 | - deferredMutations = deferredMutations.concat(mutations); | |
| 207 | - return; | |
| 208 | - } | |
| 209 | - let addedNodes = []; | |
| 210 | - let removedNodes = /* @__PURE__ */ new Set(); | |
| 211 | - let addedAttributes = /* @__PURE__ */ new Map(); | |
| 212 | - let removedAttributes = /* @__PURE__ */ new Map(); | |
| 213 | - for (let i = 0; i < mutations.length; i++) { | |
| 214 | - if (mutations[i].target._x_ignoreMutationObserver) | |
| 215 | - continue; | |
| 216 | - if (mutations[i].type === "childList") { | |
| 217 | - mutations[i].removedNodes.forEach((node) => { | |
| 218 | - if (node.nodeType !== 1) | |
| 219 | - return; | |
| 220 | - if (!node._x_marker) | |
| 221 | - return; | |
| 222 | - removedNodes.add(node); | |
| 223 | - }); | |
| 224 | - mutations[i].addedNodes.forEach((node) => { | |
| 225 | - if (node.nodeType !== 1) | |
| 226 | - return; | |
| 227 | - if (removedNodes.has(node)) { | |
| 228 | - removedNodes.delete(node); | |
| 229 | - return; | |
| 230 | - } | |
| 231 | - if (node._x_marker) | |
| 232 | - return; | |
| 233 | - addedNodes.push(node); | |
| 234 | - }); | |
| 235 | - } | |
| 236 | - if (mutations[i].type === "attributes") { | |
| 237 | - let el = mutations[i].target; | |
| 238 | - let name = mutations[i].attributeName; | |
| 239 | - let oldValue = mutations[i].oldValue; | |
| 240 | - let add2 = () => { | |
| 241 | - if (!addedAttributes.has(el)) | |
| 242 | - addedAttributes.set(el, []); | |
| 243 | - addedAttributes.get(el).push({ name, value: el.getAttribute(name) }); | |
| 244 | - }; | |
| 245 | - let remove = () => { | |
| 246 | - if (!removedAttributes.has(el)) | |
| 247 | - removedAttributes.set(el, []); | |
| 248 | - removedAttributes.get(el).push(name); | |
| 249 | - }; | |
| 250 | - if (el.hasAttribute(name) && oldValue === null) { | |
| 251 | - add2(); | |
| 252 | - } else if (el.hasAttribute(name)) { | |
| 253 | - remove(); | |
| 254 | - add2(); | |
| 255 | - } else { | |
| 256 | - remove(); | |
| 257 | - } | |
| 258 | - } | |
| 259 | - } | |
| 260 | - removedAttributes.forEach((attrs, el) => { | |
| 261 | - cleanupAttributes(el, attrs); | |
| 262 | - }); | |
| 263 | - addedAttributes.forEach((attrs, el) => { | |
| 264 | - onAttributeAddeds.forEach((i) => i(el, attrs)); | |
| 265 | - }); | |
| 266 | - for (let node of removedNodes) { | |
| 267 | - if (addedNodes.some((i) => i.contains(node))) | |
| 268 | - continue; | |
| 269 | - onElRemoveds.forEach((i) => i(node)); | |
| 270 | - } | |
| 271 | - for (let node of addedNodes) { | |
| 272 | - if (!node.isConnected) | |
| 273 | - continue; | |
| 274 | - onElAddeds.forEach((i) => i(node)); | |
| 275 | - } | |
| 276 | - addedNodes = null; | |
| 277 | - removedNodes = null; | |
| 278 | - addedAttributes = null; | |
| 279 | - removedAttributes = null; | |
| 280 | -} | |
| 392 | +${expression ? "Expression: \"" + expression + "\"\n\n" : ""}`, el); | |
| 393 | + setTimeout(() => { | |
| 394 | + throw error2; | |
| 395 | + }, 0); | |
| 396 | + } | |
| 397 | + var shouldAutoEvaluateFunctions = true; | |
| 398 | + function dontAutoEvaluateFunctions(callback) { | |
| 399 | + let cache = shouldAutoEvaluateFunctions; | |
| 400 | + shouldAutoEvaluateFunctions = false; | |
| 401 | + let result = callback(); | |
| 402 | + shouldAutoEvaluateFunctions = cache; | |
| 403 | + return result; | |
| 404 | + } | |
| 405 | + function evaluate(el, expression, extras = {}) { | |
| 406 | + let result; | |
| 407 | + evaluateLater(el, expression)((value) => result = value, extras); | |
| 408 | + return result; | |
| 409 | + } | |
| 410 | + function evaluateLater(...args) { | |
| 411 | + return theEvaluatorFunction(...args); | |
| 412 | + } | |
| 413 | + var theEvaluatorFunction = normalEvaluator; | |
| 414 | + function setEvaluator(newEvaluator) { | |
| 415 | + theEvaluatorFunction = newEvaluator; | |
| 416 | + } | |
| 417 | + function normalEvaluator(el, expression) { | |
| 418 | + let overriddenMagics = {}; | |
| 419 | + injectMagics(overriddenMagics, el); | |
| 420 | + let dataStack = [overriddenMagics, ...closestDataStack(el)]; | |
| 421 | + let evaluator = typeof expression === "function" ? generateEvaluatorFromFunction(dataStack, expression) : generateEvaluatorFromString(dataStack, expression, el); | |
| 422 | + return tryCatch.bind(null, el, expression, evaluator); | |
| 423 | + } | |
| 424 | + function generateEvaluatorFromFunction(dataStack, func) { | |
| 425 | + return (receiver = () => {}, { scope: scope2 = {}, params = [], context } = {}) => { | |
| 426 | + runIfTypeOfFunction(receiver, func.apply(mergeProxies([scope2, ...dataStack]), params)); | |
| 427 | + }; | |
| 428 | + } | |
| 429 | + var evaluatorMemo = {}; | |
| 430 | + function generateFunctionFromString(expression, el) { | |
| 431 | + if (evaluatorMemo[expression]) return evaluatorMemo[expression]; | |
| 432 | + let AsyncFunction = Object.getPrototypeOf(async function() {}).constructor; | |
| 433 | + let rightSideSafeExpression = /^[\n\s]*if.*\(.*\)/.test(expression.trim()) || /^(let|const)\s/.test(expression.trim()) ? `(async()=>{ ${expression} })()` : expression; | |
| 434 | + const safeAsyncFunction = () => { | |
| 435 | + try { | |
| 436 | + let func2 = new AsyncFunction(["__self", "scope"], `with (scope) { __self.result = ${rightSideSafeExpression} }; __self.finished = true; return __self.result;`); | |
| 437 | + Object.defineProperty(func2, "name", { value: `[Alpine] ${expression}` }); | |
| 438 | + return func2; | |
| 439 | + } catch (error2) { | |
| 440 | + handleError(error2, el, expression); | |
| 441 | + return Promise.resolve(); | |
| 442 | + } | |
| 443 | + }; | |
| 444 | + let func = safeAsyncFunction(); | |
| 445 | + evaluatorMemo[expression] = func; | |
| 446 | + return func; | |
| 447 | + } | |
| 448 | + function generateEvaluatorFromString(dataStack, expression, el) { | |
| 449 | + let func = generateFunctionFromString(expression, el); | |
| 450 | + return (receiver = () => {}, { scope: scope2 = {}, params = [], context } = {}) => { | |
| 451 | + func.result = void 0; | |
| 452 | + func.finished = false; | |
| 453 | + let completeScope = mergeProxies([scope2, ...dataStack]); | |
| 454 | + if (typeof func === "function") { | |
| 455 | + let promise = func.call(context, func, completeScope).catch((error2) => handleError(error2, el, expression)); | |
| 456 | + if (func.finished) { | |
| 457 | + runIfTypeOfFunction(receiver, func.result, completeScope, params, el); | |
| 458 | + func.result = void 0; | |
| 459 | + } else promise.then((result) => { | |
| 460 | + runIfTypeOfFunction(receiver, result, completeScope, params, el); | |
| 461 | + }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0); | |
| 462 | + } | |
| 463 | + }; | |
| 464 | + } | |
| 465 | + function runIfTypeOfFunction(receiver, value, scope2, params, el) { | |
| 466 | + if (shouldAutoEvaluateFunctions && typeof value === "function") { | |
| 467 | + let result = value.apply(scope2, params); | |
| 468 | + if (result instanceof Promise) result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value)); | |
| 469 | + else receiver(result); | |
| 470 | + } else if (typeof value === "object" && value instanceof Promise) value.then((i) => receiver(i)); | |
| 471 | + else receiver(value); | |
| 472 | + } | |
| 473 | + var prefixAsString = "x-"; | |
| 474 | + function prefix(subject = "") { | |
| 475 | + return prefixAsString + subject; | |
| 476 | + } | |
| 477 | + function setPrefix(newPrefix) { | |
| 478 | + prefixAsString = newPrefix; | |
| 479 | + } | |
| 480 | + var directiveHandlers = {}; | |
| 481 | + function directive(name, callback) { | |
| 482 | + directiveHandlers[name] = callback; | |
| 483 | + return { before(directive2) { | |
| 484 | + if (!directiveHandlers[directive2]) { | |
| 485 | + console.warn(String.raw`Cannot find directive \`${directive2}\`. \`${name}\` will use the default order of execution`); | |
| 486 | + return; | |
| 487 | + } | |
| 488 | + const pos = directiveOrder.indexOf(directive2); | |
| 489 | + directiveOrder.splice(pos >= 0 ? pos : directiveOrder.indexOf("DEFAULT"), 0, name); | |
| 490 | + } }; | |
| 491 | + } | |
| 492 | + function directiveExists(name) { | |
| 493 | + return Object.keys(directiveHandlers).includes(name); | |
| 494 | + } | |
| 495 | + function directives(el, attributes, originalAttributeOverride) { | |
| 496 | + attributes = Array.from(attributes); | |
| 497 | + if (el._x_virtualDirectives) { | |
| 498 | + let vAttributes = Object.entries(el._x_virtualDirectives).map(([name, value]) => ({ | |
| 499 | + name, | |
| 500 | + value | |
| 501 | + })); | |
| 502 | + let staticAttributes = attributesOnly(vAttributes); | |
| 503 | + vAttributes = vAttributes.map((attribute) => { | |
| 504 | + if (staticAttributes.find((attr) => attr.name === attribute.name)) return { | |
| 505 | + name: `x-bind:${attribute.name}`, | |
| 506 | + value: `"${attribute.value}"` | |
| 507 | + }; | |
| 508 | + return attribute; | |
| 509 | + }); | |
| 510 | + attributes = attributes.concat(vAttributes); | |
| 511 | + } | |
| 512 | + let transformedAttributeMap = {}; | |
| 513 | + return attributes.map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority).map((directive2) => { | |
| 514 | + return getDirectiveHandler(el, directive2); | |
| 515 | + }); | |
| 516 | + } | |
| 517 | + function attributesOnly(attributes) { | |
| 518 | + return Array.from(attributes).map(toTransformedAttributes()).filter((attr) => !outNonAlpineAttributes(attr)); | |
| 519 | + } | |
| 520 | + var isDeferringHandlers = false; | |
| 521 | + var directiveHandlerStacks = /* @__PURE__ */ new Map(); | |
| 522 | + var currentHandlerStackKey = Symbol(); | |
| 523 | + function deferHandlingDirectives(callback) { | |
| 524 | + isDeferringHandlers = true; | |
| 525 | + let key = Symbol(); | |
| 526 | + currentHandlerStackKey = key; | |
| 527 | + directiveHandlerStacks.set(key, []); | |
| 528 | + let flushHandlers = () => { | |
| 529 | + while (directiveHandlerStacks.get(key).length) directiveHandlerStacks.get(key).shift()(); | |
| 530 | + directiveHandlerStacks.delete(key); | |
| 531 | + }; | |
| 532 | + let stopDeferring = () => { | |
| 533 | + isDeferringHandlers = false; | |
| 534 | + flushHandlers(); | |
| 535 | + }; | |
| 536 | + callback(flushHandlers); | |
| 537 | + stopDeferring(); | |
| 538 | + } | |
| 539 | + function getElementBoundUtilities(el) { | |
| 540 | + let cleanups = []; | |
| 541 | + let cleanup2 = (callback) => cleanups.push(callback); | |
| 542 | + let [effect3, cleanupEffect] = elementBoundEffect(el); | |
| 543 | + cleanups.push(cleanupEffect); | |
| 544 | + let utilities = { | |
| 545 | + Alpine: alpine_default, | |
| 546 | + effect: effect3, | |
| 547 | + cleanup: cleanup2, | |
| 548 | + evaluateLater: evaluateLater.bind(evaluateLater, el), | |
| 549 | + evaluate: evaluate.bind(evaluate, el) | |
| 550 | + }; | |
| 551 | + let doCleanup = () => cleanups.forEach((i) => i()); | |
| 552 | + return [utilities, doCleanup]; | |
| 553 | + } | |
| 554 | + function getDirectiveHandler(el, directive2) { | |
| 555 | + let noop = () => {}; | |
| 556 | + let handler4 = directiveHandlers[directive2.type] || noop; | |
| 557 | + let [utilities, cleanup2] = getElementBoundUtilities(el); | |
| 558 | + onAttributeRemoved(el, directive2.original, cleanup2); | |
| 559 | + let fullHandler = () => { | |
| 560 | + if (el._x_ignore || el._x_ignoreSelf) return; | |
| 561 | + handler4.inline && handler4.inline(el, directive2, utilities); | |
| 562 | + handler4 = handler4.bind(handler4, el, directive2, utilities); | |
| 563 | + isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler4) : handler4(); | |
| 564 | + }; | |
| 565 | + fullHandler.runCleanups = cleanup2; | |
| 566 | + return fullHandler; | |
| 567 | + } | |
| 568 | + var startingWith = (subject, replacement) => ({ name, value }) => { | |
| 569 | + if (name.startsWith(subject)) name = name.replace(subject, replacement); | |
| 570 | + return { | |
| 571 | + name, | |
| 572 | + value | |
| 573 | + }; | |
| 574 | + }; | |
| 575 | + var into = (i) => i; | |
| 576 | + function toTransformedAttributes(callback = () => {}) { | |
| 577 | + return ({ name, value }) => { | |
| 578 | + let { name: newName, value: newValue } = attributeTransformers.reduce((carry, transform) => { | |
| 579 | + return transform(carry); | |
| 580 | + }, { | |
| 581 | + name, | |
| 582 | + value | |
| 583 | + }); | |
| 584 | + if (newName !== name) callback(newName, name); | |
| 585 | + return { | |
| 586 | + name: newName, | |
| 587 | + value: newValue | |
| 588 | + }; | |
| 589 | + }; | |
| 590 | + } | |
| 591 | + var attributeTransformers = []; | |
| 592 | + function mapAttributes(callback) { | |
| 593 | + attributeTransformers.push(callback); | |
| 594 | + } | |
| 595 | + function outNonAlpineAttributes({ name }) { | |
| 596 | + return alpineAttributeRegex().test(name); | |
| 597 | + } | |
| 598 | + var alpineAttributeRegex = () => new RegExp(`^${prefixAsString}([^:^.]+)\\b`); | |
| 599 | + function toParsedDirectives(transformedAttributeMap, originalAttributeOverride) { | |
| 600 | + return ({ name, value }) => { | |
| 601 | + let typeMatch = name.match(alpineAttributeRegex()); | |
| 602 | + let valueMatch = name.match(/:([a-zA-Z0-9\-_:]+)/); | |
| 603 | + let modifiers = name.match(/\.[^.\]]+(?=[^\]]*$)/g) || []; | |
| 604 | + let original = originalAttributeOverride || transformedAttributeMap[name] || name; | |
| 605 | + return { | |
| 606 | + type: typeMatch ? typeMatch[1] : null, | |
| 607 | + value: valueMatch ? valueMatch[1] : null, | |
| 608 | + modifiers: modifiers.map((i) => i.replace(".", "")), | |
| 609 | + expression: value, | |
| 610 | + original | |
| 611 | + }; | |
| 612 | + }; | |
| 613 | + } | |
| 614 | + var DEFAULT = "DEFAULT"; | |
| 615 | + var directiveOrder = [ | |
| 616 | + "ignore", | |
| 617 | + "ref", | |
| 618 | + "data", | |
| 619 | + "id", | |
| 620 | + "anchor", | |
| 621 | + "bind", | |
| 622 | + "init", | |
| 623 | + "for", | |
| 624 | + "model", | |
| 625 | + "modelable", | |
| 626 | + "transition", | |
| 627 | + "show", | |
| 628 | + "if", | |
| 629 | + DEFAULT, | |
| 630 | + "teleport" | |
| 631 | + ]; | |
| 632 | + function byPriority(a, b) { | |
| 633 | + let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type; | |
| 634 | + let typeB = directiveOrder.indexOf(b.type) === -1 ? DEFAULT : b.type; | |
| 635 | + return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB); | |
| 636 | + } | |
| 637 | + function dispatch(el, name, detail = {}) { | |
| 638 | + el.dispatchEvent(new CustomEvent(name, { | |
| 639 | + detail, | |
| 640 | + bubbles: true, | |
| 641 | + composed: true, | |
| 642 | + cancelable: true | |
| 643 | + })); | |
| 644 | + } | |
| 645 | + function walk(el, callback) { | |
| 646 | + if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) { | |
| 647 | + Array.from(el.children).forEach((el2) => walk(el2, callback)); | |
| 648 | + return; | |
| 649 | + } | |
| 650 | + let skip = false; | |
| 651 | + callback(el, () => skip = true); | |
| 652 | + if (skip) return; | |
| 653 | + let node = el.firstElementChild; | |
| 654 | + while (node) { | |
| 655 | + walk(node, callback, false); | |
| 656 | + node = node.nextElementSibling; | |
| 657 | + } | |
| 658 | + } | |
| 659 | + function warn(message, ...args) { | |
| 660 | + console.warn(`Alpine Warning: ${message}`, ...args); | |
| 661 | + } | |
| 662 | + var started = false; | |
| 663 | + function start() { | |
| 664 | + if (started) warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."); | |
| 665 | + started = true; | |
| 666 | + if (!document.body) warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"); | |
| 667 | + dispatch(document, "alpine:init"); | |
| 668 | + dispatch(document, "alpine:initializing"); | |
| 669 | + startObservingMutations(); | |
| 670 | + onElAdded((el) => initTree(el, walk)); | |
| 671 | + onElRemoved((el) => destroyTree(el)); | |
| 672 | + onAttributesAdded((el, attrs) => { | |
| 673 | + directives(el, attrs).forEach((handle) => handle()); | |
| 674 | + }); | |
| 675 | + let outNestedComponents = (el) => !closestRoot(el.parentElement, true); | |
| 676 | + Array.from(document.querySelectorAll(allSelectors().join(","))).filter(outNestedComponents).forEach((el) => { | |
| 677 | + initTree(el); | |
| 678 | + }); | |
| 679 | + dispatch(document, "alpine:initialized"); | |
| 680 | + setTimeout(() => { | |
| 681 | + warnAboutMissingPlugins(); | |
| 682 | + }); | |
| 683 | + } | |
| 684 | + var rootSelectorCallbacks = []; | |
| 685 | + var initSelectorCallbacks = []; | |
| 686 | + function rootSelectors() { | |
| 687 | + return rootSelectorCallbacks.map((fn) => fn()); | |
| 688 | + } | |
| 689 | + function allSelectors() { | |
| 690 | + return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn()); | |
| 691 | + } | |
| 692 | + function addRootSelector(selectorCallback) { | |
| 693 | + rootSelectorCallbacks.push(selectorCallback); | |
| 694 | + } | |
| 695 | + function addInitSelector(selectorCallback) { | |
| 696 | + initSelectorCallbacks.push(selectorCallback); | |
| 697 | + } | |
| 698 | + function closestRoot(el, includeInitSelectors = false) { | |
| 699 | + return findClosest(el, (element) => { | |
| 700 | + if ((includeInitSelectors ? allSelectors() : rootSelectors()).some((selector) => element.matches(selector))) return true; | |
| 701 | + }); | |
| 702 | + } | |
| 703 | + function findClosest(el, callback) { | |
| 704 | + if (!el) return; | |
| 705 | + if (callback(el)) return el; | |
| 706 | + if (el._x_teleportBack) el = el._x_teleportBack; | |
| 707 | + if (!el.parentElement) return; | |
| 708 | + return findClosest(el.parentElement, callback); | |
| 709 | + } | |
| 710 | + function isRoot(el) { | |
| 711 | + return rootSelectors().some((selector) => el.matches(selector)); | |
| 712 | + } | |
| 713 | + var initInterceptors2 = []; | |
| 714 | + function interceptInit(callback) { | |
| 715 | + initInterceptors2.push(callback); | |
| 716 | + } | |
| 717 | + var markerDispenser = 1; | |
| 718 | + function initTree(el, walker = walk, intercept = () => {}) { | |
| 719 | + if (findClosest(el, (i) => i._x_ignore)) return; | |
| 720 | + deferHandlingDirectives(() => { | |
| 721 | + walker(el, (el2, skip) => { | |
| 722 | + if (el2._x_marker) return; | |
| 723 | + intercept(el2, skip); | |
| 724 | + initInterceptors2.forEach((i) => i(el2, skip)); | |
| 725 | + directives(el2, el2.attributes).forEach((handle) => handle()); | |
| 726 | + if (!el2._x_ignore) el2._x_marker = markerDispenser++; | |
| 727 | + el2._x_ignore && skip(); | |
| 728 | + }); | |
| 729 | + }); | |
| 730 | + } | |
| 731 | + function destroyTree(root, walker = walk) { | |
| 732 | + walker(root, (el) => { | |
| 733 | + cleanupElement(el); | |
| 734 | + cleanupAttributes(el); | |
| 735 | + delete el._x_marker; | |
| 736 | + }); | |
| 737 | + } | |
| 738 | + function warnAboutMissingPlugins() { | |
| 739 | + [ | |
| 740 | + [ | |
| 741 | + "ui", | |
| 742 | + "dialog", | |
| 743 | + ["[x-dialog], [x-popover]"] | |
| 744 | + ], | |
| 745 | + [ | |
| 746 | + "anchor", | |
| 747 | + "anchor", | |
| 748 | + ["[x-anchor]"] | |
| 749 | + ], | |
| 750 | + [ | |
| 751 | + "sort", | |
| 752 | + "sort", | |
| 753 | + ["[x-sort]"] | |
| 754 | + ] | |
| 755 | + ].forEach(([plugin2, directive2, selectors]) => { | |
| 756 | + if (directiveExists(directive2)) return; | |
| 757 | + selectors.some((selector) => { | |
| 758 | + if (document.querySelector(selector)) { | |
| 759 | + warn(`found "${selector}", but missing ${plugin2} plugin`); | |
| 760 | + return true; | |
| 761 | + } | |
| 762 | + }); | |
| 763 | + }); | |
| 764 | + } | |
| 765 | + var tickStack = []; | |
| 766 | + var isHolding = false; | |
| 767 | + function nextTick(callback = () => {}) { | |
| 768 | + queueMicrotask(() => { | |
| 769 | + isHolding || setTimeout(() => { | |
| 770 | + releaseNextTicks(); | |
| 771 | + }); | |
| 772 | + }); | |
| 773 | + return new Promise((res) => { | |
| 774 | + tickStack.push(() => { | |
| 775 | + callback(); | |
| 776 | + res(); | |
| 777 | + }); | |
| 778 | + }); | |
| 779 | + } | |
| 780 | + function releaseNextTicks() { | |
| 781 | + isHolding = false; | |
| 782 | + while (tickStack.length) tickStack.shift()(); | |
| 783 | + } | |
| 784 | + function holdNextTicks() { | |
| 785 | + isHolding = true; | |
| 786 | + } | |
| 787 | + function setClasses(el, value) { | |
| 788 | + if (Array.isArray(value)) return setClassesFromString(el, value.join(" ")); | |
| 789 | + else if (typeof value === "object" && value !== null) return setClassesFromObject(el, value); | |
| 790 | + else if (typeof value === "function") return setClasses(el, value()); | |
| 791 | + return setClassesFromString(el, value); | |
| 792 | + } | |
| 793 | + function setClassesFromString(el, classString) { | |
| 794 | + let missingClasses = (classString2) => classString2.split(" ").filter((i) => !el.classList.contains(i)).filter(Boolean); | |
| 795 | + let addClassesAndReturnUndo = (classes) => { | |
| 796 | + el.classList.add(...classes); | |
| 797 | + return () => { | |
| 798 | + el.classList.remove(...classes); | |
| 799 | + }; | |
| 800 | + }; | |
| 801 | + classString = classString === true ? classString = "" : classString || ""; | |
| 802 | + return addClassesAndReturnUndo(missingClasses(classString)); | |
| 803 | + } | |
| 804 | + function setClassesFromObject(el, classObject) { | |
| 805 | + let split = (classString) => classString.split(" ").filter(Boolean); | |
| 806 | + let forAdd = Object.entries(classObject).flatMap(([classString, bool]) => bool ? split(classString) : false).filter(Boolean); | |
| 807 | + let forRemove = Object.entries(classObject).flatMap(([classString, bool]) => !bool ? split(classString) : false).filter(Boolean); | |
| 808 | + let added = []; | |
| 809 | + let removed = []; | |
| 810 | + forRemove.forEach((i) => { | |
| 811 | + if (el.classList.contains(i)) { | |
| 812 | + el.classList.remove(i); | |
| 813 | + removed.push(i); | |
| 814 | + } | |
| 815 | + }); | |
| 816 | + forAdd.forEach((i) => { | |
| 817 | + if (!el.classList.contains(i)) { | |
| 818 | + el.classList.add(i); | |
| 819 | + added.push(i); | |
| 820 | + } | |
| 821 | + }); | |
| 822 | + return () => { | |
| 823 | + removed.forEach((i) => el.classList.add(i)); | |
| 824 | + added.forEach((i) => el.classList.remove(i)); | |
| 825 | + }; | |
| 826 | + } | |
| 827 | + function setStyles(el, value) { | |
| 828 | + if (typeof value === "object" && value !== null) return setStylesFromObject(el, value); | |
| 829 | + return setStylesFromString(el, value); | |
| 830 | + } | |
| 831 | + function setStylesFromObject(el, value) { | |
| 832 | + let previousStyles = {}; | |
| 833 | + Object.entries(value).forEach(([key, value2]) => { | |
| 834 | + previousStyles[key] = el.style[key]; | |
| 835 | + if (!key.startsWith("--")) key = kebabCase(key); | |
| 836 | + el.style.setProperty(key, value2); | |
| 837 | + }); | |
| 838 | + setTimeout(() => { | |
| 839 | + if (el.style.length === 0) el.removeAttribute("style"); | |
| 840 | + }); | |
| 841 | + return () => { | |
| 842 | + setStyles(el, previousStyles); | |
| 843 | + }; | |
| 844 | + } | |
| 845 | + function setStylesFromString(el, value) { | |
| 846 | + let cache = el.getAttribute("style", value); | |
| 847 | + el.setAttribute("style", value); | |
| 848 | + return () => { | |
| 849 | + el.setAttribute("style", cache || ""); | |
| 850 | + }; | |
| 851 | + } | |
| 852 | + function kebabCase(subject) { | |
| 853 | + return subject.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); | |
| 854 | + } | |
| 855 | + function once(callback, fallback = () => {}) { | |
| 856 | + let called = false; | |
| 857 | + return function() { | |
| 858 | + if (!called) { | |
| 859 | + called = true; | |
| 860 | + callback.apply(this, arguments); | |
| 861 | + } else fallback.apply(this, arguments); | |
| 862 | + }; | |
| 863 | + } | |
| 864 | + directive("transition", (el, { value, modifiers, expression }, { evaluate: evaluate2 }) => { | |
| 865 | + if (typeof expression === "function") expression = evaluate2(expression); | |
| 866 | + if (expression === false) return; | |
| 867 | + if (!expression || typeof expression === "boolean") registerTransitionsFromHelper(el, modifiers, value); | |
| 868 | + else registerTransitionsFromClassString(el, expression, value); | |
| 869 | + }); | |
| 870 | + function registerTransitionsFromClassString(el, classString, stage) { | |
| 871 | + registerTransitionObject(el, setClasses, ""); | |
| 872 | + ({ | |
| 873 | + "enter": (classes) => { | |
| 874 | + el._x_transition.enter.during = classes; | |
| 875 | + }, | |
| 876 | + "enter-start": (classes) => { | |
| 877 | + el._x_transition.enter.start = classes; | |
| 878 | + }, | |
| 879 | + "enter-end": (classes) => { | |
| 880 | + el._x_transition.enter.end = classes; | |
| 881 | + }, | |
| 882 | + "leave": (classes) => { | |
| 883 | + el._x_transition.leave.during = classes; | |
| 884 | + }, | |
| 885 | + "leave-start": (classes) => { | |
| 886 | + el._x_transition.leave.start = classes; | |
| 887 | + }, | |
| 888 | + "leave-end": (classes) => { | |
| 889 | + el._x_transition.leave.end = classes; | |
| 890 | + } | |
| 891 | + })[stage](classString); | |
| 892 | + } | |
| 893 | + function registerTransitionsFromHelper(el, modifiers, stage) { | |
| 894 | + registerTransitionObject(el, setStyles); | |
| 895 | + let doesntSpecify = !modifiers.includes("in") && !modifiers.includes("out") && !stage; | |
| 896 | + let transitioningIn = doesntSpecify || modifiers.includes("in") || ["enter"].includes(stage); | |
| 897 | + let transitioningOut = doesntSpecify || modifiers.includes("out") || ["leave"].includes(stage); | |
| 898 | + if (modifiers.includes("in") && !doesntSpecify) modifiers = modifiers.filter((i, index) => index < modifiers.indexOf("out")); | |
| 899 | + if (modifiers.includes("out") && !doesntSpecify) modifiers = modifiers.filter((i, index) => index > modifiers.indexOf("out")); | |
| 900 | + let wantsAll = !modifiers.includes("opacity") && !modifiers.includes("scale"); | |
| 901 | + let wantsOpacity = wantsAll || modifiers.includes("opacity"); | |
| 902 | + let wantsScale = wantsAll || modifiers.includes("scale"); | |
| 903 | + let opacityValue = wantsOpacity ? 0 : 1; | |
| 904 | + let scaleValue = wantsScale ? modifierValue(modifiers, "scale", 95) / 100 : 1; | |
| 905 | + let delay = modifierValue(modifiers, "delay", 0) / 1e3; | |
| 906 | + let origin = modifierValue(modifiers, "origin", "center"); | |
| 907 | + let property = "opacity, transform"; | |
| 908 | + let durationIn = modifierValue(modifiers, "duration", 150) / 1e3; | |
| 909 | + let durationOut = modifierValue(modifiers, "duration", 75) / 1e3; | |
| 910 | + let easing = `cubic-bezier(0.4, 0.0, 0.2, 1)`; | |
| 911 | + if (transitioningIn) { | |
| 912 | + el._x_transition.enter.during = { | |
| 913 | + transformOrigin: origin, | |
| 914 | + transitionDelay: `${delay}s`, | |
| 915 | + transitionProperty: property, | |
| 916 | + transitionDuration: `${durationIn}s`, | |
| 917 | + transitionTimingFunction: easing | |
| 918 | + }; | |
| 919 | + el._x_transition.enter.start = { | |
| 920 | + opacity: opacityValue, | |
| 921 | + transform: `scale(${scaleValue})` | |
| 922 | + }; | |
| 923 | + el._x_transition.enter.end = { | |
| 924 | + opacity: 1, | |
| 925 | + transform: `scale(1)` | |
| 926 | + }; | |
| 927 | + } | |
| 928 | + if (transitioningOut) { | |
| 929 | + el._x_transition.leave.during = { | |
| 930 | + transformOrigin: origin, | |
| 931 | + transitionDelay: `${delay}s`, | |
| 932 | + transitionProperty: property, | |
| 933 | + transitionDuration: `${durationOut}s`, | |
| 934 | + transitionTimingFunction: easing | |
| 935 | + }; | |
| 936 | + el._x_transition.leave.start = { | |
| 937 | + opacity: 1, | |
| 938 | + transform: `scale(1)` | |
| 939 | + }; | |
| 940 | + el._x_transition.leave.end = { | |
| 941 | + opacity: opacityValue, | |
| 942 | + transform: `scale(${scaleValue})` | |
| 943 | + }; | |
| 944 | + } | |
| 945 | + } | |
| 946 | + function registerTransitionObject(el, setFunction, defaultValue = {}) { | |
| 947 | + if (!el._x_transition) el._x_transition = { | |
| 948 | + enter: { | |
| 949 | + during: defaultValue, | |
| 950 | + start: defaultValue, | |
| 951 | + end: defaultValue | |
| 952 | + }, | |
| 953 | + leave: { | |
| 954 | + during: defaultValue, | |
| 955 | + start: defaultValue, | |
| 956 | + end: defaultValue | |
| 957 | + }, | |
| 958 | + in(before = () => {}, after = () => {}) { | |
| 959 | + transition(el, setFunction, { | |
| 960 | + during: this.enter.during, | |
| 961 | + start: this.enter.start, | |
| 962 | + end: this.enter.end | |
| 963 | + }, before, after); | |
| 964 | + }, | |
| 965 | + out(before = () => {}, after = () => {}) { | |
| 966 | + transition(el, setFunction, { | |
| 967 | + during: this.leave.during, | |
| 968 | + start: this.leave.start, | |
| 969 | + end: this.leave.end | |
| 970 | + }, before, after); | |
| 971 | + } | |
| 972 | + }; | |
| 973 | + } | |
| 974 | + window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) { | |
| 975 | + const nextTick2 = document.visibilityState === "visible" ? requestAnimationFrame : setTimeout; | |
| 976 | + let clickAwayCompatibleShow = () => nextTick2(show); | |
| 977 | + if (value) { | |
| 978 | + if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow(); | |
| 979 | + else el._x_transition ? el._x_transition.in(show) : clickAwayCompatibleShow(); | |
| 980 | + return; | |
| 981 | + } | |
| 982 | + el._x_hidePromise = el._x_transition ? new Promise((resolve, reject) => { | |
| 983 | + el._x_transition.out(() => {}, () => resolve(hide)); | |
| 984 | + el._x_transitioning && el._x_transitioning.beforeCancel(() => reject({ isFromCancelledTransition: true })); | |
| 985 | + }) : Promise.resolve(hide); | |
| 986 | + queueMicrotask(() => { | |
| 987 | + let closest = closestHide(el); | |
| 988 | + if (closest) { | |
| 989 | + if (!closest._x_hideChildren) closest._x_hideChildren = []; | |
| 990 | + closest._x_hideChildren.push(el); | |
| 991 | + } else nextTick2(() => { | |
| 992 | + let hideAfterChildren = (el2) => { | |
| 993 | + let carry = Promise.all([el2._x_hidePromise, ...(el2._x_hideChildren || []).map(hideAfterChildren)]).then(([i]) => i?.()); | |
| 994 | + delete el2._x_hidePromise; | |
| 995 | + delete el2._x_hideChildren; | |
| 996 | + return carry; | |
| 997 | + }; | |
| 998 | + hideAfterChildren(el).catch((e) => { | |
| 999 | + if (!e.isFromCancelledTransition) throw e; | |
| 1000 | + }); | |
| 1001 | + }); | |
| 1002 | + }); | |
| 1003 | + }; | |
| 1004 | + function closestHide(el) { | |
| 1005 | + let parent = el.parentNode; | |
| 1006 | + if (!parent) return; | |
| 1007 | + return parent._x_hidePromise ? parent : closestHide(parent); | |
| 1008 | + } | |
| 1009 | + function transition(el, setFunction, { during, start: start2, end } = {}, before = () => {}, after = () => {}) { | |
| 1010 | + if (el._x_transitioning) el._x_transitioning.cancel(); | |
| 1011 | + if (Object.keys(during).length === 0 && Object.keys(start2).length === 0 && Object.keys(end).length === 0) { | |
| 1012 | + before(); | |
| 1013 | + after(); | |
| 1014 | + return; | |
| 1015 | + } | |
| 1016 | + let undoStart; | |
| 1017 | + let undoDuring; | |
| 1018 | + let undoEnd; | |
| 1019 | + performTransition(el, { | |
| 1020 | + start() { | |
| 1021 | + undoStart = setFunction(el, start2); | |
| 1022 | + }, | |
| 1023 | + during() { | |
| 1024 | + undoDuring = setFunction(el, during); | |
| 1025 | + }, | |
| 1026 | + before, | |
| 1027 | + end() { | |
| 1028 | + undoStart(); | |
| 1029 | + undoEnd = setFunction(el, end); | |
| 1030 | + }, | |
| 1031 | + after, | |
| 1032 | + cleanup() { | |
| 1033 | + undoDuring(); | |
| 1034 | + undoEnd(); | |
| 1035 | + } | |
| 1036 | + }); | |
| 1037 | + } | |
| 1038 | + function performTransition(el, stages) { | |
| 1039 | + let interrupted; | |
| 1040 | + let reachedBefore; | |
| 1041 | + let reachedEnd; | |
| 1042 | + let finish = once(() => { | |
| 1043 | + mutateDom(() => { | |
| 1044 | + interrupted = true; | |
| 1045 | + if (!reachedBefore) stages.before(); | |
| 1046 | + if (!reachedEnd) { | |
| 1047 | + stages.end(); | |
| 1048 | + releaseNextTicks(); | |
| 1049 | + } | |
| 1050 | + stages.after(); | |
| 1051 | + if (el.isConnected) stages.cleanup(); | |
| 1052 | + delete el._x_transitioning; | |
| 1053 | + }); | |
| 1054 | + }); | |
| 1055 | + el._x_transitioning = { | |
| 1056 | + beforeCancels: [], | |
| 1057 | + beforeCancel(callback) { | |
| 1058 | + this.beforeCancels.push(callback); | |
| 1059 | + }, | |
| 1060 | + cancel: once(function() { | |
| 1061 | + while (this.beforeCancels.length) this.beforeCancels.shift()(); | |
| 1062 | + finish(); | |
| 1063 | + }), | |
| 1064 | + finish | |
| 1065 | + }; | |
| 1066 | + mutateDom(() => { | |
| 1067 | + stages.start(); | |
| 1068 | + stages.during(); | |
| 1069 | + }); | |
| 1070 | + holdNextTicks(); | |
| 1071 | + requestAnimationFrame(() => { | |
| 1072 | + if (interrupted) return; | |
| 1073 | + let duration = Number(getComputedStyle(el).transitionDuration.replace(/,.*/, "").replace("s", "")) * 1e3; | |
| 1074 | + let delay = Number(getComputedStyle(el).transitionDelay.replace(/,.*/, "").replace("s", "")) * 1e3; | |
| 1075 | + if (duration === 0) duration = Number(getComputedStyle(el).animationDuration.replace("s", "")) * 1e3; | |
| 1076 | + mutateDom(() => { | |
| 1077 | + stages.before(); | |
| 1078 | + }); | |
| 1079 | + reachedBefore = true; | |
| 1080 | + requestAnimationFrame(() => { | |
| 1081 | + if (interrupted) return; | |
| 1082 | + mutateDom(() => { | |
| 1083 | + stages.end(); | |
| 1084 | + }); | |
| 1085 | + releaseNextTicks(); | |
| 1086 | + setTimeout(el._x_transitioning.finish, duration + delay); | |
| 1087 | + reachedEnd = true; | |
| 1088 | + }); | |
| 1089 | + }); | |
| 1090 | + } | |
| 1091 | + function modifierValue(modifiers, key, fallback) { | |
| 1092 | + if (modifiers.indexOf(key) === -1) return fallback; | |
| 1093 | + const rawValue = modifiers[modifiers.indexOf(key) + 1]; | |
| 1094 | + if (!rawValue) return fallback; | |
| 1095 | + if (key === "scale") { | |
| 1096 | + if (isNaN(rawValue)) return fallback; | |
| 1097 | + } | |
| 1098 | + if (key === "duration" || key === "delay") { | |
| 1099 | + let match = rawValue.match(/([0-9]+)ms/); | |
| 1100 | + if (match) return match[1]; | |
| 1101 | + } | |
| 1102 | + if (key === "origin") { | |
| 1103 | + if ([ | |
| 1104 | + "top", | |
| 1105 | + "right", | |
| 1106 | + "left", | |
| 1107 | + "center", | |
| 1108 | + "bottom" | |
| 1109 | + ].includes(modifiers[modifiers.indexOf(key) + 2])) return [rawValue, modifiers[modifiers.indexOf(key) + 2]].join(" "); | |
| 1110 | + } | |
| 1111 | + return rawValue; | |
| 1112 | + } | |
| 1113 | + var isCloning = false; | |
| 1114 | + function skipDuringClone(callback, fallback = () => {}) { | |
| 1115 | + return (...args) => isCloning ? fallback(...args) : callback(...args); | |
| 1116 | + } | |
| 1117 | + function onlyDuringClone(callback) { | |
| 1118 | + return (...args) => isCloning && callback(...args); | |
| 1119 | + } | |
| 1120 | + var interceptors = []; | |
| 1121 | + function interceptClone(callback) { | |
| 1122 | + interceptors.push(callback); | |
| 1123 | + } | |
| 1124 | + function cloneNode(from, to) { | |
| 1125 | + interceptors.forEach((i) => i(from, to)); | |
| 1126 | + isCloning = true; | |
| 1127 | + dontRegisterReactiveSideEffects(() => { | |
| 1128 | + initTree(to, (el, callback) => { | |
| 1129 | + callback(el, () => {}); | |
| 1130 | + }); | |
| 1131 | + }); | |
| 1132 | + isCloning = false; | |
| 1133 | + } | |
| 1134 | + var isCloningLegacy = false; | |
| 1135 | + function clone(oldEl, newEl) { | |
| 1136 | + if (!newEl._x_dataStack) newEl._x_dataStack = oldEl._x_dataStack; | |
| 1137 | + isCloning = true; | |
| 1138 | + isCloningLegacy = true; | |
| 1139 | + dontRegisterReactiveSideEffects(() => { | |
| 1140 | + cloneTree(newEl); | |
| 1141 | + }); | |
| 1142 | + isCloning = false; | |
| 1143 | + isCloningLegacy = false; | |
| 1144 | + } | |
| 1145 | + function cloneTree(el) { | |
| 1146 | + let hasRunThroughFirstEl = false; | |
| 1147 | + let shallowWalker = (el2, callback) => { | |
| 1148 | + walk(el2, (el3, skip) => { | |
| 1149 | + if (hasRunThroughFirstEl && isRoot(el3)) return skip(); | |
| 1150 | + hasRunThroughFirstEl = true; | |
| 1151 | + callback(el3, skip); | |
| 1152 | + }); | |
| 1153 | + }; | |
| 1154 | + initTree(el, shallowWalker); | |
| 1155 | + } | |
| 1156 | + function dontRegisterReactiveSideEffects(callback) { | |
| 1157 | + let cache = effect; | |
| 1158 | + overrideEffect((callback2, el) => { | |
| 1159 | + let storedEffect = cache(callback2); | |
| 1160 | + release(storedEffect); | |
| 1161 | + return () => {}; | |
| 1162 | + }); | |
| 1163 | + callback(); | |
| 1164 | + overrideEffect(cache); | |
| 1165 | + } | |
| 1166 | + function bind(el, name, value, modifiers = []) { | |
| 1167 | + if (!el._x_bindings) el._x_bindings = reactive({}); | |
| 1168 | + el._x_bindings[name] = value; | |
| 1169 | + name = modifiers.includes("camel") ? camelCase(name) : name; | |
| 1170 | + switch (name) { | |
| 1171 | + case "value": | |
| 1172 | + bindInputValue(el, value); | |
| 1173 | + break; | |
| 1174 | + case "style": | |
| 1175 | + bindStyles(el, value); | |
| 1176 | + break; | |
| 1177 | + case "class": | |
| 1178 | + bindClasses(el, value); | |
| 1179 | + break; | |
| 1180 | + case "selected": | |
| 1181 | + case "checked": | |
| 1182 | + bindAttributeAndProperty(el, name, value); | |
| 1183 | + break; | |
| 1184 | + default: | |
| 1185 | + bindAttribute(el, name, value); | |
| 1186 | + break; | |
| 1187 | + } | |
| 1188 | + } | |
| 1189 | + function bindInputValue(el, value) { | |
| 1190 | + if (isRadio(el)) { | |
| 1191 | + if (el.attributes.value === void 0) el.value = value; | |
| 1192 | + if (window.fromModel) if (typeof value === "boolean") el.checked = safeParseBoolean(el.value) === value; | |
| 1193 | + else el.checked = checkedAttrLooseCompare(el.value, value); | |
| 1194 | + } else if (isCheckbox(el)) if (Number.isInteger(value)) el.value = value; | |
| 1195 | + else if (!Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) el.value = String(value); | |
| 1196 | + else if (Array.isArray(value)) el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value)); | |
| 1197 | + else el.checked = !!value; | |
| 1198 | + else if (el.tagName === "SELECT") updateSelect(el, value); | |
| 1199 | + else { | |
| 1200 | + if (el.value === value) return; | |
| 1201 | + el.value = value === void 0 ? "" : value; | |
| 1202 | + } | |
| 1203 | + } | |
| 1204 | + function bindClasses(el, value) { | |
| 1205 | + if (el._x_undoAddedClasses) el._x_undoAddedClasses(); | |
| 1206 | + el._x_undoAddedClasses = setClasses(el, value); | |
| 1207 | + } | |
| 1208 | + function bindStyles(el, value) { | |
| 1209 | + if (el._x_undoAddedStyles) el._x_undoAddedStyles(); | |
| 1210 | + el._x_undoAddedStyles = setStyles(el, value); | |
| 1211 | + } | |
| 1212 | + function bindAttributeAndProperty(el, name, value) { | |
| 1213 | + bindAttribute(el, name, value); | |
| 1214 | + setPropertyIfChanged(el, name, value); | |
| 1215 | + } | |
| 1216 | + function bindAttribute(el, name, value) { | |
| 1217 | + if ([ | |
| 1218 | + null, | |
| 1219 | + void 0, | |
| 1220 | + false | |
| 1221 | + ].includes(value) && attributeShouldntBePreservedIfFalsy(name)) el.removeAttribute(name); | |
| 1222 | + else { | |
| 1223 | + if (isBooleanAttr(name)) value = name; | |
| 1224 | + setIfChanged(el, name, value); | |
| 1225 | + } | |
| 1226 | + } | |
| 1227 | + function setIfChanged(el, attrName, value) { | |
| 1228 | + if (el.getAttribute(attrName) != value) el.setAttribute(attrName, value); | |
| 1229 | + } | |
| 1230 | + function setPropertyIfChanged(el, propName, value) { | |
| 1231 | + if (el[propName] !== value) el[propName] = value; | |
| 1232 | + } | |
| 1233 | + function updateSelect(el, value) { | |
| 1234 | + const arrayWrappedValue = [].concat(value).map((value2) => { | |
| 1235 | + return value2 + ""; | |
| 1236 | + }); | |
| 1237 | + Array.from(el.options).forEach((option) => { | |
| 1238 | + option.selected = arrayWrappedValue.includes(option.value); | |
| 1239 | + }); | |
| 1240 | + } | |
| 1241 | + function camelCase(subject) { | |
| 1242 | + return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); | |
| 1243 | + } | |
| 1244 | + function checkedAttrLooseCompare(valueA, valueB) { | |
| 1245 | + return valueA == valueB; | |
| 1246 | + } | |
| 1247 | + function safeParseBoolean(rawValue) { | |
| 1248 | + if ([ | |
| 1249 | + 1, | |
| 1250 | + "1", | |
| 1251 | + "true", | |
| 1252 | + "on", | |
| 1253 | + "yes", | |
| 1254 | + true | |
| 1255 | + ].includes(rawValue)) return true; | |
| 1256 | + if ([ | |
| 1257 | + 0, | |
| 1258 | + "0", | |
| 1259 | + "false", | |
| 1260 | + "off", | |
| 1261 | + "no", | |
| 1262 | + false | |
| 1263 | + ].includes(rawValue)) return false; | |
| 1264 | + return rawValue ? Boolean(rawValue) : null; | |
| 1265 | + } | |
| 1266 | + var booleanAttributes = /* @__PURE__ */ new Set([ | |
| 1267 | + "allowfullscreen", | |
| 1268 | + "async", | |
| 1269 | + "autofocus", | |
| 1270 | + "autoplay", | |
| 1271 | + "checked", | |
| 1272 | + "controls", | |
| 1273 | + "default", | |
| 1274 | + "defer", | |
| 1275 | + "disabled", | |
| 1276 | + "formnovalidate", | |
| 1277 | + "inert", | |
| 1278 | + "ismap", | |
| 1279 | + "itemscope", | |
| 1280 | + "loop", | |
| 1281 | + "multiple", | |
| 1282 | + "muted", | |
| 1283 | + "nomodule", | |
| 1284 | + "novalidate", | |
| 1285 | + "open", | |
| 1286 | + "playsinline", | |
| 1287 | + "readonly", | |
| 1288 | + "required", | |
| 1289 | + "reversed", | |
| 1290 | + "selected", | |
| 1291 | + "shadowrootclonable", | |
| 1292 | + "shadowrootdelegatesfocus", | |
| 1293 | + "shadowrootserializable" | |
| 1294 | + ]); | |
| 1295 | + function isBooleanAttr(attrName) { | |
| 1296 | + return booleanAttributes.has(attrName); | |
| 1297 | + } | |
| 1298 | + function attributeShouldntBePreservedIfFalsy(name) { | |
| 1299 | + return ![ | |
| 1300 | + "aria-pressed", | |
| 1301 | + "aria-checked", | |
| 1302 | + "aria-expanded", | |
| 1303 | + "aria-selected" | |
| 1304 | + ].includes(name); | |
| 1305 | + } | |
| 1306 | + function getBinding(el, name, fallback) { | |
| 1307 | + if (el._x_bindings && el._x_bindings[name] !== void 0) return el._x_bindings[name]; | |
| 1308 | + return getAttributeBinding(el, name, fallback); | |
| 1309 | + } | |
| 1310 | + function extractProp(el, name, fallback, extract = true) { | |
| 1311 | + if (el._x_bindings && el._x_bindings[name] !== void 0) return el._x_bindings[name]; | |
| 1312 | + if (el._x_inlineBindings && el._x_inlineBindings[name] !== void 0) { | |
| 1313 | + let binding = el._x_inlineBindings[name]; | |
| 1314 | + binding.extract = extract; | |
| 1315 | + return dontAutoEvaluateFunctions(() => { | |
| 1316 | + return evaluate(el, binding.expression); | |
| 1317 | + }); | |
| 1318 | + } | |
| 1319 | + return getAttributeBinding(el, name, fallback); | |
| 1320 | + } | |
| 1321 | + function getAttributeBinding(el, name, fallback) { | |
| 1322 | + let attr = el.getAttribute(name); | |
| 1323 | + if (attr === null) return typeof fallback === "function" ? fallback() : fallback; | |
| 1324 | + if (attr === "") return true; | |
| 1325 | + if (isBooleanAttr(name)) return !![name, "true"].includes(attr); | |
| 1326 | + return attr; | |
| 1327 | + } | |
| 1328 | + function isCheckbox(el) { | |
| 1329 | + return el.type === "checkbox" || el.localName === "ui-checkbox" || el.localName === "ui-switch"; | |
| 1330 | + } | |
| 1331 | + function isRadio(el) { | |
| 1332 | + return el.type === "radio" || el.localName === "ui-radio"; | |
| 1333 | + } | |
| 1334 | + function debounce(func, wait) { | |
| 1335 | + let timeout; | |
| 1336 | + return function() { | |
| 1337 | + const context = this; | |
| 1338 | + const args = arguments; | |
| 1339 | + const later = function() { | |
| 1340 | + timeout = null; | |
| 1341 | + func.apply(context, args); | |
| 1342 | + }; | |
| 1343 | + clearTimeout(timeout); | |
| 1344 | + timeout = setTimeout(later, wait); | |
| 1345 | + }; | |
| 1346 | + } | |
| 1347 | + function throttle(func, limit) { | |
| 1348 | + let inThrottle; | |
| 1349 | + return function() { | |
| 1350 | + let context = this; | |
| 1351 | + let args = arguments; | |
| 1352 | + if (!inThrottle) { | |
| 1353 | + func.apply(context, args); | |
| 1354 | + inThrottle = true; | |
| 1355 | + setTimeout(() => inThrottle = false, limit); | |
| 1356 | + } | |
| 1357 | + }; | |
| 1358 | + } | |
| 1359 | + function entangle({ get: outerGet, set: outerSet }, { get: innerGet, set: innerSet }) { | |
| 1360 | + let firstRun = true; | |
| 1361 | + let outerHash; | |
| 1362 | + let reference = effect(() => { | |
| 1363 | + let outer = outerGet(); | |
| 1364 | + let inner = innerGet(); | |
| 1365 | + if (firstRun) { | |
| 1366 | + innerSet(cloneIfObject(outer)); | |
| 1367 | + firstRun = false; | |
| 1368 | + } else { | |
| 1369 | + let outerHashLatest = JSON.stringify(outer); | |
| 1370 | + let innerHashLatest = JSON.stringify(inner); | |
| 1371 | + if (outerHashLatest !== outerHash) innerSet(cloneIfObject(outer)); | |
| 1372 | + else if (outerHashLatest !== innerHashLatest) outerSet(cloneIfObject(inner)); | |
| 1373 | + } | |
| 1374 | + outerHash = JSON.stringify(outerGet()); | |
| 1375 | + JSON.stringify(innerGet()); | |
| 1376 | + }); | |
| 1377 | + return () => { | |
| 1378 | + release(reference); | |
| 1379 | + }; | |
| 1380 | + } | |
| 1381 | + function cloneIfObject(value) { | |
| 1382 | + return typeof value === "object" ? JSON.parse(JSON.stringify(value)) : value; | |
| 1383 | + } | |
| 1384 | + function plugin(callback) { | |
| 1385 | + (Array.isArray(callback) ? callback : [callback]).forEach((i) => i(alpine_default)); | |
| 1386 | + } | |
| 1387 | + var stores = {}; | |
| 1388 | + var isReactive = false; | |
| 1389 | + function store(name, value) { | |
| 1390 | + if (!isReactive) { | |
| 1391 | + stores = reactive(stores); | |
| 1392 | + isReactive = true; | |
| 1393 | + } | |
| 1394 | + if (value === void 0) return stores[name]; | |
| 1395 | + stores[name] = value; | |
| 1396 | + initInterceptors(stores[name]); | |
| 1397 | + if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") stores[name].init(); | |
| 1398 | + } | |
| 1399 | + function getStores() { | |
| 1400 | + return stores; | |
| 1401 | + } | |
| 1402 | + var binds = {}; | |
| 1403 | + function bind2(name, bindings) { | |
| 1404 | + let getBindings = typeof bindings !== "function" ? () => bindings : bindings; | |
| 1405 | + if (name instanceof Element) return applyBindingsObject(name, getBindings()); | |
| 1406 | + else binds[name] = getBindings; | |
| 1407 | + return () => {}; | |
| 1408 | + } | |
| 1409 | + function injectBindingProviders(obj) { | |
| 1410 | + Object.entries(binds).forEach(([name, callback]) => { | |
| 1411 | + Object.defineProperty(obj, name, { get() { | |
| 1412 | + return (...args) => { | |
| 1413 | + return callback(...args); | |
| 1414 | + }; | |
| 1415 | + } }); | |
| 1416 | + }); | |
| 1417 | + return obj; | |
| 1418 | + } | |
| 1419 | + function applyBindingsObject(el, obj, original) { | |
| 1420 | + let cleanupRunners = []; | |
| 1421 | + while (cleanupRunners.length) cleanupRunners.pop()(); | |
| 1422 | + let attributes = Object.entries(obj).map(([name, value]) => ({ | |
| 1423 | + name, | |
| 1424 | + value | |
| 1425 | + })); | |
| 1426 | + let staticAttributes = attributesOnly(attributes); | |
| 1427 | + attributes = attributes.map((attribute) => { | |
| 1428 | + if (staticAttributes.find((attr) => attr.name === attribute.name)) return { | |
| 1429 | + name: `x-bind:${attribute.name}`, | |
| 1430 | + value: `"${attribute.value}"` | |
| 1431 | + }; | |
| 1432 | + return attribute; | |
| 1433 | + }); | |
| 1434 | + directives(el, attributes, original).map((handle) => { | |
| 1435 | + cleanupRunners.push(handle.runCleanups); | |
| 1436 | + handle(); | |
| 1437 | + }); | |
| 1438 | + return () => { | |
| 1439 | + while (cleanupRunners.length) cleanupRunners.pop()(); | |
| 1440 | + }; | |
| 1441 | + } | |
| 1442 | + var datas = {}; | |
| 1443 | + function data(name, callback) { | |
| 1444 | + datas[name] = callback; | |
| 1445 | + } | |
| 1446 | + function injectDataProviders(obj, context) { | |
| 1447 | + Object.entries(datas).forEach(([name, callback]) => { | |
| 1448 | + Object.defineProperty(obj, name, { | |
| 1449 | + get() { | |
| 1450 | + return (...args) => { | |
| 1451 | + return callback.bind(context)(...args); | |
| 1452 | + }; | |
| 1453 | + }, | |
| 1454 | + enumerable: false | |
| 1455 | + }); | |
| 1456 | + }); | |
| 1457 | + return obj; | |
| 1458 | + } | |
| 1459 | + var alpine_default = { | |
| 1460 | + get reactive() { | |
| 1461 | + return reactive; | |
| 1462 | + }, | |
| 1463 | + get release() { | |
| 1464 | + return release; | |
| 1465 | + }, | |
| 1466 | + get effect() { | |
| 1467 | + return effect; | |
| 1468 | + }, | |
| 1469 | + get raw() { | |
| 1470 | + return raw; | |
| 1471 | + }, | |
| 1472 | + version: "3.15.0", | |
| 1473 | + flushAndStopDeferringMutations, | |
| 1474 | + dontAutoEvaluateFunctions, | |
| 1475 | + disableEffectScheduling, | |
| 1476 | + startObservingMutations, | |
| 1477 | + stopObservingMutations, | |
| 1478 | + setReactivityEngine, | |
| 1479 | + onAttributeRemoved, | |
| 1480 | + onAttributesAdded, | |
| 1481 | + closestDataStack, | |
| 1482 | + skipDuringClone, | |
| 1483 | + onlyDuringClone, | |
| 1484 | + addRootSelector, | |
| 1485 | + addInitSelector, | |
| 1486 | + interceptClone, | |
| 1487 | + addScopeToNode, | |
| 1488 | + deferMutations, | |
| 1489 | + mapAttributes, | |
| 1490 | + evaluateLater, | |
| 1491 | + interceptInit, | |
| 1492 | + setEvaluator, | |
| 1493 | + mergeProxies, | |
| 1494 | + extractProp, | |
| 1495 | + findClosest, | |
| 1496 | + onElRemoved, | |
| 1497 | + closestRoot, | |
| 1498 | + destroyTree, | |
| 1499 | + interceptor, | |
| 1500 | + transition, | |
| 1501 | + setStyles, | |
| 1502 | + mutateDom, | |
| 1503 | + directive, | |
| 1504 | + entangle, | |
| 1505 | + throttle, | |
| 1506 | + debounce, | |
| 1507 | + evaluate, | |
| 1508 | + initTree, | |
| 1509 | + nextTick, | |
| 1510 | + prefixed: prefix, | |
| 1511 | + prefix: setPrefix, | |
| 1512 | + plugin, | |
| 1513 | + magic, | |
| 1514 | + store, | |
| 1515 | + start, | |
| 1516 | + clone, | |
| 1517 | + cloneNode, | |
| 1518 | + bound: getBinding, | |
| 1519 | + $data: scope, | |
| 1520 | + watch, | |
| 1521 | + walk, | |
| 1522 | + data, | |
| 1523 | + bind: bind2 | |
| 1524 | + }; | |
| 1525 | + var Token = class { | |
| 1526 | + constructor(type, value, start2, end) { | |
| 1527 | + this.type = type; | |
| 1528 | + this.value = value; | |
| 1529 | + this.start = start2; | |
| 1530 | + this.end = end; | |
| 1531 | + } | |
| 1532 | + }; | |
| 1533 | + var Tokenizer = class { | |
| 1534 | + constructor(input) { | |
| 1535 | + this.input = input; | |
| 1536 | + this.position = 0; | |
| 1537 | + this.tokens = []; | |
| 1538 | + } | |
| 1539 | + tokenize() { | |
| 1540 | + while (this.position < this.input.length) { | |
| 1541 | + this.skipWhitespace(); | |
| 1542 | + if (this.position >= this.input.length) break; | |
| 1543 | + const char = this.input[this.position]; | |
| 1544 | + if (this.isDigit(char)) this.readNumber(); | |
| 1545 | + else if (this.isAlpha(char) || char === "_" || char === "$") this.readIdentifierOrKeyword(); | |
| 1546 | + else if (char === "\"" || char === "'") this.readString(); | |
| 1547 | + else if (char === "/" && this.peek() === "/") this.skipLineComment(); | |
| 1548 | + else this.readOperatorOrPunctuation(); | |
| 1549 | + } | |
| 1550 | + this.tokens.push(new Token("EOF", null, this.position, this.position)); | |
| 1551 | + return this.tokens; | |
| 1552 | + } | |
| 1553 | + skipWhitespace() { | |
| 1554 | + while (this.position < this.input.length && /\s/.test(this.input[this.position])) this.position++; | |
| 1555 | + } | |
| 1556 | + skipLineComment() { | |
| 1557 | + while (this.position < this.input.length && this.input[this.position] !== "\n") this.position++; | |
| 1558 | + } | |
| 1559 | + isDigit(char) { | |
| 1560 | + return /[0-9]/.test(char); | |
| 1561 | + } | |
| 1562 | + isAlpha(char) { | |
| 1563 | + return /[a-zA-Z]/.test(char); | |
| 1564 | + } | |
| 1565 | + isAlphaNumeric(char) { | |
| 1566 | + return /[a-zA-Z0-9_$]/.test(char); | |
| 1567 | + } | |
| 1568 | + peek(offset = 1) { | |
| 1569 | + return this.input[this.position + offset] || ""; | |
| 1570 | + } | |
| 1571 | + readNumber() { | |
| 1572 | + const start2 = this.position; | |
| 1573 | + let hasDecimal = false; | |
| 1574 | + while (this.position < this.input.length) { | |
| 1575 | + const char = this.input[this.position]; | |
| 1576 | + if (this.isDigit(char)) this.position++; | |
| 1577 | + else if (char === "." && !hasDecimal) { | |
| 1578 | + hasDecimal = true; | |
| 1579 | + this.position++; | |
| 1580 | + } else break; | |
| 1581 | + } | |
| 1582 | + const value = this.input.slice(start2, this.position); | |
| 1583 | + this.tokens.push(new Token("NUMBER", parseFloat(value), start2, this.position)); | |
| 1584 | + } | |
| 1585 | + readIdentifierOrKeyword() { | |
| 1586 | + const start2 = this.position; | |
| 1587 | + while (this.position < this.input.length && this.isAlphaNumeric(this.input[this.position])) this.position++; | |
| 1588 | + const value = this.input.slice(start2, this.position); | |
| 1589 | + if ([ | |
| 1590 | + "true", | |
| 1591 | + "false", | |
| 1592 | + "null", | |
| 1593 | + "undefined", | |
| 1594 | + "new", | |
| 1595 | + "typeof", | |
| 1596 | + "void", | |
| 1597 | + "delete", | |
| 1598 | + "in", | |
| 1599 | + "instanceof" | |
| 1600 | + ].includes(value)) if (value === "true" || value === "false") this.tokens.push(new Token("BOOLEAN", value === "true", start2, this.position)); | |
| 1601 | + else if (value === "null") this.tokens.push(new Token("NULL", null, start2, this.position)); | |
| 1602 | + else if (value === "undefined") this.tokens.push(new Token("UNDEFINED", void 0, start2, this.position)); | |
| 1603 | + else this.tokens.push(new Token("KEYWORD", value, start2, this.position)); | |
| 1604 | + else this.tokens.push(new Token("IDENTIFIER", value, start2, this.position)); | |
| 1605 | + } | |
| 1606 | + readString() { | |
| 1607 | + const start2 = this.position; | |
| 1608 | + const quote = this.input[this.position]; | |
| 1609 | + this.position++; | |
| 1610 | + let value = ""; | |
| 1611 | + let escaped = false; | |
| 1612 | + while (this.position < this.input.length) { | |
| 1613 | + const char = this.input[this.position]; | |
| 1614 | + if (escaped) { | |
| 1615 | + switch (char) { | |
| 1616 | + case "n": | |
| 1617 | + value += "\n"; | |
| 1618 | + break; | |
| 1619 | + case "t": | |
| 1620 | + value += " "; | |
| 1621 | + break; | |
| 1622 | + case "r": | |
| 1623 | + value += "\r"; | |
| 1624 | + break; | |
| 1625 | + case "\\": | |
| 1626 | + value += "\\"; | |
| 1627 | + break; | |
| 1628 | + case quote: | |
| 1629 | + value += quote; | |
| 1630 | + break; | |
| 1631 | + default: value += char; | |
| 1632 | + } | |
| 1633 | + escaped = false; | |
| 1634 | + } else if (char === "\\") escaped = true; | |
| 1635 | + else if (char === quote) { | |
| 1636 | + this.position++; | |
| 1637 | + this.tokens.push(new Token("STRING", value, start2, this.position)); | |
| 1638 | + return; | |
| 1639 | + } else value += char; | |
| 1640 | + this.position++; | |
| 1641 | + } | |
| 1642 | + throw new Error(`Unterminated string starting at position ${start2}`); | |
| 1643 | + } | |
| 1644 | + readOperatorOrPunctuation() { | |
| 1645 | + const start2 = this.position; | |
| 1646 | + const char = this.input[this.position]; | |
| 1647 | + const next = this.peek(); | |
| 1648 | + const nextNext = this.peek(2); | |
| 1649 | + if (char === "=" && next === "=" && nextNext === "=") { | |
| 1650 | + this.position += 3; | |
| 1651 | + this.tokens.push(new Token("OPERATOR", "===", start2, this.position)); | |
| 1652 | + } else if (char === "!" && next === "=" && nextNext === "=") { | |
| 1653 | + this.position += 3; | |
| 1654 | + this.tokens.push(new Token("OPERATOR", "!==", start2, this.position)); | |
| 1655 | + } else if (char === "=" && next === "=") { | |
| 1656 | + this.position += 2; | |
| 1657 | + this.tokens.push(new Token("OPERATOR", "==", start2, this.position)); | |
| 1658 | + } else if (char === "!" && next === "=") { | |
| 1659 | + this.position += 2; | |
| 1660 | + this.tokens.push(new Token("OPERATOR", "!=", start2, this.position)); | |
| 1661 | + } else if (char === "<" && next === "=") { | |
| 1662 | + this.position += 2; | |
| 1663 | + this.tokens.push(new Token("OPERATOR", "<=", start2, this.position)); | |
| 1664 | + } else if (char === ">" && next === "=") { | |
| 1665 | + this.position += 2; | |
| 1666 | + this.tokens.push(new Token("OPERATOR", ">=", start2, this.position)); | |
| 1667 | + } else if (char === "&" && next === "&") { | |
| 1668 | + this.position += 2; | |
| 1669 | + this.tokens.push(new Token("OPERATOR", "&&", start2, this.position)); | |
| 1670 | + } else if (char === "|" && next === "|") { | |
| 1671 | + this.position += 2; | |
| 1672 | + this.tokens.push(new Token("OPERATOR", "||", start2, this.position)); | |
| 1673 | + } else if (char === "+" && next === "+") { | |
| 1674 | + this.position += 2; | |
| 1675 | + this.tokens.push(new Token("OPERATOR", "++", start2, this.position)); | |
| 1676 | + } else if (char === "-" && next === "-") { | |
| 1677 | + this.position += 2; | |
| 1678 | + this.tokens.push(new Token("OPERATOR", "--", start2, this.position)); | |
| 1679 | + } else { | |
| 1680 | + this.position++; | |
| 1681 | + const type = "()[]{},.;:?".includes(char) ? "PUNCTUATION" : "OPERATOR"; | |
| 1682 | + this.tokens.push(new Token(type, char, start2, this.position)); | |
| 1683 | + } | |
| 1684 | + } | |
| 1685 | + }; | |
| 1686 | + var Parser = class { | |
| 1687 | + constructor(tokens) { | |
| 1688 | + this.tokens = tokens; | |
| 1689 | + this.position = 0; | |
| 1690 | + } | |
| 1691 | + parse() { | |
| 1692 | + if (this.isAtEnd()) throw new Error("Empty expression"); | |
| 1693 | + const expr = this.parseExpression(); | |
| 1694 | + this.match("PUNCTUATION", ";"); | |
| 1695 | + if (!this.isAtEnd()) throw new Error(`Unexpected token: ${this.current().value}`); | |
| 1696 | + return expr; | |
| 1697 | + } | |
| 1698 | + parseExpression() { | |
| 1699 | + return this.parseAssignment(); | |
| 1700 | + } | |
| 1701 | + parseAssignment() { | |
| 1702 | + const expr = this.parseTernary(); | |
| 1703 | + if (this.match("OPERATOR", "=")) { | |
| 1704 | + const value = this.parseAssignment(); | |
| 1705 | + if (expr.type === "Identifier" || expr.type === "MemberExpression") return { | |
| 1706 | + type: "AssignmentExpression", | |
| 1707 | + left: expr, | |
| 1708 | + operator: "=", | |
| 1709 | + right: value | |
| 1710 | + }; | |
| 1711 | + throw new Error("Invalid assignment target"); | |
| 1712 | + } | |
| 1713 | + return expr; | |
| 1714 | + } | |
| 1715 | + parseTernary() { | |
| 1716 | + const expr = this.parseLogicalOr(); | |
| 1717 | + if (this.match("PUNCTUATION", "?")) { | |
| 1718 | + const consequent = this.parseExpression(); | |
| 1719 | + this.consume("PUNCTUATION", ":"); | |
| 1720 | + return { | |
| 1721 | + type: "ConditionalExpression", | |
| 1722 | + test: expr, | |
| 1723 | + consequent, | |
| 1724 | + alternate: this.parseExpression() | |
| 1725 | + }; | |
| 1726 | + } | |
| 1727 | + return expr; | |
| 1728 | + } | |
| 1729 | + parseLogicalOr() { | |
| 1730 | + let expr = this.parseLogicalAnd(); | |
| 1731 | + while (this.match("OPERATOR", "||")) { | |
| 1732 | + const operator = this.previous().value; | |
| 1733 | + const right = this.parseLogicalAnd(); | |
| 1734 | + expr = { | |
| 1735 | + type: "BinaryExpression", | |
| 1736 | + operator, | |
| 1737 | + left: expr, | |
| 1738 | + right | |
| 1739 | + }; | |
| 1740 | + } | |
| 1741 | + return expr; | |
| 1742 | + } | |
| 1743 | + parseLogicalAnd() { | |
| 1744 | + let expr = this.parseEquality(); | |
| 1745 | + while (this.match("OPERATOR", "&&")) { | |
| 1746 | + const operator = this.previous().value; | |
| 1747 | + const right = this.parseEquality(); | |
| 1748 | + expr = { | |
| 1749 | + type: "BinaryExpression", | |
| 1750 | + operator, | |
| 1751 | + left: expr, | |
| 1752 | + right | |
| 1753 | + }; | |
| 1754 | + } | |
| 1755 | + return expr; | |
| 1756 | + } | |
| 1757 | + parseEquality() { | |
| 1758 | + let expr = this.parseRelational(); | |
| 1759 | + while (this.match("OPERATOR", "==", "!=", "===", "!==")) { | |
| 1760 | + const operator = this.previous().value; | |
| 1761 | + const right = this.parseRelational(); | |
| 1762 | + expr = { | |
| 1763 | + type: "BinaryExpression", | |
| 1764 | + operator, | |
| 1765 | + left: expr, | |
| 1766 | + right | |
| 1767 | + }; | |
| 1768 | + } | |
| 1769 | + return expr; | |
| 1770 | + } | |
| 1771 | + parseRelational() { | |
| 1772 | + let expr = this.parseAdditive(); | |
| 1773 | + while (this.match("OPERATOR", "<", ">", "<=", ">=")) { | |
| 1774 | + const operator = this.previous().value; | |
| 1775 | + const right = this.parseAdditive(); | |
| 1776 | + expr = { | |
| 1777 | + type: "BinaryExpression", | |
| 1778 | + operator, | |
| 1779 | + left: expr, | |
| 1780 | + right | |
| 1781 | + }; | |
| 1782 | + } | |
| 1783 | + return expr; | |
| 1784 | + } | |
| 1785 | + parseAdditive() { | |
| 1786 | + let expr = this.parseMultiplicative(); | |
| 1787 | + while (this.match("OPERATOR", "+", "-")) { | |
| 1788 | + const operator = this.previous().value; | |
| 1789 | + const right = this.parseMultiplicative(); | |
| 1790 | + expr = { | |
| 1791 | + type: "BinaryExpression", | |
| 1792 | + operator, | |
| 1793 | + left: expr, | |
| 1794 | + right | |
| 1795 | + }; | |
| 1796 | + } | |
| 1797 | + return expr; | |
| 1798 | + } | |
| 1799 | + parseMultiplicative() { | |
| 1800 | + let expr = this.parseUnary(); | |
| 1801 | + while (this.match("OPERATOR", "*", "/", "%")) { | |
| 1802 | + const operator = this.previous().value; | |
| 1803 | + const right = this.parseUnary(); | |
| 1804 | + expr = { | |
| 1805 | + type: "BinaryExpression", | |
| 1806 | + operator, | |
| 1807 | + left: expr, | |
| 1808 | + right | |
| 1809 | + }; | |
| 1810 | + } | |
| 1811 | + return expr; | |
| 1812 | + } | |
| 1813 | + parseUnary() { | |
| 1814 | + if (this.match("OPERATOR", "++", "--")) return { | |
| 1815 | + type: "UpdateExpression", | |
| 1816 | + operator: this.previous().value, | |
| 1817 | + argument: this.parseUnary(), | |
| 1818 | + prefix: true | |
| 1819 | + }; | |
| 1820 | + if (this.match("OPERATOR", "!", "-", "+")) return { | |
| 1821 | + type: "UnaryExpression", | |
| 1822 | + operator: this.previous().value, | |
| 1823 | + argument: this.parseUnary(), | |
| 1824 | + prefix: true | |
| 1825 | + }; | |
| 1826 | + return this.parsePostfix(); | |
| 1827 | + } | |
| 1828 | + parsePostfix() { | |
| 1829 | + let expr = this.parseMember(); | |
| 1830 | + if (this.match("OPERATOR", "++", "--")) return { | |
| 1831 | + type: "UpdateExpression", | |
| 1832 | + operator: this.previous().value, | |
| 1833 | + argument: expr, | |
| 1834 | + prefix: false | |
| 1835 | + }; | |
| 1836 | + return expr; | |
| 1837 | + } | |
| 1838 | + parseMember() { | |
| 1839 | + let expr = this.parsePrimary(); | |
| 1840 | + while (true) if (this.match("PUNCTUATION", ".")) { | |
| 1841 | + const property = this.consume("IDENTIFIER"); | |
| 1842 | + expr = { | |
| 1843 | + type: "MemberExpression", | |
| 1844 | + object: expr, | |
| 1845 | + property: { | |
| 1846 | + type: "Identifier", | |
| 1847 | + name: property.value | |
| 1848 | + }, | |
| 1849 | + computed: false | |
| 1850 | + }; | |
| 1851 | + } else if (this.match("PUNCTUATION", "[")) { | |
| 1852 | + const property = this.parseExpression(); | |
| 1853 | + this.consume("PUNCTUATION", "]"); | |
| 1854 | + expr = { | |
| 1855 | + type: "MemberExpression", | |
| 1856 | + object: expr, | |
| 1857 | + property, | |
| 1858 | + computed: true | |
| 1859 | + }; | |
| 1860 | + } else if (this.match("PUNCTUATION", "(")) { | |
| 1861 | + const args = this.parseArguments(); | |
| 1862 | + expr = { | |
| 1863 | + type: "CallExpression", | |
| 1864 | + callee: expr, | |
| 1865 | + arguments: args | |
| 1866 | + }; | |
| 1867 | + } else break; | |
| 1868 | + return expr; | |
| 1869 | + } | |
| 1870 | + parseArguments() { | |
| 1871 | + const args = []; | |
| 1872 | + if (!this.check("PUNCTUATION", ")")) do | |
| 1873 | + args.push(this.parseExpression()); | |
| 1874 | + while (this.match("PUNCTUATION", ",")); | |
| 1875 | + this.consume("PUNCTUATION", ")"); | |
| 1876 | + return args; | |
| 1877 | + } | |
| 1878 | + parsePrimary() { | |
| 1879 | + if (this.match("NUMBER")) return { | |
| 1880 | + type: "Literal", | |
| 1881 | + value: this.previous().value | |
| 1882 | + }; | |
| 1883 | + if (this.match("STRING")) return { | |
| 1884 | + type: "Literal", | |
| 1885 | + value: this.previous().value | |
| 1886 | + }; | |
| 1887 | + if (this.match("BOOLEAN")) return { | |
| 1888 | + type: "Literal", | |
| 1889 | + value: this.previous().value | |
| 1890 | + }; | |
| 1891 | + if (this.match("NULL")) return { | |
| 1892 | + type: "Literal", | |
| 1893 | + value: null | |
| 1894 | + }; | |
| 1895 | + if (this.match("UNDEFINED")) return { | |
| 1896 | + type: "Literal", | |
| 1897 | + value: void 0 | |
| 1898 | + }; | |
| 1899 | + if (this.match("IDENTIFIER")) return { | |
| 1900 | + type: "Identifier", | |
| 1901 | + name: this.previous().value | |
| 1902 | + }; | |
| 1903 | + if (this.match("PUNCTUATION", "(")) { | |
| 1904 | + const expr = this.parseExpression(); | |
| 1905 | + this.consume("PUNCTUATION", ")"); | |
| 1906 | + return expr; | |
| 1907 | + } | |
| 1908 | + if (this.match("PUNCTUATION", "[")) return this.parseArrayLiteral(); | |
| 1909 | + if (this.match("PUNCTUATION", "{")) return this.parseObjectLiteral(); | |
| 1910 | + throw new Error(`Unexpected token: ${this.current().type} "${this.current().value}"`); | |
| 1911 | + } | |
| 1912 | + parseArrayLiteral() { | |
| 1913 | + const elements = []; | |
| 1914 | + while (!this.check("PUNCTUATION", "]") && !this.isAtEnd()) { | |
| 1915 | + elements.push(this.parseExpression()); | |
| 1916 | + if (this.match("PUNCTUATION", ",")) { | |
| 1917 | + if (this.check("PUNCTUATION", "]")) break; | |
| 1918 | + } else break; | |
| 1919 | + } | |
| 1920 | + this.consume("PUNCTUATION", "]"); | |
| 1921 | + return { | |
| 1922 | + type: "ArrayExpression", | |
| 1923 | + elements | |
| 1924 | + }; | |
| 1925 | + } | |
| 1926 | + parseObjectLiteral() { | |
| 1927 | + const properties = []; | |
| 1928 | + while (!this.check("PUNCTUATION", "}") && !this.isAtEnd()) { | |
| 1929 | + let key; | |
| 1930 | + let computed = false; | |
| 1931 | + if (this.match("STRING")) key = { | |
| 1932 | + type: "Literal", | |
| 1933 | + value: this.previous().value | |
| 1934 | + }; | |
| 1935 | + else if (this.match("IDENTIFIER")) key = { | |
| 1936 | + type: "Identifier", | |
| 1937 | + name: this.previous().value | |
| 1938 | + }; | |
| 1939 | + else if (this.match("PUNCTUATION", "[")) { | |
| 1940 | + key = this.parseExpression(); | |
| 1941 | + computed = true; | |
| 1942 | + this.consume("PUNCTUATION", "]"); | |
| 1943 | + } else throw new Error("Expected property key"); | |
| 1944 | + this.consume("PUNCTUATION", ":"); | |
| 1945 | + const value = this.parseExpression(); | |
| 1946 | + properties.push({ | |
| 1947 | + type: "Property", | |
| 1948 | + key, | |
| 1949 | + value, | |
| 1950 | + computed, | |
| 1951 | + shorthand: false | |
| 1952 | + }); | |
| 1953 | + if (this.match("PUNCTUATION", ",")) { | |
| 1954 | + if (this.check("PUNCTUATION", "}")) break; | |
| 1955 | + } else break; | |
| 1956 | + } | |
| 1957 | + this.consume("PUNCTUATION", "}"); | |
| 1958 | + return { | |
| 1959 | + type: "ObjectExpression", | |
| 1960 | + properties | |
| 1961 | + }; | |
| 1962 | + } | |
| 1963 | + match(...args) { | |
| 1964 | + for (let i = 0; i < args.length; i++) { | |
| 1965 | + const arg = args[i]; | |
| 1966 | + if (i === 0 && args.length > 1) { | |
| 1967 | + const type = arg; | |
| 1968 | + for (let j = 1; j < args.length; j++) if (this.check(type, args[j])) { | |
| 1969 | + this.advance(); | |
| 1970 | + return true; | |
| 1971 | + } | |
| 1972 | + return false; | |
| 1973 | + } else if (args.length === 1) { | |
| 1974 | + if (this.checkType(arg)) { | |
| 1975 | + this.advance(); | |
| 1976 | + return true; | |
| 1977 | + } | |
| 1978 | + return false; | |
| 1979 | + } | |
| 1980 | + } | |
| 1981 | + return false; | |
| 1982 | + } | |
| 1983 | + check(type, value) { | |
| 1984 | + if (this.isAtEnd()) return false; | |
| 1985 | + if (value !== void 0) return this.current().type === type && this.current().value === value; | |
| 1986 | + return this.current().type === type; | |
| 1987 | + } | |
| 1988 | + checkType(type) { | |
| 1989 | + if (this.isAtEnd()) return false; | |
| 1990 | + return this.current().type === type; | |
| 1991 | + } | |
| 1992 | + advance() { | |
| 1993 | + if (!this.isAtEnd()) this.position++; | |
| 1994 | + return this.previous(); | |
| 1995 | + } | |
| 1996 | + isAtEnd() { | |
| 1997 | + return this.current().type === "EOF"; | |
| 1998 | + } | |
| 1999 | + current() { | |
| 2000 | + return this.tokens[this.position]; | |
| 2001 | + } | |
| 2002 | + previous() { | |
| 2003 | + return this.tokens[this.position - 1]; | |
| 2004 | + } | |
| 2005 | + consume(type, value) { | |
| 2006 | + if (value !== void 0) { | |
| 2007 | + if (this.check(type, value)) return this.advance(); | |
| 2008 | + throw new Error(`Expected ${type} "${value}" but got ${this.current().type} "${this.current().value}"`); | |
| 2009 | + } | |
| 2010 | + if (this.check(type)) return this.advance(); | |
| 2011 | + throw new Error(`Expected ${type} but got ${this.current().type} "${this.current().value}"`); | |
| 2012 | + } | |
| 2013 | + }; | |
| 2014 | + var Evaluator = class { | |
| 2015 | + evaluate({ node, scope: scope2 = {}, context = null, allowGlobal = false, forceBindingRootScopeToFunctions = true }) { | |
| 2016 | + switch (node.type) { | |
| 2017 | + case "Literal": return node.value; | |
| 2018 | + case "Identifier": | |
| 2019 | + if (node.name in scope2) { | |
| 2020 | + const value2 = scope2[node.name]; | |
| 2021 | + if (typeof value2 === "function") return value2.bind(scope2); | |
| 2022 | + return value2; | |
| 2023 | + } | |
| 2024 | + if (allowGlobal && typeof globalThis[node.name] !== "undefined") { | |
| 2025 | + const value2 = globalThis[node.name]; | |
| 2026 | + if (typeof value2 === "function") return value2.bind(globalThis); | |
| 2027 | + return value2; | |
| 2028 | + } | |
| 2029 | + throw new Error(`Undefined variable: ${node.name}`); | |
| 2030 | + case "MemberExpression": | |
| 2031 | + const object = this.evaluate({ | |
| 2032 | + node: node.object, | |
| 2033 | + scope: scope2, | |
| 2034 | + context, | |
| 2035 | + allowGlobal, | |
| 2036 | + forceBindingRootScopeToFunctions | |
| 2037 | + }); | |
| 2038 | + if (object == null) throw new Error("Cannot read property of null or undefined"); | |
| 2039 | + let memberValue; | |
| 2040 | + if (node.computed) memberValue = object[this.evaluate({ | |
| 2041 | + node: node.property, | |
| 2042 | + scope: scope2, | |
| 2043 | + context, | |
| 2044 | + allowGlobal, | |
| 2045 | + forceBindingRootScopeToFunctions | |
| 2046 | + })]; | |
| 2047 | + else memberValue = object[node.property.name]; | |
| 2048 | + if (typeof memberValue === "function") if (forceBindingRootScopeToFunctions) return memberValue.bind(scope2); | |
| 2049 | + else return memberValue.bind(object); | |
| 2050 | + return memberValue; | |
| 2051 | + case "CallExpression": | |
| 2052 | + const args = node.arguments.map((arg) => this.evaluate({ | |
| 2053 | + node: arg, | |
| 2054 | + scope: scope2, | |
| 2055 | + context, | |
| 2056 | + allowGlobal, | |
| 2057 | + forceBindingRootScopeToFunctions | |
| 2058 | + })); | |
| 2059 | + if (node.callee.type === "MemberExpression") { | |
| 2060 | + const obj = this.evaluate({ | |
| 2061 | + node: node.callee.object, | |
| 2062 | + scope: scope2, | |
| 2063 | + context, | |
| 2064 | + allowGlobal, | |
| 2065 | + forceBindingRootScopeToFunctions | |
| 2066 | + }); | |
| 2067 | + let func; | |
| 2068 | + if (node.callee.computed) func = obj[this.evaluate({ | |
| 2069 | + node: node.callee.property, | |
| 2070 | + scope: scope2, | |
| 2071 | + context, | |
| 2072 | + allowGlobal, | |
| 2073 | + forceBindingRootScopeToFunctions | |
| 2074 | + })]; | |
| 2075 | + else func = obj[node.callee.property.name]; | |
| 2076 | + if (typeof func !== "function") throw new Error("Value is not a function"); | |
| 2077 | + return func.apply(obj, args); | |
| 2078 | + } else if (node.callee.type === "Identifier") { | |
| 2079 | + const name = node.callee.name; | |
| 2080 | + let func; | |
| 2081 | + if (name in scope2) func = scope2[name]; | |
| 2082 | + else if (allowGlobal && typeof globalThis[name] !== "undefined") func = globalThis[name]; | |
| 2083 | + else throw new Error(`Undefined variable: ${name}`); | |
| 2084 | + if (typeof func !== "function") throw new Error("Value is not a function"); | |
| 2085 | + const thisContext = context !== null ? context : scope2; | |
| 2086 | + return func.apply(thisContext, args); | |
| 2087 | + } else { | |
| 2088 | + const callee = this.evaluate({ | |
| 2089 | + node: node.callee, | |
| 2090 | + scope: scope2, | |
| 2091 | + context, | |
| 2092 | + allowGlobal, | |
| 2093 | + forceBindingRootScopeToFunctions | |
| 2094 | + }); | |
| 2095 | + if (typeof callee !== "function") throw new Error("Value is not a function"); | |
| 2096 | + return callee.apply(context, args); | |
| 2097 | + } | |
| 2098 | + case "UnaryExpression": | |
| 2099 | + const argument = this.evaluate({ | |
| 2100 | + node: node.argument, | |
| 2101 | + scope: scope2, | |
| 2102 | + context, | |
| 2103 | + allowGlobal, | |
| 2104 | + forceBindingRootScopeToFunctions | |
| 2105 | + }); | |
| 2106 | + switch (node.operator) { | |
| 2107 | + case "!": return !argument; | |
| 2108 | + case "-": return -argument; | |
| 2109 | + case "+": return +argument; | |
| 2110 | + default: throw new Error(`Unknown unary operator: ${node.operator}`); | |
| 2111 | + } | |
| 2112 | + case "UpdateExpression": | |
| 2113 | + if (node.argument.type === "Identifier") { | |
| 2114 | + const name = node.argument.name; | |
| 2115 | + if (!(name in scope2)) throw new Error(`Undefined variable: ${name}`); | |
| 2116 | + const oldValue = scope2[name]; | |
| 2117 | + if (node.operator === "++") scope2[name] = oldValue + 1; | |
| 2118 | + else if (node.operator === "--") scope2[name] = oldValue - 1; | |
| 2119 | + return node.prefix ? scope2[name] : oldValue; | |
| 2120 | + } else if (node.argument.type === "MemberExpression") { | |
| 2121 | + const obj = this.evaluate({ | |
| 2122 | + node: node.argument.object, | |
| 2123 | + scope: scope2, | |
| 2124 | + context, | |
| 2125 | + allowGlobal, | |
| 2126 | + forceBindingRootScopeToFunctions | |
| 2127 | + }); | |
| 2128 | + const prop = node.argument.computed ? this.evaluate({ | |
| 2129 | + node: node.argument.property, | |
| 2130 | + scope: scope2, | |
| 2131 | + context, | |
| 2132 | + allowGlobal, | |
| 2133 | + forceBindingRootScopeToFunctions | |
| 2134 | + }) : node.argument.property.name; | |
| 2135 | + const oldValue = obj[prop]; | |
| 2136 | + if (node.operator === "++") obj[prop] = oldValue + 1; | |
| 2137 | + else if (node.operator === "--") obj[prop] = oldValue - 1; | |
| 2138 | + return node.prefix ? obj[prop] : oldValue; | |
| 2139 | + } | |
| 2140 | + throw new Error("Invalid update expression target"); | |
| 2141 | + case "BinaryExpression": | |
| 2142 | + const left = this.evaluate({ | |
| 2143 | + node: node.left, | |
| 2144 | + scope: scope2, | |
| 2145 | + context, | |
| 2146 | + allowGlobal, | |
| 2147 | + forceBindingRootScopeToFunctions | |
| 2148 | + }); | |
| 2149 | + const right = this.evaluate({ | |
| 2150 | + node: node.right, | |
| 2151 | + scope: scope2, | |
| 2152 | + context, | |
| 2153 | + allowGlobal, | |
| 2154 | + forceBindingRootScopeToFunctions | |
| 2155 | + }); | |
| 2156 | + switch (node.operator) { | |
| 2157 | + case "+": return left + right; | |
| 2158 | + case "-": return left - right; | |
| 2159 | + case "*": return left * right; | |
| 2160 | + case "/": return left / right; | |
| 2161 | + case "%": return left % right; | |
| 2162 | + case "==": return left == right; | |
| 2163 | + case "!=": return left != right; | |
| 2164 | + case "===": return left === right; | |
| 2165 | + case "!==": return left !== right; | |
| 2166 | + case "<": return left < right; | |
| 2167 | + case ">": return left > right; | |
| 2168 | + case "<=": return left <= right; | |
| 2169 | + case ">=": return left >= right; | |
| 2170 | + case "&&": return left && right; | |
| 2171 | + case "||": return left || right; | |
| 2172 | + default: throw new Error(`Unknown binary operator: ${node.operator}`); | |
| 2173 | + } | |
| 2174 | + case "ConditionalExpression": return this.evaluate({ | |
| 2175 | + node: node.test, | |
| 2176 | + scope: scope2, | |
| 2177 | + context, | |
| 2178 | + allowGlobal, | |
| 2179 | + forceBindingRootScopeToFunctions | |
| 2180 | + }) ? this.evaluate({ | |
| 2181 | + node: node.consequent, | |
| 2182 | + scope: scope2, | |
| 2183 | + context, | |
| 2184 | + allowGlobal, | |
| 2185 | + forceBindingRootScopeToFunctions | |
| 2186 | + }) : this.evaluate({ | |
| 2187 | + node: node.alternate, | |
| 2188 | + scope: scope2, | |
| 2189 | + context, | |
| 2190 | + allowGlobal, | |
| 2191 | + forceBindingRootScopeToFunctions | |
| 2192 | + }); | |
| 2193 | + case "AssignmentExpression": | |
| 2194 | + const value = this.evaluate({ | |
| 2195 | + node: node.right, | |
| 2196 | + scope: scope2, | |
| 2197 | + context, | |
| 2198 | + allowGlobal, | |
| 2199 | + forceBindingRootScopeToFunctions | |
| 2200 | + }); | |
| 2201 | + if (node.left.type === "Identifier") { | |
| 2202 | + scope2[node.left.name] = value; | |
| 2203 | + return value; | |
| 2204 | + } else if (node.left.type === "MemberExpression") { | |
| 2205 | + const obj = this.evaluate({ | |
| 2206 | + node: node.left.object, | |
| 2207 | + scope: scope2, | |
| 2208 | + context, | |
| 2209 | + allowGlobal, | |
| 2210 | + forceBindingRootScopeToFunctions | |
| 2211 | + }); | |
| 2212 | + if (node.left.computed) { | |
| 2213 | + const prop = this.evaluate({ | |
| 2214 | + node: node.left.property, | |
| 2215 | + scope: scope2, | |
| 2216 | + context, | |
| 2217 | + allowGlobal, | |
| 2218 | + forceBindingRootScopeToFunctions | |
| 2219 | + }); | |
| 2220 | + obj[prop] = value; | |
| 2221 | + } else obj[node.left.property.name] = value; | |
| 2222 | + return value; | |
| 2223 | + } | |
| 2224 | + throw new Error("Invalid assignment target"); | |
| 2225 | + case "ArrayExpression": return node.elements.map((el) => this.evaluate({ | |
| 2226 | + node: el, | |
| 2227 | + scope: scope2, | |
| 2228 | + context, | |
| 2229 | + allowGlobal, | |
| 2230 | + forceBindingRootScopeToFunctions | |
| 2231 | + })); | |
| 2232 | + case "ObjectExpression": | |
| 2233 | + const result = {}; | |
| 2234 | + for (const prop of node.properties) { | |
| 2235 | + const key = prop.computed ? this.evaluate({ | |
| 2236 | + node: prop.key, | |
| 2237 | + scope: scope2, | |
| 2238 | + context, | |
| 2239 | + allowGlobal, | |
| 2240 | + forceBindingRootScopeToFunctions | |
| 2241 | + }) : prop.key.type === "Identifier" ? prop.key.name : this.evaluate({ | |
| 2242 | + node: prop.key, | |
| 2243 | + scope: scope2, | |
| 2244 | + context, | |
| 2245 | + allowGlobal, | |
| 2246 | + forceBindingRootScopeToFunctions | |
| 2247 | + }); | |
| 2248 | + result[key] = this.evaluate({ | |
| 2249 | + node: prop.value, | |
| 2250 | + scope: scope2, | |
| 2251 | + context, | |
| 2252 | + allowGlobal, | |
| 2253 | + forceBindingRootScopeToFunctions | |
| 2254 | + }); | |
| 2255 | + } | |
| 2256 | + return result; | |
| 2257 | + default: throw new Error(`Unknown node type: ${node.type}`); | |
| 2258 | + } | |
| 2259 | + } | |
| 2260 | + }; | |
| 2261 | + function generateRuntimeFunction(expression) { | |
| 2262 | + try { | |
| 2263 | + const ast = new Parser(new Tokenizer(expression).tokenize()).parse(); | |
| 2264 | + const evaluator = new Evaluator(); | |
| 2265 | + return function(options = {}) { | |
| 2266 | + const { scope: scope2 = {}, context = null, allowGlobal = false, forceBindingRootScopeToFunctions = false } = options; | |
| 2267 | + return evaluator.evaluate({ | |
| 2268 | + node: ast, | |
| 2269 | + scope: scope2, | |
| 2270 | + context, | |
| 2271 | + allowGlobal, | |
| 2272 | + forceBindingRootScopeToFunctions | |
| 2273 | + }); | |
| 2274 | + }; | |
| 2275 | + } catch (error2) { | |
| 2276 | + throw new Error(`CSP Parser Error: ${error2.message}`); | |
| 2277 | + } | |
| 2278 | + } | |
| 2279 | + function cspEvaluator(el, expression) { | |
| 2280 | + let dataStack = generateDataStack(el); | |
| 2281 | + if (typeof expression === "function") return generateEvaluatorFromFunction(dataStack, expression); | |
| 2282 | + let evaluator = generateEvaluator(el, expression, dataStack); | |
| 2283 | + return tryCatch.bind(null, el, expression, evaluator); | |
| 2284 | + } | |
| 2285 | + function generateDataStack(el) { | |
| 2286 | + let overriddenMagics = {}; | |
| 2287 | + injectMagics(overriddenMagics, el); | |
| 2288 | + return [overriddenMagics, ...closestDataStack(el)]; | |
| 2289 | + } | |
| 2290 | + function generateEvaluator(el, expression, dataStack) { | |
| 2291 | + return (receiver = () => {}, { scope: scope2 = {}, params = [] } = {}) => { | |
| 2292 | + let completeScope = mergeProxies([scope2, ...dataStack]); | |
| 2293 | + let returnValue = generateRuntimeFunction(expression)({ | |
| 2294 | + scope: completeScope, | |
| 2295 | + allowGlobal: true, | |
| 2296 | + forceBindingRootScopeToFunctions: true | |
| 2297 | + }); | |
| 2298 | + if (shouldAutoEvaluateFunctions && typeof returnValue === "function") { | |
| 2299 | + let nextReturnValue = returnValue.apply(returnValue, params); | |
| 2300 | + if (nextReturnValue instanceof Promise) nextReturnValue.then((i) => receiver(i)); | |
| 2301 | + else receiver(nextReturnValue); | |
| 2302 | + } else if (typeof returnValue === "object" && returnValue instanceof Promise) returnValue.then((i) => receiver(i)); | |
| 2303 | + else receiver(returnValue); | |
| 2304 | + }; | |
| 2305 | + } | |
| 2306 | + function makeMap(str, expectsLowerCase) { | |
| 2307 | + const map = /* @__PURE__ */ Object.create(null); | |
| 2308 | + const list = str.split(","); | |
| 2309 | + for (let i = 0; i < list.length; i++) map[list[i]] = true; | |
| 2310 | + return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val]; | |
| 2311 | + } | |
| 2312 | + var EMPTY_OBJ = Object.freeze({}); | |
| 2313 | + Object.freeze([]); | |
| 2314 | + var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| 2315 | + var hasOwn = (val, key) => hasOwnProperty.call(val, key); | |
| 2316 | + var isArray = Array.isArray; | |
| 2317 | + var isMap = (val) => toTypeString(val) === "[object Map]"; | |
| 2318 | + var isString = (val) => typeof val === "string"; | |
| 2319 | + var isSymbol = (val) => typeof val === "symbol"; | |
| 2320 | + var isObject = (val) => val !== null && typeof val === "object"; | |
| 2321 | + var objectToString = Object.prototype.toString; | |
| 2322 | + var toTypeString = (value) => objectToString.call(value); | |
| 2323 | + var toRawType = (value) => { | |
| 2324 | + return toTypeString(value).slice(8, -1); | |
| 2325 | + }; | |
| 2326 | + var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key; | |
| 2327 | + var cacheStringFunction = (fn) => { | |
| 2328 | + const cache = /* @__PURE__ */ Object.create(null); | |
| 2329 | + return (str) => { | |
| 2330 | + return cache[str] || (cache[str] = fn(str)); | |
| 2331 | + }; | |
| 2332 | + }; | |
| 2333 | + var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1)); | |
| 2334 | + var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); | |
| 2335 | + var targetMap = /* @__PURE__ */ new WeakMap(); | |
| 2336 | + var effectStack = []; | |
| 2337 | + var activeEffect; | |
| 2338 | + var ITERATE_KEY = Symbol("iterate"); | |
| 2339 | + var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); | |
| 2340 | + function isEffect(fn) { | |
| 2341 | + return fn && fn._isEffect === true; | |
| 2342 | + } | |
| 2343 | + function effect2(fn, options = EMPTY_OBJ) { | |
| 2344 | + if (isEffect(fn)) fn = fn.raw; | |
| 2345 | + const effect3 = createReactiveEffect(fn, options); | |
| 2346 | + if (!options.lazy) effect3(); | |
| 2347 | + return effect3; | |
| 2348 | + } | |
| 2349 | + function stop(effect3) { | |
| 2350 | + if (effect3.active) { | |
| 2351 | + cleanup(effect3); | |
| 2352 | + if (effect3.options.onStop) effect3.options.onStop(); | |
| 2353 | + effect3.active = false; | |
| 2354 | + } | |
| 2355 | + } | |
| 2356 | + var uid = 0; | |
| 2357 | + function createReactiveEffect(fn, options) { | |
| 2358 | + const effect3 = function reactiveEffect() { | |
| 2359 | + if (!effect3.active) return fn(); | |
| 2360 | + if (!effectStack.includes(effect3)) { | |
| 2361 | + cleanup(effect3); | |
| 2362 | + try { | |
| 2363 | + enableTracking(); | |
| 2364 | + effectStack.push(effect3); | |
| 2365 | + activeEffect = effect3; | |
| 2366 | + return fn(); | |
| 2367 | + } finally { | |
| 2368 | + effectStack.pop(); | |
| 2369 | + resetTracking(); | |
| 2370 | + activeEffect = effectStack[effectStack.length - 1]; | |
| 2371 | + } | |
| 2372 | + } | |
| 2373 | + }; | |
| 2374 | + effect3.id = uid++; | |
| 2375 | + effect3.allowRecurse = !!options.allowRecurse; | |
| 2376 | + effect3._isEffect = true; | |
| 2377 | + effect3.active = true; | |
| 2378 | + effect3.raw = fn; | |
| 2379 | + effect3.deps = []; | |
| 2380 | + effect3.options = options; | |
| 2381 | + return effect3; | |
| 2382 | + } | |
| 2383 | + function cleanup(effect3) { | |
| 2384 | + const { deps } = effect3; | |
| 2385 | + if (deps.length) { | |
| 2386 | + for (let i = 0; i < deps.length; i++) deps[i].delete(effect3); | |
| 2387 | + deps.length = 0; | |
| 2388 | + } | |
| 2389 | + } | |
| 2390 | + var shouldTrack = true; | |
| 2391 | + var trackStack = []; | |
| 2392 | + function pauseTracking() { | |
| 2393 | + trackStack.push(shouldTrack); | |
| 2394 | + shouldTrack = false; | |
| 2395 | + } | |
| 2396 | + function enableTracking() { | |
| 2397 | + trackStack.push(shouldTrack); | |
| 2398 | + shouldTrack = true; | |
| 2399 | + } | |
| 2400 | + function resetTracking() { | |
| 2401 | + const last = trackStack.pop(); | |
| 2402 | + shouldTrack = last === void 0 ? true : last; | |
| 2403 | + } | |
| 2404 | + function track(target, type, key) { | |
| 2405 | + if (!shouldTrack || activeEffect === void 0) return; | |
| 2406 | + let depsMap = targetMap.get(target); | |
| 2407 | + if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map()); | |
| 2408 | + let dep = depsMap.get(key); | |
| 2409 | + if (!dep) depsMap.set(key, dep = /* @__PURE__ */ new Set()); | |
| 2410 | + if (!dep.has(activeEffect)) { | |
| 2411 | + dep.add(activeEffect); | |
| 2412 | + activeEffect.deps.push(dep); | |
| 2413 | + if (activeEffect.options.onTrack) activeEffect.options.onTrack({ | |
| 2414 | + effect: activeEffect, | |
| 2415 | + target, | |
| 2416 | + type, | |
| 2417 | + key | |
| 2418 | + }); | |
| 2419 | + } | |
| 2420 | + } | |
| 2421 | + function trigger(target, type, key, newValue, oldValue, oldTarget) { | |
| 2422 | + const depsMap = targetMap.get(target); | |
| 2423 | + if (!depsMap) return; | |
| 2424 | + const effects = /* @__PURE__ */ new Set(); | |
| 2425 | + const add2 = (effectsToAdd) => { | |
| 2426 | + if (effectsToAdd) effectsToAdd.forEach((effect3) => { | |
| 2427 | + if (effect3 !== activeEffect || effect3.allowRecurse) effects.add(effect3); | |
| 2428 | + }); | |
| 2429 | + }; | |
| 2430 | + if (type === "clear") depsMap.forEach(add2); | |
| 2431 | + else if (key === "length" && isArray(target)) depsMap.forEach((dep, key2) => { | |
| 2432 | + if (key2 === "length" || key2 >= newValue) add2(dep); | |
| 2433 | + }); | |
| 2434 | + else { | |
| 2435 | + if (key !== void 0) add2(depsMap.get(key)); | |
| 2436 | + switch (type) { | |
| 2437 | + case "add": | |
| 2438 | + if (!isArray(target)) { | |
| 2439 | + add2(depsMap.get(ITERATE_KEY)); | |
| 2440 | + if (isMap(target)) add2(depsMap.get(MAP_KEY_ITERATE_KEY)); | |
| 2441 | + } else if (isIntegerKey(key)) add2(depsMap.get("length")); | |
| 2442 | + break; | |
| 2443 | + case "delete": | |
| 2444 | + if (!isArray(target)) { | |
| 2445 | + add2(depsMap.get(ITERATE_KEY)); | |
| 2446 | + if (isMap(target)) add2(depsMap.get(MAP_KEY_ITERATE_KEY)); | |
| 2447 | + } | |
| 2448 | + break; | |
| 2449 | + case "set": | |
| 2450 | + if (isMap(target)) add2(depsMap.get(ITERATE_KEY)); | |
| 2451 | + break; | |
| 2452 | + } | |
| 2453 | + } | |
| 2454 | + const run = (effect3) => { | |
| 2455 | + if (effect3.options.onTrigger) effect3.options.onTrigger({ | |
| 2456 | + effect: effect3, | |
| 2457 | + target, | |
| 2458 | + key, | |
| 2459 | + type, | |
| 2460 | + newValue, | |
| 2461 | + oldValue, | |
| 2462 | + oldTarget | |
| 2463 | + }); | |
| 2464 | + if (effect3.options.scheduler) effect3.options.scheduler(effect3); | |
| 2465 | + else effect3(); | |
| 2466 | + }; | |
| 2467 | + effects.forEach(run); | |
| 2468 | + } | |
| 2469 | + var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); | |
| 2470 | + var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol)); | |
| 2471 | + var get2 = /* @__PURE__ */ createGetter(); | |
| 2472 | + var readonlyGet = /* @__PURE__ */ createGetter(true); | |
| 2473 | + var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | |
| 2474 | + function createArrayInstrumentations() { | |
| 2475 | + const instrumentations = {}; | |
| 2476 | + [ | |
| 2477 | + "includes", | |
| 2478 | + "indexOf", | |
| 2479 | + "lastIndexOf" | |
| 2480 | + ].forEach((key) => { | |
| 2481 | + instrumentations[key] = function(...args) { | |
| 2482 | + const arr = toRaw(this); | |
| 2483 | + for (let i = 0, l = this.length; i < l; i++) track(arr, "get", i + ""); | |
| 2484 | + const res = arr[key](...args); | |
| 2485 | + if (res === -1 || res === false) return arr[key](...args.map(toRaw)); | |
| 2486 | + else return res; | |
| 2487 | + }; | |
| 2488 | + }); | |
| 2489 | + [ | |
| 2490 | + "push", | |
| 2491 | + "pop", | |
| 2492 | + "shift", | |
| 2493 | + "unshift", | |
| 2494 | + "splice" | |
| 2495 | + ].forEach((key) => { | |
| 2496 | + instrumentations[key] = function(...args) { | |
| 2497 | + pauseTracking(); | |
| 2498 | + const res = toRaw(this)[key].apply(this, args); | |
| 2499 | + resetTracking(); | |
| 2500 | + return res; | |
| 2501 | + }; | |
| 2502 | + }); | |
| 2503 | + return instrumentations; | |
| 2504 | + } | |
| 2505 | + function createGetter(isReadonly = false, shallow = false) { | |
| 2506 | + return function get3(target, key, receiver) { | |
| 2507 | + if (key === "__v_isReactive") return !isReadonly; | |
| 2508 | + else if (key === "__v_isReadonly") return isReadonly; | |
| 2509 | + else if (key === "__v_raw" && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) return target; | |
| 2510 | + const targetIsArray = isArray(target); | |
| 2511 | + if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) return Reflect.get(arrayInstrumentations, key, receiver); | |
| 2512 | + const res = Reflect.get(target, key, receiver); | |
| 2513 | + if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res; | |
| 2514 | + if (!isReadonly) track(target, "get", key); | |
| 2515 | + if (shallow) return res; | |
| 2516 | + if (isRef(res)) return !targetIsArray || !isIntegerKey(key) ? res.value : res; | |
| 2517 | + if (isObject(res)) return isReadonly ? readonly(res) : reactive2(res); | |
| 2518 | + return res; | |
| 2519 | + }; | |
| 2520 | + } | |
| 2521 | + var set2 = /* @__PURE__ */ createSetter(); | |
| 2522 | + function createSetter(shallow = false) { | |
| 2523 | + return function set3(target, key, value, receiver) { | |
| 2524 | + let oldValue = target[key]; | |
| 2525 | + if (!shallow) { | |
| 2526 | + value = toRaw(value); | |
| 2527 | + oldValue = toRaw(oldValue); | |
| 2528 | + if (!isArray(target) && isRef(oldValue) && !isRef(value)) { | |
| 2529 | + oldValue.value = value; | |
| 2530 | + return true; | |
| 2531 | + } | |
| 2532 | + } | |
| 2533 | + const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); | |
| 2534 | + const result = Reflect.set(target, key, value, receiver); | |
| 2535 | + if (target === toRaw(receiver)) { | |
| 2536 | + if (!hadKey) trigger(target, "add", key, value); | |
| 2537 | + else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue); | |
| 2538 | + } | |
| 2539 | + return result; | |
| 2540 | + }; | |
| 2541 | + } | |
| 2542 | + function deleteProperty(target, key) { | |
| 2543 | + const hadKey = hasOwn(target, key); | |
| 2544 | + const oldValue = target[key]; | |
| 2545 | + const result = Reflect.deleteProperty(target, key); | |
| 2546 | + if (result && hadKey) trigger(target, "delete", key, void 0, oldValue); | |
| 2547 | + return result; | |
| 2548 | + } | |
| 2549 | + function has(target, key) { | |
| 2550 | + const result = Reflect.has(target, key); | |
| 2551 | + if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key); | |
| 2552 | + return result; | |
| 2553 | + } | |
| 2554 | + function ownKeys(target) { | |
| 2555 | + track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); | |
| 2556 | + return Reflect.ownKeys(target); | |
| 2557 | + } | |
| 2558 | + var mutableHandlers = { | |
| 2559 | + get: get2, | |
| 2560 | + set: set2, | |
| 2561 | + deleteProperty, | |
| 2562 | + has, | |
| 2563 | + ownKeys | |
| 2564 | + }; | |
| 2565 | + var readonlyHandlers = { | |
| 2566 | + get: readonlyGet, | |
| 2567 | + set(target, key) { | |
| 2568 | + console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target); | |
| 2569 | + return true; | |
| 2570 | + }, | |
| 2571 | + deleteProperty(target, key) { | |
| 2572 | + console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); | |
| 2573 | + return true; | |
| 2574 | + } | |
| 2575 | + }; | |
| 2576 | + var toReactive = (value) => isObject(value) ? reactive2(value) : value; | |
| 2577 | + var toReadonly = (value) => isObject(value) ? readonly(value) : value; | |
| 2578 | + var toShallow = (value) => value; | |
| 2579 | + var getProto = (v) => Reflect.getPrototypeOf(v); | |
| 2580 | + function get$1(target, key, isReadonly = false, isShallow = false) { | |
| 2581 | + target = target["__v_raw"]; | |
| 2582 | + const rawTarget = toRaw(target); | |
| 2583 | + const rawKey = toRaw(key); | |
| 2584 | + if (key !== rawKey) !isReadonly && track(rawTarget, "get", key); | |
| 2585 | + !isReadonly && track(rawTarget, "get", rawKey); | |
| 2586 | + const { has: has2 } = getProto(rawTarget); | |
| 2587 | + const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | |
| 2588 | + if (has2.call(rawTarget, key)) return wrap(target.get(key)); | |
| 2589 | + else if (has2.call(rawTarget, rawKey)) return wrap(target.get(rawKey)); | |
| 2590 | + else if (target !== rawTarget) target.get(key); | |
| 2591 | + } | |
| 2592 | + function has$1(key, isReadonly = false) { | |
| 2593 | + const target = this["__v_raw"]; | |
| 2594 | + const rawTarget = toRaw(target); | |
| 2595 | + const rawKey = toRaw(key); | |
| 2596 | + if (key !== rawKey) !isReadonly && track(rawTarget, "has", key); | |
| 2597 | + !isReadonly && track(rawTarget, "has", rawKey); | |
| 2598 | + return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); | |
| 2599 | + } | |
| 2600 | + function size(target, isReadonly = false) { | |
| 2601 | + target = target["__v_raw"]; | |
| 2602 | + !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY); | |
| 2603 | + return Reflect.get(target, "size", target); | |
| 2604 | + } | |
| 2605 | + function add(value) { | |
| 2606 | + value = toRaw(value); | |
| 2607 | + const target = toRaw(this); | |
| 2608 | + if (!getProto(target).has.call(target, value)) { | |
| 2609 | + target.add(value); | |
| 2610 | + trigger(target, "add", value, value); | |
| 2611 | + } | |
| 2612 | + return this; | |
| 2613 | + } | |
| 2614 | + function set$1(key, value) { | |
| 2615 | + value = toRaw(value); | |
| 2616 | + const target = toRaw(this); | |
| 2617 | + const { has: has2, get: get3 } = getProto(target); | |
| 2618 | + let hadKey = has2.call(target, key); | |
| 2619 | + if (!hadKey) { | |
| 2620 | + key = toRaw(key); | |
| 2621 | + hadKey = has2.call(target, key); | |
| 2622 | + } else checkIdentityKeys(target, has2, key); | |
| 2623 | + const oldValue = get3.call(target, key); | |
| 2624 | + target.set(key, value); | |
| 2625 | + if (!hadKey) trigger(target, "add", key, value); | |
| 2626 | + else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue); | |
| 2627 | + return this; | |
| 2628 | + } | |
| 2629 | + function deleteEntry(key) { | |
| 2630 | + const target = toRaw(this); | |
| 2631 | + const { has: has2, get: get3 } = getProto(target); | |
| 2632 | + let hadKey = has2.call(target, key); | |
| 2633 | + if (!hadKey) { | |
| 2634 | + key = toRaw(key); | |
| 2635 | + hadKey = has2.call(target, key); | |
| 2636 | + } else checkIdentityKeys(target, has2, key); | |
| 2637 | + const oldValue = get3 ? get3.call(target, key) : void 0; | |
| 2638 | + const result = target.delete(key); | |
| 2639 | + if (hadKey) trigger(target, "delete", key, void 0, oldValue); | |
| 2640 | + return result; | |
| 2641 | + } | |
| 2642 | + function clear() { | |
| 2643 | + const target = toRaw(this); | |
| 2644 | + const hadItems = target.size !== 0; | |
| 2645 | + const oldTarget = isMap(target) ? new Map(target) : new Set(target); | |
| 2646 | + const result = target.clear(); | |
| 2647 | + if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget); | |
| 2648 | + return result; | |
| 2649 | + } | |
| 2650 | + function createForEach(isReadonly, isShallow) { | |
| 2651 | + return function forEach(callback, thisArg) { | |
| 2652 | + const observed = this; | |
| 2653 | + const target = observed["__v_raw"]; | |
| 2654 | + const rawTarget = toRaw(target); | |
| 2655 | + const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | |
| 2656 | + !isReadonly && track(rawTarget, "iterate", ITERATE_KEY); | |
| 2657 | + return target.forEach((value, key) => { | |
| 2658 | + return callback.call(thisArg, wrap(value), wrap(key), observed); | |
| 2659 | + }); | |
| 2660 | + }; | |
| 2661 | + } | |
| 2662 | + function createIterableMethod(method, isReadonly, isShallow) { | |
| 2663 | + return function(...args) { | |
| 2664 | + const target = this["__v_raw"]; | |
| 2665 | + const rawTarget = toRaw(target); | |
| 2666 | + const targetIsMap = isMap(rawTarget); | |
| 2667 | + const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; | |
| 2668 | + const isKeyOnly = method === "keys" && targetIsMap; | |
| 2669 | + const innerIterator = target[method](...args); | |
| 2670 | + const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | |
| 2671 | + !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | |
| 2672 | + return { | |
| 2673 | + next() { | |
| 2674 | + const { value, done } = innerIterator.next(); | |
| 2675 | + return done ? { | |
| 2676 | + value, | |
| 2677 | + done | |
| 2678 | + } : { | |
| 2679 | + value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), | |
| 2680 | + done | |
| 2681 | + }; | |
| 2682 | + }, | |
| 2683 | + [Symbol.iterator]() { | |
| 2684 | + return this; | |
| 2685 | + } | |
| 2686 | + }; | |
| 2687 | + }; | |
| 2688 | + } | |
| 2689 | + function createReadonlyMethod(type) { | |
| 2690 | + return function(...args) { | |
| 2691 | + { | |
| 2692 | + const key = args[0] ? `on key "${args[0]}" ` : ``; | |
| 2693 | + console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); | |
| 2694 | + } | |
| 2695 | + return type === "delete" ? false : this; | |
| 2696 | + }; | |
| 2697 | + } | |
| 2698 | + function createInstrumentations() { | |
| 2699 | + const mutableInstrumentations2 = { | |
| 2700 | + get(key) { | |
| 2701 | + return get$1(this, key); | |
| 2702 | + }, | |
| 2703 | + get size() { | |
| 2704 | + return size(this); | |
| 2705 | + }, | |
| 2706 | + has: has$1, | |
| 2707 | + add, | |
| 2708 | + set: set$1, | |
| 2709 | + delete: deleteEntry, | |
| 2710 | + clear, | |
| 2711 | + forEach: createForEach(false, false) | |
| 2712 | + }; | |
| 2713 | + const shallowInstrumentations2 = { | |
| 2714 | + get(key) { | |
| 2715 | + return get$1(this, key, false, true); | |
| 2716 | + }, | |
| 2717 | + get size() { | |
| 2718 | + return size(this); | |
| 2719 | + }, | |
| 2720 | + has: has$1, | |
| 2721 | + add, | |
| 2722 | + set: set$1, | |
| 2723 | + delete: deleteEntry, | |
| 2724 | + clear, | |
| 2725 | + forEach: createForEach(false, true) | |
| 2726 | + }; | |
| 2727 | + const readonlyInstrumentations2 = { | |
| 2728 | + get(key) { | |
| 2729 | + return get$1(this, key, true); | |
| 2730 | + }, | |
| 2731 | + get size() { | |
| 2732 | + return size(this, true); | |
| 2733 | + }, | |
| 2734 | + has(key) { | |
| 2735 | + return has$1.call(this, key, true); | |
| 2736 | + }, | |
| 2737 | + add: createReadonlyMethod("add"), | |
| 2738 | + set: createReadonlyMethod("set"), | |
| 2739 | + delete: createReadonlyMethod("delete"), | |
| 2740 | + clear: createReadonlyMethod("clear"), | |
| 2741 | + forEach: createForEach(true, false) | |
| 2742 | + }; | |
| 2743 | + const shallowReadonlyInstrumentations2 = { | |
| 2744 | + get(key) { | |
| 2745 | + return get$1(this, key, true, true); | |
| 2746 | + }, | |
| 2747 | + get size() { | |
| 2748 | + return size(this, true); | |
| 2749 | + }, | |
| 2750 | + has(key) { | |
| 2751 | + return has$1.call(this, key, true); | |
| 2752 | + }, | |
| 2753 | + add: createReadonlyMethod("add"), | |
| 2754 | + set: createReadonlyMethod("set"), | |
| 2755 | + delete: createReadonlyMethod("delete"), | |
| 2756 | + clear: createReadonlyMethod("clear"), | |
| 2757 | + forEach: createForEach(true, true) | |
| 2758 | + }; | |
| 2759 | + [ | |
| 2760 | + "keys", | |
| 2761 | + "values", | |
| 2762 | + "entries", | |
| 2763 | + Symbol.iterator | |
| 2764 | + ].forEach((method) => { | |
| 2765 | + mutableInstrumentations2[method] = createIterableMethod(method, false, false); | |
| 2766 | + readonlyInstrumentations2[method] = createIterableMethod(method, true, false); | |
| 2767 | + shallowInstrumentations2[method] = createIterableMethod(method, false, true); | |
| 2768 | + shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true); | |
| 2769 | + }); | |
| 2770 | + return [ | |
| 2771 | + mutableInstrumentations2, | |
| 2772 | + readonlyInstrumentations2, | |
| 2773 | + shallowInstrumentations2, | |
| 2774 | + shallowReadonlyInstrumentations2 | |
| 2775 | + ]; | |
| 2776 | + } | |
| 2777 | + var [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations(); | |
| 2778 | + function createInstrumentationGetter(isReadonly, shallow) { | |
| 2779 | + const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; | |
| 2780 | + return (target, key, receiver) => { | |
| 2781 | + if (key === "__v_isReactive") return !isReadonly; | |
| 2782 | + else if (key === "__v_isReadonly") return isReadonly; | |
| 2783 | + else if (key === "__v_raw") return target; | |
| 2784 | + return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); | |
| 2785 | + }; | |
| 2786 | + } | |
| 2787 | + var mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) }; | |
| 2788 | + var readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) }; | |
| 2789 | + function checkIdentityKeys(target, has2, key) { | |
| 2790 | + const rawKey = toRaw(key); | |
| 2791 | + if (rawKey !== key && has2.call(target, rawKey)) { | |
| 2792 | + const type = toRawType(target); | |
| 2793 | + console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`); | |
| 2794 | + } | |
| 2795 | + } | |
| 2796 | + var reactiveMap = /* @__PURE__ */ new WeakMap(); | |
| 2797 | + var shallowReactiveMap = /* @__PURE__ */ new WeakMap(); | |
| 2798 | + var readonlyMap = /* @__PURE__ */ new WeakMap(); | |
| 2799 | + var shallowReadonlyMap = /* @__PURE__ */ new WeakMap(); | |
| 2800 | + function targetTypeMap(rawType) { | |
| 2801 | + switch (rawType) { | |
| 2802 | + case "Object": | |
| 2803 | + case "Array": return 1; | |
| 2804 | + case "Map": | |
| 2805 | + case "Set": | |
| 2806 | + case "WeakMap": | |
| 2807 | + case "WeakSet": return 2; | |
| 2808 | + default: return 0; | |
| 2809 | + } | |
| 2810 | + } | |
| 2811 | + function getTargetType(value) { | |
| 2812 | + return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value)); | |
| 2813 | + } | |
| 2814 | + function reactive2(target) { | |
| 2815 | + if (target && target["__v_isReadonly"]) return target; | |
| 2816 | + return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | |
| 2817 | + } | |
| 2818 | + function readonly(target) { | |
| 2819 | + return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | |
| 2820 | + } | |
| 2821 | + function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | |
| 2822 | + if (!isObject(target)) { | |
| 2823 | + console.warn(`value cannot be made reactive: ${String(target)}`); | |
| 2824 | + return target; | |
| 2825 | + } | |
| 2826 | + if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target; | |
| 2827 | + const existingProxy = proxyMap.get(target); | |
| 2828 | + if (existingProxy) return existingProxy; | |
| 2829 | + const targetType = getTargetType(target); | |
| 2830 | + if (targetType === 0) return target; | |
| 2831 | + const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); | |
| 2832 | + proxyMap.set(target, proxy); | |
| 2833 | + return proxy; | |
| 2834 | + } | |
| 2835 | + function toRaw(observed) { | |
| 2836 | + return observed && toRaw(observed["__v_raw"]) || observed; | |
| 2837 | + } | |
| 2838 | + function isRef(r) { | |
| 2839 | + return Boolean(r && r.__v_isRef === true); | |
| 2840 | + } | |
| 2841 | + magic("nextTick", () => nextTick); | |
| 2842 | + magic("dispatch", (el) => dispatch.bind(dispatch, el)); | |
| 2843 | + magic("watch", (el, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => (key, callback) => { | |
| 2844 | + let evaluate2 = evaluateLater2(key); | |
| 2845 | + let getter = () => { | |
| 2846 | + let value; | |
| 2847 | + evaluate2((i) => value = i); | |
| 2848 | + return value; | |
| 2849 | + }; | |
| 2850 | + cleanup2(watch(getter, callback)); | |
| 2851 | + }); | |
| 2852 | + magic("store", getStores); | |
| 2853 | + magic("data", (el) => scope(el)); | |
| 2854 | + magic("root", (el) => closestRoot(el)); | |
| 2855 | + magic("refs", (el) => { | |
| 2856 | + if (el._x_refs_proxy) return el._x_refs_proxy; | |
| 2857 | + el._x_refs_proxy = mergeProxies(getArrayOfRefObject(el)); | |
| 2858 | + return el._x_refs_proxy; | |
| 2859 | + }); | |
| 2860 | + function getArrayOfRefObject(el) { | |
| 2861 | + let refObjects = []; | |
| 2862 | + findClosest(el, (i) => { | |
| 2863 | + if (i._x_refs) refObjects.push(i._x_refs); | |
| 2864 | + }); | |
| 2865 | + return refObjects; | |
| 2866 | + } | |
| 2867 | + var globalIdMemo = {}; | |
| 2868 | + function findAndIncrementId(name) { | |
| 2869 | + if (!globalIdMemo[name]) globalIdMemo[name] = 0; | |
| 2870 | + return ++globalIdMemo[name]; | |
| 2871 | + } | |
| 2872 | + function closestIdRoot(el, name) { | |
| 2873 | + return findClosest(el, (element) => { | |
| 2874 | + if (element._x_ids && element._x_ids[name]) return true; | |
| 2875 | + }); | |
| 2876 | + } | |
| 2877 | + function setIdRoot(el, name) { | |
| 2878 | + if (!el._x_ids) el._x_ids = {}; | |
| 2879 | + if (!el._x_ids[name]) el._x_ids[name] = findAndIncrementId(name); | |
| 2880 | + } | |
| 2881 | + magic("id", (el, { cleanup: cleanup2 }) => (name, key = null) => { | |
| 2882 | + return cacheIdByNameOnElement(el, `${name}${key ? `-${key}` : ""}`, cleanup2, () => { | |
| 2883 | + let root = closestIdRoot(el, name); | |
| 2884 | + let id = root ? root._x_ids[name] : findAndIncrementId(name); | |
| 2885 | + return key ? `${name}-${id}-${key}` : `${name}-${id}`; | |
| 2886 | + }); | |
| 2887 | + }); | |
| 2888 | + interceptClone((from, to) => { | |
| 2889 | + if (from._x_id) to._x_id = from._x_id; | |
| 2890 | + }); | |
| 2891 | + function cacheIdByNameOnElement(el, cacheKey, cleanup2, callback) { | |
| 2892 | + if (!el._x_id) el._x_id = {}; | |
| 2893 | + if (el._x_id[cacheKey]) return el._x_id[cacheKey]; | |
| 2894 | + let output = callback(); | |
| 2895 | + el._x_id[cacheKey] = output; | |
| 2896 | + cleanup2(() => { | |
| 2897 | + delete el._x_id[cacheKey]; | |
| 2898 | + }); | |
| 2899 | + return output; | |
| 2900 | + } | |
| 2901 | + magic("el", (el) => el); | |
| 2902 | + warnMissingPluginMagic("Focus", "focus", "focus"); | |
| 2903 | + warnMissingPluginMagic("Persist", "persist", "persist"); | |
| 2904 | + function warnMissingPluginMagic(name, magicName, slug) { | |
| 2905 | + magic(magicName, (el) => warn(`You can't use [$${magicName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); | |
| 2906 | + } | |
| 2907 | + directive("modelable", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { | |
| 2908 | + let func = evaluateLater2(expression); | |
| 2909 | + let innerGet = () => { | |
| 2910 | + let result; | |
| 2911 | + func((i) => result = i); | |
| 2912 | + return result; | |
| 2913 | + }; | |
| 2914 | + let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`); | |
| 2915 | + let innerSet = (val) => evaluateInnerSet(() => {}, { scope: { "__placeholder": val } }); | |
| 2916 | + innerSet(innerGet()); | |
| 2917 | + queueMicrotask(() => { | |
| 2918 | + if (!el._x_model) return; | |
| 2919 | + el._x_removeModelListeners["default"](); | |
| 2920 | + let outerGet = el._x_model.get; | |
| 2921 | + let outerSet = el._x_model.set; | |
| 2922 | + cleanup2(entangle({ | |
| 2923 | + get() { | |
| 2924 | + return outerGet(); | |
| 2925 | + }, | |
| 2926 | + set(value) { | |
| 2927 | + outerSet(value); | |
| 2928 | + } | |
| 2929 | + }, { | |
| 2930 | + get() { | |
| 2931 | + return innerGet(); | |
| 2932 | + }, | |
| 2933 | + set(value) { | |
| 2934 | + innerSet(value); | |
| 2935 | + } | |
| 2936 | + })); | |
| 2937 | + }); | |
| 2938 | + }); | |
| 2939 | + directive("teleport", (el, { modifiers, expression }, { cleanup: cleanup2 }) => { | |
| 2940 | + if (el.tagName.toLowerCase() !== "template") warn("x-teleport can only be used on a <template> tag", el); | |
| 2941 | + let target = getTarget(expression); | |
| 2942 | + let clone2 = el.content.cloneNode(true).firstElementChild; | |
| 2943 | + el._x_teleport = clone2; | |
| 2944 | + clone2._x_teleportBack = el; | |
| 2945 | + el.setAttribute("data-teleport-template", true); | |
| 2946 | + clone2.setAttribute("data-teleport-target", true); | |
| 2947 | + if (el._x_forwardEvents) el._x_forwardEvents.forEach((eventName) => { | |
| 2948 | + clone2.addEventListener(eventName, (e) => { | |
| 2949 | + e.stopPropagation(); | |
| 2950 | + el.dispatchEvent(new e.constructor(e.type, e)); | |
| 2951 | + }); | |
| 2952 | + }); | |
| 2953 | + addScopeToNode(clone2, {}, el); | |
| 2954 | + let placeInDom = (clone3, target2, modifiers2) => { | |
| 2955 | + if (modifiers2.includes("prepend")) target2.parentNode.insertBefore(clone3, target2); | |
| 2956 | + else if (modifiers2.includes("append")) target2.parentNode.insertBefore(clone3, target2.nextSibling); | |
| 2957 | + else target2.appendChild(clone3); | |
| 2958 | + }; | |
| 2959 | + mutateDom(() => { | |
| 2960 | + placeInDom(clone2, target, modifiers); | |
| 2961 | + skipDuringClone(() => { | |
| 2962 | + initTree(clone2); | |
| 2963 | + })(); | |
| 2964 | + }); | |
| 2965 | + el._x_teleportPutBack = () => { | |
| 2966 | + let target2 = getTarget(expression); | |
| 2967 | + mutateDom(() => { | |
| 2968 | + placeInDom(el._x_teleport, target2, modifiers); | |
| 2969 | + }); | |
| 2970 | + }; | |
| 2971 | + cleanup2(() => mutateDom(() => { | |
| 2972 | + clone2.remove(); | |
| 2973 | + destroyTree(clone2); | |
| 2974 | + })); | |
| 2975 | + }); | |
| 2976 | + var teleportContainerDuringClone = document.createElement("div"); | |
| 2977 | + function getTarget(expression) { | |
| 2978 | + let target = skipDuringClone(() => { | |
| 2979 | + return document.querySelector(expression); | |
| 2980 | + }, () => { | |
| 2981 | + return teleportContainerDuringClone; | |
| 2982 | + })(); | |
| 2983 | + if (!target) warn(`Cannot find x-teleport element for selector: "${expression}"`); | |
| 2984 | + return target; | |
| 2985 | + } | |
| 2986 | + var handler = () => {}; | |
| 2987 | + handler.inline = (el, { modifiers }, { cleanup: cleanup2 }) => { | |
| 2988 | + modifiers.includes("self") ? el._x_ignoreSelf = true : el._x_ignore = true; | |
| 2989 | + cleanup2(() => { | |
| 2990 | + modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore; | |
| 2991 | + }); | |
| 2992 | + }; | |
| 2993 | + directive("ignore", handler); | |
| 2994 | + directive("effect", skipDuringClone((el, { expression }, { effect: effect3 }) => { | |
| 2995 | + effect3(evaluateLater(el, expression)); | |
| 2996 | + })); | |
| 2997 | + function on(el, event, modifiers, callback) { | |
| 2998 | + let listenerTarget = el; | |
| 2999 | + let handler4 = (e) => callback(e); | |
| 3000 | + let options = {}; | |
| 3001 | + let wrapHandler = (callback2, wrapper) => (e) => wrapper(callback2, e); | |
| 3002 | + if (modifiers.includes("dot")) event = dotSyntax(event); | |
| 3003 | + if (modifiers.includes("camel")) event = camelCase2(event); | |
| 3004 | + if (modifiers.includes("passive")) options.passive = true; | |
| 3005 | + if (modifiers.includes("capture")) options.capture = true; | |
| 3006 | + if (modifiers.includes("window")) listenerTarget = window; | |
| 3007 | + if (modifiers.includes("document")) listenerTarget = document; | |
| 3008 | + if (modifiers.includes("debounce")) { | |
| 3009 | + let nextModifier = modifiers[modifiers.indexOf("debounce") + 1] || "invalid-wait"; | |
| 3010 | + let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; | |
| 3011 | + handler4 = debounce(handler4, wait); | |
| 3012 | + } | |
| 3013 | + if (modifiers.includes("throttle")) { | |
| 3014 | + let nextModifier = modifiers[modifiers.indexOf("throttle") + 1] || "invalid-wait"; | |
| 3015 | + let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; | |
| 3016 | + handler4 = throttle(handler4, wait); | |
| 3017 | + } | |
| 3018 | + if (modifiers.includes("prevent")) handler4 = wrapHandler(handler4, (next, e) => { | |
| 3019 | + e.preventDefault(); | |
| 3020 | + next(e); | |
| 3021 | + }); | |
| 3022 | + if (modifiers.includes("stop")) handler4 = wrapHandler(handler4, (next, e) => { | |
| 3023 | + e.stopPropagation(); | |
| 3024 | + next(e); | |
| 3025 | + }); | |
| 3026 | + if (modifiers.includes("once")) handler4 = wrapHandler(handler4, (next, e) => { | |
| 3027 | + next(e); | |
| 3028 | + listenerTarget.removeEventListener(event, handler4, options); | |
| 3029 | + }); | |
| 3030 | + if (modifiers.includes("away") || modifiers.includes("outside")) { | |
| 3031 | + listenerTarget = document; | |
| 3032 | + handler4 = wrapHandler(handler4, (next, e) => { | |
| 3033 | + if (el.contains(e.target)) return; | |
| 3034 | + if (e.target.isConnected === false) return; | |
| 3035 | + if (el.offsetWidth < 1 && el.offsetHeight < 1) return; | |
| 3036 | + if (el._x_isShown === false) return; | |
| 3037 | + next(e); | |
| 3038 | + }); | |
| 3039 | + } | |
| 3040 | + if (modifiers.includes("self")) handler4 = wrapHandler(handler4, (next, e) => { | |
| 3041 | + e.target === el && next(e); | |
| 3042 | + }); | |
| 3043 | + if (isKeyEvent(event) || isClickEvent(event)) handler4 = wrapHandler(handler4, (next, e) => { | |
| 3044 | + if (isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers)) return; | |
| 3045 | + next(e); | |
| 3046 | + }); | |
| 3047 | + listenerTarget.addEventListener(event, handler4, options); | |
| 3048 | + return () => { | |
| 3049 | + listenerTarget.removeEventListener(event, handler4, options); | |
| 3050 | + }; | |
| 3051 | + } | |
| 3052 | + function dotSyntax(subject) { | |
| 3053 | + return subject.replace(/-/g, "."); | |
| 3054 | + } | |
| 3055 | + function camelCase2(subject) { | |
| 3056 | + return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); | |
| 3057 | + } | |
| 3058 | + function isNumeric(subject) { | |
| 3059 | + return !Array.isArray(subject) && !isNaN(subject); | |
| 3060 | + } | |
| 3061 | + function kebabCase2(subject) { | |
| 3062 | + if ([" ", "_"].includes(subject)) return subject; | |
| 3063 | + return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); | |
| 3064 | + } | |
| 3065 | + function isKeyEvent(event) { | |
| 3066 | + return ["keydown", "keyup"].includes(event); | |
| 3067 | + } | |
| 3068 | + function isClickEvent(event) { | |
| 3069 | + return [ | |
| 3070 | + "contextmenu", | |
| 3071 | + "click", | |
| 3072 | + "mouse" | |
| 3073 | + ].some((i) => event.includes(i)); | |
| 3074 | + } | |
| 3075 | + function isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers) { | |
| 3076 | + let keyModifiers = modifiers.filter((i) => { | |
| 3077 | + return ![ | |
| 3078 | + "window", | |
| 3079 | + "document", | |
| 3080 | + "prevent", | |
| 3081 | + "stop", | |
| 3082 | + "once", | |
| 3083 | + "capture", | |
| 3084 | + "self", | |
| 3085 | + "away", | |
| 3086 | + "outside", | |
| 3087 | + "passive", | |
| 3088 | + "preserve-scroll" | |
| 3089 | + ].includes(i); | |
| 3090 | + }); | |
| 3091 | + if (keyModifiers.includes("debounce")) { | |
| 3092 | + let debounceIndex = keyModifiers.indexOf("debounce"); | |
| 3093 | + keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); | |
| 3094 | + } | |
| 3095 | + if (keyModifiers.includes("throttle")) { | |
| 3096 | + let debounceIndex = keyModifiers.indexOf("throttle"); | |
| 3097 | + keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); | |
| 3098 | + } | |
| 3099 | + if (keyModifiers.length === 0) return false; | |
| 3100 | + if (keyModifiers.length === 1 && keyToModifiers(e.key).includes(keyModifiers[0])) return false; | |
| 3101 | + const selectedSystemKeyModifiers = [ | |
| 3102 | + "ctrl", | |
| 3103 | + "shift", | |
| 3104 | + "alt", | |
| 3105 | + "meta", | |
| 3106 | + "cmd", | |
| 3107 | + "super" | |
| 3108 | + ].filter((modifier) => keyModifiers.includes(modifier)); | |
| 3109 | + keyModifiers = keyModifiers.filter((i) => !selectedSystemKeyModifiers.includes(i)); | |
| 3110 | + if (selectedSystemKeyModifiers.length > 0) { | |
| 3111 | + if (selectedSystemKeyModifiers.filter((modifier) => { | |
| 3112 | + if (modifier === "cmd" || modifier === "super") modifier = "meta"; | |
| 3113 | + return e[`${modifier}Key`]; | |
| 3114 | + }).length === selectedSystemKeyModifiers.length) { | |
| 3115 | + if (isClickEvent(e.type)) return false; | |
| 3116 | + if (keyToModifiers(e.key).includes(keyModifiers[0])) return false; | |
| 3117 | + } | |
| 3118 | + } | |
| 3119 | + return true; | |
| 3120 | + } | |
| 3121 | + function keyToModifiers(key) { | |
| 3122 | + if (!key) return []; | |
| 3123 | + key = kebabCase2(key); | |
| 3124 | + let modifierToKeyMap = { | |
| 3125 | + "ctrl": "control", | |
| 3126 | + "slash": "/", | |
| 3127 | + "space": " ", | |
| 3128 | + "spacebar": " ", | |
| 3129 | + "cmd": "meta", | |
| 3130 | + "esc": "escape", | |
| 3131 | + "up": "arrow-up", | |
| 3132 | + "down": "arrow-down", | |
| 3133 | + "left": "arrow-left", | |
| 3134 | + "right": "arrow-right", | |
| 3135 | + "period": ".", | |
| 3136 | + "comma": ",", | |
| 3137 | + "equal": "=", | |
| 3138 | + "minus": "-", | |
| 3139 | + "underscore": "_" | |
| 3140 | + }; | |
| 3141 | + modifierToKeyMap[key] = key; | |
| 3142 | + return Object.keys(modifierToKeyMap).map((modifier) => { | |
| 3143 | + if (modifierToKeyMap[modifier] === key) return modifier; | |
| 3144 | + }).filter((modifier) => modifier); | |
| 3145 | + } | |
| 3146 | + directive("model", (el, { modifiers, expression }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3147 | + let scopeTarget = el; | |
| 3148 | + if (modifiers.includes("parent")) scopeTarget = el.parentNode; | |
| 3149 | + let evaluateGet = evaluateLater(scopeTarget, expression); | |
| 3150 | + let evaluateSet; | |
| 3151 | + if (typeof expression === "string") evaluateSet = evaluateLater(scopeTarget, `${expression} = __placeholder`); | |
| 3152 | + else if (typeof expression === "function" && typeof expression() === "string") evaluateSet = evaluateLater(scopeTarget, `${expression()} = __placeholder`); | |
| 3153 | + else evaluateSet = () => {}; | |
| 3154 | + let getValue = () => { | |
| 3155 | + let result; | |
| 3156 | + evaluateGet((value) => result = value); | |
| 3157 | + return isGetterSetter(result) ? result.get() : result; | |
| 3158 | + }; | |
| 3159 | + let setValue = (value) => { | |
| 3160 | + let result; | |
| 3161 | + evaluateGet((value2) => result = value2); | |
| 3162 | + if (isGetterSetter(result)) result.set(value); | |
| 3163 | + else evaluateSet(() => {}, { scope: { "__placeholder": value } }); | |
| 3164 | + }; | |
| 3165 | + if (typeof expression === "string" && el.type === "radio") mutateDom(() => { | |
| 3166 | + if (!el.hasAttribute("name")) el.setAttribute("name", expression); | |
| 3167 | + }); | |
| 3168 | + let event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input"; | |
| 3169 | + let removeListener = isCloning ? () => {} : on(el, event, modifiers, (e) => { | |
| 3170 | + setValue(getInputValue(el, modifiers, e, getValue())); | |
| 3171 | + }); | |
| 3172 | + if (modifiers.includes("fill")) { | |
| 3173 | + if ([ | |
| 3174 | + void 0, | |
| 3175 | + null, | |
| 3176 | + "" | |
| 3177 | + ].includes(getValue()) || isCheckbox(el) && Array.isArray(getValue()) || el.tagName.toLowerCase() === "select" && el.multiple) setValue(getInputValue(el, modifiers, { target: el }, getValue())); | |
| 3178 | + } | |
| 3179 | + if (!el._x_removeModelListeners) el._x_removeModelListeners = {}; | |
| 3180 | + el._x_removeModelListeners["default"] = removeListener; | |
| 3181 | + cleanup2(() => el._x_removeModelListeners["default"]()); | |
| 3182 | + if (el.form) { | |
| 3183 | + let removeResetListener = on(el.form, "reset", [], (e) => { | |
| 3184 | + nextTick(() => el._x_model && el._x_model.set(getInputValue(el, modifiers, { target: el }, getValue()))); | |
| 3185 | + }); | |
| 3186 | + cleanup2(() => removeResetListener()); | |
| 3187 | + } | |
| 3188 | + el._x_model = { | |
| 3189 | + get() { | |
| 3190 | + return getValue(); | |
| 3191 | + }, | |
| 3192 | + set(value) { | |
| 3193 | + setValue(value); | |
| 3194 | + } | |
| 3195 | + }; | |
| 3196 | + el._x_forceModelUpdate = (value) => { | |
| 3197 | + if (value === void 0 && typeof expression === "string" && expression.match(/\./)) value = ""; | |
| 3198 | + window.fromModel = true; | |
| 3199 | + mutateDom(() => bind(el, "value", value)); | |
| 3200 | + delete window.fromModel; | |
| 3201 | + }; | |
| 3202 | + effect3(() => { | |
| 3203 | + let value = getValue(); | |
| 3204 | + if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el)) return; | |
| 3205 | + el._x_forceModelUpdate(value); | |
| 3206 | + }); | |
| 3207 | + }); | |
| 3208 | + function getInputValue(el, modifiers, event, currentValue) { | |
| 3209 | + return mutateDom(() => { | |
| 3210 | + if (event instanceof CustomEvent && event.detail !== void 0) return event.detail !== null && event.detail !== void 0 ? event.detail : event.target.value; | |
| 3211 | + else if (isCheckbox(el)) if (Array.isArray(currentValue)) { | |
| 3212 | + let newValue = null; | |
| 3213 | + if (modifiers.includes("number")) newValue = safeParseNumber(event.target.value); | |
| 3214 | + else if (modifiers.includes("boolean")) newValue = safeParseBoolean(event.target.value); | |
| 3215 | + else newValue = event.target.value; | |
| 3216 | + return event.target.checked ? currentValue.includes(newValue) ? currentValue : currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); | |
| 3217 | + } else return event.target.checked; | |
| 3218 | + else if (el.tagName.toLowerCase() === "select" && el.multiple) { | |
| 3219 | + if (modifiers.includes("number")) return Array.from(event.target.selectedOptions).map((option) => { | |
| 3220 | + return safeParseNumber(option.value || option.text); | |
| 3221 | + }); | |
| 3222 | + else if (modifiers.includes("boolean")) return Array.from(event.target.selectedOptions).map((option) => { | |
| 3223 | + return safeParseBoolean(option.value || option.text); | |
| 3224 | + }); | |
| 3225 | + return Array.from(event.target.selectedOptions).map((option) => { | |
| 3226 | + return option.value || option.text; | |
| 3227 | + }); | |
| 3228 | + } else { | |
| 3229 | + let newValue; | |
| 3230 | + if (isRadio(el)) if (event.target.checked) newValue = event.target.value; | |
| 3231 | + else newValue = currentValue; | |
| 3232 | + else newValue = event.target.value; | |
| 3233 | + if (modifiers.includes("number")) return safeParseNumber(newValue); | |
| 3234 | + else if (modifiers.includes("boolean")) return safeParseBoolean(newValue); | |
| 3235 | + else if (modifiers.includes("trim")) return newValue.trim(); | |
| 3236 | + else return newValue; | |
| 3237 | + } | |
| 3238 | + }); | |
| 3239 | + } | |
| 3240 | + function safeParseNumber(rawValue) { | |
| 3241 | + let number = rawValue ? parseFloat(rawValue) : null; | |
| 3242 | + return isNumeric2(number) ? number : rawValue; | |
| 3243 | + } | |
| 3244 | + function checkedAttrLooseCompare2(valueA, valueB) { | |
| 3245 | + return valueA == valueB; | |
| 3246 | + } | |
| 3247 | + function isNumeric2(subject) { | |
| 3248 | + return !Array.isArray(subject) && !isNaN(subject); | |
| 3249 | + } | |
| 3250 | + function isGetterSetter(value) { | |
| 3251 | + return value !== null && typeof value === "object" && typeof value.get === "function" && typeof value.set === "function"; | |
| 3252 | + } | |
| 3253 | + directive("cloak", (el) => queueMicrotask(() => mutateDom(() => el.removeAttribute(prefix("cloak"))))); | |
| 3254 | + addInitSelector(() => `[${prefix("init")}]`); | |
| 3255 | + directive("init", skipDuringClone((el, { expression }, { evaluate: evaluate2 }) => { | |
| 3256 | + if (typeof expression === "string") return !!expression.trim() && evaluate2(expression, {}, false); | |
| 3257 | + return evaluate2(expression, {}, false); | |
| 3258 | + })); | |
| 3259 | + directive("text", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => { | |
| 3260 | + let evaluate2 = evaluateLater2(expression); | |
| 3261 | + effect3(() => { | |
| 3262 | + evaluate2((value) => { | |
| 3263 | + mutateDom(() => { | |
| 3264 | + el.textContent = value; | |
| 3265 | + }); | |
| 3266 | + }); | |
| 3267 | + }); | |
| 3268 | + }); | |
| 3269 | + directive("html", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => { | |
| 3270 | + let evaluate2 = evaluateLater2(expression); | |
| 3271 | + effect3(() => { | |
| 3272 | + evaluate2((value) => { | |
| 3273 | + mutateDom(() => { | |
| 3274 | + el.innerHTML = value; | |
| 3275 | + el._x_ignoreSelf = true; | |
| 3276 | + initTree(el); | |
| 3277 | + delete el._x_ignoreSelf; | |
| 3278 | + }); | |
| 3279 | + }); | |
| 3280 | + }); | |
| 3281 | + }); | |
| 3282 | + mapAttributes(startingWith(":", into(prefix("bind:")))); | |
| 3283 | + var handler2 = (el, { value, modifiers, expression, original }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3284 | + if (!value) { | |
| 3285 | + let bindingProviders = {}; | |
| 3286 | + injectBindingProviders(bindingProviders); | |
| 3287 | + evaluateLater(el, expression)((bindings) => { | |
| 3288 | + applyBindingsObject(el, bindings, original); | |
| 3289 | + }, { scope: bindingProviders }); | |
| 3290 | + return; | |
| 3291 | + } | |
| 3292 | + if (value === "key") return storeKeyForXFor(el, expression); | |
| 3293 | + if (el._x_inlineBindings && el._x_inlineBindings[value] && el._x_inlineBindings[value].extract) return; | |
| 3294 | + let evaluate2 = evaluateLater(el, expression); | |
| 3295 | + effect3(() => evaluate2((result) => { | |
| 3296 | + if (result === void 0 && typeof expression === "string" && expression.match(/\./)) result = ""; | |
| 3297 | + mutateDom(() => bind(el, value, result, modifiers)); | |
| 3298 | + })); | |
| 3299 | + cleanup2(() => { | |
| 3300 | + el._x_undoAddedClasses && el._x_undoAddedClasses(); | |
| 3301 | + el._x_undoAddedStyles && el._x_undoAddedStyles(); | |
| 3302 | + }); | |
| 3303 | + }; | |
| 3304 | + handler2.inline = (el, { value, modifiers, expression }) => { | |
| 3305 | + if (!value) return; | |
| 3306 | + if (!el._x_inlineBindings) el._x_inlineBindings = {}; | |
| 3307 | + el._x_inlineBindings[value] = { | |
| 3308 | + expression, | |
| 3309 | + extract: false | |
| 3310 | + }; | |
| 3311 | + }; | |
| 3312 | + directive("bind", handler2); | |
| 3313 | + function storeKeyForXFor(el, expression) { | |
| 3314 | + el._x_keyExpression = expression; | |
| 3315 | + } | |
| 3316 | + addRootSelector(() => `[${prefix("data")}]`); | |
| 3317 | + directive("data", (el, { expression }, { cleanup: cleanup2 }) => { | |
| 3318 | + if (shouldSkipRegisteringDataDuringClone(el)) return; | |
| 3319 | + expression = expression === "" ? "{}" : expression; | |
| 3320 | + let magicContext = {}; | |
| 3321 | + injectMagics(magicContext, el); | |
| 3322 | + let dataProviderContext = {}; | |
| 3323 | + injectDataProviders(dataProviderContext, magicContext); | |
| 3324 | + let data2 = evaluate(el, expression, { scope: dataProviderContext }); | |
| 3325 | + if (data2 === void 0 || data2 === true) data2 = {}; | |
| 3326 | + injectMagics(data2, el); | |
| 3327 | + let reactiveData = reactive(data2); | |
| 3328 | + initInterceptors(reactiveData); | |
| 3329 | + let undo = addScopeToNode(el, reactiveData); | |
| 3330 | + reactiveData["init"] && evaluate(el, reactiveData["init"]); | |
| 3331 | + cleanup2(() => { | |
| 3332 | + reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]); | |
| 3333 | + undo(); | |
| 3334 | + }); | |
| 3335 | + }); | |
| 3336 | + interceptClone((from, to) => { | |
| 3337 | + if (from._x_dataStack) { | |
| 3338 | + to._x_dataStack = from._x_dataStack; | |
| 3339 | + to.setAttribute("data-has-alpine-state", true); | |
| 3340 | + } | |
| 3341 | + }); | |
| 3342 | + function shouldSkipRegisteringDataDuringClone(el) { | |
| 3343 | + if (!isCloning) return false; | |
| 3344 | + if (isCloningLegacy) return true; | |
| 3345 | + return el.hasAttribute("data-has-alpine-state"); | |
| 3346 | + } | |
| 3347 | + directive("show", (el, { modifiers, expression }, { effect: effect3 }) => { | |
| 3348 | + let evaluate2 = evaluateLater(el, expression); | |
| 3349 | + if (!el._x_doHide) el._x_doHide = () => { | |
| 3350 | + mutateDom(() => { | |
| 3351 | + el.style.setProperty("display", "none", modifiers.includes("important") ? "important" : void 0); | |
| 3352 | + }); | |
| 3353 | + }; | |
| 3354 | + if (!el._x_doShow) el._x_doShow = () => { | |
| 3355 | + mutateDom(() => { | |
| 3356 | + if (el.style.length === 1 && el.style.display === "none") el.removeAttribute("style"); | |
| 3357 | + else el.style.removeProperty("display"); | |
| 3358 | + }); | |
| 3359 | + }; | |
| 3360 | + let hide = () => { | |
| 3361 | + el._x_doHide(); | |
| 3362 | + el._x_isShown = false; | |
| 3363 | + }; | |
| 3364 | + let show = () => { | |
| 3365 | + el._x_doShow(); | |
| 3366 | + el._x_isShown = true; | |
| 3367 | + }; | |
| 3368 | + let clickAwayCompatibleShow = () => setTimeout(show); | |
| 3369 | + let toggle = once((value) => value ? show() : hide(), (value) => { | |
| 3370 | + if (typeof el._x_toggleAndCascadeWithTransitions === "function") el._x_toggleAndCascadeWithTransitions(el, value, show, hide); | |
| 3371 | + else value ? clickAwayCompatibleShow() : hide(); | |
| 3372 | + }); | |
| 3373 | + let oldValue; | |
| 3374 | + let firstTime = true; | |
| 3375 | + effect3(() => evaluate2((value) => { | |
| 3376 | + if (!firstTime && value === oldValue) return; | |
| 3377 | + if (modifiers.includes("immediate")) value ? clickAwayCompatibleShow() : hide(); | |
| 3378 | + toggle(value); | |
| 3379 | + oldValue = value; | |
| 3380 | + firstTime = false; | |
| 3381 | + })); | |
| 3382 | + }); | |
| 3383 | + directive("for", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3384 | + let iteratorNames = parseForExpression(expression); | |
| 3385 | + let evaluateItems = evaluateLater(el, iteratorNames.items); | |
| 3386 | + let evaluateKey = evaluateLater(el, el._x_keyExpression || "index"); | |
| 3387 | + el._x_prevKeys = []; | |
| 3388 | + el._x_lookup = {}; | |
| 3389 | + effect3(() => loop(el, iteratorNames, evaluateItems, evaluateKey)); | |
| 3390 | + cleanup2(() => { | |
| 3391 | + Object.values(el._x_lookup).forEach((el2) => mutateDom(() => { | |
| 3392 | + destroyTree(el2); | |
| 3393 | + el2.remove(); | |
| 3394 | + })); | |
| 3395 | + delete el._x_prevKeys; | |
| 3396 | + delete el._x_lookup; | |
| 3397 | + }); | |
| 3398 | + }); | |
| 3399 | + function loop(el, iteratorNames, evaluateItems, evaluateKey) { | |
| 3400 | + let isObject2 = (i) => typeof i === "object" && !Array.isArray(i); | |
| 3401 | + let templateEl = el; | |
| 3402 | + evaluateItems((items) => { | |
| 3403 | + if (isNumeric3(items) && items >= 0) items = Array.from(Array(items).keys(), (i) => i + 1); | |
| 3404 | + if (items === void 0) items = []; | |
| 3405 | + let lookup = el._x_lookup; | |
| 3406 | + let prevKeys = el._x_prevKeys; | |
| 3407 | + let scopes = []; | |
| 3408 | + let keys = []; | |
| 3409 | + if (isObject2(items)) items = Object.entries(items).map(([key, value]) => { | |
| 3410 | + let scope2 = getIterationScopeVariables(iteratorNames, value, key, items); | |
| 3411 | + evaluateKey((value2) => { | |
| 3412 | + if (keys.includes(value2)) warn("Duplicate key on x-for", el); | |
| 3413 | + keys.push(value2); | |
| 3414 | + }, { scope: { | |
| 3415 | + index: key, | |
| 3416 | + ...scope2 | |
| 3417 | + } }); | |
| 3418 | + scopes.push(scope2); | |
| 3419 | + }); | |
| 3420 | + else for (let i = 0; i < items.length; i++) { | |
| 3421 | + let scope2 = getIterationScopeVariables(iteratorNames, items[i], i, items); | |
| 3422 | + evaluateKey((value) => { | |
| 3423 | + if (keys.includes(value)) warn("Duplicate key on x-for", el); | |
| 3424 | + keys.push(value); | |
| 3425 | + }, { scope: { | |
| 3426 | + index: i, | |
| 3427 | + ...scope2 | |
| 3428 | + } }); | |
| 3429 | + scopes.push(scope2); | |
| 3430 | + } | |
| 3431 | + let adds = []; | |
| 3432 | + let moves = []; | |
| 3433 | + let removes = []; | |
| 3434 | + let sames = []; | |
| 3435 | + for (let i = 0; i < prevKeys.length; i++) { | |
| 3436 | + let key = prevKeys[i]; | |
| 3437 | + if (keys.indexOf(key) === -1) removes.push(key); | |
| 3438 | + } | |
| 3439 | + prevKeys = prevKeys.filter((key) => !removes.includes(key)); | |
| 3440 | + let lastKey = "template"; | |
| 3441 | + for (let i = 0; i < keys.length; i++) { | |
| 3442 | + let key = keys[i]; | |
| 3443 | + let prevIndex = prevKeys.indexOf(key); | |
| 3444 | + if (prevIndex === -1) { | |
| 3445 | + prevKeys.splice(i, 0, key); | |
| 3446 | + adds.push([lastKey, i]); | |
| 3447 | + } else if (prevIndex !== i) { | |
| 3448 | + let keyInSpot = prevKeys.splice(i, 1)[0]; | |
| 3449 | + let keyForSpot = prevKeys.splice(prevIndex - 1, 1)[0]; | |
| 3450 | + prevKeys.splice(i, 0, keyForSpot); | |
| 3451 | + prevKeys.splice(prevIndex, 0, keyInSpot); | |
| 3452 | + moves.push([keyInSpot, keyForSpot]); | |
| 3453 | + } else sames.push(key); | |
| 3454 | + lastKey = key; | |
| 3455 | + } | |
| 3456 | + for (let i = 0; i < removes.length; i++) { | |
| 3457 | + let key = removes[i]; | |
| 3458 | + if (!(key in lookup)) continue; | |
| 3459 | + mutateDom(() => { | |
| 3460 | + destroyTree(lookup[key]); | |
| 3461 | + lookup[key].remove(); | |
| 3462 | + }); | |
| 3463 | + delete lookup[key]; | |
| 3464 | + } | |
| 3465 | + for (let i = 0; i < moves.length; i++) { | |
| 3466 | + let [keyInSpot, keyForSpot] = moves[i]; | |
| 3467 | + let elInSpot = lookup[keyInSpot]; | |
| 3468 | + let elForSpot = lookup[keyForSpot]; | |
| 3469 | + let marker = document.createElement("div"); | |
| 3470 | + mutateDom(() => { | |
| 3471 | + if (!elForSpot) warn(`x-for ":key" is undefined or invalid`, templateEl, keyForSpot, lookup); | |
| 3472 | + elForSpot.after(marker); | |
| 3473 | + elInSpot.after(elForSpot); | |
| 3474 | + elForSpot._x_currentIfEl && elForSpot.after(elForSpot._x_currentIfEl); | |
| 3475 | + marker.before(elInSpot); | |
| 3476 | + elInSpot._x_currentIfEl && elInSpot.after(elInSpot._x_currentIfEl); | |
| 3477 | + marker.remove(); | |
| 3478 | + }); | |
| 3479 | + elForSpot._x_refreshXForScope(scopes[keys.indexOf(keyForSpot)]); | |
| 3480 | + } | |
| 3481 | + for (let i = 0; i < adds.length; i++) { | |
| 3482 | + let [lastKey2, index] = adds[i]; | |
| 3483 | + let lastEl = lastKey2 === "template" ? templateEl : lookup[lastKey2]; | |
| 3484 | + if (lastEl._x_currentIfEl) lastEl = lastEl._x_currentIfEl; | |
| 3485 | + let scope2 = scopes[index]; | |
| 3486 | + let key = keys[index]; | |
| 3487 | + let clone2 = document.importNode(templateEl.content, true).firstElementChild; | |
| 3488 | + let reactiveScope = reactive(scope2); | |
| 3489 | + addScopeToNode(clone2, reactiveScope, templateEl); | |
| 3490 | + clone2._x_refreshXForScope = (newScope) => { | |
| 3491 | + Object.entries(newScope).forEach(([key2, value]) => { | |
| 3492 | + reactiveScope[key2] = value; | |
| 3493 | + }); | |
| 3494 | + }; | |
| 3495 | + mutateDom(() => { | |
| 3496 | + lastEl.after(clone2); | |
| 3497 | + skipDuringClone(() => initTree(clone2))(); | |
| 3498 | + }); | |
| 3499 | + if (typeof key === "object") warn("x-for key cannot be an object, it must be a string or an integer", templateEl); | |
| 3500 | + lookup[key] = clone2; | |
| 3501 | + } | |
| 3502 | + for (let i = 0; i < sames.length; i++) lookup[sames[i]]._x_refreshXForScope(scopes[keys.indexOf(sames[i])]); | |
| 3503 | + templateEl._x_prevKeys = keys; | |
| 3504 | + }); | |
| 3505 | + } | |
| 3506 | + function parseForExpression(expression) { | |
| 3507 | + let forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; | |
| 3508 | + let stripParensRE = /^\s*\(|\)\s*$/g; | |
| 3509 | + let inMatch = expression.match(/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/); | |
| 3510 | + if (!inMatch) return; | |
| 3511 | + let res = {}; | |
| 3512 | + res.items = inMatch[2].trim(); | |
| 3513 | + let item = inMatch[1].replace(stripParensRE, "").trim(); | |
| 3514 | + let iteratorMatch = item.match(forIteratorRE); | |
| 3515 | + if (iteratorMatch) { | |
| 3516 | + res.item = item.replace(forIteratorRE, "").trim(); | |
| 3517 | + res.index = iteratorMatch[1].trim(); | |
| 3518 | + if (iteratorMatch[2]) res.collection = iteratorMatch[2].trim(); | |
| 3519 | + } else res.item = item; | |
| 3520 | + return res; | |
| 3521 | + } | |
| 3522 | + function getIterationScopeVariables(iteratorNames, item, index, items) { | |
| 3523 | + let scopeVariables = {}; | |
| 3524 | + if (/^\[.*\]$/.test(iteratorNames.item) && Array.isArray(item)) iteratorNames.item.replace("[", "").replace("]", "").split(",").map((i) => i.trim()).forEach((name, i) => { | |
| 3525 | + scopeVariables[name] = item[i]; | |
| 3526 | + }); | |
| 3527 | + else if (/^\{.*\}$/.test(iteratorNames.item) && !Array.isArray(item) && typeof item === "object") iteratorNames.item.replace("{", "").replace("}", "").split(",").map((i) => i.trim()).forEach((name) => { | |
| 3528 | + scopeVariables[name] = item[name]; | |
| 3529 | + }); | |
| 3530 | + else scopeVariables[iteratorNames.item] = item; | |
| 3531 | + if (iteratorNames.index) scopeVariables[iteratorNames.index] = index; | |
| 3532 | + if (iteratorNames.collection) scopeVariables[iteratorNames.collection] = items; | |
| 3533 | + return scopeVariables; | |
| 3534 | + } | |
| 3535 | + function isNumeric3(subject) { | |
| 3536 | + return !Array.isArray(subject) && !isNaN(subject); | |
| 3537 | + } | |
| 3538 | + function handler3() {} | |
| 3539 | + handler3.inline = (el, { expression }, { cleanup: cleanup2 }) => { | |
| 3540 | + let root = closestRoot(el); | |
| 3541 | + if (!root._x_refs) root._x_refs = {}; | |
| 3542 | + root._x_refs[expression] = el; | |
| 3543 | + cleanup2(() => delete root._x_refs[expression]); | |
| 3544 | + }; | |
| 3545 | + directive("ref", handler3); | |
| 3546 | + directive("if", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3547 | + if (el.tagName.toLowerCase() !== "template") warn("x-if can only be used on a <template> tag", el); | |
| 3548 | + let evaluate2 = evaluateLater(el, expression); | |
| 3549 | + let show = () => { | |
| 3550 | + if (el._x_currentIfEl) return el._x_currentIfEl; | |
| 3551 | + let clone2 = el.content.cloneNode(true).firstElementChild; | |
| 3552 | + addScopeToNode(clone2, {}, el); | |
| 3553 | + mutateDom(() => { | |
| 3554 | + el.after(clone2); | |
| 3555 | + skipDuringClone(() => initTree(clone2))(); | |
| 3556 | + }); | |
| 3557 | + el._x_currentIfEl = clone2; | |
| 3558 | + el._x_undoIf = () => { | |
| 3559 | + mutateDom(() => { | |
| 3560 | + destroyTree(clone2); | |
| 3561 | + clone2.remove(); | |
| 3562 | + }); | |
| 3563 | + delete el._x_currentIfEl; | |
| 3564 | + }; | |
| 3565 | + return clone2; | |
| 3566 | + }; | |
| 3567 | + let hide = () => { | |
| 3568 | + if (!el._x_undoIf) return; | |
| 3569 | + el._x_undoIf(); | |
| 3570 | + delete el._x_undoIf; | |
| 3571 | + }; | |
| 3572 | + effect3(() => evaluate2((value) => { | |
| 3573 | + value ? show() : hide(); | |
| 3574 | + })); | |
| 3575 | + cleanup2(() => el._x_undoIf && el._x_undoIf()); | |
| 3576 | + }); | |
| 3577 | + directive("id", (el, { expression }, { evaluate: evaluate2 }) => { | |
| 3578 | + evaluate2(expression).forEach((name) => setIdRoot(el, name)); | |
| 3579 | + }); | |
| 3580 | + interceptClone((from, to) => { | |
| 3581 | + if (from._x_ids) to._x_ids = from._x_ids; | |
| 3582 | + }); | |
| 3583 | + mapAttributes(startingWith("@", into(prefix("on:")))); | |
| 3584 | + directive("on", skipDuringClone((el, { value, modifiers, expression }, { cleanup: cleanup2 }) => { | |
| 3585 | + let evaluate2 = expression ? evaluateLater(el, expression) : () => {}; | |
| 3586 | + if (el.tagName.toLowerCase() === "template") { | |
| 3587 | + if (!el._x_forwardEvents) el._x_forwardEvents = []; | |
| 3588 | + if (!el._x_forwardEvents.includes(value)) el._x_forwardEvents.push(value); | |
| 3589 | + } | |
| 3590 | + let removeListener = on(el, value, modifiers, (e) => { | |
| 3591 | + evaluate2(() => {}, { | |
| 3592 | + scope: { "$event": e }, | |
| 3593 | + params: [e] | |
| 3594 | + }); | |
| 3595 | + }); | |
| 3596 | + cleanup2(() => removeListener()); | |
| 3597 | + })); | |
| 3598 | + warnMissingPluginDirective("Collapse", "collapse", "collapse"); | |
| 3599 | + warnMissingPluginDirective("Intersect", "intersect", "intersect"); | |
| 3600 | + warnMissingPluginDirective("Focus", "trap", "focus"); | |
| 3601 | + warnMissingPluginDirective("Mask", "mask", "mask"); | |
| 3602 | + function warnMissingPluginDirective(name, directiveName, slug) { | |
| 3603 | + directive(directiveName, (el) => warn(`You can't use [x-${directiveName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); | |
| 3604 | + } | |
| 3605 | + alpine_default.setEvaluator(cspEvaluator); | |
| 3606 | + alpine_default.setReactivityEngine({ | |
| 3607 | + reactive: reactive2, | |
| 3608 | + effect: effect2, | |
| 3609 | + release: stop, | |
| 3610 | + raw: toRaw | |
| 3611 | + }); | |
| 3612 | + var src_default = alpine_default; | |
| 281 | 3613 | |
| 282 | -// packages/alpinejs/src/scope.js | |
| 283 | -function scope(node) { | |
| 284 | - return mergeProxies(closestDataStack(node)); | |
| 285 | -} | |
| 286 | -function addScopeToNode(node, data2, referenceNode) { | |
| 287 | - node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)]; | |
| 288 | - return () => { | |
| 289 | - node._x_dataStack = node._x_dataStack.filter((i) => i !== data2); | |
| 290 | - }; | |
| 291 | -} | |
| 292 | -function closestDataStack(node) { | |
| 293 | - if (node._x_dataStack) | |
| 294 | - return node._x_dataStack; | |
| 295 | - if (typeof ShadowRoot === "function" && node instanceof ShadowRoot) { | |
| 296 | - return closestDataStack(node.host); | |
| 297 | - } | |
| 298 | - if (!node.parentNode) { | |
| 299 | - return []; | |
| 300 | - } | |
| 301 | - return closestDataStack(node.parentNode); | |
| 302 | -} | |
| 303 | -function mergeProxies(objects) { | |
| 304 | - return new Proxy({ objects }, mergeProxyTrap); | |
| 305 | -} | |
| 306 | -var mergeProxyTrap = { | |
| 307 | - ownKeys({ objects }) { | |
| 308 | - return Array.from( | |
| 309 | - new Set(objects.flatMap((i) => Object.keys(i))) | |
| 310 | - ); | |
| 311 | - }, | |
| 312 | - has({ objects }, name) { | |
| 313 | - if (name == Symbol.unscopables) | |
| 314 | - return false; | |
| 315 | - return objects.some( | |
| 316 | - (obj) => Object.prototype.hasOwnProperty.call(obj, name) || Reflect.has(obj, name) | |
| 317 | - ); | |
| 318 | - }, | |
| 319 | - get({ objects }, name, thisProxy) { | |
| 320 | - if (name == "toJSON") | |
| 321 | - return collapseProxies; | |
| 322 | - return Reflect.get( | |
| 323 | - objects.find( | |
| 324 | - (obj) => Reflect.has(obj, name) | |
| 325 | - ) || {}, | |
| 326 | - name, | |
| 327 | - thisProxy | |
| 328 | - ); | |
| 329 | - }, | |
| 330 | - set({ objects }, name, value, thisProxy) { | |
| 331 | - const target = objects.find( | |
| 332 | - (obj) => Object.prototype.hasOwnProperty.call(obj, name) | |
| 333 | - ) || objects[objects.length - 1]; | |
| 334 | - const descriptor = Object.getOwnPropertyDescriptor(target, name); | |
| 335 | - if (descriptor?.set && descriptor?.get) | |
| 336 | - return descriptor.set.call(thisProxy, value) || true; | |
| 337 | - return Reflect.set(target, name, value); | |
| 338 | - } | |
| 339 | -}; | |
| 340 | -function collapseProxies() { | |
| 341 | - let keys = Reflect.ownKeys(this); | |
| 342 | - return keys.reduce((acc, key) => { | |
| 343 | - acc[key] = Reflect.get(this, key); | |
| 344 | - return acc; | |
| 345 | - }, {}); | |
| 346 | -} | |
| 3614 | +//#endregion | |
| 3615 | +//#region packages/packages/core/alpinejs/src/init.ts | |
| 3616 | + function init() { | |
| 3617 | + document.addEventListener("DOMContentLoaded", () => { | |
| 3618 | + src_default.start(); | |
| 3619 | + }, { once: true }); | |
| 3620 | + } | |
| 347 | 3621 | |
| 348 | -// packages/alpinejs/src/interceptor.js | |
| 349 | -function initInterceptors(data2) { | |
| 350 | - let isObject2 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null; | |
| 351 | - let recurse = (obj, basePath = "") => { | |
| 352 | - Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, { value, enumerable }]) => { | |
| 353 | - if (enumerable === false || value === void 0) | |
| 354 | - return; | |
| 355 | - if (typeof value === "object" && value !== null && value.__v_skip) | |
| 356 | - return; | |
| 357 | - let path = basePath === "" ? key : `${basePath}.${key}`; | |
| 358 | - if (typeof value === "object" && value !== null && value._x_interceptor) { | |
| 359 | - obj[key] = value.initialize(data2, path, key); | |
| 360 | - } else { | |
| 361 | - if (isObject2(value) && value !== obj && !(value instanceof Element)) { | |
| 362 | - recurse(value, path); | |
| 363 | - } | |
| 364 | - } | |
| 365 | - }); | |
| 366 | - }; | |
| 367 | - return recurse(data2); | |
| 368 | -} | |
| 369 | -function interceptor(callback, mutateObj = () => { | |
| 370 | -}) { | |
| 371 | - let obj = { | |
| 372 | - initialValue: void 0, | |
| 373 | - _x_interceptor: true, | |
| 374 | - initialize(data2, path, key) { | |
| 375 | - return callback(this.initialValue, () => get(data2, path), (value) => set(data2, path, value), path, key); | |
| 376 | - } | |
| 377 | - }; | |
| 378 | - mutateObj(obj); | |
| 379 | - return (initialValue) => { | |
| 380 | - if (typeof initialValue === "object" && initialValue !== null && initialValue._x_interceptor) { | |
| 381 | - let initialize = obj.initialize.bind(obj); | |
| 382 | - obj.initialize = (data2, path, key) => { | |
| 383 | - let innerValue = initialValue.initialize(data2, path, key); | |
| 384 | - obj.initialValue = innerValue; | |
| 385 | - return initialize(data2, path, key); | |
| 386 | - }; | |
| 387 | - } else { | |
| 388 | - obj.initialValue = initialValue; | |
| 389 | - } | |
| 390 | - return obj; | |
| 391 | - }; | |
| 392 | -} | |
| 393 | -function get(obj, path) { | |
| 394 | - return path.split(".").reduce((carry, segment) => carry[segment], obj); | |
| 395 | -} | |
| 396 | -function set(obj, path, value) { | |
| 397 | - if (typeof path === "string") | |
| 398 | - path = path.split("."); | |
| 399 | - if (path.length === 1) | |
| 400 | - obj[path[0]] = value; | |
| 401 | - else if (path.length === 0) | |
| 402 | - throw error; | |
| 403 | - else { | |
| 404 | - if (obj[path[0]]) | |
| 405 | - return set(obj[path[0]], path.slice(1), value); | |
| 406 | - else { | |
| 407 | - obj[path[0]] = {}; | |
| 408 | - return set(obj[path[0]], path.slice(1), value); | |
| 409 | - } | |
| 410 | - } | |
| 411 | -} | |
| 3622 | +//#endregion | |
| 3623 | +//#region packages/packages/core/alpinejs/src/index.ts | |
| 3624 | + var src_exports = /* @__PURE__ */ __exportAll({ | |
| 3625 | + Alpine: () => src_default, | |
| 3626 | + init: () => init, | |
| 3627 | + refreshTree: () => refreshTree | |
| 3628 | + }); | |
| 3629 | + var refreshTree = (element) => { | |
| 3630 | + src_default.nextTick(() => { | |
| 3631 | + src_default.destroyTree(element); | |
| 3632 | + src_default.initTree(element); | |
| 3633 | + }); | |
| 3634 | + }; | |
| 412 | 3635 | |
| 413 | -// packages/alpinejs/src/magics.js | |
| 414 | -var magics = {}; | |
| 415 | -function magic(name, callback) { | |
| 416 | - magics[name] = callback; | |
| 417 | -} | |
| 418 | -function injectMagics(obj, el) { | |
| 419 | - let memoizedUtilities = getUtilities(el); | |
| 420 | - Object.entries(magics).forEach(([name, callback]) => { | |
| 421 | - Object.defineProperty(obj, `$${name}`, { | |
| 422 | - get() { | |
| 423 | - return callback(el, memoizedUtilities); | |
| 424 | - }, | |
| 425 | - enumerable: false | |
| 426 | - }); | |
| 427 | - }); | |
| 428 | - return obj; | |
| 429 | -} | |
| 430 | -function getUtilities(el) { | |
| 431 | - let [utilities, cleanup2] = getElementBoundUtilities(el); | |
| 432 | - let utils = { interceptor, ...utilities }; | |
| 433 | - onElRemoved(el, cleanup2); | |
| 434 | - return utils; | |
| 435 | -} | |
| 3636 | +//#endregion | |
| 3637 | +//#region \0elementor-package-library-entry | |
| 3638 | + (window.elementorV2 = window.elementorV2 || {}).alpinejs = src_exports; | |
| 436 | 3639 | |
| 437 | -// packages/alpinejs/src/utils/error.js | |
| 438 | -function tryCatch(el, expression, callback, ...args) { | |
| 439 | - try { | |
| 440 | - return callback(...args); | |
| 441 | - } catch (e) { | |
| 442 | - handleError(e, el, expression); | |
| 443 | - } | |
| 444 | -} | |
| 445 | -function handleError(error2, el, expression = void 0) { | |
| 446 | - error2 = Object.assign( | |
| 447 | - error2 ?? { message: "No error message given." }, | |
| 448 | - { el, expression } | |
| 449 | - ); | |
| 450 | - console.warn(`Alpine Expression Error: ${error2.message} | |
| 451 | - | |
| 452 | -${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); | |
| 453 | - setTimeout(() => { | |
| 454 | - throw error2; | |
| 455 | - }, 0); | |
| 456 | -} | |
| 457 | - | |
| 458 | -// packages/alpinejs/src/evaluator.js | |
| 459 | -var shouldAutoEvaluateFunctions = true; | |
| 460 | -function dontAutoEvaluateFunctions(callback) { | |
| 461 | - let cache = shouldAutoEvaluateFunctions; | |
| 462 | - shouldAutoEvaluateFunctions = false; | |
| 463 | - let result = callback(); | |
| 464 | - shouldAutoEvaluateFunctions = cache; | |
| 465 | - return result; | |
| 466 | -} | |
| 467 | -function evaluate(el, expression, extras = {}) { | |
| 468 | - let result; | |
| 469 | - evaluateLater(el, expression)((value) => result = value, extras); | |
| 470 | - return result; | |
| 471 | -} | |
| 472 | -function evaluateLater(...args) { | |
| 473 | - return theEvaluatorFunction(...args); | |
| 474 | -} | |
| 475 | -var theEvaluatorFunction = normalEvaluator; | |
| 476 | -function setEvaluator(newEvaluator) { | |
| 477 | - theEvaluatorFunction = newEvaluator; | |
| 478 | -} | |
| 479 | -function normalEvaluator(el, expression) { | |
| 480 | - let overriddenMagics = {}; | |
| 481 | - injectMagics(overriddenMagics, el); | |
| 482 | - let dataStack = [overriddenMagics, ...closestDataStack(el)]; | |
| 483 | - let evaluator = typeof expression === "function" ? generateEvaluatorFromFunction(dataStack, expression) : generateEvaluatorFromString(dataStack, expression, el); | |
| 484 | - return tryCatch.bind(null, el, expression, evaluator); | |
| 485 | -} | |
| 486 | -function generateEvaluatorFromFunction(dataStack, func) { | |
| 487 | - return (receiver = () => { | |
| 488 | - }, { scope: scope2 = {}, params = [], context } = {}) => { | |
| 489 | - let result = func.apply(mergeProxies([scope2, ...dataStack]), params); | |
| 490 | - runIfTypeOfFunction(receiver, result); | |
| 491 | - }; | |
| 492 | -} | |
| 493 | -var evaluatorMemo = {}; | |
| 494 | -function generateFunctionFromString(expression, el) { | |
| 495 | - if (evaluatorMemo[expression]) { | |
| 496 | - return evaluatorMemo[expression]; | |
| 497 | - } | |
| 498 | - let AsyncFunction = Object.getPrototypeOf(async function() { | |
| 499 | - }).constructor; | |
| 500 | - let rightSideSafeExpression = /^[\n\s]*if.*\(.*\)/.test(expression.trim()) || /^(let|const)\s/.test(expression.trim()) ? `(async()=>{ ${expression} })()` : expression; | |
| 501 | - const safeAsyncFunction = () => { | |
| 502 | - try { | |
| 503 | - let func2 = new AsyncFunction( | |
| 504 | - ["__self", "scope"], | |
| 505 | - `with (scope) { __self.result = ${rightSideSafeExpression} }; __self.finished = true; return __self.result;` | |
| 506 | - ); | |
| 507 | - Object.defineProperty(func2, "name", { | |
| 508 | - value: `[Alpine] ${expression}` | |
| 509 | - }); | |
| 510 | - return func2; | |
| 511 | - } catch (error2) { | |
| 512 | - handleError(error2, el, expression); | |
| 513 | - return Promise.resolve(); | |
| 514 | - } | |
| 515 | - }; | |
| 516 | - let func = safeAsyncFunction(); | |
| 517 | - evaluatorMemo[expression] = func; | |
| 518 | - return func; | |
| 519 | -} | |
| 520 | -function generateEvaluatorFromString(dataStack, expression, el) { | |
| 521 | - let func = generateFunctionFromString(expression, el); | |
| 522 | - return (receiver = () => { | |
| 523 | - }, { scope: scope2 = {}, params = [], context } = {}) => { | |
| 524 | - func.result = void 0; | |
| 525 | - func.finished = false; | |
| 526 | - let completeScope = mergeProxies([scope2, ...dataStack]); | |
| 527 | - if (typeof func === "function") { | |
| 528 | - let promise = func.call(context, func, completeScope).catch((error2) => handleError(error2, el, expression)); | |
| 529 | - if (func.finished) { | |
| 530 | - runIfTypeOfFunction(receiver, func.result, completeScope, params, el); | |
| 531 | - func.result = void 0; | |
| 532 | - } else { | |
| 533 | - promise.then((result) => { | |
| 534 | - runIfTypeOfFunction(receiver, result, completeScope, params, el); | |
| 535 | - }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0); | |
| 536 | - } | |
| 537 | - } | |
| 538 | - }; | |
| 539 | -} | |
| 540 | -function runIfTypeOfFunction(receiver, value, scope2, params, el) { | |
| 541 | - if (shouldAutoEvaluateFunctions && typeof value === "function") { | |
| 542 | - let result = value.apply(scope2, params); | |
| 543 | - if (result instanceof Promise) { | |
| 544 | - result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value)); | |
| 545 | - } else { | |
| 546 | - receiver(result); | |
| 547 | - } | |
| 548 | - } else if (typeof value === "object" && value instanceof Promise) { | |
| 549 | - value.then((i) => receiver(i)); | |
| 550 | - } else { | |
| 551 | - receiver(value); | |
| 552 | - } | |
| 553 | -} | |
| 554 | - | |
| 555 | -// packages/alpinejs/src/directives.js | |
| 556 | -var prefixAsString = "x-"; | |
| 557 | -function prefix(subject = "") { | |
| 558 | - return prefixAsString + subject; | |
| 559 | -} | |
| 560 | -function setPrefix(newPrefix) { | |
| 561 | - prefixAsString = newPrefix; | |
| 562 | -} | |
| 563 | -var directiveHandlers = {}; | |
| 564 | -function directive(name, callback) { | |
| 565 | - directiveHandlers[name] = callback; | |
| 566 | - return { | |
| 567 | - before(directive2) { | |
| 568 | - if (!directiveHandlers[directive2]) { | |
| 569 | - console.warn(String.raw`Cannot find directive \`${directive2}\`. \`${name}\` will use the default order of execution`); | |
| 570 | - return; | |
| 571 | - } | |
| 572 | - const pos = directiveOrder.indexOf(directive2); | |
| 573 | - directiveOrder.splice(pos >= 0 ? pos : directiveOrder.indexOf("DEFAULT"), 0, name); | |
| 574 | - } | |
| 575 | - }; | |
| 576 | -} | |
| 577 | -function directiveExists(name) { | |
| 578 | - return Object.keys(directiveHandlers).includes(name); | |
| 579 | -} | |
| 580 | -function directives(el, attributes, originalAttributeOverride) { | |
| 581 | - attributes = Array.from(attributes); | |
| 582 | - if (el._x_virtualDirectives) { | |
| 583 | - let vAttributes = Object.entries(el._x_virtualDirectives).map(([name, value]) => ({ name, value })); | |
| 584 | - let staticAttributes = attributesOnly(vAttributes); | |
| 585 | - vAttributes = vAttributes.map((attribute) => { | |
| 586 | - if (staticAttributes.find((attr) => attr.name === attribute.name)) { | |
| 587 | - return { | |
| 588 | - name: `x-bind:${attribute.name}`, | |
| 589 | - value: `"${attribute.value}"` | |
| 590 | - }; | |
| 591 | - } | |
| 592 | - return attribute; | |
| 593 | - }); | |
| 594 | - attributes = attributes.concat(vAttributes); | |
| 595 | - } | |
| 596 | - let transformedAttributeMap = {}; | |
| 597 | - let directives2 = attributes.map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority); | |
| 598 | - return directives2.map((directive2) => { | |
| 599 | - return getDirectiveHandler(el, directive2); | |
| 600 | - }); | |
| 601 | -} | |
| 602 | -function attributesOnly(attributes) { | |
| 603 | - return Array.from(attributes).map(toTransformedAttributes()).filter((attr) => !outNonAlpineAttributes(attr)); | |
| 604 | -} | |
| 605 | -var isDeferringHandlers = false; | |
| 606 | -var directiveHandlerStacks = /* @__PURE__ */ new Map(); | |
| 607 | -var currentHandlerStackKey = Symbol(); | |
| 608 | -function deferHandlingDirectives(callback) { | |
| 609 | - isDeferringHandlers = true; | |
| 610 | - let key = Symbol(); | |
| 611 | - currentHandlerStackKey = key; | |
| 612 | - directiveHandlerStacks.set(key, []); | |
| 613 | - let flushHandlers = () => { | |
| 614 | - while (directiveHandlerStacks.get(key).length) | |
| 615 | - directiveHandlerStacks.get(key).shift()(); | |
| 616 | - directiveHandlerStacks.delete(key); | |
| 617 | - }; | |
| 618 | - let stopDeferring = () => { | |
| 619 | - isDeferringHandlers = false; | |
| 620 | - flushHandlers(); | |
| 621 | - }; | |
| 622 | - callback(flushHandlers); | |
| 623 | - stopDeferring(); | |
| 624 | -} | |
| 625 | -function getElementBoundUtilities(el) { | |
| 626 | - let cleanups = []; | |
| 627 | - let cleanup2 = (callback) => cleanups.push(callback); | |
| 628 | - let [effect3, cleanupEffect] = elementBoundEffect(el); | |
| 629 | - cleanups.push(cleanupEffect); | |
| 630 | - let utilities = { | |
| 631 | - Alpine: alpine_default, | |
| 632 | - effect: effect3, | |
| 633 | - cleanup: cleanup2, | |
| 634 | - evaluateLater: evaluateLater.bind(evaluateLater, el), | |
| 635 | - evaluate: evaluate.bind(evaluate, el) | |
| 636 | - }; | |
| 637 | - let doCleanup = () => cleanups.forEach((i) => i()); | |
| 638 | - return [utilities, doCleanup]; | |
| 639 | -} | |
| 640 | -function getDirectiveHandler(el, directive2) { | |
| 641 | - let noop = () => { | |
| 642 | - }; | |
| 643 | - let handler4 = directiveHandlers[directive2.type] || noop; | |
| 644 | - let [utilities, cleanup2] = getElementBoundUtilities(el); | |
| 645 | - onAttributeRemoved(el, directive2.original, cleanup2); | |
| 646 | - let fullHandler = () => { | |
| 647 | - if (el._x_ignore || el._x_ignoreSelf) | |
| 648 | - return; | |
| 649 | - handler4.inline && handler4.inline(el, directive2, utilities); | |
| 650 | - handler4 = handler4.bind(handler4, el, directive2, utilities); | |
| 651 | - isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler4) : handler4(); | |
| 652 | - }; | |
| 653 | - fullHandler.runCleanups = cleanup2; | |
| 654 | - return fullHandler; | |
| 655 | -} | |
| 656 | -var startingWith = (subject, replacement) => ({ name, value }) => { | |
| 657 | - if (name.startsWith(subject)) | |
| 658 | - name = name.replace(subject, replacement); | |
| 659 | - return { name, value }; | |
| 660 | -}; | |
| 661 | -var into = (i) => i; | |
| 662 | -function toTransformedAttributes(callback = () => { | |
| 663 | -}) { | |
| 664 | - return ({ name, value }) => { | |
| 665 | - let { name: newName, value: newValue } = attributeTransformers.reduce((carry, transform) => { | |
| 666 | - return transform(carry); | |
| 667 | - }, { name, value }); | |
| 668 | - if (newName !== name) | |
| 669 | - callback(newName, name); | |
| 670 | - return { name: newName, value: newValue }; | |
| 671 | - }; | |
| 672 | -} | |
| 673 | -var attributeTransformers = []; | |
| 674 | -function mapAttributes(callback) { | |
| 675 | - attributeTransformers.push(callback); | |
| 676 | -} | |
| 677 | -function outNonAlpineAttributes({ name }) { | |
| 678 | - return alpineAttributeRegex().test(name); | |
| 679 | -} | |
| 680 | -var alpineAttributeRegex = () => new RegExp(`^${prefixAsString}([^:^.]+)\\b`); | |
| 681 | -function toParsedDirectives(transformedAttributeMap, originalAttributeOverride) { | |
| 682 | - return ({ name, value }) => { | |
| 683 | - let typeMatch = name.match(alpineAttributeRegex()); | |
| 684 | - let valueMatch = name.match(/:([a-zA-Z0-9\-_:]+)/); | |
| 685 | - let modifiers = name.match(/\.[^.\]]+(?=[^\]]*$)/g) || []; | |
| 686 | - let original = originalAttributeOverride || transformedAttributeMap[name] || name; | |
| 687 | - return { | |
| 688 | - type: typeMatch ? typeMatch[1] : null, | |
| 689 | - value: valueMatch ? valueMatch[1] : null, | |
| 690 | - modifiers: modifiers.map((i) => i.replace(".", "")), | |
| 691 | - expression: value, | |
| 692 | - original | |
| 693 | - }; | |
| 694 | - }; | |
| 695 | -} | |
| 696 | -var DEFAULT = "DEFAULT"; | |
| 697 | -var directiveOrder = [ | |
| 698 | - "ignore", | |
| 699 | - "ref", | |
| 700 | - "data", | |
| 701 | - "id", | |
| 702 | - "anchor", | |
| 703 | - "bind", | |
| 704 | - "init", | |
| 705 | - "for", | |
| 706 | - "model", | |
| 707 | - "modelable", | |
| 708 | - "transition", | |
| 709 | - "show", | |
| 710 | - "if", | |
| 711 | - DEFAULT, | |
| 712 | - "teleport" | |
| 713 | -]; | |
| 714 | -function byPriority(a, b) { | |
| 715 | - let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type; | |
| 716 | - let typeB = directiveOrder.indexOf(b.type) === -1 ? DEFAULT : b.type; | |
| 717 | - return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB); | |
| 718 | -} | |
| 719 | - | |
| 720 | -// packages/alpinejs/src/utils/dispatch.js | |
| 721 | -function dispatch(el, name, detail = {}) { | |
| 722 | - el.dispatchEvent( | |
| 723 | - new CustomEvent(name, { | |
| 724 | - detail, | |
| 725 | - bubbles: true, | |
| 726 | - // Allows events to pass the shadow DOM barrier. | |
| 727 | - composed: true, | |
| 728 | - cancelable: true | |
| 729 | - }) | |
| 730 | - ); | |
| 731 | -} | |
| 732 | - | |
| 733 | -// packages/alpinejs/src/utils/walk.js | |
| 734 | -function walk(el, callback) { | |
| 735 | - if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) { | |
| 736 | - Array.from(el.children).forEach((el2) => walk(el2, callback)); | |
| 737 | - return; | |
| 738 | - } | |
| 739 | - let skip = false; | |
| 740 | - callback(el, () => skip = true); | |
| 741 | - if (skip) | |
| 742 | - return; | |
| 743 | - let node = el.firstElementChild; | |
| 744 | - while (node) { | |
| 745 | - walk(node, callback, false); | |
| 746 | - node = node.nextElementSibling; | |
| 747 | - } | |
| 748 | -} | |
| 749 | - | |
| 750 | -// packages/alpinejs/src/utils/warn.js | |
| 751 | -function warn(message, ...args) { | |
| 752 | - console.warn(`Alpine Warning: ${message}`, ...args); | |
| 753 | -} | |
| 754 | - | |
| 755 | -// packages/alpinejs/src/lifecycle.js | |
| 756 | -var started = false; | |
| 757 | -function start() { | |
| 758 | - if (started) | |
| 759 | - warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."); | |
| 760 | - started = true; | |
| 761 | - if (!document.body) | |
| 762 | - warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"); | |
| 763 | - dispatch(document, "alpine:init"); | |
| 764 | - dispatch(document, "alpine:initializing"); | |
| 765 | - startObservingMutations(); | |
| 766 | - onElAdded((el) => initTree(el, walk)); | |
| 767 | - onElRemoved((el) => destroyTree(el)); | |
| 768 | - onAttributesAdded((el, attrs) => { | |
| 769 | - directives(el, attrs).forEach((handle) => handle()); | |
| 770 | - }); | |
| 771 | - let outNestedComponents = (el) => !closestRoot(el.parentElement, true); | |
| 772 | - Array.from(document.querySelectorAll(allSelectors().join(","))).filter(outNestedComponents).forEach((el) => { | |
| 773 | - initTree(el); | |
| 774 | - }); | |
| 775 | - dispatch(document, "alpine:initialized"); | |
| 776 | - setTimeout(() => { | |
| 777 | - warnAboutMissingPlugins(); | |
| 778 | - }); | |
| 779 | -} | |
| 780 | -var rootSelectorCallbacks = []; | |
| 781 | -var initSelectorCallbacks = []; | |
| 782 | -function rootSelectors() { | |
| 783 | - return rootSelectorCallbacks.map((fn) => fn()); | |
| 784 | -} | |
| 785 | -function allSelectors() { | |
| 786 | - return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn()); | |
| 787 | -} | |
| 788 | -function addRootSelector(selectorCallback) { | |
| 789 | - rootSelectorCallbacks.push(selectorCallback); | |
| 790 | -} | |
| 791 | -function addInitSelector(selectorCallback) { | |
| 792 | - initSelectorCallbacks.push(selectorCallback); | |
| 793 | -} | |
| 794 | -function closestRoot(el, includeInitSelectors = false) { | |
| 795 | - return findClosest(el, (element) => { | |
| 796 | - const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); | |
| 797 | - if (selectors.some((selector) => element.matches(selector))) | |
| 798 | - return true; | |
| 799 | - }); | |
| 800 | -} | |
| 801 | -function findClosest(el, callback) { | |
| 802 | - if (!el) | |
| 803 | - return; | |
| 804 | - if (callback(el)) | |
| 805 | - return el; | |
| 806 | - if (el._x_teleportBack) | |
| 807 | - el = el._x_teleportBack; | |
| 808 | - if (!el.parentElement) | |
| 809 | - return; | |
| 810 | - return findClosest(el.parentElement, callback); | |
| 811 | -} | |
| 812 | -function isRoot(el) { | |
| 813 | - return rootSelectors().some((selector) => el.matches(selector)); | |
| 814 | -} | |
| 815 | -var initInterceptors2 = []; | |
| 816 | -function interceptInit(callback) { | |
| 817 | - initInterceptors2.push(callback); | |
| 818 | -} | |
| 819 | -var markerDispenser = 1; | |
| 820 | -function initTree(el, walker = walk, intercept = () => { | |
| 821 | -}) { | |
| 822 | - if (findClosest(el, (i) => i._x_ignore)) | |
| 823 | - return; | |
| 824 | - deferHandlingDirectives(() => { | |
| 825 | - walker(el, (el2, skip) => { | |
| 826 | - if (el2._x_marker) | |
| 827 | - return; | |
| 828 | - intercept(el2, skip); | |
| 829 | - initInterceptors2.forEach((i) => i(el2, skip)); | |
| 830 | - directives(el2, el2.attributes).forEach((handle) => handle()); | |
| 831 | - if (!el2._x_ignore) | |
| 832 | - el2._x_marker = markerDispenser++; | |
| 833 | - el2._x_ignore && skip(); | |
| 834 | - }); | |
| 835 | - }); | |
| 836 | -} | |
| 837 | -function destroyTree(root, walker = walk) { | |
| 838 | - walker(root, (el) => { | |
| 839 | - cleanupElement(el); | |
| 840 | - cleanupAttributes(el); | |
| 841 | - delete el._x_marker; | |
| 842 | - }); | |
| 843 | -} | |
| 844 | -function warnAboutMissingPlugins() { | |
| 845 | - let pluginDirectives = [ | |
| 846 | - ["ui", "dialog", ["[x-dialog], [x-popover]"]], | |
| 847 | - ["anchor", "anchor", ["[x-anchor]"]], | |
| 848 | - ["sort", "sort", ["[x-sort]"]] | |
| 849 | - ]; | |
| 850 | - pluginDirectives.forEach(([plugin2, directive2, selectors]) => { | |
| 851 | - if (directiveExists(directive2)) | |
| 852 | - return; | |
| 853 | - selectors.some((selector) => { | |
| 854 | - if (document.querySelector(selector)) { | |
| 855 | - warn(`found "${selector}", but missing ${plugin2} plugin`); | |
| 856 | - return true; | |
| 857 | - } | |
| 858 | - }); | |
| 859 | - }); | |
| 860 | -} | |
| 861 | - | |
| 862 | -// packages/alpinejs/src/nextTick.js | |
| 863 | -var tickStack = []; | |
| 864 | -var isHolding = false; | |
| 865 | -function nextTick(callback = () => { | |
| 866 | -}) { | |
| 867 | - queueMicrotask(() => { | |
| 868 | - isHolding || setTimeout(() => { | |
| 869 | - releaseNextTicks(); | |
| 870 | - }); | |
| 871 | - }); | |
| 872 | - return new Promise((res) => { | |
| 873 | - tickStack.push(() => { | |
| 874 | - callback(); | |
| 875 | - res(); | |
| 876 | - }); | |
| 877 | - }); | |
| 878 | -} | |
| 879 | -function releaseNextTicks() { | |
| 880 | - isHolding = false; | |
| 881 | - while (tickStack.length) | |
| 882 | - tickStack.shift()(); | |
| 883 | -} | |
| 884 | -function holdNextTicks() { | |
| 885 | - isHolding = true; | |
| 886 | -} | |
| 887 | - | |
| 888 | -// packages/alpinejs/src/utils/classes.js | |
| 889 | -function setClasses(el, value) { | |
| 890 | - if (Array.isArray(value)) { | |
| 891 | - return setClassesFromString(el, value.join(" ")); | |
| 892 | - } else if (typeof value === "object" && value !== null) { | |
| 893 | - return setClassesFromObject(el, value); | |
| 894 | - } else if (typeof value === "function") { | |
| 895 | - return setClasses(el, value()); | |
| 896 | - } | |
| 897 | - return setClassesFromString(el, value); | |
| 898 | -} | |
| 899 | -function setClassesFromString(el, classString) { | |
| 900 | - let split = (classString2) => classString2.split(" ").filter(Boolean); | |
| 901 | - let missingClasses = (classString2) => classString2.split(" ").filter((i) => !el.classList.contains(i)).filter(Boolean); | |
| 902 | - let addClassesAndReturnUndo = (classes) => { | |
| 903 | - el.classList.add(...classes); | |
| 904 | - return () => { | |
| 905 | - el.classList.remove(...classes); | |
| 906 | - }; | |
| 907 | - }; | |
| 908 | - classString = classString === true ? classString = "" : classString || ""; | |
| 909 | - return addClassesAndReturnUndo(missingClasses(classString)); | |
| 910 | -} | |
| 911 | -function setClassesFromObject(el, classObject) { | |
| 912 | - let split = (classString) => classString.split(" ").filter(Boolean); | |
| 913 | - let forAdd = Object.entries(classObject).flatMap(([classString, bool]) => bool ? split(classString) : false).filter(Boolean); | |
| 914 | - let forRemove = Object.entries(classObject).flatMap(([classString, bool]) => !bool ? split(classString) : false).filter(Boolean); | |
| 915 | - let added = []; | |
| 916 | - let removed = []; | |
| 917 | - forRemove.forEach((i) => { | |
| 918 | - if (el.classList.contains(i)) { | |
| 919 | - el.classList.remove(i); | |
| 920 | - removed.push(i); | |
| 921 | - } | |
| 922 | - }); | |
| 923 | - forAdd.forEach((i) => { | |
| 924 | - if (!el.classList.contains(i)) { | |
| 925 | - el.classList.add(i); | |
| 926 | - added.push(i); | |
| 927 | - } | |
| 928 | - }); | |
| 929 | - return () => { | |
| 930 | - removed.forEach((i) => el.classList.add(i)); | |
| 931 | - added.forEach((i) => el.classList.remove(i)); | |
| 932 | - }; | |
| 933 | -} | |
| 934 | - | |
| 935 | -// packages/alpinejs/src/utils/styles.js | |
| 936 | -function setStyles(el, value) { | |
| 937 | - if (typeof value === "object" && value !== null) { | |
| 938 | - return setStylesFromObject(el, value); | |
| 939 | - } | |
| 940 | - return setStylesFromString(el, value); | |
| 941 | -} | |
| 942 | -function setStylesFromObject(el, value) { | |
| 943 | - let previousStyles = {}; | |
| 944 | - Object.entries(value).forEach(([key, value2]) => { | |
| 945 | - previousStyles[key] = el.style[key]; | |
| 946 | - if (!key.startsWith("--")) { | |
| 947 | - key = kebabCase(key); | |
| 948 | - } | |
| 949 | - el.style.setProperty(key, value2); | |
| 950 | - }); | |
| 951 | - setTimeout(() => { | |
| 952 | - if (el.style.length === 0) { | |
| 953 | - el.removeAttribute("style"); | |
| 954 | - } | |
| 955 | - }); | |
| 956 | - return () => { | |
| 957 | - setStyles(el, previousStyles); | |
| 958 | - }; | |
| 959 | -} | |
| 960 | -function setStylesFromString(el, value) { | |
| 961 | - let cache = el.getAttribute("style", value); | |
| 962 | - el.setAttribute("style", value); | |
| 963 | - return () => { | |
| 964 | - el.setAttribute("style", cache || ""); | |
| 965 | - }; | |
| 966 | -} | |
| 967 | -function kebabCase(subject) { | |
| 968 | - return subject.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); | |
| 969 | -} | |
| 970 | - | |
| 971 | -// packages/alpinejs/src/utils/once.js | |
| 972 | -function once(callback, fallback = () => { | |
| 973 | -}) { | |
| 974 | - let called = false; | |
| 975 | - return function() { | |
| 976 | - if (!called) { | |
| 977 | - called = true; | |
| 978 | - callback.apply(this, arguments); | |
| 979 | - } else { | |
| 980 | - fallback.apply(this, arguments); | |
| 981 | - } | |
| 982 | - }; | |
| 983 | -} | |
| 984 | - | |
| 985 | -// packages/alpinejs/src/directives/x-transition.js | |
| 986 | -directive("transition", (el, { value, modifiers, expression }, { evaluate: evaluate2 }) => { | |
| 987 | - if (typeof expression === "function") | |
| 988 | - expression = evaluate2(expression); | |
| 989 | - if (expression === false) | |
| 990 | - return; | |
| 991 | - if (!expression || typeof expression === "boolean") { | |
| 992 | - registerTransitionsFromHelper(el, modifiers, value); | |
| 993 | - } else { | |
| 994 | - registerTransitionsFromClassString(el, expression, value); | |
| 995 | - } | |
| 996 | -}); | |
| 997 | -function registerTransitionsFromClassString(el, classString, stage) { | |
| 998 | - registerTransitionObject(el, setClasses, ""); | |
| 999 | - let directiveStorageMap = { | |
| 1000 | - "enter": (classes) => { | |
| 1001 | - el._x_transition.enter.during = classes; | |
| 1002 | - }, | |
| 1003 | - "enter-start": (classes) => { | |
| 1004 | - el._x_transition.enter.start = classes; | |
| 1005 | - }, | |
| 1006 | - "enter-end": (classes) => { | |
| 1007 | - el._x_transition.enter.end = classes; | |
| 1008 | - }, | |
| 1009 | - "leave": (classes) => { | |
| 1010 | - el._x_transition.leave.during = classes; | |
| 1011 | - }, | |
| 1012 | - "leave-start": (classes) => { | |
| 1013 | - el._x_transition.leave.start = classes; | |
| 1014 | - }, | |
| 1015 | - "leave-end": (classes) => { | |
| 1016 | - el._x_transition.leave.end = classes; | |
| 1017 | - } | |
| 1018 | - }; | |
| 1019 | - directiveStorageMap[stage](classString); | |
| 1020 | -} | |
| 1021 | -function registerTransitionsFromHelper(el, modifiers, stage) { | |
| 1022 | - registerTransitionObject(el, setStyles); | |
| 1023 | - let doesntSpecify = !modifiers.includes("in") && !modifiers.includes("out") && !stage; | |
| 1024 | - let transitioningIn = doesntSpecify || modifiers.includes("in") || ["enter"].includes(stage); | |
| 1025 | - let transitioningOut = doesntSpecify || modifiers.includes("out") || ["leave"].includes(stage); | |
| 1026 | - if (modifiers.includes("in") && !doesntSpecify) { | |
| 1027 | - modifiers = modifiers.filter((i, index) => index < modifiers.indexOf("out")); | |
| 1028 | - } | |
| 1029 | - if (modifiers.includes("out") && !doesntSpecify) { | |
| 1030 | - modifiers = modifiers.filter((i, index) => index > modifiers.indexOf("out")); | |
| 1031 | - } | |
| 1032 | - let wantsAll = !modifiers.includes("opacity") && !modifiers.includes("scale"); | |
| 1033 | - let wantsOpacity = wantsAll || modifiers.includes("opacity"); | |
| 1034 | - let wantsScale = wantsAll || modifiers.includes("scale"); | |
| 1035 | - let opacityValue = wantsOpacity ? 0 : 1; | |
| 1036 | - let scaleValue = wantsScale ? modifierValue(modifiers, "scale", 95) / 100 : 1; | |
| 1037 | - let delay = modifierValue(modifiers, "delay", 0) / 1e3; | |
| 1038 | - let origin = modifierValue(modifiers, "origin", "center"); | |
| 1039 | - let property = "opacity, transform"; | |
| 1040 | - let durationIn = modifierValue(modifiers, "duration", 150) / 1e3; | |
| 1041 | - let durationOut = modifierValue(modifiers, "duration", 75) / 1e3; | |
| 1042 | - let easing = `cubic-bezier(0.4, 0.0, 0.2, 1)`; | |
| 1043 | - if (transitioningIn) { | |
| 1044 | - el._x_transition.enter.during = { | |
| 1045 | - transformOrigin: origin, | |
| 1046 | - transitionDelay: `${delay}s`, | |
| 1047 | - transitionProperty: property, | |
| 1048 | - transitionDuration: `${durationIn}s`, | |
| 1049 | - transitionTimingFunction: easing | |
| 1050 | - }; | |
| 1051 | - el._x_transition.enter.start = { | |
| 1052 | - opacity: opacityValue, | |
| 1053 | - transform: `scale(${scaleValue})` | |
| 1054 | - }; | |
| 1055 | - el._x_transition.enter.end = { | |
| 1056 | - opacity: 1, | |
| 1057 | - transform: `scale(1)` | |
| 1058 | - }; | |
| 1059 | - } | |
| 1060 | - if (transitioningOut) { | |
| 1061 | - el._x_transition.leave.during = { | |
| 1062 | - transformOrigin: origin, | |
| 1063 | - transitionDelay: `${delay}s`, | |
| 1064 | - transitionProperty: property, | |
| 1065 | - transitionDuration: `${durationOut}s`, | |
| 1066 | - transitionTimingFunction: easing | |
| 1067 | - }; | |
| 1068 | - el._x_transition.leave.start = { | |
| 1069 | - opacity: 1, | |
| 1070 | - transform: `scale(1)` | |
| 1071 | - }; | |
| 1072 | - el._x_transition.leave.end = { | |
| 1073 | - opacity: opacityValue, | |
| 1074 | - transform: `scale(${scaleValue})` | |
| 1075 | - }; | |
| 1076 | - } | |
| 1077 | -} | |
| 1078 | -function registerTransitionObject(el, setFunction, defaultValue = {}) { | |
| 1079 | - if (!el._x_transition) | |
| 1080 | - el._x_transition = { | |
| 1081 | - enter: { during: defaultValue, start: defaultValue, end: defaultValue }, | |
| 1082 | - leave: { during: defaultValue, start: defaultValue, end: defaultValue }, | |
| 1083 | - in(before = () => { | |
| 1084 | - }, after = () => { | |
| 1085 | - }) { | |
| 1086 | - transition(el, setFunction, { | |
| 1087 | - during: this.enter.during, | |
| 1088 | - start: this.enter.start, | |
| 1089 | - end: this.enter.end | |
| 1090 | - }, before, after); | |
| 1091 | - }, | |
| 1092 | - out(before = () => { | |
| 1093 | - }, after = () => { | |
| 1094 | - }) { | |
| 1095 | - transition(el, setFunction, { | |
| 1096 | - during: this.leave.during, | |
| 1097 | - start: this.leave.start, | |
| 1098 | - end: this.leave.end | |
| 1099 | - }, before, after); | |
| 1100 | - } | |
| 1101 | - }; | |
| 1102 | -} | |
| 1103 | -window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) { | |
| 1104 | - const nextTick2 = document.visibilityState === "visible" ? requestAnimationFrame : setTimeout; | |
| 1105 | - let clickAwayCompatibleShow = () => nextTick2(show); | |
| 1106 | - if (value) { | |
| 1107 | - if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) { | |
| 1108 | - el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow(); | |
| 1109 | - } else { | |
| 1110 | - el._x_transition ? el._x_transition.in(show) : clickAwayCompatibleShow(); | |
| 1111 | - } | |
| 1112 | - return; | |
| 1113 | - } | |
| 1114 | - el._x_hidePromise = el._x_transition ? new Promise((resolve, reject) => { | |
| 1115 | - el._x_transition.out(() => { | |
| 1116 | - }, () => resolve(hide)); | |
| 1117 | - el._x_transitioning && el._x_transitioning.beforeCancel(() => reject({ isFromCancelledTransition: true })); | |
| 1118 | - }) : Promise.resolve(hide); | |
| 1119 | - queueMicrotask(() => { | |
| 1120 | - let closest = closestHide(el); | |
| 1121 | - if (closest) { | |
| 1122 | - if (!closest._x_hideChildren) | |
| 1123 | - closest._x_hideChildren = []; | |
| 1124 | - closest._x_hideChildren.push(el); | |
| 1125 | - } else { | |
| 1126 | - nextTick2(() => { | |
| 1127 | - let hideAfterChildren = (el2) => { | |
| 1128 | - let carry = Promise.all([ | |
| 1129 | - el2._x_hidePromise, | |
| 1130 | - ...(el2._x_hideChildren || []).map(hideAfterChildren) | |
| 1131 | - ]).then(([i]) => i?.()); | |
| 1132 | - delete el2._x_hidePromise; | |
| 1133 | - delete el2._x_hideChildren; | |
| 1134 | - return carry; | |
| 1135 | - }; | |
| 1136 | - hideAfterChildren(el).catch((e) => { | |
| 1137 | - if (!e.isFromCancelledTransition) | |
| 1138 | - throw e; | |
| 1139 | - }); | |
| 1140 | - }); | |
| 1141 | - } | |
| 1142 | - }); | |
| 1143 | -}; | |
| 1144 | -function closestHide(el) { | |
| 1145 | - let parent = el.parentNode; | |
| 1146 | - if (!parent) | |
| 1147 | - return; | |
| 1148 | - return parent._x_hidePromise ? parent : closestHide(parent); | |
| 1149 | -} | |
| 1150 | -function transition(el, setFunction, { during, start: start2, end } = {}, before = () => { | |
| 1151 | -}, after = () => { | |
| 1152 | -}) { | |
| 1153 | - if (el._x_transitioning) | |
| 1154 | - el._x_transitioning.cancel(); | |
| 1155 | - if (Object.keys(during).length === 0 && Object.keys(start2).length === 0 && Object.keys(end).length === 0) { | |
| 1156 | - before(); | |
| 1157 | - after(); | |
| 1158 | - return; | |
| 1159 | - } | |
| 1160 | - let undoStart, undoDuring, undoEnd; | |
| 1161 | - performTransition(el, { | |
| 1162 | - start() { | |
| 1163 | - undoStart = setFunction(el, start2); | |
| 1164 | - }, | |
| 1165 | - during() { | |
| 1166 | - undoDuring = setFunction(el, during); | |
| 1167 | - }, | |
| 1168 | - before, | |
| 1169 | - end() { | |
| 1170 | - undoStart(); | |
| 1171 | - undoEnd = setFunction(el, end); | |
| 1172 | - }, | |
| 1173 | - after, | |
| 1174 | - cleanup() { | |
| 1175 | - undoDuring(); | |
| 1176 | - undoEnd(); | |
| 1177 | - } | |
| 1178 | - }); | |
| 1179 | -} | |
| 1180 | -function performTransition(el, stages) { | |
| 1181 | - let interrupted, reachedBefore, reachedEnd; | |
| 1182 | - let finish = once(() => { | |
| 1183 | - mutateDom(() => { | |
| 1184 | - interrupted = true; | |
| 1185 | - if (!reachedBefore) | |
| 1186 | - stages.before(); | |
| 1187 | - if (!reachedEnd) { | |
| 1188 | - stages.end(); | |
| 1189 | - releaseNextTicks(); | |
| 1190 | - } | |
| 1191 | - stages.after(); | |
| 1192 | - if (el.isConnected) | |
| 1193 | - stages.cleanup(); | |
| 1194 | - delete el._x_transitioning; | |
| 1195 | - }); | |
| 1196 | - }); | |
| 1197 | - el._x_transitioning = { | |
| 1198 | - beforeCancels: [], | |
| 1199 | - beforeCancel(callback) { | |
| 1200 | - this.beforeCancels.push(callback); | |
| 1201 | - }, | |
| 1202 | - cancel: once(function() { | |
| 1203 | - while (this.beforeCancels.length) { | |
| 1204 | - this.beforeCancels.shift()(); | |
| 1205 | - } | |
| 1206 | - ; | |
| 1207 | - finish(); | |
| 1208 | - }), | |
| 1209 | - finish | |
| 1210 | - }; | |
| 1211 | - mutateDom(() => { | |
| 1212 | - stages.start(); | |
| 1213 | - stages.during(); | |
| 1214 | - }); | |
| 1215 | - holdNextTicks(); | |
| 1216 | - requestAnimationFrame(() => { | |
| 1217 | - if (interrupted) | |
| 1218 | - return; | |
| 1219 | - let duration = Number(getComputedStyle(el).transitionDuration.replace(/,.*/, "").replace("s", "")) * 1e3; | |
| 1220 | - let delay = Number(getComputedStyle(el).transitionDelay.replace(/,.*/, "").replace("s", "")) * 1e3; | |
| 1221 | - if (duration === 0) | |
| 1222 | - duration = Number(getComputedStyle(el).animationDuration.replace("s", "")) * 1e3; | |
| 1223 | - mutateDom(() => { | |
| 1224 | - stages.before(); | |
| 1225 | - }); | |
| 1226 | - reachedBefore = true; | |
| 1227 | - requestAnimationFrame(() => { | |
| 1228 | - if (interrupted) | |
| 1229 | - return; | |
| 1230 | - mutateDom(() => { | |
| 1231 | - stages.end(); | |
| 1232 | - }); | |
| 1233 | - releaseNextTicks(); | |
| 1234 | - setTimeout(el._x_transitioning.finish, duration + delay); | |
| 1235 | - reachedEnd = true; | |
| 1236 | - }); | |
| 1237 | - }); | |
| 1238 | -} | |
| 1239 | -function modifierValue(modifiers, key, fallback) { | |
| 1240 | - if (modifiers.indexOf(key) === -1) | |
| 1241 | - return fallback; | |
| 1242 | - const rawValue = modifiers[modifiers.indexOf(key) + 1]; | |
| 1243 | - if (!rawValue) | |
| 1244 | - return fallback; | |
| 1245 | - if (key === "scale") { | |
| 1246 | - if (isNaN(rawValue)) | |
| 1247 | - return fallback; | |
| 1248 | - } | |
| 1249 | - if (key === "duration" || key === "delay") { | |
| 1250 | - let match = rawValue.match(/([0-9]+)ms/); | |
| 1251 | - if (match) | |
| 1252 | - return match[1]; | |
| 1253 | - } | |
| 1254 | - if (key === "origin") { | |
| 1255 | - if (["top", "right", "left", "center", "bottom"].includes(modifiers[modifiers.indexOf(key) + 2])) { | |
| 1256 | - return [rawValue, modifiers[modifiers.indexOf(key) + 2]].join(" "); | |
| 1257 | - } | |
| 1258 | - } | |
| 1259 | - return rawValue; | |
| 1260 | -} | |
| 1261 | - | |
| 1262 | -// packages/alpinejs/src/clone.js | |
| 1263 | -var isCloning = false; | |
| 1264 | -function skipDuringClone(callback, fallback = () => { | |
| 1265 | -}) { | |
| 1266 | - return (...args) => isCloning ? fallback(...args) : callback(...args); | |
| 1267 | -} | |
| 1268 | -function onlyDuringClone(callback) { | |
| 1269 | - return (...args) => isCloning && callback(...args); | |
| 1270 | -} | |
| 1271 | -var interceptors = []; | |
| 1272 | -function interceptClone(callback) { | |
| 1273 | - interceptors.push(callback); | |
| 1274 | -} | |
| 1275 | -function cloneNode(from, to) { | |
| 1276 | - interceptors.forEach((i) => i(from, to)); | |
| 1277 | - isCloning = true; | |
| 1278 | - dontRegisterReactiveSideEffects(() => { | |
| 1279 | - initTree(to, (el, callback) => { | |
| 1280 | - callback(el, () => { | |
| 1281 | - }); | |
| 1282 | - }); | |
| 1283 | - }); | |
| 1284 | - isCloning = false; | |
| 1285 | -} | |
| 1286 | -var isCloningLegacy = false; | |
| 1287 | -function clone(oldEl, newEl) { | |
| 1288 | - if (!newEl._x_dataStack) | |
| 1289 | - newEl._x_dataStack = oldEl._x_dataStack; | |
| 1290 | - isCloning = true; | |
| 1291 | - isCloningLegacy = true; | |
| 1292 | - dontRegisterReactiveSideEffects(() => { | |
| 1293 | - cloneTree(newEl); | |
| 1294 | - }); | |
| 1295 | - isCloning = false; | |
| 1296 | - isCloningLegacy = false; | |
| 1297 | -} | |
| 1298 | -function cloneTree(el) { | |
| 1299 | - let hasRunThroughFirstEl = false; | |
| 1300 | - let shallowWalker = (el2, callback) => { | |
| 1301 | - walk(el2, (el3, skip) => { | |
| 1302 | - if (hasRunThroughFirstEl && isRoot(el3)) | |
| 1303 | - return skip(); | |
| 1304 | - hasRunThroughFirstEl = true; | |
| 1305 | - callback(el3, skip); | |
| 1306 | - }); | |
| 1307 | - }; | |
| 1308 | - initTree(el, shallowWalker); | |
| 1309 | -} | |
| 1310 | -function dontRegisterReactiveSideEffects(callback) { | |
| 1311 | - let cache = effect; | |
| 1312 | - overrideEffect((callback2, el) => { | |
| 1313 | - let storedEffect = cache(callback2); | |
| 1314 | - release(storedEffect); | |
| 1315 | - return () => { | |
| 1316 | - }; | |
| 1317 | - }); | |
| 1318 | - callback(); | |
| 1319 | - overrideEffect(cache); | |
| 1320 | -} | |
| 1321 | - | |
| 1322 | -// packages/alpinejs/src/utils/bind.js | |
| 1323 | -function bind(el, name, value, modifiers = []) { | |
| 1324 | - if (!el._x_bindings) | |
| 1325 | - el._x_bindings = reactive({}); | |
| 1326 | - el._x_bindings[name] = value; | |
| 1327 | - name = modifiers.includes("camel") ? camelCase(name) : name; | |
| 1328 | - switch (name) { | |
| 1329 | - case "value": | |
| 1330 | - bindInputValue(el, value); | |
| 1331 | - break; | |
| 1332 | - case "style": | |
| 1333 | - bindStyles(el, value); | |
| 1334 | - break; | |
| 1335 | - case "class": | |
| 1336 | - bindClasses(el, value); | |
| 1337 | - break; | |
| 1338 | - case "selected": | |
| 1339 | - case "checked": | |
| 1340 | - bindAttributeAndProperty(el, name, value); | |
| 1341 | - break; | |
| 1342 | - default: | |
| 1343 | - bindAttribute(el, name, value); | |
| 1344 | - break; | |
| 1345 | - } | |
| 1346 | -} | |
| 1347 | -function bindInputValue(el, value) { | |
| 1348 | - if (isRadio(el)) { | |
| 1349 | - if (el.attributes.value === void 0) { | |
| 1350 | - el.value = value; | |
| 1351 | - } | |
| 1352 | - if (window.fromModel) { | |
| 1353 | - if (typeof value === "boolean") { | |
| 1354 | - el.checked = safeParseBoolean(el.value) === value; | |
| 1355 | - } else { | |
| 1356 | - el.checked = checkedAttrLooseCompare(el.value, value); | |
| 1357 | - } | |
| 1358 | - } | |
| 1359 | - } else if (isCheckbox(el)) { | |
| 1360 | - if (Number.isInteger(value)) { | |
| 1361 | - el.value = value; | |
| 1362 | - } else if (!Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) { | |
| 1363 | - el.value = String(value); | |
| 1364 | - } else { | |
| 1365 | - if (Array.isArray(value)) { | |
| 1366 | - el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value)); | |
| 1367 | - } else { | |
| 1368 | - el.checked = !!value; | |
| 1369 | - } | |
| 1370 | - } | |
| 1371 | - } else if (el.tagName === "SELECT") { | |
| 1372 | - updateSelect(el, value); | |
| 1373 | - } else { | |
| 1374 | - if (el.value === value) | |
| 1375 | - return; | |
| 1376 | - el.value = value === void 0 ? "" : value; | |
| 1377 | - } | |
| 1378 | -} | |
| 1379 | -function bindClasses(el, value) { | |
| 1380 | - if (el._x_undoAddedClasses) | |
| 1381 | - el._x_undoAddedClasses(); | |
| 1382 | - el._x_undoAddedClasses = setClasses(el, value); | |
| 1383 | -} | |
| 1384 | -function bindStyles(el, value) { | |
| 1385 | - if (el._x_undoAddedStyles) | |
| 1386 | - el._x_undoAddedStyles(); | |
| 1387 | - el._x_undoAddedStyles = setStyles(el, value); | |
| 1388 | -} | |
| 1389 | -function bindAttributeAndProperty(el, name, value) { | |
| 1390 | - bindAttribute(el, name, value); | |
| 1391 | - setPropertyIfChanged(el, name, value); | |
| 1392 | -} | |
| 1393 | -function bindAttribute(el, name, value) { | |
| 1394 | - if ([null, void 0, false].includes(value) && attributeShouldntBePreservedIfFalsy(name)) { | |
| 1395 | - el.removeAttribute(name); | |
| 1396 | - } else { | |
| 1397 | - if (isBooleanAttr(name)) | |
| 1398 | - value = name; | |
| 1399 | - setIfChanged(el, name, value); | |
| 1400 | - } | |
| 1401 | -} | |
| 1402 | -function setIfChanged(el, attrName, value) { | |
| 1403 | - if (el.getAttribute(attrName) != value) { | |
| 1404 | - el.setAttribute(attrName, value); | |
| 1405 | - } | |
| 1406 | -} | |
| 1407 | -function setPropertyIfChanged(el, propName, value) { | |
| 1408 | - if (el[propName] !== value) { | |
| 1409 | - el[propName] = value; | |
| 1410 | - } | |
| 1411 | -} | |
| 1412 | -function updateSelect(el, value) { | |
| 1413 | - const arrayWrappedValue = [].concat(value).map((value2) => { | |
| 1414 | - return value2 + ""; | |
| 1415 | - }); | |
| 1416 | - Array.from(el.options).forEach((option) => { | |
| 1417 | - option.selected = arrayWrappedValue.includes(option.value); | |
| 1418 | - }); | |
| 1419 | -} | |
| 1420 | -function camelCase(subject) { | |
| 1421 | - return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); | |
| 1422 | -} | |
| 1423 | -function checkedAttrLooseCompare(valueA, valueB) { | |
| 1424 | - return valueA == valueB; | |
| 1425 | -} | |
| 1426 | -function safeParseBoolean(rawValue) { | |
| 1427 | - if ([1, "1", "true", "on", "yes", true].includes(rawValue)) { | |
| 1428 | - return true; | |
| 1429 | - } | |
| 1430 | - if ([0, "0", "false", "off", "no", false].includes(rawValue)) { | |
| 1431 | - return false; | |
| 1432 | - } | |
| 1433 | - return rawValue ? Boolean(rawValue) : null; | |
| 1434 | -} | |
| 1435 | -var booleanAttributes = /* @__PURE__ */ new Set([ | |
| 1436 | - "allowfullscreen", | |
| 1437 | - "async", | |
| 1438 | - "autofocus", | |
| 1439 | - "autoplay", | |
| 1440 | - "checked", | |
| 1441 | - "controls", | |
| 1442 | - "default", | |
| 1443 | - "defer", | |
| 1444 | - "disabled", | |
| 1445 | - "formnovalidate", | |
| 1446 | - "inert", | |
| 1447 | - "ismap", | |
| 1448 | - "itemscope", | |
| 1449 | - "loop", | |
| 1450 | - "multiple", | |
| 1451 | - "muted", | |
| 1452 | - "nomodule", | |
| 1453 | - "novalidate", | |
| 1454 | - "open", | |
| 1455 | - "playsinline", | |
| 1456 | - "readonly", | |
| 1457 | - "required", | |
| 1458 | - "reversed", | |
| 1459 | - "selected", | |
| 1460 | - "shadowrootclonable", | |
| 1461 | - "shadowrootdelegatesfocus", | |
| 1462 | - "shadowrootserializable" | |
| 1463 | -]); | |
| 1464 | -function isBooleanAttr(attrName) { | |
| 1465 | - return booleanAttributes.has(attrName); | |
| 1466 | -} | |
| 1467 | -function attributeShouldntBePreservedIfFalsy(name) { | |
| 1468 | - return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(name); | |
| 1469 | -} | |
| 1470 | -function getBinding(el, name, fallback) { | |
| 1471 | - if (el._x_bindings && el._x_bindings[name] !== void 0) | |
| 1472 | - return el._x_bindings[name]; | |
| 1473 | - return getAttributeBinding(el, name, fallback); | |
| 1474 | -} | |
| 1475 | -function extractProp(el, name, fallback, extract = true) { | |
| 1476 | - if (el._x_bindings && el._x_bindings[name] !== void 0) | |
| 1477 | - return el._x_bindings[name]; | |
| 1478 | - if (el._x_inlineBindings && el._x_inlineBindings[name] !== void 0) { | |
| 1479 | - let binding = el._x_inlineBindings[name]; | |
| 1480 | - binding.extract = extract; | |
| 1481 | - return dontAutoEvaluateFunctions(() => { | |
| 1482 | - return evaluate(el, binding.expression); | |
| 1483 | - }); | |
| 1484 | - } | |
| 1485 | - return getAttributeBinding(el, name, fallback); | |
| 1486 | -} | |
| 1487 | -function getAttributeBinding(el, name, fallback) { | |
| 1488 | - let attr = el.getAttribute(name); | |
| 1489 | - if (attr === null) | |
| 1490 | - return typeof fallback === "function" ? fallback() : fallback; | |
| 1491 | - if (attr === "") | |
| 1492 | - return true; | |
| 1493 | - if (isBooleanAttr(name)) { | |
| 1494 | - return !![name, "true"].includes(attr); | |
| 1495 | - } | |
| 1496 | - return attr; | |
| 1497 | -} | |
| 1498 | -function isCheckbox(el) { | |
| 1499 | - return el.type === "checkbox" || el.localName === "ui-checkbox" || el.localName === "ui-switch"; | |
| 1500 | -} | |
| 1501 | -function isRadio(el) { | |
| 1502 | - return el.type === "radio" || el.localName === "ui-radio"; | |
| 1503 | -} | |
| 1504 | - | |
| 1505 | -// packages/alpinejs/src/utils/debounce.js | |
| 1506 | -function debounce(func, wait) { | |
| 1507 | - let timeout; | |
| 1508 | - return function() { | |
| 1509 | - const context = this, args = arguments; | |
| 1510 | - const later = function() { | |
| 1511 | - timeout = null; | |
| 1512 | - func.apply(context, args); | |
| 1513 | - }; | |
| 1514 | - clearTimeout(timeout); | |
| 1515 | - timeout = setTimeout(later, wait); | |
| 1516 | - }; | |
| 1517 | -} | |
| 1518 | - | |
| 1519 | -// packages/alpinejs/src/utils/throttle.js | |
| 1520 | -function throttle(func, limit) { | |
| 1521 | - let inThrottle; | |
| 1522 | - return function() { | |
| 1523 | - let context = this, args = arguments; | |
| 1524 | - if (!inThrottle) { | |
| 1525 | - func.apply(context, args); | |
| 1526 | - inThrottle = true; | |
| 1527 | - setTimeout(() => inThrottle = false, limit); | |
| 1528 | - } | |
| 1529 | - }; | |
| 1530 | -} | |
| 1531 | - | |
| 1532 | -// packages/alpinejs/src/entangle.js | |
| 1533 | -function entangle({ get: outerGet, set: outerSet }, { get: innerGet, set: innerSet }) { | |
| 1534 | - let firstRun = true; | |
| 1535 | - let outerHash; | |
| 1536 | - let innerHash; | |
| 1537 | - let reference = effect(() => { | |
| 1538 | - let outer = outerGet(); | |
| 1539 | - let inner = innerGet(); | |
| 1540 | - if (firstRun) { | |
| 1541 | - innerSet(cloneIfObject(outer)); | |
| 1542 | - firstRun = false; | |
| 1543 | - } else { | |
| 1544 | - let outerHashLatest = JSON.stringify(outer); | |
| 1545 | - let innerHashLatest = JSON.stringify(inner); | |
| 1546 | - if (outerHashLatest !== outerHash) { | |
| 1547 | - innerSet(cloneIfObject(outer)); | |
| 1548 | - } else if (outerHashLatest !== innerHashLatest) { | |
| 1549 | - outerSet(cloneIfObject(inner)); | |
| 1550 | - } else { | |
| 1551 | - } | |
| 1552 | - } | |
| 1553 | - outerHash = JSON.stringify(outerGet()); | |
| 1554 | - innerHash = JSON.stringify(innerGet()); | |
| 1555 | - }); | |
| 1556 | - return () => { | |
| 1557 | - release(reference); | |
| 1558 | - }; | |
| 1559 | -} | |
| 1560 | -function cloneIfObject(value) { | |
| 1561 | - return typeof value === "object" ? JSON.parse(JSON.stringify(value)) : value; | |
| 1562 | -} | |
| 1563 | - | |
| 1564 | -// packages/alpinejs/src/plugin.js | |
| 1565 | -function plugin(callback) { | |
| 1566 | - let callbacks = Array.isArray(callback) ? callback : [callback]; | |
| 1567 | - callbacks.forEach((i) => i(alpine_default)); | |
| 1568 | -} | |
| 1569 | - | |
| 1570 | -// packages/alpinejs/src/store.js | |
| 1571 | -var stores = {}; | |
| 1572 | -var isReactive = false; | |
| 1573 | -function store(name, value) { | |
| 1574 | - if (!isReactive) { | |
| 1575 | - stores = reactive(stores); | |
| 1576 | - isReactive = true; | |
| 1577 | - } | |
| 1578 | - if (value === void 0) { | |
| 1579 | - return stores[name]; | |
| 1580 | - } | |
| 1581 | - stores[name] = value; | |
| 1582 | - initInterceptors(stores[name]); | |
| 1583 | - if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") { | |
| 1584 | - stores[name].init(); | |
| 1585 | - } | |
| 1586 | -} | |
| 1587 | -function getStores() { | |
| 1588 | - return stores; | |
| 1589 | -} | |
| 1590 | - | |
| 1591 | -// packages/alpinejs/src/binds.js | |
| 1592 | -var binds = {}; | |
| 1593 | -function bind2(name, bindings) { | |
| 1594 | - let getBindings = typeof bindings !== "function" ? () => bindings : bindings; | |
| 1595 | - if (name instanceof Element) { | |
| 1596 | - return applyBindingsObject(name, getBindings()); | |
| 1597 | - } else { | |
| 1598 | - binds[name] = getBindings; | |
| 1599 | - } | |
| 1600 | - return () => { | |
| 1601 | - }; | |
| 1602 | -} | |
| 1603 | -function injectBindingProviders(obj) { | |
| 1604 | - Object.entries(binds).forEach(([name, callback]) => { | |
| 1605 | - Object.defineProperty(obj, name, { | |
| 1606 | - get() { | |
| 1607 | - return (...args) => { | |
| 1608 | - return callback(...args); | |
| 1609 | - }; | |
| 1610 | - } | |
| 1611 | - }); | |
| 1612 | - }); | |
| 1613 | - return obj; | |
| 1614 | -} | |
| 1615 | -function applyBindingsObject(el, obj, original) { | |
| 1616 | - let cleanupRunners = []; | |
| 1617 | - while (cleanupRunners.length) | |
| 1618 | - cleanupRunners.pop()(); | |
| 1619 | - let attributes = Object.entries(obj).map(([name, value]) => ({ name, value })); | |
| 1620 | - let staticAttributes = attributesOnly(attributes); | |
| 1621 | - attributes = attributes.map((attribute) => { | |
| 1622 | - if (staticAttributes.find((attr) => attr.name === attribute.name)) { | |
| 1623 | - return { | |
| 1624 | - name: `x-bind:${attribute.name}`, | |
| 1625 | - value: `"${attribute.value}"` | |
| 1626 | - }; | |
| 1627 | - } | |
| 1628 | - return attribute; | |
| 1629 | - }); | |
| 1630 | - directives(el, attributes, original).map((handle) => { | |
| 1631 | - cleanupRunners.push(handle.runCleanups); | |
| 1632 | - handle(); | |
| 1633 | - }); | |
| 1634 | - return () => { | |
| 1635 | - while (cleanupRunners.length) | |
| 1636 | - cleanupRunners.pop()(); | |
| 1637 | - }; | |
| 1638 | -} | |
| 1639 | - | |
| 1640 | -// packages/alpinejs/src/datas.js | |
| 1641 | -var datas = {}; | |
| 1642 | -function data(name, callback) { | |
| 1643 | - datas[name] = callback; | |
| 1644 | -} | |
| 1645 | -function injectDataProviders(obj, context) { | |
| 1646 | - Object.entries(datas).forEach(([name, callback]) => { | |
| 1647 | - Object.defineProperty(obj, name, { | |
| 1648 | - get() { | |
| 1649 | - return (...args) => { | |
| 1650 | - return callback.bind(context)(...args); | |
| 1651 | - }; | |
| 1652 | - }, | |
| 1653 | - enumerable: false | |
| 1654 | - }); | |
| 1655 | - }); | |
| 1656 | - return obj; | |
| 1657 | -} | |
| 1658 | - | |
| 1659 | -// packages/alpinejs/src/alpine.js | |
| 1660 | -var Alpine = { | |
| 1661 | - get reactive() { | |
| 1662 | - return reactive; | |
| 1663 | - }, | |
| 1664 | - get release() { | |
| 1665 | - return release; | |
| 1666 | - }, | |
| 1667 | - get effect() { | |
| 1668 | - return effect; | |
| 1669 | - }, | |
| 1670 | - get raw() { | |
| 1671 | - return raw; | |
| 1672 | - }, | |
| 1673 | - version: "3.15.0", | |
| 1674 | - flushAndStopDeferringMutations, | |
| 1675 | - dontAutoEvaluateFunctions, | |
| 1676 | - disableEffectScheduling, | |
| 1677 | - startObservingMutations, | |
| 1678 | - stopObservingMutations, | |
| 1679 | - setReactivityEngine, | |
| 1680 | - onAttributeRemoved, | |
| 1681 | - onAttributesAdded, | |
| 1682 | - closestDataStack, | |
| 1683 | - skipDuringClone, | |
| 1684 | - onlyDuringClone, | |
| 1685 | - addRootSelector, | |
| 1686 | - addInitSelector, | |
| 1687 | - interceptClone, | |
| 1688 | - addScopeToNode, | |
| 1689 | - deferMutations, | |
| 1690 | - mapAttributes, | |
| 1691 | - evaluateLater, | |
| 1692 | - interceptInit, | |
| 1693 | - setEvaluator, | |
| 1694 | - mergeProxies, | |
| 1695 | - extractProp, | |
| 1696 | - findClosest, | |
| 1697 | - onElRemoved, | |
| 1698 | - closestRoot, | |
| 1699 | - destroyTree, | |
| 1700 | - interceptor, | |
| 1701 | - // INTERNAL: not public API and is subject to change without major release. | |
| 1702 | - transition, | |
| 1703 | - // INTERNAL | |
| 1704 | - setStyles, | |
| 1705 | - // INTERNAL | |
| 1706 | - mutateDom, | |
| 1707 | - directive, | |
| 1708 | - entangle, | |
| 1709 | - throttle, | |
| 1710 | - debounce, | |
| 1711 | - evaluate, | |
| 1712 | - initTree, | |
| 1713 | - nextTick, | |
| 1714 | - prefixed: prefix, | |
| 1715 | - prefix: setPrefix, | |
| 1716 | - plugin, | |
| 1717 | - magic, | |
| 1718 | - store, | |
| 1719 | - start, | |
| 1720 | - clone, | |
| 1721 | - // INTERNAL | |
| 1722 | - cloneNode, | |
| 1723 | - // INTERNAL | |
| 1724 | - bound: getBinding, | |
| 1725 | - $data: scope, | |
| 1726 | - watch, | |
| 1727 | - walk, | |
| 1728 | - data, | |
| 1729 | - bind: bind2 | |
| 1730 | -}; | |
| 1731 | -var alpine_default = Alpine; | |
| 1732 | - | |
| 1733 | -// packages/csp/src/parser.js | |
| 1734 | -var Token = class { | |
| 1735 | - constructor(type, value, start2, end) { | |
| 1736 | - this.type = type; | |
| 1737 | - this.value = value; | |
| 1738 | - this.start = start2; | |
| 1739 | - this.end = end; | |
| 1740 | - } | |
| 1741 | -}; | |
| 1742 | -var Tokenizer = class { | |
| 1743 | - constructor(input) { | |
| 1744 | - this.input = input; | |
| 1745 | - this.position = 0; | |
| 1746 | - this.tokens = []; | |
| 1747 | - } | |
| 1748 | - tokenize() { | |
| 1749 | - while (this.position < this.input.length) { | |
| 1750 | - this.skipWhitespace(); | |
| 1751 | - if (this.position >= this.input.length) | |
| 1752 | - break; | |
| 1753 | - const char = this.input[this.position]; | |
| 1754 | - if (this.isDigit(char)) { | |
| 1755 | - this.readNumber(); | |
| 1756 | - } else if (this.isAlpha(char) || char === "_" || char === "$") { | |
| 1757 | - this.readIdentifierOrKeyword(); | |
| 1758 | - } else if (char === '"' || char === "'") { | |
| 1759 | - this.readString(); | |
| 1760 | - } else if (char === "/" && this.peek() === "/") { | |
| 1761 | - this.skipLineComment(); | |
| 1762 | - } else { | |
| 1763 | - this.readOperatorOrPunctuation(); | |
| 1764 | - } | |
| 1765 | - } | |
| 1766 | - this.tokens.push(new Token("EOF", null, this.position, this.position)); | |
| 1767 | - return this.tokens; | |
| 1768 | - } | |
| 1769 | - skipWhitespace() { | |
| 1770 | - while (this.position < this.input.length && /\s/.test(this.input[this.position])) { | |
| 1771 | - this.position++; | |
| 1772 | - } | |
| 1773 | - } | |
| 1774 | - skipLineComment() { | |
| 1775 | - while (this.position < this.input.length && this.input[this.position] !== "\n") { | |
| 1776 | - this.position++; | |
| 1777 | - } | |
| 1778 | - } | |
| 1779 | - isDigit(char) { | |
| 1780 | - return /[0-9]/.test(char); | |
| 1781 | - } | |
| 1782 | - isAlpha(char) { | |
| 1783 | - return /[a-zA-Z]/.test(char); | |
| 1784 | - } | |
| 1785 | - isAlphaNumeric(char) { | |
| 1786 | - return /[a-zA-Z0-9_$]/.test(char); | |
| 1787 | - } | |
| 1788 | - peek(offset = 1) { | |
| 1789 | - return this.input[this.position + offset] || ""; | |
| 1790 | - } | |
| 1791 | - readNumber() { | |
| 1792 | - const start2 = this.position; | |
| 1793 | - let hasDecimal = false; | |
| 1794 | - while (this.position < this.input.length) { | |
| 1795 | - const char = this.input[this.position]; | |
| 1796 | - if (this.isDigit(char)) { | |
| 1797 | - this.position++; | |
| 1798 | - } else if (char === "." && !hasDecimal) { | |
| 1799 | - hasDecimal = true; | |
| 1800 | - this.position++; | |
| 1801 | - } else { | |
| 1802 | - break; | |
| 1803 | - } | |
| 1804 | - } | |
| 1805 | - const value = this.input.slice(start2, this.position); | |
| 1806 | - this.tokens.push(new Token("NUMBER", parseFloat(value), start2, this.position)); | |
| 1807 | - } | |
| 1808 | - readIdentifierOrKeyword() { | |
| 1809 | - const start2 = this.position; | |
| 1810 | - while (this.position < this.input.length && this.isAlphaNumeric(this.input[this.position])) { | |
| 1811 | - this.position++; | |
| 1812 | - } | |
| 1813 | - const value = this.input.slice(start2, this.position); | |
| 1814 | - const keywords = ["true", "false", "null", "undefined", "new", "typeof", "void", "delete", "in", "instanceof"]; | |
| 1815 | - if (keywords.includes(value)) { | |
| 1816 | - if (value === "true" || value === "false") { | |
| 1817 | - this.tokens.push(new Token("BOOLEAN", value === "true", start2, this.position)); | |
| 1818 | - } else if (value === "null") { | |
| 1819 | - this.tokens.push(new Token("NULL", null, start2, this.position)); | |
| 1820 | - } else if (value === "undefined") { | |
| 1821 | - this.tokens.push(new Token("UNDEFINED", void 0, start2, this.position)); | |
| 1822 | - } else { | |
| 1823 | - this.tokens.push(new Token("KEYWORD", value, start2, this.position)); | |
| 1824 | - } | |
| 1825 | - } else { | |
| 1826 | - this.tokens.push(new Token("IDENTIFIER", value, start2, this.position)); | |
| 1827 | - } | |
| 1828 | - } | |
| 1829 | - readString() { | |
| 1830 | - const start2 = this.position; | |
| 1831 | - const quote = this.input[this.position]; | |
| 1832 | - this.position++; | |
| 1833 | - let value = ""; | |
| 1834 | - let escaped = false; | |
| 1835 | - while (this.position < this.input.length) { | |
| 1836 | - const char = this.input[this.position]; | |
| 1837 | - if (escaped) { | |
| 1838 | - switch (char) { | |
| 1839 | - case "n": | |
| 1840 | - value += "\n"; | |
| 1841 | - break; | |
| 1842 | - case "t": | |
| 1843 | - value += " "; | |
| 1844 | - break; | |
| 1845 | - case "r": | |
| 1846 | - value += "\r"; | |
| 1847 | - break; | |
| 1848 | - case "\\": | |
| 1849 | - value += "\\"; | |
| 1850 | - break; | |
| 1851 | - case quote: | |
| 1852 | - value += quote; | |
| 1853 | - break; | |
| 1854 | - default: | |
| 1855 | - value += char; | |
| 1856 | - } | |
| 1857 | - escaped = false; | |
| 1858 | - } else if (char === "\\") { | |
| 1859 | - escaped = true; | |
| 1860 | - } else if (char === quote) { | |
| 1861 | - this.position++; | |
| 1862 | - this.tokens.push(new Token("STRING", value, start2, this.position)); | |
| 1863 | - return; | |
| 1864 | - } else { | |
| 1865 | - value += char; | |
| 1866 | - } | |
| 1867 | - this.position++; | |
| 1868 | - } | |
| 1869 | - throw new Error(`Unterminated string starting at position ${start2}`); | |
| 1870 | - } | |
| 1871 | - readOperatorOrPunctuation() { | |
| 1872 | - const start2 = this.position; | |
| 1873 | - const char = this.input[this.position]; | |
| 1874 | - const next = this.peek(); | |
| 1875 | - const nextNext = this.peek(2); | |
| 1876 | - if (char === "=" && next === "=" && nextNext === "=") { | |
| 1877 | - this.position += 3; | |
| 1878 | - this.tokens.push(new Token("OPERATOR", "===", start2, this.position)); | |
| 1879 | - } else if (char === "!" && next === "=" && nextNext === "=") { | |
| 1880 | - this.position += 3; | |
| 1881 | - this.tokens.push(new Token("OPERATOR", "!==", start2, this.position)); | |
| 1882 | - } else if (char === "=" && next === "=") { | |
| 1883 | - this.position += 2; | |
| 1884 | - this.tokens.push(new Token("OPERATOR", "==", start2, this.position)); | |
| 1885 | - } else if (char === "!" && next === "=") { | |
| 1886 | - this.position += 2; | |
| 1887 | - this.tokens.push(new Token("OPERATOR", "!=", start2, this.position)); | |
| 1888 | - } else if (char === "<" && next === "=") { | |
| 1889 | - this.position += 2; | |
| 1890 | - this.tokens.push(new Token("OPERATOR", "<=", start2, this.position)); | |
| 1891 | - } else if (char === ">" && next === "=") { | |
| 1892 | - this.position += 2; | |
| 1893 | - this.tokens.push(new Token("OPERATOR", ">=", start2, this.position)); | |
| 1894 | - } else if (char === "&" && next === "&") { | |
| 1895 | - this.position += 2; | |
| 1896 | - this.tokens.push(new Token("OPERATOR", "&&", start2, this.position)); | |
| 1897 | - } else if (char === "|" && next === "|") { | |
| 1898 | - this.position += 2; | |
| 1899 | - this.tokens.push(new Token("OPERATOR", "||", start2, this.position)); | |
| 1900 | - } else if (char === "+" && next === "+") { | |
| 1901 | - this.position += 2; | |
| 1902 | - this.tokens.push(new Token("OPERATOR", "++", start2, this.position)); | |
| 1903 | - } else if (char === "-" && next === "-") { | |
| 1904 | - this.position += 2; | |
| 1905 | - this.tokens.push(new Token("OPERATOR", "--", start2, this.position)); | |
| 1906 | - } else { | |
| 1907 | - this.position++; | |
| 1908 | - const type = "()[]{},.;:?".includes(char) ? "PUNCTUATION" : "OPERATOR"; | |
| 1909 | - this.tokens.push(new Token(type, char, start2, this.position)); | |
| 1910 | - } | |
| 1911 | - } | |
| 1912 | -}; | |
| 1913 | -var Parser = class { | |
| 1914 | - constructor(tokens) { | |
| 1915 | - this.tokens = tokens; | |
| 1916 | - this.position = 0; | |
| 1917 | - } | |
| 1918 | - parse() { | |
| 1919 | - if (this.isAtEnd()) { | |
| 1920 | - throw new Error("Empty expression"); | |
| 1921 | - } | |
| 1922 | - const expr = this.parseExpression(); | |
| 1923 | - this.match("PUNCTUATION", ";"); | |
| 1924 | - if (!this.isAtEnd()) { | |
| 1925 | - throw new Error(`Unexpected token: ${this.current().value}`); | |
| 1926 | - } | |
| 1927 | - return expr; | |
| 1928 | - } | |
| 1929 | - parseExpression() { | |
| 1930 | - return this.parseAssignment(); | |
| 1931 | - } | |
| 1932 | - parseAssignment() { | |
| 1933 | - const expr = this.parseTernary(); | |
| 1934 | - if (this.match("OPERATOR", "=")) { | |
| 1935 | - const value = this.parseAssignment(); | |
| 1936 | - if (expr.type === "Identifier" || expr.type === "MemberExpression") { | |
| 1937 | - return { | |
| 1938 | - type: "AssignmentExpression", | |
| 1939 | - left: expr, | |
| 1940 | - operator: "=", | |
| 1941 | - right: value | |
| 1942 | - }; | |
| 1943 | - } | |
| 1944 | - throw new Error("Invalid assignment target"); | |
| 1945 | - } | |
| 1946 | - return expr; | |
| 1947 | - } | |
| 1948 | - parseTernary() { | |
| 1949 | - const expr = this.parseLogicalOr(); | |
| 1950 | - if (this.match("PUNCTUATION", "?")) { | |
| 1951 | - const consequent = this.parseExpression(); | |
| 1952 | - this.consume("PUNCTUATION", ":"); | |
| 1953 | - const alternate = this.parseExpression(); | |
| 1954 | - return { | |
| 1955 | - type: "ConditionalExpression", | |
| 1956 | - test: expr, | |
| 1957 | - consequent, | |
| 1958 | - alternate | |
| 1959 | - }; | |
| 1960 | - } | |
| 1961 | - return expr; | |
| 1962 | - } | |
| 1963 | - parseLogicalOr() { | |
| 1964 | - let expr = this.parseLogicalAnd(); | |
| 1965 | - while (this.match("OPERATOR", "||")) { | |
| 1966 | - const operator = this.previous().value; | |
| 1967 | - const right = this.parseLogicalAnd(); | |
| 1968 | - expr = { | |
| 1969 | - type: "BinaryExpression", | |
| 1970 | - operator, | |
| 1971 | - left: expr, | |
| 1972 | - right | |
| 1973 | - }; | |
| 1974 | - } | |
| 1975 | - return expr; | |
| 1976 | - } | |
| 1977 | - parseLogicalAnd() { | |
| 1978 | - let expr = this.parseEquality(); | |
| 1979 | - while (this.match("OPERATOR", "&&")) { | |
| 1980 | - const operator = this.previous().value; | |
| 1981 | - const right = this.parseEquality(); | |
| 1982 | - expr = { | |
| 1983 | - type: "BinaryExpression", | |
| 1984 | - operator, | |
| 1985 | - left: expr, | |
| 1986 | - right | |
| 1987 | - }; | |
| 1988 | - } | |
| 1989 | - return expr; | |
| 1990 | - } | |
| 1991 | - parseEquality() { | |
| 1992 | - let expr = this.parseRelational(); | |
| 1993 | - while (this.match("OPERATOR", "==", "!=", "===", "!==")) { | |
| 1994 | - const operator = this.previous().value; | |
| 1995 | - const right = this.parseRelational(); | |
| 1996 | - expr = { | |
| 1997 | - type: "BinaryExpression", | |
| 1998 | - operator, | |
| 1999 | - left: expr, | |
| 2000 | - right | |
| 2001 | - }; | |
| 2002 | - } | |
| 2003 | - return expr; | |
| 2004 | - } | |
| 2005 | - parseRelational() { | |
| 2006 | - let expr = this.parseAdditive(); | |
| 2007 | - while (this.match("OPERATOR", "<", ">", "<=", ">=")) { | |
| 2008 | - const operator = this.previous().value; | |
| 2009 | - const right = this.parseAdditive(); | |
| 2010 | - expr = { | |
| 2011 | - type: "BinaryExpression", | |
| 2012 | - operator, | |
| 2013 | - left: expr, | |
| 2014 | - right | |
| 2015 | - }; | |
| 2016 | - } | |
| 2017 | - return expr; | |
| 2018 | - } | |
| 2019 | - parseAdditive() { | |
| 2020 | - let expr = this.parseMultiplicative(); | |
| 2021 | - while (this.match("OPERATOR", "+", "-")) { | |
| 2022 | - const operator = this.previous().value; | |
| 2023 | - const right = this.parseMultiplicative(); | |
| 2024 | - expr = { | |
| 2025 | - type: "BinaryExpression", | |
| 2026 | - operator, | |
| 2027 | - left: expr, | |
| 2028 | - right | |
| 2029 | - }; | |
| 2030 | - } | |
| 2031 | - return expr; | |
| 2032 | - } | |
| 2033 | - parseMultiplicative() { | |
| 2034 | - let expr = this.parseUnary(); | |
| 2035 | - while (this.match("OPERATOR", "*", "/", "%")) { | |
| 2036 | - const operator = this.previous().value; | |
| 2037 | - const right = this.parseUnary(); | |
| 2038 | - expr = { | |
| 2039 | - type: "BinaryExpression", | |
| 2040 | - operator, | |
| 2041 | - left: expr, | |
| 2042 | - right | |
| 2043 | - }; | |
| 2044 | - } | |
| 2045 | - return expr; | |
| 2046 | - } | |
| 2047 | - parseUnary() { | |
| 2048 | - if (this.match("OPERATOR", "++", "--")) { | |
| 2049 | - const operator = this.previous().value; | |
| 2050 | - const argument = this.parseUnary(); | |
| 2051 | - return { | |
| 2052 | - type: "UpdateExpression", | |
| 2053 | - operator, | |
| 2054 | - argument, | |
| 2055 | - prefix: true | |
| 2056 | - }; | |
| 2057 | - } | |
| 2058 | - if (this.match("OPERATOR", "!", "-", "+")) { | |
| 2059 | - const operator = this.previous().value; | |
| 2060 | - const argument = this.parseUnary(); | |
| 2061 | - return { | |
| 2062 | - type: "UnaryExpression", | |
| 2063 | - operator, | |
| 2064 | - argument, | |
| 2065 | - prefix: true | |
| 2066 | - }; | |
| 2067 | - } | |
| 2068 | - return this.parsePostfix(); | |
| 2069 | - } | |
| 2070 | - parsePostfix() { | |
| 2071 | - let expr = this.parseMember(); | |
| 2072 | - if (this.match("OPERATOR", "++", "--")) { | |
| 2073 | - const operator = this.previous().value; | |
| 2074 | - return { | |
| 2075 | - type: "UpdateExpression", | |
| 2076 | - operator, | |
| 2077 | - argument: expr, | |
| 2078 | - prefix: false | |
| 2079 | - }; | |
| 2080 | - } | |
| 2081 | - return expr; | |
| 2082 | - } | |
| 2083 | - parseMember() { | |
| 2084 | - let expr = this.parsePrimary(); | |
| 2085 | - while (true) { | |
| 2086 | - if (this.match("PUNCTUATION", ".")) { | |
| 2087 | - const property = this.consume("IDENTIFIER"); | |
| 2088 | - expr = { | |
| 2089 | - type: "MemberExpression", | |
| 2090 | - object: expr, | |
| 2091 | - property: { type: "Identifier", name: property.value }, | |
| 2092 | - computed: false | |
| 2093 | - }; | |
| 2094 | - } else if (this.match("PUNCTUATION", "[")) { | |
| 2095 | - const property = this.parseExpression(); | |
| 2096 | - this.consume("PUNCTUATION", "]"); | |
| 2097 | - expr = { | |
| 2098 | - type: "MemberExpression", | |
| 2099 | - object: expr, | |
| 2100 | - property, | |
| 2101 | - computed: true | |
| 2102 | - }; | |
| 2103 | - } else if (this.match("PUNCTUATION", "(")) { | |
| 2104 | - const args = this.parseArguments(); | |
| 2105 | - expr = { | |
| 2106 | - type: "CallExpression", | |
| 2107 | - callee: expr, | |
| 2108 | - arguments: args | |
| 2109 | - }; | |
| 2110 | - } else { | |
| 2111 | - break; | |
| 2112 | - } | |
| 2113 | - } | |
| 2114 | - return expr; | |
| 2115 | - } | |
| 2116 | - parseArguments() { | |
| 2117 | - const args = []; | |
| 2118 | - if (!this.check("PUNCTUATION", ")")) { | |
| 2119 | - do { | |
| 2120 | - args.push(this.parseExpression()); | |
| 2121 | - } while (this.match("PUNCTUATION", ",")); | |
| 2122 | - } | |
| 2123 | - this.consume("PUNCTUATION", ")"); | |
| 2124 | - return args; | |
| 2125 | - } | |
| 2126 | - parsePrimary() { | |
| 2127 | - if (this.match("NUMBER")) { | |
| 2128 | - return { type: "Literal", value: this.previous().value }; | |
| 2129 | - } | |
| 2130 | - if (this.match("STRING")) { | |
| 2131 | - return { type: "Literal", value: this.previous().value }; | |
| 2132 | - } | |
| 2133 | - if (this.match("BOOLEAN")) { | |
| 2134 | - return { type: "Literal", value: this.previous().value }; | |
| 2135 | - } | |
| 2136 | - if (this.match("NULL")) { | |
| 2137 | - return { type: "Literal", value: null }; | |
| 2138 | - } | |
| 2139 | - if (this.match("UNDEFINED")) { | |
| 2140 | - return { type: "Literal", value: void 0 }; | |
| 2141 | - } | |
| 2142 | - if (this.match("IDENTIFIER")) { | |
| 2143 | - return { type: "Identifier", name: this.previous().value }; | |
| 2144 | - } | |
| 2145 | - if (this.match("PUNCTUATION", "(")) { | |
| 2146 | - const expr = this.parseExpression(); | |
| 2147 | - this.consume("PUNCTUATION", ")"); | |
| 2148 | - return expr; | |
| 2149 | - } | |
| 2150 | - if (this.match("PUNCTUATION", "[")) { | |
| 2151 | - return this.parseArrayLiteral(); | |
| 2152 | - } | |
| 2153 | - if (this.match("PUNCTUATION", "{")) { | |
| 2154 | - return this.parseObjectLiteral(); | |
| 2155 | - } | |
| 2156 | - throw new Error(`Unexpected token: ${this.current().type} "${this.current().value}"`); | |
| 2157 | - } | |
| 2158 | - parseArrayLiteral() { | |
| 2159 | - const elements = []; | |
| 2160 | - while (!this.check("PUNCTUATION", "]") && !this.isAtEnd()) { | |
| 2161 | - elements.push(this.parseExpression()); | |
| 2162 | - if (this.match("PUNCTUATION", ",")) { | |
| 2163 | - if (this.check("PUNCTUATION", "]")) { | |
| 2164 | - break; | |
| 2165 | - } | |
| 2166 | - } else { | |
| 2167 | - break; | |
| 2168 | - } | |
| 2169 | - } | |
| 2170 | - this.consume("PUNCTUATION", "]"); | |
| 2171 | - return { | |
| 2172 | - type: "ArrayExpression", | |
| 2173 | - elements | |
| 2174 | - }; | |
| 2175 | - } | |
| 2176 | - parseObjectLiteral() { | |
| 2177 | - const properties = []; | |
| 2178 | - while (!this.check("PUNCTUATION", "}") && !this.isAtEnd()) { | |
| 2179 | - let key; | |
| 2180 | - let computed = false; | |
| 2181 | - if (this.match("STRING")) { | |
| 2182 | - key = { type: "Literal", value: this.previous().value }; | |
| 2183 | - } else if (this.match("IDENTIFIER")) { | |
| 2184 | - const name = this.previous().value; | |
| 2185 | - key = { type: "Identifier", name }; | |
| 2186 | - } else if (this.match("PUNCTUATION", "[")) { | |
| 2187 | - key = this.parseExpression(); | |
| 2188 | - computed = true; | |
| 2189 | - this.consume("PUNCTUATION", "]"); | |
| 2190 | - } else { | |
| 2191 | - throw new Error("Expected property key"); | |
| 2192 | - } | |
| 2193 | - this.consume("PUNCTUATION", ":"); | |
| 2194 | - const value = this.parseExpression(); | |
| 2195 | - properties.push({ | |
| 2196 | - type: "Property", | |
| 2197 | - key, | |
| 2198 | - value, | |
| 2199 | - computed, | |
| 2200 | - shorthand: false | |
| 2201 | - }); | |
| 2202 | - if (this.match("PUNCTUATION", ",")) { | |
| 2203 | - if (this.check("PUNCTUATION", "}")) { | |
| 2204 | - break; | |
| 2205 | - } | |
| 2206 | - } else { | |
| 2207 | - break; | |
| 2208 | - } | |
| 2209 | - } | |
| 2210 | - this.consume("PUNCTUATION", "}"); | |
| 2211 | - return { | |
| 2212 | - type: "ObjectExpression", | |
| 2213 | - properties | |
| 2214 | - }; | |
| 2215 | - } | |
| 2216 | - match(...args) { | |
| 2217 | - for (let i = 0; i < args.length; i++) { | |
| 2218 | - const arg = args[i]; | |
| 2219 | - if (i === 0 && args.length > 1) { | |
| 2220 | - const type = arg; | |
| 2221 | - for (let j = 1; j < args.length; j++) { | |
| 2222 | - if (this.check(type, args[j])) { | |
| 2223 | - this.advance(); | |
| 2224 | - return true; | |
| 2225 | - } | |
| 2226 | - } | |
| 2227 | - return false; | |
| 2228 | - } else if (args.length === 1) { | |
| 2229 | - if (this.checkType(arg)) { | |
| 2230 | - this.advance(); | |
| 2231 | - return true; | |
| 2232 | - } | |
| 2233 | - return false; | |
| 2234 | - } | |
| 2235 | - } | |
| 2236 | - return false; | |
| 2237 | - } | |
| 2238 | - check(type, value) { | |
| 2239 | - if (this.isAtEnd()) | |
| 2240 | - return false; | |
| 2241 | - if (value !== void 0) { | |
| 2242 | - return this.current().type === type && this.current().value === value; | |
| 2243 | - } | |
| 2244 | - return this.current().type === type; | |
| 2245 | - } | |
| 2246 | - checkType(type) { | |
| 2247 | - if (this.isAtEnd()) | |
| 2248 | - return false; | |
| 2249 | - return this.current().type === type; | |
| 2250 | - } | |
| 2251 | - advance() { | |
| 2252 | - if (!this.isAtEnd()) | |
| 2253 | - this.position++; | |
| 2254 | - return this.previous(); | |
| 2255 | - } | |
| 2256 | - isAtEnd() { | |
| 2257 | - return this.current().type === "EOF"; | |
| 2258 | - } | |
| 2259 | - current() { | |
| 2260 | - return this.tokens[this.position]; | |
| 2261 | - } | |
| 2262 | - previous() { | |
| 2263 | - return this.tokens[this.position - 1]; | |
| 2264 | - } | |
| 2265 | - consume(type, value) { | |
| 2266 | - if (value !== void 0) { | |
| 2267 | - if (this.check(type, value)) | |
| 2268 | - return this.advance(); | |
| 2269 | - throw new Error(`Expected ${type} "${value}" but got ${this.current().type} "${this.current().value}"`); | |
| 2270 | - } | |
| 2271 | - if (this.check(type)) | |
| 2272 | - return this.advance(); | |
| 2273 | - throw new Error(`Expected ${type} but got ${this.current().type} "${this.current().value}"`); | |
| 2274 | - } | |
| 2275 | -}; | |
| 2276 | -var Evaluator = class { | |
| 2277 | - evaluate({ node, scope: scope2 = {}, context = null, allowGlobal = false, forceBindingRootScopeToFunctions = true }) { | |
| 2278 | - switch (node.type) { | |
| 2279 | - case "Literal": | |
| 2280 | - return node.value; | |
| 2281 | - case "Identifier": | |
| 2282 | - if (node.name in scope2) { | |
| 2283 | - const value2 = scope2[node.name]; | |
| 2284 | - if (typeof value2 === "function") { | |
| 2285 | - return value2.bind(scope2); | |
| 2286 | - } | |
| 2287 | - return value2; | |
| 2288 | - } | |
| 2289 | - if (allowGlobal && typeof globalThis[node.name] !== "undefined") { | |
| 2290 | - const value2 = globalThis[node.name]; | |
| 2291 | - if (typeof value2 === "function") { | |
| 2292 | - return value2.bind(globalThis); | |
| 2293 | - } | |
| 2294 | - return value2; | |
| 2295 | - } | |
| 2296 | - throw new Error(`Undefined variable: ${node.name}`); | |
| 2297 | - case "MemberExpression": | |
| 2298 | - const object = this.evaluate({ node: node.object, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2299 | - if (object == null) { | |
| 2300 | - throw new Error("Cannot read property of null or undefined"); | |
| 2301 | - } | |
| 2302 | - let memberValue; | |
| 2303 | - if (node.computed) { | |
| 2304 | - const property = this.evaluate({ node: node.property, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2305 | - memberValue = object[property]; | |
| 2306 | - } else { | |
| 2307 | - memberValue = object[node.property.name]; | |
| 2308 | - } | |
| 2309 | - if (typeof memberValue === "function") { | |
| 2310 | - if (forceBindingRootScopeToFunctions) { | |
| 2311 | - return memberValue.bind(scope2); | |
| 2312 | - } else { | |
| 2313 | - return memberValue.bind(object); | |
| 2314 | - } | |
| 2315 | - } | |
| 2316 | - return memberValue; | |
| 2317 | - case "CallExpression": | |
| 2318 | - const args = node.arguments.map((arg) => this.evaluate({ node: arg, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions })); | |
| 2319 | - if (node.callee.type === "MemberExpression") { | |
| 2320 | - const obj = this.evaluate({ node: node.callee.object, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2321 | - let func; | |
| 2322 | - if (node.callee.computed) { | |
| 2323 | - const prop = this.evaluate({ node: node.callee.property, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2324 | - func = obj[prop]; | |
| 2325 | - } else { | |
| 2326 | - func = obj[node.callee.property.name]; | |
| 2327 | - } | |
| 2328 | - if (typeof func !== "function") { | |
| 2329 | - throw new Error("Value is not a function"); | |
| 2330 | - } | |
| 2331 | - return func.apply(obj, args); | |
| 2332 | - } else { | |
| 2333 | - if (node.callee.type === "Identifier") { | |
| 2334 | - const name = node.callee.name; | |
| 2335 | - let func; | |
| 2336 | - if (name in scope2) { | |
| 2337 | - func = scope2[name]; | |
| 2338 | - } else if (allowGlobal && typeof globalThis[name] !== "undefined") { | |
| 2339 | - func = globalThis[name]; | |
| 2340 | - } else { | |
| 2341 | - throw new Error(`Undefined variable: ${name}`); | |
| 2342 | - } | |
| 2343 | - if (typeof func !== "function") { | |
| 2344 | - throw new Error("Value is not a function"); | |
| 2345 | - } | |
| 2346 | - const thisContext = context !== null ? context : scope2; | |
| 2347 | - return func.apply(thisContext, args); | |
| 2348 | - } else { | |
| 2349 | - const callee = this.evaluate({ node: node.callee, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2350 | - if (typeof callee !== "function") { | |
| 2351 | - throw new Error("Value is not a function"); | |
| 2352 | - } | |
| 2353 | - return callee.apply(context, args); | |
| 2354 | - } | |
| 2355 | - } | |
| 2356 | - case "UnaryExpression": | |
| 2357 | - const argument = this.evaluate({ node: node.argument, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2358 | - switch (node.operator) { | |
| 2359 | - case "!": | |
| 2360 | - return !argument; | |
| 2361 | - case "-": | |
| 2362 | - return -argument; | |
| 2363 | - case "+": | |
| 2364 | - return +argument; | |
| 2365 | - default: | |
| 2366 | - throw new Error(`Unknown unary operator: ${node.operator}`); | |
| 2367 | - } | |
| 2368 | - case "UpdateExpression": | |
| 2369 | - if (node.argument.type === "Identifier") { | |
| 2370 | - const name = node.argument.name; | |
| 2371 | - if (!(name in scope2)) { | |
| 2372 | - throw new Error(`Undefined variable: ${name}`); | |
| 2373 | - } | |
| 2374 | - const oldValue = scope2[name]; | |
| 2375 | - if (node.operator === "++") { | |
| 2376 | - scope2[name] = oldValue + 1; | |
| 2377 | - } else if (node.operator === "--") { | |
| 2378 | - scope2[name] = oldValue - 1; | |
| 2379 | - } | |
| 2380 | - return node.prefix ? scope2[name] : oldValue; | |
| 2381 | - } else if (node.argument.type === "MemberExpression") { | |
| 2382 | - const obj = this.evaluate({ node: node.argument.object, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2383 | - const prop = node.argument.computed ? this.evaluate({ node: node.argument.property, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }) : node.argument.property.name; | |
| 2384 | - const oldValue = obj[prop]; | |
| 2385 | - if (node.operator === "++") { | |
| 2386 | - obj[prop] = oldValue + 1; | |
| 2387 | - } else if (node.operator === "--") { | |
| 2388 | - obj[prop] = oldValue - 1; | |
| 2389 | - } | |
| 2390 | - return node.prefix ? obj[prop] : oldValue; | |
| 2391 | - } | |
| 2392 | - throw new Error("Invalid update expression target"); | |
| 2393 | - case "BinaryExpression": | |
| 2394 | - const left = this.evaluate({ node: node.left, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2395 | - const right = this.evaluate({ node: node.right, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2396 | - switch (node.operator) { | |
| 2397 | - case "+": | |
| 2398 | - return left + right; | |
| 2399 | - case "-": | |
| 2400 | - return left - right; | |
| 2401 | - case "*": | |
| 2402 | - return left * right; | |
| 2403 | - case "/": | |
| 2404 | - return left / right; | |
| 2405 | - case "%": | |
| 2406 | - return left % right; | |
| 2407 | - case "==": | |
| 2408 | - return left == right; | |
| 2409 | - case "!=": | |
| 2410 | - return left != right; | |
| 2411 | - case "===": | |
| 2412 | - return left === right; | |
| 2413 | - case "!==": | |
| 2414 | - return left !== right; | |
| 2415 | - case "<": | |
| 2416 | - return left < right; | |
| 2417 | - case ">": | |
| 2418 | - return left > right; | |
| 2419 | - case "<=": | |
| 2420 | - return left <= right; | |
| 2421 | - case ">=": | |
| 2422 | - return left >= right; | |
| 2423 | - case "&&": | |
| 2424 | - return left && right; | |
| 2425 | - case "||": | |
| 2426 | - return left || right; | |
| 2427 | - default: | |
| 2428 | - throw new Error(`Unknown binary operator: ${node.operator}`); | |
| 2429 | - } | |
| 2430 | - case "ConditionalExpression": | |
| 2431 | - const test = this.evaluate({ node: node.test, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2432 | - return test ? this.evaluate({ node: node.consequent, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }) : this.evaluate({ node: node.alternate, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2433 | - case "AssignmentExpression": | |
| 2434 | - const value = this.evaluate({ node: node.right, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2435 | - if (node.left.type === "Identifier") { | |
| 2436 | - scope2[node.left.name] = value; | |
| 2437 | - return value; | |
| 2438 | - } else if (node.left.type === "MemberExpression") { | |
| 2439 | - const obj = this.evaluate({ node: node.left.object, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2440 | - if (node.left.computed) { | |
| 2441 | - const prop = this.evaluate({ node: node.left.property, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2442 | - obj[prop] = value; | |
| 2443 | - } else { | |
| 2444 | - obj[node.left.property.name] = value; | |
| 2445 | - } | |
| 2446 | - return value; | |
| 2447 | - } | |
| 2448 | - throw new Error("Invalid assignment target"); | |
| 2449 | - case "ArrayExpression": | |
| 2450 | - return node.elements.map((el) => this.evaluate({ node: el, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions })); | |
| 2451 | - case "ObjectExpression": | |
| 2452 | - const result = {}; | |
| 2453 | - for (const prop of node.properties) { | |
| 2454 | - const key = prop.computed ? this.evaluate({ node: prop.key, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }) : prop.key.type === "Identifier" ? prop.key.name : this.evaluate({ node: prop.key, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2455 | - const value2 = this.evaluate({ node: prop.value, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2456 | - result[key] = value2; | |
| 2457 | - } | |
| 2458 | - return result; | |
| 2459 | - default: | |
| 2460 | - throw new Error(`Unknown node type: ${node.type}`); | |
| 2461 | - } | |
| 2462 | - } | |
| 2463 | -}; | |
| 2464 | -function generateRuntimeFunction(expression) { | |
| 2465 | - try { | |
| 2466 | - const tokenizer = new Tokenizer(expression); | |
| 2467 | - const tokens = tokenizer.tokenize(); | |
| 2468 | - const parser = new Parser(tokens); | |
| 2469 | - const ast = parser.parse(); | |
| 2470 | - const evaluator = new Evaluator(); | |
| 2471 | - return function(options = {}) { | |
| 2472 | - const { scope: scope2 = {}, context = null, allowGlobal = false, forceBindingRootScopeToFunctions = false } = options; | |
| 2473 | - return evaluator.evaluate({ node: ast, scope: scope2, context, allowGlobal, forceBindingRootScopeToFunctions }); | |
| 2474 | - }; | |
| 2475 | - } catch (error2) { | |
| 2476 | - throw new Error(`CSP Parser Error: ${error2.message}`); | |
| 2477 | - } | |
| 2478 | -} | |
| 2479 | - | |
| 2480 | -// packages/csp/src/evaluator.js | |
| 2481 | -function cspEvaluator(el, expression) { | |
| 2482 | - let dataStack = generateDataStack(el); | |
| 2483 | - if (typeof expression === "function") { | |
| 2484 | - return generateEvaluatorFromFunction(dataStack, expression); | |
| 2485 | - } | |
| 2486 | - let evaluator = generateEvaluator(el, expression, dataStack); | |
| 2487 | - return tryCatch.bind(null, el, expression, evaluator); | |
| 2488 | -} | |
| 2489 | -function generateDataStack(el) { | |
| 2490 | - let overriddenMagics = {}; | |
| 2491 | - injectMagics(overriddenMagics, el); | |
| 2492 | - return [overriddenMagics, ...closestDataStack(el)]; | |
| 2493 | -} | |
| 2494 | -function generateEvaluator(el, expression, dataStack) { | |
| 2495 | - return (receiver = () => { | |
| 2496 | - }, { scope: scope2 = {}, params = [] } = {}) => { | |
| 2497 | - let completeScope = mergeProxies([scope2, ...dataStack]); | |
| 2498 | - let evaluate2 = generateRuntimeFunction(expression); | |
| 2499 | - let returnValue = evaluate2({ | |
| 2500 | - scope: completeScope, | |
| 2501 | - allowGlobal: true, | |
| 2502 | - forceBindingRootScopeToFunctions: true | |
| 2503 | - }); | |
| 2504 | - if (shouldAutoEvaluateFunctions && typeof returnValue === "function") { | |
| 2505 | - let nextReturnValue = returnValue.apply(returnValue, params); | |
| 2506 | - if (nextReturnValue instanceof Promise) { | |
| 2507 | - nextReturnValue.then((i) => receiver(i)); | |
| 2508 | - } else { | |
| 2509 | - receiver(nextReturnValue); | |
| 2510 | - } | |
| 2511 | - } else if (typeof returnValue === "object" && returnValue instanceof Promise) { | |
| 2512 | - returnValue.then((i) => receiver(i)); | |
| 2513 | - } else { | |
| 2514 | - receiver(returnValue); | |
| 2515 | - } | |
| 2516 | - }; | |
| 2517 | -} | |
| 2518 | - | |
| 2519 | -// node_modules/@vue/shared/dist/shared.esm-bundler.js | |
| 2520 | -function makeMap(str, expectsLowerCase) { | |
| 2521 | - const map = /* @__PURE__ */ Object.create(null); | |
| 2522 | - const list = str.split(","); | |
| 2523 | - for (let i = 0; i < list.length; i++) { | |
| 2524 | - map[list[i]] = true; | |
| 2525 | - } | |
| 2526 | - return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val]; | |
| 2527 | -} | |
| 2528 | -var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; | |
| 2529 | -var isBooleanAttr2 = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`); | |
| 2530 | -var EMPTY_OBJ = true ? Object.freeze({}) : 0; | |
| 2531 | -var EMPTY_ARR = true ? Object.freeze([]) : 0; | |
| 2532 | -var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| 2533 | -var hasOwn = (val, key) => hasOwnProperty.call(val, key); | |
| 2534 | -var isArray = Array.isArray; | |
| 2535 | -var isMap = (val) => toTypeString(val) === "[object Map]"; | |
| 2536 | -var isString = (val) => typeof val === "string"; | |
| 2537 | -var isSymbol = (val) => typeof val === "symbol"; | |
| 2538 | -var isObject = (val) => val !== null && typeof val === "object"; | |
| 2539 | -var objectToString = Object.prototype.toString; | |
| 2540 | -var toTypeString = (value) => objectToString.call(value); | |
| 2541 | -var toRawType = (value) => { | |
| 2542 | - return toTypeString(value).slice(8, -1); | |
| 2543 | -}; | |
| 2544 | -var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key; | |
| 2545 | -var cacheStringFunction = (fn) => { | |
| 2546 | - const cache = /* @__PURE__ */ Object.create(null); | |
| 2547 | - return (str) => { | |
| 2548 | - const hit = cache[str]; | |
| 2549 | - return hit || (cache[str] = fn(str)); | |
| 2550 | - }; | |
| 2551 | -}; | |
| 2552 | -var camelizeRE = /-(\w)/g; | |
| 2553 | -var camelize = cacheStringFunction((str) => { | |
| 2554 | - return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | |
| 2555 | -}); | |
| 2556 | -var hyphenateRE = /\B([A-Z])/g; | |
| 2557 | -var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); | |
| 2558 | -var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1)); | |
| 2559 | -var toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``); | |
| 2560 | -var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); | |
| 2561 | - | |
| 2562 | -// node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js | |
| 2563 | -var targetMap = /* @__PURE__ */ new WeakMap(); | |
| 2564 | -var effectStack = []; | |
| 2565 | -var activeEffect; | |
| 2566 | -var ITERATE_KEY = Symbol( true ? "iterate" : 0); | |
| 2567 | -var MAP_KEY_ITERATE_KEY = Symbol( true ? "Map key iterate" : 0); | |
| 2568 | -function isEffect(fn) { | |
| 2569 | - return fn && fn._isEffect === true; | |
| 2570 | -} | |
| 2571 | -function effect2(fn, options = EMPTY_OBJ) { | |
| 2572 | - if (isEffect(fn)) { | |
| 2573 | - fn = fn.raw; | |
| 2574 | - } | |
| 2575 | - const effect3 = createReactiveEffect(fn, options); | |
| 2576 | - if (!options.lazy) { | |
| 2577 | - effect3(); | |
| 2578 | - } | |
| 2579 | - return effect3; | |
| 2580 | -} | |
| 2581 | -function stop(effect3) { | |
| 2582 | - if (effect3.active) { | |
| 2583 | - cleanup(effect3); | |
| 2584 | - if (effect3.options.onStop) { | |
| 2585 | - effect3.options.onStop(); | |
| 2586 | - } | |
| 2587 | - effect3.active = false; | |
| 2588 | - } | |
| 2589 | -} | |
| 2590 | -var uid = 0; | |
| 2591 | -function createReactiveEffect(fn, options) { | |
| 2592 | - const effect3 = function reactiveEffect() { | |
| 2593 | - if (!effect3.active) { | |
| 2594 | - return fn(); | |
| 2595 | - } | |
| 2596 | - if (!effectStack.includes(effect3)) { | |
| 2597 | - cleanup(effect3); | |
| 2598 | - try { | |
| 2599 | - enableTracking(); | |
| 2600 | - effectStack.push(effect3); | |
| 2601 | - activeEffect = effect3; | |
| 2602 | - return fn(); | |
| 2603 | - } finally { | |
| 2604 | - effectStack.pop(); | |
| 2605 | - resetTracking(); | |
| 2606 | - activeEffect = effectStack[effectStack.length - 1]; | |
| 2607 | - } | |
| 2608 | - } | |
| 2609 | - }; | |
| 2610 | - effect3.id = uid++; | |
| 2611 | - effect3.allowRecurse = !!options.allowRecurse; | |
| 2612 | - effect3._isEffect = true; | |
| 2613 | - effect3.active = true; | |
| 2614 | - effect3.raw = fn; | |
| 2615 | - effect3.deps = []; | |
| 2616 | - effect3.options = options; | |
| 2617 | - return effect3; | |
| 2618 | -} | |
| 2619 | -function cleanup(effect3) { | |
| 2620 | - const { deps } = effect3; | |
| 2621 | - if (deps.length) { | |
| 2622 | - for (let i = 0; i < deps.length; i++) { | |
| 2623 | - deps[i].delete(effect3); | |
| 2624 | - } | |
| 2625 | - deps.length = 0; | |
| 2626 | - } | |
| 2627 | -} | |
| 2628 | -var shouldTrack = true; | |
| 2629 | -var trackStack = []; | |
| 2630 | -function pauseTracking() { | |
| 2631 | - trackStack.push(shouldTrack); | |
| 2632 | - shouldTrack = false; | |
| 2633 | -} | |
| 2634 | -function enableTracking() { | |
| 2635 | - trackStack.push(shouldTrack); | |
| 2636 | - shouldTrack = true; | |
| 2637 | -} | |
| 2638 | -function resetTracking() { | |
| 2639 | - const last = trackStack.pop(); | |
| 2640 | - shouldTrack = last === void 0 ? true : last; | |
| 2641 | -} | |
| 2642 | -function track(target, type, key) { | |
| 2643 | - if (!shouldTrack || activeEffect === void 0) { | |
| 2644 | - return; | |
| 2645 | - } | |
| 2646 | - let depsMap = targetMap.get(target); | |
| 2647 | - if (!depsMap) { | |
| 2648 | - targetMap.set(target, depsMap = /* @__PURE__ */ new Map()); | |
| 2649 | - } | |
| 2650 | - let dep = depsMap.get(key); | |
| 2651 | - if (!dep) { | |
| 2652 | - depsMap.set(key, dep = /* @__PURE__ */ new Set()); | |
| 2653 | - } | |
| 2654 | - if (!dep.has(activeEffect)) { | |
| 2655 | - dep.add(activeEffect); | |
| 2656 | - activeEffect.deps.push(dep); | |
| 2657 | - if (activeEffect.options.onTrack) { | |
| 2658 | - activeEffect.options.onTrack({ | |
| 2659 | - effect: activeEffect, | |
| 2660 | - target, | |
| 2661 | - type, | |
| 2662 | - key | |
| 2663 | - }); | |
| 2664 | - } | |
| 2665 | - } | |
| 2666 | -} | |
| 2667 | -function trigger(target, type, key, newValue, oldValue, oldTarget) { | |
| 2668 | - const depsMap = targetMap.get(target); | |
| 2669 | - if (!depsMap) { | |
| 2670 | - return; | |
| 2671 | - } | |
| 2672 | - const effects = /* @__PURE__ */ new Set(); | |
| 2673 | - const add2 = (effectsToAdd) => { | |
| 2674 | - if (effectsToAdd) { | |
| 2675 | - effectsToAdd.forEach((effect3) => { | |
| 2676 | - if (effect3 !== activeEffect || effect3.allowRecurse) { | |
| 2677 | - effects.add(effect3); | |
| 2678 | - } | |
| 2679 | - }); | |
| 2680 | - } | |
| 2681 | - }; | |
| 2682 | - if (type === "clear") { | |
| 2683 | - depsMap.forEach(add2); | |
| 2684 | - } else if (key === "length" && isArray(target)) { | |
| 2685 | - depsMap.forEach((dep, key2) => { | |
| 2686 | - if (key2 === "length" || key2 >= newValue) { | |
| 2687 | - add2(dep); | |
| 2688 | - } | |
| 2689 | - }); | |
| 2690 | - } else { | |
| 2691 | - if (key !== void 0) { | |
| 2692 | - add2(depsMap.get(key)); | |
| 2693 | - } | |
| 2694 | - switch (type) { | |
| 2695 | - case "add": | |
| 2696 | - if (!isArray(target)) { | |
| 2697 | - add2(depsMap.get(ITERATE_KEY)); | |
| 2698 | - if (isMap(target)) { | |
| 2699 | - add2(depsMap.get(MAP_KEY_ITERATE_KEY)); | |
| 2700 | - } | |
| 2701 | - } else if (isIntegerKey(key)) { | |
| 2702 | - add2(depsMap.get("length")); | |
| 2703 | - } | |
| 2704 | - break; | |
| 2705 | - case "delete": | |
| 2706 | - if (!isArray(target)) { | |
| 2707 | - add2(depsMap.get(ITERATE_KEY)); | |
| 2708 | - if (isMap(target)) { | |
| 2709 | - add2(depsMap.get(MAP_KEY_ITERATE_KEY)); | |
| 2710 | - } | |
| 2711 | - } | |
| 2712 | - break; | |
| 2713 | - case "set": | |
| 2714 | - if (isMap(target)) { | |
| 2715 | - add2(depsMap.get(ITERATE_KEY)); | |
| 2716 | - } | |
| 2717 | - break; | |
| 2718 | - } | |
| 2719 | - } | |
| 2720 | - const run = (effect3) => { | |
| 2721 | - if (effect3.options.onTrigger) { | |
| 2722 | - effect3.options.onTrigger({ | |
| 2723 | - effect: effect3, | |
| 2724 | - target, | |
| 2725 | - key, | |
| 2726 | - type, | |
| 2727 | - newValue, | |
| 2728 | - oldValue, | |
| 2729 | - oldTarget | |
| 2730 | - }); | |
| 2731 | - } | |
| 2732 | - if (effect3.options.scheduler) { | |
| 2733 | - effect3.options.scheduler(effect3); | |
| 2734 | - } else { | |
| 2735 | - effect3(); | |
| 2736 | - } | |
| 2737 | - }; | |
| 2738 | - effects.forEach(run); | |
| 2739 | -} | |
| 2740 | -var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); | |
| 2741 | -var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol)); | |
| 2742 | -var get2 = /* @__PURE__ */ createGetter(); | |
| 2743 | -var readonlyGet = /* @__PURE__ */ createGetter(true); | |
| 2744 | -var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | |
| 2745 | -function createArrayInstrumentations() { | |
| 2746 | - const instrumentations = {}; | |
| 2747 | - ["includes", "indexOf", "lastIndexOf"].forEach((key) => { | |
| 2748 | - instrumentations[key] = function(...args) { | |
| 2749 | - const arr = toRaw(this); | |
| 2750 | - for (let i = 0, l = this.length; i < l; i++) { | |
| 2751 | - track(arr, "get", i + ""); | |
| 2752 | - } | |
| 2753 | - const res = arr[key](...args); | |
| 2754 | - if (res === -1 || res === false) { | |
| 2755 | - return arr[key](...args.map(toRaw)); | |
| 2756 | - } else { | |
| 2757 | - return res; | |
| 2758 | - } | |
| 2759 | - }; | |
| 2760 | - }); | |
| 2761 | - ["push", "pop", "shift", "unshift", "splice"].forEach((key) => { | |
| 2762 | - instrumentations[key] = function(...args) { | |
| 2763 | - pauseTracking(); | |
| 2764 | - const res = toRaw(this)[key].apply(this, args); | |
| 2765 | - resetTracking(); | |
| 2766 | - return res; | |
| 2767 | - }; | |
| 2768 | - }); | |
| 2769 | - return instrumentations; | |
| 2770 | -} | |
| 2771 | -function createGetter(isReadonly = false, shallow = false) { | |
| 2772 | - return function get3(target, key, receiver) { | |
| 2773 | - if (key === "__v_isReactive") { | |
| 2774 | - return !isReadonly; | |
| 2775 | - } else if (key === "__v_isReadonly") { | |
| 2776 | - return isReadonly; | |
| 2777 | - } else if (key === "__v_raw" && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { | |
| 2778 | - return target; | |
| 2779 | - } | |
| 2780 | - const targetIsArray = isArray(target); | |
| 2781 | - if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) { | |
| 2782 | - return Reflect.get(arrayInstrumentations, key, receiver); | |
| 2783 | - } | |
| 2784 | - const res = Reflect.get(target, key, receiver); | |
| 2785 | - if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { | |
| 2786 | - return res; | |
| 2787 | - } | |
| 2788 | - if (!isReadonly) { | |
| 2789 | - track(target, "get", key); | |
| 2790 | - } | |
| 2791 | - if (shallow) { | |
| 2792 | - return res; | |
| 2793 | - } | |
| 2794 | - if (isRef(res)) { | |
| 2795 | - const shouldUnwrap = !targetIsArray || !isIntegerKey(key); | |
| 2796 | - return shouldUnwrap ? res.value : res; | |
| 2797 | - } | |
| 2798 | - if (isObject(res)) { | |
| 2799 | - return isReadonly ? readonly(res) : reactive2(res); | |
| 2800 | - } | |
| 2801 | - return res; | |
| 2802 | - }; | |
| 2803 | -} | |
| 2804 | -var set2 = /* @__PURE__ */ createSetter(); | |
| 2805 | -function createSetter(shallow = false) { | |
| 2806 | - return function set3(target, key, value, receiver) { | |
| 2807 | - let oldValue = target[key]; | |
| 2808 | - if (!shallow) { | |
| 2809 | - value = toRaw(value); | |
| 2810 | - oldValue = toRaw(oldValue); | |
| 2811 | - if (!isArray(target) && isRef(oldValue) && !isRef(value)) { | |
| 2812 | - oldValue.value = value; | |
| 2813 | - return true; | |
| 2814 | - } | |
| 2815 | - } | |
| 2816 | - const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); | |
| 2817 | - const result = Reflect.set(target, key, value, receiver); | |
| 2818 | - if (target === toRaw(receiver)) { | |
| 2819 | - if (!hadKey) { | |
| 2820 | - trigger(target, "add", key, value); | |
| 2821 | - } else if (hasChanged(value, oldValue)) { | |
| 2822 | - trigger(target, "set", key, value, oldValue); | |
| 2823 | - } | |
| 2824 | - } | |
| 2825 | - return result; | |
| 2826 | - }; | |
| 2827 | -} | |
| 2828 | -function deleteProperty(target, key) { | |
| 2829 | - const hadKey = hasOwn(target, key); | |
| 2830 | - const oldValue = target[key]; | |
| 2831 | - const result = Reflect.deleteProperty(target, key); | |
| 2832 | - if (result && hadKey) { | |
| 2833 | - trigger(target, "delete", key, void 0, oldValue); | |
| 2834 | - } | |
| 2835 | - return result; | |
| 2836 | -} | |
| 2837 | -function has(target, key) { | |
| 2838 | - const result = Reflect.has(target, key); | |
| 2839 | - if (!isSymbol(key) || !builtInSymbols.has(key)) { | |
| 2840 | - track(target, "has", key); | |
| 2841 | - } | |
| 2842 | - return result; | |
| 2843 | -} | |
| 2844 | -function ownKeys(target) { | |
| 2845 | - track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); | |
| 2846 | - return Reflect.ownKeys(target); | |
| 2847 | -} | |
| 2848 | -var mutableHandlers = { | |
| 2849 | - get: get2, | |
| 2850 | - set: set2, | |
| 2851 | - deleteProperty, | |
| 2852 | - has, | |
| 2853 | - ownKeys | |
| 2854 | -}; | |
| 2855 | -var readonlyHandlers = { | |
| 2856 | - get: readonlyGet, | |
| 2857 | - set(target, key) { | |
| 2858 | - if (true) { | |
| 2859 | - console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target); | |
| 2860 | - } | |
| 2861 | - return true; | |
| 2862 | - }, | |
| 2863 | - deleteProperty(target, key) { | |
| 2864 | - if (true) { | |
| 2865 | - console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); | |
| 2866 | - } | |
| 2867 | - return true; | |
| 2868 | - } | |
| 2869 | -}; | |
| 2870 | -var toReactive = (value) => isObject(value) ? reactive2(value) : value; | |
| 2871 | -var toReadonly = (value) => isObject(value) ? readonly(value) : value; | |
| 2872 | -var toShallow = (value) => value; | |
| 2873 | -var getProto = (v) => Reflect.getPrototypeOf(v); | |
| 2874 | -function get$1(target, key, isReadonly = false, isShallow = false) { | |
| 2875 | - target = target[ | |
| 2876 | - "__v_raw" | |
| 2877 | - /* RAW */ | |
| 2878 | - ]; | |
| 2879 | - const rawTarget = toRaw(target); | |
| 2880 | - const rawKey = toRaw(key); | |
| 2881 | - if (key !== rawKey) { | |
| 2882 | - !isReadonly && track(rawTarget, "get", key); | |
| 2883 | - } | |
| 2884 | - !isReadonly && track(rawTarget, "get", rawKey); | |
| 2885 | - const { has: has2 } = getProto(rawTarget); | |
| 2886 | - const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | |
| 2887 | - if (has2.call(rawTarget, key)) { | |
| 2888 | - return wrap(target.get(key)); | |
| 2889 | - } else if (has2.call(rawTarget, rawKey)) { | |
| 2890 | - return wrap(target.get(rawKey)); | |
| 2891 | - } else if (target !== rawTarget) { | |
| 2892 | - target.get(key); | |
| 2893 | - } | |
| 2894 | -} | |
| 2895 | -function has$1(key, isReadonly = false) { | |
| 2896 | - const target = this[ | |
| 2897 | - "__v_raw" | |
| 2898 | - /* RAW */ | |
| 2899 | - ]; | |
| 2900 | - const rawTarget = toRaw(target); | |
| 2901 | - const rawKey = toRaw(key); | |
| 2902 | - if (key !== rawKey) { | |
| 2903 | - !isReadonly && track(rawTarget, "has", key); | |
| 2904 | - } | |
| 2905 | - !isReadonly && track(rawTarget, "has", rawKey); | |
| 2906 | - return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); | |
| 2907 | -} | |
| 2908 | -function size(target, isReadonly = false) { | |
| 2909 | - target = target[ | |
| 2910 | - "__v_raw" | |
| 2911 | - /* RAW */ | |
| 2912 | - ]; | |
| 2913 | - !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY); | |
| 2914 | - return Reflect.get(target, "size", target); | |
| 2915 | -} | |
| 2916 | -function add(value) { | |
| 2917 | - value = toRaw(value); | |
| 2918 | - const target = toRaw(this); | |
| 2919 | - const proto = getProto(target); | |
| 2920 | - const hadKey = proto.has.call(target, value); | |
| 2921 | - if (!hadKey) { | |
| 2922 | - target.add(value); | |
| 2923 | - trigger(target, "add", value, value); | |
| 2924 | - } | |
| 2925 | - return this; | |
| 2926 | -} | |
| 2927 | -function set$1(key, value) { | |
| 2928 | - value = toRaw(value); | |
| 2929 | - const target = toRaw(this); | |
| 2930 | - const { has: has2, get: get3 } = getProto(target); | |
| 2931 | - let hadKey = has2.call(target, key); | |
| 2932 | - if (!hadKey) { | |
| 2933 | - key = toRaw(key); | |
| 2934 | - hadKey = has2.call(target, key); | |
| 2935 | - } else if (true) { | |
| 2936 | - checkIdentityKeys(target, has2, key); | |
| 2937 | - } | |
| 2938 | - const oldValue = get3.call(target, key); | |
| 2939 | - target.set(key, value); | |
| 2940 | - if (!hadKey) { | |
| 2941 | - trigger(target, "add", key, value); | |
| 2942 | - } else if (hasChanged(value, oldValue)) { | |
| 2943 | - trigger(target, "set", key, value, oldValue); | |
| 2944 | - } | |
| 2945 | - return this; | |
| 2946 | -} | |
| 2947 | -function deleteEntry(key) { | |
| 2948 | - const target = toRaw(this); | |
| 2949 | - const { has: has2, get: get3 } = getProto(target); | |
| 2950 | - let hadKey = has2.call(target, key); | |
| 2951 | - if (!hadKey) { | |
| 2952 | - key = toRaw(key); | |
| 2953 | - hadKey = has2.call(target, key); | |
| 2954 | - } else if (true) { | |
| 2955 | - checkIdentityKeys(target, has2, key); | |
| 2956 | - } | |
| 2957 | - const oldValue = get3 ? get3.call(target, key) : void 0; | |
| 2958 | - const result = target.delete(key); | |
| 2959 | - if (hadKey) { | |
| 2960 | - trigger(target, "delete", key, void 0, oldValue); | |
| 2961 | - } | |
| 2962 | - return result; | |
| 2963 | -} | |
| 2964 | -function clear() { | |
| 2965 | - const target = toRaw(this); | |
| 2966 | - const hadItems = target.size !== 0; | |
| 2967 | - const oldTarget = true ? isMap(target) ? new Map(target) : new Set(target) : 0; | |
| 2968 | - const result = target.clear(); | |
| 2969 | - if (hadItems) { | |
| 2970 | - trigger(target, "clear", void 0, void 0, oldTarget); | |
| 2971 | - } | |
| 2972 | - return result; | |
| 2973 | -} | |
| 2974 | -function createForEach(isReadonly, isShallow) { | |
| 2975 | - return function forEach(callback, thisArg) { | |
| 2976 | - const observed = this; | |
| 2977 | - const target = observed[ | |
| 2978 | - "__v_raw" | |
| 2979 | - /* RAW */ | |
| 2980 | - ]; | |
| 2981 | - const rawTarget = toRaw(target); | |
| 2982 | - const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | |
| 2983 | - !isReadonly && track(rawTarget, "iterate", ITERATE_KEY); | |
| 2984 | - return target.forEach((value, key) => { | |
| 2985 | - return callback.call(thisArg, wrap(value), wrap(key), observed); | |
| 2986 | - }); | |
| 2987 | - }; | |
| 2988 | -} | |
| 2989 | -function createIterableMethod(method, isReadonly, isShallow) { | |
| 2990 | - return function(...args) { | |
| 2991 | - const target = this[ | |
| 2992 | - "__v_raw" | |
| 2993 | - /* RAW */ | |
| 2994 | - ]; | |
| 2995 | - const rawTarget = toRaw(target); | |
| 2996 | - const targetIsMap = isMap(rawTarget); | |
| 2997 | - const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; | |
| 2998 | - const isKeyOnly = method === "keys" && targetIsMap; | |
| 2999 | - const innerIterator = target[method](...args); | |
| 3000 | - const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | |
| 3001 | - !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | |
| 3002 | - return { | |
| 3003 | - // iterator protocol | |
| 3004 | - next() { | |
| 3005 | - const { value, done } = innerIterator.next(); | |
| 3006 | - return done ? { value, done } : { | |
| 3007 | - value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), | |
| 3008 | - done | |
| 3009 | - }; | |
| 3010 | - }, | |
| 3011 | - // iterable protocol | |
| 3012 | - [Symbol.iterator]() { | |
| 3013 | - return this; | |
| 3014 | - } | |
| 3015 | - }; | |
| 3016 | - }; | |
| 3017 | -} | |
| 3018 | -function createReadonlyMethod(type) { | |
| 3019 | - return function(...args) { | |
| 3020 | - if (true) { | |
| 3021 | - const key = args[0] ? `on key "${args[0]}" ` : ``; | |
| 3022 | - console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); | |
| 3023 | - } | |
| 3024 | - return type === "delete" ? false : this; | |
| 3025 | - }; | |
| 3026 | -} | |
| 3027 | -function createInstrumentations() { | |
| 3028 | - const mutableInstrumentations2 = { | |
| 3029 | - get(key) { | |
| 3030 | - return get$1(this, key); | |
| 3031 | - }, | |
| 3032 | - get size() { | |
| 3033 | - return size(this); | |
| 3034 | - }, | |
| 3035 | - has: has$1, | |
| 3036 | - add, | |
| 3037 | - set: set$1, | |
| 3038 | - delete: deleteEntry, | |
| 3039 | - clear, | |
| 3040 | - forEach: createForEach(false, false) | |
| 3041 | - }; | |
| 3042 | - const shallowInstrumentations2 = { | |
| 3043 | - get(key) { | |
| 3044 | - return get$1(this, key, false, true); | |
| 3045 | - }, | |
| 3046 | - get size() { | |
| 3047 | - return size(this); | |
| 3048 | - }, | |
| 3049 | - has: has$1, | |
| 3050 | - add, | |
| 3051 | - set: set$1, | |
| 3052 | - delete: deleteEntry, | |
| 3053 | - clear, | |
| 3054 | - forEach: createForEach(false, true) | |
| 3055 | - }; | |
| 3056 | - const readonlyInstrumentations2 = { | |
| 3057 | - get(key) { | |
| 3058 | - return get$1(this, key, true); | |
| 3059 | - }, | |
| 3060 | - get size() { | |
| 3061 | - return size(this, true); | |
| 3062 | - }, | |
| 3063 | - has(key) { | |
| 3064 | - return has$1.call(this, key, true); | |
| 3065 | - }, | |
| 3066 | - add: createReadonlyMethod( | |
| 3067 | - "add" | |
| 3068 | - /* ADD */ | |
| 3069 | - ), | |
| 3070 | - set: createReadonlyMethod( | |
| 3071 | - "set" | |
| 3072 | - /* SET */ | |
| 3073 | - ), | |
| 3074 | - delete: createReadonlyMethod( | |
| 3075 | - "delete" | |
| 3076 | - /* DELETE */ | |
| 3077 | - ), | |
| 3078 | - clear: createReadonlyMethod( | |
| 3079 | - "clear" | |
| 3080 | - /* CLEAR */ | |
| 3081 | - ), | |
| 3082 | - forEach: createForEach(true, false) | |
| 3083 | - }; | |
| 3084 | - const shallowReadonlyInstrumentations2 = { | |
| 3085 | - get(key) { | |
| 3086 | - return get$1(this, key, true, true); | |
| 3087 | - }, | |
| 3088 | - get size() { | |
| 3089 | - return size(this, true); | |
| 3090 | - }, | |
| 3091 | - has(key) { | |
| 3092 | - return has$1.call(this, key, true); | |
| 3093 | - }, | |
| 3094 | - add: createReadonlyMethod( | |
| 3095 | - "add" | |
| 3096 | - /* ADD */ | |
| 3097 | - ), | |
| 3098 | - set: createReadonlyMethod( | |
| 3099 | - "set" | |
| 3100 | - /* SET */ | |
| 3101 | - ), | |
| 3102 | - delete: createReadonlyMethod( | |
| 3103 | - "delete" | |
| 3104 | - /* DELETE */ | |
| 3105 | - ), | |
| 3106 | - clear: createReadonlyMethod( | |
| 3107 | - "clear" | |
| 3108 | - /* CLEAR */ | |
| 3109 | - ), | |
| 3110 | - forEach: createForEach(true, true) | |
| 3111 | - }; | |
| 3112 | - const iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; | |
| 3113 | - iteratorMethods.forEach((method) => { | |
| 3114 | - mutableInstrumentations2[method] = createIterableMethod(method, false, false); | |
| 3115 | - readonlyInstrumentations2[method] = createIterableMethod(method, true, false); | |
| 3116 | - shallowInstrumentations2[method] = createIterableMethod(method, false, true); | |
| 3117 | - shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true); | |
| 3118 | - }); | |
| 3119 | - return [ | |
| 3120 | - mutableInstrumentations2, | |
| 3121 | - readonlyInstrumentations2, | |
| 3122 | - shallowInstrumentations2, | |
| 3123 | - shallowReadonlyInstrumentations2 | |
| 3124 | - ]; | |
| 3125 | -} | |
| 3126 | -var [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations(); | |
| 3127 | -function createInstrumentationGetter(isReadonly, shallow) { | |
| 3128 | - const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; | |
| 3129 | - return (target, key, receiver) => { | |
| 3130 | - if (key === "__v_isReactive") { | |
| 3131 | - return !isReadonly; | |
| 3132 | - } else if (key === "__v_isReadonly") { | |
| 3133 | - return isReadonly; | |
| 3134 | - } else if (key === "__v_raw") { | |
| 3135 | - return target; | |
| 3136 | - } | |
| 3137 | - return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); | |
| 3138 | - }; | |
| 3139 | -} | |
| 3140 | -var mutableCollectionHandlers = { | |
| 3141 | - get: /* @__PURE__ */ createInstrumentationGetter(false, false) | |
| 3142 | -}; | |
| 3143 | -var readonlyCollectionHandlers = { | |
| 3144 | - get: /* @__PURE__ */ createInstrumentationGetter(true, false) | |
| 3145 | -}; | |
| 3146 | -function checkIdentityKeys(target, has2, key) { | |
| 3147 | - const rawKey = toRaw(key); | |
| 3148 | - if (rawKey !== key && has2.call(target, rawKey)) { | |
| 3149 | - const type = toRawType(target); | |
| 3150 | - console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`); | |
| 3151 | - } | |
| 3152 | -} | |
| 3153 | -var reactiveMap = /* @__PURE__ */ new WeakMap(); | |
| 3154 | -var shallowReactiveMap = /* @__PURE__ */ new WeakMap(); | |
| 3155 | -var readonlyMap = /* @__PURE__ */ new WeakMap(); | |
| 3156 | -var shallowReadonlyMap = /* @__PURE__ */ new WeakMap(); | |
| 3157 | -function targetTypeMap(rawType) { | |
| 3158 | - switch (rawType) { | |
| 3159 | - case "Object": | |
| 3160 | - case "Array": | |
| 3161 | - return 1; | |
| 3162 | - case "Map": | |
| 3163 | - case "Set": | |
| 3164 | - case "WeakMap": | |
| 3165 | - case "WeakSet": | |
| 3166 | - return 2; | |
| 3167 | - default: | |
| 3168 | - return 0; | |
| 3169 | - } | |
| 3170 | -} | |
| 3171 | -function getTargetType(value) { | |
| 3172 | - return value[ | |
| 3173 | - "__v_skip" | |
| 3174 | - /* SKIP */ | |
| 3175 | - ] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value)); | |
| 3176 | -} | |
| 3177 | -function reactive2(target) { | |
| 3178 | - if (target && target[ | |
| 3179 | - "__v_isReadonly" | |
| 3180 | - /* IS_READONLY */ | |
| 3181 | - ]) { | |
| 3182 | - return target; | |
| 3183 | - } | |
| 3184 | - return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | |
| 3185 | -} | |
| 3186 | -function readonly(target) { | |
| 3187 | - return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | |
| 3188 | -} | |
| 3189 | -function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | |
| 3190 | - if (!isObject(target)) { | |
| 3191 | - if (true) { | |
| 3192 | - console.warn(`value cannot be made reactive: ${String(target)}`); | |
| 3193 | - } | |
| 3194 | - return target; | |
| 3195 | - } | |
| 3196 | - if (target[ | |
| 3197 | - "__v_raw" | |
| 3198 | - /* RAW */ | |
| 3199 | - ] && !(isReadonly && target[ | |
| 3200 | - "__v_isReactive" | |
| 3201 | - /* IS_REACTIVE */ | |
| 3202 | - ])) { | |
| 3203 | - return target; | |
| 3204 | - } | |
| 3205 | - const existingProxy = proxyMap.get(target); | |
| 3206 | - if (existingProxy) { | |
| 3207 | - return existingProxy; | |
| 3208 | - } | |
| 3209 | - const targetType = getTargetType(target); | |
| 3210 | - if (targetType === 0) { | |
| 3211 | - return target; | |
| 3212 | - } | |
| 3213 | - const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); | |
| 3214 | - proxyMap.set(target, proxy); | |
| 3215 | - return proxy; | |
| 3216 | -} | |
| 3217 | -function toRaw(observed) { | |
| 3218 | - return observed && toRaw(observed[ | |
| 3219 | - "__v_raw" | |
| 3220 | - /* RAW */ | |
| 3221 | - ]) || observed; | |
| 3222 | -} | |
| 3223 | -function isRef(r) { | |
| 3224 | - return Boolean(r && r.__v_isRef === true); | |
| 3225 | -} | |
| 3226 | - | |
| 3227 | -// packages/alpinejs/src/magics/$nextTick.js | |
| 3228 | -magic("nextTick", () => nextTick); | |
| 3229 | - | |
| 3230 | -// packages/alpinejs/src/magics/$dispatch.js | |
| 3231 | -magic("dispatch", (el) => dispatch.bind(dispatch, el)); | |
| 3232 | - | |
| 3233 | -// packages/alpinejs/src/magics/$watch.js | |
| 3234 | -magic("watch", (el, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => (key, callback) => { | |
| 3235 | - let evaluate2 = evaluateLater2(key); | |
| 3236 | - let getter = () => { | |
| 3237 | - let value; | |
| 3238 | - evaluate2((i) => value = i); | |
| 3239 | - return value; | |
| 3240 | - }; | |
| 3241 | - let unwatch = watch(getter, callback); | |
| 3242 | - cleanup2(unwatch); | |
| 3243 | -}); | |
| 3244 | - | |
| 3245 | -// packages/alpinejs/src/magics/$store.js | |
| 3246 | -magic("store", getStores); | |
| 3247 | - | |
| 3248 | -// packages/alpinejs/src/magics/$data.js | |
| 3249 | -magic("data", (el) => scope(el)); | |
| 3250 | - | |
| 3251 | -// packages/alpinejs/src/magics/$root.js | |
| 3252 | -magic("root", (el) => closestRoot(el)); | |
| 3253 | - | |
| 3254 | -// packages/alpinejs/src/magics/$refs.js | |
| 3255 | -magic("refs", (el) => { | |
| 3256 | - if (el._x_refs_proxy) | |
| 3257 | - return el._x_refs_proxy; | |
| 3258 | - el._x_refs_proxy = mergeProxies(getArrayOfRefObject(el)); | |
| 3259 | - return el._x_refs_proxy; | |
| 3260 | -}); | |
| 3261 | -function getArrayOfRefObject(el) { | |
| 3262 | - let refObjects = []; | |
| 3263 | - findClosest(el, (i) => { | |
| 3264 | - if (i._x_refs) | |
| 3265 | - refObjects.push(i._x_refs); | |
| 3266 | - }); | |
| 3267 | - return refObjects; | |
| 3268 | -} | |
| 3269 | - | |
| 3270 | -// packages/alpinejs/src/ids.js | |
| 3271 | -var globalIdMemo = {}; | |
| 3272 | -function findAndIncrementId(name) { | |
| 3273 | - if (!globalIdMemo[name]) | |
| 3274 | - globalIdMemo[name] = 0; | |
| 3275 | - return ++globalIdMemo[name]; | |
| 3276 | -} | |
| 3277 | -function closestIdRoot(el, name) { | |
| 3278 | - return findClosest(el, (element) => { | |
| 3279 | - if (element._x_ids && element._x_ids[name]) | |
| 3280 | - return true; | |
| 3281 | - }); | |
| 3282 | -} | |
| 3283 | -function setIdRoot(el, name) { | |
| 3284 | - if (!el._x_ids) | |
| 3285 | - el._x_ids = {}; | |
| 3286 | - if (!el._x_ids[name]) | |
| 3287 | - el._x_ids[name] = findAndIncrementId(name); | |
| 3288 | -} | |
| 3289 | - | |
| 3290 | -// packages/alpinejs/src/magics/$id.js | |
| 3291 | -magic("id", (el, { cleanup: cleanup2 }) => (name, key = null) => { | |
| 3292 | - let cacheKey = `${name}${key ? `-${key}` : ""}`; | |
| 3293 | - return cacheIdByNameOnElement(el, cacheKey, cleanup2, () => { | |
| 3294 | - let root = closestIdRoot(el, name); | |
| 3295 | - let id = root ? root._x_ids[name] : findAndIncrementId(name); | |
| 3296 | - return key ? `${name}-${id}-${key}` : `${name}-${id}`; | |
| 3297 | - }); | |
| 3298 | -}); | |
| 3299 | -interceptClone((from, to) => { | |
| 3300 | - if (from._x_id) { | |
| 3301 | - to._x_id = from._x_id; | |
| 3302 | - } | |
| 3303 | -}); | |
| 3304 | -function cacheIdByNameOnElement(el, cacheKey, cleanup2, callback) { | |
| 3305 | - if (!el._x_id) | |
| 3306 | - el._x_id = {}; | |
| 3307 | - if (el._x_id[cacheKey]) | |
| 3308 | - return el._x_id[cacheKey]; | |
| 3309 | - let output = callback(); | |
| 3310 | - el._x_id[cacheKey] = output; | |
| 3311 | - cleanup2(() => { | |
| 3312 | - delete el._x_id[cacheKey]; | |
| 3313 | - }); | |
| 3314 | - return output; | |
| 3315 | -} | |
| 3316 | - | |
| 3317 | -// packages/alpinejs/src/magics/$el.js | |
| 3318 | -magic("el", (el) => el); | |
| 3319 | - | |
| 3320 | -// packages/alpinejs/src/magics/index.js | |
| 3321 | -warnMissingPluginMagic("Focus", "focus", "focus"); | |
| 3322 | -warnMissingPluginMagic("Persist", "persist", "persist"); | |
| 3323 | -function warnMissingPluginMagic(name, magicName, slug) { | |
| 3324 | - magic(magicName, (el) => warn(`You can't use [$${magicName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); | |
| 3325 | -} | |
| 3326 | - | |
| 3327 | -// packages/alpinejs/src/directives/x-modelable.js | |
| 3328 | -directive("modelable", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { | |
| 3329 | - let func = evaluateLater2(expression); | |
| 3330 | - let innerGet = () => { | |
| 3331 | - let result; | |
| 3332 | - func((i) => result = i); | |
| 3333 | - return result; | |
| 3334 | - }; | |
| 3335 | - let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`); | |
| 3336 | - let innerSet = (val) => evaluateInnerSet(() => { | |
| 3337 | - }, { scope: { "__placeholder": val } }); | |
| 3338 | - let initialValue = innerGet(); | |
| 3339 | - innerSet(initialValue); | |
| 3340 | - queueMicrotask(() => { | |
| 3341 | - if (!el._x_model) | |
| 3342 | - return; | |
| 3343 | - el._x_removeModelListeners["default"](); | |
| 3344 | - let outerGet = el._x_model.get; | |
| 3345 | - let outerSet = el._x_model.set; | |
| 3346 | - let releaseEntanglement = entangle( | |
| 3347 | - { | |
| 3348 | - get() { | |
| 3349 | - return outerGet(); | |
| 3350 | - }, | |
| 3351 | - set(value) { | |
| 3352 | - outerSet(value); | |
| 3353 | - } | |
| 3354 | - }, | |
| 3355 | - { | |
| 3356 | - get() { | |
| 3357 | - return innerGet(); | |
| 3358 | - }, | |
| 3359 | - set(value) { | |
| 3360 | - innerSet(value); | |
| 3361 | - } | |
| 3362 | - } | |
| 3363 | - ); | |
| 3364 | - cleanup2(releaseEntanglement); | |
| 3365 | - }); | |
| 3366 | -}); | |
| 3367 | - | |
| 3368 | -// packages/alpinejs/src/directives/x-teleport.js | |
| 3369 | -directive("teleport", (el, { modifiers, expression }, { cleanup: cleanup2 }) => { | |
| 3370 | - if (el.tagName.toLowerCase() !== "template") | |
| 3371 | - warn("x-teleport can only be used on a <template> tag", el); | |
| 3372 | - let target = getTarget(expression); | |
| 3373 | - let clone2 = el.content.cloneNode(true).firstElementChild; | |
| 3374 | - el._x_teleport = clone2; | |
| 3375 | - clone2._x_teleportBack = el; | |
| 3376 | - el.setAttribute("data-teleport-template", true); | |
| 3377 | - clone2.setAttribute("data-teleport-target", true); | |
| 3378 | - if (el._x_forwardEvents) { | |
| 3379 | - el._x_forwardEvents.forEach((eventName) => { | |
| 3380 | - clone2.addEventListener(eventName, (e) => { | |
| 3381 | - e.stopPropagation(); | |
| 3382 | - el.dispatchEvent(new e.constructor(e.type, e)); | |
| 3383 | - }); | |
| 3384 | - }); | |
| 3385 | - } | |
| 3386 | - addScopeToNode(clone2, {}, el); | |
| 3387 | - let placeInDom = (clone3, target2, modifiers2) => { | |
| 3388 | - if (modifiers2.includes("prepend")) { | |
| 3389 | - target2.parentNode.insertBefore(clone3, target2); | |
| 3390 | - } else if (modifiers2.includes("append")) { | |
| 3391 | - target2.parentNode.insertBefore(clone3, target2.nextSibling); | |
| 3392 | - } else { | |
| 3393 | - target2.appendChild(clone3); | |
| 3394 | - } | |
| 3395 | - }; | |
| 3396 | - mutateDom(() => { | |
| 3397 | - placeInDom(clone2, target, modifiers); | |
| 3398 | - skipDuringClone(() => { | |
| 3399 | - initTree(clone2); | |
| 3400 | - })(); | |
| 3401 | - }); | |
| 3402 | - el._x_teleportPutBack = () => { | |
| 3403 | - let target2 = getTarget(expression); | |
| 3404 | - mutateDom(() => { | |
| 3405 | - placeInDom(el._x_teleport, target2, modifiers); | |
| 3406 | - }); | |
| 3407 | - }; | |
| 3408 | - cleanup2( | |
| 3409 | - () => mutateDom(() => { | |
| 3410 | - clone2.remove(); | |
| 3411 | - destroyTree(clone2); | |
| 3412 | - }) | |
| 3413 | - ); | |
| 3414 | -}); | |
| 3415 | -var teleportContainerDuringClone = document.createElement("div"); | |
| 3416 | -function getTarget(expression) { | |
| 3417 | - let target = skipDuringClone(() => { | |
| 3418 | - return document.querySelector(expression); | |
| 3419 | - }, () => { | |
| 3420 | - return teleportContainerDuringClone; | |
| 3421 | - })(); | |
| 3422 | - if (!target) | |
| 3423 | - warn(`Cannot find x-teleport element for selector: "${expression}"`); | |
| 3424 | - return target; | |
| 3425 | -} | |
| 3426 | - | |
| 3427 | -// packages/alpinejs/src/directives/x-ignore.js | |
| 3428 | -var handler = () => { | |
| 3429 | -}; | |
| 3430 | -handler.inline = (el, { modifiers }, { cleanup: cleanup2 }) => { | |
| 3431 | - modifiers.includes("self") ? el._x_ignoreSelf = true : el._x_ignore = true; | |
| 3432 | - cleanup2(() => { | |
| 3433 | - modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore; | |
| 3434 | - }); | |
| 3435 | -}; | |
| 3436 | -directive("ignore", handler); | |
| 3437 | - | |
| 3438 | -// packages/alpinejs/src/directives/x-effect.js | |
| 3439 | -directive("effect", skipDuringClone((el, { expression }, { effect: effect3 }) => { | |
| 3440 | - effect3(evaluateLater(el, expression)); | |
| 3441 | -})); | |
| 3442 | - | |
| 3443 | -// packages/alpinejs/src/utils/on.js | |
| 3444 | -function on(el, event, modifiers, callback) { | |
| 3445 | - let listenerTarget = el; | |
| 3446 | - let handler4 = (e) => callback(e); | |
| 3447 | - let options = {}; | |
| 3448 | - let wrapHandler = (callback2, wrapper) => (e) => wrapper(callback2, e); | |
| 3449 | - if (modifiers.includes("dot")) | |
| 3450 | - event = dotSyntax(event); | |
| 3451 | - if (modifiers.includes("camel")) | |
| 3452 | - event = camelCase2(event); | |
| 3453 | - if (modifiers.includes("passive")) | |
| 3454 | - options.passive = true; | |
| 3455 | - if (modifiers.includes("capture")) | |
| 3456 | - options.capture = true; | |
| 3457 | - if (modifiers.includes("window")) | |
| 3458 | - listenerTarget = window; | |
| 3459 | - if (modifiers.includes("document")) | |
| 3460 | - listenerTarget = document; | |
| 3461 | - if (modifiers.includes("debounce")) { | |
| 3462 | - let nextModifier = modifiers[modifiers.indexOf("debounce") + 1] || "invalid-wait"; | |
| 3463 | - let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; | |
| 3464 | - handler4 = debounce(handler4, wait); | |
| 3465 | - } | |
| 3466 | - if (modifiers.includes("throttle")) { | |
| 3467 | - let nextModifier = modifiers[modifiers.indexOf("throttle") + 1] || "invalid-wait"; | |
| 3468 | - let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; | |
| 3469 | - handler4 = throttle(handler4, wait); | |
| 3470 | - } | |
| 3471 | - if (modifiers.includes("prevent")) | |
| 3472 | - handler4 = wrapHandler(handler4, (next, e) => { | |
| 3473 | - e.preventDefault(); | |
| 3474 | - next(e); | |
| 3475 | - }); | |
| 3476 | - if (modifiers.includes("stop")) | |
| 3477 | - handler4 = wrapHandler(handler4, (next, e) => { | |
| 3478 | - e.stopPropagation(); | |
| 3479 | - next(e); | |
| 3480 | - }); | |
| 3481 | - if (modifiers.includes("once")) { | |
| 3482 | - handler4 = wrapHandler(handler4, (next, e) => { | |
| 3483 | - next(e); | |
| 3484 | - listenerTarget.removeEventListener(event, handler4, options); | |
| 3485 | - }); | |
| 3486 | - } | |
| 3487 | - if (modifiers.includes("away") || modifiers.includes("outside")) { | |
| 3488 | - listenerTarget = document; | |
| 3489 | - handler4 = wrapHandler(handler4, (next, e) => { | |
| 3490 | - if (el.contains(e.target)) | |
| 3491 | - return; | |
| 3492 | - if (e.target.isConnected === false) | |
| 3493 | - return; | |
| 3494 | - if (el.offsetWidth < 1 && el.offsetHeight < 1) | |
| 3495 | - return; | |
| 3496 | - if (el._x_isShown === false) | |
| 3497 | - return; | |
| 3498 | - next(e); | |
| 3499 | - }); | |
| 3500 | - } | |
| 3501 | - if (modifiers.includes("self")) | |
| 3502 | - handler4 = wrapHandler(handler4, (next, e) => { | |
| 3503 | - e.target === el && next(e); | |
| 3504 | - }); | |
| 3505 | - if (isKeyEvent(event) || isClickEvent(event)) { | |
| 3506 | - handler4 = wrapHandler(handler4, (next, e) => { | |
| 3507 | - if (isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers)) { | |
| 3508 | - return; | |
| 3509 | - } | |
| 3510 | - next(e); | |
| 3511 | - }); | |
| 3512 | - } | |
| 3513 | - listenerTarget.addEventListener(event, handler4, options); | |
| 3514 | - return () => { | |
| 3515 | - listenerTarget.removeEventListener(event, handler4, options); | |
| 3516 | - }; | |
| 3517 | -} | |
| 3518 | -function dotSyntax(subject) { | |
| 3519 | - return subject.replace(/-/g, "."); | |
| 3520 | -} | |
| 3521 | -function camelCase2(subject) { | |
| 3522 | - return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); | |
| 3523 | -} | |
| 3524 | -function isNumeric(subject) { | |
| 3525 | - return !Array.isArray(subject) && !isNaN(subject); | |
| 3526 | -} | |
| 3527 | -function kebabCase2(subject) { | |
| 3528 | - if ([" ", "_"].includes( | |
| 3529 | - subject | |
| 3530 | - )) | |
| 3531 | - return subject; | |
| 3532 | - return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); | |
| 3533 | -} | |
| 3534 | -function isKeyEvent(event) { | |
| 3535 | - return ["keydown", "keyup"].includes(event); | |
| 3536 | -} | |
| 3537 | -function isClickEvent(event) { | |
| 3538 | - return ["contextmenu", "click", "mouse"].some((i) => event.includes(i)); | |
| 3539 | -} | |
| 3540 | -function isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers) { | |
| 3541 | - let keyModifiers = modifiers.filter((i) => { | |
| 3542 | - return !["window", "document", "prevent", "stop", "once", "capture", "self", "away", "outside", "passive", "preserve-scroll"].includes(i); | |
| 3543 | - }); | |
| 3544 | - if (keyModifiers.includes("debounce")) { | |
| 3545 | - let debounceIndex = keyModifiers.indexOf("debounce"); | |
| 3546 | - keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); | |
| 3547 | - } | |
| 3548 | - if (keyModifiers.includes("throttle")) { | |
| 3549 | - let debounceIndex = keyModifiers.indexOf("throttle"); | |
| 3550 | - keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); | |
| 3551 | - } | |
| 3552 | - if (keyModifiers.length === 0) | |
| 3553 | - return false; | |
| 3554 | - if (keyModifiers.length === 1 && keyToModifiers(e.key).includes(keyModifiers[0])) | |
| 3555 | - return false; | |
| 3556 | - const systemKeyModifiers = ["ctrl", "shift", "alt", "meta", "cmd", "super"]; | |
| 3557 | - const selectedSystemKeyModifiers = systemKeyModifiers.filter((modifier) => keyModifiers.includes(modifier)); | |
| 3558 | - keyModifiers = keyModifiers.filter((i) => !selectedSystemKeyModifiers.includes(i)); | |
| 3559 | - if (selectedSystemKeyModifiers.length > 0) { | |
| 3560 | - const activelyPressedKeyModifiers = selectedSystemKeyModifiers.filter((modifier) => { | |
| 3561 | - if (modifier === "cmd" || modifier === "super") | |
| 3562 | - modifier = "meta"; | |
| 3563 | - return e[`${modifier}Key`]; | |
| 3564 | - }); | |
| 3565 | - if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) { | |
| 3566 | - if (isClickEvent(e.type)) | |
| 3567 | - return false; | |
| 3568 | - if (keyToModifiers(e.key).includes(keyModifiers[0])) | |
| 3569 | - return false; | |
| 3570 | - } | |
| 3571 | - } | |
| 3572 | - return true; | |
| 3573 | -} | |
| 3574 | -function keyToModifiers(key) { | |
| 3575 | - if (!key) | |
| 3576 | - return []; | |
| 3577 | - key = kebabCase2(key); | |
| 3578 | - let modifierToKeyMap = { | |
| 3579 | - "ctrl": "control", | |
| 3580 | - "slash": "/", | |
| 3581 | - "space": " ", | |
| 3582 | - "spacebar": " ", | |
| 3583 | - "cmd": "meta", | |
| 3584 | - "esc": "escape", | |
| 3585 | - "up": "arrow-up", | |
| 3586 | - "down": "arrow-down", | |
| 3587 | - "left": "arrow-left", | |
| 3588 | - "right": "arrow-right", | |
| 3589 | - "period": ".", | |
| 3590 | - "comma": ",", | |
| 3591 | - "equal": "=", | |
| 3592 | - "minus": "-", | |
| 3593 | - "underscore": "_" | |
| 3594 | - }; | |
| 3595 | - modifierToKeyMap[key] = key; | |
| 3596 | - return Object.keys(modifierToKeyMap).map((modifier) => { | |
| 3597 | - if (modifierToKeyMap[modifier] === key) | |
| 3598 | - return modifier; | |
| 3599 | - }).filter((modifier) => modifier); | |
| 3600 | -} | |
| 3601 | - | |
| 3602 | -// packages/alpinejs/src/directives/x-model.js | |
| 3603 | -directive("model", (el, { modifiers, expression }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3604 | - let scopeTarget = el; | |
| 3605 | - if (modifiers.includes("parent")) { | |
| 3606 | - scopeTarget = el.parentNode; | |
| 3607 | - } | |
| 3608 | - let evaluateGet = evaluateLater(scopeTarget, expression); | |
| 3609 | - let evaluateSet; | |
| 3610 | - if (typeof expression === "string") { | |
| 3611 | - evaluateSet = evaluateLater(scopeTarget, `${expression} = __placeholder`); | |
| 3612 | - } else if (typeof expression === "function" && typeof expression() === "string") { | |
| 3613 | - evaluateSet = evaluateLater(scopeTarget, `${expression()} = __placeholder`); | |
| 3614 | - } else { | |
| 3615 | - evaluateSet = () => { | |
| 3616 | - }; | |
| 3617 | - } | |
| 3618 | - let getValue = () => { | |
| 3619 | - let result; | |
| 3620 | - evaluateGet((value) => result = value); | |
| 3621 | - return isGetterSetter(result) ? result.get() : result; | |
| 3622 | - }; | |
| 3623 | - let setValue = (value) => { | |
| 3624 | - let result; | |
| 3625 | - evaluateGet((value2) => result = value2); | |
| 3626 | - if (isGetterSetter(result)) { | |
| 3627 | - result.set(value); | |
| 3628 | - } else { | |
| 3629 | - evaluateSet(() => { | |
| 3630 | - }, { | |
| 3631 | - scope: { "__placeholder": value } | |
| 3632 | - }); | |
| 3633 | - } | |
| 3634 | - }; | |
| 3635 | - if (typeof expression === "string" && el.type === "radio") { | |
| 3636 | - mutateDom(() => { | |
| 3637 | - if (!el.hasAttribute("name")) | |
| 3638 | - el.setAttribute("name", expression); | |
| 3639 | - }); | |
| 3640 | - } | |
| 3641 | - let event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input"; | |
| 3642 | - let removeListener = isCloning ? () => { | |
| 3643 | - } : on(el, event, modifiers, (e) => { | |
| 3644 | - setValue(getInputValue(el, modifiers, e, getValue())); | |
| 3645 | - }); | |
| 3646 | - if (modifiers.includes("fill")) { | |
| 3647 | - if ([void 0, null, ""].includes(getValue()) || isCheckbox(el) && Array.isArray(getValue()) || el.tagName.toLowerCase() === "select" && el.multiple) { | |
| 3648 | - setValue( | |
| 3649 | - getInputValue(el, modifiers, { target: el }, getValue()) | |
| 3650 | - ); | |
| 3651 | - } | |
| 3652 | - } | |
| 3653 | - if (!el._x_removeModelListeners) | |
| 3654 | - el._x_removeModelListeners = {}; | |
| 3655 | - el._x_removeModelListeners["default"] = removeListener; | |
| 3656 | - cleanup2(() => el._x_removeModelListeners["default"]()); | |
| 3657 | - if (el.form) { | |
| 3658 | - let removeResetListener = on(el.form, "reset", [], (e) => { | |
| 3659 | - nextTick(() => el._x_model && el._x_model.set(getInputValue(el, modifiers, { target: el }, getValue()))); | |
| 3660 | - }); | |
| 3661 | - cleanup2(() => removeResetListener()); | |
| 3662 | - } | |
| 3663 | - el._x_model = { | |
| 3664 | - get() { | |
| 3665 | - return getValue(); | |
| 3666 | - }, | |
| 3667 | - set(value) { | |
| 3668 | - setValue(value); | |
| 3669 | - } | |
| 3670 | - }; | |
| 3671 | - el._x_forceModelUpdate = (value) => { | |
| 3672 | - if (value === void 0 && typeof expression === "string" && expression.match(/\./)) | |
| 3673 | - value = ""; | |
| 3674 | - window.fromModel = true; | |
| 3675 | - mutateDom(() => bind(el, "value", value)); | |
| 3676 | - delete window.fromModel; | |
| 3677 | - }; | |
| 3678 | - effect3(() => { | |
| 3679 | - let value = getValue(); | |
| 3680 | - if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el)) | |
| 3681 | - return; | |
| 3682 | - el._x_forceModelUpdate(value); | |
| 3683 | - }); | |
| 3684 | -}); | |
| 3685 | -function getInputValue(el, modifiers, event, currentValue) { | |
| 3686 | - return mutateDom(() => { | |
| 3687 | - if (event instanceof CustomEvent && event.detail !== void 0) | |
| 3688 | - return event.detail !== null && event.detail !== void 0 ? event.detail : event.target.value; | |
| 3689 | - else if (isCheckbox(el)) { | |
| 3690 | - if (Array.isArray(currentValue)) { | |
| 3691 | - let newValue = null; | |
| 3692 | - if (modifiers.includes("number")) { | |
| 3693 | - newValue = safeParseNumber(event.target.value); | |
| 3694 | - } else if (modifiers.includes("boolean")) { | |
| 3695 | - newValue = safeParseBoolean(event.target.value); | |
| 3696 | - } else { | |
| 3697 | - newValue = event.target.value; | |
| 3698 | - } | |
| 3699 | - return event.target.checked ? currentValue.includes(newValue) ? currentValue : currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); | |
| 3700 | - } else { | |
| 3701 | - return event.target.checked; | |
| 3702 | - } | |
| 3703 | - } else if (el.tagName.toLowerCase() === "select" && el.multiple) { | |
| 3704 | - if (modifiers.includes("number")) { | |
| 3705 | - return Array.from(event.target.selectedOptions).map((option) => { | |
| 3706 | - let rawValue = option.value || option.text; | |
| 3707 | - return safeParseNumber(rawValue); | |
| 3708 | - }); | |
| 3709 | - } else if (modifiers.includes("boolean")) { | |
| 3710 | - return Array.from(event.target.selectedOptions).map((option) => { | |
| 3711 | - let rawValue = option.value || option.text; | |
| 3712 | - return safeParseBoolean(rawValue); | |
| 3713 | - }); | |
| 3714 | - } | |
| 3715 | - return Array.from(event.target.selectedOptions).map((option) => { | |
| 3716 | - return option.value || option.text; | |
| 3717 | - }); | |
| 3718 | - } else { | |
| 3719 | - let newValue; | |
| 3720 | - if (isRadio(el)) { | |
| 3721 | - if (event.target.checked) { | |
| 3722 | - newValue = event.target.value; | |
| 3723 | - } else { | |
| 3724 | - newValue = currentValue; | |
| 3725 | - } | |
| 3726 | - } else { | |
| 3727 | - newValue = event.target.value; | |
| 3728 | - } | |
| 3729 | - if (modifiers.includes("number")) { | |
| 3730 | - return safeParseNumber(newValue); | |
| 3731 | - } else if (modifiers.includes("boolean")) { | |
| 3732 | - return safeParseBoolean(newValue); | |
| 3733 | - } else if (modifiers.includes("trim")) { | |
| 3734 | - return newValue.trim(); | |
| 3735 | - } else { | |
| 3736 | - return newValue; | |
| 3737 | - } | |
| 3738 | - } | |
| 3739 | - }); | |
| 3740 | -} | |
| 3741 | -function safeParseNumber(rawValue) { | |
| 3742 | - let number = rawValue ? parseFloat(rawValue) : null; | |
| 3743 | - return isNumeric2(number) ? number : rawValue; | |
| 3744 | -} | |
| 3745 | -function checkedAttrLooseCompare2(valueA, valueB) { | |
| 3746 | - return valueA == valueB; | |
| 3747 | -} | |
| 3748 | -function isNumeric2(subject) { | |
| 3749 | - return !Array.isArray(subject) && !isNaN(subject); | |
| 3750 | -} | |
| 3751 | -function isGetterSetter(value) { | |
| 3752 | - return value !== null && typeof value === "object" && typeof value.get === "function" && typeof value.set === "function"; | |
| 3753 | -} | |
| 3754 | - | |
| 3755 | -// packages/alpinejs/src/directives/x-cloak.js | |
| 3756 | -directive("cloak", (el) => queueMicrotask(() => mutateDom(() => el.removeAttribute(prefix("cloak"))))); | |
| 3757 | - | |
| 3758 | -// packages/alpinejs/src/directives/x-init.js | |
| 3759 | -addInitSelector(() => `[${prefix("init")}]`); | |
| 3760 | -directive("init", skipDuringClone((el, { expression }, { evaluate: evaluate2 }) => { | |
| 3761 | - if (typeof expression === "string") { | |
| 3762 | - return !!expression.trim() && evaluate2(expression, {}, false); | |
| 3763 | - } | |
| 3764 | - return evaluate2(expression, {}, false); | |
| 3765 | -})); | |
| 3766 | - | |
| 3767 | -// packages/alpinejs/src/directives/x-text.js | |
| 3768 | -directive("text", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => { | |
| 3769 | - let evaluate2 = evaluateLater2(expression); | |
| 3770 | - effect3(() => { | |
| 3771 | - evaluate2((value) => { | |
| 3772 | - mutateDom(() => { | |
| 3773 | - el.textContent = value; | |
| 3774 | - }); | |
| 3775 | - }); | |
| 3776 | - }); | |
| 3777 | -}); | |
| 3778 | - | |
| 3779 | -// packages/alpinejs/src/directives/x-html.js | |
| 3780 | -directive("html", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => { | |
| 3781 | - let evaluate2 = evaluateLater2(expression); | |
| 3782 | - effect3(() => { | |
| 3783 | - evaluate2((value) => { | |
| 3784 | - mutateDom(() => { | |
| 3785 | - el.innerHTML = value; | |
| 3786 | - el._x_ignoreSelf = true; | |
| 3787 | - initTree(el); | |
| 3788 | - delete el._x_ignoreSelf; | |
| 3789 | - }); | |
| 3790 | - }); | |
| 3791 | - }); | |
| 3792 | -}); | |
| 3793 | - | |
| 3794 | -// packages/alpinejs/src/directives/x-bind.js | |
| 3795 | -mapAttributes(startingWith(":", into(prefix("bind:")))); | |
| 3796 | -var handler2 = (el, { value, modifiers, expression, original }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3797 | - if (!value) { | |
| 3798 | - let bindingProviders = {}; | |
| 3799 | - injectBindingProviders(bindingProviders); | |
| 3800 | - let getBindings = evaluateLater(el, expression); | |
| 3801 | - getBindings((bindings) => { | |
| 3802 | - applyBindingsObject(el, bindings, original); | |
| 3803 | - }, { scope: bindingProviders }); | |
| 3804 | - return; | |
| 3805 | - } | |
| 3806 | - if (value === "key") | |
| 3807 | - return storeKeyForXFor(el, expression); | |
| 3808 | - if (el._x_inlineBindings && el._x_inlineBindings[value] && el._x_inlineBindings[value].extract) { | |
| 3809 | - return; | |
| 3810 | - } | |
| 3811 | - let evaluate2 = evaluateLater(el, expression); | |
| 3812 | - effect3(() => evaluate2((result) => { | |
| 3813 | - if (result === void 0 && typeof expression === "string" && expression.match(/\./)) { | |
| 3814 | - result = ""; | |
| 3815 | - } | |
| 3816 | - mutateDom(() => bind(el, value, result, modifiers)); | |
| 3817 | - })); | |
| 3818 | - cleanup2(() => { | |
| 3819 | - el._x_undoAddedClasses && el._x_undoAddedClasses(); | |
| 3820 | - el._x_undoAddedStyles && el._x_undoAddedStyles(); | |
| 3821 | - }); | |
| 3822 | -}; | |
| 3823 | -handler2.inline = (el, { value, modifiers, expression }) => { | |
| 3824 | - if (!value) | |
| 3825 | - return; | |
| 3826 | - if (!el._x_inlineBindings) | |
| 3827 | - el._x_inlineBindings = {}; | |
| 3828 | - el._x_inlineBindings[value] = { expression, extract: false }; | |
| 3829 | -}; | |
| 3830 | -directive("bind", handler2); | |
| 3831 | -function storeKeyForXFor(el, expression) { | |
| 3832 | - el._x_keyExpression = expression; | |
| 3833 | -} | |
| 3834 | - | |
| 3835 | -// packages/alpinejs/src/directives/x-data.js | |
| 3836 | -addRootSelector(() => `[${prefix("data")}]`); | |
| 3837 | -directive("data", (el, { expression }, { cleanup: cleanup2 }) => { | |
| 3838 | - if (shouldSkipRegisteringDataDuringClone(el)) | |
| 3839 | - return; | |
| 3840 | - expression = expression === "" ? "{}" : expression; | |
| 3841 | - let magicContext = {}; | |
| 3842 | - injectMagics(magicContext, el); | |
| 3843 | - let dataProviderContext = {}; | |
| 3844 | - injectDataProviders(dataProviderContext, magicContext); | |
| 3845 | - let data2 = evaluate(el, expression, { scope: dataProviderContext }); | |
| 3846 | - if (data2 === void 0 || data2 === true) | |
| 3847 | - data2 = {}; | |
| 3848 | - injectMagics(data2, el); | |
| 3849 | - let reactiveData = reactive(data2); | |
| 3850 | - initInterceptors(reactiveData); | |
| 3851 | - let undo = addScopeToNode(el, reactiveData); | |
| 3852 | - reactiveData["init"] && evaluate(el, reactiveData["init"]); | |
| 3853 | - cleanup2(() => { | |
| 3854 | - reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]); | |
| 3855 | - undo(); | |
| 3856 | - }); | |
| 3857 | -}); | |
| 3858 | -interceptClone((from, to) => { | |
| 3859 | - if (from._x_dataStack) { | |
| 3860 | - to._x_dataStack = from._x_dataStack; | |
| 3861 | - to.setAttribute("data-has-alpine-state", true); | |
| 3862 | - } | |
| 3863 | -}); | |
| 3864 | -function shouldSkipRegisteringDataDuringClone(el) { | |
| 3865 | - if (!isCloning) | |
| 3866 | - return false; | |
| 3867 | - if (isCloningLegacy) | |
| 3868 | - return true; | |
| 3869 | - return el.hasAttribute("data-has-alpine-state"); | |
| 3870 | -} | |
| 3871 | - | |
| 3872 | -// packages/alpinejs/src/directives/x-show.js | |
| 3873 | -directive("show", (el, { modifiers, expression }, { effect: effect3 }) => { | |
| 3874 | - let evaluate2 = evaluateLater(el, expression); | |
| 3875 | - if (!el._x_doHide) | |
| 3876 | - el._x_doHide = () => { | |
| 3877 | - mutateDom(() => { | |
| 3878 | - el.style.setProperty("display", "none", modifiers.includes("important") ? "important" : void 0); | |
| 3879 | - }); | |
| 3880 | - }; | |
| 3881 | - if (!el._x_doShow) | |
| 3882 | - el._x_doShow = () => { | |
| 3883 | - mutateDom(() => { | |
| 3884 | - if (el.style.length === 1 && el.style.display === "none") { | |
| 3885 | - el.removeAttribute("style"); | |
| 3886 | - } else { | |
| 3887 | - el.style.removeProperty("display"); | |
| 3888 | - } | |
| 3889 | - }); | |
| 3890 | - }; | |
| 3891 | - let hide = () => { | |
| 3892 | - el._x_doHide(); | |
| 3893 | - el._x_isShown = false; | |
| 3894 | - }; | |
| 3895 | - let show = () => { | |
| 3896 | - el._x_doShow(); | |
| 3897 | - el._x_isShown = true; | |
| 3898 | - }; | |
| 3899 | - let clickAwayCompatibleShow = () => setTimeout(show); | |
| 3900 | - let toggle = once( | |
| 3901 | - (value) => value ? show() : hide(), | |
| 3902 | - (value) => { | |
| 3903 | - if (typeof el._x_toggleAndCascadeWithTransitions === "function") { | |
| 3904 | - el._x_toggleAndCascadeWithTransitions(el, value, show, hide); | |
| 3905 | - } else { | |
| 3906 | - value ? clickAwayCompatibleShow() : hide(); | |
| 3907 | - } | |
| 3908 | - } | |
| 3909 | - ); | |
| 3910 | - let oldValue; | |
| 3911 | - let firstTime = true; | |
| 3912 | - effect3(() => evaluate2((value) => { | |
| 3913 | - if (!firstTime && value === oldValue) | |
| 3914 | - return; | |
| 3915 | - if (modifiers.includes("immediate")) | |
| 3916 | - value ? clickAwayCompatibleShow() : hide(); | |
| 3917 | - toggle(value); | |
| 3918 | - oldValue = value; | |
| 3919 | - firstTime = false; | |
| 3920 | - })); | |
| 3921 | -}); | |
| 3922 | - | |
| 3923 | -// packages/alpinejs/src/directives/x-for.js | |
| 3924 | -directive("for", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 3925 | - let iteratorNames = parseForExpression(expression); | |
| 3926 | - let evaluateItems = evaluateLater(el, iteratorNames.items); | |
| 3927 | - let evaluateKey = evaluateLater( | |
| 3928 | - el, | |
| 3929 | - // the x-bind:key expression is stored for our use instead of evaluated. | |
| 3930 | - el._x_keyExpression || "index" | |
| 3931 | - ); | |
| 3932 | - el._x_prevKeys = []; | |
| 3933 | - el._x_lookup = {}; | |
| 3934 | - effect3(() => loop(el, iteratorNames, evaluateItems, evaluateKey)); | |
| 3935 | - cleanup2(() => { | |
| 3936 | - Object.values(el._x_lookup).forEach((el2) => mutateDom( | |
| 3937 | - () => { | |
| 3938 | - destroyTree(el2); | |
| 3939 | - el2.remove(); | |
| 3940 | - } | |
| 3941 | - )); | |
| 3942 | - delete el._x_prevKeys; | |
| 3943 | - delete el._x_lookup; | |
| 3944 | - }); | |
| 3945 | -}); | |
| 3946 | -function loop(el, iteratorNames, evaluateItems, evaluateKey) { | |
| 3947 | - let isObject2 = (i) => typeof i === "object" && !Array.isArray(i); | |
| 3948 | - let templateEl = el; | |
| 3949 | - evaluateItems((items) => { | |
| 3950 | - if (isNumeric3(items) && items >= 0) { | |
| 3951 | - items = Array.from(Array(items).keys(), (i) => i + 1); | |
| 3952 | - } | |
| 3953 | - if (items === void 0) | |
| 3954 | - items = []; | |
| 3955 | - let lookup = el._x_lookup; | |
| 3956 | - let prevKeys = el._x_prevKeys; | |
| 3957 | - let scopes = []; | |
| 3958 | - let keys = []; | |
| 3959 | - if (isObject2(items)) { | |
| 3960 | - items = Object.entries(items).map(([key, value]) => { | |
| 3961 | - let scope2 = getIterationScopeVariables(iteratorNames, value, key, items); | |
| 3962 | - evaluateKey((value2) => { | |
| 3963 | - if (keys.includes(value2)) | |
| 3964 | - warn("Duplicate key on x-for", el); | |
| 3965 | - keys.push(value2); | |
| 3966 | - }, { scope: { index: key, ...scope2 } }); | |
| 3967 | - scopes.push(scope2); | |
| 3968 | - }); | |
| 3969 | - } else { | |
| 3970 | - for (let i = 0; i < items.length; i++) { | |
| 3971 | - let scope2 = getIterationScopeVariables(iteratorNames, items[i], i, items); | |
| 3972 | - evaluateKey((value) => { | |
| 3973 | - if (keys.includes(value)) | |
| 3974 | - warn("Duplicate key on x-for", el); | |
| 3975 | - keys.push(value); | |
| 3976 | - }, { scope: { index: i, ...scope2 } }); | |
| 3977 | - scopes.push(scope2); | |
| 3978 | - } | |
| 3979 | - } | |
| 3980 | - let adds = []; | |
| 3981 | - let moves = []; | |
| 3982 | - let removes = []; | |
| 3983 | - let sames = []; | |
| 3984 | - for (let i = 0; i < prevKeys.length; i++) { | |
| 3985 | - let key = prevKeys[i]; | |
| 3986 | - if (keys.indexOf(key) === -1) | |
| 3987 | - removes.push(key); | |
| 3988 | - } | |
| 3989 | - prevKeys = prevKeys.filter((key) => !removes.includes(key)); | |
| 3990 | - let lastKey = "template"; | |
| 3991 | - for (let i = 0; i < keys.length; i++) { | |
| 3992 | - let key = keys[i]; | |
| 3993 | - let prevIndex = prevKeys.indexOf(key); | |
| 3994 | - if (prevIndex === -1) { | |
| 3995 | - prevKeys.splice(i, 0, key); | |
| 3996 | - adds.push([lastKey, i]); | |
| 3997 | - } else if (prevIndex !== i) { | |
| 3998 | - let keyInSpot = prevKeys.splice(i, 1)[0]; | |
| 3999 | - let keyForSpot = prevKeys.splice(prevIndex - 1, 1)[0]; | |
| 4000 | - prevKeys.splice(i, 0, keyForSpot); | |
| 4001 | - prevKeys.splice(prevIndex, 0, keyInSpot); | |
| 4002 | - moves.push([keyInSpot, keyForSpot]); | |
| 4003 | - } else { | |
| 4004 | - sames.push(key); | |
| 4005 | - } | |
| 4006 | - lastKey = key; | |
| 4007 | - } | |
| 4008 | - for (let i = 0; i < removes.length; i++) { | |
| 4009 | - let key = removes[i]; | |
| 4010 | - if (!(key in lookup)) | |
| 4011 | - continue; | |
| 4012 | - mutateDom(() => { | |
| 4013 | - destroyTree(lookup[key]); | |
| 4014 | - lookup[key].remove(); | |
| 4015 | - }); | |
| 4016 | - delete lookup[key]; | |
| 4017 | - } | |
| 4018 | - for (let i = 0; i < moves.length; i++) { | |
| 4019 | - let [keyInSpot, keyForSpot] = moves[i]; | |
| 4020 | - let elInSpot = lookup[keyInSpot]; | |
| 4021 | - let elForSpot = lookup[keyForSpot]; | |
| 4022 | - let marker = document.createElement("div"); | |
| 4023 | - mutateDom(() => { | |
| 4024 | - if (!elForSpot) | |
| 4025 | - warn(`x-for ":key" is undefined or invalid`, templateEl, keyForSpot, lookup); | |
| 4026 | - elForSpot.after(marker); | |
| 4027 | - elInSpot.after(elForSpot); | |
| 4028 | - elForSpot._x_currentIfEl && elForSpot.after(elForSpot._x_currentIfEl); | |
| 4029 | - marker.before(elInSpot); | |
| 4030 | - elInSpot._x_currentIfEl && elInSpot.after(elInSpot._x_currentIfEl); | |
| 4031 | - marker.remove(); | |
| 4032 | - }); | |
| 4033 | - elForSpot._x_refreshXForScope(scopes[keys.indexOf(keyForSpot)]); | |
| 4034 | - } | |
| 4035 | - for (let i = 0; i < adds.length; i++) { | |
| 4036 | - let [lastKey2, index] = adds[i]; | |
| 4037 | - let lastEl = lastKey2 === "template" ? templateEl : lookup[lastKey2]; | |
| 4038 | - if (lastEl._x_currentIfEl) | |
| 4039 | - lastEl = lastEl._x_currentIfEl; | |
| 4040 | - let scope2 = scopes[index]; | |
| 4041 | - let key = keys[index]; | |
| 4042 | - let clone2 = document.importNode(templateEl.content, true).firstElementChild; | |
| 4043 | - let reactiveScope = reactive(scope2); | |
| 4044 | - addScopeToNode(clone2, reactiveScope, templateEl); | |
| 4045 | - clone2._x_refreshXForScope = (newScope) => { | |
| 4046 | - Object.entries(newScope).forEach(([key2, value]) => { | |
| 4047 | - reactiveScope[key2] = value; | |
| 4048 | - }); | |
| 4049 | - }; | |
| 4050 | - mutateDom(() => { | |
| 4051 | - lastEl.after(clone2); | |
| 4052 | - skipDuringClone(() => initTree(clone2))(); | |
| 4053 | - }); | |
| 4054 | - if (typeof key === "object") { | |
| 4055 | - warn("x-for key cannot be an object, it must be a string or an integer", templateEl); | |
| 4056 | - } | |
| 4057 | - lookup[key] = clone2; | |
| 4058 | - } | |
| 4059 | - for (let i = 0; i < sames.length; i++) { | |
| 4060 | - lookup[sames[i]]._x_refreshXForScope(scopes[keys.indexOf(sames[i])]); | |
| 4061 | - } | |
| 4062 | - templateEl._x_prevKeys = keys; | |
| 4063 | - }); | |
| 4064 | -} | |
| 4065 | -function parseForExpression(expression) { | |
| 4066 | - let forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; | |
| 4067 | - let stripParensRE = /^\s*\(|\)\s*$/g; | |
| 4068 | - let forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; | |
| 4069 | - let inMatch = expression.match(forAliasRE); | |
| 4070 | - if (!inMatch) | |
| 4071 | - return; | |
| 4072 | - let res = {}; | |
| 4073 | - res.items = inMatch[2].trim(); | |
| 4074 | - let item = inMatch[1].replace(stripParensRE, "").trim(); | |
| 4075 | - let iteratorMatch = item.match(forIteratorRE); | |
| 4076 | - if (iteratorMatch) { | |
| 4077 | - res.item = item.replace(forIteratorRE, "").trim(); | |
| 4078 | - res.index = iteratorMatch[1].trim(); | |
| 4079 | - if (iteratorMatch[2]) { | |
| 4080 | - res.collection = iteratorMatch[2].trim(); | |
| 4081 | - } | |
| 4082 | - } else { | |
| 4083 | - res.item = item; | |
| 4084 | - } | |
| 4085 | - return res; | |
| 4086 | -} | |
| 4087 | -function getIterationScopeVariables(iteratorNames, item, index, items) { | |
| 4088 | - let scopeVariables = {}; | |
| 4089 | - if (/^\[.*\]$/.test(iteratorNames.item) && Array.isArray(item)) { | |
| 4090 | - let names = iteratorNames.item.replace("[", "").replace("]", "").split(",").map((i) => i.trim()); | |
| 4091 | - names.forEach((name, i) => { | |
| 4092 | - scopeVariables[name] = item[i]; | |
| 4093 | - }); | |
| 4094 | - } else if (/^\{.*\}$/.test(iteratorNames.item) && !Array.isArray(item) && typeof item === "object") { | |
| 4095 | - let names = iteratorNames.item.replace("{", "").replace("}", "").split(",").map((i) => i.trim()); | |
| 4096 | - names.forEach((name) => { | |
| 4097 | - scopeVariables[name] = item[name]; | |
| 4098 | - }); | |
| 4099 | - } else { | |
| 4100 | - scopeVariables[iteratorNames.item] = item; | |
| 4101 | - } | |
| 4102 | - if (iteratorNames.index) | |
| 4103 | - scopeVariables[iteratorNames.index] = index; | |
| 4104 | - if (iteratorNames.collection) | |
| 4105 | - scopeVariables[iteratorNames.collection] = items; | |
| 4106 | - return scopeVariables; | |
| 4107 | -} | |
| 4108 | -function isNumeric3(subject) { | |
| 4109 | - return !Array.isArray(subject) && !isNaN(subject); | |
| 4110 | -} | |
| 4111 | - | |
| 4112 | -// packages/alpinejs/src/directives/x-ref.js | |
| 4113 | -function handler3() { | |
| 4114 | -} | |
| 4115 | -handler3.inline = (el, { expression }, { cleanup: cleanup2 }) => { | |
| 4116 | - let root = closestRoot(el); | |
| 4117 | - if (!root._x_refs) | |
| 4118 | - root._x_refs = {}; | |
| 4119 | - root._x_refs[expression] = el; | |
| 4120 | - cleanup2(() => delete root._x_refs[expression]); | |
| 4121 | -}; | |
| 4122 | -directive("ref", handler3); | |
| 4123 | - | |
| 4124 | -// packages/alpinejs/src/directives/x-if.js | |
| 4125 | -directive("if", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => { | |
| 4126 | - if (el.tagName.toLowerCase() !== "template") | |
| 4127 | - warn("x-if can only be used on a <template> tag", el); | |
| 4128 | - let evaluate2 = evaluateLater(el, expression); | |
| 4129 | - let show = () => { | |
| 4130 | - if (el._x_currentIfEl) | |
| 4131 | - return el._x_currentIfEl; | |
| 4132 | - let clone2 = el.content.cloneNode(true).firstElementChild; | |
| 4133 | - addScopeToNode(clone2, {}, el); | |
| 4134 | - mutateDom(() => { | |
| 4135 | - el.after(clone2); | |
| 4136 | - skipDuringClone(() => initTree(clone2))(); | |
| 4137 | - }); | |
| 4138 | - el._x_currentIfEl = clone2; | |
| 4139 | - el._x_undoIf = () => { | |
| 4140 | - mutateDom(() => { | |
| 4141 | - destroyTree(clone2); | |
| 4142 | - clone2.remove(); | |
| 4143 | - }); | |
| 4144 | - delete el._x_currentIfEl; | |
| 4145 | - }; | |
| 4146 | - return clone2; | |
| 4147 | - }; | |
| 4148 | - let hide = () => { | |
| 4149 | - if (!el._x_undoIf) | |
| 4150 | - return; | |
| 4151 | - el._x_undoIf(); | |
| 4152 | - delete el._x_undoIf; | |
| 4153 | - }; | |
| 4154 | - effect3(() => evaluate2((value) => { | |
| 4155 | - value ? show() : hide(); | |
| 4156 | - })); | |
| 4157 | - cleanup2(() => el._x_undoIf && el._x_undoIf()); | |
| 4158 | -}); | |
| 4159 | - | |
| 4160 | -// packages/alpinejs/src/directives/x-id.js | |
| 4161 | -directive("id", (el, { expression }, { evaluate: evaluate2 }) => { | |
| 4162 | - let names = evaluate2(expression); | |
| 4163 | - names.forEach((name) => setIdRoot(el, name)); | |
| 4164 | -}); | |
| 4165 | -interceptClone((from, to) => { | |
| 4166 | - if (from._x_ids) { | |
| 4167 | - to._x_ids = from._x_ids; | |
| 4168 | - } | |
| 4169 | -}); | |
| 4170 | - | |
| 4171 | -// packages/alpinejs/src/directives/x-on.js | |
| 4172 | -mapAttributes(startingWith("@", into(prefix("on:")))); | |
| 4173 | -directive("on", skipDuringClone((el, { value, modifiers, expression }, { cleanup: cleanup2 }) => { | |
| 4174 | - let evaluate2 = expression ? evaluateLater(el, expression) : () => { | |
| 4175 | - }; | |
| 4176 | - if (el.tagName.toLowerCase() === "template") { | |
| 4177 | - if (!el._x_forwardEvents) | |
| 4178 | - el._x_forwardEvents = []; | |
| 4179 | - if (!el._x_forwardEvents.includes(value)) | |
| 4180 | - el._x_forwardEvents.push(value); | |
| 4181 | - } | |
| 4182 | - let removeListener = on(el, value, modifiers, (e) => { | |
| 4183 | - evaluate2(() => { | |
| 4184 | - }, { scope: { "$event": e }, params: [e] }); | |
| 4185 | - }); | |
| 4186 | - cleanup2(() => removeListener()); | |
| 4187 | -})); | |
| 4188 | - | |
| 4189 | -// packages/alpinejs/src/directives/index.js | |
| 4190 | -warnMissingPluginDirective("Collapse", "collapse", "collapse"); | |
| 4191 | -warnMissingPluginDirective("Intersect", "intersect", "intersect"); | |
| 4192 | -warnMissingPluginDirective("Focus", "trap", "focus"); | |
| 4193 | -warnMissingPluginDirective("Mask", "mask", "mask"); | |
| 4194 | -function warnMissingPluginDirective(name, directiveName, slug) { | |
| 4195 | - directive(directiveName, (el) => warn(`You can't use [x-${directiveName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); | |
| 4196 | -} | |
| 4197 | - | |
| 4198 | -// packages/csp/src/index.js | |
| 4199 | -alpine_default.setEvaluator(cspEvaluator); | |
| 4200 | -alpine_default.setReactivityEngine({ reactive: reactive2, effect: effect2, release: stop, raw: toRaw }); | |
| 4201 | -var src_default = alpine_default; | |
| 4202 | - | |
| 4203 | -// packages/csp/builds/module.js | |
| 4204 | -var module_default = src_default; | |
| 4205 | - | |
| 4206 | - | |
| 4207 | - | |
| 4208 | -/***/ }), | |
| 4209 | - | |
| 4210 | -/***/ "./packages/packages/core/alpinejs/src/init.ts": | |
| 4211 | -/*!*****************************************************!*\ | |
| 4212 | - !*** ./packages/packages/core/alpinejs/src/init.ts ***! | |
| 4213 | - \*****************************************************/ | |
| 4214 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 4215 | - | |
| 4216 | -__webpack_require__.r(__webpack_exports__); | |
| 4217 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 4218 | -/* harmony export */ init: function() { return /* binding */ init; } | |
| 4219 | -/* harmony export */ }); | |
| 4220 | -/* harmony import */ var _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @alpinejs/csp */ "./node_modules/@alpinejs/csp/dist/module.esm.js"); | |
| 4221 | - | |
| 4222 | -function init() { | |
| 4223 | - document.addEventListener('DOMContentLoaded', () => { | |
| 4224 | - _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__.Alpine.start(); | |
| 4225 | - }, { | |
| 4226 | - once: true | |
| 4227 | - }); | |
| 4228 | -} | |
| 4229 | - | |
| 4230 | -/***/ }) | |
| 4231 | - | |
| 4232 | -/******/ }); | |
| 4233 | -/************************************************************************/ | |
| 4234 | -/******/ // The module cache | |
| 4235 | -/******/ var __webpack_module_cache__ = {}; | |
| 4236 | -/******/ | |
| 4237 | -/******/ // The require function | |
| 4238 | -/******/ function __webpack_require__(moduleId) { | |
| 4239 | -/******/ // Check if module is in cache | |
| 4240 | -/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 4241 | -/******/ if (cachedModule !== undefined) { | |
| 4242 | -/******/ return cachedModule.exports; | |
| 4243 | -/******/ } | |
| 4244 | -/******/ // Create a new module (and put it into the cache) | |
| 4245 | -/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 4246 | -/******/ // no module.id needed | |
| 4247 | -/******/ // no module.loaded needed | |
| 4248 | -/******/ exports: {} | |
| 4249 | -/******/ }; | |
| 4250 | -/******/ | |
| 4251 | -/******/ // Execute the module function | |
| 4252 | -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | |
| 4253 | -/******/ | |
| 4254 | -/******/ // Return the exports of the module | |
| 4255 | -/******/ return module.exports; | |
| 4256 | -/******/ } | |
| 4257 | -/******/ | |
| 4258 | -/************************************************************************/ | |
| 4259 | -/******/ /* webpack/runtime/define property getters */ | |
| 4260 | -/******/ !function() { | |
| 4261 | -/******/ // define getter functions for harmony exports | |
| 4262 | -/******/ __webpack_require__.d = function(exports, definition) { | |
| 4263 | -/******/ for(var key in definition) { | |
| 4264 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 4265 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 4266 | -/******/ } | |
| 4267 | -/******/ } | |
| 4268 | -/******/ }; | |
| 4269 | -/******/ }(); | |
| 4270 | -/******/ | |
| 4271 | -/******/ /* webpack/runtime/hasOwnProperty shorthand */ | |
| 4272 | -/******/ !function() { | |
| 4273 | -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | |
| 4274 | -/******/ }(); | |
| 4275 | -/******/ | |
| 4276 | -/******/ /* webpack/runtime/make namespace object */ | |
| 4277 | -/******/ !function() { | |
| 4278 | -/******/ // define __esModule on exports | |
| 4279 | -/******/ __webpack_require__.r = function(exports) { | |
| 4280 | -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 4281 | -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | |
| 4282 | -/******/ } | |
| 4283 | -/******/ Object.defineProperty(exports, '__esModule', { value: true }); | |
| 4284 | -/******/ }; | |
| 4285 | -/******/ }(); | |
| 4286 | -/******/ | |
| 4287 | -/************************************************************************/ | |
| 4288 | -var __webpack_exports__ = {}; | |
| 4289 | -// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. | |
| 4290 | -!function() { | |
| 4291 | -/*!******************************************************!*\ | |
| 4292 | - !*** ./packages/packages/core/alpinejs/src/index.ts ***! | |
| 4293 | - \******************************************************/ | |
| 4294 | -__webpack_require__.r(__webpack_exports__); | |
| 4295 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 4296 | -/* harmony export */ Alpine: function() { return /* reexport safe */ _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__.Alpine; }, | |
| 4297 | -/* harmony export */ init: function() { return /* reexport safe */ _init__WEBPACK_IMPORTED_MODULE_1__.init; }, | |
| 4298 | -/* harmony export */ refreshTree: function() { return /* binding */ refreshTree; } | |
| 4299 | -/* harmony export */ }); | |
| 4300 | -/* harmony import */ var _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @alpinejs/csp */ "./node_modules/@alpinejs/csp/dist/module.esm.js"); | |
| 4301 | -/* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./init */ "./packages/packages/core/alpinejs/src/init.ts"); | |
| 4302 | - | |
| 4303 | - | |
| 4304 | - | |
| 4305 | -const refreshTree = element => { | |
| 4306 | - _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__.Alpine.nextTick(() => { | |
| 4307 | - _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__.Alpine.destroyTree(element); | |
| 4308 | - _alpinejs_csp__WEBPACK_IMPORTED_MODULE_0__.Alpine.initTree(element); | |
| 4309 | - }); | |
| 4310 | -}; | |
| 4311 | -}(); | |
| 4312 | -(window.elementorV2 = window.elementorV2 || {}).alpinejs = __webpack_exports__; | |
| 4313 | -/******/ })() | |
| 4314 | -; | |
| 3640 | +//#endregion | |
| 3641 | +})(); | |
| 4315 | 3642 | window.elementorV2.alpinejs?.init?.(); |
| 4316 | 3643 | //# sourceMappingURL=alpinejs.js.map |