forlogic-core 1.13.1 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import*as r from"react";import s,{useState as n,useMemo as i,createContext as o,useContext as l,useCallback as d,useEffect as c,useRef as m,memo as u,Component as h}from"react";import{Slot as p}from"@radix-ui/react-slot";import{cva as f}from"class-variance-authority";import{clsx as g}from"clsx";import{twMerge as b}from"tailwind-merge";import{parseISO as v,isValid as y,format as N}from"date-fns";import x from"i18next";export{default as i18n}from"i18next";import{toast as w,Toaster as k}from"sonner";export{toast as sonnerToast,toast}from"sonner";import{EllipsisVertical as C,X as S,ChevronDown as _,ChevronUp as P,Check as I,Loader2 as E,Loader2Icon as A,OctagonXIcon as T,TriangleAlertIcon as R,InfoIcon as z,CircleCheckIcon as M,AlertCircle as F,Search as j,FileX as D,ChevronRight as L,Circle as O,Edit as $,PowerOff as U,Power as W,Trash2 as q,Plus as V,ArrowUpDown as B,ArrowUp as H,ArrowDown as K,Target as Q,Trophy as G,Award as J,Sparkles as X,Flame as Y,Zap as Z,Key as ee,Shield as ae,EyeOff as te,Eye as re,Unlock as se,Lock as ne,Archive as ie,FolderOpen as oe,Folder as le,FileText as de,Save as ce,Copy as me,Share as ue,Upload as he,Download as pe,HelpCircle as fe,Info as ge,Bell as be,Clock as ve,ArrowRight as ye,ArrowLeft as Ne,ChevronLeft as xe,Minus as we,Filter as ke,Bookmark as Ce,Book as Se,Video as _e,Music as Pe,Image as Ie,Camera as Ee,MapPin as Ae,Calendar as Te,Phone as Re,Mail as ze,Settings as Me,User as Fe,Home as je,Heart as De,Star as Le,ChevronsLeft as Oe,ChevronsRight as $e,CheckCircle as Ue,AlertTriangle as We,RefreshCw as qe,MoreHorizontal as Ve,GripVertical as Be,PanelLeft as He,Edit3 as Ke,Code as Qe,Heading1 as Ge,Heading2 as Je,Heading3 as Xe,Bold as Ye,Italic as Ze,Underline as ea,Strikethrough as aa,List as ta,ListOrdered as ra,Highlighter as sa,Link as na,RemoveFormatting as ia,Undo as oa,Redo as la,Globe as da,Building2 as ca,LogOut as ma,ExternalLink as ua,Users as ha,Crown as pa,UserPlus as fa}from"lucide-react";import*as ga from"@radix-ui/react-label";import*as ba from"@radix-ui/react-dialog";import*as va from"@radix-ui/react-separator";import{useFormContext as ya,FormProvider as Na,Controller as xa,appendErrors as wa,useForm as ka}from"react-hook-form";import*as Ca from"@radix-ui/react-select";import*as Sa from"@radix-ui/react-checkbox";import*as _a from"@radix-ui/react-popover";import{useTranslation as Pa,initReactI18next as Ia,I18nextProvider as Ea}from"react-i18next";export{I18nextProvider,useTranslation}from"react-i18next";import{createClient as Aa}from"@supabase/supabase-js";import{useQueryClient as Ta,useQuery as Ra,useMutation as za,QueryClient as Ma,QueryClientProvider as Fa}from"@tanstack/react-query";import{useSearchParams as ja,useLocation as Da,useNavigate as La,Link as Oa}from"react-router-dom";import*as $a from"@radix-ui/react-tooltip";import*as Ua from"@radix-ui/react-dropdown-menu";import*as Wa from"@radix-ui/react-context-menu";import*as qa from"@radix-ui/react-scroll-area";import*as Va from"@radix-ui/react-switch";import*as Ba from"@radix-ui/react-progress";import*as Ha from"@radix-ui/react-collapsible";import*as Ka from"@radix-ui/react-accordion";import*as Qa from"@radix-ui/react-alert-dialog";import*as Ga from"@radix-ui/react-avatar";import{DayPicker as Ja}from"react-day-picker";import{Drawer as Xa}from"vaul";import*as Ya from"@radix-ui/react-hover-card";import*as Za from"@radix-ui/react-navigation-menu";import*as et from"@radix-ui/react-radio-group";import{Panel as at,Group as tt,Separator as rt}from"react-resizable-panels";import*as st from"@radix-ui/react-slider";import*as nt from"@radix-ui/react-tabs";import*as it from"@radix-ui/react-toggle";import*as ot from"@radix-ui/react-toggle-group";import*as lt from"@radix-ui/react-menubar";import*as dt from"recharts";import{useEditor as ct,EditorContent as mt}from"@tiptap/react";import ut from"@tiptap/starter-kit";import ht from"@tiptap/extension-underline";import pt from"@tiptap/extension-link";import{TextStyle as ft}from"@tiptap/extension-text-style";import{Color as gt}from"@tiptap/extension-color";import bt from"@tiptap/extension-highlight";import{z as vt}from"zod";import{validateFieldsNatively as yt,toNestErrors as Nt}from"@hookform/resolvers";function xt(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{w.info(x.t("link_copied"))})}function wt(...e){return b(g(e))}const kt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(kt);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,r]of Object.entries(e))a[t]=kt(r);return a}return e},Ct=e=>{if(!e)return"";const a=v(e);if(!y(a))return"Data inválida";return`${a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${a.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},St=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),_t=(e,a)=>{let t;return(...r)=>{clearTimeout(t),t=setTimeout(()=>e(...r),a)}},Pt=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),It=f("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded",md:"h-10 px-4 py-2 text-sm rounded-md",lg:"h-12 px-8 text-base rounded-lg",xl:"h-14 px-10 text-lg rounded-lg",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6",default:"h-10 px-4 py-2"}},defaultVariants:{variant:"primary",size:"md"}}),Et=r.forwardRef(({className:a,variant:t,size:r,asChild:s=!1,...n},i)=>e(s?p:"button",{className:wt(It({variant:t,size:r,className:a})),ref:i,...n}));Et.displayName="Button";const At=s.forwardRef(({className:a,children:t,...r},s)=>e(Et,{ref:s,variant:"action",size:"sm",className:wt("h-7 px-2 text-xs",a),...r,children:t||e(C,{size:12})}));At.displayName="ActionButton";const Tt=r.forwardRef(({className:a,type:t,...r},s)=>e("input",{type:t,className:wt("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:s,...r}));Tt.displayName="Input";const Rt=f("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),zt=r.forwardRef(({className:a,...t},r)=>e(ga.Root,{ref:r,className:wt(Rt(),a),...t}));zt.displayName=ga.Root.displayName;const Mt=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));Mt.displayName="Card";const Ft=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("flex flex-col space-y-1.5 p-6",a),...t}));Ft.displayName="CardHeader";const jt=r.forwardRef(({className:a,...t},r)=>e("h3",{ref:r,className:wt("text-2xl font-semibold leading-none tracking-tight",a),...t}));jt.displayName="CardTitle";const Dt=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:wt("text-sm text-muted-foreground",a),...t}));Dt.displayName="CardDescription";const Lt=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("p-6 pt-0",a),...t}));Lt.displayName="CardContent";const Ot=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("flex items-center p-6 pt-0",a),...t}));Ot.displayName="CardFooter";const $t=r.forwardRef(({className:a,orientation:t="horizontal",decorative:r=!0,...s},n)=>e(va.Root,{ref:n,decorative:r,orientation:t,className:wt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...s}));$t.displayName=va.Root.displayName;const Ut=ba.Root,Wt=ba.Trigger,qt=ba.Portal,Vt=ba.Close,Bt=r.forwardRef(({className:a,...t},r)=>e(ba.Overlay,{ref:r,className:wt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t}));Bt.displayName=ba.Overlay.displayName;const Ht={sm:"sm:max-w-[420px]",md:"sm:max-w-lg",lg:"sm:max-w-2xl",xl:"sm:max-w-4xl",full:"max-w-[85vw]"},Kt=r.forwardRef(({className:t,children:r,size:s="md",...n},i)=>a(qt,{children:[e(Bt,{}),a(ba.Content,{ref:i,className:wt("fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-[85vw] max-h-[85vh] translate-x-[-50%] translate-y-[-50%] border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",Ht[s],t),...n,children:[r,a(ba.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e(S,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));Kt.displayName=ba.Content.displayName;const Qt=({className:t,showSeparator:r=!1,children:s,...n})=>a("div",{className:wt("flex flex-col flex-shrink-0",t),...n,children:[e("div",{className:"flex flex-col text-left",children:s}),r&&e($t,{className:"mt-2"})]});Qt.displayName="DialogHeader";const Gt=({className:a,...t})=>e("div",{className:wt("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Gt.displayName="DialogBody";const Jt=({className:t,children:r,...s})=>a("div",{className:"flex-shrink-0 pt-4",children:[e($t,{className:"mb-4"}),e("div",{className:wt("flex flex-row justify-end gap-2",t),...s,children:r})]});Jt.displayName="DialogFooter";const Xt=r.forwardRef(({className:a,...t},r)=>e(ba.Title,{ref:r,className:wt("text-lg font-semibold leading-none tracking-tight",a),...t}));Xt.displayName=ba.Title.displayName;const Yt=r.forwardRef(({className:a,...t},r)=>e(ba.Description,{ref:r,className:wt("text-sm text-muted-foreground",a),...t}));Yt.displayName=ba.Description.displayName;const Zt=Na,er=r.createContext({}),ar=({...a})=>e(er.Provider,{value:{name:a.name},children:e(xa,{...a})}),tr=()=>{const e=r.useContext(er),a=r.useContext(rr),{getFieldState:t,formState:s}=ya(),n=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=a;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},rr=r.createContext({}),sr=r.forwardRef(({className:a,...t},s)=>{const n=r.useId();return e(rr.Provider,{value:{id:n},children:e("div",{ref:s,className:wt("space-y-2",a),...t})})});sr.displayName="FormItem";const nr=r.forwardRef(({className:a,...t},r)=>{const{error:s,formItemId:n}=tr();return e(zt,{ref:r,className:wt(s&&"text-destructive",a),htmlFor:n,...t})});nr.displayName="FormLabel";const ir=r.forwardRef(({...a},t)=>{const{error:r,formItemId:s,formDescriptionId:n,formMessageId:i}=tr();return e(p,{ref:t,id:s,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...a})});ir.displayName="FormControl";const or=r.forwardRef(({className:a,...t},r)=>{const{formDescriptionId:s}=tr();return e("p",{ref:r,id:s,className:wt("text-sm text-muted-foreground",a),...t})});or.displayName="FormDescription";const lr=r.forwardRef(({className:a,children:t,...r},s)=>{const{error:n,formMessageId:i}=tr(),o=n?String(n?.message):t;return o?e("p",{ref:s,id:i,className:wt("text-sm font-medium text-destructive",a),...r,children:o}):null});lr.displayName="FormMessage";const dr=Ca.Root,cr=Ca.Group,mr=Ca.Value,ur=r.forwardRef(({className:t,children:r,...s},n)=>a(Ca.Trigger,{ref:n,className:wt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[r,e(Ca.Icon,{asChild:!0,children:e(_,{className:"h-4 w-4 opacity-50"})})]}));ur.displayName=Ca.Trigger.displayName;const hr=r.forwardRef(({className:a,...t},r)=>e(Ca.ScrollUpButton,{ref:r,className:wt("flex cursor-default items-center justify-center py-1",a),...t,children:e(P,{className:"h-4 w-4"})}));hr.displayName=Ca.ScrollUpButton.displayName;const pr=r.forwardRef(({className:a,...t},r)=>e(Ca.ScrollDownButton,{ref:r,className:wt("flex cursor-default items-center justify-center py-1",a),...t,children:e(_,{className:"h-4 w-4"})}));pr.displayName=Ca.ScrollDownButton.displayName;const fr=r.forwardRef(({className:t,children:r,position:s="popper",container:n,collisionBoundary:i,...o},l)=>e(Ca.Portal,{container:n,children:a(Ca.Content,{ref:l,className:wt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:i,...o,children:[e(hr,{}),e(Ca.Viewport,{className:wt("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e(pr,{})]})}));fr.displayName=Ca.Content.displayName;const gr=r.forwardRef(({className:a,...t},r)=>e(Ca.Label,{ref:r,className:wt("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));gr.displayName=Ca.Label.displayName;const br=r.forwardRef(({className:t,children:r,...s},n)=>a(Ca.Item,{ref:n,className:wt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Ca.ItemIndicator,{children:e(I,{className:"h-4 w-4"})})}),e(Ca.ItemText,{children:r})]}));br.displayName=Ca.Item.displayName;const vr=r.forwardRef(({className:a,...t},r)=>e(Ca.Separator,{ref:r,className:wt("-mx-1 my-1 h-px bg-muted",a),...t}));vr.displayName=Ca.Separator.displayName;const yr=r.forwardRef(({className:a,...t},r)=>e(Sa.Root,{ref:r,className:wt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",a),...t,children:e(Sa.Indicator,{className:wt("flex items-center justify-center text-current"),children:e(I,{className:"h-4 w-4"})})}));yr.displayName=Sa.Root.displayName;const Nr=r.forwardRef(({className:a,...t},r)=>e("textarea",{className:wt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:r,...t}));Nr.displayName="Textarea";const xr=f("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),wr=r.forwardRef(({className:a,variant:t,...r},s)=>e("div",{ref:s,className:wt(xr({variant:t}),a),...r}));wr.displayName="Badge";const kr={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Cr({size:a="md",className:t}){return e(E,{className:wt("animate-spin text-muted-foreground",kr[a],t)})}function Sr({isLoading:r,children:s,className:n,type:i="spinner",size:o="md"}){return r?"overlay"===i?a("div",{className:wt("relative",n),children:[s,e("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e(Cr,{size:o})})]}):e("div","skeleton"===i?{className:wt("animate-pulse",n),children:e("div",{className:"bg-muted rounded-md h-full w-full"})}:{className:wt("flex items-center justify-center py-8",n),children:e(Cr,{size:o})}):e(t,{children:s})}const _r=({...a})=>e(k,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e(M,{className:"h-4 w-4"}),info:e(z,{className:"h-4 w-4"}),warning:e(R,{className:"h-4 w-4"}),error:e(T,{className:"h-4 w-4"}),loading:e(A,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...a}),Pr=_a.Root,Ir=_a.Trigger,Er=r.forwardRef(({className:a,align:t="center",sideOffset:r=4,container:s,...n},i)=>e(_a.Portal,{container:s,children:e(_a.Content,{ref:i,align:t,sideOffset:r,className:wt("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...n})}));Er.displayName=_a.Content.displayName;const Ar=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ar.displayName="Command";const Tr=({children:a,...t})=>e("div",{...t,children:e(Ar,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})}),Rr=r.forwardRef(({className:a,...t},r)=>e("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e("input",{ref:r,className:wt("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})}));Rr.displayName="CommandInput";const zr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));zr.displayName="CommandList";const Mr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("py-6 text-center text-sm text-muted-foreground",a),...t}));Mr.displayName="CommandEmpty";const Fr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));Fr.displayName="CommandGroup";const jr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("-mx-1 h-px bg-border",a),...t}));jr.displayName="CommandSeparator";const Dr=r.forwardRef(({className:a,disabled:t,onSelect:r,value:s,...n},i)=>e("div",{ref:i,className:wt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",a),"data-disabled":t,onClick:()=>!t&&r?.(s||""),...n}));Dr.displayName="CommandItem";const Lr=({className:a,...t})=>e("span",{className:wt("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function Or({className:a,...t}){return e("div",{className:wt("animate-pulse rounded-md bg-muted",a),...t})}Lr.displayName="CommandShortcut";const $r=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Ur({multiple:t,options:r,value:s,onChange:o,getOptionValue:l,getOptionLabel:d,placeholder:c,label:m,icon:u,emptyMessage:h,searchPlaceholder:p,disabled:f,required:g,className:b,sortOptions:v,maxDisplayedBadges:y,popoverContainer:N,onOpen:x,onClose:w}){const{t:k}=Pa(),[C,P]=n(!1),[E,A]=n(""),T=i(()=>s?Array.isArray(s)?s:[s]:[],[s]),R=i(()=>{if(!N)return;let e=N,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),r=t.overflowY||t.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,a++}}catch{}return e??void 0},[N]),z=i(()=>{const e=r.map(e=>({original:e,value:l(e),label:d(e)}));return v?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[r,l,d,v]),M=i(()=>{if(!E)return z;const e=$r(E);return z.filter(a=>$r(a.label).includes(e))},[z,E]),F=i(()=>z.filter(e=>T.includes(e.value)),[z,T]),j=(e,a)=>{a.preventDefault(),a.stopPropagation(),o&&o(t?T.filter(a=>a!==e):"")},D=y?F.slice(0,y):F,L=y&&F.length>y?F.length-y:0;return a("div",{className:wt("space-y-2",b),children:[m&&a(zt,{children:[m,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a(Pr,{open:C,onOpenChange:e=>{P(e),e?x?.():(A(""),w?.())},modal:!1,children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",role:"combobox","aria-expanded":C,disabled:f,className:wt("w-full justify-between min-h-10 h-auto",0===F.length&&"text-muted-foreground"),children:[0===F.length?a("span",{className:"flex items-center gap-2",children:[u&&e(u,{className:"h-4 w-4"}),c]}):t?a("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[D.map(t=>a(wr,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&j(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>j(t.value,e),children:e(S,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),L>0&&a(wr,{variant:"outline",className:"gap-1",children:["+",L]})]}):a("span",{className:"flex items-center gap-2",children:[u&&e(u,{className:"h-4 w-4"}),F[0]?.label]}),e(_,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e(Er,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:R,collisionBoundary:R,children:a(Ar,{children:[e(Rr,{placeholder:p,value:E,onChange:e=>A(e.target.value)}),e(zr,{children:0===r.length?e(Mr,{children:h}):0===M.length?e(Mr,{children:k("no_results")}):e(Fr,{children:M.map(r=>a(Dr,{value:r.value,onSelect:()=>(e=>{if(o)if(t){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];o(a)}else o(e),P(!1)})(r.value),className:"cursor-pointer",children:[e(I,{className:wt("mr-2 h-4 w-4",T.includes(r.value)?"opacity-100":"opacity-0")}),r.label]},r.value))})})]})})]})]})}function Wr({multiple:t=!1,options:r,items:s,value:n,onChange:i,onValueChange:o,getOptionValue:l=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:m,icon:u,emptyMessage:h,searchPlaceholder:p,disabled:f=!1,required:g=!1,isLoading:b=!1,error:v,className:y,sortOptions:N=!0,maxDisplayedBadges:x,popoverContainer:w,onOpen:k,onClose:C}){const{t:S}=Pa(),_=s||r||[],P=o||i,I=c||S("select_placeholder"),E=h||S("no_results"),A=p||S("search_placeholder");if(b)return a("div",{className:wt("space-y-2",y),children:[m&&a(zt,{children:[m,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Or,{className:"h-10 w-full"})]});const T="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return T?a("div",{className:wt("space-y-2",y),children:[m&&a(zt,{children:[m,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e(F,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:T})]})]}):e(Ur,{multiple:t,options:_,value:n||(t?[]:""),onChange:P,getOptionValue:l,getOptionLabel:d,placeholder:I,label:m,icon:u,emptyMessage:E,searchPlaceholder:A,disabled:f,required:g,className:y,sortOptions:N,maxDisplayedBadges:x,popoverContainer:w,onOpen:k,onClose:C})}var qr=Object.defineProperty;class Vr{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}static parseJwtPayload(e){try{const s=e.split(".");if(3!==s.length)return null;const n=s[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let s=0;s<a.length;s++)t[s]=a.charCodeAt(s);const r=new TextDecoder("utf-8").decode(t);return JSON.parse(r)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(r){throw r}}}}catch(s){return null}}static validateTokens(e,a){const t=[],r=[];try{a.split(".")[1],e.split(".")[1];const s=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!s){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:r}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";t.push(e),i=!1}if(s.exp&&s.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:t,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:r}}catch(s){const e=`Erro na validação de tokens: ${s}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:r}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,a,t)=>{a in e?qr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(Vr,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Br="qualiex_access_token",Hr="qualiex_id_token",Kr="supabase_token",Qr="oauth_state",Gr="oauth_nonce",Jr="selected_alias",Xr="manual_logout",Yr={setAccessToken:e=>localStorage.setItem(Br,e),getAccessToken:()=>localStorage.getItem(Br),setIdToken:e=>localStorage.setItem(Hr,e),getIdToken:()=>localStorage.getItem(Hr),getSupabaseToken:()=>localStorage.getItem(Kr),setOAuthState:e=>sessionStorage.setItem(Qr,e),getOAuthState:()=>sessionStorage.getItem(Qr),clearOAuthState:()=>sessionStorage.removeItem(Qr),setOAuthNonce:e=>sessionStorage.setItem(Gr,e),getOAuthNonce:()=>sessionStorage.getItem(Gr),clearOAuthNonce:()=>sessionStorage.removeItem(Gr),setSelectedAlias:e=>localStorage.setItem(Jr,e),getSelectedAlias:()=>localStorage.getItem(Jr),clearSelectedAlias:()=>localStorage.removeItem(Jr),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Yr.getAccessToken()||!Yr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Kr,e),Yr._clearValidationCache()},areAllTokensValid:()=>{const e=Yr.getAccessToken(),a=Yr.getIdToken();if(!e||!a)return!1;try{const t=Vr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Yr.getAccessToken(),t=Yr.getIdToken(),r=Yr.getSupabaseToken();return a&&Yr.isTokenExpired(a)&&(localStorage.removeItem(Br),e=!0),t&&Yr.isTokenExpired(t)&&(localStorage.removeItem(Hr),e=!0),r&&Yr.isTokenExpired(r)&&(localStorage.removeItem(Kr),e=!0),e},clearAll:()=>{localStorage.removeItem(Br),localStorage.removeItem(Hr),localStorage.removeItem(Kr),localStorage.removeItem(Jr),localStorage.removeItem(Xr),sessionStorage.removeItem(Qr),sessionStorage.removeItem(Gr)},setManualLogout:()=>localStorage.setItem(Xr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Xr),clearManualLogout:()=>localStorage.removeItem(Xr),isTokenExpired:e=>{try{return Vr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Yr._validationCache.isValid=!1,Yr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Yr.getSupabaseToken();if(!e)return!1;if(Yr.isTokenExpired(e))return Yr._clearValidationCache(),Yr._handleExpiredToken(),!1;const a=Date.now();return a-Yr._validationCache.timestamp<Yr._validationCache.cacheValidityMs?Yr._validationCache.isValid:(Yr._validationCache.isValid=!0,Yr._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>Yr.isSupabaseTokenValid()?Yr.getSupabaseToken():null,_handleExpiredToken:()=>{Yr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Yr.isSupabaseTokenValid())return null;const e=Yr.getSupabaseToken();if(!e)return null;try{const a=Vr.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,r=a.place_id||null,s=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=a[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:r,placeName:s,payload:a}}catch(a){return Yr._handleExpiredToken(),null}},getCompanyId:e=>{const a=Yr.getAccessToken();if(a)try{const t=Vr.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const a=r.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(s){}const t=Yr.extractTokenData();if(t?.companyId)return t.companyId;const r=Yr.getIdToken();if(r)try{const a=Vr.parseJwtPayload(r);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=a[t];if(r&&"string"==typeof r){const a=r.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(s){}return null},getCurrentCompanyId:()=>{const e=Yr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Yr.getIdToken();if(!e)return[];try{const a=Vr.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=a[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};var Zr=Object.defineProperty,es=(e,a,t)=>((e,a,t)=>a in e?Zr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const as=new class{constructor(){es(this,"errors",[]),es(this,"toastCount",0),es(this,"lastToastTime",0)}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);w.error(e,{description:t})}}getErrorTitle(e){const a=e.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?"Sessão Expirada":a.includes("token")||a.includes("autenticação")?"Erro de Autenticação":a.includes("api")||a.includes("network")?"Erro de Conexão":"Erro"}success(e,a){w.success(e,{description:a})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var ts=Object.defineProperty,rs=(e,a,t)=>((e,a,t)=>a in e?ts(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const ss=import.meta.env.VITE_SUPABASE_URL,ns=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,is=class e{constructor(){rs(this,"client"),rs(this,"currentToken",null),rs(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:ns};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return Aa(ss,ns,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,a)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Yr.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const a=JSON.parse(atob(e.split(".")[1])),t=Math.floor(Date.now()/1e3);return a.exp>t}catch(a){return as.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};rs(is,"instance");let os=is;function ls(){return os.getInstance().getClient()}class ds{static async generateToken(e,a,t,r=!1){try{if(!r){const e=Yr.getSupabaseToken();if(e&&Yr.isSupabaseTokenValid())return e}const s=ls(),{data:n,error:i}=await s.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token&&n.access_token?(Yr.setSupabaseToken(n.access_token),n.access_token):null}catch(s){return s instanceof Error&&(s.message.includes("401")||s.message.includes("Unauthorized"))&&t?.(),null}}}var cs=Object.defineProperty,ms=(e,a,t)=>((e,a,t)=>a in e?cs(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class us{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Yr.getAccessToken(),a=Yr.getSelectedAlias();if(!e||!a)return null;const t=await ds.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(Yr.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}ms(us,"isRegenerating",!1),ms(us,"onLogoutCallback",null);class hs{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Yr.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var ps=Object.defineProperty;class fs{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await us.attemptRegeneration()?(this.isRetrying=!1,!0):(hs.handleError(e),this.isRetrying=!1,!1)}catch(r){return hs.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Yr.getAccessToken();return e?Yr.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,a,t)=>{((e,a,t)=>{a in e?ps(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(fs,"isRetrying",!1);var gs=Object.defineProperty,bs=(e,a,t)=>((e,a,t)=>a in e?gs(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const vs=new class{constructor(){bs(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const r=fs.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=Yr.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}async fetchUsers(e,a){try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let r=t;if(t.data)r=t.data;else{if(!Array.isArray(t))return as.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=t}if(!Array.isArray(r))return as.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(t){if(await fs.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let r=t;if(t.data)r=t.data;else{if(!Array.isArray(t))return as.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=t}return Array.isArray(r)?r.map(this.mapToQualiexUser):(as.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return as.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}const s=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return as.handleError(s,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(r){return as.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),r=new Map;return t.forEach(e=>{r.set(e.userId,e)}),r}async getUsers(e){const a=Yr.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},ys={oauth:{authUrl:import.meta.env.VITE_OAUTH_AUTH_URL,clientId:import.meta.env.VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},Ns={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},xs={debounceDelay:500},ws=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||import.meta.env.DEV},ks={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},Cs={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Ss=()=>Cs,_s={isQualiex:"true"===import.meta.env.VITE_IS_QUALIEX},Ps={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}};function Is(e,a){const t=Ss(),r=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Es(e,a){const t=Ss(),r=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function As(e,a){const t=Ss(),r=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Ts(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||Is(e.idField),emailField:e.emailField||Es(e.idField),usernameField:e.usernameField||As(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Is(e),emailField:Es(e),usernameField:As(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Rs=new Map;class zs{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,r=Rs.get(t);if(r&&Date.now()-r.timestamp<3e5)return r.users;const s=await vs.fetchUsers(e,a);return Rs.set(t,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,a){const t=new Set;for(const r of e)for(const e of a){const a=r[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const r={...e};for(const s of a){const a=e[s.idField];if(!a)continue;const n=t.get(a);if(n){if(s.nameField){r[s.nameField]||(r[s.nameField]=n.userName||n.displayName||null)}if(s.emailField){r[s.emailField]||(r[s.emailField]=n.userEmail||null)}if(s.usernameField){r[s.usernameField]||(r[s.usernameField]=n.userName||null)}}}return r}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!Yr.areAllTokensValid())return e;const t=Yr.extractTokenData();if(!t)return e;const{alias:r,companyId:s}=t;if(!r||!s)return e;const n=Ts(a.userIdFields,a.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(r,s),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(t){return as.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,a){return this.enrichWithUserData(e,{entityName:a.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const Ms=["responsible_name"],Fs=e=>Ms.includes(e);function js(e,a,t){const r="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:s,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=r,c=()=>{if(!Yr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return ls().schema(o).from(s)},m=(e,a,t,r)=>{let s=c().select(i||"*",{count:"exact"});s=s.eq("is_removed",!1),Object.entries(r).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?s=s.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?s=s.not(e,"is",null):"is_null"===a.operator&&(s=s.is(e,null)):null!==a&&(s=s.eq(e,a)))}),s=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(s,e);const o=a.includes(".");return o||Fs(a)||(s=s.order(a,{ascending:"asc"===t})),{query:s,isForeignKey:o}},u=async(e,a,t,s,n)=>{const i=Ts(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(Fs(a)||o||i){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},i=await this.getAll(e);if(!i?.data?.length)return i;const d=await zs.enrichWithUserData(i.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let c;c=o?d.sort((e,r)=>{const s=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],r)||"",i=String(s).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,r)=>{const s=e[a]||"",n=r[a]||"",i=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const m=((e,a=1,t=25)=>{const r=(a-1)*t,s=r+t,n=e.slice(r,s);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:s<e.length,hasPreviousPage:a>1}}})(c,s,n);return{data:m.data,currentPage:m.pagination.currentPage,totalPages:m.pagination.totalPages,totalItems:m.pagination.totalCount,itemsPerPage:m.pagination.itemsPerPage,hasNextPage:m.pagination.hasNextPage,hasPreviousPage:m.pagination.hasPreviousPage}}return await zs.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})};return{async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:r,page:s,limit:n,additionalFilters:i}})(e),{query:h}=m(a,t,n,c),p=((e,a,t)=>{const r=(a-1)*t,s=r+t-1;return e.range(r,s)})(h,i,o),{data:f,error:g,count:b}=await p;if(g)throw new Error(`Error fetching ${s}: ${g.message}`);let v=((e,a,t,r)=>{const s=Math.ceil((a||0)/r);return{data:e,currentPage:t,totalPages:s,totalItems:a||0,itemsPerPage:r,hasNextPage:t<s,hasPreviousPage:t>1}})(f||[],b,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=Ts(r.userIdFields,r.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(v.data)){const e=await u(v.data,t,n,i,o);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${s}: ${t.message}`);return a},async create(e){const a=kt(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:r,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from create ${s} operation`);return r},async update(e,a){const t={...kt(a),updated_at:(new Date).toISOString()},{data:r,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from update ${s} operation`);return r},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${s}: ${t.message}`)}}}const Ds=()=>{Yr.clearManualLogout()},Ls=e=>e?.placeId||null,Os=e=>e?.placeName||null,$s=e=>({placeId:Ls(e),placeName:Os(e)}),Us=class{static async initialize(){try{if(!Yr.hasAllTokens()||!Yr.areAllTokensValid())return Yr.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const a=Yr.getAccessToken(),t=Yr.getIdToken();Ds();const r=this.extractUserFromIdToken(t),s=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=Yr.extractTokenData(),o=i?.alias;let l=null;if(o&&s.some(e=>e.alias===o))l=o;else{const e=Yr.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);l=a?e:n||s[0]?.alias||null}!Yr.isSupabaseTokenValid()&&l&&await us.attemptRegeneration();let d=null;if(l){const e=Yr.getCompanyId(l),a=s.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,m=null;if(r?.id&&l){const a=Yr.getCompanyId(l);if(a)try{const e=(await vs.fetchActiveUsersMap(l,a)).get(r.id);if(e){const a=$s(e);c=a.placeId,m=a.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:s,selectedUnit:d,userId:r?.id||null,userAlias:r?.id||null,placeId:c,placeName:m,activePlaceId:c,activePlaceName:m}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=ls(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const r=new URL("/callback",window.location.origin);return r.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e=Yr.generateOAuthState();Yr.setOAuthState(e);const a=Yr.generateOAuthNonce();Yr.setOAuthNonce(a);const t=`${window.location.origin}/callback`,r=new URL(ys.oauth.authUrl);r.searchParams.set("client_id",ys.oauth.clientId),r.searchParams.set("response_type",ys.oauth.responseType),r.searchParams.set("scope",ys.oauth.scope),r.searchParams.set("redirect_uri",t),r.searchParams.set("state",e),r.searchParams.set("nonce",a),r.searchParams.set("response_mode","fragment"),ws(),window.location.href=r.toString()}static async processCallback(){try{if(Yr.hasAllTokens()){if(!Yr.getValidSupabaseToken()){Yr.getAccessToken();await us.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),r=t("access_token"),s=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!r||!s)throw new Error("Tokens não encontrados na URL de callback");Yr.setAccessToken(r),Yr.setIdToken(s),Ds();const i=this.extractAliasFromAccessToken(r);if(i)Yr.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(s);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Yr.setSelectedAlias(e[0].alias)}if(!await us.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Yr.clearOAuthState(),Yr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Yr.setManualLogout(),Yr.clearAll(),window.location.href="/login"}static decodeToken(e){return Vr.parseJwtPayload(e)}static extractUserFromIdToken(e){const a=this.decodeToken(e);return a?{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier}:null}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const r=a[e].split(";");if(r.length>=4)t.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,s]=a[e].split("|");r&&s&&t.push({id:"",alias:r.trim(),name:s.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};us.setLogoutCallback(()=>{Us.logout()});let Ws=Us;const qs=o(void 0),Vs=({children:a})=>{const[t,r]=n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let s=null;try{s=Ta()}catch{}const[o,l]=n(!1),[m,u]=n(0),h=d(e=>{r(a=>({...a,...e}))},[]),p=d(e=>{r(a=>({...a,isLoading:e}))},[]),f=d(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),g=d(async e=>{try{p(!0);const r=Yr.getAccessToken();if(!r)return;const n=await ds.generateToken(r,e.alias,void 0,!0);if(!n)return;Yr.setSupabaseToken(n),Yr.setSelectedAlias(e.alias);const i=Yr.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Yr.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let c=null,m=null;if(t.user?.id&&o&&l)try{const e=(await vs.fetchActiveUsersMap(o,l)).get(t.user.id);if(e){const a=$s(e);c=a.placeId,m=a.placeName}}catch(a){}h({alias:o,selectedUnit:d,placeId:c,placeName:m,activePlaceId:c,activePlaceName:m}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{p(!1)}},[h,s,p,t.user]),b=d(async()=>await Ws.processCallback(),[]),v=d(async()=>{Ws.logout(),f(),s&&await s.clear()},[f,s]),y=d(e=>{l(e)},[]),N=d(()=>{u(e=>e+1)},[]),x=d(()=>{u(e=>e+1)},[]);c(()=>{if(!t.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Yr.areAllTokensValid()||e&&v())},6e5);return()=>{e=!1,clearInterval(a)}},[t.isAuthenticated,v]),c(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Ws.initialize();if(!e)return;a&&a.isAuthenticated?h({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&p(!1)}catch(a){e&&(hs.handleError(a),p(!1))}})(),()=>{e=!1}},[h,p,v]);const w=i(()=>({...t,logout:v,processCallback:b,switchUnit:g,availableUnits:t.companies,isSearchVisible:o,setSearchVisible:y,clearSearch:N,refreshData:x}),[t.user,t.companies,t.alias,t.isAuthenticated,t.isLoading,t.selectedUnit,t.userId,t.userAlias,t.placeId,t.placeName,t.activePlaceId,t.activePlaceName,v,b,g,o,y,N,x]);return e(qs.Provider,{value:w,children:a})},Bs=()=>{const e=l(qs);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Hs({queryKey:e,service:a,entityName:t,searchFields:r,additionalFilters:s={},onSuccess:o}){const[l,c]=ja(),m=Ta(),{alias:u,userId:h,isAuthenticated:p}=Bs(),f=d(a=>{const t=`${e}_${a}`,r=l.get(t);return r||(l.get(a)||"")},[l,e]),g=f("search"),b=f("sortField")||Ns.sorting.defaultField,v=f("sortDirection")||Ns.sorting.defaultDirection,y=parseInt(f("page")||"1"),N=parseInt(f("limit")||String(Ns.pagination.defaultPageSize)),x=g,k=i(()=>({search:x,sortField:b,sortDirection:v,page:y,limit:N,...s}),[x,b,v,y,N,s]),C=d(()=>a.getAll(k),[a,k]),S=Ra({queryKey:[e,u,h,k],queryFn:C,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${t}". Ensure QueryClientProvider is configured in your app root.`);const _=za({mutationFn:a.create,onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),w.success(Ps.success.created(t)),o?.()},onError:e=>{w.error(`${Ps.error.create(t)}: ${e.message}`)}}),P=za({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),w.success(Ps.success.updated(t)),o?.()},onError:e=>{w.error(`${Ps.error.update(t)}: ${e.message}`)}}),I=za({mutationFn:a.delete,onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),w.success(Ps.success.deleted(t))},onError:e=>{w.error(`${Ps.error.delete(t)}: ${e.message}`)}}),E=d(a=>{const t={...Object.fromEntries(l)};Object.entries(a).forEach(([a,r])=>{const s=`${e}_${a}`;""===r||0===r?delete t[s]:t[s]=String(r)}),delete t.sortField,delete t.sortDirection,c(t)},[l,c,e]),A=d(e=>{E({search:e,page:1})},[E]),T=d(e=>{E({sortField:e,sortDirection:b===e&&"asc"===v?"desc":"asc",page:1})},[b,v,E]),R=d(e=>{E({page:e})},[E]),z=d(e=>{E({limit:e,page:1})},[E]),M=d(()=>{const a=Object.fromEntries(l),t=`${e}_`,r=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));c(r)},[c,l,e]),[F,j]=n([]),D=d(e=>{j(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=d(()=>{const e=S?.data?.data.map(e=>e.id)||[];j(a=>a.length===e.length?[]:e)},[S?.data?.data]),O=d(()=>{j([])},[]),$=i(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&F.length===e.length},[F,S?.data?.data]),U=za({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,r)=>{m.invalidateQueries({queryKey:[e]}),w.success(`${r.length} ${t}(s) deletado(s) com sucesso`),O()},onError:e=>{w.error(`Erro ao deletar itens: ${e.message}`)}}),W=d((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):_.mutate({...t,alias:u})},[u,_,P]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||Ns.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:_?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:I?.isPending??!1,error:S?.error||null,searchTerm:g,sortField:b,sortDirection:v,currentPage:y,itemsPerPage:N,queryKey:e,createEntity:_.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:I.mutate,save:W,handleSearch:A,handleSort:T,handlePageChange:R,handleItemsPerPageChange:z,clearFilters:M,refetch:S.refetch,selectedIds:F,selectItem:D,selectAll:L,clearSelection:O,isAllSelected:$,bulkDelete:e=>U.mutateAsync(e),isBulkDeleting:U.isPending}}function Ks(e){const a=js({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:a,useCrudHook:(t,r)=>Hs({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:r})}}const Qs=r.forwardRef(({className:a,...t},r)=>e("table",{ref:r,className:wt("w-full caption-bottom text-sm table-fixed",a),...t}));Qs.displayName="Table";const Gs=r.forwardRef(({className:a,...t},r)=>e("thead",{ref:r,className:wt("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Gs.displayName="TableHeader";const Js=r.forwardRef(({className:a,...t},r)=>e("tbody",{ref:r,className:wt("[&_tr:last-child]:border-0",a),...t}));Js.displayName="TableBody";const Xs=r.forwardRef(({className:a,...t},r)=>e("tfoot",{ref:r,className:wt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Xs.displayName="TableFooter";const Ys=r.forwardRef(({className:a,...t},r)=>e("tr",{ref:r,className:wt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Ys.displayName="TableRow";const Zs=r.forwardRef(({className:a,...t},r)=>e("th",{ref:r,className:wt("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",a),...t}));Zs.displayName="TableHead";const en=r.forwardRef(({className:a,...t},r)=>e("td",{ref:r,className:wt("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));en.displayName="TableCell";const an=r.forwardRef(({className:a,...t},r)=>e("caption",{ref:r,className:wt("mt-4 text-sm text-muted-foreground",a),...t}));function tn({rows:t=5,columns:r=4}){return e("div",{className:"w-full",children:a("div",{className:"rounded-md border",children:[e("div",{className:"border-b bg-muted/50 px-4 py-3",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((a,t)=>e(Or,{className:"h-4 w-24"},t))})}),e("div",{children:Array.from({length:t}).map((a,t)=>e("div",{className:"border-b px-4 py-3 last:border-0",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((a,t)=>e(Or,{className:"h-4 w-20"},t))})},t))})]})})}function rn({count:t=3}){return e("div",{className:"space-y-4",children:Array.from({length:t}).map((t,r)=>a(Mt,{children:[a(Ft,{children:[e(Or,{className:"h-4 w-3/4"}),e(Or,{className:"h-3 w-1/2"})]}),e(Lt,{children:a("div",{className:"space-y-2",children:[e(Or,{className:"h-3 w-full"}),e(Or,{className:"h-3 w-2/3"})]})})]},r))})}function sn({fields:t=4}){return a("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,r)=>a("div",{className:"space-y-2",children:[e(Or,{className:"h-4 w-24"}),e(Or,{className:"h-10 w-full"})]},r)),a("div",{className:"flex justify-end space-x-2 pt-4",children:[e(Or,{className:"h-10 w-20"}),e(Or,{className:"h-10 w-20"})]})]})}function nn(){return a("div",{className:"flex items-center justify-between p-4 border-b",children:[a("div",{className:"flex items-center space-x-3",children:[e(Or,{className:"h-8 w-8 rounded-full"}),e(Or,{className:"h-6 w-32"})]}),a("div",{className:"flex items-center space-x-2",children:[e(Or,{className:"h-8 w-8"}),e(Or,{className:"h-8 w-24"})]})]})}function on(){return e("div",{className:"w-64 border-r bg-muted/10",children:a("div",{className:"p-4",children:[e(Or,{className:"h-8 w-32 mb-6"}),e("div",{className:"space-y-2",children:Array.from({length:6}).map((t,r)=>a("div",{className:"flex items-center space-x-3 p-2",children:[e(Or,{className:"h-4 w-4"}),e(Or,{className:"h-4 w-20"})]},r))})]})})}an.displayName="TableCaption";const ln={default:D,search:j,error:F};function dn({icon:t,title:r,description:s,action:n,className:i,variant:o="default"}){const l=t?()=>t:ln[o];return a("div",{className:wt("flex flex-col items-center justify-center py-12 px-4 text-center",i),children:[e("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e(l,{className:"h-8 w-8 text-muted-foreground"})}),e("h3",{className:"text-lg font-semibold mb-2",children:r}),s&&e("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),n&&e(Et,{onClick:n.onClick,variant:"outline",children:n.label})]})}const cn=$a.Provider,mn=$a.Root,un=$a.Trigger,hn=r.forwardRef(({className:a,sideOffset:t=4,...r},s)=>e($a.Content,{ref:s,sideOffset:t,className:wt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...r}));function pn({children:t,className:s}){const n=r.useRef(null),[i,o]=r.useState(!1);r.useEffect(()=>{const e=()=>{const e=n.current;e&&o(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return n.current&&a.observe(n.current),()=>a.disconnect()},[t]);const l=e("div",{ref:n,className:`truncate w-full max-w-full ${s||""}`,children:t});return i?e(cn,{delayDuration:300,children:a(mn,{children:[e(un,{asChild:!0,children:l}),e(hn,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):l}hn.displayName=$a.Content.displayName;const fn=r.forwardRef(({direction:a,onMouseDown:t,isDragging:r,className:s},n)=>{const i="horizontal"===a;return e("div",{ref:n,onMouseDown:t,className:wt("absolute z-20 select-none touch-none","transition-colors duration-150",i&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!i&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],r&&"bg-primary/30",s),children:e("div",{className:wt("rounded-full bg-border transition-colors group-hover:bg-primary",r&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});fn.displayName="TableResizeHandle";const gn=Ua.Root,bn=Ua.Trigger,vn=Ua.Group,yn=Ua.Portal,Nn=Ua.Sub,xn=Ua.RadioGroup,wn=r.forwardRef(({className:t,inset:r,children:s,...n},i)=>a(Ua.SubTrigger,{ref:i,className:wt("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",t),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));wn.displayName=Ua.SubTrigger.displayName;const kn=r.forwardRef(({className:a,...t},r)=>e(Ua.SubContent,{ref:r,className:wt("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));kn.displayName=Ua.SubContent.displayName;const Cn=r.forwardRef(({className:a,sideOffset:t=4,...r},s)=>e(Ua.Portal,{children:e(Ua.Content,{ref:s,sideOffset:t,className:wt("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...r})}));Cn.displayName=Ua.Content.displayName;const Sn=r.forwardRef(({className:a,inset:t,...r},s)=>e(Ua.Item,{ref:s,className:wt("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...r}));Sn.displayName=Ua.Item.displayName;const _n=r.forwardRef(({className:t,children:r,checked:s,...n},i)=>a(Ua.CheckboxItem,{ref:i,className:wt("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Ua.ItemIndicator,{children:e(I,{className:"h-4 w-4"})})}),r]}));_n.displayName=Ua.CheckboxItem.displayName;const Pn=r.forwardRef(({className:t,children:r,...s},n)=>a(Ua.RadioItem,{ref:n,className:wt("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Ua.ItemIndicator,{children:e(O,{className:"h-2 w-2 fill-current"})})}),r]}));Pn.displayName=Ua.RadioItem.displayName;const In=r.forwardRef(({className:a,inset:t,...r},s)=>e(Ua.Label,{ref:s,className:wt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...r}));In.displayName=Ua.Label.displayName;const En=r.forwardRef(({className:a,...t},r)=>e(Ua.Separator,{ref:r,className:wt("-mx-1 my-1 h-px bg-muted",a),...t}));En.displayName=Ua.Separator.displayName;const An=({className:a,...t})=>e("span",{className:wt("ml-auto text-xs tracking-widest opacity-60",a),...t});An.displayName="DropdownMenuShortcut";const Tn=Wa.Root,Rn=Wa.Trigger,zn=Wa.Group,Mn=Wa.Portal,Fn=Wa.Sub,jn=Wa.RadioGroup,Dn=r.forwardRef(({className:t,inset:r,children:s,...n},i)=>a(Wa.SubTrigger,{ref:i,className:wt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",t),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));Dn.displayName=Wa.SubTrigger.displayName;const Ln=r.forwardRef(({className:a,...t},r)=>e(Wa.SubContent,{ref:r,className:wt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));Ln.displayName=Wa.SubContent.displayName;const On=r.forwardRef(({className:a,...t},r)=>e(Wa.Portal,{children:e(Wa.Content,{ref:r,className:wt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t})}));On.displayName=Wa.Content.displayName;const $n=r.forwardRef(({className:a,inset:t,...r},s)=>e(Wa.Item,{ref:s,className:wt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...r}));$n.displayName=Wa.Item.displayName;const Un=r.forwardRef(({className:t,children:r,checked:s,...n},i)=>a(Wa.CheckboxItem,{ref:i,className:wt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Wa.ItemIndicator,{children:e(I,{className:"h-4 w-4"})})}),r]}));Un.displayName=Wa.CheckboxItem.displayName;const Wn=r.forwardRef(({className:t,children:r,...s},n)=>a(Wa.RadioItem,{ref:n,className:wt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Wa.ItemIndicator,{children:e(O,{className:"h-2 w-2 fill-current"})})}),r]}));Wn.displayName=Wa.RadioItem.displayName;const qn=r.forwardRef(({className:a,inset:t,...r},s)=>e(Wa.Label,{ref:s,className:wt("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...r}));qn.displayName=Wa.Label.displayName;const Vn=r.forwardRef(({className:a,...t},r)=>e(Wa.Separator,{ref:r,className:wt("-mx-1 my-1 h-px bg-border",a),...t}));Vn.displayName=Wa.Separator.displayName;const Bn=({className:a,...t})=>e("span",{className:wt("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Bn.displayName="ContextMenuShortcut";const Hn=({onEdit:r,onDelete:s,onToggleStatus:n,isActive:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d})=>{const{t:c}=Pa(),m=[];if(r){const e={icon:$,label:c("edit"),onClick:r};m.push(e)}if(l.forEach(e=>{m.push(e)}),n){const e={icon:i?U:W,label:c(i?"deactivate":"activate"),onClick:n};m.push(e)}if(o&&s){const e={icon:q,label:c("delete"),onClick:s,destructive:!0};m.push(e)}const u="dropdown"===d?Sn:$n;return e(t,{children:m.map((t,r)=>a(u,{onClick:t.onClick,className:wt("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},r))})},Kn=({onEdit:t,onDelete:r,canDelete:s=!0,onToggleStatus:n,isActive:i=!0,customActions:o=[]})=>a(gn,{children:[e(bn,{asChild:!0,children:e(Et,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e(C,{size:12})})}),e(Cn,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e(Hn,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:r?e=>{e?.stopPropagation(),r?.()}:void 0,onToggleStatus:n?e=>{e?.stopPropagation(),n?.()}:void 0,isActive:i,canDelete:s&&!!r,customActions:o,renderAs:"dropdown"})})]}),Qn=150;function Gn({columns:e,storageKey:a,onResize:t,enabled:r=!0}){const[s,i]=n(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Qn,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Qn,e),{})}),[o,l]=n(!1),[u,h]=n(null),p=m(0),f=m(0),g=d((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),h(e),p.current=a.clientX,f.current=s[e]??Qn)},[r,s]);c(()=>{if(!o||!u)return;const r=e.find(e=>e.key===u),s=r?.minWidth??60,n=r?.maxWidth??500,d=e=>{const a=e.clientX-p.current,r=Math.max(s,Math.min(n,f.current+a));i(e=>{const a={...e,[u]:r};return t?.(a),a})},c=()=>{l(!1),h(null),a&&i(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",d),document.addEventListener("mouseup",c),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",c)}},[o,u,e,a,t]),c(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const b=d(()=>{const r=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Qn,e),{});i(r),a&&localStorage.removeItem(a),t?.(r)},[e,a,t]);return{columnWidths:s,isDragging:o,activeColumn:u,handleMouseDown:g,resetWidths:b}}function Jn({rowIds:e,defaultHeight:a=48,minHeight:t=32,maxHeight:r=120,storageKey:s,onResize:i,enabled:o=!0}){const[l,u]=n(()=>{if(!o||"undefined"==typeof window)return{};if(s){const e=localStorage.getItem(s);if(e)try{return JSON.parse(e)}catch{}}return{}}),[h,p]=n(!1),[f,g]=n(null),b=m(0),v=m(0),y=d(e=>l[e]??a,[l,a]),N=d((e,t)=>{o&&(t.preventDefault(),t.stopPropagation(),p(!0),g(e),b.current=t.clientY,v.current=l[e]??a)},[o,l,a]);c(()=>{if(!h||!f)return;const e=e=>{const a=e.clientY-b.current,s=Math.max(t,Math.min(r,v.current+a));u(e=>{const a={...e,[f]:s};return i?.(a),a})},a=()=>{p(!1),g(null),s&&u(e=>(localStorage.setItem(s,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[h,f,t,r,s,i]),c(()=>{h?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[h]);const x=d(()=>{u({}),s&&localStorage.removeItem(s),i?.({})},[s,i]);return{rowHeights:l,isDragging:h,activeRow:f,handleMouseDown:N,resetHeights:x,getRowHeight:y}}const Xn=u(({checked:a,onCheckedChange:t})=>e(yr,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),Yn=({manager:t,columns:r,onEdit:s,onView:o,onToggleStatus:l,onDelete:d,renderActions:m,customRowActions:u,enableBulkActions:h=!1,onNew:p,newButtonLabel:f,showNewButton:g=!0,customActions:b=[],hideActionBar:v=!1,enableColumnResize:y=!0,resizeStorageKey:N})=>{const{t:x}=Pa(),{setSearchVisible:w}=Bs(),[k,C]=n(!1);c(()=>(w(!0),()=>w(!1)),[w]),c(()=>{const e=()=>C(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:S,isDragging:_,activeColumn:P,handleMouseDown:I}=Gn({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,enabled:y}),{isDragging:E,activeRow:A,handleMouseDown:T,getRowHeight:R}=Jn({rowIds:t.entities.map(e=>e.id),storageKey:N?`${N}-rows`:void 0,enabled:!1}),z=i(()=>(()=>{if(y)return r.map(e=>{const a=S[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=r.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,r=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:r,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[r,y,S]),M=!v&&(p||b.length>0);return k?t.isLoading?e(rn,{count:3}):0===t.entities.length?e(dn,{title:x("empty_title"),description:x("empty_description"),variant:"search"}):a("div",{className:"flex flex-col h-full",children:[M&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:a("div",{className:"flex items-center gap-2",children:[p&&g&&a(Et,{onClick:p,children:[e(V,{size:16,className:"mr-2"}),f||x("new")]}),b.map((t,r)=>{const s=t.icon;return a(Et,{onClick:t.action,variant:t.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),t.label]},r)})]})}),e("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(n=>a(Tn,{children:[e(Rn,{asChild:!0,children:e(Mt,{className:wt("overflow-hidden cursor-pointer hover:bg-muted/50",h&&t.selectedIds.includes(n.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),h?t.selectItem(n.id):s?.(n)},children:e(Lt,{className:"p-4",children:a("div",{className:"flex items-start gap-3",children:[h&&e("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e(Xn,{checked:t.selectedIds.includes(n.id),onCheckedChange:()=>t.selectItem(n.id)})}),a("div",{className:"flex-1",children:[r.map(t=>a("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[a("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),e("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(n):String(n[t.key]??"")})]},String(t.key))),(s||o||m)&&e("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:m?m(n):e(Kn,{onEdit:s?()=>{s(n)}:void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,customActions:u?u(n):[]})})]})]})})})}),e(On,{className:"w-[160px]",children:e(Hn,{onEdit:s?()=>s(n):void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,canDelete:!!d,customActions:u?u(n):[],renderAs:"context"})})]},n.id))})]}):a("div",{className:"flex flex-col h-full",children:[M&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:a("div",{className:"flex items-center gap-2",children:[p&&g&&a(Et,{onClick:p,children:[e(V,{size:16,className:"mr-2"}),f||x("new")]}),b.map((t,r)=>{const s=t.icon;return a(Et,{onClick:t.action,variant:t.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),t.label]},r)})]})}),t.isLoading?e(tn,{rows:5,columns:r.length}):e("div",{className:"flex flex-col h-full overflow-hidden",children:e("div",{className:"flex-1 overflow-auto",children:a(Qs,{className:"table-auto",children:[a("colgroup",{children:[h&&e("col",{style:{width:"50px"}}),z.map((a,t)=>e("col",{style:a.style},t)),e("col",{style:{width:"50px"}})]}),e(Gs,{children:a(Ys,{children:[h&&e(Zs,{className:"w-[50px]",children:e(Xn,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),r.map(r=>{const s=y&&!1!==r.resizable,n=P===String(r.key);return a(Zs,{className:wt(r.className,r.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:r.sortable?()=>t.handleSort(String(r.key)):void 0,children:[a("div",{className:"flex items-center "+(r.className?.includes("text-center")?"justify-center":""),children:[r.header,r.sortable&&(i=String(r.key),t.sortField!==i?e(B,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e(H,{size:14,className:"ml-1"}):e(K,{size:14,className:"ml-1"}))]}),s&&e(fn,{direction:"horizontal",onMouseDown:e=>I(String(r.key),e),isDragging:n})]},String(r.key));var i}),e(Zs,{className:"w-[50px] text-center",children:x("actions")})]})}),e(Js,{children:0===t.entities.length?e(Ys,{children:e(en,{colSpan:h?r.length+2:r.length+1,className:"h-32",children:e(dn,{title:x("empty_title"),description:x("empty_description"),variant:"search"})})}):t.entities.map(n=>{const i=R(n.id);return n.id,a(Tn,{children:[e(Rn,{asChild:!0,children:a(Ys,{className:wt("cursor-pointer hover:bg-muted/50 relative",h&&t.selectedIds.includes(n.id)&&"bg-muted"),style:i?{height:`${i}px`}:void 0,onClick:e=>{e.stopPropagation(),h?t.selectItem(n.id):s?.(n)},children:[h&&e(en,{onClick:e=>e.stopPropagation(),children:e(Xn,{checked:t.selectedIds.includes(n.id),onCheckedChange:()=>t.selectItem(n.id)})}),r.map(a=>e(en,{className:a.className,children:e(pn,{children:a.render?a.render(n):String(n[a.key]??"")})},String(a.key))),e(en,{className:"text-center",children:m?m(n):e(Kn,{onEdit:s?()=>s(n):void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,customActions:u?u(n):[]})})]})}),e(On,{className:"w-[160px]",children:e(Hn,{onEdit:s?()=>s(n):void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,canDelete:!!d,customActions:u?u(n):[],renderAs:"context"})})]},n.id)})})]})})})]})};function Zn(e,a,t,r){const[s,o]=n({}),[l,d]=n({}),m=i(()=>e,[e]),u=e=>e instanceof Date&&!isNaN(e.getTime()),h=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},p=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return h(e)}},f=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let s;if("function"==typeof e.validation?s=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(s=e.validation.custom),s)try{const e=s(a,t);if(e)return e}catch(r){}}};c(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},s=e(m),n={};s.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);u(e)&&(t=e.toISOString().split("T")[0])}else u(t)&&(t=t.toISOString().split("T")[0])}else t=h(e);n[e.name]=t}),s.forEach(e=>{const a=p(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{s.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),d({}),t&&t(n)},[m,a,t,r]);const g=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...g(e.fields))}),a},b=()=>{const e=g(m),a={};return e.forEach(e=>{const t=f(e,s[e.name],s);t&&(a[e.name]=t)}),d(a),0===Object.keys(a).length};return{formData:s,errors:l,updateField:(e,a)=>{o(r=>{const s={...r,[e]:a},n=((e,a)=>{let t={...a};const r=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...r(e.fields))}),a};return r(m).filter(a=>a.dependsOn===e).forEach(e=>{const a=p(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,s);return t&&t(n),n}),l[e]&&d(a=>{const t={...a};return delete t[e],t});const r=g(m).find(a=>a.name===e);if(r){const t=f(r,a,s);t&&d(a=>({...a,[e]:t}))}},validateForm:b,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),b()&&e(s)}}}const ei=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],ai=({value:t="#3b82f6",onChange:r,label:s})=>a("div",{className:"space-y-2",children:[s&&e(zt,{children:s}),a(Pr,{children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e(Er,{className:"w-64",children:a("div",{className:"space-y-3",children:[a("div",{children:[e(zt,{htmlFor:"color-input",children:"Cor personalizada"}),e(Tt,{id:"color-input",type:"color",value:t,onChange:e=>r?.(e.target.value),className:"h-10 w-full"})]}),a("div",{children:[e(zt,{children:"Cores predefinidas"}),e("div",{className:"grid grid-cols-5 gap-2 mt-2",children:ei.map(a=>e("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>r?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),ti=r.forwardRef(({className:t,children:r,...s},n)=>a(qa.Root,{ref:n,className:wt("relative overflow-hidden",t),...s,children:[e(qa.Viewport,{className:"h-full w-full rounded-[inherit]",children:r}),e(ri,{}),e(qa.Corner,{})]}));ti.displayName=qa.Root.displayName;const ri=r.forwardRef(({className:a,orientation:t="vertical",...r},s)=>e(qa.ScrollAreaScrollbar,{ref:s,orientation:t,className:wt("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...r,children:e(qa.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ri.displayName=qa.ScrollAreaScrollbar.displayName;const si={Star:Le,Heart:De,Home:je,User:Fe,Settings:Me,Mail:ze,Phone:Re,Calendar:Te,MapPin:Ae,Camera:Ee,Image:Ie,Music:Pe,Video:_e,Book:Se,Bookmark:Ce,Search:j,Filter:ke,Edit:$,Trash2:q,Plus:V,Minus:we,Check:I,X:S,ChevronDown:_,ChevronUp:P,ChevronLeft:xe,ChevronRight:L,ArrowUp:H,ArrowDown:K,ArrowLeft:Ne,ArrowRight:ye,Clock:ve,Bell:be,AlertCircle:F,Info:ge,HelpCircle:fe,Download:pe,Upload:he,Share:ue,Copy:me,Save:ce,FileText:de,Folder:le,FolderOpen:oe,Archive:ie,Lock:ne,Unlock:se,Eye:re,EyeOff:te,Shield:ae,Key:ee,Zap:Z,Flame:Y,Sparkles:X,Award:J,Trophy:G,Target:Q},ni=({value:t="Star",onChange:r,label:s})=>{const{t:i}=Pa(),[o,l]=n(""),d=Object.entries(si).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),c=si[t]||Le;return a("div",{className:"space-y-2",children:[s&&e(zt,{children:s}),a(Pr,{children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e(c,{className:"h-4 w-4 mr-2"}),t]})}),e(Er,{className:"w-80",children:a("div",{className:"space-y-3",children:[a("div",{children:[e(zt,{htmlFor:"icon-search",children:i("search")}),e(Tt,{id:"icon-search",placeholder:i("search"),value:o,onChange:e=>l(e.target.value)})]}),e(ti,{className:"h-48",children:e("div",{className:"grid grid-cols-6 gap-2",children:d.map(([a,s])=>e("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>r?.(a),title:a,children:e(s,{className:"h-4 w-4"})},a))})})]})})]})]})},ii=r.forwardRef(({className:a,...t},r)=>e(Va.Root,{className:wt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a),...t,ref:r,children:e(Va.Thumb,{className:wt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));ii.displayName=Va.Root.displayName;const oi=(e={})=>{const{user:a,alias:t}=Bs(),{enabled:r=!0}=e;return Ra({queryKey:["qualiex-users",t],queryFn:()=>vs.getUsers(t),enabled:r&&!!t&&!!a,retry:2,retryDelay:1e3})},li=({value:a,onChange:t,multiple:r=!1,label:s,required:n,placeholder:o,icon:l,maxDisplayedBadges:c,className:m,disabled:u,enabled:h,displayFormat:p="name",customDisplayFn:f,filterFn:g,sortOptions:b=!0,popoverContainer:v,onOpen:y,onClose:N})=>{const{t:x}=Pa(),{data:w=[],isLoading:k,error:C}=oi({enabled:h}),S=i(()=>g?w.filter(g):w,[w,g]),_=d(e=>{if("custom"===p&&f)return f(e);const a=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${a} (${e.userEmail})`:a;case"name-role":return e.roleName?`${a} - ${e.roleName}`:a;default:return a}},[p,f]);return e(Wr,{multiple:r,value:a??(r?[]:""),onChange:t,options:S,isLoading:k,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:_,placeholder:o||x("search_placeholder"),searchPlaceholder:x("search_placeholder"),emptyMessage:x("no_results"),label:s,required:n,icon:l,maxDisplayedBadges:c,disabled:u,className:m,sortOptions:b,popoverContainer:v,onOpen:y,onClose:N})};function di({title:t,sections:r,initialData:o,onSubmit:l,onCancel:c,open:u,submitButtonText:h,isLoading:p=!1,usersData:f}){const{t:g}=Pa(),[b,v]=n(r?.[0]?.id||""),y=m(null),[N,x]=n(null),w=d(e=>{y.current=e,x(e)},[]),k=i(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:C,errors:S,updateField:_,handleSubmit:P}=Zn(k,o,void 0,u),I=i(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(C):e.disabled||!1})):[],[r,C]),E=i(()=>{const e=I.find(e=>e.id===b);if(e&&!e.disabled)return b;const a=I.find(e=>!e.disabled);return a?.id||b},[I,b]);s.useEffect(()=>{E!==b&&v(E)},[E,b]);const A=I.find(e=>e.id===E),T=t=>{const r=(t.computedValue,C[t.name]),s=void 0!==r?r:"",n=S[t.name];switch(t.type){case"group":const r="horizontal"===t.layout,i=r?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=r?wt("space-y-2 w-full",t.wrapperClassName):wt("space-y-2",t.className,t.wrapperClassName);return a("div",{className:o,children:[t.label,e("div",{className:i,children:t.fields?.map(e=>T(e))})]},t.name);case"user-select":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(li,{value:s||"",onChange:e=>_(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"textarea":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Nr,{id:t.name,value:s||"",onChange:e=>{_(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"select":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a(dr,{value:String(s),onValueChange:e=>{_(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e(ur,{className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e(mr,{placeholder:t.placeholder})}),e(fr,{children:t.options?.map(a=>e(br,{value:a.value,children:a.label},a.value))})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"multiselect":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Wr,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>_(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:n,popoverContainer:N,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"date":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Tt,{id:t.name,type:"date",value:String(s),onChange:e=>_(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:wt("w-full",n?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"color":return a("div",{children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Tt,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>_(t.name,e.target.value),className:"h-10"}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},t.name);case"color-picker":return a("div",{children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ai,{value:s||t.defaultValue||"#3b82f6",onChange:e=>_(t.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},t.name);case"icon-picker":return a("div",{children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ni,{value:s||t.defaultValue||"Star",onChange:e=>_(t.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},t.name);case"custom":if(!t.component)return null;const l=t.component,d="function"==typeof t.componentProps?t.componentProps(C):t.componentProps||{};return a("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(l,{value:s,onChange:e=>{_(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:n,popoverContainer:N,...d}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"number":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Tt,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,r=""===a?null:Number(a);_(t.name,r)},placeholder:t.placeholder,disabled:t.disabled,className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"checkbox":return a("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e(yr,{id:t.name,checked:!!s,onCheckedChange:e=>_(t.name,e),disabled:t.disabled}),a(zt,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"switch":return a("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ii,{id:t.name,checked:!!s,onCheckedChange:e=>_(t.name,e),disabled:t.disabled}),n&&e("p",{className:"text-sm text-destructive mt-2",children:n})]},t.name);default:return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Tt,{id:t.name,type:"text",value:s||"",onChange:e=>{_(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name)}},R=d(()=>{if(!A)return null;if(A.disabled)return a("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e("div",{className:"rounded-full bg-muted p-3 mb-4",children:e("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(A.component){const a=A.component;return e(a,{formData:C,updateField:_,errors:S,users:f,disabled:A.disabled})}return e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:A.fields.map(T)})},[A,C,_,S,f,T]),z=a("div",{className:"flex flex-col max-h-[80vh]",children:[I.length>1&&e("div",{className:"flex-shrink-0 p-4 border-b",children:e("div",{className:"flex space-x-2",children:I.map(a=>e(Et,{variant:E===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=I.find(a=>a.id===e);a&&!a.disabled&&v(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:p?e("div",{className:"flex items-center justify-center py-12",children:e("div",{className:"text-muted-foreground",children:g("loading")})}):a("form",{onSubmit:P(l),className:"space-y-3 md:space-y-4",children:[R(),a("div",{className:"flex justify-end space-x-2 pt-4",children:[e(Et,{type:"button",variant:"outline",onClick:c,children:g("cancel")}),e(Et,{type:"submit",disabled:p,children:h||g("save")})]})]})})]});return e(Ut,{open:u,onOpenChange:e=>{!1===e&&!0===u&&c()},children:a(Kt,{ref:w,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[a(Qt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e(Xt,{children:t}),e(Yt,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),z]})})}function ci({currentPage:r,totalPages:s,totalItems:n,itemsPerPage:i,onPageChange:o,onItemsPerPageChange:l,variant:d="full"}){const c=(r-1)*i+1,m=Math.min(r*i,n);return a("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e("div",{className:"flex items-center gap-2",children:"full"===d&&a(t,{children:[e("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),a(dr,{value:String(i),onValueChange:e=>l(Number(e)),children:[e(ur,{className:"h-8 w-[70px]",children:e(mr,{})}),a(fr,{children:[e(br,{value:"10",children:"10"}),e(br,{value:"25",children:"25"}),e(br,{value:"50",children:"50"}),e(br,{value:"100",children:"100"})]})]})]})}),a("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",m," de ",n," itens"]}),a("div",{className:"flex items-center gap-1",children:[e(Et,{variant:"outline",size:"sm",onClick:()=>o(1),disabled:1===r,className:"h-8 w-8 p-0",children:e(Oe,{size:16})}),e(Et,{variant:"outline",size:"sm",onClick:()=>o(r-1),disabled:1===r,className:"h-8 w-8 p-0",children:e(xe,{size:16})}),a("div",{className:"flex items-center gap-1 px-2",children:[e("span",{className:"text-sm font-medium",children:r}),e("span",{className:"text-sm text-muted-foreground",children:"de"}),e("span",{className:"text-sm font-medium",children:s})]}),e(Et,{variant:"outline",size:"sm",onClick:()=>o(r+1),disabled:r===s,className:"h-8 w-8 p-0",children:e(L,{size:16})}),e(Et,{variant:"outline",size:"sm",onClick:()=>o(s),disabled:r===s,className:"h-8 w-8 p-0",children:e($e,{size:16})})]})]})}function mi({manager:a}){return e(ci,{currentPage:a.pagination.currentPage,totalPages:a.pagination.totalPages,totalItems:a.pagination.totalItems,itemsPerPage:a.pagination.itemsPerPage,onPageChange:a.handlePageChange,onItemsPerPageChange:a.handleItemsPerPageChange,variant:"full"})}const ui=({selectedCount:t,onClearSelection:r,onBulkDelete:s,customActions:n=[],isLoading:i=!1})=>{const{t:o}=Pa();return a("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[a("div",{className:"flex items-center gap-3",children:[e("span",{className:"text-sm font-medium",children:o("selected_count",{count:t})}),a(Et,{variant:"ghost",size:"sm",onClick:r,className:"h-7 px-2",children:[e(S,{size:14,className:"mr-1"}),o("clear")]})]}),a("div",{className:"flex items-center gap-2",children:[n.map((t,r)=>{const s=t.icon;return a(Et,{variant:t.variant||"outline",size:"sm",onClick:()=>t.action([]),disabled:i,className:"h-7",children:[s&&e(s,{size:14,className:"mr-1"}),t.label]},r)}),s&&a(Et,{variant:"destructive",size:"sm",onClick:s,disabled:i,className:"h-7",children:[e(q,{size:14,className:"mr-1"}),o("delete")]})]})]})},hi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},pi={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},fi={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function gi({children:a,direction:t="column",gap:r="md",align:s="stretch",justify:n="start",wrap:i=!1,className:o}){return e("div",{className:wt("flex","column"===t?"flex-col":"flex-row",hi[r],pi[s],fi[n],i&&"flex-wrap",o),children:a})}function bi({manager:r,filters:s,inline:n=!1}){const{t:i}=Pa(),{isSearchVisible:o}=Bs(),l=r.searchTerm,d=a(t,{children:[s.some(e=>"search"===e.type)&&!o&&a("div",{className:"relative flex-1",children:[e(j,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e(Tt,{placeholder:i("search"),value:r.searchTerm,onChange:e=>r.handleSearch(e.target.value),className:"pl-10"})]}),s.filter(e=>"select"===e.type&&e.options).map((t,r)=>a("select",{value:t.value||"",onChange:e=>t.onChange?.(e.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[t.placeholder&&e("option",{value:"",children:t.placeholder}),t.options.map(a=>e("option",{value:a.value,children:a.label},a.value))]},`select-${r}`)),s.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e("div",{className:n?"":"w-full sm:w-auto",children:e(r,{...a.props})},`custom-${t}`)}),l&&a(Et,{variant:"outline",onClick:r.clearFilters,className:"whitespace-nowrap",children:[e(S,{className:"h-4 w-4 mr-2"}),i("clear")]})]});return n?e("div",{className:"flex items-center gap-2",children:d}):e(gi,{direction:"column",gap:"md",className:"mb-6",children:e(gi,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:d})})}function vi({manager:t,config:r,formSections:s,onSave:i,onToggleStatus:o,defaultSort:l}){t&&t.queryKey;const{t:d}=Pa(),{setSearchVisible:m}=Bs(),[u,h]=ja(),[p,f]=n(!1),[g,b]=n(null),[v,y]=n({isOpen:!1,entityId:null,entityName:""}),[N,x]=n({isOpen:!1,count:0});c(()=>(m(!0),()=>{m(!1)}),[m]),c(()=>{if(l&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=l.column,t[a]=l.direction,h(t)}}},[]);const w=()=>{y({isOpen:!1,entityId:null,entityName:""})};return a("div",{className:"flex-1 flex flex-col h-full",children:[r.enableBulkActions&&t.selectedIds.length>0&&e(ui,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:r.bulkActions&&r.bulkActions.length>0?void 0:()=>{x({isOpen:!0,count:t.selectedIds.length})},customActions:r.bulkActions,isLoading:t.isBulkDeleting}),a("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[a("div",{className:"flex items-center gap-2",children:[a(Et,{onClick:()=>{r.onNew?r.onNew():(b(null),f(!0))},children:[e(V,{size:16,className:"mr-2"}),d("new")]}),r.customActions?.map((t,r)=>a(Et,{onClick:t.action,variant:t.variant||"outline",children:[t.icon&&e(t.icon,{size:16,className:"mr-2"}),t.label]},r))]}),r.filters&&r.filters.length>0&&e("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e(bi,{manager:t,filters:r.filters,inline:!0})})]}),e("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?e("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(t.entities,t)}):e(Yn,{manager:t,columns:r.columns,onEdit:e=>{r.onEdit?r.onEdit(e):(b(e),f(!0))},onDelete:e=>{y({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:o,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions})}),e("div",{className:"flex-shrink-0 border-t bg-background",children:e(mi,{manager:t})}),!r.useCustomRouting&&e(di,{open:p,title:g?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:g||void 0,onSubmit:e=>{i(e),f(!1),b(null)},onCancel:()=>{f(!1),b(null)},isLoading:t.isLoading,submitButtonText:d(g?"update":"create")}),e(Ut,{open:v.isOpen,onOpenChange:w,children:a(Kt,{size:"sm",children:[e(Qt,{showSeparator:!0,children:e(Xt,{children:"Você tem certeza absoluta?"})}),e("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e("strong",{children:v.entityName}),". Esta ação não pode ser desfeita."]})}),a(Jt,{children:[e(Et,{variant:"outline",onClick:w,children:"Cancelar"}),e(Et,{variant:"destructive",onClick:()=>{v.entityId&&(t.deleteEntity(v.entityId),y({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e(Ut,{open:N.isOpen,onOpenChange:()=>x({isOpen:!1,count:0}),children:a(Kt,{size:"sm",children:[e(Qt,{showSeparator:!0,children:e(Xt,{children:"Você tem certeza absoluta?"})}),e("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e("strong",{children:N.count})," ",1===N.count?r.entityName:r.entityNamePlural,". Esta ação não pode ser desfeita."]})}),a(Jt,{children:[e(Et,{variant:"outline",onClick:()=>x({isOpen:!1,count:0}),children:"Cancelar"}),e(Et,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),x({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function yi(a){return({manager:t})=>{const{manager:r,config:s,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??r,d={entityName:s.entityName,entityNamePlural:s.entityNamePlural,filters:s.filters||[],columns:s.columns,cardFields:s.cardFields||[],enableBulkActions:s.enableBulkActions??!1,bulkActions:s.bulkActions||[],customActions:s.customActions,customRowActions:s.customRowActions,customListView:s.customListView,onEdit:i||s.onEdit};return e(vi,{manager:l,config:d,formSections:s.formSections,onSave:n,onToggleStatus:o,defaultSort:s.defaultSort})}}function Ni(e,a,t){return r=>{if(r.id){const a=t(r);e.updateEntity(r.id,a)}else{const t=a(r);e.createEntity(t)}}}function xi(e,a,t={}){const r=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],s={key:e,header:ki(e),label:ki(e),...wi(e,t),sortable:!0,searchable:"string"==typeof t};r.push(s)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}}function wi(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function ki(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Ci=r.forwardRef(({className:a,value:t,...r},s)=>e(Ba.Root,{ref:s,className:wt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...r,children:e(Ba.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));function Si({steps:t,currentStepIndex:r,onStepClick:s,className:n}){return e("div",{className:wt("flex items-center justify-between mb-6",n),children:t.map((r,n)=>a("div",{className:"flex items-center flex-1",children:[e("div",{className:wt("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",r.isActive&&"border-primary bg-primary text-primary-foreground",r.isCompleted&&"border-primary bg-primary text-primary-foreground",!r.isActive&&!r.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!r.isDisabled&&"cursor-pointer hover:border-primary/50",r.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!r.isDisabled&&s(n),role:s&&!r.isDisabled?"button":void 0,tabIndex:s&&!r.isDisabled?0:void 0,"aria-label":`${r.label} - ${r.isCompleted?"Completo":r.isActive?"Atual":"Pendente"}`,children:r.isCompleted?e(I,{className:"w-5 h-5"}):n+1}),n<t.length-1&&e("div",{className:wt("flex-1 h-0.5 mx-2 transition-colors",r.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},r.id))})}function _i({steps:t,currentStepIndex:r,onStepClick:s,className:n}){return e("div",{className:wt("flex items-center gap-2 mb-6 overflow-x-auto",n),children:t.map((r,n)=>a("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[a("div",{className:wt("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",r.isActive&&"bg-primary text-primary-foreground font-medium",r.isCompleted&&"bg-primary/10 text-primary",!r.isActive&&!r.isCompleted&&"bg-muted text-muted-foreground",s&&!r.isDisabled&&"cursor-pointer hover:bg-primary/20",r.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!r.isDisabled&&s(n),role:s&&!r.isDisabled?"button":void 0,tabIndex:s&&!r.isDisabled?0:void 0,"aria-label":`${r.label} - ${r.isCompleted?"Completo":r.isActive?"Atual":"Pendente"}`,children:[e("span",{className:"text-sm font-medium",children:n+1}),e("span",{className:"text-sm",children:r.label}),r.isCompleted&&e(I,{className:"w-4 h-4 ml-1"})]}),n<t.length-1&&e("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},r.id))})}function Pi({steps:t,currentStepIndex:r,className:s}){const n=t[r],i=(r+1)/t.length*100;return a("div",{className:wt("mb-6 space-y-2",s),children:[a("div",{className:"flex items-center justify-between text-sm",children:[a("span",{className:"text-muted-foreground",children:["Etapa ",r+1," de ",t.length]}),e("span",{className:"font-medium",children:n?.label})]}),e(Ci,{value:i,className:"h-2"})]})}function Ii({isFirstStep:r,isLastStep:s,canGoNext:n,canGoPrevious:i,isLoading:o,onPrevious:l,onNext:d,onSubmit:c,previousButtonText:m,nextButtonText:u,submitButtonText:h}){const{t:p}=Pa();return a(t,{children:[e("div",{children:i&&!r&&e(Et,{type:"button",variant:"outline",onClick:l,disabled:o,children:m||p("previous")})}),a("div",{className:"flex gap-2",children:[n&&!s&&e(Et,{type:"button",onClick:d,disabled:o,children:u||p("next")}),s&&e(Et,{type:"button",onClick:c,disabled:o,children:o?p("saving"):h||p("save")})]})]})}function Ei({title:t,sections:r,initialData:o,onSubmit:l,onCancel:c,open:u,submitButtonText:h,isLoading:p=!1,usersData:f,showProgressIndicator:g=!0,progressType:b="stepper",validateOnNext:v=!0,allowSkipSections:y=!1,previousButtonText:N,nextButtonText:x,onStepChange:w,onStepValidationFail:k,renderProgressIndicator:C,renderButtons:S,currentStepIndex:_,onCurrentStepChange:P}){const[I,E]=n(0),A=_??I,T=P??E,R=m(null),[z,M]=n(null),F=d(e=>{R.current=e,M(e)},[]),j=i(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:D,errors:L,updateField:O,handleSubmit:$}=Zn(j,o,void 0,u);s.useEffect(()=>{u&&T(0)},[u,T]);const U=d(()=>{const e=r[A];if(!e)return!0;const a=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),t={};let s=!0;return a.forEach(e=>{const a=D[e.name];if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(t[e.name]=`${e.label} é obrigatório`,s=!1),e.validation&&"function"==typeof e.validation){const r=e.validation(a,D);r&&(t[e.name]=r,s=!1)}}),!s&&k&&k(A,t),s},[r,A,D,k]),W=d(()=>{if(v&&!U())return;const e=A+1;e<r.length&&(T(e),w?.(e,r[e].id))},[A,r,v,U,T,w]),q=d(()=>{const e=A-1;e>=0&&(T(e),w?.(e,r[e].id))},[A,r,T,w]),V=d(()=>{let e=!0;for(let a=0;a<r.length;a++){r[a].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(a=>{const t=D[a.name];a.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(e=!1)})}e&&$(l)()},[r,D,$,l]),B=i(()=>r.map((e,a)=>({index:a,id:e.id,label:e.label||e.id,isActive:a===A,isCompleted:a<A,isDisabled:e.disabled||!1})),[r,A]),H=0===A,K=A===r.length-1,Q=i(()=>{if(!g)return null;if(C)return C(A,r.length,r);const a=y?e=>{T(e),w?.(e,r[e].id)}:void 0;switch(b){case"breadcrumb":return e(_i,{steps:B,currentStepIndex:A,onStepClick:a});case"progressbar":return e(Pi,{steps:B,currentStepIndex:A});default:return e(Si,{steps:B,currentStepIndex:A,onStepClick:a})}},[g,C,b,B,A,r,y,T,w]),G=i(()=>{const a={isFirstStep:H,isLastStep:K,canGoNext:A<r.length-1,canGoPrevious:A>0,isLoading:p,onPrevious:q,onNext:W,onSubmit:V,previousButtonText:N,nextButtonText:x,submitButtonText:h};return S?S(a):e(Ii,{...a})},[H,K,A,r.length,p,q,W,V,N,x,h,S]),J=t=>{const r=(t.computedValue,D[t.name]),s=void 0!==r?r:"",n=L[t.name];switch(t.type){case"group":return a("div",{className:"space-y-2",children:[t.label&&e(zt,{className:"text-sm font-medium",children:t.label}),e("div",{className:wt("grid gap-4",1===t.columns&&"grid-cols-1",2===t.columns&&"grid-cols-1 md:grid-cols-2",3===t.columns&&"grid-cols-1 md:grid-cols-3",4===t.columns&&"grid-cols-1 md:grid-cols-4",!t.columns&&"grid-cols-1"),children:t.fields?.map(e=>J(e))})]},t.name);case"number":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Tt,{id:t.name,type:"number",value:s,onChange:e=>O(t.name,""===e.target.value?"":Number(e.target.value)),placeholder:t.placeholder,disabled:t.disabled||void 0!==t.computedValue,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"textarea":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Nr,{id:t.name,value:s,onChange:e=>O(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,rows:t.rows||3,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"select":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a(dr,{value:s,onValueChange:e=>O(t.name,e),children:[e(ur,{className:n?"border-destructive":"",children:e(mr,{placeholder:t.placeholder||`Selecione ${t.label}`})}),e(fr,{children:t.options?.map(a=>e(br,{value:String(a.value),children:a.label},a.value))})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"multiselect":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Wr,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>O(t.name,e),placeholder:t.placeholder,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"color":case"color-picker":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ai,{value:s,onChange:e=>O(t.name,e),label:""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"icon-picker":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ni,{value:s,onChange:e=>O(t.name,e),label:""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"user-select":return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(li,{value:s,onChange:e=>O(t.name,e),placeholder:t.placeholder,disabled:t.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"custom":return t.render?a("div",{className:"space-y-2",children:[t.label&&a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t.render({value:s,onChange:e=>O(t.name,e),error:n,disabled:t.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name):null;default:return a("div",{className:"space-y-2",children:[a(zt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Tt,{id:t.name,type:t.type||"text",value:s,onChange:e=>O(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled||void 0!==t.computedValue,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name)}},X=r[A];return e(Ut,{open:u,onOpenChange:c,children:a(Kt,{ref:F,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e(Qt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e(Xt,{className:"text-white",children:t})}),Q,e("div",{className:"space-y-4 py-4",children:X?.fields.map(e=>J(e))}),e("div",{className:"flex justify-between pt-4 border-t",children:G})]})})}Ci.displayName=Ba.Root.displayName;const Ai=({children:r})=>{const{isAuthenticated:n,isLoading:i}=Bs();if(s.useEffect(()=>{if(!n)return;const e=()=>{Yr.areAllTokensValid()||Ws.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[n]),s.useEffect(()=>{if(i)return;if(n)return;if(Yr.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const r=ws();(async()=>{r?await Ws.loginDev():Ws.loginProd()})()},[n,i]),i)return e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Mt,{className:"w-full max-w-md",children:[e(Ft,{className:"text-center",children:e(jt,{className:"text-xl font-semibold",children:"Carregando..."})}),a(Lt,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){const t=new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token");return e("div",t?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Mt,{className:"w-full max-w-md",children:[e(Ft,{className:"text-center",children:e(jt,{className:"text-xl font-semibold",children:"Processando..."})}),a(Lt,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Mt,{className:"w-full max-w-md",children:[e(Ft,{className:"text-center",children:e(jt,{className:"text-xl font-semibold",children:"Iniciando..."})}),a(Lt,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:ws()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e(t,{children:r})},Ti=f("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),Ri={info:ge,warning:ge,danger:We,success:Ue},zi=r.forwardRef(({className:t,variant:r="info",showIcon:s=!0,children:n,...i},o)=>{const l=Ri[r||"info"];return a("div",{ref:o,role:"alert",className:wt(Ti({variant:r}),t),...i,children:[s&&e(l,{className:"h-4 w-4"}),n]})});zi.displayName="Alert";const Mi=r.forwardRef(({className:a,...t},r)=>e("h5",{ref:r,className:wt("mb-1 font-medium leading-none tracking-tight",a),...t}));Mi.displayName="AlertTitle";const Fi=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("text-sm [&_p]:leading-relaxed",a),...t}));Fi.displayName="AlertDescription";const ji=()=>{const{processCallback:r}=Bs(),[s,i]=n(null),[o,l]=n(!1);c(()=>{(async()=>{try{if(await r()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else i("Falha na autenticação. Tente novamente.")}catch(e){i(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[r]);const d=async()=>{l(!0),i(null);try{await r()||i("Falha na autenticação. Tente novamente.")}catch(e){i(e?.message||"Erro ao tentar novamente.")}finally{l(!1)}},m=()=>{window.location.href="/"};return e("div",s?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Mt,{className:"w-full max-w-md",children:[e(Ft,{className:"text-center",children:a(jt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e(F,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),a(Lt,{className:"space-y-4",children:[e(zi,{variant:"danger",children:e(Fi,{children:s})}),e("div",{className:"text-sm text-muted-foreground",children:e("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),a("div",{className:"flex gap-2",children:[e(Et,{onClick:d,disabled:o,className:"flex-1",children:a(t,o?{children:[e(Cr,{size:"sm",className:"mr-2"}),"Tentando..."]}:{children:[e(qe,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e(Et,{onClick:m,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Mt,{className:"w-full max-w-md",children:[e(Ft,{className:"text-center",children:e(jt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),a(Lt,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(Cr,{size:"lg"})}),e("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},Di=()=>e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Mt,{className:"w-full max-w-md",children:[e(Ft,{className:"text-center",children:e(jt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),a(Lt,{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e(Et,{onClick:async()=>{ws()?await Ws.loginDev():Ws.loginProd()},className:"w-full",size:"lg",children:ws()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Li=o(void 0);function Oi({children:a,actions:t}){const[r,s]=n({}),[i,o]=n(t);return c(()=>{o(t)},[t]),e(Li.Provider,{value:{metadata:r,setMetadata:s,clearMetadata:()=>s({}),headerActions:i,setHeaderActions:o},children:a})}function $i(){const e=l(Li);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function Ui(e){const{setMetadata:a,clearMetadata:t}=$i();c(()=>(a(e),()=>t()),[e.title,e.subtitle,a,t])}function Wi(e){return{queryClient:e.queryClient||new Ma({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const qi=import.meta.env.VITE_SUPABASE_URL,Vi=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;let Bi=null;var Hi=Object.defineProperty,Ki=(e,a,t)=>((e,a,t)=>a in e?Hi(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Qi=new class{constructor(){Ki(this,"cache",{}),Ki(this,"cacheTimestamps",new Map),Ki(this,"CACHE_TTL",3e5),Ki(this,"loadingPromises",new Map)}isCacheValid(e){const a=this.cacheTimestamps.get(e);return!!a&&Date.now()-a<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const a=this.loadingPromises.get(e);if(a)return a;const t=this.fetchTranslations(e);this.loadingPromises.set(e,t);try{return await t}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const a=(!Bi&&qi&&Vi&&(Bi=Aa(qi,Vi,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Bi),{data:t,error:r}=await a.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(r)return"42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied")||r.message?.includes("No suitable key"),{};const s={};return t?.forEach(a=>{let t;t="pt-BR"===e?a.pt:"en-US"===e?a.en||a.pt:"es-ES"===e&&a.es||a.pt,t&&(s[a.key]=t)}),this.cache[e]=s,this.cacheTimestamps.set(e,Date.now()),s}catch(a){return{}}}async upsertTranslation(e,a,t,r){const s=ls(),{error:n}=await s.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:r},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=ls(),{error:t}=await a.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(t)throw t;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var Gi=Object.defineProperty,Ji=(e,a,t)=>((e,a,t)=>a in e?Gi(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Xi="true"===import.meta.env.VITE_I18N_DEBUG_MODE;x.use(new class{constructor(e=!1){Ji(this,"type","backend"),Ji(this,"isDebugMode"),Ji(this,"cache",new Map),Ji(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,a,t){if(this.cache.has(e))return void t(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{t(null,this.cache.get(e)||{})});const r=Qi.loadTranslations(e).then(a=>{if(this.isDebugMode){const t={};Object.keys(a).forEach(e=>{t[e]=`[${e} ✅]`}),this.cache.set(e,t)}else this.cache.set(e,a)}).catch(a=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,r),r.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,r){}}(Xi)).use(Ia).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Xi?`[${e} ❌]`:`[⚠️ ${e}]`});const Yi=new class{async getUserPreferences(e,a){if(!Yr.areAllTokensValid())return null;const t=ls();try{const{data:r,error:s}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(s)return"PGRST116"===s.code?this.createDefaultPreferences(e,a):("42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied"),null);if(!r)return this.createDefaultPreferences(e,a);const n=r;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(r){return null}}async createDefaultPreferences(e,a){const t=ls(),r={id_user:e,locale:"pt-BR",timezone:"America/Sao_Paulo",datetime_format:"dd/MM/yyyy HH:mm",alias:a};try{const{data:e,error:a}=await t.schema("common").from("user_preferences").insert(r).select().single();if(a)throw a;const s=e;return{locale:s.locale,timezone:s.timezone,datetimeFormat:s.datetime_format}}catch(s){throw s}}async updatePreferences(e,a,t){const r=ls();try{const{error:s}=await r.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(s)throw s}catch(s){throw s}}},Zi=o(void 0),eo=({children:a})=>{const{user:t,alias:r}=Bs(),[s,i]=n({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[o,l]=n(!0);c(()=>{(async()=>{if(t?.id&&r)try{const e=await Yi.getUserPreferences(t.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await x.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{l(!1)}else l(!1)})()},[t?.id,r]);const m=d(async e=>{if(t?.id&&r)try{await Yi.updatePreferences(t.id,r,{locale:e}),i(a=>({...a,locale:e})),await x.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[t?.id,r]),u=d(async e=>{if(t?.id&&r)try{await Yi.updatePreferences(t.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[t?.id,r]),h=d(async e=>{if(t?.id&&r)try{await Yi.updatePreferences(t.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[t?.id,r]);return e(Zi.Provider,{value:{...s,setLocale:m,setTimezone:u,setDatetimeFormat:h,isLoading:o},children:a})},ao=()=>{const e=l(Zi);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function to({children:r}){const{ready:s}=Pa(),[i,o]=n(!0);return c(()=>{s&&i&&o(!1)},[s,i]),i&&!s?e("div",{className:"flex items-center justify-center min-h-screen bg-background",children:a("div",{className:"flex flex-col items-center gap-4",children:[e(Cr,{size:"lg"}),e("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e(t,{children:r})}const ro=Ha.Root,so=Ha.CollapsibleTrigger,no=Ha.CollapsibleContent;var io=Object.defineProperty,oo=(e,a,t)=>((e,a,t)=>a in e?io(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class lo extends h{constructor(e){super(e),oo(this,"copyErrorDetails",()=>{const e=as.getErrors().slice(0,2),a=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(a),w.success("Detalhes copiados!",{description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if(import.meta.env.DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if(import.meta.env.DEV)throw e;as.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=as.getErrors().slice(0,2);return e("div",{className:"flex items-center justify-center min-h-screen p-4",children:a(Mt,{className:"w-full max-w-2xl",children:[a(Ft,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(We,{className:"h-12 w-12 text-destructive"})}),e(jt,{children:"Algo deu errado"})]}),a(Lt,{className:"space-y-4",children:[e("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),a(ro,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e(so,{asChild:!0,children:a(Et,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e(_,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),a(no,{className:"mt-4 space-y-4",children:[a("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a("div",{children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),a("div",{className:"text-sm space-y-2",children:[e("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e(ti,{className:"h-32 w-full rounded border bg-muted p-2",children:e("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&a("div",{className:"pt-3 border-t",children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e("div",{className:"space-y-2",children:t.map((t,r)=>e("div",{className:"text-sm p-2 rounded bg-muted/50",children:a("div",{className:"flex items-start gap-2",children:[a("span",{className:"font-medium text-muted-foreground shrink-0",children:[r+1,"."]}),a("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-2 flex-wrap",children:a("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),a(Et,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e(me,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e(Et,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}function co({children:a,queryClient:t}){const r=t??new Ma({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e(lo,{children:e(Ea,{i18n:x,children:e(Fa,{client:r,children:e(Vs,{children:e(eo,{children:e(to,{children:a})})})})})})}const mo=Ka.Root,uo=r.forwardRef(({className:a,...t},r)=>e(Ka.Item,{ref:r,className:wt("border-b",a),...t}));uo.displayName="AccordionItem";const ho=r.forwardRef(({className:t,children:r,...s},n)=>e(Ka.Header,{className:"flex",children:a(Ka.Trigger,{ref:n,className:wt("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[r,e(_,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));ho.displayName=Ka.Trigger.displayName;const po=r.forwardRef(({className:a,children:t,...r},s)=>e(Ka.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:e("div",{className:wt("pb-4 pt-0",a),children:t})}));po.displayName=Ka.Content.displayName;const fo=Qa.Root,go=Qa.Trigger,bo=Qa.Portal,vo=r.forwardRef(({className:a,...t},r)=>e(Qa.Overlay,{className:wt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:r}));vo.displayName=Qa.Overlay.displayName;const yo=r.forwardRef(({className:t,...r},s)=>a(bo,{children:[e(vo,{}),e(Qa.Content,{ref:s,className:wt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...r})]}));yo.displayName=Qa.Content.displayName;const No=({className:a,...t})=>e("div",{className:wt("flex flex-col space-y-2 text-center sm:text-left",a),...t});No.displayName="AlertDialogHeader";const xo=({className:a,...t})=>e("div",{className:wt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});xo.displayName="AlertDialogFooter";const wo=r.forwardRef(({className:a,...t},r)=>e(Qa.Title,{ref:r,className:wt("text-lg font-semibold",a),...t}));wo.displayName=Qa.Title.displayName;const ko=r.forwardRef(({className:a,...t},r)=>e(Qa.Description,{ref:r,className:wt("text-sm text-muted-foreground",a),...t}));ko.displayName=Qa.Description.displayName;const Co=r.forwardRef(({className:a,...t},r)=>e(Qa.Action,{ref:r,className:wt(It(),a),...t}));Co.displayName=Qa.Action.displayName;const So=r.forwardRef(({className:a,...t},r)=>e(Qa.Cancel,{ref:r,className:wt(It({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));So.displayName=Qa.Cancel.displayName;const _o=r.forwardRef(({className:a,...t},r)=>e(Ga.Root,{ref:r,className:wt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));_o.displayName=Ga.Root.displayName;const Po=r.forwardRef(({className:a,...t},r)=>e(Ga.Image,{ref:r,className:wt("aspect-square h-full w-full",a),...t}));Po.displayName=Ga.Image.displayName;const Io=r.forwardRef(({className:a,...t},r)=>e(Ga.Fallback,{ref:r,className:wt("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));Io.displayName=Ga.Fallback.displayName;const Eo=r.forwardRef(({...a},t)=>e("nav",{ref:t,"aria-label":"breadcrumb",...a}));Eo.displayName="Breadcrumb";const Ao=r.forwardRef(({className:a,...t},r)=>e("ol",{ref:r,className:wt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));Ao.displayName="BreadcrumbList";const To=r.forwardRef(({className:a,...t},r)=>e("li",{ref:r,className:wt("inline-flex items-center gap-1.5",a),...t}));To.displayName="BreadcrumbItem";const Ro=r.forwardRef(({asChild:a,className:t,...r},s)=>e(a?p:"a",{ref:s,className:wt("transition-colors hover:text-foreground",t),...r}));Ro.displayName="BreadcrumbLink";const zo=r.forwardRef(({className:a,...t},r)=>e("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:wt("font-normal text-foreground",a),...t}));zo.displayName="BreadcrumbPage";const Mo=({children:a,className:t,...r})=>e("li",{role:"presentation","aria-hidden":"true",className:wt("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...r,children:a??e(L,{})});Mo.displayName="BreadcrumbSeparator";const Fo=({className:t,...r})=>a("span",{role:"presentation","aria-hidden":"true",className:wt("flex h-9 w-9 items-center justify-center",t),...r,children:[e(Ve,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Mais"})]});Fo.displayName="BreadcrumbEllipsis";const jo=f("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),Do=r.forwardRef(({className:a,orientation:t,...r},s)=>e("div",{ref:s,className:wt(jo({orientation:t}),a),...r}));function Lo(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function Oo(e){return(a,t)=>{let r;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,s=t?.width?String(t.width):a;r=e.formattingValues[s]||e.formattingValues[a]}else{const a=e.defaultWidth,s=t?.width?String(t.width):e.defaultWidth;r=e.values[s]||e.values[a]}return r[e.argumentCallback?e.argumentCallback(a):a]}}function $o(e){return(a,t={})=>{const r=t.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],n=a.match(s);if(!n)return null;const i=n[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(o,e=>e.test(i)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(i.length)}}}function Uo(e){return(a,t={})=>{const r=a.match(e.matchPattern);if(!r)return null;const s=r[0],n=a.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=t.valueCallback?t.valueCallback(i):i;return{value:i,rest:a.slice(s.length)}}}Do.displayName="ButtonGroup";const Wo={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},qo={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Vo={ordinalNumber:(e,a)=>{const t=Number(e),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:Oo({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Oo({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Oo({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Oo({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Oo({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},Bo={ordinalNumber:Uo({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:$o({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:$o({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:$o({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:$o({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:$o({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},Ho={code:"en-US",formatDistance:(e,a,t)=>{let r;const s=Wo[e];return r="string"==typeof s?s:1===a?s.one:s.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r},formatLong:{date:Lo({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Lo({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Lo({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,r)=>qo[e],localize:Vo,match:Bo,options:{weekStartsOn:0,firstWeekContainsDate:1}},Ko={lessThanXSeconds:{one:"menos de un segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"medio minuto",lessThanXMinutes:{one:"menos de un minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"alrededor de 1 hora",other:"alrededor de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 día",other:"{{count}} días"},aboutXWeeks:{one:"alrededor de 1 semana",other:"alrededor de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"alrededor de 1 mes",other:"alrededor de {{count}} meses"},xMonths:{one:"1 mes",other:"{{count}} meses"},aboutXYears:{one:"alrededor de 1 año",other:"alrededor de {{count}} años"},xYears:{one:"1 año",other:"{{count}} años"},overXYears:{one:"más de 1 año",other:"más de {{count}} años"},almostXYears:{one:"casi 1 año",other:"casi {{count}} años"}},Qo={date:Lo({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/y"},defaultWidth:"full"}),time:Lo({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Lo({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Go={lastWeek:"'el' eeee 'pasado a la' p",yesterday:"'ayer a la' p",today:"'hoy a la' p",tomorrow:"'mañana a la' p",nextWeek:"eeee 'a la' p",other:"P"},Jo={lastWeek:"'el' eeee 'pasado a las' p",yesterday:"'ayer a las' p",today:"'hoy a las' p",tomorrow:"'mañana a las' p",nextWeek:"eeee 'a las' p",other:"P"},Xo={ordinalNumber:(e,a)=>Number(e)+"º",era:Oo({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Oo({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:Oo({values:{narrow:["e","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],wide:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]},defaultWidth:"wide"}),day:Oo({values:{narrow:["d","l","m","m","j","v","s"],short:["do","lu","ma","mi","ju","vi","sá"],abbreviated:["dom","lun","mar","mié","jue","vie","sáb"],wide:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]},defaultWidth:"wide"}),dayPeriod:Oo({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"}},defaultFormattingWidth:"wide"})},Yo={ordinalNumber:Uo({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:$o({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:"any"}),quarter:$o({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:$o({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:"any"}),day:$o({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:$o({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:"any"})},Zo={code:"es",formatDistance:(e,a,t)=>{let r;const s=Ko[e];return r="string"==typeof s?s:1===a?s.one:s.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+r:"hace "+r:r},formatLong:Qo,formatRelative:(e,a,t,r)=>1!==a.getHours()?Jo[e]:Go[e],localize:Xo,match:Yo,options:{weekStartsOn:1,firstWeekContainsDate:1}},el={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},al={date:Lo({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},defaultWidth:"full"}),time:Lo({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Lo({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},tl={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},rl={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Oo({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Oo({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Oo({values:{narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},defaultWidth:"wide"}),day:Oo({values:{narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},defaultWidth:"wide"}),dayPeriod:Oo({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},defaultFormattingWidth:"wide"})},sl={ordinalNumber:Uo({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:$o({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:$o({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:$o({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:$o({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:$o({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})},nl={code:"pt-BR",formatDistance:(e,a,t)=>{let r;const s=el[e];return r="string"==typeof s?s:1===a?s.one:s.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+r:"há "+r:r},formatLong:al,formatRelative:(e,a,t,r)=>{const s=tl[e];return"function"==typeof s?s(a):s},localize:rl,match:sl,options:{weekStartsOn:0,firstWeekContainsDate:1}};function il({className:a,classNames:t,showOutsideDays:r=!0,...s}){return e(Ja,{showOutsideDays:r,className:wt("p-3 pointer-events-auto",a),locale:nl,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:wt(It({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:wt(It({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{Chevron:({orientation:a})=>e("left"===a?xe:L,{className:"h-4 w-4"})},...s})}il.displayName="Calendar";const ol={Root:function({children:a,className:t}){return e("div",{className:wt("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:r}){return e(Mt,{className:wt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",r),onClick:t,children:e(Lt,{className:"p-4",children:a})})},Field:function({label:t,value:r,className:s}){return a("div",{className:wt("flex justify-between items-center text-sm",s),children:[a("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e("span",{className:"text-foreground",children:r})]})}};function ll({date:t,onDateChange:r,placeholder:s="Pick a date",disabled:n=!1,className:i,disabledDates:o}){return a(Pr,{children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",disabled:n,className:wt("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",i),children:[e(Te,{className:"mr-2 h-4 w-4"}),t?N(t,"PPP"):e("span",{children:s})]})}),e(Er,{className:"w-auto p-0",align:"start",children:e(il,{mode:"single",selected:t,onSelect:r,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const dl=({shouldScaleBackground:a=!0,...t})=>e(Xa.Root,{shouldScaleBackground:a,...t});dl.displayName="Drawer";const cl=Xa.Trigger,ml=Xa.Portal,ul=Xa.Close,hl=r.forwardRef(({className:a,...t},r)=>e(Xa.Overlay,{ref:r,className:wt("fixed inset-0 z-50 bg-black/80",a),...t}));hl.displayName=Xa.Overlay.displayName;const pl=r.forwardRef(({className:t,children:r,...s},n)=>a(ml,{children:[e(hl,{}),a(Xa.Content,{ref:n,className:wt("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),r]})]}));pl.displayName="DrawerContent";const fl=({className:a,...t})=>e("div",{className:wt("grid gap-1.5 p-4 text-center sm:text-left",a),...t});fl.displayName="DrawerHeader";const gl=({className:a,...t})=>e("div",{className:wt("mt-auto flex flex-col gap-2 p-4",a),...t});gl.displayName="DrawerFooter";const bl=r.forwardRef(({className:a,...t},r)=>e(Xa.Title,{ref:r,className:wt("text-lg font-semibold leading-none tracking-tight",a),...t}));bl.displayName=Xa.Title.displayName;const vl=r.forwardRef(({className:a,...t},r)=>e(Xa.Description,{ref:r,className:wt("text-sm text-muted-foreground",a),...t}));vl.displayName=Xa.Description.displayName;const yl={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},Nl={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function xl({children:a,cols:t="auto-fit",gap:r="md",className:s}){return e("div",{className:wt("grid",yl[t],Nl[r],s),children:a})}const wl=Ya.Root,kl=Ya.Trigger,Cl=r.forwardRef(({className:a,align:t="center",sideOffset:r=4,...s},n)=>e(Ya.Content,{ref:n,align:t,sideOffset:r,className:wt("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...s}));Cl.displayName=Ya.Content.displayName;const Sl=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-slot":"input-group",className:wt("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",a),...t}));Sl.displayName="InputGroup";const _l=f("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),Pl=r.forwardRef(({className:a,align:t,...r},s)=>e("div",{ref:s,"data-slot":"input-group-addon",className:wt(_l({align:t}),a),...r}));Pl.displayName="InputGroupAddon";const Il=f("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),El=r.forwardRef(({className:a,size:t,variant:r="ghost",...s},n)=>e(Et,{ref:n,"data-slot":"input-group-button",variant:r,className:wt(Il({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...s}));El.displayName="InputGroupButton";const Al=r.forwardRef(({className:a,...t},r)=>e(Tt,{ref:r,"data-slot":"input-group-control",className:wt("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));Al.displayName="InputGroupInput";const Tl=r.forwardRef(({className:a,...t},r)=>e(Nr,{ref:r,"data-slot":"input-group-control",className:wt("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));Tl.displayName="InputGroupTextarea";const Rl=r.forwardRef(({className:a,...t},r)=>e("h1",{ref:r,className:wt("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));Rl.displayName="H1";const zl=r.forwardRef(({className:a,...t},r)=>e("h2",{ref:r,className:wt("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));zl.displayName="H2";const Ml=r.forwardRef(({className:a,...t},r)=>e("h3",{ref:r,className:wt("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));Ml.displayName="H3";const Fl=r.forwardRef(({className:a,...t},r)=>e("h4",{ref:r,className:wt("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));Fl.displayName="H4";const jl=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:wt("leading-7 [&:not(:first-child)]:mt-6",a),...t}));jl.displayName="P";const Dl=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:wt("text-xl text-muted-foreground",a),...t}));Dl.displayName="Lead";const Ll=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:wt("text-lg font-semibold",a),...t}));Ll.displayName="Large";const Ol=r.forwardRef(({className:a,...t},r)=>e("small",{ref:r,className:wt("text-sm font-medium leading-none",a),...t}));Ol.displayName="Small";const $l=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:wt("text-sm text-muted-foreground",a),...t}));$l.displayName="Muted";const Ul=r.forwardRef(({className:a,...t},r)=>e("code",{ref:r,className:wt("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));Ul.displayName="InlineCode";const Wl=r.forwardRef(({className:a,...t},r)=>e("blockquote",{ref:r,className:wt("mt-6 border-l-2 pl-6 italic",a),...t}));Wl.displayName="Blockquote";const ql=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,className:wt("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));ql.displayName="List";const Vl=r.forwardRef(({className:t,children:r,...s},n)=>a(Za.Root,{ref:n,className:wt("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[r,e(Xl,{})]}));Vl.displayName=Za.Root.displayName;const Bl=r.forwardRef(({className:a,...t},r)=>e(Za.List,{ref:r,className:wt("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));Bl.displayName=Za.List.displayName;const Hl=Za.Item,Kl=f("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),Ql=r.forwardRef(({className:t,children:r,...s},n)=>a(Za.Trigger,{ref:n,className:wt(Kl(),"group",t),...s,children:[r," ",e(_,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Ql.displayName=Za.Trigger.displayName;const Gl=r.forwardRef(({className:a,...t},r)=>e(Za.Content,{ref:r,className:wt("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",a),...t}));Gl.displayName=Za.Content.displayName;const Jl=Za.Link,Xl=r.forwardRef(({className:a,...t},r)=>e("div",{className:wt("absolute left-0 top-full flex justify-center"),children:e(Za.Viewport,{className:wt("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",a),ref:r,...t})}));Xl.displayName=Za.Viewport.displayName;const Yl=r.forwardRef(({className:a,...t},r)=>e(Za.Indicator,{ref:r,className:wt("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",a),...t,children:e("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));function Zl({items:r,maxItems:s=3,className:n}){const i=r.length>s?[r[0],...r.slice(-(s-1))]:r,o=r.length>s;return e(Eo,{className:n,children:e(Ao,{children:i.map((r,s)=>{const n=o&&1===s;return a(To,{children:[!(0===s)&&e(Mo,{}),n&&a(t,{children:[e(Fo,{}),e(Mo,{})]}),r.isCurrentPage?e(zo,{children:r.label}):e(Ro,{href:r.href,children:r.label})]},r.label)})})})}function ed(){const e=Da();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let r="";return a.forEach((e,s)=>{r+=`/${e}`;const n=s===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:r,isCurrentPage:n})}),t})()}Yl.displayName=Za.Indicator.displayName;const ad=({className:a,...t})=>e("nav",{role:"navigation","aria-label":"pagination",className:wt("mx-auto flex w-full justify-center",a),...t});ad.displayName="Pagination";const td=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,className:wt("flex flex-row items-center gap-1",a),...t}));td.displayName="PaginationContent";const rd=r.forwardRef(({className:a,...t},r)=>e("li",{ref:r,className:wt("",a),...t}));rd.displayName="PaginationItem";const sd=({className:a,isActive:t,size:r="icon",...s})=>e("a",{"aria-current":t?"page":void 0,className:wt(It({variant:t?"outline":"ghost",size:r}),a),...s});sd.displayName="PaginationLink";const nd=({className:t,...r})=>a(sd,{"aria-label":"Go to previous page",size:"default",className:wt("gap-1 pl-2.5",t),...r,children:[e(xe,{className:"h-4 w-4"}),e("span",{children:"Previous"})]});nd.displayName="PaginationPrevious";const id=({className:t,...r})=>a(sd,{"aria-label":"Go to next page",size:"default",className:wt("gap-1 pr-2.5",t),...r,children:[e("span",{children:"Next"}),e(L,{className:"h-4 w-4"})]});id.displayName="PaginationNext";const od=({className:t,...r})=>a("span",{"aria-hidden":!0,className:wt("flex h-9 w-9 items-center justify-center",t),...r,children:[e(Ve,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"More pages"})]});od.displayName="PaginationEllipsis";const ld=r.forwardRef(({className:a,...t},r)=>e(et.Root,{className:wt("grid gap-2",a),...t,ref:r}));ld.displayName=et.Root.displayName;const dd=r.forwardRef(({className:a,...t},r)=>e(et.Item,{ref:r,className:wt("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),...t,children:e(et.Indicator,{className:"flex items-center justify-center",children:e(O,{className:"h-2.5 w-2.5 fill-current text-current"})})}));dd.displayName=et.Item.displayName;const cd=({className:a,...t})=>e(tt,{className:wt("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),md=at,ud=({withHandle:a,className:t,...r})=>e(rt,{className:wt("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...r,children:a&&e("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e(Be,{className:"h-2.5 w-2.5"})})}),hd=ba.Root,pd=ba.Trigger,fd=ba.Close,gd=ba.Portal,bd=r.forwardRef(({className:a,...t},r)=>e(ba.Overlay,{className:wt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:r}));bd.displayName=ba.Overlay.displayName;const vd=f("fixed z-50 flex flex-col bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),yd=r.forwardRef(({side:t="right",className:r,children:s,...n},i)=>a(gd,{children:[e(bd,{}),a(ba.Content,{ref:i,className:wt(vd({side:t}),r),...n,children:[s,a(ba.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e(S,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));yd.displayName=ba.Content.displayName;const Nd=({className:t,showSeparator:r=!1,children:s,...n})=>a("div",{className:wt("flex flex-col flex-shrink-0",t),...n,children:[e("div",{className:"flex flex-col text-left",children:s}),r&&e($t,{className:"mt-2"})]});Nd.displayName="SheetHeader";const xd=({className:a,...t})=>e("div",{className:wt("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});xd.displayName="SheetBody";const wd=({className:t,children:r,...s})=>a("div",{className:"flex-shrink-0 pt-4",children:[e($t,{className:"mb-4"}),e("div",{className:wt("flex flex-row justify-end gap-2",t),...s,children:r})]});wd.displayName="SheetFooter";const kd=r.forwardRef(({className:a,...t},r)=>e(ba.Title,{ref:r,className:wt("text-lg font-semibold text-foreground",a),...t}));kd.displayName=ba.Title.displayName;const Cd=r.forwardRef(({className:a,...t},r)=>e(ba.Description,{ref:r,className:wt("text-sm text-muted-foreground",a),...t}));Cd.displayName=ba.Description.displayName;const Sd="sidebar:state",_d=r.createContext(null);function Pd(){const e=r.useContext(_d);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Id=r.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:n,style:i,children:o,...l},d)=>{const[c,m]=r.useState(!1);r.useEffect(()=>{const e=()=>m(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,h]=r.useState(!1),[p,f]=r.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Sd);return null!==e?"true"===e:a}return a}),g=t??p,b=r.useCallback(e=>{const a="function"==typeof e?e(g):e;s?s(a):f(a),"undefined"!=typeof window&&localStorage.setItem(Sd,String(a))},[s,g]),v=r.useCallback(()=>c?h(e=>!e):b(e=>!e),[c,b,h]);r.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v]);const y=g?"expanded":"collapsed",N=r.useMemo(()=>({state:y,open:g,setOpen:b,isMobile:c,openMobile:u,setOpenMobile:h,toggleSidebar:v}),[y,g,b,c,u,h,v]);return e(_d.Provider,{value:N,children:e(cn,{delayDuration:0,children:e("div",{className:wt("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",n),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...i},ref:d,...l,children:o})})})});Id.displayName="SidebarProvider";const Ed=r.forwardRef(({side:t="left",variant:r="sidebar",collapsible:s="offcanvas",className:n,children:i,...o},l)=>{const{isMobile:d,state:c,openMobile:m,setOpenMobile:u}=Pd();return"none"===s?e("div",{className:wt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",n),ref:l,...o,children:i}):d?e(hd,{open:m,onOpenChange:u,...o,children:a(yd,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e(kd,{className:"sr-only",children:"Menu de Navegação"}),e("div",{className:"flex h-full w-full flex-col",children:i})]})}):a("div",{ref:l,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?s:"","data-variant":r,"data-side":t,children:[e("div",{className:wt("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===r||"inset"===r?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e("div",{className:wt("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===r||"inset"===r?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",n),...o,children:e("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:i})})]})});Ed.displayName="Sidebar";const Ad=r.forwardRef(({className:t,onClick:r,...s},n)=>{const{toggleSidebar:i}=Pd();return a(Et,{ref:n,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:wt("h-7 w-7",t),onClick:e=>{r?.(e),i()},...s,children:[e(He,{}),e("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Ad.displayName="SidebarTrigger";const Td=r.forwardRef(({className:a,...t},r)=>{const{toggleSidebar:s}=Pd();return e("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:wt("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",a),...t})});Td.displayName="SidebarRail";const Rd=r.forwardRef(({className:a,...t},r)=>e("main",{ref:r,className:wt("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",a),...t}));Rd.displayName="SidebarInset";const zd=r.forwardRef(({className:a,...t},r)=>e(Tt,{ref:r,"data-sidebar":"input",className:wt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));zd.displayName="SidebarInput";const Md=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"header",className:wt("flex flex-col gap-2 p-2",a),...t}));Md.displayName="SidebarHeader";const Fd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"footer",className:wt("flex flex-col gap-2 p-2",a),...t}));Fd.displayName="SidebarFooter";const jd=r.forwardRef(({className:a,...t},r)=>e($t,{ref:r,"data-sidebar":"separator",className:wt("mx-2 w-auto bg-sidebar-border",a),...t}));jd.displayName="SidebarSeparator";const Dd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"content",className:wt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));Dd.displayName="SidebarContent";const Ld=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"group",className:wt("relative flex w-full min-w-0 flex-col p-2",a),...t}));Ld.displayName="SidebarGroup";const Od=r.forwardRef(({className:a,asChild:t=!1,...r},s)=>e(t?p:"div",{ref:s,"data-sidebar":"group-label",className:wt("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",a),...r}));Od.displayName="SidebarGroupLabel";const $d=r.forwardRef(({className:a,asChild:t=!1,...r},s)=>e(t?p:"button",{ref:s,"data-sidebar":"group-action",className:wt("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",a),...r}));$d.displayName="SidebarGroupAction";const Ud=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"group-content",className:wt("w-full text-sm",a),...t}));Ud.displayName="SidebarGroupContent";const Wd=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,"data-sidebar":"menu",className:wt("flex w-full min-w-0 flex-col gap-1",a),...t}));Wd.displayName="SidebarMenu";const qd=r.forwardRef(({className:a,...t},r)=>e("li",{ref:r,"data-sidebar":"menu-item",className:wt("group/menu-item relative",a),...t}));qd.displayName="SidebarMenuItem";const Vd=f("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Bd=r.forwardRef(({asChild:t=!1,isActive:r=!1,variant:s="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=t?p:"button",{isMobile:m,state:u}=Pd(),h=e(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":r,className:wt(Vd({variant:s,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),a(mn,{children:[e(un,{asChild:!0,children:h}),e(hn,{side:"right",align:"center",hidden:"collapsed"!==u||m,...i})]})):h});Bd.displayName="SidebarMenuButton";const Hd=r.forwardRef(({className:a,asChild:t=!1,showOnHover:r=!1,...s},n)=>e(t?p:"button",{ref:n,"data-sidebar":"menu-action",className:wt("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",a),...s}));Hd.displayName="SidebarMenuAction";const Kd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"menu-badge",className:wt("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",a),...t}));Kd.displayName="SidebarMenuBadge";const Qd=r.forwardRef(({className:t,showIcon:s=!1,...n},i)=>{const o=r.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return a("div",{ref:i,"data-sidebar":"menu-skeleton",className:wt("rounded-md h-8 flex gap-2 px-2 items-center",t),...n,children:[s&&e("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Qd.displayName="SidebarMenuSkeleton";const Gd=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,"data-sidebar":"menu-sub",className:wt("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",a),...t}));Gd.displayName="SidebarMenuSub";const Jd=r.forwardRef(({...a},t)=>e("li",{ref:t,...a}));Jd.displayName="SidebarMenuSubItem";const Xd=r.forwardRef(({asChild:a=!1,size:t="md",isActive:r,className:s,...n},i)=>e(a?p:"a",{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:wt("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",s),...n}));Xd.displayName="SidebarMenuSubButton";const Yd=r.forwardRef(({className:t,value:r,defaultValue:s,...n},i)=>{const o=r||s||[0];return a(st.Root,{ref:i,value:r,defaultValue:s,className:wt("relative flex w-full touch-none select-none items-center",t),...n,children:[e(st.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e(st.Range,{className:"absolute h-full bg-primary"})}),o.map((a,t)=>e(st.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},t))]})});Yd.displayName=st.Root.displayName;const Zd=nt.Root,ec=r.forwardRef(({className:a,...t},r)=>e(nt.List,{ref:r,className:wt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));ec.displayName=nt.List.displayName;const ac=r.forwardRef(({className:a,...t},r)=>e(nt.Trigger,{ref:r,className:wt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",a),...t}));ac.displayName=nt.Trigger.displayName;const tc=r.forwardRef(({className:a,...t},r)=>e(nt.Content,{ref:r,className:wt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));function rc({children:a,className:t}){return e("div",{className:wt("flex flex-col h-full",t),children:e(ti,{className:"flex-1",children:e("div",{className:"space-y-6 p-6",children:a})})})}function sc({title:t,description:r,actions:s,className:n}){return a("div",{className:wt("space-y-4",n),children:[a("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[a("div",{className:"space-y-1",children:[e("h2",{className:"text-2xl font-bold tracking-tight",children:t}),r&&e("p",{className:"text-muted-foreground text-sm",children:r})]}),s&&e("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e($t,{})]})}function nc({children:a,className:t}){return e("div",{className:wt("space-y-6",t),children:a})}tc.displayName=nt.Content.displayName;const ic=f("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),oc=r.forwardRef(({className:a,variant:t,size:r,...s},n)=>e(it.Root,{ref:n,className:wt(ic({variant:t,size:r,className:a})),...s}));oc.displayName=it.Root.displayName;const lc=r.createContext({size:"default",variant:"default"}),dc=r.forwardRef(({className:a,variant:t,size:r,children:s,...n},i)=>e(ot.Root,{ref:i,className:wt("flex items-center justify-center gap-1",a),...n,children:e(lc.Provider,{value:{variant:t,size:r},children:s})}));dc.displayName=ot.Root.displayName;const cc=r.forwardRef(({className:a,children:t,variant:s,size:n,...i},o)=>{const l=r.useContext(lc);return e(ot.Item,{ref:o,className:wt(ic({variant:l.variant||s,size:l.size||n}),a),...i,children:t})});cc.displayName=ot.Item.displayName;const mc=lt.Menu,uc=lt.Group,hc=lt.Portal,pc=lt.Sub,fc=lt.RadioGroup,gc=r.forwardRef(({className:a,...t},r)=>e(lt.Root,{ref:r,className:wt("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));gc.displayName=lt.Root.displayName;const bc=r.forwardRef(({className:a,...t},r)=>e(lt.Trigger,{ref:r,className:wt("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a),...t}));bc.displayName=lt.Trigger.displayName;const vc=r.forwardRef(({className:t,inset:r,children:s,...n},i)=>a(lt.SubTrigger,{ref:i,className:wt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",t),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));vc.displayName=lt.SubTrigger.displayName;const yc=r.forwardRef(({className:a,...t},r)=>e(lt.SubContent,{ref:r,className:wt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));yc.displayName=lt.SubContent.displayName;const Nc=r.forwardRef(({className:a,align:t="start",alignOffset:r=-4,sideOffset:s=8,...n},i)=>e(lt.Portal,{children:e(lt.Content,{ref:i,align:t,alignOffset:r,sideOffset:s,className:wt("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...n})}));Nc.displayName=lt.Content.displayName;const xc=r.forwardRef(({className:a,inset:t,...r},s)=>e(lt.Item,{ref:s,className:wt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...r}));xc.displayName=lt.Item.displayName;const wc=r.forwardRef(({className:t,children:r,checked:s,...n},i)=>a(lt.CheckboxItem,{ref:i,className:wt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(lt.ItemIndicator,{children:e(I,{className:"h-4 w-4"})})}),r]}));wc.displayName=lt.CheckboxItem.displayName;const kc=r.forwardRef(({className:t,children:r,...s},n)=>a(lt.RadioItem,{ref:n,className:wt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(lt.ItemIndicator,{children:e(O,{className:"h-2 w-2 fill-current"})})}),r]}));kc.displayName=lt.RadioItem.displayName;const Cc=r.forwardRef(({className:a,inset:t,...r},s)=>e(lt.Label,{ref:s,className:wt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...r}));Cc.displayName=lt.Label.displayName;const Sc=r.forwardRef(({className:a,...t},r)=>e(lt.Separator,{ref:r,className:wt("-mx-1 my-1 h-px bg-muted",a),...t}));Sc.displayName=lt.Separator.displayName;const _c=({className:a,...t})=>e("span",{className:wt("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});_c.displayname="MenubarShortcut";const Pc={light:"",dark:".dark"},Ic=r.createContext(null);function Ec(){const e=r.useContext(Ic);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Ac=r.forwardRef(({id:t,className:s,children:n,config:i,...o},l)=>{const d=r.useId(),c=`chart-${t||d.replace(/:/g,"")}`;return e(Ic.Provider,{value:{config:i},children:a("div",{"data-chart":c,ref:l,className:wt("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...o,children:[e(Tc,{id:c,config:i}),e(dt.ResponsiveContainer,{children:n})]})})});Ac.displayName="Chart";const Tc=({id:a,config:t})=>{const r=Object.entries(t).filter(([,e])=>e.theme||e.color);return r.length?e("style",{dangerouslySetInnerHTML:{__html:Object.entries(Pc).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${r.map(([a,t])=>{const r=t.theme?.[e]||t.color;return r?` --color-${a}: ${r};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Rc=dt.Tooltip,zc=r.forwardRef(({active:s,payload:n,className:i,indicator:o="dot",hideLabel:l=!1,hideIndicator:d=!1,label:c,labelFormatter:m,labelClassName:u,formatter:h,color:p,nameKey:f,labelKey:g},b)=>{const{config:v}=Ec(),y=r.useMemo(()=>{if(l||!n?.length)return null;const[a]=n,t=jc(v,a,`${g||a?.dataKey||a?.name||"value"}`),r=g||"string"!=typeof c?t?.label:v[c]?.label||c;return m?e("div",{className:wt("font-medium",u),children:m(r,n)}):r?e("div",{className:wt("font-medium",u),children:r}):null},[c,m,n,l,u,v,g]);if(!s||!n?.length)return null;const N=1===n.length&&"dot"!==o;return a("div",{ref:b,className:wt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",i),children:[N?null:y,e("div",{className:"grid gap-1.5",children:n.map((r,s)=>{const n=`${f||r.name||r.dataKey||"value"}`,i=jc(v,r,n),l=p||r.payload?.fill||r.color;return e("div",{className:wt("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===o&&"items-center"),children:h&&void 0!==r?.value&&r.name?h(r.value,r.name,r,s,r.payload):a(t,{children:[i?.icon?e(i.icon,{}):!d&&e("div",{className:wt("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===o,"w-1":"line"===o,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===o,"my-0.5":N&&"dashed"===o}),style:{"--color-bg":l,"--color-border":l}}),a("div",{className:wt("flex flex-1 justify-between leading-none",N?"items-end":"items-center"),children:[a("div",{className:"grid gap-1.5",children:[N?y:null,e("span",{className:"text-muted-foreground",children:i?.label||r.name})]}),void 0!==r.value&&e("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof r.value?r.value.toLocaleString():r.value})]})]})},r.dataKey||s)})})]})});zc.displayName="ChartTooltip";const Mc=dt.Legend,Fc=r.forwardRef(({className:t,hideIcon:r=!1,payload:s,verticalAlign:n="bottom",nameKey:i},o)=>{const{config:l}=Ec();return s?.length?e("div",{ref:o,className:wt("flex items-center justify-center gap-4","top"===n?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${i||t.dataKey||"value"}`,n=jc(l,t,s);return a("div",{className:wt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[n?.icon&&!r?e(n.icon,{}):e("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),n?.label]},t.value)})}):null});function jc(e,a,t){if("object"!=typeof a||null===a)return;const r="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let s=t;return t in a&&"string"==typeof a[t]?s=a[t]:r&&t in r&&"string"==typeof r[t]&&(s=r[t]),s in e?e[s]:e[t]}Fc.displayName="ChartLegend";const Dc=({onClick:a,isActive:t,disabled:r,children:s,title:n})=>e("button",{type:"button",onClick:a,disabled:r,title:n,className:wt("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",r&&"opacity-50 cursor-not-allowed"),children:s}),Lc=()=>e("div",{className:"w-px h-5 bg-border mx-1"}),Oc=({value:t,onChange:s,disabled:i,placeholder:o="Escreva o conteúdo aqui...",minHeight:l="300px",showModeToggle:c=!0,showVariableHint:m=!0,className:u})=>{const[h,p]=n("visual"),f=ct({extensions:[ut.configure({heading:{levels:[1,2,3]}}),ht,pt.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),ft,gt,bt.configure({multicolor:!0})],content:t||"",editable:!i,onUpdate:({editor:e})=>{s(e.getHTML())}});r.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t||"")},[t,f]);const g=d(()=>{if(!f)return;const e=f.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?f.chain().focus().extendMarkRange("link").setLink({href:a}).run():f.chain().focus().extendMarkRange("link").unsetLink().run())},[f]);return f?a("div",{className:wt("space-y-2",u),children:[c&&a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex gap-1",children:[a(Et,{type:"button",size:"sm",variant:"visual"===h?"default":"outline",onClick:()=>p("visual"),disabled:i,children:[e(Ke,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),a(Et,{type:"button",size:"sm",variant:"code"===h?"default":"outline",onClick:()=>p("code"),disabled:i,children:[e(Qe,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),a(Et,{type:"button",size:"sm",variant:"preview"===h?"default":"outline",onClick:()=>p("preview"),disabled:i,children:[e(re,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),m&&a("p",{className:"text-xs text-muted-foreground",children:["Use ",e("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===h&&a("div",{className:"border rounded-md overflow-hidden bg-background",children:[a("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e(Dc,{onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),isActive:f.isActive("heading",{level:1}),disabled:i,title:"Título 1",children:e(Ge,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),isActive:f.isActive("heading",{level:2}),disabled:i,title:"Título 2",children:e(Je,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().toggleHeading({level:3}).run(),isActive:f.isActive("heading",{level:3}),disabled:i,title:"Título 3",children:e(Xe,{className:"h-4 w-4"})}),e(Lc,{}),e(Dc,{onClick:()=>f.chain().focus().toggleBold().run(),isActive:f.isActive("bold"),disabled:i,title:"Negrito",children:e(Ye,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().toggleItalic().run(),isActive:f.isActive("italic"),disabled:i,title:"Itálico",children:e(Ze,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().toggleUnderline().run(),isActive:f.isActive("underline"),disabled:i,title:"Sublinhado",children:e(ea,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().toggleStrike().run(),isActive:f.isActive("strike"),disabled:i,title:"Riscado",children:e(aa,{className:"h-4 w-4"})}),e(Lc,{}),e(Dc,{onClick:()=>f.chain().focus().toggleBulletList().run(),isActive:f.isActive("bulletList"),disabled:i,title:"Lista",children:e(ta,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().toggleOrderedList().run(),isActive:f.isActive("orderedList"),disabled:i,title:"Lista Ordenada",children:e(ra,{className:"h-4 w-4"})}),e(Lc,{}),e(Dc,{onClick:()=>f.chain().focus().toggleHighlight().run(),isActive:f.isActive("highlight"),disabled:i,title:"Destacar",children:e(sa,{className:"h-4 w-4"})}),e(Dc,{onClick:g,isActive:f.isActive("link"),disabled:i,title:"Link",children:e(na,{className:"h-4 w-4"})}),e(Lc,{}),e(Dc,{onClick:()=>f.chain().focus().unsetAllMarks().clearNodes().run(),disabled:i,title:"Limpar Formatação",children:e(ia,{className:"h-4 w-4"})}),e(Lc,{}),e(Dc,{onClick:()=>f.chain().focus().undo().run(),disabled:i||!f.can().undo(),title:"Desfazer",children:e(oa,{className:"h-4 w-4"})}),e(Dc,{onClick:()=>f.chain().focus().redo().run(),disabled:i||!f.can().redo(),title:"Refazer",children:e(la,{className:"h-4 w-4"})})]}),e(mt,{editor:f,className:wt("prose prose-sm max-w-none p-4 focus:outline-none","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:l}})]}),"code"===h&&e("textarea",{value:t||"",onChange:e=>s(e.target.value),disabled:i,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:l},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===h&&e("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:l},children:e("div",{className:"bg-background shadow-sm rounded border p-4",children:e("div",{dangerouslySetInnerHTML:{__html:t||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null};function $c({label:t,onClick:r,icon:s,actions:n=[],variant:i="default",size:o="default",disabled:l=!1,loading:d=!1,menuAlign:c="end",className:m}){const u=l||d;if(!(n.length>0))return a(Et,{variant:i,size:o,disabled:u,onClick:r,className:m,children:[d?e(E,{className:"mr-2 h-4 w-4 animate-spin"}):s?e(s,{className:"mr-2 h-4 w-4"}):null,t]});return a("div",{className:wt("inline-flex rounded-md shadow-sm",m),children:[a(Et,{variant:i,size:o,disabled:u,onClick:r,className:"rounded-r-none border-r-0 focus:z-10",children:[d?e(E,{className:"mr-2 h-4 w-4 animate-spin"}):s?e(s,{className:"mr-2 h-4 w-4"}):null,t]}),a(gn,{children:[e(bn,{asChild:!0,children:e(Et,{variant:i,size:o,disabled:u,className:wt("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e(_,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e(Cn,{align:c,className:"min-w-[160px]",children:n.map(t=>{const r=t.icon;return a(Sn,{onClick:t.onClick,disabled:t.disabled,className:wt("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[r&&e(r,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]})}function Uc({data:t,columns:r,sortField:s,sortDirection:n,onSort:o,onRowClick:l,renderActions:d,isLoading:c=!1,emptyMessage:m="Nenhum item encontrado",className:u,enableSelection:h=!1,selectedIds:p=[],onSelectItem:f,onSelectAll:g,isAllSelected:b=!1,enableColumnResize:v=!0,onColumnResize:y,storageKey:N}){const{columnWidths:x,isDragging:w,activeColumn:k,handleMouseDown:C}=Gn({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,onResize:y,enabled:v}),{isDragging:S,activeRow:_,handleMouseDown:P,getRowHeight:I}=Jn({rowIds:t.map(e=>e.id),storageKey:N?`${N}-rows`:void 0,enabled:!1}),E=i(()=>{if(v)return r.map(e=>`${x[String(e.key)]??e.width??e.minWidth??150}px`);const e=r.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return r.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[r,v,x]);if(c)return e("div",{className:"flex-1 overflow-auto",children:e("div",{className:"p-4 space-y-3",children:[...Array(5)].map((a,t)=>e(Or,{className:"h-12 w-full"},t))})});if(0===t.length)return e("div",{className:"flex-1 flex items-center justify-center",children:e("div",{className:"text-center text-muted-foreground",children:e("p",{children:m})})});return e("div",{className:"flex-1 overflow-auto "+(w||S?"select-none":""),children:a(Qs,{className:u,children:[e(Gs,{className:"sticky top-0 bg-background z-10",children:a(Ys,{children:[h&&e(Zs,{className:"w-[40px]",children:e(yr,{checked:b,onCheckedChange:g,"aria-label":"Selecionar todos"})}),r.map((t,r)=>{const i=v&&!1!==t.resizable,l=k===String(t.key);return a(Zs,{className:`${t.className||""} relative`,style:{width:E[r]},children:[t.sortable&&o?a("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(d=String(t.key),s!==d?e(B,{size:14,className:"ml-1 opacity-50"}):e("asc"===n?H:K,{size:14,className:"ml-1"}))]}):e("span",{className:"font-medium",children:t.header}),i&&e(fn,{direction:"horizontal",onMouseDown:e=>C(String(t.key),e),isDragging:l})]},String(t.key));var d}),d&&e(Zs,{className:"w-[80px] text-right",children:"Ações"})]})}),e(Js,{children:t.map(t=>{const s=I(t.id);return t.id,a(Ys,{onClick:()=>l?.(t),className:(l?"cursor-pointer":"")+" relative",style:s?{height:`${s}px`}:void 0,children:[h&&e(en,{children:e(yr,{checked:p.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${t.id}`})}),r.map(a=>e(en,{className:a.className,children:e(pn,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),d&&e(en,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(t)})]},t.id)})})]})})}function Wc({onEdit:t,onDelete:r,onToggleStatus:s,isActive:n=!0,canEdit:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d="dropdown",variant:c="default"}){const{t:m}=Pa(),u=[];return t&&i&&u.push({icon:$,label:m("edit"),onClick:t,variant:"default"}),s&&u.push({icon:n?U:W,label:m(n?"deactivate":"activate"),onClick:s,variant:"default"}),l.forEach(e=>{!1!==e.show&&u.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),r&&o&&u.push({icon:q,label:m("remove"),onClick:r,variant:"destructive"}),0===u.length?null:"dropdown"===d?a(gn,{children:[e(bn,{asChild:!0,children:e(Et,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e(C,{size:"compact"===c?14:16})})}),e(Cn,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:u.map((t,r)=>a(Sn,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},r))})]}):e("div",{className:"flex items-center gap-1",children:u.map((t,r)=>a(Et,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:t.onClick,className:"compact"===c?"h-7 px-2":"",children:[t.icon&&e(t.icon,{size:"compact"===c?14:16}),"compact"!==c&&e("span",{className:"ml-1",children:t.label})]},r))})}function qc({searchValue:t="",onSearchChange:r,customFilters:s=[],onClearFilters:n,showClearButton:i=!0,layout:o="horizontal"}){const{t:l}=Pa(),d=t||s.length>0;return a("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[r&&a("div",{className:"relative flex-1 min-w-[200px]",children:[e(j,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(Tt,{type:"text",placeholder:l("search"),value:t,onChange:e=>r(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e("div",{className:"vertical"===o?"w-full":"",children:a},t)),i&&d&&n&&a(Et,{variant:"ghost",size:"sm",onClick:n,className:"h-9 px-3 whitespace-nowrap",children:[e(S,{size:14,className:"mr-1"}),l("clear_filters")]})]})}function Vc(e){const a=La();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const r=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(r)}}}function Bc(e,a){const t=Vc({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}}const Hc=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Kc=[{value:"dd/MM/yyyy HH:mm",label:"dd/MM/yyyy HH:mm",example:"28/11/2024 14:30",description:"Padrão Brasileiro"},{value:"MM/dd/yyyy hh:mm a",label:"MM/dd/yyyy hh:mm a",example:"11/28/2024 02:30 PM",description:"Padrão Americano (12h)"},{value:"MM/dd/yyyy HH:mm",label:"MM/dd/yyyy HH:mm",example:"11/28/2024 14:30",description:"Padrão Americano (24h)"},{value:"yyyy-MM-dd HH:mm",label:"yyyy-MM-dd HH:mm",example:"2024-11-28 14:30",description:"ISO 8601"},{value:"dd.MM.yyyy HH:mm",label:"dd.MM.yyyy HH:mm",example:"28.11.2024 14:30",description:"Padrão Europeu"},{value:"d MMM yyyy, HH:mm",label:"d MMM yyyy, HH:mm",example:"28 Nov 2024, 14:30",description:"Formato Longo"}],Qc=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/New_York",label:"New York (UTC-5/-4)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6/-5)",offset:"-06:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8/-7)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0/+1)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1/+2)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1/+2)",offset:"+01:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10/+11)",offset:"+10:00"}],Gc=()=>{const{locale:t,datetimeFormat:r,timezone:s,setLocale:n,setDatetimeFormat:i,setTimezone:o}=ao(),{t:l}=Pa();return a("div",{className:"space-y-4 p-4",children:[a("div",{children:[a("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(da,{className:"h-4 w-4"}),l("language")]}),a(dr,{value:t,onValueChange:n,children:[e(ur,{children:e(mr,{})}),e(fr,{children:Hc.map(e=>a(br,{value:e.value,children:[e.flag," ",e.label]},e.value))})]})]}),a("div",{children:[a("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(ve,{className:"h-4 w-4"}),l("timezone")||"Fuso Horário"]}),a(dr,{value:s,onValueChange:o,children:[e(ur,{children:e(mr,{})}),e(fr,{children:Qc.map(a=>e(br,{value:a.value,children:a.label},a.value))})]})]}),a("div",{children:[a("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(Te,{className:"h-4 w-4"}),l("dateTimeFormat")||"Formato de Data/Hora"]}),a(dr,{value:r,onValueChange:i,children:[e(ur,{children:e(mr,{})}),e(fr,{children:Kc.map(t=>e(br,{value:t.value,children:a("div",{className:"flex flex-col items-start",children:[e("span",{children:t.label}),a("span",{className:"text-xs text-muted-foreground",children:[t.description," • ",t.example]})]})},t.value))})]})]})]})},Jc=s.memo(({variant:r="card",className:i="",selectedUnit:o,onUnitChange:l})=>{const{user:d,companies:c,alias:m,isAuthenticated:u,logout:h,switchUnit:p}=Bs(),[f,g]=n(!1),b="true"===import.meta.env.VITE_SHOW_USER_PREFERENCES,v=c?.[0]||null,y=m?c?.find(e=>e.alias===m):v,N=c||[],x=o||y||v||v,w=s.useCallback(e=>{l?l(e):p(e)},[l,p]),k=s.useMemo(()=>{if(!N?.length)return[];const e=new Map;N.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===x?.alias),r=a.filter(e=>e.alias!==x?.alias);return r.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...r]:r},[N,x?.alias]);if(!u||!d)return null;const C=()=>a(t,{children:[a("div",{className:"flex items-center space-x-3",children:[e("div",{className:"flex-shrink-0",children:e("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e(Fe,{className:"h-5 w-5 text-primary-foreground"})})}),a("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-medium truncate",children:d.name}),a("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e("div",{className:"mt-3",children:a("div",{className:"flex items-center space-x-2",children:[e(ca,{className:"h-4 w-4 text-muted-foreground"}),e("span",{className:"text-sm font-medium",children:x.name})]})}),k.length>1&&a("div",{className:"mt-2",children:[a("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",k.length]}),a("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,3).map(a=>e(wr,{variant:a.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>w(a),children:a.name},a.alias)),k.length>3&&a(wr,{variant:"outline",className:"text-xs",children:["+",k.length-3]})]})]})]});return"dropdown"===r?a(gn,{children:[e(bn,{asChild:!0,children:e(Et,{variant:"ghost",className:`h-auto p-2 ${i}`,children:a("div",{className:"flex items-center space-x-2",children:[a("div",{className:"hidden md:block text-left",children:[e("p",{className:"text-sm font-medium",children:d.name}),e("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e(Fe,{className:"h-4 w-4 text-primary-foreground"})}),e(_,{className:"h-4 w-4"})]})})}),a(Cn,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[a(Nn,{children:[a(wn,{children:[e(qe,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e(kn,{children:k.map(t=>a(Sn,{onClick:()=>w(t),className:t.alias===x?.alias?"bg-muted":"",children:[e(ca,{className:"mr-2 h-4 w-4"}),t.name,t.alias===x?.alias&&e(wr,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),b&&e(En,{}),b&&a(Sn,{onClick:()=>g(!0),children:[e(Me,{className:"mr-2 h-4 w-4"}),"Preferências"]}),a(Sn,{onClick:h,children:[e(ma,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),b&&e(Ut,{open:f,onOpenChange:g,children:a(Kt,{children:[e(Qt,{children:e(Xt,{children:"Preferências de Internacionalização"})}),e(Gc,{})]})})]}):a(Mt,{className:i,children:[e(Ft,{children:e(jt,{className:"text-lg",children:"Informações do Usuário"})}),a(Lt,{className:"space-y-4",children:[e(C,{}),e($t,{}),b&&a(Et,{variant:"outline",onClick:()=>g(!0),size:"sm",className:"w-full",children:[e(Me,{className:"mr-2 h-4 w-4"}),"Preferências"]}),a(Et,{variant:"outline",onClick:h,size:"sm",className:"w-full",children:[e(ma,{className:"mr-2 h-4 w-4"}),"Sair"]}),b&&e(Ut,{open:f,onOpenChange:g,children:a(Kt,{children:[e(Qt,{children:e(Xt,{children:"Preferências de Internacionalização"})}),e(Gc,{})]})})]})]})}),Xc=o({});function Yc({children:a,config:t}){const r=i(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return e(Xc.Provider,{value:r,children:a})}function Zc(){return l(Xc)}function em(){const e=Da(),{navigation:a}=Zc(),{t:t}=Pa();if(!a)return t("page");const r=a.find(a=>a.path===e.pathname);if(r)return r.label;const s=a.find(a=>e.pathname.startsWith(a.path+"/"));return s?.label||t("page")}function am(e,a){const[t,r]=n(()=>e),s=m(void 0),i=d(()=>{s.current&&(clearTimeout(s.current),s.current=void 0)},[]);return c(()=>(i(),s.current=setTimeout(()=>{r(e)},a),i),[e,a,i]),[t,i]}const tm=u(function({actions:t}){const r=Da(),s=em(),{navigation:i,appName:o}=Zc(),{metadata:l,headerActions:d}=$i(),{t:m}=Pa(),{companies:u,alias:h,isSearchVisible:p,clearSearch:f,refreshData:g,switchUnit:b}=Bs(),v=h?u?.find(e=>e.alias===h)||u?.[0]||null:u?.[0]||null,[y,N]=ja(),[x,w]=n(()=>y.get("search")||""),[k,C]=am(x,xs.debounceDelay);c(()=>{if(!p)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),N(e)},[k,N,p]);const _=i?.find(e=>e.path===r.pathname)||i?.find(e=>r.pathname.startsWith(e.path+"/")),P=l.title||s,I=l.subtitle||_?.complementaryText||m("item_details");return e("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:a("div",{className:"flex items-center gap-4",children:[a("div",{className:"flex-shrink-0",children:[a("div",{className:"flex items-center gap-2 mb-1",children:[e("h1",{className:"text-lg font-semibold text-foreground truncate",children:P}),e(wr,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:o||m("module")})]}),I&&e("p",{className:"text-sm text-muted-foreground truncate",children:I})]}),p&&a("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[a("div",{className:"relative flex-1",children:[e(j,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e(Tt,{placeholder:m("search"),value:x,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),x&&e(Et,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{C(),w("");const e=new URLSearchParams(y);e.delete("search"),e.delete("page"),N(e)},title:m("clear_search"),children:e(S,{size:14})})]}),e(Et,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0",title:m("refresh_data"),children:e(qe,{size:14})})]}),a("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(d||t)&&e("div",{className:"flex items-center gap-2",children:d||t}),import.meta.env.VITE_WIKI_URL&&e(Et,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>xt(import.meta.env.VITE_WIKI_URL,e),title:m("open_wiki"),children:"Wiki"}),e("div",{className:"text-sm",children:e(Jc,{variant:"dropdown",selectedUnit:v,onUnitChange:b})})]})]})})}),rm=({key:e,enabled:a,checkFn:t,staleTime:r=3e5,gcTime:s=6e5})=>Ra({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1}),sm=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Bs();return Ra({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=ls(),{data:a,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(r){if(!hs.handleError(r))throw r;return[]}return a||[]},enabled:a&&!!t})},nm="forlogic-sidebar-pinned",im=()=>{try{const e=localStorage.getItem(nm);return!!e&&JSON.parse(e)}catch{return!1}},om=e=>{const a=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return a[e%a.length]},lm=`https://${import.meta.env.VITE_SUPABASE_PROJECT_ID_STORAGE??import.meta.env.VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,dm={logo:`${lm}/${_s.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${lm}/${_s.isQualiex?"small-forlogic.svg":"small.svg"}`},cm=dm.logo,mm=dm.smallLogo;function um({appName:r,isPinned:s,onPinToggle:n,open:i,dropdownOpen:o,onDropdownChange:l}){const{t:d}=Pa(),{data:c,isLoading:m,error:u}=sm({enabled:o}),h=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(c,e)};return a(Md,{className:"p-0 gap-0",children:[e("div",{className:"flex items-center justify-between h-[34px]",children:i?a(t,{children:[e("div",{className:"flex items-center pl-[12px]",children:e("img",{src:dm.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e("button",{onClick:n,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(s?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e(He,{className:"h-4 w-4"})})]}):e("div",{className:"flex items-center justify-center w-full h-[34px]",children:e("img",{src:dm.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e("div",{className:"mt-2 pt-0",children:a(gn,{onOpenChange:l,children:[e(bn,{asChild:!0,children:i?a("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[a("div",{className:"flex items-center gap-2 min-w-0",children:[e("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:r})]}),e(_,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e(_,{className:"h-6 w-6 text-muted-foreground"})})}),e(Cn,{className:i?"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50":"w-[58px] bg-popover rounded-lg shadow-lg border border-border p-2 z-50",align:i?"start":"center",children:m?a("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e(E,{className:"h-4 w-4 animate-spin"}),e("span",{className:"text-sm",children:d("loading")})]}):u?a("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e(F,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:d("error")})]}):c&&0!==c.length?e("div",{className:"space-y-2",children:c.map((t,r)=>e("div",{onClick:()=>h(t.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${om(r)} transition-colors duration-200\n `,children:a("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-medium text-foreground text-sm",children:t.name}),t.url&&e(ua,{className:"h-4 w-4 text-muted-foreground"})]})},t.id))}):e("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:d("no_results")})})]})})]})}function hm({config:r,isCollapsed:s=!1,isDisabled:n=!1,className:i}){const{actions:o,triggerLabel:l="Criar",triggerIcon:d=V}=r;if(!o||0===o.length)return null;const c=(r,n,i=!1)=>a(t,{children:[r,!s&&n&&e("span",{className:"truncate",children:n}),!s&&i&&e(_,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const t=o[0],r=t.icon||d,l=n||t.disabled,m=e(Et,{onClick:t.onClick,disabled:l,className:wt("w-full gap-2 justify-start",s&&"justify-center px-2",i),variant:"outline",size:"default",children:c(e(r,{className:"h-4 w-4 shrink-0"}),t.label)});return s?a(mn,{children:[e(un,{asChild:!0,children:m}),e(hn,{side:"right",children:e("p",{children:t.label})})]}):m}const m=e(Et,{disabled:n,className:wt("w-full gap-2 justify-start",s&&"justify-center px-2",i),variant:"outline",size:"default",children:c(e(d,{className:"h-4 w-4 shrink-0"}),l,!0)});return a(gn,{children:[e(bn,{asChild:!0,children:s?a(mn,{children:[e(un,{asChild:!0,children:m}),e(hn,{side:"right",children:e("p",{children:l})})]}):m}),e(Cn,{align:"start",side:s?"right":"bottom",className:"w-56 bg-popover",children:o.map(t=>{const r=t.icon;return a(Sn,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[r&&e(r,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}function pm({direction:e="right",minWidth:a=224,maxWidth:t=384,defaultWidth:r=240,storageKey:s="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,u]=n(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(s);return e?parseInt(e):r}),[h,p]=n(!1),f=m(null);c(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(o?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,o]);const g=d(e=>{e.preventDefault(),p(!0)},[]);return c(()=>{if(!h)return;const r=r=>{let s;s="left"===e?window.innerWidth-r.clientX:r.clientX,s=Math.max(a,Math.min(t,s)),u(s),i?.(s)},n=()=>{p(!1),localStorage.setItem(s,l.toString())};return document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n)}},[h,e,a,t,l,s,i]),c(()=>{h?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[h,e]),{width:l,isDragging:h,dragRef:f,handleMouseDown:g}}const fm=o(void 0);function gm({children:a}){const[t,r]=n(new Set),[s,o]=n(!1),l=d(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),c=d(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),m=d(e=>{o(e)},[]),u=i(()=>t.size>0||s,[t,s]),h=i(()=>({openModals:t,hasOpenModal:u,registerModal:l,unregisterModal:c,setHasOpenModal:m}),[t,u,l,c,m]);return e(fm.Provider,{value:h,children:a})}function bm(){const e=l(fm);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function vm(){const{hasOpenModal:e}=bm();return e}function ym({config:t,customContent:r,resizable:s=!1,minWidth:i=224,maxWidth:o=384}={}){const{t:l}=Pa(),{open:d,setOpen:u}=Pd(),h=Da(),{alias:p,user:f}=Bs(),{hasOpenModal:g}=bm(),[b,v]=n(!1),[y,N]=n(im),[x,w]=n(!1),k=m(!1),C=s?pm({minWidth:i,maxWidth:o,storageKey:"app-sidebar-width",isOpen:d}):null;c(()=>{u(!!y||!(!x&&!b))},[y,x,b,u]);return a(Ed,{collapsible:"icon",onMouseEnter:()=>{y||k.current||w(!0)},onMouseLeave:()=>{y||w(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:C&&d?{width:`${C.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e(um,{appName:t?.appName||l("module_title"),isPinned:y,onPinToggle:()=>{const e=!y;N(e),(e=>{try{localStorage.setItem(nm,JSON.stringify(e))}catch{}})(e),e||(k.current=!0,w(!1),u(!1),setTimeout(()=>{k.current=!1},300))},open:d,dropdownOpen:b,onDropdownChange:v}),t?.moduleActions&&t.moduleActions.actions.length>0&&e("div",{className:"px-3 py-2",children:e(cn,{children:e(hm,{config:t.moduleActions,isCollapsed:!d,isDisabled:g})})}),e(Dd,{children:r||e(Ld,{className:"p-0 mt-6",children:e(Ud,{children:e(Wd,{className:"space-y-2",children:e(cn,{children:t?.navigation?.map((t,r)=>{const s=({item:t,index:r})=>{const n=`${t.path}-${r}-${p??"noalias"}-${f?.id??"nouser"}`,{data:i=!0,isLoading:o}=rm({key:n,enabled:Boolean(t.permissionCheck&&p&&f?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),d=t.permissionCheck&&!i;if(d&&"Admin"===t.label)return null;const c=o?E:d?ne:t.icon;d?l("restricted_access"):t.complementaryText;return t.children&&t.children.length>0?e(ro,{defaultOpen:!0,className:"group/collapsible",children:a(qd,{children:[e(so,{asChild:!0,children:e(Bd,{size:"lg",className:"h-10",children:a("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label}),e(L,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e(no,{children:e(Gd,{children:t.children.map((a,t)=>e(s,{item:a,index:t},a.path))})})]})},t.path):e(qd,{children:d||o?a(mn,{children:[e(un,{asChild:!0,children:e(Bd,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:a("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})}),e(hn,{children:e("p",{children:l(o?"checking_access":"restricted_access")})})]}):e(Bd,{asChild:!0,isActive:(m=t.path,h.pathname===m||h.pathname.startsWith(m+"/")),size:"lg",className:"h-10",children:a(Oa,{to:t.path,className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})},t.path);var m};return e(s,{item:t,index:r},t.path)})})})})})}),s&&C&&d&&e("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:wt("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",C.isDragging&&"bg-primary/40")})]})}const Nm=u(function({children:t,sidebar:r,sidebarConfig:s,showHeader:n=!0}){const o=i(()=>r||e(ym,{config:s}),[r,s]),l=i(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e(Yc,{config:s,children:e(Oi,{children:e(Id,{defaultOpen:!1,style:l,children:a("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,a("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e(tm,{})}),e("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})}),xm={"pt-BR":nl,"en-US":Ho,"es-ES":Zo},wm=(e,a="pt-BR")=>{if(!e)return"";const t=v(e);if(!y(t))return"Invalid date";return N(t,"PP",{locale:xm[a]||nl})},km=()=>{const{locale:e,timezone:a,datetimeFormat:t}=ao();return{formatDatetime:e=>((e,a="dd/MM/yyyy HH:mm")=>{if(!e)return"";const t=v(e);return y(t)?N(t,a):"Invalid date"})(e,t,a),formatDate:a=>wm(a,e),locale:e,timezone:a,datetimeFormat:t}};class Cm{static async sendEmail(e){const a=ls(),{data:t,error:r}=await a.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(r)throw r;return t}}const Sm=Cm;function _m({open:t,onOpenChange:r,placeId:s,placeName:o,onMakeManager:l,onMakeMembers:d,currentManagerId:c,currentMemberIds:m=[]}){const{t:u}=Pa(),[h,p]=n([]),[f,g]=n(!1),[b,v]=n(""),{data:y=[],isLoading:N}=oi({enabled:t}),x=i(()=>{let e=[...y];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",r=a.userName?.toLowerCase()||"";return t.localeCompare(r)}),b){const a=b.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[y,b]),w=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},k=1===h.length,C=h.length>0;return e(Ut,{open:t,onOpenChange:r,children:a(Kt,{className:"max-w-2xl",children:[e(Qt,{children:a(Xt,{className:"flex items-center gap-2",children:[e(ha,{className:"h-5 w-5"}),"Gerenciar Acessos - ",o]})}),a("div",{className:"relative",children:[e(j,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(Tt,{placeholder:u("search_placeholder"),value:b,onChange:e=>v(e.target.value),className:"pl-9"})]}),e(ti,{className:"h-[400px] pr-4",children:N?e("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e(Or,{className:"h-16 w-full"},t))}):0===x.length?a("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e(ha,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e("p",{className:"text-sm text-muted-foreground",children:b?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e("div",{className:"space-y-2",children:x.map(t=>{const r=t.userId===c,s=m.includes(t.userId||""),n=h.includes(t.userId||"");return a("div",{className:wt("flex items-center gap-3 p-3 rounded-lg border transition-colors",n&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e(yr,{checked:n,onCheckedChange:()=>w(t.userId||""),onClick:e=>e.stopPropagation()}),a("div",{className:"flex-1",children:[a("div",{className:"flex items-center gap-2",children:[e("p",{className:"font-medium",children:t.userName}),r&&e(pa,{className:"h-4 w-4 text-yellow-500"})]}),e("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(r||s)&&e("div",{className:"text-xs text-muted-foreground",children:r?"Gestor":"Membro"})]},t.userId)})})}),a(Jt,{className:"flex gap-2 sm:gap-2",children:[e("div",{className:"flex-1 text-sm text-muted-foreground",children:h.length>0&&a("span",{children:[h.length," selecionado(s)"]})}),k&&l&&a(Et,{onClick:async()=>{if(l&&1===h.length){g(!0);try{await l(h[0],s),p([])}finally{g(!1)}}},disabled:f,variant:"outline",children:[e(pa,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&d&&a(Et,{onClick:async()=>{if(d&&0!==h.length){g(!0);try{await d(h,s),p([])}finally{g(!1)}}},disabled:f,children:[e(fa,{className:"h-4 w-4 mr-2"}),"Tornar ",h.length>1?"Membros":"Membro"]})]})]})})}function Pm({place:t,level:r=0,manageAccessConfig:s}){const[i,o]=n(!1),[l,d]=n(!1),c=t.subPlaces&&t.subPlaces.length>0,m=t.isActive??!0,u=t.usersCount??0;return a("div",{children:[a(ro,{open:i,onOpenChange:o,children:[a("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*r+1+"rem"},children:[c?a(so,{className:"flex items-center gap-2 flex-1",children:[e(L,{className:wt("h-4 w-4 transition-transform shrink-0",i&&"rotate-90")}),e(ca,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:t.name}),a("span",{className:"text-sm text-muted-foreground",children:["(",t.subPlaces.length,")"]})]}):a("div",{className:"flex items-center gap-2 flex-1",children:[e("div",{className:"w-4 shrink-0"}),e(ca,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:t.name})]}),a("div",{className:"flex items-center gap-3 ml-auto",children:[a("div",{className:"flex items-center gap-1.5",children:[e(ha,{className:"h-3.5 w-3.5 text-muted-foreground"}),e("span",{className:"text-sm text-muted-foreground",children:u})]}),e(wr,{variant:m?"default":"secondary",className:"text-xs",children:m?"Ativo":"Inativo"}),s&&e(Wc,{customActions:[{label:"Gerenciar Acessos",icon:Me,onClick:()=>d(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e(no,{children:t.subPlaces.map(a=>e(Pm,{place:a,level:r+1,manageAccessConfig:s},a.id))})]}),0===r&&e($t,{}),s&&e(_m,{open:l,onOpenChange:d,placeId:t.id,placeName:t.name,onMakeManager:s.onMakeManager,onMakeMembers:s.onMakeMembers,currentManagerId:s.getCurrentManagerId?.(t.id),currentMemberIds:s.getCurrentMemberIds?.(t.id)})]})}function Im({places:t,isLoading:r,manageAccessConfig:s}){const{t:n}=Pa();return r?e("div",{className:"flex items-center justify-center py-12",children:a("div",{className:"text-center space-y-2",children:[e("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e("p",{className:"text-sm text-muted-foreground",children:n("loading_data")})]})}):t&&0!==t.length?a("div",{className:"space-y-1",children:[e("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(a=>e(Pm,{place:a,manageAccessConfig:s},a.id))]}):a("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e(ca,{className:"h-12 w-12 text-muted-foreground/50"}),a("div",{children:[e("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var Em=Object.defineProperty,Am=(e,a,t)=>((e,a,t)=>a in e?Em(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Tm=new class{constructor(){Am(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const r=fs.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=Yr.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const r=a.get(e.id);if(e.parentId){const s=a.get(e.parentId);s?(s.subPlaces=s.subPlaces||[],s.subPlaces.push(r)):t.push(r)}else t.push(r)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),r=t.data||t||[];return this.buildHierarchy(r)}catch(t){if(await fs.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),r=t.data||t||[];return this.buildHierarchy(r)}catch(r){return as.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return as.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Rm(e,a){const t=e.map(e=>({...e})),r=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&r.has(e.id_leader)){let a=e.id_leader;for(;a&&r.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))}function zm(e){const a=new Map,t=new Map,r=[];e.forEach(e=>{const r={...e,children:[],level:0};a.set(e.id,r),t.set(e.id_user,r)}),e.forEach(e=>{const s=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(s)}r.push(s)});const s=(e,a)=>{e.level=a,e.children.forEach(e=>s(e,a+1))};r.forEach(e=>s(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",r=a.name||a.id_user||a.email||"";return t.localeCompare(r)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(r),r}function Mm(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Fm(){const{alias:e,isAuthenticated:a}=Bs(),t=Yr.getAccessToken(),{data:r=[]}=oi({enabled:!0});return Ra({queryKey:["leadership",e,r.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=ls(),{data:s,error:n}=await a.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!s||0===s.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=s.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:s.filter(a=>a.id_leader===e.id_user).length})),l=new Set(s.map(e=>e.id_user));return new Set(s.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e];o.push({id:`virtual-${e}`,alias:s[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:a?.name||"[Não encontrado]",email:a?.email||"",subordinatesCount:s.filter(a=>a.id_leader===e).length})}),zm(o)},enabled:!!t&&!!e&&a&&r.length>0})}function jm(){const e="common",{alias:a}=Bs(),t=Ta(),r=ls();return za({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await r.schema(e).from("leaders").select("id").eq("alias",a).eq("id_user",t.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");t.id_leader&&await Wm(r,a,e,t.id_user,t.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success("Líder adicionado com sucesso")},onError:e=>{w.error(e.message||"Erro ao adicionar líder")}})}function Dm(){const e="common",{alias:a}=Bs(),t=Ta(),r=ls();return za({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await Wm(r,a,e,t.id_user,t.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success("Líder virtual promovido com sucesso")},onError:e=>{w.error(e.message||"Erro ao criar líder")}})}function Lm(){const e="common",{alias:a}=Bs(),t=Ta(),r=ls();return za({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(!t.users.length)throw new Error("Selecione pelo menos um liderado");const s=t.users.map(e=>e.id_user),{data:n}=await r.schema(e).from("leaders").select("id_user").eq("alias",a).in("id_user",s).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const d of t.users){if(t.id_leader&&d.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await Wm(r,a,e,d.id_user,t.id_leader)}const i=t.users.map(e=>({alias:a,id_user:e.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await r.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{w.error(e.message||"Erro ao adicionar liderados")}})}function Om(){const e="common",{alias:a}=Bs(),t=Ta(),r=ls();return za({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:s}=await r.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!s)throw new Error("Líder não encontrado");if(s.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await Wm(r,a,e,s.id_user,t.id_leader,t.id);const{data:n,error:i}=await r.schema(e).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",a).select().single();if(i)throw i;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success("Líder atualizado com sucesso")},onError:e=>{w.error(e.message||"Erro ao atualizar líder")}})}function $m(){const{alias:e}=Bs(),a=Ta(),t=ls();return za({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:r}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),w.success("Líder removido com sucesso")},onError:e=>{w.error(e.message||"Erro ao remover líder")}})}function Um(){const e="common",{alias:a}=Bs(),t=Ta(),r=ls();return za({mutationFn:async({leaderUserId:t,selectedUsers:s})=>{if(!a)throw new Error("Unidade não selecionada");const n=s.map(e=>e.id_user),i=await Promise.all([r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).eq("id_leader",t),r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:o,error:l},{data:d,error:c}]=i;if(l)throw l;if(c)throw c;const m=o||[],u=d||[],h=new Set(n),p=m.filter(e=>!h.has(e.id_user)),f=u.filter(e=>e.id_leader!==t),g=new Set(u.map(e=>e.id_user)),b=s.filter(e=>!g.has(e.id_user));for(const N of f)await Wm(r,a,e,N.id_user,t,N.id);for(const N of b){if(N.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await Wm(r,a,e,N.id_user,t)}const v=[];if(p.length){const t=p.map(e=>e.id);v.push(r.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(f.length){const s=f.map(e=>e.id);v.push(r.schema(e).from("leaders").update({id_leader:t}).in("id",s).eq("alias",a))}if(b.length){const s=b.map(e=>({alias:a,id_user:e.id_user,id_leader:t,is_active:!0,is_removed:!1}));v.push(r.schema(e).from("leaders").insert(s))}const y=(await Promise.all(v)).find(e=>e?.error);if(y?.error)throw y.error;return{unlinked:p.length,updated:f.length,created:b.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{w.error(e.message||"Erro ao sincronizar subordinados")}})}async function Wm(e,a,t,r,s,n){const{data:i,error:o}=await e.schema(t).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1);if(o)throw o;const l=n?i.filter(e=>e.id!==n):i,d=new Set;let c=s;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===r)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const e=l.find(e=>e.id_user===c);c=e?.id_leader||null}}function qm({leader:r,expandedIds:s,onToggleExpand:n,onEdit:i}){const o=s.has(r.id),l=r.children.length>0,d=32*r.level;return a(t,{children:[a("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e("td",{className:"py-3 px-4",children:a("div",{className:"flex items-center gap-2",style:{paddingLeft:`${d}px`},children:[l?e("button",{onClick:()=>n(r.id),className:"p-1 hover:bg-accent rounded",children:e(o?_:L,{className:"h-4 w-4"})}):e("div",{className:"w-6"}),e(Fe,{className:"h-4 w-4 text-muted-foreground"}),e("button",{onClick:()=>{i(r)},className:"font-medium hover:text-primary hover:underline text-left",children:r.name||r.id_user||r.email})]})}),e("td",{className:"py-3 px-4 text-center",children:e("span",{className:"text-sm",children:r.subordinatesCount||0})})]}),l&&o&&r.children.map(a=>e(qm,{leader:a,expandedIds:s,onToggleExpand:n,onEdit:i},a.id))]})}function Vm(e,a,t){function r(t,r){if(t._zod||Object.defineProperty(t,"_zod",{value:{def:r,constr:i,traits:new Set},enumerable:!1}),t._zod.traits.has(e))return;t._zod.traits.add(e),a(t,r);const s=i.prototype,n=Object.keys(s);for(let e=0;e<n.length;e++){const a=n[e];a in t||(t[a]=s[a].bind(t))}}const s=t?.Parent??Object;class n extends s{}function i(e){var a;const s=t?.Parent?new n:this;r(s,e),(a=s._zod).deferred??(a.deferred=[]);for(const t of s._zod.deferred)t();return s}return Object.defineProperty(n,"name",{value:e}),Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>!!(t?.Parent&&a instanceof t.Parent)||a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Bm extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Hm={};function Km(e){return Hm}function Qm(e,a){return"bigint"==typeof a?a.toString():a}const Gm="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jm(e){return"string"==typeof e?e:e?.message}function Xm(e,a,t){const r={...e,path:e.path??[]};if(!e.message){const s=Jm(e.inst?._zod.def?.error?.(e))??Jm(a?.error?.(e))??Jm(t.customError?.(e))??Jm(t.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,a?.reportInput||delete r.input,r}const Ym=(e,a)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:a,enumerable:!1}),e.message=JSON.stringify(a,Qm,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zm=Vm("$ZodError",Ym),eu=Vm("$ZodError",Ym,{Parent:Error}),au=e=>(a,t,r,s)=>{const n=r?Object.assign(r,{async:!1}):{async:!1},i=a._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new Bm;if(i.issues.length){const a=new(s?.Err??e)(i.issues.map(e=>Xm(e,n,Km())));throw Gm(a,s?.callee),a}return i.value},tu=au(eu),ru=e=>async(a,t,r,s)=>{const n=r?Object.assign(r,{async:!0}):{async:!0};let i=a._zod.run({value:t,issues:[]},n);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(s?.Err??e)(i.issues.map(e=>Xm(e,n,Km())));throw Gm(a,s?.callee),a}return i.value},su=ru(eu);function nu(e,a){try{var t=e()}catch(e){return a(e)}return t&&t.then?t.then(void 0,a):t}function iu(e,a){for(var t={};e.length;){var r=e[0],s=r.code,n=r.message,i=r.path.join(".");if(!t[i])if("unionErrors"in r){var o=r.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[r.code];t[i]=wa(i,a,t,s,d?[].concat(d,r.message):r.message)}e.shift()}return t}function ou(e,a){for(var t={};e.length;){var r=e[0],s=r.code,n=r.message,i=r.path.join(".");if(!t[i])if("invalid_union"===r.code&&r.errors.length>0){var o=r.errors[0][0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:s};if("invalid_union"===r.code&&r.errors.forEach(function(a){return a.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[r.code];t[i]=wa(i,a,t,s,d?[].concat(d,r.message):r.message)}e.shift()}return t}function lu(e,a,t){if(void 0===t&&(t={}),"_def"in(r=e)&&"object"==typeof r._def&&"typeName"in r._def)return function(s,n,i){try{return Promise.resolve(nu(function(){return Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return i.shouldUseNativeValidation&&yt({},i),{errors:{},values:t.raw?Object.assign({},s):e}})},function(e){if(function(e){return Array.isArray(null==e?void 0:e.issues)}(e))return{values:{},errors:Nt(iu(e.errors,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)};throw e}))}catch(r){return Promise.reject(r)}};var r;if(function(e){return"_zod"in e&&"object"==typeof e._zod}(e))return function(s,n,i){try{return Promise.resolve(nu(function(){return Promise.resolve(("sync"===t.mode?tu:su)(e,s,a)).then(function(e){return i.shouldUseNativeValidation&&yt({},i),{errors:{},values:t.raw?Object.assign({},s):e}})},function(e){if(function(e){return e instanceof Zm}(e))return{values:{},errors:Nt(ou(e.issues,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)};throw e}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")}const du=vt.object({id_leader:vt.string().nullable(),id_users:vt.array(vt.string()).min(1,"Selecione pelo menos um liderado")}),cu=vt.object({id_leader:vt.string().nullable(),id_users:vt.array(vt.string())});function mu({value:t,onChange:r,excludeUserIds:s=[],error:i}){const{data:o=[],isLoading:l}=oi(),[d,u]=n(""),h=m(null),p=m(0),{t:f}=Pa(),g=o.filter(e=>!s.includes(e.userId||"")).filter(e=>{const a=d.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const r=t.includes(e.userId),s=t.includes(a.userId);if(r&&!s)return-1;if(!r&&s)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return c(()=>{h.current&&p.current>0&&(h.current.scrollTop=p.current)},[g]),a("div",l?{className:"flex items-center justify-center p-4",children:[e(E,{className:"h-6 w-6 animate-spin"}),e("span",{className:"ml-2",children:f("loading_data")})]}:{className:"space-y-2",children:[e(Tt,{placeholder:f("search_user"),value:d,onChange:e=>u(e.target.value)}),e("div",{ref:h,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===g.length?e("p",{className:"text-sm text-muted-foreground",children:f("search_user")}):e("div",{className:"space-y-2",children:g.map(s=>a("div",{className:"flex items-center space-x-2",children:[e(yr,{id:s.userId,checked:t.includes(s.userId),onCheckedChange:()=>{return e=s.userId,h.current&&(p.current=h.current.scrollTop),void(t.includes(e)?r(t.filter(a=>a!==e)):r([...t,e]));var e}}),e(zt,{htmlFor:s.userId,className:"flex-1 cursor-pointer",children:s.userName||s.userEmail})]},s.userId))})}),t.length>0&&e("p",{className:"text-sm text-muted-foreground",children:f("selected_count",{count:t.length})}),i&&e("p",{className:"text-sm text-destructive",children:i})]})}function uu({leader:r,prefilledLeaderId:s,onSuccess:i}){const{t:o}=Pa(),{alias:l}=Bs(),d=!!r,m=r?.id.startsWith("virtual-"),u=Lm(),h=Dm(),p=Om(),f=Um(),g=$m(),{data:b=[]}=Fm(),{data:v=[]}=oi(),[y,N]=n(""),x=Mm(b).map(e=>e.id_user),w=d?Mm(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user):[],k=ka({resolver:lu(d?cu:du),defaultValues:{id_leader:s||(d?r?.id_leader:null)||null,id_users:d?w:[]}});c(()=>{if(r){const e=Mm(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user);k.reset({id_leader:r.id_leader||null,id_users:e})}else s?k.reset({id_leader:s,id_users:[]}):k.reset({id_leader:null,id_users:[]})},[l,r?.id,r?.id_user,r?.id_leader,s,b]);const C=u.isPending||h.isPending||p.isPending||f.isPending||g.isPending,S=k.watch("id_leader"),_=k.watch("id_users"),P=d?[r.id_user,...x.filter(e=>e!==r.id_user&&!_.includes(e)&&!w.includes(e))]:[S,...x.filter(e=>!_.includes(e))].filter(Boolean);return a("form",{onSubmit:k.handleSubmit(async e=>{try{if(d)if(m){await h.mutateAsync({id_user:r.id_user,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:a})}else{await p.mutateAsync({id:r.id,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:a})}else{const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({id_leader:e.id_leader,users:a})}i?.()}catch(a){}}),className:"space-y-4",children:[d&&a("div",{children:[e(zt,{children:o("leader")}),e(Tt,{value:v.find(e=>e.userId===r.id_user)?.userName||r.name||r.id_user,disabled:!0,className:"bg-muted"})]}),a("div",{children:[e(zt,{children:o("superior")}),a(dr,{value:S||"none",onValueChange:e=>k.setValue("id_leader","none"===e?null:e),children:[e(ur,{children:e(mr,{placeholder:o("select_placeholder")})}),a(fr,{children:[e("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e(Tt,{placeholder:o("superior_search"),value:y,onChange:e=>N(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),a(ti,{className:"h-[200px]",children:[e(br,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const a=d?e.userId!==r.id_user:!_.includes(e.userId),t=!y||e.userName?.toLowerCase().includes(y.toLowerCase());return a&&t}).sort((e,a)=>{const t=e.userName||e.userEmail||"",r=a.userName||a.userEmail||"";return t.localeCompare(r)}).map(a=>e(br,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${l}`),k.formState.errors.id_leader&&e("p",{className:"text-sm text-destructive mt-1",children:k.formState.errors.id_leader.message})]}),a("div",{children:[a(zt,{children:[o("subordinates")," *"]}),e(mu,{value:_,onChange:e=>k.setValue("id_users",e),excludeUserIds:P,error:k.formState.errors.id_users?.message},`users-multiselect-${l}`)]}),a("div",{className:"flex items-center justify-between gap-2",children:[e(Et,{type:"submit",disabled:C||!d&&0===_.length,children:C&&!g.isPending?a(t,{children:[e(E,{className:"mr-2 h-4 w-4 animate-spin"}),o(d?"updating":"saving")]}):d?_.length>0?o("update_success",{count:_.length}):o("update"):o("create_success",{count:_.length})}),d&&!S&&0===_.length&&e(Et,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(r&&window.confirm(o("remove_confirm")))try{await g.mutateAsync(r.id),i?.()}catch(e){}},className:"ml-auto",children:g.isPending?a(t,{children:[e(E,{className:"mr-2 h-4 w-4 animate-spin"}),o("removing")]}):a(t,{children:[e(q,{className:"mr-2 h-4 w-4"}),o("remove")]})})]})]})}function hu({open:t,onOpenChange:r,leader:s,prefilledLeaderId:n,title:i}){return e(Ut,{open:t,onOpenChange:r,children:a(Kt,{className:"sm:max-w-[500px]",children:[e(Qt,{children:e(Xt,{children:i})}),e(uu,{leader:s,prefilledLeaderId:n,onSuccess:()=>r(!1)})]})})}const pu="leadership-expanded-nodes",fu=(e,a)=>{try{localStorage.setItem(`${pu}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function gu(){const{alias:t}=Bs(),{t:r}=Pa(),{data:s,isLoading:i,error:o,refetch:l}=Fm(),{data:d=[]}=oi({enabled:!0}),[m,u]=n(()=>t?(e=>{try{const a=localStorage.getItem(`${pu}-${e}`);if(a)return new Set(JSON.parse(a))}catch(o){}return new Set})(t):new Set),[h,p]=n(!1),[f,g]=n(),[b,v]=n(null),y=d.filter(e=>e.userName&&"Nome não disponível"!==e.userName),N=new Set(y.map(e=>e.userId)),x=y.length-(s?Mm(s).filter(e=>N.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);c(()=>{if(s&&s.length>0&&t){if(!localStorage.getItem(`${pu}-${t}`)){const e=s.map(e=>e.id),a=new Set(e);u(a),fu(t,a)}}},[s,t]);const w=e=>{u(a=>{const r=new Set(a);return r.has(e)?r.delete(e):r.add(e),t&&fu(t,r),r})},k=e=>{g(e),v(null),p(!0)};return i?e("div",{className:"flex items-center justify-center h-full",children:a("div",{className:"text-center",children:[e(qe,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e("p",{className:"text-muted-foreground",children:r("loading")})]})}):o?e("div",{className:"flex items-center justify-center h-full",children:a("div",{className:"text-center",children:[e("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e(Et,{onClick:()=>l(),children:"Tentar novamente"})]})}):a("div",{className:"flex flex-col h-full",children:[e("div",{className:"flex items-center justify-between p-4 border-b",children:a("div",{className:"flex gap-2 items-center",children:[a(Et,{size:"sm",onClick:()=>{g(void 0),v(null),p(!0)},children:[e(V,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),a(Et,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=Mm(s).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&fu(t,a)},disabled:!s||0===s.length,children:[e(_,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),a(Et,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&fu(t,e)},disabled:!s||0===s.length,children:[e(L,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e("div",{className:"flex items-center gap-2 ml-4",children:a("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e(ha,{className:"h-4 w-4 text-muted-foreground"}),a("span",{className:"text-sm font-medium",children:[x," usuário",1!==x?"s":""," não associado",1!==x?"s":""]})]})})]})}),s&&0!==s.length?e(ti,{className:"flex-1",children:e("div",{children:a("table",{className:"w-full",children:[e("thead",{children:a("tr",{className:"border-b bg-muted/50",children:[e("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e("tbody",{children:s.map(a=>e(qm,{leader:a,expandedIds:m,onToggleExpand:w,onEdit:k},a.id))})]})})}):e("div",{className:"flex items-center justify-center flex-1",children:a("div",{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e(hu,{open:h,onOpenChange:()=>{p(!1),g(void 0),v(null)},leader:f,prefilledLeaderId:b,title:f?r("edit")+" "+r("name"):b?r("add")+" Liderado":r("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})}function bu(e){const[a,t]=n(!1),[r,s]=n(0),{t:i}=Pa(),{uploadFunction:o,deleteFunction:l,defaultOptions:d,onSuccess:c,onError:m}=e||{};return{upload:async(e,a)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw w.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}t(!0),s(0);try{const t={...d,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const r=await o(e,t);return s(100),w.success("Sucesso",{description:i("file_upload_success")}),c?.(r),r}catch(r){const e=r instanceof Error?r:new Error("Erro ao fazer upload");throw w.error("Erro",{description:e.message}),m?.(e),e}finally{t(!1)}},deleteMedia:async(e,a)=>{if(!l){const e=new Error("deleteFunction não fornecida");throw w.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await l(e,a),w.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw w.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:a,progress:r}}function vu(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function yu(e,a){const t=vu(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function Nu(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function xu(e,a){const t=Nu(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function wu(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function ku(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Cu(e,a,t){switch(a||ku(e)){case"youtube":return yu(e,t);case"vimeo":return xu(e,t);default:return e}}function Su({value:r,onChange:s,onSubmit:o,onCancel:l,uploadFunction:d,deleteFunction:c,uploadOptions:u}){const{t:h}=Pa(),[p,f]=n(r||{inputType:"url",controls:!0}),g=m(null),b=m(null),{upload:v,uploading:y}=bu({uploadFunction:d,deleteFunction:c,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:N,uploading:x}=bu({uploadFunction:d,deleteFunction:c,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),k=i(()=>ku(p.videoUrl||wu(p.embedCode)||""),[p.videoUrl,p.embedCode]),C=(e,a)=>{const t={...p,[e]:a};f(t),s(t)};return a("div",{className:"space-y-6",children:[a("div",{className:"space-y-2",children:[e(zt,{children:h("input_type")}),a(dr,{value:p.inputType||"url",onValueChange:e=>C("inputType",e),children:[e(ur,{children:e(mr,{})}),a(fr,{children:[e(br,{value:"url",children:h("url")}),e(br,{value:"upload",children:h("input_type_upload")}),e(br,{value:"embed",children:h("input_type_embed")})]})]})]}),"upload"===p.inputType&&d&&a("div",{className:"space-y-2",children:[e(zt,{children:h("file")}),a("div",{className:"flex gap-2",children:[e("input",{ref:g,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||a.name.replace(/\.[^/.]+$/,"")};f(t),s(t)}catch(t){}finally{g.current&&(g.current.value="")}},className:"hidden"}),e(Et,{type:"button",variant:"outline",onClick:()=>g.current?.click(),disabled:y,children:a(t,y?{children:[e(E,{className:"mr-2 h-4 w-4 animate-spin"}),h("uploading")]}:{children:[e(he,{className:"mr-2 h-4 w-4"}),h("select_video")]})}),p.videoFile&&e("span",{className:"text-xs text-muted-foreground truncate self-center",children:h("video.fileInfo",{name:p.videoFile,size:Math.round((p.videoSize||0)/1024/1024)})})]})]}),"embed"===p.inputType&&a("div",{className:"space-y-2",children:[e(zt,{children:h("embed")}),e(Nr,{placeholder:h("embed"),value:p.embedCode||"",onChange:e=>C("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),d&&a("div",{className:"space-y-2",children:[e(zt,{children:h("thumbnail")}),a("div",{className:"flex gap-2",children:[e(Tt,{type:"url",placeholder:h("thumbnail"),value:p.thumbnail||"",onChange:e=>C("thumbnail",e.target.value),className:"flex-1"}),e("input",{ref:b,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await N(a),t={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};f(t),s(t)}catch(t){}finally{b.current&&(b.current.value="")}},className:"hidden"}),e(Et,{type:"button",variant:"outline",onClick:()=>b.current?.click(),disabled:x,children:a(t,x?{children:[e(E,{className:"mr-2 h-4 w-4 animate-spin"}),h("video.uploading")]}:{children:[e(he,{className:"mr-2 h-4 w-4"}),h("upload")]})})]}),p.thumbnailFile&&e("p",{className:"text-xs text-muted-foreground",children:h("video.thumbnailFileInfo",{name:p.thumbnailFile})})]}),a("div",{className:"space-y-2",children:[e(zt,{htmlFor:"title",children:h("title")}),e(Tt,{id:"title",placeholder:h("title"),value:p.title||"",onChange:e=>C("title",e.target.value)})]}),a("div",{className:"flex gap-6",children:[a("div",{className:"flex items-center gap-2",children:[e("input",{id:"autoplay",type:"checkbox",checked:p.autoplay||!1,onChange:e=>C("autoplay",e.target.checked),className:"h-4 w-4"}),e(zt,{htmlFor:"autoplay",className:"cursor-pointer",children:h("video.autoplay")})]}),a("div",{className:"flex items-center gap-2",children:[e("input",{id:"controls",type:"checkbox",checked:!1!==p.controls,onChange:e=>C("controls",e.target.checked),className:"h-4 w-4"}),e(zt,{htmlFor:"controls",className:"cursor-pointer",children:h("video.controls")})]})]}),a("div",{className:"space-y-2",children:[e(zt,{children:h("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=p.videoUrl||wu(p.embedCode)||"";if(!t)return e("div",{className:"text-center py-8 text-muted-foreground",children:h("no_content_preview")});if("file"===k)return a("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e("source",{src:t}),h("unsupported")]});const r="youtube"===k?yu(t,p.autoplay):xu(t,p.autoplay);return e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:p.title||h("video"),src:r,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),a("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Et,{variant:"outline",onClick:l,children:h("cancel")}),e(Et,{onClick:()=>{p.videoUrl||p.embedCode?o(p):w.error(h("error"),{description:h("error_no_video")})},disabled:!(p.videoUrl||p.embedCode),children:h("save")})]})]})}function _u({content:t,className:r="",style:s}){const n=t.videoUrl||wu(t.embedCode)||"";if(!n)return null;const i=ku(n),{t:o}=Pa();return e(Mt,{className:`overflow-hidden my-4 ${r}`,style:s,children:a(Lt,{className:"p-0",children:["file"===i?a("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:t.title||o("video"),src:"youtube"===i?yu(n,t.autoplay):xu(n,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e("div",{className:"p-4",children:e("p",{className:"text-sm font-medium",children:t.title})})]})})}function Pu({value:r,onChange:s,onSubmit:i,onCancel:o,uploadFunction:l,deleteFunction:d,uploadOptions:c}){const{t:u}=Pa(),[h,p]=n(r||{alignment:"center",allowDownload:!1}),f=m(null),{upload:g,uploading:b}=bu({uploadFunction:l,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),v=(e,a)=>{const t={...h,[e]:a};p(t),s(t)};return a("div",{className:"space-y-6",children:[a("div",{className:"space-y-2",children:[e(zt,{children:u("url")}),a("div",{className:"flex gap-2",children:[e(Tt,{type:"url",placeholder:u("url_placeholder"),value:h.imageUrl||"",onChange:e=>v("imageUrl",e.target.value),className:"flex-1"}),l&&a(t,{children:[e("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...h,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{f.current&&(f.current.value="")}},className:"hidden"}),e(Et,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:b,children:a(t,b?{children:[e(E,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}:{children:[e(he,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),h.imageFile&&e("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:h.imageFile,size:Math.round((h.imageSize||0)/1024)})})]}),h.imageUrl&&a("div",{className:"space-y-2",children:[e(zt,{children:u("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:e("div",{className:"flex "+("left"===h.alignment?"justify-start":"right"===h.alignment?"justify-end":"justify-center"),children:e("img",{src:h.imageUrl,alt:h.alt||"Preview",style:{width:h.width?`${h.width}px`:"auto",height:h.height?`${h.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),a("div",{className:"space-y-2",children:[e(zt,{htmlFor:"caption",children:u("caption")}),e(Nr,{id:"caption",placeholder:u("caption"),value:h.caption||"",onChange:e=>v("caption",e.target.value),rows:2})]}),a("div",{className:"space-y-2",children:[e(zt,{htmlFor:"alt",children:u("alt")}),e(Tt,{id:"alt",placeholder:u("alt"),value:h.alt||"",onChange:e=>v("alt",e.target.value)})]}),a("div",{className:"space-y-2",children:[e(zt,{children:u("alignment")}),a(dr,{value:h.alignment||"center",onValueChange:e=>v("alignment",e),children:[e(ur,{children:e(mr,{})}),a(fr,{children:[e(br,{value:"left",children:u("left")}),e(br,{value:"center",children:u("center")}),e(br,{value:"right",children:u("right")})]})]})]}),a("div",{className:"grid grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(zt,{htmlFor:"width",children:u("width")}),e(Tt,{id:"width",type:"number",placeholder:"px",value:h.width||"",onChange:e=>v("width",e.target.value?Number(e.target.value):void 0)})]}),a("div",{className:"space-y-2",children:[e(zt,{htmlFor:"height",children:u("height")}),e(Tt,{id:"height",type:"number",placeholder:"px",value:h.height||"",onChange:e=>v("height",e.target.value?Number(e.target.value):void 0)})]})]}),a("div",{className:"flex items-center gap-2",children:[e("input",{id:"allowDownload",type:"checkbox",checked:h.allowDownload||!1,onChange:e=>v("allowDownload",e.target.checked),className:"h-4 w-4"}),e(zt,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),a("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Et,{variant:"outline",onClick:o,children:u("cancel")}),e(Et,{onClick:()=>{h.imageUrl?i(h):w.error(u("error"),{description:u("error_no_image")})},disabled:!h.imageUrl,children:u("save")})]})]})}function Iu({content:t,className:r="",style:s}){if(!t.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e("div",{className:`flex ${n} my-4 ${r}`,style:s,children:a("div",{className:"space-y-2 max-w-full",children:[e("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&a("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e(pe,{className:"h-4 w-4"}),"Baixar imagem"]})]})})}function Eu(e,a){return e/a}function Au(e,a,t,r){const s=Eu(e,a);return t&&!r?{width:t,height:Math.round(t/s)}:r&&!t?{width:Math.round(r*s),height:r}:{width:e,height:a}}function Tu(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))}function Ru(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}}function zu(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`}export{ys as AUTH_CONFIG,mo as Accordion,po as AccordionContent,uo as AccordionItem,ho as AccordionTrigger,At as ActionButton,Wc as ActionMenu,Hn as ActionMenuItems,zi as Alert,Fi as AlertDescription,fo as AlertDialog,Co as AlertDialogAction,So as AlertDialogCancel,yo as AlertDialogContent,ko as AlertDialogDescription,xo as AlertDialogFooter,No as AlertDialogHeader,vo as AlertDialogOverlay,bo as AlertDialogPortal,wo as AlertDialogTitle,go as AlertDialogTrigger,Mi as AlertTitle,tm as AppHeader,Nm as AppLayout,ym as AppSidebar,hs as AuthErrorInterceptor,Vs as AuthProvider,Ws as AuthService,_o as Avatar,Io as AvatarFallback,Po as AvatarImage,wr as Badge,di as BaseForm,Wl as Blockquote,Eo as Breadcrumb,Fo as BreadcrumbEllipsis,To as BreadcrumbItem,Ro as BreadcrumbLink,Ao as BreadcrumbList,zo as BreadcrumbPage,Mo as BreadcrumbSeparator,ui as BulkActionBar,Et as Button,Do as ButtonGroup,Ns as CRUD_CONFIG,il as Calendar,ji as CallbackPage,Mt as Card,Lt as CardContent,Dt as CardDescription,Ot as CardFooter,Ft as CardHeader,rn as CardSkeleton,jt as CardTitle,Ac as ChartContainer,Mc as ChartLegend,Fc as ChartLegendContent,Tc as ChartStyle,Rc as ChartTooltip,zc as ChartTooltipContent,yr as Checkbox,ro as Collapsible,no as CollapsibleContent,so as CollapsibleTrigger,ai as ColorPicker,Wr as Combobox,Ar as Command,Tr as CommandDialog,Mr as CommandEmpty,Fr as CommandGroup,Rr as CommandInput,Dr as CommandItem,zr as CommandList,jr as CommandSeparator,Lr as CommandShortcut,Tn as ContextMenu,Un as ContextMenuCheckboxItem,On as ContextMenuContent,zn as ContextMenuGroup,$n as ContextMenuItem,qn as ContextMenuLabel,Mn as ContextMenuPortal,jn as ContextMenuRadioGroup,Wn as ContextMenuRadioItem,Vn as ContextMenuSeparator,Bn as ContextMenuShortcut,Fn as ContextMenuSub,Ln as ContextMenuSubContent,Dn as ContextMenuSubTrigger,Rn as ContextMenuTrigger,co as CoreProviders,vi as CrudPageInternal,mi as CrudPagination,qc as CrudPrimitiveFilterBar,ci as CrudPrimitivePagination,Uc as CrudPrimitiveTable,Yn as CrudTable,ol as DataList,ll as DatePicker,Ut as Dialog,Gt as DialogBody,Vt as DialogClose,Kt as DialogContent,Yt as DialogDescription,Jt as DialogFooter,Qt as DialogHeader,Bt as DialogOverlay,qt as DialogPortal,Xt as DialogTitle,Wt as DialogTrigger,dl as Drawer,ul as DrawerClose,pl as DrawerContent,vl as DrawerDescription,gl as DrawerFooter,fl as DrawerHeader,hl as DrawerOverlay,ml as DrawerPortal,bl as DrawerTitle,cl as DrawerTrigger,gn as DropdownMenu,_n as DropdownMenuCheckboxItem,Cn as DropdownMenuContent,vn as DropdownMenuGroup,Sn as DropdownMenuItem,In as DropdownMenuLabel,yn as DropdownMenuPortal,xn as DropdownMenuRadioGroup,Pn as DropdownMenuRadioItem,En as DropdownMenuSeparator,An as DropdownMenuShortcut,Nn as DropdownMenuSub,kn as DropdownMenuSubContent,wn as DropdownMenuSubTrigger,bn as DropdownMenuTrigger,Cm as EmailService,dn as EmptyState,Wr as EntitySelect,lo as ErrorBoundary,bi as FilterBar,Zt as Form,ir as FormControl,or as FormDescription,ar as FormField,sr as FormItem,nr as FormLabel,lr as FormMessage,sn as FormSkeleton,xl as Grid,Rl as H1,zl as H2,Ml as H3,Fl as H4,nn as HeaderSkeleton,wl as HoverCard,Cl as HoverCardContent,kl as HoverCardTrigger,ni as IconPicker,Pu as ImageEditor,Iu as ImageRenderer,Ul as InlineCode,Tt as Input,Sl as InputGroup,Pl as InputGroupAddon,El as InputGroupButton,Al as InputGroupInput,Tl as InputGroupTextarea,_s as LOGO_CONFIG,zt as Label,Ll as Large,Dl as Lead,qm as LeaderRow,hu as LeadershipDialog,uu as LeadershipForm,gu as LeadershipPage,ql as List,Sr as LoadingState,eo as LocaleProvider,Gc as LocaleSelector,Di as LoginPage,Ps as MESSAGES,_m as ManageAccessModal,gc as Menubar,wc as MenubarCheckboxItem,Nc as MenubarContent,uc as MenubarGroup,xc as MenubarItem,Cc as MenubarLabel,mc as MenubarMenu,hc as MenubarPortal,fc as MenubarRadioGroup,kc as MenubarRadioItem,Sc as MenubarSeparator,_c as MenubarShortcut,pc as MenubarSub,yc as MenubarSubContent,vc as MenubarSubTrigger,bc as MenubarTrigger,gm as ModalStateProvider,Wr as MultiSelect,$l as Muted,Vl as NavigationMenu,Gl as NavigationMenuContent,Yl as NavigationMenuIndicator,Hl as NavigationMenuItem,Jl as NavigationMenuLink,Bl as NavigationMenuList,Ql as NavigationMenuTrigger,Xl as NavigationMenuViewport,Yc as NavigationProvider,jl as P,Zl as PageBreadcrumb,Oi as PageMetadataProvider,ad as Pagination,td as PaginationContent,od as PaginationEllipsis,rd as PaginationItem,sd as PaginationLink,id as PaginationNext,nd as PaginationPrevious,Pm as PlaceCard,Im as PlacesList,Pr as Popover,Er as PopoverContent,Ir as PopoverTrigger,Ci as Progress,Ai as ProtectedRoute,Cs as QUALIEX_CONFIG,ks as QUERY_KEYS,zs as QualiexEnrichmentService,fs as QualiexErrorInterceptor,li as QualiexUserField,ld as RadioGroup,dd as RadioGroupItem,ud as ResizableHandle,md as ResizablePanel,cd as ResizablePanelGroup,Oc as RichTextEditor,xs as SEARCH_CONFIG,ti as ScrollArea,ri as ScrollBar,dr as Select,fr as SelectContent,cr as SelectGroup,br as SelectItem,gr as SelectLabel,pr as SelectScrollDownButton,hr as SelectScrollUpButton,Wr as SelectSearch,vr as SelectSeparator,ur as SelectTrigger,mr as SelectValue,$t as Separator,hd as Sheet,xd as SheetBody,fd as SheetClose,yd as SheetContent,Cd as SheetDescription,wd as SheetFooter,Nd as SheetHeader,bd as SheetOverlay,gd as SheetPortal,kd as SheetTitle,pd as SheetTrigger,Ed as Sidebar,hm as SidebarActionTrigger,Dd as SidebarContent,Fd as SidebarFooter,Ld as SidebarGroup,$d as SidebarGroupAction,Ud as SidebarGroupContent,Od as SidebarGroupLabel,um as SidebarHeader,zd as SidebarInput,Rd as SidebarInset,Wd as SidebarMenu,Hd as SidebarMenuAction,Kd as SidebarMenuBadge,Bd as SidebarMenuButton,qd as SidebarMenuItem,Qd as SidebarMenuSkeleton,Gd as SidebarMenuSub,Xd as SidebarMenuSubButton,Jd as SidebarMenuSubItem,Id as SidebarProvider,Td as SidebarRail,jd as SidebarSeparator,on as SidebarSkeleton,Ad as SidebarTrigger,Or as Skeleton,Yd as Slider,Ol as Small,_r as SonnerToaster,Cr as Spinner,$c as SplitButton,gi as Stack,ii as Switch,nc as TabPageContent,sc as TabPageHeader,rc as TabPageLayout,Qs as Table,Js as TableBody,an as TableCaption,en as TableCell,Xs as TableFooter,Zs as TableHead,Gs as TableHeader,fn as TableResizeHandle,Ys as TableRow,Kn as TableRowActions,tn as TableSkeleton,Zd as Tabs,tc as TabsContent,ec as TabsList,ac as TabsTrigger,Nr as Textarea,_r as Toaster,oc as Toggle,dc as ToggleGroup,cc as ToggleGroupItem,Yr as TokenManager,Vr as TokenService,mn as Tooltip,hn as TooltipContent,cn as TooltipProvider,un as TooltipTrigger,to as TranslationLoader,pn as TruncatedCell,Su as VideoEditor,_u as VideoRenderer,_i as WizardBreadcrumb,Ii as WizardButtons,Ei as WizardForm,Pi as WizardProgressBar,Si as WizardStepper,dm as assets,xr as badgeVariants,zm as buildHierarchy,jo as buttonGroupVariants,It as buttonVariants,Eu as calculateAspectRatio,wt as cn,yi as createCrudPage,Bc as createCrudRoutingConfig,Vc as createRoutingHandlers,js as createService,Ni as createSimpleSaveHandler,Ks as createSimpleService,_t as debounce,Es as deriveEmailField,Is as deriveNameField,As as deriveUsernameField,ku as detectVideoProvider,Sm as emailService,as as errorService,Ru as extractImageFileName,Nu as extractVimeoId,vu as extractYouTubeId,Rm as filterAndPromoteOrphans,Mm as flattenTree,St as formatCurrency,wm as formatDate,Ct as formatDatetime,zu as formatFileSize,xi as generateCrudConfig,Ss as getQualiexConfig,ls as getSupabaseClient,xt as handleExternalLink,_l as inputGroupAddonVariants,Il as inputGroupButtonVariants,ws as isDevEnvironment,Tu as isImageUrl,cm as logoSrc,Kl as navigationMenuTriggerStyle,Cu as normalizeVideoUrl,xu as normalizeVimeoUrl,yu as normalizeYouTubeUrl,wu as parseIframeSrc,Tm as placeService,vs as qualiexApi,Au as resizeKeepingAspect,Ts as resolveFieldMappings,Wi as setupQualiexCore,Pt as slugify,mm as smallLogoSrc,ic as toggleVariants,Qi as translationService,kt as trimTextFields,sm as useActiveModules,Bs as useAuth,Zn as useBaseForm,Gn as useColumnResize,jm as useCreateLeaderMutation,Lm as useCreateMultipleLeadersMutation,Dm as useCreateSingleLeaderMutation,Hs as useCrud,am as useDebounce,tr as useFormField,vm as useHasOpenModal,km as useI18nFormatters,Fm as useLeadershipApi,ao as useLocale,bu as useMediaUpload,bm as useModalState,Zc as useNavigation,Ui as usePageMetadata,$i as usePageMetadataContext,em as usePageTitle,rm as usePermissionQuery,oi as useQualiexUsers,$m as useRemoveLeaderMutation,ed as useRouteBreadcrumbs,Jn as useRowResize,Pd as useSidebar,pm as useSidebarResize,Um as useSyncSubordinatesMutation,Om as useUpdateLeaderMutation};
1
+ import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import*as r from"react";import s,{useState as n,useMemo as i,createContext as o,useContext as l,useCallback as d,useEffect as c,useRef as m,memo as u,Component as h}from"react";import{Slot as p}from"@radix-ui/react-slot";import{cva as f}from"class-variance-authority";import{clsx as g}from"clsx";import{twMerge as b}from"tailwind-merge";import{parseISO as v,isValid as N,format as y}from"date-fns";import x from"i18next";export{default as i18n}from"i18next";import{toast as w,Toaster as k}from"sonner";export{toast as sonnerToast,toast}from"sonner";import{EllipsisVertical as C,X as S,ChevronDown as _,ChevronUp as P,Check as A,Loader2 as T,Loader2Icon as I,OctagonXIcon as E,TriangleAlertIcon as R,InfoIcon as z,CircleCheckIcon as M,AlertCircle as D,Search as F,FileX as j,ChevronRight as L,Circle as O,Edit as U,PowerOff as $,Power as W,Trash2 as V,Plus as B,ArrowUpDown as q,ArrowUp as H,ArrowDown as G,Target as K,Trophy as Q,Award as J,Sparkles as X,Flame as Y,Zap as Z,Key as ee,Shield as ae,EyeOff as te,Eye as re,Unlock as se,Lock as ne,Archive as ie,FolderOpen as oe,Folder as le,FileText as de,Save as ce,Copy as me,Share as ue,Upload as he,Download as pe,HelpCircle as fe,Info as ge,Bell as be,Clock as ve,ArrowRight as Ne,ArrowLeft as ye,ChevronLeft as xe,Minus as we,Filter as ke,Bookmark as Ce,Book as Se,Video as _e,Music as Pe,Image as Ae,Camera as Te,MapPin as Ie,Calendar as Ee,Phone as Re,Mail as ze,Settings as Me,User as De,Home as Fe,Heart as je,Star as Le,ChevronsLeft as Oe,ChevronsRight as Ue,CheckCircle as $e,AlertTriangle as We,RefreshCw as Ve,MoreHorizontal as Be,GripVertical as qe,PanelLeft as He,Edit3 as Ge,Code as Ke,Heading1 as Qe,Heading2 as Je,Heading3 as Xe,Bold as Ye,Italic as Ze,Underline as ea,Strikethrough as aa,List as ta,ListOrdered as ra,Highlighter as sa,Link as na,RemoveFormatting as ia,Undo as oa,Redo as la,ImageIcon as da,LayoutGrid as ca,RotateCcw as ma,Globe as ua,Building2 as ha,LogOut as pa,ExternalLink as fa,Users as ga,Crown as ba,UserPlus as va}from"lucide-react";import*as Na from"@radix-ui/react-label";import*as ya from"@radix-ui/react-dialog";import*as xa from"@radix-ui/react-separator";import{useFormContext as wa,FormProvider as ka,Controller as Ca,appendErrors as Sa,useForm as _a}from"react-hook-form";import*as Pa from"@radix-ui/react-select";import*as Aa from"@radix-ui/react-checkbox";import*as Ta from"@radix-ui/react-popover";import{useTranslation as Ia,initReactI18next as Ea,I18nextProvider as Ra}from"react-i18next";export{I18nextProvider,useTranslation}from"react-i18next";import{createClient as za}from"@supabase/supabase-js";import{useQueryClient as Ma,useQuery as Da,useMutation as Fa,QueryClient as ja,QueryClientProvider as La}from"@tanstack/react-query";import{useSearchParams as Oa,useLocation as Ua,useNavigate as $a,Link as Wa}from"react-router-dom";import*as Va from"@radix-ui/react-tooltip";import*as Ba from"@radix-ui/react-dropdown-menu";import*as qa from"@radix-ui/react-context-menu";import*as Ha from"@radix-ui/react-scroll-area";import*as Ga from"@radix-ui/react-switch";import*as Ka from"@radix-ui/react-collapsible";import*as Qa from"@radix-ui/react-accordion";import*as Ja from"@radix-ui/react-alert-dialog";import*as Xa from"@radix-ui/react-avatar";import{DayPicker as Ya}from"react-day-picker";import{Drawer as Za}from"vaul";import*as et from"@radix-ui/react-hover-card";import*as at from"@radix-ui/react-navigation-menu";import*as tt from"@radix-ui/react-progress";import*as rt from"@radix-ui/react-radio-group";import*as st from"react-resizable-panels";import*as nt from"@radix-ui/react-slider";import*as it from"@radix-ui/react-tabs";import*as ot from"@radix-ui/react-toggle";import*as lt from"@radix-ui/react-toggle-group";import*as dt from"@radix-ui/react-menubar";import*as ct from"recharts";import{useEditor as mt,EditorContent as ut}from"@tiptap/react";import ht from"@tiptap/starter-kit";import pt from"@tiptap/extension-underline";import ft from"@tiptap/extension-link";import{TextStyle as gt}from"@tiptap/extension-text-style";import{Color as bt}from"@tiptap/extension-color";import vt from"@tiptap/extension-highlight";import{formatInTimeZone as Nt}from"date-fns-tz";import{z as yt}from"zod";import{validateFieldsNatively as xt,toNestErrors as wt}from"@hookform/resolvers";function kt(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{w.info(x.t("link_copied"))})}function Ct(...e){return b(g(e))}const St=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(St);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,r]of Object.entries(e))a[t]=St(r);return a}return e},_t=e=>{if(!e)return"";const a=v(e);if(!N(a))return"Data inválida";return`${a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${a.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},Pt=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),At=(e,a)=>{let t;return(...r)=>{clearTimeout(t),t=setTimeout(()=>e(...r),a)}},Tt=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),It=f("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded",md:"h-10 px-4 py-2 text-sm rounded-md",lg:"h-12 px-8 text-base rounded-lg",xl:"h-14 px-10 text-lg rounded-lg",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6",default:"h-10 px-4 py-2"}},defaultVariants:{variant:"primary",size:"md"}}),Et=r.forwardRef(({className:a,variant:t,size:r,asChild:s=!1,...n},i)=>e(s?p:"button",{className:Ct(It({variant:t,size:r,className:a})),ref:i,...n}));Et.displayName="Button";const Rt=s.forwardRef(({className:a,children:t,...r},s)=>e(Et,{ref:s,variant:"action",size:"sm",className:Ct("h-7 px-2 text-xs",a),...r,children:t||e(C,{size:12})}));Rt.displayName="ActionButton";const zt=r.forwardRef(({className:a,type:t,...r},s)=>e("input",{type:t,className:Ct("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:s,...r}));zt.displayName="Input";const Mt=f("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Dt=r.forwardRef(({className:a,...t},r)=>e(Na.Root,{ref:r,className:Ct(Mt(),a),...t}));Dt.displayName=Na.Root.displayName;const Ft=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));Ft.displayName="Card";const jt=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("flex flex-col space-y-1.5 p-6",a),...t}));jt.displayName="CardHeader";const Lt=r.forwardRef(({className:a,...t},r)=>e("h3",{ref:r,className:Ct("text-2xl font-semibold leading-none tracking-tight",a),...t}));Lt.displayName="CardTitle";const Ot=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:Ct("text-sm text-muted-foreground",a),...t}));Ot.displayName="CardDescription";const Ut=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("p-6 pt-0",a),...t}));Ut.displayName="CardContent";const $t=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("flex items-center p-6 pt-0",a),...t}));$t.displayName="CardFooter";const Wt=r.forwardRef(({className:a,orientation:t="horizontal",decorative:r=!0,...s},n)=>e(xa.Root,{ref:n,decorative:r,orientation:t,className:Ct("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...s}));Wt.displayName=xa.Root.displayName;const Vt=ya.Root,Bt=ya.Trigger,qt=ya.Portal,Ht=ya.Close,Gt=r.forwardRef(({className:a,...t},r)=>e(ya.Overlay,{ref:r,className:Ct("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t}));Gt.displayName=ya.Overlay.displayName;const Kt={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",minWidth:"720px",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},Qt=r.forwardRef(({className:t,children:r,size:s="md",customWidth:n,customMinWidth:i,customMaxWidth:o,customHeight:l,customMinHeight:d,customMaxHeight:c,style:m,...u},h)=>{const p=Kt[s],f={width:n??p.width,minWidth:i??p.minWidth,maxWidth:o??p.maxWidth,height:l??p.height,minHeight:d??p.minHeight,maxHeight:c??p.maxHeight,...m};return a(qt,{children:[e(Gt,{}),a(ya.Content,{ref:h,className:Ct("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),style:f,...u,children:[r,a(ya.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e(S,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]})});Qt.displayName=ya.Content.displayName;const Jt=({className:t,showSeparator:r=!1,children:s,...n})=>a("div",{className:Ct("flex flex-col flex-shrink-0",t),...n,children:[e("div",{className:"flex flex-col text-left",children:s}),r&&e(Wt,{className:"mt-2"})]});Jt.displayName="DialogHeader";const Xt=({className:a,...t})=>e("div",{className:Ct("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Xt.displayName="DialogBody";const Yt=({className:t,children:r,...s})=>a("div",{className:"flex-shrink-0 pt-4",children:[e(Wt,{className:"mb-4"}),e("div",{className:Ct("flex flex-row justify-end gap-2",t),...s,children:r})]});Yt.displayName="DialogFooter";const Zt=r.forwardRef(({className:a,...t},r)=>e(ya.Title,{ref:r,className:Ct("text-lg font-semibold leading-none tracking-tight",a),...t}));Zt.displayName=ya.Title.displayName;const er=r.forwardRef(({className:a,...t},r)=>e(ya.Description,{ref:r,className:Ct("text-sm text-muted-foreground",a),...t}));er.displayName=ya.Description.displayName;const ar=ka,tr=r.createContext({}),rr=({...a})=>e(tr.Provider,{value:{name:a.name},children:e(Ca,{...a})}),sr=()=>{const e=r.useContext(tr),a=r.useContext(nr),{getFieldState:t,formState:s}=wa(),n=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=a;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},nr=r.createContext({}),ir=r.forwardRef(({className:a,...t},s)=>{const n=r.useId();return e(nr.Provider,{value:{id:n},children:e("div",{ref:s,className:Ct("space-y-2",a),...t})})});ir.displayName="FormItem";const or=r.forwardRef(({className:a,...t},r)=>{const{error:s,formItemId:n}=sr();return e(Dt,{ref:r,className:Ct(s&&"text-destructive",a),htmlFor:n,...t})});or.displayName="FormLabel";const lr=r.forwardRef(({...a},t)=>{const{error:r,formItemId:s,formDescriptionId:n,formMessageId:i}=sr();return e(p,{ref:t,id:s,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...a})});lr.displayName="FormControl";const dr=r.forwardRef(({className:a,...t},r)=>{const{formDescriptionId:s}=sr();return e("p",{ref:r,id:s,className:Ct("text-sm text-muted-foreground",a),...t})});dr.displayName="FormDescription";const cr=r.forwardRef(({className:a,children:t,...r},s)=>{const{error:n,formMessageId:i}=sr(),o=n?String(n?.message):t;return o?e("p",{ref:s,id:i,className:Ct("text-sm font-medium text-destructive",a),...r,children:o}):null});cr.displayName="FormMessage";const mr=Pa.Root,ur=Pa.Group,hr=Pa.Value,pr=r.forwardRef(({className:t,children:r,...s},n)=>a(Pa.Trigger,{ref:n,className:Ct("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[r,e(Pa.Icon,{asChild:!0,children:e(_,{className:"h-4 w-4 opacity-50"})})]}));pr.displayName=Pa.Trigger.displayName;const fr=r.forwardRef(({className:a,...t},r)=>e(Pa.ScrollUpButton,{ref:r,className:Ct("flex cursor-default items-center justify-center py-1",a),...t,children:e(P,{className:"h-4 w-4"})}));fr.displayName=Pa.ScrollUpButton.displayName;const gr=r.forwardRef(({className:a,...t},r)=>e(Pa.ScrollDownButton,{ref:r,className:Ct("flex cursor-default items-center justify-center py-1",a),...t,children:e(_,{className:"h-4 w-4"})}));gr.displayName=Pa.ScrollDownButton.displayName;const br=r.forwardRef(({className:t,children:r,position:s="popper",container:n,collisionBoundary:i,...o},l)=>e(Pa.Portal,{container:n,children:a(Pa.Content,{ref:l,className:Ct("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:i,...o,children:[e(fr,{}),e(Pa.Viewport,{className:Ct("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e(gr,{})]})}));br.displayName=Pa.Content.displayName;const vr=r.forwardRef(({className:a,...t},r)=>e(Pa.Label,{ref:r,className:Ct("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));vr.displayName=Pa.Label.displayName;const Nr=r.forwardRef(({className:t,children:r,...s},n)=>a(Pa.Item,{ref:n,className:Ct("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Pa.ItemIndicator,{children:e(A,{className:"h-4 w-4"})})}),e(Pa.ItemText,{children:r})]}));Nr.displayName=Pa.Item.displayName;const yr=r.forwardRef(({className:a,...t},r)=>e(Pa.Separator,{ref:r,className:Ct("-mx-1 my-1 h-px bg-muted",a),...t}));yr.displayName=Pa.Separator.displayName;const xr=r.forwardRef(({className:a,...t},r)=>e(Aa.Root,{ref:r,className:Ct("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",a),...t,children:e(Aa.Indicator,{className:Ct("flex items-center justify-center text-current"),children:e(A,{className:"h-4 w-4"})})}));xr.displayName=Aa.Root.displayName;const wr=r.forwardRef(({className:a,...t},r)=>e("textarea",{className:Ct("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:r,...t}));wr.displayName="Textarea";const kr=f("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),Cr=r.forwardRef(({className:a,variant:t,...r},s)=>e("div",{ref:s,className:Ct(kr({variant:t}),a),...r}));Cr.displayName="Badge";const Sr={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function _r({size:a="md",className:t}){return e(T,{className:Ct("animate-spin text-muted-foreground",Sr[a],t)})}function Pr({isLoading:r,children:s,className:n,type:i="spinner",size:o="md"}){return r?"overlay"===i?a("div",{className:Ct("relative",n),children:[s,e("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e(_r,{size:o})})]}):e("div","skeleton"===i?{className:Ct("animate-pulse",n),children:e("div",{className:"bg-muted rounded-md h-full w-full"})}:{className:Ct("flex items-center justify-center py-8",n),children:e(_r,{size:o})}):e(t,{children:s})}const Ar=({...a})=>e(k,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e(M,{className:"h-4 w-4"}),info:e(z,{className:"h-4 w-4"}),warning:e(R,{className:"h-4 w-4"}),error:e(E,{className:"h-4 w-4"}),loading:e(I,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...a}),Tr=Ta.Root,Ir=Ta.Trigger,Er=r.forwardRef(({className:a,align:t="center",sideOffset:r=4,container:s,...n},i)=>e(Ta.Portal,{container:s,children:e(Ta.Content,{ref:i,align:t,sideOffset:r,className:Ct("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...n})}));Er.displayName=Ta.Content.displayName;const Rr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Rr.displayName="Command";const zr=({children:a,...t})=>e("div",{...t,children:e(Rr,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})}),Mr=r.forwardRef(({className:a,...t},r)=>e("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e("input",{ref:r,className:Ct("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})}));Mr.displayName="CommandInput";const Dr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Dr.displayName="CommandList";const Fr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("py-6 text-center text-sm text-muted-foreground",a),...t}));Fr.displayName="CommandEmpty";const jr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));jr.displayName="CommandGroup";const Lr=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("-mx-1 h-px bg-border",a),...t}));Lr.displayName="CommandSeparator";const Or=r.forwardRef(({className:a,disabled:t,onSelect:r,value:s,...n},i)=>e("div",{ref:i,className:Ct("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",a),"data-disabled":t,onClick:()=>!t&&r?.(s||""),...n}));Or.displayName="CommandItem";const Ur=({className:a,...t})=>e("span",{className:Ct("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function $r({className:a,...t}){return e("div",{className:Ct("animate-pulse rounded-md bg-muted",a),...t})}Ur.displayName="CommandShortcut";const Wr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Vr({multiple:t,options:r,value:s,onChange:o,getOptionValue:l,getOptionLabel:d,placeholder:c,label:m,icon:u,emptyMessage:h,searchPlaceholder:p,disabled:f,required:g,className:b,sortOptions:v,maxDisplayedBadges:N,popoverContainer:y,onOpen:x,onClose:w}){const{t:k}=Ia(),[C,P]=n(!1),[T,I]=n(""),E=i(()=>s?Array.isArray(s)?s:[s]:[],[s]),R=i(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),r=t.overflowY||t.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),z=i(()=>{const e=r.map(e=>({original:e,value:l(e),label:d(e)}));return v?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[r,l,d,v]),M=i(()=>{if(!T)return z;const e=Wr(T);return z.filter(a=>Wr(a.label).includes(e))},[z,T]),D=i(()=>z.filter(e=>E.includes(e.value)),[z,E]),F=(e,a)=>{a.preventDefault(),a.stopPropagation(),o&&o(t?E.filter(a=>a!==e):"")},j=N?D.slice(0,N):D,L=N&&D.length>N?D.length-N:0;return a("div",{className:Ct("space-y-2",b),children:[m&&a(Dt,{children:[m,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a(Tr,{open:C,onOpenChange:e=>{P(e),e?x?.():(I(""),w?.())},modal:!1,children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",role:"combobox","aria-expanded":C,disabled:f,className:Ct("w-full justify-between min-h-10 h-auto",0===D.length&&"text-muted-foreground"),children:[0===D.length?a("span",{className:"flex items-center gap-2",children:[u&&e(u,{className:"h-4 w-4"}),c]}):t?a("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[j.map(t=>a(Cr,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&F(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>F(t.value,e),children:e(S,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),L>0&&a(Cr,{variant:"outline",className:"gap-1",children:["+",L]})]}):a("span",{className:"flex items-center gap-2",children:[u&&e(u,{className:"h-4 w-4"}),D[0]?.label]}),e(_,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e(Er,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:R,collisionBoundary:R,children:a(Rr,{children:[e(Mr,{placeholder:p,value:T,onChange:e=>I(e.target.value)}),e(Dr,{children:0===r.length?e(Fr,{children:h}):0===M.length?e(Fr,{children:k("no_results")}):e(jr,{children:M.map(r=>a(Or,{value:r.value,onSelect:()=>(e=>{if(o)if(t){const a=E.includes(e)?E.filter(a=>a!==e):[...E,e];o(a)}else o(e),P(!1)})(r.value),className:"cursor-pointer",children:[e(A,{className:Ct("mr-2 h-4 w-4",E.includes(r.value)?"opacity-100":"opacity-0")}),r.label]},r.value))})})]})})]})]})}function Br({multiple:t=!1,options:r,items:s,value:n,onChange:i,onValueChange:o,getOptionValue:l=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:m,icon:u,emptyMessage:h,searchPlaceholder:p,disabled:f=!1,required:g=!1,isLoading:b=!1,error:v,className:N,sortOptions:y=!0,maxDisplayedBadges:x,popoverContainer:w,onOpen:k,onClose:C}){const{t:S}=Ia(),_=s||r||[],P=o||i,A=c||S("select_placeholder"),T=h||S("no_results"),I=p||S("search_placeholder");if(b)return a("div",{className:Ct("space-y-2",N),children:[m&&a(Dt,{children:[m,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e($r,{className:"h-10 w-full"})]});const E="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return E?a("div",{className:Ct("space-y-2",N),children:[m&&a(Dt,{children:[m,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e(D,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:E})]})]}):e(Vr,{multiple:t,options:_,value:n||(t?[]:""),onChange:P,getOptionValue:l,getOptionLabel:d,placeholder:A,label:m,icon:u,emptyMessage:T,searchPlaceholder:I,disabled:f,required:g,className:N,sortOptions:y,maxDisplayedBadges:x,popoverContainer:w,onOpen:k,onClose:C})}var qr=Object.defineProperty;class Hr{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}static parseJwtPayload(e){try{const s=e.split(".");if(3!==s.length)return null;const n=s[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let s=0;s<a.length;s++)t[s]=a.charCodeAt(s);const r=new TextDecoder("utf-8").decode(t);return JSON.parse(r)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(r){throw r}}}}catch(s){return null}}static validateTokens(e,a){const t=[],r=[];try{a.split(".")[1],e.split(".")[1];const s=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!s){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:r}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";t.push(e),i=!1}if(s.exp&&s.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:t,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:r}}catch(s){const e=`Erro na validação de tokens: ${s}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:r}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,a,t)=>{a in e?qr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(Hr,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Gr="qualiex_access_token",Kr="qualiex_id_token",Qr="supabase_token",Jr="oauth_state",Xr="oauth_nonce",Yr="selected_alias",Zr="manual_logout",es={setAccessToken:e=>localStorage.setItem(Gr,e),getAccessToken:()=>localStorage.getItem(Gr),setIdToken:e=>localStorage.setItem(Kr,e),getIdToken:()=>localStorage.getItem(Kr),getSupabaseToken:()=>localStorage.getItem(Qr),setOAuthState:e=>sessionStorage.setItem(Jr,e),getOAuthState:()=>sessionStorage.getItem(Jr),clearOAuthState:()=>sessionStorage.removeItem(Jr),setOAuthNonce:e=>sessionStorage.setItem(Xr,e),getOAuthNonce:()=>sessionStorage.getItem(Xr),clearOAuthNonce:()=>sessionStorage.removeItem(Xr),setSelectedAlias:e=>localStorage.setItem(Yr,e),getSelectedAlias:()=>localStorage.getItem(Yr),clearSelectedAlias:()=>localStorage.removeItem(Yr),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!es.getAccessToken()||!es.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Qr,e),es._clearValidationCache()},areAllTokensValid:()=>{const e=es.getAccessToken(),a=es.getIdToken();if(!e||!a)return!1;try{const t=Hr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=es.getAccessToken(),t=es.getIdToken(),r=es.getSupabaseToken();return a&&es.isTokenExpired(a)&&(localStorage.removeItem(Gr),e=!0),t&&es.isTokenExpired(t)&&(localStorage.removeItem(Kr),e=!0),r&&es.isTokenExpired(r)&&(localStorage.removeItem(Qr),e=!0),e},clearAll:()=>{localStorage.removeItem(Gr),localStorage.removeItem(Kr),localStorage.removeItem(Qr),localStorage.removeItem(Yr),localStorage.removeItem(Zr),sessionStorage.removeItem(Jr),sessionStorage.removeItem(Xr)},setManualLogout:()=>localStorage.setItem(Zr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Zr),clearManualLogout:()=>localStorage.removeItem(Zr),isTokenExpired:e=>{try{return Hr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{es._validationCache.isValid=!1,es._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=es.getSupabaseToken();if(!e)return!1;if(es.isTokenExpired(e))return es._clearValidationCache(),es._handleExpiredToken(),!1;const a=Date.now();return a-es._validationCache.timestamp<es._validationCache.cacheValidityMs?es._validationCache.isValid:(es._validationCache.isValid=!0,es._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>es.isSupabaseTokenValid()?es.getSupabaseToken():null,_handleExpiredToken:()=>{es.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!es.isSupabaseTokenValid())return null;const e=es.getSupabaseToken();if(!e)return null;try{const a=Hr.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,r=a.place_id||null,s=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=a[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:r,placeName:s,payload:a}}catch(a){return es._handleExpiredToken(),null}},getCompanyId:e=>{const a=es.getAccessToken();if(a)try{const t=Hr.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const a=r.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(s){}const t=es.extractTokenData();if(t?.companyId)return t.companyId;const r=es.getIdToken();if(r)try{const a=Hr.parseJwtPayload(r);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=a[t];if(r&&"string"==typeof r){const a=r.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(s){}return null},getCurrentCompanyId:()=>{const e=es.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=es.getIdToken();if(!e)return[];try{const a=Hr.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=a[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};var as=Object.defineProperty,ts=(e,a,t)=>((e,a,t)=>a in e?as(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const rs=new class{constructor(){ts(this,"errors",[]),ts(this,"toastCount",0),ts(this,"lastToastTime",0)}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);w.error(e,{description:t})}}getErrorTitle(e){const a=e.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?"Sessão Expirada":a.includes("token")||a.includes("autenticação")?"Erro de Autenticação":a.includes("api")||a.includes("network")?"Erro de Conexão":"Erro"}success(e,a){w.success(e,{description:a})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var ss=Object.defineProperty,ns=(e,a,t)=>((e,a,t)=>a in e?ss(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const is=import.meta.env.VITE_SUPABASE_URL,os=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,ls=class e{constructor(){ns(this,"client"),ns(this,"currentToken",null),ns(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:os};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return za(is,os,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,a)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=es.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const a=JSON.parse(atob(e.split(".")[1])),t=Math.floor(Date.now()/1e3);return a.exp>t}catch(a){return rs.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};ns(ls,"instance");let ds=ls;function cs(){return ds.getInstance().getClient()}class ms{static async generateToken(e,a,t,r=!1){try{if(!r){const e=es.getSupabaseToken();if(e&&es.isSupabaseTokenValid())return e}const s=cs(),{data:n,error:i}=await s.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token&&n.access_token?(es.setSupabaseToken(n.access_token),n.access_token):null}catch(s){return s instanceof Error&&(s.message.includes("401")||s.message.includes("Unauthorized"))&&t?.(),null}}}var us=Object.defineProperty,hs=(e,a,t)=>((e,a,t)=>a in e?us(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class ps{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=es.getAccessToken(),a=es.getSelectedAlias();if(!e||!a)return null;const t=await ms.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(es.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}hs(ps,"isRegenerating",!1),hs(ps,"onLogoutCallback",null);class fs{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(es.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var gs=Object.defineProperty;class bs{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await ps.attemptRegeneration()?(this.isRetrying=!1,!0):(fs.handleError(e),this.isRetrying=!1,!1)}catch(r){return fs.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=es.getAccessToken();return e?es.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,a,t)=>{((e,a,t)=>{a in e?gs(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(bs,"isRetrying",!1);var vs=Object.defineProperty,Ns=(e,a,t)=>((e,a,t)=>a in e?vs(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const ys=new class{constructor(){Ns(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const r=bs.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=es.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}async fetchUsers(e,a){try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let r=t;if(t.data)r=t.data;else{if(!Array.isArray(t))return rs.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=t}if(!Array.isArray(r))return rs.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(t){if(await bs.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let r=t;if(t.data)r=t.data;else{if(!Array.isArray(t))return rs.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=t}return Array.isArray(r)?r.map(this.mapToQualiexUser):(rs.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return rs.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}const s=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return rs.handleError(s,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(r){return rs.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),r=new Map;return t.forEach(e=>{r.set(e.userId,e)}),r}async getUsers(e){const a=es.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},xs={oauth:{authUrl:import.meta.env.VITE_OAUTH_AUTH_URL,clientId:import.meta.env.VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},ws={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},ks={debounceDelay:500},Cs=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||import.meta.env.DEV},Ss={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},_s={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Ps=()=>_s,As={isQualiex:"true"===import.meta.env.VITE_IS_QUALIEX},Ts={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}};function Is(e,a){const t=Ps(),r=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Es(e,a){const t=Ps(),r=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Rs(e,a){const t=Ps(),r=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function zs(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||Is(e.idField),emailField:e.emailField||Es(e.idField),usernameField:e.usernameField||Rs(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Is(e),emailField:Es(e),usernameField:Rs(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Ms=new Map;class Ds{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,r=Ms.get(t);if(r&&Date.now()-r.timestamp<3e5)return r.users;const s=await ys.fetchUsers(e,a);return Ms.set(t,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,a){const t=new Set;for(const r of e)for(const e of a){const a=r[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const r={...e};for(const s of a){const a=e[s.idField];if(!a)continue;const n=t.get(a);if(n){if(s.nameField){r[s.nameField]||(r[s.nameField]=n.userName||n.displayName||null)}if(s.emailField){r[s.emailField]||(r[s.emailField]=n.userEmail||null)}if(s.usernameField){r[s.usernameField]||(r[s.usernameField]=n.userName||null)}}}return r}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!es.areAllTokensValid())return e;const t=es.extractTokenData();if(!t)return e;const{alias:r,companyId:s}=t;if(!r||!s)return e;const n=zs(a.userIdFields,a.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(r,s),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(t){return rs.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,a){return this.enrichWithUserData(e,{entityName:a.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const Fs=["responsible_name"],js=e=>Fs.includes(e);function Ls(e,a,t){const r="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:s,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=r,c=()=>{if(!es.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return cs().schema(o).from(s)},m=(e,a,t,r)=>{let s=c().select(i||"*",{count:"exact"});s=s.eq("is_removed",!1),Object.entries(r).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?s=s.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?s=s.not(e,"is",null):"is_null"===a.operator&&(s=s.is(e,null)):null!==a&&(s=s.eq(e,a)))}),s=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(s,e);const o=a.includes(".");return o||js(a)||(s=s.order(a,{ascending:"asc"===t})),{query:s,isForeignKey:o}},u=async(e,a,t,s,n)=>{const i=zs(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(js(a)||o||i){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},i=await this.getAll(e);if(!i?.data?.length)return i;const d=await Ds.enrichWithUserData(i.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let c;c=o?d.sort((e,r)=>{const s=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],r)||"",i=String(s).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,r)=>{const s=e[a]||"",n=r[a]||"",i=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const m=((e,a=1,t=25)=>{const r=(a-1)*t,s=r+t,n=e.slice(r,s);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:s<e.length,hasPreviousPage:a>1}}})(c,s,n);return{data:m.data,currentPage:m.pagination.currentPage,totalPages:m.pagination.totalPages,totalItems:m.pagination.totalCount,itemsPerPage:m.pagination.itemsPerPage,hasNextPage:m.pagination.hasNextPage,hasPreviousPage:m.pagination.hasPreviousPage}}return await Ds.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})};return{async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:r,page:s,limit:n,additionalFilters:i}})(e),{query:h}=m(a,t,n,c),p=((e,a,t)=>{const r=(a-1)*t,s=r+t-1;return e.range(r,s)})(h,i,o),{data:f,error:g,count:b}=await p;if(g)throw new Error(`Error fetching ${s}: ${g.message}`);let v=((e,a,t,r)=>{const s=Math.ceil((a||0)/r);return{data:e,currentPage:t,totalPages:s,totalItems:a||0,itemsPerPage:r,hasNextPage:t<s,hasPreviousPage:t>1}})(f||[],b,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=zs(r.userIdFields,r.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(v.data)){const e=await u(v.data,t,n,i,o);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${s}: ${t.message}`);return a},async create(e){const a=St(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:r,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from create ${s} operation`);return r},async update(e,a){const t={...St(a),updated_at:(new Date).toISOString()},{data:r,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from update ${s} operation`);return r},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${s}: ${t.message}`)}}}const Os=()=>{es.clearManualLogout()},Us=e=>e?.placeId||null,$s=e=>e?.placeName||null,Ws=e=>({placeId:Us(e),placeName:$s(e)}),Vs=class{static async initialize(){try{if(!es.hasAllTokens()||!es.areAllTokensValid())return es.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const a=es.getAccessToken(),t=es.getIdToken();Os();const r=this.extractUserFromIdToken(t),s=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=es.extractTokenData(),o=i?.alias;let l=null;if(o&&s.some(e=>e.alias===o))l=o;else{const e=es.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);l=a?e:n||s[0]?.alias||null}!es.isSupabaseTokenValid()&&l&&await ps.attemptRegeneration();let d=null;if(l){const e=es.getCompanyId(l),a=s.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,m=null;if(r?.id&&l){const a=es.getCompanyId(l);if(a)try{const e=(await ys.fetchActiveUsersMap(l,a)).get(r.id);if(e){const a=Ws(e);c=a.placeId,m=a.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:s,selectedUnit:d,userId:r?.id||null,userAlias:r?.id||null,placeId:c,placeName:m,activePlaceId:c,activePlaceName:m}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=cs(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const r=new URL("/callback",window.location.origin);return r.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e=es.generateOAuthState();es.setOAuthState(e);const a=es.generateOAuthNonce();es.setOAuthNonce(a);const t=`${window.location.origin}/callback`,r=new URL(xs.oauth.authUrl);r.searchParams.set("client_id",xs.oauth.clientId),r.searchParams.set("response_type",xs.oauth.responseType),r.searchParams.set("scope",xs.oauth.scope),r.searchParams.set("redirect_uri",t),r.searchParams.set("state",e),r.searchParams.set("nonce",a),r.searchParams.set("response_mode","fragment"),Cs(),window.location.href=r.toString()}static async processCallback(){try{if(es.hasAllTokens()){if(!es.getValidSupabaseToken()){es.getAccessToken();await ps.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),r=t("access_token"),s=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!r||!s)throw new Error("Tokens não encontrados na URL de callback");es.setAccessToken(r),es.setIdToken(s),Os();const i=this.extractAliasFromAccessToken(r);if(i)es.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(s);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");es.setSelectedAlias(e[0].alias)}if(!await ps.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return es.clearOAuthState(),es.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){es.setManualLogout(),es.clearAll(),window.location.href="/login"}static decodeToken(e){return Hr.parseJwtPayload(e)}static extractUserFromIdToken(e){const a=this.decodeToken(e);return a?{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier}:null}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const r=a[e].split(";");if(r.length>=4)t.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,s]=a[e].split("|");r&&s&&t.push({id:"",alias:r.trim(),name:s.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};ps.setLogoutCallback(()=>{Vs.logout()});let Bs=Vs;const qs=o(void 0),Hs=({children:a})=>{const[t,r]=n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let s=null;try{s=Ma()}catch{}const[o,l]=n(!1),[m,u]=n(0),h=d(e=>{r(a=>({...a,...e}))},[]),p=d(e=>{r(a=>({...a,isLoading:e}))},[]),f=d(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),g=d(async e=>{try{p(!0);const r=es.getAccessToken();if(!r)return;const n=await ms.generateToken(r,e.alias,void 0,!0);if(!n)return;es.setSupabaseToken(n),es.setSelectedAlias(e.alias);const i=es.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||es.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let c=null,m=null;if(t.user?.id&&o&&l)try{const e=(await ys.fetchActiveUsersMap(o,l)).get(t.user.id);if(e){const a=Ws(e);c=a.placeId,m=a.placeName}}catch(a){}h({alias:o,selectedUnit:d,placeId:c,placeName:m,activePlaceId:c,activePlaceName:m}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{p(!1)}},[h,s,p,t.user]),b=d(async()=>await Bs.processCallback(),[]),v=d(async()=>{Bs.logout(),f(),s&&await s.clear()},[f,s]),N=d(e=>{l(e)},[]),y=d(()=>{u(e=>e+1)},[]),x=d(()=>{u(e=>e+1)},[]);c(()=>{if(!t.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(es.areAllTokensValid()||e&&v())},6e5);return()=>{e=!1,clearInterval(a)}},[t.isAuthenticated,v]),c(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Bs.initialize();if(!e)return;a&&a.isAuthenticated?h({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&p(!1)}catch(a){e&&(fs.handleError(a),p(!1))}})(),()=>{e=!1}},[h,p,v]);const w=i(()=>({...t,logout:v,processCallback:b,switchUnit:g,availableUnits:t.companies,isSearchVisible:o,setSearchVisible:N,clearSearch:y,refreshData:x}),[t.user,t.companies,t.alias,t.isAuthenticated,t.isLoading,t.selectedUnit,t.userId,t.userAlias,t.placeId,t.placeName,t.activePlaceId,t.activePlaceName,v,b,g,o,N,y,x]);return e(qs.Provider,{value:w,children:a})},Gs=()=>{const e=l(qs);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Ks({queryKey:e,service:a,entityName:t,searchFields:r,additionalFilters:s={},onSuccess:o}){const[l,c]=Oa(),m=Ma(),{alias:u,userId:h,isAuthenticated:p}=Gs(),f=d(a=>{const t=`${e}_${a}`,r=l.get(t);return r||(l.get(a)||"")},[l,e]),g=f("search"),b=f("sortField")||ws.sorting.defaultField,v=f("sortDirection")||ws.sorting.defaultDirection,N=parseInt(f("page")||"1"),y=parseInt(f("limit")||String(ws.pagination.defaultPageSize)),x=g,k=i(()=>({search:x,sortField:b,sortDirection:v,page:N,limit:y,...s}),[x,b,v,N,y,s]),C=d(()=>a.getAll(k),[a,k]),S=Da({queryKey:[e,u,h,k],queryFn:C,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${t}". Ensure QueryClientProvider is configured in your app root.`);const _=Fa({mutationFn:a.create,onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),w.success(Ts.success.created(t)),o?.()},onError:e=>{w.error(`${Ts.error.create(t)}: ${e.message}`)}}),P=Fa({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),w.success(Ts.success.updated(t)),o?.()},onError:e=>{w.error(`${Ts.error.update(t)}: ${e.message}`)}}),A=Fa({mutationFn:a.delete,onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),w.success(Ts.success.deleted(t))},onError:e=>{w.error(`${Ts.error.delete(t)}: ${e.message}`)}}),T=d(a=>{const t={...Object.fromEntries(l)};Object.entries(a).forEach(([a,r])=>{const s=`${e}_${a}`;""===r||0===r?delete t[s]:t[s]=String(r)}),delete t.sortField,delete t.sortDirection,c(t)},[l,c,e]),I=d(e=>{T({search:e,page:1})},[T]),E=d(e=>{T({sortField:e,sortDirection:b===e&&"asc"===v?"desc":"asc",page:1})},[b,v,T]),R=d(e=>{T({page:e})},[T]),z=d(e=>{T({limit:e,page:1})},[T]),M=d(()=>{const a=Object.fromEntries(l),t=`${e}_`,r=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));c(r)},[c,l,e]),[D,F]=n([]),j=d(e=>{F(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=d(()=>{const e=S?.data?.data.map(e=>e.id)||[];F(a=>a.length===e.length?[]:e)},[S?.data?.data]),O=d(()=>{F([])},[]),U=i(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&D.length===e.length},[D,S?.data?.data]),$=Fa({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,r)=>{m.invalidateQueries({queryKey:[e]}),w.success(`${r.length} ${t}(s) deletado(s) com sucesso`),O()},onError:e=>{w.error(`Erro ao deletar itens: ${e.message}`)}}),W=d((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):_.mutate({...t,alias:u})},[u,_,P]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||ws.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:_?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:A?.isPending??!1,error:S?.error||null,searchTerm:g,sortField:b,sortDirection:v,currentPage:N,itemsPerPage:y,queryKey:e,createEntity:_.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:A.mutate,save:W,handleSearch:I,handleSort:E,handlePageChange:R,handleItemsPerPageChange:z,clearFilters:M,refetch:S.refetch,selectedIds:D,selectItem:j,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}function Qs(e){const a=Ls({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:a,useCrudHook:(t,r)=>Ks({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:r})}}const Js=r.forwardRef(({className:a,...t},r)=>e("table",{ref:r,className:Ct("w-full caption-bottom text-sm table-fixed",a),...t}));Js.displayName="Table";const Xs=r.forwardRef(({className:a,...t},r)=>e("thead",{ref:r,className:Ct("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Xs.displayName="TableHeader";const Ys=r.forwardRef(({className:a,...t},r)=>e("tbody",{ref:r,className:Ct("[&_tr:last-child]:border-0",a),...t}));Ys.displayName="TableBody";const Zs=r.forwardRef(({className:a,...t},r)=>e("tfoot",{ref:r,className:Ct("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Zs.displayName="TableFooter";const en=r.forwardRef(({className:a,...t},r)=>e("tr",{ref:r,className:Ct("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));en.displayName="TableRow";const an=r.forwardRef(({className:a,...t},r)=>e("th",{ref:r,className:Ct("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",a),...t}));an.displayName="TableHead";const tn=r.forwardRef(({className:a,...t},r)=>e("td",{ref:r,className:Ct("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));tn.displayName="TableCell";const rn=r.forwardRef(({className:a,...t},r)=>e("caption",{ref:r,className:Ct("mt-4 text-sm text-muted-foreground",a),...t}));function sn({rows:t=5,columns:r=4}){return e("div",{className:"w-full",children:a("div",{className:"rounded-md border",children:[e("div",{className:"border-b bg-muted/50 px-4 py-3",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((a,t)=>e($r,{className:"h-4 w-24"},t))})}),e("div",{children:Array.from({length:t}).map((a,t)=>e("div",{className:"border-b px-4 py-3 last:border-0",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((a,t)=>e($r,{className:"h-4 w-20"},t))})},t))})]})})}function nn({count:t=3}){return e("div",{className:"space-y-4",children:Array.from({length:t}).map((t,r)=>a(Ft,{children:[a(jt,{children:[e($r,{className:"h-4 w-3/4"}),e($r,{className:"h-3 w-1/2"})]}),e(Ut,{children:a("div",{className:"space-y-2",children:[e($r,{className:"h-3 w-full"}),e($r,{className:"h-3 w-2/3"})]})})]},r))})}function on({fields:t=4}){return a("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,r)=>a("div",{className:"space-y-2",children:[e($r,{className:"h-4 w-24"}),e($r,{className:"h-10 w-full"})]},r)),a("div",{className:"flex justify-end space-x-2 pt-4",children:[e($r,{className:"h-10 w-20"}),e($r,{className:"h-10 w-20"})]})]})}function ln(){return a("div",{className:"flex items-center justify-between p-4 border-b",children:[a("div",{className:"flex items-center space-x-3",children:[e($r,{className:"h-8 w-8 rounded-full"}),e($r,{className:"h-6 w-32"})]}),a("div",{className:"flex items-center space-x-2",children:[e($r,{className:"h-8 w-8"}),e($r,{className:"h-8 w-24"})]})]})}function dn(){return e("div",{className:"w-64 border-r bg-muted/10",children:a("div",{className:"p-4",children:[e($r,{className:"h-8 w-32 mb-6"}),e("div",{className:"space-y-2",children:Array.from({length:6}).map((t,r)=>a("div",{className:"flex items-center space-x-3 p-2",children:[e($r,{className:"h-4 w-4"}),e($r,{className:"h-4 w-20"})]},r))})]})})}rn.displayName="TableCaption";const cn={default:j,search:F,error:D};function mn({icon:t,title:r,description:s,action:n,className:i,variant:o="default"}){const l=t?()=>t:cn[o];return a("div",{className:Ct("flex flex-col items-center justify-center py-12 px-4 text-center",i),children:[e("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e(l,{className:"h-8 w-8 text-muted-foreground"})}),e("h3",{className:"text-lg font-semibold mb-2",children:r}),s&&e("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),n&&e(Et,{onClick:n.onClick,variant:"outline",children:n.label})]})}const un=({delayDuration:a=300,...t})=>e(Va.Provider,{delayDuration:a,...t}),hn=Va.Root,pn=Va.Trigger,fn=r.forwardRef(({className:a,sideOffset:t=4,...r},s)=>e(Va.Content,{ref:s,sideOffset:t,className:Ct("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...r}));function gn({children:t,className:s}){const n=r.useRef(null),[i,o]=r.useState(!1);r.useEffect(()=>{const e=()=>{const e=n.current;e&&o(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return n.current&&a.observe(n.current),()=>a.disconnect()},[t]);const l=e("div",{ref:n,className:`truncate w-full max-w-full ${s||""}`,children:t});return i?e(un,{delayDuration:300,children:a(hn,{children:[e(pn,{asChild:!0,children:l}),e(fn,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):l}fn.displayName=Va.Content.displayName;const bn=r.forwardRef(({direction:a,onMouseDown:t,isDragging:r,className:s},n)=>{const i="horizontal"===a;return e("div",{ref:n,onMouseDown:t,className:Ct("absolute z-20 select-none touch-none","transition-colors duration-150",i&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!i&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],r&&"bg-primary/30",s),children:e("div",{className:Ct("rounded-full bg-border transition-colors group-hover:bg-primary",r&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});bn.displayName="TableResizeHandle";const vn=Ba.Root,Nn=Ba.Trigger,yn=Ba.Group,xn=Ba.Portal,wn=Ba.Sub,kn=Ba.RadioGroup,Cn=r.forwardRef(({className:t,inset:r,children:s,...n},i)=>a(Ba.SubTrigger,{ref:i,className:Ct("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",t),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));Cn.displayName=Ba.SubTrigger.displayName;const Sn=r.forwardRef(({className:a,...t},r)=>e(Ba.SubContent,{ref:r,className:Ct("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));Sn.displayName=Ba.SubContent.displayName;const _n=r.forwardRef(({className:a,sideOffset:t=4,...r},s)=>e(Ba.Portal,{children:e(Ba.Content,{ref:s,sideOffset:t,className:Ct("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...r})}));_n.displayName=Ba.Content.displayName;const Pn=r.forwardRef(({className:a,inset:t,...r},s)=>e(Ba.Item,{ref:s,className:Ct("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...r}));Pn.displayName=Ba.Item.displayName;const An=r.forwardRef(({className:t,children:r,checked:s,...n},i)=>a(Ba.CheckboxItem,{ref:i,className:Ct("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Ba.ItemIndicator,{children:e(A,{className:"h-4 w-4"})})}),r]}));An.displayName=Ba.CheckboxItem.displayName;const Tn=r.forwardRef(({className:t,children:r,...s},n)=>a(Ba.RadioItem,{ref:n,className:Ct("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Ba.ItemIndicator,{children:e(O,{className:"h-2 w-2 fill-current"})})}),r]}));Tn.displayName=Ba.RadioItem.displayName;const In=r.forwardRef(({className:a,inset:t,...r},s)=>e(Ba.Label,{ref:s,className:Ct("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...r}));In.displayName=Ba.Label.displayName;const En=r.forwardRef(({className:a,...t},r)=>e(Ba.Separator,{ref:r,className:Ct("-mx-1 my-1 h-px bg-muted",a),...t}));En.displayName=Ba.Separator.displayName;const Rn=({className:a,...t})=>e("span",{className:Ct("ml-auto text-xs tracking-widest opacity-60",a),...t});Rn.displayName="DropdownMenuShortcut";const zn=qa.Root,Mn=qa.Trigger,Dn=qa.Group,Fn=qa.Portal,jn=qa.Sub,Ln=qa.RadioGroup,On=r.forwardRef(({className:t,inset:r,children:s,...n},i)=>a(qa.SubTrigger,{ref:i,className:Ct("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",t),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));On.displayName=qa.SubTrigger.displayName;const Un=r.forwardRef(({className:a,...t},r)=>e(qa.SubContent,{ref:r,className:Ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));Un.displayName=qa.SubContent.displayName;const $n=r.forwardRef(({className:a,...t},r)=>e(qa.Portal,{children:e(qa.Content,{ref:r,className:Ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t})}));$n.displayName=qa.Content.displayName;const Wn=r.forwardRef(({className:a,inset:t,...r},s)=>e(qa.Item,{ref:s,className:Ct("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...r}));Wn.displayName=qa.Item.displayName;const Vn=r.forwardRef(({className:t,children:r,checked:s,...n},i)=>a(qa.CheckboxItem,{ref:i,className:Ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(qa.ItemIndicator,{children:e(A,{className:"h-4 w-4"})})}),r]}));Vn.displayName=qa.CheckboxItem.displayName;const Bn=r.forwardRef(({className:t,children:r,...s},n)=>a(qa.RadioItem,{ref:n,className:Ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(qa.ItemIndicator,{children:e(O,{className:"h-2 w-2 fill-current"})})}),r]}));Bn.displayName=qa.RadioItem.displayName;const qn=r.forwardRef(({className:a,inset:t,...r},s)=>e(qa.Label,{ref:s,className:Ct("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...r}));qn.displayName=qa.Label.displayName;const Hn=r.forwardRef(({className:a,...t},r)=>e(qa.Separator,{ref:r,className:Ct("-mx-1 my-1 h-px bg-border",a),...t}));Hn.displayName=qa.Separator.displayName;const Gn=({className:a,...t})=>e("span",{className:Ct("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Gn.displayName="ContextMenuShortcut";const Kn=({onEdit:r,onDelete:s,onToggleStatus:n,isActive:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d})=>{const{t:c}=Ia(),m=[];if(r){const e={icon:U,label:c("edit"),onClick:r};m.push(e)}if(l.forEach(e=>{m.push(e)}),n){const e={icon:i?$:W,label:c(i?"deactivate":"activate"),onClick:n};m.push(e)}if(o&&s){const e={icon:V,label:c("delete"),onClick:s,destructive:!0};m.push(e)}const u="dropdown"===d?Pn:Wn;return e(t,{children:m.map((t,r)=>a(u,{onClick:t.onClick,className:Ct("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},r))})},Qn=({onEdit:t,onDelete:r,canDelete:s=!0,onToggleStatus:n,isActive:i=!0,customActions:o=[]})=>a(vn,{children:[e(Nn,{asChild:!0,children:e(Et,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e(C,{size:12})})}),e(_n,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e(Kn,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:r?e=>{e?.stopPropagation(),r?.()}:void 0,onToggleStatus:n?e=>{e?.stopPropagation(),n?.()}:void 0,isActive:i,canDelete:s&&!!r,customActions:o,renderAs:"dropdown"})})]}),Jn=150;function Xn({columns:e,storageKey:a,onResize:t,enabled:r=!0}){const[s,i]=n(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Jn,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Jn,e),{})}),[o,l]=n(!1),[u,h]=n(null),p=m(0),f=m(0),g=d((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),h(e),p.current=a.clientX,f.current=s[e]??Jn)},[r,s]);c(()=>{if(!o||!u)return;const r=e.find(e=>e.key===u),s=r?.minWidth??60,n=r?.maxWidth??500,d=e=>{const a=e.clientX-p.current,r=Math.max(s,Math.min(n,f.current+a));i(e=>{const a={...e,[u]:r};return t?.(a),a})},c=()=>{l(!1),h(null),a&&i(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",d),document.addEventListener("mouseup",c),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",c)}},[o,u,e,a,t]),c(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const b=d(()=>{const r=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Jn,e),{});i(r),a&&localStorage.removeItem(a),t?.(r)},[e,a,t]);return{columnWidths:s,isDragging:o,activeColumn:u,handleMouseDown:g,resetWidths:b}}function Yn({rowIds:e,defaultHeight:a=48,minHeight:t=32,maxHeight:r=120,storageKey:s,onResize:i,enabled:o=!0}){const[l,u]=n(()=>{if(!o||"undefined"==typeof window)return{};if(s){const e=localStorage.getItem(s);if(e)try{return JSON.parse(e)}catch{}}return{}}),[h,p]=n(!1),[f,g]=n(null),b=m(0),v=m(0),N=d(e=>l[e]??a,[l,a]),y=d((e,t)=>{o&&(t.preventDefault(),t.stopPropagation(),p(!0),g(e),b.current=t.clientY,v.current=l[e]??a)},[o,l,a]);c(()=>{if(!h||!f)return;const e=e=>{const a=e.clientY-b.current,s=Math.max(t,Math.min(r,v.current+a));u(e=>{const a={...e,[f]:s};return i?.(a),a})},a=()=>{p(!1),g(null),s&&u(e=>(localStorage.setItem(s,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[h,f,t,r,s,i]),c(()=>{h?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[h]);const x=d(()=>{u({}),s&&localStorage.removeItem(s),i?.({})},[s,i]);return{rowHeights:l,isDragging:h,activeRow:f,handleMouseDown:y,resetHeights:x,getRowHeight:N}}const Zn=u(({checked:a,onCheckedChange:t})=>e(xr,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),ei=({manager:t,columns:r,onEdit:s,onView:o,onToggleStatus:l,onDelete:d,renderActions:m,customRowActions:u,enableBulkActions:h=!1,onNew:p,newButtonLabel:f,showNewButton:g=!0,customActions:b=[],hideActionBar:v=!1,enableColumnResize:N=!0,resizeStorageKey:y})=>{const{t:x}=Ia(),{setSearchVisible:w}=Gs(),[k,C]=n(!1);c(()=>(w(!0),()=>w(!1)),[w]),c(()=>{const e=()=>C(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:S,isDragging:_,activeColumn:P,handleMouseDown:A}=Xn({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:y?`${y}-columns`:void 0,enabled:N}),{isDragging:T,activeRow:I,handleMouseDown:E,getRowHeight:R}=Yn({rowIds:t.entities.map(e=>e.id),storageKey:y?`${y}-rows`:void 0,enabled:!1}),z=i(()=>(()=>{if(N)return r.map(e=>{const a=S[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=r.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,r=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:r,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[r,N,S]),M=!v&&(p||b.length>0);return k?t.isLoading?e(nn,{count:3}):0===t.entities.length?e(mn,{title:x("empty_title"),description:x("empty_description"),variant:"search"}):a("div",{className:"flex flex-col h-full",children:[M&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:a("div",{className:"flex items-center gap-2",children:[p&&g&&a(Et,{onClick:p,children:[e(B,{size:16,className:"mr-2"}),f||x("new")]}),b.map((t,r)=>{const s=t.icon;return a(Et,{onClick:t.action,variant:t.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),t.label]},r)})]})}),e("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(n=>a(zn,{children:[e(Mn,{asChild:!0,children:e(Ft,{className:Ct("overflow-hidden cursor-pointer hover:bg-muted/50",h&&t.selectedIds.includes(n.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),h?t.selectItem(n.id):s?.(n)},children:e(Ut,{className:"p-4",children:a("div",{className:"flex items-start gap-3",children:[h&&e("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e(Zn,{checked:t.selectedIds.includes(n.id),onCheckedChange:()=>t.selectItem(n.id)})}),a("div",{className:"flex-1",children:[r.map(t=>a("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[a("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),e("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(n):String(n[t.key]??"")})]},String(t.key))),(s||o||m)&&e("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:m?m(n):e(Qn,{onEdit:s?()=>{s(n)}:void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,customActions:u?u(n):[]})})]})]})})})}),e($n,{className:"w-[160px]",children:e(Kn,{onEdit:s?()=>s(n):void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,canDelete:!!d,customActions:u?u(n):[],renderAs:"context"})})]},n.id))})]}):a("div",{className:"flex flex-col h-full",children:[M&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:a("div",{className:"flex items-center gap-2",children:[p&&g&&a(Et,{onClick:p,children:[e(B,{size:16,className:"mr-2"}),f||x("new")]}),b.map((t,r)=>{const s=t.icon;return a(Et,{onClick:t.action,variant:t.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),t.label]},r)})]})}),t.isLoading?e(sn,{rows:5,columns:r.length}):e("div",{className:"flex flex-col h-full overflow-hidden",children:e("div",{className:"flex-1 overflow-auto",children:a(Js,{className:"table-auto",children:[a("colgroup",{children:[h&&e("col",{style:{width:"50px"}}),z.map((a,t)=>e("col",{style:a.style},t)),e("col",{style:{width:"50px"}})]}),e(Xs,{children:a(en,{children:[h&&e(an,{className:"w-[50px]",children:e(Zn,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),r.map(r=>{const s=N&&!1!==r.resizable,n=P===String(r.key);return a(an,{className:Ct(r.className,r.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:r.sortable?()=>t.handleSort(String(r.key)):void 0,children:[a("div",{className:"flex items-center "+(r.className?.includes("text-center")?"justify-center":""),children:[r.header,r.sortable&&(i=String(r.key),t.sortField!==i?e(q,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e(H,{size:14,className:"ml-1"}):e(G,{size:14,className:"ml-1"}))]}),s&&e(bn,{direction:"horizontal",onMouseDown:e=>A(String(r.key),e),isDragging:n})]},String(r.key));var i}),e(an,{className:"w-[50px] text-center",children:x("actions")})]})}),e(Ys,{children:0===t.entities.length?e(en,{children:e(tn,{colSpan:h?r.length+2:r.length+1,className:"h-32",children:e(mn,{title:x("empty_title"),description:x("empty_description"),variant:"search"})})}):t.entities.map(n=>{const i=R(n.id);return n.id,a(zn,{children:[e(Mn,{asChild:!0,children:a(en,{className:Ct("cursor-pointer hover:bg-muted/50 relative",h&&t.selectedIds.includes(n.id)&&"bg-muted"),style:i?{height:`${i}px`}:void 0,onClick:e=>{e.stopPropagation(),h?t.selectItem(n.id):s?.(n)},children:[h&&e(tn,{onClick:e=>e.stopPropagation(),children:e(Zn,{checked:t.selectedIds.includes(n.id),onCheckedChange:()=>t.selectItem(n.id)})}),r.map(a=>e(tn,{className:a.className,children:e(gn,{children:a.render?a.render(n):String(n[a.key]??"")})},String(a.key))),e(tn,{className:"text-center",children:m?m(n):e(Qn,{onEdit:s?()=>s(n):void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,customActions:u?u(n):[]})})]})}),e($n,{className:"w-[160px]",children:e(Kn,{onEdit:s?()=>s(n):void 0,onDelete:d?()=>d(n):void 0,onToggleStatus:l?()=>l(n):void 0,isActive:n.is_actived,canDelete:!!d,customActions:u?u(n):[],renderAs:"context"})})]},n.id)})})]})})})]})};function ai(e,a,t,r){const[s,o]=n({}),[l,d]=n({}),m=i(()=>e,[e]),u=e=>e instanceof Date&&!isNaN(e.getTime()),h=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},p=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return h(e)}},f=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let s;if("function"==typeof e.validation?s=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(s=e.validation.custom),s)try{const e=s(a,t);if(e)return e}catch(r){}}};c(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},s=e(m),n={};s.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);u(e)&&(t=e.toISOString().split("T")[0])}else u(t)&&(t=t.toISOString().split("T")[0])}else t=h(e);n[e.name]=t}),s.forEach(e=>{const a=p(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{s.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),d({}),t&&t(n)},[m,a,t,r]);const g=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...g(e.fields))}),a},b=()=>{const e=g(m),a={};return e.forEach(e=>{const t=f(e,s[e.name],s);t&&(a[e.name]=t)}),d(a),0===Object.keys(a).length};return{formData:s,errors:l,updateField:(e,a)=>{o(r=>{const s={...r,[e]:a},n=((e,a)=>{let t={...a};const r=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...r(e.fields))}),a};return r(m).filter(a=>a.dependsOn===e).forEach(e=>{const a=p(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,s);return t&&t(n),n}),l[e]&&d(a=>{const t={...a};return delete t[e],t});const r=g(m).find(a=>a.name===e);if(r){const t=f(r,a,s);t&&d(a=>({...a,[e]:t}))}},validateForm:b,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),b()&&e(s)}}}const ti=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],ri=({value:t="#3b82f6",onChange:r,label:s})=>a("div",{className:"space-y-2",children:[s&&e(Dt,{children:s}),a(Tr,{children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e(Er,{className:"w-64",children:a("div",{className:"space-y-3",children:[a("div",{children:[e(Dt,{htmlFor:"color-input",children:"Cor personalizada"}),e(zt,{id:"color-input",type:"color",value:t,onChange:e=>r?.(e.target.value),className:"h-10 w-full"})]}),a("div",{children:[e(Dt,{children:"Cores predefinidas"}),e("div",{className:"grid grid-cols-5 gap-2 mt-2",children:ti.map(a=>e("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>r?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),si=r.forwardRef(({className:t,children:r,...s},n)=>a(Ha.Root,{ref:n,className:Ct("relative overflow-hidden",t),...s,children:[e(Ha.Viewport,{className:"h-full w-full rounded-[inherit]",children:r}),e(ni,{}),e(Ha.Corner,{})]}));si.displayName=Ha.Root.displayName;const ni=r.forwardRef(({className:a,orientation:t="vertical",...r},s)=>e(Ha.ScrollAreaScrollbar,{ref:s,orientation:t,className:Ct("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...r,children:e(Ha.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ni.displayName=Ha.ScrollAreaScrollbar.displayName;const ii={Star:Le,Heart:je,Home:Fe,User:De,Settings:Me,Mail:ze,Phone:Re,Calendar:Ee,MapPin:Ie,Camera:Te,Image:Ae,Music:Pe,Video:_e,Book:Se,Bookmark:Ce,Search:F,Filter:ke,Edit:U,Trash2:V,Plus:B,Minus:we,Check:A,X:S,ChevronDown:_,ChevronUp:P,ChevronLeft:xe,ChevronRight:L,ArrowUp:H,ArrowDown:G,ArrowLeft:ye,ArrowRight:Ne,Clock:ve,Bell:be,AlertCircle:D,Info:ge,HelpCircle:fe,Download:pe,Upload:he,Share:ue,Copy:me,Save:ce,FileText:de,Folder:le,FolderOpen:oe,Archive:ie,Lock:ne,Unlock:se,Eye:re,EyeOff:te,Shield:ae,Key:ee,Zap:Z,Flame:Y,Sparkles:X,Award:J,Trophy:Q,Target:K},oi=({value:t="Star",onChange:r,label:s})=>{const{t:i}=Ia(),[o,l]=n(""),d=Object.entries(ii).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),c=ii[t]||Le;return a("div",{className:"space-y-2",children:[s&&e(Dt,{children:s}),a(Tr,{children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e(c,{className:"h-4 w-4 mr-2"}),t]})}),e(Er,{className:"w-80",children:a("div",{className:"space-y-3",children:[a("div",{children:[e(Dt,{htmlFor:"icon-search",children:i("search")}),e(zt,{id:"icon-search",placeholder:i("search"),value:o,onChange:e=>l(e.target.value)})]}),e(si,{className:"h-48",children:e("div",{className:"grid grid-cols-6 gap-2",children:d.map(([a,s])=>e("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>r?.(a),title:a,children:e(s,{className:"h-4 w-4"})},a))})})]})})]})]})},li=r.forwardRef(({className:a,...t},r)=>e(Ga.Root,{className:Ct("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a),...t,ref:r,children:e(Ga.Thumb,{className:Ct("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));li.displayName=Ga.Root.displayName;const di=(e={})=>{const{user:a,alias:t}=Gs(),{enabled:r=!0}=e;return Da({queryKey:["qualiex-users",t],queryFn:()=>ys.getUsers(t),enabled:r&&!!t&&!!a,retry:2,retryDelay:1e3})},ci=({value:a,onChange:t,multiple:r=!1,label:s,required:n,placeholder:o,icon:l,maxDisplayedBadges:c,className:m,disabled:u,enabled:h,displayFormat:p="name",customDisplayFn:f,filterFn:g,sortOptions:b=!0,popoverContainer:v,onOpen:N,onClose:y})=>{const{t:x}=Ia(),{data:w=[],isLoading:k,error:C}=di({enabled:h}),S=i(()=>g?w.filter(g):w,[w,g]),_=d(e=>{if("custom"===p&&f)return f(e);const a=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${a} (${e.userEmail})`:a;case"name-role":return e.roleName?`${a} - ${e.roleName}`:a;default:return a}},[p,f]);return e(Br,{multiple:r,value:a??(r?[]:""),onChange:t,options:S,isLoading:k,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:_,placeholder:o||x("search_placeholder"),searchPlaceholder:x("search_placeholder"),emptyMessage:x("no_results"),label:s,required:n,icon:l,maxDisplayedBadges:c,disabled:u,className:m,sortOptions:b,popoverContainer:v,onOpen:N,onClose:y})};function mi({title:t,sections:r,initialData:o,onSubmit:l,onCancel:c,open:u,submitButtonText:h,isLoading:p=!1,usersData:f}){const{t:g}=Ia(),[b,v]=n(r?.[0]?.id||""),N=m(null),[y,x]=n(null),w=d(e=>{N.current=e,x(e)},[]),k=i(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:C,errors:S,updateField:_,handleSubmit:P}=ai(k,o,void 0,u),A=i(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(C):e.disabled||!1})):[],[r,C]),T=i(()=>{const e=A.find(e=>e.id===b);if(e&&!e.disabled)return b;const a=A.find(e=>!e.disabled);return a?.id||b},[A,b]);s.useEffect(()=>{T!==b&&v(T)},[T,b]);const I=A.find(e=>e.id===T),E=t=>{const r=(t.computedValue,C[t.name]),s=void 0!==r?r:"",n=S[t.name];switch(t.type){case"group":const r="horizontal"===t.layout,i=r?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=r?Ct("space-y-2 w-full",t.wrapperClassName):Ct("space-y-2",t.className,t.wrapperClassName);return a("div",{className:o,children:[t.label,e("div",{className:i,children:t.fields?.map(e=>E(e))})]},t.name);case"user-select":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ci,{value:s||"",onChange:e=>_(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"textarea":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(wr,{id:t.name,value:s||"",onChange:e=>{_(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"select":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a(mr,{value:String(s),onValueChange:e=>{_(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e(pr,{className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e(hr,{placeholder:t.placeholder})}),e(br,{children:t.options?.map(a=>e(Nr,{value:a.value,children:a.label},a.value))})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"multiselect":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Br,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>_(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:n,popoverContainer:y,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"date":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(zt,{id:t.name,type:"date",value:String(s),onChange:e=>_(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:Ct("w-full",n?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"color":return a("div",{children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(zt,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>_(t.name,e.target.value),className:"h-10"}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},t.name);case"color-picker":return a("div",{children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ri,{value:s||t.defaultValue||"#3b82f6",onChange:e=>_(t.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},t.name);case"icon-picker":return a("div",{children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(oi,{value:s||t.defaultValue||"Star",onChange:e=>_(t.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},t.name);case"custom":if(!t.component)return null;const l=t.component,d="function"==typeof t.componentProps?t.componentProps(C):t.componentProps||{};return a("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(l,{value:s,onChange:e=>{_(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:n,popoverContainer:y,...d}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"number":return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(zt,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,r=""===a?null:Number(a);_(t.name,r)},placeholder:t.placeholder,disabled:t.disabled,className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"checkbox":return a("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e(xr,{id:t.name,checked:!!s,onCheckedChange:e=>_(t.name,e),disabled:t.disabled}),a(Dt,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name);case"switch":return a("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(li,{id:t.name,checked:!!s,onCheckedChange:e=>_(t.name,e),disabled:t.disabled}),n&&e("p",{className:"text-sm text-destructive mt-2",children:n})]},t.name);default:return a("div",{className:`space-y-2 ${t.className||""}`,children:[a(Dt,{htmlFor:t.name,children:[t.label,t.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(zt,{id:t.name,type:"text",value:s||"",onChange:e=>{_(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${n?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},t.name)}},R=d(()=>{if(!I)return null;if(I.disabled)return a("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e("div",{className:"rounded-full bg-muted p-3 mb-4",children:e("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(I.component){const a=I.component;return e(a,{formData:C,updateField:_,errors:S,users:f,disabled:I.disabled})}return e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:I.fields.map(E)})},[I,C,_,S,f,E]),z=a("div",{className:"flex flex-col max-h-[80vh]",children:[A.length>1&&e("div",{className:"flex-shrink-0 p-4 border-b",children:e("div",{className:"flex space-x-2",children:A.map(a=>e(Et,{variant:T===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=A.find(a=>a.id===e);a&&!a.disabled&&v(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:p?e("div",{className:"flex items-center justify-center py-12",children:e("div",{className:"text-muted-foreground",children:g("loading")})}):a("form",{onSubmit:P(l),className:"space-y-3 md:space-y-4",children:[R(),a("div",{className:"flex justify-end space-x-2 pt-4",children:[e(Et,{type:"button",variant:"outline",onClick:c,children:g("cancel")}),e(Et,{type:"submit",disabled:p,children:h||g("save")})]})]})})]});return e(Vt,{open:u,onOpenChange:e=>{!1===e&&!0===u&&c()},children:a(Qt,{ref:w,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[a(Jt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e(Zt,{children:t}),e(er,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),z]})})}function ui({currentPage:r,totalPages:s,totalItems:n,itemsPerPage:i,onPageChange:o,onItemsPerPageChange:l,variant:d="full"}){const c=(r-1)*i+1,m=Math.min(r*i,n);return a("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e("div",{className:"flex items-center gap-2",children:"full"===d&&a(t,{children:[e("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),a(mr,{value:String(i),onValueChange:e=>l(Number(e)),children:[e(pr,{className:"h-8 w-[70px]",children:e(hr,{})}),a(br,{children:[e(Nr,{value:"10",children:"10"}),e(Nr,{value:"25",children:"25"}),e(Nr,{value:"50",children:"50"}),e(Nr,{value:"100",children:"100"})]})]})]})}),a("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",m," de ",n," itens"]}),a("div",{className:"flex items-center gap-1",children:[e(Et,{variant:"outline",size:"sm",onClick:()=>o(1),disabled:1===r,className:"h-8 w-8 p-0",children:e(Oe,{size:16})}),e(Et,{variant:"outline",size:"sm",onClick:()=>o(r-1),disabled:1===r,className:"h-8 w-8 p-0",children:e(xe,{size:16})}),a("div",{className:"flex items-center gap-1 px-2",children:[e("span",{className:"text-sm font-medium",children:r}),e("span",{className:"text-sm text-muted-foreground",children:"de"}),e("span",{className:"text-sm font-medium",children:s})]}),e(Et,{variant:"outline",size:"sm",onClick:()=>o(r+1),disabled:r===s,className:"h-8 w-8 p-0",children:e(L,{size:16})}),e(Et,{variant:"outline",size:"sm",onClick:()=>o(s),disabled:r===s,className:"h-8 w-8 p-0",children:e(Ue,{size:16})})]})]})}function hi({manager:a}){return e(ui,{currentPage:a.pagination.currentPage,totalPages:a.pagination.totalPages,totalItems:a.pagination.totalItems,itemsPerPage:a.pagination.itemsPerPage,onPageChange:a.handlePageChange,onItemsPerPageChange:a.handleItemsPerPageChange,variant:"full"})}const pi=({selectedCount:t,onClearSelection:r,onBulkDelete:s,customActions:n=[],isLoading:i=!1})=>{const{t:o}=Ia();return a("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[a("div",{className:"flex items-center gap-3",children:[e("span",{className:"text-sm font-medium",children:o("selected_count",{count:t})}),a(Et,{variant:"ghost",size:"sm",onClick:r,className:"h-7 px-2",children:[e(S,{size:14,className:"mr-1"}),o("clear")]})]}),a("div",{className:"flex items-center gap-2",children:[n.map((t,r)=>{const s=t.icon;return a(Et,{variant:t.variant||"outline",size:"sm",onClick:()=>t.action([]),disabled:i,className:"h-7",children:[s&&e(s,{size:14,className:"mr-1"}),t.label]},r)}),s&&a(Et,{variant:"destructive",size:"sm",onClick:s,disabled:i,className:"h-7",children:[e(V,{size:14,className:"mr-1"}),o("delete")]})]})]})},fi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},gi={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},bi={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function vi({children:a,direction:t="column",gap:r="md",align:s="stretch",justify:n="start",wrap:i=!1,className:o}){return e("div",{className:Ct("flex","column"===t?"flex-col":"flex-row",fi[r],gi[s],bi[n],i&&"flex-wrap",o),children:a})}function Ni({manager:r,filters:s,inline:n=!1}){const{t:i}=Ia(),{isSearchVisible:o}=Gs(),l=r.searchTerm,d=a(t,{children:[s.some(e=>"search"===e.type)&&!o&&a("div",{className:"relative flex-1",children:[e(F,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e(zt,{placeholder:i("search"),value:r.searchTerm,onChange:e=>r.handleSearch(e.target.value),className:"pl-10"})]}),s.filter(e=>"select"===e.type&&e.options).map((t,r)=>a("select",{value:t.value||"",onChange:e=>t.onChange?.(e.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[t.placeholder&&e("option",{value:"",children:t.placeholder}),t.options.map(a=>e("option",{value:a.value,children:a.label},a.value))]},`select-${r}`)),s.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e("div",{className:n?"":"w-full sm:w-auto",children:e(r,{...a.props})},`custom-${t}`)}),l&&a(Et,{variant:"outline",onClick:r.clearFilters,className:"whitespace-nowrap",children:[e(S,{className:"h-4 w-4 mr-2"}),i("clear")]})]});return n?e("div",{className:"flex items-center gap-2",children:d}):e(vi,{direction:"column",gap:"md",className:"mb-6",children:e(vi,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:d})})}function yi({manager:t,config:r,formSections:s,onSave:i,onToggleStatus:o,defaultSort:l}){t&&t.queryKey;const{t:d}=Ia(),{setSearchVisible:m}=Gs(),[u,h]=Oa(),[p,f]=n(!1),[g,b]=n(null),[v,N]=n({isOpen:!1,entityId:null,entityName:""}),[y,x]=n({isOpen:!1,count:0});c(()=>(m(!0),()=>{m(!1)}),[m]),c(()=>{if(l&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=l.column,t[a]=l.direction,h(t)}}},[]);const w=()=>{N({isOpen:!1,entityId:null,entityName:""})};return a("div",{className:"flex-1 flex flex-col h-full",children:[r.enableBulkActions&&t.selectedIds.length>0&&e(pi,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:r.bulkActions&&r.bulkActions.length>0?void 0:()=>{x({isOpen:!0,count:t.selectedIds.length})},customActions:r.bulkActions,isLoading:t.isBulkDeleting}),a("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[a("div",{className:"flex items-center gap-2",children:[!r.hideNewButton&&a(Et,{onClick:()=>{r.onNew?r.onNew():(b(null),f(!0))},children:[e(B,{size:16,className:"mr-2"}),d("new")]}),r.customActions?.map((t,r)=>a(Et,{onClick:t.action,variant:t.variant||"outline",children:[t.icon&&e(t.icon,{size:16,className:"mr-2"}),t.label]},r))]}),r.filters&&r.filters.length>0&&e("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e(Ni,{manager:t,filters:r.filters,inline:!0})})]}),e("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?e("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(t.entities,t)}):e(ei,{manager:t,columns:r.columns,onEdit:e=>{r.onEdit?r.onEdit(e):(b(e),f(!0))},onDelete:e=>{N({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:o,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions})}),e("div",{className:"flex-shrink-0 border-t bg-background",children:e(hi,{manager:t})}),!r.useCustomRouting&&!r.onNew&&e(mi,{open:p,title:g?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:g||void 0,onSubmit:e=>{i(e),f(!1),b(null)},onCancel:()=>{f(!1),b(null)},isLoading:t.isLoading,submitButtonText:d(g?"update":"create")}),e(Vt,{open:v.isOpen,onOpenChange:w,children:a(Qt,{size:"sm",children:[e(Jt,{showSeparator:!0,children:e(Zt,{children:"Você tem certeza absoluta?"})}),e("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e("strong",{children:v.entityName}),". Esta ação não pode ser desfeita."]})}),a(Yt,{children:[e(Et,{variant:"outline",onClick:w,children:"Cancelar"}),e(Et,{variant:"destructive",onClick:()=>{v.entityId&&(t.deleteEntity(v.entityId),N({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e(Vt,{open:y.isOpen,onOpenChange:()=>x({isOpen:!1,count:0}),children:a(Qt,{size:"sm",children:[e(Jt,{showSeparator:!0,children:e(Zt,{children:"Você tem certeza absoluta?"})}),e("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e("strong",{children:y.count})," ",1===y.count?r.entityName:r.entityNamePlural,". Esta ação não pode ser desfeita."]})}),a(Yt,{children:[e(Et,{variant:"outline",onClick:()=>x({isOpen:!1,count:0}),children:"Cancelar"}),e(Et,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),x({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function xi(a){return({manager:t})=>{const{manager:r,config:s,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??r,d={entityName:s.entityName,entityNamePlural:s.entityNamePlural,filters:s.filters||[],columns:s.columns,cardFields:s.cardFields||[],enableBulkActions:s.enableBulkActions??!1,bulkActions:s.bulkActions||[],customActions:s.customActions,customRowActions:s.customRowActions,customListView:s.customListView,onEdit:i||s.onEdit,onNew:s.onNew,useCustomRouting:s.useCustomRouting,hideNewButton:s.hideNewButton};return e(yi,{manager:l,config:d,formSections:s.formSections,onSave:n,onToggleStatus:o,defaultSort:s.defaultSort})}}function wi(e,a,t){return r=>{if(r.id){const a=t(r);e.updateEntity(r.id,a)}else{const t=a(r);e.createEntity(t)}}}function ki(e,a,t={}){const r=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],s={key:e,header:Si(e),label:Si(e),...Ci(e,t),sortable:!0,searchable:"string"==typeof t};r.push(s)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}}function Ci(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function Si(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const _i=({children:r})=>{const{isAuthenticated:n,isLoading:i}=Gs();if(s.useEffect(()=>{if(!n)return;const e=()=>{es.areAllTokensValid()||Bs.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[n]),s.useEffect(()=>{if(i)return;if(n)return;if(es.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const r=Cs();(async()=>{r?await Bs.loginDev():Bs.loginProd()})()},[n,i]),i)return e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Ft,{className:"w-full max-w-md",children:[e(jt,{className:"text-center",children:e(Lt,{className:"text-xl font-semibold",children:"Carregando..."})}),a(Ut,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){const t=new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token");return e("div",t?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Ft,{className:"w-full max-w-md",children:[e(jt,{className:"text-center",children:e(Lt,{className:"text-xl font-semibold",children:"Processando..."})}),a(Ut,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Ft,{className:"w-full max-w-md",children:[e(jt,{className:"text-center",children:e(Lt,{className:"text-xl font-semibold",children:"Iniciando..."})}),a(Ut,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:Cs()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e(t,{children:r})},Pi=f("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),Ai={info:ge,warning:ge,danger:We,success:$e},Ti=r.forwardRef(({className:t,variant:r="info",showIcon:s=!0,children:n,...i},o)=>{const l=Ai[r||"info"];return a("div",{ref:o,role:"alert",className:Ct(Pi({variant:r}),t),...i,children:[s&&e(l,{className:"h-4 w-4"}),n]})});Ti.displayName="Alert";const Ii=r.forwardRef(({className:a,...t},r)=>e("h5",{ref:r,className:Ct("mb-1 font-medium leading-none tracking-tight",a),...t}));Ii.displayName="AlertTitle";const Ei=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("text-sm [&_p]:leading-relaxed",a),...t}));Ei.displayName="AlertDescription";const Ri=()=>{const{processCallback:r}=Gs(),[s,i]=n(null),[o,l]=n(!1);c(()=>{(async()=>{try{if(await r()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else i("Falha na autenticação. Tente novamente.")}catch(e){i(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[r]);const d=async()=>{l(!0),i(null);try{await r()||i("Falha na autenticação. Tente novamente.")}catch(e){i(e?.message||"Erro ao tentar novamente.")}finally{l(!1)}},m=()=>{window.location.href="/"};return e("div",s?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Ft,{className:"w-full max-w-md",children:[e(jt,{className:"text-center",children:a(Lt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e(D,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),a(Ut,{className:"space-y-4",children:[e(Ti,{variant:"danger",children:e(Ei,{children:s})}),e("div",{className:"text-sm text-muted-foreground",children:e("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),a("div",{className:"flex gap-2",children:[e(Et,{onClick:d,disabled:o,className:"flex-1",children:a(t,o?{children:[e(_r,{size:"sm",className:"mr-2"}),"Tentando..."]}:{children:[e(Ve,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e(Et,{onClick:m,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Ft,{className:"w-full max-w-md",children:[e(jt,{className:"text-center",children:e(Lt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),a(Ut,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(_r,{size:"lg"})}),e("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},zi=()=>e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a(Ft,{className:"w-full max-w-md",children:[e(jt,{className:"text-center",children:e(Lt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),a(Ut,{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e(Et,{onClick:async()=>{Cs()?await Bs.loginDev():Bs.loginProd()},className:"w-full",size:"lg",children:Cs()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Mi=o(void 0);function Di({children:a,actions:t}){const[r,s]=n({}),[i,o]=n(t);return c(()=>{o(t)},[t]),e(Mi.Provider,{value:{metadata:r,setMetadata:s,clearMetadata:()=>s({}),headerActions:i,setHeaderActions:o},children:a})}function Fi(){const e=l(Mi);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function ji(e){const{setMetadata:a,clearMetadata:t}=Fi();c(()=>(a(e),()=>t()),[e.title,e.subtitle,a,t])}function Li(e){return{queryClient:e.queryClient||new ja({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Oi=import.meta.env.VITE_SUPABASE_URL,Ui=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;let $i=null;var Wi=Object.defineProperty,Vi=(e,a,t)=>((e,a,t)=>a in e?Wi(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Bi=new class{constructor(){Vi(this,"cache",{}),Vi(this,"cacheTimestamps",new Map),Vi(this,"CACHE_TTL",3e5),Vi(this,"loadingPromises",new Map)}isCacheValid(e){const a=this.cacheTimestamps.get(e);return!!a&&Date.now()-a<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const a=this.loadingPromises.get(e);if(a)return a;const t=this.fetchTranslations(e);this.loadingPromises.set(e,t);try{return await t}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const a=(!$i&&Oi&&Ui&&($i=za(Oi,Ui,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),$i),{data:t,error:r}=await a.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(r)return"42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied")||r.message?.includes("No suitable key"),{};const s={};return t?.forEach(a=>{let t;t="pt-BR"===e?a.pt:"en-US"===e?a.en||a.pt:"es-ES"===e&&a.es||a.pt,t&&(s[a.key]=t)}),this.cache[e]=s,this.cacheTimestamps.set(e,Date.now()),s}catch(a){return{}}}async upsertTranslation(e,a,t,r){const s=cs(),{error:n}=await s.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:r},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=cs(),{error:t}=await a.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(t)throw t;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var qi=Object.defineProperty,Hi=(e,a,t)=>((e,a,t)=>a in e?qi(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Gi="true"===import.meta.env.VITE_I18N_DEBUG_MODE;x.use(new class{constructor(e=!1){Hi(this,"type","backend"),Hi(this,"isDebugMode"),Hi(this,"cache",new Map),Hi(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,a,t){if(this.cache.has(e))return void t(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{t(null,this.cache.get(e)||{})});const r=Bi.loadTranslations(e).then(a=>{if(this.isDebugMode){const t={};Object.keys(a).forEach(e=>{t[e]=`[${e} ✅]`}),this.cache.set(e,t)}else this.cache.set(e,a)}).catch(a=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,r),r.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,r){}}(Gi)).use(Ea).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Gi?`[${e} ❌]`:`[⚠️ ${e}]`});const Ki=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Qi=[{value:"dd/MM/yyyy HH:mm",label:"dd/MM/yyyy HH:mm",example:"28/11/2024 14:30",description:"Padrão Brasileiro"},{value:"MM/dd/yyyy hh:mm a",label:"MM/dd/yyyy hh:mm a",example:"11/28/2024 02:30 PM",description:"Padrão Americano (12h)"},{value:"MM/dd/yyyy HH:mm",label:"MM/dd/yyyy HH:mm",example:"11/28/2024 14:30",description:"Padrão Americano (24h)"},{value:"yyyy-MM-dd HH:mm",label:"yyyy-MM-dd HH:mm",example:"2024-11-28 14:30",description:"ISO 8601"},{value:"dd.MM.yyyy HH:mm",label:"dd.MM.yyyy HH:mm",example:"28.11.2024 14:30",description:"Padrão Europeu"},{value:"d MMM yyyy, HH:mm",label:"d MMM yyyy, HH:mm",example:"28 Nov 2024, 14:30",description:"Formato Longo"}],Ji=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],Xi="pt-BR",Yi="dd/MM/yyyy HH:mm",Zi="America/Sao_Paulo",eo=e=>Ki.find(a=>a.value===e),ao=e=>Qi.find(a=>a.value===e),to=e=>Ji.find(a=>a.value===e),ro=e=>Ki.some(a=>a.value===e),so=e=>Qi.some(a=>a.value===e),no=e=>Ji.some(a=>a.value===e),io=()=>{if("undefined"==typeof navigator)return Xi;const e=navigator.language;if(ro(e))return e;const a=e.split("-")[0],t=Ki.find(e=>e.value.startsWith(a));return t?.value||Xi},oo=()=>{if("undefined"==typeof Intl)return Zi;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return no(e)?e:Zi}catch{return Zi}},lo=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||Yi),co=()=>{const e=io();return{locale:e,timezone:oo(),datetimeFormat:lo(e)}};const mo=new class{async getUserPreferences(e,a){if(!es.areAllTokensValid())return null;const t=cs();try{const{data:r,error:s}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(s)return"PGRST116"===s.code?this.createDefaultPreferences(e,a):("42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied"),null);if(!r)return this.createDefaultPreferences(e,a);const n=r;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(r){return null}}async createDefaultPreferences(e,a){const t=cs(),r=co(),s={id_user:e,locale:r.locale,timezone:r.timezone,datetime_format:r.datetimeFormat,alias:a};try{const{data:e,error:a}=await t.schema("common").from("user_preferences").insert(s).select().single();if(a)throw a;const r=e;return{locale:r.locale,timezone:r.timezone,datetimeFormat:r.datetime_format}}catch(n){throw n}}async updatePreferences(e,a,t){const r=cs();try{const{error:s}=await r.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(s)throw s}catch(s){throw s}}},uo=o(void 0),ho=()=>co(),po=({children:a})=>{const{user:t,alias:r}=Gs(),[s,i]=n(ho),[o,l]=n(!0);c(()=>{(async()=>{if(t?.id&&r)try{const e=await mo.getUserPreferences(t.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await x.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{l(!1)}else l(!1)})()},[t?.id,r]);const m=d(async e=>{if(t?.id&&r)try{await mo.updatePreferences(t.id,r,{locale:e}),i(a=>({...a,locale:e})),await x.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[t?.id,r]),u=d(async e=>{if(t?.id&&r)try{await mo.updatePreferences(t.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[t?.id,r]),h=d(async e=>{if(t?.id&&r)try{await mo.updatePreferences(t.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[t?.id,r]);return e(uo.Provider,{value:{...s,setLocale:m,setTimezone:u,setDatetimeFormat:h,isLoading:o},children:a})},fo=()=>{const e=l(uo);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function go({children:r}){const{ready:s}=Ia(),[i,o]=n(!0);return c(()=>{s&&i&&o(!1)},[s,i]),i&&!s?e("div",{className:"flex items-center justify-center min-h-screen bg-background",children:a("div",{className:"flex flex-col items-center gap-4",children:[e(_r,{size:"lg"}),e("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e(t,{children:r})}const bo=Ka.Root,vo=Ka.CollapsibleTrigger,No=Ka.CollapsibleContent;var yo=Object.defineProperty,xo=(e,a,t)=>((e,a,t)=>a in e?yo(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class wo extends h{constructor(e){super(e),xo(this,"copyErrorDetails",()=>{const e=rs.getErrors().slice(0,2),a=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(a),w.success("Detalhes copiados!",{description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if(import.meta.env.DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if(import.meta.env.DEV)throw e;rs.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=rs.getErrors().slice(0,2);return e("div",{className:"flex items-center justify-center min-h-screen p-4",children:a(Ft,{className:"w-full max-w-2xl",children:[a(jt,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(We,{className:"h-12 w-12 text-destructive"})}),e(Lt,{children:"Algo deu errado"})]}),a(Ut,{className:"space-y-4",children:[e("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),a(bo,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e(vo,{asChild:!0,children:a(Et,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e(_,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),a(No,{className:"mt-4 space-y-4",children:[a("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a("div",{children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),a("div",{className:"text-sm space-y-2",children:[e("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e(si,{className:"h-32 w-full rounded border bg-muted p-2",children:e("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&a("div",{className:"pt-3 border-t",children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e("div",{className:"space-y-2",children:t.map((t,r)=>e("div",{className:"text-sm p-2 rounded bg-muted/50",children:a("div",{className:"flex items-start gap-2",children:[a("span",{className:"font-medium text-muted-foreground shrink-0",children:[r+1,"."]}),a("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-2 flex-wrap",children:a("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),a(Et,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e(me,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e(Et,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}function ko({children:a,queryClient:t}){const r=t??new ja({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e(wo,{children:e(Ra,{i18n:x,children:e(La,{client:r,children:e(Hs,{children:e(po,{children:e(go,{children:a})})})})})})}const Co=Qa.Root,So=r.forwardRef(({className:a,...t},r)=>e(Qa.Item,{ref:r,className:Ct("border-b",a),...t}));So.displayName="AccordionItem";const _o=r.forwardRef(({className:t,children:r,...s},n)=>e(Qa.Header,{className:"flex",children:a(Qa.Trigger,{ref:n,className:Ct("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[r,e(_,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));_o.displayName=Qa.Trigger.displayName;const Po=r.forwardRef(({className:a,children:t,...r},s)=>e(Qa.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:e("div",{className:Ct("pb-4 pt-0",a),children:t})}));Po.displayName=Qa.Content.displayName;const Ao=Ja.Root,To=Ja.Trigger,Io=Ja.Portal,Eo=r.forwardRef(({className:a,...t},r)=>e(Ja.Overlay,{className:Ct("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:r}));Eo.displayName=Ja.Overlay.displayName;const Ro=r.forwardRef(({className:t,...r},s)=>a(Io,{children:[e(Eo,{}),e(Ja.Content,{ref:s,className:Ct("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...r})]}));Ro.displayName=Ja.Content.displayName;const zo=({className:a,...t})=>e("div",{className:Ct("flex flex-col space-y-2 text-center sm:text-left",a),...t});zo.displayName="AlertDialogHeader";const Mo=({className:a,...t})=>e("div",{className:Ct("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});Mo.displayName="AlertDialogFooter";const Do=r.forwardRef(({className:a,...t},r)=>e(Ja.Title,{ref:r,className:Ct("text-lg font-semibold",a),...t}));Do.displayName=Ja.Title.displayName;const Fo=r.forwardRef(({className:a,...t},r)=>e(Ja.Description,{ref:r,className:Ct("text-sm text-muted-foreground",a),...t}));Fo.displayName=Ja.Description.displayName;const jo=r.forwardRef(({className:a,...t},r)=>e(Ja.Action,{ref:r,className:Ct(It(),a),...t}));jo.displayName=Ja.Action.displayName;const Lo=r.forwardRef(({className:a,...t},r)=>e(Ja.Cancel,{ref:r,className:Ct(It({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));Lo.displayName=Ja.Cancel.displayName;const Oo=r.forwardRef(({className:a,...t},r)=>e(Xa.Root,{ref:r,className:Ct("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));Oo.displayName=Xa.Root.displayName;const Uo=r.forwardRef(({className:a,...t},r)=>e(Xa.Image,{ref:r,className:Ct("aspect-square h-full w-full",a),...t}));Uo.displayName=Xa.Image.displayName;const $o=r.forwardRef(({className:a,...t},r)=>e(Xa.Fallback,{ref:r,className:Ct("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));$o.displayName=Xa.Fallback.displayName;const Wo=r.forwardRef(({...a},t)=>e("nav",{ref:t,"aria-label":"breadcrumb",...a}));Wo.displayName="Breadcrumb";const Vo=r.forwardRef(({className:a,...t},r)=>e("ol",{ref:r,className:Ct("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));Vo.displayName="BreadcrumbList";const Bo=r.forwardRef(({className:a,...t},r)=>e("li",{ref:r,className:Ct("inline-flex items-center gap-1.5",a),...t}));Bo.displayName="BreadcrumbItem";const qo=r.forwardRef(({asChild:a,className:t,...r},s)=>e(a?p:"a",{ref:s,className:Ct("transition-colors hover:text-foreground",t),...r}));qo.displayName="BreadcrumbLink";const Ho=r.forwardRef(({className:a,...t},r)=>e("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Ct("font-normal text-foreground",a),...t}));Ho.displayName="BreadcrumbPage";const Go=({children:a,className:t,...r})=>e("li",{role:"presentation","aria-hidden":"true",className:Ct("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...r,children:a??e(L,{})});Go.displayName="BreadcrumbSeparator";const Ko=({className:t,...r})=>a("span",{role:"presentation","aria-hidden":"true",className:Ct("flex h-9 w-9 items-center justify-center",t),...r,children:[e(Be,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Mais"})]});Ko.displayName="BreadcrumbEllipsis";const Qo=f("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),Jo=r.forwardRef(({className:a,orientation:t,...r},s)=>e("div",{ref:s,className:Ct(Qo({orientation:t}),a),...r}));function Xo(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function Yo(e){return(a,t)=>{let r;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,s=t?.width?String(t.width):a;r=e.formattingValues[s]||e.formattingValues[a]}else{const a=e.defaultWidth,s=t?.width?String(t.width):e.defaultWidth;r=e.values[s]||e.values[a]}return r[e.argumentCallback?e.argumentCallback(a):a]}}function Zo(e){return(a,t={})=>{const r=t.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],n=a.match(s);if(!n)return null;const i=n[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(o,e=>e.test(i)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(i.length)}}}function el(e){return(a,t={})=>{const r=a.match(e.matchPattern);if(!r)return null;const s=r[0],n=a.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=t.valueCallback?t.valueCallback(i):i;return{value:i,rest:a.slice(s.length)}}}Jo.displayName="ButtonGroup";const al={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},tl={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},rl={ordinalNumber:(e,a)=>{const t=Number(e),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:Yo({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Yo({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Yo({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Yo({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Yo({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},sl={ordinalNumber:el({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Zo({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Zo({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Zo({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Zo({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Zo({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},nl={code:"en-US",formatDistance:(e,a,t)=>{let r;const s=al[e];return r="string"==typeof s?s:1===a?s.one:s.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r},formatLong:{date:Xo({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Xo({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Xo({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,r)=>tl[e],localize:rl,match:sl,options:{weekStartsOn:0,firstWeekContainsDate:1}},il={lessThanXSeconds:{one:"menos de un segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"medio minuto",lessThanXMinutes:{one:"menos de un minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"alrededor de 1 hora",other:"alrededor de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 día",other:"{{count}} días"},aboutXWeeks:{one:"alrededor de 1 semana",other:"alrededor de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"alrededor de 1 mes",other:"alrededor de {{count}} meses"},xMonths:{one:"1 mes",other:"{{count}} meses"},aboutXYears:{one:"alrededor de 1 año",other:"alrededor de {{count}} años"},xYears:{one:"1 año",other:"{{count}} años"},overXYears:{one:"más de 1 año",other:"más de {{count}} años"},almostXYears:{one:"casi 1 año",other:"casi {{count}} años"}},ol={date:Xo({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/y"},defaultWidth:"full"}),time:Xo({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Xo({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ll={lastWeek:"'el' eeee 'pasado a la' p",yesterday:"'ayer a la' p",today:"'hoy a la' p",tomorrow:"'mañana a la' p",nextWeek:"eeee 'a la' p",other:"P"},dl={lastWeek:"'el' eeee 'pasado a las' p",yesterday:"'ayer a las' p",today:"'hoy a las' p",tomorrow:"'mañana a las' p",nextWeek:"eeee 'a las' p",other:"P"},cl={ordinalNumber:(e,a)=>Number(e)+"º",era:Yo({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Yo({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:Yo({values:{narrow:["e","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],wide:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]},defaultWidth:"wide"}),day:Yo({values:{narrow:["d","l","m","m","j","v","s"],short:["do","lu","ma","mi","ju","vi","sá"],abbreviated:["dom","lun","mar","mié","jue","vie","sáb"],wide:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]},defaultWidth:"wide"}),dayPeriod:Yo({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"}},defaultFormattingWidth:"wide"})},ml={ordinalNumber:el({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Zo({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:"any"}),quarter:Zo({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Zo({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:"any"}),day:Zo({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Zo({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:"any"})},ul={code:"es",formatDistance:(e,a,t)=>{let r;const s=il[e];return r="string"==typeof s?s:1===a?s.one:s.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+r:"hace "+r:r},formatLong:ol,formatRelative:(e,a,t,r)=>1!==a.getHours()?dl[e]:ll[e],localize:cl,match:ml,options:{weekStartsOn:1,firstWeekContainsDate:1}},hl={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},pl={date:Xo({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},defaultWidth:"full"}),time:Xo({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Xo({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},fl={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},gl={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Yo({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Yo({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Yo({values:{narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},defaultWidth:"wide"}),day:Yo({values:{narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},defaultWidth:"wide"}),dayPeriod:Yo({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},defaultFormattingWidth:"wide"})},bl={ordinalNumber:el({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Zo({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:Zo({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Zo({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:Zo({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:Zo({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})},vl={code:"pt-BR",formatDistance:(e,a,t)=>{let r;const s=hl[e];return r="string"==typeof s?s:1===a?s.one:s.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+r:"há "+r:r},formatLong:pl,formatRelative:(e,a,t,r)=>{const s=fl[e];return"function"==typeof s?s(a):s},localize:gl,match:bl,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Nl({className:a,classNames:t,showOutsideDays:r=!0,...s}){return e(Ya,{showOutsideDays:r,className:Ct("p-3 pointer-events-auto",a),locale:vl,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Ct(It({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Ct(It({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{Chevron:({orientation:a})=>e("left"===a?xe:L,{className:"h-4 w-4"})},...s})}Nl.displayName="Calendar";const yl={Root:function({children:a,className:t}){return e("div",{className:Ct("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:r}){return e(Ft,{className:Ct("transition-colors",t&&"cursor-pointer hover:bg-muted/50",r),onClick:t,children:e(Ut,{className:"p-4",children:a})})},Field:function({label:t,value:r,className:s}){return a("div",{className:Ct("flex justify-between items-center text-sm",s),children:[a("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e("span",{className:"text-foreground",children:r})]})}};function xl({date:t,onDateChange:r,placeholder:s="Pick a date",disabled:n=!1,className:i,disabledDates:o}){return a(Tr,{children:[e(Ir,{asChild:!0,children:a(Et,{variant:"outline",disabled:n,className:Ct("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",i),children:[e(Ee,{className:"mr-2 h-4 w-4"}),t?y(t,"PPP"):e("span",{children:s})]})}),e(Er,{className:"w-auto p-0",align:"start",children:e(Nl,{mode:"single",selected:t,onSelect:r,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const wl=({shouldScaleBackground:a=!0,...t})=>e(Za.Root,{shouldScaleBackground:a,...t});wl.displayName="Drawer";const kl=Za.Trigger,Cl=Za.Portal,Sl=Za.Close,_l=r.forwardRef(({className:a,...t},r)=>e(Za.Overlay,{ref:r,className:Ct("fixed inset-0 z-50 bg-black/80",a),...t}));_l.displayName=Za.Overlay.displayName;const Pl=r.forwardRef(({className:t,children:r,...s},n)=>a(Cl,{children:[e(_l,{}),a(Za.Content,{ref:n,className:Ct("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),r]})]}));Pl.displayName="DrawerContent";const Al=({className:a,...t})=>e("div",{className:Ct("grid gap-1.5 p-4 text-center sm:text-left",a),...t});Al.displayName="DrawerHeader";const Tl=({className:a,...t})=>e("div",{className:Ct("mt-auto flex flex-col gap-2 p-4",a),...t});Tl.displayName="DrawerFooter";const Il=r.forwardRef(({className:a,...t},r)=>e(Za.Title,{ref:r,className:Ct("text-lg font-semibold leading-none tracking-tight",a),...t}));Il.displayName=Za.Title.displayName;const El=r.forwardRef(({className:a,...t},r)=>e(Za.Description,{ref:r,className:Ct("text-sm text-muted-foreground",a),...t}));El.displayName=Za.Description.displayName;const Rl={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},zl={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Ml({children:a,cols:t="auto-fit",gap:r="md",className:s}){return e("div",{className:Ct("grid",Rl[t],zl[r],s),children:a})}const Dl=et.Root,Fl=et.Trigger,jl=r.forwardRef(({className:a,align:t="center",sideOffset:r=4,...s},n)=>e(et.Content,{ref:n,align:t,sideOffset:r,className:Ct("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...s}));jl.displayName=et.Content.displayName;const Ll=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-slot":"input-group",className:Ct("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",a),...t}));Ll.displayName="InputGroup";const Ol=f("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),Ul=r.forwardRef(({className:a,align:t,...r},s)=>e("div",{ref:s,"data-slot":"input-group-addon",className:Ct(Ol({align:t}),a),...r}));Ul.displayName="InputGroupAddon";const $l=f("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),Wl=r.forwardRef(({className:a,size:t,variant:r="ghost",...s},n)=>e(Et,{ref:n,"data-slot":"input-group-button",variant:r,className:Ct($l({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...s}));Wl.displayName="InputGroupButton";const Vl=r.forwardRef(({className:a,...t},r)=>e(zt,{ref:r,"data-slot":"input-group-control",className:Ct("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));Vl.displayName="InputGroupInput";const Bl=r.forwardRef(({className:a,...t},r)=>e(wr,{ref:r,"data-slot":"input-group-control",className:Ct("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));Bl.displayName="InputGroupTextarea";const ql=r.forwardRef(({className:a,...t},r)=>e("h1",{ref:r,className:Ct("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));ql.displayName="H1";const Hl=r.forwardRef(({className:a,...t},r)=>e("h2",{ref:r,className:Ct("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));Hl.displayName="H2";const Gl=r.forwardRef(({className:a,...t},r)=>e("h3",{ref:r,className:Ct("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));Gl.displayName="H3";const Kl=r.forwardRef(({className:a,...t},r)=>e("h4",{ref:r,className:Ct("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));Kl.displayName="H4";const Ql=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:Ct("leading-7 [&:not(:first-child)]:mt-6",a),...t}));Ql.displayName="P";const Jl=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:Ct("text-xl text-muted-foreground",a),...t}));Jl.displayName="Lead";const Xl=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,className:Ct("text-lg font-semibold",a),...t}));Xl.displayName="Large";const Yl=r.forwardRef(({className:a,...t},r)=>e("small",{ref:r,className:Ct("text-sm font-medium leading-none",a),...t}));Yl.displayName="Small";const Zl=r.forwardRef(({className:a,...t},r)=>e("p",{ref:r,className:Ct("text-sm text-muted-foreground",a),...t}));Zl.displayName="Muted";const ed=r.forwardRef(({className:a,...t},r)=>e("code",{ref:r,className:Ct("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));ed.displayName="InlineCode";const ad=r.forwardRef(({className:a,...t},r)=>e("blockquote",{ref:r,className:Ct("mt-6 border-l-2 pl-6 italic",a),...t}));ad.displayName="Blockquote";const td=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,className:Ct("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));td.displayName="List";const rd=r.forwardRef(({className:t,children:r,...s},n)=>a(at.Root,{ref:n,className:Ct("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[r,e(cd,{})]}));rd.displayName=at.Root.displayName;const sd=r.forwardRef(({className:a,...t},r)=>e(at.List,{ref:r,className:Ct("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));sd.displayName=at.List.displayName;const nd=at.Item,id=f("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),od=r.forwardRef(({className:t,children:r,...s},n)=>a(at.Trigger,{ref:n,className:Ct(id(),"group",t),...s,children:[r," ",e(_,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));od.displayName=at.Trigger.displayName;const ld=r.forwardRef(({className:a,...t},r)=>e(at.Content,{ref:r,className:Ct("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",a),...t}));ld.displayName=at.Content.displayName;const dd=at.Link,cd=r.forwardRef(({className:a,...t},r)=>e("div",{className:Ct("absolute left-0 top-full flex justify-center"),children:e(at.Viewport,{className:Ct("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",a),ref:r,...t})}));cd.displayName=at.Viewport.displayName;const md=r.forwardRef(({className:a,...t},r)=>e(at.Indicator,{ref:r,className:Ct("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",a),...t,children:e("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));function ud({items:r,maxItems:s=3,className:n}){const i=r.length>s?[r[0],...r.slice(-(s-1))]:r,o=r.length>s;return e(Wo,{className:n,children:e(Vo,{children:i.map((r,s)=>{const n=o&&1===s;return a(Bo,{children:[!(0===s)&&e(Go,{}),n&&a(t,{children:[e(Ko,{}),e(Go,{})]}),r.isCurrentPage?e(Ho,{children:r.label}):e(qo,{href:r.href,children:r.label})]},r.label)})})})}function hd(){const e=Ua();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let r="";return a.forEach((e,s)=>{r+=`/${e}`;const n=s===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:r,isCurrentPage:n})}),t})()}md.displayName=at.Indicator.displayName;const pd=({className:a,...t})=>e("nav",{role:"navigation","aria-label":"pagination",className:Ct("mx-auto flex w-full justify-center",a),...t});pd.displayName="Pagination";const fd=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,className:Ct("flex flex-row items-center gap-1",a),...t}));fd.displayName="PaginationContent";const gd=r.forwardRef(({className:a,...t},r)=>e("li",{ref:r,className:Ct("",a),...t}));gd.displayName="PaginationItem";const bd=({className:a,isActive:t,size:r="icon",...s})=>e("a",{"aria-current":t?"page":void 0,className:Ct(It({variant:t?"outline":"ghost",size:r}),a),...s});bd.displayName="PaginationLink";const vd=({className:t,...r})=>a(bd,{"aria-label":"Go to previous page",size:"default",className:Ct("gap-1 pl-2.5",t),...r,children:[e(xe,{className:"h-4 w-4"}),e("span",{children:"Previous"})]});vd.displayName="PaginationPrevious";const Nd=({className:t,...r})=>a(bd,{"aria-label":"Go to next page",size:"default",className:Ct("gap-1 pr-2.5",t),...r,children:[e("span",{children:"Next"}),e(L,{className:"h-4 w-4"})]});Nd.displayName="PaginationNext";const yd=({className:t,...r})=>a("span",{"aria-hidden":!0,className:Ct("flex h-9 w-9 items-center justify-center",t),...r,children:[e(Be,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"More pages"})]});yd.displayName="PaginationEllipsis";const xd=r.forwardRef(({className:a,value:t,...r},s)=>e(tt.Root,{ref:s,className:Ct("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...r,children:e(tt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));xd.displayName=tt.Root.displayName;const wd=r.forwardRef(({className:a,...t},r)=>e(rt.Root,{className:Ct("grid gap-2",a),...t,ref:r}));wd.displayName=rt.Root.displayName;const kd=r.forwardRef(({className:a,...t},r)=>e(rt.Item,{ref:r,className:Ct("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),...t,children:e(rt.Indicator,{className:"flex items-center justify-center",children:e(O,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kd.displayName=rt.Item.displayName;const Cd=({className:a,...t})=>e(st.PanelGroup,{className:Ct("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),Sd=st.Panel,_d=({withHandle:a,className:t,...r})=>e(st.PanelResizeHandle,{className:Ct("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...r,children:a&&e("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e(qe,{className:"h-2.5 w-2.5"})})}),Pd=ya.Root,Ad=ya.Trigger,Td=ya.Close,Id=ya.Portal,Ed=r.forwardRef(({className:a,...t},r)=>e(ya.Overlay,{className:Ct("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:r}));Ed.displayName=ya.Overlay.displayName;const Rd=f("fixed z-50 flex flex-col bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),zd=r.forwardRef(({side:t="right",className:r,children:s,...n},i)=>a(Id,{children:[e(Ed,{}),a(ya.Content,{ref:i,className:Ct(Rd({side:t}),r),...n,children:[s,a(ya.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e(S,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));zd.displayName=ya.Content.displayName;const Md=({className:t,showSeparator:r=!1,children:s,...n})=>a("div",{className:Ct("flex flex-col flex-shrink-0",t),...n,children:[e("div",{className:"flex flex-col text-left",children:s}),r&&e(Wt,{className:"mt-2"})]});Md.displayName="SheetHeader";const Dd=({className:a,...t})=>e("div",{className:Ct("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Dd.displayName="SheetBody";const Fd=({className:t,children:r,...s})=>a("div",{className:"flex-shrink-0 pt-4",children:[e(Wt,{className:"mb-4"}),e("div",{className:Ct("flex flex-row justify-end gap-2",t),...s,children:r})]});Fd.displayName="SheetFooter";const jd=r.forwardRef(({className:a,...t},r)=>e(ya.Title,{ref:r,className:Ct("text-lg font-semibold text-foreground",a),...t}));jd.displayName=ya.Title.displayName;const Ld=r.forwardRef(({className:a,...t},r)=>e(ya.Description,{ref:r,className:Ct("text-sm text-muted-foreground",a),...t}));Ld.displayName=ya.Description.displayName;const Od="sidebar:state",Ud=r.createContext(null);function $d(){const e=r.useContext(Ud);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Wd=r.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:n,style:i,children:o,...l},d)=>{const[c,m]=r.useState(!1);r.useEffect(()=>{const e=()=>m(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,h]=r.useState(!1),[p,f]=r.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Od);return null!==e?"true"===e:a}return a}),g=t??p,b=r.useCallback(e=>{const a="function"==typeof e?e(g):e;s?s(a):f(a),"undefined"!=typeof window&&localStorage.setItem(Od,String(a))},[s,g]),v=r.useCallback(()=>c?h(e=>!e):b(e=>!e),[c,b,h]);r.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v]);const N=g?"expanded":"collapsed",y=r.useMemo(()=>({state:N,open:g,setOpen:b,isMobile:c,openMobile:u,setOpenMobile:h,toggleSidebar:v}),[N,g,b,c,u,h,v]);return e(Ud.Provider,{value:y,children:e(un,{delayDuration:0,children:e("div",{className:Ct("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",n),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...i},ref:d,...l,children:o})})})});Wd.displayName="SidebarProvider";const Vd=r.forwardRef(({side:t="left",variant:r="sidebar",collapsible:s="offcanvas",className:n,children:i,...o},l)=>{const{isMobile:d,state:c,openMobile:m,setOpenMobile:u}=$d();return"none"===s?e("div",{className:Ct("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",n),ref:l,...o,children:i}):d?e(Pd,{open:m,onOpenChange:u,...o,children:a(zd,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e(jd,{className:"sr-only",children:"Menu de Navegação"}),e("div",{className:"flex h-full w-full flex-col",children:i})]})}):a("div",{ref:l,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?s:"","data-variant":r,"data-side":t,children:[e("div",{className:Ct("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===r||"inset"===r?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e("div",{className:Ct("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===r||"inset"===r?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",n),...o,children:e("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:i})})]})});Vd.displayName="Sidebar";const Bd=r.forwardRef(({className:t,onClick:r,...s},n)=>{const{toggleSidebar:i}=$d();return a(Et,{ref:n,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Ct("h-7 w-7",t),onClick:e=>{r?.(e),i()},...s,children:[e(He,{}),e("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Bd.displayName="SidebarTrigger";const qd=r.forwardRef(({className:a,...t},r)=>{const{toggleSidebar:s}=$d();return e("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:Ct("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",a),...t})});qd.displayName="SidebarRail";const Hd=r.forwardRef(({className:a,...t},r)=>e("main",{ref:r,className:Ct("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",a),...t}));Hd.displayName="SidebarInset";const Gd=r.forwardRef(({className:a,...t},r)=>e(zt,{ref:r,"data-sidebar":"input",className:Ct("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));Gd.displayName="SidebarInput";const Kd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"header",className:Ct("flex flex-col gap-2 p-2",a),...t}));Kd.displayName="SidebarHeader";const Qd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"footer",className:Ct("flex flex-col gap-2 p-2",a),...t}));Qd.displayName="SidebarFooter";const Jd=r.forwardRef(({className:a,...t},r)=>e(Wt,{ref:r,"data-sidebar":"separator",className:Ct("mx-2 w-auto bg-sidebar-border",a),...t}));Jd.displayName="SidebarSeparator";const Xd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"content",className:Ct("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));Xd.displayName="SidebarContent";const Yd=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"group",className:Ct("relative flex w-full min-w-0 flex-col p-2",a),...t}));Yd.displayName="SidebarGroup";const Zd=r.forwardRef(({className:a,asChild:t=!1,...r},s)=>e(t?p:"div",{ref:s,"data-sidebar":"group-label",className:Ct("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",a),...r}));Zd.displayName="SidebarGroupLabel";const ec=r.forwardRef(({className:a,asChild:t=!1,...r},s)=>e(t?p:"button",{ref:s,"data-sidebar":"group-action",className:Ct("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",a),...r}));ec.displayName="SidebarGroupAction";const ac=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"group-content",className:Ct("w-full text-sm",a),...t}));ac.displayName="SidebarGroupContent";const tc=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,"data-sidebar":"menu",className:Ct("flex w-full min-w-0 flex-col gap-1",a),...t}));tc.displayName="SidebarMenu";const rc=r.forwardRef(({className:a,...t},r)=>e("li",{ref:r,"data-sidebar":"menu-item",className:Ct("group/menu-item relative",a),...t}));rc.displayName="SidebarMenuItem";const sc=f("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),nc=r.forwardRef(({asChild:t=!1,isActive:r=!1,variant:s="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=t?p:"button",{isMobile:m,state:u}=$d(),h=e(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":r,className:Ct(sc({variant:s,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),a(hn,{children:[e(pn,{asChild:!0,children:h}),e(fn,{side:"right",align:"center",hidden:"collapsed"!==u||m,...i})]})):h});nc.displayName="SidebarMenuButton";const ic=r.forwardRef(({className:a,asChild:t=!1,showOnHover:r=!1,...s},n)=>e(t?p:"button",{ref:n,"data-sidebar":"menu-action",className:Ct("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",a),...s}));ic.displayName="SidebarMenuAction";const oc=r.forwardRef(({className:a,...t},r)=>e("div",{ref:r,"data-sidebar":"menu-badge",className:Ct("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",a),...t}));oc.displayName="SidebarMenuBadge";const lc=r.forwardRef(({className:t,showIcon:s=!1,...n},i)=>{const o=r.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return a("div",{ref:i,"data-sidebar":"menu-skeleton",className:Ct("rounded-md h-8 flex gap-2 px-2 items-center",t),...n,children:[s&&e("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});lc.displayName="SidebarMenuSkeleton";const dc=r.forwardRef(({className:a,...t},r)=>e("ul",{ref:r,"data-sidebar":"menu-sub",className:Ct("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",a),...t}));dc.displayName="SidebarMenuSub";const cc=r.forwardRef(({...a},t)=>e("li",{ref:t,...a}));cc.displayName="SidebarMenuSubItem";const mc=r.forwardRef(({asChild:a=!1,size:t="md",isActive:r,className:s,...n},i)=>e(a?p:"a",{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:Ct("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",s),...n}));mc.displayName="SidebarMenuSubButton";const uc=r.forwardRef(({className:t,value:r,defaultValue:s,...n},i)=>{const o=r||s||[0];return a(nt.Root,{ref:i,value:r,defaultValue:s,className:Ct("relative flex w-full touch-none select-none items-center",t),...n,children:[e(nt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e(nt.Range,{className:"absolute h-full bg-primary"})}),o.map((a,t)=>e(nt.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},t))]})});uc.displayName=nt.Root.displayName;const hc=it.Root,pc=r.forwardRef(({className:a,...t},r)=>e(it.List,{ref:r,className:Ct("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));pc.displayName=it.List.displayName;const fc=r.forwardRef(({className:a,...t},r)=>e(it.Trigger,{ref:r,className:Ct("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",a),...t}));fc.displayName=it.Trigger.displayName;const gc=r.forwardRef(({className:a,...t},r)=>e(it.Content,{ref:r,className:Ct("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));function bc({children:a,className:t}){return e("div",{className:Ct("flex flex-col h-full",t),children:e(si,{className:"flex-1",children:e("div",{className:"space-y-6 p-6",children:a})})})}function vc({title:t,description:r,actions:s,className:n}){return a("div",{className:Ct("space-y-4",n),children:[a("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[a("div",{className:"space-y-1",children:[e("h2",{className:"text-2xl font-bold tracking-tight",children:t}),r&&e("p",{className:"text-muted-foreground text-sm",children:r})]}),s&&e("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e(Wt,{})]})}function Nc({children:a,className:t}){return e("div",{className:Ct("space-y-6",t),children:a})}gc.displayName=it.Content.displayName;const yc=f("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),xc=r.forwardRef(({className:a,variant:t,size:r,...s},n)=>e(ot.Root,{ref:n,className:Ct(yc({variant:t,size:r,className:a})),...s}));xc.displayName=ot.Root.displayName;const wc=r.createContext({size:"default",variant:"default"}),kc=r.forwardRef(({className:a,variant:t,size:r,children:s,...n},i)=>e(lt.Root,{ref:i,className:Ct("flex items-center justify-center gap-1",a),...n,children:e(wc.Provider,{value:{variant:t,size:r},children:s})}));kc.displayName=lt.Root.displayName;const Cc=r.forwardRef(({className:a,children:t,variant:s,size:n,...i},o)=>{const l=r.useContext(wc);return e(lt.Item,{ref:o,className:Ct(yc({variant:l.variant||s,size:l.size||n}),a),...i,children:t})});Cc.displayName=lt.Item.displayName;const Sc=dt.Menu,_c=dt.Group,Pc=dt.Portal,Ac=dt.Sub,Tc=dt.RadioGroup,Ic=r.forwardRef(({className:a,...t},r)=>e(dt.Root,{ref:r,className:Ct("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));Ic.displayName=dt.Root.displayName;const Ec=r.forwardRef(({className:a,...t},r)=>e(dt.Trigger,{ref:r,className:Ct("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a),...t}));Ec.displayName=dt.Trigger.displayName;const Rc=r.forwardRef(({className:t,inset:r,children:s,...n},i)=>a(dt.SubTrigger,{ref:i,className:Ct("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",t),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));Rc.displayName=dt.SubTrigger.displayName;const zc=r.forwardRef(({className:a,...t},r)=>e(dt.SubContent,{ref:r,className:Ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));zc.displayName=dt.SubContent.displayName;const Mc=r.forwardRef(({className:a,align:t="start",alignOffset:r=-4,sideOffset:s=8,...n},i)=>e(dt.Portal,{children:e(dt.Content,{ref:i,align:t,alignOffset:r,sideOffset:s,className:Ct("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...n})}));Mc.displayName=dt.Content.displayName;const Dc=r.forwardRef(({className:a,inset:t,...r},s)=>e(dt.Item,{ref:s,className:Ct("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...r}));Dc.displayName=dt.Item.displayName;const Fc=r.forwardRef(({className:t,children:r,checked:s,...n},i)=>a(dt.CheckboxItem,{ref:i,className:Ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(dt.ItemIndicator,{children:e(A,{className:"h-4 w-4"})})}),r]}));Fc.displayName=dt.CheckboxItem.displayName;const jc=r.forwardRef(({className:t,children:r,...s},n)=>a(dt.RadioItem,{ref:n,className:Ct("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(dt.ItemIndicator,{children:e(O,{className:"h-2 w-2 fill-current"})})}),r]}));jc.displayName=dt.RadioItem.displayName;const Lc=r.forwardRef(({className:a,inset:t,...r},s)=>e(dt.Label,{ref:s,className:Ct("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...r}));Lc.displayName=dt.Label.displayName;const Oc=r.forwardRef(({className:a,...t},r)=>e(dt.Separator,{ref:r,className:Ct("-mx-1 my-1 h-px bg-muted",a),...t}));Oc.displayName=dt.Separator.displayName;const Uc=({className:a,...t})=>e("span",{className:Ct("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Uc.displayname="MenubarShortcut";const $c={light:"",dark:".dark"},Wc=r.createContext(null);function Vc(){const e=r.useContext(Wc);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Bc=r.forwardRef(({id:t,className:s,children:n,config:i,...o},l)=>{const d=r.useId(),c=`chart-${t||d.replace(/:/g,"")}`;return e(Wc.Provider,{value:{config:i},children:a("div",{"data-chart":c,ref:l,className:Ct("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...o,children:[e(qc,{id:c,config:i}),e(ct.ResponsiveContainer,{children:n})]})})});Bc.displayName="Chart";const qc=({id:a,config:t})=>{const r=Object.entries(t).filter(([,e])=>e.theme||e.color);return r.length?e("style",{dangerouslySetInnerHTML:{__html:Object.entries($c).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${r.map(([a,t])=>{const r=t.theme?.[e]||t.color;return r?` --color-${a}: ${r};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Hc=ct.Tooltip,Gc=r.forwardRef(({active:s,payload:n,className:i,indicator:o="dot",hideLabel:l=!1,hideIndicator:d=!1,label:c,labelFormatter:m,labelClassName:u,formatter:h,color:p,nameKey:f,labelKey:g},b)=>{const{config:v}=Vc(),N=r.useMemo(()=>{if(l||!n?.length)return null;const[a]=n,t=Jc(v,a,`${g||a?.dataKey||a?.name||"value"}`),r=g||"string"!=typeof c?t?.label:v[c]?.label||c;return m?e("div",{className:Ct("font-medium",u),children:m(r,n)}):r?e("div",{className:Ct("font-medium",u),children:r}):null},[c,m,n,l,u,v,g]);if(!s||!n?.length)return null;const y=1===n.length&&"dot"!==o;return a("div",{ref:b,className:Ct("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",i),children:[y?null:N,e("div",{className:"grid gap-1.5",children:n.map((r,s)=>{const n=`${f||r.name||r.dataKey||"value"}`,i=Jc(v,r,n),l=p||r.payload?.fill||r.color;return e("div",{className:Ct("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===o&&"items-center"),children:h&&void 0!==r?.value&&r.name?h(r.value,r.name,r,s,r.payload):a(t,{children:[i?.icon?e(i.icon,{}):!d&&e("div",{className:Ct("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===o,"w-1":"line"===o,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===o,"my-0.5":y&&"dashed"===o}),style:{"--color-bg":l,"--color-border":l}}),a("div",{className:Ct("flex flex-1 justify-between leading-none",y?"items-end":"items-center"),children:[a("div",{className:"grid gap-1.5",children:[y?N:null,e("span",{className:"text-muted-foreground",children:i?.label||r.name})]}),void 0!==r.value&&e("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof r.value?r.value.toLocaleString():r.value})]})]})},r.dataKey||s)})})]})});Gc.displayName="ChartTooltip";const Kc=ct.Legend,Qc=r.forwardRef(({className:t,hideIcon:r=!1,payload:s,verticalAlign:n="bottom",nameKey:i},o)=>{const{config:l}=Vc();return s?.length?e("div",{ref:o,className:Ct("flex items-center justify-center gap-4","top"===n?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${i||t.dataKey||"value"}`,n=Jc(l,t,s);return a("div",{className:Ct("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[n?.icon&&!r?e(n.icon,{}):e("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),n?.label]},t.value)})}):null});function Jc(e,a,t){if("object"!=typeof a||null===a)return;const r="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let s=t;return t in a&&"string"==typeof a[t]?s=a[t]:r&&t in r&&"string"==typeof r[t]&&(s=r[t]),s in e?e[s]:e[t]}Qc.displayName="ChartLegend";const Xc=({onClick:a,isActive:t,disabled:r,children:s,title:n})=>e("button",{type:"button",onClick:a,disabled:r,title:n,className:Ct("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",r&&"opacity-50 cursor-not-allowed"),children:s}),Yc=()=>e("div",{className:"w-px h-5 bg-border mx-1"}),Zc=({value:t,onChange:s,disabled:i,placeholder:o="Escreva o conteúdo aqui...",minHeight:l="300px",showModeToggle:c=!0,showVariableHint:m=!0,className:u})=>{const[h,p]=n("visual"),f=mt({extensions:[ht.configure({heading:{levels:[1,2,3]}}),pt,ft.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),gt,bt,vt.configure({multicolor:!0})],content:t||"",editable:!i,onUpdate:({editor:e})=>{s(e.getHTML())}});r.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t||"")},[t,f]);const g=d(()=>{if(!f)return;const e=f.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?f.chain().focus().extendMarkRange("link").setLink({href:a}).run():f.chain().focus().extendMarkRange("link").unsetLink().run())},[f]);return f?a("div",{className:Ct("space-y-2",u),children:[c&&a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex gap-1",children:[a(Et,{type:"button",size:"sm",variant:"visual"===h?"default":"outline",onClick:()=>p("visual"),disabled:i,children:[e(Ge,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),a(Et,{type:"button",size:"sm",variant:"code"===h?"default":"outline",onClick:()=>p("code"),disabled:i,children:[e(Ke,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),a(Et,{type:"button",size:"sm",variant:"preview"===h?"default":"outline",onClick:()=>p("preview"),disabled:i,children:[e(re,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),m&&a("p",{className:"text-xs text-muted-foreground",children:["Use ",e("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===h&&a("div",{className:"border rounded-md overflow-hidden bg-background",children:[a("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e(Xc,{onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),isActive:f.isActive("heading",{level:1}),disabled:i,title:"Título 1",children:e(Qe,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),isActive:f.isActive("heading",{level:2}),disabled:i,title:"Título 2",children:e(Je,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().toggleHeading({level:3}).run(),isActive:f.isActive("heading",{level:3}),disabled:i,title:"Título 3",children:e(Xe,{className:"h-4 w-4"})}),e(Yc,{}),e(Xc,{onClick:()=>f.chain().focus().toggleBold().run(),isActive:f.isActive("bold"),disabled:i,title:"Negrito",children:e(Ye,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().toggleItalic().run(),isActive:f.isActive("italic"),disabled:i,title:"Itálico",children:e(Ze,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().toggleUnderline().run(),isActive:f.isActive("underline"),disabled:i,title:"Sublinhado",children:e(ea,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().toggleStrike().run(),isActive:f.isActive("strike"),disabled:i,title:"Riscado",children:e(aa,{className:"h-4 w-4"})}),e(Yc,{}),e(Xc,{onClick:()=>f.chain().focus().toggleBulletList().run(),isActive:f.isActive("bulletList"),disabled:i,title:"Lista",children:e(ta,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().toggleOrderedList().run(),isActive:f.isActive("orderedList"),disabled:i,title:"Lista Ordenada",children:e(ra,{className:"h-4 w-4"})}),e(Yc,{}),e(Xc,{onClick:()=>f.chain().focus().toggleHighlight().run(),isActive:f.isActive("highlight"),disabled:i,title:"Destacar",children:e(sa,{className:"h-4 w-4"})}),e(Xc,{onClick:g,isActive:f.isActive("link"),disabled:i,title:"Link",children:e(na,{className:"h-4 w-4"})}),e(Yc,{}),e(Xc,{onClick:()=>f.chain().focus().unsetAllMarks().clearNodes().run(),disabled:i,title:"Limpar Formatação",children:e(ia,{className:"h-4 w-4"})}),e(Yc,{}),e(Xc,{onClick:()=>f.chain().focus().undo().run(),disabled:i||!f.can().undo(),title:"Desfazer",children:e(oa,{className:"h-4 w-4"})}),e(Xc,{onClick:()=>f.chain().focus().redo().run(),disabled:i||!f.can().redo(),title:"Refazer",children:e(la,{className:"h-4 w-4"})})]}),e(ut,{editor:f,className:Ct("prose prose-sm max-w-none p-4 focus:outline-none","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:l}})]}),"code"===h&&e("textarea",{value:t||"",onChange:e=>s(e.target.value),disabled:i,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:l},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===h&&e("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:l},children:e("div",{className:"bg-background shadow-sm rounded border p-4",children:e("div",{dangerouslySetInnerHTML:{__html:t||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null};function em({image:a,title:t,className:r}){return e("div",{className:Ct("relative w-full aspect-video bg-muted rounded-lg overflow-hidden",r),children:a?e("img",{src:a,alt:t,className:"w-full h-full object-cover"}):e("div",{className:"flex items-center justify-center h-full",children:e(da,{className:"w-16 h-16 text-muted-foreground"})})})}function am({steps:t,currentStepIndex:r,onStepSelect:s,stepLabel:n,className:i}){const o=t.length,l=(r+1)/o*100;return a("div",{className:Ct("flex items-center gap-3",i),children:[a(vn,{children:[e(Nn,{asChild:!0,children:a(Et,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[n," ",r+1,"/",o,e(_,{className:"h-3 w-3 ml-1"})]})}),e(_n,{align:"start",children:t.map((e,t)=>a(Pn,{onClick:()=>s(t),className:Ct(t===r&&"bg-accent"),children:[t+1,". ",e.title]},e.id))})]}),e(xd,{value:l,className:"w-32 h-2"})]})}function tm({currentStepIndex:t,totalSteps:r,onBack:s,onNext:n,onComplete:i,backButtonText:o,continueButtonText:l,finishButtonText:d,className:c}){const m=0===t,u=t===r-1;return a("div",{className:Ct("flex items-center gap-2",c),children:[!m&&a(Et,{variant:"outline",onClick:s,size:"sm",children:[e(ye,{className:"h-4 w-4 mr-2"}),o]}),a(Et,{onClick:u?i:n,size:"sm",children:[u?d:l,!u&&e(Ne,{className:"h-4 w-4 ml-2"})]})]})}const rm=r.forwardRef(({open:t,onOpenChange:s,steps:n,onComplete:i,onStepChange:o,continueButtonText:l="Continuar",backButtonText:d="Voltar",finishButtonText:c="Concluir",stepLabel:m="Etapa",size:u="md",showProgressIndicator:h=!0,currentStepIndex:p,onCurrentStepChange:f,className:g},b)=>{const[v,N]=r.useState(0),y=void 0!==p,x=y?p:v,w=r.useCallback(e=>{y?f?.(e):N(e),o?.(e)},[y,f,o]);r.useEffect(()=>{t||y||N(0)},[t,y]);const k=n[x],C=n.length;return k?e(Vt,{open:t,onOpenChange:s,children:a(Qt,{ref:b,size:u,className:Ct("p-0 gap-0",g),children:[a(Ht,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10",children:[e(S,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Fechar"})]}),a("div",{className:"p-6 space-y-4",children:[e(em,{image:k.image,title:k.title}),e(Zt,{className:"text-xl font-semibold",children:k.title}),e(er,{className:"text-muted-foreground",children:k.description})]}),e(Wt,{}),a("div",{className:"p-4 flex items-center justify-between",children:[h&&C>1?e(am,{steps:n,currentStepIndex:x,onStepSelect:e=>{w(e)},stepLabel:m}):e("div",{}),e(tm,{currentStepIndex:x,totalSteps:C,onBack:()=>{x>0&&w(x-1)},onNext:()=>{x<C-1&&w(x+1)},onComplete:()=>{i?.(),s(!1)},backButtonText:d,continueButtonText:l,finishButtonText:c})]})]})}):null});function sm({label:t,onClick:r,icon:s,actions:n=[],variant:i="default",size:o="default",disabled:l=!1,loading:d=!1,menuAlign:c="end",className:m}){const u=l||d;if(!(n.length>0))return a(Et,{variant:i,size:o,disabled:u,onClick:r,className:m,children:[d?e(T,{className:"mr-2 h-4 w-4 animate-spin"}):s?e(s,{className:"mr-2 h-4 w-4"}):null,t]});return a("div",{className:Ct("inline-flex rounded-md shadow-sm",m),children:[a(Et,{variant:i,size:o,disabled:u,onClick:r,className:"rounded-r-none border-r-0 focus:z-10",children:[d?e(T,{className:"mr-2 h-4 w-4 animate-spin"}):s?e(s,{className:"mr-2 h-4 w-4"}):null,t]}),a(vn,{children:[e(Nn,{asChild:!0,children:e(Et,{variant:i,size:o,disabled:u,className:Ct("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e(_,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e(_n,{align:c,className:"min-w-[160px]",children:n.map(t=>{const r=t.icon;return a(Pn,{onClick:t.onClick,disabled:t.disabled,className:Ct("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[r&&e(r,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]})}rm.displayName="OnboardingDialog";const nm=u(({checked:a,onCheckedChange:t})=>e(xr,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),im=({manager:r,columns:s,onEdit:n,onView:i,onToggleStatus:o,onDelete:l,renderActions:d,customRowActions:m,enableBulkActions:u=!1,onNew:h,newButtonLabel:p,showNewButton:f=!0,customActions:g=[],hideActionBar:b=!1,gridColumns:v=3,renderCard:N,viewMode:y,onViewModeChange:x,listCardRenderer:w,gridCardRenderer:k,showViewToggle:C=!1})=>{const{t:S}=Ia(),{setSearchVisible:_}=Gs();c(()=>(_(!0),()=>_(!1)),[_]);const P=!b&&(h||g.length>0||C),A=y||"grid",T="list"===A,I={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"}[T?1:v];if(r.isLoading)return a("div",{className:"flex flex-col h-full",children:[P&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e("div",{className:"flex items-center gap-2",children:h&&f&&a(Et,{onClick:h,children:[e(B,{size:16,className:"mr-2"}),p||S("new")]})})}),e("div",{className:"flex-1 overflow-auto p-4",children:e(nn,{count:6})})]});if(0===r.entities.length)return a("div",{className:"flex flex-col h-full",children:[P&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:a("div",{className:"flex items-center gap-2",children:[h&&f&&a(Et,{onClick:h,children:[e(B,{size:16,className:"mr-2"}),p||S("new")]}),g.map((t,r)=>{const s=t.icon;return a(Et,{onClick:t.action,variant:t.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),t.label]},r)})]})}),e("div",{className:"flex-1 flex items-center justify-center",children:e(mn,{title:S("empty_title"),description:S("empty_description"),variant:"search"})})]});return a("div",{className:"flex flex-col h-full",children:[P&&a("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[a("div",{className:"flex items-center gap-2",children:[h&&f&&a(Et,{onClick:h,children:[e(B,{size:16,className:"mr-2"}),p||S("new")]}),g.map((t,r)=>{const s=t.icon;return a(Et,{onClick:t.action,variant:t.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),t.label]},r)})]}),C&&x&&a(kc,{type:"single",value:A,onValueChange:e=>e&&x(e),size:"sm",children:[e(Cc,{value:"list","aria-label":"Visualização em lista",children:e(ta,{className:"h-4 w-4"})}),e(Cc,{value:"grid","aria-label":"Visualização em grade",children:e(ca,{className:"h-4 w-4"})})]})]}),e("div",{className:"flex-1 overflow-auto p-4",children:e("div",{className:Ct("grid gap-4",I),children:r.entities.map(c=>{const h=(e=>T&&w?w(e):!T&&k?k(e):N?N(e):null)(c);return a(zn,{children:[e(Mn,{asChild:!0,children:h?e("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),u?r.selectItem(c.id):n?.(c)},children:h}):e(Ft,{className:Ct("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&r.selectedIds.includes(c.id)&&"bg-muted ring-2 ring-primary",T&&"flex-row"),onClick:e=>{e.stopPropagation(),u?r.selectItem(c.id):n?.(c)},children:a(Ut,{className:Ct("p-4",T&&"flex items-center gap-4 w-full"),children:[u&&e("div",{className:Ct(T?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e(nm,{checked:r.selectedIds.includes(c.id),onCheckedChange:()=>r.selectItem(c.id)})}),T?a(t,{children:[e("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(t=>a("div",{className:"flex items-center gap-2 min-w-0",children:[a("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),e("div",{className:"text-sm text-foreground truncate",children:t.render?t.render(c):String(c[t.key]??"")})]},String(t.key)))}),(n||i||d)&&e("div",{onClick:e=>e.stopPropagation(),children:d?d(c):e(Qn,{onEdit:n?()=>n(c):void 0,onDelete:l?()=>l(c):void 0,onToggleStatus:o?()=>o(c):void 0,isActive:c.is_actived,customActions:m?m(c):[]})})]}):a("div",{className:"flex items-start gap-3",children:[u&&e("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e(nm,{checked:r.selectedIds.includes(c.id),onCheckedChange:()=>r.selectItem(c.id)})}),a("div",{className:"flex-1 min-w-0",children:[s.map((t,r)=>a("div",{className:Ct("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[a("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),e("div",{className:"text-sm text-foreground text-right truncate",children:t.render?t.render(c):String(c[t.key]??"")})]},String(t.key))),(n||i||d)&&e("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(c):e(Qn,{onEdit:n?()=>n(c):void 0,onDelete:l?()=>l(c):void 0,onToggleStatus:o?()=>o(c):void 0,isActive:c.is_actived,customActions:m?m(c):[]})})]})]})]})})}),e($n,{className:"w-[160px]",children:e(Kn,{onEdit:n?()=>n(c):void 0,onDelete:l?()=>l(c):void 0,onToggleStatus:o?()=>o(c):void 0,isActive:c.is_actived,canDelete:!!l,customActions:m?m(c):[],renderAs:"context"})})]},c.id)})})})]})};function om({data:t,columns:r,sortField:s,sortDirection:n,onSort:o,onRowClick:l,renderActions:d,isLoading:c=!1,emptyMessage:m="Nenhum item encontrado",className:u,enableSelection:h=!1,selectedIds:p=[],onSelectItem:f,onSelectAll:g,isAllSelected:b=!1,enableColumnResize:v=!0,onColumnResize:N,storageKey:y}){const{columnWidths:x,isDragging:w,activeColumn:k,handleMouseDown:C}=Xn({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:y?`${y}-columns`:void 0,onResize:N,enabled:v}),{isDragging:S,activeRow:_,handleMouseDown:P,getRowHeight:A}=Yn({rowIds:t.map(e=>e.id),storageKey:y?`${y}-rows`:void 0,enabled:!1}),T=i(()=>{if(v)return r.map(e=>`${x[String(e.key)]??e.width??e.minWidth??150}px`);const e=r.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return r.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[r,v,x]);if(c)return e("div",{className:"flex-1 overflow-auto",children:e("div",{className:"p-4 space-y-3",children:[...Array(5)].map((a,t)=>e($r,{className:"h-12 w-full"},t))})});if(0===t.length)return e("div",{className:"flex-1 flex items-center justify-center",children:e("div",{className:"text-center text-muted-foreground",children:e("p",{children:m})})});return e("div",{className:"flex-1 overflow-auto "+(w||S?"select-none":""),children:a(Js,{className:u,children:[e(Xs,{className:"sticky top-0 bg-background z-10",children:a(en,{children:[h&&e(an,{className:"w-[40px]",children:e(xr,{checked:b,onCheckedChange:g,"aria-label":"Selecionar todos"})}),r.map((t,r)=>{const i=v&&!1!==t.resizable,l=k===String(t.key);return a(an,{className:`${t.className||""} relative`,style:{width:T[r]},children:[t.sortable&&o?a("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(d=String(t.key),s!==d?e(q,{size:14,className:"ml-1 opacity-50"}):e("asc"===n?H:G,{size:14,className:"ml-1"}))]}):e("span",{className:"font-medium",children:t.header}),i&&e(bn,{direction:"horizontal",onMouseDown:e=>C(String(t.key),e),isDragging:l})]},String(t.key));var d}),d&&e(an,{className:"w-[80px] text-right",children:"Ações"})]})}),e(Ys,{children:t.map(t=>{const s=A(t.id);return t.id,a(en,{onClick:()=>l?.(t),className:(l?"cursor-pointer":"")+" relative",style:s?{height:`${s}px`}:void 0,children:[h&&e(tn,{children:e(xr,{checked:p.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${t.id}`})}),r.map(a=>e(tn,{className:a.className,children:e(gn,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),d&&e(tn,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(t)})]},t.id)})})]})})}function lm({onEdit:t,onDelete:r,onToggleStatus:s,isActive:n=!0,canEdit:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d="dropdown",variant:c="default"}){const{t:m}=Ia(),u=[];return t&&i&&u.push({icon:U,label:m("edit"),onClick:t,variant:"default"}),s&&u.push({icon:n?$:W,label:m(n?"deactivate":"activate"),onClick:s,variant:"default"}),l.forEach(e=>{!1!==e.show&&u.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),r&&o&&u.push({icon:V,label:m("remove"),onClick:r,variant:"destructive"}),0===u.length?null:"dropdown"===d?a(vn,{children:[e(Nn,{asChild:!0,children:e(Et,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e(C,{size:"compact"===c?14:16})})}),e(_n,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:u.map((t,r)=>a(Pn,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},r))})]}):e("div",{className:"flex items-center gap-1",children:u.map((t,r)=>a(Et,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:t.onClick,className:"compact"===c?"h-7 px-2":"",children:[t.icon&&e(t.icon,{size:"compact"===c?14:16}),"compact"!==c&&e("span",{className:"ml-1",children:t.label})]},r))})}function dm({searchValue:t="",onSearchChange:r,customFilters:s=[],onClearFilters:n,showClearButton:i=!0,layout:o="horizontal"}){const{t:l}=Ia(),d=t||s.length>0;return a("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[r&&a("div",{className:"relative flex-1 min-w-[200px]",children:[e(F,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(zt,{type:"text",placeholder:l("search"),value:t,onChange:e=>r(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e("div",{className:"vertical"===o?"w-full":"",children:a},t)),i&&d&&n&&a(Et,{variant:"ghost",size:"sm",onClick:n,className:"h-9 px-3 whitespace-nowrap",children:[e(S,{size:14,className:"mr-1"}),l("clear_filters")]})]})}function cm(e){const a=$a();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const r=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(r)}}}function mm(e,a){const t=cm({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}}const um=()=>{const{locale:t,datetimeFormat:r,timezone:s,setLocale:n,setDatetimeFormat:i,setTimezone:o}=fo(),{t:l}=Ia();return a("div",{className:"space-y-4 p-4",children:[a("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-sm text-muted-foreground",children:l("preferences")||"Preferências"}),a(Et,{variant:"ghost",size:"sm",onClick:()=>{const e=co();n(e.locale),o(e.timezone),i(e.datetimeFormat)},className:"h-8 gap-1.5 text-xs",children:[e(ma,{className:"h-3.5 w-3.5"}),l("useSystemDefaults")||"Usar padrão do sistema"]})]}),a("div",{children:[a("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(ua,{className:"h-4 w-4"}),l("language")]}),a(mr,{value:t,onValueChange:n,children:[e(pr,{children:e(hr,{})}),e(br,{children:Ki.map(e=>a(Nr,{value:e.value,children:[e.flag," ",e.label]},e.value))})]})]}),a("div",{children:[a("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(ve,{className:"h-4 w-4"}),l("timezone")||"Fuso Horário"]}),e(Br,{options:Ji,value:s,onChange:e=>{"string"==typeof e&&o(e)},getOptionValue:e=>e.value,getOptionLabel:e=>e.label,placeholder:l("selectTimezone")||"Selecione o fuso horário",searchPlaceholder:l("searchTimezone")||"Buscar fuso horário...",sortOptions:!1})]}),a("div",{children:[a("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(Ee,{className:"h-4 w-4"}),l("dateTimeFormat")||"Formato de Data/Hora"]}),e(Br,{options:Qi,value:r,onChange:e=>"string"==typeof e&&i(e),getOptionValue:e=>e.value,getOptionLabel:e=>`${e.label} • ${e.example}`,placeholder:l("selectDateFormat")||"Selecione o formato",searchPlaceholder:l("searchDateFormat")||"Buscar formato...",sortOptions:!1})]})]})},hm=s.memo(({variant:r="card",className:i="",selectedUnit:o,onUnitChange:l})=>{const{user:d,companies:c,alias:m,isAuthenticated:u,logout:h,switchUnit:p}=Gs(),[f,g]=n(!1),b="true"===import.meta.env.VITE_SHOW_USER_PREFERENCES,v=c?.[0]||null,N=m?c?.find(e=>e.alias===m):v,y=c||[],x=o||N||v||v,w=s.useCallback(e=>{l?l(e):p(e)},[l,p]),k=s.useMemo(()=>{if(!y?.length)return[];const e=new Map;y.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===x?.alias),r=a.filter(e=>e.alias!==x?.alias);return r.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...r]:r},[y,x?.alias]);if(!u||!d)return null;const C=()=>a(t,{children:[a("div",{className:"flex items-center space-x-3",children:[e("div",{className:"flex-shrink-0",children:e("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e(De,{className:"h-5 w-5 text-primary-foreground"})})}),a("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-medium truncate",children:d.name}),a("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e("div",{className:"mt-3",children:a("div",{className:"flex items-center space-x-2",children:[e(ha,{className:"h-4 w-4 text-muted-foreground"}),e("span",{className:"text-sm font-medium",children:x.name})]})}),k.length>1&&a("div",{className:"mt-2",children:[a("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",k.length]}),a("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,3).map(a=>e(Cr,{variant:a.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>w(a),children:a.name},a.alias)),k.length>3&&a(Cr,{variant:"outline",className:"text-xs",children:["+",k.length-3]})]})]})]});return"dropdown"===r?a(vn,{children:[e(Nn,{asChild:!0,children:e(Et,{variant:"ghost",className:`h-auto p-2 ${i}`,children:a("div",{className:"flex items-center space-x-2",children:[a("div",{className:"hidden md:block text-left",children:[e("p",{className:"text-sm font-medium",children:d.name}),e("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e(De,{className:"h-4 w-4 text-primary-foreground"})}),e(_,{className:"h-4 w-4"})]})})}),a(_n,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[a(wn,{children:[a(Cn,{children:[e(Ve,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e(Sn,{children:k.map(t=>a(Pn,{onClick:()=>w(t),className:t.alias===x?.alias?"bg-muted":"",children:[e(ha,{className:"mr-2 h-4 w-4"}),t.name,t.alias===x?.alias&&e(Cr,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),b&&e(En,{}),b&&a(Pn,{onClick:()=>g(!0),children:[e(Me,{className:"mr-2 h-4 w-4"}),"Preferências"]}),a(Pn,{onClick:h,children:[e(pa,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),b&&e(Vt,{open:f,onOpenChange:g,children:a(Qt,{children:[e(Jt,{children:e(Zt,{children:"Preferências de Internacionalização"})}),e(um,{})]})})]}):a(Ft,{className:i,children:[e(jt,{children:e(Lt,{className:"text-lg",children:"Informações do Usuário"})}),a(Ut,{className:"space-y-4",children:[e(C,{}),e(Wt,{}),b&&a(Et,{variant:"outline",onClick:()=>g(!0),size:"sm",className:"w-full",children:[e(Me,{className:"mr-2 h-4 w-4"}),"Preferências"]}),a(Et,{variant:"outline",onClick:h,size:"sm",className:"w-full",children:[e(pa,{className:"mr-2 h-4 w-4"}),"Sair"]}),b&&e(Vt,{open:f,onOpenChange:g,children:a(Qt,{children:[e(Jt,{children:e(Zt,{children:"Preferências de Internacionalização"})}),e(um,{})]})})]})]})}),pm=o({});function fm({children:a,config:t}){const r=i(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return e(pm.Provider,{value:r,children:a})}function gm(){return l(pm)}function bm(){const e=Ua(),{navigation:a}=gm(),{t:t}=Ia();if(!a)return t("page");const r=a.find(a=>a.path===e.pathname);if(r)return r.label;const s=a.find(a=>e.pathname.startsWith(a.path+"/"));return s?.label||t("page")}function vm(e,a){const[t,r]=n(e),s=m(),i=d(()=>{s.current&&(clearTimeout(s.current),s.current=void 0)},[]);return c(()=>(i(),s.current=setTimeout(()=>{r(e)},a),i),[e,a,i]),[t,i]}const Nm=u(function({actions:t}){const r=Ua(),s=bm(),{navigation:i,appName:o}=gm(),{metadata:l,headerActions:d}=Fi(),{t:m}=Ia(),{companies:u,alias:h,isSearchVisible:p,clearSearch:f,refreshData:g,switchUnit:b}=Gs(),v=h?u?.find(e=>e.alias===h)||u?.[0]||null:u?.[0]||null,[N,y]=Oa(),[x,w]=n(()=>N.get("search")||""),[k,C]=vm(x,ks.debounceDelay);c(()=>{if(!p)return;const e=new URLSearchParams(N);k?(e.set("search",k),e.set("page","1")):e.delete("search"),y(e)},[k,y,p]);const _=i?.find(e=>e.path===r.pathname)||i?.find(e=>r.pathname.startsWith(e.path+"/")),P=l.title||s,A=l.subtitle||_?.complementaryText||m("item_details");return e("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:a("div",{className:"flex items-center gap-4",children:[a("div",{className:"flex-shrink-0",children:[a("div",{className:"flex items-center gap-2 mb-1",children:[e("h1",{className:"text-lg font-semibold text-foreground truncate",children:P}),e(Cr,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:o||m("module")})]}),A&&e("p",{className:"text-sm text-muted-foreground truncate",children:A})]}),p&&a("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[a("div",{className:"relative flex-1",children:[e(F,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e(zt,{placeholder:m("search"),value:x,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),x&&e(Et,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{C(),w("");const e=new URLSearchParams(N);e.delete("search"),e.delete("page"),y(e)},title:m("clear_search"),children:e(S,{size:14})})]}),e(Et,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0",title:m("refresh_data"),children:e(Ve,{size:14})})]}),a("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(d||t)&&e("div",{className:"flex items-center gap-2",children:d||t}),import.meta.env.VITE_WIKI_URL&&e(Et,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>kt(import.meta.env.VITE_WIKI_URL,e),title:m("open_wiki"),children:"Wiki"}),e("div",{className:"text-sm",children:e(hm,{variant:"dropdown",selectedUnit:v,onUnitChange:b})})]})]})})}),ym=({key:e,enabled:a,checkFn:t,staleTime:r=3e5,gcTime:s=6e5})=>Da({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1}),xm=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Gs();return Da({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=cs(),{data:a,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(r){if(!fs.handleError(r))throw r;return[]}return a||[]},enabled:a&&!!t})},wm="forlogic-sidebar-pinned",km=()=>{try{const e=localStorage.getItem(wm);return!!e&&JSON.parse(e)}catch{return!1}},Cm=e=>{const a=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return a[e%a.length]},Sm=`https://${import.meta.env.VITE_SUPABASE_PROJECT_ID_STORAGE??import.meta.env.VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,_m={logo:`${Sm}/${As.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Sm}/${As.isQualiex?"small-forlogic.svg":"small.svg"}`},Pm=_m.logo,Am=_m.smallLogo;function Tm({appName:r,isPinned:s,onPinToggle:n,open:i,dropdownOpen:o,onDropdownChange:l}){const{t:d}=Ia(),{data:c,isLoading:m,error:u}=xm({enabled:o}),h=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(c,e)};return a(Kd,{className:"p-0 gap-0",children:[e("div",{className:"flex items-center justify-between h-[34px]",children:i?a(t,{children:[e("div",{className:"flex items-center pl-[12px]",children:e("img",{src:_m.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e("button",{onClick:n,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(s?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e(He,{className:"h-4 w-4"})})]}):e("div",{className:"flex items-center justify-center w-full h-[34px]",children:e("img",{src:_m.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e("div",{className:"mt-2 pt-0",children:a(vn,{onOpenChange:l,children:[e(Nn,{asChild:!0,children:i?a("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[a("div",{className:"flex items-center gap-2 min-w-0",children:[e("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:r})]}),e(_,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e(_,{className:"h-6 w-6 text-muted-foreground"})})}),e(_n,{className:i?"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50":"w-[58px] bg-popover rounded-lg shadow-lg border border-border p-2 z-50",align:i?"start":"center",children:m?a("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e(T,{className:"h-4 w-4 animate-spin"}),e("span",{className:"text-sm",children:d("loading")})]}):u?a("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e(D,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:d("error")})]}):c&&0!==c.length?e("div",{className:"space-y-2",children:c.map((t,r)=>e("div",{onClick:()=>h(t.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${Cm(r)} transition-colors duration-200\n `,children:a("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-medium text-foreground text-sm",children:t.name}),t.url&&e(fa,{className:"h-4 w-4 text-muted-foreground"})]})},t.id))}):e("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:d("no_results")})})]})})]})}function Im({config:r,isCollapsed:s=!1,isDisabled:n=!1,className:i}){const{actions:o,triggerLabel:l="Criar",triggerIcon:d=B}=r;if(!o||0===o.length)return null;const c=(r,n,i=!1)=>a(t,{children:[r,!s&&n&&e("span",{className:"truncate",children:n}),!s&&i&&e(_,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const t=o[0],r=t.icon||d,l=n||t.disabled,m=e(Et,{onClick:t.onClick,disabled:l,className:Ct("w-full gap-2 justify-start",s&&"justify-center px-2",i),variant:"outline",size:"default",children:c(e(r,{className:"h-4 w-4 shrink-0"}),t.label)});return s?a(hn,{children:[e(pn,{asChild:!0,children:m}),e(fn,{side:"right",children:e("p",{children:t.label})})]}):m}const m=e(Et,{disabled:n,className:Ct("w-full gap-2 justify-start",s&&"justify-center px-2",i),variant:"outline",size:"default",children:c(e(d,{className:"h-4 w-4 shrink-0"}),l,!0)});return a(vn,{children:[e(Nn,{asChild:!0,children:s?a(hn,{children:[e(pn,{asChild:!0,children:m}),e(fn,{side:"right",children:e("p",{children:l})})]}):m}),e(_n,{align:"start",side:s?"right":"bottom",className:"w-56 bg-popover",children:o.map(t=>{const r=t.icon;return a(Pn,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[r&&e(r,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}function Em({direction:e="right",minWidth:a=224,maxWidth:t=384,defaultWidth:r=240,storageKey:s="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,u]=n(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(s);return e?parseInt(e):r}),[h,p]=n(!1),f=m(null);c(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(o?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,o]);const g=d(e=>{e.preventDefault(),p(!0)},[]);return c(()=>{if(!h)return;const r=r=>{let s;s="left"===e?window.innerWidth-r.clientX:r.clientX,s=Math.max(a,Math.min(t,s)),u(s),i?.(s)},n=()=>{p(!1),localStorage.setItem(s,l.toString())};return document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n)}},[h,e,a,t,l,s,i]),c(()=>{h?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[h,e]),{width:l,isDragging:h,dragRef:f,handleMouseDown:g}}const Rm=o(void 0);function zm({children:a}){const[t,r]=n(new Set),[s,o]=n(!1),l=d(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),c=d(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),m=d(e=>{o(e)},[]),u=i(()=>t.size>0||s,[t,s]),h=i(()=>({openModals:t,hasOpenModal:u,registerModal:l,unregisterModal:c,setHasOpenModal:m}),[t,u,l,c,m]);return e(Rm.Provider,{value:h,children:a})}function Mm(){const e=l(Rm);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Dm(){const{hasOpenModal:e}=Mm();return e}function Fm({config:t,customContent:r,resizable:s=!1,minWidth:i=224,maxWidth:o=384}={}){const{t:l}=Ia(),{open:d,setOpen:u}=$d(),h=Ua(),{alias:p,user:f}=Gs(),{hasOpenModal:g}=Mm(),[b,v]=n(!1),[N,y]=n(km),[x,w]=n(!1),k=m(!1),C=s?Em({minWidth:i,maxWidth:o,storageKey:"app-sidebar-width",isOpen:d}):null;c(()=>{u(!!N||!(!x&&!b))},[N,x,b,u]);return a(Vd,{collapsible:"icon",onMouseEnter:()=>{N||k.current||w(!0)},onMouseLeave:()=>{N||w(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:C&&d?{width:`${C.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e(Tm,{appName:t?.appName||l("module_title"),isPinned:N,onPinToggle:()=>{const e=!N;y(e),(e=>{try{localStorage.setItem(wm,JSON.stringify(e))}catch{}})(e),e||(k.current=!0,w(!1),u(!1),setTimeout(()=>{k.current=!1},300))},open:d,dropdownOpen:b,onDropdownChange:v}),t?.moduleActions&&t.moduleActions.actions.length>0&&e("div",{className:"px-3 py-2",children:e(un,{children:e(Im,{config:t.moduleActions,isCollapsed:!d,isDisabled:g})})}),e(Xd,{children:r||e(Yd,{className:"p-0 mt-6",children:e(ac,{children:e(tc,{className:"space-y-2",children:e(un,{children:t?.navigation?.map((t,r)=>{const s=({item:t,index:r})=>{const n=`${t.path}-${r}-${p??"noalias"}-${f?.id??"nouser"}`,{data:i=!0,isLoading:o}=ym({key:n,enabled:Boolean(t.permissionCheck&&p&&f?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),d=t.permissionCheck&&!i;if(d&&"Admin"===t.label)return null;const c=o?T:d?ne:t.icon;d?l("restricted_access"):t.complementaryText;return t.children&&t.children.length>0?e(bo,{defaultOpen:!0,className:"group/collapsible",children:a(rc,{children:[e(vo,{asChild:!0,children:e(nc,{size:"lg",className:"h-10",children:a("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label}),e(L,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e(No,{children:e(dc,{children:t.children.map((a,t)=>e(s,{item:a,index:t},a.path))})})]})},t.path):e(rc,{children:d||o?a(hn,{children:[e(pn,{asChild:!0,children:e(nc,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:a("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})}),e(fn,{children:e("p",{children:l(o?"checking_access":"restricted_access")})})]}):e(nc,{asChild:!0,isActive:(m=t.path,h.pathname===m||h.pathname.startsWith(m+"/")),size:"lg",className:"h-10",children:a(Wa,{to:t.path,className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})},t.path);var m};return e(s,{item:t,index:r},t.path)})})})})})}),s&&C&&d&&e("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Ct("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",C.isDragging&&"bg-primary/40")})]})}const jm=u(function({children:t,sidebar:r,sidebarConfig:s,showHeader:n=!0}){const o=i(()=>r||e(Fm,{config:s}),[r,s]),l=i(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e(fm,{config:s,children:e(Di,{children:e(Wd,{defaultOpen:!1,style:l,children:a("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,a("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e(Nm,{})}),e("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})});function Lm(e){const{steps:a,initialStep:t=0,initialData:r={},onComplete:s,onCancel:o}=e,[l,c]=n(t),[m,u]=n(r),[h,p]=n(!1),[f,g]=n(!1),b=a.length,v=0===l,N=l===b-1,y=a[l],x=b>1?(l+1)/b*100:100,w=i(()=>!y?.canProceed||y.canProceed(),[y,m]),k=i(()=>!v&&!y?.disableBack,[v,y]),C=d(async()=>{w&&!h&&(N?await I():c(e=>Math.min(e+1,b-1)))},[w,h,N,b]),S=d(()=>{k&&!h&&c(e=>Math.max(e-1,0))},[k,h]),_=d(e=>{e<0||e>=b||h||(e<=l||e===l+1)&&c(e)},[l,b,h]),P=d(e=>{u(a=>({...a,...e}))},[]),A=d((e,a)=>{u(t=>({...t,[e]:a}))},[]),T=d(()=>{c(t),u(r),p(!1),g(!1),o?.()},[t,r,o]),I=d(async()=>{if(w&&!f){g(!0);try{await(s?.(m))}finally{g(!1)}}},[w,f,m,s]),E=d(e=>{p(e)},[]);return{currentStep:l,currentStepConfig:y,data:m,isFirstStep:v,isLastStep:N,isLoading:h,isCompleting:f,next:C,back:S,goTo:_,canProceed:w,canGoBack:k,setData:P,updateField:A,reset:T,complete:I,setLoading:E,progress:x,stepIndex:l,totalSteps:b}}const Om={"pt-BR":vl,"en-US":nl,"es-ES":ul},Um=(e,a=Xi,t=Zi)=>{if(!e)return"";const r=v(e);if(!N(r))return"Data inválida";const s=Om[a]||vl;try{return Nt(r,t,"PP",{locale:s})}catch(n){return Nt(r,Zi,"PP",{locale:s})}},$m=()=>{const{locale:e,timezone:a,datetimeFormat:t}=fo();return{formatDatetime:r=>((e,a=Yi,t=Zi,r=Xi)=>{if(!e)return"";const s=v(e);if(!N(s))return"Data inválida";const n=Om[r]||vl;try{return Nt(s,t,a,{locale:n})}catch(i){return Nt(s,Zi,a,{locale:n})}})(r,t,a,e),formatDate:t=>Um(t,e,a),locale:e,timezone:a,datetimeFormat:t}};class Wm{static async sendEmail(e){const a=cs(),{data:t,error:r}=await a.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(r)throw r;return t}}const Vm=Wm;function Bm({open:t,onOpenChange:r,placeId:s,placeName:o,onMakeManager:l,onMakeMembers:d,currentManagerId:c,currentMemberIds:m=[]}){const{t:u}=Ia(),[h,p]=n([]),[f,g]=n(!1),[b,v]=n(""),{data:N=[],isLoading:y}=di({enabled:t}),x=i(()=>{let e=[...N];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",r=a.userName?.toLowerCase()||"";return t.localeCompare(r)}),b){const a=b.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[N,b]),w=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},k=1===h.length,C=h.length>0;return e(Vt,{open:t,onOpenChange:r,children:a(Qt,{className:"max-w-2xl",children:[e(Jt,{children:a(Zt,{className:"flex items-center gap-2",children:[e(ga,{className:"h-5 w-5"}),"Gerenciar Acessos - ",o]})}),a("div",{className:"relative",children:[e(F,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(zt,{placeholder:u("search_placeholder"),value:b,onChange:e=>v(e.target.value),className:"pl-9"})]}),e(si,{className:"h-[400px] pr-4",children:y?e("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e($r,{className:"h-16 w-full"},t))}):0===x.length?a("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e(ga,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e("p",{className:"text-sm text-muted-foreground",children:b?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e("div",{className:"space-y-2",children:x.map(t=>{const r=t.userId===c,s=m.includes(t.userId||""),n=h.includes(t.userId||"");return a("div",{className:Ct("flex items-center gap-3 p-3 rounded-lg border transition-colors",n&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e(xr,{checked:n,onCheckedChange:()=>w(t.userId||""),onClick:e=>e.stopPropagation()}),a("div",{className:"flex-1",children:[a("div",{className:"flex items-center gap-2",children:[e("p",{className:"font-medium",children:t.userName}),r&&e(ba,{className:"h-4 w-4 text-yellow-500"})]}),e("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(r||s)&&e("div",{className:"text-xs text-muted-foreground",children:r?"Gestor":"Membro"})]},t.userId)})})}),a(Yt,{className:"flex gap-2 sm:gap-2",children:[e("div",{className:"flex-1 text-sm text-muted-foreground",children:h.length>0&&a("span",{children:[h.length," selecionado(s)"]})}),k&&l&&a(Et,{onClick:async()=>{if(l&&1===h.length){g(!0);try{await l(h[0],s),p([])}finally{g(!1)}}},disabled:f,variant:"outline",children:[e(ba,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&d&&a(Et,{onClick:async()=>{if(d&&0!==h.length){g(!0);try{await d(h,s),p([])}finally{g(!1)}}},disabled:f,children:[e(va,{className:"h-4 w-4 mr-2"}),"Tornar ",h.length>1?"Membros":"Membro"]})]})]})})}function qm({place:t,level:r=0,manageAccessConfig:s}){const[i,o]=n(!1),[l,d]=n(!1),c=t.subPlaces&&t.subPlaces.length>0,m=t.isActive??!0,u=t.usersCount??0;return a("div",{children:[a(bo,{open:i,onOpenChange:o,children:[a("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*r+1+"rem"},children:[c?a(vo,{className:"flex items-center gap-2 flex-1",children:[e(L,{className:Ct("h-4 w-4 transition-transform shrink-0",i&&"rotate-90")}),e(ha,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:t.name}),a("span",{className:"text-sm text-muted-foreground",children:["(",t.subPlaces.length,")"]})]}):a("div",{className:"flex items-center gap-2 flex-1",children:[e("div",{className:"w-4 shrink-0"}),e(ha,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:t.name})]}),a("div",{className:"flex items-center gap-3 ml-auto",children:[a("div",{className:"flex items-center gap-1.5",children:[e(ga,{className:"h-3.5 w-3.5 text-muted-foreground"}),e("span",{className:"text-sm text-muted-foreground",children:u})]}),e(Cr,{variant:m?"default":"secondary",className:"text-xs",children:m?"Ativo":"Inativo"}),s&&e(lm,{customActions:[{label:"Gerenciar Acessos",icon:Me,onClick:()=>d(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e(No,{children:t.subPlaces.map(a=>e(qm,{place:a,level:r+1,manageAccessConfig:s},a.id))})]}),0===r&&e(Wt,{}),s&&e(Bm,{open:l,onOpenChange:d,placeId:t.id,placeName:t.name,onMakeManager:s.onMakeManager,onMakeMembers:s.onMakeMembers,currentManagerId:s.getCurrentManagerId?.(t.id),currentMemberIds:s.getCurrentMemberIds?.(t.id)})]})}function Hm({places:t,isLoading:r,manageAccessConfig:s}){const{t:n}=Ia();return r?e("div",{className:"flex items-center justify-center py-12",children:a("div",{className:"text-center space-y-2",children:[e("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e("p",{className:"text-sm text-muted-foreground",children:n("loading_data")})]})}):t&&0!==t.length?a("div",{className:"space-y-1",children:[e("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(a=>e(qm,{place:a,manageAccessConfig:s},a.id))]}):a("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e(ha,{className:"h-12 w-12 text-muted-foreground/50"}),a("div",{children:[e("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var Gm=Object.defineProperty,Km=(e,a,t)=>((e,a,t)=>a in e?Gm(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Qm=new class{constructor(){Km(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const r=bs.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=es.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const r=a.get(e.id);if(e.parentId){const s=a.get(e.parentId);s?(s.subPlaces=s.subPlaces||[],s.subPlaces.push(r)):t.push(r)}else t.push(r)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),r=t.data||t||[];return this.buildHierarchy(r)}catch(t){if(await bs.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),r=t.data||t||[];return this.buildHierarchy(r)}catch(r){return rs.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return rs.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Jm(e,a){const t=e.map(e=>({...e})),r=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&r.has(e.id_leader)){let a=e.id_leader;for(;a&&r.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))}function Xm(e){const a=new Map,t=new Map,r=[];e.forEach(e=>{const r={...e,children:[],level:0};a.set(e.id,r),t.set(e.id_user,r)}),e.forEach(e=>{const s=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(s)}r.push(s)});const s=(e,a)=>{e.level=a,e.children.forEach(e=>s(e,a+1))};r.forEach(e=>s(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",r=a.name||a.id_user||a.email||"";return t.localeCompare(r)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(r),r}function Ym(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Zm(){const{alias:e,isAuthenticated:a}=Gs(),t=es.getAccessToken(),{data:r=[]}=di({enabled:!0});return Da({queryKey:["leadership",e,r.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=cs(),{data:s,error:n}=await a.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!s||0===s.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=s.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:s.filter(a=>a.id_leader===e.id_user).length})),l=new Set(s.map(e=>e.id_user));return new Set(s.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e];o.push({id:`virtual-${e}`,alias:s[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:a?.name||"[Não encontrado]",email:a?.email||"",subordinatesCount:s.filter(a=>a.id_leader===e).length})}),Xm(o)},enabled:!!t&&!!e&&a&&r.length>0})}function eu(){const e="common",{alias:a}=Gs(),t=Ma(),r=cs();return Fa({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await r.schema(e).from("leaders").select("id").eq("alias",a).eq("id_user",t.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");t.id_leader&&await iu(r,a,e,t.id_user,t.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success("Líder adicionado com sucesso")},onError:e=>{w.error(e.message||"Erro ao adicionar líder")}})}function au(){const e="common",{alias:a}=Gs(),t=Ma(),r=cs();return Fa({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await iu(r,a,e,t.id_user,t.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success("Líder virtual promovido com sucesso")},onError:e=>{w.error(e.message||"Erro ao criar líder")}})}function tu(){const e="common",{alias:a}=Gs(),t=Ma(),r=cs();return Fa({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(!t.users.length)throw new Error("Selecione pelo menos um liderado");const s=t.users.map(e=>e.id_user),{data:n}=await r.schema(e).from("leaders").select("id_user").eq("alias",a).in("id_user",s).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const d of t.users){if(t.id_leader&&d.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await iu(r,a,e,d.id_user,t.id_leader)}const i=t.users.map(e=>({alias:a,id_user:e.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await r.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{w.error(e.message||"Erro ao adicionar liderados")}})}function ru(){const e="common",{alias:a}=Gs(),t=Ma(),r=cs();return Fa({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:s}=await r.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!s)throw new Error("Líder não encontrado");if(s.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await iu(r,a,e,s.id_user,t.id_leader,t.id);const{data:n,error:i}=await r.schema(e).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",a).select().single();if(i)throw i;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success("Líder atualizado com sucesso")},onError:e=>{w.error(e.message||"Erro ao atualizar líder")}})}function su(){const{alias:e}=Gs(),a=Ma(),t=cs();return Fa({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:r}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),w.success("Líder removido com sucesso")},onError:e=>{w.error(e.message||"Erro ao remover líder")}})}function nu(){const e="common",{alias:a}=Gs(),t=Ma(),r=cs();return Fa({mutationFn:async({leaderUserId:t,selectedUsers:s})=>{if(!a)throw new Error("Unidade não selecionada");const n=s.map(e=>e.id_user),i=await Promise.all([r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).eq("id_leader",t),r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:o,error:l},{data:d,error:c}]=i;if(l)throw l;if(c)throw c;const m=o||[],u=d||[],h=new Set(n),p=m.filter(e=>!h.has(e.id_user)),f=u.filter(e=>e.id_leader!==t),g=new Set(u.map(e=>e.id_user)),b=s.filter(e=>!g.has(e.id_user));for(const y of f)await iu(r,a,e,y.id_user,t,y.id);for(const y of b){if(y.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await iu(r,a,e,y.id_user,t)}const v=[];if(p.length){const t=p.map(e=>e.id);v.push(r.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(f.length){const s=f.map(e=>e.id);v.push(r.schema(e).from("leaders").update({id_leader:t}).in("id",s).eq("alias",a))}if(b.length){const s=b.map(e=>({alias:a,id_user:e.id_user,id_leader:t,is_active:!0,is_removed:!1}));v.push(r.schema(e).from("leaders").insert(s))}const N=(await Promise.all(v)).find(e=>e?.error);if(N?.error)throw N.error;return{unlinked:p.length,updated:f.length,created:b.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),w.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{w.error(e.message||"Erro ao sincronizar subordinados")}})}async function iu(e,a,t,r,s,n){const{data:i,error:o}=await e.schema(t).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1);if(o)throw o;const l=n?i.filter(e=>e.id!==n):i,d=new Set;let c=s;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===r)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const e=l.find(e=>e.id_user===c);c=e?.id_leader||null}}function ou({leader:r,expandedIds:s,onToggleExpand:n,onEdit:i}){const o=s.has(r.id),l=r.children.length>0,d=32*r.level;return a(t,{children:[a("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e("td",{className:"py-3 px-4",children:a("div",{className:"flex items-center gap-2",style:{paddingLeft:`${d}px`},children:[l?e("button",{onClick:()=>n(r.id),className:"p-1 hover:bg-accent rounded",children:e(o?_:L,{className:"h-4 w-4"})}):e("div",{className:"w-6"}),e(De,{className:"h-4 w-4 text-muted-foreground"}),e("button",{onClick:()=>{i(r)},className:"font-medium hover:text-primary hover:underline text-left",children:r.name||r.id_user||r.email})]})}),e("td",{className:"py-3 px-4 text-center",children:e("span",{className:"text-sm",children:r.subordinatesCount||0})})]}),l&&o&&r.children.map(a=>e(ou,{leader:a,expandedIds:s,onToggleExpand:n,onEdit:i},a.id))]})}var lu=function(e,a){for(var t={};e.length;){var r=e[0],s=r.code,n=r.message,i=r.path.join(".");if(!t[i])if("unionErrors"in r){var o=r.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[r.code];t[i]=Sa(i,a,t,s,d?[].concat(d,r.message):r.message)}e.shift()}return t},du=function(e,a,t){return void 0===t&&(t={}),function(r,s,n){try{return Promise.resolve(function(s,i){try{var o=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](r,a)).then(function(e){return n.shouldUseNativeValidation&&xt({},n),{errors:{},values:t.raw?r:e}})}catch(l){return i(l)}return o&&o.then?o.then(void 0,i):o}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:wt(lu(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const cu=yt.object({id_leader:yt.string().nullable(),id_users:yt.array(yt.string()).min(1,"Selecione pelo menos um liderado")}),mu=yt.object({id_leader:yt.string().nullable(),id_users:yt.array(yt.string())});function uu({value:t,onChange:r,excludeUserIds:s=[],error:i}){const{data:o=[],isLoading:l}=di(),[d,u]=n(""),h=m(null),p=m(0),{t:f}=Ia(),g=o.filter(e=>!s.includes(e.userId||"")).filter(e=>{const a=d.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const r=t.includes(e.userId),s=t.includes(a.userId);if(r&&!s)return-1;if(!r&&s)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return c(()=>{h.current&&p.current>0&&(h.current.scrollTop=p.current)},[g]),a("div",l?{className:"flex items-center justify-center p-4",children:[e(T,{className:"h-6 w-6 animate-spin"}),e("span",{className:"ml-2",children:f("loading_data")})]}:{className:"space-y-2",children:[e(zt,{placeholder:f("search_user"),value:d,onChange:e=>u(e.target.value)}),e("div",{ref:h,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===g.length?e("p",{className:"text-sm text-muted-foreground",children:f("search_user")}):e("div",{className:"space-y-2",children:g.map(s=>a("div",{className:"flex items-center space-x-2",children:[e(xr,{id:s.userId,checked:t.includes(s.userId),onCheckedChange:()=>{return e=s.userId,h.current&&(p.current=h.current.scrollTop),void(t.includes(e)?r(t.filter(a=>a!==e)):r([...t,e]));var e}}),e(Dt,{htmlFor:s.userId,className:"flex-1 cursor-pointer",children:s.userName||s.userEmail})]},s.userId))})}),t.length>0&&e("p",{className:"text-sm text-muted-foreground",children:f("selected_count",{count:t.length})}),i&&e("p",{className:"text-sm text-destructive",children:i})]})}function hu({leader:r,prefilledLeaderId:s,onSuccess:i}){const{t:o}=Ia(),{alias:l}=Gs(),d=!!r,m=r?.id.startsWith("virtual-"),u=tu(),h=au(),p=ru(),f=nu(),g=su(),{data:b=[]}=Zm(),{data:v=[]}=di(),[N,y]=n(""),x=Ym(b).map(e=>e.id_user),w=d?Ym(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user):[],k=_a({resolver:du(d?mu:cu),defaultValues:{id_leader:s||(d?r?.id_leader:null)||null,id_users:d?w:[]}});c(()=>{if(r){const e=Ym(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user);k.reset({id_leader:r.id_leader||null,id_users:e})}else s?k.reset({id_leader:s,id_users:[]}):k.reset({id_leader:null,id_users:[]})},[l,r?.id,r?.id_user,r?.id_leader,s,b]);const C=u.isPending||h.isPending||p.isPending||f.isPending||g.isPending,S=k.watch("id_leader"),_=k.watch("id_users"),P=d?[r.id_user,...x.filter(e=>e!==r.id_user&&!_.includes(e)&&!w.includes(e))]:[S,...x.filter(e=>!_.includes(e))].filter(Boolean);return a("form",{onSubmit:k.handleSubmit(async e=>{try{if(d)if(m){await h.mutateAsync({id_user:r.id_user,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:a})}else{await p.mutateAsync({id:r.id,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:a})}else{const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({id_leader:e.id_leader,users:a})}i?.()}catch(a){}}),className:"space-y-4",children:[d&&a("div",{children:[e(Dt,{children:o("leader")}),e(zt,{value:v.find(e=>e.userId===r.id_user)?.userName||r.name||r.id_user,disabled:!0,className:"bg-muted"})]}),a("div",{children:[e(Dt,{children:o("superior")}),a(mr,{value:S||"none",onValueChange:e=>k.setValue("id_leader","none"===e?null:e),children:[e(pr,{children:e(hr,{placeholder:o("select_placeholder")})}),a(br,{children:[e("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e(zt,{placeholder:o("superior_search"),value:N,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),a(si,{className:"h-[200px]",children:[e(Nr,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const a=d?e.userId!==r.id_user:!_.includes(e.userId),t=!N||e.userName?.toLowerCase().includes(N.toLowerCase());return a&&t}).sort((e,a)=>{const t=e.userName||e.userEmail||"",r=a.userName||a.userEmail||"";return t.localeCompare(r)}).map(a=>e(Nr,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${l}`),k.formState.errors.id_leader&&e("p",{className:"text-sm text-destructive mt-1",children:k.formState.errors.id_leader.message})]}),a("div",{children:[a(Dt,{children:[o("subordinates")," *"]}),e(uu,{value:_,onChange:e=>k.setValue("id_users",e),excludeUserIds:P,error:k.formState.errors.id_users?.message},`users-multiselect-${l}`)]}),a("div",{className:"flex items-center justify-between gap-2",children:[e(Et,{type:"submit",disabled:C||!d&&0===_.length,children:C&&!g.isPending?a(t,{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),o(d?"updating":"saving")]}):d?_.length>0?o("update_success",{count:_.length}):o("update"):o("create_success",{count:_.length})}),d&&!S&&0===_.length&&e(Et,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(r&&window.confirm(o("remove_confirm")))try{await g.mutateAsync(r.id),i?.()}catch(e){}},className:"ml-auto",children:g.isPending?a(t,{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),o("removing")]}):a(t,{children:[e(V,{className:"mr-2 h-4 w-4"}),o("remove")]})})]})]})}function pu({open:t,onOpenChange:r,leader:s,prefilledLeaderId:n,title:i}){return e(Vt,{open:t,onOpenChange:r,children:a(Qt,{className:"sm:max-w-[500px]",children:[e(Jt,{children:e(Zt,{children:i})}),e(hu,{leader:s,prefilledLeaderId:n,onSuccess:()=>r(!1)})]})})}const fu="leadership-expanded-nodes",gu=(e,a)=>{try{localStorage.setItem(`${fu}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function bu(){const{alias:t}=Gs(),{t:r}=Ia(),{data:s,isLoading:i,error:o,refetch:l}=Zm(),{data:d=[]}=di({enabled:!0}),[m,u]=n(()=>t?(e=>{try{const a=localStorage.getItem(`${fu}-${e}`);if(a)return new Set(JSON.parse(a))}catch(o){}return new Set})(t):new Set),[h,p]=n(!1),[f,g]=n(),[b,v]=n(null),N=d.filter(e=>e.userName&&"Nome não disponível"!==e.userName),y=new Set(N.map(e=>e.userId)),x=N.length-(s?Ym(s).filter(e=>y.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);c(()=>{if(s&&s.length>0&&t){if(!localStorage.getItem(`${fu}-${t}`)){const e=s.map(e=>e.id),a=new Set(e);u(a),gu(t,a)}}},[s,t]);const w=e=>{u(a=>{const r=new Set(a);return r.has(e)?r.delete(e):r.add(e),t&&gu(t,r),r})},k=e=>{g(e),v(null),p(!0)};return i?e("div",{className:"flex items-center justify-center h-full",children:a("div",{className:"text-center",children:[e(Ve,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e("p",{className:"text-muted-foreground",children:r("loading")})]})}):o?e("div",{className:"flex items-center justify-center h-full",children:a("div",{className:"text-center",children:[e("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e(Et,{onClick:()=>l(),children:"Tentar novamente"})]})}):a("div",{className:"flex flex-col h-full",children:[e("div",{className:"flex items-center justify-between p-4 border-b",children:a("div",{className:"flex gap-2 items-center",children:[a(Et,{size:"sm",onClick:()=>{g(void 0),v(null),p(!0)},children:[e(B,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),a(Et,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=Ym(s).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&gu(t,a)},disabled:!s||0===s.length,children:[e(_,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),a(Et,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&gu(t,e)},disabled:!s||0===s.length,children:[e(L,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e("div",{className:"flex items-center gap-2 ml-4",children:a("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e(ga,{className:"h-4 w-4 text-muted-foreground"}),a("span",{className:"text-sm font-medium",children:[x," usuário",1!==x?"s":""," não associado",1!==x?"s":""]})]})})]})}),s&&0!==s.length?e(si,{className:"flex-1",children:e("div",{children:a("table",{className:"w-full",children:[e("thead",{children:a("tr",{className:"border-b bg-muted/50",children:[e("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e("tbody",{children:s.map(a=>e(ou,{leader:a,expandedIds:m,onToggleExpand:w,onEdit:k},a.id))})]})})}):e("div",{className:"flex items-center justify-center flex-1",children:a("div",{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e(pu,{open:h,onOpenChange:()=>{p(!1),g(void 0),v(null)},leader:f,prefilledLeaderId:b,title:f?r("edit")+" "+r("name"):b?r("add")+" Liderado":r("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})}function vu(e){const[a,t]=n(!1),[r,s]=n(0),{t:i}=Ia(),{uploadFunction:o,deleteFunction:l,defaultOptions:d,onSuccess:c,onError:m}=e||{};return{upload:async(e,a)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw w.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}t(!0),s(0);try{const t={...d,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const r=await o(e,t);return s(100),w.success("Sucesso",{description:i("file_upload_success")}),c?.(r),r}catch(r){const e=r instanceof Error?r:new Error("Erro ao fazer upload");throw w.error("Erro",{description:e.message}),m?.(e),e}finally{t(!1)}},deleteMedia:async(e,a)=>{if(!l){const e=new Error("deleteFunction não fornecida");throw w.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await l(e,a),w.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw w.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:a,progress:r}}function Nu(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function yu(e,a){const t=Nu(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function xu(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function wu(e,a){const t=xu(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function ku(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Cu(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Su(e,a,t){switch(a||Cu(e)){case"youtube":return yu(e,t);case"vimeo":return wu(e,t);default:return e}}function _u({value:r,onChange:s,onSubmit:o,onCancel:l,uploadFunction:d,deleteFunction:c,uploadOptions:u}){const{t:h}=Ia(),[p,f]=n(r||{inputType:"url",controls:!0}),g=m(null),b=m(null),{upload:v,uploading:N}=vu({uploadFunction:d,deleteFunction:c,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:y,uploading:x}=vu({uploadFunction:d,deleteFunction:c,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),k=i(()=>Cu(p.videoUrl||ku(p.embedCode)||""),[p.videoUrl,p.embedCode]),C=(e,a)=>{const t={...p,[e]:a};f(t),s(t)};return a("div",{className:"space-y-6",children:[a("div",{className:"space-y-2",children:[e(Dt,{children:h("input_type")}),a(mr,{value:p.inputType||"url",onValueChange:e=>C("inputType",e),children:[e(pr,{children:e(hr,{})}),a(br,{children:[e(Nr,{value:"url",children:h("url")}),e(Nr,{value:"upload",children:h("input_type_upload")}),e(Nr,{value:"embed",children:h("input_type_embed")})]})]})]}),"upload"===p.inputType&&d&&a("div",{className:"space-y-2",children:[e(Dt,{children:h("file")}),a("div",{className:"flex gap-2",children:[e("input",{ref:g,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||a.name.replace(/\.[^/.]+$/,"")};f(t),s(t)}catch(t){}finally{g.current&&(g.current.value="")}},className:"hidden"}),e(Et,{type:"button",variant:"outline",onClick:()=>g.current?.click(),disabled:N,children:a(t,N?{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),h("uploading")]}:{children:[e(he,{className:"mr-2 h-4 w-4"}),h("select_video")]})}),p.videoFile&&e("span",{className:"text-xs text-muted-foreground truncate self-center",children:h("video.fileInfo",{name:p.videoFile,size:Math.round((p.videoSize||0)/1024/1024)})})]})]}),"embed"===p.inputType&&a("div",{className:"space-y-2",children:[e(Dt,{children:h("embed")}),e(wr,{placeholder:h("embed"),value:p.embedCode||"",onChange:e=>C("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),d&&a("div",{className:"space-y-2",children:[e(Dt,{children:h("thumbnail")}),a("div",{className:"flex gap-2",children:[e(zt,{type:"url",placeholder:h("thumbnail"),value:p.thumbnail||"",onChange:e=>C("thumbnail",e.target.value),className:"flex-1"}),e("input",{ref:b,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await y(a),t={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};f(t),s(t)}catch(t){}finally{b.current&&(b.current.value="")}},className:"hidden"}),e(Et,{type:"button",variant:"outline",onClick:()=>b.current?.click(),disabled:x,children:a(t,x?{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),h("video.uploading")]}:{children:[e(he,{className:"mr-2 h-4 w-4"}),h("upload")]})})]}),p.thumbnailFile&&e("p",{className:"text-xs text-muted-foreground",children:h("video.thumbnailFileInfo",{name:p.thumbnailFile})})]}),a("div",{className:"space-y-2",children:[e(Dt,{htmlFor:"title",children:h("title")}),e(zt,{id:"title",placeholder:h("title"),value:p.title||"",onChange:e=>C("title",e.target.value)})]}),a("div",{className:"flex gap-6",children:[a("div",{className:"flex items-center gap-2",children:[e("input",{id:"autoplay",type:"checkbox",checked:p.autoplay||!1,onChange:e=>C("autoplay",e.target.checked),className:"h-4 w-4"}),e(Dt,{htmlFor:"autoplay",className:"cursor-pointer",children:h("video.autoplay")})]}),a("div",{className:"flex items-center gap-2",children:[e("input",{id:"controls",type:"checkbox",checked:!1!==p.controls,onChange:e=>C("controls",e.target.checked),className:"h-4 w-4"}),e(Dt,{htmlFor:"controls",className:"cursor-pointer",children:h("video.controls")})]})]}),a("div",{className:"space-y-2",children:[e(Dt,{children:h("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=p.videoUrl||ku(p.embedCode)||"";if(!t)return e("div",{className:"text-center py-8 text-muted-foreground",children:h("no_content_preview")});if("file"===k)return a("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e("source",{src:t}),h("unsupported")]});const r="youtube"===k?yu(t,p.autoplay):wu(t,p.autoplay);return e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:p.title||h("video"),src:r,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),a("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Et,{variant:"outline",onClick:l,children:h("cancel")}),e(Et,{onClick:()=>{p.videoUrl||p.embedCode?o(p):w.error(h("error"),{description:h("error_no_video")})},disabled:!(p.videoUrl||p.embedCode),children:h("save")})]})]})}function Pu({content:t,className:r="",style:s}){const n=t.videoUrl||ku(t.embedCode)||"";if(!n)return null;const i=Cu(n),{t:o}=Ia();return e(Ft,{className:`overflow-hidden my-4 ${r}`,style:s,children:a(Ut,{className:"p-0",children:["file"===i?a("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:t.title||o("video"),src:"youtube"===i?yu(n,t.autoplay):wu(n,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e("div",{className:"p-4",children:e("p",{className:"text-sm font-medium",children:t.title})})]})})}function Au({value:r,onChange:s,onSubmit:i,onCancel:o,uploadFunction:l,deleteFunction:d,uploadOptions:c}){const{t:u}=Ia(),[h,p]=n(r||{alignment:"center",allowDownload:!1}),f=m(null),{upload:g,uploading:b}=vu({uploadFunction:l,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),v=(e,a)=>{const t={...h,[e]:a};p(t),s(t)};return a("div",{className:"space-y-6",children:[a("div",{className:"space-y-2",children:[e(Dt,{children:u("url")}),a("div",{className:"flex gap-2",children:[e(zt,{type:"url",placeholder:u("url_placeholder"),value:h.imageUrl||"",onChange:e=>v("imageUrl",e.target.value),className:"flex-1"}),l&&a(t,{children:[e("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...h,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{f.current&&(f.current.value="")}},className:"hidden"}),e(Et,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:b,children:a(t,b?{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}:{children:[e(he,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),h.imageFile&&e("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:h.imageFile,size:Math.round((h.imageSize||0)/1024)})})]}),h.imageUrl&&a("div",{className:"space-y-2",children:[e(Dt,{children:u("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:e("div",{className:"flex "+("left"===h.alignment?"justify-start":"right"===h.alignment?"justify-end":"justify-center"),children:e("img",{src:h.imageUrl,alt:h.alt||"Preview",style:{width:h.width?`${h.width}px`:"auto",height:h.height?`${h.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),a("div",{className:"space-y-2",children:[e(Dt,{htmlFor:"caption",children:u("caption")}),e(wr,{id:"caption",placeholder:u("caption"),value:h.caption||"",onChange:e=>v("caption",e.target.value),rows:2})]}),a("div",{className:"space-y-2",children:[e(Dt,{htmlFor:"alt",children:u("alt")}),e(zt,{id:"alt",placeholder:u("alt"),value:h.alt||"",onChange:e=>v("alt",e.target.value)})]}),a("div",{className:"space-y-2",children:[e(Dt,{children:u("alignment")}),a(mr,{value:h.alignment||"center",onValueChange:e=>v("alignment",e),children:[e(pr,{children:e(hr,{})}),a(br,{children:[e(Nr,{value:"left",children:u("left")}),e(Nr,{value:"center",children:u("center")}),e(Nr,{value:"right",children:u("right")})]})]})]}),a("div",{className:"grid grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(Dt,{htmlFor:"width",children:u("width")}),e(zt,{id:"width",type:"number",placeholder:"px",value:h.width||"",onChange:e=>v("width",e.target.value?Number(e.target.value):void 0)})]}),a("div",{className:"space-y-2",children:[e(Dt,{htmlFor:"height",children:u("height")}),e(zt,{id:"height",type:"number",placeholder:"px",value:h.height||"",onChange:e=>v("height",e.target.value?Number(e.target.value):void 0)})]})]}),a("div",{className:"flex items-center gap-2",children:[e("input",{id:"allowDownload",type:"checkbox",checked:h.allowDownload||!1,onChange:e=>v("allowDownload",e.target.checked),className:"h-4 w-4"}),e(Dt,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),a("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Et,{variant:"outline",onClick:o,children:u("cancel")}),e(Et,{onClick:()=>{h.imageUrl?i(h):w.error(u("error"),{description:u("error_no_image")})},disabled:!h.imageUrl,children:u("save")})]})]})}function Tu({content:t,className:r="",style:s}){if(!t.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e("div",{className:`flex ${n} my-4 ${r}`,style:s,children:a("div",{className:"space-y-2 max-w-full",children:[e("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&a("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e(pe,{className:"h-4 w-4"}),"Baixar imagem"]})]})})}function Iu(e,a){return e/a}function Eu(e,a,t,r){const s=Iu(e,a);return t&&!r?{width:t,height:Math.round(t/s)}:r&&!t?{width:Math.round(r*s),height:r}:{width:e,height:a}}function Ru(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))}function zu(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}}function Mu(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const Du=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]"}]},{id:"saber",label:"Saber Gestão",modules:[{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]"},{name:"Configurações v1",description:"Configurações",color:"bg-[#5C6BC0]"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]"},{name:"Metrology v1",description:"Gestão de Metrologia",color:"bg-[#afd884]"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]"}]}];function Fu({module:t,onClick:r}){return a("button",{type:"button",onClick:r,className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors text-left w-full group",children:[e("div",{className:Ct("w-4 h-4 rounded-sm shrink-0 mt-0.5",t.color)}),a("div",{className:"min-w-0",children:[e("div",{className:"font-medium text-foreground group-hover:text-primary transition-colors",children:t.name}),t.description&&e("div",{className:"text-sm text-muted-foreground truncate",children:t.description})]})]})}function ju({modules:a,onModuleClick:t,columns:r=2}){const s=[...a].sort((e,a)=>e.name.localeCompare(a.name)),n=Math.ceil(s.length/r),i=[];for(let e=0;e<n;e++)for(let a=0;a<r;a++){const t=a*n+e;t<s.length&&i.push(s[t])}return e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1",children:i.map((a,r)=>e(Fu,{module:a,onClick:()=>t?.(a)},`${a.name}-${r}`))})}function Lu({open:t,onOpenChange:r,onModuleClick:s,wikiUrl:i="https://wiki.qualiex.com",allModulesUrl:o="https://qualiex.com/modulos",showSettingsLink:l=!0,onSettingsClick:d}){const[c,m]=n("qualiex");return e(Vt,{open:t,onOpenChange:r,children:a(Qt,{size:"lg",className:"overflow-hidden flex flex-col",children:[e(Jt,{children:e(Zt,{children:"Módulos"})}),a("div",{className:"flex-1 min-h-0 flex gap-6 overflow-hidden",children:[e("div",{className:"flex-1 min-w-0 flex flex-col",children:a(hc,{value:c,onValueChange:m,className:"flex-1 flex flex-col min-h-0",children:[e(pc,{className:"w-fit shrink-0 mt-4",children:Du.map(e=>a(fc,{value:e.id,children:[e.label,a("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),Du.map(a=>e(gc,{value:a.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e(ju,{modules:a.modules,onModuleClick:s})},a.id))]})}),a("div",{className:"w-72 shrink-0 flex flex-col gap-4",children:[a("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 space-y-2",children:[e("h4",{className:"font-semibold",children:"Dúvidas sobre os módulos?"}),e("p",{className:"text-sm opacity-90",children:"Acesse nossa Wiki e descubra todos os detalhes sobre os módulos e suas funcionalidades"}),a("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium underline underline-offset-2 hover:opacity-80 transition-opacity",children:["Acessar a Wiki",e(fa,{className:"h-3.5 w-3.5"})]})]}),a("div",{className:"bg-muted rounded-lg p-4 space-y-2",children:[e("p",{className:"text-sm text-foreground",children:"Conheça todas as soluções que o Qualiex pode te oferecer"}),a("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium text-primary underline underline-offset-2 hover:opacity-80 transition-opacity",children:["Conhecer todos os módulos",e(fa,{className:"h-3.5 w-3.5"})]})]}),e("div",{className:"flex-1"}),l&&a("button",{type:"button",onClick:d,className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e(Me,{className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),a("div",{children:[e("div",{className:"font-medium text-foreground",children:"Configurações"}),e("div",{className:"text-sm text-muted-foreground",children:"Gerenciar módulos ativos"})]})]})]})]})]})})}export{xs as AUTH_CONFIG,Co as Accordion,Po as AccordionContent,So as AccordionItem,_o as AccordionTrigger,Rt as ActionButton,lm as ActionMenu,Kn as ActionMenuItems,Ti as Alert,Ei as AlertDescription,Ao as AlertDialog,jo as AlertDialogAction,Lo as AlertDialogCancel,Ro as AlertDialogContent,Fo as AlertDialogDescription,Mo as AlertDialogFooter,zo as AlertDialogHeader,Eo as AlertDialogOverlay,Io as AlertDialogPortal,Do as AlertDialogTitle,To as AlertDialogTrigger,Ii as AlertTitle,Nm as AppHeader,jm as AppLayout,Fm as AppSidebar,fs as AuthErrorInterceptor,Hs as AuthProvider,Bs as AuthService,Oo as Avatar,$o as AvatarFallback,Uo as AvatarImage,Cr as Badge,mi as BaseForm,ad as Blockquote,Wo as Breadcrumb,Ko as BreadcrumbEllipsis,Bo as BreadcrumbItem,qo as BreadcrumbLink,Vo as BreadcrumbList,Ho as BreadcrumbPage,Go as BreadcrumbSeparator,pi as BulkActionBar,Et as Button,Jo as ButtonGroup,ws as CRUD_CONFIG,Nl as Calendar,Ri as CallbackPage,Ft as Card,Ut as CardContent,Ot as CardDescription,$t as CardFooter,jt as CardHeader,nn as CardSkeleton,Lt as CardTitle,Bc as ChartContainer,Kc as ChartLegend,Qc as ChartLegendContent,qc as ChartStyle,Hc as ChartTooltip,Gc as ChartTooltipContent,xr as Checkbox,bo as Collapsible,No as CollapsibleContent,vo as CollapsibleTrigger,ri as ColorPicker,Br as Combobox,Rr as Command,zr as CommandDialog,Fr as CommandEmpty,jr as CommandGroup,Mr as CommandInput,Or as CommandItem,Dr as CommandList,Lr as CommandSeparator,Ur as CommandShortcut,zn as ContextMenu,Vn as ContextMenuCheckboxItem,$n as ContextMenuContent,Dn as ContextMenuGroup,Wn as ContextMenuItem,qn as ContextMenuLabel,Fn as ContextMenuPortal,Ln as ContextMenuRadioGroup,Bn as ContextMenuRadioItem,Hn as ContextMenuSeparator,Gn as ContextMenuShortcut,jn as ContextMenuSub,Un as ContextMenuSubContent,On as ContextMenuSubTrigger,Mn as ContextMenuTrigger,ko as CoreProviders,im as CrudGrid,yi as CrudPageInternal,hi as CrudPagination,dm as CrudPrimitiveFilterBar,ui as CrudPrimitivePagination,om as CrudPrimitiveTable,ei as CrudTable,Qi as DATETIME_FORMATS,Yi as DEFAULT_DATETIME_FORMAT,Xi as DEFAULT_LOCALE,Zi as DEFAULT_TIMEZONE,yl as DataList,xl as DatePicker,Vt as Dialog,Xt as DialogBody,Ht as DialogClose,Qt as DialogContent,er as DialogDescription,Yt as DialogFooter,Jt as DialogHeader,Gt as DialogOverlay,qt as DialogPortal,Zt as DialogTitle,Bt as DialogTrigger,wl as Drawer,Sl as DrawerClose,Pl as DrawerContent,El as DrawerDescription,Tl as DrawerFooter,Al as DrawerHeader,_l as DrawerOverlay,Cl as DrawerPortal,Il as DrawerTitle,kl as DrawerTrigger,vn as DropdownMenu,An as DropdownMenuCheckboxItem,_n as DropdownMenuContent,yn as DropdownMenuGroup,Pn as DropdownMenuItem,In as DropdownMenuLabel,xn as DropdownMenuPortal,kn as DropdownMenuRadioGroup,Tn as DropdownMenuRadioItem,En as DropdownMenuSeparator,Rn as DropdownMenuShortcut,wn as DropdownMenuSub,Sn as DropdownMenuSubContent,Cn as DropdownMenuSubTrigger,Nn as DropdownMenuTrigger,Wm as EmailService,mn as EmptyState,Br as EntitySelect,wo as ErrorBoundary,Ni as FilterBar,ar as Form,lr as FormControl,dr as FormDescription,rr as FormField,ir as FormItem,or as FormLabel,cr as FormMessage,on as FormSkeleton,Ml as Grid,ql as H1,Hl as H2,Gl as H3,Kl as H4,ln as HeaderSkeleton,Dl as HoverCard,jl as HoverCardContent,Fl as HoverCardTrigger,oi as IconPicker,Au as ImageEditor,Tu as ImageRenderer,ed as InlineCode,zt as Input,Ll as InputGroup,Ul as InputGroupAddon,Wl as InputGroupButton,Vl as InputGroupInput,Bl as InputGroupTextarea,As as LOGO_CONFIG,Dt as Label,Xl as Large,Jl as Lead,ou as LeaderRow,pu as LeadershipDialog,hu as LeadershipForm,bu as LeadershipPage,td as List,Pr as LoadingState,po as LocaleProvider,um as LocaleSelector,zi as LoginPage,Ts as MESSAGES,Du as MODULES_DATA,Bm as ManageAccessModal,Ic as Menubar,Fc as MenubarCheckboxItem,Mc as MenubarContent,_c as MenubarGroup,Dc as MenubarItem,Lc as MenubarLabel,Sc as MenubarMenu,Pc as MenubarPortal,Tc as MenubarRadioGroup,jc as MenubarRadioItem,Oc as MenubarSeparator,Uc as MenubarShortcut,Ac as MenubarSub,zc as MenubarSubContent,Rc as MenubarSubTrigger,Ec as MenubarTrigger,zm as ModalStateProvider,Lu as ModulesDialog,Br as MultiSelect,Zl as Muted,rd as NavigationMenu,ld as NavigationMenuContent,md as NavigationMenuIndicator,nd as NavigationMenuItem,dd as NavigationMenuLink,sd as NavigationMenuList,od as NavigationMenuTrigger,cd as NavigationMenuViewport,fm as NavigationProvider,rm as OnboardingDialog,Ql as P,ud as PageBreadcrumb,Di as PageMetadataProvider,pd as Pagination,fd as PaginationContent,yd as PaginationEllipsis,gd as PaginationItem,bd as PaginationLink,Nd as PaginationNext,vd as PaginationPrevious,qm as PlaceCard,Hm as PlacesList,Tr as Popover,Er as PopoverContent,Ir as PopoverTrigger,xd as Progress,_i as ProtectedRoute,_s as QUALIEX_CONFIG,Ss as QUERY_KEYS,Ds as QualiexEnrichmentService,bs as QualiexErrorInterceptor,ci as QualiexUserField,wd as RadioGroup,kd as RadioGroupItem,_d as ResizableHandle,Sd as ResizablePanel,Cd as ResizablePanelGroup,Zc as RichTextEditor,ks as SEARCH_CONFIG,Ki as SUPPORTED_LOCALES,si as ScrollArea,ni as ScrollBar,mr as Select,br as SelectContent,ur as SelectGroup,Nr as SelectItem,vr as SelectLabel,gr as SelectScrollDownButton,fr as SelectScrollUpButton,Br as SelectSearch,yr as SelectSeparator,pr as SelectTrigger,hr as SelectValue,Wt as Separator,Pd as Sheet,Dd as SheetBody,Td as SheetClose,zd as SheetContent,Ld as SheetDescription,Fd as SheetFooter,Md as SheetHeader,Ed as SheetOverlay,Id as SheetPortal,jd as SheetTitle,Ad as SheetTrigger,Vd as Sidebar,Im as SidebarActionTrigger,Xd as SidebarContent,Qd as SidebarFooter,Yd as SidebarGroup,ec as SidebarGroupAction,ac as SidebarGroupContent,Zd as SidebarGroupLabel,Tm as SidebarHeader,Gd as SidebarInput,Hd as SidebarInset,tc as SidebarMenu,ic as SidebarMenuAction,oc as SidebarMenuBadge,nc as SidebarMenuButton,rc as SidebarMenuItem,lc as SidebarMenuSkeleton,dc as SidebarMenuSub,mc as SidebarMenuSubButton,cc as SidebarMenuSubItem,Wd as SidebarProvider,qd as SidebarRail,Jd as SidebarSeparator,dn as SidebarSkeleton,Bd as SidebarTrigger,$r as Skeleton,uc as Slider,Yl as Small,Ar as SonnerToaster,_r as Spinner,sm as SplitButton,vi as Stack,li as Switch,Ji as TIMEZONES,Nc as TabPageContent,vc as TabPageHeader,bc as TabPageLayout,Js as Table,Ys as TableBody,rn as TableCaption,tn as TableCell,Zs as TableFooter,an as TableHead,Xs as TableHeader,bn as TableResizeHandle,en as TableRow,Qn as TableRowActions,sn as TableSkeleton,hc as Tabs,gc as TabsContent,pc as TabsList,fc as TabsTrigger,wr as Textarea,Ar as Toaster,xc as Toggle,kc as ToggleGroup,Cc as ToggleGroupItem,es as TokenManager,Hr as TokenService,hn as Tooltip,fn as TooltipContent,un as TooltipProvider,pn as TooltipTrigger,go as TranslationLoader,gn as TruncatedCell,_u as VideoEditor,Pu as VideoRenderer,_m as assets,kr as badgeVariants,Xm as buildHierarchy,Qo as buttonGroupVariants,It as buttonVariants,Iu as calculateAspectRatio,Ct as cn,xi as createCrudPage,mm as createCrudRoutingConfig,cm as createRoutingHandlers,Ls as createService,wi as createSimpleSaveHandler,Qs as createSimpleService,At as debounce,Es as deriveEmailField,Is as deriveNameField,Rs as deriveUsernameField,io as detectBrowserLocale,co as detectBrowserPreferences,oo as detectBrowserTimezone,Cu as detectVideoProvider,Vm as emailService,rs as errorService,zu as extractImageFileName,xu as extractVimeoId,Nu as extractYouTubeId,Jm as filterAndPromoteOrphans,ao as findDatetimeFormat,eo as findLocale,to as findTimezone,Ym as flattenTree,Pt as formatCurrency,Um as formatDate,_t as formatDatetime,Mu as formatFileSize,ki as generateCrudConfig,Ps as getQualiexConfig,cs as getSupabaseClient,kt as handleExternalLink,lo as inferDatetimeFormat,Ol as inputGroupAddonVariants,$l as inputGroupButtonVariants,Cs as isDevEnvironment,Ru as isImageUrl,so as isValidDatetimeFormat,ro as isValidLocale,no as isValidTimezone,Pm as logoSrc,id as navigationMenuTriggerStyle,Su as normalizeVideoUrl,wu as normalizeVimeoUrl,yu as normalizeYouTubeUrl,ku as parseIframeSrc,Qm as placeService,ys as qualiexApi,Eu as resizeKeepingAspect,zs as resolveFieldMappings,Li as setupQualiexCore,Tt as slugify,Am as smallLogoSrc,yc as toggleVariants,Bi as translationService,St as trimTextFields,xm as useActiveModules,Gs as useAuth,ai as useBaseForm,Xn as useColumnResize,eu as useCreateLeaderMutation,tu as useCreateMultipleLeadersMutation,au as useCreateSingleLeaderMutation,Ks as useCrud,vm as useDebounce,sr as useFormField,Dm as useHasOpenModal,$m as useI18nFormatters,Zm as useLeadershipApi,fo as useLocale,vu as useMediaUpload,Mm as useModalState,gm as useNavigation,ji as usePageMetadata,Fi as usePageMetadataContext,bm as usePageTitle,ym as usePermissionQuery,di as useQualiexUsers,su as useRemoveLeaderMutation,hd as useRouteBreadcrumbs,Yn as useRowResize,$d as useSidebar,Em as useSidebarResize,nu as useSyncSubordinatesMutation,ru as useUpdateLeaderMutation,Lm as useWizard};