forlogic-core 1.16.7 → 1.16.9

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.
Files changed (169) hide show
  1. package/.note/memory/architecture/documentation-strategy.md +59 -0
  2. package/.note/memory/patterns/core-providers-setup.md +39 -0
  3. package/.note/memory/patterns/deprecated-patterns.md +14 -0
  4. package/.note/memory/patterns/feature-flags.md +19 -0
  5. package/.note/memory/patterns/header-metadata-pattern.md +62 -0
  6. package/.note/memory/patterns/i18n-setup.md +43 -0
  7. package/.note/memory/patterns/vite-tailwind-setup.md +49 -0
  8. package/.note/memory/rules/doc-sync-rule.md +32 -0
  9. package/.note/memory/rules/i18n-import-rule.md +29 -0
  10. package/.note/memory/rules/lib-first-rule.md +42 -0
  11. package/.note/memory/rules/no-auto-index-rule.md +37 -9
  12. package/.note/memory/rules/no-delete-policy-rule.md +41 -12
  13. package/.note/memory/rules/rls-syntax-rule.md +50 -0
  14. package/.note/memory/rules/sql-naming-rule.md +23 -0
  15. package/.note/memory/rules/supabase-import-rule.md +31 -0
  16. package/.note/memory/rules/supabase-schema-rule.md +5 -4
  17. package/.note/memory/ui/components/combo-tree.md +9 -1
  18. package/.note/memory/ui/design-system/documentation-standard.md +17 -0
  19. package/README.md +78 -212
  20. package/dist/README.md +78 -212
  21. package/dist/assets/AccordionDoc-BVPUJk8G.js +31 -0
  22. package/dist/assets/ActionButtonDoc-DLJ_K9ib.js +47 -0
  23. package/dist/assets/AlertDoc-CY1ybZeG.js +37 -0
  24. package/dist/assets/AppHeaderDoc-Crkw4dA9.js +67 -0
  25. package/dist/assets/AppSidebarDoc-ET-4j6wV.js +204 -0
  26. package/dist/assets/AuthDoc-B4v4Nci5.js +192 -0
  27. package/dist/assets/AvatarDoc-BLdMoyJd.js +11 -0
  28. package/dist/assets/BadgeDoc-CSNM1b6b.js +36 -0
  29. package/dist/assets/BaseFormDoc-DXiYuN6-.js +169 -0
  30. package/dist/assets/BodyContentDoc-Bp6YmUWX.js +83 -0
  31. package/dist/assets/BreadcrumbDoc-D7tqqTvo.js +75 -0
  32. package/dist/assets/ButtonDoc-C4JwIvU3.js +41 -0
  33. package/dist/assets/ButtonGroupDoc-QFfjC7Pm.js +7 -0
  34. package/dist/assets/CalendarDoc-COlEKqmv.js +81 -0
  35. package/dist/assets/CardDoc-BVhMoC2w.js +49 -0
  36. package/dist/assets/ChartDoc-BJ14EjI2.js +111 -0
  37. package/dist/assets/CheckboxDoc-Bcqpln9_.js +55 -0
  38. package/dist/assets/ColorPickerDoc-CcfmSwyC.js +10 -0
  39. package/dist/assets/ColorsFoundationDoc-uO6IiJbS.js +13 -0
  40. package/dist/assets/ComboTreeDoc-R4qE6XwB.js +46 -0
  41. package/dist/assets/ComboboxDoc-JIo_-gSN.js +134 -0
  42. package/dist/assets/ComponentDocTemplate-CRbRY-v5.js +1 -0
  43. package/dist/assets/ContextMenuDoc-C4-_0NLp.js +182 -0
  44. package/dist/assets/ContextsDoc-Cj9Aaoyo.js +184 -0
  45. package/dist/assets/CreateCrudPageDoc-D_SnMRJ2.js +106 -0
  46. package/dist/assets/CrudActionBarDoc-BYqtIabp.js +112 -0
  47. package/dist/assets/CrudGridDoc-DspxQrq5.js +85 -0
  48. package/dist/assets/CrudOverviewDoc-DLcOL_HZ.js +14 -0
  49. package/dist/assets/CrudPrimitivesDoc-BRS86nWg.js +164 -0
  50. package/dist/assets/CrudTableDoc-Daw8u2G_.js +113 -0
  51. package/dist/assets/DataListDoc-BrgVNhhR.js +13 -0
  52. package/dist/assets/DesignSystemHome-BFBNqq1J.js +1 -0
  53. package/dist/assets/DialogDoc-DCpRy4rg.js +981 -0
  54. package/dist/assets/DropdownMenuDoc-DT6LBa8Z.js +175 -0
  55. package/dist/assets/EmptyStateDoc-wydc09gG.js +35 -0
  56. package/dist/assets/EnvironmentsDoc-amIriwDD.js +96 -0
  57. package/dist/assets/ErrorBoundaryDoc-BEixy_Gl.js +111 -0
  58. package/dist/assets/FormDoc-DxoRt6p7.js +81 -0
  59. package/dist/assets/FoundationOverview-CxSbumIt.js +1 -0
  60. package/dist/assets/GridDoc-BpQqCMUE.js +28 -0
  61. package/dist/assets/HooksDoc-JNODhbaF.js +665 -0
  62. package/dist/assets/HoverCardDoc-CdqiYrIb.js +31 -0
  63. package/dist/assets/I18nDoc-B6LMXnE3.js +232 -0
  64. package/dist/assets/IconPickerDoc-BRdy58IC.js +10 -0
  65. package/dist/assets/IconsFoundationDoc-CrymfxTI.js +33 -0
  66. package/dist/assets/InputDoc-BK-SdpJ7.js +211 -0
  67. package/dist/assets/LabelDoc-DHvgzhaJ.js +42 -0
  68. package/dist/assets/LeadershipDoc-DRiB0spL.js +416 -0
  69. package/dist/assets/MediaDoc-B_vqnf72.js +459 -0
  70. package/dist/assets/MenubarDoc-Zvgczxe2.js +165 -0
  71. package/dist/assets/ModuleAccessDoc-Nuxb4S27.js +153 -0
  72. package/dist/assets/ModulesDialogDoc-iJWLkOZo.js +46 -0
  73. package/dist/assets/NavigationMenuDoc-CeWun1VF.js +116 -0
  74. package/dist/assets/OnboardingDialogDoc-xBL-rXeZ.js +55 -0
  75. package/dist/assets/PaginationDoc-CfvwxCMe.js +98 -0
  76. package/dist/assets/PaginationDoc-DqtRgXnF.js +27 -0
  77. package/dist/assets/PlacesDoc-nckioEzg.js +226 -0
  78. package/dist/assets/PopoverDoc-C3o2CZCT.js +64 -0
  79. package/dist/assets/ProgressDoc-BmWBNMPA.js +29 -0
  80. package/dist/assets/QualiexUserFieldDoc-CE1e4mx6.js +149 -0
  81. package/dist/assets/RadioGroupDoc-DMZH6NmR.js +57 -0
  82. package/dist/assets/RadiusDoc-BOZD3gPV.js +7 -0
  83. package/dist/assets/RequiredFieldsCounterDoc-CG-lmSSy.js +58 -0
  84. package/dist/assets/ResizableDoc-CqGkv6Cd.js +104 -0
  85. package/dist/assets/RichTextEditorDoc-m50ll-Od.js +24 -0
  86. package/dist/assets/ScrollAreaDoc-BzJ-APXo.js +28 -0
  87. package/dist/assets/SecurityDoc-B34gVeiV.js +204 -0
  88. package/dist/assets/SelectDoc-DXRv7QHK.js +80 -0
  89. package/dist/assets/SeparatorDoc-DcNh8k0P.js +4 -0
  90. package/dist/assets/ServicesDoc-8aXBd6yg.js +308 -0
  91. package/dist/assets/ShadowsDoc-Brl4hIDI.js +9 -0
  92. package/dist/assets/SignDoc-BdwerR-2.js +66 -0
  93. package/dist/assets/SkeletonDoc-BWgqgbDY.js +54 -0
  94. package/dist/assets/SliderDoc-E-NjbYVk.js +41 -0
  95. package/dist/assets/SpacingDoc-BzburM-r.js +12 -0
  96. package/dist/assets/SplitButtonDoc-BYUysmJp.js +53 -0
  97. package/dist/assets/StepSelectorDoc-PB1k4v7F.js +41 -0
  98. package/dist/assets/SwitchDoc-BLOG6kfj.js +56 -0
  99. package/dist/assets/TableDoc-Dwcs-lop.js +128 -0
  100. package/dist/assets/TabsDoc-Ovkh8ArV.js +42 -0
  101. package/dist/assets/TextareaDoc-DsBYxmbr.js +46 -0
  102. package/dist/assets/ToastDoc-BbZaFE_A.js +157 -0
  103. package/dist/assets/ToggleDoc-C28vbvhp.js +51 -0
  104. package/dist/assets/TooltipDoc-DL5cnLak.js +58 -0
  105. package/dist/assets/TruncatedCellDoc-BuDA8QcY.js +12 -0
  106. package/dist/assets/TypographyFoundationDoc-CPdH4PHa.js +7 -0
  107. package/dist/assets/UtilitiesDoc-CrQhyEfz.js +145 -0
  108. package/dist/assets/blocks-DO93nPjs.js +1 -0
  109. package/dist/assets/calendar-days-cMfwBSZx.js +1 -0
  110. package/dist/assets/circle-plus-D3NftMzS.js +1 -0
  111. package/dist/assets/circle-x-BVAVJ_oz.js +1 -0
  112. package/dist/assets/crown-B2MTZDnM.js +1 -0
  113. package/dist/assets/date-picker-zhJU-_kM.js +1 -0
  114. package/dist/assets/disabled-menu-item-C16xsaVs.js +1 -0
  115. package/dist/assets/drawer-oTqCOtsC.js +3 -0
  116. package/dist/assets/file-pen-line-CXv-Eye-.js +1 -0
  117. package/dist/assets/git-branch-V6-h6P9K.js +1 -0
  118. package/dist/assets/globe-CaUBIJU8.js +1 -0
  119. package/dist/assets/hash-B4MTXppl.js +1 -0
  120. package/dist/assets/hover-card-DEuucfxP.js +1 -0
  121. package/dist/assets/index-CE0k7Rdh.js +312 -0
  122. package/dist/assets/index-Cx3adT_u.css +1 -0
  123. package/dist/assets/life-buoy-BRndExxh.js +1 -0
  124. package/dist/assets/lucide-react-t7dCa4lv.js +1 -0
  125. package/dist/assets/monitor-Dg3HKTSE.js +1 -0
  126. package/dist/assets/package-3G45ARQh.js +1 -0
  127. package/dist/assets/pen-BYSSwjK4.js +1 -0
  128. package/dist/assets/pin-CMYagNhs.js +1 -0
  129. package/dist/assets/radio-group-BVun_Tmt.js +1 -0
  130. package/dist/assets/server-p0Sb0mKI.js +1 -0
  131. package/dist/assets/share-2-D-ZhCCq2.js +1 -0
  132. package/dist/assets/shield-x-Q7hAXWsG.js +1 -0
  133. package/dist/assets/step-selector-DHxgT2FL.js +1 -0
  134. package/dist/assets/text-align-start-6aYQqbX4.js +1 -0
  135. package/dist/assets/trash-DveAOiLF.js +1 -0
  136. package/dist/assets/useMockCrud-GY0KxHXr.js +1 -0
  137. package/dist/assets/user-check-CoGNBfIk.js +1 -0
  138. package/dist/assets/user-plus-Bad2xWIT.js +1 -0
  139. package/dist/bin/pull-docs.js +14 -13
  140. package/dist/components/modules/ModuleAccessGuard.d.ts +24 -2
  141. package/dist/components/ui/combo-tree.d.ts +2 -0
  142. package/dist/contexts/PageMetadataContext.d.ts +6 -1
  143. package/dist/crud/components/ColumnSettingsPopover.d.ts +17 -0
  144. package/dist/crud/components/CrudActionBar.d.ts +2 -1
  145. package/dist/crud/components/CrudTable.d.ts +5 -1
  146. package/dist/crud/components/GroupDropZone.d.ts +16 -0
  147. package/dist/crud/components/InlineRowActions.d.ts +15 -0
  148. package/dist/crud/hooks/useColumnDragReorder.d.ts +19 -0
  149. package/dist/crud/hooks/useColumnManager.d.ts +56 -0
  150. package/dist/crud/primitives/Table.d.ts +1 -1
  151. package/dist/crud/primitives/TreeTable.d.ts +2 -0
  152. package/dist/crud/primitives/index.d.ts +2 -1
  153. package/dist/crud/primitives/types.d.ts +33 -0
  154. package/dist/docs/KNOWLEDGE.md +68 -167
  155. package/dist/exports/crud.d.ts +2 -1
  156. package/dist/hooks/useDerivedContractedModules.d.ts +8 -0
  157. package/dist/i18n/config.d.ts +11 -0
  158. package/dist/i18n/index.d.ts +1 -1
  159. package/dist/index.css +1 -1
  160. package/dist/index.css.map +1 -1
  161. package/dist/index.d.ts +3 -1
  162. package/dist/index.esm.js +1 -1
  163. package/dist/index.html +35 -0
  164. package/dist/index.js +1 -1
  165. package/dist/providers/CoreProviders.d.ts +31 -34
  166. package/dist/types.d.ts +4 -0
  167. package/docs/KNOWLEDGE.md +68 -167
  168. package/package.json +2 -3
  169. package/docs/DESIGN_SYSTEM.md +0 -12174
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),o=require("date-fns"),i=require("sonner"),l=require("lucide-react"),c=require("@radix-ui/react-label"),d=require("@radix-ui/react-dialog"),u=require("@radix-ui/react-separator"),m=require("@radix-ui/react-alert-dialog"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),x=require("@radix-ui/react-dropdown-menu"),g=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),v=require("react-i18next"),w=require("@radix-ui/react-scroll-area"),N=require("@supabase/supabase-js"),y=require("@tanstack/react-query"),j=require("react-router-dom"),C=require("@radix-ui/react-context-menu"),k=require("@radix-ui/react-toggle-group"),S=require("@radix-ui/react-toggle"),_=require("@radix-ui/react-switch"),A=require("i18next"),T=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-tabs"),P=require("@radix-ui/react-progress"),M=require("@radix-ui/react-accordion"),I=require("@radix-ui/react-avatar"),D=require("react-day-picker"),R=require("vaul"),L=require("@radix-ui/react-hover-card"),z=require("@radix-ui/react-navigation-menu"),F=require("@radix-ui/react-radio-group"),U=require("react-resizable-panels"),q=require("@radix-ui/react-slider"),O=require("@radix-ui/react-menubar"),B=require("recharts"),$=require("@tiptap/react"),H=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),W=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),K=require("zod"),X=require("@hookform/resolvers");function Z(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var J=Z(t),ee=Z(c),te=Z(d),ae=Z(u),se=Z(m),re=Z(h),ne=Z(f),oe=Z(x),ie=Z(g),le=Z(b),ce=Z(w),de=Z(C),ue=Z(k),me=Z(S),pe=Z(_),he=Z(T),fe=Z(E),xe=Z(P),ge=Z(M),be=Z(I),ve=Z(L),we=Z(z),Ne=Z(F),ye=Z(U),je=Z(q),Ce=Z(O),ke=Z(B);const Se={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"}};function _e(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const Ae={date:_e({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:_e({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:_e({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Te={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Ee(e){return(t,a)=>{let s;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,r=a?.width?String(a.width):t;s=e.formattingValues[r]||e.formattingValues[t]}else{const t=e.defaultWidth,r=a?.width?String(a.width):e.defaultWidth;s=e.values[r]||e.values[t]}return s[e.argumentCallback?e.argumentCallback(t):t]}}const Pe={ordinalNumber:(e,t)=>{const a=Number(e),s=a%100;if(s>20||s<10)switch(s%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:Ee({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})};function Me(e){return(t,a={})=>{const s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let c;c=e.valueCallback?e.valueCallback(l):l,c=a.valueCallback?a.valueCallback(c):c;return{value:c,rest:t.slice(o.length)}}}function Ie(e){return(t,a={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],n=t.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(r.length)}}}const De={ordinalNumber:Ie({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},Re={code:"en-US",formatDistance:(e,t,a)=>{let s;const r=Se[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+s:s+" ago":s},formatLong:Ae,formatRelative:(e,t,a,s)=>Te[e],localize:Pe,match:De,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Le={};function ze(){return Le}const Fe=6048e5;function Ue(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function qe(e){const t=Ue(e);return t.setHours(0,0,0,0),t}function Oe(e){const t=Ue(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function Be(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function $e(e){const t=Ue(e),a=function(e,t){const a=qe(e),s=qe(t),r=+a-Oe(a),n=+s-Oe(s);return Math.round((r-n)/864e5)}(t,function(e){const t=Ue(e),a=Be(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function He(e,t){const a=ze(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,r=Ue(e),n=r.getDay(),o=(n<s?7:0)+n-s;return r.setDate(r.getDate()-o),r.setHours(0,0,0,0),r}function Ve(e){return He(e,{weekStartsOn:1})}function We(e){const t=Ue(e),a=t.getFullYear(),s=Be(e,0);s.setFullYear(a+1,0,4),s.setHours(0,0,0,0);const r=Ve(s),n=Be(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const o=Ve(n);return t.getTime()>=r.getTime()?a+1:t.getTime()>=o.getTime()?a:a-1}function Ge(e){const t=Ue(e),a=+Ve(t)-+function(e){const t=We(e),a=Be(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),Ve(a)}(t);return Math.round(a/Fe)+1}function Ye(e,t){const a=Ue(e),s=a.getFullYear(),r=ze(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=Be(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=He(o,t),l=Be(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const c=He(l,t);return a.getTime()>=i.getTime()?s+1:a.getTime()>=c.getTime()?s:s-1}function Qe(e,t){const a=Ue(e),s=+He(a,t)-+function(e,t){const a=ze(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,r=Ye(e,t),n=Be(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),He(n,t)}(a,t);return Math.round(s/Fe)+1}function Ke(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const Xe={y(e,t){const a=e.getFullYear(),s=a>0?a:1-a;return Ke("yy"===t?s%100:s,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):Ke(a+1,2)},d:(e,t)=>Ke(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>Ke(e.getHours()%12||12,t.length),H:(e,t)=>Ke(e.getHours(),t.length),m:(e,t)=>Ke(e.getMinutes(),t.length),s:(e,t)=>Ke(e.getSeconds(),t.length),S(e,t){const a=t.length,s=e.getMilliseconds();return Ke(Math.trunc(s*Math.pow(10,a-3)),t.length)}},Ze="midnight",Je="noon",et="morning",tt="afternoon",at="evening",st="night",rt={G:function(e,t,a){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"});case"GGGGG":return a.era(s,{width:"narrow"});default:return a.era(s,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),s=t>0?t:1-t;return a.ordinalNumber(s,{unit:"year"})}return Xe.y(e,t)},Y:function(e,t,a,s){const r=Ye(e,s),n=r>0?r:1-r;if("YY"===t){return Ke(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):Ke(n,t.length)},R:function(e,t){return Ke(We(e),t.length)},u:function(e,t){return Ke(e.getFullYear(),t.length)},Q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return Ke(s,2);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});default:return a.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return Ke(s,2);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});default:return a.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,a){const s=e.getMonth();switch(t){case"M":case"MM":return Xe.M(e,t);case"Mo":return a.ordinalNumber(s+1,{unit:"month"});case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});default:return a.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,a){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return Ke(s+1,2);case"Lo":return a.ordinalNumber(s+1,{unit:"month"});case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});default:return a.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,a,s){const r=Qe(e,s);return"wo"===t?a.ordinalNumber(r,{unit:"week"}):Ke(r,t.length)},I:function(e,t,a){const s=Ge(e);return"Io"===t?a.ordinalNumber(s,{unit:"week"}):Ke(s,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):Xe.d(e,t)},D:function(e,t,a){const s=$e(e);return"Do"===t?a.ordinalNumber(s,{unit:"dayOfYear"}):Ke(s,t.length)},E:function(e,t,a){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return Ke(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return Ke(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"});default:return a.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,a){const s=e.getDay(),r=0===s?7:s;switch(t){case"i":return String(r);case"ii":return Ke(r,t.length);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return a.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,a){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,a){const s=e.getHours();let r;switch(r=12===s?Je:0===s?Ze:s/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,a){const s=e.getHours();let r;switch(r=s>=17?at:s>=12?tt:s>=4?et:st,t){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return Xe.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):Xe.H(e,t)},K:function(e,t,a){const s=e.getHours()%12;return"Ko"===t?a.ordinalNumber(s,{unit:"hour"}):Ke(s,t.length)},k:function(e,t,a){let s=e.getHours();return 0===s&&(s=24),"ko"===t?a.ordinalNumber(s,{unit:"hour"}):Ke(s,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xe.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):Xe.s(e,t)},S:function(e,t){return Xe.S(e,t)},X:function(e,t,a){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(t){case"X":return ot(s);case"XXXX":case"XX":return it(s);default:return it(s,":")}},x:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"x":return ot(s);case"xxxx":case"xx":return it(s);default:return it(s,":")}},O:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+nt(s,":");default:return"GMT"+it(s,":")}},z:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+nt(s,":");default:return"GMT"+it(s,":")}},t:function(e,t,a){return Ke(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return Ke(e.getTime(),t.length)}};function nt(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?a+String(r):a+String(r)+t+Ke(n,2)}function ot(e,t){if(e%60==0){return(e>0?"-":"+")+Ke(Math.abs(e)/60,2)}return it(e,t)}function it(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+Ke(Math.trunc(s/60),2)+t+Ke(s%60,2)}const lt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},ct=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},dt={p:ct,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],s=a[1],r=a[2];if(!r)return lt(e,t);let n;switch(s){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",lt(s,t)).replace("{{time}}",ct(r,t))}},ut=/^D+$/,mt=/^Y+$/,pt=["D","DD","YY","YYYY"];function ht(e){if(!function(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;const t=Ue(e);return!isNaN(Number(t))}const ft=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gt=/^'([^]*?)'?$/,bt=/''/g,vt=/[a-zA-Z]/;function wt(e,t,a){const s=ze(),r=a?.locale??s.locale??Re,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=Ue(e);if(!ht(i))throw new RangeError("Invalid time value");let l=t.match(xt).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,dt[t])(e,r.formatLong)}return e}).join("").match(ft).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Nt(e)};if(rt[t])return{isToken:!0,value:e};if(t.match(vt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});r.localize.preprocessor&&(l=r.localize.preprocessor(i,l));const c={firstWeekContainsDate:n,weekStartsOn:o,locale:r};return l.map(s=>{if(!s.isToken)return s.value;const n=s.value;(!a?.useAdditionalWeekYearTokens&&function(e){return mt.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return ut.test(e)}(n))&&function(e,t,a){const s=function(e,t,a){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(pt.includes(e))throw new RangeError(s)}(n,t,String(e));return(0,rt[n[0]])(i,n,r.localize,c)}).join("")}function Nt(e){const t=e.match(gt);return t?t[1].replace(bt,"'"):e}function yt(e,t,a){const s=o.getDefaultOptions(),r=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??s.locale);return"formatToParts"in r?function(e,t){const a=e.formatToParts(t);for(let s=a.length-1;s>=0;--s)if("timeZoneName"===a[s].type)return a[s].value;return}(r,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(a);return s?s[0].substr(1):""}(r,t)}function jt(e,t){const a=function(e){kt[e]||(kt[e]=_t?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}));return kt[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),s=[];for(let e=0;e<a.length;e++){const t=Ct[a[e].type];void 0!==t&&(s[t]=parseInt(a[e].value,10))}return s}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(s[3],10),parseInt(s[1],10),parseInt(s[2],10),parseInt(s[4],10),parseInt(s[5],10),parseInt(s[6],10)]}(a,e)}const Ct={year:0,month:1,day:2,hour:3,minute:4,second:5};const kt={},St=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),_t="06/25/2014, 00:00:00"===St||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===St;function At(e,t,a,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,t,a),i.setUTCHours(s,r,n,o),i}const Tt=36e5,Et={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Pt(e,t,a){if(!e)return 0;let s,r,n=Et.timezoneZ.exec(e);if(n)return 0;if(n=Et.timezoneHH.exec(e),n)return s=parseInt(n[1],10),It(s)?-s*Tt:NaN;if(n=Et.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return It(s,e)?(r=Math.abs(s)*Tt+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Dt[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Dt[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const s=a?t:function(e){return At(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),r=Mt(s,e),n=a?r:function(e,t,a){const s=e.getTime();let r=s-t;const n=Mt(new Date(r),a);if(t===n)return t;r-=n-t;const o=Mt(new Date(r),a);if(n===o)return n;return Math.max(n,o)}(t,r,e);return-n}return NaN}function Mt(e,t){const a=jt(e,t),s=At(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function It(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const Dt={};const Rt={X:function(e,t,a){const s=Lt(a.timeZone,e);if(0===s)return"Z";switch(t){case"X":return Ut(s);case"XXXX":case"XX":return Ft(s);default:return Ft(s,":")}},x:function(e,t,a){const s=Lt(a.timeZone,e);switch(t){case"x":return Ut(s);case"xxxx":case"xx":return Ft(s);default:return Ft(s,":")}},O:function(e,t,a){const s=Lt(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return a+String(r);return a+String(r)+t+zt(n,2)}(s,":");default:return"GMT"+Ft(s,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return yt("short",e,a);default:return yt("long",e,a)}}};function Lt(e,t){const a=e?Pt(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function zt(e,t){const a=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<t;)s="0"+s;return a+s}function Ft(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+zt(Math.floor(s/60),2)+t+zt(Math.floor(s%60),2)}function Ut(e,t){if(e%60==0){return(e>0?"-":"+")+zt(Math.abs(e)/60,2)}return Ft(e,t)}function qt(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const Ot=36e5,Bt=6e4,$t={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function Ht(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const s=function(e){const t={};let a,s=$t.dateTimePattern.exec(e);s?(t.date=s[1],a=s[3]):(s=$t.datePattern.exec(e),s?(t.date=s[1],a=s[2]):(t.date=null,a=e));if(a){const e=$t.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:r,restDateString:n}=function(e,t){if(e){const a=$t.YYY[t],s=$t.YYYYY[t];let r=$t.YYYY.exec(e)||s.exec(e);if(r){const t=r[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(r=$t.YY.exec(e)||a.exec(e),r){const t=r[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(s.date,a),o=function(e,t){if(null===t)return null;let a,s,r;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=$t.MM.exec(e);if(n)return a=new Date(0),s=parseInt(n[1],10)-1,Qt(t,s)?(a.setUTCFullYear(t,s),a):new Date(NaN);if(n=$t.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=Yt(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=$t.MMDD.exec(e),n){a=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return Qt(t,s,e)?(a.setUTCFullYear(t,s,e),a):new Date(NaN)}if(n=$t.Www.exec(e),n)return r=parseInt(n[1],10)-1,Kt(r)?Vt(t,r):new Date(NaN);if(n=$t.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return Kt(r,e)?Vt(t,r,e):new Date(NaN)}return null}(n,r);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let a,r=0;if(s.time&&(r=function(e){let t,a,s=$t.HH.exec(e);if(s)return t=parseFloat(s[1].replace(",",".")),Xt(t)?t%24*Ot:NaN;if(s=$t.HHMM.exec(e),s)return t=parseInt(s[1],10),a=parseFloat(s[2].replace(",",".")),Xt(t,a)?t%24*Ot+a*Bt:NaN;if(s=$t.HHMMSS.exec(e),s){t=parseInt(s[1],10),a=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return Xt(t,a,e)?t%24*Ot+a*Bt+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||t.timeZone){if(a=Pt(s.timeZone||t.timeZone,new Date(e+r)),isNaN(a))return new Date(NaN)}else a=qt(new Date(e+r)),a=qt(new Date(e+r+a));return new Date(e+r+a)}return new Date(NaN)}function Vt(e,t,a){t=t||0,a=a||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*t+a+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const Wt=[31,28,31,30,31,30,31,31,30,31,30,31],Gt=[31,29,31,30,31,30,31,31,30,31,30,31];function Yt(e){return e%400==0||e%4==0&&e%100!=0}function Qt(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const s=Yt(e);if(s&&a>Gt[t])return!1;if(!s&&a>Wt[t])return!1}return!0}function Kt(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function Xt(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const Zt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Jt(e,t,a,s){return function(e,t,a={}){const s=(t=String(t)).match(Zt);if(s){const r=Ht(a.originalDate||e,a);t=s.reduce(function(e,t){if("'"===t[0])return e;const s=e.indexOf(t),n="'"===e[s-1],o=e.replace(t,"'"+Rt[t[0]](r,t,a)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},t)}return wt(e,t,a)}(function(e,t,a){const s=Pt(t,e=Ht(e,a),!0),r=new Date(e.getTime()-s),n=new Date(0);return n.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),n.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),n}(e,t,{timeZone:(s={...s,timeZone:t,originalDate:e}).timeZone}),a,s)}const ea={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"}},ta={date:_e({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:_e({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:_e({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},aa={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"},sa={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"},ra={ordinalNumber:(e,t)=>Number(e)+"º",era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},na={ordinalNumber:Ie({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},oa={code:"es",formatDistance:(e,t,a)=>{let s;const r=ea[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+s:"hace "+s:s},formatLong:ta,formatRelative:(e,t,a,s)=>1!==t.getHours()?sa[e]:aa[e],localize:ra,match:na,options:{weekStartsOn:1,firstWeekContainsDate:1}},ia={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"}},la={date:_e({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:_e({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:_e({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ca={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},da={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},ua={ordinalNumber:Ie({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},ma={code:"pt-BR",formatDistance:(e,t,a)=>{let s;const r=ia[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+s:"há "+s:s},formatLong:la,formatRelative:(e,t,a,s)=>{const r=ca[e];return"function"==typeof r?r(t):r},localize:da,match:ua,options:{weekStartsOn:0,firstWeekContainsDate:1}},pa=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],ha=[{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"}],fa=[{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"}],xa="pt-BR",ga="dd/MM/yyyy HH:mm",ba="America/Sao_Paulo",va=e=>pa.some(t=>t.value===e),wa=e=>fa.some(t=>t.value===e),Na=()=>{if("undefined"==typeof navigator)return xa;const e=navigator.language;if(va(e))return e;const t=e.split("-")[0],a=pa.find(e=>e.value.startsWith(t));return a?.value||xa},ya=()=>{if("undefined"==typeof Intl)return ba;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return wa(e)?e:ba}catch{return ba}},ja=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||ga),Ca={"pt-BR":ma,"en-US":Re,"es-ES":oa},ka=(e,t=ga,a=ba,s=xa)=>{if(!e)return"";const r=o.parseISO(e);if(!o.isValid(r))return"Data inválida";const n=Ca[s]||ma;try{return Jt(r,a,t,{locale:n})}catch(i){return Jt(r,ba,t,{locale:n})}},Sa=(e,t=xa,a=ba)=>{if(!e)return"";const s=o.parseISO(e);if(!o.isValid(s))return"Data inválida";const r=Ca[t]||ma;try{return Jt(s,a,"PP",{locale:r})}catch(n){return Jt(s,ba,"PP",{locale:r})}};function _a(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{i.toast.info("Link copiado para a área de transferência")})}function Aa(...e){return n.twMerge(r.clsx(e))}const Ta=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Ta);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,s]of Object.entries(e))t[a]=Ta(s);return t}return e},Ea=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"}}),Pa=J.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...o},i)=>{const l=n?a.Slot:"button";return e.jsx(l,{className:Aa(Ea({variant:s,size:r,className:t})),ref:i,...o})});Pa.displayName="Button";const Ma=t.forwardRef(({className:t,children:a,variant:s="action",...r},n)=>e.jsx(Pa,{ref:n,variant:s,size:"icon",className:Aa("h-8 w-8",t),...r,children:a||e.jsx(l.EllipsisVertical,{size:16})}));Ma.displayName="ActionButton";const Ia=J.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:Aa("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",t),ref:r,...s}));Ia.displayName="Input";const Da=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ra=J.forwardRef(({className:t,...a},s)=>e.jsx(ee.Root,{ref:s,className:Aa(Da(),t),...a}));Ra.displayName=ee.Root.displayName;const La=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));La.displayName="Card";const za=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("flex flex-col space-y-1.5 p-6",t),...a}));za.displayName="CardHeader";const Fa=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Aa("text-2xl font-semibold leading-none tracking-tight",t),...a}));Fa.displayName="CardTitle";const Ua=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Ua.displayName="CardDescription";const qa=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("p-6 pt-0",t),...a}));qa.displayName="CardContent";const Oa=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("flex items-center p-6 pt-0",t),...a}));Oa.displayName="CardFooter";const Ba=J.forwardRef(({className:t,orientation:a="horizontal",decorative:s=!0,...r},n)=>e.jsx(ae.Root,{ref:n,decorative:s,orientation:a,className:Aa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...r}));Ba.displayName=ae.Root.displayName;const $a=se.Root,Ha=se.Trigger,Va=se.Portal,Wa=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Overlay,{className:Aa("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",t),...a,ref:s}));Wa.displayName=se.Overlay.displayName;const Ga=J.forwardRef(({className:t,...a},s)=>e.jsxs(Va,{children:[e.jsx(Wa,{}),e.jsx(se.Content,{ref:s,className:Aa("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a})]}));Ga.displayName=se.Content.displayName;const Ya=({className:t,...a})=>e.jsx("div",{className:Aa("flex flex-col space-y-2 text-center sm:text-left",t),...a});Ya.displayName="AlertDialogHeader";const Qa=({className:t,...a})=>e.jsx("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});Qa.displayName="AlertDialogFooter";const Ka=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Title,{ref:s,className:Aa("text-lg font-semibold",t),...a}));Ka.displayName=se.Title.displayName;const Xa=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Xa.displayName=se.Description.displayName;const Za=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Action,{ref:s,className:Aa(Ea(),t),...a}));Za.displayName=se.Action.displayName;const Ja=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Cancel,{ref:s,className:Aa(Ea({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));Ja.displayName=se.Cancel.displayName;const es=te.Root,ts=te.Trigger,as=te.Portal,ss=te.Close,rs=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{ref:s,className:Aa("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",t),...a}));rs.displayName=te.Overlay.displayName;const ns={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},os=J.forwardRef(({className:t,children:a,size:s,variant:r="informative",isDirty:n,customWidth:o,customMinWidth:i,customMaxWidth:c,customHeight:d,customMinHeight:u,customMaxHeight:m,unsavedChangesTitle:p="Alterações não salvas",unsavedChangesDescription:h="Existem alterações não salvas. Deseja sair sem salvar?",cancelText:f="Cancelar",leaveWithoutSavingText:x="Sair sem salvar",style:g,onInteractOutside:b,onEscapeKeyDown:v,...w},N)=>{const[y,j]=J.useState(!1),C=J.useRef(null),k=s??(o||i||c||d||u||m?void 0:"md"),S=k?ns[k]:{},_={...o??S.width?{width:o??S.width}:{},...i??S.minWidth?{minWidth:i??S.minWidth}:{},...c??S.maxWidth?{maxWidth:c??S.maxWidth}:{},...d??S.height?{height:d??S.height}:{},...u??S.minHeight?{minHeight:u??S.minHeight}:{},...m??S.maxHeight?{maxHeight:m??S.maxHeight}:{},...g},A=J.useCallback(e=>{"form"===r&&n?(C.current=e,j(!0)):e()},[r,n]),T="destructive"!==r;return e.jsxs(as,{children:[e.jsx(rs,{}),e.jsxs(te.Content,{ref:N,className:Aa("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 max-sm:!w-[calc(100vw-2rem)] max-sm:!h-[calc(100dvh-2rem)] max-sm:!min-w-0 max-sm:!min-h-0 max-sm:!max-w-none max-sm:!max-h-none max-sm:p-4",t),style:_,onInteractOutside:e=>{"form"!==r&&"destructive"!==r?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==r)return"form"===r&&n?(e.preventDefault(),void A(()=>{v?.(e)})):void v?.(e);e.preventDefault()},...w,children:[a,T&&e.jsxs(te.Close,{onClick:e=>{"form"===r&&n&&(e.preventDefault(),A(()=>{const t=e.target.closest("[data-radix-collection-item]");t&&t.click()}))},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(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]}),e.jsx($a,{open:y,onOpenChange:j,children:e.jsxs(Ga,{children:[e.jsxs(Ya,{children:[e.jsx(Ka,{children:p}),e.jsx(Xa,{children:h})]}),e.jsxs(Qa,{children:[e.jsx(Ja,{onClick:()=>{j(!1),C.current=null},children:f}),e.jsx(Za,{onClick:()=>{j(!1),C.current?.(),C.current=null},children:x})]})]})})]})});os.displayName=te.Content.displayName;const is=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Aa("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Ba,{className:"mt-2"})]});is.displayName="DialogHeader";const ls=({className:t,...a})=>e.jsx("div",{className:Aa("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});ls.displayName="DialogBody";const cs=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsx("div",{className:Aa("flex flex-row justify-end gap-2",t),...s,children:a})]});cs.displayName="DialogFooter";const ds=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Aa("text-lg font-semibold leading-none tracking-tight",t),...a}));ds.displayName=te.Title.displayName;const us=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));us.displayName=te.Description.displayName;const ms=p.FormProvider,ps=J.createContext({}),hs=()=>{const e=J.useContext(ps),t=J.useContext(fs),{getFieldState:a,formState:s}=p.useFormContext(),r=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},fs=J.createContext({}),xs=J.forwardRef(({className:t,...a},s)=>{const r=J.useId();return e.jsx(fs.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Aa("space-y-2",t),...a})})});xs.displayName="FormItem";const gs=J.forwardRef(({className:t,...a},s)=>{const{error:r,formItemId:n}=hs();return e.jsx(Ra,{ref:s,className:Aa(r&&"text-destructive",t),htmlFor:n,...a})});gs.displayName="FormLabel";const bs=J.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=hs();return e.jsx(a.Slot,{ref:s,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...t})});bs.displayName="FormControl";const vs=J.forwardRef(({className:t,...a},s)=>{const{formDescriptionId:r}=hs();return e.jsx("p",{ref:s,id:r,className:Aa("text-sm text-muted-foreground",t),...a})});vs.displayName="FormDescription";const ws=J.forwardRef(({className:t,children:a,...s},r)=>{const{error:n,formMessageId:o}=hs(),i=n?String(n?.message):a;return i?e.jsx("p",{ref:r,id:o,className:Aa("text-sm font-medium text-destructive",t),...s,children:i}):null});ws.displayName="FormMessage";const Ns=re.Root,ys=re.Group,js=re.Value,Cs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(re.Trigger,{ref:r,className:Aa("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(re.Icon,{asChild:!0,children:e.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Cs.displayName=re.Trigger.displayName;const ks=J.forwardRef(({className:t,...a},s)=>e.jsx(re.ScrollUpButton,{ref:s,className:Aa("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronUp,{className:"h-4 w-4"})}));ks.displayName=re.ScrollUpButton.displayName;const Ss=J.forwardRef(({className:t,...a},s)=>e.jsx(re.ScrollDownButton,{ref:s,className:Aa("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronDown,{className:"h-4 w-4"})}));Ss.displayName=re.ScrollDownButton.displayName;const _s=J.forwardRef(({className:t,children:a,position:s="popper",container:r,collisionBoundary:n,...o},i)=>e.jsx(re.Portal,{container:r,children:e.jsxs(re.Content,{ref:i,className:Aa("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:n,...o,children:[e.jsx(ks,{}),e.jsx(re.Viewport,{className:Aa("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(Ss,{})]})}));_s.displayName=re.Content.displayName;const As=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Label,{ref:s,className:Aa("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));As.displayName=re.Label.displayName;const Ts=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(re.Item,{ref:r,className:Aa("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.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(l.Check,{className:"h-4 w-4"})})}),e.jsx(re.ItemText,{children:a})]}));Ts.displayName=re.Item.displayName;const Es=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Es.displayName=re.Separator.displayName;const Ps=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.Root,{ref:s,className:Aa("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",t),...a,children:e.jsx(ne.Indicator,{className:Aa("flex items-center justify-center text-current"),children:e.jsx(l.Check,{className:"h-4 w-4"})})}));Ps.displayName=ne.Root.displayName;const Ms=J.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:Aa("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",t),ref:s,...a}));Ms.displayName="Textarea";const Is=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"}}),Ds=J.forwardRef(({className:t,variant:a,...s},r)=>e.jsx("div",{ref:r,className:Aa(Is({variant:a}),t),...s}));Ds.displayName="Badge";const Rs={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ls({size:t="md",className:a}){return e.jsx(l.Loader2,{className:Aa("animate-spin text-muted-foreground",Rs[t],a)})}const zs=({...t})=>e.jsx(i.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(l.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(l.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(l.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(l.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(l.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"}},...t}),Fs=oe.Root,Us=oe.Trigger,qs=oe.Group,Os=oe.Portal,Bs=oe.Sub,$s=oe.RadioGroup,Hs=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Aa("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Hs.displayName=oe.SubTrigger.displayName;const Vs=J.forwardRef(({className:t,...a},s)=>e.jsx(oe.SubContent,{ref:s,className:Aa("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",t),...a}));Vs.displayName=oe.SubContent.displayName;const Ws=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:a,className:Aa("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",t),...s})}));Ws.displayName=oe.Content.displayName;const Gs=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(oe.Item,{ref:r,className:Aa("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",a&&"pl-8",t),...s}));Gs.displayName=oe.Item.displayName;const Ys=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...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(l.Check,{className:"h-4 w-4"})})}),a]}));Ys.displayName=oe.CheckboxItem.displayName;const Qs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Aa("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.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(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Qs.displayName=oe.RadioItem.displayName;const Ks=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(oe.Label,{ref:r,className:Aa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Ks.displayName=oe.Label.displayName;const Xs=J.forwardRef(({className:t,...a},s)=>e.jsx(oe.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Xs.displayName=oe.Separator.displayName;const Zs=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest opacity-60",t),...a});Zs.displayName="DropdownMenuShortcut";const Js=({delayDuration:t=300,...a})=>e.jsx(ie.Provider,{delayDuration:t,...a}),er=ie.Root,tr=ie.Trigger,ar=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:a,className:Aa("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",t),...s}));ar.displayName=ie.Content.displayName;const sr=J.forwardRef(({children:t,disabledReason:a,className:s},r)=>{const n=e.jsx(Gs,{ref:r,className:Aa("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:t});return a?e.jsx(Js,{delayDuration:100,children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("div",{className:"w-full",children:n})}),e.jsx(ar,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});sr.displayName="DisabledMenuItem";const rr=le.Root,nr=le.Trigger,or=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,container:r,...n},o)=>e.jsx(le.Portal,{container:r,children:e.jsx(le.Content,{ref:o,align:a,sideOffset:s,className:Aa("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",t),...n})}));or.displayName=le.Content.displayName;const ir=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));ir.displayName="Command";const lr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Aa("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",t),...a})}));lr.displayName="CommandInput";const cr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));cr.displayName="CommandList";const dr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("py-6 text-center text-sm text-muted-foreground",t),...a}));dr.displayName="CommandEmpty";const ur=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("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",t),...a}));ur.displayName="CommandGroup";const mr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("-mx-1 h-px bg-border",t),...a}));mr.displayName="CommandSeparator";const pr=J.forwardRef(({className:t,disabled:a,onSelect:s,value:r,...n},o)=>e.jsx("div",{ref:o,className:Aa("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",t),"data-disabled":a,onClick:()=>!a&&s?.(r||""),...n}));pr.displayName="CommandItem";const hr=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function fr({className:t,...a}){return e.jsx("div",{className:Aa("animate-pulse rounded-md bg-muted",t),...a})}hr.displayName="CommandShortcut";const xr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function gr({multiple:a,options:s,value:r,onChange:n,getOptionValue:o,getOptionLabel:i,placeholder:c,label:d,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:f,className:x,sortOptions:g,maxDisplayedBadges:b,popoverContainer:v,onOpen:w,onClose:N}){const[y,j]=t.useState(!1),[C,k]=t.useState(""),S=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),_=t.useMemo(()=>{if(!v)return;let e=v,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[v]),A=t.useMemo(()=>{const e=s.map(e=>({original:e,value:o(e),label:i(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,o,i,g]),T=t.useMemo(()=>{if(!C)return A;const e=xr(C);return A.filter(t=>xr(t.label).includes(e))},[A,C]),E=t.useMemo(()=>A.filter(e=>S.includes(e.value)),[A,S]),P=e=>{j(e),e?w?.():(k(""),N?.())},M=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?S.filter(t=>t!==e):"")},I=b?E.slice(0,b):E,D=b&&E.length>b?E.length-b:0;return e.jsxs("div",{className:Aa("space-y-2",x),children:[d&&e.jsxs(Ra,{children:[d,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:y,onOpenChange:P,modal:!1,children:[e.jsx(nr,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":y,"aria-disabled":h,tabIndex:h?-1:0,onKeyDown:e=>{h||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),P(!y))},className:Aa("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",h&&"pointer-events-none opacity-50 cursor-not-allowed",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"}),c]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[I.map(t=>e.jsxs(Ds,{variant:"secondary",className:"gap-1 pr-1",children:[t.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(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),D>0&&e.jsxs(Ds,{variant:"outline",className:"gap-1",children:["+",D]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pa,{variant:"outline",role:"combobox","aria-expanded":y,disabled:h,className:Aa("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"}),c]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:_,collisionBoundary:_,children:e.jsxs(ir,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(lr,{placeholder:p,value:C,onChange:e=>k(e.target.value)}),C&&e.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>k(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(cr,{children:0===s.length?e.jsx(dr,{children:m}):0===T.length?e.jsx(dr,{children:"Nenhum resultado encontrado"}):e.jsx(ur,{children:T.map(t=>e.jsxs(pr,{value:t.value,onSelect:()=>(e=>{if(n)if(a){const t=S.includes(e)?S.filter(t=>t!==e):[...S,e];n(t)}else n(e),j(!1)})(t.value),className:"cursor-pointer",children:[e.jsx(l.Check,{className:Aa("mr-2 h-4 w-4",S.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function br({multiple:t=!1,options:a,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:c=e=>e.label,placeholder:d,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:f=!1,required:x=!1,isLoading:g=!1,error:b,className:w,sortOptions:N=!0,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k}){const{t:S}=v.useTranslation(),_=a||s||[],A=o||n,T=d||S("select_placeholder","Selecione..."),E=p||S("no_results","Nenhum resultado encontrado"),P=h||S("search_placeholder","Pesquisar...");if(g)return e.jsxs("div",{className:Aa("space-y-2",w),children:[u&&e.jsxs(Ra,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const M="string"==typeof b?b:b instanceof Error?b.message:b?S("error_loading","Erro ao carregar"):void 0;return M?e.jsxs("div",{className:Aa("space-y-2",w),children:[u&&e.jsxs(Ra,{children:[u,x&&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(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:M})]})]}):e.jsx(gr,{multiple:t,options:_,value:r||(t?[]:""),onChange:A,getOptionValue:i,getOptionLabel:c,placeholder:T,label:u,icon:m,emptyMessage:E,searchPlaceholder:P,disabled:f,required:x,className:w,sortOptions:N,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k})}const vr=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ce.Root,{ref:r,className:Aa("relative overflow-hidden",t),...s,children:[e.jsx(ce.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(wr,{}),e.jsx(ce.Corner,{})]}));vr.displayName=ce.Root.displayName;const wr=J.forwardRef(({className:t,orientation:a="vertical",...s},r)=>e.jsx(ce.ScrollAreaScrollbar,{ref:r,orientation:a,className:Aa("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...s,children:e.jsx(ce.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));wr.displayName=ce.ScrollAreaScrollbar.displayName;const Nr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function yr(e,t){if(!t)return null;const a=Nr(t),s=[];for(const r of e){const e=Nr(r.label).includes(a),n=r.children?yr(r.children,t):null,o=n&&n.length>0;(e||o)&&s.push({...r,children:e?r.children:o?n:r.children})}return s}function jr(e,t){for(const a of e){if(a.value===t)return a.label;if(a.children){const e=jr(a.children,t);if(e)return e}}}function Cr({node:t,level:a,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=t.children&&t.children.length>0,c=n.includes(t.value);return e.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":c,className:Aa("flex items-center gap-1 rounded-sm px-2 py-1.5 text-sm cursor-pointer","hover:bg-accent hover:text-accent-foreground","outline-none"),style:{paddingLeft:8+20*a+"px"},children:[i?e.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted",onClick:e=>{e.stopPropagation(),r(t.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?e.jsx(l.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})}):e.jsx("span",{className:"w-5 shrink-0"}),e.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:e=>{e.stopPropagation(),o(t.value)},children:[e.jsx(l.Check,{className:Aa("h-4 w-4 shrink-0",c?"opacity-100":"opacity-0")}),(()=>{const a=c?t.iconSelected??(s?t.iconOpen:null)??t.icon:s?t.iconOpen??t.icon:t.icon;return a?e.jsx(a,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):null})(),e.jsx("span",{className:"truncate",children:t.label})]})]})}function kr({nodes:a,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return e.jsx(e.Fragment,{children:a.map(a=>{const l=r.has(a.value);return e.jsxs(t.Fragment,{children:[e.jsx(Cr,{node:a,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&a.children&&a.children.length>0&&e.jsx(kr,{nodes:a.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},a.value)})})}class Sr{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}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),t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);const s=new TextDecoder("utf-8").decode(a);return JSON.parse(s)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,t){const a=[],s=[];try{t.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(t),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:a,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(r.exp&&r.exp<i){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}}Sr.LARGE_PAYLOAD_THRESHOLD=1e3;const _r="qualiex_access_token",Ar="qualiex_id_token",Tr="supabase_token",Er="oauth_state",Pr="oauth_nonce",Mr="selected_alias",Ir="manual_logout",Dr={setAccessToken:e=>localStorage.setItem(_r,e),getAccessToken:()=>localStorage.getItem(_r),setIdToken:e=>localStorage.setItem(Ar,e),getIdToken:()=>localStorage.getItem(Ar),getSupabaseToken:()=>localStorage.getItem(Tr),setOAuthState:e=>sessionStorage.setItem(Er,e),getOAuthState:()=>sessionStorage.getItem(Er),clearOAuthState:()=>sessionStorage.removeItem(Er),setOAuthNonce:e=>sessionStorage.setItem(Pr,e),getOAuthNonce:()=>sessionStorage.getItem(Pr),clearOAuthNonce:()=>sessionStorage.removeItem(Pr),setSelectedAlias:e=>localStorage.setItem(Mr,e),getSelectedAlias:()=>localStorage.getItem(Mr),clearSelectedAlias:()=>localStorage.removeItem(Mr),generateOAuthState:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Dr.getAccessToken()||!Dr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Tr,e),Dr._clearValidationCache()},areAllTokensValid:()=>{const e=Dr.getAccessToken(),t=Dr.getIdToken();if(!e||!t)return!1;try{const a=Sr.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Dr.getAccessToken(),a=Dr.getIdToken(),s=Dr.getSupabaseToken();return t&&Dr.isTokenExpired(t)&&(localStorage.removeItem(_r),e=!0),a&&Dr.isTokenExpired(a)&&(localStorage.removeItem(Ar),e=!0),s&&Dr.isTokenExpired(s)&&(localStorage.removeItem(Tr),e=!0),e},clearAll:()=>{localStorage.removeItem(_r),localStorage.removeItem(Ar),localStorage.removeItem(Tr),localStorage.removeItem(Mr),localStorage.removeItem(Ir),sessionStorage.removeItem(Er),sessionStorage.removeItem(Pr),Dr._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Ir,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ir),clearManualLogout:()=>localStorage.removeItem(Ir),isTokenExpired:e=>{try{return Sr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Dr._validationCache.isValid=!1,Dr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Dr.getSupabaseToken();if(!e)return!1;if(Dr.isTokenExpired(e))return Dr._clearValidationCache(),Dr._handleExpiredToken(),!1;const t=Date.now();return t-Dr._validationCache.timestamp<Dr._validationCache.cacheValidityMs?Dr._validationCache.isValid:(Dr._validationCache.isValid=!0,Dr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Dr.isSupabaseTokenValid()?Dr.getSupabaseToken():null,_handleExpiredToken:()=>{Dr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Dr.isSupabaseTokenValid())return null;const e=Dr.getSupabaseToken();if(!e)return null;try{const t=Sr.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,s=t.place_id||null,r=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:s,placeName:r,payload:t}}catch(t){return Dr._handleExpiredToken(),null}},getCompanyId:e=>{const t=Dr.getAccessToken();if(t)try{const a=Sr.parseJwtPayload(t);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 t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}const a=Dr.extractTokenData();if(a?.companyId)return a.companyId;const s=Dr.getIdToken();if(s)try{const t=Sr.parseJwtPayload(s);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 t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}return null},getCompanyIdInt:e=>{const t=[Dr.getAccessToken(),Dr.getIdToken()];for(const a of t)if(a)try{const t=Sr.parseJwtPayload(a);if(!t)continue;for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>1&&t[0]===e)return t[1];if(!e&&t.length>1)return t[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=Dr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Dr.getIdToken();if(!e)return[];try{const t=Sr.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};const Rr=new class{constructor(){this.errors=[],this.toastCount=0,this.lastToastTime=0}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),t&&this.shouldShowToast()){const e=this.getErrorTitle(a);i.toast.error(e,{description:a})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){i.toast.success(e,{description:t})}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=[]}},Lr=(void 0).VITE_SUPABASE_URL,zr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class Fr{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:zr};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return N.createClient(Lr,zr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("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,t)}})}static getInstance(){return Fr.instance||(Fr.instance=new Fr),Fr.instance}getClient(){const e=Dr.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Sr.isTokenExpired(e)}catch(t){return Rr.handleError(t instanceof Error?t:"Supabase - Error validating token",!1),!1}}}function Ur(){return Fr.getInstance().getClient()}class qr{static async generateToken(e,t,a,s=!1){try{if(!s){const e=Dr.getSupabaseToken();if(e&&Dr.isSupabaseTokenValid())return e}const r=Ur(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token?(Dr.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&a?.(),null}}}class Or{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(e=!1){if(this.regenerationPromise)return this.regenerationPromise;this.regenerationPromise=this._doRegenerate(e);try{return await this.regenerationPromise}finally{this.regenerationPromise=null}}static async _doRegenerate(e=!1){try{const t=Dr.getAccessToken(),a=Dr.getSelectedAlias();if(!t||!a)return null;const s=await qr.generateToken(t,a,this.onLogoutCallback||void 0,e);return s||null}catch(t){return null}}}Or.regenerationPromise=null,Or.onLogoutCallback=null;class Br{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Dr.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}class $r{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await Or.attemptRegeneration()?(this.isRetrying=!1,!0):(Br.handleError(e),this.isRetrying=!1,!1)}catch(s){return Br.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Dr.getAccessToken();return e?Dr.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."}}}$r.isRetrying=!1;const Hr="ccjfvpnndclajkleyqkc",Vr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},Wr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"cdf6c125-ec32-43d1-846b-bb8f90125b90"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Gr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const t=(void 0).VITE_SUPABASE_URL;t&&(e=new URL(t).hostname.split(".")[0])}catch{}return e===Hr?Vr:Wr}function Yr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const t=(void 0).VITE_SUPABASE_URL;t&&(e=new URL(t).hostname.split(".")[0])}catch{}return e!==Hr}const Qr={get oauth(){const e=Gr();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Kr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Xr={debounceDelay:500},Zr=()=>{const e=window.location.origin,t=(()=>{try{return window.self!==window.top}catch{return!0}})();return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("lovable.dev")||e.includes("lovable.app")&&t||(void 0).DEV},Jr=()=>Gr().qualiexApiUrl,en={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},tn={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},an={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}`}};const sn=new class{get baseUrl(){return Jr()}async makeApiCall(e,t,a){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Dr.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status} ${o.statusText}`);throw e.status=o.status,e.statusCode=o.status,e}return await o.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}}parseUsersResponse(e,t=""){let a=e;if(e.data)a=e.data;else{if(!Array.isArray(e))return Rr.handleError(`[QualiexApi] Formato de resposta inesperado${t}`,!1),null;a=e}return Array.isArray(a)?a.map(this.mapToQualiexUser):(Rr.handleError(`[QualiexApi] Resposta não é um array${t}`,!1),null)}async fetchUsers(e,t){const a={companyId:t,search:"",filterStatus:"active"};try{const t=await this.makeApiCall("/api/common/v1/companiesusers",a,e);return this.parseUsersResponse(t)??[]}catch(s){if(await $r.handleApiError(s))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",a,e);return this.parseUsersResponse(t," após retry")??[]}catch(r){return Rr.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return Rr.handleError(s instanceof Error?s.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(s){return Rr.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),s=new Map;return a.forEach(e=>s.set(e.userId,e)),s}async getUsers(e){const t=Dr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async fetchSoftwares(e){try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(Rr.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(t){if(await $r.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(a){return Rr.handleError(a instanceof Error?a:"Erro ao buscar softwares após renovação de token",!0),[]}return Rr.handleError(t instanceof Error?t.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,t){try{const a=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},t),s=a?.data||a;return Array.isArray(s)?s.map(e=>({associationId:e.associationId||"",userId:e.userId||"",userName:e.userName||"",companyId:e.companyId||"",companyName:e.companyName||"",companyAlias:e.companyAlias||"",companyPhotoDate:e.companyPhotoDate,language:e.language,roleId:e.roleId||"",roleName:e.roleName||"",placeId:e.placeId,placeName:e.placeName,softwares:Array.isArray(e.softwares)?e.softwares:[],functionalities:Array.isArray(e.functionalities)?e.functionalities:[],isQualitfy:e.isQualitfy??!1,isMetroex:e.isMetroex??!1})):(Rr.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(a){if(await $r.handleApiError(a))try{const a=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},t),s=a?.data||a;return Array.isArray(s)?s.map(e=>({associationId:e.associationId||"",userId:e.userId||"",userName:e.userName||"",companyId:e.companyId||"",companyName:e.companyName||"",companyAlias:e.companyAlias||"",companyPhotoDate:e.companyPhotoDate,language:e.language,roleId:e.roleId||"",roleName:e.roleName||"",placeId:e.placeId,placeName:e.placeName,softwares:Array.isArray(e.softwares)?e.softwares:[],functionalities:Array.isArray(e.functionalities)?e.functionalities:[],isQualitfy:e.isQualitfy??!1,isMetroex:e.isMetroex??!1})):[]}catch(s){return Rr.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return Rr.handleError(a instanceof Error?a.message:"Erro ao buscar associações do usuário",!0),[]}}};function rn(e,t){const a=t||en.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function nn(e,t){const a=t||en.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function on(e,t){const a=t||en.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function ln(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||rn(e.idField),emailField:e.emailField||nn(e.idField),usernameField:e.usernameField||on(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:rn(e),emailField:nn(e),usernameField:on(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const cn=new Map;class dn{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,s=cn.get(a);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await sn.fetchUsers(e,t);return cn.set(a,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,t){const a=new Set;for(const s of e)for(const e of t){const t=s[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const s={...e};for(const r of t){const t=e[r.idField];if(!t)continue;const n=a.get(t);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||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,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!Dr.areAllTokensValid())return e;const a=Dr.extractTokenData();if(!a)return e;const{alias:s,companyId:r}=a;if(!s||!r)return e;const n=ln(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(s,r),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return Rr.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}}const un=["responsible_name"],mn=e=>un.includes(e);function pn(e,t,a){const s="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=s,d=()=>{if(!Dr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Ur().schema(i).from(r)},u=(e,t,a,s)=>{let r=d().select(o||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?r=r.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?r=r.not(e,"is",null):"is_null"===t.operator&&(r=r.is(e,null)):null!==t&&(r=r.eq(e,t)))}),r=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(r,e);const i=t.includes(".");return i||mn(t)||(r=r.order(t,{ascending:"asc"===a})),{query:r,isForeignKey:i}},m=async(e,t,a,r,n)=>{const o=ln(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(mn(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await p.getAll(e);if(!o?.data?.length)return o;const c=await dn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let d;d=i?c.sort((e,s)=>{const r=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,s)=>{const r=e[t]||"",n=s[t]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(c,t,a);const u=((e,t=1,a=25)=>{const s=(t-1)*a,r=s+a;return{data:e.slice(s,r),pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:e.length,itemsPerPage:a,hasNextPage:r<e.length,hasPreviousPage:t>1}}})(d,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalItems,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await dn.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})},p={async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:d}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,d),h=((e,t,a)=>{const s=(t-1)*a,r=s+a-1;return e.range(s,r)})(p,o,i),{data:f,error:x,count:g}=await h;if(x)throw new Error(`Error fetching ${r}: ${x.message}`);let b=((e,t,a,s)=>{const r=Math.ceil((t||0)/s);return{data:e,currentPage:a,totalPages:r,totalItems:t||0,itemsPerPage:s,hasNextPage:a<r,hasPreviousPage:a>1}})(f||[],g,o,i);if((e=>{if(!c||!l||0===e.length)return!1;const t=ln(s.userIdFields,s.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await d().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${r}: ${a.message}`);return t},async create(e){const t=Ta(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:s,error:n}=await d().insert(a).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,t){const a={...Ta(t),updated_at:(new Date).toISOString()},{data:s,error:n}=await d().update(a).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 t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await d().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${r}: ${a.message}`)}};return p}var hn;const fn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class xn{static async initialize(){try{if(!Dr.hasAllTokens()||!Dr.areAllTokensValid())return Dr.clearExpiredTokens(),{...fn};const e=Dr.getAccessToken(),t=Dr.getIdToken();Dr.clearManualLogout();const a=this.extractUserFromIdToken(t),s=this.extractCompaniesFromIdToken(t),r=this.extractAliasFromAccessToken(e),n=Dr.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=Dr.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);i=t?e:r||s[0]?.alias||null}if(!Dr.isSupabaseTokenValid()&&i&&await Or.attemptRegeneration(),!Dr.isSupabaseTokenValid())return{...fn};let l=null;if(i){const e=Dr.getCompanyId(i),t=s.find(e=>e.alias===i);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}const c=n?.placeId??null,d=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:a,alias:i,companies:s,selectedUnit:l,userId:a?.id||null,userAlias:a?.id||null,placeId:c,placeName:d,activePlaceId:c,activePlaceName:d}}catch(e){return{...fn}}}static async loginDev(){try{const e=Ur(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Dr.generateOAuthState();Dr.setOAuthState(e);const t=Dr.generateOAuthNonce();Dr.setOAuthNonce(t);const a=`${window.location.origin}/callback`,s=new URL(Qr.oauth.authUrl);s.searchParams.set("client_id",Qr.oauth.clientId),s.searchParams.set("response_type",Qr.oauth.responseType),s.searchParams.set("scope",Qr.oauth.scope),s.searchParams.set("redirect_uri",a),s.searchParams.set("state",e),s.searchParams.set("nonce",t),s.searchParams.set("response_mode","fragment"),window.location.href=s.toString()}static async processCallback(){try{const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),s=a("access_token"),r=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(s&&r){const e=Dr.getAccessToken();e!==s&&Dr.clearAll()}if(Dr.hasAllTokens()){return Dr.getValidSupabaseToken()||await Or.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");Dr.setAccessToken(o),Dr.setIdToken(i),Dr.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)Dr.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Dr.setSelectedAlias(e[0].alias)}if(!await Or.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return Dr.clearOAuthState(),Dr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Dr.setManualLogout(),Dr.clearAll(),localStorage.removeItem("auth_return_url"),window.location.href="/login"}static decodeToken(e){return Sr.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const s=t[e].split(";");if(s.length>=4)a.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=t[e].split("|");s&&r&&a.push({id:"",alias:s.trim(),name:r.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}}hn=xn,Or.setLogoutCallback(()=>{hn.logout()});const gn=e=>e?.placeId||null,bn=e=>e?.placeName||null,vn=t.createContext(void 0),wn=({children:a})=>{const[s,r]=t.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=y.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useCallback(e=>{r(t=>({...t,...e}))},[]),c=t.useCallback(e=>{r(t=>({...t,isLoading:e}))},[]),d=t.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})},[]),u=t.useCallback(async e=>{try{c(!0);const a=Dr.getAccessToken();if(!a)return;const r=await qr.generateToken(a,e.alias,void 0,!0);if(!r)return;Dr.setSupabaseToken(r),Dr.setSelectedAlias(e.alias);const o=Dr.extractTokenData(),i=o?.alias||e.alias,d=o?.companyId||Dr.getCompanyId(e.alias),u={id:d||e.id,name:e.name,alias:i};let m=null,p=null;if(s.user?.id&&i&&d)try{const e=(await sn.fetchActiveUsersMap(i,d)).get(s.user.id);if(e){const t=(e=>({placeId:gn(e),placeName:bn(e)}))(e);m=t.placeId,p=t.placeName}}catch(t){}l({alias:i,selectedUnit:u,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{c(!1)}},[l,n,c,s.user]),m=t.useCallback(async()=>{const e=await xn.processCallback();if(e){const e=await xn.initialize();e&&e.isAuthenticated&&(l({user:e.user,companies:e.companies,alias:e.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:e.selectedUnit,userId:e.userId,userAlias:e.userAlias,placeId:e.placeId,placeName:e.placeName,activePlaceId:e.activePlaceId,activePlaceName:e.activePlaceName}),n&&n.invalidateQueries({queryKey:["permission"]}))}return e},[l,n]),p=t.useCallback(async()=>{xn.logout(),d(),n&&await n.clear()},[d,n]),h=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),x=t.useCallback(()=>{},[]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(Dr.areAllTokensValid()||e&&p())},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,p]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await xn.initialize();if(!e)return;t&&t.isAuthenticated?l({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&c(!1)}catch(t){e&&(Br.handleError(t),c(!1))}})(),()=>{e=!1}},[l,c,p]);const g=t.useMemo(()=>({...s,logout:p,processCallback:m,switchUnit:u,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:h,clearSearch:f,refreshData:x}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,p,m,u,o,h,f,x]);return e.jsx(vn.Provider,{value:g,children:a})},Nn=()=>{const e=t.useContext(vn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function yn({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[l,c]=j.useSearchParams(),d=y.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Nn(),{t:h}=v.useTranslation(),f=t.useCallback(t=>{const a=`${e}_${t}`,s=l.get(a);return s||(l.get(t)||"")},[l,e]),x=f("search"),g=f("sortField")||Kr.sorting.defaultField,b=f("sortDirection")||Kr.sorting.defaultDirection,w=parseInt(f("page")||"1"),N=parseInt(f("limit")||String(Kr.pagination.defaultPageSize)),C=x,k=t.useMemo(()=>({search:C,sortField:g,sortDirection:b,page:w,limit:N,...n}),[C,g,b,w,N,n]),S=t.useCallback(()=>a.getAll(k),[a,k]),_=y.useQuery({queryKey:[e,u,m,k],queryFn:S,enabled:!!u&&p});if(!_)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const A=y.useMutation({mutationFn:a.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.created(s)),o?.()},onError:e=>{i.toast.error(`${an.error.create(s)}: ${e.message}`)}}),T=y.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.updated(s)),o?.()},onError:e=>{i.toast.error(`${an.error.update(s)}: ${e.message}`)}}),E=y.useMutation({mutationFn:a.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.deleted(s))},onError:e=>{i.toast.error(`${an.error.delete(s)}: ${e.message}`)}}),P=t.useCallback(t=>{const a={...Object.fromEntries(l)};Object.entries(t).forEach(([t,s])=>{const r=`${e}_${t}`;""===s||0===s?delete a[r]:a[r]=String(s)}),delete a.sortField,delete a.sortDirection,c(a)},[l,c,e]),M=t.useCallback(e=>{P({search:e,page:1})},[P]),I=t.useCallback(e=>{P({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,P]),D=t.useCallback(e=>{P({page:e})},[P]),R=t.useCallback(e=>{P({limit:e,page:1})},[P]),L=t.useCallback(()=>{const t=Object.fromEntries(l),a=`${e}_`,s=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));c(s)},[c,l,e]),[z,F]=t.useState([]),U=t.useCallback(e=>{F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),q=t.useCallback(()=>{const e=_?.data?.data.map(e=>e.id)||[];F(t=>t.length===e.length?[]:e)},[_?.data?.data]),O=t.useCallback(()=>{F([])},[]),B=t.useMemo(()=>{const e=_?.data?.data.map(e=>e.id)||[];return e.length>0&&z.length===e.length},[z,_?.data?.data]),$=y.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(t,a)=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(h("bulk_delete_success",`${a.length} ${s}(s) deletado(s) com sucesso`)),O()},onError:e=>{i.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),H=t.useCallback((e,t)=>{const a=t?t(e):e;e.id?T.mutate({id:e.id,data:a}):A.mutate({...a,alias:u})},[u,A,T]);return{entities:_?.data?.data||[],pagination:{data:_?.data?.data||[],currentPage:_?.data?.currentPage||1,totalPages:_?.data?.totalPages||1,totalItems:_?.data?.totalItems||0,itemsPerPage:_?.data?.itemsPerPage||Kr.pagination.defaultPageSize,hasNextPage:_?.data?.hasNextPage||!1,hasPreviousPage:_?.data?.hasPreviousPage||!1},isLoading:_?.isLoading??!0,isCreating:A?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:E?.isPending??!1,error:_?.error||null,searchTerm:x,sortField:g,sortDirection:b,currentPage:w,itemsPerPage:N,queryKey:e,createEntity:A.mutate,updateEntity:(e,t)=>T.mutate({id:e,data:t}),deleteEntity:E.mutate,save:H,handleSearch:M,handleSort:I,handlePageChange:D,handleItemsPerPageChange:R,clearFilters:L,refetch:_.refetch,selectedIds:z,selectItem:U,selectAll:q,clearSelection:O,isAllSelected:B,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}function jn(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.useEffect(()=>{const t=window.matchMedia(e);s(t.matches);const a=e=>{s(e.matches)};return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),a}function Cn(e=768){return jn(`(max-width: ${e-1}px)`)}const kn=J.forwardRef(({className:t,...a},s)=>e.jsx("table",{ref:s,className:Aa("w-full caption-bottom text-sm table-fixed",t),...a}));kn.displayName="Table";const Sn=J.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:Aa("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));Sn.displayName="TableHeader";const _n=J.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:Aa("[&_tr:last-child]:border-0",t),...a}));_n.displayName="TableBody";const An=J.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:Aa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));An.displayName="TableFooter";const Tn=J.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:Aa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",t),...a}));Tn.displayName="TableRow";const En=J.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:Aa("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));En.displayName="TableHead";const Pn=J.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:Aa("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",t),...a}));Pn.displayName="TableCell";const Mn=J.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:Aa("mt-4 text-sm text-muted-foreground",t),...a}));function In({rows:t=5,columns:a=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:a}).map((t,a)=>e.jsx(fr,{className:"h-4 w-24"},a))})}),e.jsx("div",{children:Array.from({length:t}).map((t,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:a}).map((t,a)=>e.jsx(fr,{className:"h-4 w-20"},a))})},s))})]})})}function Dn({count:t=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:t}).map((t,a)=>e.jsxs(La,{children:[e.jsxs(za,{children:[e.jsx(fr,{className:"h-4 w-3/4"}),e.jsx(fr,{className:"h-3 w-1/2"})]}),e.jsx(qa,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-3 w-full"}),e.jsx(fr,{className:"h-3 w-2/3"})]})})]},a))})}Mn.displayName="TableCaption";const Rn={default:l.FileX,search:l.Search,error:l.AlertCircle};function Ln({icon:t,title:a,description:s,action:r,className:n,variant:o="default"}){const i=!!t,l=Rn[o];return e.jsxs("div",{className:Aa("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:i?t:e.jsx(l,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(Pa,{onClick:r.onClick,variant:"outline",children:r.label})]})}function zn({children:t,className:a}){const s=J.useRef(null),[r,n]=J.useState(!1);J.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return s.current&&t.observe(s.current),()=>t.disconnect()},[t]);const o=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${a||""}`,children:t});return r?e.jsx(Js,{delayDuration:300,children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:o}),e.jsx(ar,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):o}const Fn=J.forwardRef(({direction:t,onMouseDown:a,isDragging:s,className:r},n)=>{const o="horizontal"===t;return e.jsx("div",{ref:n,onMouseDown:a,className:Aa("absolute z-20 select-none touch-none","transition-colors duration-150",o&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!o&&["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:Aa("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Fn.displayName="TableResizeHandle";const Un=de.Root,qn=de.Trigger,On=de.Group,Bn=de.Portal,$n=de.Sub,Hn=de.RadioGroup,Vn=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(de.SubTrigger,{ref:n,className:Aa("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",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Vn.displayName=de.SubTrigger.displayName;const Wn=J.forwardRef(({className:t,...a},s)=>e.jsx(de.SubContent,{ref:s,className:Aa("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",t),...a}));Wn.displayName=de.SubContent.displayName;const Gn=J.forwardRef(({className:t,...a},s)=>e.jsx(de.Portal,{children:e.jsx(de.Content,{ref:s,className:Aa("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",t),...a})}));Gn.displayName=de.Content.displayName;const Yn=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(de.Item,{ref:r,className:Aa("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",a&&"pl-8",t),...s}));Yn.displayName=de.Item.displayName;const Qn=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(de.CheckboxItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...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(l.Check,{className:"h-4 w-4"})})}),a]}));Qn.displayName=de.CheckboxItem.displayName;const Kn=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(de.RadioItem,{ref:r,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.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(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Kn.displayName=de.RadioItem.displayName;const Xn=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(de.Label,{ref:r,className:Aa("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...s}));Xn.displayName=de.Label.displayName;const Zn=J.forwardRef(({className:t,...a},s)=>e.jsx(de.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-border",t),...a}));Zn.displayName=de.Separator.displayName;const Jn=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Jn.displayName="ContextMenuShortcut";const eo=({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const c=[];if(t){const e={icon:l.Edit,label:"Editar",onClick:t};c.push(e)}if(o.forEach(e=>{c.push(e)}),s){const e={icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:s};c.push(e)}if(n&&a){const e={icon:l.Trash2,label:"Excluir",onClick:a,destructive:!0};c.push(e)}const d="dropdown"===i?Gs:Yn;return e.jsx(e.Fragment,{children:c.map((t,a)=>e.jsxs(d,{onClick:t.onClick,className:Aa("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},a))})},to=({onEdit:t,onDelete:a,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(l.EllipsisVertical,{size:12})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(eo,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!a,customActions:o,renderAs:"dropdown"})})]}),ao=150;function so({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{})}),[i,l]=t.useState(!1),[c,d]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,t)=>{r&&(t.preventDefault(),t.stopPropagation(),l(!0),d(e),u.current=t.clientX,m.current=n[e]??ao)},[r,n]);t.useEffect(()=>{if(!i||!c)return;const t=e.find(e=>e.key===c),r=t?.minWidth??60,n=t?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(r,Math.min(n,m.current+t));o(e=>{const t={...e,[c]:a};return s?.(t),t})},h=()=>{l(!1),d(null),a&&o(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,c,e,a,s]),t.useEffect(()=>(i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[i]);const h=t.useCallback(()=>{const t=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:c,handleMouseDown:p,resetWidths:h}}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"}}),no=J.forwardRef(({className:t,variant:a,size:s,...r},n)=>e.jsx(me.Root,{ref:n,className:Aa(ro({variant:a,size:s,className:t})),...r}));no.displayName=me.Root.displayName;const oo=J.createContext({size:"default",variant:"default"}),io=J.forwardRef(({className:t,variant:a,size:s,children:r,...n},o)=>e.jsx(ue.Root,{ref:o,className:Aa("flex items-center justify-center gap-1",t),...n,children:e.jsx(oo.Provider,{value:{variant:a,size:s},children:r})}));io.displayName=ue.Root.displayName;const lo=J.forwardRef(({className:t,children:a,variant:s,size:r,...n},o)=>{const i=J.useContext(oo);return e.jsx(ue.Item,{ref:o,className:Aa(ro({variant:i.variant||s,size:i.size||r}),t),...n,children:a})});lo.displayName=ue.Item.displayName;const co=t.memo(function({onNew:t,newButtonLabel:a,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:c=!1,selectedCount:d=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:f,viewMode:x,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],className:w}){const N=t&&s||c||h.length>0,y=f||b,j=r&&o;return N||j||y?e.jsxs("div",{className:Aa("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t&&s&&e.jsxs(Pa,{onClick:t,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),a||"Novo"]}),c&&e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",children:["Ações em lote",d>0&&e.jsx(Ds,{variant:"secondary",className:"ml-2",children:d}),e.jsx(l.ChevronDown,{size:16,className:"ml-2"})]})}),e.jsxs(Ws,{align:"start",children:[u.length>0?u.map((t,a)=>{const s=t.icon,r=0===d||t.disabled;return e.jsxs(Gs,{onClick:()=>!r&&t.action([]),disabled:r,className:"destructive"===t.variant?"text-destructive":void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)}):e.jsxs(Gs,{onClick:m,disabled:0===d,className:"text-destructive",children:[e.jsx(l.Trash2,{size:16,className:"mr-2"}),"Excluir"]}),d>0&&e.jsxs(e.Fragment,{children:[e.jsx(Xs,{}),e.jsxs(Gs,{onClick:p,children:[e.jsx(l.X,{size:16,className:"mr-2"}),"Limpar seleção"]})]})]})]}),h.map((t,a)=>{const s=t.icon;return e.jsxs(Pa,{onClick:t.action,variant:t.variant||"outline",disabled:t.disabled,title:t.disabled?t.disabledReason:void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]}),j&&e.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),y&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[f,b&&x&&g&&e.jsx(io,{type:"single",value:x,onValueChange:e=>e&&g(e),size:"sm",children:v.map(t=>{const a=(e=>{switch(e){case"table":return l.Table2;case"list":return l.List;case"grid":return l.LayoutGrid}})(t);return e.jsx(lo,{value:t,"aria-label":"Visualizar como "+("table"===t?"tabela":"list"===t?"lista":"grade"),children:e.jsx(a,{className:"h-4 w-4"})},t)})})]})]}):null}),uo=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(Ps,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),mo=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:c,customRowActions:d,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:f=[],hideActionBar:x,showActionBar:g=!0,showSearch:b=!1,searchValue:v,onSearchChange:w,searchPlaceholder:N,bulkActions:y=[],onBulkDelete:j,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_=!1,enableColumnResize:A=!0,resizeStorageKey:T})=>{const{setSearchVisible:E}=Nn(),P=Cn(),M=void 0!==x?!x:g;t.useEffect(()=>{if(!b)return E(!0),()=>E(!1)},[E,b]);const{columnWidths:I,isDragging:D,activeColumn:R,handleMouseDown:L}=so({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:T?`${T}-columns`:void 0,enabled:A}),z=t.useMemo(()=>(()=>{if(A)return s.map(e=>{const t=I[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:t,style:{width:`${t}px`}}});let e=0;const t=s.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,s=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:s,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,A,I]),F=m||f.length>0||b||u||C||_,U=M&&F,q=j||(()=>{a.bulkDelete?.(a.selectedIds)});return P?a.isLoading?e.jsx(Dn,{count:3}):0===a.entities.length?e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[U&&e.jsx(co,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:q,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(t=>e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:e.jsx(La,{className:Aa("overflow-hidden cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:e.jsx(qa,{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(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(a=>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:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||c)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(t):e.jsx(to,{onEdit:r?()=>{r(t)}:void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})]})})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[U&&e.jsx(co,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:q,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_}),a.isLoading?e.jsx(In,{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(kn,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),z.map((t,a)=>e.jsx("col",{style:t.style},a)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Sn,{children:e.jsxs(Tn,{children:[u&&e.jsx(En,{className:"w-[50px]",children:e.jsx(uo,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),s.map(t=>{const s=A&&!1!==t.resizable,r=R===String(t.key);return e.jsxs(En,{className:Aa(t.className,t.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:t.sortable?()=>a.handleSort(String(t.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),a.sortField!==n?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>L(String(t.key),e),isDragging:r})]},String(t.key));var n}),e.jsx(En,{className:"w-[50px] text-center",children:"Ações"})]})}),e.jsx(_n,{children:0===a.entities.length?e.jsx(Tn,{children:e.jsx(Pn,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):a.entities.map(t=>e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:e.jsxs(Tn,{className:Aa("cursor-pointer hover:bg-muted/50 relative",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:[u&&e.jsx(Pn,{onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),s.map(a=>e.jsx(Pn,{className:a.className,children:e.jsx(zn,{children:a.render?a.render(t):String(t[a.key]??"")})},String(a.key))),e.jsx(Pn,{className:"text-center",children:c?c(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id))})]})})})]})};function po(e,a,s,r){const[n,o]=t.useState({}),[i,l]=t.useState({}),c=t.useMemo(()=>e,[e]),d=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,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.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(t,a);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(c),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);d(e)&&(t=e.toISOString().split("T")[0])}else d(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[c,a,s,r]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},f=()=>{const e=h(c),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const r={...a,[e]:t},n=((e,t)=>{let a={...t};const s=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...s(e.fields))}),t};return s(c).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,r);return s&&s(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(c).find(t=>t.name===e);if(a){const s=p(a,t,n);s&&l(t=>({...t,[e]:s}))}},validateForm:f,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),f()&&e(n)}}}const ho=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],fo=({value:t="#3b82f6",onChange:a,label:s,customColorLabel:r="Cor personalizada",presetColorsLabel:n="Cores predefinidas"})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Ra,{children:s}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{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:t}}),t]})}),e.jsx(or,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Ra,{htmlFor:"color-input",children:r}),e.jsx(Ia,{id:"color-input",type:"color",value:t,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:n}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:ho.map(t=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>a?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),xo={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},go=({value:a="Star",onChange:s,label:r,searchLabel:n="Pesquisar"})=>{const[o,i]=t.useState(""),c=Object.entries(xo).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),d=xo[a]||l.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Ra,{children:r}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),a]})}),e.jsx(or,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Ra,{htmlFor:"icon-search",children:n}),e.jsx(Ia,{id:"icon-search",placeholder:n,value:o,onChange:e=>i(e.target.value)})]}),e.jsx(vr,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:c.map(([t,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(t),title:t,children:e.jsx(r,{className:"h-4 w-4"})},t))})})]})})]})]})},bo=J.forwardRef(({className:t,...a},s)=>e.jsx(pe.Root,{className:Aa("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",t),...a,ref:s,children:e.jsx(pe.Thumb,{className:Aa("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")})}));bo.displayName=pe.Root.displayName;const vo=(e={})=>{const{user:t,alias:a}=Nn(),{enabled:s=!0}=e;return y.useQuery({queryKey:["qualiex-users",a],queryFn:()=>sn.getUsers(a),enabled:s&&!!a&&!!t,staleTime:3e5,retry:2,retryDelay:1e3})},wo=({value:a,onChange:s,multiple:r=!1,label:n,required:o,placeholder:i,icon:l,maxDisplayedBadges:c,className:d,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:f,sortOptions:x=!0,popoverContainer:g,onOpen:b,onClose:v})=>{const{data:w=[],isLoading:N,error:y}=vo({enabled:m}),j=t.useMemo(()=>f?w.filter(f):w,[w,f]),C=t.useCallback(e=>{if("custom"===p&&h)return h(e);const t=e.userName||"";switch(p){case"name-email":return e.userEmail?`${t} (${e.userEmail})`:t;case"name-role":return e.roleName?`${t} - ${e.roleName}`:t;default:return t}},[p,h]);return e.jsx(br,{multiple:r,value:a??(r?[]:""),onChange:s,options:j,isLoading:N,error:y,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:C,placeholder:i||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:"Nenhum resultado encontrado",label:n,required:o,icon:l,maxDisplayedBadges:c,disabled:u,className:d,sortOptions:x,popoverContainer:g,onOpen:b,onClose:v})};function No({title:a,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:c=!1,usersData:d}){const[u,m]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[h,f]=t.useState(null),x=t.useCallback(e=>{p.current=e,f(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:b,errors:v,updateField:w,handleSubmit:N}=po(g,r,void 0,i),y=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[s,b]),j=t.useMemo(()=>{const e=y.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=y.find(e=>!e.disabled);return t?.id||u},[y,u]);t.useEffect(()=>{j!==u&&m(j)},[j,u]);const C=y.find(e=>e.id===j),k=t=>{const a=(t.computedValue,b[t.name]),s=void 0!==a?a:"",r=v[t.name];switch(t.type){case"group":const a="horizontal"===t.layout,n=a?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=a?Aa("space-y-2 w-full",t.wrapperClassName):Aa("space-y-2",t.className,t.wrapperClassName);return e.jsxs("div",{className:o,children:[t.label,e.jsx("div",{className:n,children:t.fields?.map(e=>k(e))})]},t.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(wo,{value:s||"",onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ms,{id:t.name,value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ns,{value:String(s),onValueChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e.jsx(Cs,{className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(js,{placeholder:t.placeholder})}),e.jsx(_s,{children:t.options?.map(t=>e.jsx(Ts,{value:t.value,children:t.label},t.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(br,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"date":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"date",value:String(s),onChange:e=>w(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:Aa("w-full",r?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"color":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>w(t.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fo,{value:s||t.defaultValue||"#3b82f6",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(go,{value:s||t.defaultValue||"Star",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"custom":if(!t.component)return null;const i=t.component,l="function"==typeof t.componentProps?t.componentProps(b):t.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(i,{value:s,onChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:r,popoverContainer:h,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"number":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,s=""===a?null:Number(a);w(t.name,s)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e.jsx(Ps,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),e.jsxs(Ra,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(bo,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},t.name);default:return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"text",value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name)}},S=t.useCallback(()=>{if(!C)return null;if(C.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(C.component){const t=C.component;return e.jsx(t,{formData:b,updateField:w,errors:v,users:d,disabled:C.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:C.fields.map(k)})},[C,b,w,v,d,k]),_=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[y.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:y.map(t=>e.jsx(Pa,{variant:j===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=y.find(t=>t.id===e);t&&!t.disabled&&m(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):e.jsxs("form",{onSubmit:N(n),className:"space-y-3 md:space-y-4",children:[S(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Pa,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),e.jsx(Pa,{type:"submit",disabled:c,children:l||"Salvar"})]})]})})]});return e.jsx(es,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:e.jsxs(os,{ref:x,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(is,{showSeparator:!0,children:[e.jsx(ds,{children:a}),e.jsx(us,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),_]})})}function yo({currentPage:t,totalPages:a,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:c}=v.useTranslation();if(0===s)return null;const d=(t-1)*r+1,u=Math.min(t*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"===i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:c("rows_per_page","Linhas por página")}),e.jsxs(Ns,{value:String(r),onValueChange:e=>o(Number(e)),children:[e.jsx(Cs,{className:"h-8 w-[70px]",children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"10",children:"10"}),e.jsx(Ts,{value:"25",children:"25"}),e.jsx(Ts,{value:"50",children:"50"}),e.jsx(Ts,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[d,"-",u," ",c("of","de")," ",s," ",c("items","itens")]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsLeft,{size:16})}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(t-1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c("of","de")}),e.jsx("span",{className:"text-sm font-medium",children:a})]}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(t+1),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronRight,{size:16})}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsRight,{size:16})})]})]})}function jo({manager:t}){return e.jsx(yo,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const Co={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ko={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},So={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function _o({children:t,direction:a="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return e.jsx("div",{className:Aa("flex","column"===a?"flex-col":"flex-row",Co[s],ko[r],So[n],o&&"flex-wrap",i),children:t})}function Ao({manager:t,filters:a,inline:s=!1}){const{isSearchVisible:r}=Nn(),n=t.searchTerm,o=e.jsxs(e.Fragment,{children:[a.some(e=>"search"===e.type)&&!r&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ia,{placeholder:"Pesquisar",value:t.searchTerm,onChange:e=>t.handleSearch(e.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((t,a)=>e.jsxs(Ns,{value:t.value||"",onValueChange:e=>t.onChange?.(e),children:[e.jsx(Cs,{className:"w-[180px]",children:e.jsx(js,{placeholder:t.placeholder})}),e.jsx(_s,{children:t.options.map(t=>e.jsx(Ts,{value:t.value,children:t.label},t.value))})]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...t.props})},`custom-${a}`)}),n&&e.jsxs(Pa,{variant:"outline",onClick:t.clearFilters,className:"whitespace-nowrap",children:[e.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(_o,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(_o,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function To({manager:a,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){a&&a.queryKey;const{setSearchVisible:l}=Nn(),[c,d]=j.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[f,x]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,b]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!c.has(e)&&!c.has(t)){const a=Object.fromEntries(c);a[e]=i.column,a[t]=i.direction,d(a)}}},[]);const v=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,w="function"==typeof a?.deleteEntity?e=>{x({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,N=()=>{x({isOpen:!1,entityId:null,entityName:""})},y=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,C=(s.customActions||[]).map(e=>({label:e.label,icon:e.icon,action:e.action,variant:"destructive"===e.variant?"default":e.variant,disabled:e.disabled,disabledReason:e.disabledReason}));return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&e.jsx(co,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:y,showSearch:s.showSearch,searchValue:a.searchTerm,onSearchChange:a.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:a.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{b({isOpen:!0,count:a.selectedIds.length})},onClearSelection:a.clearSelection,customActions:C,filters:s.filters&&s.filters.length>0?e.jsx(Ao,{manager:a,filters:s.filters,inline:!0}):void 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(a.entities,a)}):e.jsx(mo,{manager:a,columns:s.columns,onEdit:v,onDelete:w,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(jo,{manager:a})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&e.jsx(No,{open:u,title:p?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:p||void 0,onSubmit:e=>{n(e),m(!1),h(null)},onCancel:()=>{m(!1),h(null)},isLoading:a.isLoading,submitButtonText:p?"Atualizar":"Criar"}),e.jsx(es,{open:f.isOpen,onOpenChange:N,children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(ds,{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:f.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(cs,{children:[e.jsx(Pa,{variant:"outline",onClick:N,children:"Cancelar"}),e.jsx(Pa,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof a?.deleteEntity&&(a.deleteEntity(f.entityId),x({isOpen:!1,entityId:null,entityName:""}))},disabled:a.isDeleting,children:a.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(es,{open:g.isOpen,onOpenChange:()=>b({isOpen:!1,count:0}),children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(ds,{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:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(cs,{children:[e.jsx(Pa,{variant:"outline",onClick:()=>b({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(Pa,{variant:"destructive",onClick:()=>{a.bulkDelete?.(a.selectedIds),b({isOpen:!1,count:0})},disabled:a.isBulkDeleting,children:a.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Eo(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Po(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Mo=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"}}),Io={info:l.Info,warning:l.Info,danger:l.AlertTriangle,success:l.CheckCircle},Do=J.forwardRef(({className:t,variant:a="info",showIcon:s=!0,children:r,...n},o)=>{const i=Io[a||"info"];return e.jsxs("div",{ref:o,role:"alert",className:Aa(Mo({variant:a}),t),...n,children:[s&&e.jsx(i,{className:"h-4 w-4"}),r]})});Do.displayName="Alert";const Ro=J.forwardRef(({className:t,...a},s)=>e.jsx("h5",{ref:s,className:Aa("mb-1 font-medium leading-none tracking-tight",t),...a}));Ro.displayName="AlertTitle";const Lo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("text-sm [&_p]:leading-relaxed",t),...a}));Lo.displayName="AlertDescription";const zo=t.createContext(void 0);function Fo({children:a,actions:s}){const[r,n]=t.useState({}),[o,i]=t.useState(s);t.useEffect(()=>{i(s)},[s]);const l=t.useCallback(()=>n({}),[]),c=t.useMemo(()=>({metadata:r,setMetadata:n,clearMetadata:l,headerActions:o,setHeaderActions:i}),[r,l,o]);return e.jsx(zo.Provider,{value:c,children:a})}function Uo(){const e=t.useContext(zo);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var qo={access_denied:{pt:"Acesso negado",en:"Access denied",es:""},actions:{pt:"Ações",en:"Actions",es:"Acciones"},activate:{pt:"Ativar",en:"Activate",es:"Activar"},activate_selected:{pt:"Ativar Selecionados",en:"Activate Selected",es:"Activar Seleccionados"},active:{pt:"Ativo",en:"Active",es:"Activo"},active_employees:{pt:"Colaboradores Ativos",en:"Active Employees",es:"Empleados Activos"},active_plural:{pt:"Ativos",en:"Active",es:"Activos"},add:{pt:"Adicionar",en:"Add",es:"Agregar"},additional_fields:{pt:"Campos Adicionais",en:"Additional Fields",es:"Campos Adicionales"},address:{pt:"Endereço",en:"Address",es:"Dirección"},admin:{pt:"Admin",en:"Admin",es:"Admin"},admin_access:{pt:"Acesso Admin",en:"Admin Access",es:"Acceso Admin"},admin_system:{pt:"Administração do Sistema",en:"System Administration",es:"Administración del Sistema"},admission_date:{pt:"Data de Admissão",en:"Admission Date",es:"Fecha de Admisión"},alignment:{pt:"Alinhamento",en:"Alignment",es:"Alineación"},all:{pt:"Todos",en:"All",es:"Todos"},allow_download:{pt:"Permitir Download",en:"Allow Download",es:"Permitir Descarga"},allowed_formats:{pt:"Formatos permitidos",en:"Allowed formats",es:"Formatos permitidos"},alt:{pt:"Texto Alternativo",en:"Alt Text",es:"Texto Alternativo"},api_response:{pt:"Resposta da API:",en:"API Response:",es:"Respuesta de la API:"},apply_filters:{pt:"Aplicar filtros",en:"Apply filters",es:"Aplicar filtros"},auth_required:{pt:"Autenticação necessária",en:"Authentication required",es:"Autenticación requerida"},autoplay:{pt:"Reprodução Automática",en:"Autoplay",es:"Reproducción Automática"},back:{pt:"Voltar",en:"Back",es:"Volver"},background_color:{pt:"Cor do Fundo",en:"Background Color",es:"Color de Fondo"},birth_date:{pt:"Data de Nascimento",en:"Birth Date",es:"Fecha de Nacimiento"},boolean:{pt:"Booleano",en:"Boolean",es:"Booleano"},bulk_actions:{pt:"Ações em lote",en:"Bulk actions",es:"Acciones masivas"},cancel:{pt:"Cancelar",en:"Cancel",es:"Cancelar"},cancelled:{pt:"Cancelado",en:"Cancelled",es:"Cancelado"},caption:{pt:"Legenda",en:"Caption",es:"Leyenda"},center:{pt:"Centro",en:"Center",es:"Centro"},chatbot:{pt:"Chatbot",en:"Chatbot",es:"Chatbot"},checking_access:{pt:"Verificando acesso...",en:"Checking access...",es:"Verificando acceso..."},choose_file:{pt:"Escolher arquivo",en:"Choose file",es:"Elegir archivo"},city:{pt:"Cidade",en:"City",es:"Ciudad"},clear:{pt:"Limpar",en:"Clear",es:"Limpiar"},clear_filters:{pt:"Limpar filtros",en:"Clear filters",es:"Limpiar filtros"},clear_search:{pt:"Limpar busca",en:"Clear search",es:"Limpiar búsqueda"},clear_selection:{pt:"Limpar seleção",en:"Clear selection",es:"Limpiar selección"},click_to_create_post:{pt:"Clique no botão abaixo para criar um novo post",en:"Click the button below to create a new post",es:"Haga clic en el botón de abajo para crear una nueva publicación"},close:{pt:"Fechar",en:"Close",es:"Cerrar"},collaborator:{pt:"Colaborador",en:"Collaborator",es:"Colaborador"},config:{pt:"Configuração",en:"Configuration",es:"Configuración"},config_info:{pt:"Informações da Configuração",en:"Configuration Info",es:"Información de Configuración"},config_info_description:{pt:"Defina a chave e o valor da configuração",en:"Set the configuration key and value",es:"Defina la clave y el valor de la configuración"},config_key:{pt:"Chave da Configuração",en:"Configuration Key",es:"Clave de Configuración"},configs:{pt:"Configurações",en:"Configurations",es:"Configuraciones"},comments:{pt:"Comentários",en:"Comments",es:"Comentarios"},community:{pt:"Comunidade",en:"Community",es:"Comunidad"},community_posts:{pt:"Posts da comunidade",en:"Community posts",es:"Publicaciones de la comunidad"},companies:{pt:"Empresas",en:"Companies",es:"Empresas"},company:{pt:"Empresa",en:"Company",es:"Empresa"},completed:{pt:"Concluído",en:"Completed",es:"Completado"},confirm:{pt:"Confirmar",en:"Confirm",es:"Confirmar"},confirm_delete:{pt:"Tem certeza que deseja excluir?",en:"Are you sure you want to delete?",es:"¿Está seguro de que desea eliminar?"},confirm_delete_message:{pt:"Esta ação não pode ser desfeita.",en:"This action cannot be undone.",es:"Esta acción no se puede deshacer."},confirm_password:{pt:"Confirmar Senha",en:"Confirm Password",es:"Confirmar Contraseña"},content:{pt:"Conteúdo",en:"Content",es:"Contenido"},content_blocks:{pt:"Blocos de Conteúdo",en:"Content Blocks",es:"Bloques de Contenido"},controls:{pt:"Controles",en:"Controls",es:"Controles"},copy:{pt:"Copiar",en:"Copy",es:"Copiar"},country:{pt:"País",en:"Country",es:"País"},courses:{pt:"Cursos",en:"Courses",es:"Cursos"},create:{pt:"Criar",en:"Create",es:"Crear"},create_first_post_hint:{pt:'Crie seu primeiro post na aba "Criar Post"',en:'Create your first post in the "Create Post" tab',es:'Crea tu primera publicación en la pestaña "Crear Publicación"'},create_post:{pt:"Criar Novo Post",en:"Create New Post",es:"Crear Nueva Publicación"},create_success:{pt:"Criado com sucesso",en:"Created successfully",es:"Creado exitosamente"},create_unit:{pt:"Criar Nova Unidade",en:"Create New Unit",es:"Crear Nueva Unidad"},created_at:{pt:"Criado em",en:"Created at",es:"Creado en"},created_by:{pt:"Criado por",en:"Created by",es:"Creado por"},currency:{pt:"Moeda",en:"Currency",es:"Moneda"},dashboard:{pt:"Dashboard",en:"Dashboard",es:"Panel"},date:{pt:"Data",en:"Date",es:"Fecha"},date_and_time:{pt:"Data e Hora",en:"Date and Time",es:"Fecha y Hora"},date_format:{pt:"Formato de Data",en:"Date Format",es:"Formato de Fecha"},date_time_format:{pt:"Formato de Data/Hora",en:"Date/Time Format",es:"Formato de Fecha/Hora"},deactivate:{pt:"Inativar",en:"Deactivate",es:"Desactivar"},deactivate_selected:{pt:"Inativar Selecionados",en:"Deactivate Selected",es:"Desactivar Seleccionados"},default:{pt:"Padrão",en:"Default",es:"Por Defecto"},delete:{pt:"Excluir",en:"Delete",es:"Eliminar"},delete_confirmation:{pt:"Confirmação de Exclusão",en:"Delete Confirmation",es:"Confirmación de Eliminación"},delete_success:{pt:"Excluído com sucesso",en:"Deleted successfully",es:"Eliminado exitosamente"},deleting:{pt:"Excluindo...",en:"Deleting...",es:"Eliminando..."},department:{pt:"Departamento",en:"Department",es:"Departamento"},description:{pt:"Descrição",en:"Description",es:"Descripción"},deselect_all:{pt:"Desselecionar todos",en:"Deselect all",es:"Deseleccionar todo"},design_system:{pt:"Design System",en:"Design System",es:"Sistema de Diseño"},design_tokens_and_docs:{pt:"Design tokens e documentação",en:"Design tokens and documentation",es:"Tokens de diseño y documentación"},details:{pt:"Detalhes",en:"Details",es:"Detalles"},disabled:{pt:"Desabilitado",en:"Disabled",es:"Deshabilitado"},download:{pt:"Baixar",en:"Download",es:"Descargar"},drag_drop:{pt:"Arraste e solte ou clique para selecionar",en:"Drag and drop or click to select",es:"Arrastre y suelte o haga clic para seleccionar"},duplicate:{pt:"Duplicar",en:"Duplicate",es:"Duplicar"},edit:{pt:"Editar",en:"Edit",es:"Editar"},edit_additional_fields:{pt:"Editar Campos Adicionais",en:"Edit Additional Fields",es:"Editar Campos Adicionales"},editor_hint:{pt:"💡 Dica: Use Ctrl+B (negrito), Ctrl+I (itálico), Ctrl+U (sublinhado) ou clique nos botões.",en:"💡 Hint: Use Ctrl+B (bold), Ctrl+I (italic), Ctrl+U (underline) or click the buttons.",es:"💡 Consejo: Use Ctrl+B (negrita), Ctrl+I (cursiva), Ctrl+U (subrayado) o haga clic en los botones."},education:{pt:"Educação",en:"Education",es:"Educación"},email:{pt:"E-mail",en:"Email",es:"Correo electrónico"},email_placeholder:{pt:"email@empresa.com",en:"email@company.com",es:"email@empresa.com"},embed:{pt:"Código Embed",en:"Embed Code",es:"Código Embed"},employee:{pt:"Colaborador",en:"Employee",es:"Empleado"},employee_activated:{pt:"Colaborador ativado com sucesso",en:"Employee activated successfully",es:"Empleado activado exitosamente"},employee_deactivated:{pt:"Colaborador inativado com sucesso",en:"Employee deactivated successfully",es:"Empleado desactivado exitosamente"},employee_information:{pt:"Informações do Colaborador",en:"Employee Information",es:"Información del Empleado"},employees:{pt:"Colaboradores",en:"Employees",es:"Empleados"},employees_removed:{pt:"{{count}} colaborador(es) removido(s)",en:"{{count}} employee(s) removed",es:"{{count}} empleado(s) eliminado(s)"},empty_description:{pt:"Não há dados para exibir no momento.",en:"There is no data to display at this time.",es:"No hay datos para mostrar en este momento."},empty_title:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},en:{pt:"EN",en:"EN",es:"EN"},enabled:{pt:"Habilitado",en:"Enabled",es:"Habilitado"},enter_full_name:{pt:"Digite o nome completo",en:"Enter full name",es:"Ingrese el nombre completo"},enter_link_url:{pt:"Digite a URL do link:",en:"Enter link URL:",es:"Ingrese la URL del enlace:"},enter_youtube_url:{pt:"Cole a URL do vídeo do YouTube:",en:"Paste YouTube video URL:",es:"Pegue la URL del video de YouTube:"},error:{pt:"Erro",en:"Error",es:"Error"},error_changing_employee_status:{pt:"Erro ao alterar status do colaborador",en:"Error changing employee status",es:"Error al cambiar el estado del empleado"},error_creating:{pt:"Erro ao criar",en:"Error creating",es:"Error al crear"},error_deleting:{pt:"Erro ao excluir",en:"Error deleting",es:"Error al eliminar"},error_loading:{pt:"Erro ao carregar",en:"Error loading",es:"Error al cargar"},error_no_image:{pt:"Nenhuma imagem selecionada",en:"No image selected",es:"Ninguna imagen seleccionada"},error_no_video:{pt:"Nenhum vídeo selecionado",en:"No video selected",es:"Ningún video seleccionado"},error_saving:{pt:"Erro ao salvar",en:"Error saving",es:"Error al guardar"},error_updating:{pt:"Erro ao atualizar",en:"Error updating",es:"Error al actualizar"},es:{pt:"ES",en:"ES",es:"ES"},export:{pt:"Exportar",en:"Export",es:"Exportar"},failed:{pt:"Falhou",en:"Failed",es:"Fallido"},field_name:{pt:"Nome do Campo",en:"Field Name",es:"Nombre del Campo"},field_type:{pt:"Tipo",en:"Type",es:"Tipo"},file:{pt:"Arquivo de Vídeo",en:"Video File",es:"Archivo de Video"},file_upload_error:{pt:"Erro ao enviar arquivo",en:"Error uploading file",es:"Error al cargar el archivo"},file_upload_success:{pt:"Arquivo enviado com sucesso",en:"File uploaded successfully",es:"Archivo cargado exitosamente"},filter:{pt:"Filtrar",en:"Filter",es:"Filtrar"},first_name:{pt:"Nome",en:"First Name",es:"Nombre"},font:{pt:"Fonte",en:"Font",es:"Fuente"},format_html:{pt:"HTML",en:"HTML",es:"HTML"},format_markdown:{pt:"Markdown",en:"Markdown",es:"Markdown"},format_plain:{pt:"Texto Simples",en:"Plain Text",es:"Texto Simple"},format_rich:{pt:"Rich (WYSIWYG)",en:"Rich (WYSIWYG)",es:"Rich (WYSIWYG)"},full_name:{pt:"Nome Completo",en:"Full Name",es:"Nombre Completo"},general_settings:{pt:"Configurações Gerais",en:"General Settings",es:"Configuración General"},height:{pt:"Altura",en:"Height",es:"Altura"},home:{pt:"Início",en:"Home",es:"Inicio"},html_warning:{pt:"⚠️ HTML será sanitizado para segurança",en:"⚠️ HTML will be sanitized for security",es:"⚠️ HTML será sanitizado por seguridad"},identification:{pt:"Identificação",en:"Identification",es:"Identificación"},identification_invalid:{pt:"Identificação inválida",en:"Invalid identification",es:"Identificación inválida"},image:{pt:"Imagem",en:"Image",es:"Imagen"},import:{pt:"Importar",en:"Import",es:"Importar"},inactive:{pt:"Inativo",en:"Inactive",es:"Inactivo"},inactive_plural:{pt:"Inativos",en:"Inactive",es:"Inactivos"},info:{pt:"Informação",en:"Information",es:"Información"},input_type:{pt:"Tipo de Entrada",en:"Input Type",es:"Tipo de Entrada"},input_type_embed:{pt:"Embed",en:"Embed",es:"Incrustar"},input_type_upload:{pt:"Upload",en:"Upload",es:"Cargar"},integration:{pt:"Integração",en:"Integration",es:"Integración"},invalid_date:{pt:"Data inválida",en:"Invalid date",es:"Fecha inválida"},invalid_email:{pt:"E-mail inválido",en:"Invalid email",es:"Correo electrónico inválido"},invalid_file_type:{pt:"Por favor, selecione um arquivo de vídeo",en:"Please select a video file",es:"Por favor, seleccione un archivo de video"},invalid_phone:{pt:"Telefone inválido",en:"Invalid phone",es:"Teléfono inválido"},invalid_youtube_url:{pt:"URL do YouTube inválida. Use o formato: https://www.youtube.com/watch?v=VIDEO_ID",en:"Invalid YouTube URL. Use format: https://www.youtube.com/watch?v=VIDEO_ID",es:"URL de YouTube inválida. Use el formato: https://www.youtube.com/watch?v=VIDEO_ID"},item_details:{pt:"Detalhes do item",en:"Item details",es:"Detalles del elemento"},items:{pt:"itens",en:"items",es:"elementos"},items_per_page:{pt:"Itens por página",en:"Items per page",es:"Elementos por página"},key:{pt:"Chave",en:"Key",es:""},language:{pt:"Idioma",en:"Language",es:"Idioma"},last_10_logins:{pt:"Últimos 10 Logins",en:"Last 10 Logins",es:"Últimos 10 Inicios de Sesión"},last_modification:{pt:"Última Modificação",en:"Last Modification",es:"Última Modificación"},last_name:{pt:"Sobrenome",en:"Last Name",es:"Apellido"},leader:{pt:"Líder",en:"Leader",es:"Líder"},leadership:{pt:"Liderança",en:"Leadership",es:"Liderazgo"},leadership_hierarchy:{pt:"Hierarquia de liderança",en:"Leadership hierarchy",es:"Jerarquía de liderazgo"},left:{pt:"Esquerda",en:"Left",es:"Izquierda"},link_copied:{pt:"Link copiado para a área de transferência",en:"Link copied to clipboard",es:"Enlace copiado al portapapeles"},list:{pt:"Lista",en:"List",es:"Lista"},loading:{pt:"Carregando...",en:"Loading...",es:"Cargando..."},loading_data:{pt:"Carregando dados...",en:"Loading data...",es:"Cargando datos..."},logout:{pt:"Sair",en:"Logout",es:"Cerrar Sesión"},manage_reports:{pt:"Gerenciar relatórios",en:"Manage reports",es:"Gestionar informes"},management:{pt:"Gestão",en:"Management",es:"Gestión"},management_access_control:{pt:"Controle de acesso a gestão",en:"Management access control",es:"Control de acceso a gestión"},management_permission:{pt:"Permissão de Gestão",en:"Management Permission",es:"Permiso de Gestión"},management_permissions:{pt:"Permissões de Gestão",en:"Management Permissions",es:"Permisos de Gestión"},markdown_hint:{pt:"💡 Suporte a: **negrito**, *itálico*, [links](url), parágrafos",en:"💡 Supports: **bold**, *italic*, [links](url), paragraphs",es:"💡 Soporta: **negrita**, *cursiva*, [enlaces](url), párrafos"},max_file_size:{pt:"Tamanho máximo",en:"Maximum size",es:"Tamanho máximo"},migration:{pt:"Migração",en:"Migration",es:""},module:{pt:"Módulo",en:"Module",es:"Módulo"},module_title:{pt:"Título do módulo",en:"Module title",es:"Título del módulo"},modules:{pt:"Módulos",en:"Modules",es:"Módulos"},name:{pt:"Nome",en:"Name",es:"Nombre"},new:{pt:"Novo",en:"New",es:"Nuevo"},new_password:{pt:"Nova Senha",en:"New Password",es:"Nueva Contraseña"},new_value:{pt:"Novo valor",en:"New value",es:"Nuevo valor"},next:{pt:"Próximo",en:"Next",es:"Siguiente"},no:{pt:"Não",en:"No",es:"No"},no_additional_fields:{pt:"Nenhum campo adicional configurado.",en:"No additional fields configured.",es:"No hay campos adicionales configurados."},no_content_preview:{pt:"Nenhum conteúdo para visualizar...",en:"No content to preview...",es:"No hay contenido para previsualizar..."},no_data:{pt:"Nenhum dado disponível",en:"No data available",es:"No hay datos disponibles"},no_file_selected:{pt:"Nenhum arquivo selecionado",en:"No file selected",es:"No se seleccionó ningún archivo"},no_items_found:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},no_logins_registered:{pt:"Nenhum login registrado ainda.",en:"No logins registered yet.",es:"Aún no se han registrado inicios de sesión."},no_options:{pt:"Nenhuma opção disponível",en:"No options available",es:"No hay opciones disponibles"},no_permission_to_access_reports:{pt:"Sem permissão para acessar relatórios",en:"No permission to access reports",es:""},no_posts_found:{pt:"Nenhum post encontrado",en:"No posts found",es:"No se encontraron publicaciones"},no_results:{pt:"Nenhum resultado encontrado",en:"No results found",es:"No se encontraron resultados"},no_title:{pt:"Sem título",en:"No title",es:"Sin título"},notifications:{pt:"Notificações",en:"Notifications",es:"Notificaciones"},nr1:{pt:"Pulso",en:"Pulse",es:"Pulso"},of:{pt:"de",en:"of",es:"de"},old_password:{pt:"Senha Atual",en:"Current Password",es:"Contraseña Actual"},open_external_link:{pt:"Abrir link externo",en:"Open external link",es:"Abrir enlace externo"},open_wiki:{pt:"Abrir Wiki",en:"Open Wiki",es:"Abrir Wiki"},order:{pt:"Ordem",en:"Order",es:"Orden"},overview:{pt:"Visão geral",en:"Overview",es:"Resumen"},page:{pt:"Página",en:"Page",es:"Página"},password:{pt:"Senha",en:"Password",es:"Contraseña"},paste_html_placeholder:{pt:"Cole ou escreva HTML aqui...",en:"Paste or write HTML here...",es:"Pegue o escriba HTML aquí..."},pdi:{pt:"PDI",en:"PDI",es:"PDI"},pending:{pt:"Pendente",en:"Pending",es:"Pendiente"},performance:{pt:"Desempenho",en:"Performance",es:"Desempeño"},permissions:{pt:"Permissões",en:"Permissions",es:"Permisos"},permissions_roles:{pt:"Permissões e Roles",en:"Permissions and Roles",es:"Permisos y Roles"},phone:{pt:"Telefone",en:"Phone",es:"Teléfono"},place:{pt:"Local",en:"Place",es:"Lugar"},placeholder_select:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},places:{pt:"Locais",en:"Places",es:"Lugares"},plain_text_placeholder:{pt:"Digite texto simples aqui...",en:"Enter plain text here...",es:"Ingrese texto simple aquí..."},position:{pt:"Cargo",en:"Position",es:"Cargo"},posts:{pt:"Publicações",en:"Posts",es:"Publicaciones"},preferences:{pt:"Preferências de Internacionalização",en:"Internationalization Preferences",es:"Preferencias de Internacionalización"},preview:{pt:"Preview",en:"Preview",es:"Vista Previa"},previous:{pt:"Anterior",en:"Previous",es:"Anterior"},processing:{pt:"Processando...",en:"Processing...",es:"Procesando..."},profile:{pt:"Perfil",en:"Profile",es:"Perfil"},pt:{pt:"PT",en:"PT",es:"PT"},qualiex_places_hierarchy:{pt:"Hierarquia de locais do Qualiex",en:"Qualiex places hierarchy",es:"Jerarquía de lugares de Qualiex"},recipient_email:{pt:"Email Destinatário",en:"Recipient Email",es:"Correo del Destinatario"},redirecting:{pt:"Redirecionando...",en:"Redirecting...",es:"Redirigiendo..."},refresh_data:{pt:"Atualizar dados",en:"Refresh data",es:"Actualizar datos"},reload:{pt:"Recarregar",en:"Reload",es:"Recargar"},remove:{pt:"Remover",en:"Remove",es:"Eliminar"},remove_confirm:{pt:"Tem certeza que deseja remover?",en:"Are you sure you want to remove?",es:"¿Está seguro de que desea eliminar?"},removing:{pt:"Removendo...",en:"Removing...",es:"Eliminando..."},reports:{pt:"Relatórios",en:"Reports",es:"Informes"},required_field:{pt:"Campo obrigatório",en:"Required field",es:"Campo obligatorio"},restricted_access:{pt:"Acesso restrito",en:"Restricted access",es:"Acceso restringido"},results:{pt:"resultados",en:"results",es:"resultados"},right:{pt:"Direita",en:"Right",es:"Derecha"},role:{pt:"Papel",en:"Role",es:"Rol"},roles:{pt:"Perfis",en:"Roles",es:"Roles"},rows_per_page:{pt:"Registros por página",en:"Rows per page",es:"Registros por página"},save:{pt:"Salvar",en:"Save",es:"Guardar"},save_block:{pt:"Salvar Bloco",en:"Save Block",es:"Guardar Bloque"},save_success:{pt:"Salvo com sucesso",en:"Saved successfully",es:"Guardado exitosamente"},saving:{pt:"Salvando...",en:"Saving...",es:"Guardando..."},search:{pt:"Pesquisar",en:"Search",es:"Buscar"},search_placeholder:{pt:"Pesquisar...",en:"Search...",es:"Buscar..."},search_user:{pt:"Buscar usuário...",en:"Search user...",es:"Buscar usuario..."},searchDateFormat:{pt:"Buscar formato...",en:"Search format...",es:"Buscar formato..."},searchTimezone:{pt:"Buscar fuso horário...",en:"Search timezone...",es:"Buscar zona horaria..."},section:{pt:"Seção",en:"Section",es:"Sección"},select_all:{pt:"Selecionar todos",en:"Select all",es:"Seleccionar todo"},select_collaborator:{pt:"Selecionar Colaborador",en:"Select Collaborator",es:"Seleccionar Colaborador"},select_option:{pt:"Selecione uma opção",en:"Select an option",es:"Seleccione una opción"},select_placeholder:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},selectDateFormat:{pt:"Selecione o formato",en:"Select format",es:"Seleccione el formato"},selectTimezone:{pt:"Selecione o fuso horário",en:"Select timezone",es:"Seleccione la zona horaria"},select_text_for_link:{pt:"Selecione o texto que deseja transformar em link",en:"Select the text you want to turn into a link",es:"Seleccione el texto que desea convertir en enlace"},select_unit_collaborator:{pt:"Selecione um colaborador da unidade",en:"Select a unit collaborator",es:"Seleccione un colaborador de la unidad"},select_user:{pt:"Selecionar Usuário",en:"Select User",es:"Seleccionar Usuario"},select_user_for_admin_access:{pt:"Selecione um usuário para dar acesso admin",en:"Select a user to grant admin access",es:"Seleccione un usuario para dar acceso de administrador"},select_video:{pt:"Selecionar Vídeo",en:"Select Video",es:"Seleccionar Video"},selected:{pt:"selecionado(s)",en:"selected",es:"seleccionado(s)"},selected_count:{pt:"{{count}} selecionado(s)",en:"{{count}} selected",es:"{{count}} seleccionado(s)"},send:{pt:"Enviar",en:"Send",es:"Enviar"},settings:{pt:"Configurações",en:"Settings",es:"Configuración"},settings_summary:{pt:"Resumo das configurações",en:"Settings summary",es:"Resumen de configuración"},showing:{pt:"Mostrando",en:"Showing",es:"Mostrando"},size:{pt:"Tamanho",en:"Size",es:"Tamaño"},skills:{pt:"Habilidades",en:"Skills",es:"Habilidades"},state:{pt:"Estado",en:"State",es:"Estado"},status:{pt:"Status",en:"Status",es:"Estado"},subordinates:{pt:"Subordinados",en:"Subordinates",es:"Subordinados"},success:{pt:"Sucesso",en:"Success",es:"Éxito"},superior:{pt:"Superior Imediato",en:"Immediate Superior",es:"Superior Inmediato"},superior_none:{pt:"Nenhum superior",en:"No superior",es:"Ningún superior"},superior_search:{pt:"Buscar superior...",en:"Search superior...",es:"Buscar superior..."},system_administration:{pt:"Administração do sistema",en:"System administration",es:"Administración del sistema"},system_logs:{pt:"Logs do Sistema",en:"System Logs",es:"Registros del Sistema"},template_variables:{pt:"Variáveis do Template",en:"Template Variables",es:"Variables de Plantilla"},test_email:{pt:"Testar Envio de Email",en:"Test Email Sending",es:"Probar Envío de Correo"},text:{pt:"Texto",en:"Text",es:"Texto"},text_color:{pt:"Cor do Texto",en:"Text Color",es:"Color del Texto"},text_format:{pt:"Formato de Texto",en:"Text Format",es:"Formato de Texto"},thumbnail:{pt:"Thumbnail",en:"Thumbnail",es:"Miniatura"},timezone:{pt:"Fuso Horário",en:"Timezone",es:"Zona Horaria"},title:{pt:"Título",en:"Title",es:"Título"},to:{pt:"até",en:"to",es:"hasta"},total:{pt:"Total",en:"Total",es:"Total"},trainings:{pt:"Treinamentos",en:"Trainings",es:"Capacitaciones"},translation:{pt:"Tradução",en:"Translation",es:"Traducción"},translation_description:{pt:"Informações da tradução",en:"Translation information",es:"Información de la traducción"},translations:{pt:"Traduções",en:"Translations",es:"Traducciones"},type:{pt:"Tipo",en:"Type",es:"Tipo"},type_to_search:{pt:"Digite para pesquisar",en:"Type to search",es:"Escriba para buscar"},unit:{pt:"Unidade",en:"Unit",es:"Unidad"},units:{pt:"Unidades",en:"Units",es:"Unidades"},unsupported:{pt:"Formato não suportado",en:"Unsupported format",es:"Formato no soportado"},update:{pt:"Atualizar",en:"Update",es:"Actualizar"},value:{pt:"Valor",en:"Value",es:"Valor"},update_success:{pt:"Atualizado com sucesso",en:"Updated successfully",es:"Actualizado exitosamente"},updated_at:{pt:"Atualizado em",en:"Updated at",es:"Actualizado en"},updated_by:{pt:"Atualizado por",en:"Updated by",es:"Actualizado por"},updating:{pt:"Atualizando...",en:"Updating...",es:"Actualizando..."},upload:{pt:"Upload",en:"Upload",es:"Cargar"},useSystemDefaults:{pt:"Usar padrão do sistema",en:"Use system defaults",es:"Usar valores del sistema"},uploading:{pt:"Enviando...",en:"Uploading...",es:"Subiendo..."},url:{pt:"URL",en:"URL",es:"URL"},url_placeholder:{pt:"https://exemplo.com/imagem.jpg",en:"https://example.com/image.jpg",es:"https://ejemplo.com/imagen.jpg"},user:{pt:"Usuário",en:"User",es:"Usuario"},user_management:{pt:"Gestão de Usuários",en:"User Management",es:"Gestión de Usuarios"},username:{pt:"Usuário",en:"Username",es:"Usuario"},users:{pt:"Usuários",en:"Users",es:"Usuarios"},video:{pt:"Vídeo",en:"Video",es:"Video"},view:{pt:"Visualizar",en:"View",es:"Visualizar"},view_mode_grid:{pt:"Grade",en:"Grid",es:"Cuadrícula"},view_mode_list:{pt:"Lista",en:"List",es:"Lista"},view_mode_table:{pt:"Tabela",en:"Table",es:"Tabla"},warning:{pt:"Aviso",en:"Warning",es:"Advertencia"},width:{pt:"Largura",en:"Width",es:"Ancho"},yes:{pt:"Sim",en:"Yes",es:"Sí"},zip_code:{pt:"CEP",en:"ZIP Code",es:"Código Postal"}};A.use(v.initReactI18next).init({resources:function(e){const t={},a={},s={};for(const[r,n]of Object.entries(e))t[r]=n.pt||r,a[r]=n.en||n.pt||r,s[r]=n.es||n.pt||r;return{"pt-BR":{translations:t},"en-US":{translations:a},"es-ES":{translations:s}}}(qo),fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e});const Oo=t.createContext(void 0),Bo={locale:xa,timezone:ba,datetimeFormat:ga},$o=async()=>{},Ho=({children:t})=>e.jsx(Oo.Provider,{value:{...Bo,setLocale:$o,setTimezone:$o,setDatetimeFormat:$o,isLoading:!1},children:t}),Vo=()=>{const e=t.useContext(Oo);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},Wo=t.createContext({moduleAlias:null});function Go({moduleAlias:t=null,children:a}){return e.jsx(Wo.Provider,{value:{moduleAlias:t},children:a})}function Yo(){return t.useContext(Wo)}const Qo=he.Root,Ko=he.CollapsibleTrigger,Xo=he.CollapsibleContent;class Zo extends t.Component{constructor(e){super(e),this.copyErrorDetails=()=>{const e=Rr.getErrors().slice(0,2),t=`\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,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),i.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,t){if((void 0).DEV)throw e;Rr.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=Rr.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(La,{className:"w-full max-w-2xl",children:[e.jsxs(za,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(Fa,{children:"Algo deu errado"})]}),e.jsxs(qa,{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(Qo,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Ko,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Xo,{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(vr,{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})})]})]}),t.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:t.map((t,a)=>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:[a+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(t.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),e.jsxs(Pa,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(Pa,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Jo={analysis:12,decisions:13,audit:1,common:0,competencies:23,performance:24,docs:17,education:25,flow:7,suppliers:15,"suppliers-portal":16,mapping:11,metrology:8,control:18,msa:21,occurrences:3,okr:26,pdi:27,plans:6,"strategy-extension":14,pulse:28,boards:10,risks:4,fmea:20,staff:19,"control-plan":22},ei=6e5;function ti(e){const{moduleAlias:a}=Yo(),{alias:s,user:r,isAuthenticated:n}=Nn(),o=e??a,i=r?.id??null,l=n&&!!s&&!!i,{data:c=[],isLoading:d}=y.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>sn.fetchUserAssociations(i,s),enabled:l,staleTime:ei,gcTime:12e5}),u=t.useMemo(()=>s&&0!==c.length?c.find(e=>e.companyAlias===s)??null:null,[c,s]),m=t.useCallback(e=>{if(!u)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const t=Jo[e];return void 0!==t&&u.softwares.includes(t)})},[u]);return{hasAccess:t.useMemo(()=>!o||m(o),[o,m]),isLoading:l&&d,role:t.useMemo(()=>u?{id:u.roleId,name:u.roleName}:null,[u]),association:u,hasAccessTo:m}}const ai=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",softwareAlias:"analysis",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",softwareAlias:"decisions",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",softwareAlias:"audit",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",softwareAlias:"common",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",softwareAlias:"docs",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",softwareAlias:"flow",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",softwareAlias:"suppliers",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",softwareAlias:"mapping",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",softwareAlias:"metrology",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",softwareAlias:"occurrences",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",softwareAlias:"okr",url:"https://okr.qualiex.com"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",softwareAlias:"plans",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",softwareAlias:"suppliers-portal",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",softwareAlias:"risks",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",softwareAlias:"competencies",url:"https://competencias.sabergestao.com.br"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",softwareAlias:"performance",url:"https://desempenho.sabergestao.com.br"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",softwareAlias:"education",url:"https://educacao.sabergestao.com.br"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",softwareAlias:"pdi",url:"https://pdi.sabergestao.com.br"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",softwareAlias:"pulse",url:"https://nr1pulso.sabergestao.com.br"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",url:"https://treinamentos.sabergestao.com.br"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]",url:"https://apps1.qualiex.com/action?unitalias={alias}"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]",url:"https://apps1.qualiex.com/audit?unitalias={alias}"},{name:"Configurações v3",description:"Configurações",color:"bg-[#5C6BC0]",url:"https://apps3.qualiex.com/{alias}/common"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]",url:"https://apps1.qualiex.com/shared/dashboard?unitalias=forlogic"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]",url:"https://apps1.qualiex.com/docs?unitalias={alias}"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]",url:"https://apps1.qualiex.com/indicators?unitalias={alias}"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]",url:"https://apps1.qualiex.com/meeting?unitalias={alias}"},{name:"Metrology v3",description:"Gestão de Metrologia",color:"bg-[#afd884]",url:"https://apps3.qualiex.com/{alias}/metrology/"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]",url:"https://apps3.qualiex.com/{alias}/planner/m"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]",url:"https://apps1.qualiex.com/common/reports?unitalias=forlogic"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]",url:"https://apps1.qualiex.com/risks?unitalias={alias}"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]",url:"https://apps1.qualiex.com/staff?unitalias={alias}"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]",url:"https://apps1.qualiex.com/supply?unitalias={alias}"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker1?unitalias={alias}"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker2?unitalias={alias}"}]}],si=fe.Root,ri=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.List,{ref:s,className:Aa("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));ri.displayName=fe.List.displayName;const ni=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Trigger,{ref:s,className:Aa("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",t),...a}));ni.displayName=fe.Trigger.displayName;const oi=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Content,{ref:s,className:Aa("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));oi.displayName=fe.Content.displayName;const ii=J.forwardRef(({className:t,value:a,...s},r)=>e.jsx(xe.Root,{ref:r,className:Aa("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...s,children:e.jsx(xe.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));function li({image:t,title:a,className:s}){return e.jsx("div",{className:Aa("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:t?e.jsx("img",{src:t,alt:a,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function ci({steps:t,currentStepIndex:a,onStepSelect:s,stepLabel:r,className:n}){const o=t.length,i=(a+1)/o*100;return e.jsxs("div",{className:Aa("flex items-center gap-3",n),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",a+1,"/",o,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:t.map((t,r)=>e.jsxs(Gs,{onClick:()=>s(r),className:Aa(r===a&&"bg-accent"),children:[r+1,". ",t.title]},t.id))})]}),e.jsx(ii,{value:i,className:"w-32 h-2"})]})}function di({currentStepIndex:t,totalSteps:a,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:c,className:d}){const u=0===t,m=t===a-1;return e.jsxs("div",{className:Aa("flex items-center gap-2",d),children:[!u&&e.jsxs(Pa,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(l.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),e.jsxs(Pa,{onClick:m?n:r,size:"sm",children:[m?c:i,!m&&e.jsx(l.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}ii.displayName=xe.Root.displayName;const ui=J.forwardRef(({open:t,onOpenChange:a,steps:s,onComplete:r,onStepChange:n,continueButtonText:o="Continuar",backButtonText:i="Voltar",finishButtonText:c="Concluir",stepLabel:d="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:p,onCurrentStepChange:h,className:f},x)=>{const[g,b]=J.useState(0),v=void 0!==p,w=v?p:g,N=J.useCallback(e=>{v?h?.(e):b(e),n?.(e)},[v,h,n]);J.useEffect(()=>{t||v||b(0)},[t,v]);const y=s[w],j=s.length;return y?e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(os,{ref:x,size:u,variant:"informative",className:Aa("p-0 gap-0 overflow-hidden",f),children:[e.jsxs(ss,{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(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(li,{image:y.image,title:y.title}),e.jsx(ds,{className:"text-xl font-semibold",children:y.title}),e.jsx(us,{className:"text-muted-foreground",children:y.description})]})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(Ba,{}),e.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[m&&j>1?e.jsx(ci,{steps:s,currentStepIndex:w,onStepSelect:e=>{N(e)},stepLabel:d}):e.jsx("div",{}),e.jsx(di,{currentStepIndex:w,totalSteps:j,onBack:()=>{w>0&&N(w-1)},onNext:()=>{w<j-1&&N(w+1)},onComplete:()=>{r?.(),a(!1)},backButtonText:i,continueButtonText:o,finishButtonText:c})]})]})]})}):null});function mi({className:t}){return e.jsxs("svg",{className:t,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.5 11.7455C0.5 10.2633 2.25695 9.52546 3.36816 10.4399L22.4346 26.1528C23.3588 26.9137 23.229 28.3353 22.1953 28.9301L16.3418 32.2963C15.7961 32.6097 15.1199 32.6098 14.5742 32.2963L1.36133 24.7006C0.832671 24.3966 0.500052 23.8398 0.5 23.2289V11.7455Z",stroke:"currentColor"}),e.jsx("path",{d:"M14.612 0.735352C15.1576 0.421927 15.833 0.421964 16.3786 0.735352L25.3776 5.90723V5.9082C26.5447 6.5808 26.5183 8.24018 25.3298 8.875L25.3307 8.87598L13.9333 14.9697L13.9323 14.9688C13.3016 15.3066 12.5233 15.2301 11.9733 14.7773L4.90302 8.9541C3.97881 8.19317 4.1086 6.77256 5.14227 6.17773L14.612 0.735352Z",stroke:"currentColor"}),e.jsx("path",{d:"M28.1066 9.7966C29.2466 9.18579 30.6895 9.9732 30.6896 11.2937V23.0691C30.6895 23.6825 30.3539 24.2382 29.8264 24.5417L29.8254 24.5427L27.3449 25.9607C26.7486 26.3015 26.0057 26.264 25.4494 25.8747L25.341 25.7917L16.6076 18.5974C15.6649 17.821 15.8224 16.3676 16.8937 15.7937V15.7927L28.1066 9.79758V9.7966Z",stroke:"currentColor"})]})}function pi({className:t}){return e.jsxs("svg",{className:t,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.524143 8.74979C1.44754 8.74979 2.36325 8.74979 3.30973 8.74979C3.30973 8.90069 3.30973 9.05162 3.30973 9.19497C3.30973 9.79101 3.64061 10.1154 4.24082 10.1154C6.8879 10.1154 9.54268 10.1154 12.1898 10.1154C12.7592 10.1154 13.1286 9.77589 13.1132 9.27793C13.0978 8.8856 12.8054 8.5612 12.3745 8.51594C11.2279 8.38767 10.0736 8.26696 8.91938 8.1387C7.72666 8.01043 6.52625 7.88216 5.33352 7.74635C4.71792 7.67845 4.10232 7.61811 3.48672 7.53511C2.00928 7.32386 0.754978 6.06386 0.547213 4.61526C0.331752 3.10631 1.00122 1.73316 2.34015 0.963593C2.89419 0.646712 3.5021 0.503353 4.14848 0.503353C6.84943 0.503353 9.55038 0.495808 12.2513 0.503353C14.0904 0.510898 15.5448 1.71808 15.8603 3.49865C15.8988 3.7099 15.8988 3.92116 15.9065 4.13996C15.9141 4.2984 15.9065 4.44928 15.9065 4.61526C14.9677 4.61526 14.0443 4.61526 13.0978 4.61526C13.0978 4.44928 13.0978 4.28329 13.0978 4.1173C13.0901 3.58162 12.7592 3.25719 12.2206 3.24965C9.53499 3.24965 6.84943 3.24965 4.17157 3.24965C3.69448 3.24965 3.36359 3.52881 3.30203 3.97396C3.24816 4.3512 3.51749 4.73597 3.90224 4.8265C4.10231 4.87177 4.31008 4.88687 4.51784 4.9095C5.8183 5.05285 7.12645 5.19622 8.42691 5.33957C9.71198 5.48292 10.997 5.63382 12.2898 5.75453C13.1824 5.83753 13.9981 6.08649 14.6906 6.68253C16.1604 7.92742 16.3066 10.2588 14.9984 11.6696C14.2443 12.4845 13.3132 12.8844 12.1975 12.8844C9.5273 12.8844 6.84944 12.8844 4.17927 12.8844C2.55562 12.8844 1.21669 11.9563 0.678043 10.4549C0.539533 9.98715 0.470277 9.38356 0.524143 8.74979Z",stroke:"currentColor"}),e.jsx("path",{d:"M8.21913 24.2393C8.21913 24.2317 8.21913 24.2317 8.21913 24.2393ZM8.21913 24.2393C8.98863 24.2393 9.75812 24.2619 10.5199 24.2317C11.7511 24.1789 12.9285 23.1378 13.067 21.9381C13.1439 21.3119 13.1285 20.6706 13.1131 20.0368C13.067 18.6335 11.8743 17.4339 10.443 17.3962C8.96554 17.3584 7.4881 17.366 6.00296 17.3962C4.70251 17.4263 3.54055 18.4373 3.37896 19.6973C3.29431 20.3462 3.3097 21.0101 3.34048 21.6665C3.40204 23.017 4.58708 24.1789 5.96449 24.2317C6.7186 24.2619 7.46502 24.2393 8.21913 24.2393ZM13.1439 15.427C13.7441 14.8385 14.3367 14.2575 14.9138 13.6917C15.5756 14.333 16.2296 14.9818 16.9222 15.6608C16.8914 15.6759 16.8298 15.7061 16.7837 15.7438C16.2604 16.2493 15.7448 16.7624 15.2216 17.2679C15.1446 17.3434 15.1369 17.4037 15.1908 17.4943C15.7064 18.3845 15.9526 19.3427 15.9295 20.3613C15.9141 20.9799 15.9526 21.6062 15.8603 22.2097C15.5371 24.2846 14.352 25.7332 12.3975 26.5782C11.7126 26.8724 10.9816 26.9931 10.2352 26.9931C8.89629 26.9931 7.56504 26.9931 6.22611 26.9931C3.49438 26.9931 1.20897 25.1899 0.631845 22.5719C0.56259 22.2475 0.524115 21.9155 0.51642 21.5835C0.508725 20.9422 0.470242 20.2933 0.547192 19.6596C0.816518 17.3584 2.08619 15.7967 4.27927 14.9516C4.84101 14.7328 5.42584 14.6347 6.02605 14.6347C7.4958 14.6347 8.96554 14.6272 10.4276 14.6423C11.3279 14.6498 12.1667 14.9064 12.9516 15.3289C13.0131 15.3591 13.067 15.3892 13.1439 15.427Z",stroke:"currentColor"}),e.jsx("path",{d:"M0.508791 28.3813C1.43989 28.3813 2.3633 28.3813 3.2944 28.3813C3.31748 28.4945 3.32516 28.6001 3.35594 28.7058C3.50984 29.2943 4.01772 29.7017 4.63332 29.7319C4.76414 29.7394 4.89496 29.7394 5.02578 29.7394C7.22655 29.7394 9.4273 29.7394 11.6281 29.7394C12.3206 29.7394 12.8439 29.3923 13.0363 28.7963C13.0747 28.668 13.0978 28.5323 13.1286 28.3889C14.0443 28.3889 14.9677 28.3889 15.9142 28.3889C15.9219 28.7435 15.868 29.0906 15.7757 29.4301C15.2986 31.1955 13.6519 32.4782 11.7897 32.4857C9.39653 32.5008 7.01108 32.5083 4.61794 32.4857C2.44025 32.4706 0.624216 30.7353 0.508791 28.6077C0.501096 28.5322 0.508791 28.4643 0.508791 28.3813Z",stroke:"currentColor"})]})}function hi({educaUrl:t="https://educa.forlogic.net/",saberGestaoUrl:a="https://sabergestao.com.br/",wikiUrl:s}){const r=t||s||"https://educa.forlogic.net/";return e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-white",children:"Aprenda a usar o Qualiex"}),e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-white underline underline-offset-2 hover:opacity-80 mt-2",children:["Conheça o ForLogic Educa",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(mi,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Conheça o Saber Gestão"}),e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(pi,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),e.jsxs("a",{href:s||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(l.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}function fi({module:t,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[e.jsx("div",{className:Aa("w-4 h-4 rounded-sm shrink-0 mt-0.5",t.color)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:t.name}),t.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.description})]})]})}function xi(e,t){if(0===e.length)return e;const a=Math.ceil(e.length/t),s=[];for(let r=0;r<a;r++)for(let n=0;n<t;n++){const t=n*a+r;t<e.length&&s.push(e[t])}return s}function gi({modules:a,onModuleClick:s,contractedModules:r,onModuleInterest:n}){const o=function(){const[e,a]=t.useState(4);return t.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?a(4):window.matchMedia("(min-width: 768px)").matches?a(3):window.matchMedia("(min-width: 640px)").matches?a(2):a(1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...a].sort((e,t)=>e.name.localeCompare(t.name)),l=void 0!==r,c=l?i.filter(e=>r.includes(e.name)):i,d=l?i.filter(e=>!r.includes(e.name)):[],u=xi(c,o),m=xi(d,o),p=(e,t)=>{t?s?.(e):n?.(e)};return e.jsxs("div",{className:"space-y-6",children:[u.length>0&&e.jsx("section",{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(t=>e.jsx(fi,{module:t,onClick:()=>p(t,!0)},t.name))})}),m.length>0&&e.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(t=>e.jsx(fi,{module:t,onClick:()=>p(t,!1)},t.name))})]})]})}function bi({onModuleClick:a,contractedModules:s,onModuleInterest:r,educaUrl:n="https://educa.forlogic.net/",saberGestaoUrl:o="https://sabergestao.com.br/",wikiUrl:i}){const[l,c]=t.useState("qualiex"),[d,u]=t.useState(null),m=e=>{a?.(e)},p=e=>{u(e)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs(si,{value:l,onValueChange:c,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(ri,{className:"w-fit shrink-0",children:ai.map(t=>e.jsxs(ni,{value:t.id,children:[t.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.modules.length,")"]})]},t.id))}),ai.map(t=>e.jsx(oi,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(gi,{modules:t.modules,onModuleClick:m,contractedModules:"qualiex"===t.id?s:void 0,onModuleInterest:p})},t.id))]}),e.jsx(hi,{educaUrl:n,saberGestaoUrl:o,wikiUrl:i})]}),d&&e.jsx(ui,{open:!!d,onOpenChange:e=>!e&&u(null),steps:(h=d,h.onboardingSteps&&h.onboardingSteps.length>0?h.onboardingSteps.slice(0,3):[{id:"intro",title:`Conheça o ${h.name}`,description:h.description||`O ${h.name} é uma solução completa para otimizar seus processos e aumentar a produtividade da sua equipe.`},{id:"features",title:"Principais Funcionalidades",description:"Automatize processos, gere relatórios detalhados, acompanhe indicadores em tempo real e tenha controle total sobre suas operações."},{id:"cta",title:"Transforme sua Gestão",description:"Fale com um de nossos especialistas e descubra como este módulo pode transformar a gestão da sua empresa."}]),finishButtonText:"Quero conhecer mais",onComplete:()=>{d&&(r?.(d),u(null))}})]});var h}function vi({open:a,onOpenChange:s,onModuleClick:r,contractedModules:n,onModuleInterest:o,educaUrl:i,saberGestaoUrl:l,wikiUrl:c}){const{alias:d}=Nn(),{association:u}=ti(),m=t.useMemo(()=>{if(n)return n;if(!u?.softwares)return;const e=u.softwares,t=ai.find(e=>"qualiex"===e.id);return t?t.modules.filter(t=>{if(!t.softwareAlias)return!1;const a=Jo[t.softwareAlias];return void 0!==a&&e.includes(a)}).map(e=>e.name):void 0},[n,u]);return e.jsx(es,{open:a,onOpenChange:s,children:e.jsxs(os,{size:"lg",className:"overflow-hidden flex flex-col",children:[e.jsx(is,{className:"sr-only",children:e.jsx(ds,{children:"Módulos"})}),e.jsx(bi,{onModuleClick:e=>{if(r)r(e);else if(e.url){_a(d?e.url.replace(/\{alias\}/g,d):e.url)}},contractedModules:m,onModuleInterest:o,educaUrl:i,saberGestaoUrl:l,wikiUrl:c})]})})}function wi({open:a,onOpenChange:s,onModuleClick:r,contractedModules:n,onModuleInterest:o,userName:i,unitName:c,units:d=[],currentAlias:u,onUnitChange:m,onLogout:p,educaUrl:h,saberGestaoUrl:f,wikiUrl:x,blocking:g=!0,size:b="lg",children:v}){const w=t.useMemo(()=>{if(!d.length)return[];const e=new Map;d.forEach(t=>e.set(t.alias,t));const t=Array.from(e.values()),a=t.find(e=>e.alias===u),s=t.filter(e=>e.alias!==u).sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"}));return a?[a,...s]:s},[d,u]);return e.jsx(es,{open:a,onOpenChange:g?void 0:s,children:e.jsxs(os,{size:b,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:g?e=>e.preventDefault():void 0,onEscapeKeyDown:g?e=>e.preventDefault():void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[e.jsx(ds,{children:"Parece que você não tem acesso a essa página"}),e.jsx(us,{children:"Selecione um módulo para continuar navegando!"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[w.length>1&&e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[e.jsx(l.Building2,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:c||"Unidade"}),e.jsx(l.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Ws,{align:"end",className:"max-h-[300px] overflow-auto",children:w.map(t=>e.jsxs(Gs,{onClick:()=>m?.(t),className:t.alias===u?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t.name}),t.alias===u&&e.jsx(Ds,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},t.alias))})]}),e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"gap-2",children:[e.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-3 w-3"})]})}),e.jsxs(Ws,{align:"end",children:[e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsx("p",{className:"text-sm font-medium",children:i||"Usuário"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:p,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),v?e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[e.jsx("div",{className:"flex-1",children:v}),e.jsx(hi,{educaUrl:h,saberGestaoUrl:f,wikiUrl:x})]}):e.jsx(bi,{onModuleClick:r,contractedModules:n,onModuleInterest:o,educaUrl:h,saberGestaoUrl:f,wikiUrl:x})]})})}function Ni({children:a,contractedModules:s,onModuleClick:r,onModuleInterest:n,educaUrl:o="https://educa.forlogic.net/",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l}){const{hasAccess:c,isLoading:d,association:u}=ti(),{user:m,alias:p,companies:h,isAuthenticated:f,isLoading:x,logout:g,switchUnit:b}=Nn(),v=t.useMemo(()=>{if(s)return s;if(!u?.softwares)return;const e=u.softwares,t=ai.find(e=>"qualiex"===e.id);return t?t.modules.filter(t=>{if(!t.softwareAlias)return!1;const a=Jo[t.softwareAlias];return void 0!==a&&e.includes(a)}).map(e=>e.name):void 0},[s,u]),w=t.useMemo(()=>h?.length?p&&h.find(e=>e.alias===p)||h[0]:null,[h,p]),N=t.useMemo(()=>h?.length?h.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[h]),y=t.useCallback(e=>{const t=h?.find(t=>t.alias===e.alias);t&&b(t)},[b,h]),j=t.useCallback(e=>{if(r)r(e);else if(e.url){_a(p?e.url.replace(/\{alias\}/g,p):e.url)}},[r,p]);return x||!f?e.jsx(e.Fragment,{children:a}):d?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx(Ls,{size:"lg"})}):c?e.jsx(e.Fragment,{children:a}):e.jsx(wi,{open:!0,onModuleClick:j,contractedModules:v,onModuleInterest:n,userName:m?.name,unitName:w?.name,units:N,currentAlias:p||void 0,onUnitChange:y,onLogout:g,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,blocking:!0})}ui.displayName="OnboardingDialog";const yi=ge.Root,ji=J.forwardRef(({className:t,...a},s)=>e.jsx(ge.Item,{ref:s,className:Aa("border-b",t),...a}));ji.displayName="AccordionItem";const Ci=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(ge.Header,{className:"flex",children:e.jsxs(ge.Trigger,{ref:r,className:Aa("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Ci.displayName=ge.Trigger.displayName;const ki=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(ge.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:Aa("pb-4 pt-0",t),children:a})}));ki.displayName=ge.Content.displayName;const Si=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Root,{ref:s,className:Aa("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Si.displayName=be.Root.displayName;const _i=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Image,{ref:s,className:Aa("aspect-square h-full w-full",t),...a}));_i.displayName=be.Image.displayName;const Ai=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Fallback,{ref:s,className:Aa("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));Ai.displayName=be.Fallback.displayName;const Ti=J.forwardRef(({...t},a)=>e.jsx("nav",{ref:a,"aria-label":"breadcrumb",...t}));Ti.displayName="Breadcrumb";const Ei=J.forwardRef(({className:t,...a},s)=>e.jsx("ol",{ref:s,className:Aa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));Ei.displayName="BreadcrumbList";const Pi=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Aa("inline-flex items-center gap-1.5",t),...a}));Pi.displayName="BreadcrumbItem";const Mi=J.forwardRef(({asChild:t,className:s,...r},n)=>{const o=t?a.Slot:"a";return e.jsx(o,{ref:n,className:Aa("transition-colors hover:text-foreground",s),...r})});Mi.displayName="BreadcrumbLink";const Ii=J.forwardRef(({className:t,...a},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Aa("font-normal text-foreground",t),...a}));Ii.displayName="BreadcrumbPage";const Di=({children:t,className:a,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Aa("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...s,children:t??e.jsx(l.ChevronRight,{})});Di.displayName="BreadcrumbSeparator";const Ri=({className:t,...a})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Aa("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Ri.displayName="BreadcrumbEllipsis";const Li=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"}}),zi=J.forwardRef(({className:t,orientation:a,...s},r)=>e.jsx("div",{ref:r,className:Aa(Li({orientation:a}),t),...s}));function Fi({className:t,classNames:a,showOutsideDays:s=!0,...r}){return e.jsx(D.DayPicker,{showOutsideDays:s,className:Aa("p-3 pointer-events-auto",t),locale:ma,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:"flex h-9 w-full items-center justify-center px-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1",button_previous:Aa(Ea({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Aa(Ea({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal w-9",week:"mt-2 flex w-full",day:"group/day relative h-9 w-9 select-none p-0 text-center text-sm [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md focus-within:relative focus-within:z-20",day_button:Aa(Ea({variant:"ghost"}),"h-9 w-9 p-0 font-normal transition-none aria-selected:opacity-100"),range_start:"bg-accent rounded-l-md",range_end:"bg-accent rounded-r-md",range_middle:"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground rounded-md",today:"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...a},components:{Chevron:({orientation:t})=>"left"===t?e.jsx(l.ChevronLeft,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})},...r})}zi.displayName="ButtonGroup",Fi.displayName="Calendar";const Ui={Root:function({children:t,className:a}){return e.jsx("div",{className:Aa("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:s}){return e.jsx(La,{className:Aa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",s),onClick:a,children:e.jsx(qa,{className:"p-4",children:t})})},Field:function({label:t,value:a,className:s}){return e.jsxs("div",{className:Aa("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e.jsx("span",{className:"text-foreground",children:a})]})}};const qi=({shouldScaleBackground:t=!0,...a})=>e.jsx(R.Drawer.Root,{shouldScaleBackground:t,...a});qi.displayName="Drawer";const Oi=R.Drawer.Trigger,Bi=R.Drawer.Portal,$i=R.Drawer.Close,Hi=J.forwardRef(({className:t,...a},s)=>e.jsx(R.Drawer.Overlay,{ref:s,className:Aa("fixed inset-0 z-50 bg-black/80",t),...a}));Hi.displayName=R.Drawer.Overlay.displayName;const Vi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Bi,{children:[e.jsx(Hi,{}),e.jsxs(R.Drawer.Content,{ref:r,className:Aa("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));Vi.displayName="DrawerContent";const Wi=({className:t,...a})=>e.jsx("div",{className:Aa("grid gap-1.5 p-4 text-center sm:text-left",t),...a});Wi.displayName="DrawerHeader";const Gi=({className:t,...a})=>e.jsx("div",{className:Aa("mt-auto flex flex-col gap-2 p-4",t),...a});Gi.displayName="DrawerFooter";const Yi=J.forwardRef(({className:t,...a},s)=>e.jsx(R.Drawer.Title,{ref:s,className:Aa("text-lg font-semibold leading-none tracking-tight",t),...a}));Yi.displayName=R.Drawer.Title.displayName;const Qi=J.forwardRef(({className:t,...a},s)=>e.jsx(R.Drawer.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Qi.displayName=R.Drawer.Description.displayName;const Ki={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))]"},Xi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Zi=ve.Root,Ji=ve.Trigger,el=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,...r},n)=>e.jsx(ve.Content,{ref:n,align:a,sideOffset:s,className:Aa("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",t),...r}));el.displayName=ve.Content.displayName;const tl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Aa("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",t),...a}));tl.displayName="InputGroup";const al=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"}}),sl=J.forwardRef(({className:t,align:a,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Aa(al({align:a}),t),...s}));sl.displayName="InputGroupAddon";const rl=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"}}),nl=J.forwardRef(({className:t,size:a,variant:s="ghost",...r},n)=>e.jsx(Pa,{ref:n,"data-slot":"input-group-button",variant:s,className:Aa(rl({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...r}));nl.displayName="InputGroupButton";const ol=J.forwardRef(({className:t,...a},s)=>e.jsx(Ia,{ref:s,"data-slot":"input-group-control",className:Aa("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));ol.displayName="InputGroupInput";const il=J.forwardRef(({className:t,...a},s)=>e.jsx(Ms,{ref:s,"data-slot":"input-group-control",className:Aa("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));il.displayName="InputGroupTextarea";const ll=J.forwardRef(({className:t,...a},s)=>e.jsx("h1",{ref:s,className:Aa("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));ll.displayName="H1";const cl=J.forwardRef(({className:t,...a},s)=>e.jsx("h2",{ref:s,className:Aa("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));cl.displayName="H2";const dl=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Aa("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));dl.displayName="H3";const ul=J.forwardRef(({className:t,...a},s)=>e.jsx("h4",{ref:s,className:Aa("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));ul.displayName="H4";const ml=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("leading-7 [&:not(:first-child)]:mt-6",t),...a}));ml.displayName="P";const pl=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("text-xl text-muted-foreground",t),...a}));pl.displayName="Lead";const hl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("text-lg font-semibold",t),...a}));hl.displayName="Large";const fl=J.forwardRef(({className:t,...a},s)=>e.jsx("small",{ref:s,className:Aa("text-sm font-medium leading-none",t),...a}));fl.displayName="Small";const xl=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));xl.displayName="Muted";const gl=J.forwardRef(({className:t,...a},s)=>e.jsx("code",{ref:s,className:Aa("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));gl.displayName="InlineCode";const bl=J.forwardRef(({className:t,...a},s)=>e.jsx("blockquote",{ref:s,className:Aa("mt-6 border-l-2 pl-6 italic",t),...a}));bl.displayName="Blockquote";const vl=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Aa("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));vl.displayName="List";const wl=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(we.Root,{ref:r,className:Aa("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[a,e.jsx(_l,{})]}));wl.displayName=we.Root.displayName;const Nl=J.forwardRef(({className:t,...a},s)=>e.jsx(we.List,{ref:s,className:Aa("group flex flex-1 list-none items-center justify-center space-x-1",t),...a}));Nl.displayName=we.List.displayName;const yl=we.Item,jl=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"),Cl=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(we.Trigger,{ref:r,className:Aa(jl(),"group",t),...s,children:[a," ",e.jsx(l.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Cl.displayName=we.Trigger.displayName;const kl=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Content,{ref:s,className:Aa("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 ",t),...a}));kl.displayName=we.Content.displayName;const Sl=we.Link,_l=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:Aa("absolute left-0 top-full flex justify-center"),children:e.jsx(we.Viewport,{className:Aa("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)]",t),ref:s,...a})}));_l.displayName=we.Viewport.displayName;const Al=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Indicator,{ref:s,className:Aa("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",t),...a,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Al.displayName=we.Indicator.displayName;const Tl=({className:t,...a})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Aa("mx-auto flex w-full justify-center",t),...a});Tl.displayName="Pagination";const El=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Aa("flex flex-row items-center gap-1",t),...a}));El.displayName="PaginationContent";const Pl=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Aa("",t),...a}));Pl.displayName="PaginationItem";const Ml=({className:t,isActive:a,size:s="icon",...r})=>e.jsx("a",{"aria-current":a?"page":void 0,className:Aa(Ea({variant:a?"outline":"ghost",size:s}),t),...r});Ml.displayName="PaginationLink";const Il=({className:t,...a})=>e.jsxs(Ml,{"aria-label":"Go to previous page",size:"default",className:Aa("gap-1 pl-2.5",t),...a,children:[e.jsx(l.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Il.displayName="PaginationPrevious";const Dl=({className:t,...a})=>e.jsxs(Ml,{"aria-label":"Go to next page",size:"default",className:Aa("gap-1 pr-2.5",t),...a,children:[e.jsx("span",{children:"Next"}),e.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Dl.displayName="PaginationNext";const Rl=({className:t,...a})=>e.jsxs("span",{"aria-hidden":!0,className:Aa("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Rl.displayName="PaginationEllipsis";const Ll=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.Root,{className:Aa("grid gap-2",t),...a,ref:s}));Ll.displayName=Ne.Root.displayName;const zl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.Item,{ref:s,className:Aa("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",t),...a,children:e.jsx(Ne.Indicator,{className:"flex items-center justify-center",children:e.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));zl.displayName=Ne.Item.displayName;const Fl=ye.Panel,Ul=te.Root,ql=te.Trigger,Ol=te.Close,Bl=te.Portal,$l=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{className:Aa("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",t),...a,ref:s}));$l.displayName=te.Overlay.displayName;const Hl=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"}}),Vl=J.forwardRef(({side:t="right",className:a,children:s,...r},n)=>e.jsxs(Bl,{children:[e.jsx($l,{}),e.jsxs(te.Content,{ref:n,className:Aa(Hl({side:t}),a),...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(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Vl.displayName=te.Content.displayName;const Wl=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Aa("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Ba,{className:"mt-2"})]});Wl.displayName="SheetHeader";const Gl=({className:t,...a})=>e.jsx("div",{className:Aa("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});Gl.displayName="SheetBody";const Yl=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsx("div",{className:Aa("flex flex-row justify-end gap-2",t),...s,children:a})]});Yl.displayName="SheetFooter";const Ql=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Aa("text-lg font-semibold text-foreground",t),...a}));Ql.displayName=te.Title.displayName;const Kl=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Kl.displayName=te.Description.displayName;const Xl="sidebar:state",Zl=J.createContext(null);function Jl(){const e=J.useContext(Zl);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const ec=J.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const c=Cn(),[d,u]=J.useState(!1),[m,p]=J.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Xl);return null!==e?"true"===e:t}return t}),h=a??m,f=J.useCallback(e=>{const t="function"==typeof e?e(h):e;s?s(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Xl,String(t))},[s,h]),x=J.useCallback(()=>c?u(e=>!e):f(e=>!e),[c,f,u]);J.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const g=h?"expanded":"collapsed",b=J.useMemo(()=>({state:g,open:h,setOpen:f,isMobile:c,openMobile:d,setOpenMobile:u,toggleSidebar:x}),[g,h,f,c,d,u,x]);return e.jsx(Zl.Provider,{value:b,children:e.jsx(Js,{delayDuration:0,children:e.jsx("div",{className:Aa("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":"4rem",...n},ref:l,...i,children:o})})})});ec.displayName="SidebarProvider";const tc=J.forwardRef(({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=Jl();return"none"===s?e.jsx("div",{className:Aa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?e.jsx(Ul,{open:d,onOpenChange:u,...o,children:e.jsxs(Vl,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsx(Ql,{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:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?s:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:Aa("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"===a||"inset"===a?"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:Aa("duration-200 fixed inset-y-0 z-30 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"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),...o,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col overflow-visible 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})})]})});tc.displayName="Sidebar";const ac=J.forwardRef(({className:t,onClick:a,...s},r)=>{const{toggleSidebar:n}=Jl();return e.jsxs(Pa,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Aa("h-7 w-7",t),onClick:e=>{a?.(e),n()},...s,children:[e.jsx(l.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ac.displayName="SidebarTrigger";const sc=J.forwardRef(({className:t,...a},s)=>{const{toggleSidebar:r}=Jl();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Aa("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",t),...a})});sc.displayName="SidebarRail";const rc=J.forwardRef(({className:t,...a},s)=>e.jsx("main",{ref:s,className:Aa("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",t),...a}));rc.displayName="SidebarInset";const nc=J.forwardRef(({className:t,...a},s)=>e.jsx(Ia,{ref:s,"data-sidebar":"input",className:Aa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));nc.displayName="SidebarInput";const oc=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Aa("flex flex-col gap-2 p-2",t),...a}));oc.displayName="SidebarHeader";const ic=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Aa("flex flex-col gap-2 p-2",t),...a}));ic.displayName="SidebarFooter";const lc=J.forwardRef(({className:t,...a},s)=>e.jsx(Ba,{ref:s,"data-sidebar":"separator",className:Aa("mx-2 w-auto bg-sidebar-border",t),...a}));lc.displayName="SidebarSeparator";const cc=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Aa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));cc.displayName="SidebarContent";const dc=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Aa("relative flex w-full min-w-0 flex-col p-2",t),...a}));dc.displayName="SidebarGroup";const uc=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"div";return e.jsx(o,{ref:n,"data-sidebar":"group-label",className:Aa("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",t),...r})});uc.displayName="SidebarGroupLabel";const mc=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"button";return e.jsx(o,{ref:n,"data-sidebar":"group-action",className:Aa("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",t),...r})});mc.displayName="SidebarGroupAction";const pc=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Aa("w-full text-sm",t),...a}));pc.displayName="SidebarGroupContent";const hc=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Aa("flex w-full min-w-0 flex-col gap-1",t),...a}));hc.displayName="SidebarMenu";const fc=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Aa("group/menu-item relative",t),...a}));fc.displayName="SidebarMenuItem";const xc=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-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary 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"}}),gc=J.forwardRef(({asChild:t=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},c)=>{const d=t?a.Slot:"button",{isMobile:u,state:m}=Jl(),p=e.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Aa(xc({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:p}),e.jsx(ar,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});gc.displayName="SidebarMenuButton";const bc=J.forwardRef(({className:t,asChild:s=!1,showOnHover:r=!1,...n},o)=>{const i=s?a.Slot:"button";return e.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Aa("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",t),...n})});bc.displayName="SidebarMenuAction";const vc=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Aa("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",t),...a}));vc.displayName="SidebarMenuBadge";const wc=J.forwardRef(({className:t,showIcon:a=!1,...s},r)=>{const n=J.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Aa("rounded-md h-8 flex gap-2 px-2 items-center",t),...s,children:[a&&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}})]})});wc.displayName="SidebarMenuSkeleton";const Nc=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Aa("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",t),...a}));Nc.displayName="SidebarMenuSub";const yc=J.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));yc.displayName="SidebarMenuSubItem";const jc=J.forwardRef(({asChild:t=!1,size:s="md",isActive:r,className:n,...o},i)=>{const l=t?a.Slot:"a";return e.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Aa("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),...o})});jc.displayName="SidebarMenuSubButton";const Cc=J.forwardRef(({className:t,value:a,defaultValue:s,...r},n)=>{const o=a||s||[0];return e.jsxs(je.Root,{ref:n,value:a,defaultValue:s,className:Aa("relative flex w-full touch-none select-none items-center",t),...r,children:[e.jsx(je.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(je.Range,{className:"absolute h-full bg-primary"})}),o.map((t,a)=>e.jsx(je.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"},a))]})});Cc.displayName=je.Root.displayName;const kc=Ce.Menu,Sc=Ce.Group,_c=Ce.Portal,Ac=Ce.Sub,Tc=Ce.RadioGroup,Ec=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Root,{ref:s,className:Aa("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",t),...a}));Ec.displayName=Ce.Root.displayName;const Pc=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Trigger,{ref:s,className:Aa("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",t),...a}));Pc.displayName=Ce.Trigger.displayName;const Mc=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Aa("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",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Mc.displayName=Ce.SubTrigger.displayName;const Ic=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.SubContent,{ref:s,className:Aa("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",t),...a}));Ic.displayName=Ce.SubContent.displayName;const Dc=J.forwardRef(({className:t,align:a="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:o,align:a,alignOffset:s,sideOffset:r,className:Aa("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",t),...n})}));Dc.displayName=Ce.Content.displayName;const Rc=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Aa("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",a&&"pl-8",t),...s}));Rc.displayName=Ce.Item.displayName;const Lc=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...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(l.Check,{className:"h-4 w-4"})})}),a]}));Lc.displayName=Ce.CheckboxItem.displayName;const zc=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.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(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));zc.displayName=Ce.RadioItem.displayName;const Fc=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Aa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Fc.displayName=Ce.Label.displayName;const Uc=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Uc.displayName=Ce.Separator.displayName;const qc=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});qc.displayname="MenubarShortcut";const Oc={light:"",dark:".dark"},Bc=J.createContext(null);function $c(){const e=J.useContext(Bc);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Hc=J.forwardRef(({id:t,className:a,children:s,config:r,...n},o)=>{const i=J.useId(),l=`chart-${t||i.replace(/:/g,"")}`;return e.jsx(Bc.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:o,className:Aa("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",a),...n,children:[e.jsx(Vc,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});Hc.displayName="Chart";const Vc=({id:t,config:a})=>{const s=Object.entries(a).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Oc).map(([e,a])=>`\n${a} [data-chart=${t}] {\n${s.map(([t,a])=>{const s=a.theme?.[e]||a.color;return s?` --color-${t}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Wc=ke.Tooltip,Gc=J.forwardRef(({active:t,payload:a,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:c,formatter:d,color:u,nameKey:m,labelKey:p},h)=>{const{config:f}=$c(),x=J.useMemo(()=>{if(n||!a?.length)return null;const[t]=a,s=Kc(f,t,`${p||t?.dataKey||t?.name||"value"}`),r=p||"string"!=typeof i?s?.label:f[i]?.label||i;return l?e.jsx("div",{className:Aa("font-medium",c),children:l(r,a)}):r?e.jsx("div",{className:Aa("font-medium",c),children:r}):null},[i,l,a,n,c,f,p]);if(!t||!a?.length)return null;const g=1===a.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Aa("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:x,e.jsx("div",{className:"grid gap-1.5",children:a.map((t,a)=>{const s=`${m||t.name||t.dataKey||"value"}`,n=Kc(f,t,s),i=u||t.payload?.fill||t.color;return e.jsx("div",{className:Aa("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:d&&void 0!==t?.value&&t.name?d(t.value,t.name,t,a,t.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!o&&e.jsx("div",{className:Aa("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":i,"--color-border":i}}),e.jsxs("div",{className:Aa("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?x:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||t.name})]}),void 0!==t.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof t.value?t.value.toLocaleString():t.value})]})]})},t.dataKey||a)})})]})});Gc.displayName="ChartTooltip";const Yc=ke.Legend,Qc=J.forwardRef(({className:t,hideIcon:a=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=$c();return s?.length?e.jsx("div",{ref:o,className:Aa("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${n||t.dataKey||"value"}`,r=Kc(i,t,s);return e.jsxs("div",{className:Aa("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!a?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),r?.label]},t.value)})}):null});function Kc(e,t,a){if("object"!=typeof t||null===t)return;const s="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let r=a;return a in t&&"string"==typeof t[a]?r=t[a]:s&&a in s&&"string"==typeof s[a]&&(r=s[a]),r in e?e[r]:e[a]}Qc.displayName="ChartLegend";const Xc=({onClick:t,isActive:a,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:t,disabled:s,title:n,className:Aa("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),Zc=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Jc({label:t,onClick:a,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:c=!1,menuAlign:d="end",className:u}){const m=i||c;if(!(r.length>0))return e.jsxs(Pa,{variant:n,size:o,disabled:m,onClick:a,className:u,children:[c?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]});return e.jsxs("div",{className:Aa("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(Pa,{variant:n,size:o,disabled:m,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[c?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]}),e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:n,size:o,disabled:m,className:Aa("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e.jsx(l.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e.jsx(Ws,{align:d,className:"min-w-[160px]",children:r.map(t=>{const a=t.icon;return e.jsxs(Gs,{onClick:t.onClick,disabled:t.disabled,className:Aa("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]})}function ed({onEdit:a,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:c=[],renderAs:d="dropdown",variant:u="default"}){const{t:m}=v.useTranslation(),p=t.useMemo(()=>{const e=[];return a&&o&&e.push({key:"edit",icon:l.Edit,label:m("edit","Editar"),onClick:a,variant:"default"}),r&&e.push({key:"toggle-status",icon:n?l.PowerOff:l.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),c.forEach(t=>{!1!==t.show&&e.push({key:`custom-${t.label}`,icon:t.icon,label:t.label,onClick:t.onClick,variant:t.variant||"default",disabled:t.disabled,disabledReason:t.disabledReason})}),s&&i&&e.push({key:"delete",icon:l.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),e},[a,s,r,n,o,i,c,m]);return 0===p.length?null:"dropdown"===d?e.jsx(Js,{delayDuration:200,children:e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:e.jsx(l.EllipsisVertical,{size:"compact"===u?14:16})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(t=>t.disabled?e.jsxs(sr,{disabledReason:t.disabledReason,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},t.key):e.jsxs(Gs,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},t.key))})]})}):e.jsx("div",{className:"flex items-center gap-1",children:p.map(t=>e.jsxs(Pa,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:t.onClick,className:"compact"===u?"h-7 px-2":"",children:[t.icon&&e.jsx(t.icon,{size:"compact"===u?14:16}),"compact"!==u&&e.jsx("span",{className:"ml-1",children:t.label})]},t.key))})}function td(e){const t=j.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const s=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(s)}}}const ad=t.memo(({variant:a="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:o,companies:i,alias:c,isAuthenticated:d,logout:u,switchUnit:m}=Nn(),p=i?.[0]||null,h=c?i?.find(e=>e.alias===c):p,f=i||[],x=r||h||p||p,g=t.useCallback(e=>{n?n(e):m(e)},[n,m]),b=t.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===x?.alias),s=t.filter(e=>e.alias!==x?.alias);return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...s]:s},[f,x?.alias]);if(!d||!o)return null;return"dropdown"===a?e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{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:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(Ws,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(Bs,{children:[e.jsxs(Hs,{children:[e.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(Vs,{children:b.map(t=>e.jsxs(Gs,{onClick:()=>g(t),className:t.alias===x?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),t.name,t.alias===x?.alias&&e.jsx(Ds,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:u,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):e.jsxs(La,{className:s,children:[e.jsx(za,{children:e.jsx(Fa,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(qa,{className:"space-y-4",children:[e.jsx(()=>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(l.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:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:x.name})]})}),b.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",b.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[b.slice(0,3).map(t=>e.jsx(Ds,{variant:t.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>g(t),children:t.name},t.alias)),b.length>3&&e.jsxs(Ds,{variant:"outline",className:"text-xs",children:["+",b.length-3]})]})]})]}),{}),e.jsx(Ba,{}),e.jsxs(Pa,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),sd=t.createContext({});function rd({children:a,config:s}){const r=t.useMemo(()=>{const e=Yr(),t=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:t}},[s?.navigation,s?.appName]);return e.jsx(sd.Provider,{value:r,children:a})}function nd(){return t.useContext(sd)}function od(e,t){if(!e)return"Página";const a=e.find(e=>e.path===t);if(a)return a.label;const s=e.find(e=>t.startsWith(e.path+"/"));return s?.label||"Página"}function id(e,a){const[s,r]=t.useState(e),n=t.useRef(),o=t.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return t.useEffect(()=>(o(),n.current=setTimeout(()=>{r(e)},a),o),[e,a,o]),[s,o]}const ld=t.memo(function({actions:a}){const s=j.useLocation(),{navigation:r,appName:n}=nd(),o=od(r,s.pathname),{metadata:i,headerActions:c}=Uo(),{setOpenMobile:d}=Jl(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:f,switchUnit:x}=Nn(),g=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[b,v]=j.useSearchParams(),[w,N]=t.useState(()=>b.get("search")||""),[y,C]=id(w,Xr.debounceDelay);t.useEffect(()=>{if(!p)return;const e=new URLSearchParams(b);y?(e.set("search",y),e.set("page","1")):e.delete("search"),v(e)},[y,v,p]);const k=r?.find(e=>e.path===s.pathname)||r?.find(e=>s.pathname.startsWith(e.path+"/")),S=i.title||o,_=i.subtitle||k?.complementaryText||"Detalhes do item";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.jsx(Pa,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0",onClick:()=>d(!0),children:e.jsx(l.Menu,{size:20})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:S})}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:_})]}),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(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ia,{placeholder:"Pesquisar",value:w,onChange:e=>(e=>{N(e)})(e.target.value),className:"w-full pl-10 pr-8"}),w&&e.jsx(Pa,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{C(),N("");const e=new URLSearchParams(b);e.delete("search"),e.delete("page"),v(e)},title:"Limpar busca",children:e.jsx(l.X,{size:14})})]}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:e.jsx(l.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(c||a)&&e.jsx("div",{className:"flex items-center gap-2",children:c||a}),(void 0).VITE_WIKI_URL&&e.jsx(Pa,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>_a((void 0).VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(ad,{variant:"dropdown",selectedUnit:g,onUnitChange:x})})]})]})})}),cd=({key:e,enabled:t,checkFn:a,staleTime:s=3e5,gcTime:r=6e5})=>y.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),dd=`https://${Gr().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,ud={logo:tn.isQualiex?`${dd}/logo-qualiex.svg`:`${dd}/logo.svg`,smallLogo:tn.isQualiex?`${dd}/small-forlogic.svg`:`${dd}/small.svg`},md=ud.logo,pd=ud.smallLogo;function hd({open:a,appName:s}){const[r,n]=t.useState(!1);return e.jsxs(Js,{children:[e.jsx(oc,{className:"p-0 gap-0",children:a?e.jsxs("div",{className:"flex flex-col gap-3 pl-2",children:[e.jsx("div",{className:"flex items-center h-10",children:e.jsx("img",{src:ud.logo,alt:"Logo",className:"h-8 max-w-full object-contain"})}),e.jsxs(Pa,{variant:"secondary",size:"default",className:"h-10 gap-2 px-3 justify-start w-full",onClick:()=>n(!0),children:[e.jsx(l.Grip,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s||"Módulos"})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center w-full gap-3",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-8",children:e.jsx("img",{src:ud.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})}),e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("button",{className:"flex items-center justify-center h-10 w-8 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>n(!0),children:e.jsx(l.Grip,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:s||"Módulos"})})]})]})}),e.jsx(vi,{open:r,onOpenChange:n})]})}function fd({config:t,isCollapsed:a=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:o="Criar",triggerIcon:i=l.Plus,variant:c="button"}=t;if(!n||0===n.length)return null;if("split-button"===c){const t=n[0],o=t.icon||i,l=n.slice(1).map(e=>({id:e.id,label:e.label,icon:e.icon,onClick:e.onClick,disabled:e.disabled}));if(a){const a=e.jsx(Pa,{onClick:t.onClick,disabled:s||t.disabled,className:Aa("justify-center px-2 w-full",r),variant:"outline",size:"default",children:e.jsx(o,{className:"h-4 w-4 shrink-0"})});return e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:a}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})}return e.jsx(Jc,{label:t.label,onClick:t.onClick,icon:o,actions:l,variant:"outline",disabled:s||t.disabled,className:Aa("w-full",r),menuAlign:"start"})}const d=(t,s,r=!1)=>e.jsxs(e.Fragment,{children:[t,!a&&s&&e.jsx("span",{className:"truncate",children:s}),!a&&r&&e.jsx(l.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const t=n[0],o=t.icon||i,l=s||t.disabled,c=e.jsx(Pa,{onClick:t.onClick,disabled:l,className:Aa("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(o,{className:"h-4 w-4 shrink-0"}),t.label)});return a?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:c}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]}):c}const u=e.jsx(Pa,{disabled:s,className:Aa("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(i,{className:"h-4 w-4 shrink-0"}),o,!0)});return e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:a?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:u}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:o})})]}):u}),e.jsx(Ws,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:n.map(t=>{const a=t.icon;return e.jsxs(Gs,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}const xd="forlogic-sidebar-pinned",gd=()=>{try{const e=localStorage.getItem(xd);return!!e&&JSON.parse(e)}catch{return!1}};function bd({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,c]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[d,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!d)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),c(r),o?.(r)},r=()=>{u(!1),c(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[d,e,a,s,l,n,o]),t.useEffect(()=>(d?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d,e]),{width:l,isDragging:d,dragRef:m,handleMouseDown:p}}const vd=t.createContext(void 0);function wd(){const e=t.useContext(vd);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Nd({config:a,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{open:i,setOpen:c,setOpenMobile:d}=Jl(),u=j.useLocation(),{alias:m,user:p}=Nn(),{appName:h}=nd(),{hasOpenModal:f}=wd(),[x,g]=t.useState(gd),b=Cn(),v=t.useCallback(()=>{b&&d(!1)},[b,d]),w=r?bd({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:i}):null;t.useEffect(()=>{c(!!x)},[x,c]);const N=e=>u.pathname===e||u.pathname.startsWith(e+"/");return e.jsxs(tc,{collapsible:"icon",className:Aa("app-sidebar bg-background border-r border-border py-4",i?"px-3":"px-1.5"),style:w&&i?{width:`${w.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(hd,{open:i,appName:h}),a?.moduleActions&&a.moduleActions.actions.length>0&&e.jsx("div",{className:"py-3",children:e.jsx(Js,{children:e.jsx(fd,{config:a.moduleActions,isCollapsed:!i,isDisabled:f})})}),e.jsxs("div",{className:"relative py-5",children:[e.jsx(Ba,{}),e.jsx("div",{className:Aa("absolute top-1/2 -translate-y-1/2 z-[100] hidden md:block",i?"-right-6":"-right-[18px]"),children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("button",{onClick:()=>{const e=!x;g(e),(e=>{try{localStorage.setItem(xd,JSON.stringify(e))}catch{}})(e)},className:"h-6 w-6 flex items-center justify-center rounded-full bg-primary hover:bg-primary/90 shadow-md transition-colors",children:i?e.jsx(l.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:i?"Recolher":"Expandir"})})]})})]}),e.jsx(cc,{children:s||e.jsx(dc,{className:"p-0",children:e.jsx(pc,{children:e.jsx(hc,{className:"gap-1",children:e.jsx(Js,{children:a?.navigation?.map((t,a)=>{const s=({item:t,index:a})=>{const r=`${t.path}-${a}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:o}=cd({key:r,enabled:Boolean(t.permissionCheck&&m&&p?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),c=t.permissionCheck&&!n,d=o?l.Loader2:c?l.Lock:t.icon;c||t.complementaryText;return t.children&&t.children.length>0?i?e.jsx(Qo,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(fc,{children:[e.jsx(Ko,{asChild:!0,children:e.jsx(gc,{size:"default",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(d,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label}),e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),e.jsx(Xo,{children:e.jsx(Nc,{children:t.children.map((t,a)=>e.jsx(s,{item:t,index:a},t.path))})})]})},t.path):e.jsx(fc,{children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("div",{className:Aa("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors cursor-pointer","hover:bg-accent hover:text-accent-foreground"),children:e.jsx(d,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path):e.jsx(fc,{children:c||o?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:i?e.jsx(gc,{size:"default",className:"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:"flex items-center justify-center h-8 w-8",children:e.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsx("div",{className:"flex items-center justify-center h-8 w-8 mx-auto rounded-md opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:o?"Verificando acesso...":"Acesso restrito"})})]}):i?e.jsx(gc,{asChild:!0,isActive:N(t.path),size:"default",children:e.jsxs(j.Link,{to:t.path,className:"flex w-full items-center gap-3",onClick:v,children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(d,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx(j.Link,{to:t.path,onClick:v,className:Aa("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",N(t.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:e.jsx(d,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path)};return e.jsx(s,{item:t,index:a},t.path)})})})})})}),r&&w&&i&&e.jsx("div",{ref:w.dragRef,onMouseDown:w.handleMouseDown,className:Aa("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-['']",w.isDragging&&"bg-primary/40")})]})}const yd=t.memo(function({children:a,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||e.jsx(Nd,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(rd,{config:r,children:e.jsx(Fo,{children:e.jsx(ec,{defaultOpen:!1,style:i,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,e.jsxs("main",{className:"relative z-0 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(ld,{})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-muted/30",children:a})]})]})})})})});class jd{static async sendEmail(e){const t=Ur(),{data:a,error:s}=await t.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 a}}const Cd=jd;function kd({open:a,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:c,currentMemberIds:d=[]}){const[u,m]=t.useState([]),[p,h]=t.useState(!1),[f,x]=t.useState(""),{data:g=[],isLoading:b}=vo({enabled:a}),v=t.useMemo(()=>{let e=[...g];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",s=t.userName?.toLowerCase()||"";return a.localeCompare(s)}),f){const t=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[g,f]),w=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},N=1===u.length,y=u.length>0;return e.jsx(es,{open:a,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl",variant:"form",children:[e.jsx(is,{showSeparator:!0,children:e.jsxs(ds,{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs(ls,{children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{placeholder:"Pesquisar...",value:f,onChange:e=>x(e.target.value),className:"pl-9"})]}),e.jsx(vr,{className:"h-[400px] pr-4",children:b?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e.jsx(fr,{className:"h-16 w-full"},a))}):0===v.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(l.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:v.map(t=>{const a=t.userId===c,s=d.includes(t.userId||""),r=u.includes(t.userId||"");return e.jsxs("div",{className:Aa("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e.jsx(Ps,{checked:r,onCheckedChange:()=>w(t.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:t.userName}),a&&e.jsx(l.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(a||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a?"Gestor":"Membro"})]},t.userId)})})})]}),e.jsxs(cs,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:u.length>0&&e.jsxs("span",{children:[u.length," selecionado(s)"]})}),N&&o&&e.jsxs(Pa,{onClick:async()=>{if(o&&1===u.length){h(!0);try{await o(u[0],r),m([])}finally{h(!1)}}},disabled:p,variant:"outline",children:[e.jsx(l.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),y&&i&&e.jsxs(Pa,{onClick:async()=>{if(i&&0!==u.length){h(!0);try{await i(u,r),m([])}finally{h(!1)}}},disabled:p,children:[e.jsx(l.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",u.length>1?"Membros":"Membro"]})]})]})})}function Sd({place:a,level:s=0,manageAccessConfig:r}){const[n,o]=t.useState(!1),[i,c]=t.useState(!1),d=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Qo,{open:n,onOpenChange:o,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:[d?e.jsxs(Ko,{className:"flex items-center gap-2 flex-1",children:[e.jsx(l.ChevronRight,{className:Aa("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.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(l.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(Ds,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(ed,{customActions:[{label:"Gerenciar Acessos",icon:l.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),d&&e.jsx(Xo,{children:a.subPlaces.map(t=>e.jsx(Sd,{place:t,level:s+1,manageAccessConfig:r},t.id))})]}),0===s&&e.jsx(Ba,{}),r&&e.jsx(kd,{open:i,onOpenChange:c,placeId:a.id,placeName:a.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(a.id),currentMemberIds:r.getCurrentMemberIds?.(a.id)})]})}const _d=new class{get baseUrl(){return Jr()}async makeApiCall(e,t,a){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Dr.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=t.get(e.id);if(e.parentId){const r=t.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):a.push(s)}else a.push(s)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(a){if(await $r.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(s){return Rr.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Rr.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function Ad(e){const t=new Map,a=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};t.set(e.id,s),a.set(e.id_user,s)}),e.forEach(e=>{const r=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(r)}s.push(r)});const r=(e,t)=>{e.level=t,e.children.forEach(e=>r(e,t+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",s=t.name||t.id_user||t.email||"";return a.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Td(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function Ed(){const{alias:e,isAuthenticated:t}=Nn(),a=Dr.getAccessToken(),{data:s=[]}=vo({enabled:!0});return y.useQuery({queryKey:["leadership",e],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Ur(),{data:r,error:n}=await t.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 o={};s.forEach(e=>{o[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const i=r.map(e=>({...e,name:o[e.id_user]?.name||"[Não encontrado]",email:o[e.id_user]?.email||"",subordinatesCount:r.filter(t=>t.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 t=o[e];i.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:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e).length})}),Ad(i)},enabled:!!a&&!!e&&t&&s.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const Pd="common";function Md(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(t.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await zd(a,e,t.id_user,t.id_leader);const{data:r,error:n}=await a.schema(Pd).from("leaders").insert({alias:e,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",e]}),i.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function Id(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(!t.users.length)throw new Error(s("select_at_least_one","Selecione pelo menos um liderado"));const r=t.users.map(e=>e.id_user),{data:n}=await a.schema(Pd).from("leaders").select("id_user").eq("alias",e).in("id_user",r).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(s("users_already_leaders",`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`))}for(const c of t.users){if(t.id_leader&&c.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await zd(a,e,c.id_user,t.id_leader)}const o=t.users.map(a=>({alias:e,id_user:a.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await a.schema(Pd).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:a=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_added_success",`${a?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{i.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function Dd(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await a.schema(Pd).from("leaders").select("id_user").eq("id",t.id).eq("alias",e).single();if(!r)throw new Error(s("leader_not_found","Líder não encontrado"));if(r.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await zd(a,e,r.id_user,t.id_leader,t.id);const{data:n,error:o}=await a.schema(Pd).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",e).select().single();if(o)throw o;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function Rd(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await a.schema(Pd).from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function Ld(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const n=r.map(e=>e.id_user),o=await Promise.all([a.schema(Pd).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",t),a.schema(Pd).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:i,error:l},{data:c,error:d}]=o;if(l)throw l;if(d)throw d;const u=i||[],m=c||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),f=m.filter(e=>e.id_leader!==t),x=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!x.has(e.id_user));for(const s of f)await zd(a,e,s.id_user,t,s.id);for(const w of g){if(w.id_user===t)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await zd(a,e,w.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(a.schema(Pd).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",e))}if(f.length){const s=f.map(e=>e.id);b.push(a.schema(Pd).from("leaders").update({id_leader:t}).in("id",s).eq("alias",e))}if(g.length){const s=g.map(a=>({alias:e,id_user:a.id_user,id_leader:t,is_active:!0,is_removed:!1}));b.push(a.schema(Pd).from("leaders").insert(s))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:f.length,created:g.length}},onSuccess:a=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${a.created} adicionados, ${a.updated} atualizados, ${a.unlinked} removidos)`))},onError:e=>{i.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function zd(e,t,a,s,r){const{data:n,error:o}=await e.schema(Pd).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const i=r?n.filter(e=>e.id!==r):n,l=new Set;let c=s;for(;c;){if(l.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===a)throw new Error("Esta associação criaria um ciclo na hierarquia");l.add(c);const e=i.find(e=>e.id_user===c);c=e?.id_leader||null}}function Fd({leader:t,expandedIds:a,onToggleExpand:s,onEdit:r}){const n=a.has(t.id),o=t.children.length>0,i=32*t.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:`${i}px`},children:[o?e.jsx("button",{onClick:()=>s(t.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(l.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(t)},className:"font-medium hover:text-primary hover:underline text-left",children:t.name||t.id_user||t.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:t.subordinatesCount||0})})]}),o&&n&&t.children.map(t=>e.jsx(Fd,{leader:t,expandedIds:a,onToggleExpand:s,onEdit:r},t.id))]})}var Ud=function(e,t){for(var a={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!a[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];a[o]={message:i.message,type:i.code}}else a[o]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[o].types,c=l&&l[s.code];a[o]=p.appendErrors(o,t,a,r,c?[].concat(c,s.message):s.message)}e.shift()}return a},qd=function(e,t,a){return void 0===a&&(a={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](s,t)).then(function(e){return n.shouldUseNativeValidation&&X.validateFieldsNatively({},n),{errors:{},values:a.raw?s:e}})}catch(l){return o(l)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:X.toNestErrors(Ud(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const Od=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string()).min(1,"Selecione pelo menos um liderado")}),Bd=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string())});function $d({value:a,onChange:s,excludeUserIds:r=[],error:n}){const{data:o=[],isLoading:i}=vo(),[c,d]=t.useState(""),u=t.useRef(null),m=t.useRef(0),p=o.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=c.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const s=a.includes(e.userId),r=a.includes(t.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",o=t.userName||t.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[p]),i?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ia,{placeholder:"Buscar usuário...",value:c,onChange:e=>d(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===p.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Buscar usuário..."}):e.jsx("div",{className:"space-y-2",children:p.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ps,{id:t.userId,checked:a.includes(t.userId),onCheckedChange:()=>{return e=t.userId,u.current&&(m.current=u.current.scrollTop),void(a.includes(e)?s(a.filter(t=>t!==e)):s([...a,e]));var e}}),e.jsx(Ra,{htmlFor:t.userId,className:"flex-1 cursor-pointer",children:t.userName||t.userEmail})]},t.userId))})}),a.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.length," selecionado(s)"]}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Hd({leader:a,prefilledLeaderId:s,onSuccess:r}){const{alias:n}=Nn(),o=!!a,i=a?.id.startsWith("virtual-"),c=Id(),d=Md(),u=Dd(),m=Ld(),h=Rd(),{data:f=[]}=Ed(),{data:x=[]}=vo(),[g,b]=t.useState(""),v=Td(f).map(e=>e.id_user),w=o?Td(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user):[],N=p.useForm({resolver:qd(o?Bd:Od),defaultValues:{id_leader:s||(o?a?.id_leader:null)||null,id_users:o?w:[]}});t.useEffect(()=>{if(a){const e=Td(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user);N.reset({id_leader:a.id_leader||null,id_users:e})}else s?N.reset({id_leader:s,id_users:[]}):N.reset({id_leader:null,id_users:[]})},[n,a?.id,a?.id_user,a?.id_leader,s,f]);const y=c.isPending||d.isPending||u.isPending||m.isPending||h.isPending,j=N.watch("id_leader"),C=N.watch("id_users"),k=o?[a.id_user,...v.filter(e=>e!==a.id_user&&!C.includes(e)&&!w.includes(e))]:[j,...v.filter(e=>!C.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:N.handleSubmit(async e=>{try{if(o)if(i){await d.mutateAsync({id_user:a.id_user,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{await u.mutateAsync({id:a.id,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:t})}r?.()}catch(t){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Ra,{children:"Líder"}),e.jsx(Ia,{value:x.find(e=>e.userId===a.id_user)?.userName||a.name||a.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:"Superior Imediato"}),e.jsxs(Ns,{value:j||"none",onValueChange:e=>N.setValue("id_leader","none"===e?null:e),children:[e.jsx(Cs,{children:e.jsx(js,{placeholder:"Selecione..."})}),e.jsxs(_s,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ia,{placeholder:"Buscar superior...",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(vr,{className:"h-[200px]",children:[e.jsx(Ts,{value:"none",children:"[Nenhum]"}),x.filter(e=>{const t=o?e.userId!==a.id_user:!C.includes(e.userId),s=!g||e.userName?.toLowerCase().includes(g.toLowerCase());return t&&s}).sort((e,t)=>{const a=e.userName||e.userEmail||"",s=t.userName||t.userEmail||"";return a.localeCompare(s)}).map(t=>e.jsx(Ts,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${n}`),N.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:N.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:"Subordinados *"}),e.jsx($d,{value:C,onChange:e=>N.setValue("id_users",e),excludeUserIds:k,error:N.formState.errors.id_users?.message},`users-multiselect-${n}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Pa,{type:"submit",disabled:y||!o&&0===C.length,children:y&&!h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Atualizando...":"Salvando..."]}):o?"Atualizar":"Criar"}),o&&!j&&0===C.length&&e.jsxs($a,{children:[e.jsx(Ha,{asChild:!0,children:e.jsx(Pa,{type:"button",variant:"destructive",disabled:y,className:"ml-auto",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),e.jsxs(Ga,{children:[e.jsxs(Ya,{children:[e.jsx(Ka,{children:"Confirmar remoção"}),e.jsx(Xa,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),e.jsxs(Qa,{children:[e.jsx(Ja,{children:"Cancelar"}),e.jsx(Za,{onClick:async()=>{if(a)try{await h.mutateAsync(a.id),r?.()}catch(e){}},children:"Remover"})]})]})]})]})]})}function Vd({open:t,onOpenChange:a,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(os,{variant:"form",className:"sm:max-w-[500px]",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(ds,{children:n})}),e.jsx(ls,{children:e.jsx(Hd,{leader:s,prefilledLeaderId:r,onSuccess:()=>a(!1)})})]})})}const Wd="leadership-expanded-nodes",Gd=(e,t)=>{try{localStorage.setItem(`${Wd}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function Yd(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:l,onError:c}=e||{};return{upload:async(e,t)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);try{const a={...o,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){const t=a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t);if(!t)throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const s=await r(e,a);return i.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),l?.(s),s}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw i.toast.error("Erro",{description:e.message}),c?.(e),e}finally{s(!1)}},deleteMedia:async(e,t)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,t),i.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw i.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:a}}function Qd(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function Kd(e,t){const a=Qd(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function Xd(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function Zd(e,t){const a=Xd(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function Jd(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function eu(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function tu(e,t){return e/t}function au(){const{alias:e}=Nn(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let t=!1;return(async()=>{n(!0);try{const a=Ur(),{data:r,error:n}=await a.schema("common").from("sign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();t||s(r)}catch(a){t||s(null)}finally{t||n(!1)}})(),()=>{t=!0}},[e]);const o=t.useCallback(async(t,a)=>{if(!e)throw new Error("Alias not available");const r=Ur(),{data:n,error:o}=await r.schema("common").from("sign_configs").upsert({alias:e,api_key:t,environment:a,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e]);return{config:a,isLoading:r,saveConfig:o}}const su=(void 0).VITE_SUPABASE_URL,ru=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function nu(e,t,a){const s=Dr.getSupabaseToken(),r={"Content-Type":"application/json",apikey:ru};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${su}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:t,data:a})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const ou={async createEnvelopeWithSigner(e){const t="d4sign"===e.provider?"d4sign":"clicksign",a="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await nu(t,a,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const t="d4sign"===e.provider?"d4sign":"clicksign";return(await nu(t,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let iu=null;function lu(){return window.Clicksign?Promise.resolve():iu||(iu=new Promise((e,t)=>{const a=document.createElement("script");a.src="https://cdn-public-library.clicksign.com/embedded/embedded.min-2.1.0.js",a.onload=()=>e(),a.onerror=()=>t(new Error("Falha ao carregar script do Clicksign")),document.head.appendChild(a)}),iu)}const cu="clicksign-container";function du({signerId:a,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const i=t.useRef(null),[c,d]=t.useState(!0),[u,m]=t.useState(null);return t.useEffect(()=>{let e=!1;return i.current&&(i.current.unmount(),i.current=null),m(null),d(!0),lu().then(()=>{if(e)return;const t=new window.Clicksign(a);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(cu),t.on("loaded",function(){d(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const t=e,a=document.getElementById(cu);a&&t?.data?.height&&(a.style.height=t.data.height+"px")}),t.on("error",function(e){d(!1),n?.(e instanceof Error?e:new Error("Erro no widget de assinatura"))}),t.on("closed",function(){o?.()}),i.current=t}).catch(t=>{e||(m("Falha ao carregar o script de assinatura."),d(!1),n?.(t))}),()=>{e=!0,i.current&&(i.current.unmount(),i.current=null)}},[a,s]),e.jsxs("div",{className:"relative h-full",children:[c&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-destructive",children:u})}),e.jsx("div",{id:cu,style:{height:"600px"}})]})}function uu({documentKey:a,signerEmail:s,signerName:r,keySigner:n,environment:o,onSign:i,onError:c}){const d=t.useRef(null),[u,m]=t.useState("loading"),[p,h]=t.useState(null),f="production"===o?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",x=(()=>{const e=new URLSearchParams({email:s,display_name:r||"",disable_preview:"0"});return n&&e.set("key_signer",n),`${f}/${a}?${e.toString()}`})(),g=t.useCallback(e=>"signed"===e.data?(m("ready"),void i?.()):"wrong-data"===e.data?(m("error"),h("O signatário reportou dados incorretos."),void c?.(new Error("O signatário reportou dados incorretos"))):void 0,[i,c]);t.useEffect(()=>(window.addEventListener("message",g,!1),()=>{window.removeEventListener("message",g,!1)}),[g]);const b=t.useCallback(()=>{"loading"===u&&m("ready")},[u]);return"error"===u?e.jsxs(Do,{variant:"danger",className:"my-4",children:[e.jsx(Ro,{children:"Erro ao carregar documento"}),e.jsx(Lo,{children:p||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):e.jsxs("div",{className:"relative h-full",children:["loading"===u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),e.jsx("iframe",{ref:d,id:"d4sign-container",src:x,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return v.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return v.useTranslation}}),exports.i18n=A,exports.AUTH_CONFIG=Qr,exports.AccessDeniedDialog=wi,exports.Accordion=yi,exports.AccordionContent=ki,exports.AccordionItem=ji,exports.AccordionTrigger=Ci,exports.ActionButton=Ma,exports.ActionMenu=ed,exports.ActionMenuItems=eo,exports.Alert=Do,exports.AlertDescription=Lo,exports.AlertDialog=$a,exports.AlertDialogAction=Za,exports.AlertDialogCancel=Ja,exports.AlertDialogContent=Ga,exports.AlertDialogDescription=Xa,exports.AlertDialogFooter=Qa,exports.AlertDialogHeader=Ya,exports.AlertDialogOverlay=Wa,exports.AlertDialogPortal=Va,exports.AlertDialogTitle=Ka,exports.AlertDialogTrigger=Ha,exports.AlertTitle=Ro,exports.AppHeader=ld,exports.AppLayout=yd,exports.AppSidebar=Nd,exports.AuthErrorInterceptor=Br,exports.AuthProvider=wn,exports.AuthService=xn,exports.Avatar=Si,exports.AvatarFallback=Ai,exports.AvatarImage=_i,exports.Badge=Ds,exports.BaseForm=No,exports.Blockquote=bl,exports.BodyContent=function({breadcrumbs:t,children:a,className:s}){return e.jsxs("div",{className:Aa("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[t&&t.length>0&&e.jsx(Ti,{className:"mb-4",children:e.jsx(Ei,{children:t.map((a,s)=>{const r=s===t.length-1;return e.jsxs(J.Fragment,{children:[s>0&&e.jsx(Di,{}),e.jsx(Pi,{children:r||!a.href?e.jsx(Ii,{children:a.label}):a.asChild&&a.children?e.jsx(Mi,{asChild:!0,children:a.children}):e.jsx(Mi,{asChild:!0,children:e.jsx(j.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${s}`)})})}),e.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=Ti,exports.BreadcrumbEllipsis=Ri,exports.BreadcrumbItem=Pi,exports.BreadcrumbLink=Mi,exports.BreadcrumbList=Ei,exports.BreadcrumbPage=Ii,exports.BreadcrumbSeparator=Di,exports.Button=Pa,exports.ButtonGroup=zi,exports.CRUD_CONFIG=Kr,exports.Calendar=Fi,exports.CallbackPage=()=>{const{processCallback:a}=Nn(),s=j.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await a()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),s(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(e){localStorage.removeItem("auth_return_url"),n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[a,s]);const c=async()=>{i(!0),n(null);try{await a()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},d=()=>{window.location.href="/"};return r?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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsxs(Fa,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(qa,{className:"space-y-4",children:[e.jsx(Do,{variant:"danger",children:e.jsx(Lo,{children:r})}),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(Pa,{onClick:c,disabled:o,className:"flex-1",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ls,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(Pa,{onClick:d,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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(qa,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ls,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=La,exports.CardContent=qa,exports.CardDescription=Ua,exports.CardFooter=Oa,exports.CardHeader=za,exports.CardSkeleton=Dn,exports.CardTitle=Fa,exports.ChartContainer=Hc,exports.ChartLegend=Yc,exports.ChartLegendContent=Qc,exports.ChartStyle=Vc,exports.ChartTooltip=Wc,exports.ChartTooltipContent=Gc,exports.Checkbox=Ps,exports.Collapsible=Qo,exports.CollapsibleContent=Xo,exports.CollapsibleTrigger=Ko,exports.ColorPicker=fo,exports.ComboTree=function({multiple:a=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:c,emptyMessage:d,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:f,className:x,maxDisplayedBadges:g,popoverContainer:b,onOpen:w,onClose:N}){const{t:y}=v.useTranslation(),[j,C]=t.useState(!1),[k,S]=t.useState(""),[_,A]=t.useState(new Set),T=o||y("select_placeholder","Selecione..."),E=d||y("no_results","Nenhum resultado encontrado"),P=u||y("search_placeholder","Pesquisar..."),M=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),I=t.useMemo(()=>{if(!b)return;let e=b,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[b]),D=t.useMemo(()=>yr(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,t){const a=new Set,s=Nr(t);function r(e){if(!e.children||0===e.children.length)return Nr(e.label).includes(s);let t=!1;for(const a of e.children)r(a)&&(t=!0);return t&&a.add(e.value),t||Nr(e.label).includes(s)}for(const n of e)r(n);return a}(s,k):new Set,[s,k]),L=k?R:_,z=t.useCallback(e=>{k||A(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[k]),F=t.useMemo(()=>M.map(e=>({value:e,label:jr(s,e)||e})),[M,s]),U=e=>{C(e),e?w?.():(S(""),N?.())},q=t.useCallback(e=>{if(n)if(a){const t=M.includes(e)?M.filter(t=>t!==e):[...M,e];n(t)}else n(e),C(!1)},[n,a,M]),O=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?M.filter(t=>t!==e):"")},B=g?F.slice(0,g):F,$=g&&F.length>g?F.length-g:0;if(h)return e.jsxs("div",{className:Aa("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const H="string"==typeof f?f:f instanceof Error?f.message:f?y("error_loading","Erro ao carregar"):void 0;return H?e.jsxs("div",{className:Aa("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&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(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:H})]})]}):e.jsxs("div",{className:Aa("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:j,onOpenChange:U,modal:!1,children:[e.jsx(nr,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":j,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),U(!j))},className:Aa("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",m&&"pointer-events-none opacity-50 cursor-not-allowed",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[c&&e.jsx(c,{className:"h-4 w-4"}),T]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[B.map(t=>e.jsxs(Ds,{variant:"secondary",className:"gap-1 pr-1",children:[t.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&&O(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>O(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),$>0&&e.jsxs(Ds,{variant:"outline",className:"gap-1",children:["+",$]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pa,{variant:"outline",role:"combobox","aria-expanded":j,disabled:m,className:Aa("w-full justify-between min-h-10 h-auto",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[c&&e.jsx(c,{className:"h-4 w-4"}),T]}):e.jsxs("span",{className:"flex items-center gap-2",children:[c&&e.jsx(c,{className:"h-4 w-4"}),F[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxs(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:I,collisionBoundary:I,children:[e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(l.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("input",{className:"flex h-10 w-full bg-transparent py-3 px-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",placeholder:P,value:k,onChange:e=>S(e.target.value)}),k&&e.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(vr,{className:"max-h-[300px]",children:e.jsx("div",{role:"tree",className:"p-1",children:0===D.length?e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:y("no_search_results","Nenhum resultado encontrado")}):e.jsx(kr,{nodes:D,level:0,expandedIds:L,onToggleExpand:z,selectedValues:M,onSelect:q})})})]})]})]})},exports.Combobox=br,exports.Command=ir,exports.CommandDialog=({children:t,...a})=>e.jsx("div",{...a,children:e.jsx(ir,{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:t})}),exports.CommandEmpty=dr,exports.CommandGroup=ur,exports.CommandInput=lr,exports.CommandItem=pr,exports.CommandList=cr,exports.CommandSeparator=mr,exports.CommandShortcut=hr,exports.ContentContainer=function({title:t,subtitle:a,children:s,className:r,hasHeader:n=!0}){const o=t||a;return e.jsxs("div",{className:Aa("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-hidden",r),children:[n&&o&&e.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[t&&e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:t}),a&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),s&&e.jsx("div",{className:Aa("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Un,exports.ContextMenuCheckboxItem=Qn,exports.ContextMenuContent=Gn,exports.ContextMenuGroup=On,exports.ContextMenuItem=Yn,exports.ContextMenuLabel=Xn,exports.ContextMenuPortal=Bn,exports.ContextMenuRadioGroup=Hn,exports.ContextMenuRadioItem=Kn,exports.ContextMenuSeparator=Zn,exports.ContextMenuShortcut=Jn,exports.ContextMenuSub=$n,exports.ContextMenuSubContent=Wn,exports.ContextMenuSubTrigger=Vn,exports.ContextMenuTrigger=qn,exports.CoreProviders=function({children:a,queryClient:s,moduleAlias:r,moduleAccessGuardProps:n}){const[o]=t.useState(()=>new y.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),i=s??o;return e.jsx(Zo,{children:e.jsx(v.I18nextProvider,{i18n:A,children:e.jsx(y.QueryClientProvider,{client:i,children:e.jsx(wn,{children:e.jsx(Ho,{children:e.jsx(Go,{moduleAlias:r,children:e.jsx(Ni,{...n,children:a})})})})})})})},exports.CrudActionBar=co,exports.CrudGrid=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:l,customRowActions:c,enableBulkActions:d=!1,onNew:u,newButtonLabel:m,showNewButton:p=!0,customActions:h=[],hideActionBar:f,showActionBar:x=!0,showSearch:g=!1,searchValue:b,onSearchChange:v,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:y,filters:j,gridColumns:C=3,renderCard:k,viewMode:S,onViewModeChange:_,listCardRenderer:A,gridCardRenderer:T,showViewToggle:E=!1})=>{const{setSearchVisible:P}=Nn(),M=void 0!==f?!f:x;t.useEffect(()=>{if(!g)return P(!0),()=>P(!1)},[P,g]);const I=u||h.length>0||g||d||j||E,D=y||(()=>{a.bulkDelete?.(a.selectedIds)}),R=S||"grid",L="list"===R,z={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"}[L?1:C],F=M&&I?e.jsx(co,{onNew:u,newButtonLabel:m,showNewButton:p,showSearch:g,searchValue:b,onSearchChange:v,searchPlaceholder:w,showBulkActions:d,selectedCount:a.selectedIds.length,bulkActions:N,onBulkDelete:D,onClearSelection:a.clearSelection,customActions:h,filters:j,viewMode:R,onViewModeChange:_,showViewToggle:E,availableViewModes:["list","grid"]}):null;return a.isLoading?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(Dn,{count:6})})]}):0===a.entities.length?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:Aa("grid gap-4",z),children:a.entities.map(t=>{const u=(e=>L&&A?A(e):!L&&T?T(e):k?k(e):null)(t);return e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:u?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),d?a.selectItem(t.id):r?.(t)},children:u}):e.jsx(La,{className:Aa("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",d&&a.selectedIds.includes(t.id)&&"bg-muted ring-2 ring-primary",L&&"flex-row"),onClick:e=>{e.stopPropagation(),d?a.selectItem(t.id):r?.(t)},children:e.jsxs(qa,{className:Aa("p-4",L&&"flex items-center gap-4 w-full"),children:[d&&e.jsx("div",{className:Aa(L?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>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:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key)))}),(r||n||l)&&e.jsx("div",{onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[d&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>e.jsxs("div",{className:Aa("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:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})]})]})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id)})})})]})},exports.CrudPageInternal=To,exports.CrudPagination=jo,exports.CrudPrimitiveFilterBar=function({searchValue:t="",onSearchChange:a,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=v.useTranslation(),c=t||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{type:"text",placeholder:i("search","Pesquisar"),value:t,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e.jsx("div",{className:"vertical"===o?"w-full":"",children:t},a)),n&&c&&r&&e.jsxs(Pa,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(l.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})},exports.CrudPrimitivePagination=yo,exports.CrudPrimitiveTable=function({data:a,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:c,isLoading:d=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:f,onSelectAll:x,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:w,storageKey:N}){const{t:y}=v.useTranslation(),j=u||y("no_items_found","Nenhum item encontrado"),{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:_}=so({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,onResize:w,enabled:b}),A=t.useMemo(()=>{if(b)return s.map(e=>`${C[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return s.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[s,b,C]);return d?e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e.jsx(fr,{className:"h-12 w-full"},a))})}):0===a.length?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:j})})}):e.jsx("div",{className:"flex-1 overflow-auto "+(k?"select-none":""),children:e.jsxs(kn,{className:m,children:[e.jsx(Sn,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Tn,{children:[p&&e.jsx(En,{className:"w-[40px]",children:e.jsx(Ps,{checked:g,onCheckedChange:x,"aria-label":y("select_all","Selecionar todos")})}),s.map((t,a)=>{const s=b&&!1!==t.resizable,i=S===String(t.key);return e.jsxs(En,{className:`${t.className||""} relative`,style:{width:A[a]},children:[t.sortable&&o?e.jsxs("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(c=String(t.key),r!==c?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:t.header}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>_(String(t.key),e),isDragging:i})]},String(t.key));var c}),c&&e.jsx(En,{className:"w-[80px] text-right",children:y("actions","Ações")})]})}),e.jsx(_n,{children:a.map(t=>e.jsxs(Tn,{onClick:()=>i?.(t),className:(i?"cursor-pointer":"")+" relative",children:[p&&e.jsx(Pn,{children:e.jsx(Ps,{checked:h.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`${y("select_all","Selecionar todos")} ${t.id}`})}),s.map(a=>e.jsx(Pn,{className:a.className,children:e.jsx(zn,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),c&&e.jsx(Pn,{className:"text-right",onClick:e=>e.stopPropagation(),children:c(t)})]},t.id))})]})})},exports.CrudTable=mo,exports.D4SignWidget=uu,exports.DATETIME_FORMATS=ha,exports.DEFAULT_DATETIME_FORMAT=ga,exports.DEFAULT_LOCALE=xa,exports.DEFAULT_TIMEZONE=ba,exports.DataList=Ui,exports.DatePicker=function({date:t,onDateChange:a,placeholder:s="Selecione uma data",disabled:r=!1,className:n,disabledDates:i}){return e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",disabled:r,className:Aa("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",n),children:[e.jsx(l.Calendar,{className:"mr-2 h-4 w-4"}),t?o.format(t,"d 'de' MMMM 'de' yyyy",{locale:ma}):e.jsx("span",{children:s})]})}),e.jsx(or,{className:"w-auto p-0",align:"start",children:e.jsx(Fi,{mode:"single",selected:t,onSelect:a,disabled:i,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=es,exports.DialogBody=ls,exports.DialogClose=ss,exports.DialogContent=os,exports.DialogDescription=us,exports.DialogFooter=cs,exports.DialogHeader=is,exports.DialogOverlay=rs,exports.DialogPortal=as,exports.DialogTitle=ds,exports.DialogTrigger=ts,exports.DisabledMenuItem=sr,exports.DocumentSigner=function({file:a,onDocumentSigned:s,onError:r,showEventLog:n=!1}){const{user:o,alias:c}=Nn(),{config:d,isLoading:u}=au(),{t:m}=v.useTranslation(),[p,h]=t.useState(null),[f,x]=t.useState(!1),[g,b]=t.useState(null),[w,N]=t.useState("sandbox"),[y,j]=t.useState("clicksign"),[C,k]=t.useState(null),[S,_]=t.useState(null),[A,T]=t.useState(!1),[E,P]=t.useState(0),[M,I]=t.useState(!1),[D,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),F=t.useCallback(e=>{n&&R(t=>[...t,`[${(new Date).toLocaleTimeString()}] ${e}`])},[n]),U=t.useCallback(async e=>{if(h(e),b(null),k(null),_(null),F(`Arquivo selecionado: ${e.name}`),c&&o){x(!0);try{const t=d?.provider??"clicksign";j(t),F(`Provedor resolvido: ${t}`);const a=new FileReader,s=await new Promise((t,s)=>{a.onload=()=>{const e=a.result;t(e)},a.onerror=s,a.readAsDataURL(e)});F(`Criando envelope para assinatura via ${t}...`);const n=await ou.createEnvelopeWithSigner({alias:c,contentBase64:s,filename:e.name,signerEmail:o.email||"",signerName:o.name||"",provider:t});F(`Envelope criado: ${n.envelope_id}`),k({envelope_id:n.envelope_id,document_id:n.document_id,signer_email:n.signer_email,key_signer:n.signer_id}),N(n.environment),j(n.provider||t),"d4sign"===t?(F("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(n.document_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):n.signer_id?(F(`Signer ID obtido: ${n.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(n.signer_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):(F("AVISO: Nenhum signer ID disponível."),i.toast.error(m("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),r?.(new Error("Signer ID não disponível")))}catch(t){const e=t instanceof Error?t:new Error(m("sign_process_error","Erro ao processar documento")),a=e.message||"";a.includes("MONTHLY_LIMIT_REACHED")?(F("Limite mensal de assinaturas atingido"),i.toast.error(m("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(F(`Erro: ${a}`),i.toast.error(a)),r?.(e)}finally{x(!1)}}},[c,o,F,r,d]);t.useEffect(()=>{a&&c&&o&&!u&&a!==z.current&&(z.current=a,U(a))},[a,c,o,u,U]);const q=t.useCallback(async()=>{if(!C||!c)return;T(!0),P(0),I(!1),F("Buscando documento assinado...");for(let t=1;t<=6;t++){P(t),F(`Tentativa ${t}/6...`);try{const e=await ou.getSignedDocument({alias:c,envelopeId:C.envelope_id,documentId:C.document_id,provider:y});if(e.download_url)return F("Documento assinado disponível para download"),_(e.download_url),void T(!1)}catch(e){F(`Erro na tentativa ${t}: ${e instanceof Error?e.message:"Erro desconhecido"}`)}t<6&&(F("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}F("Não foi possível obter o documento assinado após 6 tentativas."),T(!1),I(!0)},[C,c,F,y]),O=t.useCallback(async()=>{F("Documento assinado com sucesso!"),i.toast.success(m("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&c&&(s?.({success:!0,provider:y,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:g||"",environment:w}),await q())},[F,s,C,g,c,w,y,q]);if(!c)return e.jsx(La,{className:"border-amber-200 bg-amber-50",children:e.jsx(qa,{className:"flex items-start gap-3 py-6",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800",children:m("sign_auth_required","Autenticação necessária")}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:m("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const B="d4sign"===y?"D4Sign":"Clicksign",$=()=>n&&D.length>0?e.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:D.map((t,a)=>e.jsx("div",{children:t},a))}):null;return C&&!g&&(S||A||M)?e.jsxs("div",{className:"space-y-4",children:[e.jsx(La,{className:"border-green-200 bg-green-50",children:e.jsxs(qa,{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(l.CheckCircle2,{className:"h-12 w-12 text-green-600"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-green-800",children:m("sign_signed_success","Documento assinado com sucesso!")}),e.jsx("p",{className:"text-sm text-green-700 mt-1",children:p?.name})]}),A?e.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),m("sign_preparing_doc","Preparando documento assinado...")," (",m("sign_attempt","tentativa")," ",E,"/6)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_waiting_provider",`Aguardando processamento pelo ${B}...`)})]}):S?e.jsx(Pa,{asChild:!0,variant:"default",className:"gap-2",children:e.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(l.Download,{className:"h-4 w-4"}),m("sign_download_signed","Baixar documento assinado")]})}):M?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),e.jsxs(Pa,{variant:"secondary",className:"gap-2",onClick:q,children:[e.jsx(l.RefreshCw,{className:"h-4 w-4"}),m("sign_try_again","Tentar novamente")]})]}):null]})}),e.jsx($,{})]}):g?e.jsxs("div",{className:"space-y-4",children:["d4sign"===y?e.jsx(uu,{documentKey:g,signerEmail:C?.signer_email||o?.email||"",signerName:o?.name,keySigner:C?.key_signer,environment:w,onSign:O,onError:r}):e.jsx(du,{signerId:g,environment:w,onSign:O,onError:r}),e.jsx($,{})]}):a&&(f||u)?e.jsx(La,{children:e.jsxs(qa,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&"application/pdf"===t.type?U(t):i.toast.error(m("sign_select_pdf","Selecione um arquivo PDF"))}}),f?e.jsx(La,{children:e.jsxs(qa,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsx(La,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:e.jsxs(qa,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(l.Upload,{className:"h-8 w-8 text-muted-foreground"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:m("sign_select_pdf","Selecione um arquivo PDF")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),e.jsx($,{})]})},exports.Drawer=qi,exports.DrawerClose=$i,exports.DrawerContent=Vi,exports.DrawerDescription=Qi,exports.DrawerFooter=Gi,exports.DrawerHeader=Wi,exports.DrawerOverlay=Hi,exports.DrawerPortal=Bi,exports.DrawerTitle=Yi,exports.DrawerTrigger=Oi,exports.DropdownMenu=Fs,exports.DropdownMenuCheckboxItem=Ys,exports.DropdownMenuContent=Ws,exports.DropdownMenuGroup=qs,exports.DropdownMenuItem=Gs,exports.DropdownMenuLabel=Ks,exports.DropdownMenuPortal=Os,exports.DropdownMenuRadioGroup=$s,exports.DropdownMenuRadioItem=Qs,exports.DropdownMenuSeparator=Xs,exports.DropdownMenuShortcut=Zs,exports.DropdownMenuSub=Bs,exports.DropdownMenuSubContent=Vs,exports.DropdownMenuSubTrigger=Hs,exports.DropdownMenuTrigger=Us,exports.EmailService=jd,exports.EmptyState=Ln,exports.EntitySelect=br,exports.ErrorBoundary=Zo,exports.FilterBar=Ao,exports.Form=ms,exports.FormControl=bs,exports.FormDescription=vs,exports.FormField=({...t})=>e.jsx(ps.Provider,{value:{name:t.name},children:e.jsx(p.Controller,{...t})}),exports.FormItem=xs,exports.FormLabel=gs,exports.FormMessage=ws,exports.FormSkeleton=function({fields:t=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-4 w-24"}),e.jsx(fr,{className:"h-10 w-full"})]},a)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(fr,{className:"h-10 w-20"}),e.jsx(fr,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:t,cols:a="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Aa("grid",Ki[a],Xi[s],r),children:t})},exports.H1=ll,exports.H2=cl,exports.H3=dl,exports.H4=ul,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(fr,{className:"h-8 w-8 rounded-full"}),e.jsx(fr,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(fr,{className:"h-8 w-8"}),e.jsx(fr,{className:"h-8 w-24"})]})]})},exports.HoverCard=Zi,exports.HoverCardContent=el,exports.HoverCardTrigger=Ji,exports.IconPicker=go,exports.ImageEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:c,uploadOptions:d}){const[u,m]=t.useState(a||{alignment:"center",allowDownload:!1}),p=t.useRef(null),{upload:h,uploading:f}=Yd({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),x=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ia,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:u.imageUrl||"",onChange:e=>x("imageUrl",e.target.value),className:"flex-1"}),o&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await h(t),a={...u,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),u.imageFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",u.imageFile," (",Math.round((u.imageSize||0)/1024)," KB)"]})]}),u.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===u.alignment?"justify-start":"right"===u.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:u.imageUrl,alt:u.alt||"Preview",style:{width:u.width?`${u.width}px`:"auto",height:u.height?`${u.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"caption",children:"Legenda"}),e.jsx(Ms,{id:"caption",placeholder:"Legenda",value:u.caption||"",onChange:e=>x("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"alt",children:"Texto Alternativo"}),e.jsx(Ia,{id:"alt",placeholder:"Texto Alternativo",value:u.alt||"",onChange:e=>x("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Alinhamento"}),e.jsxs(Ns,{value:u.alignment||"center",onValueChange:e=>x("alignment",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"left",children:"Esquerda"}),e.jsx(Ts,{value:"center",children:"Centro"}),e.jsx(Ts,{value:"right",children:"Direita"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"width",children:"Largura"}),e.jsx(Ia,{id:"width",type:"number",placeholder:"px",value:u.width||"",onChange:e=>x("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"height",children:"Altura"}),e.jsx(Ia,{id:"height",type:"number",placeholder:"px",value:u.height||"",onChange:e=>x("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"allowDownload",checked:u.allowDownload||!1,onCheckedChange:e=>x("allowDownload",!0===e)}),e.jsx(Ra,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Pa,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pa,{onClick:()=>{u.imageUrl?r(u):i.toast.error("Erro",{description:"Nenhuma imagem selecionada"})},disabled:!u.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:t,className:a="",style:s}){if(!t.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${a}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&e.jsxs("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(l.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=gl,exports.Input=Ia,exports.InputGroup=tl,exports.InputGroupAddon=sl,exports.InputGroupButton=nl,exports.InputGroupInput=ol,exports.InputGroupTextarea=il,exports.LOGO_CONFIG=tn,exports.Label=Ra,exports.Large=hl,exports.Lead=pl,exports.LeaderRow=Fd,exports.LeadershipDialog=Vd,exports.LeadershipForm=Hd,exports.LeadershipPage=function(){const{alias:a}=Nn(),{data:s,isLoading:r,error:n,refetch:o}=Ed(),[i,c]=t.useState(()=>a?(e=>{try{const t=localStorage.getItem(`${Wd}-${e}`);if(t)return new Set(JSON.parse(t))}catch(n){}return new Set})(a):new Set),[d,u]=t.useState(!1),[m,p]=t.useState(),[h,f]=t.useState(null),x=(s?Td(s):[]).filter(e=>"[Não encontrado]"!==e.name).length;t.useEffect(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${Wd}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);c(t),Gd(a,t)}}},[s,a]);const g=e=>{c(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),a&&Gd(a,s),s})},b=e=>{p(e),f(null),u(!0)};return r?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(l.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})]})}):n?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(Pa,{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(Pa,{size:"sm",onClick:()=>{p(void 0),f(null),u(!0)},children:[e.jsx(l.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(Pa,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=Td(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);c(t),a&&Gd(a,t)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(Pa,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;c(e),a&&Gd(a,e)},disabled:!s||0===s.length,children:[e.jsx(l.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(l.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[x," usuário",1!==x?"s":""," associado",1!==x?"s":""]})]})})]})}),s&&0!==s.length?e.jsx(vr,{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:s.map(t=>e.jsx(Fd,{leader:t,expandedIds:i,onToggleExpand:g,onEdit:b},t.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(Vd,{open:d,onOpenChange:()=>{u(!1),p(void 0),f(null)},leader:m,prefilledLeaderId:h,title:m?"Editar Nome":h?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${a}`)]})},exports.List=vl,exports.LoadingState=function({isLoading:t,children:a,className:s,type:r="spinner",size:n="md"}){return t?"overlay"===r?e.jsxs("div",{className:Aa("relative",s),children:[a,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ls,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Aa("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Aa("flex items-center justify-center py-8",s),children:e.jsx(Ls,{size:n})}):e.jsx(e.Fragment,{children:a})},exports.LocaleProvider=Ho,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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(qa,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(Pa,{onClick:async()=>{Zr()?await xn.loginDev():xn.loginProd()},className:"w-full",size:"lg",children:Zr()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=an,exports.MODULES_DATA=ai,exports.ManageAccessModal=kd,exports.Menubar=Ec,exports.MenubarCheckboxItem=Lc,exports.MenubarContent=Dc,exports.MenubarGroup=Sc,exports.MenubarItem=Rc,exports.MenubarLabel=Fc,exports.MenubarMenu=kc,exports.MenubarPortal=_c,exports.MenubarRadioGroup=Tc,exports.MenubarRadioItem=zc,exports.MenubarSeparator=Uc,exports.MenubarShortcut=qc,exports.MenubarSub=Ac,exports.MenubarSubContent=Ic,exports.MenubarSubTrigger=Mc,exports.MenubarTrigger=Pc,exports.ModalStateProvider=function({children:a}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.add(e),a})},[]),l=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.delete(e),a})},[]),c=t.useCallback(e=>{o(e)},[]),d=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:d,registerModal:i,unregisterModal:l,setHasOpenModal:c}),[s,d,i,l,c]);return e.jsx(vd.Provider,{value:u,children:a})},exports.ModuleAccessGuard=Ni,exports.ModuleGrid=gi,exports.ModuleOfferContent=function({title:t,description:a,image:s,icon:r,ctaLabel:n="Quero conhecer mais",onCtaClick:o,children:i}){return e.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(s||r)&&e.jsx("div",{className:"flex items-center justify-center",children:s?e.jsx("img",{src:s,alt:t,className:"max-h-48 w-auto object-contain rounded-lg"}):r?e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(r,{className:"h-12 w-12 text-primary"})}):null}),e.jsxs("div",{className:"space-y-3 max-w-lg",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground",children:t}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]}),i?e.jsx("div",{className:"w-full",children:i}):o?e.jsxs(Pa,{onClick:o,size:"lg",className:"gap-2",children:[e.jsx(l.Sparkles,{className:"h-4 w-4"}),n]}):null]})},exports.ModuleProvider=Go,exports.ModulesContent=bi,exports.ModulesDialog=vi,exports.ModulesFooterCards=hi,exports.MultiSelect=br,exports.Muted=xl,exports.NavigationMenu=wl,exports.NavigationMenuContent=kl,exports.NavigationMenuIndicator=Al,exports.NavigationMenuItem=yl,exports.NavigationMenuLink=Sl,exports.NavigationMenuList=Nl,exports.NavigationMenuTrigger=Cl,exports.NavigationMenuViewport=_l,exports.NavigationProvider=rd,exports.OnboardingDialog=ui,exports.P=ml,exports.PROD_PROJECT_ID=Hr,exports.PageBreadcrumb=function({items:t,maxItems:a=3,className:s}){const r=t.length>a?[t[0],...t.slice(-(a-1))]:t,n=t.length>a;return e.jsx(Ti,{className:s,children:e.jsx(Ei,{children:r.map((t,a)=>{const s=0===a,r=n&&1===a;return e.jsxs(Pi,{children:[!s&&e.jsx(Di,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Ri,{}),e.jsx(Di,{})]}),t.isCurrentPage?e.jsx(Ii,{children:t.label}):e.jsx(Mi,{asChild:!0,children:e.jsx(j.Link,{to:t.href||"/",children:t.label})})]},t.label)})})})},exports.PageMetadataProvider=Fo,exports.Pagination=Tl,exports.PaginationContent=El,exports.PaginationEllipsis=Rl,exports.PaginationItem=Pl,exports.PaginationLink=Ml,exports.PaginationNext=Dl,exports.PaginationPrevious=Il,exports.PlaceCard=Sd,exports.PlacesList=function({places:t,isLoading:a,manageAccessConfig:s}){return a?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:"Carregando dados..."})]})}):t&&0!==t.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(t=>e.jsx(Sd,{place:t,manageAccessConfig:s},t.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(l.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=rr,exports.PopoverContent=or,exports.PopoverTrigger=nr,exports.Progress=ii,exports.ProtectedRoute=({children:a})=>{const{isAuthenticated:s,isLoading:r}=Nn();if(t.useEffect(()=>{if(r)return;if(s)return;if(Dr.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const n=Zr(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{n?await xn.loginDev():xn.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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(qa,{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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(qa,{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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(qa,{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:Zr()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:a})},exports.QUALIEX_CONFIG=en,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=dn,exports.QualiexErrorInterceptor=$r,exports.QualiexUserField=wo,exports.RadioGroup=Ll,exports.RadioGroupItem=zl,exports.ResizableHandle=({withHandle:t,className:a,...s})=>e.jsx(ye.PanelResizeHandle,{className:Aa("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",a),...s,children:t&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(l.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Fl,exports.ResizablePanelGroup=({className:t,...a})=>e.jsx(ye.PanelGroup,{className:Aa("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...a}),exports.RichTextEditor=({value:a,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:o="300px",showModeToggle:i=!0,showVariableHint:c=!0,className:d})=>{const[u,m]=t.useState("visual"),p=$.useEditor({extensions:[H.configure({heading:{levels:[1,2,3]}}),V,W.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:a||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});J.useEffect(()=>{p&&a!==p.getHTML()&&p.commands.setContent(a||"")},[a,p]);const h=t.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?p.chain().focus().extendMarkRange("link").setLink({href:t}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Aa("space-y-2",d),children:[i&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Pa,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(l.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(Pa,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(l.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(Pa,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(l.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&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 cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||p?.commands.focus()},children:[e.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(Xc,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(l.Heading1,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(l.Heading2,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(l.Heading3,{className:"h-4 w-4"})}),e.jsx(Zc,{}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(l.Bold,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(l.Italic,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(l.Underline,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(l.Strikethrough,{className:"h-4 w-4"})}),e.jsx(Zc,{}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(l.List,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(l.ListOrdered,{className:"h-4 w-4"})}),e.jsx(Zc,{}),e.jsx(Xc,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(l.Highlighter,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(l.Link,{className:"h-4 w-4"})}),e.jsx(Zc,{}),e.jsx(Xc,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(l.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(Zc,{}),e.jsx(Xc,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(l.Undo,{className:"h-4 w-4"})}),e.jsx(Xc,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(l.Redo,{className:"h-4 w-4"})})]}),e.jsx($.EditorContent,{editor:p,className:Aa("prose prose-sm max-w-none focus:outline-none","[&_.ProseMirror]:p-4","[&_.ProseMirror]:min-h-full","[&_.ProseMirror]:cursor-text","[&_.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:o}})]}),"code"===u&&e.jsx("textarea",{value:a||"",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:o},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:o},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:a||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Xr,exports.SUPPORTED_LOCALES=pa,exports.ScrollArea=vr,exports.ScrollBar=wr,exports.Select=Ns,exports.SelectContent=_s,exports.SelectGroup=ys,exports.SelectItem=Ts,exports.SelectLabel=As,exports.SelectScrollDownButton=Ss,exports.SelectScrollUpButton=ks,exports.SelectSearch=br,exports.SelectSeparator=Es,exports.SelectTrigger=Cs,exports.SelectValue=js,exports.Separator=Ba,exports.Sheet=Ul,exports.SheetBody=Gl,exports.SheetClose=Ol,exports.SheetContent=Vl,exports.SheetDescription=Kl,exports.SheetFooter=Yl,exports.SheetHeader=Wl,exports.SheetOverlay=$l,exports.SheetPortal=Bl,exports.SheetTitle=Ql,exports.SheetTrigger=ql,exports.Sidebar=tc,exports.SidebarActionTrigger=fd,exports.SidebarContent=cc,exports.SidebarFooter=ic,exports.SidebarGroup=dc,exports.SidebarGroupAction=mc,exports.SidebarGroupContent=pc,exports.SidebarGroupLabel=uc,exports.SidebarHeader=hd,exports.SidebarInput=nc,exports.SidebarInset=rc,exports.SidebarMenu=hc,exports.SidebarMenuAction=bc,exports.SidebarMenuBadge=vc,exports.SidebarMenuButton=gc,exports.SidebarMenuItem=fc,exports.SidebarMenuSkeleton=wc,exports.SidebarMenuSub=Nc,exports.SidebarMenuSubButton=jc,exports.SidebarMenuSubItem=yc,exports.SidebarProvider=ec,exports.SidebarRail=sc,exports.SidebarSeparator=lc,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(fr,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(fr,{className:"h-4 w-4"}),e.jsx(fr,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=ac,exports.SignConfigForm=function({onSaved:a}){const{config:s,isLoading:r,saveConfig:n}=au(),{t:o}=v.useTranslation(),[c,d]=t.useState(""),[u,m]=t.useState("sandbox"),[p,h]=t.useState(!1);return t.useEffect(()=>{!r&&s&&(d(s.api_key),m(s.environment))},[s,r]),r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[e.jsx(l.CheckCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_configured","Assinatura digital configurada para esta unidade")})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_not_configured","Assinatura digital ainda não configurada para esta unidade")})]}),e.jsxs(La,{children:[e.jsx(za,{children:e.jsx(Fa,{className:"text-base",children:o("sign_config_title","Configuração de Assinatura Digital")})}),e.jsx(qa,{children:e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),c.trim()){h(!0);try{await n(c.trim(),u),i.toast.success(o("sign_config_saved","Configuração de assinatura salva com sucesso")),a?.()}catch(t){i.toast.error(o("sign_config_save_error","Erro ao salvar configuração de assinatura"))}finally{h(!1)}}else i.toast.error(o("sign_api_key_required","Informe a API Key do provedor de assinatura"))},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"sign-api-key",children:"API Key"}),e.jsx(Ia,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder","Insira a API Key do provedor de assinatura"),value:c,onChange:e=>d(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:o("sign_environment","Ambiente")}),e.jsxs(Ns,{value:u,onValueChange:e=>m(e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"sandbox",children:"Sandbox (Testes)"}),e.jsx(Ts,{value:"production",children:"Produção"})]})]})]}),e.jsxs(Pa,{type:"submit",disabled:p,children:[p&&e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config","Atualizar Configuração"):o("sign_save_config","Salvar Configuração")]})]})})]})]})},exports.SignWidget=du,exports.Skeleton=fr,exports.Slider=Cc,exports.Small=fl,exports.SonnerToaster=zs,exports.Spinner=Ls,exports.SplitButton=Jc,exports.Stack=_o,exports.StepSelector=function({currentStep:t,totalSteps:a,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){const c=Array.from({length:a},(e,t)=>t+1),d=e=>!(e<=t)&&(!!n&&!n(e));return e.jsxs("div",{className:Aa("flex items-center gap-3",o),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",t,"/",a,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:c.map(a=>e.jsxs(Gs,{onClick:()=>{var e;(e=a)<t?s(e):n&&!n(e)||s(e)},disabled:d(a),className:Aa("cursor-pointer",a===t&&"bg-muted font-medium",d(a)&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),r?.[a-1]||`Etapa ${a}`,a===t&&e.jsx(l.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),e.jsx(ii,{value:t/a*100,className:Aa("h-2",i)})]})},exports.Switch=bo,exports.TIMEZONES=fa,exports.TabPageContent=function({children:t,className:a}){return e.jsx("div",{className:Aa("space-y-6",a),children:t})},exports.TabPageHeader=function({title:t,description:a,actions:s,className:r}){return e.jsxs("div",{className:Aa("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:t}),a&&e.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(Ba,{})]})},exports.TabPageLayout=function({children:t,className:a}){return e.jsx("div",{className:Aa("flex flex-col h-full",a),children:e.jsx(vr,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:t})})})},exports.Table=kn,exports.TableBody=_n,exports.TableCaption=Mn,exports.TableCell=Pn,exports.TableFooter=An,exports.TableHead=En,exports.TableHeader=Sn,exports.TableResizeHandle=Fn,exports.TableRow=Tn,exports.TableRowActions=to,exports.TableSkeleton=In,exports.Tabs=si,exports.TabsContent=oi,exports.TabsList=ri,exports.TabsTrigger=ni,exports.Textarea=Ms,exports.Toaster=zs,exports.Toggle=no,exports.ToggleGroup=io,exports.ToggleGroupItem=lo,exports.TokenManager=Dr,exports.TokenService=Sr,exports.Tooltip=er,exports.TooltipContent=ar,exports.TooltipProvider=Js,exports.TooltipTrigger=tr,exports.TruncatedCell=zn,exports.VideoEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:c,uploadOptions:d}){const[u,m]=t.useState(a||{inputType:"url",controls:!0}),p=t.useRef(null),h=t.useRef(null),{upload:f,uploading:x}=Yd({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["video/*"],maxSize:104857600}}),{upload:g,uploading:b}=Yd({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),v=t.useMemo(()=>eu(u.videoUrl||Jd(u.embedCode)||""),[u.videoUrl,u.embedCode]),w=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Tipo de entrada"}),e.jsxs(Ns,{value:u.inputType||"url",onValueChange:e=>w("inputType",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"url",children:"URL"}),e.jsx(Ts,{value:"upload",children:"Upload de arquivo"}),e.jsx(Ts,{value:"embed",children:"Código embed"})]})]})]}),"upload"===u.inputType&&o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Arquivo"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:p,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await f(t),a={...u,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:u.title||t.name.replace(/\.[^/.]+$/,"")};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),u.videoFile&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",u.videoFile," (",Math.round((u.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===u.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Código embed"}),e.jsx(Ms,{placeholder:"Cole o código embed aqui",value:u.embedCode||"",onChange:e=>w("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Thumbnail"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ia,{type:"url",placeholder:"URL da thumbnail",value:u.thumbnail||"",onChange:e=>w("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...u,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};m(a),s(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),u.thumbnailFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",u.thumbnailFile]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"title",children:"Título"}),e.jsx(Ia,{id:"title",placeholder:"Título do vídeo",value:u.title||"",onChange:e=>w("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"autoplay",checked:u.autoplay||!1,onCheckedChange:e=>w("autoplay",!0===e)}),e.jsx(Ra,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"controls",checked:!1!==u.controls,onCheckedChange:e=>w("controls",!0===e)}),e.jsx(Ra,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=u.videoUrl||Jd(u.embedCode)||"";if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===v)return e.jsxs("video",{controls:!1!==u.controls,autoPlay:u.autoplay,poster:u.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const a="youtube"===v?Kd(t,u.autoplay):Zd(t,u.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:u.title||"Vídeo",src:a,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(Pa,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pa,{onClick:()=>{u.videoUrl||u.embedCode?r(u):i.toast.error("Erro",{description:"Nenhum vídeo selecionado"})},disabled:!(u.videoUrl||u.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:a="",style:s}){const r=t.videoUrl||Jd(t.embedCode)||"";if(!r)return null;const n=eu(r);return e.jsx(La,{className:`overflow-hidden my-4 ${a}`,style:s,children:e.jsxs(qa,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.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:t.title||"Vídeo",src:"youtube"===n?Kd(r,t.autoplay):Zd(r,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.assets=ud,exports.badgeVariants=Is,exports.buildHierarchy=Ad,exports.buttonGroupVariants=Li,exports.buttonVariants=Ea,exports.calculateAspectRatio=tu,exports.cn=Aa,exports.createCrudPage=function(t){return({manager:a})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=t,l=a??s,c={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:o||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton,showNewButton:r.showNewButton,newButtonLabel:r.newButtonLabel,showSearch:r.showSearch,searchPlaceholder:r.searchPlaceholder,showActionBar:r.showActionBar};return e.jsx(To,{manager:l,config:c,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,t){const a=td({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createRoutingHandlers=td,exports.createService=pn,exports.createSimpleSaveHandler=function(e,t,a){return s=>{if(s.id){const t=a(s);e.updateEntity(s.id,t)}else{const a=t(s);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=pn({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:t,useCrudHook:(a,s)=>yn({queryKey:e.tableName,service:t,entityName:e.entityName,additionalFilters:a,onSuccess:s})}},exports.createTranslatedMessages=e=>({success:{created:t=>e("msg_created_success",`${t} criado com sucesso`).replace("{{entity}}",t),updated:t=>e("msg_updated_success",`${t} atualizado com sucesso`).replace("{{entity}}",t),deleted:t=>e("msg_deleted_success",`${t} removido com sucesso`).replace("{{entity}}",t)},error:{create:t=>e("msg_create_error",`Erro ao criar ${t}`).replace("{{entity}}",t),update:t=>e("msg_update_error",`Erro ao atualizar ${t}`).replace("{{entity}}",t),delete:t=>e("msg_delete_error",`Erro ao remover ${t}`).replace("{{entity}}",t),load:t=>e("msg_load_error",`Erro ao carregar ${t}`).replace("{{entity}}",t)}}),exports.debounce=(e,t)=>{let a;return(...s)=>{clearTimeout(a),a=setTimeout(()=>e(...s),t)}},exports.deriveEmailField=nn,exports.deriveNameField=rn,exports.deriveUsernameField=on,exports.detectBrowserLocale=Na,exports.detectBrowserPreferences=()=>{const e=Na();return{locale:e,timezone:ya(),datetimeFormat:ja(e)}},exports.detectBrowserTimezone=ya,exports.detectVideoProvider=eu,exports.emailService=Cd,exports.errorService=Rr,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractVimeoId=Xd,exports.extractYouTubeId=Qd,exports.filterAndPromoteOrphans=function(e,t){const a=e.map(e=>({...e})),s=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let t=e.id_leader;for(;t&&s.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))},exports.findDatetimeFormat=e=>ha.find(t=>t.value===e),exports.findLocale=e=>pa.find(t=>t.value===e),exports.findTimezone=e=>fa.find(t=>t.value===e),exports.flattenTree=Td,exports.formatCurrency=(e,t="BRL",a="pt-BR")=>null==e?"":new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Sa,exports.formatDatetime=ka,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,t,a={}){const s=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],r={key:e,header:Po(e),label:Po(e),...Eo(e,a),sortable:!0,searchable:"string"==typeof a};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.getEnvironmentConfig=Gr,exports.getQualiexApiUrl=Jr,exports.getSupabaseClient=Ur,exports.handleExternalLink=_a,exports.inferDatetimeFormat=ja,exports.inputGroupAddonVariants=al,exports.inputGroupButtonVariants=rl,exports.isDevEnvironment=Zr,exports.isDevSupabaseProject=Yr,exports.isImageUrl=function(e){const t=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const a=new URL(e);return t.some(e=>a.pathname.toLowerCase().endsWith(e))}catch{const a=e.toLowerCase();return t.some(e=>a.endsWith(e))}},exports.isValidDatetimeFormat=e=>ha.some(t=>t.value===e),exports.isValidLocale=va,exports.isValidTimezone=wa,exports.loadClicksignScript=lu,exports.logoSrc=md,exports.navigationMenuTriggerStyle=jl,exports.normalizeVideoUrl=function(e,t,a){switch(t||eu(e)){case"youtube":return Kd(e,a);case"vimeo":return Zd(e,a);default:return e}},exports.normalizeVimeoUrl=Zd,exports.normalizeYouTubeUrl=Kd,exports.parseIframeSrc=Jd,exports.placeService=_d,exports.qualiexApi=sn,exports.resizeKeepingAspect=function(e,t,a,s){const r=tu(e,t);return a&&!s?{width:a,height:Math.round(a/r)}:s&&!a?{width:Math.round(s*r),height:s}:{width:e,height:t}},exports.resolveFieldMappings=ln,exports.resolvePageTitle=od,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new y.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.signService=ou,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=pd,exports.toggleVariants=ro,exports.trimTextFields=Ta,exports.useActiveModules=(e={})=>{const{enabled:t=!0}=e,{alias:a}=Nn();return y.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=Ur(),{data:t,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(s){if(!Br.handleError(s))throw s;return[]}return t||[]},enabled:t&&!!a})},exports.useAuth=Nn,exports.useBaseForm=po,exports.useColumnResize=so,exports.useCreateMultipleLeadersMutation=Id,exports.useCreateSingleLeaderMutation=Md,exports.useCrud=yn,exports.useDebounce=id,exports.useFormField=hs,exports.useHasOpenModal=function(){const{hasOpenModal:e}=wd();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Vo(),a=ga;return{formatDatetime:s=>ka(s,a,t,e),formatDate:a=>Sa(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useIsMobile=Cn,exports.useLeadershipApi=Ed,exports.useLocale=Vo,exports.useMediaQuery=jn,exports.useMediaUpload=Yd,exports.useModalState=wd,exports.useModuleAccess=ti,exports.useModuleConfig=Yo,exports.useNavigation=nd,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=Uo(),r=t.useRef({});t.useEffect(()=>(r.current.title===e.title&&r.current.subtitle===e.subtitle||(r.current={title:e.title,subtitle:e.subtitle},a(e)),()=>s()),[e.title,e.subtitle,a,s])},exports.usePageMetadataContext=Uo,exports.usePageTitle=function(){const e=j.useLocation(),{navigation:t}=nd();return od(t,e.pathname)},exports.usePermissionQuery=cd,exports.useQualiexUsers=vo,exports.useRemoveLeaderMutation=Rd,exports.useRouteBreadcrumbs=function(){const e=j.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let s="";return t.forEach((e,r)=>{s+=`/${e}`;const n=r===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:s,isCurrentPage:n})}),a})()},exports.useRowResize=function({rowIds:e,defaultHeight:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,c]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[d,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),f=t.useRef(0),x=t.useCallback(e=>l[e]??a,[l,a]),g=t.useCallback((e,t)=>{i&&(t.preventDefault(),t.stopPropagation(),u(!0),p(e),h.current=t.clientY,f.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!d||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(s,Math.min(r,f.current+t));c(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&c(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[d,m,s,r,n,o]),t.useEffect(()=>(d?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d]);const b=t.useCallback(()=>{c({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:d,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:x}},exports.useSidebar=Jl,exports.useSidebarResize=bd,exports.useSignConfig=au,exports.useSyncSubordinatesMutation=Ld,exports.useUpdateLeaderMutation=Dd,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=t.useState(s),[c,d]=t.useState(r),[u,m]=t.useState(!1),[p,h]=t.useState(!1),f=a.length,x=0===i,g=i===f-1,b=a[i],v=f>1?(i+1)/f*100:100,w=t.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),N=t.useMemo(()=>w(),[w,c]),y=t.useMemo(()=>!x&&!b?.disableBack,[x,b]),j=t.useCallback(e=>{d(t=>({...t,...e}))},[]),C=t.useCallback((e,t)=>{d(a=>({...a,[e]:t}))},[]),k=t.useCallback(()=>{l(s),d(r),m(!1),h(!1),o?.()},[s,r,o]),S=t.useCallback(async()=>{if(w()&&!p){h(!0);try{await(n?.(c))}finally{h(!1)}}},[w,p,c,n]),_=t.useCallback(async()=>{w()&&!u&&(g?await S():l(e=>Math.min(e+1,f-1)))},[w,u,g,f,S]),A=t.useCallback(()=>{y&&!u&&l(e=>Math.max(e-1,0))},[y,u]),T=t.useCallback(e=>{e<0||e>=f||u||(e<=i||e===i+1)&&l(e)},[i,f,u]),E=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:c,isFirstStep:x,isLastStep:g,isLoading:u,isCompleting:p,next:_,back:A,goTo:T,canProceed:N,canGoBack:y,setData:j,updateField:C,reset:k,complete:S,setLoading:E,progress:v,stepIndex:i,totalSteps:f}};
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"),o=require("date-fns"),i=require("sonner"),l=require("lucide-react"),c=require("@radix-ui/react-label"),d=require("@radix-ui/react-dialog"),u=require("@radix-ui/react-separator"),m=require("@radix-ui/react-alert-dialog"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),x=require("@radix-ui/react-dropdown-menu"),g=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),v=require("react-i18next"),w=require("@radix-ui/react-scroll-area"),y=require("@supabase/supabase-js"),N=require("@tanstack/react-query"),j=require("react-router-dom"),C=require("@radix-ui/react-context-menu"),_=require("@radix-ui/react-toggle-group"),k=require("@radix-ui/react-toggle"),S=require("@radix-ui/react-switch"),A=require("i18next"),T=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-tabs"),P=require("@radix-ui/react-progress"),M=require("@radix-ui/react-accordion"),D=require("@radix-ui/react-avatar"),I=require("react-day-picker"),R=require("vaul"),L=require("@radix-ui/react-hover-card"),z=require("@radix-ui/react-navigation-menu"),F=require("@radix-ui/react-radio-group"),U=require("react-resizable-panels"),B=require("@radix-ui/react-slider"),q=require("@radix-ui/react-menubar"),O=require("recharts"),$=require("@tiptap/react"),V=require("@tiptap/starter-kit"),H=require("@tiptap/extension-underline"),W=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),K=require("zod"),X=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 J=Z(a),ee=Z(c),ae=Z(d),te=Z(u),se=Z(m),re=Z(h),ne=Z(f),oe=Z(x),ie=Z(g),le=Z(b),ce=Z(w),de=Z(C),ue=Z(_),me=Z(k),pe=Z(S),he=Z(T),fe=Z(E),xe=Z(P),ge=Z(M),be=Z(D),ve=Z(L),we=Z(z),ye=Z(F),Ne=Z(U),je=Z(B),Ce=Z(q),_e=Z(O);const ke={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"}};function Se(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Ae={date:Se({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Se({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:Se({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Te={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Ee(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]}}const Pe={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:Ee({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})};function Me(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 o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(i,e=>e.test(o)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(i,e=>e.test(o));let c;c=e.valueCallback?e.valueCallback(l):l,c=t.valueCallback?t.valueCallback(c):c;return{value:c,rest:a.slice(o.length)}}}function De(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 o=e.valueCallback?e.valueCallback(n[0]):n[0];o=t.valueCallback?t.valueCallback(o):o;return{value:o,rest:a.slice(r.length)}}}const Ie={ordinalNumber:De({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},Re={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=ke[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:Ae,formatRelative:(e,a,t,s)=>Te[e],localize:Pe,match:Ie,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Le={};function ze(){return Le}const Fe=6048e5;function Ue(e){const a=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===a?new e.constructor(+e):"number"==typeof e||"[object Number]"===a||"string"==typeof e||"[object String]"===a?new Date(e):new Date(NaN)}function Be(e){const a=Ue(e);return a.setHours(0,0,0,0),a}function qe(e){const a=Ue(e),t=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()));return t.setUTCFullYear(a.getFullYear()),+e-+t}function Oe(e,a){return e instanceof Date?new e.constructor(a):new Date(a)}function $e(e){const a=Ue(e),t=function(e,a){const t=Be(e),s=Be(a),r=+t-qe(t),n=+s-qe(s);return Math.round((r-n)/864e5)}(a,function(e){const a=Ue(e),t=Oe(e,0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}(a));return t+1}function Ve(e,a){const t=ze(),s=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=Ue(e),n=r.getDay(),o=(n<s?7:0)+n-s;return r.setDate(r.getDate()-o),r.setHours(0,0,0,0),r}function He(e){return Ve(e,{weekStartsOn:1})}function We(e){const a=Ue(e),t=a.getFullYear(),s=Oe(e,0);s.setFullYear(t+1,0,4),s.setHours(0,0,0,0);const r=He(s),n=Oe(e,0);n.setFullYear(t,0,4),n.setHours(0,0,0,0);const o=He(n);return a.getTime()>=r.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function Ge(e){const a=Ue(e),t=+He(a)-+function(e){const a=We(e),t=Oe(e,0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),He(t)}(a);return Math.round(t/Fe)+1}function Ye(e,a){const t=Ue(e),s=t.getFullYear(),r=ze(),n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=Oe(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=Ve(o,a),l=Oe(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const c=Ve(l,a);return t.getTime()>=i.getTime()?s+1:t.getTime()>=c.getTime()?s:s-1}function Qe(e,a){const t=Ue(e),s=+Ve(t,a)-+function(e,a){const t=ze(),s=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=Ye(e,a),n=Oe(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),Ve(n,a)}(t,a);return Math.round(s/Fe)+1}function Ke(e,a){return(e<0?"-":"")+Math.abs(e).toString().padStart(a,"0")}const Xe={y(e,a){const t=e.getFullYear(),s=t>0?t:1-t;return Ke("yy"===a?s%100:s,a.length)},M(e,a){const t=e.getMonth();return"M"===a?String(t+1):Ke(t+1,2)},d:(e,a)=>Ke(e.getDate(),a.length),a(e,a){const t=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];default:return"am"===t?"a.m.":"p.m."}},h:(e,a)=>Ke(e.getHours()%12||12,a.length),H:(e,a)=>Ke(e.getHours(),a.length),m:(e,a)=>Ke(e.getMinutes(),a.length),s:(e,a)=>Ke(e.getSeconds(),a.length),S(e,a){const t=a.length,s=e.getMilliseconds();return Ke(Math.trunc(s*Math.pow(10,t-3)),a.length)}},Ze="midnight",Je="noon",ea="morning",aa="afternoon",ta="evening",sa="night",ra={G:function(e,a,t){const s=e.getFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(s,{width:"abbreviated"});case"GGGGG":return t.era(s,{width:"narrow"});default:return t.era(s,{width:"wide"})}},y:function(e,a,t){if("yo"===a){const a=e.getFullYear(),s=a>0?a:1-a;return t.ordinalNumber(s,{unit:"year"})}return Xe.y(e,a)},Y:function(e,a,t,s){const r=Ye(e,s),n=r>0?r:1-r;if("YY"===a){return Ke(n%100,2)}return"Yo"===a?t.ordinalNumber(n,{unit:"year"}):Ke(n,a.length)},R:function(e,a){return Ke(We(e),a.length)},u:function(e,a){return Ke(e.getFullYear(),a.length)},Q:function(e,a,t){const s=Math.ceil((e.getMonth()+1)/3);switch(a){case"Q":return String(s);case"QQ":return Ke(s,2);case"Qo":return t.ordinalNumber(s,{unit:"quarter"});case"QQQ":return t.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(s,{width:"narrow",context:"formatting"});default:return t.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,a,t){const s=Math.ceil((e.getMonth()+1)/3);switch(a){case"q":return String(s);case"qq":return Ke(s,2);case"qo":return t.ordinalNumber(s,{unit:"quarter"});case"qqq":return t.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(s,{width:"narrow",context:"standalone"});default:return t.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,a,t){const s=e.getMonth();switch(a){case"M":case"MM":return Xe.M(e,a);case"Mo":return t.ordinalNumber(s+1,{unit:"month"});case"MMM":return t.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(s,{width:"narrow",context:"formatting"});default:return t.month(s,{width:"wide",context:"formatting"})}},L:function(e,a,t){const s=e.getMonth();switch(a){case"L":return String(s+1);case"LL":return Ke(s+1,2);case"Lo":return t.ordinalNumber(s+1,{unit:"month"});case"LLL":return t.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(s,{width:"narrow",context:"standalone"});default:return t.month(s,{width:"wide",context:"standalone"})}},w:function(e,a,t,s){const r=Qe(e,s);return"wo"===a?t.ordinalNumber(r,{unit:"week"}):Ke(r,a.length)},I:function(e,a,t){const s=Ge(e);return"Io"===a?t.ordinalNumber(s,{unit:"week"}):Ke(s,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getDate(),{unit:"date"}):Xe.d(e,a)},D:function(e,a,t){const s=$e(e);return"Do"===a?t.ordinalNumber(s,{unit:"dayOfYear"}):Ke(s,a.length)},E:function(e,a,t){const s=e.getDay();switch(a){case"E":case"EE":case"EEE":return t.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},e:function(e,a,t,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(a){case"e":return String(n);case"ee":return Ke(n,2);case"eo":return t.ordinalNumber(n,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(e,a,t,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(a){case"c":return String(n);case"cc":return Ke(n,a.length);case"co":return t.ordinalNumber(n,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(e,a,t){const s=e.getDay(),r=0===s?7:s;switch(a){case"i":return String(r);case"ii":return Ke(r,a.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},a:function(e,a,t){const s=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(s,{width:"narrow",context:"formatting"});default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,a,t){const s=e.getHours();let r;switch(r=12===s?Je:0===s?Ze:s/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,a,t){const s=e.getHours();let r;switch(r=s>=17?ta:s>=12?aa:s>=4?ea:sa,a){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,a,t){if("ho"===a){let a=e.getHours()%12;return 0===a&&(a=12),t.ordinalNumber(a,{unit:"hour"})}return Xe.h(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getHours(),{unit:"hour"}):Xe.H(e,a)},K:function(e,a,t){const s=e.getHours()%12;return"Ko"===a?t.ordinalNumber(s,{unit:"hour"}):Ke(s,a.length)},k:function(e,a,t){let s=e.getHours();return 0===s&&(s=24),"ko"===a?t.ordinalNumber(s,{unit:"hour"}):Ke(s,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xe.m(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getSeconds(),{unit:"second"}):Xe.s(e,a)},S:function(e,a){return Xe.S(e,a)},X:function(e,a,t){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(a){case"X":return oa(s);case"XXXX":case"XX":return ia(s);default:return ia(s,":")}},x:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"x":return oa(s);case"xxxx":case"xx":return ia(s);default:return ia(s,":")}},O:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+na(s,":");default:return"GMT"+ia(s,":")}},z:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+na(s,":");default:return"GMT"+ia(s,":")}},t:function(e,a,t){return Ke(Math.trunc(e.getTime()/1e3),a.length)},T:function(e,a,t){return Ke(e.getTime(),a.length)}};function na(e,a=""){const t=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?t+String(r):t+String(r)+a+Ke(n,2)}function oa(e,a){if(e%60==0){return(e>0?"-":"+")+Ke(Math.abs(e)/60,2)}return ia(e,a)}function ia(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+Ke(Math.trunc(s/60),2)+a+Ke(s%60,2)}const la=(e,a)=>{switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},ca=(e,a)=>{switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},da={p:ca,P:(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],s=t[1],r=t[2];if(!r)return la(e,a);let n;switch(s){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",la(s,a)).replace("{{time}}",ca(r,a))}},ua=/^D+$/,ma=/^Y+$/,pa=["D","DD","YY","YYYY"];function ha(e){if(!function(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;const a=Ue(e);return!isNaN(Number(a))}const fa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xa=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ga=/^'([^]*?)'?$/,ba=/''/g,va=/[a-zA-Z]/;function wa(e,a,t){const s=ze(),r=t?.locale??s.locale??Re,n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=Ue(e);if(!ha(i))throw new RangeError("Invalid time value");let l=a.match(xa).map(e=>{const a=e[0];if("p"===a||"P"===a){return(0,da[a])(e,r.formatLong)}return e}).join("").match(fa).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const a=e[0];if("'"===a)return{isToken:!1,value:ya(e)};if(ra[a])return{isToken:!0,value:e};if(a.match(va))throw new RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");return{isToken:!1,value:e}});r.localize.preprocessor&&(l=r.localize.preprocessor(i,l));const c={firstWeekContainsDate:n,weekStartsOn:o,locale:r};return l.map(s=>{if(!s.isToken)return s.value;const n=s.value;(!t?.useAdditionalWeekYearTokens&&function(e){return ma.test(e)}(n)||!t?.useAdditionalDayOfYearTokens&&function(e){return ua.test(e)}(n))&&function(e,a,t){const s=function(e,a,t){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${a}\`) for formatting ${s} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,a,t);if(pa.includes(e))throw new RangeError(s)}(n,a,String(e));return(0,ra[n[0]])(i,n,r.localize,c)}).join("")}function ya(e){const a=e.match(ga);return a?a[1].replace(ba,"'"):e}function Na(e,a,t){const s=o.getDefaultOptions(),r=function(e,a,t){return new Intl.DateTimeFormat(t?[t.code,"en-US"]:void 0,{timeZone:a,timeZoneName:e})}(e,t.timeZone,t.locale??s.locale);return"formatToParts"in r?function(e,a){const t=e.formatToParts(a);for(let s=t.length-1;s>=0;--s)if("timeZoneName"===t[s].type)return t[s].value;return}(r,a):function(e,a){const t=e.format(a).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(t);return s?s[0].substr(1):""}(r,a)}function ja(e,a){const t=function(e){_a[e]||(_a[e]=Sa?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}));return _a[e]}(a);return"formatToParts"in t?function(e,a){try{const t=e.formatToParts(a),s=[];for(let e=0;e<t.length;e++){const a=Ca[t[e].type];void 0!==a&&(s[a]=parseInt(t[e].value,10))}return s}catch(t){if(t instanceof RangeError)return[NaN];throw t}}(t,e):function(e,a){const t=e.format(a),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(t);return[parseInt(s[3],10),parseInt(s[1],10),parseInt(s[2],10),parseInt(s[4],10),parseInt(s[5],10),parseInt(s[6],10)]}(t,e)}const Ca={year:0,month:1,day:2,hour:3,minute:4,second:5};const _a={},ka=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),Sa="06/25/2014, 00:00:00"===ka||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===ka;function Aa(e,a,t,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,a,t),i.setUTCHours(s,r,n,o),i}const Ta=36e5,Ea={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Pa(e,a,t){if(!e)return 0;let s,r,n=Ea.timezoneZ.exec(e);if(n)return 0;if(n=Ea.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Da(s)?-s*Ta:NaN;if(n=Ea.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Da(s,e)?(r=Math.abs(s)*Ta+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Ia[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Ia[e]=!0,!0}catch(a){return!1}}(e)){a=new Date(a||Date.now());const s=t?a:function(e){return Aa(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(a),r=Ma(s,e),n=t?r:function(e,a,t){const s=e.getTime();let r=s-a;const n=Ma(new Date(r),t);if(a===n)return a;r-=n-a;const o=Ma(new Date(r),t);if(n===o)return n;return Math.max(n,o)}(a,r,e);return-n}return NaN}function Ma(e,a){const t=ja(e,a),s=Aa(t[0],t[1]-1,t[2],t[3]%24,t[4],t[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function Da(e,a){return-23<=e&&e<=23&&(null==a||0<=a&&a<=59)}const Ia={};const Ra={X:function(e,a,t){const s=La(t.timeZone,e);if(0===s)return"Z";switch(a){case"X":return Ua(s);case"XXXX":case"XX":return Fa(s);default:return Fa(s,":")}},x:function(e,a,t){const s=La(t.timeZone,e);switch(a){case"x":return Ua(s);case"xxxx":case"xx":return Fa(s);default:return Fa(s,":")}},O:function(e,a,t){const s=La(t.timeZone,e);switch(a){case"O":case"OO":case"OOO":return"GMT"+function(e,a=""){const t=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return t+String(r);return t+String(r)+a+za(n,2)}(s,":");default:return"GMT"+Fa(s,":")}},z:function(e,a,t){switch(a){case"z":case"zz":case"zzz":return Na("short",e,t);default:return Na("long",e,t)}}};function La(e,a){const t=e?Pa(e,a,!0)/6e4:a?.getTimezoneOffset()??0;if(Number.isNaN(t))throw new RangeError("Invalid time zone specified: "+e);return t}function za(e,a){const t=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<a;)s="0"+s;return t+s}function Fa(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+za(Math.floor(s/60),2)+a+za(Math.floor(s%60),2)}function Ua(e,a){if(e%60==0){return(e>0?"-":"+")+za(Math.abs(e)/60,2)}return Fa(e,a)}function Ba(e){const a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),+e-+a}const qa=36e5,Oa=6e4,$a={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function Va(e,a={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const t=null==a.additionalDigits?2:Number(a.additionalDigits);if(2!==t&&1!==t&&0!==t)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const s=function(e){const a={};let t,s=$a.dateTimePattern.exec(e);s?(a.date=s[1],t=s[3]):(s=$a.datePattern.exec(e),s?(a.date=s[1],t=s[2]):(a.date=null,t=e));if(t){const e=$a.timeZone.exec(t);e?(a.time=t.replace(e[1],""),a.timeZone=e[1].trim()):a.time=t}return a}(e),{year:r,restDateString:n}=function(e,a){if(e){const t=$a.YYY[a],s=$a.YYYYY[a];let r=$a.YYYY.exec(e)||s.exec(e);if(r){const a=r[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(r=$a.YY.exec(e)||t.exec(e),r){const a=r[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}}return{year:null}}(s.date,t),o=function(e,a){if(null===a)return null;let t,s,r;if(!e||!e.length)return t=new Date(0),t.setUTCFullYear(a),t;let n=$a.MM.exec(e);if(n)return t=new Date(0),s=parseInt(n[1],10)-1,Qa(a,s)?(t.setUTCFullYear(a,s),t):new Date(NaN);if(n=$a.DDD.exec(e),n){t=new Date(0);const e=parseInt(n[1],10);return function(e,a){if(a<1)return!1;const t=Ya(e);if(t&&a>366)return!1;if(!t&&a>365)return!1;return!0}(a,e)?(t.setUTCFullYear(a,0,e),t):new Date(NaN)}if(n=$a.MMDD.exec(e),n){t=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return Qa(a,s,e)?(t.setUTCFullYear(a,s,e),t):new Date(NaN)}if(n=$a.Www.exec(e),n)return r=parseInt(n[1],10)-1,Ka(r)?Ha(a,r):new Date(NaN);if(n=$a.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return Ka(r,e)?Ha(a,r,e):new Date(NaN)}return null}(n,r);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let t,r=0;if(s.time&&(r=function(e){let a,t,s=$a.HH.exec(e);if(s)return a=parseFloat(s[1].replace(",",".")),Xa(a)?a%24*qa:NaN;if(s=$a.HHMM.exec(e),s)return a=parseInt(s[1],10),t=parseFloat(s[2].replace(",",".")),Xa(a,t)?a%24*qa+t*Oa:NaN;if(s=$a.HHMMSS.exec(e),s){a=parseInt(s[1],10),t=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return Xa(a,t,e)?a%24*qa+t*Oa+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||a.timeZone){if(t=Pa(s.timeZone||a.timeZone,new Date(e+r)),isNaN(t))return new Date(NaN)}else t=Ba(new Date(e+r)),t=Ba(new Date(e+r+t));return new Date(e+r+t)}return new Date(NaN)}function Ha(e,a,t){a=a||0,t=t||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*a+t+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const Wa=[31,28,31,30,31,30,31,31,30,31,30,31],Ga=[31,29,31,30,31,30,31,31,30,31,30,31];function Ya(e){return e%400==0||e%4==0&&e%100!=0}function Qa(e,a,t){if(a<0||a>11)return!1;if(null!=t){if(t<1)return!1;const s=Ya(e);if(s&&t>Ga[a])return!1;if(!s&&t>Wa[a])return!1}return!0}function Ka(e,a){return!(e<0||e>52)&&(null==a||!(a<0||a>6))}function Xa(e,a,t){return!(e<0||e>=25)&&((null==a||!(a<0||a>=60))&&(null==t||!(t<0||t>=60)))}const Za=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Ja(e,a,t,s){return function(e,a,t={}){const s=(a=String(a)).match(Za);if(s){const r=Va(t.originalDate||e,t);a=s.reduce(function(e,a){if("'"===a[0])return e;const s=e.indexOf(a),n="'"===e[s-1],o=e.replace(a,"'"+Ra[a[0]](r,a,t)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},a)}return wa(e,a,t)}(function(e,a,t){const s=Pa(a,e=Va(e,t),!0),r=new Date(e.getTime()-s),n=new Date(0);return n.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),n.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),n}(e,a,{timeZone:(s={...s,timeZone:a,originalDate:e}).timeZone}),t,s)}const et={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"}},at={date:Se({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:Se({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Se({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},tt={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"},st={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"},rt={ordinalNumber:(e,a)=>Number(e)+"º",era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},nt={ordinalNumber:De({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},ot={code:"es",formatDistance:(e,a,t)=>{let s;const r=et[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:at,formatRelative:(e,a,t,s)=>1!==a.getHours()?st[e]:tt[e],localize:rt,match:nt,options:{weekStartsOn:1,firstWeekContainsDate:1}},it={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"}},lt={date:Se({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:Se({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Se({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ct={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"},dt={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},ut={ordinalNumber:De({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},mt={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=it[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:lt,formatRelative:(e,a,t,s)=>{const r=ct[e];return"function"==typeof r?r(a):r},localize:dt,match:ut,options:{weekStartsOn:0,firstWeekContainsDate:1}},pt=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],ht=[{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"}],ft=[{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"}],xt="pt-BR",gt="dd/MM/yyyy HH:mm",bt="America/Sao_Paulo",vt=e=>pt.some(a=>a.value===e),wt=e=>ft.some(a=>a.value===e),yt=()=>{if("undefined"==typeof navigator)return xt;const e=navigator.language;if(vt(e))return e;const a=e.split("-")[0],t=pt.find(e=>e.value.startsWith(a));return t?.value||xt},Nt=()=>{if("undefined"==typeof Intl)return bt;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return wt(e)?e:bt}catch{return bt}},jt=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||gt),Ct={"pt-BR":mt,"en-US":Re,"es-ES":ot},_t=(e,a=gt,t=bt,s=xt)=>{if(!e)return"";const r=o.parseISO(e);if(!o.isValid(r))return"Data inválida";const n=Ct[s]||mt;try{return Ja(r,t,a,{locale:n})}catch(i){return Ja(r,bt,a,{locale:n})}},kt=(e,a=xt,t=bt)=>{if(!e)return"";const s=o.parseISO(e);if(!o.isValid(s))return"Data inválida";const r=Ct[a]||mt;try{return Ja(s,t,"PP",{locale:r})}catch(n){return Ja(s,bt,"PP",{locale:r})}};function St(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{i.toast.info("Link copiado para a área de transferência")})}function At(...e){return n.twMerge(r.clsx(e))}const Tt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Tt);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Tt(s);return a}return e},Et=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"}}),Pt=J.forwardRef(({className:a,variant:s,size:r,asChild:n=!1,...o},i)=>{const l=n?t.Slot:"button";return e.jsx(l,{className:At(Et({variant:s,size:r,className:a})),ref:i,...o})});Pt.displayName="Button";const Mt=a.forwardRef(({className:a,children:t,variant:s="action",...r},n)=>e.jsx(Pt,{ref:n,variant:s,size:"icon",className:At("h-8 w-8",a),...r,children:t||e.jsx(l.EllipsisVertical,{size:16})}));Mt.displayName="ActionButton";const Dt=J.forwardRef(({className:a,type:t,...s},r)=>e.jsx("input",{type:t,className:At("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}));Dt.displayName="Input";const It=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Rt=J.forwardRef(({className:a,...t},s)=>e.jsx(ee.Root,{ref:s,className:At(It(),a),...t}));Rt.displayName=ee.Root.displayName;const Lt=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));Lt.displayName="Card";const zt=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("flex flex-col space-y-1.5 p-6",a),...t}));zt.displayName="CardHeader";const Ft=J.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:At("text-2xl font-semibold leading-none tracking-tight",a),...t}));Ft.displayName="CardTitle";const Ut=J.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:At("text-sm text-muted-foreground",a),...t}));Ut.displayName="CardDescription";const Bt=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("p-6 pt-0",a),...t}));Bt.displayName="CardContent";const qt=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("flex items-center p-6 pt-0",a),...t}));qt.displayName="CardFooter";const Ot=J.forwardRef(({className:a,orientation:t="horizontal",decorative:s=!0,...r},n)=>e.jsx(te.Root,{ref:n,decorative:s,orientation:t,className:At("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...r}));Ot.displayName=te.Root.displayName;const $t=se.Root,Vt=se.Trigger,Ht=se.Portal,Wt=J.forwardRef(({className:a,...t},s)=>e.jsx(se.Overlay,{className:At("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}));Wt.displayName=se.Overlay.displayName;const Gt=J.forwardRef(({className:a,...t},s)=>e.jsxs(Ht,{children:[e.jsx(Wt,{}),e.jsx(se.Content,{ref:s,className:At("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})]}));Gt.displayName=se.Content.displayName;const Yt=({className:a,...t})=>e.jsx("div",{className:At("flex flex-col space-y-2 text-center sm:text-left",a),...t});Yt.displayName="AlertDialogHeader";const Qt=({className:a,...t})=>e.jsx("div",{className:At("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});Qt.displayName="AlertDialogFooter";const Kt=J.forwardRef(({className:a,...t},s)=>e.jsx(se.Title,{ref:s,className:At("text-lg font-semibold",a),...t}));Kt.displayName=se.Title.displayName;const Xt=J.forwardRef(({className:a,...t},s)=>e.jsx(se.Description,{ref:s,className:At("text-sm text-muted-foreground",a),...t}));Xt.displayName=se.Description.displayName;const Zt=J.forwardRef(({className:a,...t},s)=>e.jsx(se.Action,{ref:s,className:At(Et(),a),...t}));Zt.displayName=se.Action.displayName;const Jt=J.forwardRef(({className:a,...t},s)=>e.jsx(se.Cancel,{ref:s,className:At(Et({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));Jt.displayName=se.Cancel.displayName;const es=ae.Root,as=ae.Trigger,ts=ae.Portal,ss=ae.Close,rs=J.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{ref:s,className:At("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}));rs.displayName=ae.Overlay.displayName;const ns={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},os=J.forwardRef(({className:a,children:t,size:s,variant:r="informative",isDirty:n,customWidth:o,customMinWidth:i,customMaxWidth:c,customHeight:d,customMinHeight:u,customMaxHeight:m,unsavedChangesTitle:p="Alterações não salvas",unsavedChangesDescription:h="Existem alterações não salvas. Deseja sair sem salvar?",cancelText:f="Cancelar",leaveWithoutSavingText:x="Sair sem salvar",style:g,onInteractOutside:b,onEscapeKeyDown:v,...w},y)=>{const[N,j]=J.useState(!1),C=J.useRef(null),_=s??(o||i||c||d||u||m?void 0:"md"),k=_?ns[_]:{},S={...o??k.width?{width:o??k.width}:{},...i??k.minWidth?{minWidth:i??k.minWidth}:{},...c??k.maxWidth?{maxWidth:c??k.maxWidth}:{},...d??k.height?{height:d??k.height}:{},...u??k.minHeight?{minHeight:u??k.minHeight}:{},...m??k.maxHeight?{maxHeight:m??k.maxHeight}:{},...g},A=J.useCallback(e=>{"form"===r&&n?(C.current=e,j(!0)):e()},[r,n]),T="destructive"!==r;return e.jsxs(ts,{children:[e.jsx(rs,{}),e.jsxs(ae.Content,{ref:y,className:At("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 max-sm:!w-[calc(100vw-2rem)] max-sm:!h-[calc(100dvh-2rem)] max-sm:!min-w-0 max-sm:!min-h-0 max-sm:!max-w-none max-sm:!max-h-none max-sm:p-4",a),style:S,onInteractOutside:e=>{"form"!==r&&"destructive"!==r?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==r)return"form"===r&&n?(e.preventDefault(),void A(()=>{v?.(e)})):void v?.(e);e.preventDefault()},...w,children:[t,T&&e.jsxs(ae.Close,{onClick:e=>{"form"===r&&n&&(e.preventDefault(),A(()=>{const a=e.target.closest("[data-radix-collection-item]");a&&a.click()}))},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(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]}),e.jsx($t,{open:N,onOpenChange:j,children:e.jsxs(Gt,{children:[e.jsxs(Yt,{children:[e.jsx(Kt,{children:p}),e.jsx(Xt,{children:h})]}),e.jsxs(Qt,{children:[e.jsx(Jt,{onClick:()=>{j(!1),C.current=null},children:f}),e.jsx(Zt,{onClick:()=>{j(!1),C.current?.(),C.current=null},children:x})]})]})})]})});os.displayName=ae.Content.displayName;const is=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:At("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(Ot,{className:"mt-2"})]});is.displayName="DialogHeader";const ls=({className:a,...t})=>e.jsx("div",{className:At("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});ls.displayName="DialogBody";const cs=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ot,{className:"mb-4"}),e.jsx("div",{className:At("flex flex-row justify-end gap-2",a),...s,children:t})]});cs.displayName="DialogFooter";const ds=J.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:At("text-lg font-semibold leading-none tracking-tight",a),...t}));ds.displayName=ae.Title.displayName;const us=J.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:At("text-sm text-muted-foreground",a),...t}));us.displayName=ae.Description.displayName;const ms=p.FormProvider,ps=J.createContext({}),hs=()=>{const e=J.useContext(ps),a=J.useContext(fs),{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}},fs=J.createContext({}),xs=J.forwardRef(({className:a,...t},s)=>{const r=J.useId();return e.jsx(fs.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:At("space-y-2",a),...t})})});xs.displayName="FormItem";const gs=J.forwardRef(({className:a,...t},s)=>{const{error:r,formItemId:n}=hs();return e.jsx(Rt,{ref:s,className:At(r&&"text-destructive",a),htmlFor:n,...t})});gs.displayName="FormLabel";const bs=J.forwardRef(({...a},s)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=hs();return e.jsx(t.Slot,{ref:s,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...a})});bs.displayName="FormControl";const vs=J.forwardRef(({className:a,...t},s)=>{const{formDescriptionId:r}=hs();return e.jsx("p",{ref:s,id:r,className:At("text-sm text-muted-foreground",a),...t})});vs.displayName="FormDescription";const ws=J.forwardRef(({className:a,children:t,...s},r)=>{const{error:n,formMessageId:o}=hs(),i=n?String(n?.message):t;return i?e.jsx("p",{ref:r,id:o,className:At("text-sm font-medium text-destructive",a),...s,children:i}):null});ws.displayName="FormMessage";const ys=re.Root,Ns=re.Group,js=re.Value,Cs=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(re.Trigger,{ref:r,className:At("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(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Cs.displayName=re.Trigger.displayName;const _s=J.forwardRef(({className:a,...t},s)=>e.jsx(re.ScrollUpButton,{ref:s,className:At("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(l.ChevronUp,{className:"h-4 w-4"})}));_s.displayName=re.ScrollUpButton.displayName;const ks=J.forwardRef(({className:a,...t},s)=>e.jsx(re.ScrollDownButton,{ref:s,className:At("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(l.ChevronDown,{className:"h-4 w-4"})}));ks.displayName=re.ScrollDownButton.displayName;const Ss=J.forwardRef(({className:a,children:t,position:s="popper",container:r,collisionBoundary:n,...o},i)=>e.jsx(re.Portal,{container:r,children:e.jsxs(re.Content,{ref:i,className:At("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,...o,children:[e.jsx(_s,{}),e.jsx(re.Viewport,{className:At("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(ks,{})]})}));Ss.displayName=re.Content.displayName;const As=J.forwardRef(({className:a,...t},s)=>e.jsx(re.Label,{ref:s,className:At("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));As.displayName=re.Label.displayName;const Ts=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(re.Item,{ref:r,className:At("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(l.Check,{className:"h-4 w-4"})})}),e.jsx(re.ItemText,{children:t})]}));Ts.displayName=re.Item.displayName;const Es=J.forwardRef(({className:a,...t},s)=>e.jsx(re.Separator,{ref:s,className:At("-mx-1 my-1 h-px bg-muted",a),...t}));Es.displayName=re.Separator.displayName;const Ps=J.forwardRef(({className:a,...t},s)=>e.jsx(ne.Root,{ref:s,className:At("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:At("flex items-center justify-center text-current"),children:e.jsx(l.Check,{className:"h-4 w-4"})})}));Ps.displayName=ne.Root.displayName;const Ms=J.forwardRef(({className:a,...t},s)=>e.jsx("textarea",{className:At("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}));Ms.displayName="Textarea";const Ds=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"}}),Is=J.forwardRef(({className:a,variant:t,...s},r)=>e.jsx("div",{ref:r,className:At(Ds({variant:t}),a),...s}));Is.displayName="Badge";const Rs={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ls({size:a="md",className:t}){return e.jsx(l.Loader2,{className:At("animate-spin text-muted-foreground",Rs[a],t)})}const zs=({...a})=>e.jsx(i.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(l.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(l.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(l.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(l.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(l.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}),Fs=oe.Root,Us=oe.Trigger,Bs=oe.Group,qs=oe.Portal,Os=oe.Sub,$s=oe.RadioGroup,Vs=J.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:At("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(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Vs.displayName=oe.SubTrigger.displayName;const Hs=J.forwardRef(({className:a,...t},s)=>e.jsx(oe.SubContent,{ref:s,className:At("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}));Hs.displayName=oe.SubContent.displayName;const Ws=J.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:t,className:At("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})}));Ws.displayName=oe.Content.displayName;const Gs=J.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Item,{ref:r,className:At("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 Ys=J.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:At("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(l.Check,{className:"h-4 w-4"})})}),t]}));Ys.displayName=oe.CheckboxItem.displayName;const Qs=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:At("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(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Qs.displayName=oe.RadioItem.displayName;const Ks=J.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Label,{ref:r,className:At("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));Ks.displayName=oe.Label.displayName;const Xs=J.forwardRef(({className:a,...t},s)=>e.jsx(oe.Separator,{ref:s,className:At("-mx-1 my-1 h-px bg-muted",a),...t}));Xs.displayName=oe.Separator.displayName;const Zs=({className:a,...t})=>e.jsx("span",{className:At("ml-auto text-xs tracking-widest opacity-60",a),...t});Zs.displayName="DropdownMenuShortcut";const Js=({delayDuration:a=300,...t})=>e.jsx(ie.Provider,{delayDuration:a,...t}),er=ie.Root,ar=ie.Trigger,tr=J.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:t,className:At("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}));tr.displayName=ie.Content.displayName;const sr=J.forwardRef(({children:a,disabledReason:t,className:s},r)=>{const n=e.jsx(Gs,{ref:r,className:At("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:a});return t?e.jsx(Js,{delayDuration:100,children:e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx("div",{className:"w-full",children:n})}),e.jsx(tr,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:t})]})}):n});sr.displayName="DisabledMenuItem";const rr=le.Root,nr=le.Trigger,or=J.forwardRef(({className:a,align:t="center",sideOffset:s=4,container:r,...n},o)=>e.jsx(le.Portal,{container:r,children:e.jsx(le.Content,{ref:o,align:t,sideOffset:s,className:At("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})}));or.displayName=le.Content.displayName;const ir=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));ir.displayName="Command";const lr=J.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:At("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})}));lr.displayName="CommandInput";const cr=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));cr.displayName="CommandList";const dr=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("py-6 text-center text-sm text-muted-foreground",a),...t}));dr.displayName="CommandEmpty";const ur=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("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}));ur.displayName="CommandGroup";const mr=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("-mx-1 h-px bg-border",a),...t}));mr.displayName="CommandSeparator";const pr=J.forwardRef(({className:a,disabled:t,onSelect:s,value:r,...n},o)=>e.jsx("div",{ref:o,className:At("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}));pr.displayName="CommandItem";const hr=({className:a,...t})=>e.jsx("span",{className:At("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function fr({className:a,...t}){return e.jsx("div",{className:At("animate-pulse rounded-md bg-muted",a),...t})}hr.displayName="CommandShortcut";const xr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function gr({multiple:t,options:s,value:r,onChange:n,getOptionValue:o,getOptionLabel:i,placeholder:c,label:d,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:f,className:x,sortOptions:g,maxDisplayedBadges:b,popoverContainer:v,onOpen:w,onClose:y}){const[N,j]=a.useState(!1),[C,_]=a.useState(""),k=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),S=a.useMemo(()=>{if(!v)return;let e=v,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},[v]),A=a.useMemo(()=>{const e=s.map(e=>({original:e,value:o(e),label:i(e)}));return g?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[s,o,i,g]),T=a.useMemo(()=>{if(!C)return A;const e=xr(C);return A.filter(a=>xr(a.label).includes(e))},[A,C]),E=a.useMemo(()=>A.filter(e=>k.includes(e.value)),[A,k]),P=e=>{j(e),e?w?.():(_(""),y?.())},M=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?k.filter(a=>a!==e):"")},D=b?E.slice(0,b):E,I=b&&E.length>b?E.length-b:0;return e.jsxs("div",{className:At("space-y-2",x),children:[d&&e.jsxs(Rt,{children:[d,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:N,onOpenChange:P,modal:!1,children:[e.jsx(nr,{asChild:!0,children:t?e.jsxs("div",{role:"combobox","aria-expanded":N,"aria-disabled":h,tabIndex:h?-1:0,onKeyDown:e=>{h||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),P(!N))},className:At("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",h&&"pointer-events-none opacity-50 cursor-not-allowed",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"}),c]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[D.map(a=>e.jsxs(Is,{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(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),I>0&&e.jsxs(Is,{variant:"outline",className:"gap-1",children:["+",I]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pt,{variant:"outline",role:"combobox","aria-expanded":N,disabled:h,className:At("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"}),c]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:S,collisionBoundary:S,children:e.jsxs(ir,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(lr,{placeholder:p,value:C,onChange:e=>_(e.target.value)}),C&&e.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>_(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(cr,{children:0===s.length?e.jsx(dr,{children:m}):0===T.length?e.jsx(dr,{children:"Nenhum resultado encontrado"}):e.jsx(ur,{children:T.map(a=>e.jsxs(pr,{value:a.value,onSelect:()=>(e=>{if(n)if(t){const a=k.includes(e)?k.filter(a=>a!==e):[...k,e];n(a)}else n(e),j(!1)})(a.value),className:"cursor-pointer",children:[e.jsx(l.Check,{className:At("mr-2 h-4 w-4",k.includes(a.value)?"opacity-100":"opacity-0")}),a.label]},a.value))})})]})})]})]})}function br({multiple:a=!1,options:t,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:c=e=>e.label,placeholder:d,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:f=!1,required:x=!1,isLoading:g=!1,error:b,className:w,sortOptions:y=!0,maxDisplayedBadges:N,popoverContainer:j,onOpen:C,onClose:_}){const{t:k}=v.useTranslation(),S=t||s||[],A=o||n,T=d||k("select_placeholder","Selecione..."),E=p||k("no_results","Nenhum resultado encontrado"),P=h||k("search_placeholder","Pesquisar...");if(g)return e.jsxs("div",{className:At("space-y-2",w),children:[u&&e.jsxs(Rt,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const M="string"==typeof b?b:b instanceof Error?b.message:b?k("error_loading","Erro ao carregar"):void 0;return M?e.jsxs("div",{className:At("space-y-2",w),children:[u&&e.jsxs(Rt,{children:[u,x&&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(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:M})]})]}):e.jsx(gr,{multiple:a,options:S,value:r||(a?[]:""),onChange:A,getOptionValue:i,getOptionLabel:c,placeholder:T,label:u,icon:m,emptyMessage:E,searchPlaceholder:P,disabled:f,required:x,className:w,sortOptions:y,maxDisplayedBadges:N,popoverContainer:j,onOpen:C,onClose:_})}const vr=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ce.Root,{ref:r,className:At("relative overflow-hidden",a),...s,children:[e.jsx(ce.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(wr,{}),e.jsx(ce.Corner,{})]}));vr.displayName=ce.Root.displayName;const wr=J.forwardRef(({className:a,orientation:t="vertical",...s},r)=>e.jsx(ce.ScrollAreaScrollbar,{ref:r,orientation:t,className:At("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"})}));wr.displayName=ce.ScrollAreaScrollbar.displayName;const yr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Nr(e,a){if(!a)return null;const t=yr(a),s=[];for(const r of e){const e=yr(r.label).includes(t),n=r.children?Nr(r.children,a):null,o=n&&n.length>0;(e||o)&&s.push({...r,children:e?r.children:o?n:r.children})}return s}function jr(e,a){for(const t of e){if(t.value===a)return t.label;if(t.children){const e=jr(t.children,a);if(e)return e}}}function Cr({node:a,level:t,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=a.children&&a.children.length>0,c=n.includes(a.value);return e.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":c,className:At("flex items-center gap-1 rounded-sm px-2 py-1.5 text-sm cursor-pointer","hover:bg-accent hover:text-accent-foreground","outline-none"),style:{paddingLeft:8+20*t+"px"},children:[e.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:e=>{e.stopPropagation(),o(a.value)},children:[e.jsx(l.Check,{className:At("h-4 w-4 shrink-0",c?"opacity-100":"opacity-0")}),(()=>{const t=c?a.iconSelected??(s?a.iconOpen:null)??a.icon:s?a.iconOpen??a.icon:a.icon;return t?e.jsx(t,{className:At("h-4 w-4 shrink-0",a.iconClassName||"text-muted-foreground")}):null})(),e.jsx("span",{className:"truncate",children:a.label})]}),i&&e.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:e=>{e.stopPropagation(),r(a.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?e.jsx(l.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function _r({nodes:t,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return e.jsx(e.Fragment,{children:t.map(t=>{const l=r.has(t.value);return e.jsxs(a.Fragment,{children:[e.jsx(Cr,{node:t,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&t.children&&t.children.length>0&&e.jsx(_r,{nodes:t.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},t.value)})})}class kr{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 o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";t.push(e),o=!1}if(r.exp&&r.exp<i){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,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()}}kr.LARGE_PAYLOAD_THRESHOLD=1e3;const Sr="qualiex_access_token",Ar="qualiex_id_token",Tr="supabase_token",Er="oauth_state",Pr="oauth_nonce",Mr="selected_alias",Dr="manual_logout",Ir={setAccessToken:e=>localStorage.setItem(Sr,e),getAccessToken:()=>localStorage.getItem(Sr),setIdToken:e=>localStorage.setItem(Ar,e),getIdToken:()=>localStorage.getItem(Ar),getSupabaseToken:()=>localStorage.getItem(Tr),setOAuthState:e=>sessionStorage.setItem(Er,e),getOAuthState:()=>sessionStorage.getItem(Er),clearOAuthState:()=>sessionStorage.removeItem(Er),setOAuthNonce:e=>sessionStorage.setItem(Pr,e),getOAuthNonce:()=>sessionStorage.getItem(Pr),clearOAuthNonce:()=>sessionStorage.removeItem(Pr),setSelectedAlias:e=>localStorage.setItem(Mr,e),getSelectedAlias:()=>localStorage.getItem(Mr),clearSelectedAlias:()=>localStorage.removeItem(Mr),generateOAuthState:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Ir.getAccessToken()||!Ir.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Tr,e),Ir._clearValidationCache()},areAllTokensValid:()=>{const e=Ir.getAccessToken(),a=Ir.getIdToken();if(!e||!a)return!1;try{const t=kr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Ir.getAccessToken(),t=Ir.getIdToken(),s=Ir.getSupabaseToken();return a&&Ir.isTokenExpired(a)&&(localStorage.removeItem(Sr),e=!0),t&&Ir.isTokenExpired(t)&&(localStorage.removeItem(Ar),e=!0),s&&Ir.isTokenExpired(s)&&(localStorage.removeItem(Tr),e=!0),e},clearAll:()=>{localStorage.removeItem(Sr),localStorage.removeItem(Ar),localStorage.removeItem(Tr),localStorage.removeItem(Mr),localStorage.removeItem(Dr),sessionStorage.removeItem(Er),sessionStorage.removeItem(Pr),Ir._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Dr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Dr),clearManualLogout:()=>localStorage.removeItem(Dr),isTokenExpired:e=>{try{return kr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Ir._validationCache.isValid=!1,Ir._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Ir.getSupabaseToken();if(!e)return!1;if(Ir.isTokenExpired(e))return Ir._clearValidationCache(),Ir._handleExpiredToken(),!1;const a=Date.now();return a-Ir._validationCache.timestamp<Ir._validationCache.cacheValidityMs?Ir._validationCache.isValid:(Ir._validationCache.isValid=!0,Ir._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>Ir.isSupabaseTokenValid()?Ir.getSupabaseToken():null,_handleExpiredToken:()=>{Ir.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Ir.isSupabaseTokenValid())return null;const e=Ir.getSupabaseToken();if(!e)return null;try{const a=kr.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 Ir._handleExpiredToken(),null}},getCompanyId:e=>{const a=Ir.getAccessToken();if(a)try{const t=kr.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=Ir.extractTokenData();if(t?.companyId)return t.companyId;const s=Ir.getIdToken();if(s)try{const a=kr.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},getCompanyIdInt:e=>{const a=[Ir.getAccessToken(),Ir.getIdToken()];for(const t of a)if(t)try{const a=kr.parseJwtPayload(t);if(!a)continue;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>1&&a[0]===e)return a[1];if(!e&&a.length>1)return a[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=Ir.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Ir.getIdToken();if(!e)return[];try{const a=kr.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[]}}};const Rr=new class{constructor(){this.errors=[],this.toastCount=0,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}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);i.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){i.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=[]}},Lr=(void 0).VITE_SUPABASE_URL,zr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class Fr{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:zr};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return y.createClient(Lr,zr,{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 Fr.instance||(Fr.instance=new Fr),Fr.instance}getClient(){const e=Ir.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!kr.isTokenExpired(e)}catch(a){return Rr.handleError(a instanceof Error?a:"Supabase - Error validating token",!1),!1}}}function Ur(){return Fr.getInstance().getClient()}class Br{static async generateToken(e,a,t,s=!1){try{if(!s){const e=Ir.getSupabaseToken();if(e&&Ir.isSupabaseTokenValid())return e}const r=Ur(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token?(Ir.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}class qr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(e=!1){if(this.regenerationPromise)return this.regenerationPromise;this.regenerationPromise=this._doRegenerate(e);try{return await this.regenerationPromise}finally{this.regenerationPromise=null}}static async _doRegenerate(e=!1){try{const a=Ir.getAccessToken(),t=Ir.getSelectedAlias();if(!a||!t)return null;const s=await Br.generateToken(a,t,this.onLogoutCallback||void 0,e);return s||null}catch(a){return null}}}qr.regenerationPromise=null,qr.onLogoutCallback=null;class Or{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Ir.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 token","session expired","jwt expired","authentication failed","not authenticated"].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.")}}}class $r{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 qr.attemptRegeneration()?(this.isRetrying=!1,!0):(Or.handleError(e),this.isRetrying=!1,!1)}catch(s){return Or.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Ir.getAccessToken();return e?Ir.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."}}}$r.isRetrying=!1;const Vr="ccjfvpnndclajkleyqkc",Hr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},Wr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"cdf6c125-ec32-43d1-846b-bb8f90125b90"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Gr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const a=(void 0).VITE_SUPABASE_URL;a&&(e=new URL(a).hostname.split(".")[0])}catch{}return e===Vr?Hr:Wr}function Yr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const a=(void 0).VITE_SUPABASE_URL;a&&(e=new URL(a).hostname.split(".")[0])}catch{}return e!==Vr}const Qr={get oauth(){const e=Gr();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Kr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Xr={debounceDelay:500},Zr=()=>{const e=window.location.origin,a=(()=>{try{return window.self!==window.top}catch{return!0}})();return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("lovable.dev")||e.includes("lovable.app")&&a||(void 0).DEV},Jr=()=>Gr().qualiexApiUrl,en={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},an={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},tn={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}`}};const sn=new class{get baseUrl(){return Jr()}async makeApiCall(e,a,t){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Ir.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 o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!o.ok){const e=new Error(`API call failed: ${o.status} ${o.statusText}`);throw e.status=o.status,e.statusCode=o.status,e}return await o.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}}parseUsersResponse(e,a=""){let t=e;if(e.data)t=e.data;else{if(!Array.isArray(e))return Rr.handleError(`[QualiexApi] Formato de resposta inesperado${a}`,!1),null;t=e}return Array.isArray(t)?t.map(this.mapToQualiexUser):(Rr.handleError(`[QualiexApi] Resposta não é um array${a}`,!1),null)}async fetchUsers(e,a){const t={companyId:a,search:"",filterStatus:"active"};try{const a=await this.makeApiCall("/api/common/v1/companiesusers",t,e);return this.parseUsersResponse(a)??[]}catch(s){if(await $r.handleApiError(s))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",t,e);return this.parseUsersResponse(a," após retry")??[]}catch(r){return Rr.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return Rr.handleError(s instanceof Error?s.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return Rr.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=Ir.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async fetchSoftwares(e){try{const a=await this.makeApiCall("/api/common/v1/softwares",{},e),t=a?.data||a;return Array.isArray(t)?t.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(Rr.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(a){if(await $r.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/softwares",{},e),t=a?.data||a;return Array.isArray(t)?t.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(t){return Rr.handleError(t instanceof Error?t:"Erro ao buscar softwares após renovação de token",!0),[]}return Rr.handleError(a instanceof Error?a.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,a){try{const t=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},a),s=t?.data||t;return Array.isArray(s)?s.map(e=>({associationId:e.associationId||"",userId:e.userId||"",userName:e.userName||"",companyId:e.companyId||"",companyName:e.companyName||"",companyAlias:e.companyAlias||"",companyPhotoDate:e.companyPhotoDate,language:e.language,roleId:e.roleId||"",roleName:e.roleName||"",placeId:e.placeId,placeName:e.placeName,softwares:Array.isArray(e.softwares)?e.softwares:[],functionalities:Array.isArray(e.functionalities)?e.functionalities:[],isQualitfy:e.isQualitfy??!1,isMetroex:e.isMetroex??!1})):(Rr.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(t){if(await $r.handleApiError(t))try{const t=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},a),s=t?.data||t;return Array.isArray(s)?s.map(e=>({associationId:e.associationId||"",userId:e.userId||"",userName:e.userName||"",companyId:e.companyId||"",companyName:e.companyName||"",companyAlias:e.companyAlias||"",companyPhotoDate:e.companyPhotoDate,language:e.language,roleId:e.roleId||"",roleName:e.roleName||"",placeId:e.placeId,placeName:e.placeName,softwares:Array.isArray(e.softwares)?e.softwares:[],functionalities:Array.isArray(e.functionalities)?e.functionalities:[],isQualitfy:e.isQualitfy??!1,isMetroex:e.isMetroex??!1})):[]}catch(s){return Rr.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return Rr.handleError(t instanceof Error?t.message:"Erro ao buscar associações do usuário",!0),[]}}};function rn(e,a){const t=a||en.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function nn(e,a){const t=a||en.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function on(e,a){const t=a||en.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function ln(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||rn(e.idField),emailField:e.emailField||nn(e.idField),usernameField:e.usernameField||on(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:rn(e),emailField:nn(e),usernameField:on(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const cn=new Map;class dn{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=cn.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await sn.fetchUsers(e,a);return cn.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||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(!Ir.areAllTokensValid())return e;const t=Ir.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=ln(a.userIdFields,a.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(s,r),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(t){return Rr.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}}const un=["responsible_name"],mn=e=>un.includes(e);function pn(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:o,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=s,d=()=>{if(!Ir.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Ur().schema(i).from(r)},u=(e,a,t,s)=>{let r=d().select(o||"*",{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 i=a.includes(".");return i||mn(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:i}},m=async(e,a,t,r,n)=>{const o=ln(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),i=a.includes(".");if(mn(a)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await p.getAll(e);if(!o?.data?.length)return o;const c=await dn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let d;d=i?c.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?o:-o}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?o:-o}))(c,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t;return{data:e.slice(s,r),pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(d,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalItems,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await dn.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})},p={async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:o,limit:i,additionalFilters:d}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(a,t,n,d),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,o,i),{data:f,error:x,count:g}=await h;if(x)throw new Error(`Error fetching ${r}: ${x.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}})(f||[],g,o,i);if((e=>{if(!c||!l||0===e.length)return!1;const a=ln(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(b.data)){const e=await m(b.data,t,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:a,error:t}=await d().select(o||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Tt(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await d().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={...Tt(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await d().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 d().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}};return p}var hn;const fn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class xn{static async initialize(){try{if(!Ir.hasAllTokens()||!Ir.areAllTokensValid())return Ir.clearExpiredTokens(),{...fn};const e=Ir.getAccessToken(),a=Ir.getIdToken();Ir.clearManualLogout();const t=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=Ir.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=Ir.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);i=a?e:r||s[0]?.alias||null}if(!Ir.isSupabaseTokenValid()&&i&&await qr.attemptRegeneration(),!Ir.isSupabaseTokenValid())return{...fn};let l=null;if(i){const e=Ir.getCompanyId(i),a=s.find(e=>e.alias===i);a&&(l={id:e||a.id,name:a.name,alias:a.alias})}const c=n?.placeId??null,d=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:t,alias:i,companies:s,selectedUnit:l,userId:t?.id||null,userAlias:t?.id||null,placeId:c,placeName:d,activePlaceId:c,activePlaceName:d}}catch(e){return{...fn}}}static async loginDev(){try{const e=Ur(),{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=Ir.generateOAuthState();Ir.setOAuthState(e);const a=Ir.generateOAuthNonce();Ir.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(Qr.oauth.authUrl);s.searchParams.set("client_id",Qr.oauth.clientId),s.searchParams.set("response_type",Qr.oauth.responseType),s.searchParams.set("scope",Qr.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),window.location.href=s.toString()}static async processCallback(){try{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){const e=Ir.getAccessToken();e!==s&&Ir.clearAll()}if(Ir.hasAllTokens()){return Ir.getValidSupabaseToken()||await qr.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");Ir.setAccessToken(o),Ir.setIdToken(i),Ir.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)Ir.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Ir.setSelectedAlias(e[0].alias)}if(!await qr.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return Ir.clearOAuthState(),Ir.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Ir.setManualLogout(),Ir.clearAll(),localStorage.removeItem("auth_return_url"),window.location.href="/login"}static decodeToken(e){return kr.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}}hn=xn,qr.setLogoutCallback(()=>{hn.logout()});const gn=e=>e?.placeId||null,bn=e=>e?.placeName||null,vn=a.createContext(void 0),wn=({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=N.useQueryClient()}catch{}const[o,i]=a.useState(!1),l=a.useCallback(e=>{r(a=>({...a,...e}))},[]),c=a.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),d=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})},[]),u=a.useCallback(async e=>{try{c(!0);const t=Ir.getAccessToken();if(!t)return;const r=await Br.generateToken(t,e.alias,void 0,!0);if(!r)return;Ir.setSupabaseToken(r),Ir.setSelectedAlias(e.alias);const o=Ir.extractTokenData(),i=o?.alias||e.alias,d=o?.companyId||Ir.getCompanyId(e.alias),u={id:d||e.id,name:e.name,alias:i};let m=null,p=null;if(s.user?.id&&i&&d)try{const e=(await sn.fetchActiveUsersMap(i,d)).get(s.user.id);if(e){const a=(e=>({placeId:gn(e),placeName:bn(e)}))(e);m=a.placeId,p=a.placeName}}catch(a){}l({alias:i,selectedUnit:u,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{c(!1)}},[l,n,c,s.user]),m=a.useCallback(async()=>{const e=await xn.processCallback();if(e){const e=await xn.initialize();e&&e.isAuthenticated&&(l({user:e.user,companies:e.companies,alias:e.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:e.selectedUnit,userId:e.userId,userAlias:e.userAlias,placeId:e.placeId,placeName:e.placeName,activePlaceId:e.activePlaceId,activePlaceName:e.activePlaceName}),n&&n.invalidateQueries({queryKey:["permission"]}))}return e},[l,n]),p=a.useCallback(async()=>{xn.logout(),d(),n&&await n.clear()},[d,n]),h=a.useCallback(e=>{i(e)},[]),f=a.useCallback(()=>{},[]),x=a.useCallback(()=>{},[]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Ir.areAllTokensValid()||e&&p())},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,p]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await xn.initialize();if(!e)return;a&&a.isAuthenticated?l({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&&c(!1)}catch(a){e&&(Or.handleError(a),c(!1))}})(),()=>{e=!1}},[l,c,p]);const g=a.useMemo(()=>({...s,logout:p,processCallback:m,switchUnit:u,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:h,clearSearch:f,refreshData:x}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,p,m,u,o,h,f,x]);return e.jsx(vn.Provider,{value:g,children:t})},yn=()=>{const e=a.useContext(vn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Nn({queryKey:e,service:t,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[l,c]=j.useSearchParams(),d=N.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=yn(),{t:h}=v.useTranslation(),f=a.useCallback(a=>{const t=`${e}_${a}`,s=l.get(t);return s||(l.get(a)||"")},[l,e]),x=f("search"),g=f("sortField")||Kr.sorting.defaultField,b=f("sortDirection")||Kr.sorting.defaultDirection,w=parseInt(f("page")||"1"),y=parseInt(f("limit")||String(Kr.pagination.defaultPageSize)),C=x,_=a.useMemo(()=>({search:C,sortField:g,sortDirection:b,page:w,limit:y,...n}),[C,g,b,w,y,n]),k=a.useCallback(()=>t.getAll(_),[t,_]),S=N.useQuery({queryKey:[e,u,m,_],queryFn:k,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const A=N.useMutation({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(tn.success.created(s)),o?.()},onError:e=>{i.toast.error(`${tn.error.create(s)}: ${e.message}`)}}),T=N.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(tn.success.updated(s)),o?.()},onError:e=>{i.toast.error(`${tn.error.update(s)}: ${e.message}`)}}),E=N.useMutation({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(tn.success.deleted(s))},onError:e=>{i.toast.error(`${tn.error.delete(s)}: ${e.message}`)}}),P=a.useCallback(a=>{const t={...Object.fromEntries(l)};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,c(t)},[l,c,e]),M=a.useCallback(e=>{P({search:e,page:1})},[P]),D=a.useCallback(e=>{P({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,P]),I=a.useCallback(e=>{P({page:e})},[P]),R=a.useCallback(e=>{P({limit:e,page:1})},[P]),L=a.useCallback(()=>{const a=Object.fromEntries(l),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));c(s)},[c,l,e]),[z,F]=a.useState([]),U=a.useCallback(e=>{F(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),B=a.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];F(a=>a.length===e.length?[]:e)},[S?.data?.data]),q=a.useCallback(()=>{F([])},[]),O=a.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&z.length===e.length},[z,S?.data?.data]),$=N.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(a,t)=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(h("bulk_delete_success",`${t.length} ${s}(s) deletado(s) com sucesso`)),q()},onError:e=>{i.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),V=a.useCallback((e,a)=>{const t=a?a(e):e;e.id?T.mutate({id:e.id,data:t}):A.mutate({...t,alias:u})},[u,A,T]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||Kr.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:A?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:E?.isPending??!1,error:S?.error||null,searchTerm:x,sortField:g,sortDirection:b,currentPage:w,itemsPerPage:y,queryKey:e,createEntity:A.mutate,updateEntity:(e,a)=>T.mutate({id:e,data:a}),deleteEntity:E.mutate,save:V,handleSearch:M,handleSort:D,handlePageChange:I,handleItemsPerPageChange:R,clearFilters:L,refetch:S.refetch,selectedIds:z,selectItem:U,selectAll:B,clearSelection:q,isAllSelected:O,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}function jn(e){const[t,s]=a.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return a.useEffect(()=>{const a=window.matchMedia(e);s(a.matches);const t=e=>{s(e.matches)};return a.addEventListener("change",t),()=>a.removeEventListener("change",t)},[e]),t}function Cn(e=768){return jn(`(max-width: ${e-1}px)`)}const _n=J.forwardRef(({className:a,...t},s)=>e.jsx("table",{ref:s,className:At("w-full caption-bottom text-sm table-fixed",a),...t}));_n.displayName="Table";const kn=J.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:At("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));kn.displayName="TableHeader";const Sn=J.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:At("[&_tr:last-child]:border-0",a),...t}));Sn.displayName="TableBody";const An=J.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:At("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));An.displayName="TableFooter";const Tn=J.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:At("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Tn.displayName="TableRow";const En=J.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:At("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}));En.displayName="TableHead";const Pn=J.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:At("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));Pn.displayName="TableCell";const Mn=J.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:At("mt-4 text-sm text-muted-foreground",a),...t}));function Dn({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(fr,{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(fr,{className:"h-4 w-20"},t))})},s))})]})})}function In({count:a=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:a}).map((a,t)=>e.jsxs(Lt,{children:[e.jsxs(zt,{children:[e.jsx(fr,{className:"h-4 w-3/4"}),e.jsx(fr,{className:"h-3 w-1/2"})]}),e.jsx(Bt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-3 w-full"}),e.jsx(fr,{className:"h-3 w-2/3"})]})})]},t))})}Mn.displayName="TableCaption";const Rn={default:l.FileX,search:l.Search,error:l.AlertCircle};function Ln({icon:a,title:t,description:s,action:r,className:n,variant:o="default"}){const i=!!a,l=Rn[o];return e.jsxs("div",{className:At("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:i?a:e.jsx(l,{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(Pt,{onClick:r.onClick,variant:"outline",children:r.label})]})}function zn({children:a,className:t}){const s=J.useRef(null),[r,n]=J.useState(!1);J.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 o=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:a});return r?e.jsx(Js,{delayDuration:300,children:e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:o}),e.jsx(tr,{side:"top",className:"max-w-[400px] break-words",children:a})]})}):o}const Fn=J.forwardRef(({direction:a,onMouseDown:t,isDragging:s,className:r},n)=>{const o="horizontal"===a;return e.jsx("div",{ref:n,onMouseDown:t,className:At("absolute z-20 select-none touch-none","transition-colors duration-150",o&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!o&&["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:At("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Fn.displayName="TableResizeHandle";const Un=de.Root,Bn=de.Trigger,qn=de.Group,On=de.Portal,$n=de.Sub,Vn=de.RadioGroup,Hn=J.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(de.SubTrigger,{ref:n,className:At("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(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Hn.displayName=de.SubTrigger.displayName;const Wn=J.forwardRef(({className:a,...t},s)=>e.jsx(de.SubContent,{ref:s,className:At("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}));Wn.displayName=de.SubContent.displayName;const Gn=J.forwardRef(({className:a,...t},s)=>e.jsx(de.Portal,{children:e.jsx(de.Content,{ref:s,className:At("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})}));Gn.displayName=de.Content.displayName;const Yn=J.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(de.Item,{ref:r,className:At("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}));Yn.displayName=de.Item.displayName;const Qn=J.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(de.CheckboxItem,{ref:n,className:At("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(l.Check,{className:"h-4 w-4"})})}),t]}));Qn.displayName=de.CheckboxItem.displayName;const Kn=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(de.RadioItem,{ref:r,className:At("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(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Kn.displayName=de.RadioItem.displayName;const Xn=J.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(de.Label,{ref:r,className:At("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...s}));Xn.displayName=de.Label.displayName;const Zn=J.forwardRef(({className:a,...t},s)=>e.jsx(de.Separator,{ref:s,className:At("-mx-1 my-1 h-px bg-border",a),...t}));Zn.displayName=de.Separator.displayName;const Jn=({className:a,...t})=>e.jsx("span",{className:At("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Jn.displayName="ContextMenuShortcut";const eo=({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const c=[];if(a){const e={icon:l.Edit,label:"Editar",onClick:a};c.push(e)}if(o.forEach(e=>{c.push(e)}),s){const e={icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:s};c.push(e)}if(n&&t){const e={icon:l.Trash2,label:"Excluir",onClick:t,destructive:!0};c.push(e)}const d="dropdown"===i?Gs:Yn;return e.jsx(e.Fragment,{children:c.map((a,t)=>e.jsxs(d,{onClick:a.onClick,className:At("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))})},ao=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(l.EllipsisVertical,{size:12})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(eo,{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:o,renderAs:"dropdown"})})]}),to=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>e.jsx(Js,{delayDuration:200,children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[a&&e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),a()},children:e.jsx(l.Pencil,{size:14})})}),e.jsx(tr,{children:"Editar"})]}),o.map((a,t)=>{const s=a.icon;return e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),a.onClick()},children:e.jsx(s,{size:14})})}),e.jsx(tr,{children:a.label})]},t)}),r&&e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),r()},children:n?e.jsx(l.ToggleRight,{size:14}):e.jsx(l.ToggleLeft,{size:14})})}),e.jsx(tr,{children:n?"Inativar":"Ativar"})]}),t&&s&&e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:At("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),t()},children:e.jsx(l.Trash2,{size:14})})}),e.jsx(tr,{children:"Excluir"})]})]})}),so=150;function ro({columns:e,storageKey:t,onResize:s,enabled:r=!0}){const[n,o]=a.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??so,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??so,e),{})}),[i,l]=a.useState(!1),[c,d]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),d(e),u.current=a.clientX,m.current=n[e]??so)},[r,n]);a.useEffect(()=>{if(!i||!c)return;const a=e.find(e=>e.key===c),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));o(e=>{const a={...e,[c]:t};return s?.(a),a})},h=()=>{l(!1),d(null),t&&o(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)}},[i,c,e,t,s]),a.useEffect(()=>(i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[i]);const h=a.useCallback(()=>{const a=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??so,e),{});o(a),t&&localStorage.removeItem(t),s?.(a)},[e,t,s]);return{columnWidths:n,isDragging:i,activeColumn:c,handleMouseDown:p,resetWidths:h}}const no=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"}}),oo=J.forwardRef(({className:a,variant:t,size:s,...r},n)=>e.jsx(me.Root,{ref:n,className:At(no({variant:t,size:s,className:a})),...r}));oo.displayName=me.Root.displayName;const io=J.createContext({size:"default",variant:"default"}),lo=J.forwardRef(({className:a,variant:t,size:s,children:r,...n},o)=>e.jsx(ue.Root,{ref:o,className:At("flex items-center justify-center gap-1",a),...n,children:e.jsx(io.Provider,{value:{variant:t,size:s},children:r})}));lo.displayName=ue.Root.displayName;const co=J.forwardRef(({className:a,children:t,variant:s,size:r,...n},o)=>{const i=J.useContext(io);return e.jsx(ue.Item,{ref:o,className:At(no({variant:i.variant||s,size:i.size||r}),a),...n,children:t})});co.displayName=ue.Item.displayName;const uo=a.memo(function({onNew:a,newButtonLabel:t,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:c=!1,selectedCount:d=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:f,viewMode:x,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],rightSlot:w,className:y}){const N=d>0,j=a&&s||h.length>0,C=f||b||w,_=r&&o;return j||_||C||c&&N?e.jsxs("div",{className:At("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",y),children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a&&s&&e.jsxs(Pt,{onClick:a,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),t||"Novo"]}),h.map((a,t)=>{const s=a.icon;return e.jsxs(Pt,{onClick:a.action,variant:a.variant||"outline",disabled:a.disabled,title:a.disabled?a.disabledReason:void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]}),c&&N&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[e.jsx(Is,{variant:"secondary",className:"mr-1 tabular-nums",children:d}),e.jsxs(Js,{delayDuration:200,children:[u.length>0?u.map((a,t)=>{const s=a.icon,r=a.disabled;return e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:At("h-8 w-8","destructive"===a.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:r,onClick:()=>a.action([]),children:s?e.jsx(s,{size:16}):e.jsx("span",{className:"text-xs",children:a.label[0]})})}),e.jsx(tr,{children:a.label})]},t)}):e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:e.jsx(l.Trash2,{size:16})})}),e.jsx(tr,{children:"Excluir"})]}),e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:e.jsx(l.X,{size:16})})}),e.jsx(tr,{children:"Limpar seleção"})]})]})]}),_&&e.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Dt,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),C&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[f,b&&x&&g&&e.jsx(lo,{type:"single",value:x,onValueChange:e=>e&&g(e),size:"sm",children:v.map(a=>{const t=(e=>{switch(e){case"table":return l.Table2;case"list":return l.List;case"grid":return l.LayoutGrid}})(a);return e.jsx(co,{value:a,"aria-label":"Visualizar como "+("table"===a?"tabela":"list"===a?"lista":"grade"),children:e.jsx(t,{className:"h-4 w-4"})},a)})}),w]})]}):null}),mo=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(Ps,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked);function po(e){try{const a=localStorage.getItem(e);if(!a)return null;const t=JSON.parse(a);let s=t.groupByColumns||[];return 0===s.length&&t.groupByColumn&&(s=[t.groupByColumn]),{hiddenColumns:new Set(t.hiddenColumns||[]),columnOrder:t.columnOrder||[],groupByColumns:s}}catch{return null}}function ho({columns:e,storageKey:t,enabled:s=!0}){const r=a.useMemo(()=>e.map(e=>String(e.key)),[e]),[n,o]=a.useState(()=>s&&t?po(t)?.hiddenColumns??new Set:new Set),[i,l]=a.useState(()=>{if(!s||!t)return r;const e=po(t)?.columnOrder;return e&&e.length>0?e:r}),[c,d]=a.useState(()=>s&&t?po(t)?.groupByColumns??[]:[]),[u,m]=a.useState(new Set);a.useEffect(()=>{s&&t&&function(e,a){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(a.hiddenColumns),columnOrder:a.columnOrder,groupByColumns:a.groupByColumns}))}catch{}}(t,{hiddenColumns:n,columnOrder:i,groupByColumns:c})},[n,i,c,t,s]),a.useEffect(()=>{const a=new Set(e.map(e=>String(e.key))),t=new Set(i),s=[...a].filter(e=>!t.has(e));s.length>0&&l(e=>[...e.filter(e=>a.has(e)),...s])},[e]);const p=a.useCallback(e=>n.has(e),[n]),h=a.useCallback(e=>{o(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),f=a.useCallback(()=>{o(new Set)},[]),x=a.useCallback((e,a)=>{l(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s})},[]),g=a.useCallback(e=>{m(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),b=a.useCallback(e=>{d(e),m(new Set)},[]),v=a.useCallback(e=>{d(a=>a.includes(e)?a:[...a,e])},[]),w=a.useCallback(e=>{d(a=>a.filter(a=>a!==e)),m(a=>{const t=new Set;for(const s of a)s.includes(`${e}:`)||t.add(s);return t})},[]),y=a.useCallback((e,a)=>{d(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s}),m(new Set)},[]),N=c[0]??null,j=a.useCallback(e=>{d(e?[e]:[]),m(new Set)},[]),C=a.useMemo(()=>{if(!s)return e;const a=new Map(e.map(e=>[String(e.key),e]));return i.filter(e=>!n.has(e)&&a.has(e)).map(e=>a.get(e))},[e,i,n,s]),_=a.useCallback(e=>{if(0===c.length)return[{groupKey:"__all__",groupValue:"",items:e,count:e.length,level:0}];return function e(a,t,s,r){if(0===t.length)return[{groupKey:r||"__leaf__",groupValue:"",items:a,count:a.length,level:s}];const[n,...o]=t,i=new Map;for(const l of a){const e=String(l[n]??"(vazio)");i.has(e)||i.set(e,[]),i.get(e).push(l)}return Array.from(i.entries()).map(([a,t])=>{const i=r?`${r}|${n}:${a}`:`${n}:${a}`,l=o.length>0?e(t,o,s+1,i):void 0;return{groupKey:i,groupValue:a,items:t,count:t.length,level:s,children:l}})}(e,c,0,"")},[c]);return{visibleColumns:C,allColumns:e,isColumnHidden:p,toggleColumn:h,showAllColumns:f,columnOrder:i,reorderColumns:x,groupByColumn:N,setGroupByColumn:j,groupByColumns:c,setGroupByColumns:b,addGroupByColumn:v,removeGroupByColumn:w,reorderGroupByColumns:y,getGroupedData:_,collapsedGroups:u,toggleGroupCollapse:g}}function fo({enabled:e=!1,onReorder:t}){const[s,r]=a.useState(null),[n,o]=a.useState(null),i=a.useCallback(()=>{r(null),o(null)},[]),l=a.useCallback((a,n)=>({draggable:e,onDragStart:t=>{e&&(r(a),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",String(a)),n&&t.dataTransfer.setData("application/column-key",n))},onDragOver:a=>{e&&null!==s&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDragEnter:t=>{e&&null!==s&&(t.preventDefault(),o(a))},onDrop:r=>{r.preventDefault(),e&&null!==s&&s!==a?(t(s,a),i()):i()},onDragEnd:()=>{i()}}),[e,s,t,i]);return a.useMemo(()=>({dragFromIndex:s,dragOverIndex:n,isDragging:null!==s,getDragProps:l}),[s,n,l])}function xo({columns:t,columnOrder:s,isColumnHidden:r,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:c,setGroupByColumn:d,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p}){const[h,f]=a.useState(null),[x,g]=a.useState(null),b=a.useRef(null),v=new Map(t.map(e=>[String(e.key),e])),w=s.filter(e=>v.has(e)).map(e=>v.get(e)),y=()=>{b.current=null,f(null),g(null)},N=w.some(e=>r(String(e.key)));return e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsx(Pt,{variant:"outline",size:"icon",className:"h-8 w-8",children:e.jsx(l.Columns3,{size:16})})}),e.jsxs(or,{className:"w-[260px] p-0",align:"end",children:[e.jsx("div",{className:"px-3 py-2 border-b",children:e.jsx("span",{className:"text-sm font-medium",children:"Colunas"})}),e.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:e.jsx(Js,{delayDuration:300,children:w.map((a,t)=>{const s=String(a.key),o=r(s),v=!1!==a.hideable,w=!0===a.groupable,N=u.includes(s)||c===s;return e.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{b.current=e,f(e)})(t),onDragOver:e=>((e,a)=>{e.preventDefault(),g(a)})(e,t),onDrop:()=>(e=>{null!==b.current&&b.current!==e&&i(b.current,e),b.current=null,f(null),g(null)})(t),onDragEnd:y,className:At("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",h===t&&"opacity-50",x===t&&"border-t-2 border-primary"),children:[e.jsx(l.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),e.jsx(Ps,{checked:!o,onCheckedChange:()=>v&&n(s),disabled:!v,className:"shrink-0"}),e.jsx("span",{className:At("flex-1 truncate",o&&"text-muted-foreground"),children:a.header}),w&&e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"icon",className:At("h-6 w-6 shrink-0",N&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),N?p?p(s):d?.(null):m?m(s):d?.(s)},children:e.jsx(l.Group,{size:14})})}),e.jsx(tr,{children:N?"Remover agrupamento":"Agrupar por esta coluna"})]})]},s)})})}),N&&e.jsx("div",{className:"border-t px-3 py-2",children:e.jsx(Pt,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:o,children:"Mostrar todas"})})]})]})}function go({columns:t,groupByColumns:s,addGroupByColumn:r,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,c]=a.useState(!1),[d,u]=a.useState(null),[m,p]=a.useState(null),h=new Map(t.map(e=>[String(e.key),e])),f=()=>{u(null),p(null)},x=s.length>0;return e.jsxs("div",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",c(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||c(!1)},onDrop:e=>{e.preventDefault(),c(!1);if(Array.from(e.dataTransfer.types).includes("application/group-chip-index"))return;const a=e.dataTransfer.getData("application/column-key");if(a&&!s.includes(a)){const e=h.get(a);e&&e.groupable&&r(a)}},className:At("flex items-center gap-2 px-4 py-2 min-h-[40px] border-b transition-colors",i&&"bg-primary/5 border-primary/30",!x&&"text-muted-foreground"),children:[e.jsx(l.Group,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:x?s.map((t,s)=>{const r=h.get(t);if(!r)return null;const i=d===s,c=m===s&&d!==s;return e.jsxs(a.Fragment,{children:[s>0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),e.jsxs(Is,{variant:"secondary",className:At("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",c&&"ring-2 ring-primary"),draggable:!0,onDragStart:e=>((e,a)=>{e.stopPropagation(),e.dataTransfer.setData("application/group-chip-index",String(a)),e.dataTransfer.effectAllowed="move",u(a)})(e,s),onDragOver:e=>((e,a)=>{e.preventDefault(),e.stopPropagation(),p(a)})(e,s),onDrop:e=>((e,a)=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer.getData("application/group-chip-index");if(""!==t){const e=parseInt(t,10);isNaN(e)||e===a||o(e,a)}u(null),p(null)})(e,s),onDragEnd:f,children:[r.header,e.jsx("button",{onClick:e=>{e.stopPropagation(),n(t)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:e.jsx(l.X,{size:12})})]})]},t)}):e.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const bo=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:c,customRowActions:d,enableBulkActions:u=!1,rowActionsVariant:m="dropdown",onNew:p,newButtonLabel:h,showNewButton:f=!0,customActions:x=[],hideActionBar:g,showActionBar:b=!0,showSearch:v=!1,searchValue:w,onSearchChange:y,searchPlaceholder:N,bulkActions:j=[],onBulkDelete:C,filters:_,viewMode:k,onViewModeChange:S,showViewToggle:A=!1,enableColumnResize:T=!0,resizeStorageKey:E,enableColumnManager:P=!1,columnManagerStorageKey:M})=>{const{setSearchVisible:D}=yn(),I=Cn(),R=void 0!==g?!g:b;a.useEffect(()=>{if(!v)return D(!0),()=>D(!1)},[D,v]);const L=ho({columns:s,storageKey:M,enabled:P}),z=fo({enabled:P,onReorder:L.reorderColumns}),F=P?L.visibleColumns:s,{columnWidths:U,isDragging:B,activeColumn:q,handleMouseDown:O}=ro({columns:F.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:E?`${E}-columns`:void 0,enabled:T}),$=a.useMemo(()=>(()=>{if(T)return F.map(e=>{const a=U[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=F.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`}})})(),[F,T,U]),V=p||x.length>0||v||u||_||A||P,H=R&&V,W=C||(()=>{t.bulkDelete?.(t.selectedIds)}),G=a=>e.jsx(Pn,{className:"text-center",children:c?c(a):"inline"===m?e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:e.jsx(to,{onEdit:r?()=>r(a):void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,customActions:d?d(a):[]})}):e.jsx(ao,{onEdit:r?()=>r(a):void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,customActions:d?d(a):[]})}),Y=a=>e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(a):void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,canDelete:!!i,customActions:d?d(a):[],renderAs:"context"})}),Q=P?e.jsx(xo,{columns:s,columnOrder:L.columnOrder,isColumnHidden:L.isColumnHidden,toggleColumn:L.toggleColumn,showAllColumns:L.showAllColumns,reorderColumns:L.reorderColumns,groupByColumn:L.groupByColumn,setGroupByColumn:L.setGroupByColumn,groupByColumns:L.groupByColumns,addGroupByColumn:L.addGroupByColumn,removeGroupByColumn:L.removeGroupByColumn}):void 0;if(I)return t.isLoading?e.jsx(In,{count:3}):0===t.entities.length?e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[H&&e.jsx(uo,{onNew:p,newButtonLabel:h,showNewButton:f,showSearch:v,searchValue:w,onSearchChange:y,searchPlaceholder:N,showBulkActions:u,selectedCount:t.selectedIds.length,bulkActions:j,onBulkDelete:W,onClearSelection:t.clearSelection,customActions:x,filters:_,viewMode:k,onViewModeChange:S,showViewToggle:A}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(a=>e.jsxs(Un,{children:[e.jsx(Bn,{asChild:!0,children:e.jsx(Lt,{className:At("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(Bt,{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(mo,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1",children:[F.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||c)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(a):e.jsx(ao,{onEdit:r?()=>{r(a)}:void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,customActions:d?d(a):[]})})]})]})})})}),Y(a)]},a.id))})]});const K=P&&L.groupByColumns.length>0?L.getGroupedData(t.entities):null,X=null!==K,Z=(u?1:0)+F.length+1,J=a=>e.jsxs(Un,{children:[e.jsx(Bn,{asChild:!0,children:e.jsxs(Tn,{className:At("cursor-pointer hover:bg-muted/50 relative","inline"===m&&"group",u&&t.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:[u&&e.jsx(Pn,{onClick:e=>e.stopPropagation(),children:e.jsx(mo,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),F.map(t=>e.jsx(Pn,{className:t.className,children:e.jsx(zn,{children:t.render?t.render(a):String(a[t.key]??"")})},String(t.key))),G(a)]})}),Y(a)]},a.id),ee=(t,s)=>t.map(t=>{const r=L.collapsedGroups.has(t.groupKey),n=16*t.level,o=Math.max(30,70-15*t.level);return e.jsxs(a.Fragment,{children:[e.jsx(Tn,{className:At("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>L.toggleGroupCollapse(t.groupKey),children:e.jsx(Pn,{colSpan:s,className:"py-2 px-4",children:e.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[r?e.jsx(l.ChevronRight,{size:16}):e.jsx(l.ChevronDown,{size:16}),e.jsx("span",{children:t.groupValue}),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",t.count,")"]})]})})}),!r&&(t.children?ee(t.children,s):t.items.map(J))]},t.groupKey)});return e.jsxs("div",{className:"flex flex-col h-full",children:[H&&e.jsx(uo,{onNew:p,newButtonLabel:h,showNewButton:f,showSearch:v,searchValue:w,onSearchChange:y,searchPlaceholder:N,showBulkActions:u,selectedCount:t.selectedIds.length,bulkActions:j,onBulkDelete:W,onClearSelection:t.clearSelection,customActions:x,filters:_,viewMode:k,onViewModeChange:S,showViewToggle:A,rightSlot:Q}),t.isLoading?e.jsx(Dn,{rows:5,columns:F.length}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[P&&e.jsx(go,{columns:s,groupByColumns:L.groupByColumns,addGroupByColumn:L.addGroupByColumn,removeGroupByColumn:L.removeGroupByColumn,reorderGroupByColumns:L.reorderGroupByColumns}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(_n,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),$.map((a,t)=>e.jsx("col",{style:a.style},t)),e.jsx("col",{style:{width:"inline"===m?"auto":"50px",minWidth:"50px"}})]}),e.jsx(kn,{children:e.jsxs(Tn,{children:[u&&e.jsx(En,{className:"w-[50px]",children:e.jsx(mo,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),F.map((a,s)=>{const r=T&&!1!==a.resizable,n=q===String(a.key),o=P?z.getDragProps(s,String(a.key)):{},i=z.dragFromIndex===s,c=z.dragOverIndex===s&&z.dragFromIndex!==s;return e.jsxs(En,{className:At(a.className,a.sortable&&"hover:bg-muted/50","relative transition-opacity",P&&!z.isDragging&&"cursor-grab",P&&z.isDragging&&"cursor-grabbing",i&&"opacity-50",c&&"border-l-2 border-primary"),onClick:a.sortable?()=>t.handleSort(String(a.key)):void 0,...o,children:[e.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(d=String(a.key),t.sortField!==d?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}),r&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>O(String(a.key),e),isDragging:n})]},String(a.key));var d}),e.jsx(En,{className:"w-[50px] text-center",children:"Ações"})]})}),e.jsx(Sn,{children:0===t.entities.length?e.jsx(Tn,{children:e.jsx(Pn,{colSpan:Z,className:"h-32",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):X?ee(K,Z):t.entities.map(J)})]})})]})]})};function vo(e,t,s,r){const[n,o]=a.useState({}),[i,l]=a.useState({}),c=a.useMemo(()=>e,[e]),d=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(c),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);d(e)&&(a=e.toISOString().split("T")[0])}else d(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])}),o(n),l({}),s&&s(n)},[c,t,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},f=()=>{const e=h(c),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:i,updateField:(e,a)=>{o(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(c).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}),i[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(c).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:f,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),f()&&e(n)}}}const wo=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],yo=({value:a="#3b82f6",onChange:t,label:s,customColorLabel:r="Cor personalizada",presetColorsLabel:n="Cores predefinidas"})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Rt,{children:s}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pt,{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(or,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Rt,{htmlFor:"color-input",children:r}),e.jsx(Dt,{id:"color-input",type:"color",value:a,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Rt,{children:n}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:wo.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))})]})]})})]})]}),No={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},jo=({value:t="Star",onChange:s,label:r,searchLabel:n="Pesquisar"})=>{const[o,i]=a.useState(""),c=Object.entries(No).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),d=No[t]||l.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Rt,{children:r}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),t]})}),e.jsx(or,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Rt,{htmlFor:"icon-search",children:n}),e.jsx(Dt,{id:"icon-search",placeholder:n,value:o,onChange:e=>i(e.target.value)})]}),e.jsx(vr,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:c.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))})})]})})]})]})},Co=J.forwardRef(({className:a,...t},s)=>e.jsx(pe.Root,{className:At("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(pe.Thumb,{className:At("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")})}));Co.displayName=pe.Root.displayName;const _o=(e={})=>{const{user:a,alias:t}=yn(),{enabled:s=!0}=e;return N.useQuery({queryKey:["qualiex-users",t],queryFn:()=>sn.getUsers(t),enabled:s&&!!t&&!!a,staleTime:3e5,retry:2,retryDelay:1e3})},ko=({value:t,onChange:s,multiple:r=!1,label:n,required:o,placeholder:i,icon:l,maxDisplayedBadges:c,className:d,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:f,sortOptions:x=!0,popoverContainer:g,onOpen:b,onClose:v})=>{const{data:w=[],isLoading:y,error:N}=_o({enabled:m}),j=a.useMemo(()=>f?w.filter(f):w,[w,f]),C=a.useMemo(()=>{const e=t?Array.isArray(t)?t:[t]:[];if(0===e.length)return j;const a=new Set(j.map(e=>e.userId||e.id||"")),s=e.filter(e=>e&&!a.has(e));if(0===s.length)return j;const r=s.map(e=>({userId:e,id:e,userName:"[Usuário inativo]",userEmail:""}));return[...j,...r]},[j,t]),_=a.useCallback(e=>{if("custom"===p&&h)return h(e);const a=e.userName||"";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(br,{multiple:r,value:t??(r?[]:""),onChange:s,options:C,isLoading:y,error:N,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:_,placeholder:i||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:"Nenhum resultado encontrado",label:n,required:o,icon:l,maxDisplayedBadges:c,disabled:u,className:d,sortOptions:x,popoverContainer:g,onOpen:b,onClose:v})};function So({title:t,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:c=!1,usersData:d}){const[u,m]=a.useState(s?.[0]?.id||""),p=a.useRef(null),[h,f]=a.useState(null),x=a.useCallback(e=>{p.current=e,f(e)},[]),g=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:b,errors:v,updateField:w,handleSubmit:y}=vo(g,r,void 0,i),N=a.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[s,b]),j=a.useMemo(()=>{const e=N.find(e=>e.id===u);if(e&&!e.disabled)return u;const a=N.find(e=>!e.disabled);return a?.id||u},[N,u]);a.useEffect(()=>{j!==u&&m(j)},[j,u]);const C=N.find(e=>e.id===j),_=a=>{const t=(a.computedValue,b[a.name]),s=void 0!==t?t:"",r=v[a.name];switch(a.type){case"group":const t="horizontal"===a.layout,n=t?`flex gap-3 w-full ${a.className||""}`:"space-y-3",o=t?At("space-y-2 w-full",a.wrapperClassName):At("space-y-2",a.className,a.wrapperClassName);return e.jsxs("div",{className:o,children:[a.label,e.jsx("div",{className:n,children:a.fields?.map(e=>_(e))})]},a.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ko,{value:s||"",onChange:e=>w(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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ms,{id:a.name,value:s||"",onChange:e=>{w(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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(ys,{value:String(s),onValueChange:e=>{w(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e.jsx(Cs,{className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(js,{placeholder:a.placeholder})}),e.jsx(Ss,{children:a.options?.map(a=>e.jsx(Ts,{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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(br,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>w(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:r,popoverContainer:h,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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Dt,{id:a.name,type:"date",value:String(s),onChange:e=>w(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:At("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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Dt,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>w(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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(yo,{value:s||a.defaultValue||"#3b82f6",onChange:e=>w(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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(jo,{value:s||a.defaultValue||"Star",onChange:e=>w(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 i=a.component,l="function"==typeof a.componentProps?a.componentProps(b):a.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e.jsxs(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(i,{value:s,onChange:e=>{w(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:r,popoverContainer:h,...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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Dt,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,s=""===t?null:Number(t);w(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(Ps,{id:a.name,checked:!!s,onCheckedChange:e=>w(a.name,e),disabled:a.disabled}),e.jsxs(Rt,{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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Co,{id:a.name,checked:!!s,onCheckedChange:e=>w(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(Rt,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Dt,{id:a.name,type:"text",value:s||"",onChange:e=>{w(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)}},k=a.useCallback(()=>{if(!C)return null;if(C.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(C.component){const a=C.component;return e.jsx(a,{formData:b,updateField:w,errors:v,users:d,disabled:C.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:C.fields.map(_)})},[C,b,w,v,d,_]),S=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[N.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:N.map(a=>e.jsx(Pt,{variant:j===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=N.find(a=>a.id===e);a&&!a.disabled&&m(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 py-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):e.jsxs("form",{onSubmit:y(n),className:"space-y-3 md:space-y-4",children:[k(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Pt,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),e.jsx(Pt,{type:"submit",disabled:c,children:l||"Salvar"})]})]})})]});return e.jsx(es,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:e.jsxs(os,{ref:x,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(is,{showSeparator:!0,children:[e.jsx(ds,{children:t}),e.jsx(us,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Ao({currentPage:a,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:c}=v.useTranslation();if(0===s)return null;const d=(a-1)*r+1,u=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"===i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:c("rows_per_page","Linhas por página")}),e.jsxs(ys,{value:String(r),onValueChange:e=>o(Number(e)),children:[e.jsx(Cs,{className:"h-8 w-[70px]",children:e.jsx(js,{})}),e.jsxs(Ss,{children:[e.jsx(Ts,{value:"10",children:"10"}),e.jsx(Ts,{value:"25",children:"25"}),e.jsx(Ts,{value:"50",children:"50"}),e.jsx(Ts,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[d,"-",u," ",c("of","de")," ",s," ",c("items","itens")]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Pt,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsLeft,{size:16})}),e.jsx(Pt,{variant:"outline",size:"sm",onClick:()=>n(a-1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(l.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:c("of","de")}),e.jsx("span",{className:"text-sm font-medium",children:t})]}),e.jsx(Pt,{variant:"outline",size:"sm",onClick:()=>n(a+1),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronRight,{size:16})}),e.jsx(Pt,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsRight,{size:16})})]})]})}function To({manager:a}){return e.jsx(Ao,{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 Eo={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Po={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Mo={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function Do({children:a,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return e.jsx("div",{className:At("flex","column"===t?"flex-col":"flex-row",Eo[s],Po[r],Mo[n],o&&"flex-wrap",i),children:a})}function Io({manager:a,filters:t,inline:s=!1}){const{isSearchVisible:r}=yn(),n=a.searchTerm,o=e.jsxs(e.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Dt,{placeholder:"Pesquisar",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(ys,{value:a.value||"",onValueChange:e=>a.onChange?.(e),children:[e.jsx(Cs,{className:"w-[180px]",children:e.jsx(js,{placeholder:a.placeholder})}),e.jsx(Ss,{children:a.options.map(a=>e.jsx(Ts,{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}`)}),n&&e.jsxs(Pt,{variant:"outline",onClick:a.clearFilters,className:"whitespace-nowrap",children:[e.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(Do,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(Do,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function Ro({manager:t,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){t&&t.queryKey;const{setSearchVisible:l}=yn(),[c,d]=j.useSearchParams(),[u,m]=a.useState(!1),[p,h]=a.useState(null),[f,x]=a.useState({isOpen:!1,entityId:null,entityName:""}),[g,b]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),a.useEffect(()=>{if(i&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!c.has(e)&&!c.has(a)){const t=Object.fromEntries(c);t[e]=i.column,t[a]=i.direction,d(t)}}},[]);const v=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,w="function"==typeof t?.deleteEntity?e=>{x({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,y=()=>{x({isOpen:!1,entityId:null,entityName:""})},N=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,C=(s.customActions||[]).map(e=>({label:e.label,icon:e.icon,action:e.action,variant:"destructive"===e.variant?"default":e.variant,disabled:e.disabled,disabledReason:e.disabledReason}));return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&e.jsx(uo,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:N,showSearch:s.showSearch,searchValue:t.searchTerm,onSearchChange:t.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:t.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{b({isOpen:!0,count:t.selectedIds.length})},onClearSelection:t.clearSelection,customActions:C,filters:s.filters&&s.filters.length>0?e.jsx(Io,{manager:t,filters:s.filters,inline:!0}):void 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(bo,{manager:t,columns:s.columns,onEdit:v,onDelete:w,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(To,{manager:t})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&e.jsx(So,{open:u,title:p?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:p||void 0,onSubmit:e=>{n(e),m(!1),h(null)},onCancel:()=>{m(!1),h(null)},isLoading:t.isLoading,submitButtonText:p?"Atualizar":"Criar"}),e.jsx(es,{open:f.isOpen,onOpenChange:y,children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(ds,{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:f.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(cs,{children:[e.jsx(Pt,{variant:"outline",onClick:y,children:"Cancelar"}),e.jsx(Pt,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof t?.deleteEntity&&(t.deleteEntity(f.entityId),x({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(es,{open:g.isOpen,onOpenChange:()=>b({isOpen:!1,count:0}),children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(ds,{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:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(cs,{children:[e.jsx(Pt,{variant:"outline",onClick:()=>b({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(Pt,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),b({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Lo(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 zo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Fo=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"}}),Uo={info:l.Info,warning:l.Info,danger:l.AlertTriangle,success:l.CheckCircle},Bo=J.forwardRef(({className:a,variant:t="info",showIcon:s=!0,children:r,...n},o)=>{const i=Uo[t||"info"];return e.jsxs("div",{ref:o,role:"alert",className:At(Fo({variant:t}),a),...n,children:[s&&e.jsx(i,{className:"h-4 w-4"}),r]})});Bo.displayName="Alert";const qo=J.forwardRef(({className:a,...t},s)=>e.jsx("h5",{ref:s,className:At("mb-1 font-medium leading-none tracking-tight",a),...t}));qo.displayName="AlertTitle";const Oo=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("text-sm [&_p]:leading-relaxed",a),...t}));Oo.displayName="AlertDescription";const $o=a.createContext(void 0);function Vo({children:t,actions:s}){const[r,n]=a.useState({}),[o,i]=a.useState(s);a.useEffect(()=>{i(s)},[s]);const l=a.useCallback(()=>n({}),[]),c=a.useMemo(()=>({metadata:r,setMetadata:n,clearMetadata:l,headerActions:o,setHeaderActions:i}),[r,l,o]);return e.jsx($o.Provider,{value:c,children:t})}function Ho(){const e=a.useContext($o);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var Wo={access_denied:"Acesso negado",actions:"Ações",activate:"Ativar",activate_selected:"Ativar Selecionados",active:"Ativo",active_employees:"Colaboradores Ativos",active_plural:"Ativos",add:"Adicionar",additional_fields:"Campos Adicionais",address:"Endereço",admin:"Admin",admin_access:"Acesso Admin",admin_system:"Administração do Sistema",admission_date:"Data de Admissão",alignment:"Alinhamento",all:"Todos",allow_download:"Permitir Download",allowed_formats:"Formatos permitidos",alt:"Texto Alternativo",api_response:"Resposta da API:",apply_filters:"Aplicar filtros",auth_required:"Autenticação necessária",autoplay:"Reprodução Automática",back:"Voltar",background_color:"Cor do Fundo",birth_date:"Data de Nascimento",boolean:"Booleano",bulk_actions:"Ações em lote",cancel:"Cancelar",cancelled:"Cancelado",caption:"Legenda",center:"Centro",chatbot:"Chatbot",checking_access:"Verificando acesso...",choose_file:"Escolher arquivo",city:"Cidade",clear:"Limpar",clear_filters:"Limpar filtros",clear_search:"Limpar busca",clear_selection:"Limpar seleção",click_to_create_post:"Clique no botão abaixo para criar um novo post",close:"Fechar",collaborator:"Colaborador",config:"Configuração",config_info:"Informações da Configuração",config_info_description:"Defina a chave e o valor da configuração",config_key:"Chave da Configuração",configs:"Configurações",comments:"Comentários",community:"Comunidade",community_posts:"Posts da comunidade",companies:"Empresas",company:"Empresa",completed:"Concluído",confirm:"Confirmar",confirm_delete:"Tem certeza que deseja excluir?",confirm_delete_message:"Esta ação não pode ser desfeita.",confirm_password:"Confirmar Senha",content:"Conteúdo",content_blocks:"Blocos de Conteúdo",controls:"Controles",copy:"Copiar",country:"País",courses:"Cursos",create:"Criar",create_first_post_hint:'Crie seu primeiro post na aba "Criar Post"',create_post:"Criar Novo Post",create_success:"Criado com sucesso",create_unit:"Criar Nova Unidade",created_at:"Criado em",created_by:"Criado por",currency:"Moeda",dashboard:"Dashboard",date:"Data",date_and_time:"Data e Hora",date_format:"Formato de Data",date_time_format:"Formato de Data/Hora",deactivate:"Inativar",deactivate_selected:"Inativar Selecionados",default:"Padrão",delete:"Excluir",delete_confirmation:"Confirmação de Exclusão",delete_success:"Excluído com sucesso",deleting:"Excluindo...",department:"Departamento",description:"Descrição",deselect_all:"Desselecionar todos",design_system:"Design System",design_tokens_and_docs:"Design tokens e documentação",details:"Detalhes",disabled:"Desabilitado",download:"Baixar",drag_drop:"Arraste e solte ou clique para selecionar",duplicate:"Duplicar",edit:"Editar",edit_additional_fields:"Editar Campos Adicionais",editor_hint:"💡 Dica: Use Ctrl+B (negrito), Ctrl+I (itálico), Ctrl+U (sublinhado) ou clique nos botões.",education:"Educação",email:"E-mail",email_placeholder:"email@empresa.com",embed:"Código Embed",employee:"Colaborador",employee_activated:"Colaborador ativado com sucesso",employee_deactivated:"Colaborador inativado com sucesso",employee_information:"Informações do Colaborador",employees:"Colaboradores",employees_removed:"{{count}} colaborador(es) removido(s)",empty_description:"Não há dados para exibir no momento.",empty_title:"Nenhum item encontrado",en:"EN",enabled:"Habilitado",enter_full_name:"Digite o nome completo",enter_link_url:"Digite a URL do link:",enter_youtube_url:"Cole a URL do vídeo do YouTube:",error:"Erro",error_changing_employee_status:"Erro ao alterar status do colaborador",error_creating:"Erro ao criar",error_deleting:"Erro ao excluir",error_loading:"Erro ao carregar",error_no_image:"Nenhuma imagem selecionada",error_no_video:"Nenhum vídeo selecionado",error_saving:"Erro ao salvar",error_updating:"Erro ao atualizar",es:"ES",export:"Exportar",failed:"Falhou",field_name:"Nome do Campo",field_type:"Tipo",file:"Arquivo de Vídeo",file_upload_error:"Erro ao enviar arquivo",file_upload_success:"Arquivo enviado com sucesso",filter:"Filtrar",first_name:"Nome",font:"Fonte",format_html:"HTML",format_markdown:"Markdown",format_plain:"Texto Simples",format_rich:"Rich (WYSIWYG)",full_name:"Nome Completo",general_settings:"Configurações Gerais",height:"Altura",home:"Início",html_warning:"⚠️ HTML será sanitizado para segurança",identification:"Identificação",identification_invalid:"Identificação inválida",image:"Imagem",import:"Importar",inactive:"Inativo",inactive_plural:"Inativos",info:"Informação",input_type:"Tipo de Entrada",input_type_embed:"Embed",input_type_upload:"Upload",integration:"Integração",invalid_date:"Data inválida",invalid_email:"E-mail inválido",invalid_file_type:"Por favor, selecione um arquivo de vídeo",invalid_phone:"Telefone inválido",invalid_youtube_url:"URL do YouTube inválida. Use o formato: https://www.youtube.com/watch?v=VIDEO_ID",item_details:"Detalhes do item",items:"itens",items_per_page:"Itens por página",key:"Chave",language:"Idioma",last_10_logins:"Últimos 10 Logins",last_modification:"Última Modificação",last_name:"Sobrenome",leader:"Líder",leadership:"Liderança",leadership_hierarchy:"Hierarquia de liderança",left:"Esquerda",link_copied:"Link copiado para a área de transferência",list:"Lista",loading:"Carregando...",loading_data:"Carregando dados...",logout:"Sair",manage_reports:"Gerenciar relatórios",management:"Gestão",management_access_control:"Controle de acesso a gestão",management_permission:"Permissão de Gestão",management_permissions:"Permissões de Gestão",markdown_hint:"💡 Suporte a: **negrito**, *itálico*, [links](url), parágrafos",max_file_size:"Tamanho máximo",migration:"Migração",module:"Módulo",module_title:"Título do módulo",modules:"Módulos",name:"Nome",new:"Novo",new_password:"Nova Senha",new_value:"Novo valor",next:"Próximo",no:"Não",no_additional_fields:"Nenhum campo adicional configurado.",no_content_preview:"Nenhum conteúdo para visualizar...",no_data:"Nenhum dado disponível",no_file_selected:"Nenhum arquivo selecionado",no_items_found:"Nenhum item encontrado",no_logins_registered:"Nenhum login registrado ainda.",no_options:"Nenhuma opção disponível",no_permission_to_access_reports:"Sem permissão para acessar relatórios",no_posts_found:"Nenhum post encontrado",no_results:"Nenhum resultado encontrado",no_title:"Sem título",notifications:"Notificações",nr1:"Pulso",of:"de",old_password:"Senha Atual",open_external_link:"Abrir link externo",open_wiki:"Abrir Wiki",order:"Ordem",overview:"Visão geral",page:"Página",password:"Senha",paste_html_placeholder:"Cole ou escreva HTML aqui...",pdi:"PDI",pending:"Pendente",performance:"Desempenho",permissions:"Permissões",permissions_roles:"Permissões e Roles",phone:"Telefone",place:"Local",placeholder_select:"Selecione...",places:"Locais",plain_text_placeholder:"Digite texto simples aqui...",position:"Cargo",posts:"Publicações",preferences:"Preferências de Internacionalização",preview:"Preview",previous:"Anterior",processing:"Processando...",profile:"Perfil",pt:"PT",qualiex_places_hierarchy:"Hierarquia de locais do Qualiex",recipient_email:"Email Destinatário",redirecting:"Redirecionando...",refresh_data:"Atualizar dados",reload:"Recarregar",remove:"Remover",remove_confirm:"Tem certeza que deseja remover?",removing:"Removendo...",reports:"Relatórios",required_field:"Campo obrigatório",restricted_access:"Acesso restrito",results:"resultados",right:"Direita",role:"Papel",roles:"Perfis",rows_per_page:"Registros por página",save:"Salvar",save_block:"Salvar Bloco",save_success:"Salvo com sucesso",saving:"Salvando...",search:"Pesquisar",search_placeholder:"Pesquisar...",search_user:"Buscar usuário...",searchDateFormat:"Buscar formato...",searchTimezone:"Buscar fuso horário...",section:"Seção",select_all:"Selecionar todos",select_collaborator:"Selecionar Colaborador",select_option:"Selecione uma opção",select_placeholder:"Selecione...",selectDateFormat:"Selecione o formato",selectTimezone:"Selecione o fuso horário",select_text_for_link:"Selecione o texto que deseja transformar em link",select_unit_collaborator:"Selecione um colaborador da unidade",select_user:"Selecionar Usuário",select_user_for_admin_access:"Selecione um usuário para dar acesso admin",select_video:"Selecionar Vídeo",selected:"selecionado(s)",selected_count:"{{count}} selecionado(s)",send:"Enviar",settings:"Configurações",settings_summary:"Resumo das configurações",showing:"Mostrando",size:"Tamanho",skills:"Habilidades",state:"Estado",status:"Status",subordinates:"Subordinados",success:"Sucesso",superior:"Superior Imediato",superior_none:"Nenhum superior",superior_search:"Buscar superior...",system_administration:"Administração do sistema",system_logs:"Logs do Sistema",template_variables:"Variáveis do Template",test_email:"Testar Envio de Email",text:"Texto",text_color:"Cor do Texto",text_format:"Formato de Texto",thumbnail:"Thumbnail",timezone:"Fuso Horário",title:"Título",to:"até",total:"Total",trainings:"Treinamentos",translation:"Tradução",translation_description:"Informações da tradução",translations:"Traduções",type:"Tipo",type_to_search:"Digite para pesquisar",unit:"Unidade",units:"Unidades",unsupported:"Formato não suportado",update:"Atualizar",value:"Valor",update_success:"Atualizado com sucesso",updated_at:"Atualizado em",updated_by:"Atualizado por",updating:"Atualizando...",upload:"Upload",useSystemDefaults:"Usar padrão do sistema",uploading:"Enviando...",url:"URL",url_placeholder:"https://exemplo.com/imagem.jpg",user:"Usuário",user_management:"Gestão de Usuários",username:"Usuário",users:"Usuários",video:"Vídeo",view:"Visualizar",view_mode_grid:"Grade",view_mode_list:"Lista",view_mode_table:"Tabela",warning:"Aviso",width:"Largura",yes:"Sim",zip_code:"CEP"},Go={access_denied:"Access denied",actions:"Actions",activate:"Activate",activate_selected:"Activate Selected",active:"Active",active_employees:"Active Employees",active_plural:"Active",add:"Add",additional_fields:"Additional Fields",address:"Address",admin:"Admin",admin_access:"Admin Access",admin_system:"System Administration",admission_date:"Admission Date",alignment:"Alignment",all:"All",allow_download:"Allow Download",allowed_formats:"Allowed formats",alt:"Alt Text",api_response:"API Response:",apply_filters:"Apply filters",auth_required:"Authentication required",autoplay:"Autoplay",back:"Back",background_color:"Background Color",birth_date:"Birth Date",boolean:"Boolean",bulk_actions:"Bulk actions",cancel:"Cancel",cancelled:"Cancelled",caption:"Caption",center:"Center",chatbot:"Chatbot",checking_access:"Checking access...",choose_file:"Choose file",city:"City",clear:"Clear",clear_filters:"Clear filters",clear_search:"Clear search",clear_selection:"Clear selection",click_to_create_post:"Click the button below to create a new post",close:"Close",collaborator:"Collaborator",config:"Configuration",config_info:"Configuration Info",config_info_description:"Set the configuration key and value",config_key:"Configuration Key",configs:"Configurations",comments:"Comments",community:"Community",community_posts:"Community posts",companies:"Companies",company:"Company",completed:"Completed",confirm:"Confirm",confirm_delete:"Are you sure you want to delete?",confirm_delete_message:"This action cannot be undone.",confirm_password:"Confirm Password",content:"Content",content_blocks:"Content Blocks",controls:"Controls",copy:"Copy",country:"Country",courses:"Courses",create:"Create",create_first_post_hint:'Create your first post in the "Create Post" tab',create_post:"Create New Post",create_success:"Created successfully",create_unit:"Create New Unit",created_at:"Created at",created_by:"Created by",currency:"Currency",dashboard:"Dashboard",date:"Date",date_and_time:"Date and Time",date_format:"Date Format",date_time_format:"Date/Time Format",deactivate:"Deactivate",deactivate_selected:"Deactivate Selected",default:"Default",delete:"Delete",delete_confirmation:"Delete Confirmation",delete_success:"Deleted successfully",deleting:"Deleting...",department:"Department",description:"Description",deselect_all:"Deselect all",design_system:"Design System",design_tokens_and_docs:"Design tokens and documentation",details:"Details",disabled:"Disabled",download:"Download",drag_drop:"Drag and drop or click to select",duplicate:"Duplicate",edit:"Edit",edit_additional_fields:"Edit Additional Fields",editor_hint:"💡 Hint: Use Ctrl+B (bold), Ctrl+I (italic), Ctrl+U (underline) or click the buttons.",education:"Education",email:"Email",email_placeholder:"email@company.com",embed:"Embed Code",employee:"Employee",employee_activated:"Employee activated successfully",employee_deactivated:"Employee deactivated successfully",employee_information:"Employee Information",employees:"Employees",employees_removed:"{{count}} employee(s) removed",empty_description:"There is no data to display at this time.",empty_title:"No items found",en:"EN",enabled:"Enabled",enter_full_name:"Enter full name",enter_link_url:"Enter link URL:",enter_youtube_url:"Paste YouTube video URL:",error:"Error",error_changing_employee_status:"Error changing employee status",error_creating:"Error creating",error_deleting:"Error deleting",error_loading:"Error loading",error_no_image:"No image selected",error_no_video:"No video selected",error_saving:"Error saving",error_updating:"Error updating",es:"ES",export:"Export",failed:"Failed",field_name:"Field Name",field_type:"Type",file:"Video File",file_upload_error:"Error uploading file",file_upload_success:"File uploaded successfully",filter:"Filter",first_name:"First Name",font:"Font",format_html:"HTML",format_markdown:"Markdown",format_plain:"Plain Text",format_rich:"Rich (WYSIWYG)",full_name:"Full Name",general_settings:"General Settings",height:"Height",home:"Home",html_warning:"⚠️ HTML will be sanitized for security",identification:"Identification",identification_invalid:"Invalid identification",image:"Image",import:"Import",inactive:"Inactive",inactive_plural:"Inactive",info:"Information",input_type:"Input Type",input_type_embed:"Embed",input_type_upload:"Upload",integration:"Integration",invalid_date:"Invalid date",invalid_email:"Invalid email",invalid_file_type:"Please select a video file",invalid_phone:"Invalid phone",invalid_youtube_url:"Invalid YouTube URL. Use format: https://www.youtube.com/watch?v=VIDEO_ID",item_details:"Item details",items:"items",items_per_page:"Items per page",key:"Key",language:"Language",last_10_logins:"Last 10 Logins",last_modification:"Last Modification",last_name:"Last Name",leader:"Leader",leadership:"Leadership",leadership_hierarchy:"Leadership hierarchy",left:"Left",link_copied:"Link copied to clipboard",list:"List",loading:"Loading...",loading_data:"Loading data...",logout:"Logout",manage_reports:"Manage reports",management:"Management",management_access_control:"Management access control",management_permission:"Management Permission",management_permissions:"Management Permissions",markdown_hint:"💡 Supports: **bold**, *italic*, [links](url), paragraphs",max_file_size:"Maximum size",migration:"Migration",module:"Module",module_title:"Module title",modules:"Modules",name:"Name",new:"New",new_password:"New Password",new_value:"New value",next:"Next",no:"No",no_additional_fields:"No additional fields configured.",no_content_preview:"No content to preview...",no_data:"No data available",no_file_selected:"No file selected",no_items_found:"No items found",no_logins_registered:"No logins registered yet.",no_options:"No options available",no_permission_to_access_reports:"No permission to access reports",no_posts_found:"No posts found",no_results:"No results found",no_title:"No title",notifications:"Notifications",nr1:"Pulse",of:"of",old_password:"Current Password",open_external_link:"Open external link",open_wiki:"Open Wiki",order:"Order",overview:"Overview",page:"Page",password:"Password",paste_html_placeholder:"Paste or write HTML here...",pdi:"PDI",pending:"Pending",performance:"Performance",permissions:"Permissions",permissions_roles:"Permissions and Roles",phone:"Phone",place:"Place",placeholder_select:"Select...",places:"Places",plain_text_placeholder:"Enter plain text here...",position:"Position",posts:"Posts",preferences:"Internationalization Preferences",preview:"Preview",previous:"Previous",processing:"Processing...",profile:"Profile",pt:"PT",qualiex_places_hierarchy:"Qualiex places hierarchy",recipient_email:"Recipient Email",redirecting:"Redirecting...",refresh_data:"Refresh data",reload:"Reload",remove:"Remove",remove_confirm:"Are you sure you want to remove?",removing:"Removing...",reports:"Reports",required_field:"Required field",restricted_access:"Restricted access",results:"results",right:"Right",role:"Role",roles:"Roles",rows_per_page:"Rows per page",save:"Save",save_block:"Save Block",save_success:"Saved successfully",saving:"Saving...",search:"Search",search_placeholder:"Search...",search_user:"Search user...",searchDateFormat:"Search format...",searchTimezone:"Search timezone...",section:"Section",select_all:"Select all",select_collaborator:"Select Collaborator",select_option:"Select an option",select_placeholder:"Select...",selectDateFormat:"Select format",selectTimezone:"Select timezone",select_text_for_link:"Select the text you want to turn into a link",select_unit_collaborator:"Select a unit collaborator",select_user:"Select User",select_user_for_admin_access:"Select a user to grant admin access",select_video:"Select Video",selected:"selected",selected_count:"{{count}} selected",send:"Send",settings:"Settings",settings_summary:"Settings summary",showing:"Showing",size:"Size",skills:"Skills",state:"State",status:"Status",subordinates:"Subordinates",success:"Success",superior:"Immediate Superior",superior_none:"No superior",superior_search:"Search superior...",system_administration:"System administration",system_logs:"System Logs",template_variables:"Template Variables",test_email:"Test Email Sending",text:"Text",text_color:"Text Color",text_format:"Text Format",thumbnail:"Thumbnail",timezone:"Timezone",title:"Title",to:"to",total:"Total",trainings:"Trainings",translation:"Translation",translation_description:"Translation information",translations:"Translations",type:"Type",type_to_search:"Type to search",unit:"Unit",units:"Units",unsupported:"Unsupported format",update:"Update",value:"Value",update_success:"Updated successfully",updated_at:"Updated at",updated_by:"Updated by",updating:"Updating...",upload:"Upload",useSystemDefaults:"Use system defaults",uploading:"Uploading...",url:"URL",url_placeholder:"https://example.com/image.jpg",user:"User",user_management:"User Management",username:"Username",users:"Users",video:"Video",view:"View",view_mode_grid:"Grid",view_mode_list:"List",view_mode_table:"Table",warning:"Warning",width:"Width",yes:"Yes",zip_code:"ZIP Code"},Yo={access_denied:"Acesso negado",actions:"Acciones",activate:"Activar",activate_selected:"Activar Seleccionados",active:"Activo",active_employees:"Empleados Activos",active_plural:"Activos",add:"Agregar",additional_fields:"Campos Adicionales",address:"Dirección",admin:"Admin",admin_access:"Acceso Admin",admin_system:"Administración del Sistema",admission_date:"Fecha de Admisión",alignment:"Alineación",all:"Todos",allow_download:"Permitir Descarga",allowed_formats:"Formatos permitidos",alt:"Texto Alternativo",api_response:"Respuesta de la API:",apply_filters:"Aplicar filtros",auth_required:"Autenticación requerida",autoplay:"Reproducción Automática",back:"Volver",background_color:"Color de Fondo",birth_date:"Fecha de Nacimiento",boolean:"Booleano",bulk_actions:"Acciones masivas",cancel:"Cancelar",cancelled:"Cancelado",caption:"Leyenda",center:"Centro",chatbot:"Chatbot",checking_access:"Verificando acceso...",choose_file:"Elegir archivo",city:"Ciudad",clear:"Limpiar",clear_filters:"Limpiar filtros",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",click_to_create_post:"Haga clic en el botón de abajo para crear una nueva publicación",close:"Cerrar",collaborator:"Colaborador",config:"Configuración",config_info:"Información de Configuración",config_info_description:"Defina la clave y el valor de la configuración",config_key:"Clave de Configuración",configs:"Configuraciones",comments:"Comentarios",community:"Comunidad",community_posts:"Publicaciones de la comunidad",companies:"Empresas",company:"Empresa",completed:"Completado",confirm:"Confirmar",confirm_delete:"¿Está seguro de que desea eliminar?",confirm_delete_message:"Esta acción no se puede deshacer.",confirm_password:"Confirmar Contraseña",content:"Contenido",content_blocks:"Bloques de Contenido",controls:"Controles",copy:"Copiar",country:"País",courses:"Cursos",create:"Crear",create_first_post_hint:'Crea tu primera publicación en la pestaña "Crear Publicación"',create_post:"Crear Nueva Publicación",create_success:"Creado exitosamente",create_unit:"Crear Nueva Unidad",created_at:"Creado en",created_by:"Creado por",currency:"Moneda",dashboard:"Panel",date:"Fecha",date_and_time:"Fecha y Hora",date_format:"Formato de Fecha",date_time_format:"Formato de Fecha/Hora",deactivate:"Desactivar",deactivate_selected:"Desactivar Seleccionados",default:"Por Defecto",delete:"Eliminar",delete_confirmation:"Confirmación de Eliminación",delete_success:"Eliminado exitosamente",deleting:"Eliminando...",department:"Departamento",description:"Descripción",deselect_all:"Deseleccionar todo",design_system:"Sistema de Diseño",design_tokens_and_docs:"Tokens de diseño y documentación",details:"Detalles",disabled:"Deshabilitado",download:"Descargar",drag_drop:"Arrastre y suelte o haga clic para seleccionar",duplicate:"Duplicar",edit:"Editar",edit_additional_fields:"Editar Campos Adicionales",editor_hint:"💡 Consejo: Use Ctrl+B (negrita), Ctrl+I (cursiva), Ctrl+U (subrayado) o haga clic en los botones.",education:"Educación",email:"Correo electrónico",email_placeholder:"email@empresa.com",embed:"Código Embed",employee:"Empleado",employee_activated:"Empleado activado exitosamente",employee_deactivated:"Empleado desactivado exitosamente",employee_information:"Información del Empleado",employees:"Empleados",employees_removed:"{{count}} empleado(s) eliminado(s)",empty_description:"No hay datos para mostrar en este momento.",empty_title:"No se encontraron elementos",en:"EN",enabled:"Habilitado",enter_full_name:"Ingrese el nombre completo",enter_link_url:"Ingrese la URL del enlace:",enter_youtube_url:"Pegue la URL del video de YouTube:",error:"Error",error_changing_employee_status:"Error al cambiar el estado del empleado",error_creating:"Error al crear",error_deleting:"Error al eliminar",error_loading:"Error al cargar",error_no_image:"Ninguna imagen seleccionada",error_no_video:"Ningún video seleccionado",error_saving:"Error al guardar",error_updating:"Error al actualizar",es:"ES",export:"Exportar",failed:"Fallido",field_name:"Nombre del Campo",field_type:"Tipo",file:"Archivo de Video",file_upload_error:"Error al cargar el archivo",file_upload_success:"Archivo cargado exitosamente",filter:"Filtrar",first_name:"Nombre",font:"Fuente",format_html:"HTML",format_markdown:"Markdown",format_plain:"Texto Simple",format_rich:"Rich (WYSIWYG)",full_name:"Nombre Completo",general_settings:"Configuración General",height:"Altura",home:"Inicio",html_warning:"⚠️ HTML será sanitizado por seguridad",identification:"Identificación",identification_invalid:"Identificación inválida",image:"Imagen",import:"Importar",inactive:"Inactivo",inactive_plural:"Inactivos",info:"Información",input_type:"Tipo de Entrada",input_type_embed:"Incrustar",input_type_upload:"Cargar",integration:"Integración",invalid_date:"Fecha inválida",invalid_email:"Correo electrónico inválido",invalid_file_type:"Por favor, seleccione un archivo de video",invalid_phone:"Teléfono inválido",invalid_youtube_url:"URL de YouTube inválida. Use el formato: https://www.youtube.com/watch?v=VIDEO_ID",item_details:"Detalles del elemento",items:"elementos",items_per_page:"Elementos por página",key:"Chave",language:"Idioma",last_10_logins:"Últimos 10 Inicios de Sesión",last_modification:"Última Modificación",last_name:"Apellido",leader:"Líder",leadership:"Liderazgo",leadership_hierarchy:"Jerarquía de liderazgo",left:"Izquierda",link_copied:"Enlace copiado al portapapeles",list:"Lista",loading:"Cargando...",loading_data:"Cargando datos...",logout:"Cerrar Sesión",manage_reports:"Gestionar informes",management:"Gestión",management_access_control:"Control de acceso a gestión",management_permission:"Permiso de Gestión",management_permissions:"Permisos de Gestión",markdown_hint:"💡 Soporta: **negrita**, *cursiva*, [enlaces](url), párrafos",max_file_size:"Tamanho máximo",migration:"Migração",module:"Módulo",module_title:"Título del módulo",modules:"Módulos",name:"Nombre",new:"Nuevo",new_password:"Nueva Contraseña",new_value:"Nuevo valor",next:"Siguiente",no:"No",no_additional_fields:"No hay campos adicionales configurados.",no_content_preview:"No hay contenido para previsualizar...",no_data:"No hay datos disponibles",no_file_selected:"No se seleccionó ningún archivo",no_items_found:"No se encontraron elementos",no_logins_registered:"Aún no se han registrado inicios de sesión.",no_options:"No hay opciones disponibles",no_permission_to_access_reports:"Sem permissão para acessar relatórios",no_posts_found:"No se encontraron publicaciones",no_results:"No se encontraron resultados",no_title:"Sin título",notifications:"Notificaciones",nr1:"Pulso",of:"de",old_password:"Contraseña Actual",open_external_link:"Abrir enlace externo",open_wiki:"Abrir Wiki",order:"Orden",overview:"Resumen",page:"Página",password:"Contraseña",paste_html_placeholder:"Pegue o escriba HTML aquí...",pdi:"PDI",pending:"Pendiente",performance:"Desempeño",permissions:"Permisos",permissions_roles:"Permisos y Roles",phone:"Teléfono",place:"Lugar",placeholder_select:"Seleccionar...",places:"Lugares",plain_text_placeholder:"Ingrese texto simple aquí...",position:"Cargo",posts:"Publicaciones",preferences:"Preferencias de Internacionalización",preview:"Vista Previa",previous:"Anterior",processing:"Procesando...",profile:"Perfil",pt:"PT",qualiex_places_hierarchy:"Jerarquía de lugares de Qualiex",recipient_email:"Correo del Destinatario",redirecting:"Redirigiendo...",refresh_data:"Actualizar datos",reload:"Recargar",remove:"Eliminar",remove_confirm:"¿Está seguro de que desea eliminar?",removing:"Eliminando...",reports:"Informes",required_field:"Campo obligatorio",restricted_access:"Acceso restringido",results:"resultados",right:"Derecha",role:"Rol",roles:"Roles",rows_per_page:"Registros por página",save:"Guardar",save_block:"Guardar Bloque",save_success:"Guardado exitosamente",saving:"Guardando...",search:"Buscar",search_placeholder:"Buscar...",search_user:"Buscar usuario...",searchDateFormat:"Buscar formato...",searchTimezone:"Buscar zona horaria...",section:"Sección",select_all:"Seleccionar todo",select_collaborator:"Seleccionar Colaborador",select_option:"Seleccione una opción",select_placeholder:"Seleccionar...",selectDateFormat:"Seleccione el formato",selectTimezone:"Seleccione la zona horaria",select_text_for_link:"Seleccione el texto que desea convertir en enlace",select_unit_collaborator:"Seleccione un colaborador de la unidad",select_user:"Seleccionar Usuario",select_user_for_admin_access:"Seleccione un usuario para dar acceso de administrador",select_video:"Seleccionar Video",selected:"seleccionado(s)",selected_count:"{{count}} seleccionado(s)",send:"Enviar",settings:"Configuración",settings_summary:"Resumen de configuración",showing:"Mostrando",size:"Tamaño",skills:"Habilidades",state:"Estado",status:"Estado",subordinates:"Subordinados",success:"Éxito",superior:"Superior Inmediato",superior_none:"Ningún superior",superior_search:"Buscar superior...",system_administration:"Administración del sistema",system_logs:"Registros del Sistema",template_variables:"Variables de Plantilla",test_email:"Probar Envío de Correo",text:"Texto",text_color:"Color del Texto",text_format:"Formato de Texto",thumbnail:"Miniatura",timezone:"Zona Horaria",title:"Título",to:"hasta",total:"Total",trainings:"Capacitaciones",translation:"Traducción",translation_description:"Información de la traducción",translations:"Traducciones",type:"Tipo",type_to_search:"Escriba para buscar",unit:"Unidad",units:"Unidades",unsupported:"Formato no soportado",update:"Actualizar",value:"Valor",update_success:"Actualizado exitosamente",updated_at:"Actualizado en",updated_by:"Actualizado por",updating:"Actualizando...",upload:"Cargar",useSystemDefaults:"Usar valores del sistema",uploading:"Subiendo...",url:"URL",url_placeholder:"https://ejemplo.com/imagen.jpg",user:"Usuario",user_management:"Gestión de Usuarios",username:"Usuario",users:"Usuarios",video:"Video",view:"Visualizar",view_mode_grid:"Cuadrícula",view_mode_list:"Lista",view_mode_table:"Tabla",warning:"Advertencia",width:"Ancho",yes:"Sí",zip_code:"Código Postal"};function Qo(e,a){A.addResourceBundle(e,"app",a,!0,!0)}A.use(v.initReactI18next).init({resources:{"pt-BR":{core:Wo},"en-US":{core:Go},"es-ES":{core:Yo}},fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"app",fallbackNS:"core",ns:["core"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e});const Ko=a.createContext(void 0),Xo={locale:xt,timezone:bt,datetimeFormat:gt},Zo=async()=>{},Jo=({children:a})=>e.jsx(Ko.Provider,{value:{...Xo,setLocale:Zo,setTimezone:Zo,setDatetimeFormat:Zo,isLoading:!1},children:a}),ei=()=>{const e=a.useContext(Ko);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},ai=a.createContext({moduleAlias:null});function ti({moduleAlias:a=null,children:t}){return e.jsx(ai.Provider,{value:{moduleAlias:a},children:t})}function si(){return a.useContext(ai)}const ri=he.Root,ni=he.CollapsibleTrigger,oi=he.CollapsibleContent;class ii extends a.Component{constructor(e){super(e),this.copyErrorDetails=()=>{const e=Rr.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),i.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;Rr.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Rr.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(Lt,{className:"w-full max-w-2xl",children:[e.jsxs(zt,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(Ft,{children:"Algo deu errado"})]}),e.jsxs(Bt,{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(ri,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(ni,{asChild:!0,children:e.jsxs(Pt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(oi,{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(vr,{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(Pt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(Pt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const li=fe.Root,ci=J.forwardRef(({className:a,...t},s)=>e.jsx(fe.List,{ref:s,className:At("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));ci.displayName=fe.List.displayName;const di=J.forwardRef(({className:a,...t},s)=>e.jsx(fe.Trigger,{ref:s,className:At("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}));di.displayName=fe.Trigger.displayName;const ui=J.forwardRef(({className:a,...t},s)=>e.jsx(fe.Content,{ref:s,className:At("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));ui.displayName=fe.Content.displayName;const mi=J.forwardRef(({className:a,value:t,...s},r)=>e.jsx(xe.Root,{ref:r,className:At("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...s,children:e.jsx(xe.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));function pi({image:a,title:t,className:s}){return e.jsx("div",{className:At("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",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(l.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function hi({steps:a,currentStepIndex:t,onStepSelect:s,stepLabel:r,className:n}){const o=a.length,i=(t+1)/o*100;return e.jsxs("div",{className:At("flex items-center gap-3",n),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pt,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",t+1,"/",o,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:a.map((a,r)=>e.jsxs(Gs,{onClick:()=>s(r),className:At(r===t&&"bg-accent"),children:[r+1,". ",a.title]},a.id))})]}),e.jsx(mi,{value:i,className:"w-32 h-2"})]})}function fi({currentStepIndex:a,totalSteps:t,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:c,className:d}){const u=0===a,m=a===t-1;return e.jsxs("div",{className:At("flex items-center gap-2",d),children:[!u&&e.jsxs(Pt,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(l.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),e.jsxs(Pt,{onClick:m?n:r,size:"sm",children:[m?c:i,!m&&e.jsx(l.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}mi.displayName=xe.Root.displayName;const xi=J.forwardRef(({open:a,onOpenChange:t,steps:s,onComplete:r,onStepChange:n,continueButtonText:o="Continuar",backButtonText:i="Voltar",finishButtonText:c="Concluir",stepLabel:d="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:p,onCurrentStepChange:h,className:f},x)=>{const[g,b]=J.useState(0),v=void 0!==p,w=v?p:g,y=J.useCallback(e=>{v?h?.(e):b(e),n?.(e)},[v,h,n]);J.useEffect(()=>{a||v||b(0)},[a,v]);const N=s[w],j=s.length;return N?e.jsx(es,{open:a,onOpenChange:t,children:e.jsxs(os,{ref:x,size:u,variant:"informative",className:At("p-0 gap-0 overflow-hidden",f),children:[e.jsxs(ss,{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(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(pi,{image:N.image,title:N.title}),e.jsx(ds,{className:"text-xl font-semibold",children:N.title}),e.jsx(us,{className:"text-muted-foreground",children:N.description})]})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(Ot,{}),e.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[m&&j>1?e.jsx(hi,{steps:s,currentStepIndex:w,onStepSelect:e=>{y(e)},stepLabel:d}):e.jsx("div",{}),e.jsx(fi,{currentStepIndex:w,totalSteps:j,onBack:()=>{w>0&&y(w-1)},onNext:()=>{w<j-1&&y(w+1)},onComplete:()=>{r?.(),t(!1)},backButtonText:i,continueButtonText:o,finishButtonText:c})]})]})]})}):null});function gi({className:a}){return e.jsxs("svg",{className:a,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.5 11.7455C0.5 10.2633 2.25695 9.52546 3.36816 10.4399L22.4346 26.1528C23.3588 26.9137 23.229 28.3353 22.1953 28.9301L16.3418 32.2963C15.7961 32.6097 15.1199 32.6098 14.5742 32.2963L1.36133 24.7006C0.832671 24.3966 0.500052 23.8398 0.5 23.2289V11.7455Z",stroke:"currentColor"}),e.jsx("path",{d:"M14.612 0.735352C15.1576 0.421927 15.833 0.421964 16.3786 0.735352L25.3776 5.90723V5.9082C26.5447 6.5808 26.5183 8.24018 25.3298 8.875L25.3307 8.87598L13.9333 14.9697L13.9323 14.9688C13.3016 15.3066 12.5233 15.2301 11.9733 14.7773L4.90302 8.9541C3.97881 8.19317 4.1086 6.77256 5.14227 6.17773L14.612 0.735352Z",stroke:"currentColor"}),e.jsx("path",{d:"M28.1066 9.7966C29.2466 9.18579 30.6895 9.9732 30.6896 11.2937V23.0691C30.6895 23.6825 30.3539 24.2382 29.8264 24.5417L29.8254 24.5427L27.3449 25.9607C26.7486 26.3015 26.0057 26.264 25.4494 25.8747L25.341 25.7917L16.6076 18.5974C15.6649 17.821 15.8224 16.3676 16.8937 15.7937V15.7927L28.1066 9.79758V9.7966Z",stroke:"currentColor"})]})}function bi({className:a}){return e.jsxs("svg",{className:a,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.524143 8.74979C1.44754 8.74979 2.36325 8.74979 3.30973 8.74979C3.30973 8.90069 3.30973 9.05162 3.30973 9.19497C3.30973 9.79101 3.64061 10.1154 4.24082 10.1154C6.8879 10.1154 9.54268 10.1154 12.1898 10.1154C12.7592 10.1154 13.1286 9.77589 13.1132 9.27793C13.0978 8.8856 12.8054 8.5612 12.3745 8.51594C11.2279 8.38767 10.0736 8.26696 8.91938 8.1387C7.72666 8.01043 6.52625 7.88216 5.33352 7.74635C4.71792 7.67845 4.10232 7.61811 3.48672 7.53511C2.00928 7.32386 0.754978 6.06386 0.547213 4.61526C0.331752 3.10631 1.00122 1.73316 2.34015 0.963593C2.89419 0.646712 3.5021 0.503353 4.14848 0.503353C6.84943 0.503353 9.55038 0.495808 12.2513 0.503353C14.0904 0.510898 15.5448 1.71808 15.8603 3.49865C15.8988 3.7099 15.8988 3.92116 15.9065 4.13996C15.9141 4.2984 15.9065 4.44928 15.9065 4.61526C14.9677 4.61526 14.0443 4.61526 13.0978 4.61526C13.0978 4.44928 13.0978 4.28329 13.0978 4.1173C13.0901 3.58162 12.7592 3.25719 12.2206 3.24965C9.53499 3.24965 6.84943 3.24965 4.17157 3.24965C3.69448 3.24965 3.36359 3.52881 3.30203 3.97396C3.24816 4.3512 3.51749 4.73597 3.90224 4.8265C4.10231 4.87177 4.31008 4.88687 4.51784 4.9095C5.8183 5.05285 7.12645 5.19622 8.42691 5.33957C9.71198 5.48292 10.997 5.63382 12.2898 5.75453C13.1824 5.83753 13.9981 6.08649 14.6906 6.68253C16.1604 7.92742 16.3066 10.2588 14.9984 11.6696C14.2443 12.4845 13.3132 12.8844 12.1975 12.8844C9.5273 12.8844 6.84944 12.8844 4.17927 12.8844C2.55562 12.8844 1.21669 11.9563 0.678043 10.4549C0.539533 9.98715 0.470277 9.38356 0.524143 8.74979Z",stroke:"currentColor"}),e.jsx("path",{d:"M8.21913 24.2393C8.21913 24.2317 8.21913 24.2317 8.21913 24.2393ZM8.21913 24.2393C8.98863 24.2393 9.75812 24.2619 10.5199 24.2317C11.7511 24.1789 12.9285 23.1378 13.067 21.9381C13.1439 21.3119 13.1285 20.6706 13.1131 20.0368C13.067 18.6335 11.8743 17.4339 10.443 17.3962C8.96554 17.3584 7.4881 17.366 6.00296 17.3962C4.70251 17.4263 3.54055 18.4373 3.37896 19.6973C3.29431 20.3462 3.3097 21.0101 3.34048 21.6665C3.40204 23.017 4.58708 24.1789 5.96449 24.2317C6.7186 24.2619 7.46502 24.2393 8.21913 24.2393ZM13.1439 15.427C13.7441 14.8385 14.3367 14.2575 14.9138 13.6917C15.5756 14.333 16.2296 14.9818 16.9222 15.6608C16.8914 15.6759 16.8298 15.7061 16.7837 15.7438C16.2604 16.2493 15.7448 16.7624 15.2216 17.2679C15.1446 17.3434 15.1369 17.4037 15.1908 17.4943C15.7064 18.3845 15.9526 19.3427 15.9295 20.3613C15.9141 20.9799 15.9526 21.6062 15.8603 22.2097C15.5371 24.2846 14.352 25.7332 12.3975 26.5782C11.7126 26.8724 10.9816 26.9931 10.2352 26.9931C8.89629 26.9931 7.56504 26.9931 6.22611 26.9931C3.49438 26.9931 1.20897 25.1899 0.631845 22.5719C0.56259 22.2475 0.524115 21.9155 0.51642 21.5835C0.508725 20.9422 0.470242 20.2933 0.547192 19.6596C0.816518 17.3584 2.08619 15.7967 4.27927 14.9516C4.84101 14.7328 5.42584 14.6347 6.02605 14.6347C7.4958 14.6347 8.96554 14.6272 10.4276 14.6423C11.3279 14.6498 12.1667 14.9064 12.9516 15.3289C13.0131 15.3591 13.067 15.3892 13.1439 15.427Z",stroke:"currentColor"}),e.jsx("path",{d:"M0.508791 28.3813C1.43989 28.3813 2.3633 28.3813 3.2944 28.3813C3.31748 28.4945 3.32516 28.6001 3.35594 28.7058C3.50984 29.2943 4.01772 29.7017 4.63332 29.7319C4.76414 29.7394 4.89496 29.7394 5.02578 29.7394C7.22655 29.7394 9.4273 29.7394 11.6281 29.7394C12.3206 29.7394 12.8439 29.3923 13.0363 28.7963C13.0747 28.668 13.0978 28.5323 13.1286 28.3889C14.0443 28.3889 14.9677 28.3889 15.9142 28.3889C15.9219 28.7435 15.868 29.0906 15.7757 29.4301C15.2986 31.1955 13.6519 32.4782 11.7897 32.4857C9.39653 32.5008 7.01108 32.5083 4.61794 32.4857C2.44025 32.4706 0.624216 30.7353 0.508791 28.6077C0.501096 28.5322 0.508791 28.4643 0.508791 28.3813Z",stroke:"currentColor"})]})}function vi({educaUrl:a="https://educa.forlogic.net/",saberGestaoUrl:t="https://sabergestao.com.br/",wikiUrl:s}){const r=a||s||"https://educa.forlogic.net/";return e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ot,{className:"mb-4"}),e.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-white",children:"Aprenda a usar o Qualiex"}),e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-white underline underline-offset-2 hover:opacity-80 mt-2",children:["Conheça o ForLogic Educa",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(gi,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Conheça o Saber Gestão"}),e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(bi,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),e.jsxs("a",{href:s||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(l.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}xi.displayName="OnboardingDialog";const wi=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",softwareAlias:"analysis",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",softwareAlias:"decisions",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",softwareAlias:"audit",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",softwareAlias:"common",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",softwareAlias:"docs",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",softwareAlias:"flow",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",softwareAlias:"suppliers",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",softwareAlias:"mapping",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",softwareAlias:"metrology",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",softwareAlias:"occurrences",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",softwareAlias:"okr",url:"https://okr.qualiex.com"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",softwareAlias:"plans",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",softwareAlias:"suppliers-portal",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",softwareAlias:"risks",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",softwareAlias:"competencies",url:"https://competencias.sabergestao.com.br"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",softwareAlias:"performance",url:"https://desempenho.sabergestao.com.br"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",softwareAlias:"education",url:"https://educacao.sabergestao.com.br"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",softwareAlias:"pdi",url:"https://pdi.sabergestao.com.br"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",softwareAlias:"pulse",url:"https://nr1pulso.sabergestao.com.br"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",softwareAlias:"staff",url:"https://treinamentos.sabergestao.com.br"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]",url:"https://apps1.qualiex.com/action?unitalias={alias}"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]",url:"https://apps1.qualiex.com/audit?unitalias={alias}"},{name:"Configurações v3",description:"Configurações",color:"bg-[#5C6BC0]",url:"https://apps3.qualiex.com/{alias}/common"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]",url:"https://apps1.qualiex.com/shared/dashboard?unitalias=forlogic"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]",url:"https://apps1.qualiex.com/docs?unitalias={alias}"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]",url:"https://apps1.qualiex.com/indicators?unitalias={alias}"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]",url:"https://apps1.qualiex.com/meeting?unitalias={alias}"},{name:"Metrology v3",description:"Gestão de Metrologia",color:"bg-[#afd884]",url:"https://apps3.qualiex.com/{alias}/metrology/"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]",url:"https://apps3.qualiex.com/{alias}/planner/m"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]",url:"https://apps1.qualiex.com/common/reports?unitalias=forlogic"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]",url:"https://apps1.qualiex.com/risks?unitalias={alias}"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]",url:"https://apps1.qualiex.com/staff?unitalias={alias}"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]",url:"https://apps1.qualiex.com/supply?unitalias={alias}"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker1?unitalias={alias}"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker2?unitalias={alias}"}]}];function yi({module:a,onClick:t}){return e.jsxs("button",{type:"button",onClick:t,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[e.jsx("div",{className:At("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 transition-colors text-foreground group-hover:text-primary",children:a.name}),a.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:a.description})]})]})}function Ni(e,a){if(0===e.length)return e;const t=Math.ceil(e.length/a),s=[];for(let r=0;r<t;r++)for(let n=0;n<a;n++){const a=n*t+r;a<e.length&&s.push(e[a])}return s}function ji({modules:t,onModuleClick:s,contractedModules:r,onModuleInterest:n}){const o=function(){const[e,t]=a.useState(4);return a.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?t(4):window.matchMedia("(min-width: 768px)").matches?t(3):window.matchMedia("(min-width: 640px)").matches?t(2):t(1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...t].sort((e,a)=>e.name.localeCompare(a.name)),l=void 0!==r,c=l?i.filter(e=>r.includes(e.name)):i,d=l?i.filter(e=>!r.includes(e.name)):[],u=Ni(c,o),m=Ni(d,o),p=(e,a)=>{a?s?.(e):n?.(e)};return e.jsxs("div",{className:"space-y-6",children:[u.length>0&&e.jsx("section",{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(a=>e.jsx(yi,{module:a,onClick:()=>p(a,!0)},a.name))})}),m.length>0&&e.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(a=>e.jsx(yi,{module:a,onClick:()=>p(a,!1)},a.name))})]})]})}function Ci({onModuleClick:t,contractedModules:s,onModuleInterest:r,educaUrl:n="https://educa.forlogic.net/",saberGestaoUrl:o="https://sabergestao.com.br/",wikiUrl:i}){const[l,c]=a.useState("qualiex"),[d,u]=a.useState(null),m=e=>{t?.(e)},p=e=>{u(e)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs(li,{value:l,onValueChange:c,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(ci,{className:"w-fit shrink-0",children:wi.map(a=>e.jsxs(di,{value:a.id,children:[a.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",a.modules.length,")"]})]},a.id))}),wi.map(a=>e.jsx(ui,{value:a.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(ji,{modules:a.modules,onModuleClick:m,contractedModules:"qualiex"===a.id?s:void 0,onModuleInterest:p})},a.id))]}),e.jsx(vi,{educaUrl:n,saberGestaoUrl:o,wikiUrl:i})]}),d&&e.jsx(xi,{open:!!d,onOpenChange:e=>!e&&u(null),steps:(h=d,h.onboardingSteps&&h.onboardingSteps.length>0?h.onboardingSteps.slice(0,3):[{id:"intro",title:`Conheça o ${h.name}`,description:h.description||`O ${h.name} é uma solução completa para otimizar seus processos e aumentar a produtividade da sua equipe.`},{id:"features",title:"Principais Funcionalidades",description:"Automatize processos, gere relatórios detalhados, acompanhe indicadores em tempo real e tenha controle total sobre suas operações."},{id:"cta",title:"Transforme sua Gestão",description:"Fale com um de nossos especialistas e descubra como este módulo pode transformar a gestão da sua empresa."}]),finishButtonText:"Quero conhecer mais",onComplete:()=>{d&&(r?.(d),u(null))}})]});var h}const _i={analysis:12,decisions:13,audit:1,common:0,competencies:23,performance:24,docs:17,education:25,flow:7,suppliers:15,"suppliers-portal":16,mapping:11,metrology:8,control:18,msa:21,occurrences:3,okr:26,pdi:27,plans:6,"strategy-extension":14,pulse:28,boards:10,risks:4,fmea:20,staff:19,"control-plan":22},ki=6e5;function Si(e){const{moduleAlias:t}=si(),{alias:s,user:r,isAuthenticated:n}=yn(),o=e??t,i=r?.id??null,l=n&&!!s&&!!i,{data:c=[],isLoading:d}=N.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>sn.fetchUserAssociations(i,s),enabled:l,staleTime:ki,gcTime:12e5}),u=a.useMemo(()=>s&&0!==c.length?c.find(e=>e.companyAlias===s)??null:null,[c,s]),m=a.useCallback(e=>{if(!u)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const a=_i[e];return void 0!==a&&u.softwares.includes(a)})},[u]);return{hasAccess:a.useMemo(()=>!o||m(o),[o,m]),isLoading:l&&d,role:a.useMemo(()=>u?{id:u.roleId,name:u.roleName}:null,[u]),association:u,hasAccessTo:m}}function Ai(e){const{association:t}=Si();return a.useMemo(()=>{if(e)return e;if(!t?.softwares)return;const a=t.softwares,s=wi.find(e=>"qualiex"===e.id);return s?s.modules.filter(e=>{if(!e.softwareAlias)return!1;const t=_i[e.softwareAlias];return void 0!==t&&a.includes(t)}).map(e=>e.name):void 0},[e,t])}function Ti({open:a,onOpenChange:t,onModuleClick:s,contractedModules:r,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l}){const{alias:c}=yn(),d=Ai(r);return e.jsx(es,{open:a,onOpenChange:t,children:e.jsxs(os,{size:"lg",className:"overflow-hidden flex flex-col",children:[e.jsx(is,{className:"sr-only",children:e.jsx(ds,{children:"Módulos"})}),e.jsx(Ci,{onModuleClick:e=>{if(s)s(e);else if(e.url){St(c?e.url.replace(/\{alias\}/g,c):e.url)}},contractedModules:d,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l})]})})}function Ei({open:t,onOpenChange:s,onModuleClick:r,contractedModules:n,onModuleInterest:o,userName:i,unitName:c,units:d=[],currentAlias:u,onUnitChange:m,onLogout:p,educaUrl:h,saberGestaoUrl:f,wikiUrl:x,blocking:g=!0,size:b="lg",children:v}){const w=a.useMemo(()=>{if(!d.length)return[];const e=new Map;d.forEach(a=>e.set(a.alias,a));const a=Array.from(e.values()),t=a.find(e=>e.alias===u),s=a.filter(e=>e.alias!==u).sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"}));return t?[t,...s]:s},[d,u]);return e.jsx(es,{open:t,onOpenChange:g?void 0:s,children:e.jsxs(os,{size:b,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:g?e=>e.preventDefault():void 0,onEscapeKeyDown:g?e=>e.preventDefault():void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[e.jsx(ds,{children:"Parece que você não tem acesso a essa página"}),e.jsx(us,{children:"Selecione um módulo para continuar navegando!"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[w.length>1&&e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pt,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[e.jsx(l.Building2,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:c||"Unidade"}),e.jsx(l.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Ws,{align:"end",className:"max-h-[300px] overflow-auto",children:w.map(a=>e.jsxs(Gs,{onClick:()=>m?.(a),className:a.alias===u?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:a.name}),a.alias===u&&e.jsx(Is,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},a.alias))})]}),e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pt,{variant:"ghost",size:"sm",className:"gap-2",children:[e.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-3 w-3"})]})}),e.jsxs(Ws,{align:"end",children:[e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsx("p",{className:"text-sm font-medium",children:i||"Usuário"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:p,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),v?e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[e.jsx("div",{className:"flex-1",children:v}),e.jsx(vi,{educaUrl:h,saberGestaoUrl:f,wikiUrl:x})]}):e.jsx(Ci,{onModuleClick:r,contractedModules:n,onModuleInterest:o,educaUrl:h,saberGestaoUrl:f,wikiUrl:x})]})})}function Pi(e,a){return a.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a)}function Mi({children:t,contractedModules:s,onModuleClick:r,onModuleInterest:n,educaUrl:o="https://educa.forlogic.net/",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:c,accessDeniedRoutes:d}){const{hasAccess:u,isLoading:m,association:p}=Si(),{user:h,alias:f,companies:x,isAuthenticated:g,isLoading:b,logout:v,switchUnit:w}=yn(),y=Ai(s),N=a.useMemo(()=>x?.length?f&&x.find(e=>e.alias===f)||x[0]:null,[x,f]),j=a.useMemo(()=>x?.length?x.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[x]),C=a.useCallback(e=>{const a=x?.find(a=>a.alias===e.alias);a&&w(a)},[w,x]),_=a.useCallback(e=>{if(r)r(e);else if(e.url){St(f?e.url.replace(/\{alias\}/g,f):e.url)}},[r,f]),k=a.useMemo(()=>{if(!d)return;const e=window.location.pathname,a=Object.keys(d).find(a=>Pi(e,[a]));return a?d[a]:void 0},[d]);return b||!g||c?.length&&Pi(window.location.pathname,c)?e.jsx(e.Fragment,{children:t}):m?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx(Ls,{size:"lg"})}):u?e.jsx(e.Fragment,{children:t}):e.jsx(Ei,{open:!0,onModuleClick:_,contractedModules:y,onModuleInterest:n,userName:h?.name,unitName:N?.name,units:j,currentAlias:f||void 0,onUnitChange:C,onLogout:v,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,blocking:!0,children:k})}const Di=ge.Root,Ii=J.forwardRef(({className:a,...t},s)=>e.jsx(ge.Item,{ref:s,className:At("border-b",a),...t}));Ii.displayName="AccordionItem";const Ri=J.forwardRef(({className:a,children:t,...s},r)=>e.jsx(ge.Header,{className:"flex",children:e.jsxs(ge.Trigger,{ref:r,className:At("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(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Ri.displayName=ge.Trigger.displayName;const Li=J.forwardRef(({className:a,children:t,...s},r)=>e.jsx(ge.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:At("pb-4 pt-0",a),children:t})}));Li.displayName=ge.Content.displayName;const zi=J.forwardRef(({className:a,...t},s)=>e.jsx(be.Root,{ref:s,className:At("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));zi.displayName=be.Root.displayName;const Fi=J.forwardRef(({className:a,...t},s)=>e.jsx(be.Image,{ref:s,className:At("aspect-square h-full w-full",a),...t}));Fi.displayName=be.Image.displayName;const Ui=J.forwardRef(({className:a,...t},s)=>e.jsx(be.Fallback,{ref:s,className:At("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));Ui.displayName=be.Fallback.displayName;const Bi=J.forwardRef(({...a},t)=>e.jsx("nav",{ref:t,"aria-label":"breadcrumb",...a}));Bi.displayName="Breadcrumb";const qi=J.forwardRef(({className:a,...t},s)=>e.jsx("ol",{ref:s,className:At("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));qi.displayName="BreadcrumbList";const Oi=J.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:At("inline-flex items-center gap-1.5",a),...t}));Oi.displayName="BreadcrumbItem";const $i=J.forwardRef(({asChild:a,className:s,...r},n)=>{const o=a?t.Slot:"a";return e.jsx(o,{ref:n,className:At("transition-colors hover:text-foreground",s),...r})});$i.displayName="BreadcrumbLink";const Vi=J.forwardRef(({className:a,...t},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:At("font-normal text-foreground",a),...t}));Vi.displayName="BreadcrumbPage";const Hi=({children:a,className:t,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:At("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:a??e.jsx(l.ChevronRight,{})});Hi.displayName="BreadcrumbSeparator";const Wi=({className:a,...t})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:At("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Wi.displayName="BreadcrumbEllipsis";const Gi=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"}}),Yi=J.forwardRef(({className:a,orientation:t,...s},r)=>e.jsx("div",{ref:r,className:At(Gi({orientation:t}),a),...s}));function Qi({className:a,classNames:t,showOutsideDays:s=!0,...r}){return e.jsx(I.DayPicker,{showOutsideDays:s,className:At("p-3 pointer-events-auto",a),locale:mt,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:"flex h-9 w-full items-center justify-center px-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1",button_previous:At(Et({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:At(Et({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal w-9",week:"mt-2 flex w-full",day:"group/day relative h-9 w-9 select-none p-0 text-center text-sm [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md focus-within:relative focus-within:z-20",day_button:At(Et({variant:"ghost"}),"h-9 w-9 p-0 font-normal transition-none aria-selected:opacity-100"),range_start:"bg-accent rounded-l-md",range_end:"bg-accent rounded-r-md",range_middle:"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground rounded-md",today:"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...t},components:{Chevron:({orientation:a})=>"left"===a?e.jsx(l.ChevronLeft,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})},...r})}Yi.displayName="ButtonGroup",Qi.displayName="Calendar";const Ki={Root:function({children:a,className:t}){return e.jsx("div",{className:At("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:s}){return e.jsx(Lt,{className:At("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:e.jsx(Bt,{className:"p-4",children:a})})},Field:function({label:a,value:t,className:s}){return e.jsxs("div",{className:At("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 Xi=({shouldScaleBackground:a=!0,...t})=>e.jsx(R.Drawer.Root,{shouldScaleBackground:a,...t});Xi.displayName="Drawer";const Zi=R.Drawer.Trigger,Ji=R.Drawer.Portal,el=R.Drawer.Close,al=J.forwardRef(({className:a,...t},s)=>e.jsx(R.Drawer.Overlay,{ref:s,className:At("fixed inset-0 z-50 bg-black/80",a),...t}));al.displayName=R.Drawer.Overlay.displayName;const tl=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Ji,{children:[e.jsx(al,{}),e.jsxs(R.Drawer.Content,{ref:r,className:At("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]})]}));tl.displayName="DrawerContent";const sl=({className:a,...t})=>e.jsx("div",{className:At("grid gap-1.5 p-4 text-center sm:text-left",a),...t});sl.displayName="DrawerHeader";const rl=({className:a,...t})=>e.jsx("div",{className:At("mt-auto flex flex-col gap-2 p-4",a),...t});rl.displayName="DrawerFooter";const nl=J.forwardRef(({className:a,...t},s)=>e.jsx(R.Drawer.Title,{ref:s,className:At("text-lg font-semibold leading-none tracking-tight",a),...t}));nl.displayName=R.Drawer.Title.displayName;const ol=J.forwardRef(({className:a,...t},s)=>e.jsx(R.Drawer.Description,{ref:s,className:At("text-sm text-muted-foreground",a),...t}));ol.displayName=R.Drawer.Description.displayName;const il={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))]"},ll={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const cl=ve.Root,dl=ve.Trigger,ul=J.forwardRef(({className:a,align:t="center",sideOffset:s=4,...r},n)=>e.jsx(ve.Content,{ref:n,align:t,sideOffset:s,className:At("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}));ul.displayName=ve.Content.displayName;const ml=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:At("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}));ml.displayName="InputGroup";const pl=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"}}),hl=J.forwardRef(({className:a,align:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:At(pl({align:t}),a),...s}));hl.displayName="InputGroupAddon";const fl=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"}}),xl=J.forwardRef(({className:a,size:t,variant:s="ghost",...r},n)=>e.jsx(Pt,{ref:n,"data-slot":"input-group-button",variant:s,className:At(fl({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...r}));xl.displayName="InputGroupButton";const gl=J.forwardRef(({className:a,...t},s)=>e.jsx(Dt,{ref:s,"data-slot":"input-group-control",className:At("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));gl.displayName="InputGroupInput";const bl=J.forwardRef(({className:a,...t},s)=>e.jsx(Ms,{ref:s,"data-slot":"input-group-control",className:At("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));bl.displayName="InputGroupTextarea";const vl=J.forwardRef(({className:a,...t},s)=>e.jsx("h1",{ref:s,className:At("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));vl.displayName="H1";const wl=J.forwardRef(({className:a,...t},s)=>e.jsx("h2",{ref:s,className:At("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));wl.displayName="H2";const yl=J.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:At("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));yl.displayName="H3";const Nl=J.forwardRef(({className:a,...t},s)=>e.jsx("h4",{ref:s,className:At("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));Nl.displayName="H4";const jl=J.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:At("leading-7 [&:not(:first-child)]:mt-6",a),...t}));jl.displayName="P";const Cl=J.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:At("text-xl text-muted-foreground",a),...t}));Cl.displayName="Lead";const _l=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:At("text-lg font-semibold",a),...t}));_l.displayName="Large";const kl=J.forwardRef(({className:a,...t},s)=>e.jsx("small",{ref:s,className:At("text-sm font-medium leading-none",a),...t}));kl.displayName="Small";const Sl=J.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:At("text-sm text-muted-foreground",a),...t}));Sl.displayName="Muted";const Al=J.forwardRef(({className:a,...t},s)=>e.jsx("code",{ref:s,className:At("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));Al.displayName="InlineCode";const Tl=J.forwardRef(({className:a,...t},s)=>e.jsx("blockquote",{ref:s,className:At("mt-6 border-l-2 pl-6 italic",a),...t}));Tl.displayName="Blockquote";const El=J.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:At("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));El.displayName="List";const Pl=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(we.Root,{ref:r,className:At("relative z-10 flex max-w-max flex-1 items-center justify-center",a),...s,children:[t,e.jsx(Fl,{})]}));Pl.displayName=we.Root.displayName;const Ml=J.forwardRef(({className:a,...t},s)=>e.jsx(we.List,{ref:s,className:At("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));Ml.displayName=we.List.displayName;const Dl=we.Item,Il=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"),Rl=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(we.Trigger,{ref:r,className:At(Il(),"group",a),...s,children:[t," ",e.jsx(l.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Rl.displayName=we.Trigger.displayName;const Ll=J.forwardRef(({className:a,...t},s)=>e.jsx(we.Content,{ref:s,className:At("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}));Ll.displayName=we.Content.displayName;const zl=we.Link,Fl=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:At("absolute left-0 top-full flex justify-center"),children:e.jsx(we.Viewport,{className:At("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})}));Fl.displayName=we.Viewport.displayName;const Ul=J.forwardRef(({className:a,...t},s)=>e.jsx(we.Indicator,{ref:s,className:At("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"})}));Ul.displayName=we.Indicator.displayName;const Bl=({className:a,...t})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:At("mx-auto flex w-full justify-center",a),...t});Bl.displayName="Pagination";const ql=J.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:At("flex flex-row items-center gap-1",a),...t}));ql.displayName="PaginationContent";const Ol=J.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:At("",a),...t}));Ol.displayName="PaginationItem";const $l=({className:a,isActive:t,size:s="icon",...r})=>e.jsx("a",{"aria-current":t?"page":void 0,className:At(Et({variant:t?"outline":"ghost",size:s}),a),...r});$l.displayName="PaginationLink";const Vl=({className:a,...t})=>e.jsxs($l,{"aria-label":"Go to previous page",size:"default",className:At("gap-1 pl-2.5",a),...t,children:[e.jsx(l.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Vl.displayName="PaginationPrevious";const Hl=({className:a,...t})=>e.jsxs($l,{"aria-label":"Go to next page",size:"default",className:At("gap-1 pr-2.5",a),...t,children:[e.jsx("span",{children:"Next"}),e.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Hl.displayName="PaginationNext";const Wl=({className:a,...t})=>e.jsxs("span",{"aria-hidden":!0,className:At("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Wl.displayName="PaginationEllipsis";const Gl=J.forwardRef(({className:a,...t},s)=>e.jsx(ye.Root,{className:At("grid gap-2",a),...t,ref:s}));Gl.displayName=ye.Root.displayName;const Yl=J.forwardRef(({className:a,...t},s)=>e.jsx(ye.Item,{ref:s,className:At("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(ye.Indicator,{className:"flex items-center justify-center",children:e.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Yl.displayName=ye.Item.displayName;const Ql=Ne.Panel,Kl=ae.Root,Xl=ae.Trigger,Zl=ae.Close,Jl=ae.Portal,ec=J.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{className:At("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}));ec.displayName=ae.Overlay.displayName;const ac=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"}}),tc=J.forwardRef(({side:a="right",className:t,children:s,...r},n)=>e.jsxs(Jl,{children:[e.jsx(ec,{}),e.jsxs(ae.Content,{ref:n,className:At(ac({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(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));tc.displayName=ae.Content.displayName;const sc=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:At("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(Ot,{className:"mt-2"})]});sc.displayName="SheetHeader";const rc=({className:a,...t})=>e.jsx("div",{className:At("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});rc.displayName="SheetBody";const nc=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ot,{className:"mb-4"}),e.jsx("div",{className:At("flex flex-row justify-end gap-2",a),...s,children:t})]});nc.displayName="SheetFooter";const oc=J.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:At("text-lg font-semibold text-foreground",a),...t}));oc.displayName=ae.Title.displayName;const ic=J.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:At("text-sm text-muted-foreground",a),...t}));ic.displayName=ae.Description.displayName;const lc="sidebar:state",cc=J.createContext(null);function dc(){const e=J.useContext(cc);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const uc=J.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const c=Cn(),[d,u]=J.useState(!1),[m,p]=J.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(lc);return null!==e?"true"===e:a}return a}),h=t??m,f=J.useCallback(e=>{const a="function"==typeof e?e(h):e;s?s(a):p(a),"undefined"!=typeof window&&localStorage.setItem(lc,String(a))},[s,h]),x=J.useCallback(()=>c?u(e=>!e):f(e=>!e),[c,f,u]);J.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const g=h?"expanded":"collapsed",b=J.useMemo(()=>({state:g,open:h,setOpen:f,isMobile:c,openMobile:d,setOpenMobile:u,toggleSidebar:x}),[g,h,f,c,d,u,x]);return e.jsx(cc.Provider,{value:b,children:e.jsx(Js,{delayDuration:0,children:e.jsx("div",{className:At("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":"4rem",...n},ref:l,...i,children:o})})})});uc.displayName="SidebarProvider";const mc=J.forwardRef(({side:a="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=dc();return"none"===s?e.jsx("div",{className:At("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?e.jsx(Kl,{open:d,onOpenChange:u,...o,children:e.jsxs(tc,{"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(oc,{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:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?s:"","data-variant":t,"data-side":a,children:[e.jsx("div",{className:At("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:At("duration-200 fixed inset-y-0 z-30 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","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),...o,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col overflow-visible 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})})]})});mc.displayName="Sidebar";const pc=J.forwardRef(({className:a,onClick:t,...s},r)=>{const{toggleSidebar:n}=dc();return e.jsxs(Pt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:At("h-7 w-7",a),onClick:e=>{t?.(e),n()},...s,children:[e.jsx(l.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});pc.displayName="SidebarTrigger";const hc=J.forwardRef(({className:a,...t},s)=>{const{toggleSidebar:r}=dc();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:At("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})});hc.displayName="SidebarRail";const fc=J.forwardRef(({className:a,...t},s)=>e.jsx("main",{ref:s,className:At("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}));fc.displayName="SidebarInset";const xc=J.forwardRef(({className:a,...t},s)=>e.jsx(Dt,{ref:s,"data-sidebar":"input",className:At("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));xc.displayName="SidebarInput";const gc=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:At("flex flex-col gap-2 p-2",a),...t}));gc.displayName="SidebarHeader";const bc=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:At("flex flex-col gap-2 p-2",a),...t}));bc.displayName="SidebarFooter";const vc=J.forwardRef(({className:a,...t},s)=>e.jsx(Ot,{ref:s,"data-sidebar":"separator",className:At("mx-2 w-auto bg-sidebar-border",a),...t}));vc.displayName="SidebarSeparator";const wc=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:At("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));wc.displayName="SidebarContent";const yc=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:At("relative flex w-full min-w-0 flex-col p-2",a),...t}));yc.displayName="SidebarGroup";const Nc=J.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const o=s?t.Slot:"div";return e.jsx(o,{ref:n,"data-sidebar":"group-label",className:At("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})});Nc.displayName="SidebarGroupLabel";const jc=J.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const o=s?t.Slot:"button";return e.jsx(o,{ref:n,"data-sidebar":"group-action",className:At("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})});jc.displayName="SidebarGroupAction";const Cc=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:At("w-full text-sm",a),...t}));Cc.displayName="SidebarGroupContent";const _c=J.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:At("flex w-full min-w-0 flex-col gap-1",a),...t}));_c.displayName="SidebarMenu";const kc=J.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:At("group/menu-item relative",a),...t}));kc.displayName="SidebarMenuItem";const Sc=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-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary 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"}}),Ac=J.forwardRef(({asChild:a=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},c)=>{const d=a?t.Slot:"button",{isMobile:u,state:m}=dc(),p=e.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:At(Sc({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:p}),e.jsx(tr,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});Ac.displayName="SidebarMenuButton";const Tc=J.forwardRef(({className:a,asChild:s=!1,showOnHover:r=!1,...n},o)=>{const i=s?t.Slot:"button";return e.jsx(i,{ref:o,"data-sidebar":"menu-action",className:At("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})});Tc.displayName="SidebarMenuAction";const Ec=J.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:At("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}));Ec.displayName="SidebarMenuBadge";const Pc=J.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=J.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:At("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}})]})});Pc.displayName="SidebarMenuSkeleton";const Mc=J.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:At("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}));Mc.displayName="SidebarMenuSub";const Dc=J.forwardRef(({...a},t)=>e.jsx("li",{ref:t,...a}));Dc.displayName="SidebarMenuSubItem";const Ic=J.forwardRef(({asChild:a=!1,size:s="md",isActive:r,className:n,...o},i)=>{const l=a?t.Slot:"a";return e.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:At("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),...o})});Ic.displayName="SidebarMenuSubButton";const Rc=J.forwardRef(({className:a,value:t,defaultValue:s,...r},n)=>{const o=t||s||[0];return e.jsxs(je.Root,{ref:n,value:t,defaultValue:s,className:At("relative flex w-full touch-none select-none items-center",a),...r,children:[e.jsx(je.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(je.Range,{className:"absolute h-full bg-primary"})}),o.map((a,t)=>e.jsx(je.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))]})});Rc.displayName=je.Root.displayName;const Lc=Ce.Menu,zc=Ce.Group,Fc=Ce.Portal,Uc=Ce.Sub,Bc=Ce.RadioGroup,qc=J.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Root,{ref:s,className:At("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));qc.displayName=Ce.Root.displayName;const Oc=J.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Trigger,{ref:s,className:At("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}));Oc.displayName=Ce.Trigger.displayName;const $c=J.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:At("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(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));$c.displayName=Ce.SubTrigger.displayName;const Vc=J.forwardRef(({className:a,...t},s)=>e.jsx(Ce.SubContent,{ref:s,className:At("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}));Vc.displayName=Ce.SubContent.displayName;const Hc=J.forwardRef(({className:a,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:o,align:t,alignOffset:s,sideOffset:r,className:At("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})}));Hc.displayName=Ce.Content.displayName;const Wc=J.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Item,{ref:r,className:At("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}));Wc.displayName=Ce.Item.displayName;const Gc=J.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:At("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(l.Check,{className:"h-4 w-4"})})}),t]}));Gc.displayName=Ce.CheckboxItem.displayName;const Yc=J.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:At("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(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Yc.displayName=Ce.RadioItem.displayName;const Qc=J.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Label,{ref:r,className:At("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));Qc.displayName=Ce.Label.displayName;const Kc=J.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Separator,{ref:s,className:At("-mx-1 my-1 h-px bg-muted",a),...t}));Kc.displayName=Ce.Separator.displayName;const Xc=({className:a,...t})=>e.jsx("span",{className:At("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Xc.displayname="MenubarShortcut";const Zc={light:"",dark:".dark"},Jc=J.createContext(null);function ed(){const e=J.useContext(Jc);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const ad=J.forwardRef(({id:a,className:t,children:s,config:r,...n},o)=>{const i=J.useId(),l=`chart-${a||i.replace(/:/g,"")}`;return e.jsx(Jc.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:o,className:At("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(td,{id:l,config:r}),e.jsx(_e.ResponsiveContainer,{children:s})]})})});ad.displayName="Chart";const td=({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(Zc).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},sd=_e.Tooltip,rd=J.forwardRef(({active:a,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:c,formatter:d,color:u,nameKey:m,labelKey:p},h)=>{const{config:f}=ed(),x=J.useMemo(()=>{if(n||!t?.length)return null;const[a]=t,s=id(f,a,`${p||a?.dataKey||a?.name||"value"}`),r=p||"string"!=typeof i?s?.label:f[i]?.label||i;return l?e.jsx("div",{className:At("font-medium",c),children:l(r,t)}):r?e.jsx("div",{className:At("font-medium",c),children:r}):null},[i,l,t,n,c,f,p]);if(!a||!t?.length)return null;const g=1===t.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:At("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:x,e.jsx("div",{className:"grid gap-1.5",children:t.map((a,t)=>{const s=`${m||a.name||a.dataKey||"value"}`,n=id(f,a,s),i=u||a.payload?.fill||a.color;return e.jsx("div",{className:At("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:d&&void 0!==a?.value&&a.name?d(a.value,a.name,a,t,a.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!o&&e.jsx("div",{className:At("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":i,"--color-border":i}}),e.jsxs("div",{className:At("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?x: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)})})]})});rd.displayName="ChartTooltip";const nd=_e.Legend,od=J.forwardRef(({className:a,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=ed();return s?.length?e.jsx("div",{ref:o,className:At("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=id(i,a,s);return e.jsxs("div",{className:At("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 id(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]}od.displayName="ChartLegend";const ld=({onClick:a,isActive:t,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:a,disabled:s,title:n,className:At("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}),cd=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function dd({label:a,onClick:t,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:c=!1,menuAlign:d="end",className:u}){const m=i||c;if(!(r.length>0))return e.jsxs(Pt,{variant:n,size:o,disabled:m,onClick:t,className:u,children:[c?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]});return e.jsxs("div",{className:At("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(Pt,{variant:n,size:o,disabled:m,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[c?e.jsx(l.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(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pt,{variant:n,size:o,disabled:m,className:At("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e.jsx(l.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e.jsx(Ws,{align:d,className:"min-w-[160px]",children:r.map(a=>{const t=a.icon;return e.jsxs(Gs,{onClick:a.onClick,disabled:a.disabled,className:At("destructive"===a.variant&&"text-destructive focus:text-destructive"),children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})]})}function ud({onEdit:t,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:c=[],renderAs:d="dropdown",variant:u="default"}){const{t:m}=v.useTranslation(),p=a.useMemo(()=>{const e=[];return t&&o&&e.push({key:"edit",icon:l.Edit,label:m("edit","Editar"),onClick:t,variant:"default"}),r&&e.push({key:"toggle-status",icon:n?l.PowerOff:l.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),c.forEach(a=>{!1!==a.show&&e.push({key:`custom-${a.label}`,icon:a.icon,label:a.label,onClick:a.onClick,variant:a.variant||"default",disabled:a.disabled,disabledReason:a.disabledReason})}),s&&i&&e.push({key:"delete",icon:l.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),e},[t,s,r,n,o,i,c,m]);return 0===p.length?null:"dropdown"===d?e.jsx(Js,{delayDuration:200,children:e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pt,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:e.jsx(l.EllipsisVertical,{size:"compact"===u?14:16})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(a=>a.disabled?e.jsxs(sr,{disabledReason:a.disabledReason,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},a.key):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]},a.key))})]})}):e.jsx("div",{className:"flex items-center gap-1",children:p.map(a=>e.jsxs(Pt,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:a.onClick,className:"compact"===u?"h-7 px-2":"",children:[a.icon&&e.jsx(a.icon,{size:"compact"===u?14:16}),"compact"!==u&&e.jsx("span",{className:"ml-1",children:a.label})]},a.key))})}function md({item:a,level:t,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:c,renderActions:d,rowActionsVariant:u="default"}){const m=o.has(a.id),p=(a.children?.length??0)>0,h=24*t,f="inline"===u;return e.jsxs(e.Fragment,{children:[e.jsxs(Tn,{className:At(c&&"cursor-pointer",f&&"group"),onClick:c?()=>c(a):void 0,children:[e.jsx(Pn,{children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${h}px`},children:[p?e.jsx("button",{onClick:e=>{e.stopPropagation(),i(a.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:m?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6 shrink-0"}),n??e.jsx(l.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:String(a[r]??a.id)})]})}),s.map(s=>{const r=a[s.key],n=s.render?s.render(a,t):null!=r?String(r):"—";return e.jsx(Pn,{className:At("text-center",s.className),children:s.hoverContent?e.jsxs(cl,{openDelay:200,children:[e.jsx(dl,{asChild:!0,children:e.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),e.jsx(ul,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:s.hoverContent(a)})]}):n},String(s.key))}),d&&e.jsx(Pn,{className:"text-right",children:e.jsx("div",{onClick:e=>e.stopPropagation(),className:At("flex items-center justify-end gap-1",f&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:d(a)})})]}),p&&m&&a.children.map(a=>e.jsx(md,{item:a,level:t+1,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:c,renderActions:d,rowActionsVariant:u},a.id))]})}function pd(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 hd=a.memo(({variant:t="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:o,companies:i,alias:c,isAuthenticated:d,logout:u,switchUnit:m}=yn(),p=i?.[0]||null,h=c?i?.find(e=>e.alias===c):p,f=i||[],x=r||h||p||p,g=a.useCallback(e=>{n?n(e):m(e)},[n,m]),b=a.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===x?.alias),s=a.filter(e=>e.alias!==x?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[f,x?.alias]);if(!d||!o)return null;return"dropdown"===t?e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pt,{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:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(Ws,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(Os,{children:[e.jsxs(Vs,{children:[e.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(Hs,{children:b.map(a=>e.jsxs(Gs,{onClick:()=>g(a),className:a.alias===x?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),a.name,a.alias===x?.alias&&e.jsx(Is,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:u,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):e.jsxs(Lt,{className:s,children:[e.jsx(zt,{children:e.jsx(Ft,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Bt,{className:"space-y-4",children:[e.jsx(()=>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(l.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:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:x.name})]})}),b.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",b.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[b.slice(0,3).map(a=>e.jsx(Is,{variant:a.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>g(a),children:a.name},a.alias)),b.length>3&&e.jsxs(Is,{variant:"outline",className:"text-xs",children:["+",b.length-3]})]})]})]}),{}),e.jsx(Ot,{}),e.jsxs(Pt,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),fd=a.createContext({});function xd({children:t,config:s}){const r=a.useMemo(()=>{const e=Yr(),a=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:a}},[s?.navigation,s?.appName]);return e.jsx(fd.Provider,{value:r,children:t})}function gd(){return a.useContext(fd)}function bd(e,a){if(!e)return"Página";const t=e.find(e=>e.path===a);if(t)return t.label;const s=e.find(e=>a.startsWith(e.path+"/"));return s?.label||"Página"}function vd(e,t){const[s,r]=a.useState(e),n=a.useRef(),o=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(o(),n.current=setTimeout(()=>{r(e)},t),o),[e,t,o]),[s,o]}const wd=a.memo(function({actions:t}){const s=j.useLocation(),{navigation:r,appName:n}=gd(),o=bd(r,s.pathname),{metadata:i,headerActions:c}=Ho(),{setOpenMobile:d}=dc(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:f,switchUnit:x}=yn(),g=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[b,v]=j.useSearchParams(),[w,y]=a.useState(()=>b.get("search")||""),[N,C]=vd(w,Xr.debounceDelay);a.useEffect(()=>{if(!p)return;const e=new URLSearchParams(b);N?(e.set("search",N),e.set("page","1")):e.delete("search"),v(e)},[N,v,p]);const _=r?.find(e=>e.path===s.pathname)||r?.find(e=>s.pathname.startsWith(e.path+"/")),k=i.title||o,S=i.subtitle||_?.complementaryText||"Detalhes do item";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.jsx(Pt,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0",onClick:()=>d(!0),children:e.jsx(l.Menu,{size:20})}),e.jsxs("div",{className:"flex-shrink-0",children:[i.breadcrumbs&&i.breadcrumbs.length>0&&e.jsx("nav",{className:"flex items-center gap-1 text-xs text-muted-foreground mb-0.5",children:i.breadcrumbs.map((a,t)=>e.jsxs("span",{className:"flex items-center gap-1",children:[t>0&&e.jsx(l.ChevronRight,{className:"h-3 w-3"}),a.href?e.jsx(j.Link,{to:a.href,className:"hover:text-foreground transition-colors",children:a.label}):e.jsx("span",{children:a.label})]},t))}),e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:k})}),e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:S})]}),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(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Dt,{placeholder:"Pesquisar",value:w,onChange:e=>(e=>{y(e)})(e.target.value),className:"w-full pl-10 pr-8"}),w&&e.jsx(Pt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{C(),y("");const e=new URLSearchParams(b);e.delete("search"),e.delete("page"),v(e)},title:"Limpar busca",children:e.jsx(l.X,{size:14})})]}),e.jsx(Pt,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:e.jsx(l.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(c||t)&&e.jsx("div",{className:"flex items-center gap-2",children:c||t}),(void 0).VITE_WIKI_URL&&e.jsx(Pt,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>St((void 0).VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(hd,{variant:"dropdown",selectedUnit:g,onUnitChange:x})})]})]})})}),yd=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>N.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Nd=`https://${Gr().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,jd={logo:an.isQualiex?`${Nd}/logo-qualiex.svg`:`${Nd}/logo.svg`,smallLogo:an.isQualiex?`${Nd}/small-forlogic.svg`:`${Nd}/small.svg`},Cd=jd.logo,_d=jd.smallLogo;function kd({open:t,appName:s}){const[r,n]=a.useState(!1);return e.jsxs(Js,{children:[e.jsx(gc,{className:"p-0 gap-0",children:t?e.jsxs("div",{className:"flex flex-col gap-3 pl-2",children:[e.jsx("div",{className:"flex items-center h-10",children:e.jsx("img",{src:jd.logo,alt:"Logo",className:"h-8 max-w-full object-contain"})}),e.jsxs(Pt,{variant:"secondary",size:"default",className:"h-10 gap-2 px-3 justify-start w-full",onClick:()=>n(!0),children:[e.jsx(l.Grip,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s||"Módulos"})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center w-full gap-3",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-8",children:e.jsx("img",{src:jd.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})}),e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx("button",{className:"flex items-center justify-center h-10 w-8 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>n(!0),children:e.jsx(l.Grip,{className:"h-4 w-4"})})}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:s||"Módulos"})})]})]})}),e.jsx(Ti,{open:r,onOpenChange:n})]})}function Sd({config:a,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:o="Criar",triggerIcon:i=l.Plus,variant:c="button"}=a;if(!n||0===n.length)return null;if("split-button"===c){const a=n[0],o=a.icon||i,l=n.slice(1).map(e=>({id:e.id,label:e.label,icon:e.icon,onClick:e.onClick,disabled:e.disabled}));if(t){const t=e.jsx(Pt,{onClick:a.onClick,disabled:s||a.disabled,className:At("justify-center px-2 w-full",r),variant:"outline",size:"default",children:e.jsx(o,{className:"h-4 w-4 shrink-0"})});return e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:t}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:a.label})})]})}return e.jsx(dd,{label:a.label,onClick:a.onClick,icon:o,actions:l,variant:"outline",disabled:s||a.disabled,className:At("w-full",r),menuAlign:"start"})}const d=(a,s,r=!1)=>e.jsxs(e.Fragment,{children:[a,!t&&s&&e.jsx("span",{className:"truncate",children:s}),!t&&r&&e.jsx(l.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const a=n[0],o=a.icon||i,l=s||a.disabled,c=e.jsx(Pt,{onClick:a.onClick,disabled:l,className:At("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(o,{className:"h-4 w-4 shrink-0"}),a.label)});return t?e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:c}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:a.label})})]}):c}const u=e.jsx(Pt,{disabled:s,className:At("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(i,{className:"h-4 w-4 shrink-0"}),o,!0)});return e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:t?e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:u}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:o})})]}):u}),e.jsx(Ws,{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)})})]})}const Ad="forlogic-sidebar-pinned",Td=()=>{try{const e=localStorage.getItem(Ad);return!!e&&JSON.parse(e)}catch{return!1}};function Ed({direction:e="right",minWidth:t=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,c]=a.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[d,u]=a.useState(!1),m=a.useRef(null);a.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,i]);const p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!d)return;const a=a=>{let r;r="left"===e?window.innerWidth-a.clientX:a.clientX,r=Math.max(t,Math.min(s,r)),c(r),o?.(r)},r=()=>{u(!1),c(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}},[d,e,t,s,l,n,o]),a.useEffect(()=>(d?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d,e]),{width:l,isDragging:d,dragRef:m,handleMouseDown:p}}const Pd=a.createContext(void 0);function Md(){const e=a.useContext(Pd);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Dd({config:t,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{open:i,setOpen:c,setOpenMobile:d}=dc(),u=j.useLocation(),{alias:m,user:p}=yn(),{appName:h}=gd(),{hasOpenModal:f}=Md(),[x,g]=a.useState(Td),b=Cn(),v=a.useCallback(()=>{b&&d(!1)},[b,d]),w=r?Ed({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:i}):null;a.useEffect(()=>{c(!!x)},[x,c]);const y=e=>u.pathname===e||u.pathname.startsWith(e+"/");return e.jsxs(mc,{collapsible:"icon",className:At("app-sidebar bg-background border-r border-border py-4",i?"px-3":"px-1.5"),style:w&&i?{width:`${w.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(kd,{open:i,appName:h}),t?.moduleActions&&t.moduleActions.actions.length>0&&e.jsx("div",{className:"py-3",children:e.jsx(Js,{children:e.jsx(Sd,{config:t.moduleActions,isCollapsed:!i,isDisabled:f})})}),e.jsxs("div",{className:"relative py-5",children:[e.jsx(Ot,{}),e.jsx("div",{className:At("absolute top-1/2 -translate-y-1/2 z-[100] hidden md:block",i?"-right-6":"-right-[18px]"),children:e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx("button",{onClick:()=>{const e=!x;g(e),(e=>{try{localStorage.setItem(Ad,JSON.stringify(e))}catch{}})(e)},className:"h-6 w-6 flex items-center justify-center rounded-full bg-primary hover:bg-primary/90 shadow-md transition-colors",children:i?e.jsx(l.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:i?"Recolher":"Expandir"})})]})})]}),e.jsx(wc,{children:s||e.jsx(yc,{className:"p-0",children:e.jsx(Cc,{children:e.jsx(_c,{className:"gap-1",children:e.jsx(Js,{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:o}=yd({key:r,enabled:Boolean(a.permissionCheck&&m&&p?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),c=a.permissionCheck&&!n,d=o?l.Loader2:c?l.Lock:a.icon;c||a.complementaryText;return a.children&&a.children.length>0?i?e.jsx(ri,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(kc,{children:[e.jsx(ni,{asChild:!0,children:e.jsx(Ac,{size:"default",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(d,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:a.label}),e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),e.jsx(oi,{children:e.jsx(Mc,{children:a.children.map((a,t)=>e.jsx(s,{item:a,index:t},a.path))})})]})},a.path):e.jsx(kc,{children:e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx("div",{className:At("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors cursor-pointer","hover:bg-accent hover:text-accent-foreground"),children:e.jsx(d,{className:"h-4 w-4"})})}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:a.label})})]})},a.path):e.jsx(kc,{children:c||o?e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:i?e.jsx(Ac,{size:"default",className:"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:"flex items-center justify-center h-8 w-8",children:e.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text",children:a.label})]})}):e.jsx("div",{className:"flex items-center justify-center h-8 w-8 mx-auto rounded-md opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:o?"Verificando acesso...":"Acesso restrito"})})]}):i?e.jsx(Ac,{asChild:!0,isActive:y(a.path),size:"default",children:e.jsxs(j.Link,{to:a.path,className:"flex w-full items-center gap-3",onClick:v,children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(d,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:a.label})]})}):e.jsxs(er,{children:[e.jsx(ar,{asChild:!0,children:e.jsx(j.Link,{to:a.path,onClick:v,className:At("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",y(a.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:e.jsx(d,{className:"h-4 w-4"})})}),e.jsx(tr,{side:"right",children:e.jsx("p",{children:a.label})})]})},a.path)};return e.jsx(s,{item:a,index:t},a.path)})})})})})}),r&&w&&i&&e.jsx("div",{ref:w.dragRef,onMouseDown:w.handleMouseDown,className:At("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-['']",w.isDragging&&"bg-primary/40")})]})}const Id=a.memo(function({children:t,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=a.useMemo(()=>s||e.jsx(Dd,{config:r}),[s,r]),i=a.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(xd,{config:r,children:e.jsx(Vo,{children:e.jsx(uc,{defaultOpen:!1,style:i,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,e.jsxs("main",{className:"relative z-0 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(wd,{})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-muted/30",children:t})]})]})})})})});class Rd{static async sendEmail(e){const a=Ur(),{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 Ld=Rd;function zd({open:t,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:c,currentMemberIds:d=[]}){const[u,m]=a.useState([]),[p,h]=a.useState(!1),[f,x]=a.useState(""),{data:g=[],isLoading:b}=_o({enabled:t}),v=a.useMemo(()=>{let e=[...g];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},[g,f]),w=e=>{m(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},y=1===u.length,N=u.length>0;return e.jsx(es,{open:t,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl",variant:"form",children:[e.jsx(is,{showSeparator:!0,children:e.jsxs(ds,{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs(ls,{children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Dt,{placeholder:"Pesquisar...",value:f,onChange:e=>x(e.target.value),className:"pl-9"})]}),e.jsx(vr,{className:"h-[400px] pr-4",children:b?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e.jsx(fr,{className:"h-16 w-full"},t))}):0===v.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(l.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:v.map(a=>{const t=a.userId===c,s=d.includes(a.userId||""),r=u.includes(a.userId||"");return e.jsxs("div",{className:At("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(a.userId||""),children:[e.jsx(Ps,{checked:r,onCheckedChange:()=>w(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(l.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(cs,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:u.length>0&&e.jsxs("span",{children:[u.length," selecionado(s)"]})}),y&&o&&e.jsxs(Pt,{onClick:async()=>{if(o&&1===u.length){h(!0);try{await o(u[0],r),m([])}finally{h(!1)}}},disabled:p,variant:"outline",children:[e.jsx(l.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),N&&i&&e.jsxs(Pt,{onClick:async()=>{if(i&&0!==u.length){h(!0);try{await i(u,r),m([])}finally{h(!1)}}},disabled:p,children:[e.jsx(l.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",u.length>1?"Membros":"Membro"]})]})]})})}function Fd({place:t,level:s=0,manageAccessConfig:r}){const[n,o]=a.useState(!1),[i,c]=a.useState(!1),d=t.subPlaces&&t.subPlaces.length>0,u=t.isActive??!0,m=t.usersCount??0;return e.jsxs("div",{children:[e.jsxs(ri,{open:n,onOpenChange:o,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:[d?e.jsxs(ni,{className:"flex items-center gap-2 flex-1",children:[e.jsx(l.ChevronRight,{className:At("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(l.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(l.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(l.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(Is,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(ud,{customActions:[{label:"Gerenciar Acessos",icon:l.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),d&&e.jsx(oi,{children:t.subPlaces.map(a=>e.jsx(Fd,{place:a,level:s+1,manageAccessConfig:r},a.id))})]}),0===s&&e.jsx(Ot,{}),r&&e.jsx(zd,{open:i,onOpenChange:c,placeId:t.id,placeName:t.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(t.id),currentMemberIds:r.getCurrentMemberIds?.(t.id)})]})}const Ud=new class{get baseUrl(){return Jr()}async makeApiCall(e,a,t){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Ir.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 o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.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 $r.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 Rr.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Rr.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Bd(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 qd(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Od(){const{alias:e,isAuthenticated:a}=yn(),t=Ir.getAccessToken(),{data:s=[]}=_o({enabled:!0});return N.useQuery({queryKey:["leadership",e],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=Ur(),{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 o={};s.forEach(e=>{o[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const i=r.map(e=>({...e,name:o[e.id_user]?.name||"[Usuário inativo]",email:o[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=o[e];i.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||"[Usuário inativo]",email:a?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e).length})}),Bd(i)},enabled:!!t&&!!e&&a&&s.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const $d="common";function Vd(){const{alias:e}=yn(),a=N.useQueryClient(),t=Ur(),{t:s}=v.useTranslation();return N.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(a.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Qd(t,e,a.id_user,a.id_leader);const{data:r,error:n}=await t.schema($d).from("leaders").insert({alias:e,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function Hd(){const{alias:e}=yn(),a=N.useQueryClient(),t=Ur(),{t:s}=v.useTranslation();return N.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(!a.users.length)throw new Error(s("select_at_least_one","Selecione pelo menos um liderado"));const r=a.users.map(e=>e.id_user),{data:n}=await t.schema($d).from("leaders").select("id_user").eq("alias",e).in("id_user",r).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(s("users_already_leaders",`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`))}for(const c of a.users){if(a.id_leader&&c.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Qd(t,e,c.id_user,a.id_leader)}const o=a.users.map(t=>({alias:e,id_user:t.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await t.schema($d).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_added_success",`${t?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{i.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function Wd(){const{alias:e}=yn(),a=N.useQueryClient(),t=Ur(),{t:s}=v.useTranslation();return N.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await t.schema($d).from("leaders").select("id_user").eq("id",a.id).eq("alias",e).single();if(!r)throw new Error(s("leader_not_found","Líder não encontrado"));if(r.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Qd(t,e,r.id_user,a.id_leader,a.id);const{data:n,error:o}=await t.schema($d).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",e).select().single();if(o)throw o;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function Gd(){const{alias:e}=yn(),a=N.useQueryClient(),t=Ur(),{t:s}=v.useTranslation();return N.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await t.schema($d).from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function Yd(){const{alias:e}=yn(),a=N.useQueryClient(),t=Ur(),{t:s}=v.useTranslation();return N.useMutation({mutationFn:async({leaderUserId:a,selectedUsers:r})=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const n=r.map(e=>e.id_user),o=await Promise.all([t.schema($d).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",a),t.schema($d).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:i,error:l},{data:c,error:d}]=o;if(l)throw l;if(d)throw d;const u=i||[],m=c||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),f=m.filter(e=>e.id_leader!==a),x=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!x.has(e.id_user));for(const s of f)await Qd(t,e,s.id_user,a,s.id);for(const w of g){if(w.id_user===a)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await Qd(t,e,w.id_user,a)}const b=[];if(h.length){const a=h.map(e=>e.id);b.push(t.schema($d).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",e))}if(f.length){const s=f.map(e=>e.id);b.push(t.schema($d).from("leaders").update({id_leader:a}).in("id",s).eq("alias",e))}if(g.length){const s=g.map(t=>({alias:e,id_user:t.id_user,id_leader:a,is_active:!0,is_removed:!1}));b.push(t.schema($d).from("leaders").insert(s))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:f.length,created:g.length}},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${t.created} adicionados, ${t.updated} atualizados, ${t.unlinked} removidos)`))},onError:e=>{i.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function Qd(e,a,t,s,r){const{data:n,error:o}=await e.schema($d).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1);if(o)throw o;const i=r?n.filter(e=>e.id!==r):n,l=new Set;let c=s;for(;c;){if(l.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===t)throw new Error("Esta associação criaria um ciclo na hierarquia");l.add(c);const e=i.find(e=>e.id_user===c);c=e?.id_leader||null}}function Kd({leader:a,expandedIds:t,onToggleExpand:s,onEdit:r}){const n=t.has(a.id),o=a.children.length>0,i=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:`${i}px`},children:[o?e.jsx("button",{onClick:()=>s(a.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(l.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||"[Usuário inativo]"})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:a.subordinatesCount||0})})]}),o&&n&&a.children.map(a=>e.jsx(Kd,{leader:a,expandedIds:t,onToggleExpand:s,onEdit:r},a.id))]})}var Xd=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!t[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];t[o]={message:i.message,type:i.code}}else t[o]={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[o].types,c=l&&l[s.code];t[o]=p.appendErrors(o,a,t,r,c?[].concat(c,s.message):s.message)}e.shift()}return t},Zd=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&X.validateFieldsNatively({},n),{errors:{},values:t.raw?s:e}})}catch(l){return o(l)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:X.toNestErrors(Xd(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const Jd=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string()).min(1,"Selecione pelo menos um liderado")}),eu=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string())});function au({value:t,onChange:s,excludeUserIds:r=[],error:n}){const{data:o=[],isLoading:i}=_o(),[c,d]=a.useState(""),u=a.useRef(null),m=a.useRef(0),p=o.filter(e=>!r.includes(e.userId||"")).filter(e=>{const a=c.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||"",o=a.userName||a.userEmail||"";return n.localeCompare(o)});return a.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[p]),i?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Dt,{placeholder:"Buscar usuário...",value:c,onChange:e=>d(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===p.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Buscar usuário..."}):e.jsx("div",{className:"space-y-2",children:p.map(a=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ps,{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(Rt,{htmlFor:a.userId,className:"flex-1 cursor-pointer",children:a.userName||a.userEmail})]},a.userId))})}),t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.length," selecionado(s)"]}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function tu({leader:t,prefilledLeaderId:s,onSuccess:r}){const{alias:n}=yn(),o=!!t,i=t?.id.startsWith("virtual-"),c=Hd(),d=Vd(),u=Wd(),m=Yd(),h=Gd(),{data:f=[]}=Od(),{data:x=[]}=_o(),[g,b]=a.useState(""),v=qd(f).map(e=>e.id_user),w=o?qd(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user):[],y=p.useForm({resolver:Zd(o?eu:Jd),defaultValues:{id_leader:s||(o?t?.id_leader:null)||null,id_users:o?w:[]}});a.useEffect(()=>{if(t){const e=qd(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user);y.reset({id_leader:t.id_leader||null,id_users:e})}else s?y.reset({id_leader:s,id_users:[]}):y.reset({id_leader:null,id_users:[]})},[n,t?.id,t?.id_user,t?.id_leader,s,f]);const N=c.isPending||d.isPending||u.isPending||m.isPending||h.isPending,j=y.watch("id_leader"),C=y.watch("id_users"),_=o?[t.id_user,...v.filter(e=>e!==t.id_user&&!C.includes(e)&&!w.includes(e))]:[j,...v.filter(e=>!C.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:y.handleSubmit(async e=>{try{if(o)if(i){await d.mutateAsync({id_user:t.id_user,id_leader:e.id_leader});const a=x.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{await u.mutateAsync({id:t.id,id_leader:e.id_leader});const a=x.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{const a=x.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(Rt,{children:"Líder"}),e.jsx(Dt,{value:x.find(e=>e.userId===t.id_user)?.userName||t.name||"[Usuário inativo]",disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Superior Imediato"}),e.jsxs(ys,{value:j||"none",onValueChange:e=>y.setValue("id_leader","none"===e?null:e),children:[e.jsx(Cs,{children:e.jsx(js,{placeholder:"Selecione..."})}),e.jsxs(Ss,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Dt,{placeholder:"Buscar superior...",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(vr,{className:"h-[200px]",children:[e.jsx(Ts,{value:"none",children:"[Nenhum]"}),x.filter(e=>{const a=o?e.userId!==t.id_user:!C.includes(e.userId),s=!g||e.userName?.toLowerCase().includes(g.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(Ts,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${n}`),y.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:y.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Subordinados *"}),e.jsx(au,{value:C,onChange:e=>y.setValue("id_users",e),excludeUserIds:_,error:y.formState.errors.id_users?.message},`users-multiselect-${n}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Pt,{type:"submit",disabled:N||!o&&0===C.length,children:N&&!h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Atualizando...":"Salvando..."]}):o?"Atualizar":"Criar"}),o&&!j&&0===C.length&&e.jsxs($t,{children:[e.jsx(Vt,{asChild:!0,children:e.jsx(Pt,{type:"button",variant:"destructive",disabled:N,className:"ml-auto",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),e.jsxs(Gt,{children:[e.jsxs(Yt,{children:[e.jsx(Kt,{children:"Confirmar remoção"}),e.jsx(Xt,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),e.jsxs(Qt,{children:[e.jsx(Jt,{children:"Cancelar"}),e.jsx(Zt,{onClick:async()=>{if(t)try{await h.mutateAsync(t.id),r?.()}catch(e){}},children:"Remover"})]})]})]})]})]})}function su({open:a,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(es,{open:a,onOpenChange:t,children:e.jsxs(os,{variant:"form",className:"sm:max-w-[500px]",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(ds,{children:n})}),e.jsx(ls,{children:e.jsx(tu,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})})]})})}const ru="leadership-expanded-nodes",nu=(e,a)=>{try{localStorage.setItem(`${ru}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function ou(e){const[t,s]=a.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:l,onError:c}=e||{};return{upload:async(e,a)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);try{const t={...o,...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){const a=t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a);if(!a)throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await r(e,t);return i.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),l?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw i.toast.error("Erro",{description:e.message}),c?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,a),i.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw i.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:t}}function iu(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 lu(e,a){const t=iu(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function cu(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function du(e,a){const t=cu(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function uu(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function mu(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function pu(e,a){return e/a}function hu(){const{alias:e}=yn(),[t,s]=a.useState(null),[r,n]=a.useState(!0);a.useEffect(()=>{if(!e)return void n(!1);let a=!1;return(async()=>{n(!0);try{const t=Ur(),{data:r,error:n}=await t.schema("common").from("sign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();a||s(r)}catch(t){a||s(null)}finally{a||n(!1)}})(),()=>{a=!0}},[e]);const o=a.useCallback(async(a,t)=>{if(!e)throw new Error("Alias not available");const r=Ur(),{data:n,error:o}=await r.schema("common").from("sign_configs").upsert({alias:e,api_key:a,environment:t,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e]);return{config:t,isLoading:r,saveConfig:o}}const fu=(void 0).VITE_SUPABASE_URL,xu=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function gu(e,a,t){const s=Ir.getSupabaseToken(),r={"Content-Type":"application/json",apikey:xu};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${fu}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:a,data:t})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const bu={async createEnvelopeWithSigner(e){const a="d4sign"===e.provider?"d4sign":"clicksign",t="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await gu(a,t,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const a="d4sign"===e.provider?"d4sign":"clicksign";return(await gu(a,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let vu=null;function wu(){return window.Clicksign?Promise.resolve():vu||(vu=new Promise((e,a)=>{const t=document.createElement("script");t.src="https://cdn-public-library.clicksign.com/embedded/embedded.min-2.1.0.js",t.onload=()=>e(),t.onerror=()=>a(new Error("Falha ao carregar script do Clicksign")),document.head.appendChild(t)}),vu)}const yu="clicksign-container";function Nu({signerId:t,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const i=a.useRef(null),[c,d]=a.useState(!0),[u,m]=a.useState(null);return a.useEffect(()=>{let e=!1;return i.current&&(i.current.unmount(),i.current=null),m(null),d(!0),wu().then(()=>{if(e)return;const a=new window.Clicksign(t);a.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",a.origin=window.origin,a.mount(yu),a.on("loaded",function(){d(!1)}),a.on("signed",function(){r?.()}),a.on("resized",function(e){const a=e,t=document.getElementById(yu);t&&a?.data?.height&&(t.style.height=a.data.height+"px")}),a.on("error",function(e){d(!1),n?.(e instanceof Error?e:new Error("Erro no widget de assinatura"))}),a.on("closed",function(){o?.()}),i.current=a}).catch(a=>{e||(m("Falha ao carregar o script de assinatura."),d(!1),n?.(a))}),()=>{e=!0,i.current&&(i.current.unmount(),i.current=null)}},[t,s]),e.jsxs("div",{className:"relative h-full",children:[c&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-destructive",children:u})}),e.jsx("div",{id:yu,style:{height:"600px"}})]})}function ju({documentKey:t,signerEmail:s,signerName:r,keySigner:n,environment:o,onSign:i,onError:c}){const d=a.useRef(null),[u,m]=a.useState("loading"),[p,h]=a.useState(null),f="production"===o?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",x=(()=>{const e=new URLSearchParams({email:s,display_name:r||"",disable_preview:"0"});return n&&e.set("key_signer",n),`${f}/${t}?${e.toString()}`})(),g=a.useCallback(e=>"signed"===e.data?(m("ready"),void i?.()):"wrong-data"===e.data?(m("error"),h("O signatário reportou dados incorretos."),void c?.(new Error("O signatário reportou dados incorretos"))):void 0,[i,c]);a.useEffect(()=>(window.addEventListener("message",g,!1),()=>{window.removeEventListener("message",g,!1)}),[g]);const b=a.useCallback(()=>{"loading"===u&&m("ready")},[u]);return"error"===u?e.jsxs(Bo,{variant:"danger",className:"my-4",children:[e.jsx(qo,{children:"Erro ao carregar documento"}),e.jsx(Oo,{children:p||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):e.jsxs("div",{className:"relative h-full",children:["loading"===u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),e.jsx("iframe",{ref:d,id:"d4sign-container",src:x,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return v.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return v.useTranslation}}),exports.i18n=A,exports.AUTH_CONFIG=Qr,exports.AccessDeniedDialog=Ei,exports.Accordion=Di,exports.AccordionContent=Li,exports.AccordionItem=Ii,exports.AccordionTrigger=Ri,exports.ActionButton=Mt,exports.ActionMenu=ud,exports.ActionMenuItems=eo,exports.Alert=Bo,exports.AlertDescription=Oo,exports.AlertDialog=$t,exports.AlertDialogAction=Zt,exports.AlertDialogCancel=Jt,exports.AlertDialogContent=Gt,exports.AlertDialogDescription=Xt,exports.AlertDialogFooter=Qt,exports.AlertDialogHeader=Yt,exports.AlertDialogOverlay=Wt,exports.AlertDialogPortal=Ht,exports.AlertDialogTitle=Kt,exports.AlertDialogTrigger=Vt,exports.AlertTitle=qo,exports.AppHeader=wd,exports.AppLayout=Id,exports.AppSidebar=Dd,exports.AuthErrorInterceptor=Or,exports.AuthProvider=wn,exports.AuthService=xn,exports.Avatar=zi,exports.AvatarFallback=Ui,exports.AvatarImage=Fi,exports.Badge=Is,exports.BaseForm=So,exports.Blockquote=Tl,exports.BodyContent=function({breadcrumbs:a,children:t,className:s}){return e.jsxs("div",{className:At("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[a&&a.length>0&&e.jsx(Bi,{className:"mb-4",children:e.jsx(qi,{children:a.map((t,s)=>{const r=s===a.length-1;return e.jsxs(J.Fragment,{children:[s>0&&e.jsx(Hi,{}),e.jsx(Oi,{children:r||!t.href?e.jsx(Vi,{children:t.label}):t.asChild&&t.children?e.jsx($i,{asChild:!0,children:t.children}):e.jsx($i,{asChild:!0,children:e.jsx(j.Link,{to:t.href||"/",children:t.label})})})]},`${t.label}-${s}`)})})}),e.jsx("div",{className:"space-y-6",children:t})]})},exports.Breadcrumb=Bi,exports.BreadcrumbEllipsis=Wi,exports.BreadcrumbItem=Oi,exports.BreadcrumbLink=$i,exports.BreadcrumbList=qi,exports.BreadcrumbPage=Vi,exports.BreadcrumbSeparator=Hi,exports.Button=Pt,exports.ButtonGroup=Yi,exports.CRUD_CONFIG=Kr,exports.Calendar=Qi,exports.CallbackPage=()=>{const{processCallback:t}=yn(),s=j.useNavigate(),[r,n]=a.useState(null),[o,i]=a.useState(!1);a.useEffect(()=>{(async()=>{try{if(await t()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),s(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(e){localStorage.removeItem("auth_return_url"),n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t,s]);const c=async()=>{i(!0),n(null);try{await t()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},d=()=>{window.location.href="/"};return r?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(Lt,{className:"w-full max-w-md",children:[e.jsx(zt,{className:"text-center",children:e.jsxs(Ft,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(Bt,{className:"space-y-4",children:[e.jsx(Bo,{variant:"danger",children:e.jsx(Oo,{children:r})}),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(Pt,{onClick:c,disabled:o,className:"flex-1",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ls,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(Pt,{onClick:d,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(Lt,{className:"w-full max-w-md",children:[e.jsx(zt,{className:"text-center",children:e.jsx(Ft,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Bt,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ls,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Lt,exports.CardContent=Bt,exports.CardDescription=Ut,exports.CardFooter=qt,exports.CardHeader=zt,exports.CardSkeleton=In,exports.CardTitle=Ft,exports.ChartContainer=ad,exports.ChartLegend=nd,exports.ChartLegendContent=od,exports.ChartStyle=td,exports.ChartTooltip=sd,exports.ChartTooltipContent=rd,exports.Checkbox=Ps,exports.Collapsible=ri,exports.CollapsibleContent=oi,exports.CollapsibleTrigger=ni,exports.ColorPicker=yo,exports.ComboTree=function({multiple:t=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:c,emptyMessage:d,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:f,className:x,maxDisplayedBadges:g,popoverContainer:b,onOpen:w,onClose:y}){const{t:N}=v.useTranslation(),[j,C]=a.useState(!1),[_,k]=a.useState(""),[S,A]=a.useState(new Set),T=o||N("select_placeholder","Selecione..."),E=d||N("no_results","Nenhum resultado encontrado"),P=u||N("search_placeholder","Pesquisar..."),M=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),D=a.useMemo(()=>{if(!b)return;let e=b,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},[b]),I=a.useMemo(()=>Nr(s,_),[s,_])??s,R=a.useMemo(()=>_?function(e,a){const t=new Set,s=yr(a);function r(e){if(!e.children||0===e.children.length)return yr(e.label).includes(s);let a=!1;for(const t of e.children)r(t)&&(a=!0);return a&&t.add(e.value),a||yr(e.label).includes(s)}for(const n of e)r(n);return t}(s,_):new Set,[s,_]),L=_?R:S,z=a.useCallback(e=>{_||A(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[_]),F=a.useMemo(()=>M.map(e=>({value:e,label:jr(s,e)||e})),[M,s]),U=e=>{C(e),e?w?.():(k(""),y?.())},B=a.useCallback(e=>{if(n)if(t){const a=M.includes(e)?M.filter(a=>a!==e):[...M,e];n(a)}else n(e),C(!1)},[n,t,M]),q=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?M.filter(a=>a!==e):"")},O=g?F.slice(0,g):F,$=g&&F.length>g?F.length-g:0;if(h)return e.jsxs("div",{className:At("space-y-2",x),children:[i&&e.jsxs(Rt,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const V="string"==typeof f?f:f instanceof Error?f.message:f?N("error_loading","Erro ao carregar"):void 0;return V?e.jsxs("div",{className:At("space-y-2",x),children:[i&&e.jsxs(Rt,{children:[i,p&&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(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:V})]})]}):e.jsxs("div",{className:At("space-y-2",x),children:[i&&e.jsxs(Rt,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:j,onOpenChange:U,modal:!1,children:[e.jsx(nr,{asChild:!0,children:t?e.jsxs("div",{role:"combobox","aria-expanded":j,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),U(!j))},className:At("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",m&&"pointer-events-none opacity-50 cursor-not-allowed",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[c&&e.jsx(c,{className:"h-4 w-4"}),T]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[O.map(a=>e.jsxs(Is,{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&&q(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>q(a.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),$>0&&e.jsxs(Is,{variant:"outline",className:"gap-1",children:["+",$]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pt,{variant:"outline",role:"combobox","aria-expanded":j,disabled:m,className:At("w-full justify-between min-h-10 h-auto",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[c&&e.jsx(c,{className:"h-4 w-4"}),T]}):e.jsxs("span",{className:"flex items-center gap-2",children:[c&&e.jsx(c,{className:"h-4 w-4"}),F[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxs(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:D,collisionBoundary:D,children:[e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(l.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("input",{className:"flex h-10 w-full bg-transparent py-3 px-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",placeholder:P,value:_,onChange:e=>k(e.target.value)}),_&&e.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>k(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(vr,{className:"max-h-[300px]",children:e.jsx("div",{role:"tree",className:"p-1",children:0===I.length?e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:N("no_search_results","Nenhum resultado encontrado")}):e.jsx(_r,{nodes:I,level:0,expandedIds:L,onToggleExpand:z,selectedValues:M,onSelect:B})})})]})]})]})},exports.Combobox=br,exports.Command=ir,exports.CommandDialog=({children:a,...t})=>e.jsx("div",{...t,children:e.jsx(ir,{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=dr,exports.CommandGroup=ur,exports.CommandInput=lr,exports.CommandItem=pr,exports.CommandList=cr,exports.CommandSeparator=mr,exports.CommandShortcut=hr,exports.ContentContainer=function({title:a,subtitle:t,children:s,className:r,hasHeader:n=!0}){const o=a||t;return e.jsxs("div",{className:At("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-hidden",r),children:[n&&o&&e.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[a&&e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:a}),t&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),s&&e.jsx("div",{className:At("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Un,exports.ContextMenuCheckboxItem=Qn,exports.ContextMenuContent=Gn,exports.ContextMenuGroup=qn,exports.ContextMenuItem=Yn,exports.ContextMenuLabel=Xn,exports.ContextMenuPortal=On,exports.ContextMenuRadioGroup=Vn,exports.ContextMenuRadioItem=Kn,exports.ContextMenuSeparator=Zn,exports.ContextMenuShortcut=Jn,exports.ContextMenuSub=$n,exports.ContextMenuSubContent=Wn,exports.ContextMenuSubTrigger=Hn,exports.ContextMenuTrigger=Bn,exports.CoreProviders=function({children:t,queryClient:s,moduleAlias:r,moduleAccessGuardProps:n,appTranslations:o}){const[i]=a.useState(()=>new N.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),l=s??i;return a.useEffect(()=>{if(o)for(const[e,a]of Object.entries(o))Qo(e,a)},[o]),e.jsx(ii,{children:e.jsx(v.I18nextProvider,{i18n:A,children:e.jsx(N.QueryClientProvider,{client:l,children:e.jsx(wn,{children:e.jsx(Jo,{children:e.jsx(ti,{moduleAlias:r,children:e.jsx(Mi,{...n,children:t})})})})})})})},exports.CrudActionBar=uo,exports.CrudGrid=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:l,customRowActions:c,enableBulkActions:d=!1,onNew:u,newButtonLabel:m,showNewButton:p=!0,customActions:h=[],hideActionBar:f,showActionBar:x=!0,showSearch:g=!1,searchValue:b,onSearchChange:v,searchPlaceholder:w,bulkActions:y=[],onBulkDelete:N,filters:j,gridColumns:C=3,renderCard:_,viewMode:k,onViewModeChange:S,listCardRenderer:A,gridCardRenderer:T,showViewToggle:E=!1})=>{const{setSearchVisible:P}=yn(),M=void 0!==f?!f:x;a.useEffect(()=>{if(!g)return P(!0),()=>P(!1)},[P,g]);const D=u||h.length>0||g||d||j||E,I=N||(()=>{t.bulkDelete?.(t.selectedIds)}),R=k||"grid",L="list"===R,z={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"}[L?1:C],F=M&&D?e.jsx(uo,{onNew:u,newButtonLabel:m,showNewButton:p,showSearch:g,searchValue:b,onSearchChange:v,searchPlaceholder:w,showBulkActions:d,selectedCount:t.selectedIds.length,bulkActions:y,onBulkDelete:I,onClearSelection:t.clearSelection,customActions:h,filters:j,viewMode:R,onViewModeChange:S,showViewToggle:E,availableViewModes:["list","grid"]}):null;return t.isLoading?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(In,{count:6})})]}):0===t.entities.length?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:At("grid gap-4",z),children:t.entities.map(a=>{const u=(e=>L&&A?A(e):!L&&T?T(e):_?_(e):null)(a);return e.jsxs(Un,{children:[e.jsx(Bn,{asChild:!0,children:u?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),d?t.selectItem(a.id):r?.(a)},children:u}):e.jsx(Lt,{className:At("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",d&&t.selectedIds.includes(a.id)&&"bg-muted ring-2 ring-primary",L&&"flex-row"),onClick:e=>{e.stopPropagation(),d?t.selectItem(a.id):r?.(a)},children:e.jsxs(Bt,{className:At("p-4",L&&"flex items-center gap-4 w-full"),children:[d&&e.jsx("div",{className:At(L?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(mo,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),L?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(ao,{onEdit:r?()=>r(a):void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[d&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(mo,{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:At("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(ao,{onEdit:r?()=>r(a):void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})]})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(a):void 0,onDelete:i?()=>i(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived,canDelete:!!i,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})})]})},exports.CrudPageInternal=Ro,exports.CrudPagination=To,exports.CrudPrimitiveFilterBar=function({searchValue:a="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=v.useTranslation(),c=a||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===o?"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(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Dt,{type:"text",placeholder:i("search","Pesquisar"),value:a,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e.jsx("div",{className:"vertical"===o?"w-full":"",children:a},t)),n&&c&&r&&e.jsxs(Pt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(l.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})},exports.CrudPrimitivePagination=Ao,exports.CrudPrimitiveTable=function({data:t,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:c,isLoading:d=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:f,onSelectAll:x,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:w,enableColumnReorder:y=!1,onReorderColumns:N,storageKey:j}){const{t:C}=v.useTranslation(),_=u||C("no_items_found","Nenhum item encontrado"),{columnWidths:k,isDragging:S,activeColumn:A,handleMouseDown:T}=ro({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:w,enabled:b}),E=fo({enabled:y&&!!N,onReorder:N??(()=>{})}),P=a.useMemo(()=>{if(b)return s.map(e=>`${k[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,k]);return d?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(fr,{className:"h-12 w-full"},t))})}):0===t.length?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:_})})}):e.jsx("div",{className:"flex-1 overflow-auto "+(S?"select-none":""),children:e.jsxs(_n,{className:m,children:[e.jsx(kn,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Tn,{children:[p&&e.jsx(En,{className:"w-[40px]",children:e.jsx(Ps,{checked:g,onCheckedChange:x,"aria-label":C("select_all","Selecionar todos")})}),s.map((a,t)=>{const s=b&&!1!==a.resizable,i=A===String(a.key),c=y&&!!N,d=c?E.getDragProps(t):{},u=E.dragFromIndex===t,m=E.dragOverIndex===t&&E.dragFromIndex!==t;return e.jsxs(En,{className:At(a.className,"relative transition-opacity",c&&!E.isDragging&&"cursor-grab",c&&E.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:P[t]},...d,children:[a.sortable&&o?e.jsxs("button",{onClick:()=>o(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(p=String(a.key),r!==p?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:a.header}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>T(String(a.key),e),isDragging:i})]},String(a.key));var p}),c&&e.jsx(En,{className:"w-[80px] text-right",children:C("actions","Ações")})]})}),e.jsx(Sn,{children:t.map(a=>e.jsxs(Tn,{onClick:()=>i?.(a),className:(i?"cursor-pointer":"")+" relative",children:[p&&e.jsx(Pn,{children:e.jsx(Ps,{checked:h.includes(a.id),onCheckedChange:()=>f?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`${C("select_all","Selecionar todos")} ${a.id}`})}),s.map(t=>e.jsx(Pn,{className:t.className,children:e.jsx(zn,{children:t.render?t.render(a):String(a[t.key]??"-")})},String(t.key))),c&&e.jsx(Pn,{className:"text-right",onClick:e=>e.stopPropagation(),children:c(a)})]},a.id))})]})})},exports.CrudTable=bo,exports.D4SignWidget=ju,exports.DATETIME_FORMATS=ht,exports.DEFAULT_DATETIME_FORMAT=gt,exports.DEFAULT_LOCALE=xt,exports.DEFAULT_TIMEZONE=bt,exports.DataList=Ki,exports.DatePicker=function({date:a,onDateChange:t,placeholder:s="Selecione uma data",disabled:r=!1,className:n,disabledDates:i}){return e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pt,{variant:"outline",disabled:r,className:At("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",n),children:[e.jsx(l.Calendar,{className:"mr-2 h-4 w-4"}),a?o.format(a,"d 'de' MMMM 'de' yyyy",{locale:mt}):e.jsx("span",{children:s})]})}),e.jsx(or,{className:"w-auto p-0",align:"start",children:e.jsx(Qi,{mode:"single",selected:a,onSelect:t,disabled:i,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=es,exports.DialogBody=ls,exports.DialogClose=ss,exports.DialogContent=os,exports.DialogDescription=us,exports.DialogFooter=cs,exports.DialogHeader=is,exports.DialogOverlay=rs,exports.DialogPortal=ts,exports.DialogTitle=ds,exports.DialogTrigger=as,exports.DisabledMenuItem=sr,exports.DocumentSigner=function({file:t,onDocumentSigned:s,onError:r,showEventLog:n=!1}){const{user:o,alias:c}=yn(),{config:d,isLoading:u}=hu(),{t:m}=v.useTranslation(),[p,h]=a.useState(null),[f,x]=a.useState(!1),[g,b]=a.useState(null),[w,y]=a.useState("sandbox"),[N,j]=a.useState("clicksign"),[C,_]=a.useState(null),[k,S]=a.useState(null),[A,T]=a.useState(!1),[E,P]=a.useState(0),[M,D]=a.useState(!1),[I,R]=a.useState([]),L=a.useRef(null),z=a.useRef(null),F=a.useCallback(e=>{n&&R(a=>[...a,`[${(new Date).toLocaleTimeString()}] ${e}`])},[n]),U=a.useCallback(async e=>{if(h(e),b(null),_(null),S(null),F(`Arquivo selecionado: ${e.name}`),c&&o){x(!0);try{const a=d?.provider??"clicksign";j(a),F(`Provedor resolvido: ${a}`);const t=new FileReader,s=await new Promise((a,s)=>{t.onload=()=>{const e=t.result;a(e)},t.onerror=s,t.readAsDataURL(e)});F(`Criando envelope para assinatura via ${a}...`);const n=await bu.createEnvelopeWithSigner({alias:c,contentBase64:s,filename:e.name,signerEmail:o.email||"",signerName:o.name||"",provider:a});F(`Envelope criado: ${n.envelope_id}`),_({envelope_id:n.envelope_id,document_id:n.document_id,signer_email:n.signer_email,key_signer:n.signer_id}),y(n.environment),j(n.provider||a),"d4sign"===a?(F("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(n.document_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):n.signer_id?(F(`Signer ID obtido: ${n.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(n.signer_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):(F("AVISO: Nenhum signer ID disponível."),i.toast.error(m("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),r?.(new Error("Signer ID não disponível")))}catch(a){const e=a instanceof Error?a:new Error(m("sign_process_error","Erro ao processar documento")),t=e.message||"";t.includes("MONTHLY_LIMIT_REACHED")?(F("Limite mensal de assinaturas atingido"),i.toast.error(m("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(F(`Erro: ${t}`),i.toast.error(t)),r?.(e)}finally{x(!1)}}},[c,o,F,r,d]);a.useEffect(()=>{t&&c&&o&&!u&&t!==z.current&&(z.current=t,U(t))},[t,c,o,u,U]);const B=a.useCallback(async()=>{if(!C||!c)return;T(!0),P(0),D(!1),F("Buscando documento assinado...");for(let a=1;a<=6;a++){P(a),F(`Tentativa ${a}/6...`);try{const e=await bu.getSignedDocument({alias:c,envelopeId:C.envelope_id,documentId:C.document_id,provider:N});if(e.download_url)return F("Documento assinado disponível para download"),S(e.download_url),void T(!1)}catch(e){F(`Erro na tentativa ${a}: ${e instanceof Error?e.message:"Erro desconhecido"}`)}a<6&&(F("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}F("Não foi possível obter o documento assinado após 6 tentativas."),T(!1),D(!0)},[C,c,F,N]),q=a.useCallback(async()=>{F("Documento assinado com sucesso!"),i.toast.success(m("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&c&&(s?.({success:!0,provider:N,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:g||"",environment:w}),await B())},[F,s,C,g,c,w,N,B]);if(!c)return e.jsx(Lt,{className:"border-amber-200 bg-amber-50",children:e.jsx(Bt,{className:"flex items-start gap-3 py-6",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800",children:m("sign_auth_required","Autenticação necessária")}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:m("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const O="d4sign"===N?"D4Sign":"Clicksign",$=()=>n&&I.length>0?e.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:I.map((a,t)=>e.jsx("div",{children:a},t))}):null;return C&&!g&&(k||A||M)?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Lt,{className:"border-green-200 bg-green-50",children:e.jsxs(Bt,{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(l.CheckCircle2,{className:"h-12 w-12 text-green-600"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-green-800",children:m("sign_signed_success","Documento assinado com sucesso!")}),e.jsx("p",{className:"text-sm text-green-700 mt-1",children:p?.name})]}),A?e.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),m("sign_preparing_doc","Preparando documento assinado...")," (",m("sign_attempt","tentativa")," ",E,"/6)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_waiting_provider",`Aguardando processamento pelo ${O}...`)})]}):k?e.jsx(Pt,{asChild:!0,variant:"default",className:"gap-2",children:e.jsxs("a",{href:k,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(l.Download,{className:"h-4 w-4"}),m("sign_download_signed","Baixar documento assinado")]})}):M?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),e.jsxs(Pt,{variant:"secondary",className:"gap-2",onClick:B,children:[e.jsx(l.RefreshCw,{className:"h-4 w-4"}),m("sign_try_again","Tentar novamente")]})]}):null]})}),e.jsx($,{})]}):g?e.jsxs("div",{className:"space-y-4",children:["d4sign"===N?e.jsx(ju,{documentKey:g,signerEmail:C?.signer_email||o?.email||"",signerName:o?.name,keySigner:C?.key_signer,environment:w,onSign:q,onError:r}):e.jsx(Nu,{signerId:g,environment:w,onSign:q,onError:r}),e.jsx($,{})]}):t&&(f||u)?e.jsx(Lt,{children:e.jsxs(Bt,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const a=e.target.files?.[0];a&&"application/pdf"===a.type?U(a):i.toast.error(m("sign_select_pdf","Selecione um arquivo PDF"))}}),f?e.jsx(Lt,{children:e.jsxs(Bt,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsx(Lt,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:e.jsxs(Bt,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(l.Upload,{className:"h-8 w-8 text-muted-foreground"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:m("sign_select_pdf","Selecione um arquivo PDF")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),e.jsx($,{})]})},exports.Drawer=Xi,exports.DrawerClose=el,exports.DrawerContent=tl,exports.DrawerDescription=ol,exports.DrawerFooter=rl,exports.DrawerHeader=sl,exports.DrawerOverlay=al,exports.DrawerPortal=Ji,exports.DrawerTitle=nl,exports.DrawerTrigger=Zi,exports.DropdownMenu=Fs,exports.DropdownMenuCheckboxItem=Ys,exports.DropdownMenuContent=Ws,exports.DropdownMenuGroup=Bs,exports.DropdownMenuItem=Gs,exports.DropdownMenuLabel=Ks,exports.DropdownMenuPortal=qs,exports.DropdownMenuRadioGroup=$s,exports.DropdownMenuRadioItem=Qs,exports.DropdownMenuSeparator=Xs,exports.DropdownMenuShortcut=Zs,exports.DropdownMenuSub=Os,exports.DropdownMenuSubContent=Hs,exports.DropdownMenuSubTrigger=Vs,exports.DropdownMenuTrigger=Us,exports.EmailService=Rd,exports.EmptyState=Ln,exports.EntitySelect=br,exports.ErrorBoundary=ii,exports.FilterBar=Io,exports.Form=ms,exports.FormControl=bs,exports.FormDescription=vs,exports.FormField=({...a})=>e.jsx(ps.Provider,{value:{name:a.name},children:e.jsx(p.Controller,{...a})}),exports.FormItem=xs,exports.FormLabel=gs,exports.FormMessage=ws,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(fr,{className:"h-4 w-24"}),e.jsx(fr,{className:"h-10 w-full"})]},t)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(fr,{className:"h-10 w-20"}),e.jsx(fr,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:a,cols:t="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:At("grid",il[t],ll[s],r),children:a})},exports.H1=vl,exports.H2=wl,exports.H3=yl,exports.H4=Nl,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(fr,{className:"h-8 w-8 rounded-full"}),e.jsx(fr,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(fr,{className:"h-8 w-8"}),e.jsx(fr,{className:"h-8 w-24"})]})]})},exports.HoverCard=cl,exports.HoverCardContent=ul,exports.HoverCardTrigger=dl,exports.IconPicker=jo,exports.ImageEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:c,uploadOptions:d}){const[u,m]=a.useState(t||{alignment:"center",allowDownload:!1}),p=a.useRef(null),{upload:h,uploading:f}=ou({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),x=(e,a)=>{const t={...u,[e]:a};m(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Dt,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:u.imageUrl||"",onChange:e=>x("imageUrl",e.target.value),className:"flex-1"}),o&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await h(a),t={...u,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};m(t),s(t)}catch(t){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pt,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),u.imageFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",u.imageFile," (",Math.round((u.imageSize||0)/1024)," KB)"]})]}),u.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===u.alignment?"justify-start":"right"===u.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:u.imageUrl,alt:u.alt||"Preview",style:{width:u.width?`${u.width}px`:"auto",height:u.height?`${u.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{htmlFor:"caption",children:"Legenda"}),e.jsx(Ms,{id:"caption",placeholder:"Legenda",value:u.caption||"",onChange:e=>x("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{htmlFor:"alt",children:"Texto Alternativo"}),e.jsx(Dt,{id:"alt",placeholder:"Texto Alternativo",value:u.alt||"",onChange:e=>x("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Alinhamento"}),e.jsxs(ys,{value:u.alignment||"center",onValueChange:e=>x("alignment",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(Ss,{children:[e.jsx(Ts,{value:"left",children:"Esquerda"}),e.jsx(Ts,{value:"center",children:"Centro"}),e.jsx(Ts,{value:"right",children:"Direita"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{htmlFor:"width",children:"Largura"}),e.jsx(Dt,{id:"width",type:"number",placeholder:"px",value:u.width||"",onChange:e=>x("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{htmlFor:"height",children:"Altura"}),e.jsx(Dt,{id:"height",type:"number",placeholder:"px",value:u.height||"",onChange:e=>x("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"allowDownload",checked:u.allowDownload||!1,onCheckedChange:e=>x("allowDownload",!0===e)}),e.jsx(Rt,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Pt,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pt,{onClick:()=>{u.imageUrl?r(u):i.toast.error("Erro",{description:"Nenhuma imagem selecionada"})},disabled:!u.imageUrl,children:"Salvar"})]})]})},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(l.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Al,exports.Input=Dt,exports.InputGroup=ml,exports.InputGroupAddon=hl,exports.InputGroupButton=xl,exports.InputGroupInput=gl,exports.InputGroupTextarea=bl,exports.LOGO_CONFIG=an,exports.Label=Rt,exports.Large=_l,exports.Lead=Cl,exports.LeaderRow=Kd,exports.LeadershipDialog=su,exports.LeadershipForm=tu,exports.LeadershipPage=function(){const{alias:t}=yn(),{data:s,isLoading:r,error:n,refetch:o}=Od(),[i,c]=a.useState(()=>t?(e=>{try{const a=localStorage.getItem(`${ru}-${e}`);if(a)return new Set(JSON.parse(a))}catch(n){}return new Set})(t):new Set),[d,u]=a.useState(!1),[m,p]=a.useState(),[h,f]=a.useState(null),x=(s?qd(s):[]).filter(e=>"[Usuário inativo]"!==e.name).length;a.useEffect(()=>{if(s&&s.length>0&&t){if(!localStorage.getItem(`${ru}-${t}`)){const e=s.map(e=>e.id),a=new Set(e);c(a),nu(t,a)}}},[s,t]);const g=e=>{c(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),t&&nu(t,s),s})},b=e=>{p(e),f(null),u(!0)};return r?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(l.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})]})}):n?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(Pt,{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(Pt,{size:"sm",onClick:()=>{p(void 0),f(null),u(!0)},children:[e.jsx(l.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(Pt,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=qd(s).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);c(a),t&&nu(t,a)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(Pt,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;c(e),t&&nu(t,e)},disabled:!s||0===s.length,children:[e.jsx(l.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(l.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[x," usuário",1!==x?"s":""," associado",1!==x?"s":""]})]})})]})}),s&&0!==s.length?e.jsx(vr,{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:s.map(a=>e.jsx(Kd,{leader:a,expandedIds:i,onToggleExpand:g,onEdit:b},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(su,{open:d,onOpenChange:()=>{u(!1),p(void 0),f(null)},leader:m,prefilledLeaderId:h,title:m?"Editar Nome":h?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${t}`)]})},exports.List=El,exports.LoadingState=function({isLoading:a,children:t,className:s,type:r="spinner",size:n="md"}){return a?"overlay"===r?e.jsxs("div",{className:At("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(Ls,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:At("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:At("flex items-center justify-center py-8",s),children:e.jsx(Ls,{size:n})}):e.jsx(e.Fragment,{children:t})},exports.LocaleProvider=Jo,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(Lt,{className:"w-full max-w-md",children:[e.jsx(zt,{className:"text-center",children:e.jsx(Ft,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Bt,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(Pt,{onClick:async()=>{Zr()?await xn.loginDev():xn.loginProd()},className:"w-full",size:"lg",children:Zr()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=tn,exports.MODULES_DATA=wi,exports.ManageAccessModal=zd,exports.Menubar=qc,exports.MenubarCheckboxItem=Gc,exports.MenubarContent=Hc,exports.MenubarGroup=zc,exports.MenubarItem=Wc,exports.MenubarLabel=Qc,exports.MenubarMenu=Lc,exports.MenubarPortal=Fc,exports.MenubarRadioGroup=Bc,exports.MenubarRadioItem=Yc,exports.MenubarSeparator=Kc,exports.MenubarShortcut=Xc,exports.MenubarSub=Uc,exports.MenubarSubContent=Vc,exports.MenubarSubTrigger=$c,exports.MenubarTrigger=Oc,exports.ModalStateProvider=function({children:t}){const[s,r]=a.useState(new Set),[n,o]=a.useState(!1),i=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})},[]),c=a.useCallback(e=>{o(e)},[]),d=a.useMemo(()=>s.size>0||n,[s,n]),u=a.useMemo(()=>({openModals:s,hasOpenModal:d,registerModal:i,unregisterModal:l,setHasOpenModal:c}),[s,d,i,l,c]);return e.jsx(Pd.Provider,{value:u,children:t})},exports.ModuleAccessGuard=Mi,exports.ModuleGrid=ji,exports.ModuleOfferContent=function({title:a,description:t,image:s,icon:r,ctaLabel:n="Quero conhecer mais",onCtaClick:o,children:i}){return e.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(s||r)&&e.jsx("div",{className:"flex items-center justify-center",children:s?e.jsx("img",{src:s,alt:a,className:"max-h-48 w-auto object-contain rounded-lg"}):r?e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(r,{className:"h-12 w-12 text-primary"})}):null}),e.jsxs("div",{className:"space-y-3 max-w-lg",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground",children:a}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t})]}),i?e.jsx("div",{className:"w-full",children:i}):o?e.jsxs(Pt,{onClick:o,size:"lg",className:"gap-2",children:[e.jsx(l.Sparkles,{className:"h-4 w-4"}),n]}):null]})},exports.ModuleProvider=ti,exports.ModulesContent=Ci,exports.ModulesDialog=Ti,exports.ModulesFooterCards=vi,exports.MultiSelect=br,exports.Muted=Sl,exports.NavigationMenu=Pl,exports.NavigationMenuContent=Ll,exports.NavigationMenuIndicator=Ul,exports.NavigationMenuItem=Dl,exports.NavigationMenuLink=zl,exports.NavigationMenuList=Ml,exports.NavigationMenuTrigger=Rl,exports.NavigationMenuViewport=Fl,exports.NavigationProvider=xd,exports.OnboardingDialog=xi,exports.P=jl,exports.PROD_PROJECT_ID=Vr,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(Bi,{className:s,children:e.jsx(qi,{children:r.map((a,t)=>{const s=0===t,r=n&&1===t;return e.jsxs(Oi,{children:[!s&&e.jsx(Hi,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Wi,{}),e.jsx(Hi,{})]}),a.isCurrentPage?e.jsx(Vi,{children:a.label}):e.jsx($i,{asChild:!0,children:e.jsx(j.Link,{to:a.href||"/",children:a.label})})]},a.label)})})})},exports.PageMetadataProvider=Vo,exports.Pagination=Bl,exports.PaginationContent=ql,exports.PaginationEllipsis=Wl,exports.PaginationItem=Ol,exports.PaginationLink=$l,exports.PaginationNext=Hl,exports.PaginationPrevious=Vl,exports.PlaceCard=Fd,exports.PlacesList=function({places:a,isLoading:t,manageAccessConfig:s}){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:"Carregando dados..."})]})}):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(Fd,{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(l.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=rr,exports.PopoverContent=or,exports.PopoverTrigger=nr,exports.Progress=mi,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:s,isLoading:r}=yn();if(a.useEffect(()=>{if(r)return;if(s)return;if(Ir.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=Zr(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{n?await xn.loginDev():xn.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(Lt,{className:"w-full max-w-md",children:[e.jsx(zt,{className:"text-center",children:e.jsx(Ft,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Bt,{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(Lt,{className:"w-full max-w-md",children:[e.jsx(zt,{className:"text-center",children:e.jsx(Ft,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Bt,{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(Lt,{className:"w-full max-w-md",children:[e.jsx(zt,{className:"text-center",children:e.jsx(Ft,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Bt,{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:Zr()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:t})},exports.QUALIEX_CONFIG=en,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=dn,exports.QualiexErrorInterceptor=$r,exports.QualiexUserField=ko,exports.RadioGroup=Gl,exports.RadioGroupItem=Yl,exports.ResizableHandle=({withHandle:a,className:t,...s})=>e.jsx(Ne.PanelResizeHandle,{className:At("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(l.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Ql,exports.ResizablePanelGroup=({className:a,...t})=>e.jsx(Ne.PanelGroup,{className:At("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:o="300px",showModeToggle:i=!0,showVariableHint:c=!0,className:d})=>{const[u,m]=a.useState("visual"),p=$.useEditor({extensions:[V.configure({heading:{levels:[1,2,3]}}),H,W.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:t||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});J.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:At("space-y-2",d),children:[i&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Pt,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(l.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(Pt,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(l.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(Pt,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(l.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&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 cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||p?.commands.focus()},children:[e.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(ld,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(l.Heading1,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(l.Heading2,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(l.Heading3,{className:"h-4 w-4"})}),e.jsx(cd,{}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(l.Bold,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(l.Italic,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(l.Underline,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(l.Strikethrough,{className:"h-4 w-4"})}),e.jsx(cd,{}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(l.List,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(l.ListOrdered,{className:"h-4 w-4"})}),e.jsx(cd,{}),e.jsx(ld,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(l.Highlighter,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(l.Link,{className:"h-4 w-4"})}),e.jsx(cd,{}),e.jsx(ld,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(l.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(cd,{}),e.jsx(ld,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(l.Undo,{className:"h-4 w-4"})}),e.jsx(ld,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(l.Redo,{className:"h-4 w-4"})})]}),e.jsx($.EditorContent,{editor:p,className:At("prose prose-sm max-w-none focus:outline-none","[&_.ProseMirror]:p-4","[&_.ProseMirror]:min-h-full","[&_.ProseMirror]:cursor-text","[&_.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:o}})]}),"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:o},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:o},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=Xr,exports.SUPPORTED_LOCALES=pt,exports.ScrollArea=vr,exports.ScrollBar=wr,exports.Select=ys,exports.SelectContent=Ss,exports.SelectGroup=Ns,exports.SelectItem=Ts,exports.SelectLabel=As,exports.SelectScrollDownButton=ks,exports.SelectScrollUpButton=_s,exports.SelectSearch=br,exports.SelectSeparator=Es,exports.SelectTrigger=Cs,exports.SelectValue=js,exports.Separator=Ot,exports.Sheet=Kl,exports.SheetBody=rc,exports.SheetClose=Zl,exports.SheetContent=tc,exports.SheetDescription=ic,exports.SheetFooter=nc,exports.SheetHeader=sc,exports.SheetOverlay=ec,exports.SheetPortal=Jl,exports.SheetTitle=oc,exports.SheetTrigger=Xl,exports.Sidebar=mc,exports.SidebarActionTrigger=Sd,exports.SidebarContent=wc,exports.SidebarFooter=bc,exports.SidebarGroup=yc,exports.SidebarGroupAction=jc,exports.SidebarGroupContent=Cc,exports.SidebarGroupLabel=Nc,exports.SidebarHeader=kd,exports.SidebarInput=xc,exports.SidebarInset=fc,exports.SidebarMenu=_c,exports.SidebarMenuAction=Tc,exports.SidebarMenuBadge=Ec,exports.SidebarMenuButton=Ac,exports.SidebarMenuItem=kc,exports.SidebarMenuSkeleton=Pc,exports.SidebarMenuSub=Mc,exports.SidebarMenuSubButton=Ic,exports.SidebarMenuSubItem=Dc,exports.SidebarProvider=uc,exports.SidebarRail=hc,exports.SidebarSeparator=vc,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(fr,{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(fr,{className:"h-4 w-4"}),e.jsx(fr,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=pc,exports.SignConfigForm=function({onSaved:t}){const{config:s,isLoading:r,saveConfig:n}=hu(),{t:o}=v.useTranslation(),[c,d]=a.useState(""),[u,m]=a.useState("sandbox"),[p,h]=a.useState(!1);return a.useEffect(()=>{!r&&s&&(d(s.api_key),m(s.environment))},[s,r]),r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[e.jsx(l.CheckCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_configured","Assinatura digital configurada para esta unidade")})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_not_configured","Assinatura digital ainda não configurada para esta unidade")})]}),e.jsxs(Lt,{children:[e.jsx(zt,{children:e.jsx(Ft,{className:"text-base",children:o("sign_config_title","Configuração de Assinatura Digital")})}),e.jsx(Bt,{children:e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),c.trim()){h(!0);try{await n(c.trim(),u),i.toast.success(o("sign_config_saved","Configuração de assinatura salva com sucesso")),t?.()}catch(a){i.toast.error(o("sign_config_save_error","Erro ao salvar configuração de assinatura"))}finally{h(!1)}}else i.toast.error(o("sign_api_key_required","Informe a API Key do provedor de assinatura"))},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{htmlFor:"sign-api-key",children:"API Key"}),e.jsx(Dt,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder","Insira a API Key do provedor de assinatura"),value:c,onChange:e=>d(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:o("sign_environment","Ambiente")}),e.jsxs(ys,{value:u,onValueChange:e=>m(e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(Ss,{children:[e.jsx(Ts,{value:"sandbox",children:"Sandbox (Testes)"}),e.jsx(Ts,{value:"production",children:"Produção"})]})]})]}),e.jsxs(Pt,{type:"submit",disabled:p,children:[p&&e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config","Atualizar Configuração"):o("sign_save_config","Salvar Configuração")]})]})})]})]})},exports.SignWidget=Nu,exports.Skeleton=fr,exports.Slider=Rc,exports.Small=kl,exports.SonnerToaster=zs,exports.Spinner=Ls,exports.SplitButton=dd,exports.Stack=Do,exports.StepSelector=function({currentStep:a,totalSteps:t,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){const c=Array.from({length:t},(e,a)=>a+1),d=e=>!(e<=a)&&(!!n&&!n(e));return e.jsxs("div",{className:At("flex items-center gap-3",o),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pt,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",a,"/",t,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:c.map(t=>e.jsxs(Gs,{onClick:()=>{var e;(e=t)<a?s(e):n&&!n(e)||s(e)},disabled:d(t),className:At("cursor-pointer",t===a&&"bg-muted font-medium",d(t)&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[t,"."]}),r?.[t-1]||`Etapa ${t}`,t===a&&e.jsx(l.Check,{className:"h-4 w-4 ml-auto"})]},t))})]}),e.jsx(mi,{value:a/t*100,className:At("h-2",i)})]})},exports.Switch=Co,exports.TIMEZONES=ft,exports.TabPageContent=function({children:a,className:t}){return e.jsx("div",{className:At("space-y-6",t),children:a})},exports.TabPageHeader=function({title:a,description:t,actions:s,className:r}){return e.jsxs("div",{className:At("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(Ot,{})]})},exports.TabPageLayout=function({children:a,className:t}){return e.jsx("div",{className:At("flex flex-col h-full",t),children:e.jsx(vr,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:a})})})},exports.Table=_n,exports.TableBody=Sn,exports.TableCaption=Mn,exports.TableCell=Pn,exports.TableFooter=An,exports.TableHead=En,exports.TableHeader=kn,exports.TableResizeHandle=Fn,exports.TableRow=Tn,exports.TableRowActions=ao,exports.TableSkeleton=Dn,exports.Tabs=li,exports.TabsContent=ui,exports.TabsList=ci,exports.TabsTrigger=di,exports.Textarea=Ms,exports.Toaster=zs,exports.Toggle=oo,exports.ToggleGroup=lo,exports.ToggleGroupItem=co,exports.TokenManager=Ir,exports.TokenService=kr,exports.Tooltip=er,exports.TooltipContent=tr,exports.TooltipProvider=Js,exports.TooltipTrigger=ar,exports.TreeTable=function({data:a,columns:t,nameKey:s,nameHeader:r="Nome",iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:c,renderActions:d,actionsHeader:u="Ações",rowActionsVariant:m="default",isLoading:p,emptyMessage:h="Nenhum registro encontrado.",className:f}){return p?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:"Carregando..."})]})}):a&&0!==a.length?e.jsx("div",{className:At("border rounded-lg overflow-hidden",f),children:e.jsxs(_n,{children:[e.jsx(kn,{children:e.jsxs(Tn,{children:[e.jsx(En,{className:"text-left",children:r}),t.map(a=>e.jsx(En,{className:At("text-center",a.className),style:a.width?{width:a.width}:void 0,children:a.header},String(a.key))),d&&e.jsx(En,{className:"text-right",children:u})]})}),e.jsx(Sn,{children:a.map(a=>e.jsx(md,{item:a,level:0,columns:t,nameKey:s,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:c,renderActions:d,rowActionsVariant:m},a.id))})]})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[e.jsx(l.User,{className:"h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:h})]})},exports.TruncatedCell=zn,exports.VideoEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:c,uploadOptions:d}){const[u,m]=a.useState(t||{inputType:"url",controls:!0}),p=a.useRef(null),h=a.useRef(null),{upload:f,uploading:x}=ou({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["video/*"],maxSize:104857600}}),{upload:g,uploading:b}=ou({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),v=a.useMemo(()=>mu(u.videoUrl||uu(u.embedCode)||""),[u.videoUrl,u.embedCode]),w=(e,a)=>{const t={...u,[e]:a};m(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Tipo de entrada"}),e.jsxs(ys,{value:u.inputType||"url",onValueChange:e=>w("inputType",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(Ss,{children:[e.jsx(Ts,{value:"url",children:"URL"}),e.jsx(Ts,{value:"upload",children:"Upload de arquivo"}),e.jsx(Ts,{value:"embed",children:"Código embed"})]})]})]}),"upload"===u.inputType&&o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Arquivo"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:p,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await f(a),t={...u,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:u.title||a.name.replace(/\.[^/.]+$/,"")};m(t),s(t)}catch(t){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pt,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),u.videoFile&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",u.videoFile," (",Math.round((u.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===u.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Código embed"}),e.jsx(Ms,{placeholder:"Cole o código embed aqui",value:u.embedCode||"",onChange:e=>w("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Thumbnail"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Dt,{type:"url",placeholder:"URL da thumbnail",value:u.thumbnail||"",onChange:e=>w("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...u,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};m(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(Pt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),u.thumbnailFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",u.thumbnailFile]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{htmlFor:"title",children:"Título"}),e.jsx(Dt,{id:"title",placeholder:"Título do vídeo",value:u.title||"",onChange:e=>w("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"autoplay",checked:u.autoplay||!1,onCheckedChange:e=>w("autoplay",!0===e)}),e.jsx(Rt,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"controls",checked:!1!==u.controls,onCheckedChange:e=>w("controls",!0===e)}),e.jsx(Rt,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rt,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=u.videoUrl||uu(u.embedCode)||"";if(!a)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===v)return e.jsxs("video",{controls:!1!==u.controls,autoPlay:u.autoplay,poster:u.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:a}),"Seu navegador não suporta este vídeo."]});const t="youtube"===v?lu(a,u.autoplay):du(a,u.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:u.title||"Vídeo",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(Pt,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pt,{onClick:()=>{u.videoUrl||u.embedCode?r(u):i.toast.error("Erro",{description:"Nenhum vídeo selecionado"})},disabled:!(u.videoUrl||u.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:a,className:t="",style:s}){const r=a.videoUrl||uu(a.embedCode)||"";if(!r)return null;const n=mu(r);return e.jsx(Lt,{className:`overflow-hidden my-4 ${t}`,style:s,children:e.jsxs(Bt,{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||"Vídeo",src:"youtube"===n?lu(r,a.autoplay):du(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.addAppTranslations=Qo,exports.assets=jd,exports.badgeVariants=Ds,exports.buildHierarchy=Bd,exports.buttonGroupVariants=Gi,exports.buttonVariants=Et,exports.calculateAspectRatio=pu,exports.cn=At,exports.createCrudPage=function(a){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=a,l=t??s,c={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:o||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton,showNewButton:r.showNewButton,newButtonLabel:r.newButtonLabel,showSearch:r.showSearch,searchPlaceholder:r.searchPlaceholder,showActionBar:r.showActionBar};return e.jsx(Ro,{manager:l,config:c,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=pd({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=pd,exports.createService=pn,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=pn({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)=>Nn({queryKey:e.tableName,service:a,entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.createTranslatedMessages=e=>({success:{created:a=>e("msg_created_success",`${a} criado com sucesso`).replace("{{entity}}",a),updated:a=>e("msg_updated_success",`${a} atualizado com sucesso`).replace("{{entity}}",a),deleted:a=>e("msg_deleted_success",`${a} removido com sucesso`).replace("{{entity}}",a)},error:{create:a=>e("msg_create_error",`Erro ao criar ${a}`).replace("{{entity}}",a),update:a=>e("msg_update_error",`Erro ao atualizar ${a}`).replace("{{entity}}",a),delete:a=>e("msg_delete_error",`Erro ao remover ${a}`).replace("{{entity}}",a),load:a=>e("msg_load_error",`Erro ao carregar ${a}`).replace("{{entity}}",a)}}),exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=nn,exports.deriveNameField=rn,exports.deriveUsernameField=on,exports.detectBrowserLocale=yt,exports.detectBrowserPreferences=()=>{const e=yt();return{locale:e,timezone:Nt(),datetimeFormat:jt(e)}},exports.detectBrowserTimezone=Nt,exports.detectVideoProvider=mu,exports.emailService=Ld,exports.errorService=Rr,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=cu,exports.extractYouTubeId=iu,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=>ht.find(a=>a.value===e),exports.findLocale=e=>pt.find(a=>a.value===e),exports.findTimezone=e=>ft.find(a=>a.value===e),exports.flattenTree=qd,exports.formatCurrency=(e,a="BRL",t="pt-BR")=>null==e?"":new Intl.NumberFormat(t,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=kt,exports.formatDatetime=_t,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:zo(e),label:zo(e),...Lo(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.getEnvironmentConfig=Gr,exports.getQualiexApiUrl=Jr,exports.getSupabaseClient=Ur,exports.handleExternalLink=St,exports.inferDatetimeFormat=jt,exports.inputGroupAddonVariants=pl,exports.inputGroupButtonVariants=fl,exports.isDevEnvironment=Zr,exports.isDevSupabaseProject=Yr,exports.isImageUrl=function(e){const a=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const t=new URL(e);return a.some(e=>t.pathname.toLowerCase().endsWith(e))}catch{const t=e.toLowerCase();return a.some(e=>t.endsWith(e))}},exports.isValidDatetimeFormat=e=>ht.some(a=>a.value===e),exports.isValidLocale=vt,exports.isValidTimezone=wt,exports.loadClicksignScript=wu,exports.logoSrc=Cd,exports.navigationMenuTriggerStyle=Il,exports.normalizeVideoUrl=function(e,a,t){switch(a||mu(e)){case"youtube":return lu(e,t);case"vimeo":return du(e,t);default:return e}},exports.normalizeVimeoUrl=du,exports.normalizeYouTubeUrl=lu,exports.parseIframeSrc=uu,exports.placeService=Ud,exports.qualiexApi=sn,exports.resizeKeepingAspect=function(e,a,t,s){const r=pu(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=ln,exports.resolvePageTitle=bd,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new N.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.signService=bu,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=_d,exports.toggleVariants=no,exports.trimTextFields=Tt,exports.useActiveModules=(e={})=>{const{enabled:a=!0}=e,{alias:t}=yn();return N.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=Ur(),{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(!Or.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},exports.useAuth=yn,exports.useBaseForm=vo,exports.useColumnResize=ro,exports.useCreateMultipleLeadersMutation=Hd,exports.useCreateSingleLeaderMutation=Vd,exports.useCrud=Nn,exports.useDebounce=vd,exports.useDerivedContractedModules=Ai,exports.useFormField=hs,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Md();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a}=ei(),t=gt;return{formatDatetime:s=>_t(s,t,a,e),formatDate:t=>kt(t,e,a),locale:e,timezone:a,datetimeFormat:t}},exports.useIsMobile=Cn,exports.useLeadershipApi=Od,exports.useLocale=ei,exports.useMediaQuery=jn,exports.useMediaUpload=ou,exports.useModalState=Md,exports.useModuleAccess=Si,exports.useModuleConfig=si,exports.useNavigation=gd,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:s}=Ho(),r=a.useRef({});a.useEffect(()=>{const a=JSON.stringify(r.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(r.current.title!==e.title||r.current.subtitle!==e.subtitle||a)&&(r.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},t(e)),()=>s()},[e.title,e.subtitle,e.breadcrumbs,t,s])},exports.usePageMetadataContext=Ho,exports.usePageTitle=function(){const e=j.useLocation(),{navigation:a}=gd();return bd(a,e.pathname)},exports.usePermissionQuery=yd,exports.useQualiexUsers=_o,exports.useRemoveLeaderMutation=Gd,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,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:o,href:n?void 0:s,isCurrentPage:n})}),t})()},exports.useRowResize=function({rowIds:e,defaultHeight:t=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,c]=a.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[d,u]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),f=a.useRef(0),x=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{i&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,f.current=l[e]??t)},[i,l,t]);a.useEffect(()=>{if(!d||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,f.current+a));c(e=>{const a={...e,[m]:t};return o?.(a),a})},a=()=>{u(!1),p(null),n&&c(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)}},[d,m,s,r,n,o]),a.useEffect(()=>(d?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d]);const b=a.useCallback(()=>{c({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:d,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:x}},exports.useSidebar=dc,exports.useSidebarResize=Ed,exports.useSignConfig=hu,exports.useSyncSubordinatesMutation=Yd,exports.useUpdateLeaderMutation=Wd,exports.useWizard=function(e){const{steps:t,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=a.useState(s),[c,d]=a.useState(r),[u,m]=a.useState(!1),[p,h]=a.useState(!1),f=t.length,x=0===i,g=i===f-1,b=t[i],v=f>1?(i+1)/f*100:100,w=a.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),y=a.useMemo(()=>w(),[w,c]),N=a.useMemo(()=>!x&&!b?.disableBack,[x,b]),j=a.useCallback(e=>{d(a=>({...a,...e}))},[]),C=a.useCallback((e,a)=>{d(t=>({...t,[e]:a}))},[]),_=a.useCallback(()=>{l(s),d(r),m(!1),h(!1),o?.()},[s,r,o]),k=a.useCallback(async()=>{if(w()&&!p){h(!0);try{await(n?.(c))}finally{h(!1)}}},[w,p,c,n]),S=a.useCallback(async()=>{w()&&!u&&(g?await k():l(e=>Math.min(e+1,f-1)))},[w,u,g,f,k]),A=a.useCallback(()=>{N&&!u&&l(e=>Math.max(e-1,0))},[N,u]),T=a.useCallback(e=>{e<0||e>=f||u||(e<=i||e===i+1)&&l(e)},[i,f,u]),E=a.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:c,isFirstStep:x,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:A,goTo:T,canProceed:y,canGoBack:N,setData:j,updateField:C,reset:_,complete:k,setLoading:E,progress:v,stepIndex:i,totalSteps:f}};