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GAAGC,KAAK,IAAIP,MAAM,CAACO,KAAK,CAAC;IAC3C,CAAC,CAAC;EACN,CAAC;EAED,MAAM7B,YAAY,GAAG,MAAAA,CAAA,KAAY;IAC7B,MAAM8B,iBAAiB,GAAG,EAAE;IAC5B,CAAC,GAAG9G,SAAS,CAAC,CAAC6B,GAAG,CAACgC,IAAI,IAAI;MACvBiD,iBAAiB,CAACC,IAAI,CAACZ,QAAQ,CAACtC,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC;IACF,MAAMmD,SAAS,GAAG,MAAMZ,OAAO,CAACa,GAAG,CAACH,iBAAiB,CAAC;IACtD,OAAOE,SAAS,CAACnF,GAAG,CAAEqF,UAAU,KAAM;MAAC,QAAQ,EAAEA;IAAU,CAAC,CAAC,CAAC;EAClE,CAAC;EAEDjH,IAAI,CAAC,CAAC;AACV,CAAC,EAAE,CAAC,C","sources":["webpack://wp-hotel-booking/./assets/js/frontend/room-review.js"],"sourcesContent":["(function () {\n const openFomBtn = document.querySelector('#hb-room-add-new-review');\n const closeFormBtn = document.querySelector('.close-form-btn');\n\n const reviewFormPopup = document.querySelector('#hb-room-review-form-popup');\n let background, reviewForm\n let imageData = [];\n\n const init = () => {\n if (!reviewFormPopup) {\n return;\n }\n\n background = reviewFormPopup.querySelector('.bg-overlay');\n reviewForm = reviewFormPopup.querySelector('#hb-room-submit-review-form');\n\n openForm();\n closeForm();\n ratingReview();\n uploadImages();\n submitReview();\n sortReview();\n };\n jQuery(window).on('elementor/frontend/init', () => {\n elementorFrontend.hooks.addAction('frontend/element_ready/tours-widget-comment.default', init);\n });\n\n const sortReview = () => {\n const sortByNode = document.querySelector('#hb-room-sort-by');\n\n if (!sortByNode) {\n return;\n }\n\n document.addEventListener('click', function (event) {\n const target = event.target;\n if (target.classList.contains('toggle') && target.closest('.hb-room-commentlist-sort-filter')) {\n sortByNode.classList.add('is-open')\n } else if (!target.classList.contains('hb-sort-by-option')) {\n sortByNode.classList.remove('is-open')\n }\n });\n }\n\n const openForm = () => {\n if (!openFomBtn) {\n return;\n }\n\n\n openFomBtn.addEventListener('click', function () {\n background.classList.add('active');\n reviewForm.classList.add('active');\n });\n }\n\n const closeForm = () => {\n closeFormBtn.addEventListener('click', function () {\n background.classList.remove('active');\n reviewForm.classList.remove('active');\n })\n\n document.addEventListener('click', function (event) {\n const target = event.target;\n\n if (target.getAttribute('id') === 'hb-room-add-new-review') {\n return;\n }\n\n const formNode = target.closest('#hb-room-submit-review-form');\n\n if (!formNode && target.getAttribute('id') !== 'hb-room-submit-review-form') {\n background.classList.remove('active');\n reviewForm.classList.remove('active');\n }\n });\n }\n\n const ratingReview = () => {\n const reviewRatingNode = reviewForm.querySelector('#hb-room-submit-review-form input[name=\"review-rating\"]');\n\n if (!reviewRatingNode) {\n return;\n }\n\n const ratingNode = document.querySelector('#hb-room-submit-review-form .rating-star');\n const ratingStarItems = ratingNode.querySelectorAll('#hb-room-submit-review-form .rating-star-item');\n\n [...ratingStarItems].map(ratingStarItem => {\n ratingStarItem.addEventListener('mouseover', function (event) {\n const actived = this.closest('.rating-star.active');\n if (actived) {\n return;\n }\n\n ratingNode.classList.add('selected');\n ratingStarItem.classList.add('selected');\n });\n\n ratingStarItem.addEventListener('mouseleave', function (event) {\n const actived = this.closest('.rating-star.active');\n if (actived) {\n return;\n }\n\n ratingNode.classList.remove('selected');\n ratingStarItem.classList.remove('selected');\n });\n\n ratingStarItem.addEventListener('click', function (event) {\n event.preventDefault();\n reviewRatingNode.value = this.getAttribute('data-star-rating');\n\n const activeRatingStarNode = document.querySelector('#hb-room-submit-review-form .rating-star-item.active');\n\n if (activeRatingStarNode) {\n activeRatingStarNode.classList.remove('active');\n }\n\n ratingNode.classList.remove('selected');\n ratingNode.classList.add('active');\n ratingStarItem.classList.remove('selected');\n ratingStarItem.classList.add('active');\n });\n });\n }\n\n const uploadImages = () => {\n const galleryReview = document.querySelector('.hb-gallery-review');\n if (!galleryReview) {\n return;\n }\n\n if (typeof HB_ROOM_REVIEW_GALLERY === 'undefined') {\n return;\n }\n\n const roomId = galleryReview.getAttribute('data-room-id');\n const uploadImage = galleryReview.querySelector('#hb-room-review-image');\n const preview = galleryReview.querySelector('.gallery-preview');\n const reviewNotice = galleryReview.querySelector('.review-notice');\n\n const maxImages = HB_ROOM_REVIEW_GALLERY.max_images || 0;\n\n uploadImage.addEventListener('change', function () {\n removeNotice();\n\n const count = uploadImage.files.length;\n let uploadedCount = 0;\n const allowedTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif'];\n\n //Validate image number\n if (count + uploadedCount > maxImages) {\n handleUploadError();\n displayNotice(HB_ROOM_REVIEW_GALLERY.max_image_error, 'error');\n return;\n }\n\n for (let i = 0; i < count; i++) {\n if (!allowedTypes.includes(uploadImage.files[i].type)) {\n handleUploadError();\n displayNotice(HB_ROOM_REVIEW_GALLERY.file_type_error, 'error');\n return;\n } else if (uploadImage.files[i].size && uploadImage.files[i].size > parseInt(HB_ROOM_REVIEW_GALLERY.max_file_size) * 1024) {\n handleUploadError();\n displayNotice(HB_ROOM_REVIEW_GALLERY.max_file_size_error, 'error');\n return;\n }\n }\n\n let previewItemHtml = '';\n [...uploadImage.files].map(file => {\n const previewImage = window.URL.createObjectURL(file);\n previewItemHtml += `
\"#preview\"
`\n });\n\n if (previewItemHtml) {\n preview.innerHTML = previewItemHtml;\n }\n\n imageData = uploadImage.files;\n });\n\n const handleUploadError = () => {\n const notUploadedPreview = galleryReview.querySelectorAll('.cr-upload-images-preview .hb-upload-images-containers:not(.hb-upload-ok)');\n [...notUploadedPreview].map(el => {\n el.remove();\n });\n\n uploadImage.value = '';\n }\n\n const removeNotice = () => {\n reviewNotice.innerHTML = '';\n }\n\n const displayNotice = (message, status = 'success') => {\n if (status === 'success') {\n reviewNotice.classList.remove('error');\n reviewNotice.classList.add('success');\n } else {\n reviewNotice.classList.remove('success');\n reviewNotice.classList.add('error');\n }\n\n reviewNotice.innerHTML = message;\n }\n }\n\n const submitReview = () => {\n const submitBtnNode = reviewFormPopup.querySelector('footer button');\n submitBtnNode.addEventListener('click', async function () {\n submitBtnNode.disabled = true;\n const spinnerNode = reviewFormPopup.querySelector('.hb-room-spinner');\n spinnerNode.classList.add('active');\n const noticeNode = reviewFormPopup.querySelector('p.notice');\n noticeNode.innerHTML = '';\n const ratingNode = reviewFormPopup.querySelector('input[name=\"review-rating\"]');\n const contentNode = reviewFormPopup.querySelector('#review-content');\n const titleNode = reviewFormPopup.querySelector('#review-title');\n\n let rating = '';\n if (ratingNode) {\n rating = ratingNode.value;\n }\n\n const content = contentNode.value;\n const title = titleNode.value;\n\n const base64Images = await handleBase64();\n\n for (let i = 0; i < base64Images.length; i++) {\n base64Images[i].name = imageData[i].name;\n base64Images[i].type = imageData[i].type;\n }\n\n const roomId = reviewForm.getAttribute('data-room-id');\n\n let data = {\n \"room_id\": roomId\n }\n\n if (rating) {\n data = {...data, rating};\n }\n\n if (title) {\n data = {...data, title};\n }\n\n if (content) {\n data = {...data, content};\n }\n\n if (base64Images) {\n data = {...data, \"base64_images\": base64Images};\n }\n\n wp.apiFetch({\n path: '/hb-room/v1/update-review', method: 'POST', data,\n }).then((res) => {\n if (res.status === 'success') {\n noticeNode.classList.remove('failed');\n noticeNode.classList.add('success');\n\n if (res.msg) {\n noticeNode.innerHTML = res.msg;\n }\n\n if (res.data.redirect_url) {\n window.location.href = res.data.redirect_url;\n location.reload();\n return false;\n }\n } else {\n noticeNode.classList.remove('success');\n noticeNode.classList.add('failed');\n\n if (res.msg) {\n noticeNode.innerHTML = res.msg;\n }\n }\n }).catch((err) => {\n console.log(err);\n }).finally(() => {\n submitBtnNode.disabled = false;\n spinnerNode.classList.remove('active');\n });\n });\n }\n\n const toBase64 = (file) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result);\n reader.onerror = error => reject(error);\n });\n };\n\n const handleBase64 = async () => {\n const filePathsPromises = [];\n [...imageData].map(file => {\n filePathsPromises.push(toBase64(file));\n });\n const filePaths = await Promise.all(filePathsPromises);\n return filePaths.map((base64File) => ({\"base64\": base64File}));\n }\n\n init();\n})();\n"],"names":["openFomBtn","document","querySelector","closeFormBtn","reviewFormPopup","background","reviewForm","imageData","init","openForm","closeForm","ratingReview","uploadImages","submitReview","sortReview","jQuery","window","on","elementorFrontend","hooks","addAction","sortByNode","addEventListener","event","target","classList","contains","closest","add","remove","getAttribute","formNode","reviewRatingNode","ratingNode","ratingStarItems","querySelectorAll","map","ratingStarItem","actived","preventDefault","value","activeRatingStarNode","galleryReview","HB_ROOM_REVIEW_GALLERY","roomId","uploadImage","preview","reviewNotice","maxImages","max_images","removeNotice","count","files","length","uploadedCount","allowedTypes","handleUploadError","displayNotice","max_image_error","i","includes","type","file_type_error","size","parseInt","max_file_size","max_file_size_error","previewItemHtml","file","previewImage","URL","createObjectURL","innerHTML","notUploadedPreview","el","message","status","submitBtnNode","disabled","spinnerNode","noticeNode","contentNode","titleNode","rating","content","title","base64Images","handleBase64","name","data","wp","apiFetch","path","method","then","res","msg","redirect_url","location","href","reload","catch","err","console","log","finally","toBase64","Promise","resolve","reject","reader","FileReader","readAsDataURL","onload","result","onerror","error","filePathsPromises","push","filePaths","all","base64File"],"sourceRoot":""}