{
"version": 3,
"sources": ["../../javascript/turbo_actions.js", "../../javascript/controllers/charity_item_controller.js", "../../javascript/controllers/charity_search_controller.js", "../../javascript/controllers/copy_controller.js", "../../javascript/controllers/donation_controller.js", "../../javascript/controllers/donation_slider_controller.js", "../../javascript/controllers/dropdown_menu_controller.js", "../../javascript/controllers/modal_controller.js", "../../javascript/controllers/remote_form_controller.js", "../../javascript/controllers/slider_controller.js", "../../javascript/controllers/toggle_controller.js", "../../javascript/controllers/new_tab_controller.js", "../../javascript/controllers/form_override.js", "../../javascript/controllers/scroll_on_change_controller.js", "../../javascript/controllers/donation_tracking_controller.js", "../../javascript/controllers/logo_carousel_controller.js", "../../javascript/controllers/animate_controller.js", "../../javascript/controllers/index.js", "../../javascript/application.js"],
"sourcesContent": ["import { StreamActions } from \"@hotwired/turbo\"\n\nStreamActions.set_value = function () {\n const target = this.targetElements[0];\n if (target) {\n target.value = this.getAttribute('value');\n }\n};\n", "import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n static targets = [ 'block', 'info', 'radio' ]\n\n initialize() {\n this.update()\n if(this.descriptionTarget())\n this.descriptionTarget().dataset.scroll = true\n }\n\n descriptionTarget(){\n return document.getElementById('charityDescription');\n }\n\n update(){\n if(this.radioTarget.checked) {\n this.blockTarget.classList.add('charity-active');\n if(this.descriptionTarget())\n this.descriptionTarget().innerHTML = this.infoTarget.innerHTML\n this.scrollToSelectedCharity()\n } else {\n this.blockTarget.classList.remove('charity-active');\n }\n }\n\n trigger_update_all(){\n document.querySelectorAll('[data-controller*=\"charity-item\"] [data-charity-item-target=\"radio\"]').forEach((element, _) => {\n element.dispatchEvent(new Event('change', { 'bubbles': true }));\n })\n }\n\n scrollToSelectedCharity() {\n if(this.descriptionTarget() && this.descriptionTarget().dataset.scroll) {\n this.descriptionTarget().scrollIntoView({ behavior: 'smooth', block: 'center' });\n this.descriptionTarget().dataset.scroll = '';\n }\n }\n\n select(){\n this.radioTarget.checked = true;\n this.trigger_update_all();\n }\n}\n", "import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n static targets = [ 'search', 'results', 'image', 'id', 'ein' ]\n\n initialize() {\n // Load Mark.js dynamically when the controller initializes\n this.loadMarkJs();\n\n this.searchTarget.addEventListener(\"keydown\", (event) => {\n if(event.key === 'ArrowUp'){ this.focusPrevious(event) }\n else if(event.key === 'ArrowDown'){ this.focusNext(event) }\n else if(event.key === 'Enter'){ this.selectFocused(event) }\n }\n );\n this.searchTarget.addEventListener(\"keyup\",\n this.debounce((event) => {\n if(event.key !== 'ArrowUp' && event.key !== 'ArrowDown' && event.key !== 'Enter'){\n this.reload(event)\n }\n }, 200)\n );\n }\n\n async loadMarkJs() {\n try {\n const { default: Mark } = await import(\n 'mark.js'\n );\n this.Mark = Mark;\n } catch (error) {\n console.error('Failed to load Mark.js:', error);\n }\n }\n\n reload(event){\n let search = event.target.value;\n search = search.replace(/([0-9])-([0-9])/g, '$1$2');\n if(search != ''){\n if(this.ajax){\n this.ajax.abort();\n this.ajax = null;\n }\n this.ajax = this.getAjax(`https://ac.cnstrc.com/autocomplete/${search}?key=key_t3FDxwdb77757mVJ&filters[isDisbursable]=1&num_results_nonprofits=8&num_results_users=0`);\n } else {\n this.hide();\n }\n }\n\n currentFocus() {\n return this.resultsTarget.querySelector('li.focused');\n }\n\n nextToFocus(){\n if(this.currentFocus() && this.currentFocus().previousSibling) {\n return this.currentFocus().previousSibling;\n } else {\n return this.resultsTarget.lastElementChild;\n }\n }\n\n previousToFocus(){\n if(this.currentFocus() && this.currentFocus().nextSibling) {\n return this.currentFocus().nextSibling;\n } else {\n return this.resultsTarget.firstElementChild;\n }\n }\n\n selectFocused(event){\n event.preventDefault();\n if(this.currentFocus())\n this.select(this.currentFocus())\n }\n\n focusPrevious(_) {\n let current = this.currentFocus();\n let next = this.nextToFocus();\n if(this.currentFocus()) {\n current.setAttribute('aria-selected', 'false')\n current.classList.remove('focused')\n }\n next.setAttribute('aria-selected', 'true')\n next.classList.add('focused')\n }\n\n focusNext(_) {\n let current = this.currentFocus();\n let previous = this.previousToFocus();\n if(this.currentFocus()) {\n current.setAttribute('aria-selected', 'false')\n current.classList.remove('focused')\n }\n previous.setAttribute('aria-selected', 'true')\n previous.classList.add('focused')\n }\n\n hide(){\n this.element.classList.add('search-closed')\n this.element.setAttribute('aria-expanded', 'false')\n this.element.classList.remove('search-open')\n this.resultsTarget.innerHTML = '';\n }\n\n show(){\n this.element.classList.add('search-open')\n this.element.setAttribute('aria-expanded', 'true')\n this.element.classList.remove('search-closed')\n this.resultsTarget.innerHTML = '';\n this.imageTarget.innerHTML = '';\n }\n\n getAjax(url, success) {\n let xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n xhr.open('GET', url);\n xhr.onreadystatechange = () => {\n if (xhr.readyState > 3){\n if(xhr.status == 200){\n this.success(xhr.responseText);\n } else if(xhr.status != 0) {\n appsignal.sendError(new Error(`Search failed with status ${xhr.status} ${url}`))\n }\n }\n }\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n xhr.send();\n return xhr;\n }\n\n select(item) {\n this.searchTarget.value = item.dataset.name;\n this.searchTarget.dataset.name = item.dataset.name;\n this.searchTarget.dataset.id = item.dataset.id;\n this.searchTarget.dataset.ein = item.dataset.ein;\n\n this.searchTarget.dispatchEvent(new Event('change', { bubbles: true }))\n this.idTarget.value = item.dataset.id;\n this.einTarget.value = item.dataset.ein;\n this.einTarget.dispatchEvent(new Event('change', { bubbles: true }))\n\n this.imageTarget.innerHTML = '';\n let img = item.querySelector('img, svg');\n if(img){ this.imageTarget.append(img) }\n this.hide()\n }\n\n async success(data) {\n this.show()\n let json = JSON.parse(data);\n if(json.sections.nonprofits.length > 0){\n json.sections.nonprofits.forEach(async element => {\n // Do not list GivingMultiplier itself\n if(element.data.slug == 'GivingMultiplier' || !element.data.ein || element.data.ein === '')\n return\n\n const src = element.data.cloudinary_id ?\n `https://res.cloudinary.com/everydotorg/image/upload/c_lfill,w_48,h_48,dpr_1/c_crop,ar_48:48/q_auto,f_auto,fl_progressive/${element.data.cloudinary_id}` :\n `/default-charity-image.svg`\n const img = ``\n\n let name = element.value;\n let id = element.data.slug\n let ein = element.data.ein;\n\n let wrapper = document.createElement('div');\n wrapper.innerHTML = `\n