import{r as p,j as e}from"./client-BbMi5ewG.js";import{S as _,P}from"./Save-CBoJxzO6.js";import{a as N,s as r,u as y}from"./store-jX25q14N.js";import{I as E}from"./input-DhCVOJC-.js";import{S as M,a as H,c as R,f}from"./select-CPHcJnpt.js";import{S as V}from"./search-C6CI7Qpa.js";import{C as $,a as z}from"./card-CZBIFpqn.js";import{S as b}from"./skeleton-ImO4uxQ7.js";import{M as B,u as D,R as O,g as S}from"./index-CM0LBdHD.js";import{P as U}from"./Pagination-YytuLjdY.js";import{T as Z,a as w,b as j,c as q,d as u,e as X}from"./Table-DCeFiyCp.js";import{C as F}from"./checkbox-BS_fWNWw.js";import{A as J,a as G,b as K}from"./avatar-BMEAZdBR.js";import{B as L}from"./Button-1dacbE2T.js";import{S as Q}from"./SkeletonTableRows-BrALmXl-.js";import{E as W}from"./Edit-C8qVzzd7.js";import{T as Y}from"./Trash-AmoyyqPS.js";import{c as I,X as A}from"./utils-Q0fnGDhj.js";import{C as ee}from"./ConfirmDialog-C2asEKXG.js";import{L as se}from"./AddLocationForm-9N2H0iL8.js";import{u as te,A as ae}from"./ActionButton-CK3Uoxvt.js";import{C as ne}from"./CrudLayout-Cx6KhKUY.js";import{P as oe}from"./ProUpgradeBanner-j5GA7rlc.js";import"./vendor-DDjlQeP6.js";import"./withIconDefaults-C8UfSjn1.js";import"./lodash-Bd-B7UeG.js";import"./defineProperty-DbXIQDXj.js";import"./typeof-QjJsDpFa.js";import"./apiConfig-D-T4C2Ae.js";import"./index-D59bwJy3.js";import"./toast-1-c8k_LJ.js";import"./index-CeptMk_f.js";import"./index-BbWn2ja9.js";import"./check-DMod5j-l.js";import"./preload-helper-Dp1pzeXC.js";import"./CalenderCheck-BuHSX8YD.js";import"./calendar-CjyQ6Zau.js";import"./tag-CvsOfBQf.js";import"./shield-Bmp_421z.js";import"./proxy-DChtKkEh.js";import"./circle-check-big-uMTsaxsq.js";import"./dialog-C9IQloQy.js";import"./index-B5gX5Cyp.js";import"./index-C4Ytkwtd.js";import"./textarea-QytFj8hO.js";import"./FormField-66vt2hZL.js";import"./label-1wXMewvs.js";import"./circle-alert-CG2uW-Df.js";import"./ImageUpload-DbfzQEp2.js";import"./trash-2-wbt0ZJUy.js";import"./StatusSwitcher-C3TepXSt.js";import"./badge-C2Ir4HoT.js";import"./switch-BXH9Uq5p.js";import"./useMediaUploader-lszBTVoc.js";import"./loader-circle--S58donA.js";import"./ArrowLeftIcon-DrGyoHe_.js";import"./crown-BdDHOvET.js";/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const re=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ce=I("locate-fixed",re);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ie=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],le=I("search-x",ie);function de({locations:a,filter:s}){const c=N(),x=n=>{const{id:o,value:m}=n.target;c(r).setFilter({field:o,value:m})},l=n=>o=>{{const m=o.split("-")[0],d=o.split("-")[1];c(r).setFilter({field:"order_by",value:m}),c(r).setFilter({field:"order",value:d})}};return e.jsxs("div",{className:"",children:[e.jsx("h3",{className:"rtrb-title-18 mb-5",children:"All Locations"}),e.jsxs("div",{className:"flex flex-row gap-4",children:[e.jsxs("div",{className:"relative min-w-[400px] mr-auto",children:[e.jsx(V,{className:"w-4 h-4 absolute top-3.5 left-3 text-text-titel-color80"}),e.jsx(E,{id:"search_data",placeholder:"Search Locations...",className:"h-11 rtrb-input pl-10",onChange:x})]}),e.jsxs(M,{onValueChange:l(),id:"order",value:(s==null?void 0:s.order_by)+"-"+(s==null?void 0:s.order),children:[e.jsx(H,{className:"rtrb-input w-[220px] h-11 ",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"shrink-0",children:e.jsx("path",{d:"M7.5 13.5H10.5V12H7.5V13.5ZM1.5 4.5V6H16.5V4.5H1.5ZM4.5 9.75H13.5V8.25H4.5V9.75Z",fill:"#B6B8BC"})}),e.jsx("span",{className:"text-text-titel-color80 text-sm",children:(s==null?void 0:s.order_by)==="name"&&(s==null?void 0:s.order)==="asc"?"Name Ascending":(s==null?void 0:s.order_by)==="name"&&(s==null?void 0:s.order)==="desc"?"Name Descending":(s==null?void 0:s.order_by)==="created_at"&&(s==null?void 0:s.order)==="asc"?"Date Ascending":(s==null?void 0:s.order_by)==="created_at"&&(s==null?void 0:s.order)==="desc"?"Date Descending":"Sort By"})]})})}),e.jsxs(R,{children:[e.jsx(f,{value:"name-asc",children:"Name Ascending"}),e.jsx(f,{value:"name-desc",children:"Name Descending"}),e.jsx(f,{value:"created_at-asc",children:"Date Ascending"}),e.jsx(f,{value:"created_at-desc",children:"Date Descending"})]})]})]})]})}const me=p.memo(de);function xe(){return e.jsxs($,{className:"bg-bg-5 rounded-md border border-solid border-[#f1f1f1] relative",children:[e.jsx(b,{className:"absolute top-3 right-3 w-6 h-6 rounded-full"}),e.jsxs(z,{className:"flex flex-col items-center pt-12 pb-8",children:[e.jsx(b,{className:"w-16 h-16 rounded-full mb-4"}),e.jsx(b,{className:"h-6 w-3/4 mb-3"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3.5 h-3.5 text-gray-300 flex-shrink-0"}),e.jsx(b,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-border border-opacity-30 w-full flex justify-center",children:e.jsx(b,{className:"h-8 w-24 rounded-md"})})]})]})}function pe({locations:a=[]}){const s=y(n=>n(r).getSelectedLocationIds()||[],[a]),{setSelectedLocations:c}=N(r),x=n=>{c(n?a.map(o=>o.id):[])},l=(s==null?void 0:s.length)===a.length&&a.length>0;return e.jsx(Z,{children:e.jsxs(w,{children:[e.jsx(j,{className:"w-12",children:e.jsx(F,{checked:l,onCheckedChange:x})}),e.jsx(j,{children:"ID"}),e.jsx(j,{children:"Name"}),e.jsx(j,{children:"Address"}),e.jsx(j,{children:"Phone"}),e.jsx(j,{children:"Status"}),e.jsx(j,{children:"Created At"}),e.jsx(j,{className:"w-20"})]})})}function he({LocationData:a=[],setIsModalOpen:s,setSelectedId:c}){const x=D(),l=y(t=>t(r).loading(),[]),n=y(t=>t(r).getSelectedLocationIds()||[],[a]),{setSelectedLocations:o}=N(r),m=(t,g)=>{o(g?[...n,t]:n.filter(v=>v!==t))},d=t=>{c(t),s(!0)};return e.jsx(q,{children:l?e.jsx(Q,{rowCount:10,columns:[5,3,2,2,2,2,1]}):(a==null?void 0:a.length)>0?a.map(t=>e.jsxs(w,{className:"even:bg-[#F6F8FA]",children:[e.jsx(u,{className:"py-2",children:e.jsx(F,{checked:n==null?void 0:n.includes(t.id),onCheckedChange:g=>m(t.id,g)})}),e.jsx(u,{className:"py-2",children:t.id}),e.jsx(u,{className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(J,{className:"h-8 w-8",children:[e.jsx(G,{src:t==null?void 0:t.picture_full_path,alt:t==null?void 0:t.name}),e.jsx(K,{children:e.jsx(ce,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"font-medium",children:t==null?void 0:t.name})]})}),e.jsx(u,{className:"py-2 align-middle",children:t.address}),e.jsx(u,{className:"py-2 align-middle",children:t.phone??"-"}),e.jsx(u,{className:"py-2",children:e.jsx("span",{className:`label-${t.status}`,children:t.status})}),e.jsx(u,{className:"py-2 align-middle",children:t.created_at?new Date(t.created_at).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-"}),e.jsx(u,{className:"py-2 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",className:"p-0  hover:bg-transparent",size:"sm",onClick:()=>{x(`/locations/${t.id}/edit`)},children:e.jsx(W,{className:"w-4 h-4 text-primary hover:scale-110 transition"})}),e.jsx(L,{variant:"ghost",size:"sm",className:"p-0 hover:text-title hover:bg-transparent",onClick:()=>d(t.id),children:e.jsx(Y,{className:"w-4 h-4 text-[#E4002D]  hover:scale-110 transition"})})]})})]},t.id)):e.jsx(w,{children:e.jsx(u,{colSpan:7,className:"text-center py-4 text-muted-foreground",children:"No Location found."})})})}const ue=({locations:a=[],onExport:s=()=>{},onDelete:c=()=>{},resourceLabel:x="item(s)"})=>{const l=y(m=>m(r).getSelectedLocationIds()||[],[a]),n=l.length,o=a.length;return n===0||a.length===0?null:e.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-muted rounded-md mb-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[n," of ",o," ",x," selected."]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(L,{variant:"outline",size:"sm",className:"text-red-600 hover:text-red-700",onClick:()=>c(l),children:"Delete Selected"})})]})},je=p.memo(()=>e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16 px-4 bg-gray-50 rounded-lg border border-dashed border-border text-title2",children:[e.jsx(le,{className:"w-12 h-12 mb-4 text-gray-400"}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"No Locations Found"})]}));je.displayName="EmptyState";const ge=p.memo(()=>e.jsx(e.Fragment,{children:Array.from({length:6},(a,s)=>e.jsx(xe,{},s))}));ge.displayName="LoadingSkeletons";function ye(){const a=N(),[s,c]=p.useState(!1),[x,l]=p.useState(""),{filters:n,locations:o,loading:m,pagination:d}=y(h=>{const k=h(r);return{filters:k.getFilters(),locations:k.getLocations(),loading:k.loading(),pagination:k.getPagination()}},[]),t=p.useMemo(()=>JSON.stringify(n),[n]);p.useEffect(()=>{a(r).getLocations(n)},[a,t]);const g=p.useCallback(h=>{Array.isArray(h)?a(r).bulkDeleteLocations(h,n):a(r).removeLocation(h,n),c(!1)},[a,n]),v=p.useMemo(()=>(d==null?void 0:d.total)>0,[d==null?void 0:d.total]),i=h=>{c(!0),l(h),a(r).setSelectedLocations([])};return e.jsxs("main",{className:"rtrb-card p-10a flex-1 p-[30px] gap-6 space-y-6",children:[e.jsx(me,{locations:o,filter:n}),e.jsx(ue,{locations:o,onDelete:i,resourceLabel:"location(s)"}),e.jsxs(X,{children:[e.jsx(pe,{locations:o}),e.jsx(he,{LocationData:o,setIsModalOpen:c,setSelectedId:l})]}),e.jsx(ee,{open:s,onClose:()=>c(!1),onConfirm:()=>g(x),title:"Are you sure?",description:"This action will permanently delete this location.",confirmText:"Delete"}),v&&e.jsx(U,{pagination:d,loading:m,type:"Location",onPageChange:h=>{a(r).setFilter({field:"page",value:h})}})]})}const T=p.memo(ye);function ve(){var v;const a=te("/locations"),{mode:s}=a,c=N(),x=D(),l=y(i=>i(r).getLocation(),[]),n=y(i=>i(r).isLocationSaving(),[]),o=!!((v=window.radius_booking_param)!=null&&v.is_pro),m=async()=>{const i=await c(r).saveLocation(l);i&&x(`/locations/${i}/edit`)},d=()=>{if(!o)return e.jsxs("div",{children:[e.jsx(oe,{title:"Locations",type:"setting"}),e.jsx("div",{className:"pointer-events-none select-none opacity-50 mt-4",children:e.jsx(T,{demo:!0})})]});switch(s){case"list":return e.jsx(T,{});case"edit":case"create":return e.jsx(se,{});default:return null}},t={list:[{key:"add-location",label:"Add Location",icon:P,onClick:a.navigateTo.create,variant:"primary"}],create:[{key:"save-location",label:"Save",icon:_,onClick:m,loading:n,variant:"primary"},{key:"cancel-location",label:"Cancel",icon:A,onClick:a.navigateTo.list,variant:"cancel"}],edit:[{key:"update-location",label:"Update",icon:_,onClick:m,loading:n,variant:"primary"},{key:"cancel-location",label:"Cancel",icon:A,onClick:a.navigateTo.list,variant:"cancel"}]},g=o?(t[s]||[]).map(i=>e.jsx(ae,{label:i.label,icon:i.icon,onClick:i.onClick,loading:i.loading||!1,variant:i.variant||"primary"},i.key)):[];return e.jsx("div",{children:e.jsx(ne,{title:"Locations",description:"Manage your locations",showBack:o&&s!=="list",onBack:a.navigateTo.list,actions:g,icon:e.jsx(B,{className:"w-5 h-5 text-primary-colordefault"}),children:d()})})}const C=p.memo(ve);function fs(){return e.jsxs(O,{children:[e.jsx(S,{path:"/",element:e.jsx(C,{})}),e.jsx(S,{path:"create",element:e.jsx(C,{})}),e.jsx(S,{path:":id",element:e.jsx(C,{})}),e.jsx(S,{path:":id/edit",element:e.jsx(C,{})})]})}export{fs as default};
//# sourceMappingURL=index-DsAeN4hL.js.map
