{"version":3,"file":"application-aa91525a.js","sources":["../../../app/javascript/controllers/navbar.js","../../../app/javascript/controllers/carNotes.js","../../../app/javascript/controllers/confirmations.js","../../../app/javascript/controllers/trix.js","../../../app/javascript/controllers/carIndex.js","../../../app/javascript/controllers/sheetEntries.js","../../../node_modules/trix/dist/trix.esm.min.js","../../../node_modules/@rails/actiontext/app/assets/javascripts/actiontext.js","../../../node_modules/fslightbox/index.js"],"sourcesContent":["const navbarButton = document.getElementById(\"navbarDropdownToggle\");\nconst navbarDropdown = document.getElementById(\"navbarDropdown\");\n\nif (navbarButton && navbarDropdown) {\n navbarButton.addEventListener(\"click\", () => {\n navbarDropdown.classList.toggle(\"hidden\");\n });\n}\n\n// Navbar search\nconst searchBar = document.getElementById(\"search_bar\");\n\nconst debounce = (callback, delay) => {\n let timeout;\n return (...args) => {\n const context = this;\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n callback.apply(context, args);\n }, delay);\n };\n};\n\nif (searchBar) {\n const url = new URL(window.location.href);\n const params = new URLSearchParams(url.search);\n\n searchBar.addEventListener(\n \"keyup\",\n debounce((e) => {\n const searchQuery = e.target.value;\n\n if (params.get(\"lpg\") === \"true\") {\n window.location.href = `/cars?query=${searchQuery}&lpg=true`;\n }else{\n window.location.href = `/cars?query=${searchQuery}`;\n }\n }, 500)\n );\n}\n\n// Load current search query to search bar\nconst currentQuery = new URLSearchParams(window.location.search).get(\"query\");\nif (currentQuery) {\n searchBar.value = currentQuery;\n}\n","const imageInput = document.getElementById(\"car-note-images-input\");\nconst fileCounter = document.getElementById(\"car-note-images-counter\");\n\nif (imageInput && fileCounter) {\n imageInput.addEventListener(\"change\", () => {\n fileCounter.innerText = `(${imageInput.files.length} files selected)`;\n });\n}\n","const confirmableButtons = document.querySelectorAll(\"[data-confirmation]\");\n\nconst confirmationModal = document.getElementById(\"confirmation-modal\");\nconst confrimationTitle = document.getElementById(\"confirmation-modal-title\");\nconst cancelButton = document.getElementById(\"confirmation-modal-cancel\");\nconst confirmButton = document.getElementById(\"confirmation-modal-confirm\");\n\nconfirmableButtons.forEach((button) => {\n button.addEventListener(\"click\", (event) => {\n event.preventDefault();\n const confirmationContent = button.dataset.confirmation;\n\n confirmationModal.classList.remove(\"hidden\");\n confrimationTitle.innerText = confirmationContent;\n confirmButton.innerText = confirmationContent;\n\n cancelButton.addEventListener(\"click\", () => {\n confirmationModal.classList.add(\"hidden\");\n });\n\n confirmButton.addEventListener(\"click\", () => {\n confirmationModal.classList.add(\"hidden\");\n event.target.closest(\"form\").submit();\n });\n });\n});\n","window.addEventListener(\"trix-file-accept\", function(event) {\n event.preventDefault()\n alert(\"File attachment not supported!\")\n})\n","const lpgFilterCheckbox = document.getElementById(\"js-lpg-filter\");\nconst vinFilterCheckbox = document.getElementById(\"js-vin-filter\");\n\n// Set the checkbox to checked if the param is present in the URL\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n if (new URLSearchParams(window.location.search).get(\"lpg\")) {\n lpgFilterCheckbox.checked = true;\n }\n\n if (new URLSearchParams(window.location.search).get(\"vin\")) {\n vinFilterCheckbox.checked = true;\n }\n});\n\n// Handle the checkbox click\nconst handleFilterParams = (checkbox, paramName) => {\n checkbox.addEventListener(\"click\", (e) => {\n const isChecked = e.target.checked;\n const url = new URL(window.location.href);\n let params = new URLSearchParams(url.search);\n\n if (isChecked) {\n params.set(paramName, \"true\");\n } else {\n params.delete(paramName);\n }\n\n window.location.href = `${window.location.origin}${window.location.pathname}?${params.toString()}`;\n });\n};\n\nif (lpgFilterCheckbox || vinFilterCheckbox) {\n handleFilterParams(lpgFilterCheckbox, \"lpg\");\n handleFilterParams(vinFilterCheckbox, \"vin\");\n}\n\n// Cars sort buttons\nconst sortButtons = document.querySelectorAll(\".js-cars-sort\");\n\nsortButtons.forEach((button) => {\n button.addEventListener(\"click\", () => {\n const sortType = button.dataset.sort;\n\n const url = new URL(window.location.href);\n let params = new URLSearchParams(url.search);\n\n if (params.get(\"order_column\") === sortType) {\n params.set(\"order\", params.get(\"order\") === \"asc\" ? \"desc\" : \"asc\");\n } else {\n params.set(\"order_column\", sortType);\n params.set(\"order\", \"asc\");\n }\n\n window.location.href = `${window.location.origin}${window.location.pathname}?${params.toString()}`;\n });\n});\n\nconst currentSortType = new URLSearchParams(window.location.search).get(\"order_column\");\n\nif (currentSortType) {\n const currentSortButton = document.querySelector(`[data-sort=\"${currentSortType}\"]`);\n currentSortButton.classList.add(\"bg-gray-200\", \"text-gray-900\");\n\n const currentSortOrder = new URLSearchParams(window.location.search).get(\"order\");\n\n if (currentSortOrder === \"asc\") {\n const svg = currentSortButton.querySelector(\"svg\");\n svg.classList.add(\"rotate-180\");\n } else {\n const defaultSortButton = document.querySelector(`[data-sort=\"updated_at\"]`);\n defaultSortButton.classList.add(\"bg-gray-200\", \"text-gray-900\");\n }\n}\n","const url = new URL(window.location.href);\nlet params = new URLSearchParams(url.search);\n\n// Auto select workshop and state filters\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n const searchParam = new URLSearchParams(window.location.search);\n const workshopParam = searchParam.get(\"workshop\");\n const stateParam = searchParam.get(\"state\");\n\n if (workshopParam) {\n const workshopInput = document.getElementById(workshopParam);\n workshopInput.checked = true;\n } else {\n const defaultInput = document.getElementById(\"wernyhory\");\n defaultInput.checked = true;\n }\n\n if (stateParam) {\n const stateInput = document.getElementById(stateParam);\n stateInput.checked = true;\n } else {\n const defaultInput = document.getElementById(\"all\");\n defaultInput.checked = true;\n }\n});\n\n// Index filters handlers\nconst sheetEntryFilters = document.getElementById(\"sheet-entries-filters-js\");\n\nif (sheetEntryFilters) {\n const workshopRadios = document.querySelectorAll('input[name=\"selected_workshop\"]');\n const stateRadios = document.querySelectorAll('input[name=\"selected_state\"]');\n\n workshopRadios.forEach((radio) => {\n radio.addEventListener(\"change\", function () {\n if (this.checked) {\n params.set(\"workshop\", this.id);\n window.location.href = `${window.location.origin}${window.location.pathname}?${params.toString()}`;\n }\n });\n });\n\n stateRadios.forEach((radio) => {\n radio.addEventListener(\"change\", function () {\n if (this.checked) {\n params.set(\"state\", this.id);\n window.location.href = `${window.location.origin}${window.location.pathname}?${params.toString()}`;\n }\n });\n });\n}\n\n// Form\nconst carSheetForm = document.getElementById(\"car_sheet_form\");\n\nif (carSheetForm) {\n const carSelect = document.getElementById(\"sheet_entry_car_id\");\n const titleInput = document.getElementById(\"sheet_entry_title\");\n\n carSelect.addEventListener(\"change\", () => {\n const value = carSelect.value === \"\" ? \"\" : carSelect.options[carSelect.selectedIndex].text;\n\n titleInput.value = value;\n });\n}\n\n// Sheet entries notes opening\nconst sheetEntryOpenNote = document.querySelectorAll(\".sheet-entry-open-note-js\");\n\nif (sheetEntryOpenNote) {\n sheetEntryOpenNote.forEach((openButton) => {\n openButton.addEventListener(\"click\", () => {\n const note = openButton.nextElementSibling;\n\n if (note && note.classList.contains(\"hidden\")) {\n note.classList.remove(\"hidden\");\n }\n });\n });\n}\n\n// Sheet entries notes closing\nconst sheetEntryNoteClose = document.querySelectorAll(\".sheet-entry-note-close-js\");\n\nif (sheetEntryNoteClose) {\n sheetEntryNoteClose.forEach((closeButton) => {\n closeButton.addEventListener(\"click\", () => {\n const note = closeButton.closest(\".sheet-entry-note-js\");\n if (note && !note.classList.contains(\"hidden\")) {\n note.classList.add(\"hidden\");\n }\n });\n });\n}\n","/*\nTrix 2.0.4\nCopyright © 2022 37signals, LLC\n */\nconst t={preview:{presentation:\"gallery\",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},e={default:{tagName:\"div\",parse:!1},quote:{tagName:\"blockquote\",nestable:!0},heading1:{tagName:\"h1\",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:\"pre\",terminal:!0,text:{plaintext:!0}},bulletList:{tagName:\"ul\",parse:!1},bullet:{tagName:\"li\",listAttribute:\"bulletList\",group:!1,nestable:!0,test(t){return i(t.parentNode)===e[this.listAttribute].tagName}},numberList:{tagName:\"ol\",parse:!1},number:{tagName:\"li\",listAttribute:\"numberList\",group:!1,nestable:!0,test(t){return i(t.parentNode)===e[this.listAttribute].tagName}},attachmentGallery:{tagName:\"div\",exclusive:!0,terminal:!0,parse:!1,group:!1}},i=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},n=navigator.userAgent.match(/android\\s([0-9]+.*Chrome)/i),r=n&&parseInt(n[1]);var o={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:r&&r>12,samsungAndroid:r&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:\"undefined\"!=typeof InputEvent&&[\"data\",\"getTargetRanges\",\"inputType\"].every((t=>t in InputEvent.prototype))},s={attachFiles:\"Attach Files\",bold:\"Bold\",bullets:\"Bullets\",byte:\"Byte\",bytes:\"Bytes\",captionPlaceholder:\"Add a caption…\",code:\"Code\",heading1:\"Heading\",indent:\"Increase Level\",italic:\"Italic\",link:\"Link\",numbers:\"Numbers\",outdent:\"Decrease Level\",quote:\"Quote\",redo:\"Redo\",remove:\"Remove\",strike:\"Strikethrough\",undo:\"Undo\",unlink:\"Unlink\",url:\"URL\",urlPlaceholder:\"Enter a URL…\",GB:\"GB\",KB:\"KB\",MB:\"MB\",PB:\"PB\",TB:\"TB\"};const a=[s.bytes,s.KB,s.MB,s.GB,s.TB,s.PB];var l={prefix:\"IEC\",precision:2,formatter(t){switch(t){case 0:return\"0 \".concat(s.bytes);case 1:return\"1 \".concat(s.byte);default:let e;\"SI\"===this.prefix?e=1e3:\"IEC\"===this.prefix&&(e=1024);const i=Math.floor(Math.log(t)/Math.log(e)),n=(t/Math.pow(e,i)).toFixed(this.precision).replace(/0*$/,\"\").replace(/\\.$/,\"\");return\"\".concat(n,\" \").concat(a[i])}}};const c=function(t){for(const e in t){const i=t[e];this[e]=i}return this},h=document.documentElement,u=h.matches,d=function(t){let{onElement:e,matchingSelector:i,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=e||h,l=i,c=\"capturing\"===r,u=function(t){null!=s&&0==--s&&u.destroy();const e=p(t.target,{matchingSelector:l});null!=e&&(null==n||n.call(e,t,e),o&&t.preventDefault())};return u.destroy=()=>a.removeEventListener(t,u,c),a.addEventListener(t,u,c),u},g=function(t){let{onElement:e,bubbles:i,cancelable:n,attributes:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=null!=e?e:h;i=!1!==i,n=!1!==n;const s=document.createEvent(\"Events\");return s.initEvent(t,i,n),null!=r&&c.call(s,r),o.dispatchEvent(s)},m=function(t,e){if(1===(null==t?void 0:t.nodeType))return u.call(t,e)},p=function(t){let{matchingSelector:e,untilNode:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==e)return t;if(t.closest&&null==i)return t.closest(e);for(;t&&t!==i;){if(m(t,e))return t;t=t.parentNode}}},f=t=>document.activeElement!==t&&b(t,document.activeElement),b=function(t,e){if(t&&e)for(;e;){if(e===t)return!0;e=e.parentNode}},v=function(t){var e;if(null===(e=t)||void 0===e||!e.parentNode)return;let i=0;for(t=t.previousSibling;t;)i++,t=t.previousSibling;return i},A=t=>{var e;return null==t||null===(e=t.parentNode)||void 0===e?void 0:e.removeChild(t)},x=function(t){let{onlyNodesOfType:e,usingFilter:i,expandEntityReferences:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(()=>{switch(e){case\"element\":return NodeFilter.SHOW_ELEMENT;case\"text\":return NodeFilter.SHOW_TEXT;case\"comment\":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}})();return document.createTreeWalker(t,r,null!=i?i:null,!0===n)},y=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},C=function(t){let e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};\"object\"==typeof t?(n=t,t=n.tagName):n={attributes:n};const r=document.createElement(t);if(null!=n.editable&&(null==n.attributes&&(n.attributes={}),n.attributes.contenteditable=n.editable),n.attributes)for(e in n.attributes)i=n.attributes[e],r.setAttribute(e,i);if(n.style)for(e in n.style)i=n.style[e],r.style[e]=i;if(n.data)for(e in n.data)i=n.data[e],r.dataset[e]=i;return n.className&&n.className.split(\" \").forEach((t=>{r.classList.add(t)})),n.textContent&&(r.textContent=n.textContent),n.childNodes&&[].concat(n.childNodes).forEach((t=>{r.appendChild(t)})),r};let R;const E=function(){if(null!=R)return R;R=[];for(const t in e){const i=e[t];i.tagName&&R.push(i.tagName)}return R},S=t=>D(null==t?void 0:t.firstChild),k=function(t){return E().includes(y(t))&&!E().includes(y(t.firstChild))},L=function(t){let{strict:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{strict:!0};return e?D(t):D(t)||!D(t.firstChild)&&k(t)},D=t=>w(t)&&\"block\"===(null==t?void 0:t.data),w=t=>(null==t?void 0:t.nodeType)===Node.COMMENT_NODE,T=function(t){let{name:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t)return I(t)?\"\\ufeff\"===t.data?!e||t.parentNode.dataset.trixCursorTarget===e:void 0:T(t.firstChild)},F=t=>m(t,\"[data-trix-attachment]\"),B=t=>I(t)&&\"\"===(null==t?void 0:t.data),I=t=>(null==t?void 0:t.nodeType)===Node.TEXT_NODE,P={level2Enabled:!0,getLevel(){return this.level2Enabled&&o.supportsInputEvents?2:0},pickFiles(t){const e=C(\"input\",{type:\"file\",multiple:!0,hidden:!0,id:this.fileInputId});e.addEventListener(\"change\",(()=>{t(e.files),A(e)})),A(document.getElementById(this.fileInputId)),document.body.appendChild(e),e.click()}};var N={removeBlankTableCells:!1,tableCellSeparator:\" | \",tableRowSeparator:\"\\n\"},O={bold:{tagName:\"strong\",inheritable:!0,parser(t){const e=window.getComputedStyle(t);return\"bold\"===e.fontWeight||e.fontWeight>=600}},italic:{tagName:\"em\",inheritable:!0,parser:t=>\"italic\"===window.getComputedStyle(t).fontStyle},href:{groupTagName:\"a\",parser(t){const e=\"a:not(\".concat(\"[data-trix-attachment]\",\")\"),i=t.closest(e);if(i)return i.getAttribute(\"href\")}},strike:{tagName:\"del\",inheritable:!0},frozen:{style:{backgroundColor:\"highlight\"}}},M={getDefaultHTML:()=>'
\\n\\n