1const B=document.querySelector('meta[name="csrf-token"]')?.getAttribute("content"),R={Accept:"application/json",...B&&{"X-CSRF-TOKEN":B}};(function(){document.querySelector("#reviews-description-input").addEventListener("input",function(n){document.querySelector("#count-reviews-description-input").innerHTML=n.target.value.length});const u=document.getElementById("add-reviews-btn"),w=document.querySelector("#review-form");if(!u)return;const t={name:document.getElementById("reviews-name-input"),email:document.getElementById("reviews-email-input"),phone:document.getElementById("reviews-number-phone-input"),description:document.getElementById("reviews-description-input"),country:document.getElementById("reviews-country-input"),city:document.getElementById("reviews-city-input"),hotel:document.getElementById("reviews-hotel-input"),date:document.getElementById("reviews-date-input"),photos:document.querySelectorAll('input[type="file"][id^="reviews-photo-input"]'),file:document.getElementById("reviews-file-input"),video:document.getElementById("reviews-video-input"),agreement:document.getElementById("reviews-agreement-input")};t.photos&&t.photos.length&&t.photos.forEach(n=>{const l=document.querySelector(`label[for="${n.id}"]`)?.querySelector(".photo-preview-container"),s=l?.querySelector(".photo-preview-img"),m=l?.querySelector(".photo-placeholder-icon"),f=l?.querySelector(".remove-photo-btn");n.addEventListener("change",function(){if(n.files&&n.files[0]){const h=new FileReader;h.onload=function(y){s.src=y.target.result,s.classList.remove("hidden"),m.classList.add("hidden"),f.classList.remove("hidden")},h.readAsDataURL(n.files[0])}else m.classList.remove("hidden"),s.classList.add("hidden"),f.classList.add("hidden")}),f.addEventListener("click",function(h){h.preventDefault(),n.value="",m.classList.remove("hidden"),s.classList.add("hidden"),f.classList.add("hidden")})});const E=5e3,d=5,p=7.5*1024*1024,S=["image/jpeg","image/png"],P=["application/pdf","application/x-pdf","application/acrobat","applications/vnd.pdf","text/pdf","text/x-pdf"],c=(n,r)=>{toastr.error(n),r&&(r.classList.add("border-secondary"),r.nextElementSibling&&r.nextElementSibling.classList.remove("hidden"))},k=n=>{n&&(n.classList.remove("border-secondary"),n.nextElementSibling&&n.nextElementSibling.classList.add("hidden"))},$=n=>!n||n.length>254?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n);function F(n){return/^[\d\s()+-]{10,}$/.test(n)}const _=(n,r,l)=>{for(const s of n){const m=s.name.split(".").pop().toLowerCase();if(!r.includes(s.type.trim())&&m!=="pdf")return`ÐедопÑÑÑимÑй Ñип Ñайла: ${s.name} (${s.type})`;if(s.size>l*1024*1024)return`Файл ${s.name} болÑÑе ${l} ÐÐ`}return""};(()=>{if(!t.file)return;const n=document.querySelector(`label[for="${t.file.id}"] p`);let r=null;function l(){t.file.value="",n&&(n.textContent=`ÐеÑеÑаÑиÑе ÑÐ°Ð¹Ð»Ñ Ð² ÑÑÑ Ð¾Ð±Ð»Ð°ÑÑÑ 2 или нажмиÑе, ÑÑÐ¾Ð±Ñ Ð·Ð°Ð³ÑÑзиÑÑ`),r&&r.parentNode&&r.parentNode.removeChild(r),r=null}t.file.addEventListener("change",()=>{n&&(t.file.files.length?(n.textContent=t.file.files[0].name,r||(r=document.createElement("button"),r.type="button",r.innerHTML="Ã",r.className="absolute right-[-30px] top-1/2 -translate-y-1/2 bg-gray-200 rounded-full w-6 h-6 text-lg flex items-center justify-center",r.onclick=l,n.appendChild(r),n.style.position="relative")):l())})})(),u.addEventListener("click",async()=>{Object.keys(t).forEach(e=>{const o=t[e];e!=="agreement"&&o instanceof HTMLElement&&k(o)});const r=document.querySelector("#reviews-country-input")?.closest("[x-data]")?.querySelectorAll('input[type="hidden"][name^="reviews-country-input"]'),l=r?Array.from(r).map(e=>e.value).filter(e=>e):[],m=document.querySelector("#reviews-city-input")?.closest("[x-data]")?.querySelectorAll('input[type="hidden"][name^="reviews-city-input"]'),f=m?Array.from(m).map(e=>e.value).filter(e=>e):[],h=window.Alpine.store("common").cityResorts||[],y=[],b=[];f.forEach(e=>{const o=h.find(x=>String(x.value)===String(e));o?o.type==="region"?y.push(o.id):o.type==="resort"&&b.push(o.id):typeof e=="string"&&e.startsWith("region_")?y.push(parseInt(e.split("_")[1],10)):typeof e=="string"&&e.startsWith("resort_")&&b.push(parseInt(e.split("_")[1],10))});const i={name:t.name?.value?.trim()||"",email:t.email?.value?.trim()||"",phone:t.phone?.value?.trim()||"",description:t.description?.value?.trim()||"",destinationIds:l,regionIds:y,resortIds:b,hotel:t.hotel?.value?.trim()||"",date:t.date?.value?.trim()||"",video:t.video?.value?.trim()||"",agreement:t.agreement?.checked||!1};if(!i.name)return c("ÐведиÑе имÑ.",t.name);if(!i.email&&!i.phone){c("УкажиÑе email или Ð½Ð¾Ð¼ÐµÑ ÑелеÑона.",t.email),c("УкажиÑе email или Ð½Ð¾Ð¼ÐµÑ ÑелеÑона.",t.phone);return}if(i.email&&!$(i.email))return c("ÐевеÑнÑй email.",t.email);if(i.phone&&!F(i.phone))return c("ÐекоÑÑекÑнÑй ÑоÑÐ¼Ð°Ñ ÑелеÑона.",t.phone);if(!i.description)return c("ÐведиÑе опиÑание.",t.description);if(i.description.length>E)return c("ÐпиÑание пÑевÑÑÐ°ÐµÑ 5000 Ñимволов.",t.description);if(!i.agreement)return c("ÐÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑоглаÑие на обÑабоÑÐºÑ Ð¿ÐµÑÑоналÑнÑÑ Ð´Ð°Ð½Ð½ÑÑ .");const g=[];
2if(t.photos&&t.photos.length&&t.photos.forEach(e=>{e.files&&e.files.length&&g.push(...Array.from(e.files))}),g.length>5)return c("Ðожно добавиÑÑ Ð½Ðµ более 5 ÑоÑогÑаÑий.");const q=_(g,S,d);if(q)return c(q);const I=t.file&&t.file.files?Array.from(t.file.files):[],T=_(I,P,d);if(T)return c(T);let L="";try{if(L=grecaptcha.getResponse(),!L)return c("ÐожалÑйÑÑа, пÑойдиÑе пÑовеÑÐºÑ reCAPTCHA.")}catch(e){return console.error("ÐÑибка полÑÑÐµÐ½Ð¸Ñ Ñокена reCAPTCHA:",e),c("ÐÑибка пÑовеÑки reCAPTCHA. ÐожалÑйÑÑа, обновиÑе ÑÑÑаниÑÑ.")}const a=new FormData;a.append("author_name",i.name),a.append("email",i.email),a.append("phone",i.phone),a.append("content",i.description),i.destinationIds.forEach(e=>{a.append("destination_ids[]",e)}),i.regionIds.forEach(e=>{a.append("region_ids[]",e)}),i.resortIds.forEach(e=>{a.append("resort_ids[]",e)}),a.append("hotel_name",i.hotel),a.append("travel_dates",i.date),a.append("youtube_video_id",i.video),g.length&&g.forEach((e,o)=>a.append(`photos[${o}]`,e)),I.length&&a.append("file",I[0]),a.append("captcha",L);let C=0;for(const[e,o]of a.entries())o instanceof File?C+=o.size:typeof o=="string"&&(C+=new Blob([o]).size);if(C>p)return c("Ð Ð°Ð·Ð¼ÐµÑ Ð´Ð°Ð½Ð½ÑÑ
ÑлиÑком велик (болÑÑе 7,5 ÐÐ). УменÑÑиÑе ÑÐ°Ð·Ð¼ÐµÑ ÑоÑогÑаÑий или оÑпÑавÑÑе менÑÑе Ñайлов.");try{const e=await fetch("/api/reviews",{method:"POST",headers:R,body:a});if(!e.ok){if(e.status===413)throw new Error("Ð Ð°Ð·Ð¼ÐµÑ Ð¾ÑпÑавлÑемÑÑ
даннÑÑ
пÑевÑÑÐ°ÐµÑ Ð´Ð¾Ð¿ÑÑÑимÑй Ð»Ð¸Ð¼Ð¸Ñ ÑеÑвеÑа. УменÑÑиÑе ÑÐ°Ð·Ð¼ÐµÑ ÑоÑогÑаÑий (до 5 ÐРкаждаÑ) или оÑпÑавÑÑе менÑÑе Ñайлов.");const o=await e.json().catch(()=>({}));if(o.errors&&o.errors.captcha)try{grecaptcha.reset()}catch(H){console.error("ÐÑибка ÑбÑоÑа reCAPTCHA:",H)}const x=o.errors?.captcha?.[0]||o.errors?.error?.[0]||o.message||"ÐÑибка пÑи оÑпÑавке оÑзÑва.";throw new Error(x)}toastr.success("ÐÑзÑв ÑÑпеÑно оÑпÑавлен!");try{grecaptcha.reset()}catch(o){console.error("ÐÑибка ÑбÑоÑа reCAPTCHA:",o)}w&&(w.reset(),window.dispatchEvent(new CustomEvent("reset-form")),window.Alpine.store("common").cityResorts=[])}catch(e){const o=e.message||(e.name==="TypeError"&&e.message.includes("fetch")?"ÐÑибка ÑеÑи или ÑеÑвеÑа. ÐÑли Ð²Ñ Ð¿ÑикÑеплÑли много ÑоÑо, ÑменÑÑиÑе иÑ
ÑÐ°Ð·Ð¼ÐµÑ Ð¸Ð»Ð¸ колиÑеÑÑво и попÑобÑйÑе Ñнова.":"ÐÑибка пÑи оÑпÑавке оÑзÑва.");c(o)}});const A=document.querySelector("#reviews-country-input")?.closest("[x-data]");A&&A.addEventListener("selection-changed",function(n){const r=A.querySelectorAll('input[type="hidden"][name^="reviews-country-input"]'),l=Array.from(r).map(s=>s.value).filter(s=>s);M(l)})})();async function M(v){if(!v||v.length===0){window.Alpine.store("common").cityResorts=[];const u=document.querySelector("#reviews-city-input")?.closest("[x-data]")?.querySelector(".selected-label");u&&(u.textContent="ÐÑбеÑиÑе гоÑод/кÑÑоÑÑ");return}try{const u=v.map(d=>fetch(`/api/destinations/${d}/regions-and-resorts`,{method:"GET",headers:R}).then(p=>p.ok?p.json():[])),w=await Promise.all(u),t=[],E=new Set;if(w.forEach(d=>{(d||[]).forEach(p=>{if(p.type==="region")return;const S=String(p.value);E.has(S)||(E.add(S),t.push(p))})}),t.sort((d,p)=>d.label.localeCompare(p.label)),t.length>0)window.Alpine.store("common").cityResorts=t;else{window.Alpine.store("common").cityResorts=[];const d=document.querySelector("#reviews-city-input")?.closest("[x-data]")?.querySelector(".selected-label");d&&(d.textContent="ÐÑбеÑиÑе гоÑод/кÑÑоÑÑ")}}catch(u){console.error("ÐÑибка:",u),window.Alpine.store("common").cityResorts=[]}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.