1import{j as e,ab as ke,Q as Ce,r as o,o as w,q as L,L as E,X as me,S as Se,I as Pe}from"./index-CzU4y74h.js";import{B as k}from"./button-D0Dh8djn.js";import{I as j}from"./input-Cz34psQm.js";import{L as h}from"./label-FEBr_jP9.js";import{u as Ee}from"./useLayoutMode-BpuAGbem.js";import{C as G,c as xe}from"./classifiedTaxonomy-CcfS_W1z.js";import{u as Ie}from"./cloudinaryUpload-CGwPXeib.js";import{S as H}from"./star-CsT53tHA.js";import{I as V}from"./info-FXP1HDFd.js";import{u as De}from"./useRecaptcha-B3vD_fot.js";import{C as Fe}from"./circle-alert-O35H8__V.js";import{C as Ae}from"./check-8IyyurWK.js";import{C as $e}from"./clock-Da0fXOWx.js";import{C as Re}from"./camera-DyS6L5mC.js";import{S as pe}from"./sparkles-BEOkb6R8.js";import{U as ze}from"./upload-DEoLnq4K.js";import{S as Le}from"./shield-check-VbzmRDSF.js";const X={property:{pricePerDay:100,tier:"premium",label:"Premium"},for_sale:{pricePerDay:50,tier:"standard",label:"Standard"},vehicles_equipment:{pricePerDay:50,tier:"standard",label:"Standard"},jobs_gigs:{pricePerDay:50,tier:"standard",label:"Standard"},services:{pricePerDay:50,tier:"standard",label:"Standard"},business_commercial:{pricePerDay:50,tier:"standard",label:"Standard"},garage_estate_sales:{pricePerDay:50,tier:"standard",label:"Standard"},farm_garden:{pricePerDay:50,tier:"standard",label:"Standard"},creative_makers:{pricePerDay:50,tier:"standard",label:"Standard"},pets_animals:{pricePerDay:0,tier:"safety_alert",label:"Free Safety Alert"}},Te=["wanted_free_swap","community"];function Me(r,n){const d=X[r];return d?d.pricePerDay===0?"FREE":`$${d.pricePerDay*n}`:""}function qe(r,n){return Te.includes(r)||r==="pets_animals"&&n!=="lost_pets"?!1:!!X[r]}function Ye({categoryId:r,subcategoryId:n,enabled:d,setEnabled:m,days:b,setDays:I}){if(!r||!qe(r,n))return null;const v=X[r];if(v.tier==="safety_alert")return e.jsx("div",{className:"rounded-xl border-2 border-emerald-300 bg-emerald-50 p-4",children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:f=>m(f.target.checked),className:"mt-0.5 w-4 h-4 accent-emerald-700 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(H,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"font-heading font-bold text-[14px] text-emerald-950",children:"Push as free safety alert"})]}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-relaxed",children:"Lost pet listings are automatically pushed as a free safety alert to the top of the marketplace widget for 24 hours â no payment needed. This is our community service for helping lost pets find their way home."})]})]})});const q=v.pricePerDay*b;return e.jsx("div",{className:`rounded-xl border-2 p-4 transition-colors ${d?"border-amber-400 bg-amber-50":"border-amber-200 bg-white"}`,children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:f=>m(f.target.checked),className:"mt-0.5 w-4 h-4 accent-amber-600 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(H,{className:`w-4 h-4 ${d?"text-amber-500 fill-amber-400":"text-amber-400"}`}),e.jsx("span",{className:"font-heading font-bold text-[14px] text-emerald-950",children:"Feature this listing"}),e.jsxs("span",{className:"ml-auto text-[11px] font-bold text-amber-600 bg-amber-100 px-1.5 py-0.5 rounded",children:[v.label," · $",v.pricePerDay,"/day"]})]}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-relaxed mb-2",children:"Your listing will appear at the top of the marketplace widget shown alongside local news articles across the Country Herald site â giving you premium exposure to readers in your area. Featured listings get a golden border and star badge, making them stand out from regular listings."}),d&&e.jsxs("div",{className:"mt-3 border-t border-amber-200 pt-3",children:[e.jsx("p",{className:"text-[12px] font-bold text-slate-700 mb-1.5",children:"How many days?"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[1,2,3,5,7].map(f=>e.jsxs("button",{onClick:()=>I(f),className:`px-2.5 py-1 rounded-md text-[12px] font-medium transition-colors ${b===f?"bg-amber-600 text-white":"bg-white text-slate-600 border border-slate-200 hover:border-amber-300"}`,children:[f," day",f>1?"s":""]},f))}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-amber-100 px-3 py-2",children:[e.jsxs("span",{className:"text-[12px] text-slate-600",children:[v.pricePerDay," à ",b," ",b>1?"days":"day"]}),e.jsxs("span",{className:"font-heading text-lg font-extrabold text-amber-700",children:["$",q]})]}),e.jsxs("div",{className:"flex items-start gap-1.5 mt-2",children:[e.jsx(V,{className:"w-3 h-3 text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-relaxed",children:"Why we charge: Featured listings take priority placement in our article widgets, reaching thousands of local readers. The daily fee keeps slots limited so your ad gets maximum visibility. Max 3 featured listings per ZIP code at a time â your spot is reserved when you check out."})]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1.5",children:"Payment is processed securely via Stripe. Your listing goes live after email verification, and featured status activates immediately after checkout."})]})]})]})})}const J="ch_classified_draft_v1",T=6,ue=1e3;function ot(){ke();const{location:r}=Ce(),n=Ee(),d=o.useRef(null),[m,b]=o.useState(1),[I,N]=o.useState(!1),[v,D]=o.use
1State(!1),[q,f]=o.useState(!1),[F,y]=o.useState(""),[p,C]=o.useState([]),[A,Y]=o.useState(!1),[he,ge]=o.useState(!1),[S,K]=o.useState(!1),[Q,O]=o.useState(""),[be,$]=o.useState(!1),[ee,R]=o.useState(""),[P,fe]=o.useState(!1),[U,ye]=o.useState(1),[te,ae]=o.useState(!1),{getToken:je}=De(),[a,z]=o.useState({title:"",description:"",category_id:"",subcategory_id:"",price_type:"fixed",price_amount:"",price_text:"",condition:"",city:"",state_abbr:"",county:"",state:"",zip:"",exact_address:"",show_exact_address:!1,contact_name:"",contact_email:"",contact_phone:"",contact_mode:"relay",structured_details:{}});o.useEffect(()=>{try{const t=sessionStorage.getItem(J);if(t){const s=JSON.parse(t);z(s.form||a),C(s.images||[]),s.step&&b(s.step)}}catch{}},[]),o.useEffect(()=>{try{sessionStorage.setItem(J,JSON.stringify({form:a,images:p,step:m}))}catch{}},[a,p,m]),o.useEffect(()=>{r&&z(t=>({...t,city:t.city||r.city||"",state_abbr:t.state_abbr||r.state_abbr||"",state:t.state||r.state||"",county:t.county||r.county||"",zip:t.zip||r.zip||""}))},[r]),o.useEffect(()=>{const t=String(a.zip||"").trim();if(!/^\d{5}$/.test(t)){R("");return}let s=!1;return $(!0),R(""),w.functions.invoke("resolveZip",{zip:t}).then(l=>{if(s)return;const i=l.data||l,g=i.locations||[];if(!i.ok||g.length===0){R("We couldn't find that ZIP code. Please check and try again."),$(!1);return}const u=g[0];z(c=>({...c,city:u.city||c.city,state_abbr:u.state_abbr||c.state_abbr,state:u.state||c.state,county:u.county||c.county,zip:t})),$(!1)}).catch(()=>{s||(R("Could not resolve ZIP code. Please try again."),$(!1))}),()=>{s=!0}},[a.zip]);const x=t=>z(s=>({...s,...t})),se=async t=>{var g;O("");const s=T-p.length,l=Array.from(t).slice(0,s);if(l.length===0)return;K(!0);const i=[];for(const u of l)try{const c=await Ie(u,"classifieds");c!=null&&c.secure_url&&i.push(c.secure_url)}catch(c){const _=(c==null?void 0:c.message)||(c==null?void 0:c.error)||"";O(_?`Photo upload failed: ${_}`:"Photo upload failed. Please try again.")}if(i.length>0)try{const u=await w.functions.invoke("moderateClassifiedImage",{image_urls:i}),c=u.data||u;if(!c.approved&&((g=c.rejected_images)==null?void 0:g.length)>0){const _=i.filter(B=>!c.rejected_images.includes(B));_.length>0&&C(B=>[...B,..._]),O(`One or more photos were rejected for violating our content policy${c.reason?`: ${c.reason}`:""}. Please upload family-friendly images only.`)}else C(_=>[..._,...i])}catch{C(u=>[...u,...i])}K(!1)},re=async()=>{const t=p[0];if(t){Y(!0),y("");try{const s=await w.functions.invoke("analyzeClassifiedPhoto",{image_url:t}),l=s.data||s;if(l.error){y(l.error),Y(!1);return}const i={};l.title&&(i.title=l.title),l.description&&(i.description=l.description),l.category_id&&(i.category_id=l.category_id),l.subcategory_id&&(i.subcategory_id=l.subcategory_id),Object.keys(i).length>0&&(x(i),ge(!0))}catch(s){y(M(s))}Y(!1)}},Z=o.useRef(!1);o.useEffect(()=>{p.length>0&&!Z.current&&(Z.current=!0,re()),p.length===0&&(Z.current=!1)},[p]);const ie=t=>{C(s=>s.filter((l,i)=>i!==t))},le=()=>{var s;if(!a.category_id)return null;const t=xe[a.category_id]||[];for(const l of t)if(l.required&&!((s=a.structured_details)==null?void 0:s[l.id]))return`${l.label} is required for this category.`;return null},Ne=async()=>{N(!0),y("");try{const t=String(a.state_abbr||"").toUpperCase();if(!a.city||!t){y("City and state are required."),N(!1);return}if(!a.zip||!/^\d{5}$/.test(a.zip)){y("A valid 5-digit ZIP code is required."),N(!1);return}if(!a.contact_email){y("Email is required."),N(!1);return}const s=le();if(s){y(s),N(!1);return}const l=await je("submit_classified"),i=await w.functions.invoke("submitClassifiedListing",{title:a.title,description:a.description,category_id:a.category_id,subcategory_id:a.subcategory_id,subcategory_label:Ze(a.category_id,a.subcategory_id),price_type:a.price_type,price_amount:a.price_amount?parseFloat(a.price_amount):null,price_text:a.price_text,condition:a.condition,images:p,city:a.city,county:a.county,state:a.state,state_abbr:t,zip:a.zip,exact_address:a.exact_address,show_exact_address:a.show_exact_address,contact_name:a.contact_name,contact_email:a.contact_email,contact_phone:a.contact_phone,contact_mode:a.contact_mode,structured_details:a.structured_details,captcha_token:l}),g=i.data||i;if(g.error)throw new Error(g.error);if(sessionStorage.removeItem(J),P&&g.id){ae(!0);try{const u=await w.functions.invoke("createFeaturedCheckout",{listing_id:g.id,days:U}),c=u.data||u;if(c.error)throw new Error(c.error);if(c.checkout_url){window.location.href=c.checkout_url;return}if(c.free){D(!0);return}}catch(u){y(`Listing posted, but featured checkout failed: ${M(u)}`),D(!0);return}ae(!1)}D(!0),g.email_failed&&(f(!0),g.id&&sessionStorage.setItem("ch_classified_pending_id",g.id))}catch(t){y(M(t))}N(!1)},ve=async()=>{const t=sessionStorage.getItem("ch_classified_pending_id");if(t)try{const s=await w.functions.invoke("resendClassifiedVerification",{listing_id:t}),l=s.data||s;l.error?y(l.error):f(!1)}catch(s){y(M(s)||"Failed to resend verification email.")}},W=le(),_e=a.category_id&&a.title&&a.description&&!W,we=a.city&&a.state_abbr&&a.contact_email,ce=n==="mobile";if(v)return q?e.jsx("div",{className:"max-w-[500px] mx-auto px-4 md:px-6 pt-10 pb-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 bg-amber-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Fe,{className:"w-7 h-7 text-amber-600"})}),e.jsx("h1",{className:"font-heading font-extrabold text-2xl text-emerald-950 mb-2",children:"Email delivery issue"}),e.jsx("p",{className:"text-[14px] text-slate-600 mb-4",children:"We couldn't send your verification email. Your listing is saved â try resending below."}),e.jsx(k,{onClick:ve,className:"bg-emerald-700 hover:bg-emerald-600 text-white mb-2",children:"Resend verification email"}),F&&e.jsx("p",{className:"text-[12px] text-red-600 mb-2",children:F}),e.jsx(L,{to:"/classifieds",children:e.jsx(k,{variant:"outline",children:"Back to Classifieds"})})]})}):e.jsx("div",{className:"max-w-[500px] mx-auto px-4 md:px-6 pt-10 pb-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 bg-emerald-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Ae,{className:"w-7 h-7 text-emerald-700"})}),e.jsx("h1",{className:"font-heading font-extrabold text-2xl text-emerald-950 mb-2",children:"Check your email"}),e.jsxs("p",{className:"text-[14px] text-slate-600 mb-4",children:["We sent a verification link to ",e.jsx("span",{className:"font-semibold text-emerald-950",children:We(a.contact_email)}),". Your listing will go live after you confirm it."]}),e.jsx(L,{to:"/classifieds",children:e.jsx(k,{variant:"outline",className:"mt-2",children:"Back to Classifieds"})})]})});const ne=G.find(t=>
1t.id===a.category_id),oe=a.category_id?xe[a.category_id]||[]:[],de=Ue(a.category_id);return e.jsxs("div",{className:"max-w-[680px] mx-auto px-4 md:px-6 pt-6 pb-16",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h1",{className:"font-heading font-extrabold text-2xl text-emerald-950",children:"Post a Free Classified"}),e.jsxs("p",{className:"text-[13px] text-slate-500 mt-1",children:["Step ",m," of 2 â no account needed"]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-lg bg-emerald-50 px-2.5 py-1.5",children:[e.jsx($e,{className:"w-3.5 h-3.5 text-emerald-600 shrink-0"}),e.jsx("p",{className:"text-[12px] text-emerald-800 font-medium",children:"Takes less than 30 seconds for most users."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mb-6",children:[e.jsx("div",{className:`h-1 flex-1 rounded-full ${m>=1?"bg-emerald-600":"bg-slate-200"}`}),e.jsx("div",{className:`h-1 flex-1 rounded-full ${m>=2?"bg-emerald-600":"bg-slate-200"}`})]}),m===1&&e.jsxs("div",{className:"space-y-5",children:[ce&&e.jsxs("div",{className:"rounded-xl border-2 border-red-400 bg-red-50 p-4",children:[e.jsx("input",{ref:d,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:t=>{se(t.target.files),t.target.value=""}}),e.jsxs("button",{onClick:()=>{var t;return(t=d.current)==null?void 0:t.click()},disabled:S||p.length>=T,className:"w-full flex flex-col items-center justify-center py-6 gap-2",children:[S?e.jsx(E,{className:"w-8 h-8 text-red-500 animate-spin"}):e.jsx(Re,{className:"w-8 h-8 text-red-500"}),e.jsx("span",{className:"text-[14px] font-bold text-red-700",children:S?"Uploading...":"Click here to start upload photo"}),e.jsx("span",{className:"text-[11px] text-red-500",children:"We'll auto-detect your item and fill in the details"})]}),p.length>0&&e.jsx("div",{className:"flex gap-2 overflow-x-auto no-scrollbar pb-1 mt-2",children:p.map((t,s)=>e.jsxs("div",{className:"relative shrink-0 w-16 h-16 rounded-lg overflow-hidden",children:[e.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>ie(s),className:"absolute top-0.5 right-0.5 bg-black/60 text-white rounded-full p-0.5",children:e.jsx(me,{className:"w-3 h-3"})})]},s))}),A&&e.jsxs("div",{className:"flex items-center justify-center gap-1.5 mt-2 py-1",children:[e.jsx(pe,{className:"w-4 h-4 text-amber-500 animate-pulse"}),e.jsx("span",{className:"text-[12px] font-medium text-amber-600",children:"Analyzing photo and auto-filling details..."})]})]}),he&&e.jsxs("div",{className:"flex items-start gap-1.5 rounded-lg bg-amber-50 border border-amber-200 px-2.5 py-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-amber-800",children:"We've auto-filled some details from your photo. Please review the category, subcategory, title, and description to make sure they're correct."})]}),e.jsxs("div",{children:[e.jsx(h,{className:"mb-2 block",children:"Category"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:G.map(t=>e.jsx("button",{onClick:()=>x({category_id:t.id,subcategory_id:""}),className:`px-3 py-2 rounded-lg text-left text-[13px] font-medium transition-colors border ${a.category_id===t.id?"bg-emerald-700 text-white border-emerald-700":"bg-white text-slate-700 border-slate-200 hover:border-emerald-300"}`,children:t.label},t.id))})]}),ne&&e.jsxs("div",{children:[e.jsx(h,{className:"mb-2 block",children:"Subcategory (optional)"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("button",{onClick:()=>x({subcategory_id:""}),className:`px-2.5 py-1 rounded-md text-[12px] font-medium ${a.subcategory_id?"text-slate-500 hover:text-emerald-700":"bg-emerald-100 text-emerald-800"}`,children:"Any"}),ne.subcategories.map(t=>e.jsx("button",{onClick:()=>x({subcategory_id:t.id}),className:`px-2.5 py-1 rounded-md text-[12px] font-medium ${a.subcategory_id===t.id?"bg-emerald-100 text-emerald-800":"text-slate-500 hover:text-emerald-700"}`,children:t.label},t.id))]})]}),e.jsxs("div",{children:[e.jsxs(h,{className:"mb-1 block",children:["Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(j,{value:a.title,onChange:t=>x({title:t.target.value}),placeholder:Oe(a.category_id),maxLength:200})]}),e.jsxs("div",{children:[e.jsxs(h,{className:"mb-1 block",children:["Description ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:a.description,onChange:t=>x({description:t.target.value}),rows:4,maxLength:ue,className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm resize-none",placeholder:"Describe your item, condition, availability, or service..."}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[a.description.length,"/",ue]})]}),e.jsxs("div",{children:[e.jsxs(h,{className:"mb-1 block",children:[de," ",e.jsx("span",{className:"text-red-600 font-bold",children:"*"})]}),e.jsxs("div",{className:"rounded-lg border-2 border-red-300 bg-red-50 p-2.5",children:[e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:["fixed","negotiable","free","contact"].map(t=>e.jsx("button",{onClick:()=>x({price_type:t,price_amount:t==="free"?"":a.price_amount}),className:`px-2.5 py-1 rounded-md text-[12px] font-medium ${a.price_type===t?"bg-red-600 text-white":"text-slate-500 hover:text-red-700 border border-slate-200 bg-white"}`,children:t==="fixed"?"Fixed price":t==="contact"?"Contact for price":t.charAt(0).toUpperCase()+t.slice(1)},t))}),(a.price_type==="fixed"||a.price_type==="negotiable")&&e.jsx(j,{type:"number",value:a.price_amount,onChange:t=>x({price_amount:t.target.value}),placeholder:de,className:"max-w-[200px] border-red-200"}),e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:"Please set your price â this is the one thing the photo can't determine for you."})]})]}),oe.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-2 gap-3 mt-2",children:oe.map(t=>{var s,l;return e.jsxs("div",{children:[e.jsxs(h,{className:"text-[12px] mb-0.5 block",children:[t.label,t.required?e.jsx("span",{className:"text-red-500",children:" *"}):""]}),t.type==="select"?e.jsxs("select",{value:((s=a.structured_details)==null?void 0:s[t.id])||"",onChange:i=>x({structured_details:{...a.structured_details,[t.id]:i.target.value}}),className:"w-full rounded-lg border border-slate-200 px-2 py-1.5 text-[13px] bg-white",children:[e.jsx("option",{value:"",children:"Select..."}),t.options.map(i=>e.jsx("option",{value:i,children:i},i))]}):e.jsx(j,{type:t.type==="number"?"number":t.type==="date"?"date":"text",value:((l=a.structured_details)==null?void 0:l[t.id])||"",onChange:i=>x({structured_details:{...a.structured_details,[t.id]:i.target.value}}),placeholder:t.placeholder,className:"text-[13px]"})]},t.id)})}),W&&e.jsx("p",{className:"text-[11px] text-red-600 mt-1",children:W})]}),!ce&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs(h,{className:"block",children:["Photos (optional, up to ",T,")"]}),p.length>0&&e.jsxs("button",{onClick:re,disabled:A,className:"flex items-center gap-1 text-[12px] font-medium text-amber-600 hover:text-amber-700 disabled:opacity-50",children:[A?e.jsx(E,{className:"w-3 h-3 animate-spin"}):e.jsx(pe,{className:"w-3 h-3"}),A?"Analyzing...":"Re-analyze photo"]})]}),Q&&e.jsxs("div",{className:"flex items-start gap-1.5 rounded-lg bg-red-50 px-2.5 py-1.5 mb-1.5",children:[e.jsx(Se,{className:"w-3.5 h-3.5 text-red-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-700",children:Q})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto no-scrollbar pb-1",children:[p.map((t,s)=>e.jsxs("div",{className:"relative shrink-0 w-20 h-20 rounded-lg overflow-hidden",children:[e.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>ie(s),className:"absolute top-0.5 right-0.5 bg-black/60 text-white rounded-full p-0.5",children:e.jsx(me,{className:"w-3 h-3"})})]},s)),S&&e.jsx("div",{className:"shrink-0 w-20 h-20 rounded-lg border-2 border-emerald-200 bg-emerald-50 flex items-center justify-center",children:e.jsx(E,{className:"w-4 h-4 text-emerald-600 animate-spin"})}),p.length<T&&!S&&e.jsxs("label",{className:"shrink-0 w-20 h-20 rounded-lg border-2 border-dashed border-slate-300 flex flex-col items-center justify-center cursor-pointer hover:bg-slate-50",children:[e.jsx(ze,{className:"w-4 h-4 text-slate-400 mb-0.5"}),e.jsx("span",{className:"text-[10px] text-slate-400",children:"Add"}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:t=>se(t.target.files)})]})]})]}),e.jsx("div",{className:"rounded-lg bg-amber-50 border border-amber-200 px-3 py-2",children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-amber-800",children:"Autofill can make mistakes â double-check to ensure your category, subcategory, title, and description are correct before continuing."})]})}),e.jsx("div",{className:"sticky bottom-0 bg-white pt-3 pb-2 -mx-4 px-4 border-t border-slate-100",children:e.jsxs(k,{disabled:!_e,onClick:()=>b(2),className:"w-full bg-emerald-700 hover:bg-emerald-600 text-white",children:["Continue ",e.jsx(Pe,{className:"w-4 h-4"})]})})]}),m===2&&e.jsxs("div",{className:"space-y-5",children:[e.jsx(Ye,{categoryId:a.category_id,subcategoryId:a.subcategory_id,enabled:P,setEnabled:fe,days:U,setDays:ye}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-heading font-bold text-[16px] text-emerald-950 mb-2",children:"Location"}),e.jsxs("div",{children:[e.jsxs(h,{className:"text-[12px] mb-0.5 block",children:["ZIP c
1ode ",e.jsx("span",{className:"text-red-600 font-bold",children:"*"})]}),e.jsxs("div",{className:"rounded-lg border-2 border-red-300 bg-red-50 p-1.5",children:[e.jsxs("div",{className:"relative",children:[e.jsx(j,{value:a.zip,onChange:t=>x({zip:t.target.value.replace(/\D/g,"").slice(0,5)}),placeholder:"49503",className:"text-[13px] max-w-[160px] border-red-200 bg-white",inputMode:"numeric"}),be&&e.jsx(E,{className:"w-3.5 h-3.5 text-emerald-600 animate-spin absolute right-3 top-2.5"})]}),e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:"Required â enter your ZIP so buyers can find your listing."})]}),ee&&e.jsx("p",{className:"text-[11px] text-red-600 mt-0.5",children:ee})]}),a.city&&a.state_abbr&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-2",children:[e.jsxs("div",{children:[e.jsx(h,{className:"text-[11px] mb-0.5 block text-slate-500",children:"City"}),e.jsx("div",{className:"rounded-lg border border-slate-200 bg-slate-50 px-2 py-1.5 text-[13px] text-slate-700 truncate",children:a.city})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-[11px] mb-0.5 block text-slate-500",children:"State"}),e.jsx("div",{className:"rounded-lg border border-slate-200 bg-slate-50 px-2 py-1.5 text-[13px] text-slate-700 truncate",children:a.state_abbr})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-[11px] mb-0.5 block text-slate-500",children:"County"}),e.jsx("div",{className:"rounded-lg border border-slate-200 bg-slate-50 px-2 py-1.5 text-[13px] text-slate-700 truncate",children:a.county||"â"})]})]}),a.category_id==="garage_estate_sales"&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{children:[e.jsx(h,{className:"text-[12px] mb-0.5 block",children:"Address / area"}),e.jsx(j,{value:a.exact_address,onChange:t=>x({exact_address:t.target.value}),placeholder:"123 Main St or near downtown",className:"text-[13px]"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-slate-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.show_exact_address,onChange:t=>x({show_exact_address:t.target.checked}),className:"accent-emerald-700"}),"Show exact address publicly (garage sales only)"]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-heading font-bold text-[16px] text-emerald-950 mb-2",children:"Contact"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx(h,{className:"text-[12px] mb-0.5 block",children:"Your name (optional)"}),e.jsx(j,{value:a.contact_name,onChange:t=>x({contact_name:t.target.value}),placeholder:"John D.",className:"text-[13px]"})]}),e.jsxs("div",{children:[e.jsxs(h,{className:"text-[12px] mb-0.5 block",children:["Email ",e.jsx("span",{className:"text-red-600 font-bold",children:"*"})]}),e.jsxs("div",{className:"rounded-lg border-2 border-red-300 bg-red-50 p-1.5",children:[e.jsx(j,{type:"email",value:a.contact_email,onChange:t=>x({contact_email:t.target.value}),placeholder:"[email protected]",className:"text-[13px] border-red-200 bg-white"}),e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:"Required â we'll send a verification link to publish your listing."})]})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-[12px] mb-0.5 block",children:"Phone (optional)"}),e.jsx(j,{value:a.contact_phone,onChange:t=>x({contact_phone:t.target.value}),placeholder:"(555) 555-5555",className:"text-[13px]"})]}),e.jsxs("div",{children:[e.jsx(h,{className:"text-[12px] mb-0.5 block",children:"Contact method"}),e.jsxs("select",{value:a.contact_mode,onChange:t=>x({contact_mode:t.target.value}),className:"w-full rounded-lg border border-slate-200 px-2 py-1.5 text-[13px] bg-white",children:[e.jsx("option",{value:"relay",children:"Private relay (recommended)"}),e.jsx("option",{value:"email",children:"Show email"}),e.jsx("option",{value:"phone",children:"Show phone"})]})]}),e.jsxs("div",{className:"flex items-start gap-1.5 rounded-lg bg-emerald-50 p-2",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-emerald-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-slate-600",children:"Your email is never shown publicly when using private relay. We'll send you a verification link before your listing goes live."})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-1.5",children:"Preview"}),p[0]&&e.jsx("img",{src:p[0],alt:"",className:"w-full h-32 object-cover rounded mb-2"}),e.jsx("p",{className:"font-heading font-bold text-[15px] text-emerald-950",children:a.title||"Your listing title"}),e.jsx("p",{className:"text-[13px] text-emerald-700 font-bold",children:a.price_type==="free"?"FREE":a.price_text||(a.price_amount?`$${a.price_amount}`:"Contact for price")}),e.jsxs("p",{className:"text-[12px] text-slate-500",children:[a.city,", ",a.state_abbr]})]}),e.jsxs("div",{className:"sticky bottom-0 bg-white pt-3 pb-2 -mx-4 px-4 border-t border-slate-100",children:[F&&e.jsx("p",{className:"text-[12px] text-red-600 mb-2 text-center",children:F}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",onClick:()=>b(1),className:"flex-1",children:"Back"}),e.jsx(k,{disabled:!we||I||te,onClick:Ne,className:`flex-1 text-white ${P?"bg-amber-600 hover:bg-amber-500":"bg-emerald-700 hover:bg-emerald-600"}`,children:I||te?e.jsx(E,{className:"w-4 h-4 animate-spin"}):P?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-4 h-4 fill-white"}),P&&a.category_id==="pets_animals"&&a.subcategory_id==="lost_pets"?"Post & activate free safety alert":`Checkout â ${Me(a.category_id,U)}`]}):"Post free listing"})]}),e.jsxs("p",{className:"text-[11px] text-slate-400 text-center mt-1.5",children:["By posting, you agree to Country Herald's"," ",e.jsx(L,{to:"/community-guidelines",className:"underline",children:"community guidelines"})," ","and"," ",e.jsx(L,{to:"/classifieds/guidelines",className:"underline",children:"classifieds policy"}),"."]})]})]})]})}function Oe(r){return{for_sale:"2021 John Deere riding mower",property:"2-bedroom apartment near downtown",garage_estate_sales:"Multi-family garage sale Saturday",pets_animals:"Young tabby cat needs a new home",creative_makers:"Local photographer available for portraits",vehicles_equipment:"2018 Ford F-150 â 45k miles",jobs_gigs:"Part-time barista needed weekends",services:"Affordable lawn care & snow removal"}[r]||"What are you posting?"}function Ue(r){return{property:"Monthly rent",jobs_gigs:"Pay / compensation",services:"Starting price or rate",for_sale:"Asking price",garage_estate_sales:"Price (not required)"}[r]||"Price"}function Ze(r,n){const d=G.find(b=>b.id===r);if(!d)return"";const m=d.subcategories.find(b=>b.id===n);return(m==null?void 0:m.label)||""}function M(r){var d;if(!r)return"Something went wrong. Please try again.";const n=((d=r==null?void 0:r.response)==null?void 0:d.data)||(r==null?void 0:r.data);if(n!=null&&n.error)return n.error;if(typeof n=="string")try{const m=JSON.parse(n);if(m!=null&&m.error)return m.error}catch{}return r.message&&!/status code \d/.test(r.message)?r.message:"Something went wrong. Please check your fields and try again."}function We(r){if(!r)return"";const[n,d]=r.split("@");return!n||!d?r:`${n.length>2?n.slice(0,2)+"***":n[0]+"***"}@${d}`}export{ot as default};
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.