1import{j as e,r as h}from"./react-BQRhP09J.js";import{c as ge,u as pe,b as G}from"./query-BLGJyudK.js";import{F as he,C as ye,u as fe,s as C,c as l,e as S,o as X,l as H,a as Q,b as W,t as Y}from"./forms-DEXF2ppu.js";import{c as R,u as xe,h as Z,i as J,j as ee,k as te,l as ae,B as P,d as B}from"./index-KdyxvQU4.js";import{I as F}from"./input-OrXLLLaF.js";import{T as ie}from"./textarea-lLwMdYMY.js";import{S as _e}from"./ui-yRYlMgP2.js";import{L as Ne}from"./label-BCZL2nRd.js";import{A as be,h as je,a as ve,b as ke,c as Ae,d as Ce,e as Te,f as Se,g as we}from"./alert-dialog-DPoZaA4r.js";import{av as r,aw as x,ax as t,ay as i,az as o,aA as d,aB as n,aC as y,aD as I,aE as T,aF as z}from"./vendor-DvHlWtIv.js";import{aa as Ee,o as Ie,aq as Fe,am as De,d as Ke,C as qe,X as Be,b as Pe}from"./lucide-BjmxUG2w.js";import"./date-fns-CtL95OLy.js";import"./framer-CwSppoTa.js";const ne=he,se=h.createContext(null),A=({...a})=>e.jsx(se.Provider,{value:{name:a.name},children:e.jsx(ye,{...a})}),L=()=>{const a=h.useContext(se),m=h.useContext(le),{getFieldState:c,formState:g}=fe();if(!a)throw new Error("useFormField should be used within <FormField>");if(!m)throw new Error("useFormField should be used within <FormItem>");const p=c(a.name,g),{id:u}=m;return{id:u,name:a.name,formItemId:`${u}-form-item`,formDescriptionId:`${u}-form-item-description`,formMessageId:`${u}-form-item-message`,...p}},le=h.createContext(null),N=h.forwardRef(({className:a,...m},c)=>{const g=h.useId();return e.jsx(le.Provider,{value:{id:g},children:e.jsx("div",{ref:c,className:R("space-y-2",a),...m})})});N.displayName="FormItem";const b=h.forwardRef(({className:a,...m},c)=>{const{error:g,formItemId:p}=L();return e.jsx(Ne,{ref:c,className:R(g&&"text-destructive",a),htmlFor:p,...m})});b.displayName="FormLabel";const j=h.forwardRef(({...a},m)=>{const{error:c,formItemId:g,formDescriptionId:p,formMessageId:u}=L();return e.jsx(_e,{ref:m,id:g,"aria-describedby":c?`${p} ${u}`:`${p}`,"aria-invalid":!!c,...a})});j.displayName="FormControl";const Re=h.forwardRef(({className:a,...m},c)=>{const{formDescriptionId:g}=L();return e.jsx("p",{ref:c,id:g,className:R("text-[0.8rem] text-muted-foreground",a),...m})});Re.displayName="FormDescription";const v=h.forwardRef(({className:a,children:m,...c},g)=>{const{error:p,formMessageId:u}=L(),f=p?String(p?.message??""):m;return f?e.jsx("p",{ref:g,id:u,className:R("text-[0.8rem] font-medium text-destructive",a),...c,children:f}):null});v.displayName="FormMessage";const ze=/^T5-[0-9]{3}(?:\/T5-[0-9]{3})*$/;C().trim().refine(a=>a===""||ze.test(a),{message:"Use T5-### format, or separate connecting flights with /. Example: T5-464"});const Le=r("routes",{id:o("id").primaryKey(),slug:i("slug",{length:255}).notNull().unique(),title:t("title").notNull(),origin:t("origin").notNull(),destination:t("destination").notNull(),frequency:t("frequency").notNull(),duration:t("duration").notNull(),aircraft:t("aircraft").notNull(),description:t("description").notNull(),price:t("price").notNull(),region:t("region").notNull().default("international"),isPopular:x("is_popular").notNull().default(!1)});l(Le).omit({id:!0});const Oe=r("news",{id:o("id").primaryKey(),title:t("title").notNull(),excerpt:t("excerpt").notNull(),content:t("content"),date:t("date").notNull(),slug:t("slug"),published:x("published").notNull().default(!0),createdAt:d("created_at").defaultNow()});l(Oe).omit({id:!0,createdAt:!0});const $e=r("contact_submissions",{id:o("id").primaryKey(),firstName:t("first_name").notNull(),lastName:t("last_name").notNull(),email:t("email").notNull(),subject:t("subject").notNull(),message:t("message").notNull(),createdAt:d("created_at").defaultNow()});l($e).omit({id:!0,createdAt:!0});const Me=r("booking_inquiries",{id:o("id").primaryKey(),type:t("type").notNull(),fromCity:t("from_city").notNull(),toCity:t("to_city").notNull(),departureDate:t("departure_date").notNull(),returnDate:t("return_date"),passengers:t("passengers").notNull(),travelClass:t("travel_class").notNull(),createdAt:d("created_at").defaultNow()});l(Me).omit({id:!0,createdAt:!0});const Ue=r("cities",{id:o("id").primaryKey(),name:t("name").notNull(),code:i("code",{length:10}).notNull(),country:t("country"),status:i("status",{length:1}).notNull().default("T"),currency:i("currency",{length:3}).notNull().default("EUR"),currencySymbol:i("currency_symbol",{length:5}).notNull().default("â¬"),timezone:i("timezone",{length:50})});l(Ue).omit({id:!0});const Ve=r("flight_routes",{id:o("id").primaryKey(),name:t("name"),status:i("status",{length:1}).notNull().default("T"),minAdvanceDays:n("min_advance_days")});l(Ve).omit({id:!0});const Ge=r("flight_route_cities",{id:o("id").primaryKey(),routeId:n("route_id").notNull(),cityId:n("city_id").notNull(),order:n("order").notNull().default(0)});l(Ge).omit({id:!0});const He=r("flight_types",{id:o("id").primaryKey(),name:t("name").notNull(),seatsCount:n("seats_count").notNull().default(0),status:i("status",{length:1}).notNull().default("T")});l(He).omit({id:!0});const Qe=r("flights",{id:o("id").primaryKey(),routeId:n("route_id").notNull(),flightTypeId:n("flight_type_id"),flightNumber:i("flight_number",{length:50}),startDate:T("start_date").notNull(),endDate:T("end_date").notNull(),departureTime:I("departure_time").notNull(),arrivalTime:I("arrival_time").notNull(),recurring:t("recurring"),discount:y("discount",{precision:9,scale:2}).notNull().default("0"),status:i("status",{length:1}).notNull().default("T"),bizFallbackEnabled:x("biz_fallback_enabled").notNull().default(!1),bizFallbackThreshold:n("biz_fallback_threshold").notNull().default(100)});l(Qe).omit({id:!0});const Xe=r("flight_date_overrides",{id:o("id").primaryKey(),flightId:n("flight_id").notNull(),departureDate:T("departure_date").notNull(),ecoStatus:i("eco_status",{length:10}).notNull().default("open"),bizStatus:i("biz_status",{length:10}).notNull().default("open"),reason:i("reason",{length:255}),createdBy:i("created_by",{length:100}),createdAt:d("created_at").defaultNow()},a=>({uniqueFlightDate:z("flight_date_overrides_flight_date").on(a.flightId,a.departureDate)}));l(Xe).omit({id:!0,createdAt:!0}).extend({ecoStatus:S(["open","closed"]).default("open"),bizStatus:S(["open","closed"]).default("open")});const We=r("availability_fallback_log",{id:o("id").primaryKey(),flightId:n("flight_id").notNull(),departureDate:T("departure_date").notNull(),ecoPctAtTrigger:y("eco_pct_at_trigger",{precision:5,scale:2}).notNull(),triggeredAt:d("triggered_at").notNull().defaultNow()});l(We).omit({id:!0,triggeredAt:!0});const Ye=r("flight_dates",{id:o("id").primaryKey(),flightId:n("flight_id").notNull(),date:T("date").notNull()});l(Ye).omit({id:!0});const Ze=r("tickets",{id:o("id").primaryKey(),flightId:n("flight_id").notNull(),name:t("name").notNull(),status:i("status",{length:1}).notNull().default("T")},a=>({flightNameUnique:z("tickets_flight_id_name_unique").on(a.flightId,a.name)}));l(Ze).omit({id:!0});const Je=r("prices",{id:o("id").primaryKey(),flightId:n("flight_id").notNull(),ticketId:n("ticket_id").notNull(),fromCityId:n("from_city_id").notNull(),toCityId:n("to_city_id").notNull(),price:y("price",{precision:9,scale:2}),isReturn:i("is_return",{length:1}).notNull().default("F"),passengerType:i("passenger_type",{length:1}).notNull().default("A"),scrapedPriceUsd:y("scraped_price_usd",{precision:9,scale:2}),scrapedCurrency:i("scraped_currency",{length:3}).default("USD"),scrapedAt:d("scraped_at")});l(Je).omit({id:!0});const et=r("flight_surcharges",{id:o("id").primaryKey(),flightId:n("flight_id").notNull(),startDate:T("start_date").notNull(),endDate:T("end_date").notNull(),amount:y("amount",{precision:9,scale:2}).notNull(),appliesToAdult:x("applies_to_adult").notNull().default(!0),appliesToChild:x("applies_to_child").notNull().default(!0),appliesToInfant:x("applies_to_infant").notNull().default(!1),active:x("active").notNull().default(!0),createdBy:i("created_by",{length:100}),createdAt:d("created_at").notNull().defaultNow(),updatedBy:i("updated_by",{length:100}),updatedAt:d("updated_at").notNull().defaultNow()});l(et).omit({id:!0,createdAt:!0,updatedAt:!0});const tt=r("deleted_catalog_records",{id:o("id").primaryKey(),entityType:i("entity_type",{length:16}).notNull(),businessKey:t("business_key").notNull(),deletedAt:d("deleted_at").notNull().defaultNow()},a=>
1({uniqueKey:z("deleted_catalog_records_entity_key").on(a.entityType,a.businessKey)}));l(tt).omit({id:!0,deletedAt:!0});const at=r("bookings",{id:o("id").primaryKey(),uuid:t("uuid").notNull().unique(),flightId:n("flight_id"),returnFlightId:n("return_flight_id"),pickupCityId:n("pickup_city_id"),returnCityId:n("return_city_id"),bookingDate:T("booking_date"),bookingTime:t("booking_time"),bookingRoute:t("booking_route"),departureDate:T("departure_date"),isReturn:i("is_return",{length:1}).notNull().default("F"),returnDate:T("return_date"),code:i("code",{length:20}),subTotal:y("sub_total",{precision:9,scale:2}).default("0"),tax:y("tax",{precision:9,scale:2}).default("0"),total:y("total",{precision:9,scale:2}).default("0"),deposit:y("deposit",{precision:9,scale:2}).default("0"),paymentMethod:i("payment_method",{length:50}).default("bank"),status:i("status",{length:20}).notNull().default("pending"),cTitle:i("c_title",{length:50}),cFname:t("c_fname"),cLname:t("c_lname"),cPhone:t("c_phone"),cEmail:t("c_email"),cCompany:t("c_company"),cNotes:t("c_notes"),cAddress:t("c_address"),cCity:t("c_city"),cState:t("c_state"),cZip:t("c_zip"),cCountry:t("c_country"),isSent:i("is_sent",{length:1}).notNull().default("F"),createdAt:d("created_at").defaultNow(),processedOn:d("processed_on"),ip:t("ip"),currencyCode:i("currency_code",{length:3}).default("EUR"),travelClass:i("travel_class",{length:20}).default("economy"),tripType:i("trip_type",{length:20}).default("oneway"),adults:n("adults").default(1),children:n("children").default(0),infants:n("infants").default(0),outboundTotal:y("outbound_total",{precision:9,scale:2}),returnTotal:y("return_total",{precision:9,scale:2}),discount:y("discount",{precision:9,scale:2}).default("0"),confirmationPaymentLink:t("confirmation_payment_link"),outboundDepartureTimeOverride:I("outbound_departure_time_override"),outboundArrivalTimeOverride:I("outbound_arrival_time_override"),returnDepartureTimeOverride:I("return_departure_time_override"),returnArrivalTimeOverride:I("return_arrival_time_override"),confirmationScheduleVerified:x("confirmation_schedule_verified").notNull().default(!1)});l(at).omit({id:!0,createdAt:!0});const it=S(["all","pending","pending-oldest","confirmed","cancelled"]),nt=S(["id","departureDate","bookingDate","name","route","status","total"]),st=S(["asc","desc"]);X({page:Q.number().int().min(1).default(1),pageSize:Q.number().int().min(1).max(100).default(25),filter:it.default("all"),status:S(["pending","confirmed","cancelled"]).optional(),search:C().trim().max(200).default(""),dateFrom:C().regex(/^\d{4}-\d{2}-\d{2}$/).or(H("")).default(""),dateTo:C().regex(/^\d{4}-\d{2}-\d{2}$/).or(H("")).default(""),sortCol:nt.default("id"),sortDir:st.default("desc")});const lt=r("booking_email_logs",{id:o("id").primaryKey(),bookingId:n("booking_id").notNull(),emailType:i("email_type",{length:40}).notNull(),recipient:t("recipient").notNull(),subject:t("subject"),status:i("status",{length:20}).notNull().default("sent"),sentAt:d("sent_at").defaultNow().notNull(),errorMessage:t("error_message")});l(lt).omit({id:!0,sentAt:!0});const rt=r("booking_notification_outbox",{id:o("id").primaryKey(),bookingId:n("booking_id").notNull(),recipient:t("recipient").notNull(),status:i("status",{length:20}).notNull().default("pending"),attempts:n("attempts").notNull().default(0),lastError:t("last_error"),nextAttemptAt:d("next_attempt_at").notNull().defaultNow(),acceptedAt:d("accepted_at"),leaseToken:i("lease_token",{length:64}),leaseExpiresAt:d("lease_expires_at"),createdAt:d("created_at").notNull().defaultNow(),updatedAt:d("updated_at").notNull().defaultNow()},a=>({bookingRecipientUnique:z("booking_notification_outbox_booking_recipient_unique").on(a.bookingId,a.recipient)}));l(rt).omit({id:!0,attempts:!0,acceptedAt:!0,leaseToken:!0,leaseExpiresAt:!0,createdAt:!0,updatedAt:!0});const ot=r("booking_sms_logs",{id:o("id").primaryKey(),bookingId:n("booking_id").notNull(),recipient:t("recipient").notNull(),messageType:i("message_type",{length:40}).notNull(),template:t("template").notNull(),messageBody:t("message_body").notNull(),status:i("status",{length:20}).notNull().default("pending"),providerMessageId:t("provider_message_id"),requestKey:t("request_key").notNull().unique(),createdAt:d("created_at").defaultNow().notNull(),sentAt:d("sent_at"),errorMessage:t("error_message")}),dt=["booking-request","booking-confirmation","unable-to-confirm","cancellation","payment-reminder","follow-up"],ct=S(dt),ut=r("sms_templates",{id:o("id").primaryKey(),eventType:i("event_type",{length:40}).notNull(),name:i("name",{length:100}).notNull(),body:t("body").notNull(),enabled:x("enabled").notNull().default(!0),isSelected:x("is_selected").notNull().default(!1),createdAt:d("created_at").defaultNow().notNull(),updatedAt:d("updated_at").defaultNow().notNull()}),mt=l(ut).omit({id:!0,createdAt:!0,updatedAt:!0}).extend({eventType:ct,name:C().trim().min(1).max(100),body:C().min(1)});mt.partial();const gt=r("booking_tickets",{id:o("id").primaryKey(),bookingId:n("booking_id").notNull(),ticketId:n("ticket_id").notNull(),qty:n("qty").notNull().default(1),amount:y("amount",{precision:9,scale:2}).default("0")});l(gt).omit({id:!0});const pt=r("booking_payments",{id:o("id").primaryKey(),bookingId:n("booking_id").notNull(),paymentMethod:i("payment_method",{length:50}),amount:y("amount",{precision:9,scale:2}).default("0"),status:i("status",{length:20}).notNull().default("notpaid"),createdAt:d("created_at").defaultNow()});l(pt).omit({id:!0,createdAt:!0});const ht=r("booking_passengers",{id:o("id").primaryKey(),bookingId:n("booking_id").notNull(),isLead:x("is_lead").notNull().default(!1),type:i("type",{length:10}).notNull().default("adult"),title:i("title",{length:10}),firstName:t("first_name").notNull(),lastName:t("last_name").notNull(),dob:i("dob",{length:20}),passportNo:i("passport_no",{length:50}),passportExpiry:i("passport_expiry",{length:20}),nationality:i("nationality",{length:100}),phone:t("phone"),email:t("email")});l(ht).omit({id:!0});const yt=r("admin_users",{id:o("id").primaryKey(),email:i("email",{length:255}).notNull().unique(),password:t("password").notNull(),name:t("name").notNull(),phone:t("phone"),role:i("role",{length:50}).notNull().default("admin"),status:i("status",{length:1}).notNull().default("T"),lastLogin:d("last_login"),createdAt:d("created_at").defaultNow()});l(yt).omit({id:!0,createdAt:!0,lastLogin:!0});
1const ft=r("system_settings",{id:o("id").primaryKey(),key:i("key",{length:255}).notNull().unique(),value:t("value"),category:i("category",{length:100}).notNull().default("general")});l(ft).omit({id:!0});const xt=r("changelog_entries",{id:o("id").primaryKey(),title:t("title").notNull(),description:t("description"),category:i("category",{length:50}).notNull().default("Other"),changedBy:t("changed_by").notNull().default("Admin"),changedAt:d("changed_at").notNull().defaultNow(),version:t("version"),deploymentId:t("deployment_id").unique()}),O=["UI/UX","Content","Booking","Fares","Technical","SEO","Other"],_t=l(xt).omit({id:!0,changedAt:!0,deploymentId:!0}).extend({category:S(O)});_t.partial();const Nt=r("backup_history",{id:o("id").primaryKey(),triggerType:i("trigger_type",{length:20}).notNull(),status:i("status",{length:20}).notNull(),payloadSizeBytes:n("payload_size_bytes").notNull().default(0),destination:i("destination",{length:30}).notNull(),filename:t("filename"),errorMessage:t("error_message"),createdAt:d("created_at").notNull().defaultNow()});l(Nt).omit({id:!0,createdAt:!0});const bt=r("flight_api_health_checks",{id:o("id").primaryKey(),ok:x("ok").notNull(),apiKeySet:x("api_key_set").notNull(),httpStatus:n("http_status"),resultsCount:n("results_count").notNull().default(0),errorMessage:t("error_message"),checkedAt:d("checked_at").notNull().defaultNow()});l(bt).omit({id:!0,checkedAt:!0});l(ot).omit({id:!0,createdAt:!0});const jt={"UI/UX":"bg-blue-100 text-blue-800",Content:"bg-green-100 text-green-800",Booking:"bg-orange-100 text-orange-800",Fares:"bg-yellow-100 text-yellow-800",Technical:"bg-slate-100 text-slate-800",SEO:"bg-purple-100 text-purple-800",Other:"bg-gray-100 text-gray-700"},re=X({title:C().min(1,"Title is required"),description:C().optional(),category:S(O),changedBy:C().min(1,"Changed By is required"),version:C().optional()}),vt=25;function kt({category:a}){const m=jt[a]??"bg-gray-100 text-gray-700";return e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${m}`,"data-testid":"badge-category",children:a})}function At({entry:a,onCancel:m,onSave:c,isSaving:g}){const p=W({resolver:Y(re),defaultValues:{title:a.title,description:a.description??"",category:a.category,changedBy:a.changedBy,version:a.version??""}});return e.jsx(ne,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(c),className:"space-y-4 bg-blue-50/40 border border-blue-100 rounded-lg p-4","data-testid":`form-edit-changelog-${a.id}`,children:[e.jsx(A,{control:p.control,name:"title",render:({field:u})=>e.jsxs(N,{children:[e.jsxs(b,{children:["Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(j,{children:e.jsx(F,{placeholder:"What changed?","data-testid":"input-edit-title",...u})}),e.jsx(v,{})]})}),e.jsx(A,{control:p.control,name:"description",render:({field:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Description"}),e.jsx(j,{children:e.jsx(ie,{placeholder:"Optional â describe what was changed and why",rows:3,"data-testid":"input-edit-description",...u})}),e.jsx(v,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(A,{control:p.control,name:"category",render:({field:u})=>e.jsxs(N,{children:[e.jsxs(b,{children:["Category ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Z,{onValueChange:u.onChange,value:u.value,children:[e.jsx(j,{children:e.jsx(J,{"data-testid":"select-edit-category",children:e.jsx(ee,{})})}),e.jsx(te,{children:O.map(f=>e.jsx(ae,{value:f,"data-testid":`option-edit-category-${f}`,children:f},f))})]}),e.jsx(v,{})]})}),e.jsx(A,{control:p.control,name:"changedBy",render:({field:u})=>e.jsxs(N,{children:[e.jsxs(b,{children:["Changed By ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(j,{children:e.jsx(F,{placeholder:"Admin","data-testid":"input-edit-changed-by",...u})}),e.jsx(v,{})]})}),e.jsx(A,{control:p.control,name:"version",render:({field:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Version"}),e.jsx(j,{children:e.jsx(F,{placeholder:"e.g. 2.1.0","data-testid":"input-edit-version",...u})}),e.jsx(v,{})]})})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(P,{type:"button",variant:"outline",onClick:m,disabled:g,"data-testid":"button-cancel-edit",children:[e.jsx(Be,{size:16,className:"mr-1.5"}),"Cancel"]}),e.jsxs(P,{type:"submit",disabled:g,className:"bg-[#1E73BE] hover:bg-[#1558a0]","data-testid":"button-save-edit",children:[e.jsx(Pe,{size:16,className:"mr-1.5"}),g?"Savingâ¦":"Save"]})]})]})})}function Ct({entry:a,onDelete:m,onUpdate:c,isUpdating:g,isEditing:p,onStartEdit:u,onCancelEdit:f}){const[k,E]=h.useState(!1),D=(a.description?.length??0)>160,K=k||!D?a.description:a.description?.slice(0,160)+"â¦",$=new Date(a.changedAt).toLocaleStr
1ing("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});return p?e.jsx(At,{entry:a,onCancel:f,onSave:q=>c(a.id,q),isSaving:g}):e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4 flex flex-col gap-2","data-testid":`card-changelog-${a.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(kt,{category:a.category}),a.version&&e.jsxs("span",{className:"text-xs text-gray-500 font-mono bg-gray-50 border border-gray-200 px-1.5 py-0.5 rounded","data-testid":"text-version",children:["v",a.version]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx("button",{className:"text-gray-400 hover:text-blue-600 transition-colors","aria-label":"Edit entry",onClick:u,"data-testid":`button-edit-changelog-${a.id}`,children:e.jsx(Fe,{size:15})}),e.jsxs(be,{children:[e.jsx(je,{asChild:!0,children:e.jsx("button",{className:"text-gray-400 hover:text-red-600 transition-colors","aria-label":"Delete entry","data-testid":`button-delete-changelog-${a.id}`,children:e.jsx(De,{size:15})})}),e.jsxs(ve,{children:[e.jsxs(ke,{children:[e.jsx(Ae,{children:"Delete changelog entry?"}),e.jsxs(Ce,{children:['This will permanently remove "',a.title,'". This action cannot be undone.']})]}),e.jsxs(Te,{children:[e.jsx(Se,{"data-testid":"button-cancel-delete",children:"Cancel"}),e.jsx(we,{onClick:()=>m(a.id),className:"bg-red-600 hover:bg-red-700","data-testid":"button-confirm-delete",children:"Delete"})]})]})]})]})]}),e.jsx("p",{className:"font-semibold text-gray-900 text-sm leading-snug","data-testid":"text-entry-title",children:a.title}),a.description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed","data-testid":"text-entry-description",children:K}),D&&e.jsx("button",{onClick:()=>E(q=>!q),className:"mt-1 flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 font-medium","data-testid":"button-expand-description",children:k?e.jsxs(e.Fragment,{children:[e.jsx(Ke,{size:12})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{size:12})," Show more"]})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-400 mt-1",children:[e.jsxs("span",{"data-testid":"text-changed-by",children:["By ",a.changedBy]}),e.jsx("span",{children:"·"}),e.jsx("span",{"data-testid":"text-changed-at",children:$})]})]})}function Lt(){const{toast:a}=xe(),m=ge(),[c,g]=h.useState(1),[p,u]=h.useState([]),f=h.useRef(new Set),{data:k,isLoading:E,isFetching:D}=pe({queryKey:["/api/admin/changelog",c],queryFn:async()=>(await B("GET",`/api/admin/changelog?page=${c}&limit=${vt}`)).json()});h.useEffect(()=>{if(!(!k||k.page!==c)){if(c===1){f.current=new Set([1]),u(k.entries);return}f.current.has(c)||(f.current.add(c),u(s=>[...s,...k.entries]))}},[k,c]);const K=p,$=k?.total??0,q=k?.totalPages??1,oe=c<q,w=W({resolver:Y(re),defaultValues:{title:"",description:"",category:"Other",changedBy:"Admin",version:""}}),M=G({mutationFn:s=>B("POST","/api/admin/changelog",{...s,description:s.description||void 0,version:s.version||void 0}),onSuccess:()=>{g(1),m.invalidateQueries({queryKey:["/api/admin/changelog"]}),w.reset({title:"",description:"",category:"Other",changedBy:"Admin",version:""}),a({title:"Entry added",description:"Changelog entry created successfully."})},onError:()=>{a({title:"Error",description:"Failed to create changelog entry.",variant:"destructive"})}}),de=G({mutationFn:s=>B("DELETE",`/api/admin/changelog/${s}`),onSuccess:()=>{g(1),m.invalidateQueries({queryKey:["/api/admin/changelog"]}),a({title:"Deleted",description:"Changelog entry removed."})},onError:()=>{a({title:"Error",description:"Failed to delete entry.",variant:"destructive"})}}),[ce,U]=h.useState(null),V=G({mutationFn:({id:s,values:_})=>B("PUT",`/api/admin/changelog/${s}`,{..._,description:_.description||void 0,version:_.version||void 0}),onSuccess:()=>{m.invalidateQueries({queryKey:["/api/admin/changelog"]}),U(null),a({title:"Entry updated",description:"Changelog entry saved successfully."})},onError:()=>{a({title:"Error",description:"Failed to update changelog entry.",variant:"destructive"})}}),ue=s=>{M.mutate(s)};
1return e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ee,{size:22,className:"text-[#1a1a2e]"}),e.jsx("h1",{className:"text-xl font-bold text-[#1a1a2e]","data-testid":"heading-changelog",children:"Changelog"})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-5 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wide",children:"Add Entry"}),e.jsx(ne,{...w,children:e.jsxs("form",{onSubmit:w.handleSubmit(ue),className:"space-y-4","data-testid":"form-changelog",children:[e.jsx(A,{control:w.control,name:"title",render:({field:s})=>e.jsxs(N,{children:[e.jsxs(b,{children:["Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(j,{children:e.jsx(F,{placeholder:"What changed?","data-testid":"input-title",...s})}),e.jsx(v,{})]})}),e.jsx(A,{control:w.control,name:"description",render:({field:s})=>e.jsxs(N,{children:[e.jsx(b,{children:"Description"}),e.jsx(j,{children:e.jsx(ie,{placeholder:"Optional â describe what was changed and why",rows:3,"data-testid":"input-description",...s})}),e.jsx(v,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(A,{control:w.control,name:"category",render:({field:s})=>e.jsxs(N,{children:[e.jsxs(b,{children:["Category ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Z,{onValueChange:s.onChange,value:s.value,children:[e.jsx(j,{children:e.jsx(J,{"data-testid":"select-category",children:e.jsx(ee,{})})}),e.jsx(te,{children:O.map(_=>e.jsx(ae,{value:_,"data-testid":`option-category-${_}`,children:_},_))})]}),e.jsx(v,{})]})}),e.jsx(A,{control:w.control,name:"changedBy",render:({field:s})=>e.jsxs(N,{children:[e.jsxs(b,{children:["Changed By ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(j,{children:e.jsx(F,{placeholder:"Admin","data-testid":"input-changed-by",...s})}),e.jsx(v,{})]})}),e.jsx(A,{control:w.control,name:"version",render:({field:s})=>e.jsxs(N,{children:[e.jsx(b,{children:"Version"}),e.jsx(j,{children:e.jsx(F,{placeholder:"e.g. 2.1.0","data-testid":"input-version",...s})}),e.jsx(v,{})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(P,{type:"submit",disabled:M.isPending,className:"bg-[#1E73BE] hover:bg-[#1558a0]","data-testid":"button-submit-entry",children:[e.jsx(Ie,{size:16,className:"mr-1.5"}),M.isPending?"Addingâ¦":"Add Entry"]})})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide","data-testid":"text-history-heading",children:["History ",!E&&`(${K.length} of ${$})`]}),E&&e.jsx("div",{className:"space-y-3",children:[1,2,3].map(s=>e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg p-4 h-24 animate-pulse"},s))}),!E&&K.length===0&&e.jsx("p",{className:"text-sm text-gray-400 text-center py-8","data-testid":"text-empty-changelog",children:"No changelog entries yet. Add the first one above."}),!E&&K.map(s=>e.jsx(Ct,{entry:s,onDelete:_=>de.mutate(_),onUpdate:(_,me)=>V.mutate({id:_,values:me}),isUpdating:V.isPending&&V.variables?.id===s.id,isEditing:ce===s.id,onStartEdit:()=>U(s.id),onCancelEdit:()=>U(null)},s.id)),!E&&oe&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(P,{variant:"outline",onClick:()=>g(s=>s+1),disabled:D,"data-testid":"button-load-more",children:D?"Loadingâ¦":"Load more"})})]})]})}export{Lt 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.