forlogic-core 1.14.0 → 1.14.2

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.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),a=require("react"),t=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),i=require("date-fns"),o=require("i18next"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),x=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-popover"),g=require("react-i18next"),b=require("@supabase/supabase-js"),v=require("@tanstack/react-query"),y=require("react-router-dom"),j=require("@radix-ui/react-tooltip"),N=require("@radix-ui/react-dropdown-menu"),w=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("@radix-ui/react-progress"),P=require("@radix-ui/react-collapsible"),T=require("@radix-ui/react-accordion"),I=require("@radix-ui/react-alert-dialog"),_=require("@radix-ui/react-avatar"),A=require("react-day-picker"),E=require("vaul"),M=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),D=require("@radix-ui/react-radio-group"),F=require("react-resizable-panels"),z=require("@radix-ui/react-slider"),L=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-toggle"),U=require("@radix-ui/react-toggle-group"),q=require("@radix-ui/react-menubar"),$=require("recharts"),B=require("@tiptap/react"),W=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Q=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),X=require("zod"),J=require("@hookform/resolvers");function Y(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var Z=Y(a),ee=Y(c),ae=Y(u),te=Y(m),se=Y(h),re=Y(x),ne=Y(f),ie=Y(j),oe=Y(N),le=Y(w),de=Y(C),ce=Y(k),ue=Y(S),me=Y(P),pe=Y(T),he=Y(I),xe=Y(_),fe=Y(M),ge=Y(R),be=Y(D),ve=Y(F),ye=Y(z),je=Y(L),Ne=Y(O),we=Y(U),Ce=Y(q),ke=Y($);function Se(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info(o.t("link_copied"))})}function Pe(...e){return n.twMerge(r.clsx(e))}const Te=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Te);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Te(s);return a}return e},Ie=s.cva("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"}}),_e=Z.forwardRef(({className:a,variant:s,size:r,asChild:n=!1,...i},o)=>{const l=n?t.Slot:"button";return e.jsx(l,{className:Pe(Ie({variant:s,size:r,className:a})),ref:o,...i})});_e.displayName="Button";const Ae=a.forwardRef(({className:a,children:t,...s},r)=>e.jsx(_e,{ref:r,variant:"action",size:"sm",className:Pe("h-7 px-2 text-xs",a),...s,children:t||e.jsx(d.EllipsisVertical,{size:12})}));Ae.displayName="ActionButton";const Ee=Z.forwardRef(({className:a,type:t,...s},r)=>e.jsx("input",{type:t,className:Pe("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:r,...s}));Ee.displayName="Input";const Me=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Re=Z.forwardRef(({className:a,...t},s)=>e.jsx(ee.Root,{ref:s,className:Pe(Me(),a),...t}));Re.displayName=ee.Root.displayName;const De=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));De.displayName="Card";const Fe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex flex-col space-y-1.5 p-6",a),...t}));Fe.displayName="CardHeader";const ze=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("text-2xl font-semibold leading-none tracking-tight",a),...t}));ze.displayName="CardTitle";const Le=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Le.displayName="CardDescription";const Oe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("p-6 pt-0",a),...t}));Oe.displayName="CardContent";const Ue=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex items-center p-6 pt-0",a),...t}));Ue.displayName="CardFooter";const qe=Z.forwardRef(({className:a,orientation:t="horizontal",decorative:s=!0,...r},n)=>e.jsx(te.Root,{ref:n,decorative:s,orientation:t,className:Pe("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...r}));qe.displayName=te.Root.displayName;const $e=ae.Root,Be=ae.Trigger,We=ae.Portal,Ve=ae.Close,He=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{ref:s,className:Pe("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}));He.displayName=ae.Overlay.displayName;const Ge={sm:"sm:max-w-[420px]",md:"sm:max-w-lg",lg:"sm:max-w-2xl",xl:"sm:max-w-4xl",full:"max-w-[85vw]"},Qe=Z.forwardRef(({className:a,children:t,size:s="md",...r},n)=>e.jsxs(We,{children:[e.jsx(He,{}),e.jsxs(ae.Content,{ref:n,className:Pe("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",Ge[s],a),...r,children:[t,e.jsxs(ae.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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Qe.displayName=ae.Content.displayName;const Ke=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(qe,{className:"mt-2"})]});Ke.displayName="DialogHeader";const Xe=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Xe.displayName="DialogBody";const Je=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(qe,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Je.displayName="DialogFooter";const Ye=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Ye.displayName=ae.Title.displayName;const Ze=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Ze.displayName=ae.Description.displayName;const ea=p.FormProvider,aa=Z.createContext({}),ta=()=>{const e=Z.useContext(aa),a=Z.useContext(sa),{getFieldState:t,formState:s}=p.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},sa=Z.createContext({}),ra=Z.forwardRef(({className:a,...t},s)=>{const r=Z.useId();return e.jsx(sa.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Pe("space-y-2",a),...t})})});ra.displayName="FormItem";const na=Z.forwardRef(({className:a,...t},s)=>{const{error:r,formItemId:n}=ta();return e.jsx(Re,{ref:s,className:Pe(r&&"text-destructive",a),htmlFor:n,...t})});na.displayName="FormLabel";const ia=Z.forwardRef(({...a},s)=>{const{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=ta();return e.jsx(t.Slot,{ref:s,id:n,"aria-describedby":r?`${i} ${o}`:`${i}`,"aria-invalid":!!r,...a})});ia.displayName="FormControl";const oa=Z.forwardRef(({className:a,...t},s)=>{const{formDescriptionId:r}=ta();return e.jsx("p",{ref:s,id:r,className:Pe("text-sm text-muted-foreground",a),...t})});oa.displayName="FormDescription";const la=Z.forwardRef(({className:a,children:t,...s},r)=>{const{error:n,formMessageId:i}=ta(),o=n?String(n?.message):t;return o?e.jsx("p",{ref:r,id:i,className:Pe("text-sm font-medium text-destructive",a),...s,children:o}):null});la.displayName="FormMessage";const da=se.Root,ca=se.Group,ua=se.Value,ma=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Trigger,{ref:r,className:Pe("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",a),...s,children:[t,e.jsx(se.Icon,{asChild:!0,children:e.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ma.displayName=se.Trigger.displayName;const pa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollUpButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronUp,{className:"h-4 w-4"})}));pa.displayName=se.ScrollUpButton.displayName;const ha=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollDownButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronDown,{className:"h-4 w-4"})}));ha.displayName=se.ScrollDownButton.displayName;const xa=Z.forwardRef(({className:a,children:t,position:s="popper",container:r,collisionBoundary:n,...i},o)=>e.jsx(se.Portal,{container:r,children:e.jsxs(se.Content,{ref:o,className:Pe("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",a),position:s,collisionBoundary:n,...i,children:[e.jsx(pa,{}),e.jsx(se.Viewport,{className:Pe("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(ha,{})]})}));xa.displayName=se.Content.displayName;const fa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Label,{ref:s,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));fa.displayName=se.Label.displayName;const ga=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Item,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(se.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),e.jsx(se.ItemText,{children:t})]}));ga.displayName=se.Item.displayName;const ba=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));ba.displayName=se.Separator.displayName;const va=Z.forwardRef(({className:a,...t},s)=>e.jsx(re.Root,{ref:s,className:Pe("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.jsx(re.Indicator,{className:Pe("flex items-center justify-center text-current"),children:e.jsx(d.Check,{className:"h-4 w-4"})})}));va.displayName=re.Root.displayName;const ya=Z.forwardRef(({className:a,...t},s)=>e.jsx("textarea",{className:Pe("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:s,...t}));ya.displayName="Textarea";const ja=s.cva("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"}}),Na=Z.forwardRef(({className:a,variant:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(ja({variant:t}),a),...s}));Na.displayName="Badge";const wa={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ca({size:a="md",className:t}){return e.jsx(d.Loader2,{className:Pe("animate-spin text-muted-foreground",wa[a],t)})}const ka=({...a})=>e.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(d.Loader2Icon,{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}),Sa=ne.Root,Pa=ne.Trigger,Ta=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,container:r,...n},i)=>e.jsx(ne.Portal,{container:r,children:e.jsx(ne.Content,{ref:i,align:t,sideOffset:s,className:Pe("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})}));Ta.displayName=ne.Content.displayName;const Ia=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ia.displayName="Command";const _a=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Pe("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})}));_a.displayName="CommandInput";const Aa=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Aa.displayName="CommandList";const Ea=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("py-6 text-center text-sm text-muted-foreground",a),...t}));Ea.displayName="CommandEmpty";const Ma=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("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}));Ma.displayName="CommandGroup";const Ra=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("-mx-1 h-px bg-border",a),...t}));Ra.displayName="CommandSeparator";const Da=Z.forwardRef(({className:a,disabled:t,onSelect:s,value:r,...n},i)=>e.jsx("div",{ref:i,className:Pe("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&&s?.(r||""),...n}));Da.displayName="CommandItem";const Fa=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function za({className:a,...t}){return e.jsx("div",{className:Pe("animate-pulse rounded-md bg-muted",a),...t})}Fa.displayName="CommandShortcut";const La=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Oa({multiple:t,options:s,value:r,onChange:n,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:x,className:f,sortOptions:b,maxDisplayedBadges:v,popoverContainer:y,onOpen:j,onClose:N}){const{t:w}=g.useTranslation(),[C,k]=a.useState(!1),[S,P]=a.useState(""),T=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),I=a.useMemo(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),_=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:o(e)}));return b?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[s,i,o,b]),A=a.useMemo(()=>{if(!S)return _;const e=La(S);return _.filter(a=>La(a.label).includes(e))},[_,S]),E=a.useMemo(()=>_.filter(e=>T.includes(e.value)),[_,T]),M=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?T.filter(a=>a!==e):"")},R=v?E.slice(0,v):E,D=v&&E.length>v?E.length-v:0;return e.jsxs("div",{className:Pe("space-y-2",f),children:[c&&e.jsxs(Re,{children:[c,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Sa,{open:C,onOpenChange:e=>{k(e),e?j?.():(P(""),N?.())},modal:!1,children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":C,disabled:h,className:Pe("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),l]}):t?e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(a=>e.jsxs(Na,{variant:"secondary",className:"gap-1 pr-1",children:[a.label,e.jsx("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&&M(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(a.value,e),children:e.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),D>0&&e.jsxs(Na,{variant:"outline",className:"gap-1",children:["+",D]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ta,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:I,collisionBoundary:I,children:e.jsxs(Ia,{children:[e.jsx(_a,{placeholder:p,value:S,onChange:e=>P(e.target.value)}),e.jsx(Aa,{children:0===s.length?e.jsx(Ea,{children:m}):0===A.length?e.jsx(Ea,{children:w("no_results")}):e.jsx(Ma,{children:A.map(a=>e.jsxs(Da,{value:a.value,onSelect:()=>(e=>{if(n)if(t){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];n(a)}else n(e),k(!1)})(a.value),className:"cursor-pointer",children:[e.jsx(d.Check,{className:Pe("mr-2 h-4 w-4",T.includes(a.value)?"opacity-100":"opacity-0")}),a.label]},a.value))})})]})})]})]})}function Ua({multiple:a=!1,options:t,items:s,value:r,onChange:n,onValueChange:i,getOptionValue:o=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:b=!1,error:v,className:y,sortOptions:j=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k}){const{t:S}=g.useTranslation(),P=s||t||[],T=i||n,I=c||S("select_placeholder"),_=p||S("no_results"),A=h||S("search_placeholder");if(b)return e.jsxs("div",{className:Pe("space-y-2",y),children:[u&&e.jsxs(Re,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(za,{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?e.jsxs("div",{className:Pe("space-y-2",y),children:[u&&e.jsxs(Re,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:E})]})]}):e.jsx(Oa,{multiple:a,options:P,value:r||(a?[]:""),onChange:T,getOptionValue:o,getOptionLabel:l,placeholder:I,label:u,icon:m,emptyMessage:_,searchPlaceholder:A,disabled:x,required:f,className:y,sortOptions:j,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k})}var qa=Object.defineProperty;class $a{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 r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}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(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}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(r.exp&&r.exp<o){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}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?qa(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})($a,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Ba="qualiex_access_token",Wa="qualiex_id_token",Va="supabase_token",Ha="oauth_state",Ga="oauth_nonce",Qa="selected_alias",Ka="manual_logout",Xa={setAccessToken:e=>localStorage.setItem(Ba,e),getAccessToken:()=>localStorage.getItem(Ba),setIdToken:e=>localStorage.setItem(Wa,e),getIdToken:()=>localStorage.getItem(Wa),getSupabaseToken:()=>localStorage.getItem(Va),setOAuthState:e=>sessionStorage.setItem(Ha,e),getOAuthState:()=>sessionStorage.getItem(Ha),clearOAuthState:()=>sessionStorage.removeItem(Ha),setOAuthNonce:e=>sessionStorage.setItem(Ga,e),getOAuthNonce:()=>sessionStorage.getItem(Ga),clearOAuthNonce:()=>sessionStorage.removeItem(Ga),setSelectedAlias:e=>localStorage.setItem(Qa,e),getSelectedAlias:()=>localStorage.getItem(Qa),clearSelectedAlias:()=>localStorage.removeItem(Qa),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Xa.getAccessToken()||!Xa.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Va,e),Xa._clearValidationCache()},areAllTokensValid:()=>{const e=Xa.getAccessToken(),a=Xa.getIdToken();if(!e||!a)return!1;try{const t=$a.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Xa.getAccessToken(),t=Xa.getIdToken(),s=Xa.getSupabaseToken();return a&&Xa.isTokenExpired(a)&&(localStorage.removeItem(Ba),e=!0),t&&Xa.isTokenExpired(t)&&(localStorage.removeItem(Wa),e=!0),s&&Xa.isTokenExpired(s)&&(localStorage.removeItem(Va),e=!0),e},clearAll:()=>{localStorage.removeItem(Ba),localStorage.removeItem(Wa),localStorage.removeItem(Va),localStorage.removeItem(Qa),localStorage.removeItem(Ka),sessionStorage.removeItem(Ha),sessionStorage.removeItem(Ga)},setManualLogout:()=>localStorage.setItem(Ka,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ka),clearManualLogout:()=>localStorage.removeItem(Ka),isTokenExpired:e=>{try{return $a.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Xa._validationCache.isValid=!1,Xa._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Xa.getSupabaseToken();if(!e)return!1;if(Xa.isTokenExpired(e))return Xa._clearValidationCache(),Xa._handleExpiredToken(),!1;const a=Date.now();return a-Xa._validationCache.timestamp<Xa._validationCache.cacheValidityMs?Xa._validationCache.isValid:(Xa._validationCache.isValid=!0,Xa._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>Xa.isSupabaseTokenValid()?Xa.getSupabaseToken():null,_handleExpiredToken:()=>{Xa.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Xa.isSupabaseTokenValid())return null;const e=Xa.getSupabaseToken();if(!e)return null;try{const a=$a.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=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 s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return Xa._handleExpiredToken(),null}},getCompanyId:e=>{const a=Xa.getAccessToken();if(a)try{const t=$a.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=Xa.extractTokenData();if(t?.companyId)return t.companyId;const s=Xa.getIdToken();if(s)try{const a=$a.parseJwtPayload(s);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=Xa.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Xa.getIdToken();if(!e)return[];try{const a=$a.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.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 Ja=Object.defineProperty,Ya=(e,a,t)=>((e,a,t)=>a in e?Ja(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Za=new class{constructor(){Ya(this,"errors",[]),Ya(this,"toastCount",0),Ya(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);l.toast.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){l.toast.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 et=Object.defineProperty,at=(e,a,t)=>((e,a,t)=>a in e?et(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const tt=(void 0).VITE_SUPABASE_URL,st=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,rt=class e{constructor(){at(this,"client"),at(this,"currentToken",null),at(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:st};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return b.createClient(tt,st,{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=Xa.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 Za.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};at(rt,"instance");let nt=rt;function it(){return nt.getInstance().getClient()}class ot{static async generateToken(e,a,t,s=!1){try{if(!s){const e=Xa.getSupabaseToken();if(e&&Xa.isSupabaseTokenValid())return e}const r=it(),{data:n,error:i}=await r.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?(Xa.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}var lt=Object.defineProperty,dt=(e,a,t)=>((e,a,t)=>a in e?lt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class ct{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Xa.getAccessToken(),a=Xa.getSelectedAlias();if(!e||!a)return null;const t=await ot.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(Xa.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}dt(ct,"isRegenerating",!1),dt(ct,"onLogoutCallback",null);class ut{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Xa.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 mt=Object.defineProperty;class pt{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 ct.attemptRegeneration()?(this.isRetrying=!1,!0):(ut.handleError(e),this.isRetrying=!1,!1)}catch(s){return ut.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Xa.getAccessToken();return e?Xa.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?mt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(pt,"isRetrying",!1);var ht=Object.defineProperty,xt=(e,a,t)=>((e,a,t)=>a in e?ht(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const ft=new class{constructor(){xt(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=pt.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Xa.getAccessToken();if(!r)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 ${r}`,"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 s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Za.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=t}if(!Array.isArray(s))return Za.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(t){if(await pt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Za.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=t}return Array.isArray(s)?s.map(this.mapToQualiexUser):(Za.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return Za.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return Za.handleError(r,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return Za.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),s=new Map;return t.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const a=Xa.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},gt={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},bt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},vt={debounceDelay:500},yt=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV},jt={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Nt=()=>jt,wt={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},Ct={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 kt(e,a){const t=Nt(),s=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function St(e,a){const t=Nt(),s=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Pt(e,a){const t=Nt(),s=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Tt(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||kt(e.idField),emailField:e.emailField||St(e.idField),usernameField:e.usernameField||Pt(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:kt(e),emailField:St(e),usernameField:Pt(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const It=new Map;class _t{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=It.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await ft.fetchUsers(e,a);return It.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[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 s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||n.displayName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!Xa.areAllTokensValid())return e;const t=Xa.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=Tt(a.userIdFields,a.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(s,r),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(t){return Za.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 At=["responsible_name"],Et=e=>At.includes(e);function Mt(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!Xa.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return it().schema(o).from(r)},u=(e,a,t,s)=>{let r=c().select(i||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const o=a.includes(".");return o||Et(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:o}},m=async(e,a,t,r,n)=>{const i=Tt(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(Et(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 _t.enrichWithUserData(i.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=o?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t,n=e.slice(s,r);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await _t.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.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:s="desc",page:r=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:i}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,i,o),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let b=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=Tt(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(b.data)){const e=await m(b.data,t,n,i,o);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Te(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Te(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},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 ${r}: ${t.message}`)}}}const Rt=()=>{Xa.clearManualLogout()},Dt=e=>e?.placeId||null,Ft=e=>e?.placeName||null,zt=e=>({placeId:Dt(e),placeName:Ft(e)}),Lt=class{static async initialize(){try{if(!Xa.hasAllTokens()||!Xa.areAllTokensValid())return Xa.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=Xa.getAccessToken(),t=Xa.getIdToken();Rt();const s=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=Xa.extractTokenData(),o=i?.alias;let l=null;if(o&&r.some(e=>e.alias===o))l=o;else{const e=Xa.getSelectedAlias(),a=e&&r.some(a=>a.alias===e);l=a?e:n||r[0]?.alias||null}!Xa.isSupabaseTokenValid()&&l&&await ct.attemptRegeneration();let d=null;if(l){const e=Xa.getCompanyId(l),a=r.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,u=null;if(s?.id&&l){const a=Xa.getCompanyId(l);if(a)try{const e=(await ft.fetchActiveUsersMap(l,a)).get(s.id);if(e){const a=zt(e);c=a.placeId,u=a.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:s,alias:l,companies:r,selectedUnit:d,userId:s?.id||null,userAlias:s?.id||null,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}}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=it(),{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 s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Xa.generateOAuthState();Xa.setOAuthState(e);const a=Xa.generateOAuthNonce();Xa.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(gt.oauth.authUrl);s.searchParams.set("client_id",gt.oauth.clientId),s.searchParams.set("response_type",gt.oauth.responseType),s.searchParams.set("scope",gt.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),yt(),window.location.href=s.toString()}static async processCallback(){try{if(Xa.hasAllTokens()){if(!Xa.getValidSupabaseToken()){Xa.getAccessToken();await ct.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),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");Xa.setAccessToken(s),Xa.setIdToken(r),Rt();const i=this.extractAliasFromAccessToken(s);if(i)Xa.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Xa.setSelectedAlias(e[0].alias)}if(!await ct.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Xa.clearOAuthState(),Xa.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Xa.setManualLogout(),Xa.clearAll(),window.location.href="/login"}static decodeToken(e){return $a.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 s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};ct.setLogoutCallback(()=>{Lt.logout()});let Ot=Lt;const Ut=a.createContext(void 0),qt=({children:t})=>{const[s,r]=a.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=v.useQueryClient()}catch{}const[i,o]=a.useState(!1),[l,d]=a.useState(0),c=a.useCallback(e=>{r(a=>({...a,...e}))},[]),u=a.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),m=a.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=a.useCallback(async e=>{try{u(!0);const t=Xa.getAccessToken();if(!t)return;const r=await ot.generateToken(t,e.alias,void 0,!0);if(!r)return;Xa.setSupabaseToken(r),Xa.setSelectedAlias(e.alias);const i=Xa.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Xa.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let m=null,p=null;if(s.user?.id&&o&&l)try{const e=(await ft.fetchActiveUsersMap(o,l)).get(s.user.id);if(e){const a=zt(e);m=a.placeId,p=a.placeName}}catch(a){}c({alias:o,selectedUnit:d,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{u(!1)}},[c,n,u,s.user]),h=a.useCallback(async()=>await Ot.processCallback(),[]),x=a.useCallback(async()=>{Ot.logout(),m(),n&&await n.clear()},[m,n]),f=a.useCallback(e=>{o(e)},[]),g=a.useCallback(()=>{d(e=>e+1)},[]),b=a.useCallback(()=>{d(e=>e+1)},[]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Xa.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Ot.initialize();if(!e)return;a&&a.isAuthenticated?c({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&&u(!1)}catch(a){e&&(ut.handleError(a),u(!1))}})(),()=>{e=!1}},[c,u,x]);const y=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,x,h,p,i,f,g,b]);return e.jsx(Ut.Provider,{value:y,children:t})},$t=()=>{const e=a.useContext(Ut);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Bt({queryKey:e,service:t,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:i}){const[o,d]=y.useSearchParams(),c=v.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=$t(),h=a.useCallback(a=>{const t=`${e}_${a}`,s=o.get(t);return s||(o.get(a)||"")},[o,e]),x=h("search"),f=h("sortField")||bt.sorting.defaultField,g=h("sortDirection")||bt.sorting.defaultDirection,b=parseInt(h("page")||"1"),j=parseInt(h("limit")||String(bt.pagination.defaultPageSize)),N=x,w=a.useMemo(()=>({search:N,sortField:f,sortDirection:g,page:b,limit:j,...n}),[N,f,g,b,j,n]),C=a.useCallback(()=>t.getAll(w),[t,w]),k=v.useQuery({queryKey:[e,u,m,w],queryFn:C,enabled:!!u&&p});if(!k)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const S=v.useMutation({mutationFn:t.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.created(s)),i?.()},onError:e=>{l.toast.error(`${Ct.error.create(s)}: ${e.message}`)}}),P=v.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.updated(s)),i?.()},onError:e=>{l.toast.error(`${Ct.error.update(s)}: ${e.message}`)}}),T=v.useMutation({mutationFn:t.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.deleted(s))},onError:e=>{l.toast.error(`${Ct.error.delete(s)}: ${e.message}`)}}),I=a.useCallback(a=>{const t={...Object.fromEntries(o)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[o,d,e]),_=a.useCallback(e=>{I({search:e,page:1})},[I]),A=a.useCallback(e=>{I({sortField:e,sortDirection:f===e&&"asc"===g?"desc":"asc",page:1})},[f,g,I]),E=a.useCallback(e=>{I({page:e})},[I]),M=a.useCallback(e=>{I({limit:e,page:1})},[I]),R=a.useCallback(()=>{const a=Object.fromEntries(o),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,o,e]),[D,F]=a.useState([]),z=a.useCallback(e=>{F(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=a.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];F(a=>a.length===e.length?[]:e)},[k?.data?.data]),O=a.useCallback(()=>{F([])},[]),U=a.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&D.length===e.length},[D,k?.data?.data]),q=v.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(`${t.length} ${s}(s) deletado(s) com sucesso`),O()},onError:e=>{l.toast.error(`Erro ao deletar itens: ${e.message}`)}}),$=a.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):S.mutate({...t,alias:u})},[u,S,P]);return{entities:k?.data?.data||[],pagination:{data:k?.data?.data||[],currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||bt.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:T?.isPending??!1,error:k?.error||null,searchTerm:x,sortField:f,sortDirection:g,currentPage:b,itemsPerPage:j,queryKey:e,createEntity:S.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:T.mutate,save:$,handleSearch:_,handleSort:A,handlePageChange:E,handleItemsPerPageChange:M,clearFilters:R,refetch:k.refetch,selectedIds:D,selectItem:z,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}const Wt=Z.forwardRef(({className:a,...t},s)=>e.jsx("table",{ref:s,className:Pe("w-full caption-bottom text-sm table-fixed",a),...t}));Wt.displayName="Table";const Vt=Z.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:Pe("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Vt.displayName="TableHeader";const Ht=Z.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:Pe("[&_tr:last-child]:border-0",a),...t}));Ht.displayName="TableBody";const Gt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:Pe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Gt.displayName="TableFooter";const Qt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:Pe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Qt.displayName="TableRow";const Kt=Z.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:Pe("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}));Kt.displayName="TableHead";const Xt=Z.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:Pe("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));Xt.displayName="TableCell";const Jt=Z.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:Pe("mt-4 text-sm text-muted-foreground",a),...t}));function Yt({rows:a=5,columns:t=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((a,t)=>e.jsx(za,{className:"h-4 w-24"},t))})}),e.jsx("div",{children:Array.from({length:a}).map((a,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((a,t)=>e.jsx(za,{className:"h-4 w-20"},t))})},s))})]})})}function Zt({count:a=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:a}).map((a,t)=>e.jsxs(De,{children:[e.jsxs(Fe,{children:[e.jsx(za,{className:"h-4 w-3/4"}),e.jsx(za,{className:"h-3 w-1/2"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(za,{className:"h-3 w-full"}),e.jsx(za,{className:"h-3 w-2/3"})]})})]},t))})}Jt.displayName="TableCaption";const es={default:d.FileX,search:d.Search,error:d.AlertCircle};function as({icon:a,title:t,description:s,action:r,className:n,variant:i="default"}){const o=a?()=>a:es[i];return e.jsxs("div",{className:Pe("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e.jsx(o,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(_e,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ts=ie.Provider,ss=ie.Root,rs=ie.Trigger,ns=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:t,className:Pe("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),...s}));function is({children:a,className:t}){const s=Z.useRef(null),[r,n]=Z.useState(!1);Z.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[a]);const i=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:a});return r?e.jsx(ts,{delayDuration:300,children:e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:i}),e.jsx(ns,{side:"top",className:"max-w-[400px] break-words",children:a})]})}):i}ns.displayName=ie.Content.displayName;const os=Z.forwardRef(({direction:a,onMouseDown:t,isDragging:s,className:r},n)=>{const i="horizontal"===a;return e.jsx("div",{ref:n,onMouseDown:t,className:Pe("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"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Pe("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});os.displayName="TableResizeHandle";const ls=oe.Root,ds=oe.Trigger,cs=oe.Group,us=oe.Portal,ms=oe.Sub,ps=oe.RadioGroup,hs=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Pe("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));hs.displayName=oe.SubTrigger.displayName;const xs=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.SubContent,{ref:s,className:Pe("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}));xs.displayName=oe.SubContent.displayName;const fs=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:t,className:Pe("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),...s})}));fs.displayName=oe.Content.displayName;const gs=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Item,{ref:r,className:Pe("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),...s}));gs.displayName=oe.Item.displayName;const bs=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Pe("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",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));bs.displayName=oe.CheckboxItem.displayName;const vs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));vs.displayName=oe.RadioItem.displayName;const ys=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));ys.displayName=oe.Label.displayName;const js=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));js.displayName=oe.Separator.displayName;const Ns=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest opacity-60",a),...t});Ns.displayName="DropdownMenuShortcut";const ws=le.Root,Cs=le.Trigger,ks=le.Group,Ss=le.Portal,Ps=le.Sub,Ts=le.RadioGroup,Is=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Is.displayName=le.SubTrigger.displayName;const _s=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.SubContent,{ref:s,className:Pe("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}));_s.displayName=le.SubContent.displayName;const As=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:s,className:Pe("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})}));As.displayName=le.Content.displayName;const Es=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Item,{ref:r,className:Pe("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),...s}));Es.displayName=le.Item.displayName;const Ms=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Pe("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",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));Ms.displayName=le.CheckboxItem.displayName;const Rs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Rs.displayName=le.RadioItem.displayName;const Ds=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...s}));Ds.displayName=le.Label.displayName;const Fs=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-border",a),...t}));Fs.displayName=le.Separator.displayName;const zs=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});zs.displayName="ContextMenuShortcut";const Ls=({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:i=[],renderAs:o})=>{const{t:l}=g.useTranslation(),c=[];if(a){const e={icon:d.Edit,label:l("edit"),onClick:a};c.push(e)}if(i.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:l(r?"deactivate":"activate"),onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===o?gs:Es;return e.jsx(e.Fragment,{children:c.map((a,t)=>e.jsxs(u,{onClick:a.onClick,className:Pe("whitespace-normal cursor-pointer",a.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(a.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.label]},t))})},Os=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:i=[]})=>e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(d.EllipsisVertical,{size:12})})}),e.jsx(fs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Ls,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:i,renderAs:"dropdown"})})]}),Us=150;function qs({columns:e,storageKey:t,onResize:s,enabled:r=!0}){const[n,i]=a.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{})}),[o,l]=a.useState(!1),[d,c]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??Us)},[r,n]);a.useEffect(()=>{if(!o||!d)return;const a=e.find(e=>e.key===d),r=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));i(e=>{const a={...e,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(null),t&&i(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[o,d,e,t,s]),a.useEffect(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const h=a.useCallback(()=>{const a=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{});i(a),t&&localStorage.removeItem(t),s?.(a)},[e,t,s]);return{columnWidths:n,isDragging:o,activeColumn:d,handleMouseDown:p,resetWidths:h}}function $s({rowIds:e,defaultHeight:t=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:i,enabled:o=!0}){const[l,d]=a.useState(()=>{if(!o||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{o&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[o,l,t]);a.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return i?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=a.useCallback(()=>{d({}),n&&localStorage.removeItem(n),i?.({})},[n,i]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}}const Bs=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(va,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),Ws=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f=!1,enableColumnResize:b=!0,resizeStorageKey:v})=>{const{t:y}=g.useTranslation(),{setSearchVisible:j}=$t(),[N,w]=a.useState(!1);a.useEffect(()=>(j(!0),()=>j(!1)),[j]),a.useEffect(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:P}=qs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:v?`${v}-columns`:void 0,enabled:b}),{isDragging:T,activeRow:I,handleMouseDown:_,getRowHeight:A}=$s({rowIds:t.entities.map(e=>e.id),storageKey:v?`${v}-rows`:void 0,enabled:!1}),E=a.useMemo(()=>(()=>{if(b)return s.map(e=>{const a=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=s.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,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`}})})(),[s,b,C]),M=!f&&(m||x.length>0);return N?t.isLoading?e.jsx(Zt,{count:3}):0===t.entities.length?e.jsx(as,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(a=>e.jsxs(ws,{children:[e.jsx(Cs,{asChild:!0,children:e.jsx(De,{className:Pe("overflow-hidden cursor-pointer hover:bg-muted/50",u&&t.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(t=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Os,{onEdit:r?()=>{r(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})})})}),e.jsx(As,{className:"w-[160px]",children:e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),t.isLoading?e.jsx(Yt,{rows:5,columns:s.length}):e.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(Wt,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),E.map((a,t)=>e.jsx("col",{style:a.style},t)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Vt,{children:e.jsxs(Qt,{children:[u&&e.jsx(Kt,{className:"w-[50px]",children:e.jsx(Bs,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),s.map(a=>{const s=b&&!1!==a.resizable,r=S===String(a.key);return e.jsxs(Kt,{className:Pe(a.className,a.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:a.sortable?()=>t.handleSort(String(a.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(n=String(a.key),t.sortField!==n?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(os,{direction:"horizontal",onMouseDown:e=>P(String(a.key),e),isDragging:r})]},String(a.key));var n}),e.jsx(Kt,{className:"w-[50px] text-center",children:y("actions")})]})}),e.jsx(Ht,{children:0===t.entities.length?e.jsx(Qt,{children:e.jsx(Xt,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(as,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):t.entities.map(a=>{const n=A(a.id);return a.id,e.jsxs(ws,{children:[e.jsx(Cs,{asChild:!0,children:e.jsxs(Qt,{className:Pe("cursor-pointer hover:bg-muted/50 relative",u&&t.selectedIds.includes(a.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:[u&&e.jsx(Xt,{onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),s.map(t=>e.jsx(Xt,{className:t.className,children:e.jsx(is,{children:t.render?t.render(a):String(a[t.key]??"")})},String(t.key))),e.jsx(Xt,{className:"text-center",children:l?l(a):e.jsx(Os,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})}),e.jsx(As,{className:"w-[160px]",children:e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})]})})})]})};function Vs(e,t,s,r){const[n,i]=a.useState({}),[o,l]=a.useState({}),d=a.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=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{}}},m=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};a.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},a=e(d),n={};a.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);c(e)&&(a=e.toISOString().split("T")[0])}else c(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),t&&Object.keys(t).forEach(e=>{a.find(a=>a.name===e)||void 0===t[e]||(n[e]=t[e])}),i(n),l({}),s&&s(n)},[d,t,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:o,updateField:(e,a)=>{i(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),o[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Hs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Gs=({value:a="#3b82f6",onChange:t,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Re,{children:s}),e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:a}}),a]})}),e.jsx(Ta,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Re,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Ee,{id:"color-input",type:"color",value:a,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Re,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Hs.map(a=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>t?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),Qs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(de.Root,{ref:r,className:Pe("relative overflow-hidden",a),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(Ks,{}),e.jsx(de.Corner,{})]}));Qs.displayName=de.Root.displayName;const Ks=Z.forwardRef(({className:a,orientation:t="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:t,className:Pe("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),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Ks.displayName=de.ScrollAreaScrollbar.displayName;const Xs={Star:d.Star,Heart:d.Heart,Home:d.Home,User:d.User,Settings:d.Settings,Mail:d.Mail,Phone:d.Phone,Calendar:d.Calendar,MapPin:d.MapPin,Camera:d.Camera,Image:d.Image,Music:d.Music,Video:d.Video,Book:d.Book,Bookmark:d.Bookmark,Search:d.Search,Filter:d.Filter,Edit:d.Edit,Trash2:d.Trash2,Plus:d.Plus,Minus:d.Minus,Check:d.Check,X:d.X,ChevronDown:d.ChevronDown,ChevronUp:d.ChevronUp,ChevronLeft:d.ChevronLeft,ChevronRight:d.ChevronRight,ArrowUp:d.ArrowUp,ArrowDown:d.ArrowDown,ArrowLeft:d.ArrowLeft,ArrowRight:d.ArrowRight,Clock:d.Clock,Bell:d.Bell,AlertCircle:d.AlertCircle,Info:d.Info,HelpCircle:d.HelpCircle,Download:d.Download,Upload:d.Upload,Share:d.Share,Copy:d.Copy,Save:d.Save,FileText:d.FileText,Folder:d.Folder,FolderOpen:d.FolderOpen,Archive:d.Archive,Lock:d.Lock,Unlock:d.Unlock,Eye:d.Eye,EyeOff:d.EyeOff,Shield:d.Shield,Key:d.Key,Zap:d.Zap,Flame:d.Flame,Sparkles:d.Sparkles,Award:d.Award,Trophy:d.Trophy,Target:d.Target},Js=({value:t="Star",onChange:s,label:r})=>{const{t:n}=g.useTranslation(),[i,o]=a.useState(""),l=Object.entries(Xs).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),c=Xs[t]||d.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Re,{children:r}),e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),t]})}),e.jsx(Ta,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Re,{htmlFor:"icon-search",children:n("search")}),e.jsx(Ee,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e.jsx(Qs,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:l.map(([a,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(a),title:a,children:e.jsx(r,{className:"h-4 w-4"})},a))})})]})})]})]})},Ys=Z.forwardRef(({className:a,...t},s)=>e.jsx(ce.Root,{className:Pe("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:s,children:e.jsx(ce.Thumb,{className:Pe("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")})}));Ys.displayName=ce.Root.displayName;const Zs=(e={})=>{const{user:a,alias:t}=$t(),{enabled:s=!0}=e;return v.useQuery({queryKey:["qualiex-users",t],queryFn:()=>ft.getUsers(t),enabled:s&&!!t&&!!a,retry:2,retryDelay:1e3})},er=({value:t,onChange:s,multiple:r=!1,label:n,required:i,placeholder:o,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:x,sortOptions:f=!0,popoverContainer:b,onOpen:v,onClose:y})=>{const{t:j}=g.useTranslation(),{data:N=[],isLoading:w,error:C}=Zs({enabled:m}),k=a.useMemo(()=>x?N.filter(x):N,[N,x]),S=a.useCallback(e=>{if("custom"===p&&h)return h(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,h]);return e.jsx(Ua,{multiple:r,value:t??(r?[]:""),onChange:s,options:k,isLoading:w,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:S,placeholder:o||j("search_placeholder"),searchPlaceholder:j("search_placeholder"),emptyMessage:j("no_results"),label:n,required:i,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:f,popoverContainer:b,onOpen:v,onClose:y})};function ar({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(s?.[0]?.id||""),h=a.useRef(null),[x,f]=a.useState(null),b=a.useCallback(e=>{h.current=e,f(e)},[]),v=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:y,errors:j,updateField:N,handleSubmit:w}=Vs(v,r,void 0,o),C=a.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(y):e.disabled||!1})):[],[s,y]),k=a.useMemo(()=>{const e=C.find(e=>e.id===m);if(e&&!e.disabled)return m;const a=C.find(e=>!e.disabled);return a?.id||m},[C,m]);a.useEffect(()=>{k!==m&&p(k)},[k,m]);const S=C.find(e=>e.id===k),P=a=>{const t=(a.computedValue,y[a.name]),s=void 0!==t?t:"",r=j[a.name];switch(a.type){case"group":const t="horizontal"===a.layout,n=t?`flex gap-3 w-full ${a.className||""}`:"space-y-3",i=t?Pe("space-y-2 w-full",a.wrapperClassName):Pe("space-y-2",a.className,a.wrapperClassName);return e.jsxs("div",{className:i,children:[a.label,e.jsx("div",{className:n,children:a.fields?.map(e=>P(e))})]},a.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s||"",onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(da,{value:String(s),onValueChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e.jsx(ma,{className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ua,{placeholder:a.placeholder})}),e.jsx(xa,{children:a.options?.map(a=>e.jsx(ga,{value:a.value,children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ua,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"date":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"date",value:String(s),onChange:e=>N(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Pe("w-full",r?"border-destructive":"",a.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>N(a.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Gs,{value:s||a.defaultValue||"#3b82f6",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{value:s||a.defaultValue||"Star",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"custom":if(!a.component)return null;const o=a.component,l="function"==typeof a.componentProps?a.componentProps(y):a.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(o,{value:s,onChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:r,popoverContainer:x,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"number":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,s=""===t?null:Number(t);N(a.name,s)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e.jsx(va,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),e.jsxs(Re,{htmlFor:a.name,className:"cursor-pointer",children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ys,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},a.name);default:return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"text",value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},T=a.useCallback(()=>{if(!S)return null;if(S.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("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(S.component){const a=S.component;return e.jsx(a,{formData:y,updateField:N,errors:j,users:c,disabled:S.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:S.fields.map(P)})},[S,y,N,j,c,P]),I=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[C.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:C.map(a=>e.jsx(_e,{variant:k===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=C.find(a=>a.id===e);a&&!a.disabled&&p(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:u("loading")})}):e.jsxs("form",{onSubmit:w(n),className:"space-y-3 md:space-y-4",children:[T(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(_e,{type:"button",variant:"outline",onClick:i,children:u("cancel")}),e.jsx(_e,{type:"submit",disabled:d,children:l||u("save")})]})]})})]});return e.jsx($e,{open:o,onOpenChange:e=>{!1===e&&!0===o&&i()},children:e.jsxs(Qe,{ref:b,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Ke,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e.jsx(Ye,{children:t}),e.jsx(Ze,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),I]})})}function tr({currentPage:a,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:i,variant:o="full"}){const l=(a-1)*r+1,c=Math.min(a*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),e.jsxs(da,{value:String(r),onValueChange:e=>i(Number(e)),children:[e.jsx(ma,{className:"h-8 w-[70px]",children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"10",children:"10"}),e.jsx(ga,{value:"25",children:"25"}),e.jsx(ga,{value:"50",children:"50"}),e.jsx(ga,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[l,"-",c," de ",s," itens"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsLeft,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a-1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:a}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:t})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a+1),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronRight,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsRight,{size:16})})]})]})}function sr({manager:a}){return e.jsx(tr,{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 rr=({selectedCount:a,onClearSelection:t,onBulkDelete:s,customActions:r=[],isLoading:n=!1})=>{const{t:i}=g.useTranslation();return e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:i("selected_count",{count:a})}),e.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[e.jsx(d.X,{size:14,className:"mr-1"}),i("clear")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:n,className:"h-7",children:[s&&e.jsx(s,{size:14,className:"mr-1"}),a.label]},t)}),s&&e.jsxs(_e,{variant:"destructive",size:"sm",onClick:s,disabled:n,className:"h-7",children:[e.jsx(d.Trash2,{size:14,className:"mr-1"}),i("delete")]})]})]})},nr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ir={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},or={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function lr({children:a,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:i=!1,className:o}){return e.jsx("div",{className:Pe("flex","column"===t?"flex-col":"flex-row",nr[s],ir[r],or[n],i&&"flex-wrap",o),children:a})}function dr({manager:a,filters:t,inline:s=!1}){const{t:r}=g.useTranslation(),{isSearchVisible:n}=$t(),i=a.searchTerm,o=e.jsxs(e.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ee,{placeholder:r("search"),value:a.searchTerm,onChange:e=>a.handleSearch(e.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((a,t)=>e.jsxs("select",{value:a.value||"",onChange:e=>a.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:[a.placeholder&&e.jsx("option",{value:"",children:a.placeholder}),a.options.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...a.props})},`custom-${t}`)}),i&&e.jsxs(_e,{variant:"outline",onClick:a.clearFilters,className:"whitespace-nowrap",children:[e.jsx(d.X,{className:"h-4 w-4 mr-2"}),r("clear")]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(lr,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(lr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function cr({manager:t,config:s,formSections:r,onSave:n,onToggleStatus:i,defaultSort:o}){t&&t.queryKey;const{t:l}=g.useTranslation(),{setSearchVisible:c}=$t(),[u,m]=y.useSearchParams(),[p,h]=a.useState(!1),[x,f]=a.useState(null),[b,v]=a.useState({isOpen:!1,entityId:null,entityName:""}),[j,N]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(o&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=o.column,t[a]=o.direction,m(t)}}},[]);const w=()=>{v({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[s.enableBulkActions&&t.selectedIds.length>0&&e.jsx(rr,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:s.bulkActions&&s.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:t.selectedIds.length})},customActions:s.bulkActions,isLoading:t.isBulkDeleting}),e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_e,{onClick:()=>{s.onNew?s.onNew():(f(null),h(!0))},children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),l("new")]}),s.customActions?.map((a,t)=>e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e.jsx(a.icon,{size:16,className:"mr-2"}),a.label]},t))]}),s.filters&&s.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(dr,{manager:t,filters:s.filters,inline:!0})})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(t.entities,t)}):e.jsx(Ws,{manager:t,columns:s.columns,onEdit:e=>{s.onEdit?s.onEdit(e):(f(e),h(!0))},onDelete:e=>{v({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(sr,{manager:t})}),!s.useCustomRouting&&e.jsx(ar,{open:p,title:x?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:x||void 0,onSubmit:e=>{n(e),h(!1),f(null)},onCancel:()=>{h(!1),f(null)},isLoading:t.isLoading,submitButtonText:l(x?"update":"create")}),e.jsx($e,{open:b.isOpen,onOpenChange:w,children:e.jsxs(Qe,{size:"sm",children:[e.jsx(Ke,{showSeparator:!0,children:e.jsx(Ye,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:b.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Je,{children:[e.jsx(_e,{variant:"outline",onClick:w,children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{b.entityId&&(t.deleteEntity(b.entityId),v({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx($e,{open:j.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),children:e.jsxs(Qe,{size:"sm",children:[e.jsx(Ke,{showSeparator:!0,children:e.jsx(Ye,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:j.count})," ",1===j.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Je,{children:[e.jsx(_e,{variant:"outline",onClick:()=>N({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),N({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function ur(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 mr(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const pr=Z.forwardRef(({className:a,value:t,...s},r)=>e.jsx(ue.Root,{ref:r,className:Pe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...s,children:e.jsx(ue.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));function hr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Pe("flex items-center justify-between mb-6",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:Pe("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",t.isActive&&"border-primary bg-primary text-primary-foreground",t.isCompleted&&"border-primary bg-primary text-primary-foreground",!t.isActive&&!t.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!t.isDisabled&&"cursor-pointer hover:border-primary/50",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:t.isCompleted?e.jsx(d.Check,{className:"w-5 h-5"}):r+1}),r<a.length-1&&e.jsx("div",{className:Pe("flex-1 h-0.5 mx-2 transition-colors",t.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},t.id))})}function xr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Pe("flex items-center gap-2 mb-6 overflow-x-auto",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsxs("div",{className:Pe("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",t.isActive&&"bg-primary text-primary-foreground font-medium",t.isCompleted&&"bg-primary/10 text-primary",!t.isActive&&!t.isCompleted&&"bg-muted text-muted-foreground",s&&!t.isDisabled&&"cursor-pointer hover:bg-primary/20",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:[e.jsx("span",{className:"text-sm font-medium",children:r+1}),e.jsx("span",{className:"text-sm",children:t.label}),t.isCompleted&&e.jsx(d.Check,{className:"w-4 h-4 ml-1"})]}),r<a.length-1&&e.jsx("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},t.id))})}function fr({steps:a,currentStepIndex:t,className:s}){const r=a[t],n=(t+1)/a.length*100;return e.jsxs("div",{className:Pe("mb-6 space-y-2",s),children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Etapa ",t+1," de ",a.length]}),e.jsx("span",{className:"font-medium",children:r?.label})]}),e.jsx(pr,{value:n,className:"h-2"})]})}function gr({isFirstStep:a,isLastStep:t,canGoNext:s,canGoPrevious:r,isLoading:n,onPrevious:i,onNext:o,onSubmit:l,previousButtonText:d,nextButtonText:c,submitButtonText:u}){const{t:m}=g.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:r&&!a&&e.jsx(_e,{type:"button",variant:"outline",onClick:i,disabled:n,children:d||m("previous")})}),e.jsxs("div",{className:"flex gap-2",children:[s&&!t&&e.jsx(_e,{type:"button",onClick:o,disabled:n,children:c||m("next")}),t&&e.jsx(_e,{type:"button",onClick:l,disabled:n,children:n?m("saving"):u||m("save")})]})]})}pr.displayName=ue.Root.displayName;const br=s.cva("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"}}),vr={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},yr=Z.forwardRef(({className:a,variant:t="info",showIcon:s=!0,children:r,...n},i)=>{const o=vr[t||"info"];return e.jsxs("div",{ref:i,role:"alert",className:Pe(br({variant:t}),a),...n,children:[s&&e.jsx(o,{className:"h-4 w-4"}),r]})});yr.displayName="Alert";const jr=Z.forwardRef(({className:a,...t},s)=>e.jsx("h5",{ref:s,className:Pe("mb-1 font-medium leading-none tracking-tight",a),...t}));jr.displayName="AlertTitle";const Nr=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-sm [&_p]:leading-relaxed",a),...t}));Nr.displayName="AlertDescription";const wr=a.createContext(void 0);function Cr({children:t,actions:s}){const[r,n]=a.useState({}),[i,o]=a.useState(s);return a.useEffect(()=>{o(s)},[s]),e.jsx(wr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:i,setHeaderActions:o},children:t})}function kr(){const e=a.useContext(wr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const Sr=(void 0).VITE_SUPABASE_URL,Pr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Tr=null;var Ir=Object.defineProperty,_r=(e,a,t)=>((e,a,t)=>a in e?Ir(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Ar=new class{constructor(){_r(this,"cache",{}),_r(this,"cacheTimestamps",new Map),_r(this,"CACHE_TTL",3e5),_r(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=(!Tr&&Sr&&Pr&&(Tr=b.createClient(Sr,Pr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Tr),{data:t,error:s}=await a.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(s)return"42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied")||s.message?.includes("No suitable key"),{};const r={};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&&(r[a.key]=t)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(a){return{}}}async upsertTranslation(e,a,t,s){const r=it(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=it(),{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 Er=Object.defineProperty,Mr=(e,a,t)=>((e,a,t)=>a in e?Er(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Rr="true"===(void 0).VITE_I18N_DEBUG_MODE;o.use(new class{constructor(e=!1){Mr(this,"type","backend"),Mr(this,"isDebugMode"),Mr(this,"cache",new Map),Mr(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 s=Ar.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,s),s.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,s){}}(Rr)).use(g.initReactI18next).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Rr?`[${e} ❌]`:`[⚠️ ${e}]`});const Dr=new class{async getUserPreferences(e,a){if(!Xa.areAllTokensValid())return null;const t=it();try{const{data:s,error:r}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(r)return"PGRST116"===r.code?this.createDefaultPreferences(e,a):("42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied"),null);if(!s)return this.createDefaultPreferences(e,a);const n=s;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(s){return null}}async createDefaultPreferences(e,a){const t=it(),s={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(s).select().single();if(a)throw a;const r=e;return{locale:r.locale,timezone:r.timezone,datetimeFormat:r.datetime_format}}catch(r){throw r}}async updatePreferences(e,a,t){const s=it();try{const{error:r}=await s.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(r)throw r}catch(r){throw r}}},Fr=a.createContext(void 0),zr=({children:t})=>{const{user:s,alias:r}=$t(),[n,i]=a.useState({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[l,d]=a.useState(!0);a.useEffect(()=>{(async()=>{if(s?.id&&r)try{const e=await Dr.getUserPreferences(s.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await o.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{d(!1)}else d(!1)})()},[s?.id,r]);const c=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{locale:e}),i(a=>({...a,locale:e})),await o.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[s?.id,r]),u=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[s?.id,r]),m=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[s?.id,r]);return e.jsx(Fr.Provider,{value:{...n,setLocale:c,setTimezone:u,setDatetimeFormat:m,isLoading:l},children:t})},Lr=()=>{const e=a.useContext(Fr);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Or({children:t}){const{ready:s}=g.useTranslation(),[r,n]=a.useState(!0);return a.useEffect(()=>{s&&r&&n(!1)},[s,r]),r&&!s?e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(Ca,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:t})}const Ur=me.Root,qr=me.CollapsibleTrigger,$r=me.CollapsibleContent;var Br=Object.defineProperty,Wr=(e,a,t)=>((e,a,t)=>a in e?Br(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class Vr extends a.Component{constructor(e){super(e),Wr(this,"copyErrorDetails",()=>{const e=Za.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),l.toast.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((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if((void 0).DEV)throw e;Za.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Za.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(De,{className:"w-full max-w-2xl",children:[e.jsxs(Fe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(ze,{children:"Algo deu errado"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),e.jsxs(Ur,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(qr,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs($r,{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e.jsx(Qs,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:a.map((a,t)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(a.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),e.jsxs(_e,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(_e,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Hr=pe.Root,Gr=Z.forwardRef(({className:a,...t},s)=>e.jsx(pe.Item,{ref:s,className:Pe("border-b",a),...t}));Gr.displayName="AccordionItem";const Qr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Header,{className:"flex",children:e.jsxs(pe.Trigger,{ref:r,className:Pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[t,e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Qr.displayName=pe.Trigger.displayName;const Kr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e.jsx("div",{className:Pe("pb-4 pt-0",a),children:t})}));Kr.displayName=pe.Content.displayName;const Xr=he.Root,Jr=he.Trigger,Yr=he.Portal,Zr=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Overlay,{className:Pe("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:s}));Zr.displayName=he.Overlay.displayName;const en=Z.forwardRef(({className:a,...t},s)=>e.jsxs(Yr,{children:[e.jsx(Zr,{}),e.jsx(he.Content,{ref:s,className:Pe("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",a),...t})]}));en.displayName=he.Content.displayName;const an=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",a),...t});an.displayName="AlertDialogHeader";const tn=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});tn.displayName="AlertDialogFooter";const sn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Title,{ref:s,className:Pe("text-lg font-semibold",a),...t}));sn.displayName=he.Title.displayName;const rn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));rn.displayName=he.Description.displayName;const nn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Action,{ref:s,className:Pe(Ie(),a),...t}));nn.displayName=he.Action.displayName;const on=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Cancel,{ref:s,className:Pe(Ie({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));on.displayName=he.Cancel.displayName;const ln=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Root,{ref:s,className:Pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));ln.displayName=xe.Root.displayName;const dn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Image,{ref:s,className:Pe("aspect-square h-full w-full",a),...t}));dn.displayName=xe.Image.displayName;const cn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Fallback,{ref:s,className:Pe("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));cn.displayName=xe.Fallback.displayName;const un=Z.forwardRef(({...a},t)=>e.jsx("nav",{ref:t,"aria-label":"breadcrumb",...a}));un.displayName="Breadcrumb";const mn=Z.forwardRef(({className:a,...t},s)=>e.jsx("ol",{ref:s,className:Pe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));mn.displayName="BreadcrumbList";const pn=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("inline-flex items-center gap-1.5",a),...t}));pn.displayName="BreadcrumbItem";const hn=Z.forwardRef(({asChild:a,className:s,...r},n)=>{const i=a?t.Slot:"a";return e.jsx(i,{ref:n,className:Pe("transition-colors hover:text-foreground",s),...r})});hn.displayName="BreadcrumbLink";const xn=Z.forwardRef(({className:a,...t},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Pe("font-normal text-foreground",a),...t}));xn.displayName="BreadcrumbPage";const fn=({children:a,className:t,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pe("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:a??e.jsx(d.ChevronRight,{})});fn.displayName="BreadcrumbSeparator";const gn=({className:a,...t})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});gn.displayName="BreadcrumbEllipsis";const bn=s.cva("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"}}),vn=Z.forwardRef(({className:a,orientation:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(bn({orientation:t}),a),...s}));function yn(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function jn(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Nn(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.match(r);if(!n)return null;const i=n[0],o=s&&e.parsePatterns[s]||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 wn(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[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(r.length)}}}vn.displayName="ButtonGroup";const Cn={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"}},kn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Sn={ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:jn({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Pn={ordinalNumber:wn({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},Tn={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Cn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:{date:yn({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:yn({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:yn({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,s)=>kn[e],localize:Sn,match:Pn,options:{weekStartsOn:0,firstWeekContainsDate:1}},In={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"}},_n={date:yn({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:yn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:yn({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},An={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"},En={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"},Mn={ordinalNumber:(e,a)=>Number(e)+"º",era:jn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Rn={ordinalNumber:wn({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},Dn={code:"es",formatDistance:(e,a,t)=>{let s;const r=In[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:_n,formatRelative:(e,a,t,s)=>1!==a.getHours()?En[e]:An[e],localize:Mn,match:Rn,options:{weekStartsOn:1,firstWeekContainsDate:1}},Fn={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"}},zn={date:yn({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:yn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:yn({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ln={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"},On={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:jn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Un={ordinalNumber:wn({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},qn={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Fn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:zn,formatRelative:(e,a,t,s)=>{const r=Ln[e];return"function"==typeof r?r(a):r},localize:On,match:Un,options:{weekStartsOn:0,firstWeekContainsDate:1}};function $n({className:a,classNames:t,showOutsideDays:s=!0,...r}){return e.jsx(A.DayPicker,{showOutsideDays:s,className:Pe("p-3 pointer-events-auto",a),locale:qn,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:Pe(Ie({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:Pe(Ie({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})=>"left"===a?e.jsx(d.ChevronLeft,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}$n.displayName="Calendar";const Bn={Root:function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:s}){return e.jsx(De,{className:Pe("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:e.jsx(Oe,{className:"p-4",children:a})})},Field:function({label:a,value:t,className:s}){return e.jsxs("div",{className:Pe("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e.jsx("span",{className:"text-foreground",children:t})]})}};const Wn=({shouldScaleBackground:a=!0,...t})=>e.jsx(E.Drawer.Root,{shouldScaleBackground:a,...t});Wn.displayName="Drawer";const Vn=E.Drawer.Trigger,Hn=E.Drawer.Portal,Gn=E.Drawer.Close,Qn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Overlay,{ref:s,className:Pe("fixed inset-0 z-50 bg-black/80",a),...t}));Qn.displayName=E.Drawer.Overlay.displayName;const Kn=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Hn,{children:[e.jsx(Qn,{}),e.jsxs(E.Drawer.Content,{ref:r,className:Pe("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",a),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));Kn.displayName="DrawerContent";const Xn=({className:a,...t})=>e.jsx("div",{className:Pe("grid gap-1.5 p-4 text-center sm:text-left",a),...t});Xn.displayName="DrawerHeader";const Jn=({className:a,...t})=>e.jsx("div",{className:Pe("mt-auto flex flex-col gap-2 p-4",a),...t});Jn.displayName="DrawerFooter";const Yn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Yn.displayName=E.Drawer.Title.displayName;const Zn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Zn.displayName=E.Drawer.Description.displayName;const ei={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))]"},ai={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const ti=fe.Root,si=fe.Trigger,ri=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,...r},n)=>e.jsx(fe.Content,{ref:n,align:t,sideOffset:s,className:Pe("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),...r}));ri.displayName=fe.Content.displayName;const ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Pe("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}));ni.displayName="InputGroup";const ii=s.cva("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"}}),oi=Z.forwardRef(({className:a,align:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Pe(ii({align:t}),a),...s}));oi.displayName="InputGroupAddon";const li=s.cva("",{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"}}),di=Z.forwardRef(({className:a,size:t,variant:s="ghost",...r},n)=>e.jsx(_e,{ref:n,"data-slot":"input-group-button",variant:s,className:Pe(li({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...r}));di.displayName="InputGroupButton";const ci=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ee,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ci.displayName="InputGroupInput";const ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(ya,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ui.displayName="InputGroupTextarea";const mi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h1",{ref:s,className:Pe("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));mi.displayName="H1";const pi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h2",{ref:s,className:Pe("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));pi.displayName="H2";const hi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));hi.displayName="H3";const xi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h4",{ref:s,className:Pe("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));xi.displayName="H4";const fi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("leading-7 [&:not(:first-child)]:mt-6",a),...t}));fi.displayName="P";const gi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-xl text-muted-foreground",a),...t}));gi.displayName="Lead";const bi=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-lg font-semibold",a),...t}));bi.displayName="Large";const vi=Z.forwardRef(({className:a,...t},s)=>e.jsx("small",{ref:s,className:Pe("text-sm font-medium leading-none",a),...t}));vi.displayName="Small";const yi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));yi.displayName="Muted";const ji=Z.forwardRef(({className:a,...t},s)=>e.jsx("code",{ref:s,className:Pe("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));ji.displayName="InlineCode";const Ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("blockquote",{ref:s,className:Pe("mt-6 border-l-2 pl-6 italic",a),...t}));Ni.displayName="Blockquote";const wi=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));wi.displayName="List";const Ci=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Root,{ref:r,className:Pe("relative z-10 flex max-w-max flex-1 items-center justify-center",a),...s,children:[t,e.jsx(Ai,{})]}));Ci.displayName=ge.Root.displayName;const ki=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.List,{ref:s,className:Pe("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));ki.displayName=ge.List.displayName;const Si=ge.Item,Pi=s.cva("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"),Ti=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Trigger,{ref:r,className:Pe(Pi(),"group",a),...s,children:[t," ",e.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Ti.displayName=ge.Trigger.displayName;const Ii=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Content,{ref:s,className:Pe("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}));Ii.displayName=ge.Content.displayName;const _i=ge.Link,Ai=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:Pe("absolute left-0 top-full flex justify-center"),children:e.jsx(ge.Viewport,{className:Pe("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:s,...t})}));Ai.displayName=ge.Viewport.displayName;const Ei=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Indicator,{ref:s,className:Pe("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.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ei.displayName=ge.Indicator.displayName;const Mi=({className:a,...t})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Pe("mx-auto flex w-full justify-center",a),...t});Mi.displayName="Pagination";const Ri=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("flex flex-row items-center gap-1",a),...t}));Ri.displayName="PaginationContent";const Di=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("",a),...t}));Di.displayName="PaginationItem";const Fi=({className:a,isActive:t,size:s="icon",...r})=>e.jsx("a",{"aria-current":t?"page":void 0,className:Pe(Ie({variant:t?"outline":"ghost",size:s}),a),...r});Fi.displayName="PaginationLink";const zi=({className:a,...t})=>e.jsxs(Fi,{"aria-label":"Go to previous page",size:"default",className:Pe("gap-1 pl-2.5",a),...t,children:[e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});zi.displayName="PaginationPrevious";const Li=({className:a,...t})=>e.jsxs(Fi,{"aria-label":"Go to next page",size:"default",className:Pe("gap-1 pr-2.5",a),...t,children:[e.jsx("span",{children:"Next"}),e.jsx(d.ChevronRight,{className:"h-4 w-4"})]});Li.displayName="PaginationNext";const Oi=({className:a,...t})=>e.jsxs("span",{"aria-hidden":!0,className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Oi.displayName="PaginationEllipsis";const Ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Root,{className:Pe("grid gap-2",a),...t,ref:s}));Ui.displayName=be.Root.displayName;const qi=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Item,{ref:s,className:Pe("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.jsx(be.Indicator,{className:"flex items-center justify-center",children:e.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));qi.displayName=be.Item.displayName;const $i=ve.Panel,Bi=ae.Root,Wi=ae.Trigger,Vi=ae.Close,Hi=ae.Portal,Gi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{className:Pe("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:s}));Gi.displayName=ae.Overlay.displayName;const Qi=s.cva("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"}}),Ki=Z.forwardRef(({side:a="right",className:t,children:s,...r},n)=>e.jsxs(Hi,{children:[e.jsx(Gi,{}),e.jsxs(ae.Content,{ref:n,className:Pe(Qi({side:a}),t),...r,children:[s,e.jsxs(ae.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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ki.displayName=ae.Content.displayName;const Xi=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(qe,{className:"mt-2"})]});Xi.displayName="SheetHeader";const Ji=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Ji.displayName="SheetBody";const Yi=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(qe,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Yi.displayName="SheetFooter";const Zi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Pe("text-lg font-semibold text-foreground",a),...t}));Zi.displayName=ae.Title.displayName;const eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));eo.displayName=ae.Description.displayName;const ao="sidebar:state",to=Z.createContext(null);function so(){const e=Z.useContext(to);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const ro=Z.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=Z.useState(!1);Z.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=Z.useState(!1),[p,h]=Z.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(ao);return null!==e?"true"===e:a}return a}),x=t??p,f=Z.useCallback(e=>{const a="function"==typeof e?e(x):e;s?s(a):h(a),"undefined"!=typeof window&&localStorage.setItem(ao,String(a))},[s,x]),g=Z.useCallback(()=>d?m(e=>!e):f(e=>!e),[d,f,m]);Z.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);const b=x?"expanded":"collapsed",v=Z.useMemo(()=>({state:b,open:x,setOpen:f,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,x,f,d,u,m,g]);return e.jsx(to.Provider,{value:v,children:e.jsx(ts,{delayDuration:0,children:e.jsx("div",{className:Pe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...n},ref:l,...o,children:i})})})});ro.displayName="SidebarProvider";const no=Z.forwardRef(({side:a="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...i},o)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=so();return"none"===s?e.jsx("div",{className:Pe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:o,...i,children:n}):l?e.jsx(Bi,{open:c,onOpenChange:u,...i,children:e.jsxs(Ki,{"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:a,children:[e.jsx(Zi,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":a,children:[e.jsx("div",{className:Pe("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"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Pe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===a?"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"===t||"inset"===t?"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",r),...i,children:e.jsx("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:n})})]})});no.displayName="Sidebar";const io=Z.forwardRef(({className:a,onClick:t,...s},r)=>{const{toggleSidebar:n}=so();return e.jsxs(_e,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Pe("h-7 w-7",a),onClick:e=>{t?.(e),n()},...s,children:[e.jsx(d.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});io.displayName="SidebarTrigger";const oo=Z.forwardRef(({className:a,...t},s)=>{const{toggleSidebar:r}=so();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Pe("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})});oo.displayName="SidebarRail";const lo=Z.forwardRef(({className:a,...t},s)=>e.jsx("main",{ref:s,className:Pe("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}));lo.displayName="SidebarInset";const co=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ee,{ref:s,"data-sidebar":"input",className:Pe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));co.displayName="SidebarInput";const uo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Pe("flex flex-col gap-2 p-2",a),...t}));uo.displayName="SidebarHeader";const mo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Pe("flex flex-col gap-2 p-2",a),...t}));mo.displayName="SidebarFooter";const po=Z.forwardRef(({className:a,...t},s)=>e.jsx(qe,{ref:s,"data-sidebar":"separator",className:Pe("mx-2 w-auto bg-sidebar-border",a),...t}));po.displayName="SidebarSeparator";const ho=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Pe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));ho.displayName="SidebarContent";const xo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Pe("relative flex w-full min-w-0 flex-col p-2",a),...t}));xo.displayName="SidebarGroup";const fo=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"div";return e.jsx(i,{ref:n,"data-sidebar":"group-label",className:Pe("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})});fo.displayName="SidebarGroupLabel";const go=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"button";return e.jsx(i,{ref:n,"data-sidebar":"group-action",className:Pe("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})});go.displayName="SidebarGroupAction";const bo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Pe("w-full text-sm",a),...t}));bo.displayName="SidebarGroupContent";const vo=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Pe("flex w-full min-w-0 flex-col gap-1",a),...t}));vo.displayName="SidebarMenu";const yo=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Pe("group/menu-item relative",a),...t}));yo.displayName="SidebarMenuItem";const jo=s.cva("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"}}),No=Z.forwardRef(({asChild:a=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?t.Slot:"button",{isMobile:u,state:m}=so(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Pe(jo({variant:r,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:p}),e.jsx(ns,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):p});No.displayName="SidebarMenuButton";const wo=Z.forwardRef(({className:a,asChild:s=!1,showOnHover:r=!1,...n},i)=>{const o=s?t.Slot:"button";return e.jsx(o,{ref:i,"data-sidebar":"menu-action",className:Pe("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),...n})});wo.displayName="SidebarMenuAction";const Co=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Pe("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}));Co.displayName="SidebarMenuBadge";const ko=Z.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=Z.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Pe("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});ko.displayName="SidebarMenuSkeleton";const So=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Pe("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}));So.displayName="SidebarMenuSub";const Po=Z.forwardRef(({...a},t)=>e.jsx("li",{ref:t,...a}));Po.displayName="SidebarMenuSubItem";const To=Z.forwardRef(({asChild:a=!1,size:s="md",isActive:r,className:n,...i},o)=>{const l=a?t.Slot:"a";return e.jsx(l,{ref:o,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Pe("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"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...i})});To.displayName="SidebarMenuSubButton";const Io=Z.forwardRef(({className:a,value:t,defaultValue:s,...r},n)=>{const i=t||s||[0];return e.jsxs(ye.Root,{ref:n,value:t,defaultValue:s,className:Pe("relative flex w-full touch-none select-none items-center",a),...r,children:[e.jsx(ye.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ye.Range,{className:"absolute h-full bg-primary"})}),i.map((a,t)=>e.jsx(ye.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))]})});Io.displayName=ye.Root.displayName;const _o=je.Root,Ao=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.List,{ref:s,className:Pe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));Ao.displayName=je.List.displayName;const Eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.Trigger,{ref:s,className:Pe("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}));Eo.displayName=je.Trigger.displayName;const Mo=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.Content,{ref:s,className:Pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));Mo.displayName=je.Content.displayName;const Ro=s.cva("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"}}),Do=Z.forwardRef(({className:a,variant:t,size:s,...r},n)=>e.jsx(Ne.Root,{ref:n,className:Pe(Ro({variant:t,size:s,className:a})),...r}));Do.displayName=Ne.Root.displayName;const Fo=Z.createContext({size:"default",variant:"default"}),zo=Z.forwardRef(({className:a,variant:t,size:s,children:r,...n},i)=>e.jsx(we.Root,{ref:i,className:Pe("flex items-center justify-center gap-1",a),...n,children:e.jsx(Fo.Provider,{value:{variant:t,size:s},children:r})}));zo.displayName=we.Root.displayName;const Lo=Z.forwardRef(({className:a,children:t,variant:s,size:r,...n},i)=>{const o=Z.useContext(Fo);return e.jsx(we.Item,{ref:i,className:Pe(Ro({variant:o.variant||s,size:o.size||r}),a),...n,children:t})});Lo.displayName=we.Item.displayName;const Oo=Ce.Menu,Uo=Ce.Group,qo=Ce.Portal,$o=Ce.Sub,Bo=Ce.RadioGroup,Wo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Root,{ref:s,className:Pe("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));Wo.displayName=Ce.Root.displayName;const Vo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Trigger,{ref:s,className:Pe("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}));Vo.displayName=Ce.Trigger.displayName;const Ho=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ho.displayName=Ce.SubTrigger.displayName;const Go=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.SubContent,{ref:s,className:Pe("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}));Go.displayName=Ce.SubContent.displayName;const Qo=Z.forwardRef(({className:a,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},i)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:i,align:t,alignOffset:s,sideOffset:r,className:Pe("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})}));Qo.displayName=Ce.Content.displayName;const Ko=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Pe("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),...s}));Ko.displayName=Ce.Item.displayName;const Xo=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Pe("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",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));Xo.displayName=Ce.CheckboxItem.displayName;const Jo=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Jo.displayName=Ce.RadioItem.displayName;const Yo=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));Yo.displayName=Ce.Label.displayName;const Zo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));Zo.displayName=Ce.Separator.displayName;const el=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});el.displayname="MenubarShortcut";const al={light:"",dark:".dark"},tl=Z.createContext(null);function sl(){const e=Z.useContext(tl);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const rl=Z.forwardRef(({id:a,className:t,children:s,config:r,...n},i)=>{const o=Z.useId(),l=`chart-${a||o.replace(/:/g,"")}`;return e.jsx(tl.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:i,className:Pe("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",t),...n,children:[e.jsx(nl,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});rl.displayName="Chart";const nl=({id:a,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(al).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${s.map(([a,t])=>{const s=t.theme?.[e]||t.color;return s?` --color-${a}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},il=ke.Tooltip,ol=Z.forwardRef(({active:a,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=sl(),f=Z.useMemo(()=>{if(n||!t?.length)return null;const[a]=t,s=cl(x,a,`${p||a?.dataKey||a?.name||"value"}`),r=p||"string"!=typeof o?s?.label:x[o]?.label||o;return l?e.jsx("div",{className:Pe("font-medium",d),children:l(r,t)}):r?e.jsx("div",{className:Pe("font-medium",d),children:r}):null},[o,l,t,n,d,x,p]);if(!a||!t?.length)return null;const g=1===t.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Pe("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",s),children:[g?null:f,e.jsx("div",{className:"grid gap-1.5",children:t.map((a,t)=>{const s=`${m||a.name||a.dataKey||"value"}`,n=cl(x,a,s),o=u||a.payload?.fill||a.color;return e.jsx("div",{className:Pe("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==a?.value&&a.name?c(a.value,a.name,a,t,a.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!i&&e.jsx("div",{className:Pe("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":o,"--color-border":o}}),e.jsxs("div",{className:Pe("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||a.name})]}),void 0!==a.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof a.value?a.value.toLocaleString():a.value})]})]})},a.dataKey||t)})})]})});ol.displayName="ChartTooltip";const ll=ke.Legend,dl=Z.forwardRef(({className:a,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},i)=>{const{config:o}=sl();return s?.length?e.jsx("div",{ref:i,className:Pe("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",a),children:s.map(a=>{const s=`${n||a.dataKey||"value"}`,r=cl(o,a,s);return e.jsxs("div",{className:Pe("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:a.color}}),r?.label]},a.value)})}):null});function cl(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}dl.displayName="ChartLegend";const ul=({onClick:a,isActive:t,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:a,disabled:s,title:n,className:Pe("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),ml=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function pl({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:i=!0,customActions:o=[],renderAs:l="dropdown",variant:c="default"}){const{t:u}=g.useTranslation(),m=[];return a&&n&&m.push({icon:d.Edit,label:u("edit"),onClick:a,variant:"default"}),s&&m.push({icon:r?d.PowerOff:d.Power,label:u(r?"deactivate":"activate"),onClick:s,variant:"default"}),o.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),t&&i&&m.push({icon:d.Trash2,label:u("remove"),onClick:t,variant:"destructive"}),0===m.length?null:"dropdown"===l?e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e.jsx(d.EllipsisVertical,{size:"compact"===c?14:16})})}),e.jsx(fs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,t)=>e.jsxs(gs,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},t))})]}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((a,t)=>e.jsxs(_e,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:a.onClick,className:"compact"===c?"h-7 px-2":"",children:[a.icon&&e.jsx(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:a.label})]},t))})}function hl(e){const a=y.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const xl=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],fl=[{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"}],gl=[{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"}],bl=()=>{const{locale:a,datetimeFormat:t,timezone:s,setLocale:r,setDatetimeFormat:n,setTimezone:i}=Lr(),{t:o}=g.useTranslation();return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Globe,{className:"h-4 w-4"}),o("language")]}),e.jsxs(da,{value:a,onValueChange:r,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:xl.map(a=>e.jsxs(ga,{value:a.value,children:[a.flag," ",a.label]},a.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Clock,{className:"h-4 w-4"}),o("timezone")||"Fuso Horário"]}),e.jsxs(da,{value:s,onValueChange:i,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:gl.map(a=>e.jsx(ga,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Calendar,{className:"h-4 w-4"}),o("dateTimeFormat")||"Formato de Data/Hora"]}),e.jsxs(da,{value:t,onValueChange:n,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:fl.map(a=>e.jsx(ga,{value:a.value,children:e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{children:a.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.description," • ",a.example]})]})},a.value))})]})]})]})},vl=a.memo(({variant:t="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:i,companies:o,alias:l,isAuthenticated:c,logout:u,switchUnit:m}=$t(),[p,h]=a.useState(!1),x="true"===(void 0).VITE_SHOW_USER_PREFERENCES,f=o?.[0]||null,g=l?o?.find(e=>e.alias===l):f,b=o||[],v=r||g||f||f,y=a.useCallback(e=>{n?n(e):m(e)},[n,m]),j=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===v?.alias),s=a.filter(e=>e.alias!==v?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[b,v?.alias]);if(!c||!i)return null;const N=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",v?.name||"N/A"]})]})]}),v&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:v.name})]})}),j.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",j.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[j.slice(0,3).map(a=>e.jsx(Na,{variant:a.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>y(a),children:a.name},a.alias)),j.length>3&&e.jsxs(Na,{variant:"outline",className:"text-xs",children:["+",j.length-3]})]})]})]});return"dropdown"===t?e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:i.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(fs,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(ms,{children:[e.jsxs(hs,{children:[e.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(xs,{children:j.map(a=>e.jsxs(gs,{onClick:()=>y(a),className:a.alias===v?.alias?"bg-muted":"",children:[e.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),a.name,a.alias===v?.alias&&e.jsx(Na,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),x&&e.jsx(js,{}),x&&e.jsxs(gs,{onClick:()=>h(!0),children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(gs,{onClick:u,children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Qe,{children:[e.jsx(Ke,{children:e.jsx(Ye,{children:"Preferências de Internacionalização"})}),e.jsx(bl,{})]})})]}):e.jsxs(De,{className:s,children:[e.jsx(Fe,{children:e.jsx(ze,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(N,{}),e.jsx(qe,{}),x&&e.jsxs(_e,{variant:"outline",onClick:()=>h(!0),size:"sm",className:"w-full",children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(_e,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Qe,{children:[e.jsx(Ke,{children:e.jsx(Ye,{children:"Preferências de Internacionalização"})}),e.jsx(bl,{})]})})]})]})}),yl=a.createContext({});function jl({children:t,config:s}){const r=a.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(yl.Provider,{value:r,children:t})}function Nl(){return a.useContext(yl)}function wl(){const e=y.useLocation(),{navigation:a}=Nl(),{t:t}=g.useTranslation();if(!a)return t("page");const s=a.find(a=>a.path===e.pathname);if(s)return s.label;const r=a.find(a=>e.pathname.startsWith(a.path+"/"));return r?.label||t("page")}function Cl(e,t){const[s,r]=a.useState(e),n=a.useRef(),i=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(i(),n.current=setTimeout(()=>{r(e)},t),i),[e,t,i]),[s,i]}const kl=a.memo(function({actions:t}){const s=y.useLocation(),r=wl(),{navigation:n,appName:i}=Nl(),{metadata:o,headerActions:l}=kr(),{t:c}=g.useTranslation(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:x,switchUnit:f}=$t(),b=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[v,j]=y.useSearchParams(),[N,w]=a.useState(()=>v.get("search")||""),[C,k]=Cl(N,vt.debounceDelay);a.useEffect(()=>{if(!p)return;const e=new URLSearchParams(v);C?(e.set("search",C),e.set("page","1")):e.delete("search"),j(e)},[C,j,p]);const S=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),P=o.title||r,T=o.subtitle||S?.complementaryText||c("item_details");return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:P}),e.jsx(Na,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||c("module")})]}),T&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:T})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ee,{placeholder:c("search"),value:N,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e.jsx(_e,{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:()=>{k(),w("");const e=new URLSearchParams(v);e.delete("search"),e.delete("page"),j(e)},title:c("clear_search"),children:e.jsx(d.X,{size:14})})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:x,className:"flex-shrink-0 h-10 w-10 p-0",title:c("refresh_data"),children:e.jsx(d.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(l||t)&&e.jsx("div",{className:"flex items-center gap-2",children:l||t}),(void 0).VITE_WIKI_URL&&e.jsx(_e,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Se((void 0).VITE_WIKI_URL,e),title:c("open_wiki"),children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(vl,{variant:"dropdown",selectedUnit:b,onUnitChange:f})})]})]})})}),Sl=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>v.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Pl=(e={})=>{const{enabled:a=!0}=e,{alias:t}=$t();return v.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=it(),{data:a,error:s}=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(s){if(!ut.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},Tl="forlogic-sidebar-pinned",Il=()=>{try{const e=localStorage.getItem(Tl);return!!e&&JSON.parse(e)}catch{return!1}},_l=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]},Al=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,El={logo:`${Al}/${wt.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Al}/${wt.isQualiex?"small-forlogic.svg":"small.svg"}`},Ml=El.logo,Rl=El.smallLogo;function Dl({appName:a,isPinned:t,onPinToggle:s,open:r,dropdownOpen:n,onDropdownChange:i}){const{t:o}=g.useTranslation(),{data:l,isLoading:c,error:u}=Pl({enabled:n}),m=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(l,e)};return e.jsxs(uo,{className:"p-0 gap-0",children:[e.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center pl-[12px]",children:e.jsx("img",{src:El.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e.jsx("button",{onClick:s,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(t?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e.jsx(d.PanelLeft,{className:"h-4 w-4"})})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:e.jsx("img",{src:El.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(ls,{onOpenChange:i,children:[e.jsx(ds,{asChild:!0,children:r?e.jsxs("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:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("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.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:a})]}),e.jsx(d.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e.jsx("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.jsx(d.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),e.jsx(fs,{className:r?"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:r?"start":"center",children:c?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:o("loading")})]}):u?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o("error")})]}):l&&0!==l.length?e.jsx("div",{className:"space-y-2",children:l.map((a,t)=>e.jsx("div",{onClick:()=>m(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${_l(t)} transition-colors duration-200\n `,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-foreground text-sm",children:a.name}),a.url&&e.jsx(d.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:o("no_results")})})]})})]})}function Fl({config:a,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:i="Criar",triggerIcon:o=d.Plus}=a;if(!n||0===n.length)return null;const l=(a,s,r=!1)=>e.jsxs(e.Fragment,{children:[a,!t&&s&&e.jsx("span",{className:"truncate",children:s}),!t&&r&&e.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const a=n[0],i=a.icon||o,d=s||a.disabled,c=e.jsx(_e,{onClick:a.onClick,disabled:d,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(i,{className:"h-4 w-4 shrink-0"}),a.label)});return t?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:c}),e.jsx(ns,{side:"right",children:e.jsx("p",{children:a.label})})]}):c}const c=e.jsx(_e,{disabled:s,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(o,{className:"h-4 w-4 shrink-0"}),i,!0)});return e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:t?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:c}),e.jsx(ns,{side:"right",children:e.jsx("p",{children:i})})]}):c}),e.jsx(fs,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:n.map(a=>{const t=a.icon;return e.jsxs(gs,{onClick:a.onClick,disabled:a.disabled,className:"cursor-pointer",children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})}function zl({direction:e="right",minWidth:t=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,d]=a.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=a.useState(!1),m=a.useRef(null);a.useEffect(()=>{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 p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!c)return;const a=a=>{let r;r="left"===e?window.innerWidth-a.clientX:a.clientX,r=Math.max(t,Math.min(s,r)),d(r),i?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}},[c,e,t,s,l,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const Ll=a.createContext(void 0);function Ol(){const e=a.useContext(Ll);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Ul({config:t,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=g.useTranslation(),{open:l,setOpen:c}=so(),u=y.useLocation(),{alias:m,user:p}=$t(),{hasOpenModal:h}=Ol(),[x,f]=a.useState(!1),[b,v]=a.useState(Il),[j,N]=a.useState(!1),w=a.useRef(!1),C=r?zl({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{c(!!b||!(!j&&!x))},[b,j,x,c]);return e.jsxs(no,{collapsible:"icon",onMouseEnter:()=>{b||w.current||N(!0)},onMouseLeave:()=>{b||N(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:C&&l?{width:`${C.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(Dl,{appName:t?.appName||o("module_title"),isPinned:b,onPinToggle:()=>{const e=!b;v(e),(e=>{try{localStorage.setItem(Tl,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),c(!1),setTimeout(()=>{w.current=!1},300))},open:l,dropdownOpen:x,onDropdownChange:f}),t?.moduleActions&&t.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx(ts,{children:e.jsx(Fl,{config:t.moduleActions,isCollapsed:!l,isDisabled:h})})}),e.jsx(ho,{children:s||e.jsx(xo,{className:"p-0 mt-6",children:e.jsx(bo,{children:e.jsx(vo,{className:"space-y-2",children:e.jsx(ts,{children:t?.navigation?.map((a,t)=>{const s=({item:a,index:t})=>{const r=`${a.path}-${t}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:i}=Sl({key:r,enabled:Boolean(a.permissionCheck&&m&&p?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),l=a.permissionCheck&&!n;if(l&&"Admin"===a.label)return null;const c=i?d.Loader2:l?d.Lock:a.icon;l?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e.jsx(Ur,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(yo,{children:[e.jsx(qr,{asChild:!0,children:e.jsx(No,{size:"lg",className:"h-10",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label}),e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e.jsx($r,{children:e.jsx(So,{children:a.children.map((a,t)=>e.jsx(s,{item:a,index:t},a.path))})})]})},a.path):e.jsx(yo,{children:l||i?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:e.jsx(No,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-4 w-4 "+(i?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})}),e.jsx(ns,{children:e.jsx("p",{children:o(i?"checking_access":"restricted_access")})})]}):e.jsx(No,{asChild:!0,isActive:(h=a.path,u.pathname===h||u.pathname.startsWith(h+"/")),size:"lg",className:"h-10",children:e.jsxs(y.Link,{to:a.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})},a.path);var h};return e.jsx(s,{item:a,index:t},a.path)})})})})})}),r&&C&&l&&e.jsx("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Pe("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 ql=a.memo(function({children:t,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const i=a.useMemo(()=>s||e.jsx(Ul,{config:r}),[s,r]),o=a.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(jl,{config:r,children:e.jsx(Cr,{children:e.jsx(ro,{defaultOpen:!1,style:o,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[i,e.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(kl,{})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})}),$l={"pt-BR":qn,"en-US":Tn,"es-ES":Dn},Bl=(e,a="pt-BR")=>{if(!e)return"";const t=i.parseISO(e);if(!i.isValid(t))return"Invalid date";const s=$l[a]||qn;return i.format(t,"PP",{locale:s})};class Wl{static async sendEmail(e){const a=it(),{data:t,error:s}=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(s)throw s;return t}}const Vl=Wl;function Hl({open:t,onOpenChange:s,placeId:r,placeName:n,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=g.useTranslation(),[m,p]=a.useState([]),[h,x]=a.useState(!1),[f,b]=a.useState(""),{data:v=[],isLoading:y}=Zs({enabled:t}),j=a.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),N=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},w=1===m.length,C=m.length>0;return e.jsx($e,{open:t,onOpenChange:s,children:e.jsxs(Qe,{className:"max-w-2xl",children:[e.jsx(Ke,{children:e.jsxs(Ye,{className:"flex items-center gap-2",children:[e.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{placeholder:u("search_placeholder"),value:f,onChange:e=>b(e.target.value),className:"pl-9"})]}),e.jsx(Qs,{className:"h-[400px] pr-4",children:y?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e.jsx(za,{className:"h-16 w-full"},t))}):0===j.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:j.map(a=>{const t=a.userId===l,s=c.includes(a.userId||""),r=m.includes(a.userId||"");return e.jsxs("div",{className:Pe("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>N(a.userId||""),children:[e.jsx(va,{checked:r,onCheckedChange:()=>N(a.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:a.userName}),t&&e.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(t||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},a.userId)})})}),e.jsxs(Je,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&e.jsxs("span",{children:[m.length," selecionado(s)"]})}),w&&i&&e.jsxs(_e,{onClick:async()=>{if(i&&1===m.length){x(!0);try{await i(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[e.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&o&&e.jsxs(_e,{onClick:async()=>{if(o&&0!==m.length){x(!0);try{await o(m,r),p([])}finally{x(!1)}}},disabled:h,children:[e.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function Gl({place:t,level:s=0,manageAccessConfig:r}){const[n,i]=a.useState(!1),[o,l]=a.useState(!1),c=t.subPlaces&&t.subPlaces.length>0,u=t.isActive??!0,m=t.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Ur,{open:n,onOpenChange:i,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(qr,{className:"flex items-center gap-2 flex-1",children:[e.jsx(d.ChevronRight,{className:Pe("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:t.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",t.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(Na,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(pl,{customActions:[{label:"Gerenciar Acessos",icon:d.Settings,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx($r,{children:t.subPlaces.map(a=>e.jsx(Gl,{place:a,level:s+1,manageAccessConfig:r},a.id))})]}),0===s&&e.jsx(qe,{}),r&&e.jsx(Hl,{open:o,onOpenChange:l,placeId:t.id,placeName:t.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(t.id),currentMemberIds:r.getCurrentMemberIds?.(t.id)})]})}var Ql=Object.defineProperty,Kl=(e,a,t)=>((e,a,t)=>a in e?Ql(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Xl=new class{constructor(){Kl(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=pt.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Xa.getAccessToken();if(!r)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 ${r}`,"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 s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await pt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return Za.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Za.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Jl(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Yl(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Zl(){const{alias:e,isAuthenticated:a}=$t(),t=Xa.getAccessToken(),{data:s=[]}=Zs({enabled:!0});return v.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=it(),{data:r,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(!r||0===r.length)return[];const i={};s.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=r.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.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:r[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:r.filter(a=>a.id_leader===e).length})}),Jl(o)},enabled:!!t&&!!e&&a&&s.length>0})}function ed(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({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 nd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.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 r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder virtual promovido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao criar líder")}})}function ad(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({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 r=t.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",a).in("id_user",r).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 nd(s,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 s.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{l.toast.error(e.message||"Erro ao adicionar liderados")}})}function td(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,r.id_user,t.id_leader,t.id);const{data:n,error:i}=await s.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]}),l.toast.success("Líder atualizado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao atualizar líder")}})}function sd(){const{alias:e}=$t(),a=v.useQueryClient(),t=it();return v.useMutation({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(s)throw s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success("Líder removido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao remover líder")}})}function rd(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!a)throw new Error("Unidade não selecionada");const n=r.map(e=>e.id_user),i=await Promise.all([s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).eq("id_leader",t),s.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 u=o||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==t),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const y of x)await nd(s,a,e,y.id_user,t,y.id);for(const y of g){if(y.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await nd(s,a,e,y.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(x.length){const r=x.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:t}).in("id",r).eq("alias",a))}if(g.length){const r=g.map(e=>({alias:a,id_user:e.id_user,id_leader:t,is_active:!0,is_removed:!1}));b.push(s.schema(e).from("leaders").insert(r))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{l.toast.error(e.message||"Erro ao sincronizar subordinados")}})}async function nd(e,a,t,s,r,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=r;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===s)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 id({leader:a,expandedIds:t,onToggleExpand:s,onEdit:r}){const n=t.has(a.id),i=a.children.length>0,o=32*a.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${o}px`},children:[i?e.jsx("button",{onClick:()=>s(a.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(d.ChevronDown,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(d.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(a)},className:"font-medium hover:text-primary hover:underline text-left",children:a.name||a.id_user||a.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:a.subordinatesCount||0})})]}),i&&n&&a.children.map(a=>e.jsx(id,{leader:a,expandedIds:t,onToggleExpand:s,onEdit:r},a.id))]})}var od=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!t[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[s.code];t[i]=p.appendErrors(i,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},ld=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,i){try{var o=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&J.validateFieldsNatively({},n),{errors:{},values:t.raw?s: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:J.toNestErrors(od(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const dd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string()).min(1,"Selecione pelo menos um liderado")}),cd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string())});function ud({value:t,onChange:s,excludeUserIds:r=[],error:n}){const{data:i=[],isLoading:o}=Zs(),[l,c]=a.useState(""),u=a.useRef(null),m=a.useRef(0),{t:p}=g.useTranslation(),h=i.filter(e=>!r.includes(e.userId||"")).filter(e=>{const a=l.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const s=t.includes(e.userId),r=t.includes(a.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return a.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[h]),o?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:p("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ee,{placeholder:p("search_user"),value:l,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===h.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:p("search_user")}):e.jsx("div",{className:"space-y-2",children:h.map(a=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(va,{id:a.userId,checked:t.includes(a.userId),onCheckedChange:()=>{return e=a.userId,u.current&&(m.current=u.current.scrollTop),void(t.includes(e)?s(t.filter(a=>a!==e)):s([...t,e]));var e}}),e.jsx(Re,{htmlFor:a.userId,className:"flex-1 cursor-pointer",children:a.userName||a.userEmail})]},a.userId))})}),t.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p("selected_count",{count:t.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function md({leader:t,prefilledLeaderId:s,onSuccess:r}){const{t:n}=g.useTranslation(),{alias:i}=$t(),o=!!t,l=t?.id.startsWith("virtual-"),c=ad(),u=ed(),m=td(),h=rd(),x=sd(),{data:f=[]}=Zl(),{data:b=[]}=Zs(),[v,y]=a.useState(""),j=Yl(f).map(e=>e.id_user),N=o?Yl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user):[],w=p.useForm({resolver:ld(o?cd:dd),defaultValues:{id_leader:s||(o?t?.id_leader:null)||null,id_users:o?N:[]}});a.useEffect(()=>{if(t){const e=Yl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user);w.reset({id_leader:t.id_leader||null,id_users:e})}else s?w.reset({id_leader:s,id_users:[]}):w.reset({id_leader:null,id_users:[]})},[i,t?.id,t?.id_user,t?.id_leader,s,f]);const C=c.isPending||u.isPending||m.isPending||h.isPending||x.isPending,k=w.watch("id_leader"),S=w.watch("id_users"),P=o?[t.id_user,...j.filter(e=>e!==t.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...j.filter(e=>!S.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:w.handleSubmit(async e=>{try{if(o)if(l){await u.mutateAsync({id_user:t.id_user,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{await m.mutateAsync({id:t.id,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:a})}r?.()}catch(a){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Re,{children:n("leader")}),e.jsx(Ee,{value:b.find(e=>e.userId===t.id_user)?.userName||t.name||t.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Re,{children:n("superior")}),e.jsxs(da,{value:k||"none",onValueChange:e=>w.setValue("id_leader","none"===e?null:e),children:[e.jsx(ma,{children:e.jsx(ua,{placeholder:n("select_placeholder")})}),e.jsxs(xa,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ee,{placeholder:n("superior_search"),value:v,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(Qs,{className:"h-[200px]",children:[e.jsx(ga,{value:"none",children:"[Nenhum]"}),b.filter(e=>{const a=o?e.userId!==t.id_user:!S.includes(e.userId),s=!v||e.userName?.toLowerCase().includes(v.toLowerCase());return a&&s}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(a=>e.jsx(ga,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${i}`),w.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:w.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(Re,{children:[n("subordinates")," *"]}),e.jsx(ud,{value:S,onChange:e=>w.setValue("id_users",e),excludeUserIds:P,error:w.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(_e,{type:"submit",disabled:C||!o&&0===S.length,children:C&&!x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n(o?"updating":"saving")]}):o?S.length>0?n("update_success",{count:S.length}):n("update"):n("create_success",{count:S.length})}),o&&!k&&0===S.length&&e.jsx(_e,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(t&&window.confirm(n("remove_confirm")))try{await x.mutateAsync(t.id),r?.()}catch(e){}},className:"ml-auto",children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n("removing")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),n("remove")]})})]})]})}function pd({open:a,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return e.jsx($e,{open:a,onOpenChange:t,children:e.jsxs(Qe,{className:"sm:max-w-[500px]",children:[e.jsx(Ke,{children:e.jsx(Ye,{children:n})}),e.jsx(md,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const hd="leadership-expanded-nodes",xd=(e,a)=>{try{localStorage.setItem(`${hd}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function fd(e){const[t,s]=a.useState(!1),[r,n]=a.useState(0),{t:i}=g.useTranslation(),{uploadFunction:o,deleteFunction:d,defaultOptions:c,onSuccess:u,onError:m}=e||{};return{upload:async(e,a)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0),n(0);try{const t={...c,...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 s=await o(e,t);return n(100),l.toast.success("Sucesso",{description:i("file_upload_success")}),u?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),m?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!d){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await d(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:t,progress:r}}function gd(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 bd(e,a){const t=gd(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function vd(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function yd(e,a){const t=vd(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function jd(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Nd(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function wd(e,a){return e/a}exports.i18n=o,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return g.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return g.useTranslation}}),exports.AUTH_CONFIG=gt,exports.Accordion=Hr,exports.AccordionContent=Kr,exports.AccordionItem=Gr,exports.AccordionTrigger=Qr,exports.ActionButton=Ae,exports.ActionMenu=pl,exports.ActionMenuItems=Ls,exports.Alert=yr,exports.AlertDescription=Nr,exports.AlertDialog=Xr,exports.AlertDialogAction=nn,exports.AlertDialogCancel=on,exports.AlertDialogContent=en,exports.AlertDialogDescription=rn,exports.AlertDialogFooter=tn,exports.AlertDialogHeader=an,exports.AlertDialogOverlay=Zr,exports.AlertDialogPortal=Yr,exports.AlertDialogTitle=sn,exports.AlertDialogTrigger=Jr,exports.AlertTitle=jr,exports.AppHeader=kl,exports.AppLayout=ql,exports.AppSidebar=Ul,exports.AuthErrorInterceptor=ut,exports.AuthProvider=qt,exports.AuthService=Ot,exports.Avatar=ln,exports.AvatarFallback=cn,exports.AvatarImage=dn,exports.Badge=Na,exports.BaseForm=ar,exports.Blockquote=Ni,exports.Breadcrumb=un,exports.BreadcrumbEllipsis=gn,exports.BreadcrumbItem=pn,exports.BreadcrumbLink=hn,exports.BreadcrumbList=mn,exports.BreadcrumbPage=xn,exports.BreadcrumbSeparator=fn,exports.BulkActionBar=rr,exports.Button=_e,exports.ButtonGroup=vn,exports.CRUD_CONFIG=bt,exports.Calendar=$n,exports.CallbackPage=()=>{const{processCallback:t}=$t(),[s,r]=a.useState(null),[n,i]=a.useState(!1);a.useEffect(()=>{(async()=>{try{if(await t()){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 r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const o=async()=>{i(!0),r(null);try{await t()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},l=()=>{window.location.href="/"};return s?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsxs(ze,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(yr,{variant:"danger",children:e.jsx(Nr,{children:s})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_e,{onClick:o,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(_e,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ca,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=De,exports.CardContent=Oe,exports.CardDescription=Le,exports.CardFooter=Ue,exports.CardHeader=Fe,exports.CardSkeleton=Zt,exports.CardTitle=ze,exports.ChartContainer=rl,exports.ChartLegend=ll,exports.ChartLegendContent=dl,exports.ChartStyle=nl,exports.ChartTooltip=il,exports.ChartTooltipContent=ol,exports.Checkbox=va,exports.Collapsible=Ur,exports.CollapsibleContent=$r,exports.CollapsibleTrigger=qr,exports.ColorPicker=Gs,exports.Combobox=Ua,exports.Command=Ia,exports.CommandDialog=({children:a,...t})=>e.jsx("div",{...t,children:e.jsx(Ia,{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})}),exports.CommandEmpty=Ea,exports.CommandGroup=Ma,exports.CommandInput=_a,exports.CommandItem=Da,exports.CommandList=Aa,exports.CommandSeparator=Ra,exports.CommandShortcut=Fa,exports.ContextMenu=ws,exports.ContextMenuCheckboxItem=Ms,exports.ContextMenuContent=As,exports.ContextMenuGroup=ks,exports.ContextMenuItem=Es,exports.ContextMenuLabel=Ds,exports.ContextMenuPortal=Ss,exports.ContextMenuRadioGroup=Ts,exports.ContextMenuRadioItem=Rs,exports.ContextMenuSeparator=Fs,exports.ContextMenuShortcut=zs,exports.ContextMenuSub=Ps,exports.ContextMenuSubContent=_s,exports.ContextMenuSubTrigger=Is,exports.ContextMenuTrigger=Cs,exports.CoreProviders=function({children:a,queryClient:t}){const s=t??new v.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(Vr,{children:e.jsx(g.I18nextProvider,{i18n:o,children:e.jsx(v.QueryClientProvider,{client:s,children:e.jsx(qt,{children:e.jsx(zr,{children:e.jsx(Or,{children:a})})})})})})},exports.CrudPageInternal=cr,exports.CrudPagination=sr,exports.CrudPrimitiveFilterBar=function({searchValue:a="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:i="horizontal"}){const{t:o}=g.useTranslation(),l=a||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===i?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{type:"text",placeholder:o("search"),value:a,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e.jsx("div",{className:"vertical"===i?"w-full":"",children:a},t)),n&&l&&r&&e.jsxs(_e,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(d.X,{size:14,className:"mr-1"}),o("clear_filters")]})]})},exports.CrudPrimitivePagination=tr,exports.CrudPrimitiveTable=function({data:t,columns:s,sortField:r,sortDirection:n,onSort:i,onRowClick:o,renderActions:l,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:y}){const{columnWidths:j,isDragging:N,activeColumn:w,handleMouseDown:C}=qs({columns:s.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:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:P,getRowHeight:T}=$s({rowIds:t.map(e=>e.id),storageKey:y?`${y}-rows`:void 0,enabled:!1}),I=a.useMemo(()=>{if(b)return s.map(e=>`${j[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.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}%`})},[s,b,j]);if(c)return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((a,t)=>e.jsx(za,{className:"h-12 w-full"},t))})});if(0===t.length)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:u})})});const _=N||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(_?"select-none":""),children:e.jsxs(Wt,{className:m,children:[e.jsx(Vt,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Qt,{children:[p&&e.jsx(Kt,{className:"w-[40px]",children:e.jsx(va,{checked:g,onCheckedChange:f,"aria-label":"Selecionar todos"})}),s.map((a,t)=>{const s=b&&!1!==a.resizable,o=w===String(a.key);return e.jsxs(Kt,{className:`${a.className||""} relative`,style:{width:I[t]},children:[a.sortable&&i?e.jsxs("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(l=String(a.key),r!==l?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:a.header}),s&&e.jsx(os,{direction:"horizontal",onMouseDown:e=>C(String(a.key),e),isDragging:o})]},String(a.key));var l}),l&&e.jsx(Kt,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(Ht,{children:t.map(a=>{const t=T(a.id);return a.id,e.jsxs(Qt,{onClick:()=>o?.(a),className:(o?"cursor-pointer":"")+" relative",style:t?{height:`${t}px`}:void 0,children:[p&&e.jsx(Xt,{children:e.jsx(va,{checked:h.includes(a.id),onCheckedChange:()=>x?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),s.map(t=>e.jsx(Xt,{className:t.className,children:e.jsx(is,{children:t.render?t.render(a):String(a[t.key]??"-")})},String(t.key))),l&&e.jsx(Xt,{className:"text-right",onClick:e=>e.stopPropagation(),children:l(a)})]},a.id)})})]})})},exports.CrudTable=Ws,exports.DataList=Bn,exports.DatePicker=function({date:a,onDateChange:t,placeholder:s="Pick a date",disabled:r=!1,className:n,disabledDates:o}){return e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",disabled:r,className:Pe("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",n),children:[e.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),a?i.format(a,"PPP"):e.jsx("span",{children:s})]})}),e.jsx(Ta,{className:"w-auto p-0",align:"start",children:e.jsx($n,{mode:"single",selected:a,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=$e,exports.DialogBody=Xe,exports.DialogClose=Ve,exports.DialogContent=Qe,exports.DialogDescription=Ze,exports.DialogFooter=Je,exports.DialogHeader=Ke,exports.DialogOverlay=He,exports.DialogPortal=We,exports.DialogTitle=Ye,exports.DialogTrigger=Be,exports.Drawer=Wn,exports.DrawerClose=Gn,exports.DrawerContent=Kn,exports.DrawerDescription=Zn,exports.DrawerFooter=Jn,exports.DrawerHeader=Xn,exports.DrawerOverlay=Qn,exports.DrawerPortal=Hn,exports.DrawerTitle=Yn,exports.DrawerTrigger=Vn,exports.DropdownMenu=ls,exports.DropdownMenuCheckboxItem=bs,exports.DropdownMenuContent=fs,exports.DropdownMenuGroup=cs,exports.DropdownMenuItem=gs,exports.DropdownMenuLabel=ys,exports.DropdownMenuPortal=us,exports.DropdownMenuRadioGroup=ps,exports.DropdownMenuRadioItem=vs,exports.DropdownMenuSeparator=js,exports.DropdownMenuShortcut=Ns,exports.DropdownMenuSub=ms,exports.DropdownMenuSubContent=xs,exports.DropdownMenuSubTrigger=hs,exports.DropdownMenuTrigger=ds,exports.EmailService=Wl,exports.EmptyState=as,exports.EntitySelect=Ua,exports.ErrorBoundary=Vr,exports.FilterBar=dr,exports.Form=ea,exports.FormControl=ia,exports.FormDescription=oa,exports.FormField=({...a})=>e.jsx(aa.Provider,{value:{name:a.name},children:e.jsx(p.Controller,{...a})}),exports.FormItem=ra,exports.FormLabel=na,exports.FormMessage=la,exports.FormSkeleton=function({fields:a=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(za,{className:"h-4 w-24"}),e.jsx(za,{className:"h-10 w-full"})]},t)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(za,{className:"h-10 w-20"}),e.jsx(za,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:a,cols:t="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Pe("grid",ei[t],ai[s],r),children:a})},exports.H1=mi,exports.H2=pi,exports.H3=hi,exports.H4=xi,exports.HeaderSkeleton=function(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(za,{className:"h-8 w-8 rounded-full"}),e.jsx(za,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(za,{className:"h-8 w-8"}),e.jsx(za,{className:"h-8 w-24"})]})]})},exports.HoverCard=ti,exports.HoverCardContent=ri,exports.HoverCardTrigger=si,exports.IconPicker=Js,exports.ImageEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),b=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("url")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("url_placeholder"),value:m.imageUrl||"",onChange:e=>b("imageUrl",e.target.value),className:"flex-1"}),i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),m.imageFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:m.imageFile,size:Math.round((m.imageSize||0)/1024)})})]}),m.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"caption",children:u("caption")}),e.jsx(ya,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>b("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"alt",children:u("alt")}),e.jsx(Ee,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>b("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("alignment")}),e.jsxs(da,{value:m.alignment||"center",onValueChange:e=>b("alignment",e),children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"left",children:u("left")}),e.jsx(ga,{value:"center",children:u("center")}),e.jsx(ga,{value:"right",children:u("right")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"width",children:u("width")}),e.jsx(Ee,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>b("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"height",children:u("height")}),e.jsx(Ee,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>b("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"allowDownload",type:"checkbox",checked:m.allowDownload||!1,onChange:e=>b("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{onClick:()=>{m.imageUrl?r(m):l.toast.error(u("error"),{description:u("error_no_image")})},disabled:!m.imageUrl,children:u("save")})]})]})},exports.ImageRenderer=function({content:a,className:t="",style:s}){if(!a.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${t}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:a.imageUrl,alt:a.alt||"",style:{width:a.width?`${a.width}px`:"auto",height:a.height?`${a.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),a.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&e.jsxs("a",{href:a.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=ji,exports.Input=Ee,exports.InputGroup=ni,exports.InputGroupAddon=oi,exports.InputGroupButton=di,exports.InputGroupInput=ci,exports.InputGroupTextarea=ui,exports.LOGO_CONFIG=wt,exports.Label=Re,exports.Large=bi,exports.Lead=gi,exports.LeaderRow=id,exports.LeadershipDialog=pd,exports.LeadershipForm=md,exports.LeadershipPage=function(){const{alias:t}=$t(),{t:s}=g.useTranslation(),{data:r,isLoading:n,error:i,refetch:o}=Zl(),{data:l=[]}=Zs({enabled:!0}),[c,u]=a.useState(()=>t?(e=>{try{const a=localStorage.getItem(`${hd}-${e}`);if(a)return new Set(JSON.parse(a))}catch(i){}return new Set})(t):new Set),[m,p]=a.useState(!1),[h,x]=a.useState(),[f,b]=a.useState(null),v=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),y=new Set(v.map(e=>e.userId)),j=v.length-(r?Yl(r).filter(e=>y.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);a.useEffect(()=>{if(r&&r.length>0&&t){if(!localStorage.getItem(`${hd}-${t}`)){const e=r.map(e=>e.id),a=new Set(e);u(a),xd(t,a)}}},[r,t]);const N=e=>{u(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),t&&xd(t,s),s})},w=e=>{x(e),b(null),p(!0)};return n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:s("loading")})]})}):i?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(_e,{onClick:()=>o(),children:"Tentar novamente"})]})}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(_e,{size:"sm",onClick:()=>{x(void 0),b(null),p(!0)},children:[e.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{if(!r)return;const e=Yl(r).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&xd(t,a)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&xd(t,e)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[j," usuário",1!==j?"s":""," não associado",1!==j?"s":""]})]})})]})}),r&&0!==r.length?e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:r.map(a=>e.jsx(id,{leader:a,expandedIds:c,onToggleExpand:N,onEdit:w},a.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(pd,{open:m,onOpenChange:()=>{p(!1),x(void 0),b(null)},leader:h,prefilledLeaderId:f,title:h?s("edit")+" "+s("name"):f?s("add")+" Liderado":s("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})},exports.List=wi,exports.LoadingState=function({isLoading:a,children:t,className:s,type:r="spinner",size:n="md"}){return a?"overlay"===r?e.jsxs("div",{className:Pe("relative",s),children:[t,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ca,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Pe("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Pe("flex items-center justify-center py-8",s),children:e.jsx(Ca,{size:n})}):e.jsx(e.Fragment,{children:t})},exports.LocaleProvider=zr,exports.LocaleSelector=bl,exports.LoginPage=()=>e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(_e,{onClick:async()=>{yt()?await Ot.loginDev():Ot.loginProd()},className:"w-full",size:"lg",children:yt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Ct,exports.ManageAccessModal=Hl,exports.Menubar=Wo,exports.MenubarCheckboxItem=Xo,exports.MenubarContent=Qo,exports.MenubarGroup=Uo,exports.MenubarItem=Ko,exports.MenubarLabel=Yo,exports.MenubarMenu=Oo,exports.MenubarPortal=qo,exports.MenubarRadioGroup=Bo,exports.MenubarRadioItem=Jo,exports.MenubarSeparator=Zo,exports.MenubarShortcut=el,exports.MenubarSub=$o,exports.MenubarSubContent=Go,exports.MenubarSubTrigger=Ho,exports.MenubarTrigger=Vo,exports.ModalStateProvider=function({children:t}){const[s,r]=a.useState(new Set),[n,i]=a.useState(!1),o=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=a.useCallback(e=>{i(e)},[]),c=a.useMemo(()=>s.size>0||n,[s,n]),u=a.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:o,unregisterModal:l,setHasOpenModal:d}),[s,c,o,l,d]);return e.jsx(Ll.Provider,{value:u,children:t})},exports.MultiSelect=Ua,exports.Muted=yi,exports.NavigationMenu=Ci,exports.NavigationMenuContent=Ii,exports.NavigationMenuIndicator=Ei,exports.NavigationMenuItem=Si,exports.NavigationMenuLink=_i,exports.NavigationMenuList=ki,exports.NavigationMenuTrigger=Ti,exports.NavigationMenuViewport=Ai,exports.NavigationProvider=jl,exports.P=fi,exports.PageBreadcrumb=function({items:a,maxItems:t=3,className:s}){const r=a.length>t?[a[0],...a.slice(-(t-1))]:a,n=a.length>t;return e.jsx(un,{className:s,children:e.jsx(mn,{children:r.map((a,t)=>{const s=0===t,r=n&&1===t;return e.jsxs(pn,{children:[!s&&e.jsx(fn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(gn,{}),e.jsx(fn,{})]}),a.isCurrentPage?e.jsx(xn,{children:a.label}):e.jsx(hn,{href:a.href,children:a.label})]},a.label)})})})},exports.PageMetadataProvider=Cr,exports.Pagination=Mi,exports.PaginationContent=Ri,exports.PaginationEllipsis=Oi,exports.PaginationItem=Di,exports.PaginationLink=Fi,exports.PaginationNext=Li,exports.PaginationPrevious=zi,exports.PlaceCard=Gl,exports.PlacesList=function({places:a,isLoading:t,manageAccessConfig:s}){const{t:r}=g.useTranslation();return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("loading_data")})]})}):a&&0!==a.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(a=>e.jsx(Gl,{place:a,manageAccessConfig:s},a.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Sa,exports.PopoverContent=Ta,exports.PopoverTrigger=Pa,exports.Progress=pr,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:s,isLoading:r}=$t();if(a.useEffect(()=>{if(!s)return;const e=()=>{Xa.areAllTokensValid()||Ot.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[s]),a.useEffect(()=>{if(r)return;if(s)return;if(Xa.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 n=yt();(async()=>{n?await Ot.loginDev():Ot.loginProd()})()},[s,r]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:yt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:t})},exports.QUALIEX_CONFIG=jt,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=_t,exports.QualiexErrorInterceptor=pt,exports.QualiexUserField=er,exports.RadioGroup=Ui,exports.RadioGroupItem=qi,exports.ResizableHandle=({withHandle:a,className:t,...s})=>e.jsx(ve.PanelResizeHandle,{className:Pe("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),...s,children:a&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=$i,exports.ResizablePanelGroup=({className:a,...t})=>e.jsx(ve.PanelGroup,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),exports.RichTextEditor=({value:t,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:i="300px",showModeToggle:o=!0,showVariableHint:l=!0,className:c})=>{const[u,m]=a.useState("visual"),p=B.useEditor({extensions:[W.configure({heading:{levels:[1,2,3]}}),V,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Q.Color,K.configure({multicolor:!0})],content:t||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});Z.useEffect(()=>{p&&t!==p.getHTML()&&p.commands.setContent(t||"")},[t,p]);const h=a.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?p.chain().focus().extendMarkRange("link").setLink({href:a}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Pe("space-y-2",c),children:[o&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(_e,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(_e,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(_e,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),l&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(d.Heading1,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(d.Heading2,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(d.Heading3,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(d.Bold,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(d.Italic,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(d.Underline,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(d.Strikethrough,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(d.ListOrdered,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(d.Highlighter,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(d.Link,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(d.Undo,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(d.Redo,{className:"h-4 w-4"})})]}),e.jsx(B.EditorContent,{editor:p,className:Pe("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:i}})]}),"code"===u&&e.jsx("textarea",{value:t||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:t||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=vt,exports.ScrollArea=Qs,exports.ScrollBar=Ks,exports.Select=da,exports.SelectContent=xa,exports.SelectGroup=ca,exports.SelectItem=ga,exports.SelectLabel=fa,exports.SelectScrollDownButton=ha,exports.SelectScrollUpButton=pa,exports.SelectSearch=Ua,exports.SelectSeparator=ba,exports.SelectTrigger=ma,exports.SelectValue=ua,exports.Separator=qe,exports.Sheet=Bi,exports.SheetBody=Ji,exports.SheetClose=Vi,exports.SheetContent=Ki,exports.SheetDescription=eo,exports.SheetFooter=Yi,exports.SheetHeader=Xi,exports.SheetOverlay=Gi,exports.SheetPortal=Hi,exports.SheetTitle=Zi,exports.SheetTrigger=Wi,exports.Sidebar=no,exports.SidebarActionTrigger=Fl,exports.SidebarContent=ho,exports.SidebarFooter=mo,exports.SidebarGroup=xo,exports.SidebarGroupAction=go,exports.SidebarGroupContent=bo,exports.SidebarGroupLabel=fo,exports.SidebarHeader=Dl,exports.SidebarInput=co,exports.SidebarInset=lo,exports.SidebarMenu=vo,exports.SidebarMenuAction=wo,exports.SidebarMenuBadge=Co,exports.SidebarMenuButton=No,exports.SidebarMenuItem=yo,exports.SidebarMenuSkeleton=ko,exports.SidebarMenuSub=So,exports.SidebarMenuSubButton=To,exports.SidebarMenuSubItem=Po,exports.SidebarProvider=ro,exports.SidebarRail=oo,exports.SidebarSeparator=po,exports.SidebarSkeleton=function(){return e.jsx("div",{className:"w-64 border-r bg-muted/10",children:e.jsxs("div",{className:"p-4",children:[e.jsx(za,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((a,t)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx(za,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=io,exports.Skeleton=za,exports.Slider=Io,exports.Small=vi,exports.SonnerToaster=ka,exports.Spinner=Ca,exports.SplitButton=function({label:a,onClick:t,icon:s,actions:r=[],variant:n="default",size:i="default",disabled:o=!1,loading:l=!1,menuAlign:c="end",className:u}){const m=o||l;return r.length>0?e.jsxs("div",{className:Pe("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]}),e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:n,size:i,disabled:m,className:Pe("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"}[i]),"aria-label":"Mais opções",children:e.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[i]})})}),e.jsx(fs,{align:c,className:"min-w-[160px]",children:r.map(a=>{const t=a.icon;return e.jsxs(gs,{onClick:a.onClick,disabled:a.disabled,className:Pe("destructive"===a.variant&&"text-destructive focus:text-destructive"),children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})]}):e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,className:u,children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]})},exports.Stack=lr,exports.Switch=Ys,exports.TabPageContent=function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-6",t),children:a})},exports.TabPageHeader=function({title:a,description:t,actions:s,className:r}){return e.jsxs("div",{className:Pe("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:a}),t&&e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(qe,{})]})},exports.TabPageLayout=function({children:a,className:t}){return e.jsx("div",{className:Pe("flex flex-col h-full",t),children:e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:a})})})},exports.Table=Wt,exports.TableBody=Ht,exports.TableCaption=Jt,exports.TableCell=Xt,exports.TableFooter=Gt,exports.TableHead=Kt,exports.TableHeader=Vt,exports.TableResizeHandle=os,exports.TableRow=Qt,exports.TableRowActions=Os,exports.TableSkeleton=Yt,exports.Tabs=_o,exports.TabsContent=Mo,exports.TabsList=Ao,exports.TabsTrigger=Eo,exports.Textarea=ya,exports.Toaster=ka,exports.Toggle=Do,exports.ToggleGroup=zo,exports.ToggleGroupItem=Lo,exports.TokenManager=Xa,exports.TokenService=$a,exports.Tooltip=ss,exports.TooltipContent=ns,exports.TooltipProvider=ts,exports.TooltipTrigger=rs,exports.TranslationLoader=Or,exports.TruncatedCell=is,exports.VideoEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{inputType:"url",controls:!0}),h=a.useRef(null),x=a.useRef(null),{upload:f,uploading:b}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:y}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),j=a.useMemo(()=>Nd(m.videoUrl||jd(m.embedCode)||""),[m.videoUrl,m.embedCode]),N=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("input_type")}),e.jsxs(da,{value:m.inputType||"url",onValueChange:e=>N("inputType",e),children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"url",children:u("url")}),e.jsx(ga,{value:"upload",children:u("input_type_upload")}),e.jsx(ga,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:h,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await f(a),t={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||a.name.replace(/\.[^/.]+$/,"")};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("select_video")]})}),m.videoFile&&e.jsx("span",{className:"text-xs text-muted-foreground truncate self-center",children:u("video.fileInfo",{name:m.videoFile,size:Math.round((m.videoSize||0)/1024/1024)})})]})]}),"embed"===m.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("embed")}),e.jsx(ya,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};p(t),s(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("video.uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]}),m.thumbnailFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("video.thumbnailFileInfo",{name:m.thumbnailFile})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"title",children:u("title")}),e.jsx(Ee,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>N("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"autoplay",type:"checkbox",checked:m.autoplay||!1,onChange:e=>N("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"autoplay",className:"cursor-pointer",children:u("video.autoplay")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"controls",type:"checkbox",checked:!1!==m.controls,onChange:e=>N("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=m.videoUrl||jd(m.embedCode)||"";if(!a)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===j)return e.jsxs("video",{controls:!1!==m.controls,autoPlay:m.autoplay,poster:m.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:a}),u("unsupported")]});const t="youtube"===j?bd(a,m.autoplay):yd(a,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:t,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{onClick:()=>{m.videoUrl||m.embedCode?r(m):l.toast.error(u("error"),{description:u("error_no_video")})},disabled:!(m.videoUrl||m.embedCode),children:u("save")})]})]})},exports.VideoRenderer=function({content:a,className:t="",style:s}){const r=a.videoUrl||jd(a.embedCode)||"";if(!r)return null;const n=Nd(r),{t:i}=g.useTranslation();return e.jsx(De,{className:`overflow-hidden my-4 ${t}`,style:s,children:e.jsxs(Oe,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:a.title||i("video"),src:"youtube"===n?bd(r,a.autoplay):yd(r,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.WizardBreadcrumb=xr,exports.WizardButtons=gr,exports.WizardForm=function({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c,showProgressIndicator:u=!0,progressType:m="stepper",validateOnNext:p=!0,allowSkipSections:h=!1,previousButtonText:x,nextButtonText:f,onStepChange:g,onStepValidationFail:b,renderProgressIndicator:v,renderButtons:y,currentStepIndex:j,onCurrentStepChange:N}){const[w,C]=a.useState(0),k=j??w,S=N??C,P=a.useRef(null),[T,I]=a.useState(null),_=a.useCallback(e=>{P.current=e,I(e)},[]),A=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:E,errors:M,updateField:R,handleSubmit:D}=Vs(A,r,void 0,o);a.useEffect(()=>{o&&S(0)},[o,S]);const F=a.useCallback(()=>{const e=s[k];if(!e)return!0;const a=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),t={};let r=!0;return a.forEach(e=>{const a=E[e.name];if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(t[e.name]=`${e.label} é obrigatório`,r=!1),e.validation&&"function"==typeof e.validation){const s=e.validation(a,E);s&&(t[e.name]=s,r=!1)}}),!r&&b&&b(k,t),r},[s,k,E,b]),z=a.useCallback(()=>{if(p&&!F())return;const e=k+1;e<s.length&&(S(e),g?.(e,s[e].id))},[k,s,p,F,S,g]),L=a.useCallback(()=>{const e=k-1;e>=0&&(S(e),g?.(e,s[e].id))},[k,s,S,g]),O=a.useCallback(()=>{let e=!0;for(let a=0;a<s.length;a++){s[a].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(a=>{const t=E[a.name];a.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(e=!1)})}e&&D(n)()},[s,E,D,n]),U=a.useMemo(()=>s.map((e,a)=>({index:a,id:e.id,label:e.label||e.id,isActive:a===k,isCompleted:a<k,isDisabled:e.disabled||!1})),[s,k]),q=0===k,$=k===s.length-1,B=a.useMemo(()=>{if(!u)return null;if(v)return v(k,s.length,s);const a=h?e=>{S(e),g?.(e,s[e].id)}:void 0;switch(m){case"breadcrumb":return e.jsx(xr,{steps:U,currentStepIndex:k,onStepClick:a});case"progressbar":return e.jsx(fr,{steps:U,currentStepIndex:k});default:return e.jsx(hr,{steps:U,currentStepIndex:k,onStepClick:a})}},[u,v,m,U,k,s,h,S,g]),W=a.useMemo(()=>{const a={isFirstStep:q,isLastStep:$,canGoNext:k<s.length-1,canGoPrevious:k>0,isLoading:d,onPrevious:L,onNext:z,onSubmit:O,previousButtonText:x,nextButtonText:f,submitButtonText:l};return y?y(a):e.jsx(gr,{...a})},[q,$,k,s.length,d,L,z,O,x,f,l,y]),V=a=>{const t=(a.computedValue,E[a.name]),s=void 0!==t?t:"",r=M[a.name];switch(a.type){case"group":return e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsx(Re,{className:"text-sm font-medium",children:a.label}),e.jsx("div",{className:Pe("grid gap-4",1===a.columns&&"grid-cols-1",2===a.columns&&"grid-cols-1 md:grid-cols-2",3===a.columns&&"grid-cols-1 md:grid-cols-3",4===a.columns&&"grid-cols-1 md:grid-cols-4",!a.columns&&"grid-cols-1"),children:a.fields?.map(e=>V(e))})]},a.name);case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"number",value:s,onChange:e=>R(a.name,""===e.target.value?"":Number(e.target.value)),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,rows:a.rows||3,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(da,{value:s,onValueChange:e=>R(a.name,e),children:[e.jsx(ma,{className:r?"border-destructive":"",children:e.jsx(ua,{placeholder:a.placeholder||`Selecione ${a.label}`})}),e.jsx(xa,{children:a.options?.map(a=>e.jsx(ga,{value:String(a.value),children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ua,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>R(a.name,e),placeholder:a.placeholder,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":case"color-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Gs,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"user-select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s,onChange:e=>R(a.name,e),placeholder:a.placeholder,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"custom":return a.render?e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.render({value:s,onChange:e=>R(a.name,e),error:r,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name):null;default:return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:a.type||"text",value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},H=s[k];return e.jsx($e,{open:o,onOpenChange:i,children:e.jsxs(Qe,{ref:_,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ke,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e.jsx(Ye,{className:"text-white",children:t})}),B,e.jsx("div",{className:"space-y-4 py-4",children:H?.fields.map(e=>V(e))}),e.jsx("div",{className:"flex justify-between pt-4 border-t",children:W})]})})},exports.WizardProgressBar=fr,exports.WizardStepper=hr,exports.assets=El,exports.badgeVariants=ja,exports.buildHierarchy=Jl,exports.buttonGroupVariants=bn,exports.buttonVariants=Ie,exports.calculateAspectRatio=wd,exports.cn=Pe,exports.createCrudPage=function(a){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:i||r.onEdit};return e.jsx(cr,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:o,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=hl({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=hl,exports.createService=Mt,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=Mt({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,s)=>Bt({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=St,exports.deriveNameField=kt,exports.deriveUsernameField=Pt,exports.detectVideoProvider=Nd,exports.emailService=Vl,exports.errorService=Za,exports.extractImageFileName=function(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"}},exports.extractVimeoId=vd,exports.extractYouTubeId=gd,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.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))},exports.flattenTree=Yl,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Bl,exports.formatDatetime=e=>{if(!e)return"";const a=i.parseISO(e);if(!i.isValid(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"})}`},exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:mr(e),label:mr(e),...ur(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.getQualiexConfig=Nt,exports.getSupabaseClient=it,exports.handleExternalLink=Se,exports.inputGroupAddonVariants=ii,exports.inputGroupButtonVariants=li,exports.isDevEnvironment=yt,exports.isImageUrl=function(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))},exports.logoSrc=Ml,exports.navigationMenuTriggerStyle=Pi,exports.normalizeVideoUrl=function(e,a,t){switch(a||Nd(e)){case"youtube":return bd(e,t);case"vimeo":return yd(e,t);default:return e}},exports.normalizeVimeoUrl=yd,exports.normalizeYouTubeUrl=bd,exports.parseIframeSrc=jd,exports.placeService=Xl,exports.qualiexApi=ft,exports.resizeKeepingAspect=function(e,a,t,s){const r=wd(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=Tt,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new v.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.slugify=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),exports.smallLogoSrc=Rl,exports.toggleVariants=Ro,exports.translationService=Ar,exports.trimTextFields=Te,exports.useActiveModules=Pl,exports.useAuth=$t,exports.useBaseForm=Vs,exports.useColumnResize=qs,exports.useCreateLeaderMutation=function(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({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 s.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 nd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.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 r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder adicionado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=ad,exports.useCreateSingleLeaderMutation=ed,exports.useCrud=Bt,exports.useDebounce=Cl,exports.useFormField=ta,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Ol();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a,datetimeFormat:t}=Lr();return{formatDatetime:e=>((e,a="dd/MM/yyyy HH:mm")=>{if(!e)return"";const t=i.parseISO(e);return i.isValid(t)?i.format(t,a):"Invalid date"})(e,t,a),formatDate:a=>Bl(a,e),locale:e,timezone:a,datetimeFormat:t}},exports.useLeadershipApi=Zl,exports.useLocale=Lr,exports.useMediaUpload=fd,exports.useModalState=Ol,exports.useNavigation=Nl,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:s}=kr();a.useEffect(()=>(t(e),()=>s()),[e.title,e.subtitle,t,s])},exports.usePageMetadataContext=kr,exports.usePageTitle=wl,exports.usePermissionQuery=Sl,exports.useQualiexUsers=Zs,exports.useRemoveLeaderMutation=sd,exports.useRouteBreadcrumbs=function(){const e=y.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:s,isCurrentPage:n})}),t})()},exports.useRowResize=$s,exports.useSidebar=so,exports.useSidebarResize=zl,exports.useSyncSubordinatesMutation=rd,exports.useUpdateLeaderMutation=td;
1
+ "use strict";var e=require("react/jsx-runtime"),a=require("react"),t=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),i=require("date-fns"),o=require("i18next"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),x=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-popover"),g=require("react-i18next"),b=require("@supabase/supabase-js"),v=require("@tanstack/react-query"),j=require("react-router-dom"),y=require("@radix-ui/react-tooltip"),N=require("@radix-ui/react-dropdown-menu"),w=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("@radix-ui/react-collapsible"),T=require("@radix-ui/react-accordion"),P=require("@radix-ui/react-alert-dialog"),A=require("@radix-ui/react-avatar"),I=require("react-day-picker"),_=require("vaul"),E=require("@radix-ui/react-hover-card"),M=require("@radix-ui/react-navigation-menu"),R=require("@radix-ui/react-progress"),D=require("@radix-ui/react-radio-group"),z=require("react-resizable-panels"),F=require("@radix-ui/react-slider"),L=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-toggle"),U=require("@radix-ui/react-toggle-group"),q=require("@radix-ui/react-menubar"),$=require("recharts"),B=require("@tiptap/react"),W=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Q=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),X=require("date-fns-tz"),J=require("zod"),Y=require("@hookform/resolvers");function Z(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var ee=Z(a),ae=Z(c),te=Z(u),se=Z(m),re=Z(h),ne=Z(x),ie=Z(f),oe=Z(y),le=Z(N),de=Z(w),ce=Z(C),ue=Z(k),me=Z(S),pe=Z(T),he=Z(P),xe=Z(A),fe=Z(E),ge=Z(M),be=Z(R),ve=Z(D),je=Z(z),ye=Z(F),Ne=Z(L),we=Z(O),Ce=Z(U),ke=Z(q),Se=Z($);function Te(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info(o.t("link_copied"))})}function Pe(...e){return n.twMerge(r.clsx(e))}const Ae=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Ae);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Ae(s);return a}return e},Ie=s.cva("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"}}),_e=ee.forwardRef(({className:a,variant:s,size:r,asChild:n=!1,...i},o)=>{const l=n?t.Slot:"button";return e.jsx(l,{className:Pe(Ie({variant:s,size:r,className:a})),ref:o,...i})});_e.displayName="Button";const Ee=a.forwardRef(({className:a,children:t,...s},r)=>e.jsx(_e,{ref:r,variant:"action",size:"sm",className:Pe("h-7 px-2 text-xs",a),...s,children:t||e.jsx(d.EllipsisVertical,{size:12})}));Ee.displayName="ActionButton";const Me=ee.forwardRef(({className:a,type:t,...s},r)=>e.jsx("input",{type:t,className:Pe("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:r,...s}));Me.displayName="Input";const Re=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),De=ee.forwardRef(({className:a,...t},s)=>e.jsx(ae.Root,{ref:s,className:Pe(Re(),a),...t}));De.displayName=ae.Root.displayName;const ze=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));ze.displayName="Card";const Fe=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex flex-col space-y-1.5 p-6",a),...t}));Fe.displayName="CardHeader";const Le=ee.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("text-2xl font-semibold leading-none tracking-tight",a),...t}));Le.displayName="CardTitle";const Oe=ee.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Oe.displayName="CardDescription";const Ue=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("p-6 pt-0",a),...t}));Ue.displayName="CardContent";const qe=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex items-center p-6 pt-0",a),...t}));qe.displayName="CardFooter";const $e=ee.forwardRef(({className:a,orientation:t="horizontal",decorative:s=!0,...r},n)=>e.jsx(se.Root,{ref:n,decorative:s,orientation:t,className:Pe("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...r}));$e.displayName=se.Root.displayName;const Be=te.Root,We=te.Trigger,Ve=te.Portal,He=te.Close,Ge=ee.forwardRef(({className:a,...t},s)=>e.jsx(te.Overlay,{ref:s,className:Pe("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}));Ge.displayName=te.Overlay.displayName;const Qe={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"}},Ke=ee.forwardRef(({className:a,children:t,size:s="md",customWidth:r,customMinWidth:n,customMaxWidth:i,customHeight:o,customMinHeight:l,customMaxHeight:c,style:u,...m},p)=>{const h=Qe[s],x={width:r??h.width,minWidth:n??h.minWidth,maxWidth:i??h.maxWidth,height:o??h.height,minHeight:l??h.minHeight,maxHeight:c??h.maxHeight,...u};return e.jsxs(Ve,{children:[e.jsx(Ge,{}),e.jsxs(te.Content,{ref:p,className:Pe("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",a),style:x,...m,children:[t,e.jsxs(te.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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ke.displayName=te.Content.displayName;const Xe=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx($e,{className:"mt-2"})]});Xe.displayName="DialogHeader";const Je=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Je.displayName="DialogBody";const Ye=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx($e,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Ye.displayName="DialogFooter";const Ze=ee.forwardRef(({className:a,...t},s)=>e.jsx(te.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Ze.displayName=te.Title.displayName;const ea=ee.forwardRef(({className:a,...t},s)=>e.jsx(te.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));ea.displayName=te.Description.displayName;const aa=p.FormProvider,ta=ee.createContext({}),sa=()=>{const e=ee.useContext(ta),a=ee.useContext(ra),{getFieldState:t,formState:s}=p.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},ra=ee.createContext({}),na=ee.forwardRef(({className:a,...t},s)=>{const r=ee.useId();return e.jsx(ra.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Pe("space-y-2",a),...t})})});na.displayName="FormItem";const ia=ee.forwardRef(({className:a,...t},s)=>{const{error:r,formItemId:n}=sa();return e.jsx(De,{ref:s,className:Pe(r&&"text-destructive",a),htmlFor:n,...t})});ia.displayName="FormLabel";const oa=ee.forwardRef(({...a},s)=>{const{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=sa();return e.jsx(t.Slot,{ref:s,id:n,"aria-describedby":r?`${i} ${o}`:`${i}`,"aria-invalid":!!r,...a})});oa.displayName="FormControl";const la=ee.forwardRef(({className:a,...t},s)=>{const{formDescriptionId:r}=sa();return e.jsx("p",{ref:s,id:r,className:Pe("text-sm text-muted-foreground",a),...t})});la.displayName="FormDescription";const da=ee.forwardRef(({className:a,children:t,...s},r)=>{const{error:n,formMessageId:i}=sa(),o=n?String(n?.message):t;return o?e.jsx("p",{ref:r,id:i,className:Pe("text-sm font-medium text-destructive",a),...s,children:o}):null});da.displayName="FormMessage";const ca=re.Root,ua=re.Group,ma=re.Value,pa=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(re.Trigger,{ref:r,className:Pe("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",a),...s,children:[t,e.jsx(re.Icon,{asChild:!0,children:e.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));pa.displayName=re.Trigger.displayName;const ha=ee.forwardRef(({className:a,...t},s)=>e.jsx(re.ScrollUpButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronUp,{className:"h-4 w-4"})}));ha.displayName=re.ScrollUpButton.displayName;const xa=ee.forwardRef(({className:a,...t},s)=>e.jsx(re.ScrollDownButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronDown,{className:"h-4 w-4"})}));xa.displayName=re.ScrollDownButton.displayName;const fa=ee.forwardRef(({className:a,children:t,position:s="popper",container:r,collisionBoundary:n,...i},o)=>e.jsx(re.Portal,{container:r,children:e.jsxs(re.Content,{ref:o,className:Pe("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",a),position:s,collisionBoundary:n,...i,children:[e.jsx(ha,{}),e.jsx(re.Viewport,{className:Pe("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(xa,{})]})}));fa.displayName=re.Content.displayName;const ga=ee.forwardRef(({className:a,...t},s)=>e.jsx(re.Label,{ref:s,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));ga.displayName=re.Label.displayName;const ba=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(re.Item,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(re.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),e.jsx(re.ItemText,{children:t})]}));ba.displayName=re.Item.displayName;const va=ee.forwardRef(({className:a,...t},s)=>e.jsx(re.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));va.displayName=re.Separator.displayName;const ja=ee.forwardRef(({className:a,...t},s)=>e.jsx(ne.Root,{ref:s,className:Pe("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.jsx(ne.Indicator,{className:Pe("flex items-center justify-center text-current"),children:e.jsx(d.Check,{className:"h-4 w-4"})})}));ja.displayName=ne.Root.displayName;const ya=ee.forwardRef(({className:a,...t},s)=>e.jsx("textarea",{className:Pe("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:s,...t}));ya.displayName="Textarea";const Na=s.cva("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"}}),wa=ee.forwardRef(({className:a,variant:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(Na({variant:t}),a),...s}));wa.displayName="Badge";const Ca={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function ka({size:a="md",className:t}){return e.jsx(d.Loader2,{className:Pe("animate-spin text-muted-foreground",Ca[a],t)})}const Sa=({...a})=>e.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(d.Loader2Icon,{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}),Ta=ie.Root,Pa=ie.Trigger,Aa=ee.forwardRef(({className:a,align:t="center",sideOffset:s=4,container:r,...n},i)=>e.jsx(ie.Portal,{container:r,children:e.jsx(ie.Content,{ref:i,align:t,sideOffset:s,className:Pe("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})}));Aa.displayName=ie.Content.displayName;const Ia=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ia.displayName="Command";const _a=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Pe("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})}));_a.displayName="CommandInput";const Ea=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Ea.displayName="CommandList";const Ma=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("py-6 text-center text-sm text-muted-foreground",a),...t}));Ma.displayName="CommandEmpty";const Ra=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("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}));Ra.displayName="CommandGroup";const Da=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("-mx-1 h-px bg-border",a),...t}));Da.displayName="CommandSeparator";const za=ee.forwardRef(({className:a,disabled:t,onSelect:s,value:r,...n},i)=>e.jsx("div",{ref:i,className:Pe("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&&s?.(r||""),...n}));za.displayName="CommandItem";const Fa=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function La({className:a,...t}){return e.jsx("div",{className:Pe("animate-pulse rounded-md bg-muted",a),...t})}Fa.displayName="CommandShortcut";const Oa=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Ua({multiple:t,options:s,value:r,onChange:n,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:x,className:f,sortOptions:b,maxDisplayedBadges:v,popoverContainer:j,onOpen:y,onClose:N}){const{t:w}=g.useTranslation(),[C,k]=a.useState(!1),[S,T]=a.useState(""),P=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),A=a.useMemo(()=>{if(!j)return;let e=j,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[j]),I=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:o(e)}));return b?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[s,i,o,b]),_=a.useMemo(()=>{if(!S)return I;const e=Oa(S);return I.filter(a=>Oa(a.label).includes(e))},[I,S]),E=a.useMemo(()=>I.filter(e=>P.includes(e.value)),[I,P]),M=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?P.filter(a=>a!==e):"")},R=v?E.slice(0,v):E,D=v&&E.length>v?E.length-v:0;return e.jsxs("div",{className:Pe("space-y-2",f),children:[c&&e.jsxs(De,{children:[c,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ta,{open:C,onOpenChange:e=>{k(e),e?y?.():(T(""),N?.())},modal:!1,children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":C,disabled:h,className:Pe("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),l]}):t?e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(a=>e.jsxs(wa,{variant:"secondary",className:"gap-1 pr-1",children:[a.label,e.jsx("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&&M(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(a.value,e),children:e.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),D>0&&e.jsxs(wa,{variant:"outline",className:"gap-1",children:["+",D]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Aa,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:A,collisionBoundary:A,children:e.jsxs(Ia,{children:[e.jsx(_a,{placeholder:p,value:S,onChange:e=>T(e.target.value)}),e.jsx(Ea,{children:0===s.length?e.jsx(Ma,{children:m}):0===_.length?e.jsx(Ma,{children:w("no_results")}):e.jsx(Ra,{children:_.map(a=>e.jsxs(za,{value:a.value,onSelect:()=>(e=>{if(n)if(t){const a=P.includes(e)?P.filter(a=>a!==e):[...P,e];n(a)}else n(e),k(!1)})(a.value),className:"cursor-pointer",children:[e.jsx(d.Check,{className:Pe("mr-2 h-4 w-4",P.includes(a.value)?"opacity-100":"opacity-0")}),a.label]},a.value))})})]})})]})]})}function qa({multiple:a=!1,options:t,items:s,value:r,onChange:n,onValueChange:i,getOptionValue:o=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:b=!1,error:v,className:j,sortOptions:y=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k}){const{t:S}=g.useTranslation(),T=s||t||[],P=i||n,A=c||S("select_placeholder"),I=p||S("no_results"),_=h||S("search_placeholder");if(b)return e.jsxs("div",{className:Pe("space-y-2",j),children:[u&&e.jsxs(De,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(La,{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?e.jsxs("div",{className:Pe("space-y-2",j),children:[u&&e.jsxs(De,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:E})]})]}):e.jsx(Ua,{multiple:a,options:T,value:r||(a?[]:""),onChange:P,getOptionValue:o,getOptionLabel:l,placeholder:A,label:u,icon:m,emptyMessage:I,searchPlaceholder:_,disabled:x,required:f,className:j,sortOptions:y,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k})}var $a=Object.defineProperty;class Ba{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 r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}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(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}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(r.exp&&r.exp<o){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}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?$a(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(Ba,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Wa="qualiex_access_token",Va="qualiex_id_token",Ha="supabase_token",Ga="oauth_state",Qa="oauth_nonce",Ka="selected_alias",Xa="manual_logout",Ja={setAccessToken:e=>localStorage.setItem(Wa,e),getAccessToken:()=>localStorage.getItem(Wa),setIdToken:e=>localStorage.setItem(Va,e),getIdToken:()=>localStorage.getItem(Va),getSupabaseToken:()=>localStorage.getItem(Ha),setOAuthState:e=>sessionStorage.setItem(Ga,e),getOAuthState:()=>sessionStorage.getItem(Ga),clearOAuthState:()=>sessionStorage.removeItem(Ga),setOAuthNonce:e=>sessionStorage.setItem(Qa,e),getOAuthNonce:()=>sessionStorage.getItem(Qa),clearOAuthNonce:()=>sessionStorage.removeItem(Qa),setSelectedAlias:e=>localStorage.setItem(Ka,e),getSelectedAlias:()=>localStorage.getItem(Ka),clearSelectedAlias:()=>localStorage.removeItem(Ka),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Ja.getAccessToken()||!Ja.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Ha,e),Ja._clearValidationCache()},areAllTokensValid:()=>{const e=Ja.getAccessToken(),a=Ja.getIdToken();if(!e||!a)return!1;try{const t=Ba.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Ja.getAccessToken(),t=Ja.getIdToken(),s=Ja.getSupabaseToken();return a&&Ja.isTokenExpired(a)&&(localStorage.removeItem(Wa),e=!0),t&&Ja.isTokenExpired(t)&&(localStorage.removeItem(Va),e=!0),s&&Ja.isTokenExpired(s)&&(localStorage.removeItem(Ha),e=!0),e},clearAll:()=>{localStorage.removeItem(Wa),localStorage.removeItem(Va),localStorage.removeItem(Ha),localStorage.removeItem(Ka),localStorage.removeItem(Xa),sessionStorage.removeItem(Ga),sessionStorage.removeItem(Qa)},setManualLogout:()=>localStorage.setItem(Xa,"true"),isManualLogout:()=>"true"===localStorage.getItem(Xa),clearManualLogout:()=>localStorage.removeItem(Xa),isTokenExpired:e=>{try{return Ba.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Ja._validationCache.isValid=!1,Ja._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Ja.getSupabaseToken();if(!e)return!1;if(Ja.isTokenExpired(e))return Ja._clearValidationCache(),Ja._handleExpiredToken(),!1;const a=Date.now();return a-Ja._validationCache.timestamp<Ja._validationCache.cacheValidityMs?Ja._validationCache.isValid:(Ja._validationCache.isValid=!0,Ja._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>Ja.isSupabaseTokenValid()?Ja.getSupabaseToken():null,_handleExpiredToken:()=>{Ja.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Ja.isSupabaseTokenValid())return null;const e=Ja.getSupabaseToken();if(!e)return null;try{const a=Ba.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=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 s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return Ja._handleExpiredToken(),null}},getCompanyId:e=>{const a=Ja.getAccessToken();if(a)try{const t=Ba.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=Ja.extractTokenData();if(t?.companyId)return t.companyId;const s=Ja.getIdToken();if(s)try{const a=Ba.parseJwtPayload(s);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=Ja.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Ja.getIdToken();if(!e)return[];try{const a=Ba.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.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 Ya=Object.defineProperty,Za=(e,a,t)=>((e,a,t)=>a in e?Ya(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const et=new class{constructor(){Za(this,"errors",[]),Za(this,"toastCount",0),Za(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);l.toast.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){l.toast.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 at=Object.defineProperty,tt=(e,a,t)=>((e,a,t)=>a in e?at(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const st=(void 0).VITE_SUPABASE_URL,rt=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,nt=class e{constructor(){tt(this,"client"),tt(this,"currentToken",null),tt(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:rt};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return b.createClient(st,rt,{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=Ja.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 et.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};tt(nt,"instance");let it=nt;function ot(){return it.getInstance().getClient()}class lt{static async generateToken(e,a,t,s=!1){try{if(!s){const e=Ja.getSupabaseToken();if(e&&Ja.isSupabaseTokenValid())return e}const r=ot(),{data:n,error:i}=await r.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?(Ja.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}var dt=Object.defineProperty,ct=(e,a,t)=>((e,a,t)=>a in e?dt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class ut{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Ja.getAccessToken(),a=Ja.getSelectedAlias();if(!e||!a)return null;const t=await lt.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(Ja.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}ct(ut,"isRegenerating",!1),ct(ut,"onLogoutCallback",null);class mt{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Ja.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 pt=Object.defineProperty;class ht{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 ut.attemptRegeneration()?(this.isRetrying=!1,!0):(mt.handleError(e),this.isRetrying=!1,!1)}catch(s){return mt.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Ja.getAccessToken();return e?Ja.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?pt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(ht,"isRetrying",!1);var xt=Object.defineProperty,ft=(e,a,t)=>((e,a,t)=>a in e?xt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const gt=new class{constructor(){ft(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=ht.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Ja.getAccessToken();if(!r)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 ${r}`,"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 s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return et.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=t}if(!Array.isArray(s))return et.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(t){if(await ht.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return et.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=t}return Array.isArray(s)?s.map(this.mapToQualiexUser):(et.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return et.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return et.handleError(r,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return et.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),s=new Map;return t.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const a=Ja.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},bt={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},vt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},jt={debounceDelay:500},yt=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV},Nt={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},wt=()=>Nt,Ct={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},kt={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 St(e,a){const t=wt(),s=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Tt(e,a){const t=wt(),s=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Pt(e,a){const t=wt(),s=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function At(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||St(e.idField),emailField:e.emailField||Tt(e.idField),usernameField:e.usernameField||Pt(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:St(e),emailField:Tt(e),usernameField:Pt(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const It=new Map;class _t{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=It.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await gt.fetchUsers(e,a);return It.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[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 s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||n.displayName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!Ja.areAllTokensValid())return e;const t=Ja.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=At(a.userIdFields,a.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(s,r),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(t){return et.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 Et=["responsible_name"],Mt=e=>Et.includes(e);function Rt(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!Ja.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return ot().schema(o).from(r)},u=(e,a,t,s)=>{let r=c().select(i||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const o=a.includes(".");return o||Mt(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:o}},m=async(e,a,t,r,n)=>{const i=At(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(Mt(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 _t.enrichWithUserData(i.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=o?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t,n=e.slice(s,r);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await _t.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.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:s="desc",page:r=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:i}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,i,o),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let b=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=At(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(b.data)){const e=await m(b.data,t,n,i,o);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Ae(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Ae(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},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 ${r}: ${t.message}`)}}}const Dt=()=>{Ja.clearManualLogout()},zt=e=>e?.placeId||null,Ft=e=>e?.placeName||null,Lt=e=>({placeId:zt(e),placeName:Ft(e)}),Ot=class{static async initialize(){try{if(!Ja.hasAllTokens()||!Ja.areAllTokensValid())return Ja.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=Ja.getAccessToken(),t=Ja.getIdToken();Dt();const s=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=Ja.extractTokenData(),o=i?.alias;let l=null;if(o&&r.some(e=>e.alias===o))l=o;else{const e=Ja.getSelectedAlias(),a=e&&r.some(a=>a.alias===e);l=a?e:n||r[0]?.alias||null}!Ja.isSupabaseTokenValid()&&l&&await ut.attemptRegeneration();let d=null;if(l){const e=Ja.getCompanyId(l),a=r.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,u=null;if(s?.id&&l){const a=Ja.getCompanyId(l);if(a)try{const e=(await gt.fetchActiveUsersMap(l,a)).get(s.id);if(e){const a=Lt(e);c=a.placeId,u=a.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:s,alias:l,companies:r,selectedUnit:d,userId:s?.id||null,userAlias:s?.id||null,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}}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=ot(),{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 s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Ja.generateOAuthState();Ja.setOAuthState(e);const a=Ja.generateOAuthNonce();Ja.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(bt.oauth.authUrl);s.searchParams.set("client_id",bt.oauth.clientId),s.searchParams.set("response_type",bt.oauth.responseType),s.searchParams.set("scope",bt.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),yt(),window.location.href=s.toString()}static async processCallback(){try{if(Ja.hasAllTokens()){if(!Ja.getValidSupabaseToken()){Ja.getAccessToken();await ut.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),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");Ja.setAccessToken(s),Ja.setIdToken(r),Dt();const i=this.extractAliasFromAccessToken(s);if(i)Ja.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Ja.setSelectedAlias(e[0].alias)}if(!await ut.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Ja.clearOAuthState(),Ja.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Ja.setManualLogout(),Ja.clearAll(),window.location.href="/login"}static decodeToken(e){return Ba.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 s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};ut.setLogoutCallback(()=>{Ot.logout()});let Ut=Ot;const qt=a.createContext(void 0),$t=({children:t})=>{const[s,r]=a.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=v.useQueryClient()}catch{}const[i,o]=a.useState(!1),[l,d]=a.useState(0),c=a.useCallback(e=>{r(a=>({...a,...e}))},[]),u=a.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),m=a.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=a.useCallback(async e=>{try{u(!0);const t=Ja.getAccessToken();if(!t)return;const r=await lt.generateToken(t,e.alias,void 0,!0);if(!r)return;Ja.setSupabaseToken(r),Ja.setSelectedAlias(e.alias);const i=Ja.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Ja.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let m=null,p=null;if(s.user?.id&&o&&l)try{const e=(await gt.fetchActiveUsersMap(o,l)).get(s.user.id);if(e){const a=Lt(e);m=a.placeId,p=a.placeName}}catch(a){}c({alias:o,selectedUnit:d,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{u(!1)}},[c,n,u,s.user]),h=a.useCallback(async()=>await Ut.processCallback(),[]),x=a.useCallback(async()=>{Ut.logout(),m(),n&&await n.clear()},[m,n]),f=a.useCallback(e=>{o(e)},[]),g=a.useCallback(()=>{d(e=>e+1)},[]),b=a.useCallback(()=>{d(e=>e+1)},[]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Ja.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Ut.initialize();if(!e)return;a&&a.isAuthenticated?c({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&&u(!1)}catch(a){e&&(mt.handleError(a),u(!1))}})(),()=>{e=!1}},[c,u,x]);const j=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,x,h,p,i,f,g,b]);return e.jsx(qt.Provider,{value:j,children:t})},Bt=()=>{const e=a.useContext(qt);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Wt({queryKey:e,service:t,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:i}){const[o,d]=j.useSearchParams(),c=v.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Bt(),h=a.useCallback(a=>{const t=`${e}_${a}`,s=o.get(t);return s||(o.get(a)||"")},[o,e]),x=h("search"),f=h("sortField")||vt.sorting.defaultField,g=h("sortDirection")||vt.sorting.defaultDirection,b=parseInt(h("page")||"1"),y=parseInt(h("limit")||String(vt.pagination.defaultPageSize)),N=x,w=a.useMemo(()=>({search:N,sortField:f,sortDirection:g,page:b,limit:y,...n}),[N,f,g,b,y,n]),C=a.useCallback(()=>t.getAll(w),[t,w]),k=v.useQuery({queryKey:[e,u,m,w],queryFn:C,enabled:!!u&&p});if(!k)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const S=v.useMutation({mutationFn:t.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(kt.success.created(s)),i?.()},onError:e=>{l.toast.error(`${kt.error.create(s)}: ${e.message}`)}}),T=v.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(kt.success.updated(s)),i?.()},onError:e=>{l.toast.error(`${kt.error.update(s)}: ${e.message}`)}}),P=v.useMutation({mutationFn:t.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(kt.success.deleted(s))},onError:e=>{l.toast.error(`${kt.error.delete(s)}: ${e.message}`)}}),A=a.useCallback(a=>{const t={...Object.fromEntries(o)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[o,d,e]),I=a.useCallback(e=>{A({search:e,page:1})},[A]),_=a.useCallback(e=>{A({sortField:e,sortDirection:f===e&&"asc"===g?"desc":"asc",page:1})},[f,g,A]),E=a.useCallback(e=>{A({page:e})},[A]),M=a.useCallback(e=>{A({limit:e,page:1})},[A]),R=a.useCallback(()=>{const a=Object.fromEntries(o),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,o,e]),[D,z]=a.useState([]),F=a.useCallback(e=>{z(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=a.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];z(a=>a.length===e.length?[]:e)},[k?.data?.data]),O=a.useCallback(()=>{z([])},[]),U=a.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&D.length===e.length},[D,k?.data?.data]),q=v.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(`${t.length} ${s}(s) deletado(s) com sucesso`),O()},onError:e=>{l.toast.error(`Erro ao deletar itens: ${e.message}`)}}),$=a.useCallback((e,a)=>{const t=a?a(e):e;e.id?T.mutate({id:e.id,data:t}):S.mutate({...t,alias:u})},[u,S,T]);return{entities:k?.data?.data||[],pagination:{data:k?.data?.data||[],currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||vt.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:P?.isPending??!1,error:k?.error||null,searchTerm:x,sortField:f,sortDirection:g,currentPage:b,itemsPerPage:y,queryKey:e,createEntity:S.mutate,updateEntity:(e,a)=>T.mutate({id:e,data:a}),deleteEntity:P.mutate,save:$,handleSearch:I,handleSort:_,handlePageChange:E,handleItemsPerPageChange:M,clearFilters:R,refetch:k.refetch,selectedIds:D,selectItem:F,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}const Vt=ee.forwardRef(({className:a,...t},s)=>e.jsx("table",{ref:s,className:Pe("w-full caption-bottom text-sm table-fixed",a),...t}));Vt.displayName="Table";const Ht=ee.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:Pe("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Ht.displayName="TableHeader";const Gt=ee.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:Pe("[&_tr:last-child]:border-0",a),...t}));Gt.displayName="TableBody";const Qt=ee.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:Pe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Qt.displayName="TableFooter";const Kt=ee.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:Pe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Kt.displayName="TableRow";const Xt=ee.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:Pe("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}));Xt.displayName="TableHead";const Jt=ee.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:Pe("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));Jt.displayName="TableCell";const Yt=ee.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:Pe("mt-4 text-sm text-muted-foreground",a),...t}));function Zt({rows:a=5,columns:t=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((a,t)=>e.jsx(La,{className:"h-4 w-24"},t))})}),e.jsx("div",{children:Array.from({length:a}).map((a,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((a,t)=>e.jsx(La,{className:"h-4 w-20"},t))})},s))})]})})}function es({count:a=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:a}).map((a,t)=>e.jsxs(ze,{children:[e.jsxs(Fe,{children:[e.jsx(La,{className:"h-4 w-3/4"}),e.jsx(La,{className:"h-3 w-1/2"})]}),e.jsx(Ue,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(La,{className:"h-3 w-full"}),e.jsx(La,{className:"h-3 w-2/3"})]})})]},t))})}Yt.displayName="TableCaption";const as={default:d.FileX,search:d.Search,error:d.AlertCircle};function ts({icon:a,title:t,description:s,action:r,className:n,variant:i="default"}){const o=a?()=>a:as[i];return e.jsxs("div",{className:Pe("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e.jsx(o,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(_e,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ss=({delayDuration:a=300,...t})=>e.jsx(oe.Provider,{delayDuration:a,...t}),rs=oe.Root,ns=oe.Trigger,is=ee.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(oe.Content,{ref:r,sideOffset:t,className:Pe("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),...s}));function os({children:a,className:t}){const s=ee.useRef(null),[r,n]=ee.useState(!1);ee.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[a]);const i=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:a});return r?e.jsx(ss,{delayDuration:300,children:e.jsxs(rs,{children:[e.jsx(ns,{asChild:!0,children:i}),e.jsx(is,{side:"top",className:"max-w-[400px] break-words",children:a})]})}):i}is.displayName=oe.Content.displayName;const ls=ee.forwardRef(({direction:a,onMouseDown:t,isDragging:s,className:r},n)=>{const i="horizontal"===a;return e.jsx("div",{ref:n,onMouseDown:t,className:Pe("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"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Pe("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});ls.displayName="TableResizeHandle";const ds=le.Root,cs=le.Trigger,us=le.Group,ms=le.Portal,ps=le.Sub,hs=le.RadioGroup,xs=ee.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Pe("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));xs.displayName=le.SubTrigger.displayName;const fs=ee.forwardRef(({className:a,...t},s)=>e.jsx(le.SubContent,{ref:s,className:Pe("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}));fs.displayName=le.SubContent.displayName;const gs=ee.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:r,sideOffset:t,className:Pe("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),...s})}));gs.displayName=le.Content.displayName;const bs=ee.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Item,{ref:r,className:Pe("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),...s}));bs.displayName=le.Item.displayName;const vs=ee.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Pe("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",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));vs.displayName=le.CheckboxItem.displayName;const js=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));js.displayName=le.RadioItem.displayName;const ys=ee.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));ys.displayName=le.Label.displayName;const Ns=ee.forwardRef(({className:a,...t},s)=>e.jsx(le.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));Ns.displayName=le.Separator.displayName;const ws=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest opacity-60",a),...t});ws.displayName="DropdownMenuShortcut";const Cs=de.Root,ks=de.Trigger,Ss=de.Group,Ts=de.Portal,Ps=de.Sub,As=de.RadioGroup,Is=ee.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(de.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Is.displayName=de.SubTrigger.displayName;const _s=ee.forwardRef(({className:a,...t},s)=>e.jsx(de.SubContent,{ref:s,className:Pe("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}));_s.displayName=de.SubContent.displayName;const Es=ee.forwardRef(({className:a,...t},s)=>e.jsx(de.Portal,{children:e.jsx(de.Content,{ref:s,className:Pe("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})}));Es.displayName=de.Content.displayName;const Ms=ee.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(de.Item,{ref:r,className:Pe("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),...s}));Ms.displayName=de.Item.displayName;const Rs=ee.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(de.CheckboxItem,{ref:n,className:Pe("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",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(de.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));Rs.displayName=de.CheckboxItem.displayName;const Ds=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(de.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(de.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Ds.displayName=de.RadioItem.displayName;const zs=ee.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(de.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...s}));zs.displayName=de.Label.displayName;const Fs=ee.forwardRef(({className:a,...t},s)=>e.jsx(de.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-border",a),...t}));Fs.displayName=de.Separator.displayName;const Ls=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Ls.displayName="ContextMenuShortcut";const Os=({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:i=[],renderAs:o})=>{const{t:l}=g.useTranslation(),c=[];if(a){const e={icon:d.Edit,label:l("edit"),onClick:a};c.push(e)}if(i.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:l(r?"deactivate":"activate"),onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===o?bs:Ms;return e.jsx(e.Fragment,{children:c.map((a,t)=>e.jsxs(u,{onClick:a.onClick,className:Pe("whitespace-normal cursor-pointer",a.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(a.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.label]},t))})},Us=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:i=[]})=>e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(_e,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(d.EllipsisVertical,{size:12})})}),e.jsx(gs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Os,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:i,renderAs:"dropdown"})})]}),qs=150;function $s({columns:e,storageKey:t,onResize:s,enabled:r=!0}){const[n,i]=a.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??qs,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??qs,e),{})}),[o,l]=a.useState(!1),[d,c]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??qs)},[r,n]);a.useEffect(()=>{if(!o||!d)return;const a=e.find(e=>e.key===d),r=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));i(e=>{const a={...e,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(null),t&&i(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[o,d,e,t,s]),a.useEffect(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const h=a.useCallback(()=>{const a=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??qs,e),{});i(a),t&&localStorage.removeItem(t),s?.(a)},[e,t,s]);return{columnWidths:n,isDragging:o,activeColumn:d,handleMouseDown:p,resetWidths:h}}function Bs({rowIds:e,defaultHeight:t=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:i,enabled:o=!0}){const[l,d]=a.useState(()=>{if(!o||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{o&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[o,l,t]);a.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return i?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=a.useCallback(()=>{d({}),n&&localStorage.removeItem(n),i?.({})},[n,i]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}}const Ws=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(ja,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),Vs=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f=!1,enableColumnResize:b=!0,resizeStorageKey:v})=>{const{t:j}=g.useTranslation(),{setSearchVisible:y}=Bt(),[N,w]=a.useState(!1);a.useEffect(()=>(y(!0),()=>y(!1)),[y]),a.useEffect(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:T}=$s({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:v?`${v}-columns`:void 0,enabled:b}),{isDragging:P,activeRow:A,handleMouseDown:I,getRowHeight:_}=Bs({rowIds:t.entities.map(e=>e.id),storageKey:v?`${v}-rows`:void 0,enabled:!1}),E=a.useMemo(()=>(()=>{if(b)return s.map(e=>{const a=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=s.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,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`}})})(),[s,b,C]),M=!f&&(m||x.length>0);return N?t.isLoading?e.jsx(es,{count:3}):0===t.entities.length?e.jsx(ts,{title:j("empty_title"),description:j("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||j("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(a=>e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(ze,{className:Pe("overflow-hidden cursor-pointer hover:bg-muted/50",u&&t.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:e.jsx(Ue,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Ws,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(t=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Us,{onEdit:r?()=>{r(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})})})}),e.jsx(Es,{className:"w-[160px]",children:e.jsx(Os,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||j("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),t.isLoading?e.jsx(Zt,{rows:5,columns:s.length}):e.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(Vt,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),E.map((a,t)=>e.jsx("col",{style:a.style},t)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Ht,{children:e.jsxs(Kt,{children:[u&&e.jsx(Xt,{className:"w-[50px]",children:e.jsx(Ws,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),s.map(a=>{const s=b&&!1!==a.resizable,r=S===String(a.key);return e.jsxs(Xt,{className:Pe(a.className,a.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:a.sortable?()=>t.handleSort(String(a.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(n=String(a.key),t.sortField!==n?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(ls,{direction:"horizontal",onMouseDown:e=>T(String(a.key),e),isDragging:r})]},String(a.key));var n}),e.jsx(Xt,{className:"w-[50px] text-center",children:j("actions")})]})}),e.jsx(Gt,{children:0===t.entities.length?e.jsx(Kt,{children:e.jsx(Jt,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(ts,{title:j("empty_title"),description:j("empty_description"),variant:"search"})})}):t.entities.map(a=>{const n=_(a.id);return a.id,e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(Kt,{className:Pe("cursor-pointer hover:bg-muted/50 relative",u&&t.selectedIds.includes(a.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:[u&&e.jsx(Jt,{onClick:e=>e.stopPropagation(),children:e.jsx(Ws,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),s.map(t=>e.jsx(Jt,{className:t.className,children:e.jsx(os,{children:t.render?t.render(a):String(a[t.key]??"")})},String(t.key))),e.jsx(Jt,{className:"text-center",children:l?l(a):e.jsx(Us,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})}),e.jsx(Es,{className:"w-[160px]",children:e.jsx(Os,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})]})})})]})};function Hs(e,t,s,r){const[n,i]=a.useState({}),[o,l]=a.useState({}),d=a.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=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{}}},m=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};a.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},a=e(d),n={};a.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);c(e)&&(a=e.toISOString().split("T")[0])}else c(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),t&&Object.keys(t).forEach(e=>{a.find(a=>a.name===e)||void 0===t[e]||(n[e]=t[e])}),i(n),l({}),s&&s(n)},[d,t,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:o,updateField:(e,a)=>{i(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),o[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Gs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Qs=({value:a="#3b82f6",onChange:t,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(De,{children:s}),e.jsxs(Ta,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:a}}),a]})}),e.jsx(Aa,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(De,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Me,{id:"color-input",type:"color",value:a,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(De,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Gs.map(a=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>t?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),Ks=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ce.Root,{ref:r,className:Pe("relative overflow-hidden",a),...s,children:[e.jsx(ce.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(Xs,{}),e.jsx(ce.Corner,{})]}));Ks.displayName=ce.Root.displayName;const Xs=ee.forwardRef(({className:a,orientation:t="vertical",...s},r)=>e.jsx(ce.ScrollAreaScrollbar,{ref:r,orientation:t,className:Pe("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),...s,children:e.jsx(ce.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Xs.displayName=ce.ScrollAreaScrollbar.displayName;const Js={Star:d.Star,Heart:d.Heart,Home:d.Home,User:d.User,Settings:d.Settings,Mail:d.Mail,Phone:d.Phone,Calendar:d.Calendar,MapPin:d.MapPin,Camera:d.Camera,Image:d.Image,Music:d.Music,Video:d.Video,Book:d.Book,Bookmark:d.Bookmark,Search:d.Search,Filter:d.Filter,Edit:d.Edit,Trash2:d.Trash2,Plus:d.Plus,Minus:d.Minus,Check:d.Check,X:d.X,ChevronDown:d.ChevronDown,ChevronUp:d.ChevronUp,ChevronLeft:d.ChevronLeft,ChevronRight:d.ChevronRight,ArrowUp:d.ArrowUp,ArrowDown:d.ArrowDown,ArrowLeft:d.ArrowLeft,ArrowRight:d.ArrowRight,Clock:d.Clock,Bell:d.Bell,AlertCircle:d.AlertCircle,Info:d.Info,HelpCircle:d.HelpCircle,Download:d.Download,Upload:d.Upload,Share:d.Share,Copy:d.Copy,Save:d.Save,FileText:d.FileText,Folder:d.Folder,FolderOpen:d.FolderOpen,Archive:d.Archive,Lock:d.Lock,Unlock:d.Unlock,Eye:d.Eye,EyeOff:d.EyeOff,Shield:d.Shield,Key:d.Key,Zap:d.Zap,Flame:d.Flame,Sparkles:d.Sparkles,Award:d.Award,Trophy:d.Trophy,Target:d.Target},Ys=({value:t="Star",onChange:s,label:r})=>{const{t:n}=g.useTranslation(),[i,o]=a.useState(""),l=Object.entries(Js).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),c=Js[t]||d.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(De,{children:r}),e.jsxs(Ta,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),t]})}),e.jsx(Aa,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(De,{htmlFor:"icon-search",children:n("search")}),e.jsx(Me,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e.jsx(Ks,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:l.map(([a,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(a),title:a,children:e.jsx(r,{className:"h-4 w-4"})},a))})})]})})]})]})},Zs=ee.forwardRef(({className:a,...t},s)=>e.jsx(ue.Root,{className:Pe("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:s,children:e.jsx(ue.Thumb,{className:Pe("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")})}));Zs.displayName=ue.Root.displayName;const er=(e={})=>{const{user:a,alias:t}=Bt(),{enabled:s=!0}=e;return v.useQuery({queryKey:["qualiex-users",t],queryFn:()=>gt.getUsers(t),enabled:s&&!!t&&!!a,retry:2,retryDelay:1e3})},ar=({value:t,onChange:s,multiple:r=!1,label:n,required:i,placeholder:o,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:x,sortOptions:f=!0,popoverContainer:b,onOpen:v,onClose:j})=>{const{t:y}=g.useTranslation(),{data:N=[],isLoading:w,error:C}=er({enabled:m}),k=a.useMemo(()=>x?N.filter(x):N,[N,x]),S=a.useCallback(e=>{if("custom"===p&&h)return h(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,h]);return e.jsx(qa,{multiple:r,value:t??(r?[]:""),onChange:s,options:k,isLoading:w,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:S,placeholder:o||y("search_placeholder"),searchPlaceholder:y("search_placeholder"),emptyMessage:y("no_results"),label:n,required:i,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:f,popoverContainer:b,onOpen:v,onClose:j})};function tr({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(s?.[0]?.id||""),h=a.useRef(null),[x,f]=a.useState(null),b=a.useCallback(e=>{h.current=e,f(e)},[]),v=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:j,errors:y,updateField:N,handleSubmit:w}=Hs(v,r,void 0,o),C=a.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(j):e.disabled||!1})):[],[s,j]),k=a.useMemo(()=>{const e=C.find(e=>e.id===m);if(e&&!e.disabled)return m;const a=C.find(e=>!e.disabled);return a?.id||m},[C,m]);a.useEffect(()=>{k!==m&&p(k)},[k,m]);const S=C.find(e=>e.id===k),T=a=>{const t=(a.computedValue,j[a.name]),s=void 0!==t?t:"",r=y[a.name];switch(a.type){case"group":const t="horizontal"===a.layout,n=t?`flex gap-3 w-full ${a.className||""}`:"space-y-3",i=t?Pe("space-y-2 w-full",a.wrapperClassName):Pe("space-y-2",a.className,a.wrapperClassName);return e.jsxs("div",{className:i,children:[a.label,e.jsx("div",{className:n,children:a.fields?.map(e=>T(e))})]},a.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ar,{value:s||"",onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(ca,{value:String(s),onValueChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e.jsx(pa,{className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ma,{placeholder:a.placeholder})}),e.jsx(fa,{children:a.options?.map(a=>e.jsx(ba,{value:a.value,children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(qa,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"date":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:a.name,type:"date",value:String(s),onChange:e=>N(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Pe("w-full",r?"border-destructive":"",a.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":return e.jsxs("div",{children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>N(a.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Qs,{value:s||a.defaultValue||"#3b82f6",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ys,{value:s||a.defaultValue||"Star",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"custom":if(!a.component)return null;const o=a.component,l="function"==typeof a.componentProps?a.componentProps(j):a.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(o,{value:s,onChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:r,popoverContainer:x,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"number":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,s=""===t?null:Number(t);N(a.name,s)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e.jsx(ja,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),e.jsxs(De,{htmlFor:a.name,className:"cursor-pointer",children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Zs,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},a.name);default:return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(De,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:a.name,type:"text",value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},P=a.useCallback(()=>{if(!S)return null;if(S.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("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(S.component){const a=S.component;return e.jsx(a,{formData:j,updateField:N,errors:y,users:c,disabled:S.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:S.fields.map(T)})},[S,j,N,y,c,T]),A=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[C.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:C.map(a=>e.jsx(_e,{variant:k===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=C.find(a=>a.id===e);a&&!a.disabled&&p(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:u("loading")})}):e.jsxs("form",{onSubmit:w(n),className:"space-y-3 md:space-y-4",children:[P(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(_e,{type:"button",variant:"outline",onClick:i,children:u("cancel")}),e.jsx(_e,{type:"submit",disabled:d,children:l||u("save")})]})]})})]});return e.jsx(Be,{open:o,onOpenChange:e=>{!1===e&&!0===o&&i()},children:e.jsxs(Ke,{ref:b,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Xe,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e.jsx(Ze,{children:t}),e.jsx(ea,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),A]})})}function sr({currentPage:a,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:i,variant:o="full"}){const l=(a-1)*r+1,c=Math.min(a*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),e.jsxs(ca,{value:String(r),onValueChange:e=>i(Number(e)),children:[e.jsx(pa,{className:"h-8 w-[70px]",children:e.jsx(ma,{})}),e.jsxs(fa,{children:[e.jsx(ba,{value:"10",children:"10"}),e.jsx(ba,{value:"25",children:"25"}),e.jsx(ba,{value:"50",children:"50"}),e.jsx(ba,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[l,"-",c," de ",s," itens"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsLeft,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a-1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:a}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:t})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a+1),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronRight,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsRight,{size:16})})]})]})}function rr({manager:a}){return e.jsx(sr,{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 nr=({selectedCount:a,onClearSelection:t,onBulkDelete:s,customActions:r=[],isLoading:n=!1})=>{const{t:i}=g.useTranslation();return e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:i("selected_count",{count:a})}),e.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[e.jsx(d.X,{size:14,className:"mr-1"}),i("clear")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:n,className:"h-7",children:[s&&e.jsx(s,{size:14,className:"mr-1"}),a.label]},t)}),s&&e.jsxs(_e,{variant:"destructive",size:"sm",onClick:s,disabled:n,className:"h-7",children:[e.jsx(d.Trash2,{size:14,className:"mr-1"}),i("delete")]})]})]})},ir={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},or={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},lr={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function dr({children:a,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:i=!1,className:o}){return e.jsx("div",{className:Pe("flex","column"===t?"flex-col":"flex-row",ir[s],or[r],lr[n],i&&"flex-wrap",o),children:a})}function cr({manager:a,filters:t,inline:s=!1}){const{t:r}=g.useTranslation(),{isSearchVisible:n}=Bt(),i=a.searchTerm,o=e.jsxs(e.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Me,{placeholder:r("search"),value:a.searchTerm,onChange:e=>a.handleSearch(e.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((a,t)=>e.jsxs("select",{value:a.value||"",onChange:e=>a.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:[a.placeholder&&e.jsx("option",{value:"",children:a.placeholder}),a.options.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...a.props})},`custom-${t}`)}),i&&e.jsxs(_e,{variant:"outline",onClick:a.clearFilters,className:"whitespace-nowrap",children:[e.jsx(d.X,{className:"h-4 w-4 mr-2"}),r("clear")]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(dr,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(dr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function ur({manager:t,config:s,formSections:r,onSave:n,onToggleStatus:i,defaultSort:o}){t&&t.queryKey;const{t:l}=g.useTranslation(),{setSearchVisible:c}=Bt(),[u,m]=j.useSearchParams(),[p,h]=a.useState(!1),[x,f]=a.useState(null),[b,v]=a.useState({isOpen:!1,entityId:null,entityName:""}),[y,N]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(o&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=o.column,t[a]=o.direction,m(t)}}},[]);const w=()=>{v({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[s.enableBulkActions&&t.selectedIds.length>0&&e.jsx(nr,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:s.bulkActions&&s.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:t.selectedIds.length})},customActions:s.bulkActions,isLoading:t.isBulkDeleting}),e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[!s.hideNewButton&&e.jsxs(_e,{onClick:()=>{s.onNew?s.onNew():(f(null),h(!0))},children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),l("new")]}),s.customActions?.map((a,t)=>e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e.jsx(a.icon,{size:16,className:"mr-2"}),a.label]},t))]}),s.filters&&s.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(cr,{manager:t,filters:s.filters,inline:!0})})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(t.entities,t)}):e.jsx(Vs,{manager:t,columns:s.columns,onEdit:e=>{s.onEdit?s.onEdit(e):(f(e),h(!0))},onDelete:e=>{v({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(rr,{manager:t})}),!s.useCustomRouting&&!s.onNew&&e.jsx(tr,{open:p,title:x?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:x||void 0,onSubmit:e=>{n(e),h(!1),f(null)},onCancel:()=>{h(!1),f(null)},isLoading:t.isLoading,submitButtonText:l(x?"update":"create")}),e.jsx(Be,{open:b.isOpen,onOpenChange:w,children:e.jsxs(Ke,{size:"sm",children:[e.jsx(Xe,{showSeparator:!0,children:e.jsx(Ze,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:b.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Ye,{children:[e.jsx(_e,{variant:"outline",onClick:w,children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{b.entityId&&(t.deleteEntity(b.entityId),v({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(Be,{open:y.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),children:e.jsxs(Ke,{size:"sm",children:[e.jsx(Xe,{showSeparator:!0,children:e.jsx(Ze,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:y.count})," ",1===y.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Ye,{children:[e.jsx(_e,{variant:"outline",onClick:()=>N({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),N({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function mr(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 pr(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const hr=s.cva("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"}}),xr={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},fr=ee.forwardRef(({className:a,variant:t="info",showIcon:s=!0,children:r,...n},i)=>{const o=xr[t||"info"];return e.jsxs("div",{ref:i,role:"alert",className:Pe(hr({variant:t}),a),...n,children:[s&&e.jsx(o,{className:"h-4 w-4"}),r]})});fr.displayName="Alert";const gr=ee.forwardRef(({className:a,...t},s)=>e.jsx("h5",{ref:s,className:Pe("mb-1 font-medium leading-none tracking-tight",a),...t}));gr.displayName="AlertTitle";const br=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-sm [&_p]:leading-relaxed",a),...t}));br.displayName="AlertDescription";const vr=a.createContext(void 0);function jr({children:t,actions:s}){const[r,n]=a.useState({}),[i,o]=a.useState(s);return a.useEffect(()=>{o(s)},[s]),e.jsx(vr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:i,setHeaderActions:o},children:t})}function yr(){const e=a.useContext(vr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const Nr=(void 0).VITE_SUPABASE_URL,wr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Cr=null;var kr=Object.defineProperty,Sr=(e,a,t)=>((e,a,t)=>a in e?kr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Tr=new class{constructor(){Sr(this,"cache",{}),Sr(this,"cacheTimestamps",new Map),Sr(this,"CACHE_TTL",3e5),Sr(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=(!Cr&&Nr&&wr&&(Cr=b.createClient(Nr,wr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Cr),{data:t,error:s}=await a.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(s)return"42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied")||s.message?.includes("No suitable key"),{};const r={};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&&(r[a.key]=t)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(a){return{}}}async upsertTranslation(e,a,t,s){const r=ot(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=ot(),{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 Pr=Object.defineProperty,Ar=(e,a,t)=>((e,a,t)=>a in e?Pr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Ir="true"===(void 0).VITE_I18N_DEBUG_MODE;o.use(new class{constructor(e=!1){Ar(this,"type","backend"),Ar(this,"isDebugMode"),Ar(this,"cache",new Map),Ar(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 s=Tr.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,s),s.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,s){}}(Ir)).use(g.initReactI18next).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Ir?`[${e} ❌]`:`[⚠️ ${e}]`});const _r=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Er=[{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"}],Mr=[{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"}],Rr="pt-BR",Dr="dd/MM/yyyy HH:mm",zr="America/Sao_Paulo",Fr=e=>_r.some(a=>a.value===e),Lr=e=>Mr.some(a=>a.value===e),Or=()=>{if("undefined"==typeof navigator)return Rr;const e=navigator.language;if(Fr(e))return e;const a=e.split("-")[0],t=_r.find(e=>e.value.startsWith(a));return t?.value||Rr},Ur=()=>{if("undefined"==typeof Intl)return zr;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Lr(e)?e:zr}catch{return zr}},qr=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||Dr),$r=()=>{const e=Or();return{locale:e,timezone:Ur(),datetimeFormat:qr(e)}};const Br=new class{async getUserPreferences(e,a){if(!Ja.areAllTokensValid())return null;const t=ot();try{const{data:s,error:r}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(r)return"PGRST116"===r.code?this.createDefaultPreferences(e,a):("42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied"),null);if(!s)return this.createDefaultPreferences(e,a);const n=s;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(s){return null}}async createDefaultPreferences(e,a){const t=ot(),s=$r(),r={id_user:e,locale:s.locale,timezone:s.timezone,datetime_format:s.datetimeFormat,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(n){throw n}}async updatePreferences(e,a,t){const s=ot();try{const{error:r}=await s.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(r)throw r}catch(r){throw r}}},Wr=a.createContext(void 0),Vr=()=>$r(),Hr=({children:t})=>{const{user:s,alias:r}=Bt(),[n,i]=a.useState(Vr),[l,d]=a.useState(!0);a.useEffect(()=>{(async()=>{if(s?.id&&r)try{const e=await Br.getUserPreferences(s.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await o.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{d(!1)}else d(!1)})()},[s?.id,r]);const c=a.useCallback(async e=>{if(s?.id&&r)try{await Br.updatePreferences(s.id,r,{locale:e}),i(a=>({...a,locale:e})),await o.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[s?.id,r]),u=a.useCallback(async e=>{if(s?.id&&r)try{await Br.updatePreferences(s.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[s?.id,r]),m=a.useCallback(async e=>{if(s?.id&&r)try{await Br.updatePreferences(s.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[s?.id,r]);return e.jsx(Wr.Provider,{value:{...n,setLocale:c,setTimezone:u,setDatetimeFormat:m,isLoading:l},children:t})},Gr=()=>{const e=a.useContext(Wr);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Qr({children:t}){const{ready:s}=g.useTranslation(),[r,n]=a.useState(!0);return a.useEffect(()=>{s&&r&&n(!1)},[s,r]),r&&!s?e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(ka,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:t})}const Kr=me.Root,Xr=me.CollapsibleTrigger,Jr=me.CollapsibleContent;var Yr=Object.defineProperty,Zr=(e,a,t)=>((e,a,t)=>a in e?Yr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class en extends a.Component{constructor(e){super(e),Zr(this,"copyErrorDetails",()=>{const e=et.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),l.toast.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((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if((void 0).DEV)throw e;et.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=et.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(ze,{className:"w-full max-w-2xl",children:[e.jsxs(Fe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(Le,{children:"Algo deu errado"})]}),e.jsxs(Ue,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),e.jsxs(Kr,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Xr,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Jr,{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e.jsx(Ks,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:a.map((a,t)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(a.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),e.jsxs(_e,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(_e,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const an=pe.Root,tn=ee.forwardRef(({className:a,...t},s)=>e.jsx(pe.Item,{ref:s,className:Pe("border-b",a),...t}));tn.displayName="AccordionItem";const sn=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Header,{className:"flex",children:e.jsxs(pe.Trigger,{ref:r,className:Pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[t,e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));sn.displayName=pe.Trigger.displayName;const rn=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e.jsx("div",{className:Pe("pb-4 pt-0",a),children:t})}));rn.displayName=pe.Content.displayName;const nn=he.Root,on=he.Trigger,ln=he.Portal,dn=ee.forwardRef(({className:a,...t},s)=>e.jsx(he.Overlay,{className:Pe("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:s}));dn.displayName=he.Overlay.displayName;const cn=ee.forwardRef(({className:a,...t},s)=>e.jsxs(ln,{children:[e.jsx(dn,{}),e.jsx(he.Content,{ref:s,className:Pe("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",a),...t})]}));cn.displayName=he.Content.displayName;const un=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",a),...t});un.displayName="AlertDialogHeader";const mn=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});mn.displayName="AlertDialogFooter";const pn=ee.forwardRef(({className:a,...t},s)=>e.jsx(he.Title,{ref:s,className:Pe("text-lg font-semibold",a),...t}));pn.displayName=he.Title.displayName;const hn=ee.forwardRef(({className:a,...t},s)=>e.jsx(he.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));hn.displayName=he.Description.displayName;const xn=ee.forwardRef(({className:a,...t},s)=>e.jsx(he.Action,{ref:s,className:Pe(Ie(),a),...t}));xn.displayName=he.Action.displayName;const fn=ee.forwardRef(({className:a,...t},s)=>e.jsx(he.Cancel,{ref:s,className:Pe(Ie({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));fn.displayName=he.Cancel.displayName;const gn=ee.forwardRef(({className:a,...t},s)=>e.jsx(xe.Root,{ref:s,className:Pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));gn.displayName=xe.Root.displayName;const bn=ee.forwardRef(({className:a,...t},s)=>e.jsx(xe.Image,{ref:s,className:Pe("aspect-square h-full w-full",a),...t}));bn.displayName=xe.Image.displayName;const vn=ee.forwardRef(({className:a,...t},s)=>e.jsx(xe.Fallback,{ref:s,className:Pe("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));vn.displayName=xe.Fallback.displayName;const jn=ee.forwardRef(({...a},t)=>e.jsx("nav",{ref:t,"aria-label":"breadcrumb",...a}));jn.displayName="Breadcrumb";const yn=ee.forwardRef(({className:a,...t},s)=>e.jsx("ol",{ref:s,className:Pe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));yn.displayName="BreadcrumbList";const Nn=ee.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("inline-flex items-center gap-1.5",a),...t}));Nn.displayName="BreadcrumbItem";const wn=ee.forwardRef(({asChild:a,className:s,...r},n)=>{const i=a?t.Slot:"a";return e.jsx(i,{ref:n,className:Pe("transition-colors hover:text-foreground",s),...r})});wn.displayName="BreadcrumbLink";const Cn=ee.forwardRef(({className:a,...t},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Pe("font-normal text-foreground",a),...t}));Cn.displayName="BreadcrumbPage";const kn=({children:a,className:t,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pe("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:a??e.jsx(d.ChevronRight,{})});kn.displayName="BreadcrumbSeparator";const Sn=({className:a,...t})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Sn.displayName="BreadcrumbEllipsis";const Tn=s.cva("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"}}),Pn=ee.forwardRef(({className:a,orientation:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(Tn({orientation:t}),a),...s}));function An(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function In(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function _n(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.match(r);if(!n)return null;const i=n[0],o=s&&e.parsePatterns[s]||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 En(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[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(r.length)}}}Pn.displayName="ButtonGroup";const Mn={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"}},Rn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Dn={ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:In({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:In({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:In({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:In({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:In({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"})},zn={ordinalNumber:En({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:_n({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:_n({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:_n({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:_n({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:_n({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"})},Fn={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Mn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:{date:An({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:An({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:An({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,s)=>Rn[e],localize:Dn,match:zn,options:{weekStartsOn:0,firstWeekContainsDate:1}},Ln={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"}},On={date:An({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:An({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:An({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Un={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"},qn={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"},$n={ordinalNumber:(e,a)=>Number(e)+"º",era:In({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:In({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:In({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:In({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:In({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"})},Bn={ordinalNumber:En({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:_n({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:_n({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:_n({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:_n({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:_n({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"})},Wn={code:"es",formatDistance:(e,a,t)=>{let s;const r=Ln[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:On,formatRelative:(e,a,t,s)=>1!==a.getHours()?qn[e]:Un[e],localize:$n,match:Bn,options:{weekStartsOn:1,firstWeekContainsDate:1}},Vn={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"}},Hn={date:An({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:An({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:An({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Gn={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"},Qn={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:In({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:In({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:In({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:In({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:In({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"})},Kn={ordinalNumber:En({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:_n({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:_n({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:_n({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:_n({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:_n({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"})},Xn={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Vn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:Hn,formatRelative:(e,a,t,s)=>{const r=Gn[e];return"function"==typeof r?r(a):r},localize:Qn,match:Kn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Jn({className:a,classNames:t,showOutsideDays:s=!0,...r}){return e.jsx(I.DayPicker,{showOutsideDays:s,className:Pe("p-3 pointer-events-auto",a),locale:Xn,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:Pe(Ie({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:Pe(Ie({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})=>"left"===a?e.jsx(d.ChevronLeft,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}Jn.displayName="Calendar";const Yn={Root:function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:s}){return e.jsx(ze,{className:Pe("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:e.jsx(Ue,{className:"p-4",children:a})})},Field:function({label:a,value:t,className:s}){return e.jsxs("div",{className:Pe("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e.jsx("span",{className:"text-foreground",children:t})]})}};const Zn=({shouldScaleBackground:a=!0,...t})=>e.jsx(_.Drawer.Root,{shouldScaleBackground:a,...t});Zn.displayName="Drawer";const ei=_.Drawer.Trigger,ai=_.Drawer.Portal,ti=_.Drawer.Close,si=ee.forwardRef(({className:a,...t},s)=>e.jsx(_.Drawer.Overlay,{ref:s,className:Pe("fixed inset-0 z-50 bg-black/80",a),...t}));si.displayName=_.Drawer.Overlay.displayName;const ri=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ai,{children:[e.jsx(si,{}),e.jsxs(_.Drawer.Content,{ref:r,className:Pe("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",a),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));ri.displayName="DrawerContent";const ni=({className:a,...t})=>e.jsx("div",{className:Pe("grid gap-1.5 p-4 text-center sm:text-left",a),...t});ni.displayName="DrawerHeader";const ii=({className:a,...t})=>e.jsx("div",{className:Pe("mt-auto flex flex-col gap-2 p-4",a),...t});ii.displayName="DrawerFooter";const oi=ee.forwardRef(({className:a,...t},s)=>e.jsx(_.Drawer.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));oi.displayName=_.Drawer.Title.displayName;const li=ee.forwardRef(({className:a,...t},s)=>e.jsx(_.Drawer.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));li.displayName=_.Drawer.Description.displayName;const di={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))]"},ci={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const ui=fe.Root,mi=fe.Trigger,pi=ee.forwardRef(({className:a,align:t="center",sideOffset:s=4,...r},n)=>e.jsx(fe.Content,{ref:n,align:t,sideOffset:s,className:Pe("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),...r}));pi.displayName=fe.Content.displayName;const hi=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Pe("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}));hi.displayName="InputGroup";const xi=s.cva("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"}}),fi=ee.forwardRef(({className:a,align:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Pe(xi({align:t}),a),...s}));fi.displayName="InputGroupAddon";const gi=s.cva("",{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"}}),bi=ee.forwardRef(({className:a,size:t,variant:s="ghost",...r},n)=>e.jsx(_e,{ref:n,"data-slot":"input-group-button",variant:s,className:Pe(gi({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...r}));bi.displayName="InputGroupButton";const vi=ee.forwardRef(({className:a,...t},s)=>e.jsx(Me,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));vi.displayName="InputGroupInput";const ji=ee.forwardRef(({className:a,...t},s)=>e.jsx(ya,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ji.displayName="InputGroupTextarea";const yi=ee.forwardRef(({className:a,...t},s)=>e.jsx("h1",{ref:s,className:Pe("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));yi.displayName="H1";const Ni=ee.forwardRef(({className:a,...t},s)=>e.jsx("h2",{ref:s,className:Pe("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));Ni.displayName="H2";const wi=ee.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));wi.displayName="H3";const Ci=ee.forwardRef(({className:a,...t},s)=>e.jsx("h4",{ref:s,className:Pe("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));Ci.displayName="H4";const ki=ee.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("leading-7 [&:not(:first-child)]:mt-6",a),...t}));ki.displayName="P";const Si=ee.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-xl text-muted-foreground",a),...t}));Si.displayName="Lead";const Ti=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-lg font-semibold",a),...t}));Ti.displayName="Large";const Pi=ee.forwardRef(({className:a,...t},s)=>e.jsx("small",{ref:s,className:Pe("text-sm font-medium leading-none",a),...t}));Pi.displayName="Small";const Ai=ee.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Ai.displayName="Muted";const Ii=ee.forwardRef(({className:a,...t},s)=>e.jsx("code",{ref:s,className:Pe("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));Ii.displayName="InlineCode";const _i=ee.forwardRef(({className:a,...t},s)=>e.jsx("blockquote",{ref:s,className:Pe("mt-6 border-l-2 pl-6 italic",a),...t}));_i.displayName="Blockquote";const Ei=ee.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));Ei.displayName="List";const Mi=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Root,{ref:r,className:Pe("relative z-10 flex max-w-max flex-1 items-center justify-center",a),...s,children:[t,e.jsx(Ui,{})]}));Mi.displayName=ge.Root.displayName;const Ri=ee.forwardRef(({className:a,...t},s)=>e.jsx(ge.List,{ref:s,className:Pe("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));Ri.displayName=ge.List.displayName;const Di=ge.Item,zi=s.cva("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"),Fi=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Trigger,{ref:r,className:Pe(zi(),"group",a),...s,children:[t," ",e.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Fi.displayName=ge.Trigger.displayName;const Li=ee.forwardRef(({className:a,...t},s)=>e.jsx(ge.Content,{ref:s,className:Pe("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}));Li.displayName=ge.Content.displayName;const Oi=ge.Link,Ui=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:Pe("absolute left-0 top-full flex justify-center"),children:e.jsx(ge.Viewport,{className:Pe("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:s,...t})}));Ui.displayName=ge.Viewport.displayName;const qi=ee.forwardRef(({className:a,...t},s)=>e.jsx(ge.Indicator,{ref:s,className:Pe("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.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));qi.displayName=ge.Indicator.displayName;const $i=({className:a,...t})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Pe("mx-auto flex w-full justify-center",a),...t});$i.displayName="Pagination";const Bi=ee.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("flex flex-row items-center gap-1",a),...t}));Bi.displayName="PaginationContent";const Wi=ee.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("",a),...t}));Wi.displayName="PaginationItem";const Vi=({className:a,isActive:t,size:s="icon",...r})=>e.jsx("a",{"aria-current":t?"page":void 0,className:Pe(Ie({variant:t?"outline":"ghost",size:s}),a),...r});Vi.displayName="PaginationLink";const Hi=({className:a,...t})=>e.jsxs(Vi,{"aria-label":"Go to previous page",size:"default",className:Pe("gap-1 pl-2.5",a),...t,children:[e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Hi.displayName="PaginationPrevious";const Gi=({className:a,...t})=>e.jsxs(Vi,{"aria-label":"Go to next page",size:"default",className:Pe("gap-1 pr-2.5",a),...t,children:[e.jsx("span",{children:"Next"}),e.jsx(d.ChevronRight,{className:"h-4 w-4"})]});Gi.displayName="PaginationNext";const Qi=({className:a,...t})=>e.jsxs("span",{"aria-hidden":!0,className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Qi.displayName="PaginationEllipsis";const Ki=ee.forwardRef(({className:a,value:t,...s},r)=>e.jsx(be.Root,{ref:r,className:Pe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...s,children:e.jsx(be.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Ki.displayName=be.Root.displayName;const Xi=ee.forwardRef(({className:a,...t},s)=>e.jsx(ve.Root,{className:Pe("grid gap-2",a),...t,ref:s}));Xi.displayName=ve.Root.displayName;const Ji=ee.forwardRef(({className:a,...t},s)=>e.jsx(ve.Item,{ref:s,className:Pe("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.jsx(ve.Indicator,{className:"flex items-center justify-center",children:e.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Ji.displayName=ve.Item.displayName;const Yi=je.Panel,Zi=te.Root,eo=te.Trigger,ao=te.Close,to=te.Portal,so=ee.forwardRef(({className:a,...t},s)=>e.jsx(te.Overlay,{className:Pe("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:s}));so.displayName=te.Overlay.displayName;const ro=s.cva("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"}}),no=ee.forwardRef(({side:a="right",className:t,children:s,...r},n)=>e.jsxs(to,{children:[e.jsx(so,{}),e.jsxs(te.Content,{ref:n,className:Pe(ro({side:a}),t),...r,children:[s,e.jsxs(te.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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));no.displayName=te.Content.displayName;const io=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx($e,{className:"mt-2"})]});io.displayName="SheetHeader";const oo=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});oo.displayName="SheetBody";const lo=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx($e,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});lo.displayName="SheetFooter";const co=ee.forwardRef(({className:a,...t},s)=>e.jsx(te.Title,{ref:s,className:Pe("text-lg font-semibold text-foreground",a),...t}));co.displayName=te.Title.displayName;const uo=ee.forwardRef(({className:a,...t},s)=>e.jsx(te.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));uo.displayName=te.Description.displayName;const mo="sidebar:state",po=ee.createContext(null);function ho(){const e=ee.useContext(po);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const xo=ee.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=ee.useState(!1);ee.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=ee.useState(!1),[p,h]=ee.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(mo);return null!==e?"true"===e:a}return a}),x=t??p,f=ee.useCallback(e=>{const a="function"==typeof e?e(x):e;s?s(a):h(a),"undefined"!=typeof window&&localStorage.setItem(mo,String(a))},[s,x]),g=ee.useCallback(()=>d?m(e=>!e):f(e=>!e),[d,f,m]);ee.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);const b=x?"expanded":"collapsed",v=ee.useMemo(()=>({state:b,open:x,setOpen:f,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,x,f,d,u,m,g]);return e.jsx(po.Provider,{value:v,children:e.jsx(ss,{delayDuration:0,children:e.jsx("div",{className:Pe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...n},ref:l,...o,children:i})})})});xo.displayName="SidebarProvider";const fo=ee.forwardRef(({side:a="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...i},o)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=ho();return"none"===s?e.jsx("div",{className:Pe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:o,...i,children:n}):l?e.jsx(Zi,{open:c,onOpenChange:u,...i,children:e.jsxs(no,{"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:a,children:[e.jsx(co,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":a,children:[e.jsx("div",{className:Pe("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"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Pe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===a?"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"===t||"inset"===t?"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",r),...i,children:e.jsx("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:n})})]})});fo.displayName="Sidebar";const go=ee.forwardRef(({className:a,onClick:t,...s},r)=>{const{toggleSidebar:n}=ho();return e.jsxs(_e,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Pe("h-7 w-7",a),onClick:e=>{t?.(e),n()},...s,children:[e.jsx(d.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});go.displayName="SidebarTrigger";const bo=ee.forwardRef(({className:a,...t},s)=>{const{toggleSidebar:r}=ho();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Pe("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})});bo.displayName="SidebarRail";const vo=ee.forwardRef(({className:a,...t},s)=>e.jsx("main",{ref:s,className:Pe("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}));vo.displayName="SidebarInset";const jo=ee.forwardRef(({className:a,...t},s)=>e.jsx(Me,{ref:s,"data-sidebar":"input",className:Pe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));jo.displayName="SidebarInput";const yo=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Pe("flex flex-col gap-2 p-2",a),...t}));yo.displayName="SidebarHeader";const No=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Pe("flex flex-col gap-2 p-2",a),...t}));No.displayName="SidebarFooter";const wo=ee.forwardRef(({className:a,...t},s)=>e.jsx($e,{ref:s,"data-sidebar":"separator",className:Pe("mx-2 w-auto bg-sidebar-border",a),...t}));wo.displayName="SidebarSeparator";const Co=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Pe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));Co.displayName="SidebarContent";const ko=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Pe("relative flex w-full min-w-0 flex-col p-2",a),...t}));ko.displayName="SidebarGroup";const So=ee.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"div";return e.jsx(i,{ref:n,"data-sidebar":"group-label",className:Pe("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})});So.displayName="SidebarGroupLabel";const To=ee.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"button";return e.jsx(i,{ref:n,"data-sidebar":"group-action",className:Pe("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})});To.displayName="SidebarGroupAction";const Po=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Pe("w-full text-sm",a),...t}));Po.displayName="SidebarGroupContent";const Ao=ee.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Pe("flex w-full min-w-0 flex-col gap-1",a),...t}));Ao.displayName="SidebarMenu";const Io=ee.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Pe("group/menu-item relative",a),...t}));Io.displayName="SidebarMenuItem";const _o=s.cva("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"}}),Eo=ee.forwardRef(({asChild:a=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?t.Slot:"button",{isMobile:u,state:m}=ho(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Pe(_o({variant:r,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),e.jsxs(rs,{children:[e.jsx(ns,{asChild:!0,children:p}),e.jsx(is,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):p});Eo.displayName="SidebarMenuButton";const Mo=ee.forwardRef(({className:a,asChild:s=!1,showOnHover:r=!1,...n},i)=>{const o=s?t.Slot:"button";return e.jsx(o,{ref:i,"data-sidebar":"menu-action",className:Pe("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),...n})});Mo.displayName="SidebarMenuAction";const Ro=ee.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Pe("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}));Ro.displayName="SidebarMenuBadge";const Do=ee.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=ee.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Pe("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});Do.displayName="SidebarMenuSkeleton";const zo=ee.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Pe("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}));zo.displayName="SidebarMenuSub";const Fo=ee.forwardRef(({...a},t)=>e.jsx("li",{ref:t,...a}));Fo.displayName="SidebarMenuSubItem";const Lo=ee.forwardRef(({asChild:a=!1,size:s="md",isActive:r,className:n,...i},o)=>{const l=a?t.Slot:"a";return e.jsx(l,{ref:o,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Pe("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"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...i})});Lo.displayName="SidebarMenuSubButton";const Oo=ee.forwardRef(({className:a,value:t,defaultValue:s,...r},n)=>{const i=t||s||[0];return e.jsxs(ye.Root,{ref:n,value:t,defaultValue:s,className:Pe("relative flex w-full touch-none select-none items-center",a),...r,children:[e.jsx(ye.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ye.Range,{className:"absolute h-full bg-primary"})}),i.map((a,t)=>e.jsx(ye.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))]})});Oo.displayName=ye.Root.displayName;const Uo=Ne.Root,qo=ee.forwardRef(({className:a,...t},s)=>e.jsx(Ne.List,{ref:s,className:Pe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));qo.displayName=Ne.List.displayName;const $o=ee.forwardRef(({className:a,...t},s)=>e.jsx(Ne.Trigger,{ref:s,className:Pe("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}));$o.displayName=Ne.Trigger.displayName;const Bo=ee.forwardRef(({className:a,...t},s)=>e.jsx(Ne.Content,{ref:s,className:Pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));Bo.displayName=Ne.Content.displayName;const Wo=s.cva("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"}}),Vo=ee.forwardRef(({className:a,variant:t,size:s,...r},n)=>e.jsx(we.Root,{ref:n,className:Pe(Wo({variant:t,size:s,className:a})),...r}));Vo.displayName=we.Root.displayName;const Ho=ee.createContext({size:"default",variant:"default"}),Go=ee.forwardRef(({className:a,variant:t,size:s,children:r,...n},i)=>e.jsx(Ce.Root,{ref:i,className:Pe("flex items-center justify-center gap-1",a),...n,children:e.jsx(Ho.Provider,{value:{variant:t,size:s},children:r})}));Go.displayName=Ce.Root.displayName;const Qo=ee.forwardRef(({className:a,children:t,variant:s,size:r,...n},i)=>{const o=ee.useContext(Ho);return e.jsx(Ce.Item,{ref:i,className:Pe(Wo({variant:o.variant||s,size:o.size||r}),a),...n,children:t})});Qo.displayName=Ce.Item.displayName;const Ko=ke.Menu,Xo=ke.Group,Jo=ke.Portal,Yo=ke.Sub,Zo=ke.RadioGroup,el=ee.forwardRef(({className:a,...t},s)=>e.jsx(ke.Root,{ref:s,className:Pe("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));el.displayName=ke.Root.displayName;const al=ee.forwardRef(({className:a,...t},s)=>e.jsx(ke.Trigger,{ref:s,className:Pe("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}));al.displayName=ke.Trigger.displayName;const tl=ee.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(ke.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));tl.displayName=ke.SubTrigger.displayName;const sl=ee.forwardRef(({className:a,...t},s)=>e.jsx(ke.SubContent,{ref:s,className:Pe("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}));sl.displayName=ke.SubContent.displayName;const rl=ee.forwardRef(({className:a,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},i)=>e.jsx(ke.Portal,{children:e.jsx(ke.Content,{ref:i,align:t,alignOffset:s,sideOffset:r,className:Pe("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})}));rl.displayName=ke.Content.displayName;const nl=ee.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(ke.Item,{ref:r,className:Pe("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),...s}));nl.displayName=ke.Item.displayName;const il=ee.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(ke.CheckboxItem,{ref:n,className:Pe("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",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ke.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));il.displayName=ke.CheckboxItem.displayName;const ol=ee.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ke.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ke.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ol.displayName=ke.RadioItem.displayName;const ll=ee.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(ke.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));ll.displayName=ke.Label.displayName;const dl=ee.forwardRef(({className:a,...t},s)=>e.jsx(ke.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));dl.displayName=ke.Separator.displayName;const cl=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});cl.displayname="MenubarShortcut";const ul={light:"",dark:".dark"},ml=ee.createContext(null);function pl(){const e=ee.useContext(ml);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const hl=ee.forwardRef(({id:a,className:t,children:s,config:r,...n},i)=>{const o=ee.useId(),l=`chart-${a||o.replace(/:/g,"")}`;return e.jsx(ml.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:i,className:Pe("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",t),...n,children:[e.jsx(xl,{id:l,config:r}),e.jsx(Se.ResponsiveContainer,{children:s})]})})});hl.displayName="Chart";const xl=({id:a,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(ul).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${s.map(([a,t])=>{const s=t.theme?.[e]||t.color;return s?` --color-${a}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},fl=Se.Tooltip,gl=ee.forwardRef(({active:a,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=pl(),f=ee.useMemo(()=>{if(n||!t?.length)return null;const[a]=t,s=jl(x,a,`${p||a?.dataKey||a?.name||"value"}`),r=p||"string"!=typeof o?s?.label:x[o]?.label||o;return l?e.jsx("div",{className:Pe("font-medium",d),children:l(r,t)}):r?e.jsx("div",{className:Pe("font-medium",d),children:r}):null},[o,l,t,n,d,x,p]);if(!a||!t?.length)return null;const g=1===t.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Pe("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",s),children:[g?null:f,e.jsx("div",{className:"grid gap-1.5",children:t.map((a,t)=>{const s=`${m||a.name||a.dataKey||"value"}`,n=jl(x,a,s),o=u||a.payload?.fill||a.color;return e.jsx("div",{className:Pe("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==a?.value&&a.name?c(a.value,a.name,a,t,a.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!i&&e.jsx("div",{className:Pe("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":o,"--color-border":o}}),e.jsxs("div",{className:Pe("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||a.name})]}),void 0!==a.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof a.value?a.value.toLocaleString():a.value})]})]})},a.dataKey||t)})})]})});gl.displayName="ChartTooltip";const bl=Se.Legend,vl=ee.forwardRef(({className:a,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},i)=>{const{config:o}=pl();return s?.length?e.jsx("div",{ref:i,className:Pe("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",a),children:s.map(a=>{const s=`${n||a.dataKey||"value"}`,r=jl(o,a,s);return e.jsxs("div",{className:Pe("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:a.color}}),r?.label]},a.value)})}):null});function jl(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}vl.displayName="ChartLegend";const yl=({onClick:a,isActive:t,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:a,disabled:s,title:n,className:Pe("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),Nl=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function wl({image:a,title:t,className:s}){return e.jsx("div",{className:Pe("relative w-full aspect-video bg-muted rounded-lg overflow-hidden",s),children:a?e.jsx("img",{src:a,alt:t,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(d.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function Cl({steps:a,currentStepIndex:t,onStepSelect:s,stepLabel:r,className:n}){const i=a.length,o=(t+1)/i*100;return e.jsxs("div",{className:Pe("flex items-center gap-3",n),children:[e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(_e,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",t+1,"/",i,e.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(gs,{align:"start",children:a.map((a,r)=>e.jsxs(bs,{onClick:()=>s(r),className:Pe(r===t&&"bg-accent"),children:[r+1,". ",a.title]},a.id))})]}),e.jsx(Ki,{value:o,className:"w-32 h-2"})]})}function kl({currentStepIndex:a,totalSteps:t,onBack:s,onNext:r,onComplete:n,backButtonText:i,continueButtonText:o,finishButtonText:l,className:c}){const u=0===a,m=a===t-1;return e.jsxs("div",{className:Pe("flex items-center gap-2",c),children:[!u&&e.jsxs(_e,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(d.ArrowLeft,{className:"h-4 w-4 mr-2"}),i]}),e.jsxs(_e,{onClick:m?n:r,size:"sm",children:[m?l:o,!m&&e.jsx(d.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const Sl=ee.forwardRef(({open:a,onOpenChange:t,steps:s,onComplete:r,onStepChange:n,continueButtonText:i="Continuar",backButtonText:o="Voltar",finishButtonText:l="Concluir",stepLabel:c="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:p,onCurrentStepChange:h,className:x},f)=>{const[g,b]=ee.useState(0),v=void 0!==p,j=v?p:g,y=ee.useCallback(e=>{v?h?.(e):b(e),n?.(e)},[v,h,n]);ee.useEffect(()=>{a||v||b(0)},[a,v]);const N=s[j],w=s.length;return N?e.jsx(Be,{open:a,onOpenChange:t,children:e.jsxs(Ke,{ref:f,size:u,className:Pe("p-0 gap-0",x),children:[e.jsxs(He,{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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(wl,{image:N.image,title:N.title}),e.jsx(Ze,{className:"text-xl font-semibold",children:N.title}),e.jsx(ea,{className:"text-muted-foreground",children:N.description})]}),e.jsx($e,{}),e.jsxs("div",{className:"p-4 flex items-center justify-between",children:[m&&w>1?e.jsx(Cl,{steps:s,currentStepIndex:j,onStepSelect:e=>{y(e)},stepLabel:c}):e.jsx("div",{}),e.jsx(kl,{currentStepIndex:j,totalSteps:w,onBack:()=>{j>0&&y(j-1)},onNext:()=>{j<w-1&&y(j+1)},onComplete:()=>{r?.(),t(!1)},backButtonText:o,continueButtonText:i,finishButtonText:l})]})]})}):null});Sl.displayName="OnboardingDialog";const Tl=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(ja,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked);function Pl({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:i=!0,customActions:o=[],renderAs:l="dropdown",variant:c="default"}){const{t:u}=g.useTranslation(),m=[];return a&&n&&m.push({icon:d.Edit,label:u("edit"),onClick:a,variant:"default"}),s&&m.push({icon:r?d.PowerOff:d.Power,label:u(r?"deactivate":"activate"),onClick:s,variant:"default"}),o.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),t&&i&&m.push({icon:d.Trash2,label:u("remove"),onClick:t,variant:"destructive"}),0===m.length?null:"dropdown"===l?e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(_e,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e.jsx(d.EllipsisVertical,{size:"compact"===c?14:16})})}),e.jsx(gs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,t)=>e.jsxs(bs,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},t))})]}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((a,t)=>e.jsxs(_e,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:a.onClick,className:"compact"===c?"h-7 px-2":"",children:[a.icon&&e.jsx(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:a.label})]},t))})}function Al(e){const a=j.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const Il=()=>{const{locale:a,datetimeFormat:t,timezone:s,setLocale:r,setDatetimeFormat:n,setTimezone:i}=Gr(),{t:o}=g.useTranslation();return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:o("preferences")||"Preferências"}),e.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>{const e=$r();r(e.locale),i(e.timezone),n(e.datetimeFormat)},className:"h-8 gap-1.5 text-xs",children:[e.jsx(d.RotateCcw,{className:"h-3.5 w-3.5"}),o("useSystemDefaults")||"Usar padrão do sistema"]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Globe,{className:"h-4 w-4"}),o("language")]}),e.jsxs(ca,{value:a,onValueChange:r,children:[e.jsx(pa,{children:e.jsx(ma,{})}),e.jsx(fa,{children:_r.map(a=>e.jsxs(ba,{value:a.value,children:[a.flag," ",a.label]},a.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Clock,{className:"h-4 w-4"}),o("timezone")||"Fuso Horário"]}),e.jsx(qa,{options:Mr,value:s,onChange:e=>{"string"==typeof e&&i(e)},getOptionValue:e=>e.value,getOptionLabel:e=>e.label,placeholder:o("selectTimezone")||"Selecione o fuso horário",searchPlaceholder:o("searchTimezone")||"Buscar fuso horário...",sortOptions:!1})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Calendar,{className:"h-4 w-4"}),o("dateTimeFormat")||"Formato de Data/Hora"]}),e.jsx(qa,{options:Er,value:t,onChange:e=>"string"==typeof e&&n(e),getOptionValue:e=>e.value,getOptionLabel:e=>`${e.label} • ${e.example}`,placeholder:o("selectDateFormat")||"Selecione o formato",searchPlaceholder:o("searchDateFormat")||"Buscar formato...",sortOptions:!1})]})]})},_l=a.memo(({variant:t="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:i,companies:o,alias:l,isAuthenticated:c,logout:u,switchUnit:m}=Bt(),[p,h]=a.useState(!1),x="true"===(void 0).VITE_SHOW_USER_PREFERENCES,f=o?.[0]||null,g=l?o?.find(e=>e.alias===l):f,b=o||[],v=r||g||f||f,j=a.useCallback(e=>{n?n(e):m(e)},[n,m]),y=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===v?.alias),s=a.filter(e=>e.alias!==v?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[b,v?.alias]);if(!c||!i)return null;const N=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",v?.name||"N/A"]})]})]}),v&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:v.name})]})}),y.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",y.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[y.slice(0,3).map(a=>e.jsx(wa,{variant:a.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>j(a),children:a.name},a.alias)),y.length>3&&e.jsxs(wa,{variant:"outline",className:"text-xs",children:["+",y.length-3]})]})]})]});return"dropdown"===t?e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(_e,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:i.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(gs,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(ps,{children:[e.jsxs(xs,{children:[e.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(fs,{children:y.map(a=>e.jsxs(bs,{onClick:()=>j(a),className:a.alias===v?.alias?"bg-muted":"",children:[e.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),a.name,a.alias===v?.alias&&e.jsx(wa,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),x&&e.jsx(Ns,{}),x&&e.jsxs(bs,{onClick:()=>h(!0),children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(bs,{onClick:u,children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),x&&e.jsx(Be,{open:p,onOpenChange:h,children:e.jsxs(Ke,{children:[e.jsx(Xe,{children:e.jsx(Ze,{children:"Preferências de Internacionalização"})}),e.jsx(Il,{})]})})]}):e.jsxs(ze,{className:s,children:[e.jsx(Fe,{children:e.jsx(Le,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Ue,{className:"space-y-4",children:[e.jsx(N,{}),e.jsx($e,{}),x&&e.jsxs(_e,{variant:"outline",onClick:()=>h(!0),size:"sm",className:"w-full",children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(_e,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),x&&e.jsx(Be,{open:p,onOpenChange:h,children:e.jsxs(Ke,{children:[e.jsx(Xe,{children:e.jsx(Ze,{children:"Preferências de Internacionalização"})}),e.jsx(Il,{})]})})]})]})}),El=a.createContext({});function Ml({children:t,config:s}){const r=a.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(El.Provider,{value:r,children:t})}function Rl(){return a.useContext(El)}function Dl(){const e=j.useLocation(),{navigation:a}=Rl(),{t:t}=g.useTranslation();if(!a)return t("page");const s=a.find(a=>a.path===e.pathname);if(s)return s.label;const r=a.find(a=>e.pathname.startsWith(a.path+"/"));return r?.label||t("page")}function zl(e,t){const[s,r]=a.useState(e),n=a.useRef(),i=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(i(),n.current=setTimeout(()=>{r(e)},t),i),[e,t,i]),[s,i]}const Fl=a.memo(function({actions:t}){const s=j.useLocation(),r=Dl(),{navigation:n,appName:i}=Rl(),{metadata:o,headerActions:l}=yr(),{t:c}=g.useTranslation(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:x,switchUnit:f}=Bt(),b=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[v,y]=j.useSearchParams(),[N,w]=a.useState(()=>v.get("search")||""),[C,k]=zl(N,jt.debounceDelay);a.useEffect(()=>{if(!p)return;const e=new URLSearchParams(v);C?(e.set("search",C),e.set("page","1")):e.delete("search"),y(e)},[C,y,p]);const S=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),T=o.title||r,P=o.subtitle||S?.complementaryText||c("item_details");return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:T}),e.jsx(wa,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||c("module")})]}),P&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:P})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Me,{placeholder:c("search"),value:N,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e.jsx(_e,{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:()=>{k(),w("");const e=new URLSearchParams(v);e.delete("search"),e.delete("page"),y(e)},title:c("clear_search"),children:e.jsx(d.X,{size:14})})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:x,className:"flex-shrink-0 h-10 w-10 p-0",title:c("refresh_data"),children:e.jsx(d.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(l||t)&&e.jsx("div",{className:"flex items-center gap-2",children:l||t}),(void 0).VITE_WIKI_URL&&e.jsx(_e,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Te((void 0).VITE_WIKI_URL,e),title:c("open_wiki"),children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(_l,{variant:"dropdown",selectedUnit:b,onUnitChange:f})})]})]})})}),Ll=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>v.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Ol=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Bt();return v.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=ot(),{data:a,error:s}=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(s){if(!mt.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},Ul="forlogic-sidebar-pinned",ql=()=>{try{const e=localStorage.getItem(Ul);return!!e&&JSON.parse(e)}catch{return!1}},$l=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]},Bl=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,Wl={logo:`${Bl}/${Ct.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Bl}/${Ct.isQualiex?"small-forlogic.svg":"small.svg"}`},Vl=Wl.logo,Hl=Wl.smallLogo;function Gl({appName:a,isPinned:t,onPinToggle:s,open:r,dropdownOpen:n,onDropdownChange:i}){const{t:o}=g.useTranslation(),{data:l,isLoading:c,error:u}=Ol({enabled:n}),m=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(l,e)};return e.jsxs(yo,{className:"p-0 gap-0",children:[e.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center pl-[12px]",children:e.jsx("img",{src:Wl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e.jsx("button",{onClick:s,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(t?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e.jsx(d.PanelLeft,{className:"h-4 w-4"})})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:e.jsx("img",{src:Wl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(ds,{onOpenChange:i,children:[e.jsx(cs,{asChild:!0,children:r?e.jsxs("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:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("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.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:a})]}),e.jsx(d.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e.jsx("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.jsx(d.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),e.jsx(gs,{className:r?"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:r?"start":"center",children:c?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:o("loading")})]}):u?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o("error")})]}):l&&0!==l.length?e.jsx("div",{className:"space-y-2",children:l.map((a,t)=>e.jsx("div",{onClick:()=>m(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${$l(t)} transition-colors duration-200\n `,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-foreground text-sm",children:a.name}),a.url&&e.jsx(d.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:o("no_results")})})]})})]})}function Ql({config:a,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:i="Criar",triggerIcon:o=d.Plus}=a;if(!n||0===n.length)return null;const l=(a,s,r=!1)=>e.jsxs(e.Fragment,{children:[a,!t&&s&&e.jsx("span",{className:"truncate",children:s}),!t&&r&&e.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const a=n[0],i=a.icon||o,d=s||a.disabled,c=e.jsx(_e,{onClick:a.onClick,disabled:d,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(i,{className:"h-4 w-4 shrink-0"}),a.label)});return t?e.jsxs(rs,{children:[e.jsx(ns,{asChild:!0,children:c}),e.jsx(is,{side:"right",children:e.jsx("p",{children:a.label})})]}):c}const c=e.jsx(_e,{disabled:s,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(o,{className:"h-4 w-4 shrink-0"}),i,!0)});return e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:t?e.jsxs(rs,{children:[e.jsx(ns,{asChild:!0,children:c}),e.jsx(is,{side:"right",children:e.jsx("p",{children:i})})]}):c}),e.jsx(gs,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:n.map(a=>{const t=a.icon;return e.jsxs(bs,{onClick:a.onClick,disabled:a.disabled,className:"cursor-pointer",children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})}function Kl({direction:e="right",minWidth:t=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,d]=a.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=a.useState(!1),m=a.useRef(null);a.useEffect(()=>{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 p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!c)return;const a=a=>{let r;r="left"===e?window.innerWidth-a.clientX:a.clientX,r=Math.max(t,Math.min(s,r)),d(r),i?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}},[c,e,t,s,l,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const Xl=a.createContext(void 0);function Jl(){const e=a.useContext(Xl);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Yl({config:t,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=g.useTranslation(),{open:l,setOpen:c}=ho(),u=j.useLocation(),{alias:m,user:p}=Bt(),{hasOpenModal:h}=Jl(),[x,f]=a.useState(!1),[b,v]=a.useState(ql),[y,N]=a.useState(!1),w=a.useRef(!1),C=r?Kl({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{c(!!b||!(!y&&!x))},[b,y,x,c]);return e.jsxs(fo,{collapsible:"icon",onMouseEnter:()=>{b||w.current||N(!0)},onMouseLeave:()=>{b||N(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:C&&l?{width:`${C.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(Gl,{appName:t?.appName||o("module_title"),isPinned:b,onPinToggle:()=>{const e=!b;v(e),(e=>{try{localStorage.setItem(Ul,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),c(!1),setTimeout(()=>{w.current=!1},300))},open:l,dropdownOpen:x,onDropdownChange:f}),t?.moduleActions&&t.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx(ss,{children:e.jsx(Ql,{config:t.moduleActions,isCollapsed:!l,isDisabled:h})})}),e.jsx(Co,{children:s||e.jsx(ko,{className:"p-0 mt-6",children:e.jsx(Po,{children:e.jsx(Ao,{className:"space-y-2",children:e.jsx(ss,{children:t?.navigation?.map((a,t)=>{const s=({item:a,index:t})=>{const r=`${a.path}-${t}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:i}=Ll({key:r,enabled:Boolean(a.permissionCheck&&m&&p?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),l=a.permissionCheck&&!n;if(l&&"Admin"===a.label)return null;const c=i?d.Loader2:l?d.Lock:a.icon;l?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e.jsx(Kr,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Io,{children:[e.jsx(Xr,{asChild:!0,children:e.jsx(Eo,{size:"lg",className:"h-10",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label}),e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e.jsx(Jr,{children:e.jsx(zo,{children:a.children.map((a,t)=>e.jsx(s,{item:a,index:t},a.path))})})]})},a.path):e.jsx(Io,{children:l||i?e.jsxs(rs,{children:[e.jsx(ns,{asChild:!0,children:e.jsx(Eo,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-4 w-4 "+(i?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})}),e.jsx(is,{children:e.jsx("p",{children:o(i?"checking_access":"restricted_access")})})]}):e.jsx(Eo,{asChild:!0,isActive:(h=a.path,u.pathname===h||u.pathname.startsWith(h+"/")),size:"lg",className:"h-10",children:e.jsxs(j.Link,{to:a.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})},a.path);var h};return e.jsx(s,{item:a,index:t},a.path)})})})})})}),r&&C&&l&&e.jsx("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Pe("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 Zl=a.memo(function({children:t,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const i=a.useMemo(()=>s||e.jsx(Yl,{config:r}),[s,r]),o=a.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(Ml,{config:r,children:e.jsx(jr,{children:e.jsx(xo,{defaultOpen:!1,style:o,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[i,e.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(Fl,{})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})});const ed={"pt-BR":Xn,"en-US":Fn,"es-ES":Wn},ad=(e,a=Rr,t=zr)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const r=ed[a]||Xn;try{return X.formatInTimeZone(s,t,"PP",{locale:r})}catch(n){return X.formatInTimeZone(s,zr,"PP",{locale:r})}};class td{static async sendEmail(e){const a=ot(),{data:t,error:s}=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(s)throw s;return t}}const sd=td;function rd({open:t,onOpenChange:s,placeId:r,placeName:n,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=g.useTranslation(),[m,p]=a.useState([]),[h,x]=a.useState(!1),[f,b]=a.useState(""),{data:v=[],isLoading:j}=er({enabled:t}),y=a.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),N=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},w=1===m.length,C=m.length>0;return e.jsx(Be,{open:t,onOpenChange:s,children:e.jsxs(Ke,{className:"max-w-2xl",children:[e.jsx(Xe,{children:e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Me,{placeholder:u("search_placeholder"),value:f,onChange:e=>b(e.target.value),className:"pl-9"})]}),e.jsx(Ks,{className:"h-[400px] pr-4",children:j?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e.jsx(La,{className:"h-16 w-full"},t))}):0===y.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:y.map(a=>{const t=a.userId===l,s=c.includes(a.userId||""),r=m.includes(a.userId||"");return e.jsxs("div",{className:Pe("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>N(a.userId||""),children:[e.jsx(ja,{checked:r,onCheckedChange:()=>N(a.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:a.userName}),t&&e.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(t||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},a.userId)})})}),e.jsxs(Ye,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&e.jsxs("span",{children:[m.length," selecionado(s)"]})}),w&&i&&e.jsxs(_e,{onClick:async()=>{if(i&&1===m.length){x(!0);try{await i(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[e.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&o&&e.jsxs(_e,{onClick:async()=>{if(o&&0!==m.length){x(!0);try{await o(m,r),p([])}finally{x(!1)}}},disabled:h,children:[e.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function nd({place:t,level:s=0,manageAccessConfig:r}){const[n,i]=a.useState(!1),[o,l]=a.useState(!1),c=t.subPlaces&&t.subPlaces.length>0,u=t.isActive??!0,m=t.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Kr,{open:n,onOpenChange:i,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(Xr,{className:"flex items-center gap-2 flex-1",children:[e.jsx(d.ChevronRight,{className:Pe("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:t.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",t.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(wa,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(Pl,{customActions:[{label:"Gerenciar Acessos",icon:d.Settings,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx(Jr,{children:t.subPlaces.map(a=>e.jsx(nd,{place:a,level:s+1,manageAccessConfig:r},a.id))})]}),0===s&&e.jsx($e,{}),r&&e.jsx(rd,{open:o,onOpenChange:l,placeId:t.id,placeName:t.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(t.id),currentMemberIds:r.getCurrentMemberIds?.(t.id)})]})}var id=Object.defineProperty,od=(e,a,t)=>((e,a,t)=>a in e?id(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const ld=new class{constructor(){od(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=ht.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Ja.getAccessToken();if(!r)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 ${r}`,"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 s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await ht.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return et.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return et.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function dd(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function cd(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function ud(){const{alias:e,isAuthenticated:a}=Bt(),t=Ja.getAccessToken(),{data:s=[]}=er({enabled:!0});return v.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=ot(),{data:r,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(!r||0===r.length)return[];const i={};s.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=r.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.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:r[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:r.filter(a=>a.id_leader===e).length})}),dd(o)},enabled:!!t&&!!e&&a&&s.length>0})}function md(){const e="common",{alias:a}=Bt(),t=v.useQueryClient(),s=ot();return v.useMutation({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 gd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.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 r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder virtual promovido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao criar líder")}})}function pd(){const e="common",{alias:a}=Bt(),t=v.useQueryClient(),s=ot();return v.useMutation({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 r=t.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",a).in("id_user",r).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 gd(s,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 s.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{l.toast.error(e.message||"Erro ao adicionar liderados")}})}function hd(){const e="common",{alias:a}=Bt(),t=v.useQueryClient(),s=ot();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await gd(s,a,e,r.id_user,t.id_leader,t.id);const{data:n,error:i}=await s.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]}),l.toast.success("Líder atualizado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao atualizar líder")}})}function xd(){const{alias:e}=Bt(),a=v.useQueryClient(),t=ot();return v.useMutation({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(s)throw s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success("Líder removido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao remover líder")}})}function fd(){const e="common",{alias:a}=Bt(),t=v.useQueryClient(),s=ot();return v.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!a)throw new Error("Unidade não selecionada");const n=r.map(e=>e.id_user),i=await Promise.all([s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).eq("id_leader",t),s.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 u=o||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==t),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const j of x)await gd(s,a,e,j.id_user,t,j.id);for(const j of g){if(j.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await gd(s,a,e,j.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(x.length){const r=x.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:t}).in("id",r).eq("alias",a))}if(g.length){const r=g.map(e=>({alias:a,id_user:e.id_user,id_leader:t,is_active:!0,is_removed:!1}));b.push(s.schema(e).from("leaders").insert(r))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{l.toast.error(e.message||"Erro ao sincronizar subordinados")}})}async function gd(e,a,t,s,r,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=r;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===s)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 bd({leader:a,expandedIds:t,onToggleExpand:s,onEdit:r}){const n=t.has(a.id),i=a.children.length>0,o=32*a.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${o}px`},children:[i?e.jsx("button",{onClick:()=>s(a.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(d.ChevronDown,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(d.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(a)},className:"font-medium hover:text-primary hover:underline text-left",children:a.name||a.id_user||a.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:a.subordinatesCount||0})})]}),i&&n&&a.children.map(a=>e.jsx(bd,{leader:a,expandedIds:t,onToggleExpand:s,onEdit:r},a.id))]})}var vd=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!t[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[s.code];t[i]=p.appendErrors(i,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},jd=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,i){try{var o=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&Y.validateFieldsNatively({},n),{errors:{},values:t.raw?s: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:Y.toNestErrors(vd(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const yd=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string()).min(1,"Selecione pelo menos um liderado")}),Nd=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string())});function wd({value:t,onChange:s,excludeUserIds:r=[],error:n}){const{data:i=[],isLoading:o}=er(),[l,c]=a.useState(""),u=a.useRef(null),m=a.useRef(0),{t:p}=g.useTranslation(),h=i.filter(e=>!r.includes(e.userId||"")).filter(e=>{const a=l.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const s=t.includes(e.userId),r=t.includes(a.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return a.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[h]),o?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:p("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{placeholder:p("search_user"),value:l,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===h.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:p("search_user")}):e.jsx("div",{className:"space-y-2",children:h.map(a=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ja,{id:a.userId,checked:t.includes(a.userId),onCheckedChange:()=>{return e=a.userId,u.current&&(m.current=u.current.scrollTop),void(t.includes(e)?s(t.filter(a=>a!==e)):s([...t,e]));var e}}),e.jsx(De,{htmlFor:a.userId,className:"flex-1 cursor-pointer",children:a.userName||a.userEmail})]},a.userId))})}),t.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p("selected_count",{count:t.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Cd({leader:t,prefilledLeaderId:s,onSuccess:r}){const{t:n}=g.useTranslation(),{alias:i}=Bt(),o=!!t,l=t?.id.startsWith("virtual-"),c=pd(),u=md(),m=hd(),h=fd(),x=xd(),{data:f=[]}=ud(),{data:b=[]}=er(),[v,j]=a.useState(""),y=cd(f).map(e=>e.id_user),N=o?cd(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user):[],w=p.useForm({resolver:jd(o?Nd:yd),defaultValues:{id_leader:s||(o?t?.id_leader:null)||null,id_users:o?N:[]}});a.useEffect(()=>{if(t){const e=cd(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user);w.reset({id_leader:t.id_leader||null,id_users:e})}else s?w.reset({id_leader:s,id_users:[]}):w.reset({id_leader:null,id_users:[]})},[i,t?.id,t?.id_user,t?.id_leader,s,f]);const C=c.isPending||u.isPending||m.isPending||h.isPending||x.isPending,k=w.watch("id_leader"),S=w.watch("id_users"),T=o?[t.id_user,...y.filter(e=>e!==t.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...y.filter(e=>!S.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:w.handleSubmit(async e=>{try{if(o)if(l){await u.mutateAsync({id_user:t.id_user,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{await m.mutateAsync({id:t.id,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:a})}r?.()}catch(a){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(De,{children:n("leader")}),e.jsx(Me,{value:b.find(e=>e.userId===t.id_user)?.userName||t.name||t.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(De,{children:n("superior")}),e.jsxs(ca,{value:k||"none",onValueChange:e=>w.setValue("id_leader","none"===e?null:e),children:[e.jsx(pa,{children:e.jsx(ma,{placeholder:n("select_placeholder")})}),e.jsxs(fa,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Me,{placeholder:n("superior_search"),value:v,onChange:e=>j(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(Ks,{className:"h-[200px]",children:[e.jsx(ba,{value:"none",children:"[Nenhum]"}),b.filter(e=>{const a=o?e.userId!==t.id_user:!S.includes(e.userId),s=!v||e.userName?.toLowerCase().includes(v.toLowerCase());return a&&s}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(a=>e.jsx(ba,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${i}`),w.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:w.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(De,{children:[n("subordinates")," *"]}),e.jsx(wd,{value:S,onChange:e=>w.setValue("id_users",e),excludeUserIds:T,error:w.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(_e,{type:"submit",disabled:C||!o&&0===S.length,children:C&&!x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n(o?"updating":"saving")]}):o?S.length>0?n("update_success",{count:S.length}):n("update"):n("create_success",{count:S.length})}),o&&!k&&0===S.length&&e.jsx(_e,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(t&&window.confirm(n("remove_confirm")))try{await x.mutateAsync(t.id),r?.()}catch(e){}},className:"ml-auto",children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n("removing")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),n("remove")]})})]})]})}function kd({open:a,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(Be,{open:a,onOpenChange:t,children:e.jsxs(Ke,{className:"sm:max-w-[500px]",children:[e.jsx(Xe,{children:e.jsx(Ze,{children:n})}),e.jsx(Cd,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const Sd="leadership-expanded-nodes",Td=(e,a)=>{try{localStorage.setItem(`${Sd}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function Pd(e){const[t,s]=a.useState(!1),[r,n]=a.useState(0),{t:i}=g.useTranslation(),{uploadFunction:o,deleteFunction:d,defaultOptions:c,onSuccess:u,onError:m}=e||{};return{upload:async(e,a)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0),n(0);try{const t={...c,...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 s=await o(e,t);return n(100),l.toast.success("Sucesso",{description:i("file_upload_success")}),u?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),m?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!d){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await d(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:t,progress:r}}function Ad(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 Id(e,a){const t=Ad(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function _d(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function Ed(e,a){const t=_d(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function Md(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Rd(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Dd(e,a){return e/a}const zd=[{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 Fd({module:a,onClick:t}){return e.jsxs("button",{type:"button",onClick:t,className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors text-left w-full group",children:[e.jsx("div",{className:Pe("w-4 h-4 rounded-sm shrink-0 mt-0.5",a.color)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground group-hover:text-primary transition-colors",children:a.name}),a.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:a.description})]})]})}function Ld({modules:a,onModuleClick:t,columns:s=2}){const r=[...a].sort((e,a)=>e.name.localeCompare(a.name)),n=Math.ceil(r.length/s),i=[];for(let e=0;e<n;e++)for(let a=0;a<s;a++){const t=a*n+e;t<r.length&&i.push(r[t])}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1",children:i.map((a,s)=>e.jsx(Fd,{module:a,onClick:()=>t?.(a)},`${a.name}-${s}`))})}exports.i18n=o,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return g.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return g.useTranslation}}),exports.AUTH_CONFIG=bt,exports.Accordion=an,exports.AccordionContent=rn,exports.AccordionItem=tn,exports.AccordionTrigger=sn,exports.ActionButton=Ee,exports.ActionMenu=Pl,exports.ActionMenuItems=Os,exports.Alert=fr,exports.AlertDescription=br,exports.AlertDialog=nn,exports.AlertDialogAction=xn,exports.AlertDialogCancel=fn,exports.AlertDialogContent=cn,exports.AlertDialogDescription=hn,exports.AlertDialogFooter=mn,exports.AlertDialogHeader=un,exports.AlertDialogOverlay=dn,exports.AlertDialogPortal=ln,exports.AlertDialogTitle=pn,exports.AlertDialogTrigger=on,exports.AlertTitle=gr,exports.AppHeader=Fl,exports.AppLayout=Zl,exports.AppSidebar=Yl,exports.AuthErrorInterceptor=mt,exports.AuthProvider=$t,exports.AuthService=Ut,exports.Avatar=gn,exports.AvatarFallback=vn,exports.AvatarImage=bn,exports.Badge=wa,exports.BaseForm=tr,exports.Blockquote=_i,exports.Breadcrumb=jn,exports.BreadcrumbEllipsis=Sn,exports.BreadcrumbItem=Nn,exports.BreadcrumbLink=wn,exports.BreadcrumbList=yn,exports.BreadcrumbPage=Cn,exports.BreadcrumbSeparator=kn,exports.BulkActionBar=nr,exports.Button=_e,exports.ButtonGroup=Pn,exports.CRUD_CONFIG=vt,exports.Calendar=Jn,exports.CallbackPage=()=>{const{processCallback:t}=Bt(),[s,r]=a.useState(null),[n,i]=a.useState(!1);a.useEffect(()=>{(async()=>{try{if(await t()){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 r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const o=async()=>{i(!0),r(null);try{await t()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},l=()=>{window.location.href="/"};return s?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(ze,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsxs(Le,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(Ue,{className:"space-y-4",children:[e.jsx(fr,{variant:"danger",children:e.jsx(br,{children:s})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_e,{onClick:o,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(ka,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(_e,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(ze,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(Le,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ka,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=ze,exports.CardContent=Ue,exports.CardDescription=Oe,exports.CardFooter=qe,exports.CardHeader=Fe,exports.CardSkeleton=es,exports.CardTitle=Le,exports.ChartContainer=hl,exports.ChartLegend=bl,exports.ChartLegendContent=vl,exports.ChartStyle=xl,exports.ChartTooltip=fl,exports.ChartTooltipContent=gl,exports.Checkbox=ja,exports.Collapsible=Kr,exports.CollapsibleContent=Jr,exports.CollapsibleTrigger=Xr,exports.ColorPicker=Qs,exports.Combobox=qa,exports.Command=Ia,exports.CommandDialog=({children:a,...t})=>e.jsx("div",{...t,children:e.jsx(Ia,{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})}),exports.CommandEmpty=Ma,exports.CommandGroup=Ra,exports.CommandInput=_a,exports.CommandItem=za,exports.CommandList=Ea,exports.CommandSeparator=Da,exports.CommandShortcut=Fa,exports.ContextMenu=Cs,exports.ContextMenuCheckboxItem=Rs,exports.ContextMenuContent=Es,exports.ContextMenuGroup=Ss,exports.ContextMenuItem=Ms,exports.ContextMenuLabel=zs,exports.ContextMenuPortal=Ts,exports.ContextMenuRadioGroup=As,exports.ContextMenuRadioItem=Ds,exports.ContextMenuSeparator=Fs,exports.ContextMenuShortcut=Ls,exports.ContextMenuSub=Ps,exports.ContextMenuSubContent=_s,exports.ContextMenuSubTrigger=Is,exports.ContextMenuTrigger=ks,exports.CoreProviders=function({children:a,queryClient:t}){const s=t??new v.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(en,{children:e.jsx(g.I18nextProvider,{i18n:o,children:e.jsx(v.QueryClientProvider,{client:s,children:e.jsx($t,{children:e.jsx(Hr,{children:e.jsx(Qr,{children:a})})})})})})},exports.CrudGrid=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f=!1,gridColumns:b=3,renderCard:v,viewMode:j,onViewModeChange:y,listCardRenderer:N,gridCardRenderer:w,showViewToggle:C=!1})=>{const{t:k}=g.useTranslation(),{setSearchVisible:S}=Bt();a.useEffect(()=>(S(!0),()=>S(!1)),[S]);const T=!f&&(m||x.length>0||C),P=j||"grid",A="list"===P,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"}[A?1:b];if(t.isLoading)return e.jsxs("div",{className:"flex flex-col h-full",children:[T&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsx("div",{className:"flex items-center gap-2",children:m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||k("new")]})})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(es,{count:6})})]});if(0===t.entities.length)return e.jsxs("div",{className:"flex flex-col h-full",children:[T&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||k("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(ts,{title:k("empty_title"),description:k("empty_description"),variant:"search"})})]});return e.jsxs("div",{className:"flex flex-col h-full",children:[T&&e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||k("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]}),C&&y&&e.jsxs(Go,{type:"single",value:P,onValueChange:e=>e&&y(e),size:"sm",children:[e.jsx(Qo,{value:"list","aria-label":"Visualização em lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(Qo,{value:"grid","aria-label":"Visualização em grade",children:e.jsx(d.LayoutGrid,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:Pe("grid gap-4",I),children:t.entities.map(a=>{const d=(e=>A&&N?N(e):!A&&w?w(e):v?v(e):null)(a);return e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:d?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:d}):e.jsx(ze,{className:Pe("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&t.selectedIds.includes(a.id)&&"bg-muted ring-2 ring-primary",A&&"flex-row"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:e.jsxs(Ue,{className:Pe("p-4",A&&"flex items-center gap-4 w-full"),children:[u&&e.jsx("div",{className:Pe(A?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(Tl,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),A?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key)))}),(r||n||l)&&e.jsx("div",{onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Us,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Tl,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((t,r)=>e.jsxs("div",{className:Pe("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Us,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})]})})}),e.jsx(Es,{className:"w-[160px]",children:e.jsx(Os,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})})]})},exports.CrudPageInternal=ur,exports.CrudPagination=rr,exports.CrudPrimitiveFilterBar=function({searchValue:a="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:i="horizontal"}){const{t:o}=g.useTranslation(),l=a||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===i?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Me,{type:"text",placeholder:o("search"),value:a,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e.jsx("div",{className:"vertical"===i?"w-full":"",children:a},t)),n&&l&&r&&e.jsxs(_e,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(d.X,{size:14,className:"mr-1"}),o("clear_filters")]})]})},exports.CrudPrimitivePagination=sr,exports.CrudPrimitiveTable=function({data:t,columns:s,sortField:r,sortDirection:n,onSort:i,onRowClick:o,renderActions:l,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:j}){const{columnWidths:y,isDragging:N,activeColumn:w,handleMouseDown:C}=$s({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:j?`${j}-columns`:void 0,onResize:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:T,getRowHeight:P}=Bs({rowIds:t.map(e=>e.id),storageKey:j?`${j}-rows`:void 0,enabled:!1}),A=a.useMemo(()=>{if(b)return s.map(e=>`${y[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.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}%`})},[s,b,y]);if(c)return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((a,t)=>e.jsx(La,{className:"h-12 w-full"},t))})});if(0===t.length)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:u})})});const I=N||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(I?"select-none":""),children:e.jsxs(Vt,{className:m,children:[e.jsx(Ht,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Kt,{children:[p&&e.jsx(Xt,{className:"w-[40px]",children:e.jsx(ja,{checked:g,onCheckedChange:f,"aria-label":"Selecionar todos"})}),s.map((a,t)=>{const s=b&&!1!==a.resizable,o=w===String(a.key);return e.jsxs(Xt,{className:`${a.className||""} relative`,style:{width:A[t]},children:[a.sortable&&i?e.jsxs("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(l=String(a.key),r!==l?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:a.header}),s&&e.jsx(ls,{direction:"horizontal",onMouseDown:e=>C(String(a.key),e),isDragging:o})]},String(a.key));var l}),l&&e.jsx(Xt,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(Gt,{children:t.map(a=>{const t=P(a.id);return a.id,e.jsxs(Kt,{onClick:()=>o?.(a),className:(o?"cursor-pointer":"")+" relative",style:t?{height:`${t}px`}:void 0,children:[p&&e.jsx(Jt,{children:e.jsx(ja,{checked:h.includes(a.id),onCheckedChange:()=>x?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),s.map(t=>e.jsx(Jt,{className:t.className,children:e.jsx(os,{children:t.render?t.render(a):String(a[t.key]??"-")})},String(t.key))),l&&e.jsx(Jt,{className:"text-right",onClick:e=>e.stopPropagation(),children:l(a)})]},a.id)})})]})})},exports.CrudTable=Vs,exports.DATETIME_FORMATS=Er,exports.DEFAULT_DATETIME_FORMAT=Dr,exports.DEFAULT_LOCALE=Rr,exports.DEFAULT_TIMEZONE=zr,exports.DataList=Yn,exports.DatePicker=function({date:a,onDateChange:t,placeholder:s="Pick a date",disabled:r=!1,className:n,disabledDates:o}){return e.jsxs(Ta,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",disabled:r,className:Pe("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",n),children:[e.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),a?i.format(a,"PPP"):e.jsx("span",{children:s})]})}),e.jsx(Aa,{className:"w-auto p-0",align:"start",children:e.jsx(Jn,{mode:"single",selected:a,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=Be,exports.DialogBody=Je,exports.DialogClose=He,exports.DialogContent=Ke,exports.DialogDescription=ea,exports.DialogFooter=Ye,exports.DialogHeader=Xe,exports.DialogOverlay=Ge,exports.DialogPortal=Ve,exports.DialogTitle=Ze,exports.DialogTrigger=We,exports.Drawer=Zn,exports.DrawerClose=ti,exports.DrawerContent=ri,exports.DrawerDescription=li,exports.DrawerFooter=ii,exports.DrawerHeader=ni,exports.DrawerOverlay=si,exports.DrawerPortal=ai,exports.DrawerTitle=oi,exports.DrawerTrigger=ei,exports.DropdownMenu=ds,exports.DropdownMenuCheckboxItem=vs,exports.DropdownMenuContent=gs,exports.DropdownMenuGroup=us,exports.DropdownMenuItem=bs,exports.DropdownMenuLabel=ys,exports.DropdownMenuPortal=ms,exports.DropdownMenuRadioGroup=hs,exports.DropdownMenuRadioItem=js,exports.DropdownMenuSeparator=Ns,exports.DropdownMenuShortcut=ws,exports.DropdownMenuSub=ps,exports.DropdownMenuSubContent=fs,exports.DropdownMenuSubTrigger=xs,exports.DropdownMenuTrigger=cs,exports.EmailService=td,exports.EmptyState=ts,exports.EntitySelect=qa,exports.ErrorBoundary=en,exports.FilterBar=cr,exports.Form=aa,exports.FormControl=oa,exports.FormDescription=la,exports.FormField=({...a})=>e.jsx(ta.Provider,{value:{name:a.name},children:e.jsx(p.Controller,{...a})}),exports.FormItem=na,exports.FormLabel=ia,exports.FormMessage=da,exports.FormSkeleton=function({fields:a=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(La,{className:"h-4 w-24"}),e.jsx(La,{className:"h-10 w-full"})]},t)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(La,{className:"h-10 w-20"}),e.jsx(La,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:a,cols:t="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Pe("grid",di[t],ci[s],r),children:a})},exports.H1=yi,exports.H2=Ni,exports.H3=wi,exports.H4=Ci,exports.HeaderSkeleton=function(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(La,{className:"h-8 w-8 rounded-full"}),e.jsx(La,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(La,{className:"h-8 w-8"}),e.jsx(La,{className:"h-8 w-24"})]})]})},exports.HoverCard=ui,exports.HoverCardContent=pi,exports.HoverCardTrigger=mi,exports.IconPicker=Ys,exports.ImageEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=Pd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),b=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("url")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{type:"url",placeholder:u("url_placeholder"),value:m.imageUrl||"",onChange:e=>b("imageUrl",e.target.value),className:"flex-1"}),i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),m.imageFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:m.imageFile,size:Math.round((m.imageSize||0)/1024)})})]}),m.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"caption",children:u("caption")}),e.jsx(ya,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>b("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"alt",children:u("alt")}),e.jsx(Me,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>b("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("alignment")}),e.jsxs(ca,{value:m.alignment||"center",onValueChange:e=>b("alignment",e),children:[e.jsx(pa,{children:e.jsx(ma,{})}),e.jsxs(fa,{children:[e.jsx(ba,{value:"left",children:u("left")}),e.jsx(ba,{value:"center",children:u("center")}),e.jsx(ba,{value:"right",children:u("right")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"width",children:u("width")}),e.jsx(Me,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>b("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"height",children:u("height")}),e.jsx(Me,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>b("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"allowDownload",type:"checkbox",checked:m.allowDownload||!1,onChange:e=>b("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(De,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{onClick:()=>{m.imageUrl?r(m):l.toast.error(u("error"),{description:u("error_no_image")})},disabled:!m.imageUrl,children:u("save")})]})]})},exports.ImageRenderer=function({content:a,className:t="",style:s}){if(!a.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${t}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:a.imageUrl,alt:a.alt||"",style:{width:a.width?`${a.width}px`:"auto",height:a.height?`${a.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),a.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&e.jsxs("a",{href:a.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Ii,exports.Input=Me,exports.InputGroup=hi,exports.InputGroupAddon=fi,exports.InputGroupButton=bi,exports.InputGroupInput=vi,exports.InputGroupTextarea=ji,exports.LOGO_CONFIG=Ct,exports.Label=De,exports.Large=Ti,exports.Lead=Si,exports.LeaderRow=bd,exports.LeadershipDialog=kd,exports.LeadershipForm=Cd,exports.LeadershipPage=function(){const{alias:t}=Bt(),{t:s}=g.useTranslation(),{data:r,isLoading:n,error:i,refetch:o}=ud(),{data:l=[]}=er({enabled:!0}),[c,u]=a.useState(()=>t?(e=>{try{const a=localStorage.getItem(`${Sd}-${e}`);if(a)return new Set(JSON.parse(a))}catch(i){}return new Set})(t):new Set),[m,p]=a.useState(!1),[h,x]=a.useState(),[f,b]=a.useState(null),v=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),j=new Set(v.map(e=>e.userId)),y=v.length-(r?cd(r).filter(e=>j.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);a.useEffect(()=>{if(r&&r.length>0&&t){if(!localStorage.getItem(`${Sd}-${t}`)){const e=r.map(e=>e.id),a=new Set(e);u(a),Td(t,a)}}},[r,t]);const N=e=>{u(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),t&&Td(t,s),s})},w=e=>{x(e),b(null),p(!0)};return n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:s("loading")})]})}):i?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(_e,{onClick:()=>o(),children:"Tentar novamente"})]})}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(_e,{size:"sm",onClick:()=>{x(void 0),b(null),p(!0)},children:[e.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{if(!r)return;const e=cd(r).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&Td(t,a)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&Td(t,e)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[y," usuário",1!==y?"s":""," não associado",1!==y?"s":""]})]})})]})}),r&&0!==r.length?e.jsx(Ks,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:r.map(a=>e.jsx(bd,{leader:a,expandedIds:c,onToggleExpand:N,onEdit:w},a.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(kd,{open:m,onOpenChange:()=>{p(!1),x(void 0),b(null)},leader:h,prefilledLeaderId:f,title:h?s("edit")+" "+s("name"):f?s("add")+" Liderado":s("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})},exports.List=Ei,exports.LoadingState=function({isLoading:a,children:t,className:s,type:r="spinner",size:n="md"}){return a?"overlay"===r?e.jsxs("div",{className:Pe("relative",s),children:[t,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(ka,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Pe("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Pe("flex items-center justify-center py-8",s),children:e.jsx(ka,{size:n})}):e.jsx(e.Fragment,{children:t})},exports.LocaleProvider=Hr,exports.LocaleSelector=Il,exports.LoginPage=()=>e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(ze,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(Le,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Ue,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(_e,{onClick:async()=>{yt()?await Ut.loginDev():Ut.loginProd()},className:"w-full",size:"lg",children:yt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=kt,exports.MODULES_DATA=zd,exports.ManageAccessModal=rd,exports.Menubar=el,exports.MenubarCheckboxItem=il,exports.MenubarContent=rl,exports.MenubarGroup=Xo,exports.MenubarItem=nl,exports.MenubarLabel=ll,exports.MenubarMenu=Ko,exports.MenubarPortal=Jo,exports.MenubarRadioGroup=Zo,exports.MenubarRadioItem=ol,exports.MenubarSeparator=dl,exports.MenubarShortcut=cl,exports.MenubarSub=Yo,exports.MenubarSubContent=sl,exports.MenubarSubTrigger=tl,exports.MenubarTrigger=al,exports.ModalStateProvider=function({children:t}){const[s,r]=a.useState(new Set),[n,i]=a.useState(!1),o=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=a.useCallback(e=>{i(e)},[]),c=a.useMemo(()=>s.size>0||n,[s,n]),u=a.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:o,unregisterModal:l,setHasOpenModal:d}),[s,c,o,l,d]);return e.jsx(Xl.Provider,{value:u,children:t})},exports.ModulesDialog=function({open:t,onOpenChange:s,onModuleClick:r,wikiUrl:n="https://qualiex.forlogic.net/",allModulesUrl:i="https://qualiex.com/",showSettingsLink:o=!0,onSettingsClick:l}){const[c,u]=a.useState("qualiex");return e.jsx(Be,{open:t,onOpenChange:s,children:e.jsxs(Ke,{size:"lg",className:"overflow-hidden flex flex-col",children:[e.jsx(Xe,{children:e.jsx(Ze,{children:"Módulos"})}),e.jsxs("div",{className:"flex-1 min-h-0 flex gap-6 overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:e.jsxs(Uo,{value:c,onValueChange:u,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(qo,{className:"w-fit shrink-0 mt-4",children:zd.map(a=>e.jsxs($o,{value:a.id,children:[a.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",a.modules.length,")"]})]},a.id))}),zd.map(a=>e.jsx(Bo,{value:a.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(Ld,{modules:a.modules,onModuleClick:r})},a.id))]})}),e.jsxs("div",{className:"w-72 shrink-0 flex flex-col gap-4",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"Dúvidas sobre os módulos?"}),e.jsx("p",{className:"text-sm opacity-90",children:"Acesse nossa Wiki e descubra todos os detalhes sobre os módulos e suas funcionalidades"}),e.jsxs("a",{href:n,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.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-foreground",children:"Conheça todas as soluções que o Qualiex pode te oferecer"}),e.jsxs("a",{href:i,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.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx("div",{className:"flex-1"}),o&&e.jsxs("button",{type:"button",onClick:l,className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsx(d.Settings,{className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"Configurações"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Gerenciar módulos ativos"})]})]})]})]})]})})},exports.MultiSelect=qa,exports.Muted=Ai,exports.NavigationMenu=Mi,exports.NavigationMenuContent=Li,exports.NavigationMenuIndicator=qi,exports.NavigationMenuItem=Di,exports.NavigationMenuLink=Oi,exports.NavigationMenuList=Ri,exports.NavigationMenuTrigger=Fi,exports.NavigationMenuViewport=Ui,exports.NavigationProvider=Ml,exports.OnboardingDialog=Sl,exports.P=ki,exports.PageBreadcrumb=function({items:a,maxItems:t=3,className:s}){const r=a.length>t?[a[0],...a.slice(-(t-1))]:a,n=a.length>t;return e.jsx(jn,{className:s,children:e.jsx(yn,{children:r.map((a,t)=>{const s=0===t,r=n&&1===t;return e.jsxs(Nn,{children:[!s&&e.jsx(kn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Sn,{}),e.jsx(kn,{})]}),a.isCurrentPage?e.jsx(Cn,{children:a.label}):e.jsx(wn,{href:a.href,children:a.label})]},a.label)})})})},exports.PageMetadataProvider=jr,exports.Pagination=$i,exports.PaginationContent=Bi,exports.PaginationEllipsis=Qi,exports.PaginationItem=Wi,exports.PaginationLink=Vi,exports.PaginationNext=Gi,exports.PaginationPrevious=Hi,exports.PlaceCard=nd,exports.PlacesList=function({places:a,isLoading:t,manageAccessConfig:s}){const{t:r}=g.useTranslation();return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("loading_data")})]})}):a&&0!==a.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(a=>e.jsx(nd,{place:a,manageAccessConfig:s},a.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Ta,exports.PopoverContent=Aa,exports.PopoverTrigger=Pa,exports.Progress=Ki,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:s,isLoading:r}=Bt();if(a.useEffect(()=>{if(!s)return;const e=()=>{Ja.areAllTokensValid()||Ut.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[s]),a.useEffect(()=>{if(r)return;if(s)return;if(Ja.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 n=yt();(async()=>{n?await Ut.loginDev():Ut.loginProd()})()},[s,r]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(ze,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(Le,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(ze,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(Le,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(ze,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(Le,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:yt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:t})},exports.QUALIEX_CONFIG=Nt,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=_t,exports.QualiexErrorInterceptor=ht,exports.QualiexUserField=ar,exports.RadioGroup=Xi,exports.RadioGroupItem=Ji,exports.ResizableHandle=({withHandle:a,className:t,...s})=>e.jsx(je.PanelResizeHandle,{className:Pe("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),...s,children:a&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Yi,exports.ResizablePanelGroup=({className:a,...t})=>e.jsx(je.PanelGroup,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),exports.RichTextEditor=({value:t,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:i="300px",showModeToggle:o=!0,showVariableHint:l=!0,className:c})=>{const[u,m]=a.useState("visual"),p=B.useEditor({extensions:[W.configure({heading:{levels:[1,2,3]}}),V,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Q.Color,K.configure({multicolor:!0})],content:t||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});ee.useEffect(()=>{p&&t!==p.getHTML()&&p.commands.setContent(t||"")},[t,p]);const h=a.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?p.chain().focus().extendMarkRange("link").setLink({href:a}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Pe("space-y-2",c),children:[o&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(_e,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(_e,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(_e,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),l&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(yl,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(d.Heading1,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(d.Heading2,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(d.Heading3,{className:"h-4 w-4"})}),e.jsx(Nl,{}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(d.Bold,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(d.Italic,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(d.Underline,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(d.Strikethrough,{className:"h-4 w-4"})}),e.jsx(Nl,{}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(d.ListOrdered,{className:"h-4 w-4"})}),e.jsx(Nl,{}),e.jsx(yl,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(d.Highlighter,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(d.Link,{className:"h-4 w-4"})}),e.jsx(Nl,{}),e.jsx(yl,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(Nl,{}),e.jsx(yl,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(d.Undo,{className:"h-4 w-4"})}),e.jsx(yl,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(d.Redo,{className:"h-4 w-4"})})]}),e.jsx(B.EditorContent,{editor:p,className:Pe("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:i}})]}),"code"===u&&e.jsx("textarea",{value:t||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:t||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=jt,exports.SUPPORTED_LOCALES=_r,exports.ScrollArea=Ks,exports.ScrollBar=Xs,exports.Select=ca,exports.SelectContent=fa,exports.SelectGroup=ua,exports.SelectItem=ba,exports.SelectLabel=ga,exports.SelectScrollDownButton=xa,exports.SelectScrollUpButton=ha,exports.SelectSearch=qa,exports.SelectSeparator=va,exports.SelectTrigger=pa,exports.SelectValue=ma,exports.Separator=$e,exports.Sheet=Zi,exports.SheetBody=oo,exports.SheetClose=ao,exports.SheetContent=no,exports.SheetDescription=uo,exports.SheetFooter=lo,exports.SheetHeader=io,exports.SheetOverlay=so,exports.SheetPortal=to,exports.SheetTitle=co,exports.SheetTrigger=eo,exports.Sidebar=fo,exports.SidebarActionTrigger=Ql,exports.SidebarContent=Co,exports.SidebarFooter=No,exports.SidebarGroup=ko,exports.SidebarGroupAction=To,exports.SidebarGroupContent=Po,exports.SidebarGroupLabel=So,exports.SidebarHeader=Gl,exports.SidebarInput=jo,exports.SidebarInset=vo,exports.SidebarMenu=Ao,exports.SidebarMenuAction=Mo,exports.SidebarMenuBadge=Ro,exports.SidebarMenuButton=Eo,exports.SidebarMenuItem=Io,exports.SidebarMenuSkeleton=Do,exports.SidebarMenuSub=zo,exports.SidebarMenuSubButton=Lo,exports.SidebarMenuSubItem=Fo,exports.SidebarProvider=xo,exports.SidebarRail=bo,exports.SidebarSeparator=wo,exports.SidebarSkeleton=function(){return e.jsx("div",{className:"w-64 border-r bg-muted/10",children:e.jsxs("div",{className:"p-4",children:[e.jsx(La,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((a,t)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(La,{className:"h-4 w-4"}),e.jsx(La,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=go,exports.Skeleton=La,exports.Slider=Oo,exports.Small=Pi,exports.SonnerToaster=Sa,exports.Spinner=ka,exports.SplitButton=function({label:a,onClick:t,icon:s,actions:r=[],variant:n="default",size:i="default",disabled:o=!1,loading:l=!1,menuAlign:c="end",className:u}){const m=o||l;return r.length>0?e.jsxs("div",{className:Pe("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]}),e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(_e,{variant:n,size:i,disabled:m,className:Pe("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"}[i]),"aria-label":"Mais opções",children:e.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[i]})})}),e.jsx(gs,{align:c,className:"min-w-[160px]",children:r.map(a=>{const t=a.icon;return e.jsxs(bs,{onClick:a.onClick,disabled:a.disabled,className:Pe("destructive"===a.variant&&"text-destructive focus:text-destructive"),children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})]}):e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,className:u,children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]})},exports.Stack=dr,exports.Switch=Zs,exports.TIMEZONES=Mr,exports.TabPageContent=function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-6",t),children:a})},exports.TabPageHeader=function({title:a,description:t,actions:s,className:r}){return e.jsxs("div",{className:Pe("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:a}),t&&e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx($e,{})]})},exports.TabPageLayout=function({children:a,className:t}){return e.jsx("div",{className:Pe("flex flex-col h-full",t),children:e.jsx(Ks,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:a})})})},exports.Table=Vt,exports.TableBody=Gt,exports.TableCaption=Yt,exports.TableCell=Jt,exports.TableFooter=Qt,exports.TableHead=Xt,exports.TableHeader=Ht,exports.TableResizeHandle=ls,exports.TableRow=Kt,exports.TableRowActions=Us,exports.TableSkeleton=Zt,exports.Tabs=Uo,exports.TabsContent=Bo,exports.TabsList=qo,exports.TabsTrigger=$o,exports.Textarea=ya,exports.Toaster=Sa,exports.Toggle=Vo,exports.ToggleGroup=Go,exports.ToggleGroupItem=Qo,exports.TokenManager=Ja,exports.TokenService=Ba,exports.Tooltip=rs,exports.TooltipContent=is,exports.TooltipProvider=ss,exports.TooltipTrigger=ns,exports.TranslationLoader=Qr,exports.TruncatedCell=os,exports.VideoEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{inputType:"url",controls:!0}),h=a.useRef(null),x=a.useRef(null),{upload:f,uploading:b}=Pd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:j}=Pd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),y=a.useMemo(()=>Rd(m.videoUrl||Md(m.embedCode)||""),[m.videoUrl,m.embedCode]),N=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("input_type")}),e.jsxs(ca,{value:m.inputType||"url",onValueChange:e=>N("inputType",e),children:[e.jsx(pa,{children:e.jsx(ma,{})}),e.jsxs(fa,{children:[e.jsx(ba,{value:"url",children:u("url")}),e.jsx(ba,{value:"upload",children:u("input_type_upload")}),e.jsx(ba,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:h,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await f(a),t={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||a.name.replace(/\.[^/.]+$/,"")};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("select_video")]})}),m.videoFile&&e.jsx("span",{className:"text-xs text-muted-foreground truncate self-center",children:u("video.fileInfo",{name:m.videoFile,size:Math.round((m.videoSize||0)/1024/1024)})})]})]}),"embed"===m.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("embed")}),e.jsx(ya,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};p(t),s(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("video.uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]}),m.thumbnailFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("video.thumbnailFileInfo",{name:m.thumbnailFile})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"title",children:u("title")}),e.jsx(Me,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>N("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"autoplay",type:"checkbox",checked:m.autoplay||!1,onChange:e=>N("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(De,{htmlFor:"autoplay",className:"cursor-pointer",children:u("video.autoplay")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"controls",type:"checkbox",checked:!1!==m.controls,onChange:e=>N("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(De,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=m.videoUrl||Md(m.embedCode)||"";if(!a)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===y)return e.jsxs("video",{controls:!1!==m.controls,autoPlay:m.autoplay,poster:m.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:a}),u("unsupported")]});const t="youtube"===y?Id(a,m.autoplay):Ed(a,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:t,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{onClick:()=>{m.videoUrl||m.embedCode?r(m):l.toast.error(u("error"),{description:u("error_no_video")})},disabled:!(m.videoUrl||m.embedCode),children:u("save")})]})]})},exports.VideoRenderer=function({content:a,className:t="",style:s}){const r=a.videoUrl||Md(a.embedCode)||"";if(!r)return null;const n=Rd(r),{t:i}=g.useTranslation();return e.jsx(ze,{className:`overflow-hidden my-4 ${t}`,style:s,children:e.jsxs(Ue,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:a.title||i("video"),src:"youtube"===n?Id(r,a.autoplay):Ed(r,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.assets=Wl,exports.badgeVariants=Na,exports.buildHierarchy=dd,exports.buttonGroupVariants=Tn,exports.buttonVariants=Ie,exports.calculateAspectRatio=Dd,exports.cn=Pe,exports.createCrudPage=function(a){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:i||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton};return e.jsx(ur,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:o,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=Al({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=Al,exports.createService=Rt,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=Rt({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,s)=>Wt({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=Tt,exports.deriveNameField=St,exports.deriveUsernameField=Pt,exports.detectBrowserLocale=Or,exports.detectBrowserPreferences=$r,exports.detectBrowserTimezone=Ur,exports.detectVideoProvider=Rd,exports.emailService=sd,exports.errorService=et,exports.extractImageFileName=function(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"}},exports.extractVimeoId=_d,exports.extractYouTubeId=Ad,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.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))},exports.findDatetimeFormat=e=>Er.find(a=>a.value===e),exports.findLocale=e=>_r.find(a=>a.value===e),exports.findTimezone=e=>Mr.find(a=>a.value===e),exports.flattenTree=cd,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=ad,exports.formatDatetime=e=>{if(!e)return"";const a=i.parseISO(e);if(!i.isValid(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"})}`},exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:pr(e),label:pr(e),...mr(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.getQualiexConfig=wt,exports.getSupabaseClient=ot,exports.handleExternalLink=Te,exports.inferDatetimeFormat=qr,exports.inputGroupAddonVariants=xi,exports.inputGroupButtonVariants=gi,exports.isDevEnvironment=yt,exports.isImageUrl=function(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))},exports.isValidDatetimeFormat=e=>Er.some(a=>a.value===e),exports.isValidLocale=Fr,exports.isValidTimezone=Lr,exports.logoSrc=Vl,exports.navigationMenuTriggerStyle=zi,exports.normalizeVideoUrl=function(e,a,t){switch(a||Rd(e)){case"youtube":return Id(e,t);case"vimeo":return Ed(e,t);default:return e}},exports.normalizeVimeoUrl=Ed,exports.normalizeYouTubeUrl=Id,exports.parseIframeSrc=Md,exports.placeService=ld,exports.qualiexApi=gt,exports.resizeKeepingAspect=function(e,a,t,s){const r=Dd(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=At,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new v.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.slugify=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),exports.smallLogoSrc=Hl,exports.toggleVariants=Wo,exports.translationService=Tr,exports.trimTextFields=Ae,exports.useActiveModules=Ol,exports.useAuth=Bt,exports.useBaseForm=Hs,exports.useColumnResize=$s,exports.useCreateLeaderMutation=function(){const e="common",{alias:a}=Bt(),t=v.useQueryClient(),s=ot();return v.useMutation({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 s.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 gd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.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 r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder adicionado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=pd,exports.useCreateSingleLeaderMutation=md,exports.useCrud=Wt,exports.useDebounce=zl,exports.useFormField=sa,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Jl();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a,datetimeFormat:t}=Gr();return{formatDatetime:s=>((e,a=Dr,t=zr,s=Rr)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const n=ed[s]||Xn;try{return X.formatInTimeZone(r,t,a,{locale:n})}catch(o){return X.formatInTimeZone(r,zr,a,{locale:n})}})(s,t,a,e),formatDate:t=>ad(t,e,a),locale:e,timezone:a,datetimeFormat:t}},exports.useLeadershipApi=ud,exports.useLocale=Gr,exports.useMediaUpload=Pd,exports.useModalState=Jl,exports.useNavigation=Rl,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:s}=yr();a.useEffect(()=>(t(e),()=>s()),[e.title,e.subtitle,t,s])},exports.usePageMetadataContext=yr,exports.usePageTitle=Dl,exports.usePermissionQuery=Ll,exports.useQualiexUsers=er,exports.useRemoveLeaderMutation=xd,exports.useRouteBreadcrumbs=function(){const e=j.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:s,isCurrentPage:n})}),t})()},exports.useRowResize=Bs,exports.useSidebar=ho,exports.useSidebarResize=Kl,exports.useSyncSubordinatesMutation=fd,exports.useUpdateLeaderMutation=hd,exports.useWizard=function(e){const{steps:t,initialStep:s=0,initialData:r={},onComplete:n,onCancel:i}=e,[o,l]=a.useState(s),[d,c]=a.useState(r),[u,m]=a.useState(!1),[p,h]=a.useState(!1),x=t.length,f=0===o,g=o===x-1,b=t[o],v=x>1?(o+1)/x*100:100,j=a.useMemo(()=>!b?.canProceed||b.canProceed(),[b,d]),y=a.useMemo(()=>!f&&!b?.disableBack,[f,b]),N=a.useCallback(async()=>{j&&!u&&(g?await P():l(e=>Math.min(e+1,x-1)))},[j,u,g,x]),w=a.useCallback(()=>{y&&!u&&l(e=>Math.max(e-1,0))},[y,u]),C=a.useCallback(e=>{e<0||e>=x||u||(e<=o||e===o+1)&&l(e)},[o,x,u]),k=a.useCallback(e=>{c(a=>({...a,...e}))},[]),S=a.useCallback((e,a)=>{c(t=>({...t,[e]:a}))},[]),T=a.useCallback(()=>{l(s),c(r),m(!1),h(!1),i?.()},[s,r,i]),P=a.useCallback(async()=>{if(j&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[j,p,d,n]),A=a.useCallback(e=>{m(e)},[]);return{currentStep:o,currentStepConfig:b,data:d,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:N,back:w,goTo:C,canProceed:j,canGoBack:y,setData:k,updateField:S,reset:T,complete:P,setLoading:A,progress:v,stepIndex:o,totalSteps:x}};