| @@ -1,3 +1,3643 @@ | ||
| 1 | -/*! For license information please see alpinejs.js.LICENSE.txt */ | |
| 2 | -!function(){"use strict";var e={"./node_modules/@alpinejs/csp/dist/module.esm.js":function(e,t,n){n.r(t),n.d(t,{Alpine:function(){return je},default:function(){return Me}});var i,r,o,s,a=!1,l=!1,c=[],u=-1;function scheduler(e){!function queueJob(e){c.includes(e)||c.push(e);!function queueFlush(){l||a||(a=!0,queueMicrotask(flushJobs))}()}(e)}function dequeueJob(e){let t=c.indexOf(e);-1!==t&&t>u&&c.splice(t,1)}function flushJobs(){a=!1,l=!0;for(let e=0;e<c.length;e++)c[e](),u=e;c.length=0,u=-1,l=!1}var d=!0;function overrideEffect(e){r=e}function watch(e,t){let n,i=!0,s=r(()=>{let r=e();JSON.stringify(r),i?n=r:queueMicrotask(()=>{t(r,n),n=r}),i=!1});return()=>o(s)}var p=[],f=[],h=[];function onElRemoved(e,t){"function"==typeof t?(e._x_cleanups||(e._x_cleanups=[]),e._x_cleanups.push(t)):(t=e,f.push(t))}function onAttributesAdded(e){p.push(e)}function onAttributeRemoved(e,t,n){e._x_attributeCleanups||(e._x_attributeCleanups={}),e._x_attributeCleanups[t]||(e._x_attributeCleanups[t]=[]),e._x_attributeCleanups[t].push(n)}function cleanupAttributes(e,t){e._x_attributeCleanups&&Object.entries(e._x_attributeCleanups).forEach(([n,i])=>{(void 0===t||t.includes(n))&&(i.forEach(e=>e()),delete e._x_attributeCleanups[n])})}var m=new MutationObserver(onMutate),_=!1;function startObservingMutations(){m.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),_=!0}function stopObservingMutations(){!function flushObserver(){let e=m.takeRecords();g.push(()=>e.length>0&&onMutate(e));let t=g.length;queueMicrotask(()=>{if(g.length===t)for(;g.length>0;)g.shift()()})}(),m.disconnect(),_=!1}var g=[];function mutateDom(e){if(!_)return e();stopObservingMutations();let t=e();return startObservingMutations(),t}var v=!1,y=[];function onMutate(e){if(v)return void(y=y.concat(e));let t=[],n=new Set,i=new Map,r=new Map;for(let o=0;o<e.length;o++)if(!e[o].target._x_ignoreMutationObserver&&("childList"===e[o].type&&(e[o].removedNodes.forEach(e=>{1===e.nodeType&&e._x_marker&&n.add(e)}),e[o].addedNodes.forEach(e=>{1===e.nodeType&&(n.has(e)?n.delete(e):e._x_marker||t.push(e))})),"attributes"===e[o].type)){let t=e[o].target,n=e[o].attributeName,s=e[o].oldValue,add2=()=>{i.has(t)||i.set(t,[]),i.get(t).push({name:n,value:t.getAttribute(n)})},remove=()=>{r.has(t)||r.set(t,[]),r.get(t).push(n)};t.hasAttribute(n)&&null===s?add2():t.hasAttribute(n)?(remove(),add2()):remove()}r.forEach((e,t)=>{cleanupAttributes(t,e)}),i.forEach((e,t)=>{p.forEach(n=>n(t,e))});for(let e of n)t.some(t=>t.contains(e))||f.forEach(t=>t(e));for(let e of t)e.isConnected&&h.forEach(t=>t(e));t=null,n=null,i=null,r=null}function scope(e){return mergeProxies(closestDataStack(e))}function addScopeToNode(e,t,n){return e._x_dataStack=[t,...closestDataStack(n||e)],()=>{e._x_dataStack=e._x_dataStack.filter(e=>e!==t)}}function closestDataStack(e){return e._x_dataStack?e._x_dataStack:"function"==typeof ShadowRoot&&e instanceof ShadowRoot?closestDataStack(e.host):e.parentNode?closestDataStack(e.parentNode):[]}function mergeProxies(e){return new Proxy({objects:e},x)}var x={ownKeys({objects:e}){return Array.from(new Set(e.flatMap(e=>Object.keys(e))))},has({objects:e},t){return t!=Symbol.unscopables&&e.some(e=>Object.prototype.hasOwnProperty.call(e,t)||Reflect.has(e,t))},get({objects:e},t,n){return"toJSON"==t?collapseProxies:Reflect.get(e.find(e=>Reflect.has(e,t))||{},t,n)},set({objects:e},t,n,i){const r=e.find(e=>Object.prototype.hasOwnProperty.call(e,t))||e[e.length-1],o=Object.getOwnPropertyDescriptor(r,t);return o?.set&&o?.get?o.set.call(i,n)||!0:Reflect.set(r,t,n)}};function collapseProxies(){return Reflect.ownKeys(this).reduce((e,t)=>(e[t]=Reflect.get(this,t),e),{})}function initInterceptors(e){let recurse=(t,n="")=>{Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i,{value:r,enumerable:o}])=>{if(!1===o||void 0===r)return;if("object"==typeof r&&null!==r&&r.__v_skip)return;let s=""===n?i:`${n}.${i}`;var a;"object"==typeof r&&null!==r&&r._x_interceptor?t[i]=r.initialize(e,s,i):"object"!=typeof(a=r)||Array.isArray(a)||null===a||r===t||r instanceof Element||recurse(r,s)})};return recurse(e)}function interceptor(e,t=()=>{}){let n={initialValue:void 0,_x_interceptor:!0,initialize(t,n,i){return e(this.initialValue,()=>function get(e,t){return t.split(".").reduce((e,t)=>e[t],e)}(t,n),e=>set(t,n,e),n,i)}};return t(n),e=>{if("object"==typeof e&&null!==e&&e._x_interceptor){let t=n.initialize.bind(n);n.initialize=(i,r,o)=>{let s=e.initialize(i,r,o);return n.initialValue=s,t(i,r,o)}}else n.initialValue=e;return n}}function set(e,t,n){if("string"==typeof t&&(t=t.split(".")),1!==t.length){if(0===t.length)throw error;return e[t[0]]||(e[t[0]]={}),set(e[t[0]],t.slice(1),n)}e[t[0]]=n}var b={};function magic(e,t){b[e]=t}function injectMagics(e,t){let n=function getUtilities(e){let[t,n]=getElementBoundUtilities(e),i={interceptor:interceptor,...t};return onElRemoved(e,n),i}(t);return Object.entries(b).forEach(([i,r])=>{Object.defineProperty(e,`$${i}`,{get(){return r(t,n)},enumerable:!1})}),e}function tryCatch(e,t,n,...i){try{return n(...i)}catch(n){handleError(n,e,t)}}function handleError(e,t,n=void 0){e=Object.assign(e??{message:"No error message given."},{el:t,expression:n}),console.warn(`Alpine Expression Error: ${e.message}\n\n${n?'Expression: "'+n+'"\n\n':""}`,t),setTimeout(()=>{throw e},0)}var w=!0;function dontAutoEvaluateFunctions(e){let t=w;w=!1;let n=e();return w=t,n}function evaluate(e,t,n={}){let i;return evaluateLater(e,t)(e=>i=e,n),i}function evaluateLater(...e){return E(...e)}var E=function normalEvaluator(e,t){let n={};injectMagics(n,e);let i=[n,...closestDataStack(e)],r="function"==typeof t?generateEvaluatorFromFunction(i,t):function generateEvaluatorFromString(e,t,n){let i=function generateFunctionFromString(e,t){if(k[e])return k[e];let n=Object.getPrototypeOf(async function(){}).constructor,i=/^[\n\s]*if.*\(.*\)/.test(e.trim())||/^(let|const)\s/.test(e.trim())?`(async()=>{ ${e} })()`:e;const safeAsyncFunction=()=>{try{let t=new n(["__self","scope"],`with (scope) { __self.result = ${i} }; __self.finished = true; return __self.result;`);return Object.defineProperty(t,"name",{value:`[Alpine] ${e}`}),t}catch(n){return handleError(n,t,e),Promise.resolve()}};let r=safeAsyncFunction();return k[e]=r,r}(t,n);return(r=()=>{},{scope:o={},params:s=[],context:a}={})=>{i.result=void 0,i.finished=!1;let l=mergeProxies([o,...e]);if("function"==typeof i){let e=i.call(a,i,l).catch(e=>handleError(e,n,t));i.finished?(runIfTypeOfFunction(r,i.result,l,s,n),i.result=void 0):e.then(e=>{runIfTypeOfFunction(r,e,l,s,n)}).catch(e=>handleError(e,n,t)).finally(()=>i.result=void 0)}}}(i,t,e);return tryCatch.bind(null,e,t,r)};function generateEvaluatorFromFunction(e,t){return(n=()=>{},{scope:i={},params:r=[],context:o}={})=>{runIfTypeOfFunction(n,t.apply(mergeProxies([i,...e]),r))}}var k={};function runIfTypeOfFunction(e,t,n,i,r){if(w&&"function"==typeof t){let o=t.apply(n,i);o instanceof Promise?o.then(t=>runIfTypeOfFunction(e,t,n,i)).catch(e=>handleError(e,r,t)):e(o)}else"object"==typeof t&&t instanceof Promise?t.then(t=>e(t)):e(t)}var A="x-";function prefix(e=""){return A+e}var O={};function directive(e,t){return O[e]=t,{before(t){if(!O[t])return void console.warn(String.raw`Cannot find directive \`${t}\`. \`${e}\` will use the default order of execution`);const n=P.indexOf(t);P.splice(n>=0?n:P.indexOf("DEFAULT"),0,e)}}}function directives(e,t,n){if(t=Array.from(t),e._x_virtualDirectives){let n=Object.entries(e._x_virtualDirectives).map(([e,t])=>({name:e,value:t})),i=attributesOnly(n);n=n.map(e=>i.find(t=>t.name===e.name)?{name:`x-bind:${e.name}`,value:`"${e.value}"`}:e),t=t.concat(n)}let i={},r=t.map(toTransformedAttributes((e,t)=>i[e]=t)).filter(outNonAlpineAttributes).map(function toParsedDirectives(e,t){return({name:n,value:i})=>{let r=n.match(alpineAttributeRegex()),o=n.match(/:([a-zA-Z0-9\-_:]+)/),s=n.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],a=t||e[n]||n;return{type:r?r[1]:null,value:o?o[1]:null,modifiers:s.map(e=>e.replace(".","")),expression:i,original:a}}}(i,n)).sort(byPriority);return r.map(t=>function getDirectiveHandler(e,t){let noop=()=>{},n=O[t.type]||noop,[i,r]=getElementBoundUtilities(e);onAttributeRemoved(e,t.original,r);let fullHandler=()=>{e._x_ignore||e._x_ignoreSelf||(n.inline&&n.inline(e,t,i),n=n.bind(n,e,t,i),T?R.get(S).push(n):n())};return fullHandler.runCleanups=r,fullHandler}(e,t))}function attributesOnly(e){return Array.from(e).map(toTransformedAttributes()).filter(e=>!outNonAlpineAttributes(e))}var T=!1,R=new Map,S=Symbol();function getElementBoundUtilities(e){let t=[],[n,i]=function elementBoundEffect(e){let cleanup2=()=>{};return[t=>{let n=r(t);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(e=>e())}),e._x_effects.add(n),cleanup2=()=>{void 0!==n&&(e._x_effects.delete(n),o(n))},n},()=>{cleanup2()}]}(e);t.push(i);return[{Alpine:J,effect:n,cleanup:e=>t.push(e),evaluateLater:evaluateLater.bind(evaluateLater,e),evaluate:evaluate.bind(evaluate,e)},()=>t.forEach(e=>e())]}var startingWith=(e,t)=>({name:n,value:i})=>(n.startsWith(e)&&(n=n.replace(e,t)),{name:n,value:i});function toTransformedAttributes(e=()=>{}){return({name:t,value:n})=>{let{name:i,value:r}=C.reduce((e,t)=>t(e),{name:t,value:n});return i!==t&&e(i,t),{name:i,value:r}}}var C=[];function mapAttributes(e){C.push(e)}function outNonAlpineAttributes({name:e}){return alpineAttributeRegex().test(e)}var alpineAttributeRegex=()=>new RegExp(`^${A}([^:^.]+)\\b`);var N="DEFAULT",P=["ignore","ref","data","id","anchor","bind","init","for","model","modelable","transition","show","if",N,"teleport"];function byPriority(e,t){let n=-1===P.indexOf(e.type)?N:e.type,i=-1===P.indexOf(t.type)?N:t.type;return P.indexOf(n)-P.indexOf(i)}function dispatch(e,t,n={}){e.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0,cancelable:!0}))}function walk(e,t){if("function"==typeof ShadowRoot&&e instanceof ShadowRoot)return void Array.from(e.children).forEach(e=>walk(e,t));let n=!1;if(t(e,()=>n=!0),n)return;let i=e.firstElementChild;for(;i;)walk(i,t),i=i.nextElementSibling}function warn(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var I=!1;var j=[],M=[];function rootSelectors(){return j.map(e=>e())}function allSelectors(){return j.concat(M).map(e=>e())}function addRootSelector(e){j.push(e)}function addInitSelector(e){M.push(e)}function closestRoot(e,t=!1){return findClosest(e,e=>{if((t?allSelectors():rootSelectors()).some(t=>e.matches(t)))return!0})}function findClosest(e,t){if(e){if(t(e))return e;if(e._x_teleportBack&&(e=e._x_teleportBack),e.parentElement)return findClosest(e.parentElement,t)}}var $=[];var D=1;function initTree(e,t=walk,n=()=>{}){findClosest(e,e=>e._x_ignore)||function deferHandlingDirectives(e){T=!0;let t=Symbol();S=t,R.set(t,[]);let flushHandlers=()=>{for(;R.get(t).length;)R.get(t).shift()();R.delete(t)};e(flushHandlers),T=!1,flushHandlers()}(()=>{t(e,(e,t)=>{e._x_marker||(n(e,t),$.forEach(n=>n(e,t)),directives(e,e.attributes).forEach(e=>e()),e._x_ignore||(e._x_marker=D++),e._x_ignore&&t())})})}function destroyTree(e,t=walk){t(e,e=>{!function cleanupElement(e){for(e._x_effects?.forEach(dequeueJob);e._x_cleanups?.length;)e._x_cleanups.pop()()}(e),cleanupAttributes(e),delete e._x_marker})}var U=[],L=!1;function nextTick(e=()=>{}){return queueMicrotask(()=>{L||setTimeout(()=>{releaseNextTicks()})}),new Promise(t=>{U.push(()=>{e(),t()})})}function releaseNextTicks(){for(L=!1;U.length;)U.shift()()}function setClasses(e,t){return Array.isArray(t)?setClassesFromString(e,t.join(" ")):"object"==typeof t&&null!==t?function setClassesFromObject(e,t){let split=e=>e.split(" ").filter(Boolean),n=Object.entries(t).flatMap(([e,t])=>!!t&&split(e)).filter(Boolean),i=Object.entries(t).flatMap(([e,t])=>!t&&split(e)).filter(Boolean),r=[],o=[];return i.forEach(t=>{e.classList.contains(t)&&(e.classList.remove(t),o.push(t))}),n.forEach(t=>{e.classList.contains(t)||(e.classList.add(t),r.push(t))}),()=>{o.forEach(t=>e.classList.add(t)),r.forEach(t=>e.classList.remove(t))}}(e,t):"function"==typeof t?setClasses(e,t()):setClassesFromString(e,t)}function setClassesFromString(e,t){return t=!0===t?t="":t||"",n=t.split(" ").filter(t=>!e.classList.contains(t)).filter(Boolean),e.classList.add(...n),()=>{e.classList.remove(...n)};var n}function setStyles(e,t){return"object"==typeof t&&null!==t?function setStylesFromObject(e,t){let n={};return Object.entries(t).forEach(([t,i])=>{n[t]=e.style[t],t.startsWith("--")||(t=function kebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}(t)),e.style.setProperty(t,i)}),setTimeout(()=>{0===e.style.length&&e.removeAttribute("style")}),()=>{setStyles(e,n)}}(e,t):function setStylesFromString(e,t){let n=e.getAttribute("style",t);return e.setAttribute("style",t),()=>{e.setAttribute("style",n||"")}}(e,t)}function once(e,t=()=>{}){let n=!1;return function(){n?t.apply(this,arguments):(n=!0,e.apply(this,arguments))}}function registerTransitionObject(e,t,n={}){e._x_transition||(e._x_transition={enter:{during:n,start:n,end:n},leave:{during:n,start:n,end:n},in(n=()=>{},i=()=>{}){transition(e,t,{during:this.enter.during,start:this.enter.start,end:this.enter.end},n,i)},out(n=()=>{},i=()=>{}){transition(e,t,{during:this.leave.during,start:this.leave.start,end:this.leave.end},n,i)}})}function closestHide(e){let t=e.parentNode;if(t)return t._x_hidePromise?t:closestHide(t)}function transition(e,t,{during:n,start:i,end:r}={},o=()=>{},s=()=>{}){if(e._x_transitioning&&e._x_transitioning.cancel(),0===Object.keys(n).length&&0===Object.keys(i).length&&0===Object.keys(r).length)return o(),void s();let a,l,c;!function performTransition(e,t){let n,i,r,o=once(()=>{mutateDom(()=>{n=!0,i||t.before(),r||(t.end(),releaseNextTicks()),t.after(),e.isConnected&&t.cleanup(),delete e._x_transitioning})});e._x_transitioning={beforeCancels:[],beforeCancel(e){this.beforeCancels.push(e)},cancel:once(function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();o()}),finish:o},mutateDom(()=>{t.start(),t.during()}),function holdNextTicks(){L=!0}(),requestAnimationFrame(()=>{if(n)return;let o=1e3*Number(getComputedStyle(e).transitionDuration.replace(/,.*/,"").replace("s","")),s=1e3*Number(getComputedStyle(e).transitionDelay.replace(/,.*/,"").replace("s",""));0===o&&(o=1e3*Number(getComputedStyle(e).animationDuration.replace("s",""))),mutateDom(()=>{t.before()}),i=!0,requestAnimationFrame(()=>{n||(mutateDom(()=>{t.end()}),releaseNextTicks(),setTimeout(e._x_transitioning.finish,o+s),r=!0)})})}(e,{start(){a=t(e,i)},during(){l=t(e,n)},before:o,end(){a(),c=t(e,r)},after:s,cleanup(){l(),c()}})}function modifierValue(e,t,n){if(-1===e.indexOf(t))return n;const i=e[e.indexOf(t)+1];if(!i)return n;if("scale"===t&&isNaN(i))return n;if("duration"===t||"delay"===t){let e=i.match(/([0-9]+)ms/);if(e)return e[1]}return"origin"===t&&["top","right","left","center","bottom"].includes(e[e.indexOf(t)+2])?[i,e[e.indexOf(t)+2]].join(" "):i}directive("transition",(e,{value:t,modifiers:n,expression:i},{evaluate:r})=>{"function"==typeof i&&(i=r(i)),!1!==i&&(i&&"boolean"!=typeof i?function registerTransitionsFromClassString(e,t,n){registerTransitionObject(e,setClasses,"");let i={enter:t=>{e._x_transition.enter.during=t},"enter-start":t=>{e._x_transition.enter.start=t},"enter-end":t=>{e._x_transition.enter.end=t},leave:t=>{e._x_transition.leave.during=t},"leave-start":t=>{e._x_transition.leave.start=t},"leave-end":t=>{e._x_transition.leave.end=t}};i[n](t)}(e,i,t):function registerTransitionsFromHelper(e,t,n){registerTransitionObject(e,setStyles);let i=!t.includes("in")&&!t.includes("out")&&!n,r=i||t.includes("in")||["enter"].includes(n),o=i||t.includes("out")||["leave"].includes(n);t.includes("in")&&!i&&(t=t.filter((e,n)=>n<t.indexOf("out")));t.includes("out")&&!i&&(t=t.filter((e,n)=>n>t.indexOf("out")));let s=!t.includes("opacity")&&!t.includes("scale"),a=s||t.includes("opacity"),l=s||t.includes("scale"),c=a?0:1,u=l?modifierValue(t,"scale",95)/100:1,d=modifierValue(t,"delay",0)/1e3,p=modifierValue(t,"origin","center"),f="opacity, transform",h=modifierValue(t,"duration",150)/1e3,m=modifierValue(t,"duration",75)/1e3,_="cubic-bezier(0.4, 0.0, 0.2, 1)";r&&(e._x_transition.enter.during={transformOrigin:p,transitionDelay:`${d}s`,transitionProperty:f,transitionDuration:`${h}s`,transitionTimingFunction:_},e._x_transition.enter.start={opacity:c,transform:`scale(${u})`},e._x_transition.enter.end={opacity:1,transform:"scale(1)"});o&&(e._x_transition.leave.during={transformOrigin:p,transitionDelay:`${d}s`,transitionProperty:f,transitionDuration:`${m}s`,transitionTimingFunction:_},e._x_transition.leave.start={opacity:1,transform:"scale(1)"},e._x_transition.leave.end={opacity:c,transform:`scale(${u})`})}(e,n,t))}),window.Element.prototype._x_toggleAndCascadeWithTransitions=function(e,t,n,i){const r="visible"===document.visibilityState?requestAnimationFrame:setTimeout;let clickAwayCompatibleShow=()=>r(n);t?e._x_transition&&(e._x_transition.enter||e._x_transition.leave)?e._x_transition.enter&&(Object.entries(e._x_transition.enter.during).length||Object.entries(e._x_transition.enter.start).length||Object.entries(e._x_transition.enter.end).length)?e._x_transition.in(n):clickAwayCompatibleShow():e._x_transition?e._x_transition.in(n):clickAwayCompatibleShow():(e._x_hidePromise=e._x_transition?new Promise((t,n)=>{e._x_transition.out(()=>{},()=>t(i)),e._x_transitioning&&e._x_transitioning.beforeCancel(()=>n({isFromCancelledTransition:!0}))}):Promise.resolve(i),queueMicrotask(()=>{let t=closestHide(e);t?(t._x_hideChildren||(t._x_hideChildren=[]),t._x_hideChildren.push(e)):r(()=>{let hideAfterChildren=e=>{let t=Promise.all([e._x_hidePromise,...(e._x_hideChildren||[]).map(hideAfterChildren)]).then(([e])=>e?.());return delete e._x_hidePromise,delete e._x_hideChildren,t};hideAfterChildren(e).catch(e=>{if(!e.isFromCancelledTransition)throw e})})}))};var F=!1;function skipDuringClone(e,t=()=>{}){return(...n)=>F?t(...n):e(...n)}var B=[];function interceptClone(e){B.push(e)}var G=!1;function dontRegisterReactiveSideEffects(e){let t=r;overrideEffect((e,n)=>{let i=t(e);return o(i),()=>{}}),e(),overrideEffect(t)}function bind(e,t,n,r=[]){switch(e._x_bindings||(e._x_bindings=i({})),e._x_bindings[t]=n,t=r.includes("camel")?function camelCase(e){return e.toLowerCase().replace(/-(\w)/g,(e,t)=>t.toUpperCase())}(t):t){case"value":!function bindInputValue(e,t){if(isRadio(e))void 0===e.attributes.value&&(e.value=t),window.fromModel&&(e.checked="boolean"==typeof t?safeParseBoolean(e.value)===t:checkedAttrLooseCompare(e.value,t));else if(isCheckbox(e))Number.isInteger(t)?e.value=t:Array.isArray(t)||"boolean"==typeof t||[null,void 0].includes(t)?Array.isArray(t)?e.checked=t.some(t=>checkedAttrLooseCompare(t,e.value)):e.checked=!!t:e.value=String(t);else if("SELECT"===e.tagName)!function updateSelect(e,t){const n=[].concat(t).map(e=>e+"");Array.from(e.options).forEach(e=>{e.selected=n.includes(e.value)})}(e,t);else{if(e.value===t)return;e.value=void 0===t?"":t}}(e,n);break;case"style":!function bindStyles(e,t){e._x_undoAddedStyles&&e._x_undoAddedStyles();e._x_undoAddedStyles=setStyles(e,t)}(e,n);break;case"class":!function bindClasses(e,t){e._x_undoAddedClasses&&e._x_undoAddedClasses();e._x_undoAddedClasses=setClasses(e,t)}(e,n);break;case"selected":case"checked":!function bindAttributeAndProperty(e,t,n){bindAttribute(e,t,n),function setPropertyIfChanged(e,t,n){e[t]!==n&&(e[t]=n)}(e,t,n)}(e,t,n);break;default:bindAttribute(e,t,n)}}function bindAttribute(e,t,n){[null,void 0,!1].includes(n)&&function attributeShouldntBePreservedIfFalsy(e){return!["aria-pressed","aria-checked","aria-expanded","aria-selected"].includes(e)}(t)?e.removeAttribute(t):(isBooleanAttr(t)&&(n=t),function setIfChanged(e,t,n){e.getAttribute(t)!=n&&e.setAttribute(t,n)}(e,t,n))}function checkedAttrLooseCompare(e,t){return e==t}function safeParseBoolean(e){return!![1,"1","true","on","yes",!0].includes(e)||![0,"0","false","off","no",!1].includes(e)&&(e?Boolean(e):null)}var q=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected","shadowrootclonable","shadowrootdelegatesfocus","shadowrootserializable"]);function isBooleanAttr(e){return q.has(e)}function getAttributeBinding(e,t,n){let i=e.getAttribute(t);return null===i?"function"==typeof n?n():n:""===i||(isBooleanAttr(t)?!![t,"true"].includes(i):i)}function isCheckbox(e){return"checkbox"===e.type||"ui-checkbox"===e.localName||"ui-switch"===e.localName}function isRadio(e){return"radio"===e.type||"ui-radio"===e.localName}function debounce(e,t){let n;return function(){const i=this,r=arguments;clearTimeout(n),n=setTimeout(function(){n=null,e.apply(i,r)},t)}}function throttle(e,t){let n;return function(){let i=this,r=arguments;n||(e.apply(i,r),n=!0,setTimeout(()=>n=!1,t))}}function entangle({get:e,set:t},{get:n,set:i}){let s,a,l=!0,c=r(()=>{let r=e(),o=n();if(l)i(cloneIfObject(r)),l=!1;else{let e=JSON.stringify(r),n=JSON.stringify(o);e!==s?i(cloneIfObject(r)):e!==n&&t(cloneIfObject(o))}s=JSON.stringify(e()),a=JSON.stringify(n())});return()=>{o(c)}}function cloneIfObject(e){return"object"==typeof e?JSON.parse(JSON.stringify(e)):e}var z={},V=!1;var K={};function applyBindingsObject(e,t,n){let i=[];for(;i.length;)i.pop()();let r=Object.entries(t).map(([e,t])=>({name:e,value:t})),o=attributesOnly(r);return r=r.map(e=>o.find(t=>t.name===e.name)?{name:`x-bind:${e.name}`,value:`"${e.value}"`}:e),directives(e,r,n).map(e=>{i.push(e.runCleanups),e()}),()=>{for(;i.length;)i.pop()()}}var W={};var J={get reactive(){return i},get release(){return o},get effect(){return r},get raw(){return s},version:"3.15.0",flushAndStopDeferringMutations:function flushAndStopDeferringMutations(){v=!1,onMutate(y),y=[]},dontAutoEvaluateFunctions:dontAutoEvaluateFunctions,disableEffectScheduling:function disableEffectScheduling(e){d=!1,e(),d=!0},startObservingMutations:startObservingMutations,stopObservingMutations:stopObservingMutations,setReactivityEngine:function setReactivityEngine(e){i=e.reactive,o=e.release,r=t=>e.effect(t,{scheduler:e=>{d?scheduler(e):e()}}),s=e.raw},onAttributeRemoved:onAttributeRemoved,onAttributesAdded:onAttributesAdded,closestDataStack:closestDataStack,skipDuringClone:skipDuringClone,onlyDuringClone:function onlyDuringClone(e){return(...t)=>F&&e(...t)},addRootSelector:addRootSelector,addInitSelector:addInitSelector,interceptClone:interceptClone,addScopeToNode:addScopeToNode,deferMutations:function deferMutations(){v=!0},mapAttributes:mapAttributes,evaluateLater:evaluateLater,interceptInit:function interceptInit(e){$.push(e)},setEvaluator:function setEvaluator(e){E=e},mergeProxies:mergeProxies,extractProp:function extractProp(e,t,n,i=!0){if(e._x_bindings&&void 0!==e._x_bindings[t])return e._x_bindings[t];if(e._x_inlineBindings&&void 0!==e._x_inlineBindings[t]){let n=e._x_inlineBindings[t];return n.extract=i,dontAutoEvaluateFunctions(()=>evaluate(e,n.expression))}return getAttributeBinding(e,t,n)},findClosest:findClosest,onElRemoved:onElRemoved,closestRoot:closestRoot,destroyTree:destroyTree,interceptor:interceptor,transition:transition,setStyles:setStyles,mutateDom:mutateDom,directive:directive,entangle:entangle,throttle:throttle,debounce:debounce,evaluate:evaluate,initTree:initTree,nextTick:nextTick,prefixed:prefix,prefix:function setPrefix(e){A=e},plugin:function plugin(e){(Array.isArray(e)?e:[e]).forEach(e=>e(J))},magic:magic,store:function store(e,t){if(V||(z=i(z),V=!0),void 0===t)return z[e];z[e]=t,initInterceptors(z[e]),"object"==typeof t&&null!==t&&t.hasOwnProperty("init")&&"function"==typeof t.init&&z[e].init()},start:function start(){I&&warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),I=!0,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?"),dispatch(document,"alpine:init"),dispatch(document,"alpine:initializing"),startObservingMutations(),function onElAdded(e){h.push(e)}(e=>initTree(e,walk)),onElRemoved(e=>destroyTree(e)),onAttributesAdded((e,t)=>{directives(e,t).forEach(e=>e())}),Array.from(document.querySelectorAll(allSelectors().join(","))).filter(e=>!closestRoot(e.parentElement,!0)).forEach(e=>{initTree(e)}),dispatch(document,"alpine:initialized"),setTimeout(()=>{!function warnAboutMissingPlugins(){[["ui","dialog",["[x-dialog], [x-popover]"]],["anchor","anchor",["[x-anchor]"]],["sort","sort",["[x-sort]"]]].forEach(([e,t,n])=>{(function directiveExists(e){return Object.keys(O).includes(e)})(t)||n.some(t=>{if(document.querySelector(t))return warn(`found "${t}", but missing ${e} plugin`),!0})})}()})},clone:function clone(e,t){t._x_dataStack||(t._x_dataStack=e._x_dataStack),F=!0,G=!0,dontRegisterReactiveSideEffects(()=>{!function cloneTree(e){let t=!1;initTree(e,(e,n)=>{walk(e,(e,i)=>{if(t&&function isRoot(e){return rootSelectors().some(t=>e.matches(t))}(e))return i();t=!0,n(e,i)})})}(t)}),F=!1,G=!1},cloneNode:function cloneNode(e,t){B.forEach(n=>n(e,t)),F=!0,dontRegisterReactiveSideEffects(()=>{initTree(t,(e,t)=>{t(e,()=>{})})}),F=!1},bound:function getBinding(e,t,n){return e._x_bindings&&void 0!==e._x_bindings[t]?e._x_bindings[t]:getAttributeBinding(e,t,n)},$data:scope,watch:watch,walk:walk,data:function data(e,t){W[e]=t},bind:function bind2(e,t){let n="function"!=typeof t?()=>t:t;return e instanceof Element?applyBindingsObject(e,n()):(K[e]=n,()=>{})}},H=class{constructor(e,t,n,i){this.type=e,this.value=t,this.start=n,this.end=i}},Z=class{constructor(e){this.input=e,this.position=0,this.tokens=[]}tokenize(){for(;this.position<this.input.length&&(this.skipWhitespace(),!(this.position>=this.input.length));){const e=this.input[this.position];this.isDigit(e)?this.readNumber():this.isAlpha(e)||"_"===e||"$"===e?this.readIdentifierOrKeyword():'"'===e||"'"===e?this.readString():"/"===e&&"/"===this.peek()?this.skipLineComment():this.readOperatorOrPunctuation()}return this.tokens.push(new H("EOF",null,this.position,this.position)),this.tokens}skipWhitespace(){for(;this.position<this.input.length&&/\s/.test(this.input[this.position]);)this.position++}skipLineComment(){for(;this.position<this.input.length&&"\n"!==this.input[this.position];)this.position++}isDigit(e){return/[0-9]/.test(e)}isAlpha(e){return/[a-zA-Z]/.test(e)}isAlphaNumeric(e){return/[a-zA-Z0-9_$]/.test(e)}peek(e=1){return this.input[this.position+e]||""}readNumber(){const e=this.position;let t=!1;for(;this.position<this.input.length;){const e=this.input[this.position];if(this.isDigit(e))this.position++;else{if("."!==e||t)break;t=!0,this.position++}}const n=this.input.slice(e,this.position);this.tokens.push(new H("NUMBER",parseFloat(n),e,this.position))}readIdentifierOrKeyword(){const e=this.position;for(;this.position<this.input.length&&this.isAlphaNumeric(this.input[this.position]);)this.position++;const t=this.input.slice(e,this.position);["true","false","null","undefined","new","typeof","void","delete","in","instanceof"].includes(t)?"true"===t||"false"===t?this.tokens.push(new H("BOOLEAN","true"===t,e,this.position)):"null"===t?this.tokens.push(new H("NULL",null,e,this.position)):"undefined"===t?this.tokens.push(new H("UNDEFINED",void 0,e,this.position)):this.tokens.push(new H("KEYWORD",t,e,this.position)):this.tokens.push(new H("IDENTIFIER",t,e,this.position))}readString(){const e=this.position,t=this.input[this.position];this.position++;let n="",i=!1;for(;this.position<this.input.length;){const r=this.input[this.position];if(i){switch(r){case"n":n+="\n";break;case"t":n+="\t";break;case"r":n+="\r";break;case"\\":n+="\\";break;case t:n+=t;break;default:n+=r}i=!1}else if("\\"===r)i=!0;else{if(r===t)return this.position++,void this.tokens.push(new H("STRING",n,e,this.position));n+=r}this.position++}throw new Error(`Unterminated string starting at position ${e}`)}readOperatorOrPunctuation(){const e=this.position,t=this.input[this.position],n=this.peek(),i=this.peek(2);if("="===t&&"="===n&&"="===i)this.position+=3,this.tokens.push(new H("OPERATOR","===",e,this.position));else if("!"===t&&"="===n&&"="===i)this.position+=3,this.tokens.push(new H("OPERATOR","!==",e,this.position));else if("="===t&&"="===n)this.position+=2,this.tokens.push(new H("OPERATOR","==",e,this.position));else if("!"===t&&"="===n)this.position+=2,this.tokens.push(new H("OPERATOR","!=",e,this.position));else if("<"===t&&"="===n)this.position+=2,this.tokens.push(new H("OPERATOR","<=",e,this.position));else if(">"===t&&"="===n)this.position+=2,this.tokens.push(new H("OPERATOR",">=",e,this.position));else if("&"===t&&"&"===n)this.position+=2,this.tokens.push(new H("OPERATOR","&&",e,this.position));else if("|"===t&&"|"===n)this.position+=2,this.tokens.push(new H("OPERATOR","||",e,this.position));else if("+"===t&&"+"===n)this.position+=2,this.tokens.push(new H("OPERATOR","++",e,this.position));else if("-"===t&&"-"===n)this.position+=2,this.tokens.push(new H("OPERATOR","--",e,this.position));else{this.position++;const n="()[]{},.;:?".includes(t)?"PUNCTUATION":"OPERATOR";this.tokens.push(new H(n,t,e,this.position))}}},X=class{constructor(e){this.tokens=e,this.position=0}parse(){if(this.isAtEnd())throw new Error("Empty expression");const e=this.parseExpression();if(this.match("PUNCTUATION",";"),!this.isAtEnd())throw new Error(`Unexpected token: ${this.current().value}`);return e}parseExpression(){return this.parseAssignment()}parseAssignment(){const e=this.parseTernary();if(this.match("OPERATOR","=")){const t=this.parseAssignment();if("Identifier"===e.type||"MemberExpression"===e.type)return{type:"AssignmentExpression",left:e,operator:"=",right:t};throw new Error("Invalid assignment target")}return e}parseTernary(){const e=this.parseLogicalOr();if(this.match("PUNCTUATION","?")){const t=this.parseExpression();this.consume("PUNCTUATION",":");return{type:"ConditionalExpression",test:e,consequent:t,alternate:this.parseExpression()}}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.match("OPERATOR","||");){e={type:"BinaryExpression",operator:this.previous().value,left:e,right:this.parseLogicalAnd()}}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.match("OPERATOR","&&");){e={type:"BinaryExpression",operator:this.previous().value,left:e,right:this.parseEquality()}}return e}parseEquality(){let e=this.parseRelational();for(;this.match("OPERATOR","==","!=","===","!==");){e={type:"BinaryExpression",operator:this.previous().value,left:e,right:this.parseRelational()}}return e}parseRelational(){let e=this.parseAdditive();for(;this.match("OPERATOR","<",">","<=",">=");){e={type:"BinaryExpression",operator:this.previous().value,left:e,right:this.parseAdditive()}}return e}parseAdditive(){let e=this.parseMultiplicative();for(;this.match("OPERATOR","+","-");){e={type:"BinaryExpression",operator:this.previous().value,left:e,right:this.parseMultiplicative()}}return e}parseMultiplicative(){let e=this.parseUnary();for(;this.match("OPERATOR","*","/","%");){e={type:"BinaryExpression",operator:this.previous().value,left:e,right:this.parseUnary()}}return e}parseUnary(){if(this.match("OPERATOR","++","--")){return{type:"UpdateExpression",operator:this.previous().value,argument:this.parseUnary(),prefix:!0}}if(this.match("OPERATOR","!","-","+")){return{type:"UnaryExpression",operator:this.previous().value,argument:this.parseUnary(),prefix:!0}}return this.parsePostfix()}parsePostfix(){let e=this.parseMember();if(this.match("OPERATOR","++","--")){return{type:"UpdateExpression",operator:this.previous().value,argument:e,prefix:!1}}return e}parseMember(){let e=this.parsePrimary();for(;;)if(this.match("PUNCTUATION",".")){e={type:"MemberExpression",object:e,property:{type:"Identifier",name:this.consume("IDENTIFIER").value},computed:!1}}else if(this.match("PUNCTUATION","[")){const t=this.parseExpression();this.consume("PUNCTUATION","]"),e={type:"MemberExpression",object:e,property:t,computed:!0}}else{if(!this.match("PUNCTUATION","("))break;e={type:"CallExpression",callee:e,arguments:this.parseArguments()}}return e}parseArguments(){const e=[];if(!this.check("PUNCTUATION",")"))do{e.push(this.parseExpression())}while(this.match("PUNCTUATION",","));return this.consume("PUNCTUATION",")"),e}parsePrimary(){if(this.match("NUMBER"))return{type:"Literal",value:this.previous().value};if(this.match("STRING"))return{type:"Literal",value:this.previous().value};if(this.match("BOOLEAN"))return{type:"Literal",value:this.previous().value};if(this.match("NULL"))return{type:"Literal",value:null};if(this.match("UNDEFINED"))return{type:"Literal",value:void 0};if(this.match("IDENTIFIER"))return{type:"Identifier",name:this.previous().value};if(this.match("PUNCTUATION","(")){const e=this.parseExpression();return this.consume("PUNCTUATION",")"),e}if(this.match("PUNCTUATION","["))return this.parseArrayLiteral();if(this.match("PUNCTUATION","{"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${this.current().type} "${this.current().value}"`)}parseArrayLiteral(){const e=[];for(;!this.check("PUNCTUATION","]")&&!this.isAtEnd()&&(e.push(this.parseExpression()),this.match("PUNCTUATION",","))&&!this.check("PUNCTUATION","]"););return this.consume("PUNCTUATION","]"),{type:"ArrayExpression",elements:e}}parseObjectLiteral(){const e=[];for(;!this.check("PUNCTUATION","}")&&!this.isAtEnd();){let t,n=!1;if(this.match("STRING"))t={type:"Literal",value:this.previous().value};else if(this.match("IDENTIFIER")){t={type:"Identifier",name:this.previous().value}}else{if(!this.match("PUNCTUATION","["))throw new Error("Expected property key");t=this.parseExpression(),n=!0,this.consume("PUNCTUATION","]")}this.consume("PUNCTUATION",":");const i=this.parseExpression();if(e.push({type:"Property",key:t,value:i,computed:n,shorthand:!1}),!this.match("PUNCTUATION",","))break;if(this.check("PUNCTUATION","}"))break}return this.consume("PUNCTUATION","}"),{type:"ObjectExpression",properties:e}}match(...e){for(let t=0;t<e.length;t++){const n=e[t];if(0===t&&e.length>1){const t=n;for(let n=1;n<e.length;n++)if(this.check(t,e[n]))return this.advance(),!0;return!1}if(1===e.length)return!!this.checkType(n)&&(this.advance(),!0)}return!1}check(e,t){return!this.isAtEnd()&&(void 0!==t?this.current().type===e&&this.current().value===t:this.current().type===e)}checkType(e){return!this.isAtEnd()&&this.current().type===e}advance(){return this.isAtEnd()||this.position++,this.previous()}isAtEnd(){return"EOF"===this.current().type}current(){return this.tokens[this.position]}previous(){return this.tokens[this.position-1]}consume(e,t){if(void 0!==t){if(this.check(e,t))return this.advance();throw new Error(`Expected ${e} "${t}" but got ${this.current().type} "${this.current().value}"`)}if(this.check(e))return this.advance();throw new Error(`Expected ${e} but got ${this.current().type} "${this.current().value}"`)}},Y=class{evaluate({node:e,scope:t={},context:n=null,allowGlobal:i=!1,forceBindingRootScopeToFunctions:r=!0}){switch(e.type){case"Literal":return e.value;case"Identifier":if(e.name in t){const n=t[e.name];return"function"==typeof n?n.bind(t):n}if(i&&void 0!==globalThis[e.name]){const t=globalThis[e.name];return"function"==typeof t?t.bind(globalThis):t}throw new Error(`Undefined variable: ${e.name}`);case"MemberExpression":const o=this.evaluate({node:e.object,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});if(null==o)throw new Error("Cannot read property of null or undefined");let s;if(e.computed){s=o[this.evaluate({node:e.property,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r})]}else s=o[e.property.name];return"function"==typeof s?r?s.bind(t):s.bind(o):s;case"CallExpression":const a=e.arguments.map(e=>this.evaluate({node:e,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}));if("MemberExpression"===e.callee.type){const o=this.evaluate({node:e.callee.object,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});let s;if(e.callee.computed){s=o[this.evaluate({node:e.callee.property,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r})]}else s=o[e.callee.property.name];if("function"!=typeof s)throw new Error("Value is not a function");return s.apply(o,a)}if("Identifier"===e.callee.type){const r=e.callee.name;let o;if(r in t)o=t[r];else{if(!i||void 0===globalThis[r])throw new Error(`Undefined variable: ${r}`);o=globalThis[r]}if("function"!=typeof o)throw new Error("Value is not a function");const s=null!==n?n:t;return o.apply(s,a)}{const o=this.evaluate({node:e.callee,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});if("function"!=typeof o)throw new Error("Value is not a function");return o.apply(n,a)}case"UnaryExpression":const l=this.evaluate({node:e.argument,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});switch(e.operator){case"!":return!l;case"-":return-l;case"+":return+l;default:throw new Error(`Unknown unary operator: ${e.operator}`)}case"UpdateExpression":if("Identifier"===e.argument.type){const n=e.argument.name;if(!(n in t))throw new Error(`Undefined variable: ${n}`);const i=t[n];return"++"===e.operator?t[n]=i+1:"--"===e.operator&&(t[n]=i-1),e.prefix?t[n]:i}if("MemberExpression"===e.argument.type){const o=this.evaluate({node:e.argument.object,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}),s=e.argument.computed?this.evaluate({node:e.argument.property,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}):e.argument.property.name,a=o[s];return"++"===e.operator?o[s]=a+1:"--"===e.operator&&(o[s]=a-1),e.prefix?o[s]:a}throw new Error("Invalid update expression target");case"BinaryExpression":const c=this.evaluate({node:e.left,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}),u=this.evaluate({node:e.right,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});switch(e.operator){case"+":return c+u;case"-":return c-u;case"*":return c*u;case"/":return c/u;case"%":return c%u;case"==":return c==u;case"!=":return c!=u;case"===":return c===u;case"!==":return c!==u;case"<":return c<u;case">":return c>u;case"<=":return c<=u;case">=":return c>=u;case"&&":return c&&u;case"||":return c||u;default:throw new Error(`Unknown binary operator: ${e.operator}`)}case"ConditionalExpression":return this.evaluate({node:e.test,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r})?this.evaluate({node:e.consequent,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}):this.evaluate({node:e.alternate,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});case"AssignmentExpression":const d=this.evaluate({node:e.right,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});if("Identifier"===e.left.type)return t[e.left.name]=d,d;if("MemberExpression"===e.left.type){const o=this.evaluate({node:e.left.object,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});if(e.left.computed){o[this.evaluate({node:e.left.property,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r})]=d}else o[e.left.property.name]=d;return d}throw new Error("Invalid assignment target");case"ArrayExpression":return e.elements.map(e=>this.evaluate({node:e,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}));case"ObjectExpression":const p={};for(const o of e.properties){const e=o.computed?this.evaluate({node:o.key,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}):"Identifier"===o.key.type?o.key.name:this.evaluate({node:o.key,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r}),s=this.evaluate({node:o.value,scope:t,context:n,allowGlobal:i,forceBindingRootScopeToFunctions:r});p[e]=s}return p;default:throw new Error(`Unknown node type: ${e.type}`)}}};function makeMap(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}var Q,ee=Object.freeze({}),te=(Object.freeze([]),Object.prototype.hasOwnProperty),hasOwn=(e,t)=>te.call(e,t),ne=Array.isArray,isMap=e=>"[object Map]"===toTypeString(e),isSymbol=e=>"symbol"==typeof e,isObject=e=>null!==e&&"object"==typeof e,ie=Object.prototype.toString,toTypeString=e=>ie.call(e),toRawType=e=>toTypeString(e).slice(8,-1),isIntegerKey=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,cacheStringFunction=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},re=/-(\w)/g,oe=(cacheStringFunction(e=>e.replace(re,(e,t)=>t?t.toUpperCase():"")),/\B([A-Z])/g),se=(cacheStringFunction(e=>e.replace(oe,"-$1").toLowerCase()),cacheStringFunction(e=>e.charAt(0).toUpperCase()+e.slice(1))),ae=(cacheStringFunction(e=>e?`on${se(e)}`:""),(e,t)=>e!==t&&(e==e||t==t)),le=new WeakMap,ce=[],ue=Symbol("iterate"),de=Symbol("Map key iterate");var pe=0;function cleanup(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}var fe=!0,he=[];function resetTracking(){const e=he.pop();fe=void 0===e||e}function track(e,t,n){if(!fe||void 0===Q)return;let i=le.get(e);i||le.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=new Set),r.has(Q)||(r.add(Q),Q.deps.push(r),Q.options.onTrack&&Q.options.onTrack({effect:Q,target:e,type:t,key:n}))}function trigger(e,t,n,i,r,o){const s=le.get(e);if(!s)return;const a=new Set,add2=e=>{e&&e.forEach(e=>{(e!==Q||e.allowRecurse)&&a.add(e)})};if("clear"===t)s.forEach(add2);else if("length"===n&&ne(e))s.forEach((e,t)=>{("length"===t||t>=i)&&add2(e)});else switch(void 0!==n&&add2(s.get(n)),t){case"add":ne(e)?isIntegerKey(n)&&add2(s.get("length")):(add2(s.get(ue)),isMap(e)&&add2(s.get(de)));break;case"delete":ne(e)||(add2(s.get(ue)),isMap(e)&&add2(s.get(de)));break;case"set":isMap(e)&&add2(s.get(ue))}a.forEach(s=>{s.options.onTrigger&&s.options.onTrigger({effect:s,target:e,key:n,type:t,newValue:i,oldValue:r,oldTarget:o}),s.options.scheduler?s.options.scheduler(s):s()})}var me=makeMap("__proto__,__v_isRef,__isVue"),_e=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(isSymbol)),ge=createGetter(),ve=createGetter(!0),ye=createArrayInstrumentations();function createArrayInstrumentations(){const e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...e){const n=toRaw(this);for(let e=0,t=this.length;e<t;e++)track(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(toRaw)):i}}),["push","pop","shift","unshift","splice"].forEach(t=>{e[t]=function(...e){!function pauseTracking(){he.push(fe),fe=!1}();const n=toRaw(this)[t].apply(this,e);return resetTracking(),n}}),e}function createGetter(e=!1,t=!1){return function get3(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_raw"===i&&r===(e?t?Ne:Ce:t?Se:Re).get(n))return n;const o=ne(n);if(!e&&o&&hasOwn(ye,i))return Reflect.get(ye,i,r);const s=Reflect.get(n,i,r);if(isSymbol(i)?_e.has(i):me(i))return s;if(e||track(n,"get",i),t)return s;if(isRef(s)){return!o||!isIntegerKey(i)?s.value:s}return isObject(s)?e?readonly(s):reactive2(s):s}}function createSetter(e=!1){return function set3(t,n,i,r){let o=t[n];if(!e&&(i=toRaw(i),o=toRaw(o),!ne(t)&&isRef(o)&&!isRef(i)))return o.value=i,!0;const s=ne(t)&&isIntegerKey(n)?Number(n)<t.length:hasOwn(t,n),a=Reflect.set(t,n,i,r);return t===toRaw(r)&&(s?ae(i,o)&&trigger(t,"set",n,i,o):trigger(t,"add",n,i)),a}}var xe={get:ge,set:createSetter(),deleteProperty:function deleteProperty(e,t){const n=hasOwn(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&trigger(e,"delete",t,void 0,i),r},has:function has(e,t){const n=Reflect.has(e,t);return isSymbol(t)&&_e.has(t)||track(e,"has",t),n},ownKeys:function ownKeys(e){return track(e,"iterate",ne(e)?"length":ue),Reflect.ownKeys(e)}},be={get:ve,set(e,t){return console.warn(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0},deleteProperty(e,t){return console.warn(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},toReactive=e=>isObject(e)?reactive2(e):e,toReadonly=e=>isObject(e)?readonly(e):e,toShallow=e=>e,getProto=e=>Reflect.getPrototypeOf(e);function get$1(e,t,n=!1,i=!1){const r=toRaw(e=e.__v_raw),o=toRaw(t);t!==o&&!n&&track(r,"get",t),!n&&track(r,"get",o);const{has:s}=getProto(r),a=i?toShallow:n?toReadonly:toReactive;return s.call(r,t)?a(e.get(t)):s.call(r,o)?a(e.get(o)):void(e!==r&&e.get(t))}function has$1(e,t=!1){const n=this.__v_raw,i=toRaw(n),r=toRaw(e);return e!==r&&!t&&track(i,"has",e),!t&&track(i,"has",r),e===r?n.has(e):n.has(e)||n.has(r)}function size(e,t=!1){return e=e.__v_raw,!t&&track(toRaw(e),"iterate",ue),Reflect.get(e,"size",e)}function add(e){e=toRaw(e);const t=toRaw(this);return getProto(t).has.call(t,e)||(t.add(e),trigger(t,"add",e,e)),this}function set$1(e,t){t=toRaw(t);const n=toRaw(this),{has:i,get:r}=getProto(n);let o=i.call(n,e);o?checkIdentityKeys(n,i,e):(e=toRaw(e),o=i.call(n,e));const s=r.call(n,e);return n.set(e,t),o?ae(t,s)&&trigger(n,"set",e,t,s):trigger(n,"add",e,t),this}function deleteEntry(e){const t=toRaw(this),{has:n,get:i}=getProto(t);let r=n.call(t,e);r?checkIdentityKeys(t,n,e):(e=toRaw(e),r=n.call(t,e));const o=i?i.call(t,e):void 0,s=t.delete(e);return r&&trigger(t,"delete",e,void 0,o),s}function clear(){const e=toRaw(this),t=0!==e.size,n=isMap(e)?new Map(e):new Set(e),i=e.clear();return t&&trigger(e,"clear",void 0,void 0,n),i}function createForEach(e,t){return function forEach(n,i){const r=this,o=r.__v_raw,s=toRaw(o),a=t?toShallow:e?toReadonly:toReactive;return!e&&track(s,"iterate",ue),o.forEach((e,t)=>n.call(i,a(e),a(t),r))}}function createIterableMethod(e,t,n){return function(...i){const r=this.__v_raw,o=toRaw(r),s=isMap(o),a="entries"===e||e===Symbol.iterator&&s,l="keys"===e&&s,c=r[e](...i),u=n?toShallow:t?toReadonly:toReactive;return!t&&track(o,"iterate",l?de:ue),{next(){const{value:e,done:t}=c.next();return t?{value:e,done:t}:{value:a?[u(e[0]),u(e[1])]:u(e),done:t}},[Symbol.iterator](){return this}}}}function createReadonlyMethod(e){return function(...t){{const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${se(e)} operation ${n}failed: target is readonly.`,toRaw(this))}return"delete"!==e&&this}}function createInstrumentations(){const e={get(e){return get$1(this,e)},get size(){return size(this)},has:has$1,add:add,set:set$1,delete:deleteEntry,clear:clear,forEach:createForEach(!1,!1)},t={get(e){return get$1(this,e,!1,!0)},get size(){return size(this)},has:has$1,add:add,set:set$1,delete:deleteEntry,clear:clear,forEach:createForEach(!1,!0)},n={get(e){return get$1(this,e,!0)},get size(){return size(this,!0)},has(e){return has$1.call(this,e,!0)},add:createReadonlyMethod("add"),set:createReadonlyMethod("set"),delete:createReadonlyMethod("delete"),clear:createReadonlyMethod("clear"),forEach:createForEach(!0,!1)},i={get(e){return get$1(this,e,!0,!0)},get size(){return size(this,!0)},has(e){return has$1.call(this,e,!0)},add:createReadonlyMethod("add"),set:createReadonlyMethod("set"),delete:createReadonlyMethod("delete"),clear:createReadonlyMethod("clear"),forEach:createForEach(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(r=>{e[r]=createIterableMethod(r,!1,!1),n[r]=createIterableMethod(r,!0,!1),t[r]=createIterableMethod(r,!1,!0),i[r]=createIterableMethod(r,!0,!0)}),[e,n,t,i]}var[we,Ee,ke,Ae]=createInstrumentations();function createInstrumentationGetter(e,t){const n=t?e?Ae:ke:e?Ee:we;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(hasOwn(n,i)&&i in t?n:t,i,r)}var Oe={get:createInstrumentationGetter(!1,!1)},Te={get:createInstrumentationGetter(!0,!1)};function checkIdentityKeys(e,t,n){const i=toRaw(n);if(i!==n&&t.call(e,i)){const t=toRawType(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" 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.`)}}var Re=new WeakMap,Se=new WeakMap,Ce=new WeakMap,Ne=new WeakMap;function reactive2(e){return e&&e.__v_isReadonly?e:createReactiveObject(e,!1,xe,Oe,Re)}function readonly(e){return createReactiveObject(e,!0,be,Te,Ce)}function createReactiveObject(e,t,n,i,r){if(!isObject(e))return console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const o=r.get(e);if(o)return o;const s=function getTargetType(e){return e.__v_skip||!Object.isExtensible(e)?0:function targetTypeMap(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(toRawType(e))}(e);if(0===s)return e;const a=new Proxy(e,2===s?i:n);return r.set(e,a),a}function toRaw(e){return e&&toRaw(e.__v_raw)||e}function isRef(e){return Boolean(e&&!0===e.__v_isRef)}magic("nextTick",()=>nextTick),magic("dispatch",e=>dispatch.bind(dispatch,e)),magic("watch",(e,{evaluateLater:t,cleanup:n})=>(e,i)=>{let r=t(e),o=watch(()=>{let e;return r(t=>e=t),e},i);n(o)}),magic("store",function getStores(){return z}),magic("data",e=>scope(e)),magic("root",e=>closestRoot(e)),magic("refs",e=>(e._x_refs_proxy||(e._x_refs_proxy=mergeProxies(function getArrayOfRefObject(e){let t=[];return findClosest(e,e=>{e._x_refs&&t.push(e._x_refs)}),t}(e))),e._x_refs_proxy));var Pe={};function findAndIncrementId(e){return Pe[e]||(Pe[e]=0),++Pe[e]}function warnMissingPluginMagic(e,t,n){magic(t,i=>warn(`You can't use [$${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${n}`,i))}magic("id",(e,{cleanup:t})=>(n,i=null)=>function cacheIdByNameOnElement(e,t,n,i){e._x_id||(e._x_id={});if(e._x_id[t])return e._x_id[t];let r=i();return e._x_id[t]=r,n(()=>{delete e._x_id[t]}),r}(e,`${n}${i?`-${i}`:""}`,t,()=>{let t=function closestIdRoot(e,t){return findClosest(e,e=>{if(e._x_ids&&e._x_ids[t])return!0})}(e,n),r=t?t._x_ids[n]:findAndIncrementId(n);return i?`${n}-${r}-${i}`:`${n}-${r}`})),interceptClone((e,t)=>{e._x_id&&(t._x_id=e._x_id)}),magic("el",e=>e),warnMissingPluginMagic("Focus","focus","focus"),warnMissingPluginMagic("Persist","persist","persist"),directive("modelable",(e,{expression:t},{effect:n,evaluateLater:i,cleanup:r})=>{let o=i(t),innerGet=()=>{let e;return o(t=>e=t),e},s=i(`${t} = __placeholder`),innerSet=e=>s(()=>{},{scope:{__placeholder:e}}),a=innerGet();innerSet(a),queueMicrotask(()=>{if(!e._x_model)return;e._x_removeModelListeners.default();let t=e._x_model.get,n=e._x_model.set,i=entangle({get(){return t()},set(e){n(e)}},{get(){return innerGet()},set(e){innerSet(e)}});r(i)})}),directive("teleport",(e,{modifiers:t,expression:n},{cleanup:i})=>{"template"!==e.tagName.toLowerCase()&&warn("x-teleport can only be used on a <template> tag",e);let r=getTarget(n),o=e.content.cloneNode(!0).firstElementChild;e._x_teleport=o,o._x_teleportBack=e,e.setAttribute("data-teleport-template",!0),o.setAttribute("data-teleport-target",!0),e._x_forwardEvents&&e._x_forwardEvents.forEach(t=>{o.addEventListener(t,t=>{t.stopPropagation(),e.dispatchEvent(new t.constructor(t.type,t))})}),addScopeToNode(o,{},e);let placeInDom=(e,t,n)=>{n.includes("prepend")?t.parentNode.insertBefore(e,t):n.includes("append")?t.parentNode.insertBefore(e,t.nextSibling):t.appendChild(e)};mutateDom(()=>{placeInDom(o,r,t),skipDuringClone(()=>{initTree(o)})()}),e._x_teleportPutBack=()=>{let i=getTarget(n);mutateDom(()=>{placeInDom(e._x_teleport,i,t)})},i(()=>mutateDom(()=>{o.remove(),destroyTree(o)}))});var Ie=document.createElement("div");function getTarget(e){let t=skipDuringClone(()=>document.querySelector(e),()=>Ie)();return t||warn(`Cannot find x-teleport element for selector: "${e}"`),t}var handler=()=>{};function on(e,t,n,i){let r=e,handler4=e=>i(e),o={},wrapHandler=(e,t)=>n=>t(e,n);if(n.includes("dot")&&(t=function dotSyntax(e){return e.replace(/-/g,".")}(t)),n.includes("camel")&&(t=function camelCase2(e){return e.toLowerCase().replace(/-(\w)/g,(e,t)=>t.toUpperCase())}(t)),n.includes("passive")&&(o.passive=!0),n.includes("capture")&&(o.capture=!0),n.includes("window")&&(r=window),n.includes("document")&&(r=document),n.includes("debounce")){let e=n[n.indexOf("debounce")+1]||"invalid-wait",t=isNumeric(e.split("ms")[0])?Number(e.split("ms")[0]):250;handler4=debounce(handler4,t)}if(n.includes("throttle")){let e=n[n.indexOf("throttle")+1]||"invalid-wait",t=isNumeric(e.split("ms")[0])?Number(e.split("ms")[0]):250;handler4=throttle(handler4,t)}return n.includes("prevent")&&(handler4=wrapHandler(handler4,(e,t)=>{t.preventDefault(),e(t)})),n.includes("stop")&&(handler4=wrapHandler(handler4,(e,t)=>{t.stopPropagation(),e(t)})),n.includes("once")&&(handler4=wrapHandler(handler4,(e,n)=>{e(n),r.removeEventListener(t,handler4,o)})),(n.includes("away")||n.includes("outside"))&&(r=document,handler4=wrapHandler(handler4,(t,n)=>{e.contains(n.target)||!1!==n.target.isConnected&&(e.offsetWidth<1&&e.offsetHeight<1||!1!==e._x_isShown&&t(n))})),n.includes("self")&&(handler4=wrapHandler(handler4,(t,n)=>{n.target===e&&t(n)})),(function isKeyEvent(e){return["keydown","keyup"].includes(e)}(t)||isClickEvent(t))&&(handler4=wrapHandler(handler4,(e,t)=>{(function isListeningForASpecificKeyThatHasntBeenPressed(e,t){let n=t.filter(e=>!["window","document","prevent","stop","once","capture","self","away","outside","passive","preserve-scroll"].includes(e));if(n.includes("debounce")){let e=n.indexOf("debounce");n.splice(e,isNumeric((n[e+1]||"invalid-wait").split("ms")[0])?2:1)}if(n.includes("throttle")){let e=n.indexOf("throttle");n.splice(e,isNumeric((n[e+1]||"invalid-wait").split("ms")[0])?2:1)}if(0===n.length)return!1;if(1===n.length&&keyToModifiers(e.key).includes(n[0]))return!1;const i=["ctrl","shift","alt","meta","cmd","super"].filter(e=>n.includes(e));if(n=n.filter(e=>!i.includes(e)),i.length>0){if(i.filter(t=>("cmd"!==t&&"super"!==t||(t="meta"),e[`${t}Key`])).length===i.length){if(isClickEvent(e.type))return!1;if(keyToModifiers(e.key).includes(n[0]))return!1}}return!0})(t,n)||e(t)})),r.addEventListener(t,handler4,o),()=>{r.removeEventListener(t,handler4,o)}}function isNumeric(e){return!Array.isArray(e)&&!isNaN(e)}function isClickEvent(e){return["contextmenu","click","mouse"].some(t=>e.includes(t))}function keyToModifiers(e){if(!e)return[];e=function kebabCase2(e){return[" ","_"].includes(e)?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()}(e);let t={ctrl:"control",slash:"/",space:" ",spacebar:" ",cmd:"meta",esc:"escape",up:"arrow-up",down:"arrow-down",left:"arrow-left",right:"arrow-right",period:".",comma:",",equal:"=",minus:"-",underscore:"_"};return t[e]=e,Object.keys(t).map(n=>{if(t[n]===e)return n}).filter(e=>e)}function getInputValue(e,t,n,i){return mutateDom(()=>{if(n instanceof CustomEvent&&void 0!==n.detail)return null!==n.detail&&void 0!==n.detail?n.detail:n.target.value;if(isCheckbox(e)){if(Array.isArray(i)){let e=null;return e=t.includes("number")?safeParseNumber(n.target.value):t.includes("boolean")?safeParseBoolean(n.target.value):n.target.value,n.target.checked?i.includes(e)?i:i.concat([e]):i.filter(t=>!function checkedAttrLooseCompare2(e,t){return e==t}(t,e))}return n.target.checked}if("select"===e.tagName.toLowerCase()&&e.multiple)return t.includes("number")?Array.from(n.target.selectedOptions).map(e=>safeParseNumber(e.value||e.text)):t.includes("boolean")?Array.from(n.target.selectedOptions).map(e=>safeParseBoolean(e.value||e.text)):Array.from(n.target.selectedOptions).map(e=>e.value||e.text);{let r;return r=isRadio(e)?n.target.checked?n.target.value:i:n.target.value,t.includes("number")?safeParseNumber(r):t.includes("boolean")?safeParseBoolean(r):t.includes("trim")?r.trim():r}})}function safeParseNumber(e){let t=e?parseFloat(e):null;return function isNumeric2(e){return!Array.isArray(e)&&!isNaN(e)}(t)?t:e}function isGetterSetter(e){return null!==e&&"object"==typeof e&&"function"==typeof e.get&&"function"==typeof e.set}handler.inline=(e,{modifiers:t},{cleanup:n})=>{t.includes("self")?e._x_ignoreSelf=!0:e._x_ignore=!0,n(()=>{t.includes("self")?delete e._x_ignoreSelf:delete e._x_ignore})},directive("ignore",handler),directive("effect",skipDuringClone((e,{expression:t},{effect:n})=>{n(evaluateLater(e,t))})),directive("model",(e,{modifiers:t,expression:n},{effect:i,cleanup:r})=>{let o=e;t.includes("parent")&&(o=e.parentNode);let s,a=evaluateLater(o,n);s="string"==typeof n?evaluateLater(o,`${n} = __placeholder`):"function"==typeof n&&"string"==typeof n()?evaluateLater(o,`${n()} = __placeholder`):()=>{};let getValue=()=>{let e;return a(t=>e=t),isGetterSetter(e)?e.get():e},setValue=e=>{let t;a(e=>t=e),isGetterSetter(t)?t.set(e):s(()=>{},{scope:{__placeholder:e}})};"string"==typeof n&&"radio"===e.type&&mutateDom(()=>{e.hasAttribute("name")||e.setAttribute("name",n)});let l="select"===e.tagName.toLowerCase()||["checkbox","radio"].includes(e.type)||t.includes("lazy")?"change":"input",c=F?()=>{}:on(e,l,t,n=>{setValue(getInputValue(e,t,n,getValue()))});if(t.includes("fill")&&([void 0,null,""].includes(getValue())||isCheckbox(e)&&Array.isArray(getValue())||"select"===e.tagName.toLowerCase()&&e.multiple)&&setValue(getInputValue(e,t,{target:e},getValue())),e._x_removeModelListeners||(e._x_removeModelListeners={}),e._x_removeModelListeners.default=c,r(()=>e._x_removeModelListeners.default()),e.form){let n=on(e.form,"reset",[],n=>{nextTick(()=>e._x_model&&e._x_model.set(getInputValue(e,t,{target:e},getValue())))});r(()=>n())}e._x_model={get(){return getValue()},set(e){setValue(e)}},e._x_forceModelUpdate=t=>{void 0===t&&"string"==typeof n&&n.match(/\./)&&(t=""),window.fromModel=!0,mutateDom(()=>bind(e,"value",t)),delete window.fromModel},i(()=>{let n=getValue();t.includes("unintrusive")&&document.activeElement.isSameNode(e)||e._x_forceModelUpdate(n)})}),directive("cloak",e=>queueMicrotask(()=>mutateDom(()=>e.removeAttribute(prefix("cloak"))))),addInitSelector(()=>`[${prefix("init")}]`),directive("init",skipDuringClone((e,{expression:t},{evaluate:n})=>"string"==typeof t?!!t.trim()&&n(t,{},!1):n(t,{},!1))),directive("text",(e,{expression:t},{effect:n,evaluateLater:i})=>{let r=i(t);n(()=>{r(t=>{mutateDom(()=>{e.textContent=t})})})}),directive("html",(e,{expression:t},{effect:n,evaluateLater:i})=>{let r=i(t);n(()=>{r(t=>{mutateDom(()=>{e.innerHTML=t,e._x_ignoreSelf=!0,initTree(e),delete e._x_ignoreSelf})})})}),mapAttributes(startingWith(":",prefix("bind:")));var handler2=(e,{value:t,modifiers:n,expression:i,original:r},{effect:o,cleanup:s})=>{if(!t){let t={};return function injectBindingProviders(e){return Object.entries(K).forEach(([t,n])=>{Object.defineProperty(e,t,{get(){return(...e)=>n(...e)}})}),e}(t),void evaluateLater(e,i)(t=>{applyBindingsObject(e,t,r)},{scope:t})}if("key"===t)return function storeKeyForXFor(e,t){e._x_keyExpression=t}(e,i);if(e._x_inlineBindings&&e._x_inlineBindings[t]&&e._x_inlineBindings[t].extract)return;let a=evaluateLater(e,i);o(()=>a(r=>{void 0===r&&"string"==typeof i&&i.match(/\./)&&(r=""),mutateDom(()=>bind(e,t,r,n))})),s(()=>{e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedStyles&&e._x_undoAddedStyles()})};function getIterationScopeVariables(e,t,n,i){let r={};if(/^\[.*\]$/.test(e.item)&&Array.isArray(t)){e.item.replace("[","").replace("]","").split(",").map(e=>e.trim()).forEach((e,n)=>{r[e]=t[n]})}else if(/^\{.*\}$/.test(e.item)&&!Array.isArray(t)&&"object"==typeof t){e.item.replace("{","").replace("}","").split(",").map(e=>e.trim()).forEach(e=>{r[e]=t[e]})}else r[e.item]=t;return e.index&&(r[e.index]=n),e.collection&&(r[e.collection]=i),r}function handler3(){}function warnMissingPluginDirective(e,t,n){directive(t,i=>warn(`You can't use [x-${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${n}`,i))}handler2.inline=(e,{value:t,modifiers:n,expression:i})=>{t&&(e._x_inlineBindings||(e._x_inlineBindings={}),e._x_inlineBindings[t]={expression:i,extract:!1})},directive("bind",handler2),addRootSelector(()=>`[${prefix("data")}]`),directive("data",(e,{expression:t},{cleanup:n})=>{if(function shouldSkipRegisteringDataDuringClone(e){return!!F&&(!!G||e.hasAttribute("data-has-alpine-state"))}(e))return;t=""===t?"{}":t;let r={};injectMagics(r,e);let o={};!function injectDataProviders(e,t){return Object.entries(W).forEach(([n,i])=>{Object.defineProperty(e,n,{get(){return(...e)=>i.bind(t)(...e)},enumerable:!1})}),e}(o,r);let s=evaluate(e,t,{scope:o});void 0!==s&&!0!==s||(s={}),injectMagics(s,e);let a=i(s);initInterceptors(a);let l=addScopeToNode(e,a);a.init&&evaluate(e,a.init),n(()=>{a.destroy&&evaluate(e,a.destroy),l()})}),interceptClone((e,t)=>{e._x_dataStack&&(t._x_dataStack=e._x_dataStack,t.setAttribute("data-has-alpine-state",!0))}),directive("show",(e,{modifiers:t,expression:n},{effect:i})=>{let r=evaluateLater(e,n);e._x_doHide||(e._x_doHide=()=>{mutateDom(()=>{e.style.setProperty("display","none",t.includes("important")?"important":void 0)})}),e._x_doShow||(e._x_doShow=()=>{mutateDom(()=>{1===e.style.length&&"none"===e.style.display?e.removeAttribute("style"):e.style.removeProperty("display")})});let o,hide=()=>{e._x_doHide(),e._x_isShown=!1},show=()=>{e._x_doShow(),e._x_isShown=!0},clickAwayCompatibleShow=()=>setTimeout(show),s=once(e=>e?show():hide(),t=>{"function"==typeof e._x_toggleAndCascadeWithTransitions?e._x_toggleAndCascadeWithTransitions(e,t,show,hide):t?clickAwayCompatibleShow():hide()}),a=!0;i(()=>r(e=>{(a||e!==o)&&(t.includes("immediate")&&(e?clickAwayCompatibleShow():hide()),s(e),o=e,a=!1)}))}),directive("for",(e,{expression:t},{effect:n,cleanup:r})=>{let o=function parseForExpression(e){let t=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,n=/^\s*\(|\)\s*$/g,i=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,r=e.match(i);if(!r)return;let o={};o.items=r[2].trim();let s=r[1].replace(n,"").trim(),a=s.match(t);a?(o.item=s.replace(t,"").trim(),o.index=a[1].trim(),a[2]&&(o.collection=a[2].trim())):o.item=s;return o}(t),s=evaluateLater(e,o.items),a=evaluateLater(e,e._x_keyExpression||"index");e._x_prevKeys=[],e._x_lookup={},n(()=>function loop(e,t,n,r){let isObject2=e=>"object"==typeof e&&!Array.isArray(e),o=e;n(n=>{(function isNumeric3(e){return!Array.isArray(e)&&!isNaN(e)})(n)&&n>=0&&(n=Array.from(Array(n).keys(),e=>e+1)),void 0===n&&(n=[]);let s=e._x_lookup,a=e._x_prevKeys,l=[],c=[];if(isObject2(n))n=Object.entries(n).map(([i,o])=>{let s=getIterationScopeVariables(t,o,i,n);r(t=>{c.includes(t)&&warn("Duplicate key on x-for",e),c.push(t)},{scope:{index:i,...s}}),l.push(s)});else for(let i=0;i<n.length;i++){let o=getIterationScopeVariables(t,n[i],i,n);r(t=>{c.includes(t)&&warn("Duplicate key on x-for",e),c.push(t)},{scope:{index:i,...o}}),l.push(o)}let u=[],d=[],p=[],f=[];for(let e=0;e<a.length;e++){let t=a[e];-1===c.indexOf(t)&&p.push(t)}a=a.filter(e=>!p.includes(e));let h="template";for(let e=0;e<c.length;e++){let t=c[e],n=a.indexOf(t);if(-1===n)a.splice(e,0,t),u.push([h,e]);else if(n!==e){let t=a.splice(e,1)[0],i=a.splice(n-1,1)[0];a.splice(e,0,i),a.splice(n,0,t),d.push([t,i])}else f.push(t);h=t}for(let e=0;e<p.length;e++){let t=p[e];t in s&&(mutateDom(()=>{destroyTree(s[t]),s[t].remove()}),delete s[t])}for(let e=0;e<d.length;e++){let[t,n]=d[e],i=s[t],r=s[n],a=document.createElement("div");mutateDom(()=>{r||warn('x-for ":key" is undefined or invalid',o,n,s),r.after(a),i.after(r),r._x_currentIfEl&&r.after(r._x_currentIfEl),a.before(i),i._x_currentIfEl&&i.after(i._x_currentIfEl),a.remove()}),r._x_refreshXForScope(l[c.indexOf(n)])}for(let e=0;e<u.length;e++){let[t,n]=u[e],r="template"===t?o:s[t];r._x_currentIfEl&&(r=r._x_currentIfEl);let a=l[n],d=c[n],p=document.importNode(o.content,!0).firstElementChild,f=i(a);addScopeToNode(p,f,o),p._x_refreshXForScope=e=>{Object.entries(e).forEach(([e,t])=>{f[e]=t})},mutateDom(()=>{r.after(p),skipDuringClone(()=>initTree(p))()}),"object"==typeof d&&warn("x-for key cannot be an object, it must be a string or an integer",o),s[d]=p}for(let e=0;e<f.length;e++)s[f[e]]._x_refreshXForScope(l[c.indexOf(f[e])]);o._x_prevKeys=c})}(e,o,s,a)),r(()=>{Object.values(e._x_lookup).forEach(e=>mutateDom(()=>{destroyTree(e),e.remove()})),delete e._x_prevKeys,delete e._x_lookup})}),handler3.inline=(e,{expression:t},{cleanup:n})=>{let i=closestRoot(e);i._x_refs||(i._x_refs={}),i._x_refs[t]=e,n(()=>delete i._x_refs[t])},directive("ref",handler3),directive("if",(e,{expression:t},{effect:n,cleanup:i})=>{"template"!==e.tagName.toLowerCase()&&warn("x-if can only be used on a <template> tag",e);let r=evaluateLater(e,t);n(()=>r(t=>{t?(()=>{if(e._x_currentIfEl)return e._x_currentIfEl;let t=e.content.cloneNode(!0).firstElementChild;addScopeToNode(t,{},e),mutateDom(()=>{e.after(t),skipDuringClone(()=>initTree(t))()}),e._x_currentIfEl=t,e._x_undoIf=()=>{mutateDom(()=>{destroyTree(t),t.remove()}),delete e._x_currentIfEl}})():e._x_undoIf&&(e._x_undoIf(),delete e._x_undoIf)})),i(()=>e._x_undoIf&&e._x_undoIf())}),directive("id",(e,{expression:t},{evaluate:n})=>{n(t).forEach(t=>function setIdRoot(e,t){e._x_ids||(e._x_ids={}),e._x_ids[t]||(e._x_ids[t]=findAndIncrementId(t))}(e,t))}),interceptClone((e,t)=>{e._x_ids&&(t._x_ids=e._x_ids)}),mapAttributes(startingWith("@",prefix("on:"))),directive("on",skipDuringClone((e,{value:t,modifiers:n,expression:i},{cleanup:r})=>{let o=i?evaluateLater(e,i):()=>{};"template"===e.tagName.toLowerCase()&&(e._x_forwardEvents||(e._x_forwardEvents=[]),e._x_forwardEvents.includes(t)||e._x_forwardEvents.push(t));let s=on(e,t,n,e=>{o(()=>{},{scope:{$event:e},params:[e]})});r(()=>s())})),warnMissingPluginDirective("Collapse","collapse","collapse"),warnMissingPluginDirective("Intersect","intersect","intersect"),warnMissingPluginDirective("Focus","trap","focus"),warnMissingPluginDirective("Mask","mask","mask"),J.setEvaluator(function cspEvaluator(e,t){let n=function generateDataStack(e){let t={};return injectMagics(t,e),[t,...closestDataStack(e)]}(e);if("function"==typeof t)return generateEvaluatorFromFunction(n,t);let i=function generateEvaluator(e,t,n){return(e=()=>{},{scope:i={},params:r=[]}={})=>{let o=mergeProxies([i,...n]),s=function generateRuntimeFunction(e){try{const t=new Z(e).tokenize(),n=new X(t).parse(),i=new Y;return function(e={}){const{scope:t={},context:r=null,allowGlobal:o=!1,forceBindingRootScopeToFunctions:s=!1}=e;return i.evaluate({node:n,scope:t,context:r,allowGlobal:o,forceBindingRootScopeToFunctions:s})}}catch(e){throw new Error(`CSP Parser Error: ${e.message}`)}}(t),a=s({scope:o,allowGlobal:!0,forceBindingRootScopeToFunctions:!0});if(w&&"function"==typeof a){let t=a.apply(a,r);t instanceof Promise?t.then(t=>e(t)):e(t)}else"object"==typeof a&&a instanceof Promise?a.then(t=>e(t)):e(a)}}(0,t,n);return tryCatch.bind(null,e,t,i)}),J.setReactivityEngine({reactive:reactive2,effect:function effect2(e,t=ee){(function isEffect(e){return e&&!0===e._isEffect})(e)&&(e=e.raw);const n=function createReactiveEffect(e,t){const n=function reactiveEffect(){if(!n.active)return e();if(!ce.includes(n)){cleanup(n);try{return function enableTracking(){he.push(fe),fe=!0}(),ce.push(n),Q=n,e()}finally{ce.pop(),resetTracking(),Q=ce[ce.length-1]}}};return n.id=pe++,n.allowRecurse=!!t.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,t);return t.lazy||n(),n},release:function stop(e){e.active&&(cleanup(e),e.options.onStop&&e.options.onStop(),e.active=!1)},raw:toRaw});var je=J,Me=J},"./packages/packages/core/alpinejs/src/init.ts":function(e,t,n){n.r(t),n.d(t,{init:function(){return init}});var i=n("./node_modules/@alpinejs/csp/dist/module.esm.js");function init(){document.addEventListener("DOMContentLoaded",()=>{i.Alpine.start()},{once:!0})}}},t={};function __webpack_require__(n){var i=t[n];if(void 0!==i)return i.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=function(e,t){for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){__webpack_require__.r(n),__webpack_require__.d(n,{Alpine:function(){return e.Alpine},init:function(){return t.init},refreshTree:function(){return refreshTree}});var e=__webpack_require__("./node_modules/@alpinejs/csp/dist/module.esm.js"),t=__webpack_require__("./packages/packages/core/alpinejs/src/init.ts");const refreshTree=t=>{e.Alpine.nextTick(()=>{e.Alpine.destroyTree(t),e.Alpine.initTree(t)})}}(),(window.elementorV2=window.elementorV2||{}).alpinejs=n}(),window.elementorV2.alpinejs?.init?.(); | |
| 1 | +(function() { | |
| 2 | + | |
| 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 | + }; | |
| 22 | + | |
| 23 | +//#endregion | |
| 24 | + | |
| 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} | |
| 391 | + | |
| 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; | |
| 3613 | + | |
| 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 | + } | |
| 3621 | + | |
| 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 | + }; | |
| 3635 | + | |
| 3636 | +//#endregion | |
| 3637 | +//#region \0elementor-package-library-entry | |
| 3638 | + (window.elementorV2 = window.elementorV2 || {}).alpinejs = src_exports; | |
| 3639 | + | |
| 3640 | +//#endregion | |
| 3641 | +})(); | |
| 3642 | +window.elementorV2.alpinejs?.init?.(); | |
| 3 | 3643 | //# sourceMappingURL=alpinejs.js.map |