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,KACzC,EAAY,GAAK,EAAM,SAAS,KAClC,GAAY,GAAG,IAAc,IAAI,OAAO,IAC1C,gBAAe,KACT,KAAK,GAAG,MAAM,SAAS,IAEvB,KAAK,GAAG,MAAM,KAAK,GAAG,eAAiB,KAAO,GAChD,KAAK,GAAG,kBAAkB,KAAK,GAAG,eAAiB,EAAG,KAAK,GAAG,eAAiB,EACjF,IAEK,CACT,CAvLA,SAAS,eAAgB,CACvB,QAAS,IAAM,eACf,KAAM,IAAM,YACZ,UAAW,IAAM,YAEnB,OAAO,QAAU,aAAa,gBAqL9B,IAAI,eAAiB","file":"/npm/@alpinejs/mask@3.15.8/dist/module.cjs.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@alpinejs/mask@3.15.8/dist/module.cjs.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n  for (var name in all)\n    __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n  if (from && typeof from === \"object\" || typeof from === \"function\") {\n    for (let key of __getOwnPropNames(from))\n      if (!__hasOwnProp.call(to, key) && key !== except)\n        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n  }\n  return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// packages/mask/builds/module.js\nvar module_exports = {};\n__export(module_exports, {\n  default: () => module_default,\n  mask: () => src_default,\n  stripDown: () => stripDown\n});\nmodule.exports = __toCommonJS(module_exports);\n\n// packages/mask/src/index.js\nfunction src_default(Alpine) {\n  Alpine.directive(\"mask\", (el, { value, expression }, { effect, evaluateLater, cleanup }) => {\n    let templateFn = () => expression;\n    let lastInputValue = \"\";\n    queueMicrotask(() => {\n      if ([\"function\", \"dynamic\"].includes(value)) {\n        let evaluator = evaluateLater(expression);\n        effect(() => {\n          templateFn = (input) => {\n            let result;\n            Alpine.dontAutoEvaluateFunctions(() => {\n              evaluator((value2) => {\n                result = typeof value2 === \"function\" ? value2(input) : value2;\n              }, { scope: {\n                // These are \"magics\" we'll make available to the x-mask:function:\n                \"$input\": input,\n                \"$money\": formatMoney.bind({ el })\n              } });\n            });\n            return result;\n          };\n          processInputValue(el, false);\n        });\n      } else {\n        processInputValue(el, false);\n      }\n      if (el._x_model) {\n        if (el._x_model.get() === el.value)\n          return;\n        if (el._x_model.get() === null && el.value === \"\")\n          return;\n        el._x_model.set(el.value);\n      }\n    });\n    const controller = new AbortController();\n    cleanup(() => {\n      controller.abort();\n    });\n    el.addEventListener(\"input\", () => processInputValue(el), {\n      signal: controller.signal,\n      // Setting this as a capture phase listener to ensure it runs\n      // before wire:model or x-model added as a latent binding...\n      capture: true\n    });\n    el.addEventListener(\"blur\", () => processInputValue(el, false), { signal: controller.signal });\n    function processInputValue(el2, shouldRestoreCursor = true) {\n      let input = el2.value;\n      let template = templateFn(input);\n      if (!template || template === \"false\")\n        return false;\n      if (lastInputValue.length - el2.value.length === 1) {\n        return lastInputValue = el2.value;\n      }\n      let setInput = () => {\n        lastInputValue = el2.value = formatInput(input, template);\n      };\n      if (shouldRestoreCursor) {\n        restoreCursorPosition(el2, template, () => {\n          setInput();\n        });\n      } else {\n        setInput();\n      }\n    }\n    function formatInput(input, template) {\n      if (input === \"\")\n        return \"\";\n      let strippedDownInput = stripDown(template, input);\n      let rebuiltInput = buildUp(template, strippedDownInput);\n      return rebuiltInput;\n    }\n  }).before(\"model\");\n}\nfunction restoreCursorPosition(el, template, callback) {\n  let cursorPosition = el.selectionStart;\n  let unformattedValue = el.value;\n  callback();\n  let beforeLeftOfCursorBeforeFormatting = unformattedValue.slice(0, cursorPosition);\n  let newPosition = buildUp(\n    template,\n    stripDown(\n      template,\n      beforeLeftOfCursorBeforeFormatting\n    )\n  ).length;\n  el.setSelectionRange(newPosition, newPosition);\n}\nfunction stripDown(template, input) {\n  let inputToBeStripped = input;\n  let output = \"\";\n  let regexes = {\n    \"9\": /[0-9]/,\n    \"a\": /[a-zA-Z]/,\n    \"*\": /[a-zA-Z0-9]/\n  };\n  let wildcardTemplate = \"\";\n  for (let i = 0; i < template.length; i++) {\n    if ([\"9\", \"a\", \"*\"].includes(template[i])) {\n      wildcardTemplate += template[i];\n      continue;\n    }\n    for (let j = 0; j < inputToBeStripped.length; j++) {\n      if (inputToBeStripped[j] === template[i]) {\n        inputToBeStripped = inputToBeStripped.slice(0, j) + inputToBeStripped.slice(j + 1);\n        break;\n      }\n    }\n  }\n  for (let i = 0; i < wildcardTemplate.length; i++) {\n    let found = false;\n    for (let j = 0; j < inputToBeStripped.length; j++) {\n      if (regexes[wildcardTemplate[i]].test(inputToBeStripped[j])) {\n        output += inputToBeStripped[j];\n        inputToBeStripped = inputToBeStripped.slice(0, j) + inputToBeStripped.slice(j + 1);\n        found = true;\n        break;\n      }\n    }\n    if (!found)\n      break;\n  }\n  return output;\n}\nfunction buildUp(template, input) {\n  let clean = Array.from(input);\n  let output = \"\";\n  for (let i = 0; i < template.length; i++) {\n    if (![\"9\", \"a\", \"*\"].includes(template[i])) {\n      output += template[i];\n      continue;\n    }\n    if (clean.length === 0)\n      break;\n    output += clean.shift();\n  }\n  return output;\n}\nfunction formatMoney(input, delimiter = \".\", thousands, precision = 2) {\n  if (input === \"-\")\n    return \"-\";\n  if (/^\\D+$/.test(input))\n    return \"9\";\n  if (thousands === null || thousands === void 0) {\n    thousands = delimiter === \",\" ? \".\" : \",\";\n  }\n  let addThousands = (input2, thousands2) => {\n    let output = \"\";\n    let counter = 0;\n    for (let i = input2.length - 1; i >= 0; i--) {\n      if (input2[i] === thousands2)\n        continue;\n      if (counter === 3) {\n        output = input2[i] + thousands2 + output;\n        counter = 0;\n      } else {\n        output = input2[i] + output;\n      }\n      counter++;\n    }\n    return output;\n  };\n  let minus = input.startsWith(\"-\") ? \"-\" : \"\";\n  let strippedInput = input.replaceAll(new RegExp(`[^0-9\\\\${delimiter}]`, \"g\"), \"\");\n  let template = Array.from({ length: strippedInput.split(delimiter)[0].length }).fill(\"9\").join(\"\");\n  template = `${minus}${addThousands(template, thousands)}`;\n  if (precision > 0 && input.includes(delimiter))\n    template += `${delimiter}` + \"9\".repeat(precision);\n  queueMicrotask(() => {\n    if (this.el.value.endsWith(delimiter))\n      return;\n    if (this.el.value[this.el.selectionStart - 1] === delimiter) {\n      this.el.setSelectionRange(this.el.selectionStart - 1, this.el.selectionStart - 1);\n    }\n  });\n  return template;\n}\n\n// packages/mask/builds/module.js\nvar module_default = src_default;\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n  mask,\n  stripDown\n});\n"]}