{"version":3,"sources":["webpack:///./node_modules/cocoon-js-vanilla/index.js","webpack:///./app/javascript/entrypoints/public.tsx","webpack:///./app/javascript/mastodon/load_keyboard_extensions.js"],"names":["document","addEventListener","cocoonElementCounter","createNewID","Date","getTime","newcontentBraced","id","newcontentUnderscored","cocoonAddFields","e","target","preventDefault","stopPropagation","thisNode","assoc","getAttribute","assocs","content","insertionMethod","insertionNode","insertionTraversal","count","parseInt","regexpBraced","RegExp","regexpUnderscored","newId","newContent","replace","newContents","originalEvent","isNaN","Math","max","push","insertionNodeElem","console","warn","querySelector","parentNode","getInsertionNodeElem","length","forEach","node","i","contentNode","beforeInsert","CustomEvent","bubbles","cancelable","detail","dispatchEvent","defaultPrevented","htmlMapping","before","prepend","append","after","htmlMethod","addedContent","insertAdjacentHTML","previousElementSibling","firstElementChild","lastElementChild","nextElementSibling","afterInsert","cocoonRemoveFields","wrapperClass","nodeToDelete","closest","triggerNode","beforeRemove","timeout","setTimeout","classList","contains","parentElement","removeChild","elem","selector","sibling","matches","cocoonGetPreviousSibling","value","style","display","inputs","querySelectorAll","removeAttribute","afterRemove","this","hideRemovedFields","targets","start","messages","defineMessages","usernameTaken","defaultMessage","passwordExceedsLength","passwordDoesNotMatch","loaded","_localeData$relative_","localeData","getLocale","locale","documentElement","lang","dateTimeFormat","Intl","DateTimeFormat","year","month","day","hour","minute","dateFormat","timeFormat","timeStyle","formatMessage","_ref","values","message","IntlMessageFormat","format","innerHTML","emojify","datetime","dateTime","formattedDate","title","textContent","todayFormat","formattedContent","date","today","getDate","getMonth","getFullYear","isToday","formattedTime","time","timeGiven","includes","now","timeAgoString","formatDate","options","reactComponents","then","_ref2","default","MediaContainer","component","Array","from","children","child","createElement","createRoot","render","_jsx","components","body","appendChild","catch","error","Rails","delegate","_throttle","_ref3","HTMLInputElement","axios","get","params","acct","setCustomValidity","leading","trailing","password","confirmation","maxLength","_ref4","avatar","file","files","url","URL","createObjectURL","dataset","originalSrc","src","_ref5","focus","select","setSelectionRange","_ref6","_target$parentNode","HTMLButtonElement","input","navigator","clipboard","writeText","parent","add","remove","toggleSidebar","sidebar","toggleButton","overflow","setAttribute","toggle","key","_ref7","HTMLImageElement","original","_ref8","static","_ref9","form","setInputDisabled","disabled","wrapper","hidden","type","checked","field","_ref10","HTMLElement","button","ariaExpanded","loadPolyfills","loadLocale","ready","test","userAgent","arrowKeyNav","register","Promise","resolve"],"mappings":"8EAAAA,SAASC,iBAAiB,oBAAoB,WAC5C,IAAIC,EAAuB,EAEvBC,EAAc,WAChB,OAAQ,IAAIC,MAAOC,UAAYH,GACjC,EAEII,EAAmB,SAAUC,GAC/B,MAAO,IAAMA,EAAK,KACpB,EAEIC,EAAwB,SAAUD,GACpC,MAAO,IAAMA,EAAK,KACpB,EAuCIE,EAAkB,SAAUC,EAAGC,GACjCD,EAAEE,iBACFF,EAAEG,kBAEF,IAAIC,EAAWH,EACXI,EAAQD,EAASE,aAAa,oBAC9BC,EAASH,EAASE,aAAa,qBAC/BE,EAAUJ,EAASE,aAAa,uCAChCG,EAAkBL,EAASE,aAAa,sCAAwCF,EAASE,aAAa,wCAA0C,SAChJI,EAAgBN,EAASE,aAAa,mCACtCK,EAAqBP,EAASE,aAAa,wCAC3CM,EAAQC,SAAST,EAASE,aAAa,cAAe,IACtDQ,EAAe,IAAIC,OAAO,UAAYV,EAAQ,cAAe,KAC7DW,EAAoB,IAAID,OAAO,QAAUV,EAAQ,UAAW,KAC5DY,EAAQxB,IACRyB,EAAaV,EAAQW,QAAQL,EAAclB,EAAiBqB,IAC5DG,EAAc,GACdC,EAAgBrB,EAcpB,IAZIkB,IAAeV,IACjBM,EAAe,IAAIC,OAAO,UAAYR,EAAS,cAAe,KAC9DS,EAAoB,IAAID,OAAO,QAAUR,EAAS,UAAW,KAC7DW,EAAaV,EAAQW,QAAQL,EAAclB,EAAiBqB,KAI9DG,EAAc,CADdF,EAAaA,EAAWC,QAAQH,EAAmBlB,EAAsBmB,KAGzEL,EAASU,MAAMV,GAAS,EAAI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AAxBA,EAAOC,aACTD,EAAOC,aAAe,QAEtBD,EAAOC,aAAe,OACxB,IASFC,cACGlF,KAAKmF,KACLnF,MARH,WACEoF,YAAMpI,GAAQgE,OAAOC,IACnBjI,QAAQiI,MAAMA,EAAM,GAExB,IAKGjB,MCxZY,WACb,MAAI,QAAQqF,KAAKlC,UAAUmC,WAJpB,iCAK6BtF,MAAKuF,IACrCA,EAAYC,UAAU,IAGnBC,QAAQC,SACjB,IDkZG1E,OAAOC,IACNjI,QAAQiI,MAAMA,EAAM,G","file":"js/public-cf992aad0910d8b5774e.chunk.js","sourcesContent":["document.addEventListener('DOMContentLoaded', function () {\n  var cocoonElementCounter = 0;\n\n  var createNewID = function () {\n    return (new Date().getTime() + cocoonElementCounter++);\n  };\n\n  var newcontentBraced = function (id) {\n    return '[' + id + ']$1';\n  };\n\n  var newcontentUnderscored = function (id) {\n    return '_' + id + '_$1';\n  };\n\n  var getInsertionNodeElem = function (insertionNode, insertionTraversal, thisNode) {\n    if (!insertionNode) {\n      return thisNode.parentNode;\n    }\n\n    if (typeof insertionNode === 'function') {\n      if (insertionTraversal) {\n        console.warn('association-insertion-traversal is ignored, because association-insertion-node is given as a function.');\n      }\n      return insertionNode(thisNode);\n    }\n\n    if (typeof insertionNode === 'string') {\n      if (insertionTraversal) {\n        return thisNode[insertionTraversal](insertionNode);\n      } else {\n        return insertionNode === 'this' ? thisNode : document.querySelector(insertionNode);\n      }\n    }\n  };\n\n  var cocoonDetach = function (node) {\n    return node.parentElement.removeChild(node);\n  };\n\n  var cocoonGetPreviousSibling = function (elem, selector) {\n    var sibling = elem.previousElementSibling;\n\n    if (!selector) return sibling;\n\n    while (sibling) {\n      var match = sibling.matches(selector);\n      if (match) return sibling;\n      sibling = sibling.previousElementSibling;\n    }\n  };\n\n  var cocoonAddFields = function (e, target) {\n    e.preventDefault();\n    e.stopPropagation();\n\n    var thisNode = target;\n    var assoc = thisNode.getAttribute('data-association');\n    var assocs = thisNode.getAttribute('data-associations');\n    var content = thisNode.getAttribute('data-association-insertion-template');\n    var insertionMethod = thisNode.getAttribute('data-association-insertion-method') || thisNode.getAttribute('data-association-insertion-position') || 'before';\n    var insertionNode = thisNode.getAttribute('data-association-insertion-node');\n    var insertionTraversal = thisNode.getAttribute('data-association-insertion-traversal');\n    var count = parseInt(thisNode.getAttribute('data-count'), 10);\n    var regexpBraced = new RegExp('\\\\[new_' + assoc + '\\\\](.*?\\\\s)', 'g');\n    var regexpUnderscored = new RegExp('_new_' + assoc + '_(\\\\w*)', 'g');\n    var newId = createNewID();\n    var newContent = content.replace(regexpBraced, newcontentBraced(newId));\n    var newContents = [];\n    var originalEvent = e;\n\n    if (newContent === content) {\n      regexpBraced = new RegExp('\\\\[new_' + assocs + '\\\\](.*?\\\\s)', 'g');\n      regexpUnderscored = new RegExp('_new_' + assocs + '_(\\\\w*)', 'g');\n      newContent = content.replace(regexpBraced, newcontentBraced(newId));\n    }\n\n    newContent = newContent.replace(regexpUnderscored, newcontentUnderscored(newId));\n    newContents = [newContent];\n\n    count = (isNaN(count) ? 1 : Math.max(count, 1));\n    count -= 1;\n\n    while (count) {\n      newId = createNewID();\n      newContent = content.replace(regexpBraced, newcontentBraced(newId));\n      newContent = newContent.replace(regexpUnderscored, newcontentUnderscored(newId));\n      newContents.push(newContent);\n\n      count -= 1;\n    }\n\n    var insertionNodeElem = getInsertionNodeElem(insertionNode, insertionTraversal, thisNode);\n\n    if (!insertionNodeElem || (insertionNodeElem.length === 0)) {\n      console.warn(\"Couldn't find the element to insert the template. Make sure your `data-association-insertion-*` on `link_to_add_association` is correct.\");\n    }\n\n    newContents.forEach(function (node, i) {\n      var contentNode = node;\n\n      var beforeInsert = new CustomEvent('cocoon:before-insert', { bubbles: true, cancelable: true, detail: [contentNode, originalEvent] });\n      insertionNodeElem.dispatchEvent(beforeInsert);\n\n      if (!beforeInsert.defaultPrevented) {\n        // allow any of the jquery dom manipulation methods (after, before, append, prepend, etc)\n        // to be called on the node.  allows the insertion node to be the parent of the inserted\n        // code and doesn't force it to be a sibling like after/before does. default: 'before'\n        var htmlMapping = {\n          before: 'beforebegin',\n          prepend: 'afterbegin',\n          append: 'beforeend',\n          after: 'afterend'\n        };\n\n        var htmlMethod = htmlMapping[insertionMethod];\n        var addedContent = insertionNodeElem.insertAdjacentHTML(htmlMethod, contentNode);\n\n        if (htmlMethod === htmlMapping.before) {\n          addedContent = insertionNodeElem.previousElementSibling;\n        } else if (htmlMethod === htmlMapping.prepend) {\n          addedContent = insertionNodeElem.firstElementChild;\n        } else if (htmlMethod === htmlMapping.append) {\n          addedContent = insertionNodeElem.lastElementChild;\n        } else if (htmlMethod === htmlMapping.after) {\n          addedContent = insertionNodeElem.nextElementSibling;\n        }\n\n        var afterInsert = new CustomEvent('cocoon:after-insert', { bubbles: true, detail: [contentNode, originalEvent, addedContent] });\n        insertionNodeElem.dispatchEvent(afterInsert);\n      }\n    });\n  };\n\n  var cocoonRemoveFields = function (e, target) {\n    var thisNode = target;\n    var wrapperClass = thisNode.getAttribute('data-wrapper-class') || 'nested-fields';\n    var nodeToDelete = thisNode.closest('.' + wrapperClass);\n    var triggerNode = nodeToDelete.parentNode;\n    var originalEvent = e;\n\n    e.preventDefault();\n    e.stopPropagation();\n\n    var beforeRemove = new CustomEvent('cocoon:before-remove', { bubbles: true, cancelable: true, detail: [nodeToDelete, originalEvent] });\n    triggerNode.dispatchEvent(beforeRemove);\n\n    if (!beforeRemove.defaultPrevented) {\n      var timeout = triggerNode.getAttribute('data-remove-timeout') || 0;\n\n      setTimeout(function () {\n        if (thisNode.classList.contains('dynamic')) {\n          cocoonDetach(nodeToDelete);\n        } else {\n          var hiddenInput = cocoonGetPreviousSibling(thisNode, 'input[type=hidden]');\n          hiddenInput.value = '1';\n          nodeToDelete.style.display = 'none';\n\n          var inputs = nodeToDelete.querySelectorAll(\"input[required]\");\n          for (var i = 0; i < inputs.length; i++) {\n            inputs[i].removeAttribute(\"required\");\n          }\n        }\n        var afterRemove = new CustomEvent('cocoon:after-remove', { bubbles: true, detail: [nodeToDelete, originalEvent] });\n        triggerNode.dispatchEvent(afterRemove);\n      }, timeout);\n    }\n  };\n\n  document.addEventListener('click', function (e) {\n    for (var target = e.target; target && target !== this; target = target.parentNode) {\n      if (target.matches('.add_fields')) {\n        cocoonAddFields(e, target);\n        return;\n      }\n      if (target.matches('.remove_fields')) {\n        cocoonRemoveFields(e, target);\n        return;\n      }\n    }\n  }, false);\n\n  var hideRemovedFields = function () {    \n    var targets = document.querySelectorAll('.remove_fields.existing.destroyed');\n    for (var i = 0; i < targets.length; i++) {\n      var thisNode = targets[i];\n      var wrapperClass = thisNode.getAttribute('data-wrapper-class') || 'nested-fields';\n      var nodeToHide = thisNode.closest('.' + wrapperClass);\n      \n      nodeToHide.style.display = 'none';\n    }\n  }\n\n  document.addEventListener('page:load', hideRemovedFields);\n  document.addEventListener('turbolinks:load', hideRemovedFields); // Has been replaced by Turbo\n  document.addEventListener('turbo:load', hideRemovedFields);\n\n  hideRemovedFields();\n});\n","import { createRoot } from 'react-dom/client';\n\nimport './public-path';\n\nimport { IntlMessageFormat } from 'intl-messageformat';\nimport type { MessageDescriptor, PrimitiveType } from 'react-intl';\nimport { defineMessages } from 'react-intl';\n\nimport Rails from '@rails/ujs';\nimport axios from 'axios';\nimport { throttle } from 'lodash';\n\nimport { start } from '../mastodon/common';\nimport { timeAgoString } from '../mastodon/components/relative_timestamp';\nimport emojify from '../mastodon/features/emoji/emoji';\nimport loadKeyboardExtensions from '../mastodon/load_keyboard_extensions';\nimport { loadLocale, getLocale } from '../mastodon/locales';\nimport { loadPolyfills } from '../mastodon/polyfills';\nimport ready from '../mastodon/ready';\n\nimport 'cocoon-js-vanilla';\n\nstart();\n\nconst messages = defineMessages({\n  usernameTaken: {\n    id: 'username.taken',\n    defaultMessage: 'That username is taken. Try another',\n  },\n  passwordExceedsLength: {\n    id: 'password_confirmation.exceeds_maxlength',\n    defaultMessage: 'Password confirmation exceeds the maximum password length',\n  },\n  passwordDoesNotMatch: {\n    id: 'password_confirmation.mismatching',\n    defaultMessage: 'Password confirmation does not match',\n  },\n});\n\nfunction loaded() {\n  const { messages: localeData } = getLocale();\n\n  const locale = document.documentElement.lang;\n\n  const dateTimeFormat = new Intl.DateTimeFormat(locale, {\n    year: 'numeric',\n    month: 'long',\n    day: 'numeric',\n    hour: 'numeric',\n    minute: 'numeric',\n  });\n\n  const dateFormat = new Intl.DateTimeFormat(locale, {\n    year: 'numeric',\n    month: 'short',\n    day: 'numeric',\n  });\n\n  const timeFormat = new Intl.DateTimeFormat(locale, {\n    timeStyle: 'short',\n  });\n\n  const formatMessage = (\n    { id, defaultMessage }: MessageDescriptor,\n    values?: Record<string, PrimitiveType>,\n  ) => {\n    let message: string | undefined = undefined;\n\n    if (id) message = localeData[id];\n\n    if (!message) message = defaultMessage as string;\n\n    const messageFormat = new IntlMessageFormat(message, locale);\n    return messageFormat.format(values) as string;\n  };\n\n  document.querySelectorAll('.emojify').forEach((content) => {\n    content.innerHTML = emojify(content.innerHTML);\n  });\n\n  document\n    .querySelectorAll<HTMLTimeElement>('time.formatted')\n    .forEach((content) => {\n      const datetime = new Date(content.dateTime);\n      const formattedDate = dateTimeFormat.format(datetime);\n\n      content.title = formattedDate;\n      content.textContent = formattedDate;\n    });\n\n  const isToday = (date: Date) => {\n    const today = new Date();\n\n    return (\n      date.getDate() === today.getDate() &&\n      date.getMonth() === today.getMonth() &&\n      date.getFullYear() === today.getFullYear()\n    );\n  };\n  const todayFormat = new IntlMessageFormat(\n    localeData['relative_format.today'] ?? 'Today at {time}',\n    locale,\n  );\n\n  document\n    .querySelectorAll<HTMLTimeElement>('time.relative-formatted')\n    .forEach((content) => {\n      const datetime = new Date(content.dateTime);\n\n      let formattedContent: string;\n\n      if (isToday(datetime)) {\n        const formattedTime = timeFormat.format(datetime);\n\n        formattedContent = todayFormat.format({\n          time: formattedTime,\n        }) as string;\n      } else {\n        formattedContent = dateFormat.format(datetime);\n      }\n\n      const timeGiven = content.dateTime.includes('T');\n      content.title = timeGiven\n        ? dateTimeFormat.format(datetime)\n        : dateFormat.format(datetime);\n\n      content.textContent = formattedContent;\n    });\n\n  document\n    .querySelectorAll<HTMLTimeElement>('time.time-ago')\n    .forEach((content) => {\n      const datetime = new Date(content.dateTime);\n      const now = new Date();\n\n      const timeGiven = content.dateTime.includes('T');\n      content.title = timeGiven\n        ? dateTimeFormat.format(datetime)\n        : dateFormat.format(datetime);\n      content.textContent = timeAgoString(\n        {\n          formatMessage,\n          formatDate: (date: Date, options) =>\n            new Intl.DateTimeFormat(locale, options).format(date),\n        },\n        datetime,\n        now.getTime(),\n        now.getFullYear(),\n        timeGiven,\n      );\n    });\n\n  const reactComponents = document.querySelectorAll('[data-component]');\n\n  if (reactComponents.length > 0) {\n    import(\n      /* webpackChunkName: \"containers/media_container\" */ '../mastodon/containers/media_container'\n    )\n      .then(({ default: MediaContainer }) => {\n        reactComponents.forEach((component) => {\n          Array.from(component.children).forEach((child) => {\n            component.removeChild(child);\n          });\n        });\n\n        const content = document.createElement('div');\n\n        const root = createRoot(content);\n        root.render(\n          <MediaContainer locale={locale} components={reactComponents} />,\n        );\n        document.body.appendChild(content);\n\n        return true;\n      })\n      .catch((error: unknown) => {\n        console.error(error);\n      });\n  }\n\n  Rails.delegate(\n    document,\n    'input#user_account_attributes_username',\n    'input',\n    throttle(\n      ({ target }) => {\n        if (!(target instanceof HTMLInputElement)) return;\n\n        if (target.value && target.value.length > 0) {\n          axios\n            .get('/api/v1/accounts/lookup', { params: { acct: target.value } })\n            .then(() => {\n              target.setCustomValidity(formatMessage(messages.usernameTaken));\n              return true;\n            })\n            .catch(() => {\n              target.setCustomValidity('');\n            });\n        } else {\n          target.setCustomValidity('');\n        }\n      },\n      500,\n      { leading: false, trailing: true },\n    ),\n  );\n\n  Rails.delegate(\n    document,\n    '#user_password,#user_password_confirmation',\n    'input',\n    () => {\n      const password = document.querySelector<HTMLInputElement>(\n        'input#user_password',\n      );\n      const confirmation = document.querySelector<HTMLInputElement>(\n        'input#user_password_confirmation',\n      );\n      if (!confirmation || !password) return;\n\n      if (\n        confirmation.value &&\n        confirmation.value.length > password.maxLength\n      ) {\n        confirmation.setCustomValidity(\n          formatMessage(messages.passwordExceedsLength),\n        );\n      } else if (password.value && password.value !== confirmation.value) {\n        confirmation.setCustomValidity(\n          formatMessage(messages.passwordDoesNotMatch),\n        );\n      } else {\n        confirmation.setCustomValidity('');\n      }\n    },\n  );\n}\n\nRails.delegate(\n  document,\n  '#edit_profile input[type=file]',\n  'change',\n  ({ target }) => {\n    if (!(target instanceof HTMLInputElement)) return;\n\n    const avatar = document.querySelector<HTMLImageElement>(\n      `img#${target.id}-preview`,\n    );\n\n    if (!avatar) return;\n\n    let file: File | undefined;\n    if (target.files) file = target.files[0];\n\n    const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;\n\n    if (url) avatar.src = url;\n  },\n);\n\nRails.delegate(document, '.input-copy input', 'click', ({ target }) => {\n  if (!(target instanceof HTMLInputElement)) return;\n\n  target.focus();\n  target.select();\n  target.setSelectionRange(0, target.value.length);\n});\n\nRails.delegate(document, '.input-copy button', 'click', ({ target }) => {\n  if (!(target instanceof HTMLButtonElement)) return;\n\n  const input = target.parentNode?.querySelector<HTMLInputElement>(\n    '.input-copy__wrapper input',\n  );\n\n  if (!input) return;\n\n  navigator.clipboard\n    .writeText(input.value)\n    .then(() => {\n      const parent = target.parentElement;\n\n      if (parent) {\n        parent.classList.add('copied');\n\n        setTimeout(() => {\n          parent.classList.remove('copied');\n        }, 700);\n      }\n\n      return true;\n    })\n    .catch((error: unknown) => {\n      console.error(error);\n    });\n});\n\nconst toggleSidebar = () => {\n  const sidebar = document.querySelector<HTMLUListElement>('.sidebar ul');\n  const toggleButton = document.querySelector<HTMLAnchorElement>(\n    'a.sidebar__toggle__icon',\n  );\n\n  if (!sidebar || !toggleButton) return;\n\n  if (sidebar.classList.contains('visible')) {\n    document.body.style.overflow = '';\n    toggleButton.setAttribute('aria-expanded', 'false');\n  } else {\n    document.body.style.overflow = 'hidden';\n    toggleButton.setAttribute('aria-expanded', 'true');\n  }\n\n  toggleButton.classList.toggle('active');\n  sidebar.classList.toggle('visible');\n};\n\nRails.delegate(document, '.sidebar__toggle__icon', 'click', () => {\n  toggleSidebar();\n});\n\nRails.delegate(document, '.sidebar__toggle__icon', 'keydown', (e) => {\n  if (e.key === ' ' || e.key === 'Enter') {\n    e.preventDefault();\n    toggleSidebar();\n  }\n});\n\nRails.delegate(document, 'img.custom-emoji', 'mouseover', ({ target }) => {\n  if (target instanceof HTMLImageElement && target.dataset.original)\n    target.src = target.dataset.original;\n});\nRails.delegate(document, 'img.custom-emoji', 'mouseout', ({ target }) => {\n  if (target instanceof HTMLImageElement && target.dataset.static)\n    target.src = target.dataset.static;\n});\n\nconst setInputDisabled = (\n  input: HTMLInputElement | HTMLSelectElement,\n  disabled: boolean,\n) => {\n  input.disabled = disabled;\n\n  const wrapper = input.closest('.with_label');\n  if (wrapper) {\n    wrapper.classList.toggle('disabled', input.disabled);\n\n    const hidden =\n      input.type === 'checkbox' &&\n      wrapper.querySelector<HTMLInputElement>('input[type=hidden][value=\"0\"]');\n    if (hidden) {\n      hidden.disabled = input.disabled;\n    }\n  }\n};\n\nRails.delegate(\n  document,\n  '#account_statuses_cleanup_policy_enabled',\n  'change',\n  ({ target }) => {\n    if (!(target instanceof HTMLInputElement) || !target.form) return;\n\n    target.form\n      .querySelectorAll<\n        HTMLInputElement | HTMLSelectElement\n      >('input:not([type=hidden], #account_statuses_cleanup_policy_enabled), select')\n      .forEach((input) => {\n        setInputDisabled(input, !target.checked);\n      });\n  },\n);\n\n// Empty the honeypot fields in JS in case something like an extension\n// automatically filled them.\nRails.delegate(document, '#registration_new_user,#new_user', 'submit', () => {\n  [\n    'user_website',\n    'user_confirm_password',\n    'registration_user_website',\n    'registration_user_confirm_password',\n  ].forEach((id) => {\n    const field = document.querySelector<HTMLInputElement>(`input#${id}`);\n    if (field) {\n      field.value = '';\n    }\n  });\n});\n\nRails.delegate(document, '.rules-list button', 'click', ({ target }) => {\n  if (!(target instanceof HTMLElement)) {\n    return;\n  }\n\n  const button = target.closest('button');\n\n  if (!button) {\n    return;\n  }\n\n  if (button.ariaExpanded === 'true') {\n    button.ariaExpanded = 'false';\n  } else {\n    button.ariaExpanded = 'true';\n  }\n});\n\nfunction main() {\n  ready(loaded).catch((error: unknown) => {\n    console.error(error);\n  });\n}\n\nloadPolyfills()\n  .then(loadLocale)\n  .then(main)\n  .then(loadKeyboardExtensions)\n  .catch((error: unknown) => {\n    console.error(error);\n  });\n","// On KaiOS, we may not be able to use a mouse cursor or navigate using Tab-based focus, so we install\n// special left/right focus navigation keyboard listeners, at least on public pages (i.e. so folks\n// can at least log in using KaiOS devices).\n\nfunction importArrowKeyNavigation() {\n  return import(/* webpackChunkName: \"arrow-key-navigation\" */ 'arrow-key-navigation');\n}\n\nexport default function loadKeyboardExtensions() {\n  if (/KAIOS/.test(navigator.userAgent)) {\n    return importArrowKeyNavigation().then(arrowKeyNav => {\n      arrowKeyNav.register();\n    });\n  }\n  return Promise.resolve();\n}\n"],"sourceRoot":""}