forlogic-core 2.1.5 → 2.2.0

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 (195) hide show
  1. package/README.md +53 -1
  2. package/dist/action-plans/components/ActionPlanAttachmentsTab.d.ts +3 -0
  3. package/dist/action-plans/components/ActionPlanCommentsTab.d.ts +3 -0
  4. package/dist/action-plans/components/ActionPlanCostTab.d.ts +5 -0
  5. package/dist/action-plans/components/ActionPlanGeneralTab.d.ts +3 -0
  6. package/dist/action-plans/components/ActionPlanHistoryTab.d.ts +3 -0
  7. package/dist/action-plans/components/ActionPlanPredecessorsTab.d.ts +5 -0
  8. package/dist/action-plans/components/ActionPlanProgressDialog.d.ts +3 -0
  9. package/dist/action-plans/components/ActionPlanProgressTab.d.ts +5 -0
  10. package/dist/action-plans/components/ActionPlanStatusBadge.d.ts +3 -0
  11. package/dist/action-plans/constants.d.ts +24 -0
  12. package/dist/action-plans/hooks/useActionPlan.d.ts +5 -0
  13. package/dist/action-plans/hooks/useActionPlanProgress.d.ts +5 -0
  14. package/dist/action-plans/types.d.ts +60 -0
  15. package/dist/action-plans/utils/formatTime.d.ts +9 -0
  16. package/dist/audit-trail/components/AuditTrailDetails.d.ts +10 -0
  17. package/dist/audit-trail/components/AuditTrailFilter.d.ts +10 -0
  18. package/dist/audit-trail/components/AuditTrailPage.d.ts +10 -0
  19. package/dist/audit-trail/types.d.ts +58 -0
  20. package/dist/audit-trail/utils.d.ts +18 -2
  21. package/dist/auth/components/EditProfileDialog.d.ts +1 -0
  22. package/dist/auth/components/ProtectedRoute.d.ts +5 -0
  23. package/dist/auth/contexts/AuthContext.d.ts +5 -0
  24. package/dist/auth/pages/CallbackPage.d.ts +5 -0
  25. package/dist/auth/services/AuthService.d.ts +5 -0
  26. package/dist/auth/services/TokenManager.d.ts +5 -0
  27. package/dist/auth/services/TokenService.d.ts +10 -0
  28. package/dist/auth/utils/ErrorInterceptor.d.ts +5 -0
  29. package/dist/components/dashboards/dashboard-form.d.ts +15 -0
  30. package/dist/components/dashboards/dashboard-general-view.d.ts +15 -0
  31. package/dist/components/dashboards/dashboard-grid.d.ts +25 -0
  32. package/dist/components/dashboards/dashboard-list.d.ts +10 -0
  33. package/dist/components/dashboards/dashboard-panel-renderer.d.ts +10 -0
  34. package/dist/components/dashboards/dashboard-view.d.ts +10 -0
  35. package/dist/components/dashboards/helpers.d.ts +44 -5
  36. package/dist/components/dashboards/panels/burndown-panel.d.ts +15 -0
  37. package/dist/components/dashboards/panels/cartesian-panel.d.ts +20 -0
  38. package/dist/components/dashboards/panels/list-panel.d.ts +15 -0
  39. package/dist/components/dashboards/panels/matrix-risk-panel.d.ts +25 -0
  40. package/dist/components/dashboards/panels/numeric-panel.d.ts +10 -0
  41. package/dist/components/dashboards/panels/panel-error.d.ts +10 -0
  42. package/dist/components/dashboards/panels/panel-header.d.ts +10 -0
  43. package/dist/components/dashboards/panels/panel-loader.d.ts +10 -0
  44. package/dist/components/dashboards/panels/panel-no-data.d.ts +10 -0
  45. package/dist/components/dashboards/panels/panel-unavailable.d.ts +10 -0
  46. package/dist/components/dashboards/panels/pareto-panel.d.ts +10 -0
  47. package/dist/components/dashboards/panels/performance-panel.d.ts +15 -0
  48. package/dist/components/dashboards/panels/pie-panel.d.ts +10 -0
  49. package/dist/components/dashboards/panels/text-panel.d.ts +10 -0
  50. package/dist/components/dashboards/types.d.ts +230 -0
  51. package/dist/components/modules/AccessDeniedDialog.d.ts +3 -1
  52. package/dist/components/modules/ModuleAccessGuard.d.ts +3 -1
  53. package/dist/components/modules/ModulesContent.d.ts +3 -1
  54. package/dist/components/modules/ModulesDialog.d.ts +1 -1
  55. package/dist/components/modules/ModulesFooterCards.d.ts +3 -1
  56. package/dist/components/modules/types.d.ts +2 -0
  57. package/dist/components/ui/accordion.d.ts +35 -0
  58. package/dist/components/ui/action-button.d.ts +5 -0
  59. package/dist/components/ui/alert-dialog.d.ts +82 -0
  60. package/dist/components/ui/alert.d.ts +32 -0
  61. package/dist/components/ui/avatar.d.ts +30 -0
  62. package/dist/components/ui/badge.d.ts +32 -0
  63. package/dist/components/ui/breadcrumb.d.ts +54 -0
  64. package/dist/components/ui/button-group.d.ts +15 -0
  65. package/dist/components/ui/button.d.ts +55 -0
  66. package/dist/components/ui/calendar.d.ts +16 -0
  67. package/dist/components/ui/card.d.ts +49 -0
  68. package/dist/components/ui/chart.d.ts +35 -0
  69. package/dist/components/ui/checkbox.d.ts +11 -0
  70. package/dist/components/ui/collapsible.d.ts +15 -0
  71. package/dist/components/ui/color-picker.d.ts +5 -0
  72. package/dist/components/ui/combo-tree.d.ts +23 -0
  73. package/dist/components/ui/combobox.d.ts +28 -0
  74. package/dist/components/ui/command.d.ts +66 -0
  75. package/dist/components/ui/context-menu.d.ts +95 -0
  76. package/dist/components/ui/date-picker.d.ts +10 -0
  77. package/dist/components/ui/dialog-wizard.d.ts +22 -4
  78. package/dist/components/ui/dialog.d.ts +181 -0
  79. package/dist/components/ui/drawer.d.ts +72 -0
  80. package/dist/components/ui/dropdown-menu.d.ts +153 -0
  81. package/dist/components/ui/electronic-signature-dialog.d.ts +10 -0
  82. package/dist/components/ui/export-dialog.d.ts +20 -0
  83. package/dist/components/ui/form.d.ts +96 -0
  84. package/dist/components/ui/hover-card.d.ts +15 -0
  85. package/dist/components/ui/icon-picker.d.ts +5 -0
  86. package/dist/components/ui/iframe-dialog.d.ts +10 -0
  87. package/dist/components/ui/input-group.d.ts +16 -0
  88. package/dist/components/ui/input.d.ts +5 -0
  89. package/dist/components/ui/menubar.d.ts +80 -0
  90. package/dist/components/ui/multiselect-permissions.d.ts +25 -0
  91. package/dist/components/ui/navigation-menu.d.ts +45 -0
  92. package/dist/components/ui/onboarding-dialog.d.ts +15 -0
  93. package/dist/components/ui/online-editor-dialog.d.ts +10 -0
  94. package/dist/components/ui/pagination.d.ts +53 -0
  95. package/dist/components/ui/popover.d.ts +8 -0
  96. package/dist/components/ui/radio-group.d.ts +3 -0
  97. package/dist/components/ui/report-request-list.d.ts +20 -0
  98. package/dist/components/ui/resizable.d.ts +15 -0
  99. package/dist/components/ui/rich-text-editor.d.ts +13 -0
  100. package/dist/components/ui/scroll-area.d.ts +3 -0
  101. package/dist/components/ui/select.d.ts +71 -0
  102. package/dist/components/ui/separator.d.ts +13 -0
  103. package/dist/components/ui/sheet.d.ts +76 -0
  104. package/dist/components/ui/sidebar.d.ts +203 -0
  105. package/dist/components/ui/skeleton-variants.d.ts +25 -0
  106. package/dist/components/ui/skeleton.d.ts +12 -0
  107. package/dist/components/ui/slider.d.ts +5 -0
  108. package/dist/components/ui/sonner.d.ts +5 -0
  109. package/dist/components/ui/spinner.d.ts +5 -0
  110. package/dist/components/ui/split-button.d.ts +6 -0
  111. package/dist/components/ui/stack.d.ts +5 -0
  112. package/dist/components/ui/status-badge.d.ts +3 -0
  113. package/dist/components/ui/step-selector.d.ts +5 -0
  114. package/dist/components/ui/stimulsoft-viewer.d.ts +8 -0
  115. package/dist/components/ui/switch.d.ts +21 -0
  116. package/dist/components/ui/tab-page-layout.d.ts +33 -0
  117. package/dist/components/ui/table-resize-handle.d.ts +10 -3
  118. package/dist/components/ui/table.d.ts +102 -0
  119. package/dist/components/ui/tabs.d.ts +59 -0
  120. package/dist/components/ui/terms-of-use-dialog.d.ts +50 -4
  121. package/dist/components/ui/textarea.d.ts +27 -0
  122. package/dist/components/ui/timepicker.d.ts +23 -0
  123. package/dist/components/ui/toggle-group.d.ts +25 -0
  124. package/dist/components/ui/toggle.d.ts +21 -0
  125. package/dist/components/ui/tooltip.d.ts +48 -0
  126. package/dist/components/ui/truncated-cell.d.ts +13 -0
  127. package/dist/components/ui/typography.d.ts +119 -0
  128. package/dist/components/ui/updates-notification.d.ts +33 -0
  129. package/dist/components/ui/users-groups-selector.d.ts +43 -0
  130. package/dist/components/ui/viewer-dialog.d.ts +107 -0
  131. package/dist/crud/components/ActionMenuItems.d.ts +5 -0
  132. package/dist/crud/components/BaseForm.d.ts +46 -0
  133. package/dist/crud/components/ColumnSettingsPopover.d.ts +10 -0
  134. package/dist/crud/components/CrudActionBar.d.ts +20 -0
  135. package/dist/crud/components/CrudGrid.d.ts +10 -0
  136. package/dist/crud/components/CrudPagination.d.ts +5 -0
  137. package/dist/crud/components/CrudTable.d.ts +5 -0
  138. package/dist/crud/components/TableRowActions.d.ts +5 -0
  139. package/dist/crud/createCrudPage.d.ts +41 -8
  140. package/dist/crud/generateCrudConfig.d.ts +13 -8
  141. package/dist/crud/hooks/useBaseForm.d.ts +39 -0
  142. package/dist/crud/hooks/useColumnManager.d.ts +25 -0
  143. package/dist/crud/hooks/useCrud.d.ts +35 -0
  144. package/dist/crud/primitives/ActionMenu.d.ts +41 -0
  145. package/dist/crud/primitives/FilterBar.d.ts +45 -0
  146. package/dist/crud/primitives/Pagination.d.ts +5 -0
  147. package/dist/crud/primitives/Table.d.ts +5 -0
  148. package/dist/crud/primitives/TreeTable.d.ts +5 -0
  149. package/dist/crud/primitives/types.d.ts +57 -0
  150. package/dist/crud/utils/routingHelpers.d.ts +11 -0
  151. package/dist/custom-form-fields/components/CustomFormFields.d.ts +3 -0
  152. package/dist/custom-form-fields/fields/FormDateField.d.ts +3 -0
  153. package/dist/custom-form-fields/fields/FormMultiSelectionField.d.ts +3 -0
  154. package/dist/custom-form-fields/fields/FormNumericField.d.ts +3 -0
  155. package/dist/custom-form-fields/fields/FormQuestionsField.d.ts +3 -0
  156. package/dist/custom-form-fields/fields/FormSingleSelectionField.d.ts +3 -0
  157. package/dist/custom-form-fields/fields/FormTextField.d.ts +3 -0
  158. package/dist/custom-form-fields/fields/FormTimeField.d.ts +3 -0
  159. package/dist/custom-form-fields/fields/FormUrlField.d.ts +3 -0
  160. package/dist/custom-form-fields/fields/ReadOnlyTextField.d.ts +3 -0
  161. package/dist/custom-form-fields/types.d.ts +84 -21
  162. package/dist/exports/integrations.d.ts +1 -0
  163. package/dist/file-upload/components/SingleFileUpload.d.ts +59 -0
  164. package/dist/file-upload/types.d.ts +15 -0
  165. package/dist/file-upload/utils/formatBytes.d.ts +5 -0
  166. package/dist/file-upload/utils/getFileExtension.d.ts +5 -0
  167. package/dist/hooks/useColumnResize.d.ts +24 -0
  168. package/dist/hooks/useRowResize.d.ts +18 -0
  169. package/dist/hooks/useSidebarResize.d.ts +18 -0
  170. package/dist/hooks/useUpdatesNotification.d.ts +16 -0
  171. package/dist/index.css +1 -1
  172. package/dist/index.css.map +1 -1
  173. package/dist/index.esm.js +1 -1
  174. package/dist/index.js +1 -1
  175. package/dist/integrations/clarity/clarityTracking.d.ts +31 -0
  176. package/dist/integrations/clarity/index.d.ts +3 -0
  177. package/dist/integrations/clarity/types.d.ts +46 -0
  178. package/dist/integrations/clarity/useClarity.d.ts +34 -0
  179. package/dist/integrations/index.d.ts +5 -0
  180. package/dist/providers/CoreProviders.d.ts +16 -1
  181. package/dist/qualiex/components/QualiexUserField.d.ts +8 -0
  182. package/dist/qualiex/hooks/useQualiexUsers.d.ts +16 -26
  183. package/dist/qualiex/services/qualiexApi.d.ts +38 -2
  184. package/dist/qualiex/utils/QualiexErrorInterceptor.d.ts +5 -0
  185. package/dist/supabase/SupabaseSingleton.d.ts +34 -0
  186. package/dist/types.d.ts +51 -2
  187. package/dist/vite/index.esm.js +4 -1
  188. package/dist/vite/index.js +4 -1
  189. package/docs/STORAGE_BUCKETS.md +384 -0
  190. package/docs/WORKSPACE_KNOWLEDGE.md +1 -0
  191. package/docs/design-system/README.md +1 -1
  192. package/docs/design-system/patterns/core-providers.md +2 -0
  193. package/docs/design-system/selectors.md +4 -0
  194. package/package.json +7 -1
  195. package/dist/components/ui/__tests__/status-badge.test.d.ts +0 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("i18next"),a=require("react/jsx-runtime"),t=require("react"),s=require("@radix-ui/react-slot"),r=require("class-variance-authority"),n=require("clsx"),o=require("tailwind-merge"),i=require("date-fns"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("@radix-ui/react-alert-dialog"),h=require("react-hook-form"),x=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),g=require("@radix-ui/react-dropdown-menu"),v=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),j=require("react-i18next"),y=require("@radix-ui/react-scroll-area"),w=require("@supabase/supabase-js"),N=require("@tanstack/react-query"),_=require("react-router-dom"),C=require("@radix-ui/react-context-menu"),k=require("@radix-ui/react-toggle-group"),S=require("@radix-ui/react-toggle"),T=require("@radix-ui/react-switch"),P=require("@radix-ui/react-collapsible"),D=require("@radix-ui/react-tabs"),E=require("@radix-ui/react-accordion"),A=require("@radix-ui/react-avatar"),I=require("react-day-picker"),M=require("vaul"),F=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),L=require("@radix-ui/react-progress"),z=require("@radix-ui/react-radio-group"),U=require("react-resizable-panels"),O=require("@radix-ui/react-slider"),V=require("@radix-ui/react-menubar"),B=require("recharts"),q=require("@tiptap/react"),$=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),K=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),J=require("zod"),Z=require("@hookform/resolvers");function ee(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 ae=ee(t),te=ee(c),se=ee(u),re=ee(m),ne=ee(p),oe=ee(x),ie=ee(f),le=ee(g),de=ee(v),ce=ee(b),ue=ee(y),me=ee(C),pe=ee(k),he=ee(S),xe=ee(T),fe=ee(P),ge=ee(D),ve=ee(E),be=ee(A),je=ee(F),ye=ee(R),we=ee(L),Ne=ee(z),_e=ee(U),Ce=ee(O),ke=ee(V),Se=ee(B);const Te="ccjfvpnndclajkleyqkc",Pe={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},De={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Ee(){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===Te?Pe:De}function Ae(){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!==Te}const Ie={get oauth(){const e=Ee();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Me={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Fe={debounceDelay:500},Re=()=>{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},Le=()=>Re(),ze=Re,Ue=()=>Ee().qualiexApiUrl,Oe={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Ve={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},Be={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}`}},qe=`https://${Ee().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,$e={logo:Ve.isQualiex?`${qe}/logo-qualiex-white.svg`:`${qe}/saber-gestao-white.png`,smallLogo:Ve.isQualiex?`${qe}/logo-forlogic-white.svg`:`${qe}/small.svg`,favicon:`${qe}/favicon.png`},We=$e.logo,He=$e.smallLogo;if("undefined"!=typeof document){document.querySelectorAll("link[rel='icon'], link[rel='shortcut icon']").forEach(e=>e.remove());const e=document.createElement("link");e.rel="icon",e.type="image/png",e.href=$e.favicon,document.head.appendChild(e)}const Ge={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 Ye(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Qe={date:Ye({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ye({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:Ye({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ke={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Xe(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Je(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 d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(o.length)}}}function Ze(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 ea={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Ge[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:Qe,formatRelative:(e,a,t,s)=>Ke[e],localize:{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:Xe({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Xe({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:Xe({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:Xe({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:Xe({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"})},match:{ordinalNumber:Ze({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Je({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:Je({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:Je({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:Je({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:Je({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};let aa={};function ta(){return aa}const sa=6048e5;function ra(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 na(e){const a=ra(e);return a.setHours(0,0,0,0),a}function oa(e){const a=ra(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 ia(e,a){return e instanceof Date?new e.constructor(a):new Date(a)}function la(e){const a=ra(e),t=function(e,a){const t=na(e),s=na(a),r=+t-oa(t),n=+s-oa(s);return Math.round((r-n)/864e5)}(a,function(e){const a=ra(e),t=ia(e,0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}(a));return t+1}function da(e,a){const t=ta(),s=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=ra(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 ca(e){return da(e,{weekStartsOn:1})}function ua(e){const a=ra(e),t=a.getFullYear(),s=ia(e,0);s.setFullYear(t+1,0,4),s.setHours(0,0,0,0);const r=ca(s),n=ia(e,0);n.setFullYear(t,0,4),n.setHours(0,0,0,0);const o=ca(n);return a.getTime()>=r.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function ma(e){const a=ra(e),t=+ca(a)-+function(e){const a=ua(e),t=ia(e,0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),ca(t)}(a);return Math.round(t/sa)+1}function pa(e,a){const t=ra(e),s=t.getFullYear(),r=ta(),n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=ia(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=da(o,a),l=ia(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=da(l,a);return t.getTime()>=i.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function ha(e,a){const t=ra(e),s=+da(t,a)-+function(e,a){const t=ta(),s=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=pa(e,a),n=ia(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),da(n,a)}(t,a);return Math.round(s/sa)+1}function xa(e,a){return(e<0?"-":"")+Math.abs(e).toString().padStart(a,"0")}const fa={y(e,a){const t=e.getFullYear(),s=t>0?t:1-t;return xa("yy"===a?s%100:s,a.length)},M(e,a){const t=e.getMonth();return"M"===a?String(t+1):xa(t+1,2)},d:(e,a)=>xa(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)=>xa(e.getHours()%12||12,a.length),H:(e,a)=>xa(e.getHours(),a.length),m:(e,a)=>xa(e.getMinutes(),a.length),s:(e,a)=>xa(e.getSeconds(),a.length),S(e,a){const t=a.length,s=e.getMilliseconds();return xa(Math.trunc(s*Math.pow(10,t-3)),a.length)}},ga="midnight",va="noon",ba="morning",ja="afternoon",ya="evening",wa="night",Na={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 fa.y(e,a)},Y:function(e,a,t,s){const r=pa(e,s),n=r>0?r:1-r;if("YY"===a){return xa(n%100,2)}return"Yo"===a?t.ordinalNumber(n,{unit:"year"}):xa(n,a.length)},R:function(e,a){return xa(ua(e),a.length)},u:function(e,a){return xa(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 xa(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 xa(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 fa.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 xa(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=ha(e,s);return"wo"===a?t.ordinalNumber(r,{unit:"week"}):xa(r,a.length)},I:function(e,a,t){const s=ma(e);return"Io"===a?t.ordinalNumber(s,{unit:"week"}):xa(s,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getDate(),{unit:"date"}):fa.d(e,a)},D:function(e,a,t){const s=la(e);return"Do"===a?t.ordinalNumber(s,{unit:"dayOfYear"}):xa(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 xa(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 xa(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 xa(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?va:0===s?ga: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?ya:s>=12?ja:s>=4?ba:wa,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 fa.h(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getHours(),{unit:"hour"}):fa.H(e,a)},K:function(e,a,t){const s=e.getHours()%12;return"Ko"===a?t.ordinalNumber(s,{unit:"hour"}):xa(s,a.length)},k:function(e,a,t){let s=e.getHours();return 0===s&&(s=24),"ko"===a?t.ordinalNumber(s,{unit:"hour"}):xa(s,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):fa.m(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getSeconds(),{unit:"second"}):fa.s(e,a)},S:function(e,a){return fa.S(e,a)},X:function(e,a,t){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(a){case"X":return Ca(s);case"XXXX":case"XX":return ka(s);default:return ka(s,":")}},x:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"x":return Ca(s);case"xxxx":case"xx":return ka(s);default:return ka(s,":")}},O:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+_a(s,":");default:return"GMT"+ka(s,":")}},z:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+_a(s,":");default:return"GMT"+ka(s,":")}},t:function(e,a,t){return xa(Math.trunc(e.getTime()/1e3),a.length)},T:function(e,a,t){return xa(e.getTime(),a.length)}};function _a(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+xa(n,2)}function Ca(e,a){if(e%60==0){return(e>0?"-":"+")+xa(Math.abs(e)/60,2)}return ka(e,a)}function ka(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+xa(Math.trunc(s/60),2)+a+xa(s%60,2)}const Sa=(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"})}},Ta=(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"})}},Pa={p:Ta,P:(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],s=t[1],r=t[2];if(!r)return Sa(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}}",Sa(s,a)).replace("{{time}}",Ta(r,a))}},Da=/^D+$/,Ea=/^Y+$/,Aa=["D","DD","YY","YYYY"];function Ia(e){if(!(a=e,a instanceof Date||"object"==typeof a&&"[object Date]"===Object.prototype.toString.call(a)||"number"==typeof e))return!1;var a;const t=ra(e);return!isNaN(Number(t))}const Ma=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Fa=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ra=/^'([^]*?)'?$/,La=/''/g,za=/[a-zA-Z]/;function Ua(e,a,t){const s=ta(),r=t?.locale??s.locale??ea,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=ra(e);if(!Ia(i))throw new RangeError("Invalid time value");let l=a.match(Fa).map(e=>{const a=e[0];if("p"===a||"P"===a){return(0,Pa[a])(e,r.formatLong)}return e}).join("").match(Ma).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const a=e[0];if("'"===a)return{isToken:!1,value:Oa(e)};if(Na[a])return{isToken:!0,value:e};if(a.match(za))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 d={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 Ea.test(e)}(n)||!t?.useAdditionalDayOfYearTokens&&function(e){return Da.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(Aa.includes(e))throw new RangeError(s)}(n,a,String(e));return(0,Na[n[0]])(i,n,r.localize,d)}).join("")}function Oa(e){const a=e.match(Ra);return a?a[1].replace(La,"'"):e}function Va(e,a,t){const s=i.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 Ba(e,a){const t=function(e){$a[e]||($a[e]=Ha?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=qa[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 qa={year:0,month:1,day:2,hour:3,minute:4,second:5};const $a={},Wa=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")),Ha="06/25/2014, 00:00:00"===Wa||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===Wa;function Ga(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 Ya=36e5,Qa={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Ka(e,a,t){if(!e)return 0;let s,r,n=Qa.timezoneZ.exec(e);if(n)return 0;if(n=Qa.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Ja(s)?-s*Ya:NaN;if(n=Qa.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Ja(s,e)?(r=Math.abs(s)*Ya+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Za[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Za[e]=!0,!0}catch(a){return!1}}(e)){a=new Date(a||Date.now());const s=t?a:function(e){return Ga(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(a),r=Xa(s,e),n=t?r:function(e,a,t){const s=e.getTime();let r=s-a;const n=Xa(new Date(r),t);if(a===n)return a;r-=n-a;const o=Xa(new Date(r),t);if(n===o)return n;return Math.max(n,o)}(a,r,e);return-n}return NaN}function Xa(e,a){const t=Ba(e,a),s=Ga(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 Ja(e,a){return-23<=e&&e<=23&&(null==a||0<=a&&a<=59)}const Za={};const et={X:function(e,a,t){const s=at(t.timeZone,e);if(0===s)return"Z";switch(a){case"X":return rt(s);case"XXXX":case"XX":return st(s);default:return st(s,":")}},x:function(e,a,t){const s=at(t.timeZone,e);switch(a){case"x":return rt(s);case"xxxx":case"xx":return st(s);default:return st(s,":")}},O:function(e,a,t){const s=at(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+tt(n,2)}(s,":");default:return"GMT"+st(s,":")}},z:function(e,a,t){switch(a){case"z":case"zz":case"zzz":return Va("short",e,t);default:return Va("long",e,t)}}};function at(e,a){const t=e?Ka(e,a,!0)/6e4:a?.getTimezoneOffset()??0;if(Number.isNaN(t))throw new RangeError("Invalid time zone specified: "+e);return t}function tt(e,a){const t=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<a;)s="0"+s;return t+s}function st(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+tt(Math.floor(s/60),2)+a+tt(Math.floor(s%60),2)}function rt(e,a){if(e%60==0){return(e>0?"-":"+")+tt(Math.abs(e)/60,2)}return st(e,a)}function nt(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 ot=36e5,it=6e4,lt={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 dt(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=lt.dateTimePattern.exec(e);s?(a.date=s[1],t=s[3]):(s=lt.datePattern.exec(e),s?(a.date=s[1],t=s[2]):(a.date=null,t=e));if(t){const e=lt.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=lt.YYY[a],s=lt.YYYYY[a];let r=lt.YYYY.exec(e)||s.exec(e);if(r){const a=r[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(r=lt.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=lt.MM.exec(e);if(n)return t=new Date(0),s=parseInt(n[1],10)-1,ht(a,s)?(t.setUTCFullYear(a,s),t):new Date(NaN);if(n=lt.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=pt(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=lt.MMDD.exec(e),n){t=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return ht(a,s,e)?(t.setUTCFullYear(a,s,e),t):new Date(NaN)}if(n=lt.Www.exec(e),n)return r=parseInt(n[1],10)-1,xt(r)?ct(a,r):new Date(NaN);if(n=lt.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return xt(r,e)?ct(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=lt.HH.exec(e);if(s)return a=parseFloat(s[1].replace(",",".")),ft(a)?a%24*ot:NaN;if(s=lt.HHMM.exec(e),s)return a=parseInt(s[1],10),t=parseFloat(s[2].replace(",",".")),ft(a,t)?a%24*ot+t*it:NaN;if(s=lt.HHMMSS.exec(e),s){a=parseInt(s[1],10),t=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return ft(a,t,e)?a%24*ot+t*it+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||a.timeZone){if(t=Ka(s.timeZone||a.timeZone,new Date(e+r)),isNaN(t))return new Date(NaN)}else t=nt(new Date(e+r)),t=nt(new Date(e+r+t));return new Date(e+r+t)}return new Date(NaN)}function ct(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 ut=[31,28,31,30,31,30,31,31,30,31,30,31],mt=[31,29,31,30,31,30,31,31,30,31,30,31];function pt(e){return e%400==0||e%4==0&&e%100!=0}function ht(e,a,t){if(a<0||a>11)return!1;if(null!=t){if(t<1)return!1;const s=pt(e);if(s&&t>mt[a])return!1;if(!s&&t>ut[a])return!1}return!0}function xt(e,a){return!(e<0||e>52)&&(null==a||!(a<0||a>6))}function ft(e,a,t){return!(e<0||e>=25)&&((null==a||!(a<0||a>=60))&&(null==t||!(t<0||t>=60)))}const gt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function vt(e,a,t,s){return function(e,a,t={}){const s=(a=String(a)).match(gt);if(s){const r=dt(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,"'"+et[a[0]](r,a,t)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},a)}return Ua(e,a,t)}(function(e,a,t){const s=Ka(a,e=dt(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 bt={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"}},jt={date:Ye({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:Ye({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ye({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},yt={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"},wt={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"},Nt={code:"es",formatDistance:(e,a,t)=>{let s;const r=bt[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:jt,formatRelative:(e,a,t,s)=>1!==a.getHours()?wt[e]:yt[e],localize:{ordinalNumber:(e,a)=>Number(e)+"º",era:Xe({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Xe({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:Xe({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:Xe({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:Xe({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"})},match:{ordinalNumber:Ze({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Je({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:Je({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:Je({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:Je({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:Je({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"})},options:{weekStartsOn:1,firstWeekContainsDate:1}},_t={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"}},Ct={date:Ye({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:Ye({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ye({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},kt={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"},St={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=_t[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:Ct,formatRelative:(e,a,t,s)=>{const r=kt[e];return"function"==typeof r?r(a):r},localize:{ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Xe({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Xe({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:Xe({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:Xe({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:Xe({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"})},match:{ordinalNumber:Ze({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Je({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:Je({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:Je({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:Je({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:Je({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Tt=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Pt=[{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"}],Dt=[{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"}],Et="pt-BR",At="dd/MM/yyyy HH:mm",It="America/Sao_Paulo",Mt=e=>Tt.some(a=>a.value===e),Ft=e=>Dt.some(a=>a.value===e),Rt=()=>{if("undefined"==typeof navigator)return Et;const e=navigator.language;if(Mt(e))return e;const a=e.split("-")[0],t=Tt.find(e=>e.value.startsWith(a));return t?.value||Et},Lt=()=>{if("undefined"==typeof Intl)return It;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Ft(e)?e:It}catch{return It}},zt=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||At),Ut={"pt-BR":St,"en-US":ea,"es-ES":Nt},Ot=(e,a=At,t=It,s=Et)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const n=Ut[s]||St;try{return vt(r,t,a,{locale:n})}catch(o){return vt(r,It,a,{locale:n})}},Vt=(e,a=Et,t=It)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const r=Ut[a]||St;try{return vt(s,t,"PP",{locale:r})}catch(n){return vt(s,It,"PP",{locale:r})}};function Bt(e){const a=e.replace("#",""),t=3===a.length?a.split("").map(e=>e+e).join(""):a;return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}function qt(e,a=.1){const{r:t,g:s,b:r}=Bt(e);return`rgba(${t}, ${s}, ${r}, ${a})`}function $t(e){const{r:a,g:t,b:s}=Bt(e),[r,n,o]=[a,t,s].map(e=>{const a=e/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return.2126*r+.7152*n+.0722*o}function Wt(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info("Link copiado para a área de transferência")})}function Ht(e,a){return a?e.replace(/\{alias\}/g,a):e}function Gt(...e){return o.twMerge(n.clsx(e))}const Yt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Yt);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Yt(s);return a}return e},Qt=r.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-lg",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"}}),Kt=ae.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},i)=>{const l=n?s.Slot:"button";return a.jsx(l,{className:Gt(Qt({variant:t,size:r,className:e})),ref:i,...o})});Kt.displayName="Button";const Xt=t.forwardRef(({className:e,children:t,variant:s="action",...r},n)=>a.jsx(Kt,{ref:n,variant:s,size:"icon",className:Gt("h-8 w-8",e),...r,children:t||a.jsx(d.EllipsisVertical,{size:16})}));Xt.displayName="ActionButton";const Jt=ae.forwardRef(({className:e,type:t,showCharCount:s,maxLength:r,onChange:n,...o},i)=>{const[l,d]=ae.useState(0);ae.useEffect(()=>{"string"==typeof o.value?d(o.value.length):"string"==typeof o.defaultValue&&d(o.defaultValue.length)},[o.value,o.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("input",{type:t,className:Gt("flex h-10 w-full rounded-lg 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 hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors md:text-sm",e),ref:i,maxLength:r,onChange:e=>{d(e.target.value.length),n?.(e)},...o}),s&&r&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[l," / ",r]})]})});Jt.displayName="Input";const Zt=r.cva("text-xs font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),es=ae.forwardRef(({className:e,...t},s)=>a.jsx(te.Root,{ref:s,className:Gt(Zt(),e),...t}));es.displayName=te.Root.displayName;const as=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));as.displayName="Card";const ts=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("flex flex-col space-y-1.5 p-6",e),...t}));ts.displayName="CardHeader";const ss=ae.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Gt("text-2xl font-semibold leading-none tracking-tight",e),...t}));ss.displayName="CardTitle";const rs=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Gt("text-sm text-muted-foreground",e),...t}));rs.displayName="CardDescription";const ns=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("p-6 pt-0",e),...t}));ns.displayName="CardContent";const os=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("flex items-center p-6 pt-0",e),...t}));os.displayName="CardFooter";const is=ae.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...r},n)=>a.jsx(re.Root,{ref:n,decorative:s,orientation:t,className:Gt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));is.displayName=re.Root.displayName;const ls=ne.Root,ds=ne.Trigger,cs=ne.Portal,us=ae.forwardRef(({className:e,...t},s)=>a.jsx(ne.Overlay,{className:Gt("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",e),...t,ref:s}));us.displayName=ne.Overlay.displayName;const ms=ae.forwardRef(({className:e,...t},s)=>a.jsxs(cs,{children:[a.jsx(us,{}),a.jsx(ne.Content,{ref:s,className:Gt("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",e),...t})]}));ms.displayName=ne.Content.displayName;const ps=({className:e,...t})=>a.jsx("div",{className:Gt("flex flex-col space-y-2 text-center sm:text-left",e),...t});ps.displayName="AlertDialogHeader";const hs=({className:e,...t})=>a.jsx("div",{className:Gt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});hs.displayName="AlertDialogFooter";const xs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ne.Title,{ref:s,className:Gt("text-lg font-semibold",e),...t}));xs.displayName=ne.Title.displayName;const fs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ne.Description,{ref:s,className:Gt("text-sm text-muted-foreground",e),...t}));fs.displayName=ne.Description.displayName;const gs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ne.Action,{ref:s,className:Gt(Qt(),e),...t}));gs.displayName=ne.Action.displayName;const vs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ne.Cancel,{ref:s,className:Gt(Qt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));vs.displayName=ne.Cancel.displayName;const bs=se.Root,js=se.Trigger,ys=se.Portal,ws=se.Close,Ns=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Overlay,{ref:s,className:Gt("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",e),...t}));Ns.displayName=se.Overlay.displayName;const _s={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"}},Cs=ae.forwardRef(({className:t,children:s,size:r,variant:n="informative",isDirty:o,customWidth:i,customMinWidth:l,customMaxWidth:c,customHeight:u,customMinHeight:m,customMaxHeight:p,unsavedChangesTitle:h=e.t("unsaved_changes"),unsavedChangesDescription:x=e.t("unsaved_changes_description"),cancelText:f=e.t("cancel"),leaveWithoutSavingText:g=e.t("leave_without_saving"),style:v,onInteractOutside:b,onEscapeKeyDown:j,...y},w)=>{const[N,_]=ae.useState(!1),C=ae.useRef(null),k=ae.useRef(!1),S=r??(i||l||c||u||m||p?void 0:"md"),T=S?_s[S]:{},P={...i??T.width?{width:i??T.width}:{},...l??T.minWidth?{minWidth:l??T.minWidth}:{},...c??T.maxWidth?{maxWidth:c??T.maxWidth}:{},...u??T.height?{height:u??T.height}:{},...m??T.minHeight?{minHeight:m??T.minHeight}:{},...p??T.maxHeight?{maxHeight:p??T.maxHeight}:{},...v},D=ae.useCallback(e=>{"form"===n&&o?(C.current=e,_(!0)):e()},[n,o]),E=ae.useRef(null),A="destructive"!==n;if("development"===process.env.NODE_ENV&&s){const e=ae.Children.toArray(s);e.some(e=>ae.isValidElement(e)&&"DialogFooter"===e.type?.displayName),e.some(e=>ae.isValidElement(e)&&"DialogBody"===e.type?.displayName)}return a.jsxs(ys,{children:[a.jsx(Ns,{}),a.jsxs(se.Content,{ref:w,className:Gt("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border-0 border-l-[10px] border-l-primary 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:P,onInteractOutside:e=>{"form"!==n&&"destructive"!==n?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==n)return"form"===n&&o?(e.preventDefault(),void D(()=>{k.current=!0,E.current?.click()})):void j?.(e);e.preventDefault()},...y,children:[s,A&&a.jsxs(se.Close,{ref:E,onClick:e=>{k.current?k.current=!1:"form"===n&&o&&(e.preventDefault(),D(()=>{k.current=!0,E.current?.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]}),a.jsx(ls,{open:N,onOpenChange:_,children:a.jsxs(ms,{children:[a.jsxs(ps,{children:[a.jsx(xs,{children:h}),a.jsx(fs,{children:x})]}),a.jsxs(hs,{children:[a.jsx(vs,{onClick:()=>{_(!1),C.current=null},children:f}),a.jsx(gs,{onClick:()=>{_(!1),C.current?.(),C.current=null},children:g})]})]})})]})});Cs.displayName=se.Content.displayName;const ks=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Gt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(is,{className:"mt-2"})]});ks.displayName="DialogHeader";const Ss=({className:e,...t})=>a.jsx("div",{className:Gt("flex-1 min-h-0 overflow-auto py-4 px-2 -mx-2",e),...t});Ss.displayName="DialogBody";const Ts=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(is,{className:"mb-4"}),a.jsx("div",{className:Gt("flex flex-row justify-end gap-2",e),...s,children:t})]});Ts.displayName="DialogFooter";const Ps=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Title,{ref:s,className:Gt("text-xl font-semibold leading-none tracking-tight",e),...t}));Ps.displayName=se.Title.displayName;const Ds=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Description,{ref:s,className:Gt("text-sm text-muted-foreground",e),...t}));Ds.displayName=se.Description.displayName;const Es=h.FormProvider,As=ae.createContext({}),Is=()=>{const e=ae.useContext(As),a=ae.useContext(Ms),{getFieldState:t,formState:s}=h.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}},Ms=ae.createContext({}),Fs=ae.forwardRef(({className:e,...t},s)=>{const r=ae.useId();return a.jsx(Ms.Provider,{value:{id:r},children:a.jsx("div",{ref:s,className:Gt("space-y-1.5",e),...t})})});Fs.displayName="FormItem";const Rs=ae.forwardRef(({className:e,...t},s)=>{const{error:r,formItemId:n}=Is();return a.jsx(es,{ref:s,className:Gt(r&&"text-destructive",e),htmlFor:n,...t})});Rs.displayName="FormLabel";const Ls=ae.forwardRef(({...e},t)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=Is();return a.jsx(s.Slot,{ref:t,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...e})});Ls.displayName="FormControl";const zs=ae.forwardRef(({className:e,...t},s)=>{const{formDescriptionId:r}=Is();return a.jsx("p",{ref:s,id:r,className:Gt("text-sm text-muted-foreground",e),...t})});zs.displayName="FormDescription";const Us=ae.forwardRef(({className:e,children:t,...s},r)=>{const{error:n,formMessageId:o}=Is(),i=n?String(n?.message):t;return i?a.jsx("p",{ref:r,id:o,className:Gt("text-sm font-medium text-destructive",e),...s,children:i}):null});Us.displayName="FormMessage";const Os=oe.Root,Vs=oe.Group,Bs=oe.Value,qs=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(oe.Trigger,{ref:r,className:Gt("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors [&>span]:line-clamp-1",e),...s,children:[t,a.jsx(oe.Icon,{asChild:!0,children:a.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));qs.displayName=oe.Trigger.displayName;const $s=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.ScrollUpButton,{ref:s,className:Gt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronUp,{className:"h-4 w-4"})}));$s.displayName=oe.ScrollUpButton.displayName;const Ws=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.ScrollDownButton,{ref:s,className:Gt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronDown,{className:"h-4 w-4"})}));Ws.displayName=oe.ScrollDownButton.displayName;const Hs=ae.forwardRef(({className:e,children:t,position:s="popper",container:r,collisionBoundary:n,...o},i)=>a.jsx(oe.Portal,{container:r,children:a.jsxs(oe.Content,{ref:i,className:Gt("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",e),position:s,collisionBoundary:n,...o,children:[a.jsx($s,{}),a.jsx(oe.Viewport,{className:Gt("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),a.jsx(Ws,{})]})}));Hs.displayName=oe.Content.displayName;const Gs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Label,{ref:s,className:Gt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Gs.displayName=oe.Label.displayName;const Ys=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(oe.Item,{ref:r,className:Gt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(oe.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),a.jsx(oe.ItemText,{children:t})]}));Ys.displayName=oe.Item.displayName;const Qs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Separator,{ref:s,className:Gt("-mx-1 my-1 h-px bg-muted",e),...t}));Qs.displayName=oe.Separator.displayName;const Ks=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.Root,{ref:s,className:Gt("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",e),...t,children:a.jsx(ie.Indicator,{className:Gt("flex items-center justify-center text-current"),children:a.jsx(d.Check,{className:"h-4 w-4"})})}));Ks.displayName=ie.Root.displayName;const Xs=ae.forwardRef(({className:e,showCharCount:t,maxLength:s,onChange:r,...n},o)=>{const[i,l]=ae.useState(0);ae.useEffect(()=>{"string"==typeof n.value?l(n.value.length):"string"==typeof n.defaultValue&&l(n.defaultValue.length)},[n.value,n.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("textarea",{className:Gt("flex min-h-[80px] w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",e),ref:o,maxLength:s,onChange:e=>{l(e.target.value.length),r?.(e)},...n}),t&&s&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[i," / ",s]})]})});Xs.displayName="Textarea";const Js=r.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"}}),Zs=ae.forwardRef(({className:e,variant:t,...s},r)=>a.jsx("div",{ref:r,className:Gt(Js({variant:t}),e),...s}));Zs.displayName="Badge";const er={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function ar({size:e="md",className:t}){return a.jsx(d.Loader2,{className:Gt("animate-spin text-muted-foreground",er[e],t)})}function tr({isLoading:e,children:t,className:s,type:r="spinner",size:n="md"}){return e?"overlay"===r?a.jsxs("div",{className:Gt("relative",s),children:[t,a.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:a.jsx(ar,{size:n})})]}):"skeleton"===r?a.jsx("div",{className:Gt("animate-pulse",s),children:a.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):a.jsx("div",{className:Gt("flex items-center justify-center py-8",s),children:a.jsx(ar,{size:n})}):a.jsx(a.Fragment,{children:t})}const sr=({...e})=>a.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:a.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:a.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:a.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:a.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:a.jsx(d.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive-light !border-destructive-light",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...e}),rr=le.Root,nr=le.Trigger,or=le.Group,ir=le.Portal,lr=le.Sub,dr=le.RadioGroup,cr=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(le.SubTrigger,{ref:n,className:Gt("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",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));cr.displayName=le.SubTrigger.displayName;const ur=ae.forwardRef(({className:e,...t},s)=>a.jsx(le.SubContent,{ref:s,className:Gt("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",e),...t}));ur.displayName=le.SubContent.displayName;const mr=ae.forwardRef(({className:e,sideOffset:t=4,...s},r)=>a.jsx(le.Portal,{children:a.jsx(le.Content,{ref:r,sideOffset:t,className:Gt("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",e),...s})}));mr.displayName=le.Content.displayName;const pr=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(le.Item,{ref:r,className:Gt("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",e),...s}));pr.displayName=le.Item.displayName;const hr=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(le.CheckboxItem,{ref:n,className:Gt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(le.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));hr.displayName=le.CheckboxItem.displayName;const xr=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(le.RadioItem,{ref:r,className:Gt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(le.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));xr.displayName=le.RadioItem.displayName;const fr=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(le.Label,{ref:r,className:Gt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));fr.displayName=le.Label.displayName;const gr=ae.forwardRef(({className:e,...t},s)=>a.jsx(le.Separator,{ref:s,className:Gt("-mx-1 my-1 h-px bg-muted",e),...t}));gr.displayName=le.Separator.displayName;const vr=({className:e,...t})=>a.jsx("span",{className:Gt("ml-auto text-xs tracking-widest opacity-60",e),...t});vr.displayName="DropdownMenuShortcut";const br=({delayDuration:e=300,...t})=>a.jsx(de.Provider,{delayDuration:e,...t}),jr=de.Root,yr=de.Trigger,wr=ae.forwardRef(({className:e,sideOffset:t=4,...s},r)=>a.jsx(de.Content,{ref:r,sideOffset:t,className:Gt("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",e),...s}));wr.displayName=de.Content.displayName;const Nr=ae.forwardRef(({children:e,disabledReason:t,className:s},r)=>{const n=a.jsx(pr,{ref:r,className:Gt("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:e});return t?a.jsx(br,{delayDuration:100,children:a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx("div",{className:"w-full",children:n})}),a.jsx(wr,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:t})]})}):n});Nr.displayName="DisabledMenuItem";const _r=ce.Root,Cr=ce.Trigger,kr=ae.forwardRef(({className:e,align:t="center",sideOffset:s=4,container:r,...n},o)=>a.jsx(ce.Portal,{container:r,children:a.jsx(ce.Content,{ref:o,align:t,sideOffset:s,className:Gt("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",e),...n})}));kr.displayName=ce.Content.displayName;const Sr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Sr.displayName="Command";const Tr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:a.jsx("input",{ref:s,className:Gt("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",e),...t})}));Tr.displayName="CommandInput";const Pr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Pr.displayName="CommandList";const Dr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("py-6 text-center text-sm text-muted-foreground",e),...t}));Dr.displayName="CommandEmpty";const Er=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("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",e),...t}));Er.displayName="CommandGroup";const Ar=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("-mx-1 h-px bg-border",e),...t}));Ar.displayName="CommandSeparator";const Ir=ae.forwardRef(({className:e,disabled:t,onSelect:s,value:r,...n},o)=>a.jsx("div",{ref:o,className:Gt("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",e),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Ir.displayName="CommandItem";const Mr=({className:e,...t})=>a.jsx("span",{className:Gt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function Fr({className:e,...t}){return a.jsx("div",{className:Gt("animate-pulse rounded-md bg-muted",e),...t})}Mr.displayName="CommandShortcut";const Rr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Lr({multiple:s,options:r,value:n,onChange:o,getOptionValue:i,getOptionLabel:l,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x,required:f,className:g,sortOptions:v,maxDisplayedBadges:b,popoverContainer:j,onOpen:y,onClose:w}){const[N,_]=t.useState(!1),[C,k]=t.useState(""),S=t.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),T=t.useMemo(()=>{if(!j)return;let e=j,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[j]),P=t.useMemo(()=>{const e=r.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[r,i,l,v]),D=t.useMemo(()=>{if(!C)return P;const e=Rr(C);return P.filter(a=>Rr(a.label).includes(e))},[P,C]),E=t.useMemo(()=>P.filter(e=>S.includes(e.value)),[P,S]),A=e=>{_(e),e?y?.():(k(""),w?.())},I=(e,a)=>{a.preventDefault(),a.stopPropagation(),o&&o(s?S.filter(a=>a!==e):"")},M=b?E.slice(0,b):E,F=b&&E.length>b?E.length-b:0;return a.jsxs("div",{className:Gt("space-y-2",g),children:[u&&a.jsxs(es,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(_r,{open:N,onOpenChange:A,modal:!1,children:[a.jsx(Cr,{asChild:!0,children:s?a.jsxs("div",{role:"combobox","aria-expanded":N,"aria-disabled":x,tabIndex:x?-1:0,onKeyDown:e=>{x||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),A(!N))},className:Gt("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",x&&"pointer-events-none opacity-50 cursor-not-allowed",0===E.length&&"text-muted-foreground"),children:[0===E.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[M.map(e=>a.jsxs(Zs,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&I(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>I(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),F>0&&a.jsxs(Zs,{variant:"outline",className:"gap-1",children:["+",F]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):a.jsxs(Kt,{variant:"outline",role:"combobox","aria-expanded":N,disabled:x,className:Gt("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),E[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),a.jsx(kr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:T,collisionBoundary:T,children:a.jsxs(Sr,{children:[a.jsxs("div",{className:"relative",children:[a.jsx(Tr,{placeholder:h,value:C,onChange:e=>k(e.target.value)}),C&&a.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:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx(Pr,{children:0===r.length?a.jsx(Dr,{children:p}):0===D.length?a.jsx(Dr,{children:e.t("no_results")}):a.jsx(Er,{children:D.map(e=>a.jsxs(Ir,{value:e.value,onSelect:()=>(e=>{if(o)if(s){const a=S.includes(e)?S.filter(a=>a!==e):[...S,e];o(a)}else o(e),_(!1)})(e.value),className:"cursor-pointer",children:[a.jsx(d.Check,{className:Gt("mr-2 h-4 w-4",S.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})]})]})}function zr({multiple:e=!1,options:t,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:g=!1,error:v,className:b,sortOptions:y=!0,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C}){const{t:k}=j.useTranslation(),S=t||s||[],T=o||n,P=c||k("select_placeholder","Selecione..."),D=p||k("no_results",k("no_results")),E=h||k("search_placeholder","Pesquisar...");if(g)return a.jsxs("div",{className:Gt("space-y-2",b),children:[u&&a.jsxs(es,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Fr,{className:"h-10 w-full"})]});const A="string"==typeof v?v:v instanceof Error?v.message:v?k("error_loading",k("error_loading")):void 0;return A?a.jsxs("div",{className:Gt("space-y-2",b),children:[u&&a.jsxs(es,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:A})]})]}):a.jsx(Lr,{multiple:e,options:S,value:r||(e?[]:""),onChange:T,getOptionValue:i,getOptionLabel:l,placeholder:P,label:u,icon:m,emptyMessage:D,searchPlaceholder:E,disabled:x,required:f,className:b,sortOptions:y,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C})}const Ur=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ue.Root,{ref:r,className:Gt("relative overflow-hidden",e),...s,children:[a.jsx(ue.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(Or,{}),a.jsx(ue.Corner,{})]}));Ur.displayName=ue.Root.displayName;const Or=ae.forwardRef(({className:e,orientation:t="vertical",...s},r)=>a.jsx(ue.ScrollAreaScrollbar,{ref:r,orientation:t,className:Gt("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]",e),...s,children:a.jsx(ue.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Or.displayName=ue.ScrollAreaScrollbar.displayName;const Vr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Br(e,a){if(!a)return null;const t=Vr(a),s=[];for(const r of e){const e=Vr(r.label).includes(t),n=r.children?Br(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 qr(e,a){for(const t of e){if(t.value===a)return t.label;if(t.children){const e=qr(t.children,a);if(e)return e}}}function $r({node:e,level:t,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=e.children&&e.children.length>0,l=n.includes(e.value);return a.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":l,className:Gt("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:[a.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:a=>{a.stopPropagation(),o(e.value)},children:[a.jsx(d.Check,{className:Gt("h-4 w-4 shrink-0",l?"opacity-100":"opacity-0")}),(()=>{const t=l?e.iconSelected??(s?e.iconOpen:null)??e.icon:s?e.iconOpen??e.icon:e.icon;return t?a.jsx(t,{className:Gt("h-4 w-4 shrink-0",e.iconClassName||"text-muted-foreground")}):null})(),a.jsx("span",{className:"truncate",children:e.label})]}),i&&a.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:a=>{a.stopPropagation(),r(e.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?a.jsx(d.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function Wr({nodes:e,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return a.jsx(a.Fragment,{children:e.map(e=>{const l=r.has(e.value);return a.jsxs(t.Fragment,{children:[a.jsx($r,{node:e,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&e.children&&e.children.length>0&&a.jsx(Wr,{nodes:e.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},e.value)})})}function Hr({multiple:e=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:l,emptyMessage:c,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:x,className:f,maxDisplayedBadges:g,popoverContainer:v,onOpen:b,onClose:y,defaultExpanded:w=!0}){const{t:N}=j.useTranslation(),[_,C]=t.useState(!1),[k,S]=t.useState(""),[T,P]=t.useState(()=>w?function(e){const a=new Set;return function e(t){for(const s of t)s.children&&s.children.length>0&&(a.add(s.value),e(s.children))}(e),a}(s):new Set),D=o||N("select_placeholder","Selecione..."),E=c||N("no_results",N("no_results")),A=u||N("search_placeholder","Pesquisar..."),I=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),M=t.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]),F=t.useMemo(()=>Br(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,a){const t=new Set,s=Vr(a);function r(e){if(!e.children||0===e.children.length)return Vr(e.label).includes(s);let a=!1;for(const t of e.children)r(t)&&(a=!0);return a&&t.add(e.value),a||Vr(e.label).includes(s)}for(const n of e)r(n);return t}(s,k):new Set,[s,k]),L=k?R:T,z=t.useCallback(e=>{k||P(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[k]),U=t.useMemo(()=>I.map(e=>({value:e,label:qr(s,e)||e})),[I,s]),O=e=>{C(e),e?b?.():(S(""),y?.())},V=t.useCallback(a=>{if(n)if(e){const e=I.includes(a)?I.filter(e=>e!==a):[...I,a];n(e)}else n(a),C(!1)},[n,e,I]),B=(a,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(e?I.filter(e=>e!==a):"")},q=g?U.slice(0,g):U,$=g&&U.length>g?U.length-g:0;if(h)return a.jsxs("div",{className:Gt("space-y-2",f),children:[i&&a.jsxs(es,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Fr,{className:"h-10 w-full"})]});const W="string"==typeof x?x:x instanceof Error?x.message:x?N("error_loading",N("error_loading")):void 0;return W?a.jsxs("div",{className:Gt("space-y-2",f),children:[i&&a.jsxs(es,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:W})]})]}):a.jsxs("div",{className:Gt("space-y-2",f),children:[i&&a.jsxs(es,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(_r,{open:_,onOpenChange:O,modal:!1,children:[a.jsx(Cr,{asChild:!0,children:e?a.jsxs("div",{role:"combobox","aria-expanded":_,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),O(!_))},className:Gt("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===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),D]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[q.map(e=>a.jsxs(Zs,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&B(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>B(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),$>0&&a.jsxs(Zs,{variant:"outline",className:"gap-1",children:["+",$]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):a.jsxs(Kt,{variant:"outline",role:"combobox","aria-expanded":_,disabled:m,className:Gt("w-full justify-between min-h-10 h-auto font-normal",0===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),D]}):a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),U[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(kr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:M,collisionBoundary:M,children:[a.jsxs("div",{className:"flex items-center border-b px-3",children:[a.jsx(d.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.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:A,value:k,onChange:e=>S(e.target.value)}),k&&a.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx(Ur,{className:"max-h-[300px]",children:a.jsx("div",{role:"tree",className:"p-1",children:0===F.length?a.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:N("no_search_results",N("no_results"))}):a.jsx(Wr,{nodes:F,level:0,expandedIds:L,onToggleExpand:z,selectedValues:I,onSelect:V})})})]})]})]})}class Gr{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()}}Gr.LARGE_PAYLOAD_THRESHOLD=1e3;const Yr="qualiex_access_token",Qr="qualiex_id_token",Kr="supabase_token",Xr="oauth_state",Jr="oauth_nonce",Zr="selected_alias",en="manual_logout",an="supabase_project_id",tn={setAccessToken:e=>localStorage.setItem(Yr,e),getAccessToken:()=>localStorage.getItem(Yr),setIdToken:e=>localStorage.setItem(Qr,e),getIdToken:()=>localStorage.getItem(Qr),getSupabaseToken:()=>localStorage.getItem(Kr),setOAuthState:e=>sessionStorage.setItem(Xr,e),getOAuthState:()=>sessionStorage.getItem(Xr),clearOAuthState:()=>sessionStorage.removeItem(Xr),setOAuthNonce:e=>sessionStorage.setItem(Jr,e),getOAuthNonce:()=>sessionStorage.getItem(Jr),clearOAuthNonce:()=>sessionStorage.removeItem(Jr),setSelectedAlias:e=>localStorage.setItem(Zr,e),getSelectedAlias:()=>localStorage.getItem(Zr),clearSelectedAlias:()=>localStorage.removeItem(Zr),generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!tn.getAccessToken()||!tn.getIdToken()),checkProjectMismatch:()=>{const e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)return!1;const a=localStorage.getItem(an);return a&&a!==e?(tn.clearAll(),localStorage.setItem(an,e),!0):(a||localStorage.setItem(an,e),!1)},setSupabaseToken:e=>{localStorage.setItem(Kr,e),tn._clearValidationCache()},areAllTokensValid:()=>{const e=tn.getAccessToken(),a=tn.getIdToken();if(!e||!a)return!1;try{const t=Gr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=tn.getAccessToken(),t=tn.getIdToken(),s=tn.getSupabaseToken();return a&&tn.isTokenExpired(a)&&(localStorage.removeItem(Yr),e=!0),t&&tn.isTokenExpired(t)&&(localStorage.removeItem(Qr),e=!0),s&&tn.isTokenExpired(s)&&(localStorage.removeItem(Kr),e=!0),e},clearAll:()=>{localStorage.removeItem(Yr),localStorage.removeItem(Qr),localStorage.removeItem(Kr),localStorage.removeItem(Zr),localStorage.removeItem(en),sessionStorage.removeItem(Xr),sessionStorage.removeItem(Jr),tn._clearValidationCache()},setManualLogout:()=>localStorage.setItem(en,"true"),isManualLogout:()=>"true"===localStorage.getItem(en),clearManualLogout:()=>localStorage.removeItem(en),isTokenExpired:e=>{try{return Gr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{tn._validationCache.isValid=!1,tn._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=tn.getSupabaseToken();if(!e)return!1;if(tn.isTokenExpired(e))return tn._clearValidationCache(),tn._handleExpiredToken(),!1;const a=Date.now();return a-tn._validationCache.timestamp<tn._validationCache.cacheValidityMs?tn._validationCache.isValid:(tn._validationCache.isValid=!0,tn._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>tn.isSupabaseTokenValid()?tn.getSupabaseToken():null,_handleExpiredToken:()=>{tn.clearAll()},extractTokenData:()=>{if(!tn.isSupabaseTokenValid())return null;const e=tn.getSupabaseToken();if(!e)return null;try{const a=Gr.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 tn._handleExpiredToken(),null}},getCompanyId:e=>{const a=tn.getAccessToken();if(a)try{const t=Gr.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=tn.extractTokenData();if(t?.companyId)return t.companyId;const s=tn.getIdToken();if(s)try{const a=Gr.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=[tn.getAccessToken(),tn.getIdToken()];for(const t of a)if(t)try{const a=Gr.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=tn.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=tn.getIdToken();if(!e)return[];try{const a=Gr.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 sn=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);l.toast.error(e,{description:t})}}getErrorTitle(a){const t=a.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?e.t("error_session_expired"):t.includes("token")||t.includes("autenticação")?e.t("error_authentication"):t.includes("api")||t.includes("network")?e.t("error_connection"):"Erro"}success(e,a){l.toast.success(e,{description:a})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}},rn=(void 0).VITE_SUPABASE_URL,nn=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class on{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:nn};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return w.createClient(rn,nn,{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 on.instance||(on.instance=new on),on.instance}getClient(){const e=tn.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Gr.isTokenExpired(e)}catch(a){return sn.handleError(a instanceof Error?a:"Supabase - Error validating token",!1),!1}}}function ln(){return on.getInstance().getClient()}class dn{static async generateToken(e,a,t,s=!1){try{if(!s){const e=tn.getSupabaseToken();if(e&&tn.isSupabaseTokenValid())return e}const r=ln(),{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?(tn.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 cn{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=tn.getAccessToken(),t=tn.getSelectedAlias();if(!a||!t)return null;const s=await dn.generateToken(a,t,this.onLogoutCallback||void 0,e);return s||null}catch(a){return null}}}cn.regenerationPromise=null,cn.onLogoutCallback=null;class un{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(tn.clearAll(),window.location.href="/login",!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 mn{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 cn.attemptRegeneration()?(this.isRetrying=!1,!0):(un.handleError(e),this.isRetrying=!1,!1)}catch(s){return un.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=tn.getAccessToken();return e?tn.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."}}}mn.isRetrying=!1;const pn=new class{get baseUrl(){return Ue()}async makeApiCall(e,a,t){const s=mn.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=tn.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 sn.handleError(`[QualiexApi] Formato de resposta inesperado${a}`,!1),null;t=e}return Array.isArray(t)?t.map(this.mapToQualiexUser):(sn.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 mn.handleApiError(s))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",t,e);return this.parseUsersResponse(a," após retry")??[]}catch(r){return sn.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return sn.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 sn.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=tn.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||""})):(sn.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(a){if(await mn.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 sn.handleError(t instanceof Error?t:"Erro ao buscar softwares após renovação de token",!0),[]}return sn.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})):(sn.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(t){if(await mn.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 sn.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return sn.handleError(t instanceof Error?t.message:"Erro ao buscar associações do usuário",!0),[]}}};function hn(e,a){const t=a||Oe.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function xn(e,a){const t=a||Oe.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function fn(e,a){const t=a||Oe.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function gn(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||hn(e.idField),emailField:e.emailField||xn(e.idField),usernameField:e.usernameField||fn(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:hn(e),emailField:xn(e),usernameField:fn(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const vn=new Map;class bn{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=vn.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await pn.fetchUsers(e,a);return vn.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(!tn.areAllTokensValid())return e;const t=tn.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=gn(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 sn.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}}const jn=["responsible_name"],yn=e=>jn.includes(e);function wn(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:d=!1}=s,c=()=>{if(!tn.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return ln().schema(i).from(r)},u=(e,a,t,s)=>{let r=c().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||yn(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:i}},m=async(e,a,t,r,n)=>{const o=gn(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),i=a.includes(".");if(yn(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 d=await bn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.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}))(d,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}}})(c,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 bn.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:c}=(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,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,o,i),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let v=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const a=gn(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(v.data)){const e=await m(v.data,t,n,o,i);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:a,error:t}=await c().select(o||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Yt(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Yt(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}};return p}var Nn;const _n={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class Cn{static async initialize(){try{if(tn.checkProjectMismatch())return{..._n};if(!tn.hasAllTokens()||!tn.areAllTokensValid())return tn.clearExpiredTokens(),{..._n};const e=tn.getAccessToken(),a=tn.getIdToken();tn.clearManualLogout();const t=this.extractUserFromIdToken(a,e),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=tn.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=tn.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);i=a?e:r||s[0]?.alias||null}if(!tn.isSupabaseTokenValid()&&i&&await cn.attemptRegeneration(),!tn.isSupabaseTokenValid())return{..._n};let l=null;if(i){const e=tn.getCompanyId(i),a=s.find(e=>e.alias===i);a&&(l={id:e||a.id,name:a.name,alias:a.alias})}const d=n?.placeId??null,c=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:d,placeName:c,activePlaceId:d,activePlaceName:c}}catch(e){return{..._n}}}static async loginDev(){try{const e=ln(),{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="Lw==";tn.setOAuthState(e);const a=tn.generateOAuthNonce();tn.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(Ie.oauth.authUrl);s.searchParams.set("client_id",Ie.oauth.clientId),s.searchParams.set("response_type",Ie.oauth.responseType),s.searchParams.set("scope",Ie.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=tn.getAccessToken();e!==s&&tn.clearAll()}if(tn.hasAllTokens()){return tn.getValidSupabaseToken()||await cn.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");tn.setAccessToken(o),tn.setIdToken(i),tn.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)tn.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");tn.setSelectedAlias(e[0].alias)}if(!await cn.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return tn.clearOAuthState(),tn.clearOAuthNonce(),!0}catch(e){throw e}}static async logout(){tn.setManualLogout(),tn.clearAll(),localStorage.removeItem("auth_return_url"),sessionStorage.clear();try{if("caches"in window){const e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}}catch{}window.location.href="/login"}static decodeToken(e){return Gr.parseJwtPayload(e)}static extractUserFromIdToken(e,a){const t=this.decodeToken(e);if(!t)return null;const s=a?this.decodeToken(a):null;return{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier,isSysAdmin:"1"===s?.admin}}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}}Nn=Cn,cn.setLogoutCallback(()=>{Nn.logout()});const kn=e=>e?.placeId||null,Sn=e=>e?.placeName||null,Tn=t.createContext(void 0),Pn=({children:e})=>{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=N.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useRef(0),d=t.useCallback(e=>{r(a=>({...a,...e}))},[]),c=t.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),u=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})},[]),m=t.useCallback(async e=>{if(e.alias===s.alias)return;const a=++l.current;try{const r=tn.getAccessToken();if(!r)return;const o=await dn.generateToken(r,e.alias,void 0,!0);if(l.current!==a)return;if(!o)return;tn.setSupabaseToken(o),tn.setSelectedAlias(e.alias);const i=tn.extractTokenData(),c=i?.alias||e.alias,u=i?.companyId||tn.getCompanyId(e.alias),m={id:u||e.id,name:e.name,alias:c};let p=null,h=null;if(s.user?.id&&c&&u)try{const e=await pn.fetchActiveUsersMap(c,u);if(l.current!==a)return;const t=e.get(s.user.id);if(t){const e=(e=>({placeId:kn(e),placeName:Sn(e)}))(t);p=e.placeId,h=e.placeName}}catch(t){}if(l.current!==a)return;d({alias:c,selectedUnit:m,placeId:p,placeName:h,activePlaceId:p,activePlaceName:h}),n&&await n.clear()}catch(t){}},[d,n,s.user,s.alias]),p=t.useCallback(async()=>{const e=await Cn.processCallback();if(e){const e=await Cn.initialize();e&&e.isAuthenticated&&(d({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},[d,n]),h=t.useCallback(async()=>{await Cn.logout(),u(),n&&await n.clear()},[u,n]),x=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),g=t.useCallback(()=>{n&&n.invalidateQueries()},[n]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(async()=>{if(e)if(tn.areAllTokensValid()){if(!tn.isSupabaseTokenValid())try{await cn.attemptRegeneration()||e&&h()}catch(a){e&&h()}}else e&&h()},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,h]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Cn.initialize();if(!e)return;a&&a.isAuthenticated?d({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&&(un.handleError(a),c(!1))}})(),()=>{e=!1}},[d,c,h]);const v=t.useMemo(()=>({...s,logout:h,processCallback:p,switchUnit:m,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:x,clearSearch:f,refreshData:g}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,h,p,m,o,x,f,g]);return a.jsx(Tn.Provider,{value:v,children:e})},Dn=()=>{const e=t.useContext(Tn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function En({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[i,d]=_.useSearchParams(),c=N.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Dn(),{t:h}=j.useTranslation(),x=t.useCallback(a=>{const t=`${e}_${a}`,s=i.get(t);return s||(i.get(a)||"")},[i,e]),f=x("search"),g=x("sortField")||Me.sorting.defaultField,v=x("sortDirection")||Me.sorting.defaultDirection,b=parseInt(x("page")||"1"),y=parseInt(x("limit")||String(Me.pagination.defaultPageSize)),w=f,C=t.useMemo(()=>({search:w,sortField:g,sortDirection:v,page:b,limit:y,...n}),[w,g,v,b,y,n]),k=t.useCallback(()=>a.getAll(C),[a,C]),S=N.useQuery({queryKey:[e,u,m,C],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 T=N.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Be.success.created(s)),o?.()},onError:e=>{l.toast.error(`${Be.error.create(s)}: ${e.message}`)}}),P=N.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Be.success.updated(s)),o?.()},onError:e=>{l.toast.error(`${Be.error.update(s)}: ${e.message}`)}}),D=N.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Be.success.deleted(s))},onError:e=>{l.toast.error(`${Be.error.delete(s)}: ${e.message}`)}}),E=t.useCallback(a=>{const t={...Object.fromEntries(i)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[i,d,e]),A=t.useCallback(e=>{E({search:e,page:1})},[E]),I=t.useCallback(e=>{E({sortField:e,sortDirection:g===e&&"asc"===v?"desc":"asc",page:1})},[g,v,E]),M=t.useCallback(e=>{E({page:e})},[E]),F=t.useCallback(e=>{E({limit:e,page:1})},[E]),R=t.useCallback(()=>{const a=Object.fromEntries(i),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,i,e]),[L,z]=t.useState([]),U=t.useCallback(e=>{z(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),O=t.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];z(a=>a.length===e.length?[]:e)},[S?.data?.data]),V=t.useCallback(()=>{z([])},[]),B=t.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&L.length===e.length},[L,S?.data?.data]),q=N.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(h("bulk_delete_success",`${t.length} ${s}(s) deletado(s) com sucesso`)),V()},onError:e=>{l.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),$=t.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):T.mutate({...t,alias:u})},[u,T,P]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||Me.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:T?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:D?.isPending??!1,error:S?.error||null,searchTerm:f,sortField:g,sortDirection:v,currentPage:b,itemsPerPage:y,queryKey:e,createEntity:T.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:D.mutate,save:$,handleSearch:A,handleSort:I,handlePageChange:M,handleItemsPerPageChange:F,clearFilters:R,refetch:S.refetch,selectedIds:L,selectItem:U,selectAll:O,clearSelection:V,isAllSelected:B,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}function An(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.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]),a}function In(e=768){return An(`(max-width: ${e-1}px)`)}const Mn=ae.forwardRef(({className:e,...t},s)=>a.jsx("table",{ref:s,className:Gt("w-full caption-bottom text-[13px] table-fixed",e),...t}));Mn.displayName="Table";const Fn=ae.forwardRef(({className:e,...t},s)=>a.jsx("thead",{ref:s,className:Gt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));Fn.displayName="TableHeader";const Rn=ae.forwardRef(({className:e,...t},s)=>a.jsx("tbody",{ref:s,className:Gt("[&_tr:last-child]:border-0",e),...t}));Rn.displayName="TableBody";const Ln=ae.forwardRef(({className:e,...t},s)=>a.jsx("tfoot",{ref:s,className:Gt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Ln.displayName="TableFooter";const zn=ae.forwardRef(({className:e,...t},s)=>a.jsx("tr",{ref:s,className:Gt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",e),...t}));zn.displayName="TableRow";const Un=ae.forwardRef(({className:e,...t},s)=>a.jsx("th",{ref:s,className:Gt("h-9 px-4 py-2 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));Un.displayName="TableHead";const On=ae.forwardRef(({className:e,...t},s)=>a.jsx("td",{ref:s,className:Gt("px-4 py-2 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",e),...t}));On.displayName="TableCell";const Vn=ae.forwardRef(({className:e,...t},s)=>a.jsx("caption",{ref:s,className:Gt("mt-4 text-sm text-muted-foreground",e),...t}));function Bn({rows:e=5,columns:t=4}){return a.jsx("div",{className:"w-full",children:a.jsxs("div",{className:"rounded-md border",children:[a.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Fr,{className:"h-4 w-24"},t))})}),a.jsx("div",{children:Array.from({length:e}).map((e,s)=>a.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Fr,{className:"h-4 w-20"},t))})},s))})]})})}function qn({count:e=3}){return a.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>a.jsxs(as,{children:[a.jsxs(ts,{children:[a.jsx(Fr,{className:"h-4 w-3/4"}),a.jsx(Fr,{className:"h-3 w-1/2"})]}),a.jsx(ns,{children:a.jsxs("div",{className:"space-y-2",children:[a.jsx(Fr,{className:"h-3 w-full"}),a.jsx(Fr,{className:"h-3 w-2/3"})]})})]},t))})}Vn.displayName="TableCaption";const $n={default:d.FileX,search:d.Search,error:d.AlertCircle};function Wn({icon:e,title:t,description:s,action:r,className:n,variant:o="default"}){const{t:i}=j.useTranslation(),l=!!e,d=$n[o];return a.jsxs("div",{className:Gt("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[a.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:l?e:a.jsx(d,{className:"h-8 w-8 text-muted-foreground"})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&a.jsx(Kt,{onClick:r.onClick,variant:"outline",children:r.label})]})}function Hn({children:e,className:t}){const s=ae.useRef(null),[r,n]=ae.useState(!1);ae.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()},[e]);const o=a.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:e});return r?a.jsx(br,{delayDuration:300,children:a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:o}),a.jsx(wr,{side:"top",className:"max-w-[400px] break-words",children:e})]})}):o}const Gn=ae.forwardRef(({direction:e,onMouseDown:t,isDragging:s,className:r},n)=>{const o="horizontal"===e;return a.jsx("div",{ref:n,onMouseDown:t,className:Gt("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:a.jsx("div",{className:Gt("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Gn.displayName="TableResizeHandle";const Yn=me.Root,Qn=me.Trigger,Kn=me.Group,Xn=me.Portal,Jn=me.Sub,Zn=me.RadioGroup,eo=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(me.SubTrigger,{ref:n,className:Gt("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",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));eo.displayName=me.SubTrigger.displayName;const ao=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.SubContent,{ref:s,className:Gt("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",e),...t}));ao.displayName=me.SubContent.displayName;const to=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.Portal,{children:a.jsx(me.Content,{ref:s,className:Gt("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",e),...t})}));to.displayName=me.Content.displayName;const so=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Item,{ref:r,className:Gt("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",e),...s}));so.displayName=me.Item.displayName;const ro=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(me.CheckboxItem,{ref:n,className:Gt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));ro.displayName=me.CheckboxItem.displayName;const no=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(me.RadioItem,{ref:r,className:Gt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));no.displayName=me.RadioItem.displayName;const oo=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Label,{ref:r,className:Gt("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...s}));oo.displayName=me.Label.displayName;const io=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.Separator,{ref:s,className:Gt("-mx-1 my-1 h-px bg-border",e),...t}));io.displayName=me.Separator.displayName;const lo=({className:e,...t})=>a.jsx("span",{className:Gt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});lo.displayName="ContextMenuShortcut";const co=({onEdit:e,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:l}=j.useTranslation(),c=[];if(e){const a={icon:d.Edit,label:l("edit"),onClick:e};c.push(a)}if(o.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:r?"Inativar":"Ativar",onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("ap_delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===i?pr:so;return a.jsx(a.Fragment,{children:c.map((e,t)=>a.jsxs(u,{onClick:e.onClick,className:Gt("whitespace-normal cursor-pointer",e.destructive&&"text-destructive focus:text-destructive"),children:[a.jsx(e.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.label]},t))})},uo=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:a.jsx(d.EllipsisVertical,{size:12})})}),a.jsx(mr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:a.jsx(co,{onEdit:e?a=>{a?.stopPropagation(),e?.()}: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"})})]}),mo=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>{const{t:i}=j.useTranslation();return a.jsx(br,{delayDuration:200,children:a.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e()},children:a.jsx(d.Pencil,{size:14})})}),a.jsx(wr,{children:i("edit")})]}),o.map((e,t)=>{const s=e.icon;return a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e.onClick()},children:a.jsx(s,{size:14})})}),a.jsx(wr,{children:e.label})]},t)}),r&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),r()},children:n?a.jsx(d.ToggleRight,{size:14}):a.jsx(d.ToggleLeft,{size:14})})}),a.jsx(wr,{children:n?"Inativar":"Ativar"})]}),t&&s&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:Gt("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),t()},children:a.jsx(d.Trash2,{size:14})})}),a.jsx(wr,{children:i("ap_delete")})]})]})})},po=150;function ho({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??po,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??po,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??po)},[r,n]);t.useEffect(()=>{if(!i||!d)return;const t=e.find(e=>e.key===d),r=t?.minWidth??60,n=t?.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,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(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,d,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,a)=>(e[a.key]=a.defaultWidth??po,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}const xo=r.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"}}),fo=ae.forwardRef(({className:e,variant:t,size:s,...r},n)=>a.jsx(he.Root,{ref:n,className:Gt(xo({variant:t,size:s,className:e})),...r}));fo.displayName=he.Root.displayName;const go=ae.createContext({size:"default",variant:"default"}),vo=ae.forwardRef(({className:e,variant:t,size:s,children:r,...n},o)=>a.jsx(pe.Root,{ref:o,className:Gt("flex items-center justify-center gap-1",e),...n,children:a.jsx(go.Provider,{value:{variant:t,size:s},children:r})}));vo.displayName=pe.Root.displayName;const bo=ae.forwardRef(({className:e,children:t,variant:s,size:r,...n},o)=>{const i=ae.useContext(go);return a.jsx(pe.Item,{ref:o,className:Gt(xo({variant:i.variant||s,size:i.size||r}),e),...n,children:t})});bo.displayName=pe.Item.displayName;const jo=t.memo(function({onNew:e,newButtonLabel:t,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:l=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:x,viewMode:f,onViewModeChange:g,showViewToggle:v=!1,availableViewModes:b=["table","list","grid"],rightSlot:y,className:w}){const{t:N}=j.useTranslation(),_=c>0,C=e&&s||h.length>0,k=x||v||y,S=r&&o;return C||S||k||l&&_?a.jsxs("div",{className:Gt("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e&&s&&a.jsxs(Kt,{onClick:e,children:[a.jsx(d.Plus,{size:16,className:"mr-2"}),t||"Novo"]}),h.map((e,t)=>{const s=e.icon;return a.jsxs(Kt,{onClick:e.action,variant:e.variant||"outline",disabled:e.disabled,title:e.disabled?e.disabledReason:void 0,children:[s&&a.jsx(s,{size:16,className:"mr-2"}),e.label]},t)})]}),l&&_&&a.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[a.jsx(Zs,{variant:"secondary",className:"mr-1 tabular-nums",children:c}),a.jsxs(br,{delayDuration:200,children:[u.length>0?u.map((e,t)=>{const s=e.icon,r=e.disabled;return a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:Gt("h-8 w-8","destructive"===e.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:r,onClick:()=>e.action([]),children:s?a.jsx(s,{size:16}):a.jsx("span",{className:"text-xs",children:e.label[0]})})}),a.jsx(wr,{children:e.label})]},t)}):a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:a.jsx(d.Trash2,{size:16})})}),a.jsx(wr,{children:N("ap_delete")})]}),a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:a.jsx(d.X,{size:16})})}),a.jsx(wr,{children:N("clear_selection")})]})]})]}),S&&a.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:a.jsxs("div",{className:"relative w-full",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Jt,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),k&&a.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[x,v&&f&&g&&a.jsx(vo,{type:"single",value:f,onValueChange:e=>e&&g(e),size:"sm",children:b.map(e=>{const t=(e=>{switch(e){case"table":return d.Table2;case"list":return d.List;case"grid":return d.LayoutGrid}})(e);return a.jsx(bo,{value:e,"aria-label":"Visualizar como "+("table"===e?"tabela":"list"===e?"lista":"grade"),children:a.jsx(t,{className:"h-4 w-4"})},e)})}),y]})]}):null}),yo=t.memo(({checked:e,onCheckedChange:t})=>a.jsx(Ks,{checked:e,onCheckedChange:t}),(e,a)=>e.checked===a.checked);function wo(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 No({columns:e,storageKey:a,enabled:s=!0,defaultHiddenColumns:r}){const n=t.useMemo(()=>e.map(e=>String(e.key)),[e]),o=t.useMemo(()=>new Set(r??[]),[r]),[i,l]=t.useState(()=>{if(!s)return o;if(!a)return o;const e=wo(a);return e?.hiddenColumns??o}),[d,c]=t.useState(()=>{if(!s||!a)return n;const e=wo(a)?.columnOrder;return e&&e.length>0?e:n}),[u,m]=t.useState(()=>s&&a?wo(a)?.groupByColumns??[]:[]),[p,h]=t.useState(new Set);t.useEffect(()=>{s&&a&&function(e,a){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(a.hiddenColumns),columnOrder:a.columnOrder,groupByColumns:a.groupByColumns}))}catch{}}(a,{hiddenColumns:i,columnOrder:d,groupByColumns:u})},[i,d,u,a,s]),t.useEffect(()=>{const a=new Set(e.map(e=>String(e.key))),t=new Set(d),s=[...a].filter(e=>!t.has(e));s.length>0&&c(e=>[...e.filter(e=>a.has(e)),...s])},[e]);const x=t.useCallback(e=>i.has(e),[i]),f=t.useCallback(e=>{l(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),g=t.useCallback(()=>{l(new Set)},[]),v=t.useCallback(()=>{if(l(o),c(n),m([]),h(new Set),a)try{localStorage.removeItem(a)}catch{}},[n,o,a]),b=t.useCallback((e,a)=>{c(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s})},[]),j=t.useCallback(e=>{h(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),y=t.useCallback(e=>{m(e),h(new Set)},[]),w=t.useCallback(e=>{m(a=>a.includes(e)?a:[...a,e])},[]),N=t.useCallback(e=>{m(a=>a.filter(a=>a!==e)),h(a=>{const t=new Set;for(const s of a)s.includes(`${e}:`)||t.add(s);return t})},[]),_=t.useCallback((e,a)=>{m(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s}),h(new Set)},[]),C=u[0]??null,k=t.useCallback(e=>{m(e?[e]:[]),h(new Set)},[]),S=t.useMemo(()=>{if(!s)return e;const a=new Map(e.map(e=>[String(e.key),e]));return d.filter(e=>!i.has(e)&&a.has(e)).map(e=>a.get(e))},[e,d,i,s]),T=t.useCallback(e=>{if(0===u.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,u,0,"")},[u]);return{visibleColumns:S,allColumns:e,isColumnHidden:x,toggleColumn:f,showAllColumns:g,resetColumns:v,columnOrder:d,reorderColumns:b,groupByColumn:C,setGroupByColumn:k,groupByColumns:u,setGroupByColumns:y,addGroupByColumn:w,removeGroupByColumn:N,reorderGroupByColumns:_,getGroupedData:T,collapsedGroups:p,toggleGroupCollapse:j}}function _o({enabled:e=!1,onReorder:a}){const[s,r]=t.useState(null),[n,o]=t.useState(null),i=t.useCallback(()=>{r(null),o(null)},[]),l=t.useCallback((t,n)=>({draggable:e,onDragStart:a=>{e&&(r(t),a.dataTransfer.effectAllowed="copyMove",a.dataTransfer.setData("text/plain",String(t)),n&&a.dataTransfer.setData("application/column-key",n))},onDragOver:a=>{e&&null!==s&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDragEnter:a=>{e&&null!==s&&(a.preventDefault(),o(t))},onDrop:r=>{r.preventDefault(),e&&null!==s&&s!==t?(a(s,t),i()):i()},onDragEnd:()=>{i()}}),[e,s,a,i]);return t.useMemo(()=>({dragFromIndex:s,dragOverIndex:n,isDragging:null!==s,getDragProps:l}),[s,n,l])}function Co({columns:e,columnOrder:s,isColumnHidden:r,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:l,setGroupByColumn:c,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p,resetColumns:h}){const{t:x}=j.useTranslation(),[f,g]=t.useState(null),[v,b]=t.useState(null),y=t.useRef(null),w=new Map(e.map(e=>[String(e.key),e])),N=s.filter(e=>w.has(e)).map(e=>w.get(e)),_=()=>{y.current=null,g(null),b(null)};N.some(e=>r(String(e.key)));const C=N.every(e=>!r(String(e.key)));return a.jsxs(_r,{children:[a.jsx(Cr,{asChild:!0,children:a.jsx(Kt,{variant:"outline",size:"icon",className:"h-8 w-8",children:a.jsx(d.Columns3,{size:16})})}),a.jsxs(kr,{className:"w-[260px] p-0",align:"end",children:[a.jsx("div",{className:"px-3 py-2 border-b",children:a.jsx("span",{className:"text-sm font-medium",children:"Colunas"})}),a.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:a.jsx(br,{delayDuration:300,children:N.map((e,t)=>{const s=String(e.key),o=r(s),h=!1!==e.hideable,j=!0===e.groupable,w=u.includes(s)||l===s;return a.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{y.current=e,g(e)})(t),onDragOver:e=>((e,a)=>{e.preventDefault(),b(a)})(e,t),onDrop:()=>(e=>{null!==y.current&&y.current!==e&&i(y.current,e),y.current=null,g(null),b(null)})(t),onDragEnd:_,className:Gt("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",f===t&&"opacity-50",v===t&&"border-t-2 border-primary"),children:[a.jsx(d.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),a.jsx(Ks,{checked:!o,onCheckedChange:()=>h&&n(s),disabled:!h,className:"shrink-0"}),a.jsx("span",{className:Gt("flex-1 truncate",o&&"text-muted-foreground"),children:e.header}),j&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:Gt("h-6 w-6 shrink-0",w&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),w?p?p(s):c?.(null):m?m(s):c?.(s)},children:a.jsx(d.Group,{size:14})})}),a.jsx(wr,{children:x(w?"remove_grouping":"group_by_column")})]})]},s)})})}),a.jsxs("div",{className:"border-t px-3 py-2 space-y-1",children:[a.jsx(Kt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:C?()=>N.filter(e=>!1!==e.hideable).forEach(e=>n(String(e.key))):o,children:x(C?"deselect_all":"select_all_columns")}),h&&a.jsx(Kt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:h,children:"Redefinir padrão"})]})]})]})}function ko({columns:e,groupByColumns:s,addGroupByColumn:r,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,l]=t.useState(!1),[c,u]=t.useState(null),[m,p]=t.useState(null),h=new Map(e.map(e=>[String(e.key),e])),x=()=>{u(null),p(null)},f=s.length>0;return a.jsxs("div",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",l(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},onDrop:e=>{e.preventDefault(),l(!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:Gt("flex items-center gap-2 px-4 py-2 min-h-[40px] border-b transition-colors",i&&"bg-primary/5 border-primary/30",!f&&"text-muted-foreground"),children:[a.jsx(d.Group,{size:14,className:"shrink-0 text-muted-foreground"}),a.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:f?s.map((e,s)=>{const r=h.get(e);if(!r)return null;const i=c===s,l=m===s&&c!==s;return a.jsxs(t.Fragment,{children:[s>0&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),a.jsxs(Zs,{variant:"secondary",className:Gt("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",l&&"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:x,children:[r.header,a.jsx("button",{onClick:a=>{a.stopPropagation(),n(e)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:a.jsx(d.X,{size:12})})]})]},e)}):a.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const So=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:u,enableBulkActions:m=!1,rowActionsVariant:p="dropdown",onNew:h,newButtonLabel:x,showNewButton:f=!0,customActions:g=[],hideActionBar:v,showActionBar:b=!0,showSearch:y=!1,searchValue:w,onSearchChange:N,searchPlaceholder:_,bulkActions:C=[],onBulkDelete:k,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D=!1,enableColumnResize:E=!0,resizeStorageKey:A,enableColumnManager:I=!0,columnManagerStorageKey:M,defaultHiddenColumns:F,enableGrouping:R=!1,enableExpandableRows:L=!1,renderExpandedContent:z,expandedRowIds:U,onToggleExpand:O,defaultExpandAll:V=!1,hideActionsColumn:B=!1})=>{const{t:q}=j.useTranslation(),{setSearchVisible:$}=Dn(),W=In(),[H,G]=t.useState(()=>V&&L?new Set(s.entities.map(e=>e.id)):new Set),Y=void 0!==U,Q=Y?new Set(U):H,K=t.useCallback(e=>{Y&&O?O(e):G(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[Y,O]),X=void 0!==v?!v:b;t.useEffect(()=>{if(!y)return $(!0),()=>$(!1)},[$,y]);const J=No({columns:r,storageKey:M,enabled:I,defaultHiddenColumns:F}),Z=_o({enabled:I,onReorder:J.reorderColumns}),ee=I?J.visibleColumns:r,{columnWidths:ae,isDragging:te,activeColumn:se,handleMouseDown:re}=ho({columns:ee.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:A?`${A}-columns`:void 0,enabled:E}),ne=t.useMemo(()=>(()=>{if(E){const e=ee.map(e=>ae[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return ee.map((t,s)=>({...t,calculatedWidth:e[s],style:{width:e[s]/a*100+"%"}}))}let e=0;const a=ee.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`}})})(),[ee,E,ae]),oe=h||g.length>0||y||m||S||D||I,ie=X&&oe,le=k||(()=>{s.bulkDelete?.(s.selectedIds)}),de=e=>a.jsx(On,{className:"text-center",children:c?c(e):"inline"===p?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:a.jsx(mo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}):a.jsx(uo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}),ce=e=>a.jsx(to,{className:"w-[160px]",children:a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:u?u(e):[],renderAs:"context"})}),ue=I?a.jsx(Co,{columns:r,columnOrder:J.columnOrder,isColumnHidden:J.isColumnHidden,toggleColumn:J.toggleColumn,showAllColumns:J.showAllColumns,resetColumns:J.resetColumns,reorderColumns:J.reorderColumns,groupByColumn:R?J.groupByColumn:void 0,setGroupByColumn:R?J.setGroupByColumn:void 0,groupByColumns:R?J.groupByColumns:void 0,addGroupByColumn:R?J.addGroupByColumn:void 0,removeGroupByColumn:R?J.removeGroupByColumn:void 0}):void 0;if(W)return s.isLoading?a.jsx(qn,{count:3}):0===s.entities.length?a.jsx(Wn,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"}):a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(jo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:y,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D}),a.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:s.entities.map(e=>a.jsxs(Yn,{children:[a.jsx(Qn,{asChild:!0,children:a.jsx(as,{className:Gt("overflow-hidden cursor-pointer hover:bg-muted/50",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:a.jsx(ns,{className:"p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[m&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1",children:[ee.map(t=>a.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||c)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(e):a.jsx(uo,{onEdit:n?()=>{n(e)}:void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})})]})]})})})}),ce(e)]},e.id))})]});const me=R&&J.groupByColumns.length>0?J.getGroupedData(s.entities):null,pe=null!==me,he=(L?1:0)+(m?1:0)+ee.length+(B?0:1),xe=e=>{const r=L&&Q.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(Yn,{children:[a.jsx(Qn,{asChild:!0,children:a.jsxs(zn,{className:Gt("cursor-pointer hover:bg-muted/50 relative",("inline"===p||B)&&"group",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:[L&&a.jsx(On,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),K(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":q(r?"collapse_row":"expand_row"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),m&&a.jsx(On,{onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),ee.map(t=>a.jsx(On,{className:t.className,children:a.jsx(Hn,{children:t.render?t.render(e):String(e[t.key]??"")})},String(t.key))),!B&&de(e)]})}),ce(e)]}),r&&z&&a.jsx(zn,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(On,{colSpan:he,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:z(e)})})})]},e.id)},fe=(e,s)=>{const{t:r}=j.useTranslation();return e.map(e=>{const r=J.collapsedGroups.has(e.groupKey),n=16*e.level,o=Math.max(30,70-15*e.level);return a.jsxs(t.Fragment,{children:[a.jsx(zn,{className:Gt("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>J.toggleGroupCollapse(e.groupKey),children:a.jsx(On,{colSpan:s,className:"py-2 px-4",children:a.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[r?a.jsx(d.ChevronRight,{size:16}):a.jsx(d.ChevronDown,{size:16}),a.jsx("span",{children:e.groupValue}),a.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",e.count,")"]})]})})}),!r&&(e.children?fe(e.children,s):e.items.map(xe))]},e.groupKey)})};return a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(jo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:y,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D}),s.isLoading?a.jsx(Bn,{rows:5,columns:ee.length}):a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[R&&a.jsx(ko,{columns:r,groupByColumns:J.groupByColumns,addGroupByColumn:J.addGroupByColumn,removeGroupByColumn:J.removeGroupByColumn,reorderGroupByColumns:J.reorderGroupByColumns}),a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs(Mn,{className:"table-fixed w-full",children:[a.jsxs("colgroup",{children:[L&&a.jsx("col",{style:{width:"40px"}}),m&&a.jsx("col",{style:{width:"50px"}}),ne.map((e,t)=>a.jsx("col",{style:e.style},t)),!B&&a.jsx("col",{style:{width:"inline"===p?"auto":"50px",minWidth:"50px"}})]}),a.jsx(Fn,{children:a.jsxs(zn,{children:[L&&a.jsx(Un,{className:"w-[40px]"}),m&&a.jsx(Un,{className:"w-[50px]",children:a.jsx(yo,{checked:s.isAllSelected,onCheckedChange:s.selectAll})}),ee.map((e,t)=>{const r=E&&!1!==e.resizable,n=se===String(e.key),o=I?Z.getDragProps(t,String(e.key)):{},i=Z.dragFromIndex===t,l=Z.dragOverIndex===t&&Z.dragFromIndex!==t;return a.jsxs(Un,{className:Gt(e.className,!1!==e.sortable&&"hover:bg-muted/50 cursor-pointer","relative transition-opacity",I&&Z.isDragging&&"cursor-grabbing",i&&"opacity-50",l&&"border-l-2 border-primary"),onClick:!1!==e.sortable?()=>s.handleSort(String(e.key)):void 0,...o,children:[a.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,!1!==e.sortable&&(c=String(e.key),s.sortField!==c?null:"asc"===s.sortDirection?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),r&&a.jsx(Gn,{direction:"horizontal",onMouseDown:a=>re(String(e.key),a),isDragging:n})]},String(e.key));var c}),!B&&a.jsx(Un,{className:"w-[50px] text-center",children:ue||e.t("actions")})]})}),a.jsx(Rn,{children:0===s.entities.length?a.jsx(zn,{children:a.jsx(On,{colSpan:he,className:"h-32",children:a.jsx(Wn,{title:e.t("no_items_found_empty"),description:"Não há dados para exibir no momento.",variant:"search"})})}):pe?fe(me,he):s.entities.map(xe)})]})})]})]})};function To(e,a,s,r){const[n,o]=t.useState({}),[i,l]=t.useState({}),d=t.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},t=e(d),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);c(e)&&(t=e.toISOString().split("T")[0])}else c(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{t.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors: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(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),i[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Po=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Do=({value:e="#3b82f6",onChange:t,label:s,customColorLabel:r,presetColorsLabel:n})=>{const{t:o}=j.useTranslation(),i=r??o("custom_color"),l=n??o("preset_colors");return a.jsxs("div",{className:"space-y-2",children:[s&&a.jsx(es,{children:s}),a.jsxs(_r,{children:[a.jsx(Cr,{asChild:!0,children:a.jsxs(Kt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[a.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),a.jsx(kr,{className:"w-64",children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx(es,{htmlFor:"color-input",children:i}),a.jsx(Jt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),a.jsxs("div",{children:[a.jsx(es,{children:l}),a.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Po.map(e=>a.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]})},Eo=[{name:"alarm",filled:!1},{name:"account_box",filled:!0},{name:"announcement",filled:!0},{name:"assessment",filled:!0},{name:"assignment",filled:!0},{name:"bookmark",filled:!0},{name:"build",filled:!0},{name:"change_history",filled:!1},{name:"credit_card",filled:!1},{name:"date_range",filled:!0},{name:"extension",filled:!0},{name:"face",filled:!0},{name:"favorite",filled:!0},{name:"store",filled:!0},{name:"group_work",filled:!0},{name:"home",filled:!0},{name:"label",filled:!0},{name:"lightbulb_2",filled:!1},{name:"list",filled:!0},{name:"line_weight",filled:!0},{name:"question_answer",filled:!0},{name:"mode_heat",filled:!0},{name:"reorder",filled:!0},{name:"warning",filled:!0},{name:"room",filled:!0},{name:"settings",filled:!0},{name:"shopping_cart",filled:!0},{name:"work",filled:!0},{name:"star_rate",filled:!0},{name:"monetization_on",filled:!0},{name:"view_list",filled:!0},{name:"visibility",filled:!0},{name:"error",filled:!0},{name:"equalizer",filled:!0},{name:"release_alert",filled:!0},{name:"mic",filled:!0},{name:"videocam",filled:!0},{name:"call",filled:!0},{name:"chat",filled:!0},{name:"chat_bubble",filled:!0},{name:"email",filled:!0},{name:"link",filled:!0},{name:"report",filled:!0},{name:"flag",filled:!0},{name:"attach_file",filled:!0},{name:"attachment",filled:!0},{name:"attach_money",filled:!0},{name:"bubble_chart",filled:!0},{name:"folder",filled:!0},{name:"business",filled:!0},{name:"device_hub",filled:!0},{name:"flash_on",filled:!0},{name:"image",filled:!0},{name:"lens",filled:!0},{name:"photo_camera",filled:!0},{name:"style",filled:!0},{name:"view_compact",filled:!0},{name:"wb_incandescent",filled:!0},{name:"directions_bus",filled:!0},{name:"directions_car",filled:!0},{name:"flight",filled:!0},{name:"hotel",filled:!0},{name:"local_offer",filled:!0},{name:"restaurant",filled:!0},{name:"restaurant_menu",filled:!0},{name:"local_shipping",filled:!0},{name:"all_inclusive",filled:!0},{name:"business_center",filled:!0},{name:"notifications",filled:!0},{name:"share",filled:!0}];function Ao({name:e,filled:t,className:s}){return a.jsx("span",{className:`material-symbols-outlined ${s??""}`,style:t?{fontVariationSettings:"'FILL' 1"}:void 0,children:e})}const Io=({value:e=null,onChange:s,label:r,noIconLabel:n="SEM ÍCONE"})=>{const[o,i]=t.useState(!1),l=e?(c=e,Eo.find(e=>e.name===c)):null;var c;const u=e=>{s?.(e),i(!1)};return a.jsxs("div",{className:"space-y-2",children:[r&&a.jsx(es,{children:r}),a.jsxs(_r,{open:o,onOpenChange:i,children:[a.jsx(Cr,{asChild:!0,children:a.jsxs(Kt,{variant:"outline",className:"justify-start text-left font-normal gap-2",children:[l?a.jsx(Ao,{name:l.name,filled:l.filled,className:"text-xl text-muted-foreground"}):a.jsx("span",{className:"text-muted-foreground text-sm",children:n}),a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 opacity-50"})]})}),a.jsx(kr,{className:"w-72 p-3",align:"start",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(Ur,{className:"h-64",children:a.jsx("div",{className:"grid grid-cols-7 gap-1",children:Eo.map(t=>a.jsx("button",{type:"button",className:"flex items-center justify-center p-1.5 rounded hover:bg-accent transition-colors "+(e===t.name?"bg-primary/10 text-primary":"text-muted-foreground"),onClick:()=>u(t.name),title:t.name,children:a.jsx(Ao,{name:t.name,filled:t.filled,className:"text-2xl"})},t.name))})}),a.jsx("button",{type:"button",className:"w-full py-2 text-sm font-semibold text-foreground hover:bg-accent rounded transition-colors border-t pt-3",onClick:()=>u(null),children:n})]})})]})]})},Mo=ae.forwardRef(({className:e,...t},s)=>a.jsx(xe.Root,{className:Gt("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",e),...t,ref:s,children:a.jsx(xe.Thumb,{className:Gt("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")})}));Mo.displayName=xe.Root.displayName;const Fo=(e={})=>{const{user:a,alias:t}=Dn(),{enabled:s=!0}=e;return N.useQuery({queryKey:["qualiex-users",t],queryFn:()=>pn.getUsers(t),enabled:s&&!!t&&!!a,staleTime:3e5,retry:2,retryDelay:1e3})},Ro=({value:s,onChange:r,multiple:n=!1,label:o,required:i,placeholder:l,icon:d,maxDisplayedBadges:c,className:u,disabled:m,enabled:p,displayFormat:h="name",customDisplayFn:x,filterFn:f,sortOptions:g=!0,popoverContainer:v,onOpen:b,onClose:y})=>{const{t:w}=j.useTranslation(),{data:N=[],isLoading:_,error:C}=Fo({enabled:p}),k=t.useMemo(()=>f?N.filter(f):N,[N,f]),S=t.useMemo(()=>{const a=s?Array.isArray(s)?s:[s]:[];if(0===a.length)return k;const t=new Set(k.map(e=>e.userId||e.id||"")),r=a.filter(e=>e&&!t.has(e));if(0===r.length)return k;const n=r.map(a=>({userId:a,id:a,userName:e.t("inactive_user"),userEmail:""}));return[...k,...n]},[k,s]),T=t.useCallback(e=>{if("custom"===h&&x)return x(e);const a=e.userName||"";switch(h){case"name-email":return e.userEmail?`${a} (${e.userEmail})`:a;case"name-role":return e.roleName?`${a} - ${e.roleName}`:a;default:return a}},[h,x]);return a.jsx(zr,{multiple:n,value:s??(n?[]:""),onChange:r,options:S,isLoading:_,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:T,placeholder:l||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:w("no_results"),label:o,required:i,icon:d,maxDisplayedBadges:c,disabled:m,className:u,sortOptions:g,popoverContainer:v,onOpen:b,onClose:y})};function Lo({title:e,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:d=!1,usersData:c}){const[u,m]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[h,x]=t.useState(null),f=t.useCallback(e=>{p.current=e,x(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:v,errors:b,updateField:j,handleSubmit:y}=To(g,r,void 0,i),w=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(v):e.disabled||!1})):[],[s,v]),N=t.useMemo(()=>{const e=w.find(e=>e.id===u);if(e&&!e.disabled)return u;const a=w.find(e=>!e.disabled);return a?.id||u},[w,u]);t.useEffect(()=>{N!==u&&m(N)},[N,u]);const _=w.find(e=>e.id===N),C=e=>{const t=(e.computedValue,v[e.name]),s=void 0!==t?t:"",r=b[e.name];switch(e.type){case"group":const t="horizontal"===e.layout,n=t?`flex gap-3 w-full ${e.className||""}`:"space-y-3",o=t?Gt("space-y-2 w-full",e.wrapperClassName):Gt("space-y-2",e.className,e.wrapperClassName);return a.jsxs("div",{className:o,children:[e.label,a.jsx("div",{className:n,children:e.fields?.map(e=>C(e))})]},e.name);case"user-select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Ro,{value:s||"",onChange:a=>j(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-destructive":""}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"textarea":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Xs,{id:e.name,value:s||"",onChange:a=>{j(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,rows:e.rows,maxLength:e.maxLength,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Os,{value:String(s),onValueChange:a=>{j(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[a.jsx(qs,{className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,children:a.jsx(Bs,{placeholder:e.placeholder})}),a.jsx(Hs,{children:e.options?.map(e=>a.jsx(Ys,{value:e.value,children:e.label},e.value))})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"multiselect":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(zr,{options:e.options||[],value:Array.isArray(s)?s:[],onChange:a=>j(e.name,a),placeholder:e.placeholder,disabled:e.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"date":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Jt,{id:e.name,type:"date",value:String(s),onChange:a=>j(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Gt("w-full",r?"border-destructive":"",e.disabled?"bg-muted cursor-not-allowed":"")}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"color":return a.jsxs("div",{children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Jt,{id:e.name,type:"color",value:s||e.defaultValue||"#000000",onChange:a=>j(e.name,a.target.value),className:"h-10"}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return a.jsxs("div",{children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Do,{value:s||e.defaultValue||"#3b82f6",onChange:a=>j(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return a.jsxs("div",{children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Io,{value:s||e.defaultValue||null,onChange:a=>j(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"custom":if(!e.component)return null;const i=e.component,l="function"==typeof e.componentProps?e.componentProps(v):e.componentProps||{};return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(i,{value:s,onChange:a=>{j(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,error:r,popoverContainer:h,...l}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"number":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Jt,{id:e.name,type:"number",value:null!=s?String(s):"",onChange:a=>{const t=a.target.value,s=""===t?null:Number(t);j(e.name,s)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"checkbox":return a.jsxs("div",{className:`flex items-center space-x-2 ${e.className||""}`,children:[a.jsx(Ks,{id:e.name,checked:!!s,onCheckedChange:a=>j(e.name,a),disabled:e.disabled}),a.jsxs(es,{htmlFor:e.name,className:"cursor-pointer",children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"switch":return a.jsxs("div",{className:`flex items-center justify-between space-x-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Mo,{id:e.name,checked:!!s,onCheckedChange:a=>j(e.name,a),disabled:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},e.name);default:return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(es,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Jt,{id:e.name,type:"text",value:s||"",onChange:a=>{j(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name)}},k=t.useCallback(()=>{if(!_)return null;if(_.disabled)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:a.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),a.jsx("p",{className:"text-muted-foreground max-w-sm",children:"Complete as informações obrigatórias na seção i18n.t('ap_general_info') para acessar esta seção."})]});if(_.component){const e=_.component;return a.jsx(e,{formData:v,updateField:j,errors:b,users:c,disabled:_.disabled})}return a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.fields.map(C)})},[_,v,j,b,c,C]),S=a.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[w.length>1&&a.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:a.jsx("div",{className:"flex space-x-2",children:w.map(e=>a.jsx(Kt,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=w.find(a=>a.id===e);a&&!a.disabled&&m(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):a.jsxs("form",{onSubmit:y(n),className:"space-y-3 md:space-y-4",children:[k(),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Kt,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Kt,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return a.jsx(bs,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:a.jsxs(Cs,{ref:f,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[a.jsxs(ks,{showSeparator:!0,children:[a.jsx(Ps,{children:e}),a.jsx(Ds,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function zo({currentPage:e,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:l}=j.useTranslation();if(0===s)return null;const c=(e-1)*r+1,u=Math.min(e*r,s);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[a.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:l("rows_per_page","Linhas por página")}),a.jsxs(Os,{value:String(r),onValueChange:e=>o(Number(e)),children:[a.jsx(qs,{className:"h-8 w-[70px]",children:a.jsx(Bs,{})}),a.jsxs(Hs,{children:[a.jsx(Ys,{value:"10",children:"10"}),a.jsx(Ys,{value:"25",children:"25"}),a.jsx(Ys,{value:"50",children:"50"}),a.jsx(Ys,{value:"100",children:"100"})]})]})]})}),a.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," ",l("of","de")," ",s," ",l("items","itens")]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsLeft,{size:16})}),a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronLeft,{size:16})}),a.jsxs("div",{className:"flex items-center gap-1 px-2",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-sm text-muted-foreground",children:l("of","de")}),a.jsx("span",{className:"text-sm font-medium",children:t})]}),a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronRight,{size:16})}),a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsRight,{size:16})})]})]})}function Uo({manager:e}){return a.jsx(zo,{currentPage:e.pagination.currentPage,totalPages:e.pagination.totalPages,totalItems:e.pagination.totalItems,itemsPerPage:e.pagination.itemsPerPage,onPageChange:e.handlePageChange,onItemsPerPageChange:e.handleItemsPerPageChange,variant:"full"})}const Oo={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Vo={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Bo={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function qo({children:e,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return a.jsx("div",{className:Gt("flex","column"===t?"flex-col":"flex-row",Oo[s],Vo[r],Bo[n],o&&"flex-wrap",i),children:e})}function $o({manager:e,filters:t,inline:s=!1}){const{t:r}=j.useTranslation(),{isSearchVisible:n}=Dn(),o=e.searchTerm,i=a.jsxs(a.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Jt,{placeholder:"Pesquisar",value:e.searchTerm,onChange:a=>e.handleSearch(a.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((e,t)=>a.jsxs(Os,{value:e.value||"",onValueChange:a=>e.onChange?.(a),children:[a.jsx(qs,{className:"w-[180px]",children:a.jsx(Bs,{placeholder:e.placeholder})}),a.jsx(Hs,{children:e.options.map(e=>a.jsx(Ys,{value:e.value,children:e.label},e.value))})]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return a.jsx("div",{className:s?"":"w-full sm:w-auto",children:a.jsx(r,{...e.props})},`custom-${t}`)}),o&&a.jsxs(Kt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[a.jsx(d.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?a.jsx("div",{className:"flex items-center gap-2",children:i}):a.jsx(qo,{direction:"column",gap:"md",className:"mb-6",children:a.jsx(qo,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function Wo({manager:e,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){e&&e.queryKey;const{setSearchVisible:l}=Dn(),[d,c]=_.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[x,f]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,v]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&e){const a=`${e.queryKey}_sortField`,t=`${e.queryKey}_sortDirection`;if(!d.has(a)&&!d.has(t)){const e=Object.fromEntries(d);e[a]=i.column,e[t]=i.direction,c(e)}}},[]);const b=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,j="function"==typeof e?.deleteEntity?e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,y=()=>{f({isOpen:!1,entityId:null,entityName:""})},w=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,N=(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 a.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&a.jsx(jo,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:w,showSearch:s.showSearch,searchValue:e.searchTerm,onSearchChange:e.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:e.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{v({isOpen:!0,count:e.selectedIds.length})},onClearSelection:e.clearSelection,customActions:N,filters:s.filters&&s.filters.length>0?a.jsx($o,{manager:e,filters:s.filters,inline:!0}):void 0}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?a.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(e.entities,e)}):a.jsx(So,{manager:e,columns:s.columns,onEdit:b,onDelete:j,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions,enableColumnManager:!0,columnManagerStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-columns`,resizeStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-resize`,defaultHiddenColumns:s.defaultHiddenColumns})}),a.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:a.jsx(Uo,{manager:e})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&a.jsx(Lo,{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:e.isLoading,submitButtonText:p?"Atualizar":"Criar"}),a.jsx(bs,{open:x.isOpen,onOpenChange:y,children:a.jsxs(Cs,{size:"sm",variant:"destructive",children:[a.jsx(ks,{showSeparator:!0,children:a.jsx(Ps,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:x.entityName}),". Esta ação não pode ser desfeita."]})}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"outline",onClick:y,children:"Cancelar"}),a.jsx(Kt,{variant:"destructive",onClick:()=>{x.entityId&&"function"==typeof e?.deleteEntity&&(e.deleteEntity(x.entityId),f({isOpen:!1,entityId:null,entityName:""}))},disabled:e.isDeleting,children:e.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),a.jsx(bs,{open:g.isOpen,onOpenChange:()=>v({isOpen:!1,count:0}),children:a.jsxs(Cs,{size:"sm",variant:"destructive",children:[a.jsx(ks,{showSeparator:!0,children:a.jsx(Ps,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"outline",onClick:()=>v({isOpen:!1,count:0}),children:"Cancelar"}),a.jsx(Kt,{variant:"destructive",onClick:()=>{e.bulkDelete?.(e.selectedIds),v({isOpen:!1,count:0})},disabled:e.isBulkDeleting,children:e.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Ho(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 Go(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Yo(e={}){const{paramName:a="alias"}=e,s=_.useParams(),{alias:r,companies:n}=Dn(),o=s[a]||null;return t.useMemo(()=>{if(!o)return{urlAlias:null,isAliasMismatch:!1,isValidAlias:!1,isMissing:!0,matchedCompany:null};const e=n?.find(e=>e.alias===o)||null,a=!!e;return{urlAlias:o,isAliasMismatch:a&&o!==r,isValidAlias:a,isMissing:!1,matchedCompany:e}},[o,r,n])}const Qo=r.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"}}),Ko={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},Xo=ae.forwardRef(({className:e,variant:t="info",showIcon:s=!0,children:r,...n},o)=>{const i=Ko[t||"info"];return a.jsxs("div",{ref:o,role:"alert",className:Gt(Qo({variant:t}),e),...n,children:[s&&a.jsx(i,{className:"h-4 w-4"}),r]})});Xo.displayName="Alert";const Jo=ae.forwardRef(({className:e,...t},s)=>a.jsx("h5",{ref:s,className:Gt("mb-1 font-medium leading-none tracking-tight",e),...t}));Jo.displayName="AlertTitle";const Zo=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("text-sm [&_p]:leading-relaxed",e),...t}));Zo.displayName="AlertDescription";const ei=t.createContext(void 0);function ai({children:e,actions:s}){const{t:r}=j.useTranslation(),[n,o]=t.useState({}),[i,l]=t.useState(s);t.useEffect(()=>{l(s)},[s]);const d=t.useCallback(()=>o({}),[]),c=t.useMemo(()=>({metadata:n,setMetadata:o,clearMetadata:d,headerActions:i,setHeaderActions:l}),[n,d,i]);return a.jsx(ei.Provider,{value:c,children:e})}function ti(){const e=t.useContext(ei);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var si={actions:"Ações",activate:"Ativar",add_first_item:"Adicione seu primeiro item para começar",add_item:"Adicionar Item",advanced_filter:"Filtro avançado",all:"Todos",allow:"Permitir",allowed_items:"Itens permitidos",also_discover:"Conheça também",alt_text:"Texto Alternativo",anonymous:"Anônimo",ap_action_plan:"Plano de Ação",ap_action_type:"Tipo de Ação",ap_add:"Adicionar",ap_add_comment_placeholder:"Adicionar comentário...",ap_add_cost:"Adicionar custo",ap_add_predecessor:"Adicionar predecessor",ap_attachments:"Anexos",ap_belongs_to:"Pertence a",ap_cause:"Causa",ap_change_status:"Alterar Status",ap_checker:"Verificador",ap_clear:"Limpar",ap_comments:"Comentários",ap_cost_description:"Descrição do custo",ap_costs:"Custos",ap_delete:"Excluir",ap_description:"Descrição",ap_description_placeholder:"Descreva o plano de ação",ap_duration_days:"Duração (dias)",ap_edit_progress:"Editar Progresso",ap_end_date:"Data de Término",ap_estimated_cost:"Custo Estimado",ap_file_duplicate:"Arquivo duplicado",ap_file_upload_error:"Erro ao enviar arquivo",ap_general:"Geral",ap_general_info:"Informações Gerais",ap_history:"Histórico",ap_justification:"Justificativa",ap_justification_placeholder:"Justificativa do plano de ação",ap_name:"Nome",ap_new_action:"Nova Ação",ap_no_attachments:"Nenhum anexo",ap_no_comments:"Nenhum comentário",ap_no_costs:"Nenhum custo registrado",ap_no_history:"Nenhum registro no histórico",ap_no_predecessors:"Nenhum predecessor adicionado",ap_no_progress:"Sem dados de progresso disponíveis",ap_overall_progress:"Progresso geral",ap_place:"Local",ap_plan_name_placeholder:"Nome do plano de ação",ap_predecessors:"Predecessores",ap_priority:"Prioridade",ap_priority_high:"Alta",ap_priority_low:"Baixa",ap_priority_medium:"Média",ap_progress:"Progresso",ap_progress_comment_placeholder:"Adicione um comentário sobre o progresso",ap_progress_percent:"Progresso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progresso",ap_reporting:"Reportando...",ap_reports_history:"Histórico de reportes",ap_responsible:"Responsável",ap_select_action:"Selecione uma ação",ap_select_cause:"Selecione a causa",ap_select_checker:"Selecione o verificador",ap_select_date:"Selecione a data",ap_select_parent:"Selecione a ação pai",ap_select_place:"Selecione o local",ap_select_priority:"Selecione a prioridade",ap_select_responsible:"Selecione o responsável",ap_select_type:"Selecione o tipo",ap_start_date:"Data de Início",ap_status_canceled:"Cancelada",ap_status_done:"Concluída",ap_status_effectiveness_check:"Verificação de eficácia",ap_status_running:"Em andamento",ap_status_suspended:"Suspensa",ap_status_waiting_start:"Aguardando início",ap_time_label:"Tempo",ap_time_spent:"Tempo gasto (HH:MM)",ap_total_cost:"Custo total realizado",ap_total_time:"Tempo total",ap_type_corrective:"Corretiva",ap_type_immediate:"Imediata",ap_type_improvement:"Oportunidade de Melhoria",ap_type_preventive:"Preventiva",ap_type_standardization:"Padronização",ap_value:"Valor (R$)",ap_via_app:"Via app",approval_approve:"Aprovar",approval_execute_action:"Executar ação",approval_opinion:"Parecer *",approval_read_less:"Ler menos",approval_read_more:"Ler mais",approval_reprove_radio:"Reprovar e retornar para etapa",approval_search_approver:"Buscar aprovador...",approval_select_approver:"Selecionar aprovador",approval_select_approver_placeholder:"Selecione um aprovador...",approval_select_step:"Selecione a etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuários",audit_description:"Descrição",audit_esign:"Assinatura eletrônica",audit_not_informed:"Não informado",audit_references:"Referências",audit_security:"Segurança",audit_trail:"Trilha de Auditoria",auth_error:"Erro durante a autenticação. Tente novamente.",auth_failed:"Falha na autenticação. Tente novamente.",auto_login:"Fazendo login automático...",back:"Voltar",bulk_delete_error:"Erro ao excluir itens em lote",bulk_delete_success:"Itens excluídos com sucesso",cancel:"Cancelar",change_photo:"Trocar foto",cannot_be_own_leader:"Um líder não pode ser seu próprio superior",clear_filters:"Limpar filtros",clear_formatting:"Limpar Formatação",clear_search:"Limpar busca",clear_selection:"Limpar seleção",close:"Fechar",collapse_row:"Recolher linha",columns:"Colunas",conclude:"Concluir",confirm_removal:"Confirmar remoção",could_not_load_info:"Não foi possível carregar as informações",current:"Atual",custom_color:"Cor personalizada",dashboard_advanced_filter:"Filtro avançado",dashboard_all_access:"Todos os colaboradores terão acesso",dashboard_average:"Média",dashboard_code:"Código",dashboard_distinct_count:"Contagem distinta",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Sair do fullscreen",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabela",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Meus dashboards",dashboard_new:"Novo Dashboard",dashboard_no_data:"A consulta não retornou itens para o seu perfil.",dashboard_no_refresh:"Não atualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"Não compartilhado",dashboard_only_mine:"Somente meus",dashboard_only_overdue:"Somente atrasados",dashboard_only_responsible:"Somente o responsável terá acesso",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remover favorito",dashboard_responsible:"Responsável",dashboard_select_groups:"Selecione grupos, locais e colaboradores específicos",dashboard_shared_unit:"Compartilhado com todos os colaboradores da unidade",dashboard_status:"Situação",dashboard_title:"Título",dashboard_wait_refresh:"Aguarde para atualizar novamente",dashboard_work_done:"Trabalho executado",dashboard_work_planned:"Trabalho planejado",deactivate:"Inativar",deselect_all:"Deselecionar todas",dev_login:"Login Desenvolvimento",download:"Download",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nome",electronic_signature:"Assinatura Eletrônica",embed_code:"Código embed",embedded_content:"Embedded content",enter_code:"Digite o código",enter_password:"Digite sua senha",error_authentication:"Erro de Autenticação",error_connection:"Erro de Conexão",error_copied_clipboard:"Os detalhes do erro foram copiados para a área de transferência.",error_loading:"Erro ao carregar",error_loading_data:"Erro ao carregar dados",error_session_expired:"Sessão Expirada",error_token_expired:"Token de autenticação expirado. Faça login novamente.",esign_code_description:"Um código de verificação foi enviado para o seu e-mail. Insira o código abaixo para confirmar a operação.",esign_code_error:"Erro ao validar o código. Tente novamente.",esign_invalid_code:"Código inválido. Tente novamente.",esign_invalid_password:"Senha incorreta. Tente novamente.",esign_password_description:"Digite sua senha para confirmar a operação.",esign_password_error:"Erro ao validar a senha. Tente novamente.",esign_resend_error:"Erro ao reenviar o código.",expand_row:"Expandir linha",expiration_date:"Data de expiração",file_error:"Erro no arquivo",file_upload:"Upload de arquivo",go_to_next_page:"Ir para próxima página",go_to_previous_page:"Ir para página anterior",group_by_column:"Agrupar por esta coluna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descrição da imagem",import_flows:"Fluxos de Importação",import_manage:"Gerencie seus fluxos de importação",inactive_user:"[Usuário inativo]",input_type:"Tipo de entrada",invalid_form:"Formulário inválido. Preencha todos os campos obrigatórios.",italic:"Itálico",item_details:"Detalhes do item",items:"itens",items_per_page:"Itens por página",know_saber_gestao:"Conheça o Saber Gestão",know_staff:"Conheça Staff",language:"Idioma",last_update:"Última atualização",leader:"Líder",leader_create_error:"Erro ao criar líder",leader_not_found:"Líder não encontrado",leader_promoted_success:"Líder promovido com sucesso",leader_remove_error:"Erro ao remover líder",leader_removed_success:"Líder removido com sucesso",leader_update_error:"Erro ao atualizar líder",leader_updated_success:"Líder atualizado com sucesso",leadership_add_root:"Adicionar Líder Raiz",leadership_add_subordinate:"Adicionar Liderado",leadership_cycle_error:"Esta associação criaria um ciclo na hierarquia",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Imediato",leadership_make_root:"Tornar Líder Raiz",leadership_make_root_short:"Tornar Raiz",leadership_no_hierarchy:"Nenhuma hierarquia de liderança encontrada.",leadership_no_members:"Nenhum membro na equipe",leadership_no_user_selected:"Nenhum usuário selecionado",leadership_no_users_available:"Nenhum usuário disponível",leadership_no_users_found:"Nenhum usuário encontrado",leadership_remove_team:"Remover da equipe",leadership_select_subordinates:"Selecione pelo menos um liderado",learn_qualiex:"Aprenda a usar o Qualiex",leave_without_saving:"Sair sem salvar",lines_per_page:"Linhas por página",link:"Link",login_with_qualiex:"Entrar com Qualiex",manage_access:"Gerenciar Acessos",modules:"Módulos",more_options:"Mais opções",msg_create_error:"Erro ao criar registro",msg_created_success:"Registro criado com sucesso",msg_delete_error:"Erro ao excluir registro",msg_deleted_success:"Registro excluído com sucesso",msg_load_error:"Erro ao carregar dados",msg_update_error:"Erro ao atualizar registro",msg_updated_success:"Registro atualizado com sucesso",new_document:"Novo Documento",new_folder:"Nova Pasta",new_item:"Novo Item",next:"Próximo",no_access_page:"Parece que você não tem acesso a essa página",no_data_to_display:"Não há dados para exibir no momento.",no_errors_recorded:"Nenhum erro registrado",no_image_selected:"Nenhuma imagem selecionada",no_item_selected:"Nenhum item selecionado",no_items_found:"Nenhum item encontrado",no_items_found_empty:"Nenhum item encontrado",no_place_found:"Nenhum local encontrado",no_place_selected:"Sem local",no_products:"Sem produtos",no_reports_found:"Nenhum relatório encontrado",no_results:"Nenhum resultado encontrado",no_search_results:"Nenhum resultado para a busca",no_video_selected:"Nenhum vídeo selecionado",not_authenticated:"Não autenticado",not_available:"Não disponível",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Cole o código embed aqui",permissions:"Permissões",preset_colors:"Cores predefinidas",preview:"Visualizar",redirecting_auth:"Redirecionando para autenticação...",refresh_data:"Atualizar dados",remove:"Remover",remove_grouping:"Remover agrupamento",replace:"Substituir",report:"Relatório",request_date:"Data da solicitação",required_field:"Campo obrigatório",resend_code:"Reenviar código",restricted_access:"Acesso restrito",rows_per_page:"Registros por página",save:"Salvar",save_as_draft:"Salvar como Rascunho",save_as_template:"Salvar como Modelo",saving:"Salvando...",search:"Pesquisar",search_placeholder:"Pesquisar...",search_report_placeholder:"Buscar relatório...",search_user_placeholder:"Buscar usuário...",select_all:"Selecionar todos",select_all_columns:"Selecionar todas",select_all_items:"Selecionar todos",select_at_least_one:"Selecione pelo menos um item",select_at_least_one_item:"Selecione ao menos um item",select_date:"Selecione uma data",select_file_format:"Selecione o formato do arquivo",select_items_to_add:"Selecione itens para adicionar...",select_placeholder:"Selecione...",selected:"Selecionados",session_expired:"Sua sessão expirou. Você será redirecionado para fazer login novamente.",sign_access_error:"Erro ao acessar serviço de assinatura",sign_api_key_info:"Informe a API Key do provedor de assinatura",sign_api_key_input:"Insira a API Key do provedor de assinatura",sign_api_key_placeholder:"Insira a chave de API",sign_api_key_required:"Chave de API obrigatória",sign_attempt:"Tentativa de assinatura",sign_auth_required:"Autenticação necessária para assinar",sign_click_to_select:"Clique para selecionar documento",sign_config_save_err:"Erro ao salvar configuração de assinatura",sign_config_save_error:"Erro ao salvar configuração de assinatura",sign_config_saved:"Configuração de assinatura salva",sign_config_saved_success:"Configuração de assinatura salva com sucesso",sign_configured:"Assinatura configurada",sign_configured_unit:"Assinatura digital configurada para esta unidade",sign_digital_config:"Configuração de Assinatura Digital",sign_doc_available:"Documento assinado disponível para download",sign_doc_load_error:"Erro ao carregar documento",sign_doc_process_error:"Erro ao processar documento",sign_doc_sent:"Documento enviado para assinatura",sign_download_signed:"Baixar documento assinado",sign_email_fallback:"E-mail de fallback para assinatura",sign_environment:"Ambiente de assinatura",sign_fetch_failed:"Falha ao buscar documento assinado",sign_file_not_allowed:"Extensão de arquivo não permitida",sign_file_type_not_allowed:"Tipo de arquivo não permitido",sign_incorrect_data:"O signatário reportou dados incorretos.",sign_login_required:"Login necessário para assinar",sign_login_to_sign:"Faça login para utilizar a assinatura digital.",sign_monthly_limit:"Limite mensal de assinaturas atingido",sign_no_access:"Não foi possível obter o acesso para assinatura. Tente novamente.",sign_not_configured:"Assinatura não configurada",sign_not_configured_unit:"Assinatura digital ainda não configurada para esta unidade",sign_preparing_doc:"Preparando documento para assinatura",sign_process_error:"Erro ao processar assinatura",sign_save_config:"Salvar configuração",sign_save_config_btn:"Salvar Configuração",sign_select_pdf:"Selecione um arquivo PDF",sign_sending_doc:"Enviando documento para assinatura",sign_signed_success:"Documento assinado com sucesso",sign_signer_unavailable:"Signer ID não disponível",sign_try_again:"Tentar novamente",sign_update_config:"Atualizar configuração",sign_update_config_btn:"Atualizar Configuração",sign_waiting_provider:"Aguardando provedor de assinatura",sign_widget_error:"Erro no widget de assinatura",something_went_wrong:"Algo deu errado",state:"Estado",status:"Status",status_completed:"Concluído",status_error:"Erro",status_expired:"Expirado",status_processing:"Processando",status_waiting:"Aguardando",steps:"Etapas",subordinates_add_error:"Erro ao adicionar subordinados",subordinates_added_success:"Subordinados adicionados com sucesso",subordinates_sync_error:"Erro ao sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados com sucesso",team_all_groups:"Todos os grupos",terms_confirm_reading:"Confirmar leitura",terms_confirmation_available:"Confirmação disponível em",terms_of_use:"Termos de Uso",terms_read_agree:"Li e concordo",terms_see_later:"Ver depois",terms_updated:"Termos de Uso Atualizados",terms_view:"Visualizar termo de uso",terms_view_short:"View term",try_adjust_search:"Tente ajustar sua busca",try_again:"Tentar Novamente",unit_not_selected:"Nenhuma unidade selecionada",unknown_error:"Erro desconhecido",unsaved_changes:"Alterações não salvas",unsaved_changes_description:"Existem alterações não salvas. Deseja sair sem salvar?",updates:"Atualizações",user:"Usuário",user_info:"Informações do Usuário",user_photo:"Foto do usuário",users_already_leaders:"Usuários já são líderes",verification_code:"Código de verificação",video:"Vídeo",video_title:"Título do vídeo",view_report:"Visualizar relatório",want_to_know_more:"Quero conhecer mais",write_content_here:"Escreva o conteúdo aqui..."},ri={actions:"Actions",activate:"Activate",add_first_item:"Add your first item to get started",add_item:"Add Item",advanced_filter:"Advanced filter",all:"All",allow:"Allow",allowed_items:"Allowed items",also_discover:"Also discover",alt_text:"Alternative Text",anonymous:"Anonymous",ap_action_plan:"Action Plan",ap_action_type:"Action type",ap_add:"Add",ap_add_comment_placeholder:"Add a comment...",ap_add_cost:"Add cost",ap_add_predecessor:"Add predecessor",ap_attachments:"Attachments",ap_belongs_to:"Belongs to",ap_cause:"Cause",ap_change_status:"Change Status",ap_checker:"Checker",ap_clear:"Clear",ap_comments:"Comments",ap_cost_description:"Cost description",ap_costs:"Costs",ap_delete:"Delete",ap_description:"Description",ap_description_placeholder:"Describe the action plan",ap_duration_days:"Duration (days)",ap_edit_progress:"Edit Progress",ap_end_date:"End date",ap_estimated_cost:"Estimated cost",ap_file_duplicate:"Duplicate file",ap_file_upload_error:"Error uploading file",ap_general:"General",ap_general_info:"General Information",ap_history:"History",ap_justification:"Justification",ap_justification_placeholder:"Action plan justification",ap_name:"Name",ap_new_action:"New Action",ap_no_attachments:"No attachments",ap_no_comments:"No comments",ap_no_costs:"No costs recorded",ap_no_history:"No history records",ap_no_predecessors:"No predecessors added",ap_no_progress:"No progress data available",ap_overall_progress:"Overall progress",ap_place:"Place",ap_plan_name_placeholder:"Action plan name",ap_predecessors:"Predecessors",ap_priority:"Priority",ap_priority_high:"High",ap_priority_low:"Low",ap_priority_medium:"Medium",ap_progress:"Progress",ap_progress_comment_placeholder:"Add a comment about the progress",ap_progress_percent:"Progress (%)",ap_report:"Report",ap_report_progress:"Report progress",ap_reporting:"Reporting...",ap_reports_history:"Reports history",ap_responsible:"Responsible",ap_select_action:"Select an action",ap_select_cause:"Select cause",ap_select_checker:"Select checker",ap_select_date:"Select date",ap_select_parent:"Select parent action",ap_select_place:"Select place",ap_select_priority:"Select priority",ap_select_responsible:"Select responsible",ap_select_type:"Select type",ap_start_date:"Start date",ap_status_canceled:"Canceled",ap_status_done:"Completed",ap_status_effectiveness_check:"Effectiveness check",ap_status_running:"In progress",ap_status_suspended:"Suspended",ap_status_waiting_start:"Waiting to start",ap_time_label:"Time",ap_time_spent:"Time spent (HH:MM)",ap_total_cost:"Total realized cost",ap_total_time:"Total time",ap_type_corrective:"Corrective",ap_type_immediate:"Immediate",ap_type_improvement:"Improvement Opportunity",ap_type_preventive:"Preventive",ap_type_standardization:"Standardization",ap_value:"Value",ap_via_app:"Via app",approval_approve:"Approve",approval_execute_action:"Execute action",approval_opinion:"Opinion *",approval_read_less:"Read less",approval_read_more:"Read more",approval_reprove_radio:"Reject and return to step",approval_search_approver:"Search approver...",approval_select_approver:"Select approver",approval_select_approver_placeholder:"Select an approver...",approval_select_step:"Select the step",approval_step_label:"Step",approval_user_group:"User group",audit_description:"Description",audit_esign:"Electronic signature",audit_not_informed:"Not informed",audit_references:"References",audit_security:"Security",audit_trail:"Audit Trail",auth_error:"Error during authentication. Try again.",auth_failed:"Authentication failed. Try again.",auto_login:"Logging in automatically...",back:"Back",bulk_delete_error:"Error deleting items in bulk",bulk_delete_success:"Items deleted successfully",cancel:"Cancel",change_photo:"Change photo",cannot_be_own_leader:"A leader cannot be their own superior",clear_filters:"Clear filters",clear_formatting:"Clear Formatting",clear_search:"Clear search",clear_selection:"Clear selection",close:"Close",collapse_row:"Collapse row",columns:"Columns",conclude:"Finish",confirm_removal:"Confirm removal",could_not_load_info:"Could not load the information",current:"Current",custom_color:"Custom color",dashboard_advanced_filter:"Advanced filter",dashboard_all_access:"All collaborators will have access",dashboard_average:"Average",dashboard_code:"Code",dashboard_distinct_count:"Distinct count",dashboard_edit:"Edit Dashboard",dashboard_exit_fullscreen:"Exit fullscreen",dashboard_export_chart:"Export chart",dashboard_export_table:"Export table",dashboard_max_value:"Maximum value",dashboard_min_value:"Minimum value",dashboard_my:"My dashboards",dashboard_new:"New Dashboard",dashboard_no_data:"The query returned no items for your profile.",dashboard_no_refresh:"Do not refresh",dashboard_normal_page:"Normal page",dashboard_not_shared:"Not shared",dashboard_only_mine:"Only mine",dashboard_only_overdue:"Only overdue",dashboard_only_responsible:"Only the responsible will have access",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remove favorite",dashboard_responsible:"Responsible",dashboard_select_groups:"Select groups, places and specific collaborators",dashboard_shared_unit:"Shared with all unit collaborators",dashboard_status:"Status",dashboard_title:"Title",dashboard_wait_refresh:"Wait to refresh again",dashboard_work_done:"Work done",dashboard_work_planned:"Work planned",deactivate:"Deactivate",deselect_all:"Deselect all",dev_login:"Development Login",download:"Download",edit:"Edit",edit_profile:"Edit Profile",edit_name:"Edit Name",electronic_signature:"Electronic Signature",embed_code:"Embed code",embedded_content:"Embedded content",enter_code:"Enter the code",enter_password:"Enter your password",error_authentication:"Authentication Error",error_connection:"Connection Error",error_copied_clipboard:"Error details were copied to the clipboard.",error_loading:"Error loading",error_loading_data:"Error loading data",error_session_expired:"Session Expired",error_token_expired:"Authentication token expired. Please log in again.",esign_code_description:"A verification code was sent to your email. Enter the code below to confirm the operation.",esign_code_error:"Error validating code. Try again.",esign_invalid_code:"Invalid code. Try again.",esign_invalid_password:"Incorrect password. Try again.",esign_password_description:"Enter your password to confirm the operation.",esign_password_error:"Error validating password. Try again.",esign_resend_error:"Error resending code.",expand_row:"Expand row",expiration_date:"Expiration date",file_error:"File error",file_upload:"File upload",go_to_next_page:"Go to next page",go_to_previous_page:"Go to previous page",group_by_column:"Group by this column",heading_1:"Heading 1",heading_2:"Heading 2",heading_3:"Heading 3",image_description:"Image description",import_flows:"Import Flows",import_manage:"Manage your import flows",inactive_user:"[Inactive user]",input_type:"Input type",invalid_form:"Invalid form. Fill in all required fields.",italic:"Italic",item_details:"Item details",items:"items",items_per_page:"Items per page",know_saber_gestao:"Discover Saber Gestão",know_staff:"Discover Staff",language:"Language",last_update:"Last update",leader:"Leader",leader_create_error:"Error creating leader",leader_not_found:"Leader not found",leader_promoted_success:"Leader promoted successfully",leader_remove_error:"Error removing leader",leader_removed_success:"Leader removed successfully",leader_update_error:"Error updating leader",leader_updated_success:"Leader updated successfully",leadership_add_root:"Add Root Leader",leadership_add_subordinate:"Add Subordinate",leadership_cycle_error:"This association would create a cycle in the hierarchy",leadership_define_leader:"Define Leader",leadership_immediate_superior:"Immediate Superior",leadership_make_root:"Make Root Leader",leadership_make_root_short:"Make Root",leadership_no_hierarchy:"No leadership hierarchy found.",leadership_no_members:"No team members",leadership_no_user_selected:"No user selected",leadership_no_users_available:"No users available",leadership_no_users_found:"No users found",leadership_remove_team:"Remove from team",leadership_select_subordinates:"Select at least one subordinate",learn_qualiex:"Learn how to use Qualiex",leave_without_saving:"Leave without saving",lines_per_page:"Lines per page",link:"Link",login_with_qualiex:"Login with Qualiex",manage_access:"Manage Access",modules:"Modules",more_options:"More options",msg_create_error:"Error creating record",msg_created_success:"Record created successfully",msg_delete_error:"Error deleting record",msg_deleted_success:"Record deleted successfully",msg_load_error:"Error loading data",msg_update_error:"Error updating record",msg_updated_success:"Record updated successfully",new_document:"New Document",new_folder:"New Folder",new_item:"New Item",next:"Next",no_access_page:"It seems you don't have access to this page",no_data_to_display:"No data to display at this time.",no_errors_recorded:"No errors recorded",no_image_selected:"No image selected",no_item_selected:"No item selected",no_items_found:"No items found",no_items_found_empty:"No items found",no_place_found:"No place found",no_place_selected:"No place",no_products:"No products",no_reports_found:"No reports found",no_results:"No results found",no_search_results:"No results for the search",no_video_selected:"No video selected",not_authenticated:"Not authenticated",not_available:"Not available",of:"of",open_popover:"Open Popover",open_wiki:"Open Wiki",ordered_list:"Ordered List",page:"Page",paste_embed_code:"Paste the embed code here",permissions:"Permissions",preset_colors:"Preset colors",preview:"Preview",redirecting_auth:"Redirecting to authentication...",refresh_data:"Refresh data",remove:"Remove",remove_grouping:"Remove grouping",replace:"Replace",report:"Report",request_date:"Request date",required_field:"Required field",resend_code:"Resend code",restricted_access:"Restricted access",rows_per_page:"Rows per page",save:"Save",save_as_draft:"Save as Draft",save_as_template:"Save as Template",saving:"Saving...",search:"Search",search_placeholder:"Search...",search_report_placeholder:"Search report...",search_user_placeholder:"Search user...",select_all:"Select all",select_all_columns:"Select all",select_all_items:"Select all",select_at_least_one:"Select at least one item",select_at_least_one_item:"Select at least one item",select_date:"Select a date",select_file_format:"Select the file format",select_items_to_add:"Select items to add...",select_placeholder:"Select...",selected:"Selected",session_expired:"Your session has expired. You will be redirected to log in again.",sign_access_error:"Error accessing signature service",sign_api_key_info:"Enter the signature provider API Key",sign_api_key_input:"Enter the signature provider API Key",sign_api_key_placeholder:"Enter API key",sign_api_key_required:"API key is required",sign_attempt:"Signature attempt",sign_auth_required:"Authentication required to sign",sign_click_to_select:"Click to select document",sign_config_save_err:"Error saving signature configuration",sign_config_save_error:"Error saving signature configuration",sign_config_saved:"Signature configuration saved",sign_config_saved_success:"Signature configuration saved successfully",sign_configured:"Signature configured",sign_configured_unit:"Digital signature configured for this unit",sign_digital_config:"Digital Signature Configuration",sign_doc_available:"Signed document available for download",sign_doc_load_error:"Error loading document",sign_doc_process_error:"Error processing document",sign_doc_sent:"Document sent for signature",sign_download_signed:"Download signed document",sign_email_fallback:"Signature fallback email",sign_environment:"Signature environment",sign_fetch_failed:"Failed to fetch signed document",sign_file_not_allowed:"File extension not allowed",sign_file_type_not_allowed:"File type not allowed",sign_incorrect_data:"The signer reported incorrect data.",sign_login_required:"Login required to sign",sign_login_to_sign:"Log in to use the digital signature.",sign_monthly_limit:"Monthly signature limit reached",sign_no_access:"Could not obtain access for signing. Try again.",sign_not_configured:"Signature not configured",sign_not_configured_unit:"Digital signature not yet configured for this unit",sign_preparing_doc:"Preparing document for signature",sign_process_error:"Error processing signature",sign_save_config:"Save configuration",sign_save_config_btn:"Save Configuration",sign_select_pdf:"Select a PDF file",sign_sending_doc:"Sending document for signature",sign_signed_success:"Document signed successfully",sign_signer_unavailable:"Signer ID not available",sign_try_again:"Try again",sign_update_config:"Update configuration",sign_update_config_btn:"Update Configuration",sign_waiting_provider:"Waiting for signature provider",sign_widget_error:"Signature widget error",something_went_wrong:"Something went wrong",state:"State",status:"Status",status_completed:"Completed",status_error:"Error",status_expired:"Expired",status_processing:"Processing",status_waiting:"Waiting",steps:"Steps",subordinates_add_error:"Error adding subordinates",subordinates_added_success:"Subordinates added successfully",subordinates_sync_error:"Error syncing subordinates",subordinates_synced_success:"Subordinates synced successfully",team_all_groups:"All groups",terms_confirm_reading:"Confirm reading",terms_confirmation_available:"Confirmation available at",terms_of_use:"Terms of Use",terms_read_agree:"I have read and agree",terms_see_later:"See later",terms_updated:"Terms of Use Updated",terms_view:"View terms of use",terms_view_short:"View term",try_adjust_search:"Try adjusting your search",try_again:"Try Again",unit_not_selected:"No unit selected",unknown_error:"Unknown error",unsaved_changes:"Unsaved changes",unsaved_changes_description:"There are unsaved changes. Do you want to leave without saving?",updates:"Updates",user:"User",user_info:"User Information",user_photo:"User photo",users_already_leaders:"Users are already leaders",verification_code:"Verification code",video:"Video",video_title:"Video title",view_report:"View report",want_to_know_more:"I want to know more",write_content_here:"Write content here..."},ni={actions:"Acciones",activate:"Activar",add_first_item:"Agregue su primer elemento para comenzar",add_item:"Agregar Elemento",advanced_filter:"Filtro avanzado",all:"Todos",allow:"Permitir",allowed_items:"Elementos permitidos",also_discover:"Conozca también",alt_text:"Texto Alternativo",anonymous:"Anónimo",ap_action_plan:"Plan de Acción",ap_action_type:"Tipo de acción",ap_add:"Agregar",ap_add_comment_placeholder:"Agregar comentario...",ap_add_cost:"Agregar costo",ap_add_predecessor:"Agregar predecesor",ap_attachments:"Anexos",ap_belongs_to:"Pertenece a",ap_cause:"Causa",ap_change_status:"Cambiar Estado",ap_checker:"Verificador",ap_clear:"Limpiar",ap_comments:"Comentarios",ap_cost_description:"Descripción del costo",ap_costs:"Costos",ap_delete:"Eliminar",ap_description:"Descripción",ap_description_placeholder:"Describa el plan de acción",ap_duration_days:"Duración (días)",ap_edit_progress:"Editar Progreso",ap_end_date:"Fecha de finalización",ap_estimated_cost:"Costo estimado",ap_file_duplicate:"Archivo duplicado",ap_file_upload_error:"Error al subir archivo",ap_general:"General",ap_general_info:"Información General",ap_history:"Historial",ap_justification:"Justificación",ap_justification_placeholder:"Justificación del plan de acción",ap_name:"Nombre",ap_new_action:"Nueva Acción",ap_no_attachments:"Sin anexos",ap_no_comments:"Sin comentarios",ap_no_costs:"Ningún costo registrado",ap_no_history:"Sin registros en el historial",ap_no_predecessors:"Sin predecesores agregados",ap_no_progress:"Sin datos de progreso disponibles",ap_overall_progress:"Progreso general",ap_place:"Lugar",ap_plan_name_placeholder:"Nombre del plan de acción",ap_predecessors:"Predecesores",ap_priority:"Prioridad",ap_priority_high:"Alta",ap_priority_low:"Baja",ap_priority_medium:"Media",ap_progress:"Progreso",ap_progress_comment_placeholder:"Agregue un comentario sobre el progreso",ap_progress_percent:"Progreso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progreso",ap_reporting:"Reportando...",ap_reports_history:"Historial de reportes",ap_responsible:"Responsable",ap_select_action:"Seleccione una acción",ap_select_cause:"Seleccione la causa",ap_select_checker:"Seleccione el verificador",ap_select_date:"Seleccione la fecha",ap_select_parent:"Seleccione la acción padre",ap_select_place:"Seleccione el lugar",ap_select_priority:"Seleccione la prioridad",ap_select_responsible:"Seleccione el responsable",ap_select_type:"Seleccione el tipo",ap_start_date:"Fecha de inicio",ap_status_canceled:"Cancelada",ap_status_done:"Completada",ap_status_effectiveness_check:"Verificación de eficacia",ap_status_running:"En progreso",ap_status_suspended:"Suspendida",ap_status_waiting_start:"Esperando inicio",ap_time_label:"Tiempo",ap_time_spent:"Tiempo dedicado (HH:MM)",ap_total_cost:"Costo total realizado",ap_total_time:"Tiempo total",ap_type_corrective:"Correctiva",ap_type_immediate:"Inmediata",ap_type_improvement:"Oportunidad de Mejora",ap_type_preventive:"Preventiva",ap_type_standardization:"Estandarización",ap_value:"Valor",ap_via_app:"Vía app",approval_approve:"Aprobar",approval_execute_action:"Ejecutar acción",approval_opinion:"Opinión *",approval_read_less:"Leer menos",approval_read_more:"Leer más",approval_reprove_radio:"Rechazar y retornar a etapa",approval_search_approver:"Buscar aprobador...",approval_select_approver:"Seleccionar aprobador",approval_select_approver_placeholder:"Seleccione un aprobador...",approval_select_step:"Seleccione la etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuarios",audit_description:"Descripción",audit_esign:"Firma electrónica",audit_not_informed:"No informado",audit_references:"Referencias",audit_security:"Seguridad",audit_trail:"Pista de Auditoría",auth_error:"Error durante la autenticación. Intente de nuevo.",auth_failed:"Fallo en la autenticación. Intente de nuevo.",auto_login:"Iniciando sesión automáticamente...",back:"Volver",bulk_delete_error:"Error al eliminar elementos en lote",bulk_delete_success:"Elementos eliminados exitosamente",cancel:"Cancelar",change_photo:"Cambiar foto",cannot_be_own_leader:"Un líder no puede ser su propio superior",clear_filters:"Limpiar filtros",clear_formatting:"Limpiar Formato",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",close:"Cerrar",collapse_row:"Contraer fila",columns:"Columnas",conclude:"Concluir",confirm_removal:"Confirmar eliminación",could_not_load_info:"No se pudo cargar la información",current:"Actual",custom_color:"Color personalizado",dashboard_advanced_filter:"Filtro avanzado",dashboard_all_access:"Todos los colaboradores tendrán acceso",dashboard_average:"Promedio",dashboard_code:"Código",dashboard_distinct_count:"Conteo distinto",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Salir de pantalla completa",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabla",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Mis dashboards",dashboard_new:"Nuevo Dashboard",dashboard_no_data:"La consulta no devolvió elementos para su perfil.",dashboard_no_refresh:"No actualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"No compartido",dashboard_only_mine:"Solo míos",dashboard_only_overdue:"Solo atrasados",dashboard_only_responsible:"Solo el responsable tendrá acceso",dashboard_open_query:"Abrir consulta",dashboard_remove_favorite:"Quitar favorito",dashboard_responsible:"Responsable",dashboard_select_groups:"Seleccione grupos, lugares y colaboradores específicos",dashboard_shared_unit:"Compartido con todos los colaboradores de la unidad",dashboard_status:"Situación",dashboard_title:"Título",dashboard_wait_refresh:"Espere para actualizar nuevamente",dashboard_work_done:"Trabajo ejecutado",dashboard_work_planned:"Trabajo planificado",deactivate:"Desactivar",deselect_all:"Deseleccionar todas",dev_login:"Login Desarrollo",download:"Descargar",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nombre",electronic_signature:"Firma Electrónica",embed_code:"Código embed",embedded_content:"Contenido embebido",enter_code:"Ingrese el código",enter_password:"Ingrese su contraseña",error_authentication:"Error de Autenticación",error_connection:"Error de Conexión",error_copied_clipboard:"Los detalles del error se copiaron al portapapeles.",error_loading:"Error al cargar",error_loading_data:"Error al cargar datos",error_session_expired:"Sesión Expirada",error_token_expired:"Token de autenticación expirado. Inicie sesión nuevamente.",esign_code_description:"Un código de verificación fue enviado a su correo. Ingrese el código a continuación para confirmar la operación.",esign_code_error:"Error al validar el código. Intente de nuevo.",esign_invalid_code:"Código inválido. Intente de nuevo.",esign_invalid_password:"Contraseña incorrecta. Intente de nuevo.",esign_password_description:"Ingrese su contraseña para confirmar la operación.",esign_password_error:"Error al validar la contraseña. Intente de nuevo.",esign_resend_error:"Error al reenviar el código.",expand_row:"Expandir fila",expiration_date:"Fecha de expiración",file_error:"Error en el archivo",file_upload:"Subir archivo",go_to_next_page:"Ir a la página siguiente",go_to_previous_page:"Ir a la página anterior",group_by_column:"Agrupar por esta columna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descripción de la imagen",import_flows:"Flujos de Importación",import_manage:"Gestione sus flujos de importación",inactive_user:"[Usuario inactivo]",input_type:"Tipo de entrada",invalid_form:"Formulario inválido. Complete todos los campos obligatorios.",italic:"Itálica",item_details:"Detalles del elemento",items:"elementos",items_per_page:"Elementos por página",know_saber_gestao:"Conozca Saber Gestión",know_staff:"Conozca Staff",language:"Idioma",last_update:"Última actualización",leader:"Líder",leader_create_error:"Error al crear líder",leader_not_found:"Líder no encontrado",leader_promoted_success:"Líder promovido exitosamente",leader_remove_error:"Error al eliminar líder",leader_removed_success:"Líder eliminado exitosamente",leader_update_error:"Error al actualizar líder",leader_updated_success:"Líder actualizado exitosamente",leadership_add_root:"Agregar Líder Raíz",leadership_add_subordinate:"Agregar Subordinado",leadership_cycle_error:"Esta asociación crearía un ciclo en la jerarquía",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Inmediato",leadership_make_root:"Hacer Líder Raíz",leadership_make_root_short:"Hacer Raíz",leadership_no_hierarchy:"No se encontró jerarquía de liderazgo.",leadership_no_members:"Ningún miembro en el equipo",leadership_no_user_selected:"Ningún usuario seleccionado",leadership_no_users_available:"Ningún usuario disponible",leadership_no_users_found:"Ningún usuario encontrado",leadership_remove_team:"Quitar del equipo",leadership_select_subordinates:"Seleccione al menos un subordinado",learn_qualiex:"Aprenda a usar Qualiex",leave_without_saving:"Salir sin guardar",lines_per_page:"Líneas por página",link:"Enlace",login_with_qualiex:"Iniciar sesión con Qualiex",manage_access:"Gestionar Accesos",modules:"Módulos",more_options:"Más opciones",msg_create_error:"Error al crear registro",msg_created_success:"Registro creado exitosamente",msg_delete_error:"Error al eliminar registro",msg_deleted_success:"Registro eliminado exitosamente",msg_load_error:"Error al cargar datos",msg_update_error:"Error al actualizar registro",msg_updated_success:"Registro actualizado exitosamente",new_document:"Nuevo Documento",new_folder:"Nueva Carpeta",new_item:"Nuevo Elemento",next:"Siguiente",no_access_page:"Parece que no tienes acceso a esta página",no_data_to_display:"No hay datos para mostrar en este momento.",no_errors_recorded:"Sin errores registrados",no_image_selected:"Ninguna imagen seleccionada",no_item_selected:"Ningún elemento seleccionado",no_items_found:"No se encontraron elementos",no_items_found_empty:"Ningún elemento encontrado",no_place_found:"Ningún lugar encontrado",no_place_selected:"Sin lugar",no_products:"Sin productos",no_reports_found:"Ningún informe encontrado",no_results:"No se encontraron resultados",no_search_results:"Sin resultados para la búsqueda",no_video_selected:"Ningún vídeo seleccionado",not_authenticated:"No autenticado",not_available:"No disponible",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Pegue el código embed aquí",permissions:"Permisos",preset_colors:"Colores predefinidos",preview:"Vista previa",redirecting_auth:"Redirigiendo a autenticación...",refresh_data:"Actualizar datos",remove:"Eliminar",remove_grouping:"Quitar agrupación",replace:"Reemplazar",report:"Informe",request_date:"Fecha de solicitud",required_field:"Campo obligatorio",resend_code:"Reenviar código",restricted_access:"Acceso restringido",rows_per_page:"Registros por página",save:"Guardar",save_as_draft:"Guardar como Borrador",save_as_template:"Guardar como Plantilla",saving:"Guardando...",search:"Buscar",search_placeholder:"Buscar...",search_report_placeholder:"Buscar informe...",search_user_placeholder:"Buscar usuario...",select_all:"Seleccionar todo",select_all_columns:"Seleccionar todas",select_all_items:"Seleccionar todos",select_at_least_one:"Seleccione al menos un elemento",select_at_least_one_item:"Seleccione al menos un elemento",select_date:"Seleccione una fecha",select_file_format:"Seleccione el formato del archivo",select_items_to_add:"Seleccione elementos para agregar...",select_placeholder:"Seleccionar...",selected:"Seleccionados",session_expired:"Su sesión ha expirado. Será redirigido para iniciar sesión nuevamente.",sign_access_error:"Error al acceder al servicio de firma",sign_api_key_info:"Ingrese la API Key del proveedor de firma",sign_api_key_input:"Ingrese la API Key del proveedor de firma",sign_api_key_placeholder:"Ingrese la clave de API",sign_api_key_required:"Clave de API obligatoria",sign_attempt:"Intento de firma",sign_auth_required:"Autenticación requerida para firmar",sign_click_to_select:"Haga clic para seleccionar documento",sign_config_save_err:"Error al guardar configuración de firma",sign_config_save_error:"Error al guardar configuración de firma",sign_config_saved:"Configuración de firma guardada",sign_config_saved_success:"Configuración de firma guardada exitosamente",sign_configured:"Firma configurada",sign_configured_unit:"Firma digital configurada para esta unidad",sign_digital_config:"Configuración de Firma Digital",sign_doc_available:"Documento firmado disponible para descarga",sign_doc_load_error:"Error al cargar documento",sign_doc_process_error:"Error al procesar documento",sign_doc_sent:"Documento enviado para firma",sign_download_signed:"Descargar documento firmado",sign_email_fallback:"Correo de respaldo para firma",sign_environment:"Ambiente de firma",sign_fetch_failed:"Error al obtener documento firmado",sign_file_not_allowed:"Extensión de archivo no permitida",sign_file_type_not_allowed:"Tipo de archivo no permitido",sign_incorrect_data:"El firmante reportó datos incorrectos.",sign_login_required:"Inicio de sesión requerido para firmar",sign_login_to_sign:"Inicie sesión para usar la firma digital.",sign_monthly_limit:"Límite mensual de firmas alcanzado",sign_no_access:"No se pudo obtener acceso para firma. Intente de nuevo.",sign_not_configured:"Firma no configurada",sign_not_configured_unit:"Firma digital aún no configurada para esta unidad",sign_preparing_doc:"Preparando documento para firma",sign_process_error:"Error al procesar firma",sign_save_config:"Guardar configuración",sign_save_config_btn:"Guardar Configuración",sign_select_pdf:"Seleccione un archivo PDF",sign_sending_doc:"Enviando documento para firma",sign_signed_success:"Documento firmado exitosamente",sign_signer_unavailable:"ID del firmante no disponible",sign_try_again:"Intentar de nuevo",sign_update_config:"Actualizar configuración",sign_update_config_btn:"Actualizar Configuración",sign_waiting_provider:"Esperando proveedor de firma",sign_widget_error:"Error en el widget de firma",something_went_wrong:"Algo salió mal",state:"Estado",status:"Estado",status_completed:"Completado",status_error:"Error",status_expired:"Expirado",status_processing:"Procesando",status_waiting:"Esperando",steps:"Etapas",subordinates_add_error:"Error al agregar subordinados",subordinates_added_success:"Subordinados agregados exitosamente",subordinates_sync_error:"Error al sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados exitosamente",team_all_groups:"Todos los grupos",terms_confirm_reading:"Confirmar lectura",terms_confirmation_available:"Confirmación disponible en",terms_of_use:"Términos de Uso",terms_read_agree:"He leído y acepto",terms_see_later:"Ver después",terms_updated:"Términos de Uso Actualizados",terms_view:"Ver términos de uso",terms_view_short:"Ver término",try_adjust_search:"Intente ajustar su búsqueda",try_again:"Intentar de Nuevo",unit_not_selected:"Ninguna unidad seleccionada",unknown_error:"Error desconocido",unsaved_changes:"Cambios sin guardar",unsaved_changes_description:"Hay cambios sin guardar. ¿Desea salir sin guardar?",updates:"Actualizaciones",user:"Usuario",user_info:"Información del Usuario",user_photo:"Foto del usuario",users_already_leaders:"Los usuarios ya son líderes",verification_code:"Código de verificación",video:"Video",video_title:"Título del vídeo",view_report:"Ver informe",want_to_know_more:"Quiero conocer más",write_content_here:"Escriba el contenido aquí..."};const oi="true"===(void 0).VITE_I18N_DEBUG_MODE;function ii(a,t){e.addResourceBundle(a,"app",t,!0,!0)}oi&&e.use({type:"postProcessor",name:"debugKeys",process:(e,a)=>`🔑 ${Array.isArray(a)?a[0]:a}`}),e.use(j.initReactI18next).init({resources:{"pt-BR":{core:si},"en-US":{core:ri},"es-ES":{core:ni}},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,postProcess:oi?["debugKeys"]:[]});const li=t.createContext(void 0),di={locale:Et,timezone:It,datetimeFormat:At},ci=async()=>{},ui=({children:e})=>a.jsx(li.Provider,{value:{...di,setLocale:ci,setTimezone:ci,setDatetimeFormat:ci,isLoading:!1},children:e}),mi=()=>{const e=t.useContext(li);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},pi=t.createContext({moduleAlias:null});function hi({moduleAlias:e=null,children:t}){return a.jsx(pi.Provider,{value:{moduleAlias:e},children:t})}function xi(){return t.useContext(pi)}const fi=fe.Root,gi=fe.CollapsibleTrigger,vi=fe.CollapsibleContent;class bi extends t.Component{constructor(a){super(a),this.copyErrorDetails=()=>{const a=sn.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||e.t("unknown_error")}\n\nStack Trace:\n${this.state.error?.stack||e.t("not_available")}\n\n=== ÚLTIMOS ERROS ===\n${a.map((e,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||e.t("no_errors_recorded")}\n `.trim();navigator.clipboard.writeText(t),l.toast.success("Detalhes copiados!",{description:e.t("error_copied_clipboard")})},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;sn.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=sn.getErrors().slice(0,2);return a.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:a.jsxs(as,{className:"w-full max-w-2xl",children:[a.jsxs(ts,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),a.jsx(ss,{children:e.t("something_went_wrong")})]}),a.jsxs(ns,{className:"space-y-4",children:[a.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),a.jsxs(fi,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[a.jsx(gi,{asChild:!0,children:a.jsxs(Kt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),a.jsxs(vi,{className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),a.jsxs("div",{className:"text-sm space-y-2",children:[a.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||e.t("unknown_error")}),this.state.error?.stack&&a.jsx(Ur,{className:"h-32 w-full rounded border bg-muted p-2",children:a.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&a.jsxs("div",{className:"pt-3 border-t",children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),a.jsx("div",{className:"space-y-2",children:t.map((e,t)=>a.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),a.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),a.jsxs(Kt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),a.jsx(Kt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const ji=ge.Root,yi=ae.forwardRef(({className:e,...t},s)=>a.jsx(ge.List,{ref:s,className:Gt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));yi.displayName=ge.List.displayName;const wi=ae.forwardRef(({className:e,...t},s)=>a.jsx(ge.Trigger,{ref:s,className:Gt("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",e),...t}));wi.displayName=ge.Trigger.displayName;const Ni=ae.forwardRef(({className:e,...t},s)=>a.jsx(ge.Content,{ref:s,className:Gt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function _i({className:e}){return a.jsxs("svg",{className:e,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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 Ci({className:e}){return a.jsxs("svg",{className:e,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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 ki({educaUrl:e="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:t="https://sabergestao.com.br/",wikiUrl:s,alias:r}){const{t:n}=j.useTranslation(),o=Ht(e||s||"https://educacao.sabergestao.com.br/{alias}/fe",r);return a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(is,{className:"mb-4"}),a.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[a.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-white",children:n("learn_qualiex")}),a.jsxs("a",{href:o,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",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(_i,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:n("know_saber_gestao")}),a.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",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(Ci,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),a.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",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(d.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}Ni.displayName=ge.Content.displayName;const Si=[{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/{alias}"},{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/{alias}"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",softwareAlias:"performance",url:"https://desempenho.sabergestao.com.br/{alias}"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",softwareAlias:"education",url:"https://educacao.sabergestao.com.br/{alias}"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",softwareAlias:"pdi",url:"https://pdi.sabergestao.com.br/{alias}"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",softwareAlias:"pulse",url:"https://nr1pulso.sabergestao.com.br/{alias}"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",softwareAlias:"staff",url:"https://treinamentos.sabergestao.com.br/{alias}"}]},{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={alias}"},{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={alias}"},{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 Ti({module:e,onClick:t}){return a.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:[a.jsx("div",{className:Gt("w-4 h-4 rounded-sm shrink-0 mt-0.5",e.color)}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:e.name}),e.description&&a.jsx("div",{className:"text-sm text-muted-foreground truncate",children:e.description})]})]})}function Pi(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 Di({modules:e,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=[...e].sort((e,a)=>e.name.localeCompare(a.name)),l=void 0!==r,d=l?i.filter(e=>r.includes(e.name)):i,c=l?i.filter(e=>!r.includes(e.name)):[],u=Pi(d,o),m=Pi(c,o),p=(e,a)=>{a?s?.(e):n?.(e)};return a.jsxs("div",{className:"space-y-6",children:[u.length>0&&a.jsx("section",{children:a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(e=>a.jsx(Ti,{module:e,onClick:()=>p(e,!0)},e.name))})}),m.length>0&&a.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(e=>a.jsx(Ti,{module:e,onClick:()=>p(e,!1)},e.name))})]})]})}function Ei({onModuleClick:e,contractedModules:s,onModuleInterest:r,nonContractedUrl:n="https://qualiex.com/",educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,alias:d}){const[c,u]=t.useState("qualiex"),m=a=>{e?.(a)},p=e=>{window.open(n,"_blank","noopener,noreferrer"),r?.(e)};return a.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[a.jsxs(ji,{value:c,onValueChange:u,className:"flex-1 flex flex-col min-h-0",children:[a.jsx(yi,{className:"w-fit shrink-0",children:Si.map(e=>a.jsxs(wi,{value:e.id,children:[e.label,a.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),Si.map(e=>a.jsx(Ni,{value:e.id,className:"flex-1 mt-4 overflow-auto pr-2",children:a.jsx(Di,{modules:e.modules,onModuleClick:m,contractedModules:"qualiex"===e.id?s:void 0,onModuleInterest:p})},e.id))]}),a.jsx(ki,{educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:d})]})}const Ai={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},Ii=6e5;function Mi(e){const{moduleAlias:a}=xi(),{alias:s,user:r,isAuthenticated:n}=Dn(),o=e??a,i=r?.id??null,l=n&&!!s&&!!i,{data:d=[],isLoading:c}=N.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>pn.fetchUserAssociations(i,s),enabled:l,staleTime:Ii,gcTime:12e5}),u=t.useMemo(()=>s&&0!==d.length?d.find(e=>e.companyAlias===s)??null:null,[d,s]),m=t.useCallback(e=>{if(!u)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const a=Ai[e];return void 0!==a&&u.softwares.includes(a)})},[u]);return{hasAccess:t.useMemo(()=>!o||m(o),[o,m]),isLoading:l&&c,role:t.useMemo(()=>u?{id:u.roleId,name:u.roleName}:null,[u]),association:u,hasAccessTo:m}}function Fi(e){const{association:a}=Mi();return t.useMemo(()=>{if(e)return e;if(!a?.softwares)return;const t=a.softwares,s=Si.find(e=>"qualiex"===e.id);return s?s.modules.filter(e=>{if(!e.softwareAlias)return!1;const a=Ai[e.softwareAlias];return void 0!==a&&t.includes(a)}).map(e=>e.name):void 0},[e,a])}function Ri({open:e,onOpenChange:t,onModuleClick:s,contractedModules:r,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l}){const{alias:d}=Dn(),c=Fi(r);return a.jsx(bs,{open:e,onOpenChange:t,children:a.jsxs(Cs,{size:"lg",className:"overflow-hidden flex flex-col",children:[a.jsx(ks,{className:"sr-only",children:a.jsx(Ps,{children:"Módulos"})}),a.jsx(Ei,{onModuleClick:e=>{s?s(e):e.url&&Wt(Ht(e.url,d||void 0))},contractedModules:c,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:d||void 0})]})})}function Li({open:s,onOpenChange:r,onModuleClick:n,contractedModules:o,onModuleInterest:i,userName:l,unitName:c,units:u=[],currentAlias:m,onUnitChange:p,onLogout:h,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,blocking:v=!0,size:b="lg",children:y}){const{t:w}=j.useTranslation(),N=t.useMemo(()=>{if(!u.length)return[];const e=new Map;u.forEach(a=>e.set(a.alias,a));const a=Array.from(e.values()),t=a.find(e=>e.alias===m),s=a.filter(e=>e.alias!==m).sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"}));return t?[t,...s]:s},[u,m]);return a.jsx(bs,{open:s,onOpenChange:v?void 0:r,children:a.jsxs(Cs,{size:b,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:v?e=>e.preventDefault():void 0,onEscapeKeyDown:v?e=>e.preventDefault():void 0,children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[a.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[a.jsx(Ps,{children:w("no_access_page")}),a.jsx(Ds,{children:"Selecione um módulo para continuar navegando!"})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[N.length>1&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsxs(Kt,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[a.jsx(d.Building2,{className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate text-xs",children:c||"Unidade"}),a.jsx(d.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),a.jsx(mr,{align:"end",className:"max-h-[300px] overflow-auto",children:N.map(e=>a.jsxs(pr,{onClick:()=>p?.(e),className:e.alias===m?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate",children:e.name}),e.alias===m&&a.jsx(Zs,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},e.alias))})]}),a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsxs(Kt,{variant:"ghost",size:"sm",className:"gap-2",children:[a.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:a.jsx(d.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),a.jsx(d.ChevronDown,{className:"h-3 w-3"})]})}),a.jsxs(mr,{align:"end",children:[a.jsxs("div",{className:"px-2 py-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:l||e.t("user")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:c})]}),a.jsx(gr,{}),a.jsxs(pr,{onClick:h,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),y?a.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[a.jsx("div",{className:"flex-1",children:y}),a.jsx(ki,{educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m})]}):a.jsx(Ei,{onModuleClick:n,contractedModules:o,onModuleInterest:i,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m})]})})}function zi(e,a){const{t:t}=j.useTranslation();return a.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a)}function Ui({children:e,contractedModules:s,onModuleClick:r,onModuleInterest:n,educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:d,accessDeniedRoutes:c}){const{t:u}=j.useTranslation(),{hasAccess:m,isLoading:p,association:h}=Mi(),{user:x,alias:f,companies:g,isAuthenticated:v,isLoading:b,logout:y,switchUnit:w}=Dn(),N=Fi(s),_=t.useMemo(()=>g?.length?f&&g.find(e=>e.alias===f)||g[0]:null,[g,f]),C=t.useMemo(()=>g?.length?g.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[g]),k=t.useCallback(e=>{const a=g?.find(a=>a.alias===e.alias);if(!a)return;const{pathname:t,search:s,hash:r}=window.location;if(f){const e=t.split("/"),n=e.indexOf(f);if(n>=0)return e[n]=a.alias,void(window.location.href=e.join("/")+s+r)}w(a)},[f,w,g]),S=t.useCallback(e=>{r?r(e):e.url&&Wt(Ht(e.url,f||void 0))},[r,f]),T=t.useMemo(()=>{if(!c)return;const e=window.location.pathname,a=Object.keys(c).find(a=>zi(e,[a]));return a?c[a]:void 0},[c]);return b||!v||d?.length&&zi(window.location.pathname,d)?a.jsx(a.Fragment,{children:e}):p?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsx(ar,{size:"lg"})}):m?a.jsx(a.Fragment,{children:e}):a.jsx(Li,{open:!0,onModuleClick:S,contractedModules:N,onModuleInterest:n,userName:x?.name,unitName:_?.name,units:C,currentAlias:f||void 0,onUnitChange:k,onLogout:y,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,blocking:!0,children:T})}let Oi=!1;function Vi(){if(Oi||"undefined"==typeof document)return;Oi=!0;for(const a of["https://fonts.googleapis.com","https://fonts.gstatic.com"])if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=a,a.includes("gstatic")&&(e.crossOrigin="anonymous"),document.head.appendChild(e)}const e=["https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap","https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap"];for(const a of e)if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=a,document.head.appendChild(e)}}const Bi=ve.Root,qi=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.Item,{ref:s,className:Gt("border-b",e),...t}));qi.displayName="AccordionItem";const $i=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsx(ve.Header,{className:"flex",children:a.jsxs(ve.Trigger,{ref:r,className:Gt("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...s,children:[t,a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));$i.displayName=ve.Trigger.displayName;const Wi=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsx(ve.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:a.jsx("div",{className:Gt("pb-4 pt-0",e),children:t})}));Wi.displayName=ve.Content.displayName;const Hi=ae.forwardRef(({className:e,...t},s)=>a.jsx(be.Root,{ref:s,className:Gt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Hi.displayName=be.Root.displayName;const Gi=ae.forwardRef(({className:e,...t},s)=>a.jsx(be.Image,{ref:s,className:Gt("aspect-square h-full w-full",e),...t}));Gi.displayName=be.Image.displayName;const Yi=ae.forwardRef(({className:e,...t},s)=>a.jsx(be.Fallback,{ref:s,className:Gt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Yi.displayName=be.Fallback.displayName;const Qi=ae.forwardRef(({...e},t)=>a.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));Qi.displayName="Breadcrumb";const Ki=ae.forwardRef(({className:e,...t},s)=>a.jsx("ol",{ref:s,className:Gt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));Ki.displayName="BreadcrumbList";const Xi=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Gt("inline-flex items-center gap-1.5",e),...t}));Xi.displayName="BreadcrumbItem";const Ji=ae.forwardRef(({asChild:e,className:t,...r},n)=>{const o=e?s.Slot:"a";return a.jsx(o,{ref:n,className:Gt("transition-colors hover:text-foreground",t),...r})});Ji.displayName="BreadcrumbLink";const Zi=ae.forwardRef(({className:e,...t},s)=>a.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Gt("font-normal text-foreground",e),...t}));Zi.displayName="BreadcrumbPage";const el=({children:e,className:t,...s})=>a.jsx("li",{role:"presentation","aria-hidden":"true",className:Gt("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:e??a.jsx(d.ChevronRight,{})});el.displayName="BreadcrumbSeparator";const al=({className:e,...t})=>a.jsxs("span",{role:"presentation","aria-hidden":"true",className:Gt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Mais"})]});al.displayName="BreadcrumbEllipsis";const tl=r.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"}}),sl=ae.forwardRef(({className:e,orientation:t,...s},r)=>a.jsx("div",{ref:r,className:Gt(tl({orientation:t}),e),...s}));function rl({className:e,classNames:t,showOutsideDays:s=!0,...r}){return a.jsx(I.DayPicker,{showOutsideDays:s,className:Gt("p-3 pointer-events-auto",e),locale:St,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:Gt(Qt({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Gt(Qt({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:Gt(Qt({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:e})=>"left"===e?a.jsx(d.ChevronLeft,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}sl.displayName="ButtonGroup",rl.displayName="Calendar";const nl={Root:function({children:e,className:t}){return a.jsx("div",{className:Gt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:s}){return a.jsx(as,{className:Gt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:a.jsx(ns,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:s}){return a.jsxs("div",{className:Gt("flex justify-between items-center text-sm",s),children:[a.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),a.jsx("span",{className:"text-foreground",children:t})]})}};function ol({date:e,onDateChange:t,placeholder:s,disabled:r=!1,className:n,disabledDates:o}){const{t:l}=j.useTranslation(),c=s??l("select_date");return a.jsxs(_r,{children:[a.jsx(Cr,{asChild:!0,children:a.jsxs(Kt,{variant:"outline",disabled:r,className:Gt("w-full justify-start text-left font-normal",!e&&"text-muted-foreground",n),children:[a.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),e?i.format(e,"d 'de' MMMM 'de' yyyy",{locale:St}):a.jsx("span",{children:c})]})}),a.jsx(kr,{className:"w-auto p-0",align:"start",children:a.jsx(rl,{mode:"single",selected:e,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const il=({shouldScaleBackground:e=!0,...t})=>a.jsx(M.Drawer.Root,{shouldScaleBackground:e,...t});il.displayName="Drawer";const ll=M.Drawer.Trigger,dl=M.Drawer.Portal,cl=M.Drawer.Close,ul=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Overlay,{ref:s,className:Gt("fixed inset-0 z-50 bg-black/80",e),...t}));ul.displayName=M.Drawer.Overlay.displayName;const ml=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(dl,{children:[a.jsx(ul,{}),a.jsxs(M.Drawer.Content,{ref:r,className:Gt("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",e),...s,children:[a.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));ml.displayName="DrawerContent";const pl=({className:e,...t})=>a.jsx("div",{className:Gt("grid gap-1.5 p-4 text-center sm:text-left",e),...t});pl.displayName="DrawerHeader";const hl=({className:e,...t})=>a.jsx("div",{className:Gt("mt-auto flex flex-col gap-2 p-4",e),...t});hl.displayName="DrawerFooter";const xl=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Title,{ref:s,className:Gt("text-lg font-semibold leading-none tracking-tight",e),...t}));xl.displayName=M.Drawer.Title.displayName;const fl=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Description,{ref:s,className:Gt("text-sm text-muted-foreground",e),...t}));fl.displayName=M.Drawer.Description.displayName;const gl={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))]"},vl={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const bl=je.Root,jl=je.Trigger,yl=ae.forwardRef(({className:e,align:t="center",sideOffset:s=4,...r},n)=>a.jsx(je.Content,{ref:n,align:t,sideOffset:s,className:Gt("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",e),...r}));yl.displayName=je.Content.displayName;const wl=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-slot":"input-group",className:Gt("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",e),...t}));wl.displayName="InputGroup";const Nl=r.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"}}),_l=ae.forwardRef(({className:e,align:t,...s},r)=>a.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Gt(Nl({align:t}),e),...s}));_l.displayName="InputGroupAddon";const Cl=r.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"}}),kl=ae.forwardRef(({className:e,size:t,variant:s="ghost",...r},n)=>a.jsx(Kt,{ref:n,"data-slot":"input-group-button",variant:s,className:Gt(Cl({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",e),...r}));kl.displayName="InputGroupButton";const Sl=ae.forwardRef(({className:e,...t},s)=>a.jsx(Jt,{ref:s,"data-slot":"input-group-control",className:Gt("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Sl.displayName="InputGroupInput";const Tl=ae.forwardRef(({className:e,...t},s)=>a.jsx(Xs,{ref:s,"data-slot":"input-group-control",className:Gt("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Tl.displayName="InputGroupTextarea";const Pl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h1",{ref:s,className:Gt("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",e),...t}));Pl.displayName="H1";const Dl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h2",{ref:s,className:Gt("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",e),...t}));Dl.displayName="H2";const El=ae.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Gt("scroll-m-20 text-2xl font-semibold tracking-tight",e),...t}));El.displayName="H3";const Al=ae.forwardRef(({className:e,...t},s)=>a.jsx("h4",{ref:s,className:Gt("scroll-m-20 text-xl font-semibold tracking-tight",e),...t}));Al.displayName="H4";const Il=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Gt("leading-7 [&:not(:first-child)]:mt-6",e),...t}));Il.displayName="P";const Ml=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Gt("text-xl text-muted-foreground",e),...t}));Ml.displayName="Lead";const Fl=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Gt("text-lg font-semibold",e),...t}));Fl.displayName="Large";const Rl=ae.forwardRef(({className:e,...t},s)=>a.jsx("small",{ref:s,className:Gt("text-sm font-medium leading-none",e),...t}));Rl.displayName="Small";const Ll=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Gt("text-sm text-muted-foreground",e),...t}));Ll.displayName="Muted";const zl=ae.forwardRef(({className:e,...t},s)=>a.jsx("code",{ref:s,className:Gt("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",e),...t}));zl.displayName="InlineCode";const Ul=ae.forwardRef(({className:e,...t},s)=>a.jsx("blockquote",{ref:s,className:Gt("mt-6 border-l-2 pl-6 italic",e),...t}));Ul.displayName="Blockquote";const Ol=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Gt("my-6 ml-6 list-disc [&>li]:mt-2",e),...t}));Ol.displayName="List";const Vl=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ye.Root,{ref:r,className:Gt("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...s,children:[t,a.jsx(Yl,{})]}));Vl.displayName=ye.Root.displayName;const Bl=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.List,{ref:s,className:Gt("group flex flex-1 list-none items-center justify-center space-x-1",e),...t}));Bl.displayName=ye.List.displayName;const ql=ye.Item,$l=r.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"),Wl=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ye.Trigger,{ref:r,className:Gt($l(),"group",e),...s,children:[t," ",a.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Wl.displayName=ye.Trigger.displayName;const Hl=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Content,{ref:s,className:Gt("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 ",e),...t}));Hl.displayName=ye.Content.displayName;const Gl=ye.Link,Yl=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:Gt("absolute left-0 top-full flex justify-center"),children:a.jsx(ye.Viewport,{className:Gt("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)]",e),ref:s,...t})}));Yl.displayName=ye.Viewport.displayName;const Ql=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Indicator,{ref:s,className:Gt("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",e),...t,children:a.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ql.displayName=ye.Indicator.displayName;const Kl=({className:e,...t})=>a.jsx("nav",{role:"navigation","aria-label":"pagination",className:Gt("mx-auto flex w-full justify-center",e),...t});Kl.displayName="Pagination";const Xl=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Gt("flex flex-row items-center gap-1",e),...t}));Xl.displayName="PaginationContent";const Jl=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Gt("",e),...t}));Jl.displayName="PaginationItem";const Zl=({className:e,isActive:t,size:s="icon",...r})=>a.jsx("a",{"aria-current":t?"page":void 0,className:Gt(Qt({variant:t?"outline":"ghost",size:s}),e),...r});Zl.displayName="PaginationLink";const ed=({className:t,...s})=>a.jsxs(Zl,{"aria-label":e.t("go_to_previous_page"),size:"default",className:Gt("gap-1 pl-2.5",t),...s,children:[a.jsx(d.ChevronLeft,{className:"h-4 w-4"}),a.jsx("span",{children:"Previous"})]});ed.displayName="PaginationPrevious";const ad=({className:t,...s})=>a.jsxs(Zl,{"aria-label":e.t("go_to_next_page"),size:"default",className:Gt("gap-1 pr-2.5",t),...s,children:[a.jsx("span",{children:"Next"}),a.jsx(d.ChevronRight,{className:"h-4 w-4"})]});ad.displayName="PaginationNext";const td=({className:e,...t})=>a.jsxs("span",{"aria-hidden":!0,className:Gt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"More pages"})]});td.displayName="PaginationEllipsis";const sd=ae.forwardRef(({className:e,value:t,...s},r)=>a.jsx(we.Root,{ref:r,className:Gt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...s,children:a.jsx(we.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));sd.displayName=we.Root.displayName;const rd=ae.forwardRef(({className:e,...t},s)=>a.jsx(Ne.Root,{className:Gt("grid gap-2",e),...t,ref:s}));rd.displayName=Ne.Root.displayName;const nd=ae.forwardRef(({className:e,...t},s)=>a.jsx(Ne.Item,{ref:s,className:Gt("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",e),...t,children:a.jsx(Ne.Indicator,{className:"flex items-center justify-center",children:a.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));nd.displayName=Ne.Item.displayName;const od=_e.Panel,id=se.Root,ld=se.Trigger,dd=se.Close,cd=se.Portal,ud=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Overlay,{className:Gt("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",e),...t,ref:s}));ud.displayName=se.Overlay.displayName;const md=r.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"}}),pd=ae.forwardRef(({side:e="right",className:t,children:s,...r},n)=>a.jsxs(cd,{children:[a.jsx(ud,{}),a.jsxs(se.Content,{ref:n,className:Gt(md({side:e}),t),...r,children:[s,a.jsxs(se.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pd.displayName=se.Content.displayName;const hd=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Gt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(is,{className:"mt-2"})]});hd.displayName="SheetHeader";const xd=({className:e,...t})=>a.jsx("div",{className:Gt("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",e),...t});xd.displayName="SheetBody";const fd=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(is,{className:"mb-4"}),a.jsx("div",{className:Gt("flex flex-row justify-end gap-2",e),...s,children:t})]});fd.displayName="SheetFooter";const gd=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Title,{ref:s,className:Gt("text-lg font-semibold text-foreground",e),...t}));gd.displayName=se.Title.displayName;const vd=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Description,{ref:s,className:Gt("text-sm text-muted-foreground",e),...t}));vd.displayName=se.Description.displayName;const bd="sidebar:state",jd=ae.createContext(null);function yd(){const e=ae.useContext(jd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const wd=ae.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const d=In(),[c,u]=ae.useState(!1),[m,p]=ae.useState(()=>{if("undefined"!=typeof window){const a=localStorage.getItem(bd);return null!==a?"true"===a:e}return e}),h=t??m,x=ae.useCallback(e=>{const a="function"==typeof e?e(h):e;s?s(a):p(a),"undefined"!=typeof window&&localStorage.setItem(bd,String(a))},[s,h]),f=ae.useCallback(()=>d?u(e=>!e):x(e=>!e),[d,x,u]);ae.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f]);const g=h?"expanded":"collapsed",v=ae.useMemo(()=>({state:g,open:h,setOpen:x,isMobile:d,openMobile:c,setOpenMobile:u,toggleSidebar:f}),[g,h,x,d,c,u,f]);return a.jsx(jd.Provider,{value:v,children:a.jsx(br,{delayDuration:0,children:a.jsx("div",{className:Gt("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})})})});wd.displayName="SidebarProvider";const Nd=ae.forwardRef(({side:e="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=yd();return"none"===s?a.jsx("div",{className:Gt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?a.jsx(id,{open:c,onOpenChange:u,...o,children:a.jsxs(pd,{"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:e,children:[a.jsx(gd,{className:"sr-only",children:"Menu de Navegação"}),a.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):a.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":e,children:[a.jsx("div",{className:Gt("duration-200 relative h-[calc(100svh-var(--header-height,0px))] 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]")}),a.jsx("div",{className:Gt("duration-200 fixed z-30 hidden w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","top-[var(--header-height,0px)] h-[calc(100svh-var(--header-height,0px))]","left"===e?"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:a.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})})]})});Nd.displayName="Sidebar";const _d=ae.forwardRef(({className:e,onClick:t,...s},r)=>{const{toggleSidebar:n}=yd();return a.jsxs(Kt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Gt("h-7 w-7",e),onClick:e=>{t?.(e),n()},...s,children:[a.jsx(d.PanelLeft,{}),a.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});_d.displayName="SidebarTrigger";const Cd=ae.forwardRef(({className:e,...t},s)=>{const{toggleSidebar:r}=yd();return a.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Gt("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",e),...t})});Cd.displayName="SidebarRail";const kd=ae.forwardRef(({className:e,...t},s)=>a.jsx("main",{ref:s,className:Gt("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",e),...t}));kd.displayName="SidebarInset";const Sd=ae.forwardRef(({className:e,...t},s)=>a.jsx(Jt,{ref:s,"data-sidebar":"input",className:Gt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Sd.displayName="SidebarInput";const Td=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"header",className:Gt("flex flex-col gap-2 p-2",e),...t}));Td.displayName="SidebarHeader";const Pd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"footer",className:Gt("flex flex-col gap-2 p-2",e),...t}));Pd.displayName="SidebarFooter";const Dd=ae.forwardRef(({className:e,...t},s)=>a.jsx(is,{ref:s,"data-sidebar":"separator",className:Gt("mx-2 w-auto bg-sidebar-border",e),...t}));Dd.displayName="SidebarSeparator";const Ed=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"content",className:Gt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Ed.displayName="SidebarContent";const Ad=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group",className:Gt("relative flex w-full min-w-0 flex-col p-2",e),...t}));Ad.displayName="SidebarGroup";const Id=ae.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"div";return a.jsx(o,{ref:n,"data-sidebar":"group-label",className:Gt("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",e),...r})});Id.displayName="SidebarGroupLabel";const Md=ae.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"button";return a.jsx(o,{ref:n,"data-sidebar":"group-action",className:Gt("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",e),...r})});Md.displayName="SidebarGroupAction";const Fd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group-content",className:Gt("w-full text-sm",e),...t}));Fd.displayName="SidebarGroupContent";const Rd=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu",className:Gt("flex w-full min-w-0 flex-col gap-1",e),...t}));Rd.displayName="SidebarMenu";const Ld=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Gt("group/menu-item relative",e),...t}));Ld.displayName="SidebarMenuItem";const zd=r.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"}}),Ud=ae.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=e?s.Slot:"button",{isMobile:u,state:m}=yd(),p=a.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":t,className:Gt(zd({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:p}),a.jsx(wr,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});Ud.displayName="SidebarMenuButton";const Od=ae.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...n},o)=>{const i=t?s.Slot:"button";return a.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Gt("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",e),...n})});Od.displayName="SidebarMenuAction";const Vd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Gt("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",e),...t}));Vd.displayName="SidebarMenuBadge";const Bd=ae.forwardRef(({className:e,showIcon:t=!1,...s},r)=>{const n=ae.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return a.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Gt("rounded-md h-8 flex gap-2 px-2 items-center",e),...s,children:[t&&a.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),a.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});Bd.displayName="SidebarMenuSkeleton";const qd=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Gt("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",e),...t}));qd.displayName="SidebarMenuSub";const $d=ae.forwardRef(({...e},t)=>a.jsx("li",{ref:t,...e}));$d.displayName="SidebarMenuSubItem";const Wd=ae.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:n,...o},i)=>{const l=e?s.Slot:"a";return a.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:Gt("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});Wd.displayName="SidebarMenuSubButton";const Hd=ae.forwardRef(({className:e,value:t,defaultValue:s,...r},n)=>{const o=t||s||[0];return a.jsxs(Ce.Root,{ref:n,value:t,defaultValue:s,className:Gt("relative flex w-full touch-none select-none items-center",e),...r,children:[a.jsx(Ce.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:a.jsx(Ce.Range,{className:"absolute h-full bg-primary"})}),o.map((e,t)=>a.jsx(Ce.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))]})});Hd.displayName=Ce.Root.displayName;const Gd=ke.Menu,Yd=ke.Group,Qd=ke.Portal,Kd=ke.Sub,Xd=ke.RadioGroup,Jd=ae.forwardRef(({className:e,...t},s)=>a.jsx(ke.Root,{ref:s,className:Gt("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",e),...t}));Jd.displayName=ke.Root.displayName;const Zd=ae.forwardRef(({className:e,...t},s)=>a.jsx(ke.Trigger,{ref:s,className:Gt("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",e),...t}));Zd.displayName=ke.Trigger.displayName;const ec=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(ke.SubTrigger,{ref:n,className:Gt("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",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ec.displayName=ke.SubTrigger.displayName;const ac=ae.forwardRef(({className:e,...t},s)=>a.jsx(ke.SubContent,{ref:s,className:Gt("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",e),...t}));ac.displayName=ke.SubContent.displayName;const tc=ae.forwardRef(({className:e,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>a.jsx(ke.Portal,{children:a.jsx(ke.Content,{ref:o,align:t,alignOffset:s,sideOffset:r,className:Gt("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",e),...n})}));tc.displayName=ke.Content.displayName;const sc=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(ke.Item,{ref:r,className:Gt("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",e),...s}));sc.displayName=ke.Item.displayName;const rc=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(ke.CheckboxItem,{ref:n,className:Gt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(ke.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));rc.displayName=ke.CheckboxItem.displayName;const nc=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ke.RadioItem,{ref:r,className:Gt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(ke.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));nc.displayName=ke.RadioItem.displayName;const oc=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(ke.Label,{ref:r,className:Gt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));oc.displayName=ke.Label.displayName;const ic=ae.forwardRef(({className:e,...t},s)=>a.jsx(ke.Separator,{ref:s,className:Gt("-mx-1 my-1 h-px bg-muted",e),...t}));ic.displayName=ke.Separator.displayName;const lc=({className:e,...t})=>a.jsx("span",{className:Gt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});lc.displayname="MenubarShortcut";const dc={light:"",dark:".dark"},cc=ae.createContext(null);function uc(){const e=ae.useContext(cc);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const mc=ae.forwardRef(({id:e,className:t,children:s,config:r,...n},o)=>{const i=ae.useId(),l=`chart-${e||i.replace(/:/g,"")}`;return a.jsx(cc.Provider,{value:{config:r},children:a.jsxs("div",{"data-chart":l,ref:o,className:Gt("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:[a.jsx(pc,{id:l,config:r}),a.jsx(Se.ResponsiveContainer,{children:s})]})})});mc.displayName="Chart";const pc=({id:e,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?a.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(dc).map(([a,t])=>`\n${t} [data-chart=${e}] {\n${s.map(([e,t])=>{const s=t.theme?.[a]||t.color;return s?` --color-${e}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},hc=Se.Tooltip,xc=ae.forwardRef(({active:e,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=uc(),f=ae.useMemo(()=>{if(n||!t?.length)return null;const[e]=t,s=vc(x,e,`${p||e?.dataKey||e?.name||"value"}`),r=p||"string"!=typeof i?s?.label:x[i]?.label||i;return l?a.jsx("div",{className:Gt("font-medium",d),children:l(r,t)}):r?a.jsx("div",{className:Gt("font-medium",d),children:r}):null},[i,l,t,n,d,x,p]);if(!e||!t?.length)return null;const g=1===t.length&&"dot"!==r;return a.jsxs("div",{ref:h,className:Gt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:f,a.jsx("div",{className:"grid gap-1.5",children:t.map((e,t)=>{const s=`${m||e.name||e.dataKey||"value"}`,n=vc(x,e,s),i=u||e.payload?.fill||e.color;return a.jsx("div",{className:Gt("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==e?.value&&e.name?c(e.value,e.name,e,t,e.payload):a.jsxs(a.Fragment,{children:[n?.icon?a.jsx(n.icon,{}):!o&&a.jsx("div",{className:Gt("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}}),a.jsxs("div",{className:Gt("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[a.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,a.jsx("span",{className:"text-muted-foreground",children:n?.label||e.name})]}),void 0!==e.value&&a.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString():e.value})]})]})},e.dataKey||t)})})]})});xc.displayName="ChartTooltip";const fc=Se.Legend,gc=ae.forwardRef(({className:e,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=uc();return s?.length?a.jsx("div",{ref:o,className:Gt("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",e),children:s.map(e=>{const s=`${n||e.dataKey||"value"}`,r=vc(i,e,s);return a.jsxs("div",{className:Gt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?a.jsx(r.icon,{}):a.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),r?.label]},e.value)})}):null});function vc(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]}gc.displayName="ChartLegend";const bc=({onClick:e,isActive:t,disabled:s,children:r,title:n})=>a.jsx("button",{type:"button",onClick:e,disabled:s,title:n,className:Gt("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}),jc=()=>a.jsx("div",{className:"w-px h-5 bg-border mx-1"});function yc({image:e,title:t,className:s}){return a.jsx("div",{className:Gt("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:e?a.jsx("img",{src:e,alt:t,className:"w-full h-full object-cover"}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(d.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function wc({steps:e,currentStepIndex:t,onStepSelect:s,stepLabel:r,className:n}){const{t:o}=j.useTranslation(),i=e.length,l=(t+1)/i*100;return a.jsxs("div",{className:Gt("flex items-center gap-3",n),children:[a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsxs(Kt,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",t+1,"/",i,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(mr,{align:"start",children:e.map((e,r)=>a.jsxs(pr,{onClick:()=>s(r),className:Gt(r===t&&"bg-accent"),children:[r+1,". ",e.title]},e.id))})]}),a.jsx(sd,{value:l,className:"w-32 h-2"})]})}function Nc({currentStepIndex:e,totalSteps:t,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:l,className:c}){const{t:u}=j.useTranslation(),m=0===e,p=e===t-1;return a.jsxs("div",{className:Gt("flex items-center gap-2",c),children:[!m&&a.jsxs(Kt,{variant:"outline",onClick:s,size:"sm",children:[a.jsx(d.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),a.jsxs(Kt,{onClick:p?n:r,size:"sm",children:[p?l:i,!p&&a.jsx(d.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const _c=ae.forwardRef(({open:t,onOpenChange:s,steps:r,onComplete:n,onStepChange:o,continueButtonText:i="Continuar",backButtonText:l="Voltar",finishButtonText:c="Concluir",stepLabel:u=e.t("approval_step_label"),size:m="md",showProgressIndicator:p=!0,currentStepIndex:h,onCurrentStepChange:x,className:f},g)=>{const[v,b]=ae.useState(0),j=void 0!==h,y=j?h:v,w=ae.useCallback(e=>{j?x?.(e):b(e),o?.(e)},[j,x,o]);ae.useEffect(()=>{t||j||b(0)},[t,j]);const N=r[y],_=r.length;return N?a.jsx(bs,{open:t,onOpenChange:s,children:a.jsxs(Cs,{ref:g,size:m,variant:"informative",className:Gt("p-0 gap-0 overflow-hidden",f),children:[a.jsxs(ws,{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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Fechar"})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx(yc,{image:N.image,title:N.title}),a.jsx(Ps,{className:"text-xl font-semibold",children:N.title}),a.jsx(Ds,{className:"text-muted-foreground",children:N.description})]})}),a.jsxs("div",{className:"flex-shrink-0",children:[a.jsx(is,{}),a.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[p&&_>1?a.jsx(wc,{steps:r,currentStepIndex:y,onStepSelect:e=>{w(e)},stepLabel:u}):a.jsx("div",{}),a.jsx(Nc,{currentStepIndex:y,totalSteps:_,onBack:()=>{y>0&&w(y-1)},onNext:()=>{y<_-1&&w(y+1)},onComplete:()=>{n?.(),s(!1)},backButtonText:l,continueButtonText:i,finishButtonText:c})]})]})]})}):null});function Cc({label:e,onClick:t,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:l=!1,menuAlign:c="end",className:u}){const{t:m}=j.useTranslation(),p=i||l;if(!(r.length>0))return a.jsxs(Kt,{variant:n,size:o,disabled:p,onClick:t,className:u,children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]});return a.jsxs("div",{className:Gt("inline-flex rounded-md shadow-sm",u),children:[a.jsxs(Kt,{variant:n,size:o,disabled:p,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]}),a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:n,size:o,disabled:p,className:Gt("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":m("more_options"),children:a.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),a.jsx(mr,{align:c,className:"min-w-[160px]",children:r.map(e=>{const t=e.icon;return a.jsxs(pr,{onClick:e.onClick,disabled:e.disabled,className:Gt("destructive"===e.variant&&"text-destructive focus:text-destructive"),children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})]})}var kc;_c.displayName="OnboardingDialog",exports.ExportFormat=void 0,(kc=exports.ExportFormat||(exports.ExportFormat={})).CSV="csv",kc.PDF="pdf",kc.XLSX="xlsx",kc.PNG="png",kc.JPEG="jpeg",kc.SVG="svg";const Sc=[{value:exports.ExportFormat.CSV,label:"CSV",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.XLSX,label:"XLSX",icon:a.jsx(d.FileSpreadsheet,{className:"h-5 w-5"})}],Tc=[{value:exports.ExportFormat.PNG,label:"PNG",icon:a.jsx(d.Image,{className:"h-5 w-5"})},{value:exports.ExportFormat.JPEG,label:"JPEG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.SVG,label:"SVG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})}];const Pc=t.forwardRef(({value:e,onChange:s,onTimeChange:r,label:n,error:o,format:i="24h",className:l,id:c,...u},m)=>{const p=c??ae.useId(),h=t.useCallback(e=>{const a=e.target.value;s?.(a),r?.(a)},[s,r]),x=t.useCallback(e=>{["0","1","2","3","4","5","6","7","8","9","Backspace","Tab",":","ArrowLeft","ArrowRight","Delete"].includes(e.key)||e.preventDefault()},[]);return a.jsxs("div",{className:Gt("grid gap-1.5",l),children:[n&&a.jsx(es,{htmlFor:p,children:n}),a.jsxs("div",{className:"relative",children:[a.jsx(Jt,{ref:m,id:p,type:"time",value:e??"",onChange:h,onKeyDown:x,min:"00:00",max:"23:59",step:60,className:Gt("pr-9",o&&"border-destructive focus-visible:ring-destructive"),...u}),a.jsx(d.Clock,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})});function Dc({currentStep:e,totalSteps:t,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){ae.useEffect(()=>{process.env.NODE_ENV},[]);const l=Array.from({length:t},(e,a)=>a+1),c=a=>!(a<=e)&&(!!n&&!n(a));return a.jsxs("div",{className:Gt("flex items-center gap-3",o),children:[a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsxs(Kt,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",e,"/",t,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(mr,{align:"start",children:l.map(t=>a.jsxs(pr,{onClick:()=>{var a;(a=t)<e?s(a):n&&!n(a)||s(a)},disabled:c(t),className:Gt("cursor-pointer",t===e&&"bg-muted font-medium",c(t)&&"opacity-50 cursor-not-allowed"),children:[a.jsxs("span",{className:"mr-2 text-muted-foreground",children:[t,"."]}),r?.[t-1]||`Etapa ${t}`,t===e&&a.jsx(d.Check,{className:"h-4 w-4 ml-auto"})]},t))})]}),a.jsx(sd,{value:e/t*100,className:Gt("h-2",i)})]})}function Ec(e){const a=tn.getAccessToken(),t={"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},"un-alias":e};if(a)try{const e=JSON.parse(atob(a.split(".")[1]));e.sub&&(t["x-waf-rate"]=btoa(e.sub))}catch{}return t}async function Ac(e,a,t){let s=await fetch(e,a);if(401===s.status){if(await mn.handleApiError({status:401})){const r={...a,headers:Ec(t)};s=await fetch(e,r)}}return s}function Ic(e){const[a,s]=t.useState([]),[r,n]=t.useState(0),[o,i]=t.useState(!1);t.useEffect(()=>{if(!e)return;let a=!1;const t=`${Ue().replace(/\/?$/,"/")}api/common/v1/updates/listUpdatesNotification`;return async function(){i(!0);try{const r=Ec(e),o=await Ac(t,{method:"GET",headers:r},e);if(!o.ok)return;const i=await o.json();!a&&i.data?.[0]&&(s(i.data[0].updates??[]),n(i.data[0].valueBadge??0))}catch(r){}finally{a||i(!1)}}(),()=>{a=!0}},[e]);const l=t.useCallback(async()=>{if(!e||r<=0||0===a.length)return;const t=a[0].id,s=`${Ue().replace(/\/?$/,"/")}api/common/v1/Updates/userVisualized/3/undefined`;n(0);try{const a=Ec(e),r=JSON.stringify({id:t,idUpdateType:3});await Ac(s,{method:"POST",headers:a,body:r},e)}catch(o){}},[e,r,a]);return{updates:a,badgeCount:r,loading:o,markAsVisualized:l}}Pc.displayName="Timepicker";const Mc=t.forwardRef(({updates:t,badgeCount:s,onOpen:r,onViewAll:n},o)=>{const i=void 0===t,l=Dn(),c=l?.alias??null,u=Ic(i?c:null),m=i?u.updates??[]:t,p=i?u.badgeCount??0:s??0,h=r??(i?u.markAsVisualized:void 0),x=n??(i&&c?()=>{const e=`https://apps4.qualiex.com/common/${c}/up/view`;window.open(e,"_blank","noopener,noreferrer")}:void 0);return a.jsxs(_r,{children:[a.jsx(Cr,{asChild:!0,children:a.jsxs(Kt,{ref:o,variant:"ghost",size:"sm",className:"relative h-9 w-9 p-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:h,title:e.t("updates"),children:[a.jsx(d.Coffee,{className:"h-7 w-7"}),p>0&&a.jsx("span",{className:"absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:p>99?"99+":p})]})}),a.jsxs(kr,{align:"end",className:"w-80 p-0",children:[a.jsx("div",{className:"border-b border-border px-4 py-3",children:a.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Atualizações"})}),a.jsx("div",{className:"max-h-72 overflow-y-auto",children:m.length>0?a.jsx("ul",{className:"divide-y divide-border",children:m.map(e=>a.jsxs("li",{className:"px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer",onClick:x,children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.text})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[a.jsx(d.Coffee,{className:"h-8 w-8 text-muted-foreground mb-2"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum café quentinho, ou melhor, atualização quentinha no momento!"})]})}),a.jsx("div",{className:"border-t border-border px-4 py-2",children:a.jsxs(Kt,{variant:"ghost",size:"sm",className:"w-full justify-between text-primary hover:text-primary",onClick:x,children:["Ver todas as atualizações",a.jsx(d.ArrowRight,{className:"h-[18px] w-[18px]"})]})})]})]})});var Fc,Rc;Mc.displayName="UpdatesNotification",exports.FileViewerType=void 0,(Fc=exports.FileViewerType||(exports.FileViewerType={}))[Fc.none=0]="none",Fc[Fc.image=1]="image",Fc[Fc.video=2]="video",Fc[Fc.audio=3]="audio",Fc[Fc.wopi=4]="wopi",Fc[Fc.onlineEditor=5]="onlineEditor",Fc[Fc.report=6]="report",exports.FilePrintType=void 0,(Rc=exports.FilePrintType||(exports.FilePrintType={}))[Rc.SimplePrint=0]="SimplePrint",Rc[Rc.ManagedCopy=1]="ManagedCopy",Rc[Rc.NonManagedCopy=2]="NonManagedCopy";const Lc={".jpg":exports.FileViewerType.image,".jpeg":exports.FileViewerType.image,".png":exports.FileViewerType.image,".bmp":exports.FileViewerType.image,".gif":exports.FileViewerType.image,".svg":exports.FileViewerType.image,".webp":exports.FileViewerType.image,".wav":exports.FileViewerType.audio,".mp3":exports.FileViewerType.audio,".mp4":exports.FileViewerType.video,".webm":exports.FileViewerType.video,".ogg":exports.FileViewerType.video,".pdf":exports.FileViewerType.wopi,".ods":exports.FileViewerType.wopi,".xls":exports.FileViewerType.wopi,".xlsb":exports.FileViewerType.wopi,".xlsm":exports.FileViewerType.wopi,".xlsx":exports.FileViewerType.wopi,".doc":exports.FileViewerType.wopi,".docm":exports.FileViewerType.wopi,".docx":exports.FileViewerType.wopi,".dot":exports.FileViewerType.wopi,".dotm":exports.FileViewerType.wopi,".dotx":exports.FileViewerType.wopi,".odt":exports.FileViewerType.wopi,".odp":exports.FileViewerType.wopi,".pot":exports.FileViewerType.wopi,".potm":exports.FileViewerType.wopi,".potx":exports.FileViewerType.wopi,".pps":exports.FileViewerType.wopi,".ppsm":exports.FileViewerType.wopi,".ppsx":exports.FileViewerType.wopi,".ppt":exports.FileViewerType.wopi,".pptm":exports.FileViewerType.wopi,".pptx":exports.FileViewerType.wopi,".gdocs":exports.FileViewerType.onlineEditor,".gsheets":exports.FileViewerType.onlineEditor};function zc(e){const{t:a}=j.useTranslation();return e?Lc[e.toLowerCase()]??exports.FileViewerType.none:exports.FileViewerType.none}const Uc={".pdf":"wv/wordviewerframe.aspx?PdfMode=1&",".xls":"x/_layouts/xlviewerinternal.aspx?",".xlsb":"x/_layouts/xlviewerinternal.aspx?",".xlsm":"x/_layouts/xlviewerinternal.aspx?",".xlsx":"x/_layouts/xlviewerinternal.aspx?",".ods":"x/_layouts/xlviewerinternal.aspx?",".doc":"wv/wordviewerframe.aspx?",".docm":"wv/wordviewerframe.aspx?",".docx":"wv/wordviewerframe.aspx?",".dot":"wv/wordviewerframe.aspx?",".dotm":"wv/wordviewerframe.aspx?",".dotx":"wv/wordviewerframe.aspx?",".odt":"wv/wordviewerframe.aspx?",".ppt":"p/PowerPointFrame.aspx?",".pptm":"p/PowerPointFrame.aspx?",".pptx":"p/PowerPointFrame.aspx?",".pot":"p/PowerPointFrame.aspx?",".potm":"p/PowerPointFrame.aspx?",".potx":"p/PowerPointFrame.aspx?",".pps":"p/PowerPointFrame.aspx?",".ppsm":"p/PowerPointFrame.aspx?",".ppsx":"p/PowerPointFrame.aspx?",".odp":"p/PowerPointFrame.aspx?"};function Oc(e){const{t:a}=j.useTranslation();return Uc[e?.toLowerCase()]||""}function Vc(e){const{t:a}=j.useTranslation(),t=e%60;return`${Math.floor(e/60)}min ${t<10?"0":""}${t}`}function Bc({open:e,onOpenChange:s,url:r,title:n,className:o,minHeight:i="250px"}){const{t:l}=j.useTranslation(),c=t.useCallback(()=>{s(!1)},[s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&c()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,c]),a.jsx(bs,{open:e,onOpenChange:s,children:a.jsxs(Cs,{className:Gt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",o),children:[a.jsxs("div",{className:"flex items-center justify-end mb-2.5",children:[n&&a.jsx("h2",{className:"text-lg font-medium text-foreground truncate mr-auto",children:n}),a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(wr,{children:"Fechar"})]})]}),a.jsx("iframe",{src:r,className:"border-none w-full",style:{minHeight:i},title:n||l("embedded_content")})]})})}function qc({term:s,open:r,onClose:n,onSign:o,viewOnly:i=!1,title:l=e.t("terms_of_use"),signLabel:c=e.t("terms_read_agree")}){const u=t.useMemo(()=>s.file?function(e,a=""){const{t:t}=j.useTranslation(),s=atob(e),r=[];for(let o=0;o<s.length;o+=512){const e=s.slice(o,o+512),a=new Array(e.length);for(let t=0;t<e.length;t++)a[t]=e.charCodeAt(t);r.push(new Uint8Array(a))}const n=new Blob(r,{type:a});return URL.createObjectURL(n)}(s.file,s.type):null,[s.file,s.type]),m=t.useCallback(()=>{u&&URL.revokeObjectURL(u),n()},[u,n]),p=t.useCallback(()=>{s.hasUserSignature?m():o?.(s.id)},[s,o,m]),h=!i&&!s.hasUserSignature&&o;return a.jsx(bs,{open:r,onOpenChange:e=>!e&&m(),children:a.jsxs(Cs,{className:Gt("flex flex-col p-0 sm:max-w-[80vw] h-[95vh]","[&>button.absolute]:hidden"),children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[a.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[a.jsx(d.FileText,{className:"h-5 w-5 text-primary"}),l]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsx(Kt,{size:"sm",onClick:p,children:c}),a.jsx(Kt,{variant:"ghost",size:"icon",onClick:m,children:a.jsx(d.X,{className:"h-4 w-4"})})]})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s.file&&u?a.jsx("iframe",{className:"h-full w-full border-0",src:u,title:l}):a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a.jsx("p",{children:"Nenhum termo de uso ativo encontrado."})})})]})})}function $c(e){const{t:a}=j.useTranslation();return e.split(" ").slice(0,2).map(e=>e[0]?.toUpperCase()??"").join("")}function Wc(e){const{t:a}=j.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Hc(e){const{t:a}=j.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Gc(e){const{t:a}=j.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.allowedIds?.forEach(e=>t.add(e)),s.inheritedIds?.forEach(e=>t.add(e));return t}var Yc;exports.ReportRequestStatus=void 0,(Yc=exports.ReportRequestStatus||(exports.ReportRequestStatus={}))[Yc.WaitingProcessing=1]="WaitingProcessing",Yc[Yc.Processing=2]="Processing",Yc[Yc.Completed=3]="Completed",Yc[Yc.Error=4]="Error",Yc[Yc.Expired=5]="Expired";const Qc={report:e.t("report"),status:e.t("status"),requestDate:e.t("request_date"),lastUpdate:e.t("last_update"),expirationDate:e.t("expiration_date"),viewReport:e.t("view_report"),searchPlaceholder:e.t("search_report_placeholder"),noResults:e.t("no_reports_found"),statusWaiting:e.t("status_waiting"),statusProcessing:e.t("status_processing"),statusCompleted:e.t("status_completed"),statusError:e.t("status_error"),statusExpired:e.t("status_expired")};function Kc(e){const{t:a}=j.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Xc(e){const{t:a}=j.useTranslation();return e.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Jc={sm:{badge:"px-1.5 py-0.5 text-[11px] gap-1",icon:14},md:{badge:"px-2.5 py-1 text-xs gap-1.5",icon:16},lg:{badge:"px-3 py-1.5 text-sm gap-2",icon:18}};function Zc({label:e,color:t,icon:s,showIcon:r,size:n="md",variant:o="filled",backgroundColor:i,className:l}){const d=Jc[n],c=r??!!s;return a.jsxs("span",{className:Gt("inline-flex items-center rounded-md font-medium whitespace-nowrap","outline"===o&&"border",d.badge,l),style:(()=>{switch(o){case"outline":return{color:t,borderColor:qt(t,.3),backgroundColor:"transparent"};case"ghost":return{color:t,backgroundColor:"transparent"};default:return{color:t,backgroundColor:i||qt(t,.1)}}})(),children:[c&&s&&a.jsx(s,{size:d.icon,strokeWidth:2}),e]})}var eu,au,tu,su,ru,nu,ou,iu,lu,du,cu,uu,mu,pu,hu,xu,fu,gu,vu,bu,ju,yu,wu,Nu,_u;exports.AggregationType=void 0,(eu=exports.AggregationType||(exports.AggregationType={})).Count="valuecount",eu.Sum="sum",eu.Average="average",eu.DistinctCount="valuecount_distict",eu.Max="max",eu.Min="min",exports.AnalysisFunctionality=void 0,(exports.AnalysisFunctionality||(exports.AnalysisFunctionality={})).ViewAllAnalysis="nes3j6wn",exports.DashboardFunctionality=void 0,(au=exports.DashboardFunctionality||(exports.DashboardFunctionality={})).RegisterDashboards="EeKs7CYA",au.RemoveDashboards="3GKZYOQ9",au.ViewAllDashboards="wYBdQNvZ",au.EditDashboards="bMFcbwv4",exports.DashboardListType=void 0,(tu=exports.DashboardListType||(exports.DashboardListType={}))[tu.Default=1]="Default",tu[tu.Compact=2]="Compact",exports.DashboardPageTime=void 0,(su=exports.DashboardPageTime||(exports.DashboardPageTime={}))[su.FiveSeconds=1]="FiveSeconds",su[su.TenSeconds=2]="TenSeconds",su[su.FifteenSeconds=3]="FifteenSeconds",su[su.ThirtySeconds=4]="ThirtySeconds",su[su.OneMinute=5]="OneMinute",su[su.ThreeMinutes=6]="ThreeMinutes",su[su.FiveMinutes=7]="FiveMinutes",su[su.TenMinutes=8]="TenMinutes",exports.DashboardPanelDimension=void 0,(ru=exports.DashboardPanelDimension||(exports.DashboardPanelDimension={}))[ru.Day=1]="Day",ru[ru.Month=2]="Month",ru[ru.Year=3]="Year",exports.DashboardPanelOrderByType=void 0,(nu=exports.DashboardPanelOrderByType||(exports.DashboardPanelOrderByType={}))[nu.Ascending=1]="Ascending",nu[nu.Descending=2]="Descending",exports.DashboardPanelOrderBy=void 0,(ou=exports.DashboardPanelOrderBy||(exports.DashboardPanelOrderBy={}))[ou.Label=1]="Label",ou[ou.Value=2]="Value",exports.DashboardPanelPeriod=void 0,(iu=exports.DashboardPanelPeriod||(exports.DashboardPanelPeriod={}))[iu.LastSevenDays=1]="LastSevenDays",iu[iu.LastWeek=2]="LastWeek",iu[iu.LastMonth=3]="LastMonth",iu[iu.PreviousQuarter=4]="PreviousQuarter",iu[iu.PreviousSemester=5]="PreviousSemester",iu[iu.LastYear=6]="LastYear",iu[iu.SpecificPeriod=7]="SpecificPeriod",iu[iu.CurrentMonth=8]="CurrentMonth",iu[iu.CurrentSemester=9]="CurrentSemester",iu[iu.CurrentWeek=10]="CurrentWeek",iu[iu.CurrentYear=11]="CurrentYear",exports.DashboardPanelType=void 0,(lu=exports.DashboardPanelType||(exports.DashboardPanelType={}))[lu.Text=1]="Text",lu[lu.Area=2]="Area",lu[lu.Bar=3]="Bar",lu[lu.Column=4]="Column",lu[lu.StackedColumn=5]="StackedColumn",lu[lu.Line=6]="Line",lu[lu.List=7]="List",lu[lu.Numeric=8]="Numeric",lu[lu.Pareto=9]="Pareto",lu[lu.Pie=10]="Pie",lu[lu.RiskMatrix=11]="RiskMatrix",lu[lu.Burndown=12]="Burndown",lu[lu.PerformanceColumns=13]="PerformanceColumns",lu[lu.EvolutionLine=14]="EvolutionLine",exports.DashboardUpdateTime=void 0,(du=exports.DashboardUpdateTime||(exports.DashboardUpdateTime={}))[du.NotUpdate=1]="NotUpdate",du[du.FiveMinutes=2]="FiveMinutes",du[du.TenMinutes=3]="TenMinutes",du[du.FifteenMinutes=4]="FifteenMinutes",du[du.ThirtyMinutes=5]="ThirtyMinutes",du[du.OneHour=6]="OneHour",exports.DashboardViewType=void 0,(cu=exports.DashboardViewType||(exports.DashboardViewType={}))[cu.NormalPage=1]="NormalPage",cu[cu.Carousel=2]="Carousel",exports.DashboardFormTab=void 0,(uu=exports.DashboardFormTab||(exports.DashboardFormTab={}))[uu.General=0]="General",uu[uu.Share=1]="Share",exports.DashboardShareType=void 0,(mu=exports.DashboardShareType||(exports.DashboardShareType={}))[mu.NotShared=1]="NotShared",mu[mu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",mu[mu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.DashboardLanguage=void 0,(pu=exports.DashboardLanguage||(exports.DashboardLanguage={})).PtBr="pt-br",pu.EnUs="en",pu.EsEs="es",exports.MatrixViewType=void 0,(hu=exports.MatrixViewType||(exports.MatrixViewType={}))[hu.Quantity=0]="Quantity",hu[hu.AllRisksList=1]="AllRisksList",exports.PanelItemsPerPanel=void 0,(xu=exports.PanelItemsPerPanel||(exports.PanelItemsPerPanel={}))[xu.Five=5]="Five",xu[xu.Ten=10]="Ten",xu[xu.Fifteen=15]="Fifteen",xu[xu.Twenty=20]="Twenty",xu[xu.All=0]="All",xu[xu.Custom=-1]="Custom",exports.PanelSortType=void 0,(fu=exports.PanelSortType||(exports.PanelSortType={}))[fu.AlphabeticalAsc=1]="AlphabeticalAsc",fu[fu.AlphabeticalDesc=2]="AlphabeticalDesc",fu[fu.CountAsc=3]="CountAsc",fu[fu.CountDesc=4]="CountDesc",fu[fu.DateAsc=5]="DateAsc",fu[fu.DateDesc=6]="DateDesc",exports.PanelState=void 0,(gu=exports.PanelState||(exports.PanelState={}))[gu.Loading=0]="Loading",gu[gu.Loaded=1]="Loaded",gu[gu.Error=3]="Error",gu[gu.NoData=4]="NoData",gu[gu.Unavailable=5]="Unavailable",exports.VisualizationType=void 0,(vu=exports.VisualizationType||(exports.VisualizationType={}))[vu.Quantity=1]="Quantity",vu[vu.Percentage=2]="Percentage",vu[vu.QuantityPercentage=3]="QuantityPercentage",exports.PlanType=void 0,(bu=exports.PlanType||(exports.PlanType={}))[bu.Program=1]="Program",bu[bu.Project=2]="Project",bu[bu.Action=3]="Action",bu[bu.PerformanceProject=4]="PerformanceProject",bu[bu.PerformanceAction=5]="PerformanceAction",exports.QueriesContextType=void 0,(ju=exports.QueriesContextType||(exports.QueriesContextType={})).OccurrenceActionPlans="xebGnSSq",ju.OccurrenceGeneral="UFws4AvH",ju.PlansActionPlans="Kux6CcVC",ju.PlansProgramProjects="UWjrp6Dw",ju.PlansIdeas="3g7vNm2w",ju.RisksGeneral="PZ4b6FhP",ju.RisksActionPlans="xZErDg57",ju.RisksAnalysis="UxsioMbH",ju.RisksIncidences="gNt5IJ2F",ju.MetrologyGeneral="4MfEPbRY",ju.MetrologyActivities="hdFM9XQW",ju.MetrologyServiceOrders="cIrVPdMv",ju.DecisionsGeneral="CopsnHDB",ju.DecisionsItems="qLFAayjx",ju.DecisionsActionPlans="RiQFpxdb",ju.FlowGeneral="AFV98JoG",ju.AuditGeneral="gON8LJPi",ju.AuditPlans="SsCNVOvr",ju.AuditPlansItems="OpPkCCFm",ju.AuditActionPlans="P1oGePhh",ju.CommonGeneral="VVfEzgMQ",ju.ActionPlans="C6Z4MgGa",ju.SuppliersEvaluations="fSCeS4mH",ju.SuppliersGeneral="8qPThkrD",ju.SuppliersEvaluationsCriteria="RiSIStdY",ju.SuppliersDocuments="Riua4jMa",ju.SuppliersMaterialsServices="UpEkatXH",ju.DocumentsGeneral="FRhhEX2J",ju.DocumentsPhysicalCopies="PZLtJ23h",ju.DocumentsObsolete="XDjbga14",ju.FmeaGeneral="aPwf4uPr",ju.FmeaActionPlans="vQ8PMrVX",exports.QueriesShareType=void 0,(yu=exports.QueriesShareType||(exports.QueriesShareType={}))[yu.NotShared=1]="NotShared",yu[yu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",yu[yu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.QuickFilterDashboard=void 0,(wu=exports.QuickFilterDashboard||(exports.QuickFilterDashboard={}))[wu.All=1]="All",wu[wu.OnlyMine=2]="OnlyMine",wu[wu.Favorites=3]="Favorites",exports.RiskCriticality=void 0,(Nu=exports.RiskCriticality||(exports.RiskCriticality={}))[Nu.Current=1]="Current",Nu[Nu.Inherent=2]="Inherent",exports.PaletteType=void 0,(_u=exports.PaletteType||(exports.PaletteType={}))[_u.Default=1]="Default",_u[_u.Pastel=2]="Pastel",_u[_u.Vibrant=3]="Vibrant",_u[_u.Earth=4]="Earth",_u[_u.Ocean=5]="Ocean",_u[_u.Floral=6]="Floral",_u[_u.Night=7]="Night",_u[_u.Winter=8]="Winter",_u[_u.Spring=9]="Spring",_u[_u.Summer=10]="Summer",_u[_u.Fall=11]="Fall",_u[_u.Gray=12]="Gray",_u[_u.Brown=13]="Brown",_u[_u.Blue=14]="Blue",_u[_u.Yellow=15]="Yellow",_u[_u.Green=16]="Green",_u[_u.Purple=17]="Purple",_u[_u.Orange=18]="Orange",_u[_u.Pink=19]="Pink",_u[_u.Red=20]="Red";const Cu={jan:1,fev:2,mar:3,abr:4,mai:5,jun:6,jul:7,ago:8,set:9,out:10,nov:11,dez:12},ku=["total_calibration_cost","total_verification_cost","total_maintenance_cost","last_calibration_cost","last_verification_cost","last_maintenance_cost","total_cost","total_reported_cost","estimated_cost","last_report_cost_reported_cost","occurrence_reported_cost","task_estimated_cost"],Su=["link","link_risk","risk_link","link_group","group_link","link_occurrence","occurrence_link","link_audit","link_project","link_program","link_ideia","flow_link","decision_link","link_supplier","auditing_link","fmea_link"];function Tu(e){if(!e)return 0;const[a,t]=e.split("/"),s=Cu[a?.toLowerCase()]??0;return 12*(parseInt(t)||0)+s}function Pu(e){const a=e.split("/"),t=a[a.length-1];return`${a.slice(0,-1).join("/")}/${encodeURIComponent(t.replace(/[!@#$%^&*()_+={}[\]|\\;:'",.<>?/`~]/g,""))}`}function Du(e){for(const a of Su)if(e[a])return e[a];return null}function Eu(e){const a=[];for(const t of Object.keys(e)){const s=e[t];null!=s&&(s instanceof Date?a.push(`${t}=${s.toISOString()}`):Array.isArray(s)?s.forEach(e=>{a.push(...Eu({[t]:e}))}):"string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s||a.push(`${t}=${s}`))}return a}const Au=/^-?\d+(,\d{3})*(\.\d+)?$/;const Iu=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});const Mu=new Set([exports.DashboardPanelType.Text]),Fu=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.Numeric,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]),Ru=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]);function Lu({config:e,viewOnly:s=!1,complement:r,complementPosition:n="before-options",queryUrlBuilder:o,onRefresh:i,onExport:l,onToggleOnlyMine:c,className:u}){const{t:m}=j.useTranslation(),[p,h]=t.useState(e.onlyMine??!1),x=Mu.has(e.typeId),f=!Fu.has(e.typeId),g=!Ru.has(e.typeId),v=t.useMemo(()=>{if(!e.jsonRules||e.typeId===exports.DashboardPanelType.PerformanceColumns)return!1;try{const a=JSON.parse(e.jsonRules);return a?.rules?.rules?.length>0}catch{return!1}},[e.jsonRules,e.typeId]),b=t.useMemo(()=>o?.(e)??"#",[o,e]),y=t.useCallback(()=>{const e=!p;h(e),c?.(e)},[p,c]),w=[];return p&&w.push(m("dashboard_only_mine")),e.onlyLate&&w.push(m("dashboard_only_overdue")),v&&w.push(m("dashboard_advanced_filter")),a.jsxs("div",{className:Gt("flex items-center justify-between gap-2 border-b bg-muted/30 px-2.5 py-1 text-sm font-medium",u),children:[a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:["before-title"===n&&r,a.jsxs("div",{className:"flex min-w-0 flex-col",children:[a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx("span",{className:"block truncate",children:e.title})}),a.jsx(wr,{children:e.title})]}),w.length>0&&a.jsx("span",{className:"text-[9px] font-normal text-muted-foreground truncate",children:w.join(" | ")})]}),"after-title"===n&&r]}),!s&&a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:["before-options"===n&&r,a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-6 w-6",children:a.jsx(d.MoreVertical,{className:"h-3.5 w-3.5"})})}),a.jsxs(mr,{align:"end",className:"w-48",children:[e.canUpdate&&a.jsxs(pr,{onClick:()=>e.onEdit?.(e.id),children:[a.jsx(d.Pencil,{className:"mr-2 h-3.5 w-3.5"}),"Editar"]}),!x&&a.jsxs(pr,{onClick:i,children:[a.jsx(d.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),"Atualizar"]}),f&&a.jsxs(pr,{disabled:e.noData,onClick:l,children:[a.jsx(d.Download,{className:"mr-2 h-3.5 w-3.5"}),"Exportar"]}),!x&&a.jsxs(pr,{disabled:!e.openQueryEnabled,onClick:()=>window.open(b,"_blank"),children:[a.jsx(d.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Abrir consulta"]}),g&&a.jsxs(a.Fragment,{children:[a.jsx(gr,{}),a.jsxs(pr,{onClick:y,children:[p&&a.jsx(d.Check,{className:"mr-2 h-3.5 w-3.5"}),!p&&a.jsx("span",{className:"mr-2 w-3.5"}),"Somente meus"]})]}),e.canUpdate&&a.jsxs(a.Fragment,{children:[a.jsx(gr,{}),a.jsxs(pr,{onClick:()=>e.onDuplicate?.(e.id),children:[a.jsx(d.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Duplicar"]}),a.jsxs(pr,{className:"text-destructive",onClick:()=>e.onRemove?.(e.id),children:[a.jsx(d.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Remover"]})]})]})]}),"after-options"===n&&r]})]})}function zu({config:e,queryUrl:t,className:s}){return a.jsxs("div",{className:Gt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"Erro ao exibir os dados."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"A consulta não pôde ser realizada."}),a.jsxs("p",{className:"mt-2 text-xs",children:[t&&a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:"Verificar a consulta"}),t&&e.canUpdate&&a.jsx("span",{className:"text-muted-foreground",children:" ou "}),e.canUpdate&&a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>e.onEdit?.(e.id),children:"revisar o painel"})]})]})}function Uu({panelType:e,className:t}){const s=e===exports.DashboardPanelType.Burndown;return a.jsxs("div",{className:Gt("flex flex-1 flex-col items-center justify-center gap-2 p-4",t),children:[a.jsx(ar,{className:"h-10 w-10 text-muted-foreground/40"}),s&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Aguarde, processando dados..."})]})}function Ou({hasRemovedColumn:t=!1,className:s}){return a.jsxs("div",{className:Gt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx("h2",{className:"text-lg font-normal text-foreground/80 lg:text-base",children:e.t("no_data_to_display")}),a.jsx("p",{className:"text-sm text-muted-foreground lg:text-xs",children:e.t("dashboard_no_data")})]})}function Vu({onRemove:e,className:t}){return a.jsxs("div",{className:Gt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",t),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"A consulta não pôde ser realizada."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Este recurso não está disponível."}),e&&a.jsx("p",{className:"mt-2 text-xs",children:a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:e,children:"Remover painel"})})]})}const Bu={[exports.AggregationType.Count]:e.t("dashboard_distinct_count").replace("distinta","").trim()||"Count",[exports.AggregationType.Sum]:"Sum",[exports.AggregationType.Average]:e.t("dashboard_average"),[exports.AggregationType.DistinctCount]:e.t("dashboard_distinct_count"),[exports.AggregationType.Max]:e.t("dashboard_max_value"),[exports.AggregationType.Min]:e.t("dashboard_min_value")};function qu({config:e,state:t,value:s,label:r,viewOnly:n=!1,onClick:o,onRefresh:i,queryUrl:l,queryUrlBuilder:d,className:c}){const{t:u}=j.useTranslation(),m=r??Bu[e.aggregationType??""]??"",p=function(e,a){if(null==e)return"—";const t=ku.includes(a.field),s=a.aggregationType===exports.AggregationType.Count||a.aggregationType===exports.AggregationType.DistinctCount;return t&&!s?Iu.format("string"==typeof e?parseFloat(e):e):"number"==typeof e?s?String(e):e.toLocaleString("pt-BR",{maximumFractionDigits:2}):String(e)}(s,e);return a.jsxs("div",{className:Gt("flex h-full flex-col",c),children:[a.jsx(Lu,{config:e,viewOnly:n,onRefresh:i,queryUrlBuilder:d}),t===exports.PanelState.Loading&&a.jsx(Uu,{}),t===exports.PanelState.Loaded&&a.jsxs("div",{className:Gt("flex flex-1 flex-col items-center justify-center",o&&"cursor-pointer hover:bg-muted/20 transition-colors"),onClick:o,children:[a.jsx("span",{className:"text-[clamp(1.5rem,7vh,5rem)] font-bold text-foreground leading-tight",children:p}),m&&a.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:m})]}),t===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:l}),t===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function $u({config:e,state:t,htmlContent:s,viewOnly:r=!1,onRefresh:n,queryUrl:o,queryUrlBuilder:i,className:l}){const d=s??e.textTypeString??"";return a.jsxs("div",{className:Gt("flex h-full flex-col",l),children:[a.jsx(Lu,{config:e,viewOnly:r,onRefresh:n,queryUrlBuilder:i}),t===exports.PanelState.Loading&&a.jsx(Uu,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 prose prose-sm max-w-none text-foreground",dangerouslySetInnerHTML:{__html:d}}),t===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:o})]})}function Wu({config:e,state:s,data:r=[],columns:n=[],viewOnly:o=!1,onRowClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,enableRowLinks:m=!0,className:p}){const h=t.useMemo(()=>n.filter(e=>!1!==e.visible),[n]),x=t.useCallback(e=>{if(i)i(e);else if(m){const a=Du(e);a&&window.open(Pu(a),"_blank")}},[i,m]);return a.jsxs("div",{className:Gt("flex h-full flex-col",p),children:[a.jsx(Lu,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(Uu,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 bg-muted/60 backdrop-blur-sm",children:a.jsx("tr",{children:h.map(e=>a.jsx("th",{className:"px-2 py-1.5 text-left text-xs font-medium text-muted-foreground whitespace-nowrap border-b",children:e.header||e.columnLabel||e.columnName},e.columnName))})}),a.jsx("tbody",{children:r.map((e,t)=>{const s=m&&!!Du(e);return a.jsx("tr",{className:Gt("border-b border-border/50 transition-colors hover:bg-muted/30",(s||i)&&"cursor-pointer"),onClick:()=>x(e),children:h.map(t=>a.jsx("td",{className:"px-2 py-1.5 text-foreground whitespace-nowrap truncate max-w-[200px]",children:t.render?t.render(e[t.columnName],e):Hu(e[t.columnName],t)},t.columnName))},t)})})]})}),s===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function Hu(e,a){return null==e?"":e instanceof Date?"datetime"===a.columnType?e.toLocaleString("pt-BR"):e.toLocaleDateString("pt-BR"):"number"==typeof e?e.toLocaleString("pt-BR"):String(e)}const Gu=["hsl(var(--primary))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))","#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3"];function Yu({config:e,variant:s,state:r,data:n=[],series:o,colors:i,categoryKey:l="key",yAxisFormat:d,viewOnly:c=!1,onPointClick:u,onRefresh:m,onExport:p,queryUrl:h,queryUrlBuilder:x,className:f}){const g=i?.length?i:e.hexColors?.length?e.hexColors:Gu,v=t.useMemo(()=>o?.length?o:[{dataKey:"value",name:e.title}],[o,e.title]),b="bar"===s,j="stacked-column"===s,y=t.useMemo(()=>{if(d)return e=>d.replace("{value}",e.toLocaleString("pt-BR"))},[d]);return a.jsxs("div",{className:Gt("flex h-full flex-col",f),children:[a.jsx(Lu,{config:e,viewOnly:c,onRefresh:m,onExport:p,queryUrlBuilder:x}),r===exports.PanelState.Loading&&a.jsx(Uu,{}),r===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:Qu({variant:s,data:n,series:v,colors:g,categoryKey:l,isHorizontalBar:b,isStacked:j,yAxisTickFormatter:y,tooltipFormatter:e=>"number"==typeof e?e.toLocaleString("pt-BR"):String(e??""),onPointClick:u})})}),r===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),r===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:h}),r===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function Qu({variant:e,data:t,series:s,colors:r,categoryKey:n,isHorizontalBar:o,isStacked:i,yAxisTickFormatter:l,tooltipFormatter:d,onPointClick:c}){const u={tick:{fontSize:11},tickLine:!1,axisLine:!1},m=a.jsx(B.XAxis,{dataKey:o?void 0:n,type:o?"number":"category",...u,angle:o?0:-45,textAnchor:o?"middle":"end",height:o?void 0:60,tickFormatter:o?l:void 0}),p=a.jsx(B.YAxis,{dataKey:o?n:void 0,type:o?"category":"number",...u,width:o?100:60,tickFormatter:o?void 0:l}),h=a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),x=a.jsx(B.Tooltip,{formatter:d,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),f=s.length>1?a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}):null,g=c?(e,a)=>c(t[a],a):void 0;return"bar"===e||"column"===e||"stacked-column"===e?a.jsxs(B.BarChart,{data:t,layout:o?"vertical":"horizontal",margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(B.Bar,{dataKey:e.dataKey,name:e.name||e.dataKey,fill:e.color||r[t%r.length],stackId:i?e.stackId||"stack":void 0,radius:i?void 0:[2,2,0,0],onClick:g,cursor:c?"pointer":void 0},e.dataKey))]}):"area"===e?a.jsxs(B.AreaChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>{const s=e.color||r[t%r.length];return a.jsx(B.Area,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:s,fill:s,fillOpacity:.15,strokeWidth:2,dot:!1,activeDot:{r:4,cursor:c?"pointer":void 0}},e.dataKey)})]}):a.jsxs(B.LineChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(B.Line,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:e.color||r[t%r.length],strokeWidth:2,dot:{r:3},activeDot:{r:5,cursor:c?"pointer":void 0}},e.dataKey))]})}const Ku=["#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3","#b2df8a","#fb9a99","#fdbf6f","#cab2d6","#ffff99"];function Xu({config:e,state:s,data:r=[],colors:n,viewOnly:o=!1,onSliceClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,className:m}){const p=n?.length?n:e.hexColors?.length?e.hexColors:Ku,h=t.useMemo(()=>r.map(e=>({...e,name:String(e.key??""),value:e.value??0})),[r]),x=t.useMemo(()=>h.reduce((e,a)=>e+(a.value??0),0),[h]);return a.jsxs("div",{className:Gt("flex h-full flex-col",m),children:[a.jsx(Lu,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(Uu,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.PieChart,{children:[a.jsx(B.Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:"80%",label:({name:e,percent:a})=>`${e??""}: ${(100*(a??0)).toFixed(0)}%`,labelLine:!0,onClick:i?(e,a)=>i(r[a],a):void 0,cursor:i?"pointer":void 0,children:h.map((e,t)=>a.jsx(B.Cell,{fill:p[t%p.length]},t))}),a.jsx(B.Tooltip,{formatter:e=>{const a="number"==typeof e?e:0,t=x>0?(a/x*100).toFixed(1):"0";return`${a.toLocaleString("pt-BR")} (${t}%)`}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}})]})})}),s===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ju({config:e,state:s,data:r=[],barColor:n,lineColor:o="#e31a1c",viewOnly:i=!1,onPointClick:l,onRefresh:d,onExport:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=e.hexColors?.length?e.hexColors:["#1f78b4"],x=n??h[0],f=t.useMemo(()=>{const e=[...r].sort((e,a)=>(a.value??0)-(e.value??0)),a=e.reduce((e,a)=>e+(a.value??0),0);let t=0;return e.map(e=>(t+=e.value??0,{key:String(e.key??""),value:e.value??0,cumulativePercent:a>0?Math.round(t/a*100):0}))},[r]);return a.jsxs("div",{className:Gt("flex h-full flex-col",p),children:[a.jsx(Lu,{config:e,viewOnly:i,onRefresh:d,onExport:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(Uu,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.ComposedChart,{data:f,margin:{top:5,right:30,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"key",tick:{fontSize:11},angle:-45,textAnchor:"end",height:60}),a.jsx(B.YAxis,{yAxisId:"left",tick:{fontSize:11},tickLine:!1,axisLine:!1}),a.jsx(B.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(B.Tooltip,{formatter:(e,a)=>"% Acumulado"===a?`${e}%`:"number"==typeof e?e.toLocaleString("pt-BR"):e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Bar,{yAxisId:"left",dataKey:"value",name:"Quantidade",fill:x,radius:[2,2,0,0],onClick:l?(e,a)=>l(r[a],a):void 0,cursor:l?"pointer":void 0}),a.jsx(B.Line,{yAxisId:"right",type:"monotone",dataKey:"cumulativePercent",name:"% Acumulado",stroke:o,strokeWidth:2,dot:{r:3,fill:o}})]})})}),s===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function Zu({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onRefresh:d,queryUrl:c,queryUrlBuilder:u,className:m}){const{t:p}=j.useTranslation(),h=r??p("dashboard_work_done"),x=n??p("dashboard_work_planned");return a.jsxs("div",{className:Gt("flex h-full flex-col",m),children:[a.jsx(Lu,{config:e,viewOnly:l,onRefresh:d,queryUrlBuilder:u}),t===exports.PanelState.Loading&&a.jsx(Uu,{panelType:exports.DashboardPanelType.Burndown}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.AreaChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"date",tick:{fontSize:10},angle:-45,textAnchor:"end",height:50}),a.jsx(B.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(B.Tooltip,{formatter:e=>`${e}%`,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Area,{type:"monotone",dataKey:"executedPercentage",name:h,stroke:o,fill:o,fillOpacity:.2,strokeWidth:2,dot:{r:3}}),a.jsx(B.Area,{type:"monotone",dataKey:"plannedPercentage",name:x,stroke:i,fill:i,fillOpacity:.1,strokeWidth:2,dot:{r:3}})]})})}),t===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:c}),t===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function em({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onPointClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const{t:h}=j.useTranslation(),x=r??h("dashboard_work_done"),f=n??h("dashboard_work_planned");return a.jsxs("div",{className:Gt("flex h-full flex-col",p),children:[a.jsx(Lu,{config:e,viewOnly:l,onRefresh:c,queryUrlBuilder:m}),t===exports.PanelState.Loading&&a.jsx(Uu,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.BarChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"name",tick:{fontSize:10},angle:-45,textAnchor:"end",height:60}),a.jsx(B.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`}),a.jsx(B.Tooltip,{formatter:e=>"number"==typeof e?`${e}%`:e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Bar,{dataKey:"executedWork",name:x,fill:o,radius:[2,2,0,0],onClick:d?(e,a)=>d(s[a],a):void 0,cursor:d?"pointer":void 0}),a.jsx(B.Bar,{dataKey:"plannedWork",name:f,fill:i,radius:[2,2,0,0]})]})})}),t===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:u}),t===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}function am({config:e,state:s,rule:r,risks:n=[],matrixViewType:o=exports.MatrixViewType.Quantity,viewOnly:i=!1,onCellClick:l,onRiskClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=t.useMemo(()=>[...r?.parametersY??[]].sort((e,a)=>a.position-e.position),[r?.parametersY]),x=r?.parametersX??[],f=t.useMemo(()=>{const e={};return n.forEach(a=>{const t=`${a.parameterYPosition}-${a.parameterXPosition}`;e[t]||(e[t]=[]),e[t].push(a)}),e},[n]);return a.jsxs("div",{className:Gt("flex h-full flex-col",p),children:[a.jsx(Lu,{config:e,viewOnly:i,onRefresh:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(Uu,{}),s===exports.PanelState.Loaded&&r&&a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsxs("div",{className:"flex gap-4 items-stretch min-w-fit",children:[a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"text-xs font-medium text-muted-foreground [writing-mode:vertical-lr] rotate-180",children:r.name_y})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex mb-1",children:[a.jsx("div",{className:"w-16 shrink-0"}),a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.threat_strategy_type_name}),!r.disable_opportunities&&a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.opportunity_strategy_type_name})]}),h.map((e,t)=>a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0 flex items-center justify-center border border-border/50 text-xs font-medium p-1 text-center",children:e.name}),x.map((s,n)=>{const i=((e,a)=>f[`${a.position}-${e.position}`]??[])(s,e),c=((e,a)=>r?.colorMatrix?.[a]?.[e]??"hsl(var(--muted))")(n,t);return a.jsxs("div",{className:Gt("flex-1 min-w-[60px] min-h-[40px] border border-border/50 flex flex-col items-center justify-center gap-0.5 p-1",(l||d)&&i.length>0&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:c},onClick:()=>i.length>0&&l?.(s,e,i),children:[o===exports.MatrixViewType.Quantity&&i.length>0&&a.jsxs("span",{className:"text-xs font-semibold",children:[i.length," risco",1!==i.length?"s":""]}),o===exports.MatrixViewType.AllRisksList&&i.map(e=>a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx("button",{type:"button",className:"text-[10px] text-primary underline hover:text-primary/80",onClick:a=>{a.stopPropagation(),d?.(e)},children:e.code})}),a.jsxs(wr,{className:"max-w-[250px]",children:[a.jsxs("p",{className:"font-medium",children:[e.code," - ",e.name]}),e.analysisDate&&a.jsxs("p",{className:"text-xs mt-1",children:["Última análise: ",a.jsx("strong",{children:e.analysisDate})]}),e.strategy&&a.jsxs("p",{className:"text-xs",children:["Estratégia: ",a.jsx("strong",{children:e.strategy})]}),e.resultName&&a.jsxs("p",{className:"text-xs",children:["Criticidade: ",a.jsx("strong",{style:{backgroundColor:c},className:"px-1 rounded",children:e.resultName})]})]})]},e.code))]},s.position)})]},e.position)),a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0"}),x.map(e=>a.jsx("div",{className:"flex-1 min-w-[60px] border border-border/50 text-xs font-medium p-1 text-center",children:e.name},e.position))]}),a.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground mt-2",children:r.name_x})]})]})}),s===exports.PanelState.NoData&&a.jsx(Ou,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(zu,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(Vu,{onRemove:()=>e.onRemove?.(e.id)})]})}const tm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:a,y:t}=e;return"translate3d("+(a?Math.round(a):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:a,scaleY:t}=e;return"scaleX("+a+") scaleY("+t+")"}},Transform:{toString(e){if(e)return[tm.Translate.toString(e),tm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:a,duration:t,easing:s}=e;return a+" "+t+"ms "+s}}});function sm(e){switch(Number(e)){case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Numeric:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.Text:return{x:1,y:1};default:return{x:2,y:2}}}function rm({panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:i}){const{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:m,isDragging:p}=X.useSortable({id:e.id,disabled:!o}),h=t.useMemo(()=>({gridColumn:`${e.col+1} / span ${e.sizeX}`,gridRow:`${e.row+1} / span ${e.sizeY}`,minHeight:e.sizeY*r+(e.sizeY-1)*n+"px",transform:tm.Transform.toString(u),transition:m,zIndex:p?50:void 0,opacity:p?.85:1}),[e,s,r,n,u,m,p]);return a.jsxs("div",{ref:c,style:h,className:Gt("rounded-lg border border-border bg-card shadow-sm overflow-hidden","transition-shadow duration-200",p&&"shadow-lg ring-2 ring-primary/20"),...l,children:[a.jsx("div",{className:Gt("dashboard-panel-drag-handle",o&&"cursor-grab active:cursor-grabbing"),...o?d:{}}),a.jsx("div",{className:"h-full",children:i})]})}function nm({panels:e,columns:s=8,cellHeight:r=160,cellGap:n=10,allowDragging:o=!1,showGridLines:i=!1,renderPanel:l,onLayoutChange:d,className:c}){const[u,m]=t.useState(e);t.useMemo(()=>{m(e)},[e]);const p=K.useSensors(K.useSensor(K.PointerSensor,{activationConstraint:{distance:8}})),h=t.useMemo(()=>0===u.length?1:Math.max(...u.map(e=>e.row+e.sizeY)),[u]),x=t.useMemo(()=>u.map(e=>e.id),[u]),f=t.useCallback(e=>{const{active:a,over:t}=e;if(!t||a.id===t.id)return;const s=u.findIndex(e=>e.id===a.id),r=u.findIndex(e=>e.id===t.id);if(-1===s||-1===r)return;const n=[...u],o={...n[s]},i={...n[r]},l=o.col,c=o.row;o.col=i.col,o.row=i.row,i.col=l,i.row=c,n[s]=o,n[r]=i,m(n),d?.(n)},[u,d]),g=t.useMemo(()=>({display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gridTemplateRows:`repeat(${h}, ${r}px)`,gap:`${n}px`}),[s,h,r,n]);return 0===u.length?a.jsxs("div",{className:Gt("flex flex-col items-center justify-center py-16 text-center",c),children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Nenhum painel adicionado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione painéis para visualizar seus dados aqui."})]}):a.jsx(K.DndContext,{sensors:p,collisionDetection:K.closestCenter,onDragEnd:f,children:a.jsx(X.SortableContext,{items:x,strategy:X.rectSortingStrategy,children:a.jsx("div",{style:g,className:Gt("relative w-full",i&&"bg-muted/30",c),children:u.map(e=>a.jsx(rm,{panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:l(e.id)},e.id))})})})}const om={[exports.DashboardPanelType.Bar]:"bar",[exports.DashboardPanelType.Column]:"column",[exports.DashboardPanelType.StackedColumn]:"stacked-column",[exports.DashboardPanelType.Area]:"area",[exports.DashboardPanelType.Line]:"line",[exports.DashboardPanelType.EvolutionLine]:"evolution-line"};function im({config:e,state:t,data:s,numericValue:r,listColumns:n,cartesianData:o,cartesianSeries:i,burndownData:l,performanceData:d,matrixRule:c,matrixRisks:u,onPanelClick:m}){const p=om[e.typeId];if(p)return a.jsx(Yu,{config:e,variant:p,state:t,data:o,series:i});switch(e.typeId){case exports.DashboardPanelType.Numeric:return a.jsx(qu,{config:e,state:t,value:r});case exports.DashboardPanelType.Text:return a.jsx($u,{config:e,state:t});case exports.DashboardPanelType.List:return a.jsx(Wu,{config:e,state:t,data:s,columns:n??[]});case exports.DashboardPanelType.Pie:return a.jsx(Xu,{config:e,state:t,data:s});case exports.DashboardPanelType.Pareto:return a.jsx(Ju,{config:e,state:t,data:s});case exports.DashboardPanelType.Burndown:return a.jsx(Zu,{config:e,state:t,data:l});case exports.DashboardPanelType.PerformanceColumns:return a.jsx(em,{config:e,state:t,data:d});case exports.DashboardPanelType.RiskMatrix:return a.jsx(am,{config:e,state:t,rule:c,risks:u??[]});default:return a.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:["Tipo de painel não suportado (",e.typeId,")"]})}}function lm({dashboard:e,panels:s,pages:r,activePageId:n,canEdit:o=!1,isFullscreen:i=!1,isLoading:l=!1,getPanelData:d,onRefresh:c,onToggleFullscreen:u,onToggleFavorite:m,onEdit:p,onShare:h,onAddPanel:x,onEditPanel:f,onRemovePanel:g,onDuplicatePanel:v,onLayoutChange:b,onPageChange:y,toolbarActions:w,className:N}){const{t:_}=j.useTranslation(),[C,k]=t.useState(!1),S=e.idViewType===exports.DashboardViewType.Carousel,T=t.useMemo(()=>s,[s,S,n]),P=t.useMemo(()=>T.map(e=>{const a=sm(e.typeId);return{id:e.id,col:e.col,row:e.row,sizeX:e.sizeX,sizeY:e.sizeY,minSizeX:a.x,minSizeY:a.y}}),[T]),D=t.useCallback(e=>({id:e.id,title:e.titlePtBr||e.titleEnUs||e.titleEsEs,typeId:e.typeId,queryId:e.queryId,queryContextId:e.queryContextId,queryTitle:e.queryTitle,querySelectedColumns:e.querySelectedColumns,field:e.field??"",fieldType:e.fieldType??"",fieldAuxAxis:e.fieldAuxAxis,fieldAuxAxisType:e.fieldAuxAxisType,aggregationType:e.aggregationType,textTypeString:e.textTypeString,referenceDate:e.referenceDate,period:e.period,initialDate:e.initialDate,finalDate:e.finalDate,dimension:e.dimension,yAxis:e.yAxis,yAxisType:e.yAxisType,orderBy:e.orderBy,orderByType:e.orderByType,secondaryGrouping:e.secondaryGrouping,secondaryGroupingType:e.secondaryGroupingType,onlyLate:e.onlyLate,jsonRules:e.jsonRules,ignoreRules:e.ignoreRules,visualizationType:e.visualizationType,sortType:e.sortType,itemsPerPanel:e.itemsPerPanel,secondaryItemsPerPanel:e.secondaryItemsPerPanel,matrixViewRule:e.matrixViewRule,listPanelColumns:e.listPanelColumns,listPanelListType:e.listPanelListType,paletteId:e.paletteId,hexColors:e.hexColors,showNotInformedData:e.showNotInformedData,fieldAnalysisRule:e.fieldAnalysisRule,fieldCriticality:e.fieldCriticality,fieldPlansType:e.fieldPlansType,fieldPlansSelected:e.fieldPlansSelected,fieldPlansBurndown:e.fieldPlansBurndown,fieldPlansBurndownGroup:e.fieldPlansBurndownGroup,analysisCriteriaId:e.analysisCriteriaId,analysisCriteriaParameter:e.analysisCriteriaParameter,evolutionSecondaryGrouping:e.evolutionSecondaryGrouping,canUpdate:o,hasRemovedColumn:e.hasRemovedColumn,panelSize:{x:e.sizeX,y:e.sizeY},onEdit:f,onRemove:g,onDuplicate:v}),[o,f,g,v]),E=t.useCallback(()=>{C||l||(k(!0),c?.(),setTimeout(()=>k(!1),3e4))},[C,l,c]),A=t.useCallback(e=>{const t=T.find(a=>a.id===e);if(!t)return null;const s=D(t),r=d?.(e)??{state:exports.PanelState.Loaded};return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(Lu,{config:s,onRefresh:()=>{}}),a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(im,{config:s,...r})})]})},[T,D,d,o,f,g,v]);return a.jsxs("div",{className:Gt("flex flex-col h-full",i&&"fixed inset-0 z-50 bg-background",N),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:e.title}),e.responsibleName&&!i&&a.jsx("span",{className:"text-xs text-muted-foreground truncate hidden sm:inline",children:e.responsibleName})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[w,c&&a.jsx("button",{onClick:E,disabled:C||l,className:Gt("inline-flex items-center justify-center rounded-md p-2 text-sm","hover:bg-accent hover:text-accent-foreground transition-colors","disabled:opacity-50 disabled:pointer-events-none"),title:C?_("dashboard_wait_refresh"):"Atualizar",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m0 0a9 9 0 0 1 9-9m-9 9a9 9 0 0 0 9 9"})})}),u&&a.jsx("button",{onClick:u,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:i?_("dashboard_exit_fullscreen"):"Fullscreen",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i?a.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"}):a.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),o&&!i&&h&&a.jsx("button",{onClick:h,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:"Compartilhar",children:a.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),m&&!i&&a.jsx("button",{onClick:m,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:e.isFavorite?_("dashboard_remove_favorite"):"Favoritar",children:a.jsx("svg",{className:Gt("h-4 w-4",e.isFavorite&&"fill-yellow-400 text-yellow-400"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})]})]}),S&&r&&r.length>1&&a.jsx("div",{className:"flex items-center gap-1 px-4 py-1 border-b border-border bg-card overflow-x-auto",children:r.map(e=>a.jsx("button",{onClick:()=>y?.(e.id),className:Gt("px-3 py-1.5 text-sm rounded-md whitespace-nowrap transition-colors",n===e.id?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:e.name||`Dashboard ${e.position}`},e.id))}),o&&!i&&x&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsxs("button",{onClick:x,className:Gt("inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Adicionar painel"]})}),l&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!l&&a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted/30",children:a.jsx(nm,{panels:P,allowDragging:o,showGridLines:o,renderPanel:A,onLayoutChange:b})})]})}function dm(e,a=exports.DashboardLanguage.PtBr){const{t:t}=j.useTranslation();switch(a){case exports.DashboardLanguage.EnUs:return e.titleEnUs||e.titlePtBr||e.titleEsEs;case exports.DashboardLanguage.EsEs:return e.titleEsEs||e.titleEnUs||e.titlePtBr;default:return e.titlePtBr||e.titleEnUs||e.titleEsEs}}function cm(e){const{t:a}=j.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}const um=[{value:exports.QuickFilterDashboard.All,label:"Todos"},{value:exports.QuickFilterDashboard.OnlyMine,label:e.t("dashboard_my")},{value:exports.QuickFilterDashboard.Favorites,label:"Favoritos"}];function mm({dashboards:e,limit:s,isLoading:r=!1,language:n=exports.DashboardLanguage.PtBr,canAdd:o=!1,canEdit:i=!1,canRemove:l=!1,onOpen:d,onEdit:c,onShare:u,onDuplicate:m,onRemove:p,onAdd:h,onToggleFavorite:x,onRefresh:f,onSearch:g,onQuickFilterChange:v,toolbarExtra:b,className:y}){const{t:w}=j.useTranslation(),[N,_]=t.useState(""),[C,k]=t.useState(exports.QuickFilterDashboard.All),[S,T]=t.useState(null),P=t.useCallback(e=>{_(e),g?.(e)},[g]),D=t.useCallback(e=>{k(e),v?.(e)},[v]),E=t.useMemo(()=>{let a=e;if(N){const e=N.toLowerCase();a=a.filter(a=>a.code?.toLowerCase().includes(e)||dm(a,n).toLowerCase().includes(e)||a.responsibleName?.toLowerCase().includes(e))}switch(C){case exports.QuickFilterDashboard.OnlyMine:break;case exports.QuickFilterDashboard.Favorites:a=a.filter(e=>e.isFavorite)}return a},[e,N,C,n]);return a.jsxs("div",{className:Gt("flex flex-col h-full",y),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboards"}),s&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.countDashboards,"/",s.maxDashboards,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative",children:[a.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"m21 21-4.3-4.3"})]}),a.jsx("input",{type:"text",placeholder:"Buscar...",value:N,onChange:e=>P(e.target.value),className:Gt("h-9 w-48 rounded-md border border-input bg-background pl-9 pr-3 text-sm","placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")})]}),b,o&&h&&a.jsxs("button",{onClick:h,className:Gt("inline-flex items-center gap-1.5 px-3 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Novo"]})]})]}),a.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-card",children:um.map(e=>a.jsx("button",{onClick:()=>D(e.value),disabled:r,className:Gt("px-3 py-1.5 text-sm rounded-md transition-colors",C===e.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground","disabled:opacity-50"),children:e.label},e.value))}),r&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!r&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-muted/80 backdrop-blur-sm border-b border-border",children:a.jsxs("tr",{children:[a.jsx("th",{className:"w-12 px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Código"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Título"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Responsável"}),a.jsx("th",{className:"w-12 px-3 py-2 text-center font-medium text-muted-foreground",children:a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Última modificação"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Situação"}),a.jsx("th",{className:"w-12 px-3 py-2"})]})}),a.jsxs("tbody",{children:[0===E.length&&a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-3 py-12 text-center text-muted-foreground",children:"Nenhum dashboard encontrado."})}),E.map(e=>a.jsxs("tr",{onClick:()=>d?.(e),className:Gt("border-b border-border cursor-pointer transition-colors","hover:bg-accent/50"),children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),x?.(e)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsx("svg",{className:Gt("h-4 w-4",e.isFavorite?"fill-yellow-400 text-yellow-400":"text-muted-foreground"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-foreground",children:e.code}),a.jsx("td",{className:"px-3 py-2 text-foreground font-medium",children:dm(e,n)}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:e.responsibleName}),a.jsx("td",{className:"px-3 py-2 text-center",children:e.hasSharedIcon&&a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:cm(e.lastModified)}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("span",{className:Gt("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",e.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),children:e.isActive?"Ativo":"Inativo"})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(S===e.id?null:e.id)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsxs("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"5",r:"1"}),a.jsx("circle",{cx:"12",cy:"12",r:"1"}),a.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),S===e.id&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>T(null)}),a.jsxs("div",{className:"absolute right-0 top-8 z-50 min-w-[160px] rounded-md border border-border bg-popover shadow-md py-1",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),d?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Abrir"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),c?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Editar"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),u?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Compartilhar"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),m?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Duplicar"}),l&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"my-1 border-t border-border"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),p?.(e)},className:"w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-destructive/10 transition-colors",children:"Remover"})]})]})]})]})})]},e.id))]})]})})]})}const pm=[{value:exports.DashboardUpdateTime.NotUpdate,label:e.t("dashboard_no_refresh")},{value:exports.DashboardUpdateTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardUpdateTime.TenMinutes,label:"10 minutos"},{value:exports.DashboardUpdateTime.FifteenMinutes,label:"15 minutos"},{value:exports.DashboardUpdateTime.ThirtyMinutes,label:"30 minutos"},{value:exports.DashboardUpdateTime.OneHour,label:"1 hora"}],hm=[{value:exports.DashboardViewType.NormalPage,label:e.t("dashboard_normal_page")},{value:exports.DashboardViewType.Carousel,label:"Carrossel"}],xm=[{value:exports.DashboardPageTime.FiveSeconds,label:"5 segundos"},{value:exports.DashboardPageTime.TenSeconds,label:"10 segundos"},{value:exports.DashboardPageTime.FifteenSeconds,label:"15 segundos"},{value:exports.DashboardPageTime.ThirtySeconds,label:"30 segundos"},{value:exports.DashboardPageTime.OneMinute,label:"1 minuto"},{value:exports.DashboardPageTime.ThreeMinutes,label:"3 minutos"},{value:exports.DashboardPageTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardPageTime.TenMinutes,label:"10 minutos"}],fm=[{value:exports.DashboardShareType.NotShared,label:e.t("dashboard_not_shared"),description:e.t("dashboard_only_responsible")},{value:exports.DashboardShareType.SharedWithAllCollaborators,label:e.t("dashboard_shared_unit"),description:e.t("dashboard_all_access")},{value:exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators,label:e.t("dashboard_select_groups"),description:e.t("dashboard_select_groups")}],gm=[{key:"pt-br",label:"PT-BR"},{key:"en",label:"EN-US"},{key:"es",label:"ES-ES"}];function vm({dashboard:e,initialTab:s=exports.DashboardFormTab.General,isSaving:r=!1,isQualitfy:n=!1,users:o=[],groups:i=[],places:l=[],collaborators:d=[],onSave:c,onCancel:u,className:m}){const{t:p}=j.useTranslation(),h=!!e,[x,f]=t.useState(s),[g,v]=t.useState({"pt-br":!!e?.titlePtBr||!h,en:!!e?.titleEnUs,es:!!e?.titleEsEs}),[b,y]=t.useState(e?.titlePtBr??""),[w,N]=t.useState(e?.titleEnUs??""),[_,C]=t.useState(e?.titleEsEs??""),[k,S]=t.useState(e?.responsibleId??""),[T,P]=t.useState(e?.isActive??!0),[D,E]=t.useState(e?.idUpdateTime??exports.DashboardUpdateTime.NotUpdate),[A,I]=t.useState(e?.idViewType??exports.DashboardViewType.NormalPage),[M,F]=t.useState(e?.idPageTime??exports.DashboardPageTime.FifteenSeconds),[R,L]=t.useState(e?.idShare??exports.DashboardShareType.NotShared),[z,U]=t.useState(e?.groups??[]),[O,V]=t.useState(e?.places??[]),[B,q]=t.useState(e?.collaborators??[]),$=A===exports.DashboardViewType.Carousel,W=g["pt-br"]||g.en||g.es,H=t.useMemo(()=>!!W&&(!(g["pt-br"]&&!b.trim())&&(!(g.en&&!w.trim())&&!(g.es&&!_.trim()))),[W,g,b,w,_]),G=t.useCallback(e=>{v(a=>({...a,[e]:!a[e]}))},[]),Y=t.useCallback(()=>{H&&!r&&c?.({titlePtBr:g["pt-br"]?b:"",titleEnUs:g.en?w:"",titleEsEs:g.es?_:"",responsibleId:k||void 0,isActive:T,idUpdateTime:D,idViewType:A,idPageTime:$?M:null,idShare:R,groups:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?z:[],places:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?O:[],collaborators:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?B:[]})},[H,r,c,g,b,w,_,k,T,D,A,M,$,R,z,O,B]);return a.jsxs("div",{className:Gt("flex flex-col h-full bg-background",m),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p(h?"dashboard_edit":"dashboard_new")}),h&&e&&a.jsx("span",{className:"text-sm text-muted-foreground",children:e.code})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:u,className:"px-3 py-2 text-sm rounded-md border border-input hover:bg-accent transition-colors",children:"Cancelar"}),a.jsxs("button",{onClick:Y,disabled:!H||r,className:Gt("inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors","disabled:opacity-50 disabled:pointer-events-none"),children:[r?a.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"}):a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Salvar"]})]})]}),a.jsxs("div",{className:"flex border-b border-border bg-card",children:[a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.General),className:Gt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.General?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Geral"}),a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.Share),className:Gt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.Share?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Compartilhamento"})]}),a.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x===exports.DashboardFormTab.General&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium text-foreground",children:"Título *"}),a.jsx("div",{className:"flex gap-2",children:gm.map(e=>a.jsx("button",{onClick:()=>G(e.key),className:Gt("px-3 py-1 text-xs rounded-md border transition-colors",g[e.key]?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:bg-accent"),children:e.label},e.key))}),!W&&a.jsx("p",{className:"text-xs text-destructive",children:"Selecione pelo menos um idioma"})]}),g["pt-br"]&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Português (BR)"}),a.jsx("input",{value:b,onChange:e=>y(e.target.value),maxLength:200,className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[b.length,"/200"]})]}),g.en&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Inglês (US)"}),a.jsx("input",{value:w,onChange:e=>N(e.target.value),maxLength:200,className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[w.length,"/200"]})]}),g.es&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Espanhol (ES)"}),a.jsx("input",{value:_,onChange:e=>C(e.target.value),maxLength:200,className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[_.length,"/200"]})]}),!e?.isStandard&&o.length>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Responsável"}),a.jsxs("select",{value:k,onChange:e=>S(e.target.value),disabled:!h,className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:[a.jsx("option",{value:"",children:"Selecione..."}),o.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Intervalo de atualização"}),a.jsx("select",{value:D,onChange:e=>E(Number(e.target.value)),disabled:n,className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:pm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Situação"}),a.jsxs("div",{className:"flex items-center gap-3 h-10",children:[a.jsx("button",{onClick:()=>P(!T),disabled:e?.isGeneralViewUse,className:Gt("relative inline-flex h-6 w-11 items-center rounded-full transition-colors",T?"bg-primary":"bg-muted","disabled:opacity-50"),children:a.jsx("span",{className:Gt("inline-block h-4 w-4 rounded-full bg-white transition-transform",T?"translate-x-6":"translate-x-1")})}),a.jsx("span",{className:"text-sm text-foreground",children:T?"Ativo":"Inativo"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Tipo de visualização"}),a.jsx("select",{value:A,onChange:e=>I(Number(e.target.value)),disabled:n||$,className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:hm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),$&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Trocar página a cada"}),a.jsx("select",{value:M??"",onChange:e=>F(Number(e.target.value)),className:Gt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:xm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]})]})]}),x===exports.DashboardFormTab.Share&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 border border-border",children:[a.jsxs("svg",{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 16v-4"}),a.jsx("path",{d:"M12 8h.01"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure quem pode visualizar este dashboard. O responsável sempre terá acesso."})]}),a.jsx("div",{className:"space-y-3",children:fm.map(t=>a.jsxs("label",{className:Gt("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",R===t.value?"border-primary bg-primary/5":"border-border hover:bg-accent/50",e?.isGeneralViewUse&&"opacity-50 pointer-events-none"),children:[a.jsx("input",{type:"radio",name:"shareType",value:t.value,checked:R===t.value,onChange:()=>L(t.value),disabled:e?.isGeneralViewUse,className:"mt-1 accent-primary"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:t.label}),a.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]})]},t.value))}),R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators&&a.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Grupos de usuários (",z.length,")"]}),a.jsx("select",{multiple:!0,value:z,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);U(a)},className:Gt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:i.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Locais (",O.length,")"]}),a.jsx("select",{multiple:!0,value:O,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);V(a)},className:Gt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:l.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Colaboradores (",B.length,")"]}),a.jsx("select",{multiple:!0,value:B,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);q(a)},className:Gt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:d.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]})]})]})]})]})}function bm({data:e,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:l,isLoading:c=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:v=!0,onColumnResize:b,enableColumnReorder:y=!1,onReorderColumns:w,storageKey:N,enableExpandableRows:_=!1,renderExpandedContent:C,expandedRowIds:k,onToggleExpand:S,defaultExpandAll:T=!1,rowActionsVariant:P="default",hideActionsColumn:D=!1,actionsHeaderContent:E}){const{t:A}=j.useTranslation(),I=u||A("no_items_found",A("no_items_found_empty")),[M,F]=t.useState(()=>T?new Set(e.map(e=>e.id)):new Set),R=void 0!==k,L=R?new Set(k):M,z=t.useCallback(e=>{R&&S?S(e):F(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[R,S]),{columnWidths:U,isDragging:O,activeColumn:V,handleMouseDown:B}=ho({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:b,enabled:v}),q=_o({enabled:y&&!!w,onReorder:w??(()=>{})}),$=t.useMemo(()=>{if(v){const e=s.map(e=>U[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return e.map(e=>e/a*100+"%")}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,v,U]);if(c)return a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>a.jsx(Fr,{className:"h-12 w-full"},t))})});if(0===e.length)return a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"text-center text-muted-foreground",children:a.jsx("p",{children:I})})});const W=l&&!D,H=(p?1:0)+(_?1:0)+s.length+(W?1:0);return a.jsx("div",{className:"flex-1 overflow-auto "+(O?"select-none":""),children:a.jsxs(Mn,{className:Gt("table-fixed w-full",m),children:[a.jsx(Fn,{className:"sticky top-0 bg-background z-10",children:a.jsxs(zn,{children:[_&&a.jsx(Un,{className:"w-[40px]"}),p&&a.jsx(Un,{className:"w-[40px]",children:a.jsx(Ks,{checked:g,onCheckedChange:f,"aria-label":A("select_all","Selecionar todos")})}),s.map((e,t)=>{const s=v&&!1!==e.resizable,i=V===String(e.key),l=y&&!!w,c=l?q.getDragProps(t):{},u=q.dragFromIndex===t,m=q.dragOverIndex===t&&q.dragFromIndex!==t;return a.jsxs(Un,{className:Gt(e.className,"relative transition-opacity",e.sortable&&"cursor-pointer",l&&q.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:$[t]},...c,children:[!1!==e.sortable&&o?a.jsxs("button",{onClick:()=>o(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(p=String(e.key),r!==p?null:"asc"===n?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):a.jsx("span",{className:"font-medium",children:e.header}),s&&a.jsx(Gn,{direction:"horizontal",onMouseDown:a=>B(String(e.key),a),isDragging:i})]},String(e.key));var p}),W&&a.jsx(Un,{className:"w-[80px] text-right",children:E??A("actions","Ações")})]})}),a.jsx(Rn,{children:e.map(e=>{const r=_&&L.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(zn,{onClick:()=>i?.(e),className:Gt(i?"cursor-pointer":"","relative","inline"===P&&"group"),children:[_&&a.jsx(On,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),z(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":r?A("collapse_row","Recolher linha"):A("expand_row","Expandir linha"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),p&&a.jsx(On,{children:a.jsx(Ks,{checked:h.includes(e.id),onCheckedChange:()=>x?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`${A("select_all","Selecionar todos")} ${e.id}`})}),s.map(t=>a.jsx(On,{className:t.className,children:a.jsx(Hn,{children:t.render?t.render(e):String(e[t.key]??"-")})},String(t.key))),W&&a.jsx(On,{className:"text-right",onClick:e=>e.stopPropagation(),children:"inline"===P?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:l(e)}):l(e)})]}),r&&C&&a.jsx(zn,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(On,{colSpan:H,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:C(e)})})})]},e.id)})})]})})}function jm({onEdit:e,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:l=[],renderAs:c="dropdown",variant:u="default"}){const{t:m}=j.useTranslation(),p=t.useMemo(()=>{const a=[];return e&&o&&a.push({key:"edit",icon:d.Edit,label:m("edit","Editar"),onClick:e,variant:"default"}),r&&a.push({key:"toggle-status",icon:n?d.PowerOff:d.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),l.forEach(e=>{!1!==e.show&&a.push({key:`custom-${e.label}`,icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),s&&i&&a.push({key:"delete",icon:d.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),a},[e,s,r,n,o,i,l,m]);return 0===p.length?null:"dropdown"===c?a.jsx(br,{delayDuration:200,children:a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:a.jsx(d.EllipsisVertical,{size:"compact"===u?14:16})})}),a.jsx(mr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(e=>e.disabled?a.jsxs(Nr,{disabledReason:e.disabledReason,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key):a.jsxs(pr,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key))})]})}):a.jsx("div",{className:"flex items-center gap-1",children:p.map(e=>a.jsxs(Kt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:e.onClick,className:"compact"===u?"h-7 px-2":"",children:[e.icon&&a.jsx(e.icon,{size:"compact"===u?14:16}),"compact"!==u&&a.jsx("span",{className:"ml-1",children:e.label})]},e.key))})}function ym({searchValue:e="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=j.useTranslation(),l=e||s.length>0;return a.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Jt,{type:"text",placeholder:i("search","Pesquisar"),value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((e,t)=>a.jsx("div",{className:"vertical"===o?"w-full":"",children:e},t)),n&&l&&r&&a.jsxs(Kt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[a.jsx(d.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})}function wm(e,a){const{t:t}=j.useTranslation(),s=new Set;function r(e){if(e)for(const a of e)s.add(a.id),r(a.children)}return function e(t){for(const s of t){if(s.id===a)return r(s.children),!0;if(s.children&&e(s.children))return!0}return!1}(e),s}function Nm({children:e,itemId:t,enableDrag:s,onDragStartCell:r,onDragEndCell:n,onDragOverCell:o,onDropCell:i,className:l}){return a.jsx(On,{draggable:s,onDragStart:s?e=>r(t,e):void 0,onDragEnd:s?n:void 0,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(t,e)},className:l,children:e})}function _m({item:e,level:t,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u="default",enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:j,onDropCell:y,dragCount:w}){const N=o.has(e.id),_=(e.children?.length??0)>0,C=24*t,k="inline"===u,S=f===e.id||p?.has(e.id)&&f&&p?.has(f),T=g===e.id&&f!==e.id,P=p?.has(e.id)??!1,D={itemId:e.id,enableDrag:x,onDragStartCell:v,onDragEndCell:b,onDragOverCell:j,onDropCell:y};return a.jsxs(a.Fragment,{children:[a.jsxs(zn,{className:Gt(l&&"cursor-pointer",k&&"group",S&&"opacity-40",T&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:l?()=>l(e):void 0,children:[a.jsx(Nm,{...D,children:a.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${C}px`},children:[m&&a.jsx(Ks,{checked:P,onCheckedChange:()=>h?.(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),x&&a.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),_?a.jsx("button",{onClick:a=>{a.stopPropagation(),i(e.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:N?a.jsx(d.ChevronDown,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})}):a.jsx("div",{className:"w-6 shrink-0"}),n??a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"truncate",children:String(e[r]??e.id)}),f===e.id&&w&&w>1&&a.jsx("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary px-1.5 py-0 text-xs font-semibold text-primary-foreground",children:w})]})}),s.map(s=>{const r=e[s.key],n=s.render?s.render(e,t):null!=r?String(r):"—";return a.jsx(Nm,{...D,className:Gt("text-center",s.className),children:s.hoverContent?a.jsxs(bl,{openDelay:200,children:[a.jsx(jl,{asChild:!0,children:a.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),a.jsx(yl,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:s.hoverContent(e)})]}):n},String(s.key))}),c&&a.jsx(Nm,{...D,className:"text-right",children:a.jsx("div",{onClick:e=>e.stopPropagation(),className:Gt("flex items-center justify-end gap-1",k&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:c(e)})})]}),_&&N&&e.children.map(e=>a.jsx(_m,{item:e,level:t+1,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u,enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:j,onDropCell:y,dragCount:w},e.id))]})}function Cm({onDrop:t,isDragOver:s,onDragOver:r,onDragLeave:n,label:o}){return a.jsxs("div",{className:Gt("absolute top-0 left-0 right-0 z-10 flex items-center justify-center gap-2 py-2 px-4 border-2 border-dashed rounded-md text-sm transition-colors mx-2 mt-2",s?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:r,onDragEnter:r,onDragLeave:n,onDrop:t,children:[a.jsx(d.ArrowUpToLine,{className:"h-4 w-4"}),o??e.t("leadership_make_root_short")]})}function km({data:s,columns:r,nameKey:n,nameHeader:o=e.t("ap_name"),iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,actionsHeader:p="",rowActionsVariant:h="default",isLoading:x,emptyMessage:f="Nenhum registro encontrado.",className:g,enableSelection:v,selectedIds:b,onSelectItem:y,onSelectAll:w,isAllSelected:N,enableRowDrag:_,onMoveNode:C,onMoveNodes:k,rootDropLabel:S,actionsWidth:T=20,nameMinWidth:P=200}){const[D,E]=t.useState(null),[A,I]=t.useState(null),[M,F]=t.useState(!1),[R,L]=t.useState(1),z=t.useRef(null),U=t.useRef([]),O=t.useRef(null),V=t.useMemo(()=>new Set(b??[]),[b]),B=t.useMemo(()=>{if(!D||!s)return new Set;const e=U.current.length>0?U.current:[D],a=function(e,a){const{t:t}=j.useTranslation(),s=new Set;for(const r of a)wm(e,r).forEach(e=>s.add(e));return s}(s,e);return e.forEach(e=>a.add(e)),a},[D,s]),q=t.useRef(B);q.current=B;const $=t.useCallback(()=>{z.current=null,U.current=[],O.current=null,E(null),I(null),F(!1),L(1)},[]),W=t.useCallback((e,a)=>{e.length>1&&k?k(e,a):1===e.length&&C?.(e[0],a)},[C,k]),H=t.useCallback((e,a)=>{const t=V.has(e)&&V.size>1?Array.from(V):[e];z.current=e,U.current=t,O.current=null,E(e),L(t.length),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t))},[V]),G=t.useCallback((e,a)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",q.current.has(e)?I(null):(O.current=e,I(e))},[]),Y=t.useCallback((e,a)=>{a.preventDefault(),a.stopPropagation();const t=q.current.has(e)?O.current:e;if(!t)return void $();let s=U.current;if(0===s.length){try{const e=a.dataTransfer.getData("application/x-tree-ids");if(e){const a=JSON.parse(e);Array.isArray(a)&&a.length>0&&(s=a)}}catch{}if(0===s.length){const e=a.dataTransfer.getData("text/plain");e&&(s=[e])}}0===s.length||s.includes(t)||W(s,t),$()},[W,$]),Q=t.useCallback(e=>{e.preventDefault(),e.stopPropagation();let a=U.current;if(0===a.length){try{const t=e.dataTransfer.getData("application/x-tree-ids");if(t){const e=JSON.parse(t);Array.isArray(e)&&e.length>0&&(a=e)}}catch{}if(0===a.length){const t=e.dataTransfer.getData("text/plain");t&&(a=[t])}}0!==a.length?(W(a,null),$()):$()},[W,$]),K=t.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",F(!0)},[]),X=t.useCallback(e=>{_&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[_]),J=t.useCallback(e=>{if(!_)return;const a=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-tree-row-id]"),t=a?.dataset?.treeRowId??O.current;t&&Y(t,e)},[_,Y]);if(x)return a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!s||0===s.length)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[a.jsx(d.User,{className:"h-10 w-10 text-muted-foreground/50"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:f})]});const Z=null!==D;return a.jsxs("div",{className:Gt("border rounded-lg overflow-hidden relative",g),onDragOver:X,onDrop:J,onDragLeave:_?e=>{const a=e.relatedTarget;a&&e.currentTarget.contains(a)||(I(null),F(!1))}:void 0,children:[_&&Z&&a.jsx(Cm,{onDrop:Q,isDragOver:M,onDragOver:K,onDragLeave:()=>F(!1),label:S}),a.jsxs(Mn,{children:[a.jsx(Fn,{children:a.jsxs(zn,{children:[a.jsx(Un,{className:"text-left",style:{minWidth:P},children:a.jsxs("div",{className:"flex items-center gap-2",children:[v&&a.jsx(Ks,{checked:N??!1,onCheckedChange:()=>w?.()}),o]})}),r.map(e=>a.jsx(Un,{className:Gt("text-center",e.className),style:e.width?{width:e.width}:void 0,children:e.header},String(e.key))),m&&a.jsx(Un,{className:"text-right",style:{width:T},children:p})]})}),a.jsx(Rn,{children:s.map(e=>a.jsx(_m,{item:e,level:0,columns:r,nameKey:n,iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,rowActionsVariant:h,enableSelection:v,selectedIds:V,onSelectItem:y,enableRowDrag:_,draggedId:D,dragOverId:A,onDragStartCell:H,onDragEndCell:$,onDragOverCell:G,onDropCell:Y,dragCount:R},e.id))})]})]})}function Sm(e){const a=_.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 Tm=[{value:"pt-BR",label:"Português (Brasil)"},{value:"en-US",label:"English (US)"},{value:"es-ES",label:"Español"}],Pm=({open:e,onOpenChange:s,user:r,userPhotoUrl:n,userInitials:o})=>{const{t:i,i18n:l}=j.useTranslation(),c=t.useRef(null),[u,m]=t.useState(null),[p,h]=t.useState(l.language||"pt-BR"),x=u||n,f=e=>{e||(m(null),h(l.language||"pt-BR")),s(e)};return a.jsx(bs,{open:e,onOpenChange:f,children:a.jsxs(Cs,{className:"sm:max-w-md",children:[a.jsx(ks,{children:a.jsx(Ps,{children:i("edit_profile","Editar Perfil")})}),a.jsxs("div",{className:"space-y-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"relative",children:a.jsxs(Hi,{className:"w-16 h-16",children:[x&&a.jsx(Gi,{src:x,alt:r.name||""}),a.jsx(Yi,{className:"bg-primary text-primary-foreground font-semibold text-lg",children:o})]})}),a.jsxs("div",{children:[a.jsxs(Kt,{variant:"outline",size:"sm",onClick:()=>c.current?.click(),children:[a.jsx(d.Camera,{className:"mr-2 h-4 w-4"}),i("change_photo","Trocar foto")]}),a.jsx("input",{ref:c,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const a=e.target.files?.[0];if(!a)return;const t=URL.createObjectURL(a);m(t)}})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:i("language","Idioma")}),a.jsxs(Os,{value:p,onValueChange:h,children:[a.jsx(qs,{children:a.jsx(Bs,{})}),a.jsx(Hs,{children:Tm.map(e=>a.jsx(Ys,{value:e.value,children:e.label},e.value))})]})]})]}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"outline",onClick:()=>f(!1),children:i("cancel","Cancelar")}),a.jsx(Kt,{onClick:()=>{p!==l.language&&l.changeLanguage(p),s(!1)},children:i("save","Salvar")})]})]})})},Dm="true"===(void 0).VITE_SHOW_EDIT_PROFILE,Em=t.memo(({variant:e="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{t:o}=j.useTranslation(),{user:i,companies:l,alias:c,isAuthenticated:u,logout:m,switchUnit:p}=Dn(),{role:h}=Mi(),x=h?.name||null,f=l?.[0]||null,g=c?l?.find(e=>e.alias===c):f,v=l||[],b=r||g||f||f,y=t.useMemo(()=>{if(!i?.id)return null;const e=(new Date).toISOString().slice(0,10);return`https://login-api.qualiex.com/api/Users/Photo/${i.id}/${e}/1?size=48`},[i?.id]),w=t.useMemo(()=>{if(!i?.name)return"";const e=i.name.trim().split(/\s+/);return 1===e.length?e[0].charAt(0).toUpperCase():(e[0].charAt(0)+e[e.length-1].charAt(0)).toUpperCase()},[i?.name]),N=t.useCallback(e=>{n?n(e):p(e)},[n,p]),_=t.useMemo(()=>{if(!v?.length)return[];const e=new Map;v.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===b?.alias),s=a.filter(e=>e.alias!==b?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[v,b?.alias]),[C,k]=t.useState(!1);if(!u||!i)return null;return"dropdown"===e?a.jsxs(a.Fragment,{children:[a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",className:`h-auto p-2 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10 ${s}`,children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("div",{className:"hidden md:block text-right",children:[a.jsxs("p",{className:"text-sm font-medium",children:[i.name?.split(" ")[0],x?` [${x}]`:""]}),a.jsx("p",{className:"text-xs text-primary-foreground/70",children:b?.name||"N/A"})]}),a.jsxs(Hi,{className:"w-8 h-8 border border-primary-foreground/30",children:[y&&a.jsx(Gi,{src:y,alt:i.name||o("user_photo")}),a.jsx(Yi,{className:"bg-primary-foreground/20 text-primary-foreground font-semibold text-xs",children:w||a.jsx(d.User,{className:"h-4 w-4"})})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),a.jsxs(mr,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[a.jsxs(lr,{children:[a.jsxs(cr,{children:[a.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),a.jsx(ur,{children:_.map(e=>a.jsxs(pr,{onClick:()=>N(e),className:e.alias===b?.alias?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===b?.alias&&a.jsx(Zs,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Dm&&a.jsxs(a.Fragment,{children:[a.jsx(gr,{}),a.jsxs(pr,{onClick:()=>k(!0),children:[a.jsx(d.UserPen,{className:"mr-2 h-4 w-4"}),o("edit_profile","Editar Perfil")]})]}),a.jsx(gr,{}),a.jsxs(pr,{onClick:m,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}),Dm&&a.jsx(Pm,{open:C,onOpenChange:k,user:i,userPhotoUrl:y,userInitials:w})]}):a.jsxs(as,{className:s,children:[a.jsx(ts,{children:a.jsx(ss,{className:"text-lg",children:o("user_info")})}),a.jsxs(ns,{className:"space-y-4",children:[a.jsx(()=>a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsxs(Hi,{className:"w-10 h-10",children:[y&&a.jsx(Gi,{src:y,alt:i.name||o("user_photo")}),a.jsx(Yi,{className:"bg-primary text-primary-foreground text-white font-semibold text-sm",children:w||a.jsx(d.User,{className:"h-5 w-5"})})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",b?.name||"N/A"]})]})]}),b&&a.jsx("div",{className:"mt-3",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:b.name})]})}),_.length>1&&a.jsxs("div",{className:"mt-2",children:[a.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",_.length]}),a.jsxs("div",{className:"flex flex-wrap gap-1",children:[_.slice(0,3).map(e=>a.jsx(Zs,{variant:e.alias===b?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>N(e),children:e.name},e.alias)),_.length>3&&a.jsxs(Zs,{variant:"outline",className:"text-xs",children:["+",_.length-3]})]})]})]}),{}),a.jsx(is,{}),a.jsxs(Kt,{variant:"outline",onClick:m,size:"sm",className:"w-full",children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Am=t.createContext({});function Im({children:e,config:s}){const r=t.useMemo(()=>{const e=Ae(),a=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:a}},[s?.navigation,s?.appName]);return a.jsx(Am.Provider,{value:r,children:e})}function Mm(){return t.useContext(Am)}function Fm(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 Rm(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]}function Lm({appName:e}){const[s,r]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between w-[258px]",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>r(!0),children:a.jsx("img",{src:$e.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),e&&a.jsx("button",{className:"min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground/80 hover:text-primary-foreground/60 transition-colors leading-tight py-1",onClick:()=>r(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(e)})})]}),a.jsx(Ri,{open:s,onOpenChange:r})]})}const zm=t.memo(function({actions:s}){const r=_.useLocation(),n=_.useNavigate(),{navigation:o,appName:i}=Mm(),l=Fm(o,r.pathname),{metadata:c,headerActions:u}=ti(),{setOpenMobile:m}=yd(),{companies:p,alias:h,isSearchVisible:x,clearSearch:f,refreshData:g,switchUnit:v}=Dn(),b=h?p?.find(e=>e.alias===h)||p?.[0]||null:p?.[0]||null,[j,y]=_.useSearchParams(),w=t.useCallback(e=>{const{pathname:a,search:t,hash:s}=r;if(h){const r=a.split("/"),o=r.indexOf(h);if(o>=0)return r[o]=e.alias,void n(r.join("/")+t+s)}v(e)},[h,r,n,v]),[N,C]=t.useState(()=>j.get("search")||""),[k,S]=Rm(N,Fe.debounceDelay);t.useEffect(()=>{if(!x)return;const e=new URLSearchParams(j);k?(e.set("search",k),e.set("page","1")):e.delete("search"),y(e)},[k,y,x]);const T=o?.find(e=>e.path===r.pathname)||o?.find(e=>r.pathname.startsWith(e.path+"/")),P=c.title||l,D=c.subtitle||T?.complementaryText||e.t("item_details");return a.jsx("header",{className:"bg-primary border-b border-primary px-2 md:px-4 py-2",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Kt,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:()=>m(!0),children:a.jsx(d.Menu,{size:20})}),a.jsx("div",{className:"hidden md:flex items-center flex-shrink-0",children:a.jsx(Lm,{appName:i})}),a.jsx("div",{className:"hidden md:block w-px h-8 bg-primary-foreground/20 flex-shrink-0"}),a.jsxs("div",{className:"flex-shrink-0",children:[c.breadcrumbs&&c.breadcrumbs.length>0&&a.jsx("nav",{className:"flex items-center gap-1 text-xs text-primary-foreground/70 mb-0.5",children:c.breadcrumbs.map((e,t)=>a.jsxs("span",{className:"flex items-center gap-1",children:[t>0&&a.jsx(d.ChevronRight,{className:"h-3 w-3"}),e.href?a.jsx(_.Link,{to:e.href,className:"hover:text-primary-foreground transition-colors",children:e.label}):a.jsx("span",{children:e.label})]},t))}),a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("h1",{className:"text-lg font-semibold text-primary-foreground truncate",children:P})}),D&&a.jsx("div",{className:"text-sm text-primary-foreground/70 truncate",children:D})]}),x&&a.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Jt,{placeholder:"Pesquisar",value:N,onChange:e=>{return a=e.target.value,void C(a);var a},className:"w-full pl-10 pr-8"}),N&&a.jsx(Kt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-primary-foreground/10 text-primary-foreground/60",onClick:()=>{S(),C("");const e=new URLSearchParams(j);e.delete("search"),e.delete("page"),y(e)},title:e.t("clear_search"),children:a.jsx(d.X,{size:14})})]}),a.jsx(Kt,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0 bg-primary-foreground/20 border-primary-foreground/30 text-primary-foreground hover:bg-primary-foreground/30 hover:text-primary-foreground",title:e.t("refresh_data"),children:a.jsx(d.RefreshCw,{size:14})})]}),a.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(u||s)&&a.jsx("div",{className:"flex items-center gap-2",children:u||s}),(void 0).VITE_WIKI_URL&&a.jsx(Kt,{variant:"ghost",size:"sm",className:"h-8 px-3 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:e=>Wt((void 0).VITE_WIKI_URL,e),title:e.t("open_wiki"),children:"Wiki"}),a.jsx(Mc,{}),a.jsx("div",{className:"text-sm",children:a.jsx(Em,{variant:"dropdown",selectedUnit:b,onUnitChange:w})})]})]})})}),Um=({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});function Om({config:e,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{t:n}=j.useTranslation(),{actions:o,triggerLabel:i="Criar",triggerIcon:l=d.Plus,variant:c="button"}=e;if(!o||0===o.length)return null;if("split-button"===c){const e=o[0],n=e.icon||l,i=o.slice(1).map(e=>({id:e.id,label:e.label,icon:e.icon,onClick:e.onClick,disabled:e.disabled}));if(t){const t=a.jsx(Kt,{onClick:e.onClick,disabled:s||e.disabled,className:Gt("justify-center px-2 w-full",r),variant:"outline",size:"default",children:a.jsx(n,{className:"h-4 w-4 shrink-0"})});return a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:t}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:e.label})})]})}return a.jsx(Cc,{label:e.label,onClick:e.onClick,icon:n,actions:i,variant:"outline",disabled:s||e.disabled,className:Gt("w-full",r),menuAlign:"start"})}const u=(e,s,r=!1)=>a.jsxs(a.Fragment,{children:[e,!t&&s&&a.jsx("span",{className:"truncate",children:s}),!t&&r&&a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const e=o[0],n=e.icon||l,i=s||e.disabled,d=a.jsx(Kt,{onClick:e.onClick,disabled:i,className:Gt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(n,{className:"h-4 w-4 shrink-0"}),e.label)});return t?a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:d}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:e.label})})]}):d}const m=a.jsx(Kt,{disabled:s,className:Gt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(l,{className:"h-4 w-4 shrink-0"}),i,!0)});return a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:t?a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:m}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:i})})]}):m}),a.jsx(mr,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:o.map(e=>{const t=e.icon;return a.jsxs(pr,{onClick:e.onClick,disabled:e.disabled,className:"cursor-pointer",children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})}const Vm="forlogic-sidebar-pinned",Bm=()=>{try{const e=localStorage.getItem(Vm);return!!e&&JSON.parse(e)}catch{return!1}};function qm({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=290,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,d]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,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","290px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!c)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),d(r),o?.(r)},r=()=>{u(!1),d(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[c,e,a,s,l,n,o]),t.useEffect(()=>(c?(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=""}),[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const $m=t.createContext(void 0);function Wm(){const e=t.useContext($m);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Hm({config:e,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=j.useTranslation(),{open:l,setOpen:c,setOpenMobile:u}=yd(),m=_.useLocation(),{alias:p,user:h}=Dn(),{appName:x}=Mm(),{hasOpenModal:f}=Wm(),[g,v]=t.useState(Bm),b=In(),y=!!b||l,w=t.useCallback(()=>{b&&u(!1)},[b,u]),N=r?qm({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:l}):null;t.useEffect(()=>{c(!!g)},[g,c]);const C=e=>m.pathname===e||m.pathname.startsWith(e+"/");return a.jsxs(Nd,{collapsible:"icon",className:Gt("app-sidebar bg-background border-r border-border flex flex-col",y?"px-3":"px-1.5"),style:N&&y?{width:`${N.width}px`,transition:"none"}:{transition:"width 300ms ease-in-out"},children:[e?.moduleActions&&e.moduleActions.actions.length>0&&a.jsx("div",{className:"py-3",children:a.jsx(br,{children:a.jsx(Om,{config:e.moduleActions,isCollapsed:!y,isDisabled:f})})}),a.jsx(Ed,{className:Gt(e?.moduleActions&&e.moduleActions.actions.length>0?"pt-0":"pt-3"),children:s||a.jsx(Ad,{className:"p-0",children:a.jsx(Fd,{children:a.jsx(Rd,{className:"gap-1",children:a.jsx(br,{children:e?.navigation?.map((e,t)=>{if("separator"===e.type)return a.jsx(Dd,{className:"my-2"},`sep-${t}`);const s=({item:e,index:t})=>{const r=`${e.path}-${t}-${p??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:o}=Um({key:r,enabled:Boolean(e.permissionCheck&&p&&h?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),l=e.permissionCheck&&!n,c=o?d.Loader2:l?d.Lock:e.icon;l?i("restricted_access"):e.complementaryText;return e.children&&e.children.length>0?y?a.jsx(fi,{defaultOpen:!0,className:"group/collapsible",children:a.jsxs(Ld,{children:[a.jsx(gi,{asChild:!0,children:a.jsx(Ud,{size:"default",children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label}),a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),a.jsx(vi,{children:a.jsx(qd,{children:e.children.map((e,t)=>a.jsx(s,{item:e,index:t},e.path))})})]})},e.path):a.jsx(Ld,{children:a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx("div",{className:Gt("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:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path):a.jsx(Ld,{children:l||o?a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:y?a.jsx(Ud,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.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:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:o?"Verificando acesso...":i("restricted_access")})})]}):y?a.jsx(Ud,{asChild:!0,isActive:C(e.path),size:"default",children:a.jsxs(_.Link,{to:e.path,className:"flex w-full items-center gap-3",onClick:w,children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(_.Link,{to:e.path,onClick:w,className:Gt("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",C(e.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path)};return a.jsx(s,{item:e,index:t},e.path)})})})})})}),!b&&a.jsx("div",{className:Gt("mt-auto pb-4 pt-2 flex",l?"justify-end":"justify-center"),children:a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx("button",{onClick:()=>{const e=!g;v(e),(e=>{try{localStorage.setItem(Vm,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:l?a.jsx(d.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),a.jsx(wr,{side:"right",children:a.jsx("p",{children:l?"Recolher":"Expandir"})})]})}),r&&N&&y&&a.jsx("div",{ref:N.dragRef,onMouseDown:N.handleMouseDown,className:Gt("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-['']",N.isDragging&&"bg-primary/40")})]})}const Gm=t.memo(function({children:e,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||a.jsx(Hm,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"290px","--sidebar-width-icon":"58px"}),[]),l=t.useRef(null),d=t.useRef(null),c=t.useCallback(()=>{if(l.current&&d.current){const e=l.current.offsetHeight;d.current.style.setProperty("--header-height",`${e}px`)}},[]);return t.useEffect(()=>{c();const e=new ResizeObserver(c);return l.current&&e.observe(l.current),()=>e.disconnect()},[c]),a.jsx(Im,{config:r,children:a.jsx(ai,{children:a.jsx(wd,{defaultOpen:!1,style:i,children:a.jsxs("div",{ref:d,className:"flex flex-col h-screen w-full overflow-hidden",children:[n&&a.jsx("div",{ref:l,className:"flex-shrink-0 sticky top-0 z-40 bg-primary",children:a.jsx(zm,{})}),a.jsxs("div",{className:"sidebar-container flex flex-1 overflow-hidden",children:[o,a.jsx("main",{className:"relative z-0 flex-1 flex flex-col overflow-hidden",children:a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30",children:e})})]})]})})})})});class Ym{static async sendEmail(e){const a=ln(),{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 Qm=Ym;function Km({open:e,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=j.useTranslation(),[m,p]=t.useState([]),[h,x]=t.useState(!1),[f,g]=t.useState(""),{data:v=[],isLoading:b}=Fo({enabled:e}),y=t.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),w=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},N=1===m.length,_=m.length>0;return a.jsx(bs,{open:e,onOpenChange:s,children:a.jsxs(Cs,{className:"max-w-2xl",variant:"form",children:[a.jsx(ks,{showSeparator:!0,children:a.jsxs(Ps,{className:"flex items-center gap-2",children:[a.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),a.jsxs(Ss,{children:[a.jsxs("div",{className:"relative mb-4",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Jt,{placeholder:"Pesquisar...",value:f,onChange:e=>g(e.target.value),className:"pl-9"})]}),a.jsx(Ur,{className:"h-[400px] pr-4",children:b?a.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>a.jsx(Fr,{className:"h-16 w-full"},t))}):0===y.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:u(f?"leadership_no_users_found":"leadership_no_users_available")})]}):a.jsx("div",{className:"space-y-2",children:y.map(e=>{const t=e.userId===l,s=c.includes(e.userId||""),r=m.includes(e.userId||"");return a.jsxs("div",{className:Gt("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(e.userId||""),children:[a.jsx(Ks,{checked:r,onCheckedChange:()=>w(e.userId||""),onClick:e=>e.stopPropagation()}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium",children:e.userName}),t&&a.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||s)&&a.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})})]}),a.jsxs(Ts,{className:"flex gap-2 sm:gap-2",children:[a.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&a.jsxs("span",{children:[m.length," selecionado(s)"]})}),N&&o&&a.jsxs(Kt,{onClick:async()=>{if(o&&1===m.length){x(!0);try{await o(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[a.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),_&&i&&a.jsxs(Kt,{onClick:async()=>{if(i&&0!==m.length){x(!0);try{await i(m,r),p([])}finally{x(!1)}}},disabled:h,children:[a.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function Xm({place:e,level:s=0,manageAccessConfig:r}){const{t:n}=j.useTranslation(),[o,i]=t.useState(!1),[l,c]=t.useState(!1),u=e.subPlaces&&e.subPlaces.length>0,m=e.isActive??!0,p=e.usersCount??0;return a.jsxs("div",{children:[a.jsxs(fi,{open:o,onOpenChange:i,children:[a.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:[u?a.jsxs(gi,{className:"flex items-center gap-2 flex-1",children:[a.jsx(d.ChevronRight,{className:Gt("h-4 w-4 transition-transform shrink-0",o&&"rotate-90")}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name}),a.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):a.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a.jsx("div",{className:"w-4 shrink-0"}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name})]}),a.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:p})]}),a.jsx(Zs,{variant:m?"default":"secondary",className:"text-xs",children:m?"Ativo":"Inativo"}),r&&a.jsx(jm,{customActions:[{label:n("manage_access"),icon:d.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),u&&a.jsx(vi,{children:e.subPlaces.map(e=>a.jsx(Xm,{place:e,level:s+1,manageAccessConfig:r},e.id))})]}),0===s&&a.jsx(is,{}),r&&a.jsx(Km,{open:l,onOpenChange:c,placeId:e.id,placeName:e.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(e.id),currentMemberIds:r.getCurrentMemberIds?.(e.id)})]})}const Jm=new class{get baseUrl(){return Ue()}async makeApiCall(e,a,t){const s=mn.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=tn.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 mn.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 sn.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return sn.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Zm(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 ep(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function ap(){const{alias:a,isAuthenticated:t}=Dn(),s=tn.getAccessToken(),{data:r=[]}=Fo({enabled:!0});return N.useQuery({queryKey:["leadership",a],queryFn:async()=>{if(!s||!a)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=ln(),{data:n,error:o}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",a);if(o)throw new Error("Erro ao buscar hierarquia de liderança");if(!n||0===n.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const l=n.map(a=>{const t=n.filter(e=>e.id_leader===a.id_user);return{...a,name:i[a.id_user]?.name||e.t("inactive_user"),email:i[a.id_user]?.email||"",subordinatesCount:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))}}),d=new Set(n.map(e=>e.id_user));return new Set(n.filter(e=>e.id_leader&&!d.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e],t=n.filter(a=>a.id_leader===e);l.push({id:`virtual-${e}`,alias:n[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:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))})}),Zm(l)},enabled:!!s&&!!a&&t&&r.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const tp="common";function sp(){const{alias:e}=Dn(),a=N.useQueryClient(),t=ln(),{t:s}=j.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 lp(t,e,a.id_user,a.id_leader);const{data:r,error:n}=await t.schema(tp).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]}),l.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function rp(){const{alias:e}=Dn(),a=N.useQueryClient(),t=ln(),{t:s}=j.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",s("leadership_select_subordinates")));const r=a.users.map(e=>e.id_user),{data:n}=await t.schema(tp).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 d of a.users){if(a.id_leader&&d.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 lp(t,e,d.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(tp).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_added_success",`${t?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{l.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function np(){const{alias:e}=Dn(),a=N.useQueryClient(),t=ln(),{t:s}=j.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(tp).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 lp(t,e,r.id_user,a.id_leader,a.id);const{data:n,error:o}=await t.schema(tp).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]}),l.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function op(){const{alias:e}=Dn(),a=N.useQueryClient(),t=ln(),{t:s}=j.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(tp).from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function ip(){const{alias:e}=Dn(),a=N.useQueryClient(),t=ln(),{t:s}=j.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(tp).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",a),t.schema(tp).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:d,error:c}]=o;if(l)throw l;if(c)throw c;const u=i||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==a),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const s of x)await lp(t,e,s.id_user,a,s.id);for(const j of g){if(j.id_user===a)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await lp(t,e,j.id_user,a)}const v=[];if(h.length){const a=h.map(e=>e.id);v.push(t.schema(tp).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",e))}if(x.length){const s=x.map(e=>e.id);v.push(t.schema(tp).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}));v.push(t.schema(tp).from("leaders").insert(s))}const b=(await Promise.all(v)).find(e=>e?.error);if(b?.error)throw b.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${t.created} adicionados, ${t.updated} atualizados, ${t.unlinked} removidos)`))},onError:e=>{l.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function lp(a,t,s,r,n){const{data:o,error:i}=await a.schema(tp).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(i)throw i;const l=n?o.filter(e=>e.id!==n):o,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error(e.t("leadership_cycle_error"));if(c===s)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const a=l.find(e=>e.id_user===c);c=a?.id_leader||null}}var dp=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,d=l&&l[s.code];t[o]=h.appendErrors(o,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},cp=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&&Z.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:Z.toNestErrors(dp(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const up=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string()).min(1,e.t("leadership_select_subordinates"))}),mp=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string())});function pp({value:s,onChange:r,excludeUserIds:n=[],error:o}){const{data:i=[],isLoading:l}=Fo(),[c,u]=t.useState(""),m=t.useRef(null),p=t.useRef(0),h=i.filter(e=>!n.includes(e.userId||"")).filter(e=>{const a=c.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const t=s.includes(e.userId),r=s.includes(a.userId);if(t&&!r)return-1;if(!t&&r)return 1;const n=e.userName||e.userEmail||"",o=a.userName||a.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{m.current&&p.current>0&&(m.current.scrollTop=p.current)},[h]),l?a.jsxs("div",{className:"flex items-center justify-center p-4",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),a.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Jt,{placeholder:e.t("search_user_placeholder"),value:c,onChange:e=>u(e.target.value)}),a.jsx("div",{ref:m,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===h.length?a.jsx("p",{className:"text-sm text-muted-foreground",children:e.t("search_user_placeholder")}):a.jsx("div",{className:"space-y-2",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Ks,{id:e.userId,checked:s.includes(e.userId),onCheckedChange:()=>{return a=e.userId,m.current&&(p.current=m.current.scrollTop),void(s.includes(a)?r(s.filter(e=>e!==a)):r([...s,a]));var a}}),a.jsx(es,{htmlFor:e.userId,className:"flex-1 cursor-pointer",children:e.userName||e.userEmail})]},e.userId))})}),s.length>0&&a.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.length," selecionado(s)"]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})}function hp({leader:s,prefilledLeaderId:r,onSuccess:n}){const{t:o}=j.useTranslation(),{alias:i}=Dn(),l=!!s,c=s?.id.startsWith("virtual-"),u=rp(),m=sp(),p=np(),x=ip(),f=op(),{data:g=[]}=ap(),{data:v=[]}=Fo(),[b,y]=t.useState(""),w=ep(g).map(e=>e.id_user),N=l?ep(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user):[],_=h.useForm({resolver:cp(l?mp:up),defaultValues:{id_leader:r||(l?s?.id_leader:null)||null,id_users:l?N:[]}});t.useEffect(()=>{if(s){const e=ep(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user);_.reset({id_leader:s.id_leader||null,id_users:e})}else r?_.reset({id_leader:r,id_users:[]}):_.reset({id_leader:null,id_users:[]})},[i,s?.id,s?.id_user,s?.id_leader,r,g]);const C=u.isPending||m.isPending||p.isPending||x.isPending||f.isPending,k=_.watch("id_leader"),S=_.watch("id_users"),T=l?[s.id_user,...w.filter(e=>e!==s.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...w.filter(e=>!S.includes(e))].filter(Boolean);return a.jsxs("form",{onSubmit:_.handleSubmit(async e=>{try{if(l)if(c){await m.mutateAsync({id_user:s.id_user,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{await p.mutateAsync({id:s.id,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({id_leader:e.id_leader,users:a})}n?.()}catch(a){}}),className:"space-y-4",children:[l&&a.jsxs("div",{children:[a.jsx(es,{children:e.t("leader")}),a.jsx(Jt,{value:v.find(e=>e.userId===s.id_user)?.userName||s.name||e.t("inactive_user"),disabled:!0,className:"bg-muted"})]}),a.jsxs("div",{children:[a.jsx(es,{children:o("leadership_immediate_superior")}),a.jsxs(Os,{value:k||"none",onValueChange:e=>_.setValue("id_leader","none"===e?null:e),children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:"Selecione..."})}),a.jsxs(Hs,{children:[a.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:a.jsx(Jt,{placeholder:"Buscar superior...",value:b,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),a.jsxs(Ur,{className:"h-[200px]",children:[a.jsx(Ys,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const a=l?e.userId!==s.id_user:!S.includes(e.userId),t=!b||e.userName?.toLowerCase().includes(b.toLowerCase());return a&&t}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(e=>a.jsx(Ys,{value:e.userId,children:e.userName},e.userId))]})]})]},`superior-select-${i}`),_.formState.errors.id_leader&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:_.formState.errors.id_leader.message})]}),a.jsxs("div",{children:[a.jsx(es,{children:"Subordinados *"}),a.jsx(pp,{value:S,onChange:e=>_.setValue("id_users",e),excludeUserIds:T,error:_.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx(Kt,{type:"submit",disabled:C||!l&&0===S.length,children:C&&!f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Atualizando...":"Salvando..."]}):l?"Atualizar":"Criar"}),l&&!k&&0===S.length&&a.jsxs(ls,{children:[a.jsx(ds,{asChild:!0,children:a.jsx(Kt,{type:"button",variant:"destructive",disabled:C,className:"ml-auto",children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),a.jsxs(ms,{children:[a.jsxs(ps,{children:[a.jsx(xs,{children:o("confirm_removal")}),a.jsx(fs,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),a.jsxs(hs,{children:[a.jsx(vs,{children:o("cancel")}),a.jsx(gs,{onClick:async()=>{if(s)try{await f.mutateAsync(s.id),n?.()}catch(e){}},children:o("remove")})]})]})]})]})]})}function xp({open:e,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return a.jsx(bs,{open:e,onOpenChange:t,children:a.jsxs(Cs,{variant:"form",className:"sm:max-w-[500px]",children:[a.jsx(ks,{showSeparator:!0,children:a.jsx(Ps,{children:n})}),a.jsx(Ss,{children:a.jsx(hp,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})})]})})}const fp="leadership-expanded-nodes",gp=(e,a)=>{const{t:t}=j.useTranslation();try{localStorage.setItem(`${fp}-${e}`,JSON.stringify(Array.from(a)))}catch{}};function vp(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:i,onError:d}=e||{};return{upload:async(e,a)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);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){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await r(e,t);return l.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),i?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),d?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:a}}function bp(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 jp(e,a){const t=bp(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function yp(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function wp(e,a){const t=yp(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function Np(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function _p(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Cp(e,a){return e/a}function kp(){const{alias:e}=Dn(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let a=!1;return(async()=>{n(!0);try{const t=ln(),{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]);return{config:a,isLoading:r,saveConfig:t.useCallback(async(a,t)=>{if(!e)throw new Error("Alias not available");const r=ln(),{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])}}const Sp=(void 0).VITE_SUPABASE_URL,Tp=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function Pp(e,a,t){const s=tn.getSupabaseToken(),r={"Content-Type":"application/json",apikey:Tp};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${Sp}/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 Dp={async createEnvelopeWithSigner(e){const a="d4sign"===e.provider?"d4sign":"clicksign",t="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await Pp(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 Pp(a,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let Ep=null;function Ap(){return window.Clicksign?Promise.resolve():Ep||(Ep=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)}),Ep)}const Ip="clicksign-container";function Mp({signerId:e,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const{t:i}=j.useTranslation(),l=t.useRef(null),[c,u]=t.useState(!0),[m,p]=t.useState(null);return t.useEffect(()=>{let a=!1;return l.current&&(l.current.unmount(),l.current=null),p(null),u(!0),Ap().then(()=>{if(a)return;const t=new window.Clicksign(e);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(Ip),t.on("loaded",function(){u(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const a=e,t=document.getElementById(Ip);t&&a?.data?.height&&(t.style.height=a.data.height+"px")}),t.on("error",function(e){u(!1),n?.(e instanceof Error?e:new Error(i("sign_widget_error")))}),t.on("closed",function(){o?.()}),l.current=t}).catch(e=>{a||(p("Falha ao carregar o script de assinatura."),u(!1),n?.(e))}),()=>{a=!0,l.current&&(l.current.unmount(),l.current=null)}},[e,s]),a.jsxs("div",{className:"relative h-full",children:[c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx("p",{className:"text-sm text-destructive",children:m})}),a.jsx("div",{id:Ip,style:{height:"600px"}})]})}function Fp({documentKey:s,signerEmail:r,signerName:n,keySigner:o,environment:i,onSign:l,onError:c}){const u=t.useRef(null),[m,p]=t.useState("loading"),[h,x]=t.useState(null),f="production"===i?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",g=(()=>{const e=new URLSearchParams({email:r,display_name:n||"",disable_preview:"0"});return o&&e.set("key_signer",o),`${f}/${s}?${e.toString()}`})(),v=t.useCallback(a=>"signed"===a.data?(p("ready"),void l?.()):"wrong-data"===a.data?(p("error"),x(e.t("sign_incorrect_data")),void c?.(new Error(e.t("sign_incorrect_data")))):void 0,[l,c]);t.useEffect(()=>(window.addEventListener("message",v,!1),()=>{window.removeEventListener("message",v,!1)}),[v]);const b=t.useCallback(()=>{"loading"===m&&p("ready")},[m]);return"error"===m?a.jsxs(Xo,{variant:"danger",className:"my-4",children:[a.jsx(Jo,{children:e.t("sign_doc_load_error")}),a.jsx(Zo,{children:h||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):a.jsxs("div",{className:"relative h-full",children:["loading"===m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),a.jsx("iframe",{ref:u,id:"d4sign-container",src:g,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}var Rp,Lp,zp,Up,Op;exports.ETaskPlanStatus=void 0,(Rp=exports.ETaskPlanStatus||(exports.ETaskPlanStatus={}))[Rp.waitingStart=1]="waitingStart",Rp[Rp.running=2]="running",Rp[Rp.effectivenessCheck=3]="effectivenessCheck",Rp[Rp.done=4]="done",Rp[Rp.suspended=5]="suspended",Rp[Rp.canceled=6]="canceled",exports.ETaskPlanPriority=void 0,(Lp=exports.ETaskPlanPriority||(exports.ETaskPlanPriority={}))[Lp.low=0]="low",Lp[Lp.medium=1]="medium",Lp[Lp.high=2]="high",exports.ETaskPlanAssociationType=void 0,(zp=exports.ETaskPlanAssociationType||(exports.ETaskPlanAssociationType={}))[zp.plan=2]="plan",zp[zp.occurrence=3]="occurrence",zp[zp.risk=4]="risk",zp[zp.decisions=5]="decisions",zp[zp.audit=6]="audit",zp[zp.strategyExtension=7]="strategyExtension",zp[zp.standardization=8]="standardization",zp[zp.supplier=9]="supplier",zp[zp.auditItems=10]="auditItems",exports.ETaskPlanTypeProgress=void 0,(Up=exports.ETaskPlanTypeProgress||(exports.ETaskPlanTypeProgress={}))[Up.currentProgress=1]="currentProgress",Up[Up.cumulativeProgress=2]="cumulativeProgress",exports.EAttachmentItemStatus=void 0,(Op=exports.EAttachmentItemStatus||(exports.EAttachmentItemStatus={})).uploading="uploading",Op.waiting="waiting",Op.done="done",Op.error="error",Op.canceled="canceled",Op.duplicateItem="duplicateItem";const Vp={[exports.ETaskPlanStatus.waitingStart]:"#D6D6D6",[exports.ETaskPlanStatus.running]:"#DAE9F4",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB29",[exports.ETaskPlanStatus.done]:"#DDEECA",[exports.ETaskPlanStatus.suspended]:"#FFF2D6",[exports.ETaskPlanStatus.canceled]:"#F4433629"},Bp={[exports.ETaskPlanStatus.waitingStart]:"#666666",[exports.ETaskPlanStatus.running]:"#1B75BB",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB",[exports.ETaskPlanStatus.done]:"#4CAF50",[exports.ETaskPlanStatus.suspended]:"#FF9800",[exports.ETaskPlanStatus.canceled]:"#F44336"},qp={[exports.ETaskPlanStatus.waitingStart]:"waiting-start",[exports.ETaskPlanStatus.running]:"running",[exports.ETaskPlanStatus.effectivenessCheck]:"effectiveness-check",[exports.ETaskPlanStatus.done]:"done",[exports.ETaskPlanStatus.suspended]:"suspended",[exports.ETaskPlanStatus.canceled]:"canceled"};function $p(){return{[exports.ETaskPlanStatus.waitingStart]:e.t("ap_status_waiting_start"),[exports.ETaskPlanStatus.running]:e.t("ap_status_running"),[exports.ETaskPlanStatus.effectivenessCheck]:e.t("ap_status_effectiveness_check"),[exports.ETaskPlanStatus.done]:e.t("ap_status_done"),[exports.ETaskPlanStatus.suspended]:e.t("ap_status_suspended"),[exports.ETaskPlanStatus.canceled]:e.t("ap_status_canceled")}}const Wp=new Proxy({},{get:(e,a)=>{if("symbol"==typeof a)return;return $p()[a]}});const Hp=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];const Gp=[{id:exports.ETaskPlanPriority.low,label:"Baixa",color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:"Média",color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:"Alta",color:"#F44336"}],Yp=[exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.canceled],Qp=[exports.ETaskPlanStatus.waitingStart,exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.suspended];function Kp(e){const{actionPlan:a,isNew:s=!1,config:r,onSave:n,onCancel:o,onDelete:i,onChangeStatus:l}=e,[d,c]=t.useState({formData:a||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});t.useEffect(()=>{a&&c(e=>({...e,formData:a,isFormDisabled:r?.disableFields||Yp.includes(a.statusId)}))},[a,r?.disableFields]),t.useEffect(()=>{c(a=>({...a,isLoading:e.isLoading||!1}))},[e.isLoading]);const u=t.useCallback((e,a)=>{c(t=>({...t,formData:{...t.formData,[e]:a}}))},[]),m=t.useCallback(e=>{c(a=>({...a,activeTab:e}))},[]),p=t.useCallback(async()=>{if(n){c(e=>({...e,isSaving:!0}));try{await n(d.formData)}finally{c(e=>({...e,isSaving:!1}))}}},[n,d.formData]),h=t.useCallback(async e=>{if(l&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await l(d.formData.id,e)}finally{c(e=>({...e,isLoading:!1}))}}},[l,d.formData.id]),x=t.useCallback(async()=>{if(i&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await i(d.formData.id)}finally{c(e=>({...e,isLoading:!1}))}}},[i,d.formData.id]);return{formData:d.formData,isLoading:d.isLoading,isSaving:d.isSaving,activeTab:d.activeTab,isFormDisabled:d.isFormDisabled,updateField:u,setActiveTab:m,save:p,changeStatus:h,remove:x,cancel:o}}const Xp={[exports.ETaskPlanStatus.waitingStart]:{label:"",color:"#8B7355",icon:d.Clock},[exports.ETaskPlanStatus.running]:{label:"",color:"#2E7D5B",icon:d.Play},[exports.ETaskPlanStatus.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:d.ShieldCheck},[exports.ETaskPlanStatus.done]:{label:"",color:"#3D7A40",icon:d.CheckCircle2},[exports.ETaskPlanStatus.suspended]:{label:"",color:"#6B7280",icon:d.Pause},[exports.ETaskPlanStatus.canceled]:{label:"",color:"#B44A4A",icon:d.X}};function Jp({status:e,labels:t,className:s,size:r,showIcon:n,variant:o}){const i=$p(),l=Xp[e];if(!l)return null;const d=t?.[e]||i[e]||"";return a.jsx(Zc,{label:d,color:l.color,icon:l.icon,size:r,showIcon:n,variant:o,className:s})}function Zp({formData:e,updateField:s,disabled:r=!1,users:n=[],places:o=[],actionTypes:i,causes:l=[],parentActions:d=[],config:c}){const{t:u}=j.useTranslation(),m=c?.requiredFields,p=i||Hp,h=e=>{if(c?.hiddenFields?.includes(e))return!1;if(c?.visibleFields&&c.visibleFields.length>0)return c.visibleFields.includes(e);const a=`${e}Visible`;return!m||!(a in m)||!1!==m[a]},x=e=>m?!!m[e]:"name"===e,f=t.useMemo(()=>{if(e.startDate&&e.endDate){const a=new Date(e.startDate),t=new Date(e.endDate).getTime()-a.getTime();return Math.max(0,Math.ceil(t/864e5))}return e.duration||0},[e.startDate,e.endDate,e.duration]);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),a.jsx(Jt,{value:e.name||"",onChange:e=>s("name",e.target.value),maxLength:500,disabled:r,placeholder:u("ap_plan_name_placeholder")})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("responsibleWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),a.jsxs(Os,{value:e.responsibleId||"",onValueChange:e=>s("responsibleId",e),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_responsible")})}),a.jsx(Hs,{children:n.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]}),h("checkerWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),a.jsxs(Os,{value:e.checkerId||"",onValueChange:e=>s("checkerId",e),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_checker")})}),a.jsx(Hs,{children:n.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("place")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),a.jsxs(Os,{value:e.placeId||"",onValueChange:e=>s("placeId",e),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_place")})}),a.jsx(Hs,{children:eh(o).map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]}),h("planType")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),a.jsxs(Os,{value:e.typeId||"",onValueChange:e=>s("typeId",e),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_type")})}),a.jsx(Hs,{children:p.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("priority")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),a.jsxs(Os,{value:e.priorityType?.toString()||"",onValueChange:e=>s("priorityType",Number(e)),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_priority")})}),a.jsx(Hs,{children:Gp.map(e=>a.jsx(Ys,{value:e.id.toString(),children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:e.color}}),e.label]})},e.id))})]})]}),d.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:u("ap_belongs_to")}),a.jsxs(Os,{value:e.parentId||"",onValueChange:e=>s("parentId",e),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_parent")})}),a.jsx(Hs,{children:d.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[h("startDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),a.jsx(ol,{date:e.startDate?new Date(e.startDate):void 0,onDateChange:e=>s("startDate",e||null),disabled:r,placeholder:u("ap_select_date")})]}),h("endDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),a.jsx(ol,{date:e.endDate?new Date(e.endDate):void 0,onDateChange:e=>s("endDate",e||null),disabled:r,placeholder:u("ap_select_date"),disabledDates:e.startDate?a=>a<new Date(e.startDate):void 0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:u("ap_duration_days")}),a.jsx(Jt,{type:"number",value:f,disabled:!0,className:"bg-muted"})]})]}),h("estimatedCost")&&a.jsxs("div",{className:"space-y-2 max-w-xs",children:[a.jsx(es,{className:Gt(x("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),a.jsx(Jt,{type:"number",min:0,step:.01,value:e.estimatedCost||"",onChange:e=>s("estimatedCost",Number(e.target.value)),disabled:r,className:"pl-9",placeholder:"0,00"})]})]}),h("cause")&&l.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Causa"}),a.jsxs(Os,{value:e.causeId||"",onValueChange:e=>s("causeId",e),disabled:r,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:u("ap_select_cause")})}),a.jsx(Hs,{children:l.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]}),h("description")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),a.jsx(Xs,{value:e.description||"",onChange:e=>s("description",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_description_placeholder")})]}),h("justification")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{className:Gt(x("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),a.jsx(Xs,{value:e.justification||"",onChange:e=>s("justification",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_justification_placeholder")})]})]})}function eh(e,a=0){const t=[];for(const s of e)t.push({...s,depth:a}),s.children?.length&&t.push(...eh(s.children,a+1));return t}function ah(e){const{progress:a,onReportProgress:s,onEditProgress:r,onDeleteProgress:n}=e,[o,i]=t.useState(!1),[l,d]=t.useState(null),c=!!a&&Qp.includes(a.status),u=t.useCallback(async e=>{if(s&&a){i(!0);try{const t=100===e.percentProgress;await s({id:a.id,...e,conclude:t})}finally{i(!1)}}},[s,a]),m=t.useCallback(async e=>{if(r){i(!0);try{await r(e)}finally{i(!1),d(null)}}},[r]),p=t.useCallback(async e=>{if(n){i(!0);try{await n(e)}finally{i(!1)}}},[n]);return{progress:a,canReportProgress:c,isSubmitting:o,editingReport:l,setEditingReport:d,reportProgress:u,editProgress:m,deleteProgress:p}}function th(e){if(!e)return"";let a=(e||"").trim();if(!a)return"00:00";if(a.includes(":")){const e=a.split(":");if(e.length>=2){const a=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let s=parseInt(a)||0,r=parseInt(t)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}if(a=a.replace(/\D/g,""),!a)return"00:00";let t=0,s=0;return 4===a.length?(t=parseInt(a.substring(0,2))||0,s=parseInt(a.substring(2,4))||0,t+=Math.floor(s/60),s%=60):(t=parseInt(a)||0,s=0),`${t.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}function sh(e){if(null==e)return"00:00";const a=String(e).replace(/\D/g,"");if(a.length<3){let e=parseInt(a)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=a.slice(-2),t=a.slice(0,-2);let s=parseInt(t)||0,r=parseInt(e)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}function rh(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function nh({open:e,onOpenChange:s,report:r,onSave:n,isSubmitting:o=!1}){const{t:i}=j.useTranslation(),[l,d]=t.useState(r?.percentProgress||0),[c,u]=t.useState(r?.timeProgress||""),[m,p]=t.useState(r?.comments||""),h=l!==(r?.percentProgress??0)||c!==(r?.timeProgress??"")||m!==(r?.comments??"");t.useEffect(()=>{r&&(d(r.percentProgress),u(r.timeProgress||""),p(r.comments||""))},[r]);return a.jsx(bs,{open:e,onOpenChange:s,children:a.jsxs(Cs,{className:"sm:max-w-md",variant:"form",isDirty:h,children:[a.jsx(ks,{children:a.jsx(Ps,{children:i("ap_edit_progress")})}),a.jsxs("div",{className:"space-y-4 py-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:i("ap_progress_percent")}),a.jsx(Jt,{type:"number",min:0,max:100,value:l,onChange:e=>d(Number(e.target.value))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:i("ap_time_spent")}),a.jsx(Jt,{value:c,onChange:e=>u(e.target.value),onBlur:()=>u(th(c)||""),placeholder:"00:00"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:i("ap_comments")}),a.jsx(Xs,{value:m,onChange:e=>p(e.target.value),rows:3,maxLength:4e3})]})]}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"outline",onClick:()=>s(!1),disabled:o,children:"Cancelar"}),a.jsx(Kt,{onClick:()=>{r&&n({...r,percentProgress:l,timeProgress:th(c)||"00:00",comments:m})},disabled:o,children:o?"Salvando...":"Salvar"})]})]})})}function oh(e){const{t:s}=j.useTranslation(),{progress:r,canReportProgress:n,isSubmitting:o,editingReport:i,setEditingReport:l,reportProgress:d,editProgress:c,deleteProgress:u}=ah(e),[m,p]=t.useState(""),[h,x]=t.useState(""),[f,g]=t.useState("");if(!r)return a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const v=rh(r.percentProgress),b=!m,y=!m&&!h&&!f;return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"font-medium",children:s("ap_overall_progress")}),a.jsxs("span",{className:"font-semibold",style:{color:v||void 0},children:[r.percentProgress,"%"]})]}),a.jsx(sd,{value:r.percentProgress,className:"h-3"}),r.timeProgress&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",sh(r.timeProgress)]})]}),n&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_report_progress")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:s("ap_progress_percent")}),a.jsx(Jt,{type:"number",min:0,max:100,value:m,onChange:e=>p(e.target.value),placeholder:"0"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:s("ap_time_spent")}),a.jsx(Jt,{value:h,onChange:e=>x(e.target.value),onBlur:()=>x(th(h)||""),placeholder:"00:00"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:s("ap_comments")}),a.jsx(Xs,{value:f,onChange:e=>g(e.target.value),rows:3,maxLength:4e3,placeholder:s("ap_progress_comment_placeholder")})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>{p(""),x(""),g("")},disabled:y||o,children:"Limpar"}),a.jsx(Kt,{size:"sm",onClick:async()=>{const e=Number(m);(e||0===e)&&(await d({percentProgress:e,timeProgress:th(h)||"00:00",comments:f}),p(""),x(""),g(""))},disabled:b||o,children:o?"Reportando...":"Reportar"})]})]}),r.reports.length>0&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_reports_history")}),a.jsx("div",{className:"space-y-2",children:r.reports.map(e=>a.jsx(ih,{report:e,onEdit:()=>l(e),onDelete:()=>u(e.id),disabled:!n},e.id))})]}),a.jsx(nh,{open:!!i,onOpenChange:e=>!e&&l(null),report:i,onSave:c,isSubmitting:o})]})}function ih({report:t,onEdit:s,onDelete:r,disabled:n}){const o=t.date?new Date(t.date):null,i=rh(t.percentProgress);return a.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",children:t.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:t.userName}),o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:o.toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("span",{style:{color:i||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&a.jsxs("span",{children:["Tempo: ",sh(t.timeProgress)]})]}),t.comments&&a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!n&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Xt,{})}),a.jsxs(mr,{align:"end",children:[a.jsx(pr,{onClick:s,children:e.t("edit")}),a.jsx(pr,{className:"text-destructive",onClick:r,children:e.t("ap_delete")})]})]})]})}function lh({predecessors:e=[],availablePredecessors:s=[],onAdd:r,onRemove:n,disabled:o=!1}){const{t:i}=j.useTranslation(),[l,c]=t.useState(""),u=s.filter(a=>!e.some(e=>e.predecessorId===a.id));return a.jsxs("div",{className:"space-y-6 p-1",children:[!o&&u.length>0&&a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx(es,{children:i("ap_add_predecessor")}),a.jsxs(Os,{value:l,onValueChange:c,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:i("ap_select_action")})}),a.jsx(Hs,{children:u.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]}),a.jsxs(Kt,{size:"sm",onClick:()=>{l&&r&&(r(l),c(""))},disabled:!l,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[e.predecessorCode&&a.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.predecessorCode}),a.jsx("span",{className:"text-sm font-medium",children:e.predecessorName}),null!=e.predecessorStatus&&a.jsx(Jp,{status:e.predecessorStatus})]}),!o&&n&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Xt,{})}),a.jsx(mr,{align:"end",children:a.jsx(pr,{className:"text-destructive",onClick:()=>n(e.predecessorId),children:"Remover"})})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function dh({costs:e=[],onAdd:s,onEdit:r,onDelete:n,disabled:o=!1}){const{t:i}=j.useTranslation(),[l,c]=t.useState(""),[u,m]=t.useState(""),p=e.reduce((e,a)=>e+(a.value||0),0);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:i("ap_total_cost")}),a.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",p.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!o&&s&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:i("ap_add_cost")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Descrição"}),a.jsx(Jt,{value:l,onChange:e=>c(e.target.value),placeholder:i("ap_cost_description")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Valor (R$)"}),a.jsx(Jt,{type:"number",min:0,step:.01,value:u,onChange:e=>m(e.target.value),placeholder:"0,00"})]})]}),a.jsx("div",{className:"flex justify-end",children:a.jsxs(Kt,{size:"sm",onClick:()=>{l&&u&&s&&(s({description:l,value:Number(u),date:(new Date).toISOString()}),c(""),m(""))},disabled:!l||!u,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:e.description}),e.date&&a.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(e.date).toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",e.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!o&&(r||n)&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Xt,{})}),a.jsxs(mr,{align:"end",children:[r&&a.jsx(pr,{onClick:()=>r(e),children:i("edit")}),n&&a.jsx(pr,{className:"text-destructive",onClick:()=>n(e.id),children:i("ap_delete")})]})]})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function ch({comments:e=[],currentUserId:s,onAdd:r,onEdit:n,onDelete:o,disabled:i=!1,maxLength:l=4e3}){const{t:c}=j.useTranslation(),[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(null),[g,v]=t.useState(""),b=()=>{f(null),v("")};return a.jsxs("div",{className:"space-y-6 p-1",children:[!i&&r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(Xs,{value:u,onChange:e=>m(e.target.value),placeholder:c("ap_add_comment_placeholder"),maxLength:l,rows:3}),a.jsxs("div",{className:"flex items-center justify-between",children:[l&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length,"/",l]}),a.jsxs("div",{className:"flex gap-2 ml-auto",children:[a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>m(""),disabled:!u||p,children:"Limpar"}),a.jsx(Kt,{size:"sm",onClick:async()=>{if(u.trim()&&r){h(!0);try{await r(u),m("")}finally{h(!1)}}},disabled:!u.trim()||p,children:p?"Enviando...":"Comentar"})]})]})]}),a.jsxs("div",{className:"space-y-1",children:[e.length>0?a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:"text-sm font-medium",children:c("ap_comments")}),a.jsx(Zs,{variant:"info",className:"text-[10px] px-1.5 py-0",children:e.length})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.MessageSquare,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),e.map(e=>a.jsxs("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground overflow-hidden",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.userEmail}),a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:uh(e.dateEdited||e.dateCreation)}),e.dateEdited&&a.jsx("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),x===e.id?a.jsxs("div",{className:"space-y-2",children:[a.jsx(Xs,{value:g,onChange:e=>v(e.target.value),maxLength:l,rows:3}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Kt,{variant:"outline",size:"sm",onClick:b,disabled:p,children:"Cancelar"}),a.jsx(Kt,{size:"sm",onClick:()=>(async e=>{if(g.trim()&&n){h(!0);try{await n({...e,text:g,stringText:g}),f(null),v("")}finally{h(!1)}}})(e),disabled:!g.trim()||p,children:p?"Salvando...":"Salvar"})]})]}):a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.stringText||e.text})]}),!i&&s===e.userId&&x!==e.id&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Xt,{})}),a.jsxs(mr,{align:"end",children:[n&&a.jsx(pr,{onClick:()=>(e=>{f(e.id),v(e.stringText||e.text)})(e),children:c("edit")}),o&&a.jsx(pr,{className:"text-destructive",onClick:()=>(async e=>{if(o){h(!0);try{await o(e)}finally{h(!1)}}})(e.id),children:"Excluir"})]})]})]},e.id))]})]})}function uh(e){const{t:a}=j.useTranslation();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function mh({history:e=[],isLoading:t=!1}){const{t:s}=j.useTranslation();return t?a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===e.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Clock,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:s("ap_no_history")})]}):a.jsx("div",{className:"p-1",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),a.jsx("div",{className:"space-y-0",children:e.map((e,t)=>a.jsxs("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[a.jsx("div",{className:"relative z-10 flex-shrink-0 h-8 w-8 rounded-full bg-primary/10 border-2 border-primary/30 flex items-center justify-center",children:e.icon?a.jsx("span",{className:"text-xs text-primary",children:e.icon}):a.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),a.jsxs("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium",children:e.translateEvent||e.eventName}),e.eventDescription&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.eventDescription})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0 h-6 w-6 rounded-full bg-muted overflow-hidden flex items-center justify-center text-[10px] font-medium text-muted-foreground",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-xs font-medium truncate block",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-[10px] text-muted-foreground truncate block",children:e.userEmail})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Calendar,{className:"h-3 w-3"}),a.jsx("span",{children:ph(e.date)})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),a.jsx("span",{children:hh(e.date)})]}),e.isMobileRequest&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Smartphone,{className:"h-3 w-3"}),a.jsx("span",{children:s("ap_via_app")})]})]})]})]},e.id))})]})})}function ph(e){const{t:a}=j.useTranslation();return new Date(e).toLocaleDateString("pt-BR")}function hh(e){const{t:a}=j.useTranslation();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function xh({attachments:e=[],onUpload:s,onDelete:r,onRename:n,onDownload:o,onView:i,disabled:l=!1}){const{t:c}=j.useTranslation(),u=t.useRef(null),[m,p]=t.useState(null),[h,x]=t.useState(""),f=async e=>{h.trim()&&n&&(await n(e.id,h),p(null),x(""))},g=()=>{p(null),x("")};return a.jsxs("div",{className:"space-y-4 p-1",children:[!l&&s&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:e=>{const a=e.target.files;if(a&&s){for(let e=0;e<a.length;e++){const t=a.item(e);t&&s(t)}u.current&&(u.current.value="")}}}),a.jsxs(Kt,{size:"sm",onClick:()=>u.current?.click(),children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:Gt("flex items-center gap-3 rounded-lg border bg-card p-3",e.status===exports.EAttachmentItemStatus.error&&"border-destructive/50 bg-destructive/5",e.status===exports.EAttachmentItemStatus.canceled&&"opacity-50"),children:[a.jsx("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:a.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:e.extension.replace(".","").substring(0,4)})}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[m===e.id?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:h,onChange:e=>x(e.target.value),onKeyDown:a=>{"Enter"===a.key&&f(e),"Escape"===a.key&&g()},autoFocus:!0}),a.jsx(Kt,{size:"sm",variant:"outline",onClick:g,children:c("cancel")}),a.jsx(Kt,{size:"sm",onClick:()=>f(e),children:c("save")})]}):a.jsx("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>i?.(e.id),children:e.name}),(e.status===exports.EAttachmentItemStatus.uploading||e.status===exports.EAttachmentItemStatus.waiting)&&a.jsx(sd,{value:e.progress||0,className:"h-1.5"}),e.status===exports.EAttachmentItemStatus.error&&a.jsx("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),e.status===exports.EAttachmentItemStatus.duplicateItem&&a.jsx("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),e.status===exports.EAttachmentItemStatus.canceled&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[e.status===exports.EAttachmentItemStatus.done&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:fh(e.size)}),a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Xt,{})}),a.jsxs(mr,{align:"end",children:[n&&!l&&a.jsx(pr,{onClick:()=>(e=>{const a=e.name.replace(e.extension,"");p(e.id),x(a)})(e),children:"Renomear"}),i&&a.jsx(pr,{onClick:()=>i(e.id),children:"Visualizar"}),o&&a.jsx(pr,{onClick:()=>o(e.id),children:"Download"}),r&&!l&&a.jsxs(a.Fragment,{children:[a.jsx(gr,{}),a.jsx(pr,{className:"text-destructive",onClick:()=>r(e.id),children:"Excluir"})]})]})]})]}),e.status===exports.EAttachmentItemStatus.uploading&&a.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>r?.(e.id),children:"Cancelar"})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Paperclip,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function fh(e){const{t:a}=j.useTranslation();if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(1))} ${["B","KB","MB","GB"][t]}`}const gh=["application/x-msdownload","application/x-msdos-program","application/x-executable","application/x-javascript","application/javascript","text/javascript","text/vbscript","application/sql","application/x-sh","application/x-shellscript","application/hta","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12"];function vh(e){if(!e)return"";if(e<1024)return`${e} Bytes`;const a=e/1024;if(a<1024)return`${Math.round(a)} KB`;const t=a/1024;if(t<1024)return`${Math.round(t)} MB`;const s=t/1024;return Math.round(100*s)/100+" GB"}function bh(e){const a=e.lastIndexOf(".");return-1===a?"":e.substring(a+1).toLowerCase()}var jh,yh,wh;function Nh(e){switch(e.type){case exports.ECustomFormFieldType.text:return e.textValue;case exports.ECustomFormFieldType.number:return e.numberValue;case exports.ECustomFormFieldType.date:return e.dateValue;case exports.ECustomFormFieldType.time:return e.timeValue;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:return e.itemsValue;case exports.ECustomFormFieldType.questions:return e.questionsValue;case exports.ECustomFormFieldType.readOnlyText:return e.textValue;default:return null}}function _h(e,a){if(!a)return!0;const t=null!=Nh(e)&&""!==Nh(e)&&!(Array.isArray(Nh(e))&&0===Nh(e).length);return!1!==e.isActive||t}function Ch({field:e}){return a.jsxs("div",{className:"space-y-1",children:[e.name&&a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&a.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function kh({field:e,readOnly:t,onChange:s}){const r=e.config,n=r?.multiline??!1,o=t||e.readOnly,i=a=>{s?.({...e,textValue:a})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),n?a.jsx(Xs,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o,rows:4}):a.jsx(Jt,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o})]})}function Sh({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e.dateValue?"string"==typeof e.dateValue?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Jt,{type:"date",value:n,onChange:a=>{return t=a.target.value,void s?.({...e,dateValue:t||void 0});var t},placeholder:e.placeholder,disabled:r})]})}function Th({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e=>{if(!e)return;const[a,t]=e.split(":").map(Number);return 60*a+t};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Jt,{type:"time",value:(e=>{if(null==e)return"";const a=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`})(e.timeValue),onChange:a=>s?.({...e,timeValue:n(a.target.value)}),placeholder:e.placeholder,disabled:r})]})}function Ph({field:e,readOnly:s,onChange:r}){const n=e.config,o=n?.multiple??!1,i=s||e.readOnly,[l,c]=t.useState(""),u=e.itemsValue||[],m=()=>{if(!l.trim())return;const a={value:crypto.randomUUID(),text:l.trim()};r?.({...e,itemsValue:[...u,a]}),c("")};if(!o){const t=u[0]?.text||"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jt,{type:"url",value:t,onChange:a=>(a=>{const t={value:a,text:a};r?.({...e,itemsValue:a?[t]:[]})})(a.target.value),placeholder:e.placeholder||"https://",disabled:i}),t&&a.jsx(Kt,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:a.jsx(d.ExternalLink,{className:"h-4 w-4"})})})]})]})}return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jt,{type:"url",value:l,onChange:e=>c(e.target.value),placeholder:e.placeholder||"https://",onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),m())}),a.jsx(Kt,{variant:"outline",size:"icon",onClick:m,disabled:!l.trim(),className:"flex-shrink-0",children:a.jsx(d.Plus,{className:"h-4 w-4"})})]}),u.length>0&&a.jsx("div",{className:"space-y-1",children:u.map((t,s)=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("a",{href:t.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:t.text}),!i&&a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>(a=>{const t=u.filter((e,t)=>t!==a);r?.({...e,itemsValue:t})})(s),children:a.jsx(d.Trash2,{className:"h-3 w-3"})})]},t.value))})]})}function Dh({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=null!=r?.decimals&&r.decimals>0?(1/Math.pow(10,r.decimals)).toString():"1";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Jt,{type:"number",value:e.numberValue??"",onChange:a=>(a=>{if(""===a)return void s?.({...e,numberValue:void 0});const t=parseFloat(a);isNaN(t)||s?.({...e,numberValue:t})})(a.target.value),placeholder:e.placeholder,disabled:n,min:r?.min,max:r?.max,step:o}),null!=r?.min&&null!=r?.max&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",r.min," | Max: ",r.max]})]})}function Eh({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=e.itemsValue?.[0]?.value||"",d=a=>{const t=i.find(e=>e.value===a);if(!t)return;const r={value:t.value,text:t.text,isActive:t.isActive};s?.({...e,itemsValue:[r]})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),o===exports.EFieldViewMode.dropdown&&a.jsxs(Os,{value:l,onValueChange:d,disabled:n,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:e.placeholder||"Selecione..."})}),a.jsx(Hs,{children:i.map(e=>a.jsxs(Ys,{value:e.value,children:[e.text,!1===e.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},e.value))})]}),(o===exports.EFieldViewMode.radio||o===exports.EFieldViewMode.buttons)&&a.jsx(rd,{value:l,onValueChange:d,disabled:n,className:Gt(o===exports.EFieldViewMode.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(nd,{value:t.value,id:`${e.id}-${t.value}`}),a.jsxs(es,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))}),!n&&l&&!e.required&&a.jsx("button",{type:"button",onClick:()=>{s?.({...e,itemsValue:[]})},className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function Ah({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=new Set(e.itemsValue?.map(e=>e.value)||[]);return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(t=>a.jsxs(Zs,{variant:"secondary",className:"gap-1 pr-1",children:[a.jsx("span",{className:"text-xs",children:t.text}),!n&&a.jsx("button",{type:"button",onClick:()=>(a=>{const t=(e.itemsValue||[]).filter(e=>e.value!==a);s?.({...e,itemsValue:t})})(t.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:a.jsx(d.X,{className:"h-3 w-3"})})]},t.value))}),!n&&a.jsx("div",{className:Gt(o===exports.EFieldViewMode.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ks,{id:`${e.id}-${t.value}`,checked:l.has(t.value),onCheckedChange:()=>(a=>{const t=e.itemsValue||[],r=t.some(e=>e.value===a.value)?t.filter(e=>e.value!==a.value):[...t,{value:a.value,text:a.text,isActive:a.isActive}];s?.({...e,itemsValue:r})})(t),disabled:n}),a.jsxs(es,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))})]})}function Ih({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.questions||[],i=r?.options||[],l=e.questionsValue||[];return 0===o.length||0===i.length?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{children:e.name}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{className:Gt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx("div",{className:"border rounded-md overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/50",children:[a.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(e=>a.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:e.text},e.value))]})}),a.jsx("tbody",{children:o.map((t,r)=>a.jsxs("tr",{className:Gt(r<o.length-1&&"border-b"),children:[a.jsx("td",{className:"p-2 text-muted-foreground",children:t.text}),i.map(r=>{return a.jsx("td",{className:"text-center p-2",children:a.jsx(rd,{value:(o=t.value,l.find(e=>e.questionValue===o)?.optionValue||""),onValueChange:a=>((a,t,r,n)=>{const o={questionValue:a,questionText:t,optionValue:r,optionText:n},i=l.filter(e=>e.questionValue!==a);i.push(o),s?.({...e,questionsValue:i})})(t.value,t.text,a,r.text),disabled:n,className:"flex justify-center",children:a.jsx(nd,{value:r.value,id:`${e.id}-${t.value}-${r.value}`})})},r.value);var o})]},t.value))})]})})]})}function Mh({field:e,readOnly:t,onChange:s}){const r={field:e,readOnly:t,onChange:s};switch(e.type){case exports.ECustomFormFieldType.readOnlyText:return a.jsx(Ch,{...r});case exports.ECustomFormFieldType.text:return a.jsx(kh,{...r});case exports.ECustomFormFieldType.date:return a.jsx(Sh,{...r});case exports.ECustomFormFieldType.time:return a.jsx(Th,{...r});case exports.ECustomFormFieldType.url:return a.jsx(Ph,{...r});case exports.ECustomFormFieldType.number:return a.jsx(Dh,{...r});case exports.ECustomFormFieldType.singleSelection:return a.jsx(Eh,{...r});case exports.ECustomFormFieldType.multiSelection:return a.jsx(Ah,{...r});case exports.ECustomFormFieldType.questions:return a.jsx(Ih,{...r});default:return null}}function Fh({queryParams:e,events:s,softwares:r,users:n=[],permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},isLoading:i=!1,onFilter:l,onReset:c,onExport:u,onSoftwareChange:m}){const[p,h]=t.useState(e.softwareId),[x,f]=t.useState(e.eventId),[g,v]=t.useState(e.userId||"all"),[b,j]=t.useState(Rh(e.startDate)),[y,w]=t.useState(Rh(e.endDate)),N=t.useCallback(e=>{const a=parseInt(e);h(a),m?.(a)},[m]),_=t.useCallback(()=>{l({...e,softwareId:p,eventId:x,userId:"all"===g?void 0:g,startDate:new Date(b),endDate:new Date(y),software:r.find(e=>e.id===p)?.software||e.software,event:s.find(e=>e.id===x)?.name||e.event})},[e,p,x,g,b,y,r,s,l]),C=t.useCallback(()=>{const a=new Date;a.setHours(0,0,0,0),j(Rh(a)),w(Rh(a)),f(e.eventId),o.viewAllEvents&&v("all"),c?.()},[e.eventId,o.viewAllEvents,c]),k=o.viewOnlyMyEvents&&!o.viewAllEvents,S=p&&x&&b&&y;return a.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-border bg-card p-3",children:[a.jsxs("div",{className:"flex flex-col gap-1 min-w-[180px]",children:[a.jsx(es,{className:"text-xs text-muted-foreground",children:"Módulo *"}),a.jsxs(Os,{value:String(p),onValueChange:N,disabled:i,children:[a.jsx(qs,{className:"h-8 text-xs",children:a.jsx(Bs,{placeholder:"Selecione..."})}),a.jsx(Hs,{children:r.map(e=>a.jsx(Ys,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(es,{className:"text-xs text-muted-foreground",children:"Evento *"}),a.jsxs(Os,{value:String(x),onValueChange:e=>f(parseInt(e)),disabled:i,children:[a.jsx(qs,{className:"h-8 text-xs",children:a.jsx(Bs,{placeholder:"Selecione..."})}),a.jsx(Hs,{children:s.map(e=>a.jsx(Ys,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(es,{className:"text-xs text-muted-foreground",children:"Usuário *"}),a.jsxs(Os,{value:g,onValueChange:v,disabled:i||k,children:[a.jsx(qs,{className:"h-8 text-xs",children:a.jsx(Bs,{placeholder:"Selecione..."})}),a.jsxs(Hs,{children:[a.jsx(Ys,{value:"all",className:"text-xs",children:"Todos"}),n.map(e=>a.jsx(Ys,{value:e.id,className:"text-xs",children:e.name},e.id))]})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(es,{className:"text-xs text-muted-foreground",children:"De *"}),a.jsx(Jt,{type:"date",value:b,onChange:e=>j(e.target.value),className:"h-8 text-xs",max:y,disabled:i})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(es,{className:"text-xs text-muted-foreground",children:"Até *"}),a.jsx(Jt,{type:"date",value:y,onChange:e=>w(e.target.value),className:"h-8 text-xs",min:b,disabled:i})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsxs(Kt,{variant:"outline",size:"sm",onClick:C,disabled:i,children:[a.jsx(d.RotateCcw,{className:"h-3.5 w-3.5 mr-1"}),"Limpar"]}),o.download&&u&&a.jsxs(Kt,{variant:"outline",size:"sm",onClick:()=>u("xlsx"),disabled:i,children:[a.jsx(d.Download,{className:"h-3.5 w-3.5 mr-1"}),"Exportar"]}),a.jsxs(Kt,{size:"sm",onClick:_,disabled:i||!S,children:[a.jsx(d.Filter,{className:"h-3.5 w-3.5 mr-1"}),"Filtrar"]})]})]})}function Rh(e){return(e instanceof Date?e:new Date(e)).toISOString().split("T")[0]}function Lh(e,a,t,s="Anônimo"){return e.map(e=>({...e,translatedSoftware:Uh(e.software,t),user:e.userEmail||e.userName||s,translatedEvent:zh(e.eventName,a),date:new Date(e.dateTime)})).sort((e,a)=>(a.date?.getTime()??0)-(e.date?.getTime()??0))}function zh(e,a){const t=a.find(a=>a.name===e);return t?.translation||e}function Uh(e,a){const t=e.includes(".")?e.split(".").pop():e,s=a.find(e=>e.software===t);return s?.translation||t}function Oh(e,a){const t=[],s={...Gh,...a?.labels},r=e.eventName;t.push({name:s.event,value:r});const n=e.entities?.[0];if(n&&(t.push({name:s.entityName,value:Vh(n)}),n.description&&t.push({name:s.description,value:n.description}),n.justification&&t.push({name:s.justification,value:n.justification}),n.statusName&&t.push({name:s.status,value:n.statusName}),n.equipmentType&&t.push({name:s.type,value:n.equipmentType}),n.extra?.length)){[...new Set(n.extra.map(e=>e.property))].forEach(e=>{const a=n.extra.filter(a=>a.property===e).map(e=>e.value||"").join(", ");t.push({name:Wh(e),value:a})})}e.entities?.forEach(e=>{e.data?.forEach(e=>{if("Removed"===e.property)return;if(""===e.newValue&&!e.tagTranslate)return;const n=Bh(e,r,a?.translateProperty),o=qh(e,null,r,s,a);o&&t.push({name:n,value:o})})}),e.entities?.forEach(e=>{if(e.association?.length){const a=e.association.filter(e=>""!==e.id).map(e=>{const a=Vh(e);return`(${e.softwareName||e.type}) ${a}`});a.length&&t.push({name:s.references,value:a.join(", ")})}}),n?.isElectronicSigned&&t.push({name:s.security,value:"🛡️ "+s.electronicSigned}),t.push({name:s.accomplishedBy,value:e.userName?`${e.userName} (${e.userEmail})`:e.userEmail});const o=a?.formatDate?a.formatDate(e.dateTime):Hh(e.dateTime);return t.push({name:s.accomplishedIn,value:o}),t}function Vh(e){return e.code&&e.name&&e.code!==e.name?`${e.code} ${e.name}`:e.name||e.code||""}function Bh(e,a,t){if(e.propertyCustomName)return e.propertyCustomName;const s=Wh(e.property);return t?t(a,s):s}function qh(e,a,t,s,r){if(e.propertyResource||(e.propertyResource=a?`${a.propertyResource}.${e.property}`:e.property),e.children?.length){if(e.newValue){const a=Bh(e,t,r?.translateProperty),n=function(e,a){switch(e.state){case"Added":return a.stateAdded;case"Modified":return e.children?.some(e=>"Removed"===e.property)?a.stateRemoved:a.stateModified;default:return""}}(e,s);let o=`${a}: "${$h(e,"newValue",s,r)}" ${n}`;const i=e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,qh(a,e,t,s,r)));return i.some(Boolean)&&(o+="\n"+i.filter(Boolean).join("\n")),o}return e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,qh(a,e,t,s,r))).filter(Boolean).join("\n")}if("Removed"===e.property)return"";if("Modified"===e.state){const n=$h(e,"oldValue",s,r),o=$h(e,"newValue",s,r);return`${a?Bh(e,t,r?.translateProperty)+": ":""}${s.changedFrom} "${n}" ${s.changedTo} "${o}"`}const n=$h(e,"newValue",s,r);return a?`${Bh(e,t,r?.translateProperty)}: ${n}`:n}function $h(e,a,t,s){const r=e[a];return null==r||""===r?"Modified"===e.state||"Added"===e.state||"Unchanged"===e.state?t.uninformed:"":"string"==typeof r&&function(e){if("string"!=typeof e)return!1;if(!/^\d{4}[-/]\d{2}[-/]\d{2}/.test(e))return!1;const a=new Date(e);return!isNaN(a.getTime())}(r)?s?.formatDate?s.formatDate(r):Hh(r):String(r)}function Wh(e){return e.replace(/([A-Z])/g,(e,a,t)=>`${t>0?"-":""}${a.toLowerCase()}`)}function Hh(e){try{return new Date(e).toLocaleString()}catch{return e}}exports.ECustomFormFieldType=void 0,(jh=exports.ECustomFormFieldType||(exports.ECustomFormFieldType={}))[jh.readOnlyText=1]="readOnlyText",jh[jh.text=2]="text",jh[jh.date=3]="date",jh[jh.time=4]="time",jh[jh.url=5]="url",jh[jh.number=6]="number",jh[jh.singleSelection=7]="singleSelection",jh[jh.multiSelection=8]="multiSelection",jh[jh.questions=9]="questions",exports.EFieldViewMode=void 0,(yh=exports.EFieldViewMode||(exports.EFieldViewMode={}))[yh.dropdown=1]="dropdown",yh[yh.buttons=2]="buttons",yh[yh.radio=3]="radio",yh[yh.checkbox=4]="checkbox",exports.ESelectionFieldDataSource=void 0,(wh=exports.ESelectionFieldDataSource||(exports.ESelectionFieldDataSource={}))[wh.custom=1]="custom",wh[wh.users=2]="users",wh[wh.usersLists=3]="usersLists";const Gh={event:"Evento",entityName:"Item",description:e.t("audit_description"),justification:"Justificativa",status:"Status",type:"Tipo",references:e.t("audit_references"),security:e.t("audit_security"),electronicSigned:e.t("audit_esign"),accomplishedBy:"Realizado por",accomplishedIn:"Realizado em",changedFrom:"de",changedTo:"para",uninformed:e.t("audit_not_informed"),stateAdded:"(adicionado)",stateModified:"(modificado)",stateRemoved:"(removido)"};function Yh({documentId:e,onFetchDetails:s,onClose:r,labels:n,translateProperty:o,translatePropertyValue:i,formatDate:l}){const[c,u]=t.useState(!1),[m,p]=t.useState([]),[h,x]=t.useState(null),f=t.useCallback(async e=>{u(!0),x(null);try{const a=Oh(await s(e),{translateProperty:o,translatePropertyValue:i,formatDate:l,labels:n});p(a)}catch(a){x("Erro ao carregar detalhes da trilha de auditoria."),p([])}finally{u(!1)}},[s,o,i,l,n]);return t.useEffect(()=>{e&&f(e)},[e,f]),e?a.jsxs("div",{className:"flex flex-col h-full bg-background",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[a.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Detalhes da Auditoria"}),a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(d.X,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:c?a.jsxs("div",{className:"flex items-center justify-center p-6",children:[a.jsx(ar,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando detalhes..."})]}):h?a.jsx("div",{className:"p-6 text-sm text-destructive",children:h}):a.jsx("table",{className:"w-full text-xs",children:a.jsx("tbody",{children:m.map((e,t)=>a.jsxs("tr",{className:t%2==0?"bg-background":"bg-muted/20",children:[a.jsx("td",{className:"px-4 py-2.5 font-semibold text-foreground whitespace-nowrap align-top w-[180px] border-b border-border/50",children:e.name}),a.jsx("td",{className:"px-4 py-2.5 text-muted-foreground break-words border-b border-border/50",children:a.jsx("span",{dangerouslySetInnerHTML:{__html:e.value.replace(/\n/g,"<br />")}})})]},t))})})})]}):null}function Qh({open:s,onOpenChange:r,returnSteps:n,initialObservation:o="",title:i=e.t("approval_execute_action"),descriptions:d=[],setDefaultApproverOnInit:c=!0,onSubmit:u}){const[m,p]=t.useState(!0),[h,x]=t.useState(c&&n.length>0?n[0].id:null),[f,g]=t.useState(o),v=e=>{p(e),e&&!c?x(null):!e&&!c&&n.length>0&&x(n[0].id)},b=f!==o||!m;return a.jsx(bs,{open:s,onOpenChange:r,children:a.jsxs(Cs,{className:"sm:max-w-[480px]",variant:"form",isDirty:b,children:[a.jsx(ks,{children:a.jsx(Ps,{children:i})}),a.jsxs("div",{className:"space-y-4",children:[d.length>0&&a.jsx("div",{className:"space-y-1 text-sm text-muted-foreground",children:d.map((e,t)=>a.jsx("p",{dangerouslySetInnerHTML:{__html:e}},t))}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:m,onChange:()=>v(!0),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_approve")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:!m,onChange:()=>v(!1),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_reprove_radio")})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{children:"Etapa"}),a.jsxs(Os,{value:h??void 0,onValueChange:x,disabled:m,children:[a.jsx(qs,{children:a.jsx(Bs,{placeholder:e.t("approval_select_step")})}),a.jsx(Hs,{children:n.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(es,{children:e.t("approval_opinion")}),a.jsx(Xs,{value:f,onChange:e=>g(e.target.value),maxLength:4e3,rows:4,autoFocus:!0}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/",4e3]})]})]}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),a.jsx(Kt,{onClick:()=>{if(!f.trim())return void l.toast.error("Formulário inválido. Preencha todos os campos obrigatórios.");const e=m?null:n.find(e=>e.id===h);u({approved:m,returnStepId:m?null:h,returnType:e?.type??null,observation:f})},disabled:!b,children:"Concluir"})]})]})})}function Kh({open:e,onOpenChange:s,approvers:r,isLoading:n=!1,ignoreUserIds:o=[],onSubmit:i}){const{t:l}=j.useTranslation(),[d,c]=t.useState(null),u=t.useMemo(()=>{const e=new Set(o);return r.filter(a=>!e.has(a.id))},[r,o]),m=t.useMemo(()=>u.map(e=>({value:e.id,label:e.name})),[u]);return a.jsx(bs,{open:e,onOpenChange:s,children:a.jsxs(Cs,{className:"sm:max-w-[450px]",variant:"form",isDirty:!!d,children:[a.jsx(ks,{children:a.jsx(Ps,{children:l("approval_select_approver")})}),a.jsx(tr,{isLoading:n,type:"spinner",children:a.jsx("div",{className:"space-y-4",children:a.jsx(zr,{options:m,value:d??void 0,onValueChange:e=>c("string"==typeof e?e:e?.[0]??null),placeholder:l("approval_select_approver_placeholder"),searchPlaceholder:l("approval_search_approver")})})}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),a.jsx(Kt,{onClick:()=>{if(!d)return;const e=u.find(e=>e.id===d);e&&i(e)},disabled:!d||n,children:"Concluir"})]})]})})}function Xh(e){const{t:a}=j.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}function Jh({text:e,maxLength:s=130}){const{t:r}=j.useTranslation(),[n,o]=t.useState(!1);return e.length<=s?a.jsx("span",{children:e}):a.jsxs("span",{children:[n?e:`${e.substring(0,s)}... `,a.jsx("button",{className:"text-primary hover:underline text-sm cursor-pointer",onClick:()=>o(!n),children:r(n?"approval_read_less":"approval_read_more")})]})}function Zh({approver:e}){if(1===e.type&&e.approverId)return a.jsxs(Hi,{className:"h-9 w-9 shrink-0",children:[a.jsx(Gi,{src:e.photoUrl,alt:e.name}),a.jsx(Yi,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]});const t=2===e.type?d.Users:3===e.type?d.MapPin:d.User;return a.jsx("div",{className:"h-9 w-9 rounded-full bg-muted-foreground/30 flex items-center justify-center shrink-0",children:a.jsx(t,{className:"h-4 w-4 text-background"})})}function ex({approver:e}){return e.date?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-green-500/10 text-foreground",children:[a.jsx(d.CheckCircle,{className:"h-3.5 w-3.5 text-green-600"}),"Aprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:Xh(e.date)}),1!==e.type&&e.approvedUsername&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["por ",e.approvedUsername]})]}):e.returnDate?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-red-500/10 text-foreground",children:[a.jsx(d.XCircle,{className:"h-3.5 w-3.5 text-red-600"}),"Reprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:Xh(e.returnDate)})]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-muted text-muted-foreground",children:[a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),"Aguardando"]})}function ax({approver:e}){const{t:t}=j.useTranslation(),s=1!==e.type||e.approverId?e.name:"A definir";return a.jsxs("div",{children:[2===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:t("approval_user_group")}),3===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Local"}),a.jsx("p",{className:"text-sm font-medium break-words",children:s}),a.jsx(ex,{approver:e})]})}var tx;exports.ApprovalFlowReturnStep=void 0,(tx=exports.ApprovalFlowReturnStep||(exports.ApprovalFlowReturnStep={}))[tx.ApprovalFlow=1]="ApprovalFlow",tx[tx.Association=2]="Association",exports.i18n=e,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return j.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return j.useTranslation}}),exports.AUTH_CONFIG=Ie,exports.AccessDeniedDialog=Li,exports.Accordion=Bi,exports.AccordionContent=Wi,exports.AccordionItem=qi,exports.AccordionTrigger=$i,exports.ActionButton=Xt,exports.ActionMenu=Xt,exports.ActionMenuItems=co,exports.ActionPlanAttachmentsTab=xh,exports.ActionPlanCommentsTab=ch,exports.ActionPlanCostTab=dh,exports.ActionPlanGeneralTab=Zp,exports.ActionPlanHistoryTab=mh,exports.ActionPlanPage=function(e){const{formData:t,isLoading:s,isSaving:r,activeTab:n,isFormDisabled:o,updateField:i,setActiveTab:l,save:c,changeStatus:u,remove:m,cancel:p}=Kp(e),{t:h}=j.useTranslation(),{isNew:x=!1,config:f,users:g,places:v,actionTypes:b,causes:y,parentActions:w,progress:N,predecessors:_,availablePredecessors:C,costs:k,comments:S,history:T,attachments:P,attachmentsSlot:D,commentsSlot:E,historySlot:A,onAddPredecessor:I,onRemovePredecessor:M,onAddCost:F,onEditCost:R,onDeleteCost:L,onAddComment:z,onEditComment:U,onDeleteComment:O,onUploadAttachment:V,onDeleteAttachment:B,onRenameAttachment:q,onDownloadAttachment:$,onViewAttachment:W}=e;if(s&&!t.id)return a.jsx(tr,{isLoading:!0,children:a.jsx("div",{})});const H=function(e){const{t:a}=j.useTranslation();if(!e)return[];return{[exports.ETaskPlanStatus.waitingStart]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.running]:[exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.effectivenessCheck]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.done]:[exports.ETaskPlanStatus.running],[exports.ETaskPlanStatus.suspended]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.canceled]:[exports.ETaskPlanStatus.waitingStart]}[e]||[]}(t.statusId);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[p&&a.jsx(Kt,{variant:"ghost",size:"icon",onClick:p,children:a.jsx(d.ArrowLeft,{className:"h-4 w-4"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:x?h("ap_new_action"):t.name||h("ap_action_plan")}),!x&&t.statusId&&a.jsx(Jp,{status:t.statusId})]}),t.code&&a.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:t.code})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!x&&H.length>0&&!o&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:"outline",size:"sm",children:"Alterar Status"})}),a.jsx(mr,{align:"end",children:H.map(e=>a.jsx(pr,{onClick:()=>u(e),children:Wp[e]},e))})]}),!x&&e.onDelete&&a.jsxs(rr,{children:[a.jsx(nr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",children:a.jsx(d.MoreVertical,{className:"h-4 w-4"})})}),a.jsx(mr,{align:"end",children:a.jsx(pr,{className:"text-destructive",onClick:m,children:"Excluir"})})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:a.jsxs(ji,{value:n,onValueChange:l,children:[a.jsxs(yi,{className:"mb-6",children:[a.jsx(wi,{value:"general",children:"Geral"}),!x&&a.jsx(wi,{value:"progress",children:"Progresso"}),!x&&f?.enablePredecessors&&a.jsx(wi,{value:"predecessors",children:h("ap_predecessors")}),!x&&f?.enableCosts&&a.jsx(wi,{value:"costs",children:"Custos"}),!x&&f?.enableAttachments&&a.jsx(wi,{value:"attachments",children:h("ap_attachments")}),!x&&f?.enableComments&&a.jsx(wi,{value:"comments",children:h("ap_comments")}),!x&&f?.enableHistory&&a.jsx(wi,{value:"history",children:"Histórico"})]}),a.jsx(Ni,{value:"general",children:a.jsx(Zp,{formData:t,updateField:i,disabled:o,users:g,places:v,actionTypes:b,causes:y,parentActions:w,config:f})}),!x&&a.jsx(Ni,{value:"progress",children:a.jsx(oh,{...e})}),!x&&f?.enablePredecessors&&a.jsx(Ni,{value:"predecessors",children:a.jsx(lh,{predecessors:_,availablePredecessors:C,onAdd:I,onRemove:M,disabled:o})}),!x&&f?.enableCosts&&a.jsx(Ni,{value:"costs",children:a.jsx(dh,{costs:k,onAdd:F,onEdit:R,onDelete:L,disabled:o})}),!x&&f?.enableAttachments&&a.jsx(Ni,{value:"attachments",children:D||a.jsx(xh,{attachments:P,onUpload:V,onDelete:B,onRename:q,onDownload:$,onView:W,disabled:o})}),!x&&f?.enableComments&&a.jsx(Ni,{value:"comments",children:E||a.jsx(ch,{comments:S,onAdd:z,onEdit:U,onDelete:O,disabled:o})}),!x&&f?.enableHistory&&a.jsx(Ni,{value:"history",children:A||a.jsx(mh,{history:T})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[p&&a.jsx(Kt,{variant:"outline",onClick:p,disabled:r,children:"Cancelar"}),a.jsx(Kt,{onClick:c,disabled:r||o,children:r?"Salvando...":"Salvar"})]})]})},exports.ActionPlanPredecessorsTab=lh,exports.ActionPlanProgressDialog=nh,exports.ActionPlanProgressTab=oh,exports.ActionPlanStatusBadge=Jp,exports.Alert=Xo,exports.AlertDescription=Zo,exports.AlertDialog=ls,exports.AlertDialogAction=gs,exports.AlertDialogCancel=vs,exports.AlertDialogContent=ms,exports.AlertDialogDescription=fs,exports.AlertDialogFooter=hs,exports.AlertDialogHeader=ps,exports.AlertDialogOverlay=us,exports.AlertDialogPortal=cs,exports.AlertDialogTitle=xs,exports.AlertDialogTrigger=ds,exports.AlertTitle=Jo,exports.AliasRedirect=function(){const{alias:e}=Dn(),{pathname:t,search:s,hash:r}=_.useLocation();return e?a.jsx(_.Navigate,{to:`/${e}${t}${s}${r}`,replace:!0}):null},exports.AliasRouteGuard=function({children:e,paramName:s="alias"}){const r=_.useNavigate(),n=_.useLocation(),o=_.useParams(),{alias:i,isAuthenticated:l,isLoading:d,switchUnit:c}=Dn(),{urlAlias:u,isAliasMismatch:m,isValidAlias:p,isMissing:h,matchedCompany:x}=Yo({paramName:s}),[f,g]=t.useState(!1),v=t.useRef(!1),b=s in o,j=t.useCallback(e=>{const a=o[s],{pathname:t,search:r,hash:i}=n;if(a){const s=t.split("/"),n=s.findIndex(e=>e===a);if(n>=0)return s[n]=e,s.join("/")+r+i}return`/${e}${"/"===t?"":t}${r}${i}`},[o,s,n]);return t.useEffect(()=>{if(b&&!d&&l&&i&&!v.current)if(h)r(j(i),{replace:!0});else if(!u||p){if(m&&x&&!v.current){(async()=>{v.current=!0,g(!0);try{await c(x)}catch(e){i&&r(j(i),{replace:!0})}finally{v.current=!1,g(!1)}})()}}else r(j(i),{replace:!0})},[b,d,l,i,h,u,p,m,x,c,j,r]),d||!l?a.jsx(a.Fragment,{children:e}):f?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(ar,{size:"lg"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Trocando unidade..."})]})}):a.jsx(a.Fragment,{children:e})},exports.AppHeader=zm,exports.AppLayout=Gm,exports.AppSidebar=Hm,exports.ApprovalSidenav=function({config:e,isLoading:s=!1,onClose:r,onApprove:n,onDefineApprover:o,onRefreshSteps:i,availableApprovers:l=[],isLoadingApprovers:c=!1}){const{t:u}=j.useTranslation(),[m,p]=t.useState(!1),[h,x]=t.useState(!1),[f,g]=t.useState(""),[v,b]=t.useState(""),[y,w]=t.useState(!1),[N,_]=t.useState(""),C=s||m,k=t.useCallback((e,a)=>{g(e),b(a??""),x(!0)},[]),S=t.useCallback(async a=>{x(!1),p(!0);if(!await n(e.associationId,{stepApproverId:f,...a}))return k(f,a.observation),void p(!1);r(),p(!1)},[e.associationId,f,n,r,k]),T=t.useCallback(e=>{_(e),w(!0)},[]),P=t.useCallback(async a=>{w(!1),p(!0),await o(e.associationId,N,a),await(i?.(e.associationId)),p(!1)},[e.associationId,N,o,i]),D=e.approvalFlowSteps.find(e=>e.isCurrentStep)?.approvers.filter(e=>1===e.type&&e.approverId).map(e=>e.approverId)??[],E=(a,t)=>e.canApprove&&a.isCurrentStep&&t.approverId&&!t.date&&t.canApprove,A=(a,t)=>!e.flowReproved&&a.isCurrentStep&&1===t.type&&t.canApprove&&(!t.approverId||t.isToBeDefined);return a.jsxs("div",{className:"w-[550px] max-w-[900px] min-w-[400px] h-full flex flex-col bg-background",children:[a.jsxs("div",{className:"shrink-0 shadow-sm px-1 py-2 flex items-center gap-1 border-l-4",style:{borderLeftColor:e.color},children:[a.jsx(Kt,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0",children:a.jsx(d.X,{className:"h-5 w-5"})}),a.jsx("span",{className:"text-lg font-medium",children:e.title})]}),C?a.jsx(tr,{isLoading:!0,type:"spinner",className:"flex-1",children:a.jsx("div",{})}):a.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.approvalFlowInfo.length>0&&a.jsx("div",{className:"space-y-1",children:e.approvalFlowInfo.map((e,t)=>a.jsx("div",{className:Gt("flex items-center gap-1.5 text-sm",e.color&&"rounded-lg px-2 py-1"),style:e.color?{color:e.color,backgroundColor:e.backgroundColor}:void 0,children:e.title?`${e.title}: ${e.value}`:e.value},t))}),a.jsx("hr",{className:"border-border"}),e.approvalFlowSteps.map(t=>a.jsxs("div",{className:Gt("space-y-2",(!t.isCurrentStep||e.flowReproved)&&"opacity-50"),children:[a.jsxs("p",{className:"font-semibold text-sm",children:[t.index,". Etapa: ",t.name]}),t.description&&a.jsx("p",{className:"text-sm text-muted-foreground break-words",children:a.jsx(Jh,{text:t.description})}),t.returnDate&&a.jsxs("div",{className:"border-y border-border py-3 mt-3 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs rounded px-1.5 py-0.5 bg-red-500/10 text-red-600",children:"Retorno de etapa"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.returnUserName," em ",Xh(t.returnDate)]})]}),t.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground bg-muted rounded p-2 break-words",children:a.jsx(Jh,{text:t.returnObservation})})]}),t.approvers.map(e=>a.jsxs("div",{className:"p-2 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[a.jsx(Zh,{approver:e}),a.jsx(ax,{approver:e})]}),E(t,e)&&a.jsx(Kt,{size:"sm",onClick:()=>k(e.id),children:"Aprovar"}),A(t,e)&&a.jsx(Kt,{size:"sm",variant:"outline",onClick:()=>T(e.id),children:"Selecionar"})]}),e.observation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(Jh,{text:e.observation})}),e.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(Jh,{text:e.returnObservation})})]},e.id))]},t.id))]}),a.jsx(Qh,{open:h,onOpenChange:x,returnSteps:e.returnSteps,initialObservation:v,title:e.approveDialogTitle,descriptions:e.approveDialogDescriptions,setDefaultApproverOnInit:e.approveDialogSetDefaultApproverOnInit,onSubmit:S}),a.jsx(Kh,{open:y,onOpenChange:w,approvers:l,isLoading:c,ignoreUserIds:D,onSubmit:P})]})},exports.ApproveDialog=Qh,exports.AuditTrailDetails=Yh,exports.AuditTrailFilter=Fh,exports.AuditTrailPage=function({title:s,softwares:r,softwareId:n,permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},callbacks:i,limit:l=2e3,currentUserId:c,labels:u,formatDate:m,anonymousLabel:p=e.t("anonymous")}){const{t:h}=j.useTranslation();s??h("audit_trail");const[x,f]=t.useState(!0),[g,v]=t.useState([]),[b,y]=t.useState([]),[w,N]=t.useState([]),[_,C]=t.useState(null),[k,S]=t.useState(!1),T=t.useRef(null),P=new Date;P.setHours(0,0,0,0);const[D,E]=t.useState({software:r.find(e=>e.id===n)?.software||"",softwareId:n,event:"All",eventId:1,startDate:P,endDate:P,limit:l,softwares:r,userId:o.viewOnlyMyEvents&&!o.viewAllEvents?c:void 0});t.useEffect(()=>{(async()=>{f(!0);try{const[e,a]=await Promise.all([i.onFetchEvents(D.softwareId),i.onFetchUsers?.()??Promise.resolve([])]);y(e),N(a),await A(D,e)}catch(e){}finally{f(!1)}})()},[]);const A=t.useCallback(async(e,a)=>{try{const t=Lh((await i.onFetchTrails(e)).data,a||b,r,p);v(t)}catch(t){}},[i,b,r,p]),I=t.useCallback(async e=>{f(!0),E(e);try{await A(e)}finally{f(!1)}},[A]),M=t.useCallback(async e=>{try{const a=await i.onFetchEvents(e);y(a)}catch(a){}},[i]),F=t.useCallback(e=>{C(e.documentId),S(!0)},[]),R=t.useCallback(()=>{S(!1),C(null)},[]),L=t.useCallback(async()=>{const e={...D,startDate:P,endDate:P,eventId:1,userId:o.viewAllEvents?void 0:c};E(e),f(!0);try{await A(e)}finally{f(!1)}},[D,A]),z=t.useCallback(e=>{i.onExport?.(e,g)},[i,g]),U=t.useCallback(e=>{try{return new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}},[]);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"p-3",children:a.jsx(Fh,{queryParams:D,events:b,softwares:r,users:w,permissions:o,isLoading:x,onFilter:I,onReset:L,onExport:o.download?z:void 0,onSoftwareChange:M})}),a.jsxs("div",{className:"flex flex-1 min-h-0 relative",children:[a.jsxs("div",{className:Gt("flex-1 overflow-auto transition-all duration-300",k?"mr-[400px]":""),children:[x?a.jsxs("div",{className:"flex items-center justify-center h-64",children:[a.jsx(ar,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando trilha de auditoria..."})]}):0===g.length?a.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground",children:[a.jsx(d.FileText,{className:"h-12 w-12 mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:"Nenhum registro encontrado"}),a.jsx("p",{className:"text-xs mt-1",children:"Ajuste os filtros e tente novamente"})]}):a.jsxs("table",{className:"w-full text-xs border-collapse",children:[a.jsx("thead",{className:"sticky top-0 z-10",children:a.jsxs("tr",{className:"bg-muted/60 border-b border-border",children:[a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Layers,{className:"h-3 w-3"}),"Módulo"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),"Data"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.User,{className:"h-3 w-3"}),"Usuário"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.FileText,{className:"h-3 w-3"}),"Evento"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Item"}),a.jsx("th",{className:"px-3 py-2 w-10"})]})}),a.jsx("tbody",{children:g.map((e,t)=>a.jsxs("tr",{onClick:()=>F(e),className:Gt("cursor-pointer border-b border-border/50 transition-colors","hover:bg-accent/50",_===e.documentId&&"bg-accent",t%2==0?"bg-background":"bg-muted/10"),children:[a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedSoftware}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",children:e.date?U(e.date.toISOString()):"—"}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.user}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedEvent}),a.jsx("td",{className:"px-3 py-2 text-foreground truncate max-w-[200px]",title:e.entityName,children:e.entityName}),a.jsx("td",{className:"px-3 py-2",children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.documentId||t))})]}),!x&&g.length>0&&a.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border bg-muted/20",children:[g.length," registro",1!==g.length?"s":""]})]}),a.jsx("div",{ref:T,className:Gt("fixed right-0 top-0 h-full w-[400px] border-l border-border bg-background shadow-lg z-30","transition-transform duration-300 ease-in-out",k?"translate-x-0":"translate-x-full"),children:k&&a.jsx(Yh,{documentId:_,onFetchDetails:i.onFetchDetails,onClose:R,labels:u,translateProperty:i.translateProperty,translatePropertyValue:i.translatePropertyValue,formatDate:m||U})})]})]})},exports.AuthErrorInterceptor=un,exports.AuthProvider=Pn,exports.AuthService=Cn,exports.AutoComplete=zr,exports.Avatar=Hi,exports.AvatarFallback=Yi,exports.AvatarImage=Gi,exports.Badge=Zs,exports.BaseForm=Lo,exports.Blockquote=Ul,exports.BodyContent=function({breadcrumbs:e,children:t,className:s}){return a.jsxs("div",{className:Gt("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[e&&e.length>0&&a.jsx(Qi,{className:"mb-4",children:a.jsx(Ki,{children:e.map((t,s)=>{const r=s===e.length-1;return a.jsxs(ae.Fragment,{children:[s>0&&a.jsx(el,{}),a.jsx(Xi,{children:r||!t.href?a.jsx(Zi,{children:t.label}):t.asChild&&t.children?a.jsx(Ji,{asChild:!0,children:t.children}):a.jsx(Ji,{asChild:!0,children:a.jsx(_.Link,{to:t.href||"/",children:t.label})})})]},`${t.label}-${s}`)})})}),a.jsx("div",{className:"space-y-6",children:t})]})},exports.Breadcrumb=Qi,exports.BreadcrumbEllipsis=al,exports.BreadcrumbItem=Xi,exports.BreadcrumbLink=Ji,exports.BreadcrumbList=Ki,exports.BreadcrumbPage=Zi,exports.BreadcrumbSeparator=el,exports.BurndownPanel=Zu,exports.Button=Kt,exports.ButtonGroup=sl,exports.CLOSED_STATUSES=Yp,exports.CRUD_CONFIG=Me,exports.CURRENCY_FIELDS=ku,exports.Calendar=rl,exports.CallbackPage=()=>{const{processCallback:e}=Dn(),s=_.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await e()){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(a){localStorage.removeItem("auth_return_url"),n(a?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e,s]);const l=async()=>{i(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(a){n(a?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(as,{className:"w-full max-w-md",children:[a.jsx(ts,{className:"text-center",children:a.jsxs(ss,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[a.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),a.jsxs(ns,{className:"space-y-4",children:[a.jsx(Xo,{variant:"danger",children:a.jsx(Zo,{children:r})}),a.jsx("div",{className:"text-sm text-muted-foreground",children:a.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Kt,{onClick:l,disabled:o,className:"flex-1",children:o?a.jsxs(a.Fragment,{children:[a.jsx(ar,{size:"sm",className:"mr-2"}),"Tentando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),a.jsx(Kt,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(as,{className:"w-full max-w-md",children:[a.jsx(ts,{className:"text-center",children:a.jsx(ss,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),a.jsxs(ns,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(ar,{size:"lg"})}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=as,exports.CardContent=ns,exports.CardDescription=rs,exports.CardFooter=os,exports.CardHeader=ts,exports.CardSkeleton=qn,exports.CardTitle=ss,exports.CartesianPanel=Yu,exports.ChartContainer=mc,exports.ChartLegend=fc,exports.ChartLegendContent=gc,exports.ChartStyle=pc,exports.ChartTooltip=hc,exports.ChartTooltipContent=xc,exports.Checkbox=Ks,exports.Collapsible=fi,exports.CollapsibleContent=vi,exports.CollapsibleTrigger=gi,exports.ColorPicker=Do,exports.ColumnSettingsPopover=Co,exports.ComboTree=Hr,exports.Combobox=zr,exports.Command=Sr,exports.CommandDialog=({children:e,...t})=>a.jsx("div",{...t,children:a.jsx(Sr,{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:e})}),exports.CommandEmpty=Dr,exports.CommandGroup=Er,exports.CommandInput=Tr,exports.CommandItem=Ir,exports.CommandList=Pr,exports.CommandSeparator=Ar,exports.CommandShortcut=Mr,exports.ContentContainer=function({title:e,subtitle:t,children:s,className:r,hasHeader:n=!0}){const o=e||t;return a.jsxs("div",{className:Gt("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-visible",r),children:[n&&o&&a.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[e&&a.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),t&&a.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),s&&a.jsx("div",{className:Gt("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Yn,exports.ContextMenuCheckboxItem=ro,exports.ContextMenuContent=to,exports.ContextMenuGroup=Kn,exports.ContextMenuItem=so,exports.ContextMenuLabel=oo,exports.ContextMenuPortal=Xn,exports.ContextMenuRadioGroup=Zn,exports.ContextMenuRadioItem=no,exports.ContextMenuSeparator=io,exports.ContextMenuShortcut=lo,exports.ContextMenuSub=Jn,exports.ContextMenuSubContent=ao,exports.ContextMenuSubTrigger=eo,exports.ContextMenuTrigger=Qn,exports.CoreProviders=function({children:s,queryClient:r,moduleAlias:n,moduleAccessGuardProps:o,appTranslations:i}){Vi();const[l]=t.useState(()=>new N.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),d=r??l;return t.useEffect(()=>{if(i)for(const[e,a]of Object.entries(i))ii(e,a)},[i]),a.jsx(bi,{children:a.jsx(j.I18nextProvider,{i18n:e,children:a.jsx(N.QueryClientProvider,{client:d,children:a.jsx(Pn,{children:a.jsx(ui,{children:a.jsx(hi,{moduleAlias:n,children:a.jsx(Ui,{...o,children:s})})})})})})})},exports.CrudActionBar=jo,exports.CrudActionMenu=jm,exports.CrudGrid=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f,showActionBar:g=!0,showSearch:v=!1,searchValue:b,onSearchChange:y,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:_,filters:C,gridColumns:k=3,renderCard:S,viewMode:T,onViewModeChange:P,listCardRenderer:D,gridCardRenderer:E,showViewToggle:A=!1})=>{const{setSearchVisible:I}=Dn(),M=void 0!==f?!f:g;t.useEffect(()=>{if(!v)return I(!0),()=>I(!1)},[I,v]);const F=m||x.length>0||v||u||C||A,R=_||(()=>{s.bulkDelete?.(s.selectedIds)}),L=T||"grid",z="list"===L,U={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"}[z?1:k],O=M&&F?a.jsx(jo,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:v,searchValue:b,onSearchChange:y,searchPlaceholder:w,showBulkActions:u,selectedCount:s.selectedIds.length,bulkActions:N,onBulkDelete:R,onClearSelection:s.clearSelection,customActions:x,filters:C,viewMode:L,onViewModeChange:P,showViewToggle:A,availableViewModes:["list","grid"]}):null;return s.isLoading?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx(qn,{count:6})})]}):0===s.entities.length?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx(Wn,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"})})]}):a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx("div",{className:Gt("grid gap-4",U),children:s.entities.map(e=>{const t=(e=>{const{t:a}=j.useTranslation();return z&&D?D(e):!z&&E?E(e):S?S(e):null})(e);return a.jsxs(Yn,{children:[a.jsx(Qn,{asChild:!0,children:t?a.jsx("div",{className:"cursor-pointer",onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:t}):a.jsx(as,{className:Gt("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&s.selectedIds.includes(e.id)&&"bg-muted ring-2 ring-primary",z&&"flex-row"),onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:a.jsxs(ns,{className:Gt("p-4",z&&"flex items-center gap-4 w-full"),children:[u&&a.jsx("div",{className:Gt(z?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),z?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:r.map(t=>a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key)))}),(n||o||d)&&a.jsx("div",{onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(uo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[u&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[r.map((t,s)=>a.jsxs("div",{className:Gt("flex justify-between items-start gap-2",s!==r.length-1&&"mb-2"),children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||d)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(uo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]})]})]})})}),a.jsx(to,{className:"w-[160px]",children:a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:c?c(e):[],renderAs:"context"})})]},e.id)})})})]})},exports.CrudPageInternal=Wo,exports.CrudPagination=Uo,exports.CrudPrimitiveFilterBar=ym,exports.CrudPrimitivePagination=zo,exports.CrudPrimitiveTable=bm,exports.CrudTable=So,exports.CustomFormFields=function({fields:e,readOnly:s=!1,hideInactiveWithoutValue:r=!1,onChange:n,onFieldChange:o}){const i=t.useCallback(a=>{if(o?.(a),n){const t=e.map(e=>e.id===a.id?a:e);n(t)}},[e,n,o]),l=e.filter(e=>_h(e,r));return 0===l.length?null:a.jsx("div",{className:"space-y-4",children:l.map(e=>a.jsx(Mh,{field:e,readOnly:s,onChange:i},e.id))})},exports.D4SignWidget=Fp,exports.DASHBOARD_STORAGE_KEYS={advancedFilter:"analysisDashboardsListFilter"},exports.DATETIME_FORMATS=Pt,exports.DEFAULT_ACTION_TYPES=Hp,exports.DEFAULT_DATETIME_FORMAT=At,exports.DEFAULT_LOCALE=Et,exports.DEFAULT_TIMEZONE=It,exports.DashboardForm=vm,exports.DashboardGeneralView=function({dashboards:e,limit:s,generalView:r,language:n=exports.DashboardLanguage.PtBr,isLoading:o=!1,canAdd:i=!1,canEdit:l=!1,canRemove:d=!1,canEditStandard:c=!1,activePanels:u=[],activePages:m=[],getPanelData:p,users:h=[],groups:x=[],places:f=[],collaborators:g=[],isSaving:v=!1,onOpen:b,onBackToList:j,onRefresh:y,onRefreshList:w,onToggleFavorite:N,onSave:_,onUpdate:C,onRemove:k,onDuplicate:S,onShare:T,onAddPanel:P,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:A,onLayoutChange:I,onSearch:M,onQuickFilterChange:F,onSetGeneralView:R,viewState:L,onViewStateChange:z,listToolbarExtra:U,viewToolbarActions:O,className:V}){const[B,q]=t.useState({mode:"list"}),$=L??B,W=t.useCallback(e=>{z?z(e):q(e)},[z]),H=t.useMemo(()=>"view"===$.mode||"edit"===$.mode||"share"===$.mode?e.find(e=>e.id===$.dashboardId)??null:null,[e,$]),[G,Y]=t.useState(!1),[Q,K]=t.useState(m[0]?.id);t.useEffect(()=>{m.length>0&&!Q&&K(m[0]?.id)},[m,Q]),t.useEffect(()=>{if("view"!==$.mode||!H||H.idViewType!==exports.DashboardViewType.Carousel||m.length<=1)return;const e=function(e){switch(e){case exports.DashboardPageTime.FiveSeconds:return 5e3;case exports.DashboardPageTime.TenSeconds:return 1e4;case exports.DashboardPageTime.FifteenSeconds:return 15e3;case exports.DashboardPageTime.ThirtySeconds:return 3e4;case exports.DashboardPageTime.OneMinute:return 6e4;case exports.DashboardPageTime.ThreeMinutes:return 18e4;case exports.DashboardPageTime.FiveMinutes:return 3e5;case exports.DashboardPageTime.TenMinutes:return 6e5;default:return 15e3}}(H.idPageTime),a=setInterval(()=>{K(e=>{const a=(m.findIndex(a=>a.id===e)+1)%m.length;return m[a]?.id})},e);return()=>clearInterval(a)},[$,H,m]);const X=t.useCallback(e=>{W({mode:"view",dashboardId:e.id}),K(void 0),b?.(e)},[W,b]),J=t.useCallback(()=>{W({mode:"list"}),Y(!1),j?.()},[W,j]),Z=t.useCallback(()=>{W({mode:"create"})},[W]),ee=t.useCallback(e=>{W({mode:"edit",dashboardId:e.id})},[W]),ae=t.useCallback(e=>{W({mode:"share",dashboardId:e.id})},[W]),te=t.useCallback(e=>{"edit"===$.mode||"share"===$.mode?C?.($.dashboardId,e):_?.(e)},[$,_,C]),se=t.useCallback(()=>{"edit"===$.mode||"share"===$.mode?W({mode:"view",dashboardId:$.dashboardId}):W({mode:"list"})},[$,W]),re=t.useCallback(()=>{H&&N?.(H)},[H,N]),ne=t.useCallback(()=>{H&&ee(H)},[H,ee]),oe=t.useCallback(()=>{H&&ae(H)},[H,ae]);return a.jsxs("div",{className:Gt("flex flex-col h-full",V),children:["list"===$.mode&&a.jsx(mm,{dashboards:e,limit:s,isLoading:o,language:n,canAdd:i,canEdit:l,canRemove:d,onOpen:X,onEdit:ee,onShare:ae,onDuplicate:S,onRemove:k,onAdd:Z,onToggleFavorite:N,onRefresh:w,onSearch:M,onQuickFilterChange:F,toolbarExtra:U,className:"flex-1"}),"view"===$.mode&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[!G&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:[a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]}),r?.dashboardId===H.id&&a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary",children:[a.jsxs("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),a.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),"Visão geral"]}),l&&R&&r?.dashboardId!==H.id&&a.jsx("button",{onClick:()=>R(H.id),className:"ml-auto text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Definir como visão geral"})]}),a.jsx(lm,{dashboard:H,panels:u,pages:m,activePageId:Q,canEdit:l||c&&!!H.isStandard,isFullscreen:G,isLoading:o,getPanelData:p,onRefresh:y,onToggleFullscreen:()=>Y(e=>!e),onToggleFavorite:re,onEdit:ne,onShare:oe,onAddPanel:P,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:A,onLayoutChange:I,onPageChange:K,toolbarActions:O,className:"flex-1"})]}),"create"===$.mode&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]})}),a.jsx(vm,{users:h,groups:x,places:f,collaborators:g,isSaving:v,onSave:te,onCancel:se,className:"flex-1"})]}),("edit"===$.mode||"share"===$.mode)&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:se,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar"]})}),a.jsx(vm,{dashboard:H,initialTab:"share"===$.mode?exports.DashboardFormTab.Share:exports.DashboardFormTab.General,users:h,groups:x,places:f,collaborators:g,isSaving:v,isQualitfy:!!H.isStandard&&!c,onSave:te,onCancel:se,className:"flex-1"})]})]})},exports.DashboardGrid=nm,exports.DashboardList=mm,exports.DashboardPanelRenderer=im,exports.DashboardView=lm,exports.DataFilterBar=ym,exports.DataList=nl,exports.DataPagination=zo,exports.DataTable=bm,exports.DatePicker=ol,exports.Dialog=bs,exports.DialogBody=Ss,exports.DialogClose=ws,exports.DialogContent=Cs,exports.DialogDescription=Ds,exports.DialogFooter=Ts,exports.DialogHeader=ks,exports.DialogOverlay=Ns,exports.DialogPortal=ys,exports.DialogTitle=Ps,exports.DialogTrigger=js,exports.DialogWizard=function({open:t,onOpenChange:s,currentStep:r,onStepChange:n,steps:o,canGoToStep:i,children:l,title:c,description:u,onSave:m,saveLabel:p=e.t("save"),nextLabel:h=e.t("next"),backLabel:x=e.t("back"),variant:f="form",isDirty:g,size:v="lg",unsavedChangesTitle:b,unsavedChangesDescription:y,cancelText:w,leaveWithoutSavingText:N,className:_,disableNext:C,hideNavigation:k,footerLeft:S}){const{t:T}=j.useTranslation(),P=o.length,D=r>=P,E=r<=1;return a.jsx(bs,{open:t,onOpenChange:s,children:a.jsxs(Cs,{size:v,variant:f,isDirty:g,unsavedChangesTitle:b,unsavedChangesDescription:y,cancelText:w,leaveWithoutSavingText:N,className:Gt("!p-0 !border-l-0 flex-row overflow-hidden",_),children:[a.jsxs("div",{className:"hidden sm:flex w-56 flex-shrink-0 flex-col bg-primary text-primary-foreground p-6 rounded-l-lg",children:[a.jsx("h3",{className:"text-sm font-medium opacity-80 mb-6",children:"Etapas"}),a.jsx("nav",{className:"flex flex-col gap-1 flex-1",children:o.map((e,t)=>{const s=t+1,o=s===r,l=(e=>e<r)(s),c=(u=s)<=r||!i||i(u);var u;return a.jsxs("button",{type:"button",onClick:()=>(e=>{e!==r&&(e<r?n(e):i&&!i(e)||n(e))})(s),disabled:!c,className:Gt("flex items-center gap-2 py-3 px-2 rounded-md text-left transition-colors text-xs",o&&"bg-primary-foreground/20 font-semibold",!o&&c&&"hover:bg-primary-foreground/10 cursor-pointer",!c&&"opacity-40 cursor-not-allowed"),children:[a.jsx("span",{className:Gt("flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold flex-shrink-0 transition-colors",o&&"bg-primary-foreground text-primary",l&&!o&&"bg-primary-foreground/30 text-primary-foreground",!o&&!l&&"border-2 border-primary-foreground/40 text-primary-foreground/60"),children:l&&!o?a.jsx(d.Check,{className:"h-3.5 w-3.5"}):s}),a.jsx("span",{className:Gt("line-clamp-2",o&&"text-primary-foreground",!o&&"text-primary-foreground/70"),children:e})]},s)})})]}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[a.jsxs(ks,{className:"p-6 pb-0",children:[a.jsxs("p",{className:"text-xs text-muted-foreground sm:hidden mb-1",children:["Etapa ",r," de ",P]}),a.jsx(Ps,{children:c}),u&&a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]}),a.jsx(Ss,{className:"px-6",children:l}),!k&&a.jsx(Ts,{className:"px-6 pb-6",children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("div",{className:"flex items-center gap-2",children:S}),a.jsxs("div",{className:"flex items-center gap-2",children:[!E&&a.jsx(Kt,{variant:"outline",onClick:()=>n(r-1),children:x}),D?a.jsx(Kt,{onClick:m,disabled:C,children:p}):a.jsx(Kt,{onClick:()=>n(r+1),disabled:C,children:h})]})]})})]})]})})},exports.DisabledMenuItem=Nr,exports.DocumentSigner=function({file:s,onDocumentSigned:r,onError:n,showEventLog:o=!1}){const{user:i,alias:c}=Dn(),{config:u,isLoading:m}=kp(),{t:p}=j.useTranslation(),[h,x]=t.useState(null),[f,g]=t.useState(!1),[v,b]=t.useState(null),[y,w]=t.useState("sandbox"),[N,_]=t.useState("clicksign"),[C,k]=t.useState(null),[S,T]=t.useState(null),[P,D]=t.useState(!1),[E,A]=t.useState(0),[I,M]=t.useState(!1),[F,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),U=t.useCallback(e=>{o&&R(a=>[...a,`[${(new Date).toLocaleTimeString()}] ${e}`])},[o]),O=t.useCallback(async a=>{if(x(a),b(null),k(null),T(null),U(`Arquivo selecionado: ${a.name}`),c&&i){g(!0);try{const t=u?.provider??"clicksign";_(t),U(`Provedor resolvido: ${t}`);const s=new FileReader,r=await new Promise((e,t)=>{s.onload=()=>{const a=s.result;e(a)},s.onerror=t,s.readAsDataURL(a)});U(`Criando envelope para assinatura via ${t}...`);const o=await Dp.createEnvelopeWithSigner({alias:c,contentBase64:r,filename:a.name,signerEmail:i.email||"",signerName:i.name||"",provider:t});U(`Envelope criado: ${o.envelope_id}`),k({envelope_id:o.envelope_id,document_id:o.document_id,signer_email:o.signer_email,key_signer:o.signer_id}),w(o.environment),_(o.provider||t),"d4sign"===t?(U("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(o.document_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):o.signer_id?(U(`Signer ID obtido: ${o.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(o.signer_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):(U(e.t("sign_signer_unavailable")),l.toast.error(p("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),n?.(new Error(p("sign_signer_unavailable"))))}catch(t){const a=t instanceof Error?t:new Error(p("sign_process_error",p("sign_doc_process_error"))),s=a.message||"";s.includes("MONTHLY_LIMIT_REACHED")?(U(e.t("sign_monthly_limit")),l.toast.error(p("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(U(`Erro: ${s}`),l.toast.error(s)),n?.(a)}finally{g(!1)}}},[c,i,U,n,u]);t.useEffect(()=>{s&&c&&i&&!m&&s!==z.current&&(z.current=s,O(s))},[s,c,i,m,O]);const V=t.useCallback(async()=>{if(!C||!c)return;D(!0),A(0),M(!1),U("Buscando documento assinado...");for(let t=1;t<=6;t++){A(t),U(`Tentativa ${t}/6...`);try{const a=await Dp.getSignedDocument({alias:c,envelopeId:C.envelope_id,documentId:C.document_id,provider:N});if(a.download_url)return U(e.t("sign_doc_available")),T(a.download_url),void D(!1)}catch(a){U(`Erro na tentativa ${t}: ${a instanceof Error?a.message:p("unknown_error")}`)}t<6&&(U("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}U(e.t("sign_fetch_failed")),D(!1),M(!0)},[C,c,U,N]),B=t.useCallback(async()=>{U("Documento assinado com sucesso!"),l.toast.success(p("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&c&&(r?.({success:!0,provider:N,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:v||"",environment:y}),await V())},[U,r,C,v,c,y,N,V]);if(!c)return a.jsx(as,{className:"border-amber-200 bg-amber-50",children:a.jsx(ns,{className:"flex items-start gap-3 py-6",children:a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-amber-800",children:p("sign_auth_required","Autenticação necessária")}),a.jsx("p",{className:"text-sm text-amber-700 mt-1",children:p("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const q="d4sign"===N?"D4Sign":"Clicksign",$=()=>o&&F.length>0?a.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:F.map((e,t)=>a.jsx("div",{children:e},t))}):null;return C&&!v&&(S||P||I)?a.jsxs("div",{className:"space-y-4",children:[a.jsx(as,{className:"border-green-200 bg-green-50",children:a.jsxs(ns,{className:"flex flex-col items-center gap-4 py-8",children:[a.jsx(d.CheckCircle2,{className:"h-12 w-12 text-green-600"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-lg font-semibold text-green-800",children:p("sign_signed_success","Documento assinado com sucesso!")}),a.jsx("p",{className:"text-sm text-green-700 mt-1",children:h?.name})]}),P?a.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),p("sign_preparing_doc","Preparando documento assinado...")," (",p("sign_attempt","tentativa")," ",E,"/6)"]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_waiting_provider",`Aguardando processamento pelo ${q}...`)})]}):S?a.jsx(Kt,{asChild:!0,variant:"default",className:"gap-2",children:a.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(d.Download,{className:"h-4 w-4"}),p("sign_download_signed","Baixar documento assinado")]})}):I?a.jsxs("div",{className:"text-center space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),a.jsxs(Kt,{variant:"secondary",className:"gap-2",onClick:V,children:[a.jsx(d.RefreshCw,{className:"h-4 w-4"}),p("sign_try_again","Tentar novamente")]})]}):null]})}),a.jsx($,{})]}):v?a.jsxs("div",{className:"space-y-4",children:["d4sign"===N?a.jsx(Fp,{documentKey:v,signerEmail:C?.signer_email||i?.email||"",signerName:i?.name,keySigner:C?.key_signer,environment:y,onSign:B,onError:n}):a.jsx(Mp,{signerId:v,environment:y,onSign:B,onError:n}),a.jsx($,{})]}):s&&(f||m)?a.jsx(as,{children:a.jsxs(ns,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const a=e.target.files?.[0];a&&"application/pdf"===a.type?O(a):l.toast.error(p("sign_select_pdf","Selecione um arquivo PDF"))}}),f?a.jsx(as,{children:a.jsxs(ns,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsx(as,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:a.jsxs(ns,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[a.jsx(d.Upload,{className:"h-8 w-8 text-muted-foreground"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"font-medium",children:p("sign_select_pdf","Selecione um arquivo PDF")}),a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),a.jsx($,{})]})},exports.Drawer=il,exports.DrawerClose=cl,exports.DrawerContent=ml,exports.DrawerDescription=fl,exports.DrawerFooter=hl,exports.DrawerHeader=pl,exports.DrawerOverlay=ul,exports.DrawerPortal=dl,exports.DrawerTitle=xl,exports.DrawerTrigger=ll,exports.DropdownMenu=rr,exports.DropdownMenuCheckboxItem=hr,exports.DropdownMenuContent=mr,exports.DropdownMenuGroup=or,exports.DropdownMenuItem=pr,exports.DropdownMenuLabel=fr,exports.DropdownMenuPortal=ir,exports.DropdownMenuRadioGroup=dr,exports.DropdownMenuRadioItem=xr,exports.DropdownMenuSeparator=gr,exports.DropdownMenuShortcut=vr,exports.DropdownMenuSub=lr,exports.DropdownMenuSubContent=ur,exports.DropdownMenuSubTrigger=cr,exports.DropdownMenuTrigger=nr,exports.ElectronicSignatureDialog=function({open:s,onOpenChange:r,onConfirm:n,onGenerateCode:o,mode:i="code",email:l,maxLength:c=8,title:u=e.t("electronic_signature"),description:m,confirmLabel:p=e.t("conclude"),cancelLabel:h=e.t("cancel"),resendLabel:x=e.t("resend_code"),errorMessage:f}){const g="password"===i,v=g?e.t("esign_password_description"):e.t("esign_code_description"),b=m??v,[j,y]=t.useState(""),[w,N]=t.useState(!1),[_,C]=t.useState(!1),[k,S]=t.useState(null),T=t.useCallback(async()=>{if(j.trim()){N(!0),S(null);try{await n(j)?(y(""),r(!1)):S(f??(g?e.t("esign_invalid_password"):e.t("esign_invalid_code")))}catch{S(f??(g?e.t("esign_password_error"):e.t("esign_code_error")))}finally{N(!1)}}},[j,n,r,f,g]),P=t.useCallback(async()=>{if(o){C(!0),S(null);try{await o()}catch{S(e.t("esign_resend_error"))}finally{C(!1)}}},[o]),D=e=>{e||(y(""),S(null)),r(e)},E=g?d.Lock:d.ShieldCheck,A=g?"Senha":e.t("verification_code"),I=g?e.t("enter_password"):e.t("enter_code");return a.jsx(bs,{open:s,onOpenChange:D,children:a.jsxs(Cs,{className:"sm:max-w-md",variant:"form",isDirty:!!j,children:[a.jsx(ks,{children:a.jsxs(Ps,{className:"flex items-center gap-2",children:[a.jsx(E,{className:"h-5 w-5 text-primary"}),u]})}),a.jsxs("div",{className:"py-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:b}),!g&&l&&a.jsxs("div",{className:"flex items-center gap-2 text-sm bg-muted/50 rounded-md px-3 py-2",children:[a.jsx(d.Mail,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-muted-foreground",children:"Enviado para:"}),a.jsx("span",{className:"font-medium",children:l})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"signature-input",children:A}),a.jsx(Jt,{id:"signature-input",type:g?"password":"text",value:j,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j.trim()&&(e.preventDefault(),T())},maxLength:g?void 0:c,placeholder:I,autoFocus:!0,className:Gt(k&&"border-destructive focus-visible:ring-destructive")}),k&&a.jsx("p",{className:"text-sm text-destructive",children:k})]}),!g&&a.jsxs(Kt,{variant:"ghost",size:"sm",onClick:P,disabled:_,className:"text-primary",children:[a.jsx(d.RefreshCw,{className:Gt("h-4 w-4 mr-1",_&&"animate-spin")}),x]})]}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"outline",onClick:()=>D(!1),disabled:w,children:h}),a.jsx(Kt,{onClick:T,disabled:!j.trim()||w,children:w?"Validando...":p})]})]})})},exports.EllipsisText=Hn,exports.EmailService=Ym,exports.EmptyState=Wn,exports.EntitySelect=zr,exports.ErrorBoundary=bi,exports.ExportDialog=function({open:e,onOpenChange:s,onExport:r,mode:n="table",options:o,title:i,description:l,cancelLabel:d="Cancelar",exportLabel:c="Exportar"}){const{t:u}=j.useTranslation(),[m,p]=t.useState(""),h=o??("chart"===n?Tc:Sc),x=i??u("chart"===n?"dashboard_export_chart":"dashboard_export_table"),f=l??u("select_file_format"),g=e=>{e||p(""),s(e)};return a.jsx(bs,{open:e,onOpenChange:g,children:a.jsxs(Cs,{className:"sm:max-w-md",variant:"form",isDirty:!!m,children:[a.jsx(ks,{children:a.jsx(Ps,{children:x})}),a.jsxs("div",{className:"py-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),a.jsx(rd,{value:m,onValueChange:p,className:"gap-3",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(nd,{value:e.value,id:`export-${e.value}`}),a.jsxs(es,{htmlFor:`export-${e.value}`,className:Gt("flex items-center gap-2 cursor-pointer font-normal",m===e.value&&"font-medium"),children:[e.icon,e.label]})]},e.value))})]}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"outline",onClick:()=>g(!1),children:d}),a.jsx(Kt,{onClick:()=>{m&&(r(m),s(!1),p(""))},disabled:!m,children:c})]})]})})},exports.FORBIDDEN_FILE_TYPES=gh,exports.FilterBar=$o,exports.Form=Es,exports.FormControl=Ls,exports.FormDateField=Sh,exports.FormDescription=zs,exports.FormField=({...e})=>a.jsx(As.Provider,{value:{name:e.name},children:a.jsx(h.Controller,{...e})}),exports.FormItem=Fs,exports.FormLabel=Rs,exports.FormMessage=Us,exports.FormMultiSelectionField=Ah,exports.FormNumericField=Dh,exports.FormQuestionsField=Ih,exports.FormSingleSelectionField=Eh,exports.FormSkeleton=function({fields:e=4}){return a.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Fr,{className:"h-4 w-24"}),a.jsx(Fr,{className:"h-10 w-full"})]},t)),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Fr,{className:"h-10 w-20"}),a.jsx(Fr,{className:"h-10 w-20"})]})]})},exports.FormTextField=kh,exports.FormTimeField=Th,exports.FormUrlField=Ph,exports.Grid=function({children:e,cols:t="auto-fit",gap:s="md",className:r}){return a.jsx("div",{className:Gt("grid",gl[t],vl[s],r),children:e})},exports.H1=Pl,exports.H2=Dl,exports.H3=El,exports.H4=Al,exports.HeaderSkeleton=function(){return a.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Fr,{className:"h-8 w-8 rounded-full"}),a.jsx(Fr,{className:"h-6 w-32"})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Fr,{className:"h-8 w-8"}),a.jsx(Fr,{className:"h-8 w-24"})]})]})},exports.HoverCard=bl,exports.HoverCardContent=yl,exports.HoverCardTrigger=jl,exports.IconPicker=Io,exports.IframeDialog=Bc,exports.ImageEditor=function({value:e,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:i,uploadOptions:c}){const{t:u}=j.useTranslation(),[m,p]=t.useState(e||{alignment:"center",allowDownload:!1}),h=t.useRef(null),{upload:x,uploading:f}=vp({uploadFunction:o,deleteFunction:i,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Jt,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),o&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),a.jsx(Kt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),m.imageFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",m.imageFile," (",Math.round((m.imageSize||0)/1024)," KB)"]})]}),m.imageUrl&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:a.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:a.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"caption",children:"Legenda"}),a.jsx(Xs,{id:"caption",placeholder:"Legenda",value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"alt",children:u("alt_text")}),a.jsx(Jt,{id:"alt",placeholder:u("alt_text"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Alinhamento"}),a.jsxs(Os,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[a.jsx(qs,{children:a.jsx(Bs,{})}),a.jsxs(Hs,{children:[a.jsx(Ys,{value:"left",children:"Esquerda"}),a.jsx(Ys,{value:"center",children:"Centro"}),a.jsx(Ys,{value:"right",children:"Direita"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"width",children:"Largura"}),a.jsx(Jt,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"height",children:"Altura"}),a.jsx(Jt,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ks,{id:"allowDownload",checked:m.allowDownload||!1,onCheckedChange:e=>g("allowDownload",!0===e)}),a.jsx(es,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Kt,{variant:"outline",onClick:n,children:"Cancelar"}),a.jsx(Kt,{onClick:()=>{m.imageUrl?r(m):l.toast.error("Erro",{description:u("no_image_selected")})},disabled:!m.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:e,className:t="",style:s}){const{t:r}=j.useTranslation();if(!e.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return a.jsx("div",{className:`flex ${n} my-4 ${t}`,style:s,children:a.jsxs("div",{className:"space-y-2 max-w-full",children:[a.jsx("img",{src:e.imageUrl,alt:e.alt||"",style:{width:e.width?`${e.width}px`:"auto",height:e.height?`${e.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),e.caption&&a.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&a.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[a.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=zl,exports.Input=Jt,exports.InputGroup=wl,exports.InputGroupAddon=_l,exports.InputGroupButton=kl,exports.InputGroupInput=Sl,exports.InputGroupTextarea=Tl,exports.LINK_PROPERTIES=Su,exports.LOGO_CONFIG=Ve,exports.Label=es,exports.Large=Fl,exports.Lead=Ml,exports.LeadershipDialog=xp,exports.LeadershipForm=hp,exports.LeadershipPage=function({unassociatedUsers:s=[],onAssociateUser:r,onMoveNode:n,onMoveNodes:o,columns:i,nameHeader:l=e.t("leader"),rootDropLabel:c=e.t("leadership_make_root")}={}){const{alias:u}=Dn(),{data:m,isLoading:p,error:h,refetch:x}=ap(),f=np(),g=sp(),[v,b]=t.useState(()=>u?(e=>{try{const a=localStorage.getItem(`${fp}-${e}`);if(a)return new Set(JSON.parse(a))}catch{}return new Set})(u):new Set),[j,y]=t.useState([]),[w,N]=t.useState(new Set),[_,C]=t.useState(!0),[k,S]=t.useState(!1),[T,P]=t.useState(),[D,E]=t.useState(null),A=t.useMemo(()=>m?ep(m):[],[m]),I=t.useMemo(()=>A.map(e=>e.id),[A]),M=I.length>0&&j.length===I.length,F=A.filter(e=>e.children.length>0).every(e=>v.has(e.id));t.useEffect(()=>{if(m&&m.length>0&&u){if(!localStorage.getItem(`${fp}-${u}`)){const e=m.map(e=>e.id),a=new Set(e);b(a),gp(u,a)}}},[m,u]);const R=t.useCallback(e=>{b(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),u&&gp(u,t),t})},[u]),L=t.useCallback(()=>{if(F){const e=new Set;b(e),u&&gp(u,e)}else{const e=new Set(A.filter(e=>e.children.length>0).map(e=>e.id));b(e),u&&gp(u,e)}},[F,A,u]),z=t.useCallback(e=>{y(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),U=t.useCallback(()=>{y(M?[]:I)},[M,I]),O=t.useCallback(e=>{N(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),V=t.useCallback(e=>A.find(a=>a.id===e),[A]),B=t.useCallback((e,a)=>{if(n)return void n(e,a);const t=s.find(a=>a.id===e);if(t){if(r){const e=a?V(a):null;r(t.id,e?.id_user||null)}else g.mutate({id_user:t.id,id_leader:a&&V(a)?.id_user||null});return}const o=V(e);if(!o)return;const i=a?V(a):null;f.mutate({id:o.id,id_leader:i?.id_user||null})},[n,s,r,V,f,g]),q=t.useCallback((e,a)=>{o?o(e,a):(e.forEach(e=>B(e,a)),y([]))},[o,B]),$=t.useCallback(e=>{P(e),E(null),S(!0)},[]),W=t.useCallback(()=>{P(void 0),E(null),S(!0)},[]),H=t.useCallback(()=>{S(!1),P(void 0),E(null)},[]),G=t.useCallback((e,a)=>{const t=w.has(e)&&w.size>1?Array.from(w):[e];a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t)),a.currentTarget.style.opacity="0.4"},[w]),Y=t.useMemo(()=>[{key:"subordinatesCount",header:"Subordinados",hoverContent:e=>e.subordinateNames&&e.subordinateNames.length>0?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subordinados diretos:"}),[...e.subordinateNames].sort((e,a)=>e.localeCompare(a)).map(e=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(d.User,{className:"h-3 w-3 text-muted-foreground"}),a.jsx("span",{children:e})]},e))]}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"Sem subordinados diretos"})},{key:"email",header:"Email",className:"text-left",width:180,render:e=>a.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground text-sm",children:[a.jsx(d.Mail,{className:"h-3.5 w-3.5"}),e.email||"—"]})}],[]),Q=i??Y;if(p)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(h)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),a.jsx(Kt,{onClick:()=>x(),children:e.t("try_again")})]})});const K=A.filter(a=>a.name!==e.t("inactive_user")).length;return a.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs(Kt,{size:"sm",onClick:W,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),a.jsx(Kt,{size:"sm",variant:"outline",onClick:L,children:F?a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 mr-1"}),"Colapsar"]}):a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronRight,{className:"h-4 w-4 mr-1"}),"Expandir"]})}),a.jsx("div",{className:"flex items-center gap-2 ml-4",children:a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("span",{className:"text-sm font-medium",children:[K," usuário",1!==K?"s":""," associado",1!==K?"s":""]})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote"})]}),a.jsx(km,{data:m||[],columns:Q,nameKey:"name",nameHeader:l,expandedIds:v,onToggleExpand:R,iconComponent:a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground shrink-0"}),rowActionsVariant:"inline",enableRowDrag:!0,enableSelection:!0,selectedIds:j,onSelectItem:z,onSelectAll:U,isAllSelected:M,onMoveNode:B,onMoveNodes:q,rootDropLabel:c,emptyMessage:e.t("leadership_no_hierarchy"),renderActions:e=>a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(e),children:a.jsx(d.Pencil,{className:"h-4 w-4"})})}),s.length>0&&a.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>C(e=>!e),className:"w-full px-4 py-2.5 bg-muted/50 border-b flex items-center gap-2 hover:bg-muted/70 transition-colors cursor-pointer",children:[_?a.jsx(d.ChevronDown,{className:"h-4 w-4 text-muted-foreground shrink-0"}):a.jsx(d.ChevronRight,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx(d.UserPlus,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:"Usuários não associados"}),a.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(",s.length,")"]}),w.size>0&&a.jsxs("span",{className:"text-xs text-primary ml-1",children:["(",w.size," selecionado",w.size>1?"s":"",")"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Arraste para a hierarquia acima"})]}),_&&a.jsx("div",{className:"divide-y",children:s.map(e=>a.jsxs("div",{draggable:!0,onDragStart:a=>G(e.id,a),onDragEnd:e=>{e.currentTarget.style.opacity="1"},className:Gt("flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors",w.has(e.id)&&"bg-primary/5"),children:[a.jsx(Ks,{checked:w.has(e.id),onCheckedChange:()=>O(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),a.jsx("span",{className:"text-muted-foreground shrink-0 select-none",children:"⠿"}),a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"text-sm truncate",children:e.name}),a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})]}),a.jsxs("div",{className:"px-3 py-2 bg-muted/20 border rounded-lg text-xs text-muted-foreground flex justify-between",children:[a.jsxs("span",{children:["Usuários associados: ",K]}),s.length>0&&a.jsxs("span",{children:["Usuários não associados: ",s.length]})]}),a.jsx(xp,{open:k,onOpenChange:H,leader:T,prefilledLeaderId:D,title:T?e.t("edit_name"):D?e.t("leadership_add_subordinate"):e.t("leadership_add_root")},`leadership-dialog-${u}`)]})},exports.List=Ol,exports.ListPanel=Wu,exports.LoadingState=tr,exports.LocaleProvider=ui,exports.LoginPage=()=>{const{t:e}=j.useTranslation();return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(as,{className:"w-full max-w-md",children:[a.jsx(ts,{className:"text-center",children:a.jsx(ss,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),a.jsxs(ns,{className:"text-center space-y-4",children:[a.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),a.jsx(Kt,{onClick:async()=>{Le()?await Cn.loginDev():Cn.loginProd()},className:"w-full",size:"lg",children:Le()?e("dev_login"):e("login_with_qualiex")})]})]})})},exports.MESSAGES=Be,exports.MODULES_DATA=Si,exports.MONTHS_MAP=Cu,exports.ManageAccessModal=Km,exports.MatrixRiskPanel=am,exports.Menubar=Jd,exports.MenubarCheckboxItem=rc,exports.MenubarContent=tc,exports.MenubarGroup=Yd,exports.MenubarItem=sc,exports.MenubarLabel=oc,exports.MenubarMenu=Gd,exports.MenubarPortal=Qd,exports.MenubarRadioGroup=Xd,exports.MenubarRadioItem=nc,exports.MenubarSeparator=ic,exports.MenubarShortcut=lc,exports.MenubarSub=Kd,exports.MenubarSubContent=ac,exports.MenubarSubTrigger=ec,exports.MenubarTrigger=Zd,exports.ModalStateProvider=function({children:e}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=t.useCallback(e=>{o(e)},[]),c=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:i,unregisterModal:l,setHasOpenModal:d}),[s,c,i,l,d]);return a.jsx($m.Provider,{value:u,children:e})},exports.ModuleAccessGuard=Ui,exports.ModuleGrid=Di,exports.ModuleOfferContent=function({title:e,description:t,image:s,icon:r,ctaLabel:n,onCtaClick:o,children:i}){const{t:l}=j.useTranslation(),c=n??l("want_to_know_more");return a.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(s||r)&&a.jsx("div",{className:"flex items-center justify-center",children:s?a.jsx("img",{src:s,alt:e,className:"max-h-48 w-auto object-contain rounded-lg"}):r?a.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:a.jsx(r,{className:"h-12 w-12 text-primary"})}):null}),a.jsxs("div",{className:"space-y-3 max-w-lg",children:[a.jsx("h3",{className:"text-xl font-semibold text-foreground",children:e}),a.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t})]}),i?a.jsx("div",{className:"w-full",children:i}):o?a.jsxs(Kt,{onClick:o,size:"lg",className:"gap-2",children:[a.jsx(d.Sparkles,{className:"h-4 w-4"}),c]}):null]})},exports.ModuleProvider=hi,exports.ModulesContent=Ei,exports.ModulesDialog=Ri,exports.ModulesFooterCards=ki,exports.MultiSelect=zr,exports.MultiselectPermissions=function({items:s,categories:r,value:n,onChange:o,readonly:i=!1,isLoading:l=!1,title:c=e.t("permissions"),addButtonLabel:u=e.t("allow"),chipsTitle:m=e.t("allowed_items"),chipsPlaceholder:p=e.t("no_item_selected"),searchPlaceholder:h=e.t("search_placeholder"),selectPlaceholder:x=e.t("select_items_to_add"),itemInfoTemplate:f=e=>`${e} ${1===e?"item":"itens"}`,disclaimer:g,disclaimerLink:v,onDisclaimerClick:b,className:y}){const[w,N]=t.useState(r[0]?.id??""),[_,C]=t.useState(""),[k,S]=t.useState([]),[T,P]=t.useState(!1),D=t.useMemo(()=>Gc(n[w]),[n,w]),E=t.useMemo(()=>function(e){const{t:a}=j.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.inheritedIds?.forEach(e=>t.add(e));return t}(n[w]),[n,w]),A=t.useMemo(()=>s.filter(e=>D.has(e.id)),[s,D]),I=t.useMemo(()=>{const e=Hc(_);return s.filter(a=>!D.has(a.id)&&!(e&&!Hc(a.name).includes(e)))},[s,D,_]),M=t.useMemo(()=>{const e={};for(const a of r)e[a.id]=Gc(n[a.id]).size;return e},[r,n]),F=t.useCallback(e=>{N(e),S([]),C("")},[]),R=t.useCallback(e=>{S(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=t.useCallback(()=>{if(0===k.length)return;const e=[...n[w]??[]];for(const a of k){const t=s.find(e=>e.id===a),r=t?.group??"default",n=e.find(e=>e.context===r);n?n.allowedIds.includes(a)||(n.allowedIds=[...n.allowedIds,a]):e.push({context:r,allowedIds:[a],inheritedIds:[]})}o({...n,[w]:e}),S([]),C(""),P(!1)},[k,n,w,s,o]),z=t.useCallback(e=>{if(E.has(e))return;const a=(n[w]??[]).map(a=>({...a,allowedIds:a.allowedIds.filter(a=>a!==e)}));o({...n,[w]:a})},[n,w,E,o]);return l?a.jsxs("div",{className:Gt("rounded-md border bg-muted/30 p-4 animate-pulse space-y-3",y),children:[a.jsx("div",{className:"h-4 w-32 bg-muted rounded"}),a.jsx("div",{className:"h-9 w-full bg-muted rounded"}),a.jsx("div",{className:"h-20 w-full bg-muted rounded"})]}):a.jsx("div",{className:Gt("rounded-md border bg-muted/30",y),children:a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c}),a.jsxs(Os,{value:w,onValueChange:F,children:[a.jsx(qs,{className:"h-9 text-sm",children:a.jsx(Bs,{})}),a.jsx(Hs,{children:r.map(e=>a.jsx(Ys,{value:e.id,children:a.jsxs("span",{className:"flex items-center gap-2",children:[e.icon,e.name,M[e.id]>0&&a.jsx(Zs,{variant:"secondary",className:"ml-1 text-xs px-1.5 py-0",children:M[e.id]})]})},e.id))})]})]}),!i&&a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(_r,{open:T,onOpenChange:P,children:[a.jsx(Cr,{asChild:!0,children:a.jsxs(Kt,{variant:"outline",role:"combobox",className:"flex-1 justify-between h-9 text-sm font-normal text-muted-foreground",children:[k.length>0?`${k.length} selecionado${k.length>1?"s":""}`:x,a.jsx(d.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(kr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:[a.jsx("div",{className:"p-2 border-b",children:a.jsxs("div",{className:"relative",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Jt,{className:"pl-8 h-8 text-sm",placeholder:h,value:_,onChange:e=>C(e.target.value)})]})}),a.jsx(Ur,{className:"max-h-[220px]",children:0===I.length?a.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nenhum item encontrado"}):a.jsx("div",{className:"p-1",children:I.map(e=>{const t=k.includes(e.id);return a.jsxs("div",{className:Gt("flex items-center gap-3 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent",t&&"bg-accent/50"),onClick:()=>R(e.id),children:[a.jsx("div",{className:Gt("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",t&&"bg-primary text-primary-foreground"),children:t&&a.jsx(d.Check,{className:"h-3 w-3"})}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"truncate",children:e.name}),null!=e.count&&a.jsx("span",{className:"text-xs text-muted-foreground",children:f(e.count)})]})]},e.id)})})})]})]}),a.jsxs(Kt,{size:"sm",className:"h-9 gap-1",disabled:0===k.length,onClick:L,children:[a.jsx(d.Plus,{className:"h-4 w-4"}),u]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:m}),a.jsx("div",{className:Gt("rounded-md border bg-background p-3 min-h-[60px]",i&&"bg-muted/50"),children:0===A.length?a.jsx("span",{className:"text-sm text-muted-foreground",children:p}):a.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(e=>{const t=E.has(e.id);return a.jsxs(Zs,{variant:t?"secondary":"default",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.name,!i&&!t&&a.jsx("button",{type:"button",className:"ml-0.5 rounded-full hover:bg-primary-foreground/20 p-0.5",onClick:()=>z(e.id),children:a.jsx(d.X,{className:"h-3 w-3"})})]},e.id)})})}),i&&g&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.jsx("span",{dangerouslySetInnerHTML:{__html:g}})," ",v&&b&&a.jsx("button",{type:"button",className:"text-primary underline hover:no-underline",onClick:b,children:v})]})]})]})})},exports.Muted=Ll,exports.NavigationMenu=Vl,exports.NavigationMenuContent=Hl,exports.NavigationMenuIndicator=Ql,exports.NavigationMenuItem=ql,exports.NavigationMenuLink=Gl,exports.NavigationMenuList=Bl,exports.NavigationMenuTrigger=Wl,exports.NavigationMenuViewport=Yl,exports.NavigationProvider=Im,exports.NumericPanel=qu,exports.OnboardingDialog=_c,exports.OnlineEditorDialog=function({open:e,onOpenChange:s,identifier:r,fileName:n,mode:o="edit",type:i="document",onClose:l,className:c}){const[u,m]=t.useState(!0),p=function(e,a="edit",t="document"){return`https://docs.google.com/${t}/d/${e}/${a}?usp=drivesdk?embedded=true&rm=demo`}(r,o,i);t.useEffect(()=>{if(e){m(!0);const e=setTimeout(()=>m(!1),300);return()=>clearTimeout(e)}},[e]);const h=t.useCallback(()=>{l?.(),s(!1)},[l,s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&h()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,h]),a.jsx(bs,{open:e,onOpenChange:s,children:a.jsxs(Cs,{className:Gt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",c),children:[a.jsxs("div",{className:"flex items-center justify-between mb-6 min-h-[30px]",children:[u?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-80px)]",children:n}),a.jsx("div",{className:"flex items-center ml-4 z-20",children:a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(wr,{children:"Fechar"})]})})]}),a.jsx("div",{className:"flex flex-col items-center justify-center min-h-[160px] w-full min-w-[77vw] min-h-[80vh]",children:u?a.jsx(ar,{className:"h-14 w-14"}):a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(ar,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{src:p,className:"border-none w-full h-full z-[1] relative",title:n})]})})]})})},exports.P=Il,exports.PRIORITIES=Gp,exports.PROD_PROJECT_ID=Te,exports.PROGRESS_ALLOWED_STATUSES=Qp,exports.PageBreadcrumb=function({items:e,maxItems:t=3,className:s}){const r=e.length>t?[e[0],...e.slice(-(t-1))]:e,n=e.length>t;return a.jsx(Qi,{className:s,children:a.jsx(Ki,{children:r.map((e,t)=>{const s=0===t,r=n&&1===t;return a.jsxs(Xi,{children:[!s&&a.jsx(el,{}),r&&a.jsxs(a.Fragment,{children:[a.jsx(al,{}),a.jsx(el,{})]}),e.isCurrentPage?a.jsx(Zi,{children:e.label}):a.jsx(Ji,{asChild:!0,children:a.jsx(_.Link,{to:e.href||"/",children:e.label})})]},e.label)})})})},exports.PageMetadataProvider=ai,exports.Pagination=Kl,exports.PaginationContent=Xl,exports.PaginationEllipsis=td,exports.PaginationItem=Jl,exports.PaginationLink=Zl,exports.PaginationNext=ad,exports.PaginationPrevious=ed,exports.PanelError=zu,exports.PanelHeader=Lu,exports.PanelLoader=Uu,exports.PanelNoData=Ou,exports.PanelUnavailable=Vu,exports.ParetoPanel=Ju,exports.PerformancePanel=em,exports.PiePanel=Xu,exports.PlaceCard=Xm,exports.PlacesList=function({places:e,isLoading:t,manageAccessConfig:s}){return t?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):e&&0!==e.length?a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>a.jsx(Xm,{place:e,manageAccessConfig:s},e.id))]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[a.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=_r,exports.PopoverContent=kr,exports.PopoverTrigger=Cr,exports.Progress=sd,exports.ProtectedRoute=({children:s})=>{const{isAuthenticated:r,isLoading:n}=Dn();if(t.useEffect(()=>{if(n)return;if(r)return;if(tn.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 s=Le(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{s?await Cn.loginDev():Cn.loginProd()})()},[r,n]),n&&!r)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(as,{className:"w-full max-w-md",children:[a.jsx(ts,{className:"text-center",children:a.jsx(ss,{className:"text-xl font-semibold",children:"Carregando..."})}),a.jsxs(ns,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!r){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(as,{className:"w-full max-w-md",children:[a.jsx(ts,{className:"text-center",children:a.jsx(ss,{className:"text-xl font-semibold",children:"Processando..."})}),a.jsxs(ns,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(as,{className:"w-full max-w-md",children:[a.jsx(ts,{className:"text-center",children:a.jsx(ss,{className:"text-xl font-semibold",children:"Iniciando..."})}),a.jsxs(ns,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:Le()?e.t("auto_login"):e.t("redirecting_auth")})]})]})})}return a.jsx(a.Fragment,{children:s})},exports.QUALIEX_CONFIG=Oe,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=bn,exports.QualiexErrorInterceptor=mn,exports.QualiexUserField=Ro,exports.RadioGroup=rd,exports.RadioGroupItem=nd,exports.ReadOnlyTextField=Ch,exports.ReportRequestList=function({requests:e,isLoading:s=!1,onGetReportUrl:r,formatDate:n=Xc,labels:o,className:i}){const{t:l}=j.useTranslation(),c={...Qc,...o},[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(""),[g,v]=t.useState(""),[b,y]=t.useState(null),w=t.useMemo(()=>{if(!u)return e;const a=Kc(u);return e.filter(e=>Kc(e.reportName).includes(a))},[e,u]),N=t.useCallback(async e=>{if(!b){y(e.id);try{const a=await r(e.id);a&&(f(a),v(e.reportName),h(!0))}finally{y(null)}}},[r,b]);return s?a.jsx("div",{className:Gt("space-y-3",i),children:Array.from({length:5}).map((e,t)=>a.jsx(Fr,{className:"h-12 w-full"},t))}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:Gt("space-y-3",i),children:[a.jsxs("div",{className:"relative max-w-sm",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Jt,{className:"pl-8 h-9 text-sm",placeholder:c.searchPlaceholder,value:u,onChange:e=>m(e.target.value)})]}),a.jsx(Ur,{className:"rounded-md border",children:a.jsxs(Mn,{children:[a.jsx(Fn,{children:a.jsxs(zn,{children:[a.jsx(Un,{className:"min-w-[140px]",children:c.report}),a.jsx(Un,{className:"min-w-[150px]",children:c.status}),a.jsx(Un,{className:"min-w-[160px]",children:c.requestDate}),a.jsx(Un,{className:"min-w-[160px]",children:c.lastUpdate}),a.jsx(Un,{className:"min-w-[160px]",children:c.expirationDate}),a.jsx(Un,{className:"min-w-[140px]"})]})}),a.jsx(Rn,{children:0===w.length?a.jsx(zn,{children:a.jsx(On,{colSpan:6,className:"text-center text-muted-foreground py-8",children:c.noResults})}):w.map(e=>{const t=function(e){const{t:a}=j.useTranslation();return new Date>new Date(e.expirationDate)&&e.statusId===exports.ReportRequestStatus.Completed?exports.ReportRequestStatus.Expired:e.statusId}(e),s=function(e,t){const{t:s}=j.useTranslation();switch(e){case exports.ReportRequestStatus.WaitingProcessing:return{label:t.statusWaiting,icon:a.jsx(d.Hourglass,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50"};case exports.ReportRequestStatus.Processing:return{label:t.statusProcessing,icon:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 animate-spin"}),variant:"outline",className:"text-blue-600 border-blue-300 bg-blue-50"};case exports.ReportRequestStatus.Completed:return{label:t.statusCompleted,icon:a.jsx(d.CheckCircle2,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50"};case exports.ReportRequestStatus.Error:return{label:t.statusError,icon:a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),variant:"danger"};case exports.ReportRequestStatus.Expired:return{label:t.statusExpired,icon:a.jsx(d.TriangleAlert,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-orange-600 border-orange-300 bg-orange-50"};default:return{label:"—",icon:null,variant:"secondary"}}}(t,c),r=t===exports.ReportRequestStatus.Completed,o=t===exports.ReportRequestStatus.Expired;return a.jsxs(zn,{children:[a.jsx(On,{className:"font-medium",children:e.reportName}),a.jsx(On,{children:a.jsxs(Zs,{variant:s.variant,className:Gt("gap-1",s.className),children:[s.icon,s.label]})}),a.jsx(On,{className:"text-sm",children:n(new Date(e.requestDate))}),a.jsx(On,{className:"text-sm",children:n(new Date(e.lastUpdate))}),a.jsx(On,{className:Gt("text-sm",o&&"text-destructive"),children:n(new Date(e.expirationDate))}),a.jsx(On,{children:a.jsxs(Kt,{variant:"ghost",size:"sm",className:"gap-1.5",disabled:!r||b===e.id,onClick:()=>N(e),children:[b===e.id?a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}):a.jsx(d.Eye,{className:"h-4 w-4"}),c.viewReport]})})]},e.id)})})]})})]}),a.jsx(Bc,{open:p,onOpenChange:h,url:x,title:g})]})},exports.ResizableHandle=({withHandle:e,className:t,...s})=>a.jsx(_e.PanelResizeHandle,{className:Gt("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:e&&a.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:a.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=od,exports.ResizablePanelGroup=({className:e,...t})=>a.jsx(_e.PanelGroup,{className:Gt("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),exports.RichTextEditor=({value:s,onChange:r,disabled:n,placeholder:o=e.t("write_content_here"),minHeight:i="300px",showModeToggle:l=!0,showVariableHint:c=!0,className:u})=>{const{t:m}=j.useTranslation(),[p,h]=t.useState("visual"),x=q.useEditor({extensions:[$.configure({heading:{levels:[1,2,3]}}),W,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:s||"",editable:!n,onUpdate:({editor:e})=>{r(e.getHTML())}});ae.useEffect(()=>{x&&s!==x.getHTML()&&x.commands.setContent(s||"")},[s,x]);const f=t.useCallback(()=>{if(!x)return;const e=x.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?x.chain().focus().extendMarkRange("link").setLink({href:a}).run():x.chain().focus().extendMarkRange("link").unsetLink().run())},[x]);return x?a.jsxs("div",{className:Gt("space-y-2",u),children:[l&&a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(Kt,{type:"button",size:"sm",variant:"visual"===p?"default":"outline",onClick:()=>h("visual"),disabled:n,children:[a.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),a.jsxs(Kt,{type:"button",size:"sm",variant:"code"===p?"default":"outline",onClick:()=>h("code"),disabled:n,children:[a.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),a.jsxs(Kt,{type:"button",size:"sm",variant:"preview"===p?"default":"outline",onClick:()=>h("preview"),disabled:n,children:[a.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",a.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===p&&a.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||x?.commands.focus()},children:[a.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[a.jsx(bc,{onClick:()=>x.chain().focus().toggleHeading({level:1}).run(),isActive:x.isActive("heading",{level:1}),disabled:n,title:e.t("heading_1"),children:a.jsx(d.Heading1,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),isActive:x.isActive("heading",{level:2}),disabled:n,title:e.t("heading_2"),children:a.jsx(d.Heading2,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleHeading({level:3}).run(),isActive:x.isActive("heading",{level:3}),disabled:n,title:e.t("heading_3"),children:a.jsx(d.Heading3,{className:"h-4 w-4"})}),a.jsx(jc,{}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleBold().run(),isActive:x.isActive("bold"),disabled:n,title:e.t("bold"),children:a.jsx(d.Bold,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleItalic().run(),isActive:x.isActive("italic"),disabled:n,title:e.t("italic"),children:a.jsx(d.Italic,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleUnderline().run(),isActive:x.isActive("underline"),disabled:n,title:"Sublinhado",children:a.jsx(d.Underline,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleStrike().run(),isActive:x.isActive("strike"),disabled:n,title:"Riscado",children:a.jsx(d.Strikethrough,{className:"h-4 w-4"})}),a.jsx(jc,{}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleBulletList().run(),isActive:x.isActive("bulletList"),disabled:n,title:"Lista",children:a.jsx(d.List,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleOrderedList().run(),isActive:x.isActive("orderedList"),disabled:n,title:m("ordered_list"),children:a.jsx(d.ListOrdered,{className:"h-4 w-4"})}),a.jsx(jc,{}),a.jsx(bc,{onClick:()=>x.chain().focus().toggleHighlight().run(),isActive:x.isActive("highlight"),disabled:n,title:"Destacar",children:a.jsx(d.Highlighter,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:f,isActive:x.isActive("link"),disabled:n,title:"Link",children:a.jsx(d.Link,{className:"h-4 w-4"})}),a.jsx(jc,{}),a.jsx(bc,{onClick:()=>x.chain().focus().unsetAllMarks().clearNodes().run(),disabled:n,title:m("clear_formatting"),children:a.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),a.jsx(jc,{}),a.jsx(bc,{onClick:()=>x.chain().focus().undo().run(),disabled:n||!x.can().undo(),title:"Desfazer",children:a.jsx(d.Undo,{className:"h-4 w-4"})}),a.jsx(bc,{onClick:()=>x.chain().focus().redo().run(),disabled:n||!x.can().redo(),title:"Refazer",children:a.jsx(d.Redo,{className:"h-4 w-4"})})]}),a.jsx(q.EditorContent,{editor:x,className:Gt("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:i}})]}),"code"===p&&a.jsx("textarea",{value:s||"",onChange:e=>r(e.target.value),disabled:n,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===p&&a.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:a.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:a.jsx("div",{dangerouslySetInnerHTML:{__html:s||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Fe,exports.STATUS_COLORS=Vp,exports.STATUS_LABELS=Wp,exports.STATUS_MAP=qp,exports.STATUS_TEXT_COLORS=Bp,exports.SUPPORTED_LOCALES=Tt,exports.ScrollArea=Ur,exports.ScrollBar=Or,exports.Select=Os,exports.SelectApproverDialog=Kh,exports.SelectContent=Hs,exports.SelectGroup=Vs,exports.SelectItem=Ys,exports.SelectLabel=Gs,exports.SelectScrollDownButton=Ws,exports.SelectScrollUpButton=$s,exports.SelectSearch=zr,exports.SelectSeparator=Qs,exports.SelectTrigger=qs,exports.SelectValue=Bs,exports.Separator=is,exports.Sheet=id,exports.SheetBody=xd,exports.SheetClose=dd,exports.SheetContent=pd,exports.SheetDescription=vd,exports.SheetFooter=fd,exports.SheetHeader=hd,exports.SheetOverlay=ud,exports.SheetPortal=cd,exports.SheetTitle=gd,exports.SheetTrigger=ld,exports.Sidebar=Nd,exports.SidebarActionTrigger=Om,exports.SidebarContent=Ed,exports.SidebarFooter=Pd,exports.SidebarGroup=Ad,exports.SidebarGroupAction=Md,exports.SidebarGroupContent=Fd,exports.SidebarGroupLabel=Id,exports.SidebarHeader=function({open:e,appName:s}){const[r,n]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx(Td,{className:"p-0 gap-0",children:e?a.jsxs("div",{className:"flex items-center gap-2 pl-2 min-h-10",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:$e.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),s&&a.jsx("button",{className:"flex-1 min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground hover:text-primary-foreground/80 transition-colors leading-tight py-1",onClick:()=>n(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(s)})})]}):a.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:a.jsx("button",{className:"flex items-center justify-center h-10 w-8 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:$e.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})})})}),a.jsx(Ri,{open:r,onOpenChange:n})]})},exports.SidebarInput=Sd,exports.SidebarInset=kd,exports.SidebarLogo=Lm,exports.SidebarMenu=Rd,exports.SidebarMenuAction=Od,exports.SidebarMenuBadge=Vd,exports.SidebarMenuButton=Ud,exports.SidebarMenuItem=Ld,exports.SidebarMenuSkeleton=Bd,exports.SidebarMenuSub=qd,exports.SidebarMenuSubButton=Wd,exports.SidebarMenuSubItem=$d,exports.SidebarProvider=wd,exports.SidebarRail=Cd,exports.SidebarSeparator=Dd,exports.SidebarSkeleton=function(){return a.jsx("div",{className:"w-64 border-r bg-muted/10",children:a.jsxs("div",{className:"p-4",children:[a.jsx(Fr,{className:"h-8 w-32 mb-6"}),a.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>a.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Fr,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=_d,exports.SignConfigForm=function({onSaved:e}){const{config:s,isLoading:r,saveConfig:n}=kp(),{t:o}=j.useTranslation(),[i,c]=t.useState(""),[u,m]=t.useState("sandbox"),[p,h]=t.useState(!1);return t.useEffect(()=>{!r&&s&&(c(s.api_key),m(s.environment))},[s,r]),r?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a.jsxs("div",{className:"space-y-4",children:[s?a.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[a.jsx(d.CheckCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_configured",o("sign_configured_unit"))})]}):a.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_not_configured",o("sign_not_configured_unit"))})]}),a.jsxs(as,{children:[a.jsx(ts,{children:a.jsx(ss,{className:"text-base",children:o("sign_digital_config")})}),a.jsx(ns,{children:a.jsxs("form",{onSubmit:async a=>{if(a.preventDefault(),i.trim()){h(!0);try{await n(i.trim(),u),l.toast.success(o("sign_config_saved",o("sign_config_saved_success"))),e?.()}catch(t){l.toast.error(o("sign_config_save_error",o("sign_config_save_err")))}finally{h(!1)}}else l.toast.error(o("sign_api_key_required",o("sign_api_key_info")))},className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"sign-api-key",children:"API Key"}),a.jsx(Jt,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder",o("sign_api_key_input")),value:i,onChange:e=>c(e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:o("sign_environment","Ambiente")}),a.jsxs(Os,{value:u,onValueChange:e=>m(e),children:[a.jsx(qs,{children:a.jsx(Bs,{})}),a.jsxs(Hs,{children:[a.jsx(Ys,{value:"sandbox",children:"Sandbox (Testes)"}),a.jsx(Ys,{value:"production",children:"Produção"})]})]})]}),a.jsxs(Kt,{type:"submit",disabled:p,children:[p&&a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config",o("sign_update_config_btn")):o("sign_save_config",o("sign_save_config_btn"))]})]})})]})]})},exports.SignWidget=Mp,exports.SingleFileUpload=function({storedFile:e,customFileName:s,allowedExtensions:r,customExtensionErrorMessage:n,minSizeInBytes:o=1,maxSizeInBytes:i=314572800,showDownloadButton:l=!0,showViewButton:c=!0,showReplaceButton:u=!0,showCloseButton:m=!0,required:p=!1,touched:h=!1,disabled:x=!1,error:f,onFileSelect:g,onFileRemove:v,onFileReplace:b,onDownload:y,onView:w,className:N}){const{t:_}=j.useTranslation(),C=t.useRef(null),[k,S]=t.useState(null),[T,P]=t.useState(null),[D,E]=t.useState(!1),A=k||e,I=k?.name||e?.name||"",M=k?.size||e?.size;I&&bh(I);const F=s||I,R=l&&!k&&!!e,L=c&&!k&&!!e,z=!!T||!!f||p&&h&&!A,U=!!A,O=t.useCallback(e=>{if(gh.includes(e.type))return{type:"forbidden-type"};if(e.size<=o)return{type:"min-size"};if(e.size>=i)return{type:"max-size"};if(r?.length){const a=bh(e.name);if(!r.includes(a))return{type:"extension",message:n}}return null},[o,i,r,n]),V=t.useCallback(e=>{const a=e.target.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),S(null),void(C.current&&(C.current.value=""));P(null),S(a),g?.(a),C.current&&(C.current.value="")},[O,g]),B=t.useCallback(e=>{if(e.preventDefault(),e.stopPropagation(),x)return;const a=e.dataTransfer.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),void S(null);P(null),S(a),g?.(a)},[x,O,g]),q=t.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),$=t.useCallback(()=>{b?.(),C.current?.click()},[b]),W=t.useCallback(()=>{S(null),P(null),v?.(),C.current&&(C.current.value="")},[v]),H=t.useCallback(async()=>{if(!D&&e&&y){E(!0);try{await y(e)}finally{E(!1)}}},[D,e,y]),G=t.useCallback(()=>{e&&w&&w(e)},[e,w]),Y=t.useCallback(()=>{x||C.current?.click()},[x]),Q=(()=>{if(f)return f;if(!T)return p&&h&&!A?_("required_field"):null;switch(T.type){case"extension":return T.message||_("sign_file_not_allowed");case"forbidden-type":return _("sign_file_type_not_allowed");case"min-size":return`Tamanho mínimo: ${vh(o)}`;case"max-size":return`Tamanho máximo: ${vh(i)}`;default:return _("file_error")}})();return a.jsxs("div",{className:Gt("space-y-1",N),children:[a.jsx("div",{className:Gt("rounded-md border border-dashed transition-colors",U&&"border-solid border-border",!U&&"border-muted-foreground/30 hover:border-primary/50 cursor-pointer",z&&"border-destructive border-solid",x&&"opacity-50 pointer-events-none"),children:U?a.jsxs("div",{className:"flex items-center justify-between px-3 min-h-[36px]",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx(d.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.jsx("p",{className:"text-xs truncate",children:F})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[null!=M&&a.jsx("span",{className:"text-xs text-muted-foreground",children:vh(M)}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[R&&y&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:D,onClick:H,children:a.jsx(d.Download,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(wr,{children:"Download"})]}),L&&w&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(wr,{children:"Visualizar"})]}),u&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:$,children:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(wr,{children:"Substituir"})]}),m&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 bg-muted rounded",onClick:W,children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground"})})}),a.jsx(wr,{children:_("remove")})]})]})]})]}):a.jsxs("div",{className:"flex items-center justify-center gap-2 min-h-[36px] px-3",tabIndex:0,onClick:Y,onKeyDown:e=>"Enter"===e.key&&Y(),onDrop:B,onDragOver:q,children:[a.jsx(d.CloudUpload,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:["Arraste ou ",a.jsx("span",{className:"text-primary",children:"selecione um arquivo"})]})]})}),Q&&a.jsx("p",{className:"text-xs text-destructive",children:Q}),a.jsx("input",{ref:C,type:"file",className:"hidden",accept:r?.map(e=>`.${e}`).join(","),onChange:V,disabled:x})]})},exports.Skeleton=Fr,exports.Slider=Hd,exports.Small=Rl,exports.SonnerToaster=sr,exports.Spinner=ar,exports.SplitButton=Cc,exports.Stack=qo,exports.StatusBadge=Zc,exports.StepSelector=Dc,exports.Stepper=Dc,exports.StimulsoftViewer=function({reportApiUrl:e,parameters:s={},minHeight:r="80vh",...n}){const o=t.useMemo(()=>{const a=`${e}/api/reports/v1/Viewer/InitViewer`,t=new URLSearchParams(s).toString();return t?`${a}?${t}`:a},[e,s]);return a.jsx(Bc,{...n,url:o,minHeight:r})},exports.Switch=Mo,exports.TIMEZONES=Dt,exports.TabPageContent=function({children:e,className:t}){return a.jsx("div",{className:Gt("space-y-6",t),children:e})},exports.TabPageHeader=function({title:e,description:t,actions:s,className:r}){return a.jsxs("div",{className:Gt("space-y-4",r),children:[a.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),a.jsx(is,{})]})},exports.TabPageLayout=function({children:e,className:t}){return a.jsx("div",{className:Gt("flex flex-col h-full",t),children:a.jsx(Ur,{className:"flex-1",children:a.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=Mn,exports.TableBody=Rn,exports.TableCaption=Vn,exports.TableCell=On,exports.TableFooter=Ln,exports.TableHead=Un,exports.TableHeader=Fn,exports.TableResizeHandle=Gn,exports.TableRow=zn,exports.TableRowActions=uo,exports.TableSkeleton=Bn,exports.Tabs=ji,exports.TabsContent=Ni,exports.TabsList=yi,exports.TabsTrigger=wi,exports.TeamSelector=function({users:e,value:s,onChange:r,disabled:n=!1,placeholder:o="Buscar membro da equipe...",confirmRemoval:i=!0,confirmTitle:l,confirmMessage:c="Tem certeza que deseja remover este membro da equipe?",emptyMessage:u,className:m}){const{t:p}=j.useTranslation(),h=l??p("leadership_remove_team"),x=u??p("leadership_no_members"),[f,g]=t.useState(""),[v,b]=t.useState(!1),[y,w]=t.useState(null),N=t.useMemo(()=>new Set(s),[s]),_=t.useMemo(()=>e.filter(e=>N.has(e.id)),[e,N]),C=t.useMemo(()=>e.filter(e=>!N.has(e.id)).map(e=>({value:e.id,label:e.name})),[e,N]),k=t.useCallback(e=>{e&&!N.has(e)&&(r([...s,e]),g(""))},[s,r,N]),S=t.useCallback(e=>{i?(w(e),b(!0)):r(s.filter(a=>a!==e))},[s,r,i]),T=t.useCallback(()=>{y&&r(s.filter(e=>e!==y)),b(!1),w(null)},[y,s,r]);return a.jsxs("div",{className:Gt("space-y-3",m),children:[a.jsx("div",{className:"flex items-start gap-3",children:a.jsx("div",{className:"flex-1",children:a.jsx(zr,{options:C,value:f,onValueChange:e=>{const a="string"==typeof e?e:e?.[0]??"";g(a),a&&k(a)},placeholder:o,searchPlaceholder:"Buscar...",disabled:n})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-muted-foreground",children:"Selecionados"}),a.jsx("span",{className:"text-xs bg-muted text-muted-foreground rounded-full px-2 py-0.5 font-medium",children:_.length})]}),_.length>0?a.jsx("div",{className:"space-y-2",children:_.map(e=>a.jsxs("div",{className:"flex items-center border border-border rounded-lg p-2 gap-3",children:[a.jsxs(Hi,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(Gi,{src:e.avatar,alt:e.name}),a.jsx(Yi,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-sm font-medium truncate",title:e.name,dangerouslySetInnerHTML:{__html:e.title||e.name}})}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.roleName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.Shield,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.roleName})]}),e.placeName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.MapPin,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.placeName})]}),a.jsx("button",{type:"button",className:Gt("text-muted-foreground hover:text-destructive transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>!n&&S(e.id),title:p("remove"),children:a.jsx(d.X,{className:"h-4 w-4"})})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[a.jsx(d.User,{className:"h-12 w-12 mb-2 opacity-30"}),a.jsx("p",{className:"text-sm",children:x})]}),a.jsx(bs,{open:v,onOpenChange:b,children:a.jsxs(Cs,{className:"sm:max-w-[400px]",children:[a.jsx(ks,{children:a.jsx(Ps,{children:h})}),a.jsx("p",{className:"text-sm text-muted-foreground",children:c}),a.jsxs(Ts,{children:[a.jsx(Kt,{variant:"ghost",onClick:()=>b(!1),children:"Cancelar"}),a.jsx(Kt,{variant:"destructive",onClick:T,children:"Remover"})]})]})})]})},exports.TermsOfUseDialog=function({term:s,open:r,onClose:n,onAgree:o,title:i=e.t("terms_updated"),seeLaterLabel:l=e.t("terms_see_later"),agreeLabel:c=e.t("terms_read_agree"),viewTermLabel:u=e.t("terms_view")}){const[m,p]=t.useState(!1),h=t.useCallback(()=>{o(s.id)},[o,s.id]);return a.jsxs(a.Fragment,{children:[a.jsx(bs,{open:r&&!m,onOpenChange:e=>!e&&n(),children:a.jsxs(Cs,{className:"sm:max-w-md",children:[a.jsx(ks,{children:a.jsxs(Ps,{className:"flex items-center gap-2",children:[a.jsx(d.ShieldCheck,{className:"h-5 w-5 text-primary"}),i]})}),a.jsxs("div",{className:"space-y-4",children:[s.description&&a.jsx(Ur,{className:"max-h-48",children:a.jsx("div",{className:"text-sm text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:s.description}})}),s.file&&a.jsxs(Kt,{variant:"link",className:"px-0 text-primary",onClick:()=>p(!0),children:[a.jsx(d.ExternalLink,{className:"mr-1 h-4 w-4"}),u]})]}),a.jsxs(Ts,{className:"gap-2 sm:gap-0",children:[a.jsx(Kt,{variant:"ghost",onClick:n,children:l}),a.jsx(Kt,{onClick:h,children:c})]})]})}),m&&a.jsx(qc,{term:s,open:m,onClose:()=>p(!1),viewOnly:!0})]})},exports.TermsOfUseViewer=qc,exports.TextPanel=$u,exports.Textarea=Xs,exports.Timepicker=Pc,exports.Toaster=sr,exports.Toggle=fo,exports.ToggleGroup=vo,exports.ToggleGroupItem=bo,exports.TokenManager=tn,exports.TokenService=Gr,exports.Tooltip=jr,exports.TooltipContent=wr,exports.TooltipProvider=br,exports.TooltipTrigger=yr,exports.TreeSelect=Hr,exports.TreeTable=km,exports.TruncatedCell=Hn,exports.UpdatesNotification=Mc,exports.UsersGroupsSelector=function({users:s,groups:r=[],value:n,onChange:o,disabled:i=!1,maxHeight:l=350,hideGroupFilter:c=!1,searchPlaceholder:u="Buscar usuário...",selectLabel:m="Selecionar",doneLabel:p="Concluir",allLabel:h="Todos",emptyLabel:x=e.t("leadership_no_user_selected"),selectedLabel:f="selecionado",selectedPluralLabel:g="selecionados",className:v}){const[b,j]=t.useState(!1),[y,w]=t.useState(""),[N,_]=t.useState(void 0),C=t.useMemo(()=>new Set(n),[n]),k=t.useMemo(()=>{let e=s;if(N&&(e=e.filter(e=>e.groupIds?.includes(N))),y){const a=Wc(y);e=e.filter(e=>Wc(e.name).includes(a)||Wc(e.email??"").includes(a))}return e},[s,N,y]),S=t.useMemo(()=>b?k:s.filter(e=>C.has(e.id)),[b,k,s,C]),T=n.length,P=t.useMemo(()=>k.length>0&&k.every(e=>C.has(e.id)),[k,C]),D=t.useCallback(e=>{if(i)return;const a=C.has(e)?n.filter(a=>a!==e):[...n,e];o(a)},[n,C,o,i]),E=t.useCallback(e=>{if(i)return;const a=new Set(k.map(e=>e.id));if(e){const e=new Set([...n,...a]);o(Array.from(e))}else o(n.filter(e=>!a.has(e)))},[n,k,o,i]),A=t.useCallback(()=>{j(e=>!e),w(""),_(void 0)},[]);return a.jsxs("div",{className:Gt("rounded-md border bg-muted/30",v),children:[(!i||T>0)&&a.jsxs("div",{className:Gt("flex items-center justify-between px-4 py-2",!i&&"cursor-pointer hover:bg-muted/50"),onClick:i?void 0:A,children:[a.jsx("span",{className:"text-sm font-medium text-primary uppercase",children:!i&&(b?p:m)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:T>0&&`${T} ${1===T?f:g}`})]}),a.jsxs("div",{className:"px-4 pb-3",children:[b&&a.jsxs("div",{className:"flex gap-3 mb-3",children:[!c&&r.length>0&&a.jsxs(Os,{value:N??"__all__",onValueChange:e=>_("__all__"===e?void 0:e),children:[a.jsx(qs,{className:"w-[200px] h-9 text-sm",children:a.jsx(Bs,{placeholder:e.t("approval_user_group")})}),a.jsxs(Hs,{children:[a.jsx(Ys,{value:"__all__",children:e.t("team_all_groups")}),r.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Jt,{className:"pl-8 h-9 text-sm",placeholder:u,value:y,onChange:e=>w(e.target.value)})]})]}),!b&&0===T&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:[a.jsx(d.Users,{className:"h-4 w-4 mr-2"}),x]}),b&&k.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Ks,{checked:P,onCheckedChange:e=>E(!!e)}),a.jsx("span",{className:"text-sm",children:h})]}),S.length>0&&a.jsx(Ur,{style:{maxHeight:l},className:"pr-2",children:a.jsx("div",{className:"space-y-0.5",children:S.map(e=>a.jsxs("div",{className:Gt("flex items-center gap-3 rounded-md bg-background px-3 py-2 text-sm",b&&!i&&"cursor-pointer hover:bg-accent/50"),onClick:b?()=>D(e.id):void 0,children:[b&&a.jsx(Ks,{checked:C.has(e.id),onCheckedChange:()=>D(e.id),onClick:e=>e.stopPropagation()}),a.jsxs(Hi,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(Gi,{src:e.avatar,alt:e.name}),a.jsx(Yi,{className:"text-xs",children:$c(e.name)})]}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"font-normal truncate",children:e.name}),e.email&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})}),b&&0===k.length&&a.jsx("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:"Nenhum usuário encontrado"})]})]})},exports.VideoEditor=function({value:s,onChange:r,onSubmit:n,onCancel:o,uploadFunction:i,deleteFunction:c,uploadOptions:u}){const{t:m}=j.useTranslation(),[p,h]=t.useState(s||{inputType:"url",controls:!0}),x=t.useRef(null),f=t.useRef(null),{upload:g,uploading:v}=vp({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:b,uploading:y}=vp({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),w=t.useMemo(()=>_p(p.videoUrl||Np(p.embedCode)||""),[p.videoUrl,p.embedCode]),N=(e,a)=>{const t={...p,[e]:a};h(t),r(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:m("input_type")}),a.jsxs(Os,{value:p.inputType||"url",onValueChange:e=>N("inputType",e),children:[a.jsx(qs,{children:a.jsx(Bs,{})}),a.jsxs(Hs,{children:[a.jsx(Ys,{value:"url",children:"URL"}),a.jsx(Ys,{value:"upload",children:m("file_upload")}),a.jsx(Ys,{value:"embed",children:m("embed_code")})]})]})]}),"upload"===p.inputType&&i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Arquivo"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{ref:x,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||a.name.replace(/\.[^/.]+$/,"")};h(t),r(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),a.jsx(Kt,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:v,children:v?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),p.videoFile&&a.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",p.videoFile," (",Math.round((p.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===p.inputType&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:m("embed_code")}),a.jsx(Xs,{placeholder:m("paste_embed_code"),value:p.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Thumbnail"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Jt,{type:"url",placeholder:"URL da thumbnail",value:p.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),a.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await b(a),t={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(t),r(t)}catch(t){}finally{f.current&&(f.current.value="")}},className:"hidden"}),a.jsx(Kt,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:y,children:y?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),p.thumbnailFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",p.thumbnailFile]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{htmlFor:"title",children:"Título"}),a.jsx(Jt,{id:"title",placeholder:m("video_title"),value:p.title||"",onChange:e=>N("title",e.target.value)})]}),a.jsxs("div",{className:"flex gap-6",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ks,{id:"autoplay",checked:p.autoplay||!1,onCheckedChange:e=>N("autoplay",!0===e)}),a.jsx(es,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ks,{id:"controls",checked:!1!==p.controls,onCheckedChange:e=>N("controls",!0===e)}),a.jsx(es,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(es,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=p.videoUrl||Np(p.embedCode)||"";if(!t)return a.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===w)return a.jsxs("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[a.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const s="youtube"===w?jp(t,p.autoplay):wp(t,p.autoplay);return a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:p.title||e.t("video"),src:s,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Kt,{variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Kt,{onClick:()=>{p.videoUrl||p.embedCode?n(p):l.toast.error("Erro",{description:m("no_video_selected")})},disabled:!(p.videoUrl||p.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:s="",style:r}){const n=t.videoUrl||Np(t.embedCode)||"";if(!n)return null;const o=_p(n);return a.jsx(as,{className:`overflow-hidden my-4 ${s}`,style:r,children:a.jsxs(ns,{className:"p-0",children:["file"===o?a.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[a.jsx("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:t.title||e.t("video"),src:"youtube"===o?jp(n,t.autoplay):wp(n,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.ViewerDialog=function({open:e,onOpenChange:s,template:r,viewerType:n,isLoading:o=!1,enableDownload:i=!0,onDownload:l,isDownloading:c=!1,enableFavorite:u=!1,isFavorite:m=!1,onFavorite:p,isFavoriting:h=!1,enableConfirmReading:x=!1,readingConfirmationDate:f,onConfirmReading:g,isConfirmingReading:v=!1,readingConfirmationTimeRemaining:b,onIframeLoad:y,className:w}){const{t:N}=j.useTranslation(),_=t.useRef(null),C=n??zc(r.extension),k=c||v||h,S=r.code?`${r.code} – ${r.name}`:r.name,T=t.useCallback(()=>{_.current&&y&&y(_.current)},[y]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&s(!1)};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,s]),a.jsx(bs,{open:e,onOpenChange:s,children:a.jsxs(Cs,{className:Gt("max-w-[95vw] max-h-[95vh] p-6 gap-0 [&>button.absolute]:hidden",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"w-[90vw]",w),children:[a.jsxs("div",{className:"flex items-center justify-between mb-4 min-h-[35px]",children:[o?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-200px)]",children:S}),a.jsxs("div",{className:"flex items-center gap-1 ml-4 z-20",children:[!o&&a.jsxs(a.Fragment,{children:[(x||f)&&a.jsx(a.Fragment,{children:f?a.jsxs("div",{className:"flex flex-col mr-2.5",children:[a.jsxs("span",{className:"text-sm font-medium flex items-center gap-1 text-foreground",children:[a.jsx(d.CheckCheck,{className:"h-4 w-4"}),"Leitura confirmada"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-5",children:f.toLocaleDateString()})]}):null!=b&&b>0?a.jsxs("div",{className:"flex items-center gap-1 mr-2.5 text-sm text-muted-foreground",children:[a.jsx("span",{children:N("terms_confirmation_available")}),a.jsx("span",{className:"font-medium min-w-[72px]",children:Vc(b)}),a.jsx("span",{children:"segundos"})]}):a.jsxs(Kt,{variant:"default",size:"sm",disabled:k,onClick:()=>g?.(),className:"mr-2.5",children:[a.jsx(d.ShieldCheck,{className:"h-4 w-4 mr-1"}),v?"Confirmando...":N("terms_confirm_reading")]})}),C!==exports.FileViewerType.none&&u&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>p?.(m),children:a.jsx(d.Star,{className:Gt("h-4 w-4",m&&"fill-accent text-accent")})})}),a.jsx(wr,{children:m?"Desfavoritar":"Favoritar"})]}),C!==exports.FileViewerType.none&&i&&a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>l?.(),children:a.jsx(d.Download,{className:"h-4 w-4"})})}),a.jsx(wr,{children:"Download"})]})]}),a.jsxs(jr,{children:[a.jsx(yr,{asChild:!0,children:a.jsx(Kt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>s(!1),children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(wr,{children:"Fechar"})]})]})]}),a.jsx("div",{className:Gt("flex flex-col items-center justify-center min-h-[160px] w-full",o&&"relative -top-5",C===exports.FileViewerType.none&&"min-h-[124px]",C===exports.FileViewerType.image&&"max-h-[85vh]",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"min-w-[77vw] min-h-[80vh]"),children:o?a.jsx(ar,{className:"h-14 w-14"}):a.jsxs(a.Fragment,{children:[(C===exports.FileViewerType.none||!r.url)&&a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-base text-foreground mb-1",children:"Extensão não suportada para visualização."}),a.jsx("b",{className:"text-base text-foreground",children:"Deseja fazer o download do arquivo?"})]}),C===exports.FileViewerType.image&&a.jsx("img",{loading:"eager",src:r.url,alt:r.name,className:"max-w-full max-h-[85vh] object-contain"}),C===exports.FileViewerType.video&&a.jsx("video",{controls:!0,autoPlay:!0,src:r.url,className:"w-full h-full"}),C===exports.FileViewerType.audio&&a.jsx("audio",{controls:!0,autoPlay:!0,src:r.url}),(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(ar,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{ref:_,src:r.url,onLoad:T,className:"border-none w-full h-full z-[1] relative",title:r.name})]})]})}),!o&&C===exports.FileViewerType.none&&a.jsxs("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-border",children:[a.jsx(Kt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),i&&a.jsx(Kt,{variant:"default",onClick:()=>l?.(),children:"Download"})]})]})})},exports.addAppTranslations=ii,exports.assets=$e,exports.badgeVariants=Js,exports.buildDetailRows=Oh,exports.buildHierarchy=Zm,exports.buildModuleUrl=Ht,exports.buildPlacesTree=function(e){e.forEach(a=>{a.children=e.filter(e=>e.parentId===a.id)});const a=e.filter(e=>!e.parentId);return function e(a,t){a?.forEach(a=>{t(a),a.children&&e(a.children,t)})}(a,a=>{a.children=e.filter(e=>e.parentId===a.id)}),a},exports.buildWopiUrl=function(e){const{t:a}=j.useTranslation(),{viewerUrl:t,wopiUrl:s,fileId:r,token:n,extension:o,language:i="pt-br"}=e,l=Oc(o);return l?`${t}${l}ui=${i}&rs=${i}&access_token=${n}&WOPISrc=${encodeURIComponent(`${s}${r}`)}`:null},exports.buttonGroupVariants=tl,exports.buttonVariants=Qt,exports.calculateAspectRatio=Cp,exports.camelToDash=Wh,exports.cn=Gt,exports.createCrudPage=function(e){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=e,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit: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 a.jsx(Wo,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=Sm({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=Sm,exports.createService=wn,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=wn({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)=>En({queryKey:e.tableName,service:a,entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.createStatusConfig=function(e){return a=>e[a]},exports.createTranslatedMessages=a=>({success:{created:a=>e.t("msg_created_success",`${a} criado com sucesso`).replace("{{entity}}",a),updated:a=>e.t("msg_updated_success",`${a} atualizado com sucesso`).replace("{{entity}}",a),deleted:a=>e.t("msg_deleted_success",`${a} removido com sucesso`).replace("{{entity}}",a)},error:{create:a=>e.t("msg_create_error",`Erro ao criar ${a}`).replace("{{entity}}",a),update:a=>e.t("msg_update_error",`Erro ao atualizar ${a}`).replace("{{entity}}",a),delete:a=>e.t("msg_delete_error",`Erro ao remover ${a}`).replace("{{entity}}",a),load:a=>e.t("msg_load_error",`Erro ao carregar ${a}`).replace("{{entity}}",a)}}),exports.currencyFormatter=Iu,exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=xn,exports.deriveNameField=hn,exports.deriveUsernameField=fn,exports.detectBrowserLocale=Rt,exports.detectBrowserPreferences=()=>{const e=Rt();return{locale:e,timezone:Lt(),datetimeFormat:zt(e)}},exports.detectBrowserTimezone=Lt,exports.detectVideoProvider=_p,exports.emailService=Qm,exports.errorService=sn,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.extractNumberFromCurrency=function(e){const a=e.replace(/[^\d,.-]/g,"").replace(/\./g,"").replace(",",".");return parseFloat(a)},exports.extractVimeoId=yp,exports.extractYouTubeId=bp,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=>Pt.find(a=>a.value===e),exports.findLocale=e=>Tt.find(a=>a.value===e),exports.findTimezone=e=>Dt.find(a=>a.value===e),exports.flattenTree=ep,exports.formatBytes=vh,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=Vt,exports.formatDatetime=Ot,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.formatTime=sh,exports.formatTimeProgress=th,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:Go(e),label:Go(e),...Ho(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.generatePastelBg=qt,exports.getActionTypes=function(){return[{id:"immediate",label:e.t("ap_type_immediate")},{id:"corrective",label:e.t("ap_type_corrective")},{id:"preventive",label:e.t("ap_type_preventive")},{id:"improvement",label:e.t("ap_type_improvement")},{id:"standardization",label:e.t("ap_type_standardization")}]},exports.getContrastRatio=function(e,a){const t=$t(e),s=$t(a);return(Math.max(t,s)+.05)/(Math.min(t,s)+.05)},exports.getDefaultPanelSize=function(e){switch(e){case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.List:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Text:case exports.DashboardPanelType.StackedColumn:return{x:4,y:2};case exports.DashboardPanelType.Pareto:case exports.DashboardPanelType.RiskMatrix:case exports.DashboardPanelType.Burndown:case exports.DashboardPanelType.PerformanceColumns:return{x:8,y:2};case exports.DashboardPanelType.Numeric:return{x:1,y:1};default:return{x:2,y:2}}},exports.getEnvironmentConfig=Ee,exports.getFieldValue=Nh,exports.getFileExtension=bh,exports.getFormFieldValues=function(e){return e.filter(e=>e.type!==exports.ECustomFormFieldType.readOnlyText).map(e=>({formFieldAssociationId:e.id,textValue:e.type===exports.ECustomFormFieldType.text?e.textValue:void 0,numberValue:e.type===exports.ECustomFormFieldType.number?e.numberValue:void 0,dateValue:e.type===exports.ECustomFormFieldType.date?e.dateValue:void 0,timeValue:e.type===exports.ECustomFormFieldType.time?e.timeValue:void 0,itemsValue:[exports.ECustomFormFieldType.url,exports.ECustomFormFieldType.singleSelection,exports.ECustomFormFieldType.multiSelection].includes(e.type)?e.itemsValue:void 0,questionsValue:e.type===exports.ECustomFormFieldType.questions?e.questionsValue:void 0}))},exports.getLinkFromRow=Du,exports.getLuminance=$t,exports.getMinPanelSize=sm,exports.getOnlineViewerType=function(e){const{t:a}=j.useTranslation();return{".gdocs":"document",".gsheets":"spreadsheets"}[e.toLowerCase()]||"document"},exports.getPriorities=function(){return[{id:exports.ETaskPlanPriority.low,label:e.t("ap_priority_low"),color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:e.t("ap_priority_medium"),color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:e.t("ap_priority_high"),color:"#F44336"}]},exports.getProgressColor=rh,exports.getQualiexApiUrl=Ue,exports.getStatusLabels=$p,exports.getSupabaseClient=ln,exports.getViewerType=zc,exports.getWopiViewer=Oc,exports.handleExternalLink=Wt,exports.inferDatetimeFormat=zt,exports.inputGroupAddonVariants=Nl,exports.inputGroupButtonVariants=Cl,exports.isCurrency=function(e){return!!Au.test(e)&&!isNaN(parseFloat(e.replace(/,/g,"")))},exports.isDevEnvironment=ze,exports.isDevSupabaseProject=Ae,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.isLovablePreview=Re,exports.isNullOrEmptyField=function(e){return null==e?.value||""===e.value.trim()},exports.isValidDatetimeFormat=e=>Pt.some(a=>a.value===e),exports.isValidLocale=Mt,exports.isValidTimezone=Ft,exports.loadClicksignScript=Ap,exports.loadForlogicFonts=Vi,exports.logoSrc=We,exports.mergeTranslationFiles=function(...e){return Object.assign({},...e)},exports.navigationMenuTriggerStyle=$l,exports.normalizeVideoUrl=function(e,a,t){switch(a||_p(e)){case"youtube":return jp(e,t);case"vimeo":return wp(e,t);default:return e}},exports.normalizeVimeoUrl=wp,exports.normalizeYouTubeUrl=jp,exports.parseIframeSrc=Np,exports.placeService=Jm,exports.processTrails=Lh,exports.processUrl=Pu,exports.qualiexApi=pn,exports.resizeKeepingAspect=function(e,a,t,s){const r=Cp(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=gn,exports.resolvePageTitle=Fm,exports.setFormFieldValues=function(e,a){return a?.length?e.map(e=>{const t=a.find(a=>a.formFieldAssociationId===e.id);if(!t)return e;const s={...e};switch(e.type){case exports.ECustomFormFieldType.text:s.textValue=t.textValue;break;case exports.ECustomFormFieldType.number:s.numberValue=t.numberValue;break;case exports.ECustomFormFieldType.date:s.dateValue=t.dateValue;break;case exports.ECustomFormFieldType.time:s.timeValue=t.timeValue;break;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:s.itemsValue=t.itemsValue||[];break;case exports.ECustomFormFieldType.questions:s.questionsValue=t.questionsValue||[]}return s}):e},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new N.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.shouldShowField=_h,exports.shouldUseDevTokens=Le,exports.signService=Dp,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=He,exports.sortByMonthYear=function(e){return e?.sort((e,a)=>{if(!e?.items?.length||!a?.items?.length)return 0;return Tu(e.items[0]?.keyDate)-Tu(a.items[0]?.keyDate)})},exports.toQueryString=function(e){return e?Eu(e).join("&"):null},exports.toggleVariants=xo,exports.trimTextFields=Yt,exports.useActionPlan=Kp,exports.useActionPlanProgress=ah,exports.useActiveModules=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Dn();return N.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=ln(),{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(!un.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},exports.useAliasFromUrl=Yo,exports.useAuth=Dn,exports.useBaseForm=To,exports.useColumnManager=No,exports.useColumnResize=ho,exports.useCreateMultipleLeadersMutation=rp,exports.useCreateSingleLeaderMutation=sp,exports.useCrud=En,exports.useDebounce=Rm,exports.useDerivedContractedModules=Fi,exports.useFormField=Is,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Wm();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a}=mi(),t=At;return{formatDatetime:s=>Ot(s,t,a,e),formatDate:t=>Vt(t,e,a),locale:e,timezone:a,datetimeFormat:t}},exports.useIsMobile=In,exports.useLeadershipApi=ap,exports.useLocale=mi,exports.useMediaQuery=An,exports.useMediaUpload=vp,exports.useModalState=Wm,exports.useModuleAccess=Mi,exports.useModuleConfig=xi,exports.useNavigation=Mm,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=ti(),r=t.useRef({});t.useEffect(()=>{const t=JSON.stringify(r.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(r.current.title!==e.title||r.current.subtitle!==e.subtitle||t)&&(r.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},a(e)),()=>s()},[e.title,e.subtitle,e.breadcrumbs,a,s])},exports.usePageMetadataContext=ti,exports.usePageTitle=function(){const e=_.useLocation(),{navigation:a}=Mm();return Fm(a,e.pathname)},exports.usePermissionQuery=Um,exports.useQualiexUsers=Fo,exports.useRemoveLeaderMutation=op,exports.useRouteBreadcrumbs=function(){const e=_.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:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,d]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),x=t.useRef(0),f=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,x.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return o?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,o]),t.useEffect(()=>(c?(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=""}),[c]);const v=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:v,getRowHeight:f}},exports.useSidebar=yd,exports.useSidebarResize=qm,exports.useSignConfig=kp,exports.useSyncSubordinatesMutation=ip,exports.useUpdateLeaderMutation=np,exports.useUpdatesNotification=Ic,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=t.useState(s),[d,c]=t.useState(r),[u,m]=t.useState(!1),[p,h]=t.useState(!1),x=a.length,f=0===i,g=i===x-1,v=a[i],b=x>1?(i+1)/x*100:100,j=t.useCallback(()=>!v?.canProceed||v.canProceed(),[v]),y=t.useMemo(()=>j(),[j,d]),w=t.useMemo(()=>!f&&!v?.disableBack,[f,v]),N=t.useCallback(e=>{c(a=>({...a,...e}))},[]),_=t.useCallback((e,a)=>{c(t=>({...t,[e]:a}))},[]),C=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),k=t.useCallback(async()=>{if(j()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[j,p,d,n]),S=t.useCallback(async()=>{j()&&!u&&(g?await k():l(e=>Math.min(e+1,x-1)))},[j,u,g,x,k]),T=t.useCallback(()=>{w&&!u&&l(e=>Math.max(e-1,0))},[w,u]),P=t.useCallback(e=>{e<0||e>=x||u||(e<=i||e===i+1)&&l(e)},[i,x,u]),D=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:v,data:d,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:T,goTo:P,canProceed:y,canGoBack:w,setData:N,updateField:_,reset:C,complete:k,setLoading:D,progress:b,stepIndex:i,totalSteps:x}},exports.validateFields=function(e){const a=[];return e.forEach(e=>{if(!e.required||e.readOnly||e.type===exports.ECustomFormFieldType.readOnlyText)return;const t=Nh(e);if((null==t||""===t||Array.isArray(t)&&0===t.length)&&a.push(e.id),e.type===exports.ECustomFormFieldType.number&&null!=t){const s=e.config;null!=s?.min&&t<s.min&&a.push(e.id),null!=s?.max&&t>s.max&&a.push(e.id)}}),{valid:0===a.length,invalidFields:[...new Set(a)]}};
1
+ "use strict";var e=require("i18next"),a=require("react/jsx-runtime"),t=require("react"),s=require("@radix-ui/react-slot"),r=require("class-variance-authority"),n=require("clsx"),o=require("tailwind-merge"),i=require("date-fns"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("@radix-ui/react-alert-dialog"),h=require("react-hook-form"),x=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),g=require("@radix-ui/react-dropdown-menu"),v=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),j=require("react-i18next"),y=require("@supabase/supabase-js"),w=require("@tanstack/react-query"),N=require("react-router-dom"),_=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-toggle-group"),k=require("@radix-ui/react-toggle"),S=require("@radix-ui/react-scroll-area"),T=require("@radix-ui/react-switch"),P=require("@radix-ui/react-collapsible"),D=require("@radix-ui/react-tabs"),E=require("@microsoft/clarity"),A=require("@radix-ui/react-accordion"),I=require("@radix-ui/react-avatar"),M=require("react-day-picker"),F=require("vaul"),R=require("@radix-ui/react-hover-card"),L=require("@radix-ui/react-navigation-menu"),z=require("@radix-ui/react-progress"),U=require("@radix-ui/react-radio-group"),O=require("react-resizable-panels"),V=require("@radix-ui/react-slider"),B=require("@radix-ui/react-menubar"),q=require("recharts"),$=require("@tiptap/react"),W=require("@tiptap/starter-kit"),H=require("@tiptap/extension-underline"),G=require("@tiptap/extension-link"),Y=require("@tiptap/extension-text-style"),Q=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),X=require("@dnd-kit/core"),J=require("@dnd-kit/sortable"),Z=require("zod"),ee=require("@hookform/resolvers");function ae(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 te=ae(t),se=ae(c),re=ae(u),ne=ae(m),oe=ae(p),ie=ae(x),le=ae(f),de=ae(g),ce=ae(v),ue=ae(b),me=ae(_),pe=ae(C),he=ae(k),xe=ae(S),fe=ae(T),ge=ae(P),ve=ae(D),be=ae(A),je=ae(I),ye=ae(R),we=ae(L),Ne=ae(z),_e=ae(U),Ce=ae(O),ke=ae(V),Se=ae(B),Te=ae(q);const Pe="ccjfvpnndclajkleyqkc",De={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},Ee={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Ae(){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===Pe?De:Ee}function Ie(){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!==Pe}const Me={get oauth(){const e=Ae();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Fe={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Re={debounceDelay:500},Le=()=>{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},ze=()=>Le(),Ue=Le,Oe=()=>Ae().qualiexApiUrl,Ve={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Be={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},qe={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}`}},$e=`https://${Ae().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,We={logo:Be.isQualiex?`${$e}/logo-qualiex-white.svg`:`${$e}/saber-gestao-white.png`,smallLogo:Be.isQualiex?`${$e}/logo-forlogic-white.svg`:`${$e}/small.svg`,favicon:`${$e}/favicon.png`},He=We.logo,Ge=We.smallLogo;if("undefined"!=typeof document){document.querySelectorAll("link[rel='icon'], link[rel='shortcut icon']").forEach(e=>e.remove());const e=document.createElement("link");e.rel="icon",e.type="image/png",e.href=We.favicon,document.head.appendChild(e)}const Ye={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 Qe(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Ke={date:Qe({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Qe({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:Qe({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Xe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Je(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Ze(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 d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(o.length)}}}function ea(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 aa={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Ye[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:Ke,formatRelative:(e,a,t,s)=>Xe[e],localize:{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:Je({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};let ta={};function sa(){return ta}const ra=6048e5;function na(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 oa(e){const a=na(e);return a.setHours(0,0,0,0),a}function ia(e){const a=na(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 la(e,a){return e instanceof Date?new e.constructor(a):new Date(a)}function da(e){const a=na(e),t=function(e,a){const t=oa(e),s=oa(a),r=+t-ia(t),n=+s-ia(s);return Math.round((r-n)/864e5)}(a,function(e){const a=na(e),t=la(e,0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}(a));return t+1}function ca(e,a){const t=sa(),s=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=na(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 ua(e){return ca(e,{weekStartsOn:1})}function ma(e){const a=na(e),t=a.getFullYear(),s=la(e,0);s.setFullYear(t+1,0,4),s.setHours(0,0,0,0);const r=ua(s),n=la(e,0);n.setFullYear(t,0,4),n.setHours(0,0,0,0);const o=ua(n);return a.getTime()>=r.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function pa(e){const a=na(e),t=+ua(a)-+function(e){const a=ma(e),t=la(e,0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),ua(t)}(a);return Math.round(t/ra)+1}function ha(e,a){const t=na(e),s=t.getFullYear(),r=sa(),n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=la(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=ca(o,a),l=la(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=ca(l,a);return t.getTime()>=i.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function xa(e,a){const t=na(e),s=+ca(t,a)-+function(e,a){const t=sa(),s=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=ha(e,a),n=la(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),ca(n,a)}(t,a);return Math.round(s/ra)+1}function fa(e,a){return(e<0?"-":"")+Math.abs(e).toString().padStart(a,"0")}const ga={y(e,a){const t=e.getFullYear(),s=t>0?t:1-t;return fa("yy"===a?s%100:s,a.length)},M(e,a){const t=e.getMonth();return"M"===a?String(t+1):fa(t+1,2)},d:(e,a)=>fa(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)=>fa(e.getHours()%12||12,a.length),H:(e,a)=>fa(e.getHours(),a.length),m:(e,a)=>fa(e.getMinutes(),a.length),s:(e,a)=>fa(e.getSeconds(),a.length),S(e,a){const t=a.length,s=e.getMilliseconds();return fa(Math.trunc(s*Math.pow(10,t-3)),a.length)}},va="midnight",ba="noon",ja="morning",ya="afternoon",wa="evening",Na="night",_a={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 ga.y(e,a)},Y:function(e,a,t,s){const r=ha(e,s),n=r>0?r:1-r;if("YY"===a){return fa(n%100,2)}return"Yo"===a?t.ordinalNumber(n,{unit:"year"}):fa(n,a.length)},R:function(e,a){return fa(ma(e),a.length)},u:function(e,a){return fa(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 fa(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 fa(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 ga.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 fa(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=xa(e,s);return"wo"===a?t.ordinalNumber(r,{unit:"week"}):fa(r,a.length)},I:function(e,a,t){const s=pa(e);return"Io"===a?t.ordinalNumber(s,{unit:"week"}):fa(s,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getDate(),{unit:"date"}):ga.d(e,a)},D:function(e,a,t){const s=da(e);return"Do"===a?t.ordinalNumber(s,{unit:"dayOfYear"}):fa(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 fa(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 fa(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 fa(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?ba:0===s?va: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?wa:s>=12?ya:s>=4?ja:Na,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 ga.h(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getHours(),{unit:"hour"}):ga.H(e,a)},K:function(e,a,t){const s=e.getHours()%12;return"Ko"===a?t.ordinalNumber(s,{unit:"hour"}):fa(s,a.length)},k:function(e,a,t){let s=e.getHours();return 0===s&&(s=24),"ko"===a?t.ordinalNumber(s,{unit:"hour"}):fa(s,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):ga.m(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getSeconds(),{unit:"second"}):ga.s(e,a)},S:function(e,a){return ga.S(e,a)},X:function(e,a,t){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(a){case"X":return ka(s);case"XXXX":case"XX":return Sa(s);default:return Sa(s,":")}},x:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"x":return ka(s);case"xxxx":case"xx":return Sa(s);default:return Sa(s,":")}},O:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ca(s,":");default:return"GMT"+Sa(s,":")}},z:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ca(s,":");default:return"GMT"+Sa(s,":")}},t:function(e,a,t){return fa(Math.trunc(e.getTime()/1e3),a.length)},T:function(e,a,t){return fa(e.getTime(),a.length)}};function Ca(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+fa(n,2)}function ka(e,a){if(e%60==0){return(e>0?"-":"+")+fa(Math.abs(e)/60,2)}return Sa(e,a)}function Sa(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+fa(Math.trunc(s/60),2)+a+fa(s%60,2)}const Ta=(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"})}},Pa=(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:Pa,P:(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],s=t[1],r=t[2];if(!r)return Ta(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}}",Ta(s,a)).replace("{{time}}",Pa(r,a))}},Ea=/^D+$/,Aa=/^Y+$/,Ia=["D","DD","YY","YYYY"];function Ma(e){if(!(a=e,a instanceof Date||"object"==typeof a&&"[object Date]"===Object.prototype.toString.call(a)||"number"==typeof e))return!1;var a;const t=na(e);return!isNaN(Number(t))}const Fa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ra=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,La=/^'([^]*?)'?$/,za=/''/g,Ua=/[a-zA-Z]/;function Oa(e,a,t){const s=sa(),r=t?.locale??s.locale??aa,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=na(e);if(!Ma(i))throw new RangeError("Invalid time value");let l=a.match(Ra).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:Va(e)};if(_a[a])return{isToken:!0,value:e};if(a.match(Ua))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 d={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 Aa.test(e)}(n)||!t?.useAdditionalDayOfYearTokens&&function(e){return Ea.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(Ia.includes(e))throw new RangeError(s)}(n,a,String(e));return(0,_a[n[0]])(i,n,r.localize,d)}).join("")}function Va(e){const a=e.match(La);return a?a[1].replace(za,"'"):e}function Ba(e,a,t){const s=i.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 qa(e,a){const t=function(e){Wa[e]||(Wa[e]=Ga?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 Wa[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=$a[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 $a={year:0,month:1,day:2,hour:3,minute:4,second:5};const Wa={},Ha=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")),Ga="06/25/2014, 00:00:00"===Ha||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===Ha;function Ya(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 Qa=36e5,Ka={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Xa(e,a,t){if(!e)return 0;let s,r,n=Ka.timezoneZ.exec(e);if(n)return 0;if(n=Ka.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Za(s)?-s*Qa:NaN;if(n=Ka.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Za(s,e)?(r=Math.abs(s)*Qa+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(et[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),et[e]=!0,!0}catch(a){return!1}}(e)){a=new Date(a||Date.now());const s=t?a:function(e){return Ya(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(a),r=Ja(s,e),n=t?r:function(e,a,t){const s=e.getTime();let r=s-a;const n=Ja(new Date(r),t);if(a===n)return a;r-=n-a;const o=Ja(new Date(r),t);if(n===o)return n;return Math.max(n,o)}(a,r,e);return-n}return NaN}function Ja(e,a){const t=qa(e,a),s=Ya(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 Za(e,a){return-23<=e&&e<=23&&(null==a||0<=a&&a<=59)}const et={};const at={X:function(e,a,t){const s=tt(t.timeZone,e);if(0===s)return"Z";switch(a){case"X":return nt(s);case"XXXX":case"XX":return rt(s);default:return rt(s,":")}},x:function(e,a,t){const s=tt(t.timeZone,e);switch(a){case"x":return nt(s);case"xxxx":case"xx":return rt(s);default:return rt(s,":")}},O:function(e,a,t){const s=tt(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+st(n,2)}(s,":");default:return"GMT"+rt(s,":")}},z:function(e,a,t){switch(a){case"z":case"zz":case"zzz":return Ba("short",e,t);default:return Ba("long",e,t)}}};function tt(e,a){const t=e?Xa(e,a,!0)/6e4:a?.getTimezoneOffset()??0;if(Number.isNaN(t))throw new RangeError("Invalid time zone specified: "+e);return t}function st(e,a){const t=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<a;)s="0"+s;return t+s}function rt(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+st(Math.floor(s/60),2)+a+st(Math.floor(s%60),2)}function nt(e,a){if(e%60==0){return(e>0?"-":"+")+st(Math.abs(e)/60,2)}return rt(e,a)}function ot(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 it=36e5,lt=6e4,dt={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 ct(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=dt.dateTimePattern.exec(e);s?(a.date=s[1],t=s[3]):(s=dt.datePattern.exec(e),s?(a.date=s[1],t=s[2]):(a.date=null,t=e));if(t){const e=dt.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=dt.YYY[a],s=dt.YYYYY[a];let r=dt.YYYY.exec(e)||s.exec(e);if(r){const a=r[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(r=dt.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=dt.MM.exec(e);if(n)return t=new Date(0),s=parseInt(n[1],10)-1,xt(a,s)?(t.setUTCFullYear(a,s),t):new Date(NaN);if(n=dt.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=ht(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=dt.MMDD.exec(e),n){t=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return xt(a,s,e)?(t.setUTCFullYear(a,s,e),t):new Date(NaN)}if(n=dt.Www.exec(e),n)return r=parseInt(n[1],10)-1,ft(r)?ut(a,r):new Date(NaN);if(n=dt.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return ft(r,e)?ut(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=dt.HH.exec(e);if(s)return a=parseFloat(s[1].replace(",",".")),gt(a)?a%24*it:NaN;if(s=dt.HHMM.exec(e),s)return a=parseInt(s[1],10),t=parseFloat(s[2].replace(",",".")),gt(a,t)?a%24*it+t*lt:NaN;if(s=dt.HHMMSS.exec(e),s){a=parseInt(s[1],10),t=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return gt(a,t,e)?a%24*it+t*lt+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||a.timeZone){if(t=Xa(s.timeZone||a.timeZone,new Date(e+r)),isNaN(t))return new Date(NaN)}else t=ot(new Date(e+r)),t=ot(new Date(e+r+t));return new Date(e+r+t)}return new Date(NaN)}function ut(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 mt=[31,28,31,30,31,30,31,31,30,31,30,31],pt=[31,29,31,30,31,30,31,31,30,31,30,31];function ht(e){return e%400==0||e%4==0&&e%100!=0}function xt(e,a,t){if(a<0||a>11)return!1;if(null!=t){if(t<1)return!1;const s=ht(e);if(s&&t>pt[a])return!1;if(!s&&t>mt[a])return!1}return!0}function ft(e,a){return!(e<0||e>52)&&(null==a||!(a<0||a>6))}function gt(e,a,t){return!(e<0||e>=25)&&((null==a||!(a<0||a>=60))&&(null==t||!(t<0||t>=60)))}const vt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function bt(e,a,t,s){return function(e,a,t={}){const s=(a=String(a)).match(vt);if(s){const r=ct(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,"'"+at[a[0]](r,a,t)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},a)}return Oa(e,a,t)}(function(e,a,t){const s=Xa(a,e=ct(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 jt={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"}},yt={date:Qe({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:Qe({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Qe({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},wt={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"},Nt={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"},_t={code:"es",formatDistance:(e,a,t)=>{let s;const r=jt[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:yt,formatRelative:(e,a,t,s)=>1!==a.getHours()?Nt[e]:wt[e],localize:{ordinalNumber:(e,a)=>Number(e)+"º",era:Je({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:1,firstWeekContainsDate:1}},Ct={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"}},kt={date:Qe({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:Qe({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Qe({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},St={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"},Tt={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Ct[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:kt,formatRelative:(e,a,t,s)=>{const r=St[e];return"function"==typeof r?r(a):r},localize:{ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Je({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},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:"🇪🇸"}],Dt=[{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"}],Et=[{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"}],At="pt-BR",It="dd/MM/yyyy HH:mm",Mt="America/Sao_Paulo",Ft=e=>Pt.some(a=>a.value===e),Rt=e=>Et.some(a=>a.value===e),Lt=()=>{if("undefined"==typeof navigator)return At;const e=navigator.language;if(Ft(e))return e;const a=e.split("-")[0],t=Pt.find(e=>e.value.startsWith(a));return t?.value||At},zt=()=>{if("undefined"==typeof Intl)return Mt;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Rt(e)?e:Mt}catch{return Mt}},Ut=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||It),Ot={"pt-BR":Tt,"en-US":aa,"es-ES":_t},Vt=(e,a=It,t=Mt,s=At)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const n=Ot[s]||Tt;try{return bt(r,t,a,{locale:n})}catch(o){return bt(r,Mt,a,{locale:n})}},Bt=(e,a=At,t=Mt)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const r=Ot[a]||Tt;try{return bt(s,t,"PP",{locale:r})}catch(n){return bt(s,Mt,"PP",{locale:r})}};function qt(e){const a=e.replace("#",""),t=3===a.length?a.split("").map(e=>e+e).join(""):a;return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}function $t(e,a=.1){const{r:t,g:s,b:r}=qt(e);return`rgba(${t}, ${s}, ${r}, ${a})`}function Wt(e){const{r:a,g:t,b:s}=qt(e),[r,n,o]=[a,t,s].map(e=>{const a=e/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return.2126*r+.7152*n+.0722*o}function Ht(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info("Link copiado para a área de transferência")})}function Gt(e,a){return a?e.replace(/\{alias\}/g,a):e}function Yt(...e){return o.twMerge(n.clsx(e))}const Qt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Qt);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Qt(s);return a}return e},Kt=r.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-lg",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"}}),Xt=te.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},i)=>{const l=n?s.Slot:"button";return a.jsx(l,{className:Yt(Kt({variant:t,size:r,className:e})),ref:i,...o})});Xt.displayName="Button";const Jt=t.forwardRef(({className:e,children:t,variant:s="action",...r},n)=>a.jsx(Xt,{ref:n,variant:s,size:"icon",className:Yt("h-8 w-8",e),...r,children:t||a.jsx(d.EllipsisVertical,{size:16})}));Jt.displayName="ActionButton";const Zt=te.forwardRef(({className:e,type:t,showCharCount:s,maxLength:r,onChange:n,...o},i)=>{const[l,d]=te.useState(0);te.useEffect(()=>{"string"==typeof o.value?d(o.value.length):"string"==typeof o.defaultValue&&d(o.defaultValue.length)},[o.value,o.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("input",{type:t,className:Yt("flex h-10 w-full rounded-lg 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 hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors md:text-sm",e),ref:i,maxLength:r,onChange:e=>{d(e.target.value.length),n?.(e)},...o}),s&&r&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[l," / ",r]})]})});Zt.displayName="Input";const es=r.cva("text-xs font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),as=te.forwardRef(({className:e,...t},s)=>a.jsx(se.Root,{ref:s,className:Yt(es(),e),...t}));as.displayName=se.Root.displayName;const ts=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ts.displayName="Card";const ss=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("flex flex-col space-y-1.5 p-6",e),...t}));ss.displayName="CardHeader";const rs=te.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Yt("text-2xl font-semibold leading-none tracking-tight",e),...t}));rs.displayName="CardTitle";const ns=te.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));ns.displayName="CardDescription";const os=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("p-6 pt-0",e),...t}));os.displayName="CardContent";const is=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("flex items-center p-6 pt-0",e),...t}));is.displayName="CardFooter";const ls=te.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...r},n)=>a.jsx(ne.Root,{ref:n,decorative:s,orientation:t,className:Yt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ls.displayName=ne.Root.displayName;const ds=oe.Root,cs=oe.Trigger,us=oe.Portal,ms=te.forwardRef(({className:e,...t},s)=>a.jsx(oe.Overlay,{className:Yt("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",e),...t,ref:s}));ms.displayName=oe.Overlay.displayName;const ps=te.forwardRef(({className:e,...t},s)=>a.jsxs(us,{children:[a.jsx(ms,{}),a.jsx(oe.Content,{ref:s,className:Yt("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",e),...t})]}));ps.displayName=oe.Content.displayName;const hs=({className:e,...t})=>a.jsx("div",{className:Yt("flex flex-col space-y-2 text-center sm:text-left",e),...t});hs.displayName="AlertDialogHeader";const xs=({className:e,...t})=>a.jsx("div",{className:Yt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xs.displayName="AlertDialogFooter";const fs=te.forwardRef(({className:e,...t},s)=>a.jsx(oe.Title,{ref:s,className:Yt("text-lg font-semibold",e),...t}));fs.displayName=oe.Title.displayName;const gs=te.forwardRef(({className:e,...t},s)=>a.jsx(oe.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));gs.displayName=oe.Description.displayName;const vs=te.forwardRef(({className:e,...t},s)=>a.jsx(oe.Action,{ref:s,className:Yt(Kt(),e),...t}));vs.displayName=oe.Action.displayName;const bs=te.forwardRef(({className:e,...t},s)=>a.jsx(oe.Cancel,{ref:s,className:Yt(Kt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));bs.displayName=oe.Cancel.displayName;const js=re.Root,ys=re.Trigger,ws=re.Portal,Ns=re.Close,_s=te.forwardRef(({className:e,...t},s)=>a.jsx(re.Overlay,{ref:s,className:Yt("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",e),...t}));_s.displayName=re.Overlay.displayName;const Cs={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"}},ks=te.forwardRef(({className:t,children:s,size:r,variant:n="informative",isDirty:o,customWidth:i,customMinWidth:l,customMaxWidth:c,customHeight:u,customMinHeight:m,customMaxHeight:p,unsavedChangesTitle:h=e.t("unsaved_changes"),unsavedChangesDescription:x=e.t("unsaved_changes_description"),cancelText:f=e.t("cancel"),leaveWithoutSavingText:g=e.t("leave_without_saving"),style:v,onInteractOutside:b,onEscapeKeyDown:j,...y},w)=>{const[N,_]=te.useState(!1),C=te.useRef(null),k=te.useRef(!1),S=r??(i||l||c||u||m||p?void 0:"md"),T=S?Cs[S]:{},P={...i??T.width?{width:i??T.width}:{},...l??T.minWidth?{minWidth:l??T.minWidth}:{},...c??T.maxWidth?{maxWidth:c??T.maxWidth}:{},...u??T.height?{height:u??T.height}:{},...m??T.minHeight?{minHeight:m??T.minHeight}:{},...p??T.maxHeight?{maxHeight:p??T.maxHeight}:{},...v},D=te.useCallback(e=>{"form"===n&&o?(C.current=e,_(!0)):e()},[n,o]),E=te.useRef(null),A="destructive"!==n;if("development"===process.env.NODE_ENV&&s){const e=te.Children.toArray(s);e.some(e=>te.isValidElement(e)&&"DialogFooter"===e.type?.displayName),e.some(e=>te.isValidElement(e)&&"DialogBody"===e.type?.displayName)}return a.jsxs(ws,{children:[a.jsx(_s,{}),a.jsxs(re.Content,{ref:w,className:Yt("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border-0 border-l-[10px] border-l-primary 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:P,onInteractOutside:e=>{"form"!==n&&"destructive"!==n?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==n)return"form"===n&&o?(e.preventDefault(),void D(()=>{k.current=!0,E.current?.click()})):void j?.(e);e.preventDefault()},...y,children:[s,A&&a.jsxs(re.Close,{ref:E,onClick:e=>{k.current?k.current=!1:"form"===n&&o&&(e.preventDefault(),D(()=>{k.current=!0,E.current?.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]}),a.jsx(ds,{open:N,onOpenChange:_,children:a.jsxs(ps,{children:[a.jsxs(hs,{children:[a.jsx(fs,{children:h}),a.jsx(gs,{children:x})]}),a.jsxs(xs,{children:[a.jsx(bs,{onClick:()=>{_(!1),C.current=null},children:f}),a.jsx(vs,{onClick:()=>{_(!1),C.current?.(),C.current=null},children:g})]})]})})]})});ks.displayName=re.Content.displayName;const Ss=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Yt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(ls,{className:"mt-2"})]});Ss.displayName="DialogHeader";const Ts=({className:e,...t})=>a.jsx("div",{className:Yt("flex-1 min-h-0 overflow-auto py-4 px-2 -mx-2",e),...t});Ts.displayName="DialogBody";const Ps=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsx("div",{className:Yt("flex flex-row justify-end gap-2",e),...s,children:t})]});Ps.displayName="DialogFooter";const Ds=te.forwardRef(({className:e,...t},s)=>a.jsx(re.Title,{ref:s,className:Yt("text-xl font-semibold leading-none tracking-tight",e),...t}));Ds.displayName=re.Title.displayName;const Es=te.forwardRef(({className:e,...t},s)=>a.jsx(re.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Es.displayName=re.Description.displayName;const As=h.FormProvider,Is=te.createContext({}),Ms=()=>{const e=te.useContext(Is),a=te.useContext(Fs),{getFieldState:t,formState:s}=h.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=te.createContext({}),Rs=te.forwardRef(({className:e,...t},s)=>{const r=te.useId();return a.jsx(Fs.Provider,{value:{id:r},children:a.jsx("div",{ref:s,className:Yt("space-y-1.5",e),...t})})});Rs.displayName="FormItem";const Ls=te.forwardRef(({className:e,...t},s)=>{const{error:r,formItemId:n}=Ms();return a.jsx(as,{ref:s,className:Yt(r&&"text-destructive",e),htmlFor:n,...t})});Ls.displayName="FormLabel";const zs=te.forwardRef(({...e},t)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=Ms();return a.jsx(s.Slot,{ref:t,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...e})});zs.displayName="FormControl";const Us=te.forwardRef(({className:e,...t},s)=>{const{formDescriptionId:r}=Ms();return a.jsx("p",{ref:s,id:r,className:Yt("text-sm text-muted-foreground",e),...t})});Us.displayName="FormDescription";const Os=te.forwardRef(({className:e,children:t,...s},r)=>{const{error:n,formMessageId:o}=Ms(),i=n?String(n?.message):t;return i?a.jsx("p",{ref:r,id:o,className:Yt("text-sm font-medium text-destructive",e),...s,children:i}):null});Os.displayName="FormMessage";const Vs=ie.Root,Bs=ie.Group,qs=ie.Value,$s=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ie.Trigger,{ref:r,className:Yt("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors [&>span]:line-clamp-1",e),...s,children:[t,a.jsx(ie.Icon,{asChild:!0,children:a.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));$s.displayName=ie.Trigger.displayName;const Ws=te.forwardRef(({className:e,...t},s)=>a.jsx(ie.ScrollUpButton,{ref:s,className:Yt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronUp,{className:"h-4 w-4"})}));Ws.displayName=ie.ScrollUpButton.displayName;const Hs=te.forwardRef(({className:e,...t},s)=>a.jsx(ie.ScrollDownButton,{ref:s,className:Yt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronDown,{className:"h-4 w-4"})}));Hs.displayName=ie.ScrollDownButton.displayName;const Gs=te.forwardRef(({className:e,children:t,position:s="popper",container:r,collisionBoundary:n,...o},i)=>a.jsx(ie.Portal,{container:r,children:a.jsxs(ie.Content,{ref:i,className:Yt("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",e),position:s,collisionBoundary:n,...o,children:[a.jsx(Ws,{}),a.jsx(ie.Viewport,{className:Yt("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),a.jsx(Hs,{})]})}));Gs.displayName=ie.Content.displayName;const Ys=te.forwardRef(({className:e,...t},s)=>a.jsx(ie.Label,{ref:s,className:Yt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ys.displayName=ie.Label.displayName;const Qs=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ie.Item,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(ie.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),a.jsx(ie.ItemText,{children:t})]}));Qs.displayName=ie.Item.displayName;const Ks=te.forwardRef(({className:e,...t},s)=>a.jsx(ie.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-muted",e),...t}));Ks.displayName=ie.Separator.displayName;const Xs=te.forwardRef(({className:e,...t},s)=>a.jsx(le.Root,{ref:s,className:Yt("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",e),...t,children:a.jsx(le.Indicator,{className:Yt("flex items-center justify-center text-current"),children:a.jsx(d.Check,{className:"h-4 w-4"})})}));Xs.displayName=le.Root.displayName;const Js=te.forwardRef(({className:e,showCharCount:t,maxLength:s,onChange:r,...n},o)=>{const[i,l]=te.useState(0);te.useEffect(()=>{"string"==typeof n.value?l(n.value.length):"string"==typeof n.defaultValue&&l(n.defaultValue.length)},[n.value,n.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("textarea",{className:Yt("flex min-h-[80px] w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",e),ref:o,maxLength:s,onChange:e=>{l(e.target.value.length),r?.(e)},...n}),t&&s&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[i," / ",s]})]})});Js.displayName="Textarea";const Zs=r.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"}}),er=te.forwardRef(({className:e,variant:t,...s},r)=>a.jsx("div",{ref:r,className:Yt(Zs({variant:t}),e),...s}));er.displayName="Badge";const ar={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function tr({size:e="md",className:t}){return a.jsx(d.Loader2,{className:Yt("animate-spin text-muted-foreground",ar[e],t)})}function sr({isLoading:e,children:t,className:s,type:r="spinner",size:n="md"}){return e?"overlay"===r?a.jsxs("div",{className:Yt("relative",s),children:[t,a.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:a.jsx(tr,{size:n})})]}):"skeleton"===r?a.jsx("div",{className:Yt("animate-pulse",s),children:a.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):a.jsx("div",{className:Yt("flex items-center justify-center py-8",s),children:a.jsx(tr,{size:n})}):a.jsx(a.Fragment,{children:t})}const rr=({...e})=>a.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:a.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:a.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:a.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:a.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:a.jsx(d.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive-light !border-destructive-light",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...e}),nr=de.Root,or=de.Trigger,ir=de.Group,lr=de.Portal,dr=de.Sub,cr=de.RadioGroup,ur=te.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(de.SubTrigger,{ref:n,className:Yt("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",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ur.displayName=de.SubTrigger.displayName;const mr=te.forwardRef(({className:e,...t},s)=>a.jsx(de.SubContent,{ref:s,className:Yt("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",e),...t}));mr.displayName=de.SubContent.displayName;const pr=te.forwardRef(({className:e,sideOffset:t=4,...s},r)=>a.jsx(de.Portal,{children:a.jsx(de.Content,{ref:r,sideOffset:t,className:Yt("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",e),...s})}));pr.displayName=de.Content.displayName;const hr=te.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(de.Item,{ref:r,className:Yt("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",e),...s}));hr.displayName=de.Item.displayName;const xr=te.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(de.CheckboxItem,{ref:n,className:Yt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(de.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));xr.displayName=de.CheckboxItem.displayName;const fr=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(de.RadioItem,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(de.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));fr.displayName=de.RadioItem.displayName;const gr=te.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(de.Label,{ref:r,className:Yt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));gr.displayName=de.Label.displayName;const vr=te.forwardRef(({className:e,...t},s)=>a.jsx(de.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-muted",e),...t}));vr.displayName=de.Separator.displayName;const br=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest opacity-60",e),...t});br.displayName="DropdownMenuShortcut";const jr=({delayDuration:e=300,...t})=>a.jsx(ce.Provider,{delayDuration:e,...t}),yr=ce.Root,wr=ce.Trigger,Nr=te.forwardRef(({className:e,sideOffset:t=4,...s},r)=>a.jsx(ce.Content,{ref:r,sideOffset:t,className:Yt("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",e),...s}));Nr.displayName=ce.Content.displayName;const _r=te.forwardRef(({children:e,disabledReason:t,className:s},r)=>{const n=a.jsx(hr,{ref:r,className:Yt("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:e});return t?a.jsx(jr,{delayDuration:100,children:a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("div",{className:"w-full",children:n})}),a.jsx(Nr,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:t})]})}):n});_r.displayName="DisabledMenuItem";const Cr=ue.Root,kr=ue.Trigger,Sr=te.forwardRef(({className:e,align:t="center",sideOffset:s=4,container:r,...n},o)=>a.jsx(ue.Portal,{container:r,children:a.jsx(ue.Content,{ref:o,align:t,sideOffset:s,className:Yt("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",e),...n})}));Sr.displayName=ue.Content.displayName;const Tr=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tr.displayName="Command";const Pr=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:a.jsx("input",{ref:s,className:Yt("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",e),...t})}));Pr.displayName="CommandInput";const Dr=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Dr.displayName="CommandList";const Er=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("py-6 text-center text-sm text-muted-foreground",e),...t}));Er.displayName="CommandEmpty";const Ar=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("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",e),...t}));Ar.displayName="CommandGroup";const Ir=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("-mx-1 h-px bg-border",e),...t}));Ir.displayName="CommandSeparator";const Mr=te.forwardRef(({className:e,disabled:t,onSelect:s,value:r,...n},o)=>a.jsx("div",{ref:o,className:Yt("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",e),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Mr.displayName="CommandItem";const Fr=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function Rr({className:e,...t}){return a.jsx("div",{className:Yt("animate-pulse rounded-md bg-muted",e),...t})}Fr.displayName="CommandShortcut";const Lr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function zr({multiple:s,options:r,value:n,onChange:o,getOptionValue:i,getOptionLabel:l,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x,required:f,className:g,sortOptions:v,maxDisplayedBadges:b,popoverContainer:j,onOpen:y,onClose:w}){const[N,_]=t.useState(!1),[C,k]=t.useState(""),S=t.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),T=t.useMemo(()=>{if(!j)return;let e=j,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[j]),P=t.useMemo(()=>{const e=r.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[r,i,l,v]),D=t.useMemo(()=>{if(!C)return P;const e=Lr(C);return P.filter(a=>Lr(a.label).includes(e))},[P,C]),E=t.useMemo(()=>P.filter(e=>S.includes(e.value)),[P,S]),A=e=>{_(e),e?y?.():(k(""),w?.())},I=(e,a)=>{a.preventDefault(),a.stopPropagation(),o&&o(s?S.filter(a=>a!==e):"")},M=b?E.slice(0,b):E,F=b&&E.length>b?E.length-b:0;return a.jsxs("div",{className:Yt("space-y-2",g),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Cr,{open:N,onOpenChange:A,modal:!1,children:[a.jsx(kr,{asChild:!0,children:s?a.jsxs("div",{role:"combobox","aria-expanded":N,"aria-disabled":x,tabIndex:x?-1:0,onKeyDown:e=>{x||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),A(!N))},className:Yt("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",x&&"pointer-events-none opacity-50 cursor-not-allowed",0===E.length&&"text-muted-foreground"),children:[0===E.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[M.map(e=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&I(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>I(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),F>0&&a.jsxs(er,{variant:"outline",className:"gap-1",children:["+",F]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):a.jsxs(Xt,{variant:"outline",role:"combobox","aria-expanded":N,disabled:x,className:Yt("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),E[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),a.jsx(Sr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:T,collisionBoundary:T,children:a.jsxs(Tr,{children:[a.jsxs("div",{className:"relative",children:[a.jsx(Pr,{placeholder:h,value:C,onChange:e=>k(e.target.value)}),C&&a.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:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx(Dr,{children:0===r.length?a.jsx(Er,{children:p}):0===D.length?a.jsx(Er,{children:e.t("no_results")}):a.jsx(Ar,{children:D.map(e=>a.jsxs(Mr,{value:e.value,onSelect:()=>(e=>{if(o)if(s){const a=S.includes(e)?S.filter(a=>a!==e):[...S,e];o(a)}else o(e),_(!1)})(e.value),className:"cursor-pointer",children:[a.jsx(d.Check,{className:Yt("mr-2 h-4 w-4",S.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})]})]})}function Ur({multiple:e=!1,options:t,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:g=!1,error:v,className:b,sortOptions:y=!0,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C}){const{t:k}=j.useTranslation(),S=t||s||[],T=o||n,P=c||k("select_placeholder","Selecione..."),D=p||k("no_results",k("no_results")),E=h||k("search_placeholder","Pesquisar...");if(g)return a.jsxs("div",{className:Yt("space-y-2",b),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Rr,{className:"h-10 w-full"})]});const A="string"==typeof v?v:v instanceof Error?v.message:v?k("error_loading",k("error_loading")):void 0;return A?a.jsxs("div",{className:Yt("space-y-2",b),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:A})]})]}):a.jsx(zr,{multiple:e,options:S,value:r||(e?[]:""),onChange:T,getOptionValue:i,getOptionLabel:l,placeholder:P,label:u,icon:m,emptyMessage:D,searchPlaceholder:E,disabled:x,required:f,className:b,sortOptions:y,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C})}const Or=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Vr(e,a){if(!a)return null;const t=Or(a),s=[];for(const r of e){const e=Or(r.label).includes(t),n=r.children?Vr(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 Br(e,a){for(const t of e){if(t.value===a)return t.label;if(t.children){const e=Br(t.children,a);if(e)return e}}}function qr({node:e,level:t,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=e.children&&e.children.length>0,l=n.includes(e.value);return a.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":l,className:Yt("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:[a.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:a=>{a.stopPropagation(),o(e.value)},children:[a.jsx(d.Check,{className:Yt("h-4 w-4 shrink-0",l?"opacity-100":"opacity-0")}),(()=>{const t=l?e.iconSelected??(s?e.iconOpen:null)??e.icon:s?e.iconOpen??e.icon:e.icon;return t?a.jsx(t,{className:Yt("h-4 w-4 shrink-0",e.iconClassName||"text-muted-foreground")}):null})(),a.jsx("span",{className:"truncate",children:e.label})]}),i&&a.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:a=>{a.stopPropagation(),r(e.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?a.jsx(d.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function $r({nodes:e,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return a.jsx(a.Fragment,{children:e.map(e=>{const l=r.has(e.value);return a.jsxs(t.Fragment,{children:[a.jsx(qr,{node:e,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&e.children&&e.children.length>0&&a.jsx($r,{nodes:e.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},e.value)})})}function Wr({multiple:e=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:l,emptyMessage:c,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:x,className:f,maxDisplayedBadges:g,popoverContainer:v,onOpen:b,onClose:y,defaultExpanded:w=!0}){const{t:N}=j.useTranslation(),[_,C]=t.useState(!1),[k,S]=t.useState(""),[T,P]=t.useState(()=>w?function(e){const a=new Set;return function e(t){for(const s of t)s.children&&s.children.length>0&&(a.add(s.value),e(s.children))}(e),a}(s):new Set),D=o||N("select_placeholder","Selecione..."),E=c||N("no_results",N("no_results")),A=u||N("search_placeholder","Pesquisar..."),I=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),M=t.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]),F=t.useMemo(()=>Vr(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,a){const t=new Set,s=Or(a);function r(e){if(!e.children||0===e.children.length)return Or(e.label).includes(s);let a=!1;for(const t of e.children)r(t)&&(a=!0);return a&&t.add(e.value),a||Or(e.label).includes(s)}for(const n of e)r(n);return t}(s,k):new Set,[s,k]),L=k?R:T,z=t.useCallback(e=>{k||P(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[k]),U=t.useMemo(()=>I.map(e=>({value:e,label:Br(s,e)||e})),[I,s]),O=e=>{C(e),e?b?.():(S(""),y?.())},V=t.useCallback(a=>{if(n)if(e){const e=I.includes(a)?I.filter(e=>e!==a):[...I,a];n(e)}else n(a),C(!1)},[n,e,I]),B=(a,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(e?I.filter(e=>e!==a):"")},q=g?U.slice(0,g):U,$=g&&U.length>g?U.length-g:0;if(h)return a.jsxs("div",{className:Yt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Rr,{className:"h-10 w-full"})]});const W="string"==typeof x?x:x instanceof Error?x.message:x?N("error_loading",N("error_loading")):void 0;return W?a.jsxs("div",{className:Yt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:W})]})]}):a.jsxs("div",{className:Yt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Cr,{open:_,onOpenChange:O,modal:!1,children:[a.jsx(kr,{asChild:!0,children:e?a.jsxs("div",{role:"combobox","aria-expanded":_,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),O(!_))},className:Yt("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===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),D]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[q.map(e=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&B(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>B(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),$>0&&a.jsxs(er,{variant:"outline",className:"gap-1",children:["+",$]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):a.jsxs(Xt,{variant:"outline",role:"combobox","aria-expanded":_,disabled:m,className:Yt("w-full justify-between min-h-10 h-auto font-normal",0===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),D]}):a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),U[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(Sr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:M,collisionBoundary:M,children:[a.jsxs("div",{className:"flex items-center border-b px-3",children:[a.jsx(d.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.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:A,value:k,onChange:e=>S(e.target.value)}),k&&a.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx("div",{className:"max-h-[300px] overflow-y-auto overflow-x-hidden",children:a.jsx("div",{role:"tree",className:"p-1",children:0===F.length?a.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:N("no_search_results",N("no_results"))}):a.jsx($r,{nodes:F,level:0,expandedIds:L,onToggleExpand:z,selectedValues:I,onSelect:V})})})]})]})]})}class Hr{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}static parseJwtPayload(e){try{const 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()}}Hr.LARGE_PAYLOAD_THRESHOLD=1e3;const Gr="qualiex_access_token",Yr="qualiex_id_token",Qr="supabase_token",Kr="oauth_state",Xr="oauth_nonce",Jr="selected_alias",Zr="manual_logout",en="supabase_project_id",an={setAccessToken:e=>localStorage.setItem(Gr,e),getAccessToken:()=>localStorage.getItem(Gr),setIdToken:e=>localStorage.setItem(Yr,e),getIdToken:()=>localStorage.getItem(Yr),getSupabaseToken:()=>localStorage.getItem(Qr),setOAuthState:e=>sessionStorage.setItem(Kr,e),getOAuthState:()=>sessionStorage.getItem(Kr),clearOAuthState:()=>sessionStorage.removeItem(Kr),setOAuthNonce:e=>sessionStorage.setItem(Xr,e),getOAuthNonce:()=>sessionStorage.getItem(Xr),clearOAuthNonce:()=>sessionStorage.removeItem(Xr),setSelectedAlias:e=>localStorage.setItem(Jr,e),getSelectedAlias:()=>localStorage.getItem(Jr),clearSelectedAlias:()=>localStorage.removeItem(Jr),generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!an.getAccessToken()||!an.getIdToken()),checkProjectMismatch:()=>{const e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)return!1;const a=localStorage.getItem(en);return a&&a!==e?(an.clearAll(),localStorage.setItem(en,e),!0):(a||localStorage.setItem(en,e),!1)},setSupabaseToken:e=>{localStorage.setItem(Qr,e),an._clearValidationCache()},areAllTokensValid:()=>{const e=an.getAccessToken(),a=an.getIdToken();if(!e||!a)return!1;try{const t=Hr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=an.getAccessToken(),t=an.getIdToken(),s=an.getSupabaseToken();return a&&an.isTokenExpired(a)&&(localStorage.removeItem(Gr),e=!0),t&&an.isTokenExpired(t)&&(localStorage.removeItem(Yr),e=!0),s&&an.isTokenExpired(s)&&(localStorage.removeItem(Qr),e=!0),e},clearAll:()=>{localStorage.removeItem(Gr),localStorage.removeItem(Yr),localStorage.removeItem(Qr),localStorage.removeItem(Jr),localStorage.removeItem(Zr),sessionStorage.removeItem(Kr),sessionStorage.removeItem(Xr),an._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Zr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Zr),clearManualLogout:()=>localStorage.removeItem(Zr),isTokenExpired:e=>{try{return Hr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{an._validationCache.isValid=!1,an._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=an.getSupabaseToken();if(!e)return!1;if(an.isTokenExpired(e))return an._clearValidationCache(),an._handleExpiredToken(),!1;const a=Date.now();return a-an._validationCache.timestamp<an._validationCache.cacheValidityMs?an._validationCache.isValid:(an._validationCache.isValid=!0,an._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>an.isSupabaseTokenValid()?an.getSupabaseToken():null,_handleExpiredToken:()=>{an.clearAll()},extractTokenData:()=>{if(!an.isSupabaseTokenValid())return null;const e=an.getSupabaseToken();if(!e)return null;try{const a=Hr.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 an._handleExpiredToken(),null}},getCompanyId:e=>{const a=an.getAccessToken();if(a)try{const t=Hr.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const 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=an.extractTokenData();if(t?.companyId)return t.companyId;const s=an.getIdToken();if(s)try{const a=Hr.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=[an.getAccessToken(),an.getIdToken()];for(const t of a)if(t)try{const a=Hr.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=an.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=an.getIdToken();if(!e)return[];try{const a=Hr.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const 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 tn=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);l.toast.error(e,{description:t})}}getErrorTitle(a){const t=a.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?e.t("error_session_expired"):t.includes("token")||t.includes("autenticação")?e.t("error_authentication"):t.includes("api")||t.includes("network")?e.t("error_connection"):"Erro"}success(e,a){l.toast.success(e,{description:a})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}},sn=(void 0).VITE_SUPABASE_URL,rn=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class nn{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:rn};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return y.createClient(sn,rn,{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 nn.instance||(nn.instance=new nn),nn.instance}getClient(){const e=an.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Hr.isTokenExpired(e)}catch(a){return tn.handleError(a instanceof Error?a:"Supabase - Error validating token",!1),!1}}}function on(){return nn.getInstance().getClient()}class ln{static async generateToken(e,a,t,s=!1){try{if(!s){const e=an.getSupabaseToken();if(e&&an.isSupabaseTokenValid())return e}const r=on(),{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?(an.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 dn{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=an.getAccessToken(),t=an.getSelectedAlias();if(!a||!t)return null;const s=await ln.generateToken(a,t,this.onLogoutCallback||void 0,e);return s||null}catch(a){return null}}}dn.regenerationPromise=null,dn.onLogoutCallback=null;class cn{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(an.clearAll(),window.location.href="/login",!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 un{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 dn.attemptRegeneration()?(this.isRetrying=!1,!0):(cn.handleError(e),this.isRetrying=!1,!1)}catch(s){return cn.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=an.getAccessToken();return e?an.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."}}}un.isRetrying=!1;const mn=new class{get baseUrl(){return Oe()}async makeApiCall(e,a,t){const s=un.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=an.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){let a;return a="boolean"==typeof e.isActive?e.isActive:"boolean"==typeof e.active?e.active:"string"!=typeof e.status||"active"===e.status.toLowerCase(),{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,isActive:a}}parseUsersResponse(e,a=""){let t=e;if(e.data)t=e.data;else{if(!Array.isArray(e))return tn.handleError(`[QualiexApi] Formato de resposta inesperado${a}`,!1),null;t=e}return Array.isArray(t)?t.map(e=>this.mapToQualiexUser(e)):(tn.handleError(`[QualiexApi] Resposta não é um array${a}`,!1),null)}async fetchUsers(e,a,t="active"){const s={companyId:a,search:"",filterStatus:t};try{const a=await this.makeApiCall("/api/common/v1/companiesusers",s,e);return this.parseUsersResponse(a)??[]}catch(r){if(await un.handleApiError(r))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",s,e);return this.parseUsersResponse(a," após retry")??[]}catch(n){return tn.handleError(n instanceof Error?n:"Erro ao buscar usuários após renovação de token",!0),[]}return tn.handleError(r instanceof Error?r.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 tn.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a,"active"),s=new Map;return t.forEach(e=>s.set(e.userId,e)),s}async fetchAllUsersMap(e,a){const t=await this.fetchUsers(e,a,"all"),s=new Map;return t.forEach(e=>s.set(e.userId,e)),s}async getUsers(e,a="active"){const t=an.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId,a):[]}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||""})):(tn.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(a){if(await un.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 tn.handleError(t instanceof Error?t:"Erro ao buscar softwares após renovação de token",!0),[]}return tn.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})):(tn.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(t){if(await un.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 tn.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return tn.handleError(t instanceof Error?t.message:"Erro ao buscar associações do usuário",!0),[]}}};function pn(e,a){const t=a||Ve.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function hn(e,a){const t=a||Ve.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function xn(e,a){const t=a||Ve.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function fn(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||pn(e.idField),emailField:e.emailField||hn(e.idField),usernameField:e.usernameField||xn(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:pn(e),emailField:hn(e),usernameField:xn(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const gn=new Map;class vn{static async fetchQualiexUsers(e,a){const t=`${a}_${e}_all`,s=gn.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await mn.fetchUsers(e,a,"all");return gn.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(!an.areAllTokensValid())return e;const t=an.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=fn(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 tn.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}}const bn=["responsible_name"],jn=e=>bn.includes(e);function yn(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:d=!1}=s,c=()=>{if(!an.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return on().schema(i).from(r)},u=(e,a,t,s)=>{let r=c().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||jn(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:i}},m=async(e,a,t,r,n)=>{const o=fn(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),i=a.includes(".");if(jn(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 d=await vn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.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}))(d,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}}})(c,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 vn.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:c}=(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,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,o,i),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let v=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const a=fn(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(v.data)){const e=await m(v.data,t,n,o,i);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:a,error:t}=await c().select(o||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Qt(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Qt(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}};return p}var wn;const Nn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class _n{static async initialize(){try{if(an.checkProjectMismatch())return{...Nn};if(!an.hasAllTokens()||!an.areAllTokensValid())return an.clearExpiredTokens(),{...Nn};const e=an.getAccessToken(),a=an.getIdToken();an.clearManualLogout();const t=this.extractUserFromIdToken(a,e),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=an.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=an.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);i=a?e:r||s[0]?.alias||null}if(!an.isSupabaseTokenValid()&&i&&await dn.attemptRegeneration(),!an.isSupabaseTokenValid())return{...Nn};let l=null;if(i){const e=an.getCompanyId(i),a=s.find(e=>e.alias===i);a&&(l={id:e||a.id,name:a.name,alias:a.alias})}const d=n?.placeId??null,c=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:d,placeName:c,activePlaceId:d,activePlaceName:c}}catch(e){return{...Nn}}}static async loginDev(){try{const e=on(),{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="Lw==";an.setOAuthState(e);const a=an.generateOAuthNonce();an.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(Me.oauth.authUrl);s.searchParams.set("client_id",Me.oauth.clientId),s.searchParams.set("response_type",Me.oauth.responseType),s.searchParams.set("scope",Me.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=an.getAccessToken();e!==s&&an.clearAll()}if(an.hasAllTokens()){return an.getValidSupabaseToken()||await dn.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");an.setAccessToken(o),an.setIdToken(i),an.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)an.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");an.setSelectedAlias(e[0].alias)}if(!await dn.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return an.clearOAuthState(),an.clearOAuthNonce(),!0}catch(e){throw e}}static async logout(){an.setManualLogout(),an.clearAll(),localStorage.removeItem("auth_return_url"),sessionStorage.clear();try{if("caches"in window){const e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}}catch{}window.location.href="/login"}static decodeToken(e){return Hr.parseJwtPayload(e)}static extractUserFromIdToken(e,a){const t=this.decodeToken(e);if(!t)return null;const s=a?this.decodeToken(a):null;return{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier,isSysAdmin:"1"===s?.admin}}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}}wn=_n,dn.setLogoutCallback(()=>{wn.logout()});const Cn=e=>e?.placeId||null,kn=e=>e?.placeName||null,Sn=t.createContext(void 0),Tn=({children:e})=>{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=w.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useRef(0),d=t.useCallback(e=>{r(a=>({...a,...e}))},[]),c=t.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),u=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})},[]),m=t.useCallback(async e=>{if(e.alias===s.alias)return;const a=++l.current;try{const r=an.getAccessToken();if(!r)return;const o=await ln.generateToken(r,e.alias,void 0,!0);if(l.current!==a)return;if(!o)return;an.setSupabaseToken(o),an.setSelectedAlias(e.alias);const i=an.extractTokenData(),c=i?.alias||e.alias,u=i?.companyId||an.getCompanyId(e.alias),m={id:u||e.id,name:e.name,alias:c};let p=null,h=null;if(s.user?.id&&c&&u)try{const e=await mn.fetchActiveUsersMap(c,u);if(l.current!==a)return;const t=e.get(s.user.id);if(t){const e=(e=>({placeId:Cn(e),placeName:kn(e)}))(t);p=e.placeId,h=e.placeName}}catch(t){}if(l.current!==a)return;d({alias:c,selectedUnit:m,placeId:p,placeName:h,activePlaceId:p,activePlaceName:h}),n&&await n.clear()}catch(t){}},[d,n,s.user,s.alias]),p=t.useCallback(async()=>{const e=await _n.processCallback();if(e){const e=await _n.initialize();e&&e.isAuthenticated&&(d({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},[d,n]),h=t.useCallback(async()=>{await _n.logout(),u(),n&&await n.clear()},[u,n]),x=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),g=t.useCallback(()=>{n&&n.invalidateQueries()},[n]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(async()=>{if(e)if(an.areAllTokensValid()){if(!an.isSupabaseTokenValid())try{await dn.attemptRegeneration()||e&&h()}catch(a){e&&h()}}else e&&h()},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,h]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await _n.initialize();if(!e)return;a&&a.isAuthenticated?d({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&&(cn.handleError(a),c(!1))}})(),()=>{e=!1}},[d,c,h]);const v=t.useMemo(()=>({...s,logout:h,processCallback:p,switchUnit:m,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:x,clearSearch:f,refreshData:g}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,h,p,m,o,x,f,g]);return a.jsx(Sn.Provider,{value:v,children:e})},Pn=()=>{const e=t.useContext(Sn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Dn({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[i,d]=N.useSearchParams(),c=w.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Pn(),{t:h}=j.useTranslation(),x=t.useCallback(a=>{const t=`${e}_${a}`,s=i.get(t);return s||(i.get(a)||"")},[i,e]),f=x("search"),g=x("sortField")||Fe.sorting.defaultField,v=x("sortDirection")||Fe.sorting.defaultDirection,b=parseInt(x("page")||"1"),y=parseInt(x("limit")||String(Fe.pagination.defaultPageSize)),_=f,C=t.useMemo(()=>({search:_,sortField:g,sortDirection:v,page:b,limit:y,...n}),[_,g,v,b,y,n]),k=t.useCallback(()=>a.getAll(C),[a,C]),S=w.useQuery({queryKey:[e,u,m,C],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 T=w.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.created(s)),o?.()},onError:e=>{l.toast.error(`${qe.error.create(s)}: ${e.message}`)}}),P=w.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.updated(s)),o?.()},onError:e=>{l.toast.error(`${qe.error.update(s)}: ${e.message}`)}}),D=w.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.deleted(s))},onError:e=>{l.toast.error(`${qe.error.delete(s)}: ${e.message}`)}}),E=t.useCallback(a=>{const t={...Object.fromEntries(i)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[i,d,e]),A=t.useCallback(e=>{E({search:e,page:1})},[E]),I=t.useCallback(e=>{E({sortField:e,sortDirection:g===e&&"asc"===v?"desc":"asc",page:1})},[g,v,E]),M=t.useCallback(e=>{E({page:e})},[E]),F=t.useCallback(e=>{E({limit:e,page:1})},[E]),R=t.useCallback(()=>{const a=Object.fromEntries(i),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,i,e]),[L,z]=t.useState([]),U=t.useCallback(e=>{z(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),O=t.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];z(a=>a.length===e.length?[]:e)},[S?.data?.data]),V=t.useCallback(()=>{z([])},[]),B=t.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&L.length===e.length},[L,S?.data?.data]),q=w.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(h("bulk_delete_success",`${t.length} ${s}(s) deletado(s) com sucesso`)),V()},onError:e=>{l.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),$=t.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):T.mutate({...t,alias:u})},[u,T,P]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||Fe.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:T?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:D?.isPending??!1,error:S?.error||null,searchTerm:f,sortField:g,sortDirection:v,currentPage:b,itemsPerPage:y,queryKey:e,createEntity:T.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:D.mutate,save:$,handleSearch:A,handleSort:I,handlePageChange:M,handleItemsPerPageChange:F,clearFilters:R,refetch:S.refetch,selectedIds:L,selectItem:U,selectAll:O,clearSelection:V,isAllSelected:B,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}function En(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.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]),a}function An(e=768){return En(`(max-width: ${e-1}px)`)}const In=te.forwardRef(({className:e,...t},s)=>a.jsx("table",{ref:s,className:Yt("w-full caption-bottom text-[13px] table-fixed",e),...t}));In.displayName="Table";const Mn=te.forwardRef(({className:e,...t},s)=>a.jsx("thead",{ref:s,className:Yt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));Mn.displayName="TableHeader";const Fn=te.forwardRef(({className:e,...t},s)=>a.jsx("tbody",{ref:s,className:Yt("[&_tr:last-child]:border-0",e),...t}));Fn.displayName="TableBody";const Rn=te.forwardRef(({className:e,...t},s)=>a.jsx("tfoot",{ref:s,className:Yt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Rn.displayName="TableFooter";const Ln=te.forwardRef(({className:e,...t},s)=>a.jsx("tr",{ref:s,className:Yt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",e),...t}));Ln.displayName="TableRow";const zn=te.forwardRef(({className:e,...t},s)=>a.jsx("th",{ref:s,className:Yt("h-9 px-4 py-2 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));zn.displayName="TableHead";const Un=te.forwardRef(({className:e,...t},s)=>a.jsx("td",{ref:s,className:Yt("px-4 py-2 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",e),...t}));Un.displayName="TableCell";const On=te.forwardRef(({className:e,...t},s)=>a.jsx("caption",{ref:s,className:Yt("mt-4 text-sm text-muted-foreground",e),...t}));function Vn({rows:e=5,columns:t=4}){return a.jsx("div",{className:"w-full",children:a.jsxs("div",{className:"rounded-md border",children:[a.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Rr,{className:"h-4 w-24"},t))})}),a.jsx("div",{children:Array.from({length:e}).map((e,s)=>a.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Rr,{className:"h-4 w-20"},t))})},s))})]})})}function Bn({count:e=3}){return a.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>a.jsxs(ts,{children:[a.jsxs(ss,{children:[a.jsx(Rr,{className:"h-4 w-3/4"}),a.jsx(Rr,{className:"h-3 w-1/2"})]}),a.jsx(os,{children:a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rr,{className:"h-3 w-full"}),a.jsx(Rr,{className:"h-3 w-2/3"})]})})]},t))})}On.displayName="TableCaption";const qn={default:d.FileX,search:d.Search,error:d.AlertCircle};function $n({icon:e,title:t,description:s,action:r,className:n,variant:o="default"}){const{t:i}=j.useTranslation(),l=!!e,d=qn[o];return a.jsxs("div",{className:Yt("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[a.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:l?e:a.jsx(d,{className:"h-8 w-8 text-muted-foreground"})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&a.jsx(Xt,{onClick:r.onClick,variant:"outline",children:r.label})]})}function Wn({children:e,className:t}){const s=te.useRef(null),[r,n]=te.useState(!1);te.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()},[e]);const o=a.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:e});return r?a.jsx(jr,{delayDuration:300,children:a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:o}),a.jsx(Nr,{side:"top",className:"max-w-[400px] break-words",children:e})]})}):o}const Hn=te.forwardRef(({direction:e,onMouseDown:t,isDragging:s,className:r},n)=>{const o="horizontal"===e;return a.jsx("div",{ref:n,onMouseDown:t,className:Yt("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:a.jsx("div",{className:Yt("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Hn.displayName="TableResizeHandle";const Gn=me.Root,Yn=me.Trigger,Qn=me.Group,Kn=me.Portal,Xn=me.Sub,Jn=me.RadioGroup,Zn=te.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(me.SubTrigger,{ref:n,className:Yt("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",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Zn.displayName=me.SubTrigger.displayName;const eo=te.forwardRef(({className:e,...t},s)=>a.jsx(me.SubContent,{ref:s,className:Yt("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",e),...t}));eo.displayName=me.SubContent.displayName;const ao=te.forwardRef(({className:e,...t},s)=>a.jsx(me.Portal,{children:a.jsx(me.Content,{ref:s,className:Yt("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",e),...t})}));ao.displayName=me.Content.displayName;const to=te.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Item,{ref:r,className:Yt("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",e),...s}));to.displayName=me.Item.displayName;const so=te.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(me.CheckboxItem,{ref:n,className:Yt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));so.displayName=me.CheckboxItem.displayName;const ro=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(me.RadioItem,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ro.displayName=me.RadioItem.displayName;const no=te.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Label,{ref:r,className:Yt("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...s}));no.displayName=me.Label.displayName;const oo=te.forwardRef(({className:e,...t},s)=>a.jsx(me.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-border",e),...t}));oo.displayName=me.Separator.displayName;const io=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});io.displayName="ContextMenuShortcut";const lo=({onEdit:e,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:l}=j.useTranslation(),c=[];if(e){const a={icon:d.Edit,label:l("edit"),onClick:e};c.push(a)}if(o.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:r?"Inativar":"Ativar",onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("ap_delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===i?hr:to;return a.jsx(a.Fragment,{children:c.map((e,t)=>a.jsxs(u,{onClick:e.onClick,className:Yt("whitespace-normal cursor-pointer",e.destructive&&"text-destructive focus:text-destructive"),children:[a.jsx(e.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.label]},t))})},co=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:a.jsx(d.EllipsisVertical,{size:12})})}),a.jsx(pr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:a.jsx(lo,{onEdit:e?a=>{a?.stopPropagation(),e?.()}: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"})})]}),uo=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>{const{t:i}=j.useTranslation();return a.jsx(jr,{delayDuration:200,children:a.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e()},children:a.jsx(d.Pencil,{size:14})})}),a.jsx(Nr,{children:i("edit")})]}),o.map((e,t)=>{const s=e.icon;return a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e.onClick()},children:a.jsx(s,{size:14})})}),a.jsx(Nr,{children:e.label})]},t)}),r&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),r()},children:n?a.jsx(d.ToggleRight,{size:14}):a.jsx(d.ToggleLeft,{size:14})})}),a.jsx(Nr,{children:n?"Inativar":"Ativar"})]}),t&&s&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Yt("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),t()},children:a.jsx(d.Trash2,{size:14})})}),a.jsx(Nr,{children:i("ap_delete")})]})]})})},mo=150;function po({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??mo,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??mo,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??mo)},[r,n]);t.useEffect(()=>{if(!i||!d)return;const t=e.find(e=>e.key===d),r=t?.minWidth??60,n=t?.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,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(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,d,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,a)=>(e[a.key]=a.defaultWidth??mo,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}const ho=r.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"}}),xo=te.forwardRef(({className:e,variant:t,size:s,...r},n)=>a.jsx(he.Root,{ref:n,className:Yt(ho({variant:t,size:s,className:e})),...r}));xo.displayName=he.Root.displayName;const fo=te.createContext({size:"default",variant:"default"}),go=te.forwardRef(({className:e,variant:t,size:s,children:r,...n},o)=>a.jsx(pe.Root,{ref:o,className:Yt("flex items-center justify-center gap-1",e),...n,children:a.jsx(fo.Provider,{value:{variant:t,size:s},children:r})}));go.displayName=pe.Root.displayName;const vo=te.forwardRef(({className:e,children:t,variant:s,size:r,...n},o)=>{const i=te.useContext(fo);return a.jsx(pe.Item,{ref:o,className:Yt(ho({variant:i.variant||s,size:i.size||r}),e),...n,children:t})});vo.displayName=pe.Item.displayName;const bo=t.memo(function({onNew:e,newButtonLabel:t,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:l=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:x,viewMode:f,onViewModeChange:g,showViewToggle:v=!1,availableViewModes:b=["table","list","grid"],rightSlot:y,className:w}){const{t:N}=j.useTranslation(),_=c>0,C=e&&s||h.length>0,k=x||v||y,S=r&&o;return C||S||k||l&&_?a.jsxs("div",{className:Yt("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e&&s&&a.jsxs(Xt,{onClick:e,children:[a.jsx(d.Plus,{size:16,className:"mr-2"}),t||"Novo"]}),h.map((e,t)=>{const s=e.icon;return a.jsxs(Xt,{onClick:e.action,variant:e.variant||"outline",disabled:e.disabled,title:e.disabled?e.disabledReason:void 0,children:[s&&a.jsx(s,{size:16,className:"mr-2"}),e.label]},t)})]}),l&&_&&a.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[a.jsx(er,{variant:"secondary",className:"mr-1 tabular-nums",children:c}),a.jsxs(jr,{delayDuration:200,children:[u.length>0?u.map((e,t)=>{const s=e.icon,r=e.disabled;return a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Yt("h-8 w-8","destructive"===e.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:r,onClick:()=>e.action([]),children:s?a.jsx(s,{size:16}):a.jsx("span",{className:"text-xs",children:e.label[0]})})}),a.jsx(Nr,{children:e.label})]},t)}):a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:a.jsx(d.Trash2,{size:16})})}),a.jsx(Nr,{children:N("ap_delete")})]}),a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:a.jsx(d.X,{size:16})})}),a.jsx(Nr,{children:N("clear_selection")})]})]})]}),S&&a.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:a.jsxs("div",{className:"relative w-full",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),k&&a.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[x,v&&f&&g&&a.jsx(go,{type:"single",value:f,onValueChange:e=>e&&g(e),size:"sm",children:b.map(e=>{const t=(e=>{switch(e){case"table":return d.Table2;case"list":return d.List;case"grid":return d.LayoutGrid}})(e);return a.jsx(vo,{value:e,"aria-label":"Visualizar como "+("table"===e?"tabela":"list"===e?"lista":"grade"),children:a.jsx(t,{className:"h-4 w-4"})},e)})}),y]})]}):null}),jo=t.memo(({checked:e,onCheckedChange:t})=>a.jsx(Xs,{checked:e,onCheckedChange:t}),(e,a)=>e.checked===a.checked);function yo(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 wo({columns:e,storageKey:a,enabled:s=!0,defaultHiddenColumns:r}){const n=t.useMemo(()=>e.map(e=>String(e.key)),[e]),o=t.useMemo(()=>new Set(r??[]),[r]),[i,l]=t.useState(()=>{if(!s)return o;if(!a)return o;const e=yo(a);return e?.hiddenColumns??o}),[d,c]=t.useState(()=>{if(!s||!a)return n;const e=yo(a)?.columnOrder;return e&&e.length>0?e:n}),[u,m]=t.useState(()=>s&&a?yo(a)?.groupByColumns??[]:[]),[p,h]=t.useState(new Set);t.useEffect(()=>{s&&a&&function(e,a){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(a.hiddenColumns),columnOrder:a.columnOrder,groupByColumns:a.groupByColumns}))}catch{}}(a,{hiddenColumns:i,columnOrder:d,groupByColumns:u})},[i,d,u,a,s]),t.useEffect(()=>{const a=new Set(e.map(e=>String(e.key))),t=new Set(d),s=[...a].filter(e=>!t.has(e));s.length>0&&c(e=>[...e.filter(e=>a.has(e)),...s])},[e]);const x=t.useCallback(e=>i.has(e),[i]),f=t.useCallback(e=>{l(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),g=t.useCallback(()=>{l(new Set)},[]),v=t.useCallback(()=>{if(l(o),c(n),m([]),h(new Set),a)try{localStorage.removeItem(a)}catch{}},[n,o,a]),b=t.useCallback((e,a)=>{c(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s})},[]),j=t.useCallback(e=>{h(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),y=t.useCallback(e=>{m(e),h(new Set)},[]),w=t.useCallback(e=>{m(a=>a.includes(e)?a:[...a,e])},[]),N=t.useCallback(e=>{m(a=>a.filter(a=>a!==e)),h(a=>{const t=new Set;for(const s of a)s.includes(`${e}:`)||t.add(s);return t})},[]),_=t.useCallback((e,a)=>{m(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s}),h(new Set)},[]),C=u[0]??null,k=t.useCallback(e=>{m(e?[e]:[]),h(new Set)},[]),S=t.useMemo(()=>{if(!s)return e;const a=new Map(e.map(e=>[String(e.key),e]));return d.filter(e=>!i.has(e)&&a.has(e)).map(e=>a.get(e))},[e,d,i,s]),T=t.useCallback(e=>{if(0===u.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,u,0,"")},[u]);return{visibleColumns:S,allColumns:e,isColumnHidden:x,toggleColumn:f,showAllColumns:g,resetColumns:v,columnOrder:d,reorderColumns:b,groupByColumn:C,setGroupByColumn:k,groupByColumns:u,setGroupByColumns:y,addGroupByColumn:w,removeGroupByColumn:N,reorderGroupByColumns:_,getGroupedData:T,collapsedGroups:p,toggleGroupCollapse:j}}function No({enabled:e=!1,onReorder:a}){const[s,r]=t.useState(null),[n,o]=t.useState(null),i=t.useCallback(()=>{r(null),o(null)},[]),l=t.useCallback((t,n)=>({draggable:e,onDragStart:a=>{e&&(r(t),a.dataTransfer.effectAllowed="copyMove",a.dataTransfer.setData("text/plain",String(t)),n&&a.dataTransfer.setData("application/column-key",n))},onDragOver:a=>{e&&null!==s&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDragEnter:a=>{e&&null!==s&&(a.preventDefault(),o(t))},onDrop:r=>{r.preventDefault(),e&&null!==s&&s!==t?(a(s,t),i()):i()},onDragEnd:()=>{i()}}),[e,s,a,i]);return t.useMemo(()=>({dragFromIndex:s,dragOverIndex:n,isDragging:null!==s,getDragProps:l}),[s,n,l])}function _o({columns:e,columnOrder:s,isColumnHidden:r,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:l,setGroupByColumn:c,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p,resetColumns:h}){const{t:x}=j.useTranslation(),[f,g]=t.useState(null),[v,b]=t.useState(null),y=t.useRef(null),w=new Map(e.map(e=>[String(e.key),e])),N=s.filter(e=>w.has(e)).map(e=>w.get(e)),_=()=>{y.current=null,g(null),b(null)};N.some(e=>r(String(e.key)));const C=N.every(e=>!r(String(e.key)));return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsx(Xt,{variant:"outline",size:"icon",className:"h-8 w-8",children:a.jsx(d.Columns3,{size:16})})}),a.jsxs(Sr,{className:"w-[260px] p-0",align:"end",children:[a.jsx("div",{className:"px-3 py-2 border-b",children:a.jsx("span",{className:"text-sm font-medium",children:"Colunas"})}),a.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:a.jsx(jr,{delayDuration:300,children:N.map((e,t)=>{const s=String(e.key),o=r(s),h=!1!==e.hideable,j=!0===e.groupable,w=u.includes(s)||l===s;return a.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{y.current=e,g(e)})(t),onDragOver:e=>((e,a)=>{e.preventDefault(),b(a)})(e,t),onDrop:()=>(e=>{null!==y.current&&y.current!==e&&i(y.current,e),y.current=null,g(null),b(null)})(t),onDragEnd:_,className:Yt("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",f===t&&"opacity-50",v===t&&"border-t-2 border-primary"),children:[a.jsx(d.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),a.jsx(Xs,{checked:!o,onCheckedChange:()=>h&&n(s),disabled:!h,className:"shrink-0"}),a.jsx("span",{className:Yt("flex-1 truncate",o&&"text-muted-foreground"),children:e.header}),j&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Yt("h-6 w-6 shrink-0",w&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),w?p?p(s):c?.(null):m?m(s):c?.(s)},children:a.jsx(d.Group,{size:14})})}),a.jsx(Nr,{children:x(w?"remove_grouping":"group_by_column")})]})]},s)})})}),a.jsxs("div",{className:"border-t px-3 py-2 space-y-1",children:[a.jsx(Xt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:C?()=>N.filter(e=>!1!==e.hideable).forEach(e=>n(String(e.key))):o,children:x(C?"deselect_all":"select_all_columns")}),h&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:h,children:"Redefinir padrão"})]})]})]})}function Co({columns:e,groupByColumns:s,addGroupByColumn:r,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,l]=t.useState(!1),[c,u]=t.useState(null),[m,p]=t.useState(null),h=new Map(e.map(e=>[String(e.key),e])),x=()=>{u(null),p(null)},f=s.length>0;return a.jsxs("div",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",l(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},onDrop:e=>{e.preventDefault(),l(!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:Yt("flex items-center gap-2 px-4 py-2 min-h-[40px] border-b transition-colors",i&&"bg-primary/5 border-primary/30",!f&&"text-muted-foreground"),children:[a.jsx(d.Group,{size:14,className:"shrink-0 text-muted-foreground"}),a.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:f?s.map((e,s)=>{const r=h.get(e);if(!r)return null;const i=c===s,l=m===s&&c!==s;return a.jsxs(t.Fragment,{children:[s>0&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),a.jsxs(er,{variant:"secondary",className:Yt("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",l&&"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:x,children:[r.header,a.jsx("button",{onClick:a=>{a.stopPropagation(),n(e)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:a.jsx(d.X,{size:12})})]})]},e)}):a.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const ko=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:u,enableBulkActions:m=!1,rowActionsVariant:p="dropdown",onNew:h,newButtonLabel:x,showNewButton:f=!0,customActions:g=[],hideActionBar:v,showActionBar:b=!0,showSearch:y=!1,searchValue:w,onSearchChange:N,searchPlaceholder:_,bulkActions:C=[],onBulkDelete:k,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D=!1,enableColumnResize:E=!0,resizeStorageKey:A,enableColumnManager:I=!0,columnManagerStorageKey:M,defaultHiddenColumns:F,enableGrouping:R=!1,enableExpandableRows:L=!1,renderExpandedContent:z,expandedRowIds:U,onToggleExpand:O,defaultExpandAll:V=!1,hideActionsColumn:B=!1})=>{const{t:q}=j.useTranslation(),{setSearchVisible:$}=Pn(),W=An(),[H,G]=t.useState(()=>V&&L?new Set(s.entities.map(e=>e.id)):new Set),Y=void 0!==U,Q=Y?new Set(U):H,K=t.useCallback(e=>{Y&&O?O(e):G(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[Y,O]),X=void 0!==v?!v:b;t.useEffect(()=>{if(!y)return $(!0),()=>$(!1)},[$,y]);const J=wo({columns:r,storageKey:M,enabled:I,defaultHiddenColumns:F}),Z=No({enabled:I,onReorder:J.reorderColumns}),ee=I?J.visibleColumns:r,{columnWidths:ae,isDragging:te,activeColumn:se,handleMouseDown:re}=po({columns:ee.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:A?`${A}-columns`:void 0,enabled:E}),ne=t.useMemo(()=>(()=>{if(E){const e=ee.map(e=>ae[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return ee.map((t,s)=>({...t,calculatedWidth:e[s],style:{width:e[s]/a*100+"%"}}))}let e=0;const a=ee.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`}})})(),[ee,E,ae]),oe=h||g.length>0||y||m||S||D||I,ie=X&&oe,le=k||(()=>{s.bulkDelete?.(s.selectedIds)}),de=e=>a.jsx(Un,{className:"text-center",children:c?c(e):"inline"===p?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:a.jsx(uo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}):a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}),ce=e=>a.jsx(ao,{className:"w-[160px]",children:a.jsx(lo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:u?u(e):[],renderAs:"context"})}),ue=I?a.jsx(_o,{columns:r,columnOrder:J.columnOrder,isColumnHidden:J.isColumnHidden,toggleColumn:J.toggleColumn,showAllColumns:J.showAllColumns,resetColumns:J.resetColumns,reorderColumns:J.reorderColumns,groupByColumn:R?J.groupByColumn:void 0,setGroupByColumn:R?J.setGroupByColumn:void 0,groupByColumns:R?J.groupByColumns:void 0,addGroupByColumn:R?J.addGroupByColumn:void 0,removeGroupByColumn:R?J.removeGroupByColumn:void 0}):void 0;if(W)return s.isLoading?a.jsx(Bn,{count:3}):0===s.entities.length?a.jsx($n,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"}):a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(bo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:y,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D}),a.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:s.entities.map(e=>a.jsxs(Gn,{children:[a.jsx(Yn,{asChild:!0,children:a.jsx(ts,{className:Yt("overflow-hidden cursor-pointer hover:bg-muted/50",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:a.jsx(os,{className:"p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[m&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(jo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1",children:[ee.map(t=>a.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||c)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(e):a.jsx(co,{onEdit:n?()=>{n(e)}:void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})})]})]})})})}),ce(e)]},e.id))})]});const me=R&&J.groupByColumns.length>0?J.getGroupedData(s.entities):null,pe=null!==me,he=(L?1:0)+(m?1:0)+ee.length+(B?0:1),xe=e=>{const r=L&&Q.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(Gn,{children:[a.jsx(Yn,{asChild:!0,children:a.jsxs(Ln,{className:Yt("cursor-pointer hover:bg-muted/50 relative",("inline"===p||B)&&"group",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:[L&&a.jsx(Un,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),K(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":q(r?"collapse_row":"expand_row"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),m&&a.jsx(Un,{onClick:e=>e.stopPropagation(),children:a.jsx(jo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),ee.map(t=>a.jsx(Un,{className:t.className,children:a.jsx(Wn,{children:t.render?t.render(e):String(e[t.key]??"")})},String(t.key))),!B&&de(e)]})}),ce(e)]}),r&&z&&a.jsx(Ln,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(Un,{colSpan:he,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:z(e)})})})]},e.id)},fe=(e,s)=>{const{t:r}=j.useTranslation();return e.map(e=>{const r=J.collapsedGroups.has(e.groupKey),n=16*e.level,o=Math.max(30,70-15*e.level);return a.jsxs(t.Fragment,{children:[a.jsx(Ln,{className:Yt("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>J.toggleGroupCollapse(e.groupKey),children:a.jsx(Un,{colSpan:s,className:"py-2 px-4",children:a.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[r?a.jsx(d.ChevronRight,{size:16}):a.jsx(d.ChevronDown,{size:16}),a.jsx("span",{children:e.groupValue}),a.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",e.count,")"]})]})})}),!r&&(e.children?fe(e.children,s):e.items.map(xe))]},e.groupKey)})};return a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(bo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:y,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D}),s.isLoading?a.jsx(Vn,{rows:5,columns:ee.length}):a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[R&&a.jsx(Co,{columns:r,groupByColumns:J.groupByColumns,addGroupByColumn:J.addGroupByColumn,removeGroupByColumn:J.removeGroupByColumn,reorderGroupByColumns:J.reorderGroupByColumns}),a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs(In,{className:"table-fixed w-full",children:[a.jsxs("colgroup",{children:[L&&a.jsx("col",{style:{width:"40px"}}),m&&a.jsx("col",{style:{width:"50px"}}),ne.map((e,t)=>a.jsx("col",{style:e.style},t)),!B&&a.jsx("col",{style:{width:"inline"===p?"auto":"50px",minWidth:"50px"}})]}),a.jsx(Mn,{children:a.jsxs(Ln,{children:[L&&a.jsx(zn,{className:"w-[40px]"}),m&&a.jsx(zn,{className:"w-[50px]",children:a.jsx(jo,{checked:s.isAllSelected,onCheckedChange:s.selectAll})}),ee.map((e,t)=>{const r=E&&!1!==e.resizable,n=se===String(e.key),o=I?Z.getDragProps(t,String(e.key)):{},i=Z.dragFromIndex===t,l=Z.dragOverIndex===t&&Z.dragFromIndex!==t;return a.jsxs(zn,{className:Yt(e.className,!1!==e.sortable&&"hover:bg-muted/50 cursor-pointer","relative transition-opacity",I&&Z.isDragging&&"cursor-grabbing",i&&"opacity-50",l&&"border-l-2 border-primary"),onClick:!1!==e.sortable?()=>s.handleSort(String(e.key)):void 0,...o,children:[a.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,!1!==e.sortable&&(c=String(e.key),s.sortField!==c?null:"asc"===s.sortDirection?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),r&&a.jsx(Hn,{direction:"horizontal",onMouseDown:a=>re(String(e.key),a),isDragging:n})]},String(e.key));var c}),!B&&a.jsx(zn,{className:"w-[50px] text-center",children:ue||e.t("actions")})]})}),a.jsx(Fn,{children:0===s.entities.length?a.jsx(Ln,{children:a.jsx(Un,{colSpan:he,className:"h-32",children:a.jsx($n,{title:e.t("no_items_found_empty"),description:"Não há dados para exibir no momento.",variant:"search"})})}):pe?fe(me,he):s.entities.map(xe)})]})})]})]})};function So(e,a,s,r){const[n,o]=t.useState({}),[i,l]=t.useState({}),d=t.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},t=e(d),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);c(e)&&(t=e.toISOString().split("T")[0])}else c(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{t.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors: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(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),i[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const To=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Po=({value:e="#3b82f6",onChange:t,label:s,customColorLabel:r,presetColorsLabel:n})=>{const{t:o}=j.useTranslation(),i=r??o("custom_color"),l=n??o("preset_colors");return a.jsxs("div",{className:"space-y-2",children:[s&&a.jsx(as,{children:s}),a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[a.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),a.jsx(Sr,{className:"w-64",children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx(as,{htmlFor:"color-input",children:i}),a.jsx(Zt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),a.jsxs("div",{children:[a.jsx(as,{children:l}),a.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:To.map(e=>a.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]})},Do=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(xe.Root,{ref:r,className:Yt("relative overflow-hidden",e),...s,children:[a.jsx(xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(Eo,{}),a.jsx(xe.Corner,{})]}));Do.displayName=xe.Root.displayName;const Eo=te.forwardRef(({className:e,orientation:t="vertical",...s},r)=>a.jsx(xe.ScrollAreaScrollbar,{ref:r,orientation:t,className:Yt("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]",e),...s,children:a.jsx(xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Eo.displayName=xe.ScrollAreaScrollbar.displayName;const Ao=[{name:"alarm",filled:!1},{name:"account_box",filled:!0},{name:"announcement",filled:!0},{name:"assessment",filled:!0},{name:"assignment",filled:!0},{name:"bookmark",filled:!0},{name:"build",filled:!0},{name:"change_history",filled:!1},{name:"credit_card",filled:!1},{name:"date_range",filled:!0},{name:"extension",filled:!0},{name:"face",filled:!0},{name:"favorite",filled:!0},{name:"store",filled:!0},{name:"group_work",filled:!0},{name:"home",filled:!0},{name:"label",filled:!0},{name:"lightbulb_2",filled:!1},{name:"list",filled:!0},{name:"line_weight",filled:!0},{name:"question_answer",filled:!0},{name:"mode_heat",filled:!0},{name:"reorder",filled:!0},{name:"warning",filled:!0},{name:"room",filled:!0},{name:"settings",filled:!0},{name:"shopping_cart",filled:!0},{name:"work",filled:!0},{name:"star_rate",filled:!0},{name:"monetization_on",filled:!0},{name:"view_list",filled:!0},{name:"visibility",filled:!0},{name:"error",filled:!0},{name:"equalizer",filled:!0},{name:"release_alert",filled:!0},{name:"mic",filled:!0},{name:"videocam",filled:!0},{name:"call",filled:!0},{name:"chat",filled:!0},{name:"chat_bubble",filled:!0},{name:"email",filled:!0},{name:"link",filled:!0},{name:"report",filled:!0},{name:"flag",filled:!0},{name:"attach_file",filled:!0},{name:"attachment",filled:!0},{name:"attach_money",filled:!0},{name:"bubble_chart",filled:!0},{name:"folder",filled:!0},{name:"business",filled:!0},{name:"device_hub",filled:!0},{name:"flash_on",filled:!0},{name:"image",filled:!0},{name:"lens",filled:!0},{name:"photo_camera",filled:!0},{name:"style",filled:!0},{name:"view_compact",filled:!0},{name:"wb_incandescent",filled:!0},{name:"directions_bus",filled:!0},{name:"directions_car",filled:!0},{name:"flight",filled:!0},{name:"hotel",filled:!0},{name:"local_offer",filled:!0},{name:"restaurant",filled:!0},{name:"restaurant_menu",filled:!0},{name:"local_shipping",filled:!0},{name:"all_inclusive",filled:!0},{name:"business_center",filled:!0},{name:"notifications",filled:!0},{name:"share",filled:!0}];function Io({name:e,filled:t,className:s}){return a.jsx("span",{className:`material-symbols-outlined ${s??""}`,style:t?{fontVariationSettings:"'FILL' 1"}:void 0,children:e})}const Mo=({value:e=null,onChange:s,label:r,noIconLabel:n="SEM ÍCONE"})=>{const[o,i]=t.useState(!1),l=e?(c=e,Ao.find(e=>e.name===c)):null;var c;const u=e=>{s?.(e),i(!1)};return a.jsxs("div",{className:"space-y-2",children:[r&&a.jsx(as,{children:r}),a.jsxs(Cr,{open:o,onOpenChange:i,children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"justify-start text-left font-normal gap-2",children:[l?a.jsx(Io,{name:l.name,filled:l.filled,className:"text-xl text-muted-foreground"}):a.jsx("span",{className:"text-muted-foreground text-sm",children:n}),a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 opacity-50"})]})}),a.jsx(Sr,{className:"w-72 p-3",align:"start",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(Do,{className:"h-64",children:a.jsx("div",{className:"grid grid-cols-7 gap-1",children:Ao.map(t=>a.jsx("button",{type:"button",className:"flex items-center justify-center p-1.5 rounded hover:bg-accent transition-colors "+(e===t.name?"bg-primary/10 text-primary":"text-muted-foreground"),onClick:()=>u(t.name),title:t.name,children:a.jsx(Io,{name:t.name,filled:t.filled,className:"text-2xl"})},t.name))})}),a.jsx("button",{type:"button",className:"w-full py-2 text-sm font-semibold text-foreground hover:bg-accent rounded transition-colors border-t pt-3",onClick:()=>u(null),children:n})]})})]})]})},Fo=te.forwardRef(({className:e,...t},s)=>a.jsx(fe.Root,{className:Yt("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",e),...t,ref:s,children:a.jsx(fe.Thumb,{className:Yt("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")})}));Fo.displayName=fe.Root.displayName;const Ro=(e={})=>{const{user:a,alias:t}=Pn(),{enabled:s=!0,status:r="active"}=e;return w.useQuery({queryKey:["qualiex-users",t,r],queryFn:()=>mn.getUsers(t,r),enabled:s&&!!t&&!!a,staleTime:3e5,retry:2,retryDelay:1e3})},Lo=({value:s,onChange:r,multiple:n=!1,label:o,required:i,placeholder:l,icon:d,maxDisplayedBadges:c,className:u,disabled:m,enabled:p,displayFormat:h="name",customDisplayFn:x,filterFn:f,sortOptions:g=!0,popoverContainer:v,onOpen:b,onClose:y})=>{const{t:w}=j.useTranslation(),{data:N=[],isLoading:_,error:C}=Ro({enabled:p}),[k,S]=t.useState(new Map),T=t.useMemo(()=>s?Array.isArray(s)?s.filter(Boolean):[s].filter(Boolean):[],[s]),P=t.useMemo(()=>{if(0===T.length||0===N.length)return"";const e=new Set(N.map(e=>e.userId||e.id||""));return T.filter(a=>a&&!e.has(a)&&!k.has(a)).sort().join(",")},[T,N,k]);t.useEffect(()=>{if(!P)return;const e=P.split(",");let a=!1;const t=an.extractTokenData();return t?.alias&&t?.companyId?(mn.fetchUsers(t.alias,t.companyId,"all").then(t=>{a||S(a=>{const s=new Map(a);for(const r of e){const e=t.find(e=>e.userId===r||e.id===r);e&&s.set(r,{...e,isActive:e.isActive??!1})}return s})}).catch(()=>{}),()=>{a=!0}):void 0},[P]);const D=t.useMemo(()=>f?N.filter(f):N,[N,f]),E=t.useMemo(()=>{if(0===T.length)return D;const a=new Set(D.map(e=>e.userId||e.id||"")),t=T.filter(e=>e&&!a.has(e));if(0===t.length)return D;const s=t.map(a=>{const t=k.get(a);return t||{userId:a,id:a,userName:e.t("inactive_user"),userEmail:"",isActive:!1}});return[...D,...s]},[D,T,k]),A=t.useCallback(a=>{let t;if("custom"===h&&x)t=x(a);else{const e=a.userName||"";switch(h){case"name-email":t=a.userEmail?`${e} (${a.userEmail})`:e;break;case"name-role":t=a.roleName?`${e} - ${a.roleName}`:e;break;default:t=e}}return!1===a.isActive?`${t} (${e.t("inactive")})`:t},[h,x]);return a.jsx(Ur,{multiple:n,value:s??(n?[]:""),onChange:r,options:E,isLoading:_,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:A,placeholder:l||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:w("no_results"),label:o,required:i,icon:d,maxDisplayedBadges:c,disabled:m,className:u,sortOptions:g,popoverContainer:v,onOpen:b,onClose:y})};function zo({title:e,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:d=!1,usersData:c}){const[u,m]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[h,x]=t.useState(null),f=t.useCallback(e=>{p.current=e,x(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:v,errors:b,updateField:j,handleSubmit:y}=So(g,r,void 0,i),w=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(v):e.disabled||!1})):[],[s,v]),N=t.useMemo(()=>{const e=w.find(e=>e.id===u);if(e&&!e.disabled)return u;const a=w.find(e=>!e.disabled);return a?.id||u},[w,u]);t.useEffect(()=>{N!==u&&m(N)},[N,u]);const _=w.find(e=>e.id===N),C=e=>{const t=(e.computedValue,v[e.name]),s=void 0!==t?t:"",r=b[e.name];switch(e.type){case"group":const t="horizontal"===e.layout,n=t?`flex gap-3 w-full ${e.className||""}`:"space-y-3",o=t?Yt("space-y-2 w-full",e.wrapperClassName):Yt("space-y-2",e.className,e.wrapperClassName);return a.jsxs("div",{className:o,children:[e.label,a.jsx("div",{className:n,children:e.fields?.map(e=>C(e))})]},e.name);case"user-select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Lo,{value:s||"",onChange:a=>j(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-destructive":""}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"textarea":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Js,{id:e.name,value:s||"",onChange:a=>{j(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,rows:e.rows,maxLength:e.maxLength,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Vs,{value:String(s),onValueChange:a=>{j(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[a.jsx($s,{className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,children:a.jsx(qs,{placeholder:e.placeholder})}),a.jsx(Gs,{children:e.options?.map(e=>a.jsx(Qs,{value:e.value,children:e.label},e.value))})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"multiselect":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Ur,{options:e.options||[],value:Array.isArray(s)?s:[],onChange:a=>j(e.name,a),placeholder:e.placeholder,disabled:e.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"date":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"date",value:String(s),onChange:a=>j(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Yt("w-full",r?"border-destructive":"",e.disabled?"bg-muted cursor-not-allowed":"")}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"color":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"color",value:s||e.defaultValue||"#000000",onChange:a=>j(e.name,a.target.value),className:"h-10"}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Po,{value:s||e.defaultValue||"#3b82f6",onChange:a=>j(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Mo,{value:s||e.defaultValue||null,onChange:a=>j(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"custom":if(!e.component)return null;const i=e.component,l="function"==typeof e.componentProps?e.componentProps(v):e.componentProps||{};return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(i,{value:s,onChange:a=>{j(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,error:r,popoverContainer:h,...l}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"number":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"number",value:null!=s?String(s):"",onChange:a=>{const t=a.target.value,s=""===t?null:Number(t);j(e.name,s)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"checkbox":return a.jsxs("div",{className:`flex items-center space-x-2 ${e.className||""}`,children:[a.jsx(Xs,{id:e.name,checked:!!s,onCheckedChange:a=>j(e.name,a),disabled:e.disabled}),a.jsxs(as,{htmlFor:e.name,className:"cursor-pointer",children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"switch":return a.jsxs("div",{className:`flex items-center justify-between space-x-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Fo,{id:e.name,checked:!!s,onCheckedChange:a=>j(e.name,a),disabled:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},e.name);default:return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"text",value:s||"",onChange:a=>{j(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name)}},k=t.useCallback(()=>{if(!_)return null;if(_.disabled)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:a.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),a.jsx("p",{className:"text-muted-foreground max-w-sm",children:"Complete as informações obrigatórias na seção i18n.t('ap_general_info') para acessar esta seção."})]});if(_.component){const e=_.component;return a.jsx(e,{formData:v,updateField:j,errors:b,users:c,disabled:_.disabled})}return a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.fields.map(C)})},[_,v,j,b,c,C]),S=a.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[w.length>1&&a.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:a.jsx("div",{className:"flex space-x-2",children:w.map(e=>a.jsx(Xt,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=w.find(a=>a.id===e);a&&!a.disabled&&m(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):a.jsxs("form",{onSubmit:y(n),className:"space-y-3 md:space-y-4",children:[k(),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Xt,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Xt,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return a.jsx(js,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:a.jsxs(ks,{ref:f,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[a.jsxs(Ss,{showSeparator:!0,children:[a.jsx(Ds,{children:e}),a.jsx(Es,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Uo({currentPage:e,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:l}=j.useTranslation();if(0===s)return null;const c=(e-1)*r+1,u=Math.min(e*r,s);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[a.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:l("rows_per_page","Linhas por página")}),a.jsxs(Vs,{value:String(r),onValueChange:e=>o(Number(e)),children:[a.jsx($s,{className:"h-8 w-[70px]",children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Qs,{value:"10",children:"10"}),a.jsx(Qs,{value:"25",children:"25"}),a.jsx(Qs,{value:"50",children:"50"}),a.jsx(Qs,{value:"100",children:"100"})]})]})]})}),a.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," ",l("of","de")," ",s," ",l("items","itens")]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsLeft,{size:16})}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronLeft,{size:16})}),a.jsxs("div",{className:"flex items-center gap-1 px-2",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-sm text-muted-foreground",children:l("of","de")}),a.jsx("span",{className:"text-sm font-medium",children:t})]}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronRight,{size:16})}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsRight,{size:16})})]})]})}function Oo({manager:e}){return a.jsx(Uo,{currentPage:e.pagination.currentPage,totalPages:e.pagination.totalPages,totalItems:e.pagination.totalItems,itemsPerPage:e.pagination.itemsPerPage,onPageChange:e.handlePageChange,onItemsPerPageChange:e.handleItemsPerPageChange,variant:"full"})}const Vo={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Bo={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},qo={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function $o({children:e,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return a.jsx("div",{className:Yt("flex","column"===t?"flex-col":"flex-row",Vo[s],Bo[r],qo[n],o&&"flex-wrap",i),children:e})}function Wo({manager:e,filters:t,inline:s=!1}){const{t:r}=j.useTranslation(),{isSearchVisible:n}=Pn(),o=e.searchTerm,i=a.jsxs(a.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Zt,{placeholder:"Pesquisar",value:e.searchTerm,onChange:a=>e.handleSearch(a.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((e,t)=>a.jsxs(Vs,{value:e.value||"",onValueChange:a=>e.onChange?.(a),children:[a.jsx($s,{className:"w-[180px]",children:a.jsx(qs,{placeholder:e.placeholder})}),a.jsx(Gs,{children:e.options.map(e=>a.jsx(Qs,{value:e.value,children:e.label},e.value))})]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return a.jsx("div",{className:s?"":"w-full sm:w-auto",children:a.jsx(r,{...e.props})},`custom-${t}`)}),o&&a.jsxs(Xt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[a.jsx(d.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?a.jsx("div",{className:"flex items-center gap-2",children:i}):a.jsx($o,{direction:"column",gap:"md",className:"mb-6",children:a.jsx($o,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function Ho({manager:e,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){e&&e.queryKey;const{setSearchVisible:l}=Pn(),[d,c]=N.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[x,f]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,v]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&e){const a=`${e.queryKey}_sortField`,t=`${e.queryKey}_sortDirection`;if(!d.has(a)&&!d.has(t)){const e=Object.fromEntries(d);e[a]=i.column,e[t]=i.direction,c(e)}}},[]);const b=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,j="function"==typeof e?.deleteEntity?e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,y=()=>{f({isOpen:!1,entityId:null,entityName:""})},w=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,_=(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 a.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&a.jsx(bo,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:w,showSearch:s.showSearch,searchValue:e.searchTerm,onSearchChange:e.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:e.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{v({isOpen:!0,count:e.selectedIds.length})},onClearSelection:e.clearSelection,customActions:_,filters:s.filters&&s.filters.length>0?a.jsx(Wo,{manager:e,filters:s.filters,inline:!0}):void 0}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?a.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(e.entities,e)}):a.jsx(ko,{manager:e,columns:s.columns,onEdit:b,onDelete:j,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions,enableColumnManager:!0,columnManagerStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-columns`,resizeStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-resize`,defaultHiddenColumns:s.defaultHiddenColumns})}),a.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:a.jsx(Oo,{manager:e})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&a.jsx(zo,{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:e.isLoading,submitButtonText:p?"Atualizar":"Criar"}),a.jsx(js,{open:x.isOpen,onOpenChange:y,children:a.jsxs(ks,{size:"sm",variant:"destructive",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Ds,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:x.entityName}),". Esta ação não pode ser desfeita."]})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:y,children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:()=>{x.entityId&&"function"==typeof e?.deleteEntity&&(e.deleteEntity(x.entityId),f({isOpen:!1,entityId:null,entityName:""}))},disabled:e.isDeleting,children:e.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),a.jsx(js,{open:g.isOpen,onOpenChange:()=>v({isOpen:!1,count:0}),children:a.jsxs(ks,{size:"sm",variant:"destructive",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Ds,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>v({isOpen:!1,count:0}),children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:()=>{e.bulkDelete?.(e.selectedIds),v({isOpen:!1,count:0})},disabled:e.isBulkDeleting,children:e.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Go(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 Yo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Qo(e={}){const{paramName:a="alias"}=e,s=N.useParams(),{alias:r,companies:n}=Pn(),o=s[a]||null;return t.useMemo(()=>{if(!o)return{urlAlias:null,isAliasMismatch:!1,isValidAlias:!1,isMissing:!0,matchedCompany:null};const e=n?.find(e=>e.alias===o)||null,a=!!e;return{urlAlias:o,isAliasMismatch:a&&o!==r,isValidAlias:a,isMissing:!1,matchedCompany:e}},[o,r,n])}const Ko=r.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"}}),Xo={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},Jo=te.forwardRef(({className:e,variant:t="info",showIcon:s=!0,children:r,...n},o)=>{const i=Xo[t||"info"];return a.jsxs("div",{ref:o,role:"alert",className:Yt(Ko({variant:t}),e),...n,children:[s&&a.jsx(i,{className:"h-4 w-4"}),r]})});Jo.displayName="Alert";const Zo=te.forwardRef(({className:e,...t},s)=>a.jsx("h5",{ref:s,className:Yt("mb-1 font-medium leading-none tracking-tight",e),...t}));Zo.displayName="AlertTitle";const ei=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("text-sm [&_p]:leading-relaxed",e),...t}));ei.displayName="AlertDescription";const ai=t.createContext(void 0);function ti({children:e,actions:s}){const{t:r}=j.useTranslation(),[n,o]=t.useState({}),[i,l]=t.useState(s);t.useEffect(()=>{l(s)},[s]);const d=t.useCallback(()=>o({}),[]),c=t.useMemo(()=>({metadata:n,setMetadata:o,clearMetadata:d,headerActions:i,setHeaderActions:l}),[n,d,i]);return a.jsx(ai.Provider,{value:c,children:e})}function si(){const e=t.useContext(ai);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var ri={actions:"Ações",activate:"Ativar",add_first_item:"Adicione seu primeiro item para começar",add_item:"Adicionar Item",advanced_filter:"Filtro avançado",all:"Todos",allow:"Permitir",allowed_items:"Itens permitidos",also_discover:"Conheça também",alt_text:"Texto Alternativo",anonymous:"Anônimo",ap_action_plan:"Plano de Ação",ap_action_type:"Tipo de Ação",ap_add:"Adicionar",ap_add_comment_placeholder:"Adicionar comentário...",ap_add_cost:"Adicionar custo",ap_add_predecessor:"Adicionar predecessor",ap_attachments:"Anexos",ap_belongs_to:"Pertence a",ap_cause:"Causa",ap_change_status:"Alterar Status",ap_checker:"Verificador",ap_clear:"Limpar",ap_comments:"Comentários",ap_cost_description:"Descrição do custo",ap_costs:"Custos",ap_delete:"Excluir",ap_description:"Descrição",ap_description_placeholder:"Descreva o plano de ação",ap_duration_days:"Duração (dias)",ap_edit_progress:"Editar Progresso",ap_end_date:"Data de Término",ap_estimated_cost:"Custo Estimado",ap_file_duplicate:"Arquivo duplicado",ap_file_upload_error:"Erro ao enviar arquivo",ap_general:"Geral",ap_general_info:"Informações Gerais",ap_history:"Histórico",ap_justification:"Justificativa",ap_justification_placeholder:"Justificativa do plano de ação",ap_name:"Nome",ap_new_action:"Nova Ação",ap_no_attachments:"Nenhum anexo",ap_no_comments:"Nenhum comentário",ap_no_costs:"Nenhum custo registrado",ap_no_history:"Nenhum registro no histórico",ap_no_predecessors:"Nenhum predecessor adicionado",ap_no_progress:"Sem dados de progresso disponíveis",ap_overall_progress:"Progresso geral",ap_place:"Local",ap_plan_name_placeholder:"Nome do plano de ação",ap_predecessors:"Predecessores",ap_priority:"Prioridade",ap_priority_high:"Alta",ap_priority_low:"Baixa",ap_priority_medium:"Média",ap_progress:"Progresso",ap_progress_comment_placeholder:"Adicione um comentário sobre o progresso",ap_progress_percent:"Progresso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progresso",ap_reporting:"Reportando...",ap_reports_history:"Histórico de reportes",ap_responsible:"Responsável",ap_select_action:"Selecione uma ação",ap_select_cause:"Selecione a causa",ap_select_checker:"Selecione o verificador",ap_select_date:"Selecione a data",ap_select_parent:"Selecione a ação pai",ap_select_place:"Selecione o local",ap_select_priority:"Selecione a prioridade",ap_select_responsible:"Selecione o responsável",ap_select_type:"Selecione o tipo",ap_start_date:"Data de Início",ap_status_canceled:"Cancelada",ap_status_done:"Concluída",ap_status_effectiveness_check:"Verificação de eficácia",ap_status_running:"Em andamento",ap_status_suspended:"Suspensa",ap_status_waiting_start:"Aguardando início",ap_time_label:"Tempo",ap_time_spent:"Tempo gasto (HH:MM)",ap_total_cost:"Custo total realizado",ap_total_time:"Tempo total",ap_type_corrective:"Corretiva",ap_type_immediate:"Imediata",ap_type_improvement:"Oportunidade de Melhoria",ap_type_preventive:"Preventiva",ap_type_standardization:"Padronização",ap_value:"Valor (R$)",ap_via_app:"Via app",approval_approve:"Aprovar",approval_execute_action:"Executar ação",approval_opinion:"Parecer *",approval_read_less:"Ler menos",approval_read_more:"Ler mais",approval_reprove_radio:"Reprovar e retornar para etapa",approval_search_approver:"Buscar aprovador...",approval_select_approver:"Selecionar aprovador",approval_select_approver_placeholder:"Selecione um aprovador...",approval_select_step:"Selecione a etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuários",audit_description:"Descrição",audit_esign:"Assinatura eletrônica",audit_not_informed:"Não informado",audit_references:"Referências",audit_security:"Segurança",audit_trail:"Trilha de Auditoria",auth_error:"Erro durante a autenticação. Tente novamente.",auth_failed:"Falha na autenticação. Tente novamente.",auto_login:"Fazendo login automático...",back:"Voltar",bulk_delete_error:"Erro ao excluir itens em lote",bulk_delete_success:"Itens excluídos com sucesso",cancel:"Cancelar",change_photo:"Trocar foto",cannot_be_own_leader:"Um líder não pode ser seu próprio superior",clear_filters:"Limpar filtros",clear_formatting:"Limpar Formatação",clear_search:"Limpar busca",clear_selection:"Limpar seleção",close:"Fechar",collapse_row:"Recolher linha",columns:"Colunas",conclude:"Concluir",confirm_removal:"Confirmar remoção",could_not_load_info:"Não foi possível carregar as informações",current:"Atual",custom_color:"Cor personalizada",dashboard_advanced_filter:"Filtro avançado",dashboard_all_access:"Todos os colaboradores terão acesso",dashboard_average:"Média",dashboard_code:"Código",dashboard_distinct_count:"Contagem distinta",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Sair do fullscreen",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabela",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Meus dashboards",dashboard_new:"Novo Dashboard",dashboard_no_data:"A consulta não retornou itens para o seu perfil.",dashboard_no_refresh:"Não atualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"Não compartilhado",dashboard_only_mine:"Somente meus",dashboard_only_overdue:"Somente atrasados",dashboard_only_responsible:"Somente o responsável terá acesso",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remover favorito",dashboard_responsible:"Responsável",dashboard_select_groups:"Selecione grupos, locais e colaboradores específicos",dashboard_shared_unit:"Compartilhado com todos os colaboradores da unidade",dashboard_status:"Situação",dashboard_title:"Título",dashboard_wait_refresh:"Aguarde para atualizar novamente",dashboard_work_done:"Trabalho executado",dashboard_work_planned:"Trabalho planejado",deactivate:"Inativar",deselect_all:"Deselecionar todas",dev_login:"Login Desenvolvimento",download:"Download",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nome",electronic_signature:"Assinatura Eletrônica",embed_code:"Código embed",embedded_content:"Embedded content",enter_code:"Digite o código",enter_password:"Digite sua senha",error_authentication:"Erro de Autenticação",error_connection:"Erro de Conexão",error_copied_clipboard:"Os detalhes do erro foram copiados para a área de transferência.",error_loading:"Erro ao carregar",error_loading_data:"Erro ao carregar dados",error_session_expired:"Sessão Expirada",error_token_expired:"Token de autenticação expirado. Faça login novamente.",esign_code_description:"Um código de verificação foi enviado para o seu e-mail. Insira o código abaixo para confirmar a operação.",esign_code_error:"Erro ao validar o código. Tente novamente.",esign_invalid_code:"Código inválido. Tente novamente.",esign_invalid_password:"Senha incorreta. Tente novamente.",esign_password_description:"Digite sua senha para confirmar a operação.",esign_password_error:"Erro ao validar a senha. Tente novamente.",esign_resend_error:"Erro ao reenviar o código.",expand_row:"Expandir linha",expiration_date:"Data de expiração",file_error:"Erro no arquivo",file_upload:"Upload de arquivo",go_to_next_page:"Ir para próxima página",go_to_previous_page:"Ir para página anterior",group_by_column:"Agrupar por esta coluna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descrição da imagem",import_flows:"Fluxos de Importação",import_manage:"Gerencie seus fluxos de importação",inactive:"inativo",inactive_user:"[Usuário inativo]",input_type:"Tipo de entrada",invalid_form:"Formulário inválido. Preencha todos os campos obrigatórios.",italic:"Itálico",item_details:"Detalhes do item",items:"itens",items_per_page:"Itens por página",know_saber_gestao:"Conheça o Saber Gestão",know_staff:"Conheça Staff",language:"Idioma",last_update:"Última atualização",leader:"Líder",leader_create_error:"Erro ao criar líder",leader_not_found:"Líder não encontrado",leader_promoted_success:"Líder promovido com sucesso",leader_remove_error:"Erro ao remover líder",leader_removed_success:"Líder removido com sucesso",leader_update_error:"Erro ao atualizar líder",leader_updated_success:"Líder atualizado com sucesso",leadership_add_root:"Adicionar Líder Raiz",leadership_add_subordinate:"Adicionar Liderado",leadership_cycle_error:"Esta associação criaria um ciclo na hierarquia",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Imediato",leadership_make_root:"Tornar Líder Raiz",leadership_make_root_short:"Tornar Raiz",leadership_no_hierarchy:"Nenhuma hierarquia de liderança encontrada.",leadership_no_members:"Nenhum membro na equipe",leadership_no_user_selected:"Nenhum usuário selecionado",leadership_no_users_available:"Nenhum usuário disponível",leadership_no_users_found:"Nenhum usuário encontrado",leadership_remove_team:"Remover da equipe",leadership_select_subordinates:"Selecione pelo menos um liderado",learn_qualiex:"Aprenda a usar o Qualiex",leave_without_saving:"Sair sem salvar",lines_per_page:"Linhas por página",link:"Link",login_with_qualiex:"Entrar com Qualiex",manage_access:"Gerenciar Acessos",modules:"Módulos",more_options:"Mais opções",msg_create_error:"Erro ao criar registro",msg_created_success:"Registro criado com sucesso",msg_delete_error:"Erro ao excluir registro",msg_deleted_success:"Registro excluído com sucesso",msg_load_error:"Erro ao carregar dados",msg_update_error:"Erro ao atualizar registro",msg_updated_success:"Registro atualizado com sucesso",new_document:"Novo Documento",new_folder:"Nova Pasta",new_item:"Novo Item",next:"Próximo",no_access_page:"Parece que você não tem acesso a essa página",no_data_to_display:"Não há dados para exibir no momento.",no_errors_recorded:"Nenhum erro registrado",no_image_selected:"Nenhuma imagem selecionada",no_item_selected:"Nenhum item selecionado",no_items_found:"Nenhum item encontrado",no_items_found_empty:"Nenhum item encontrado",no_place_found:"Nenhum local encontrado",no_place_selected:"Sem local",no_products:"Sem produtos",no_reports_found:"Nenhum relatório encontrado",no_results:"Nenhum resultado encontrado",no_search_results:"Nenhum resultado para a busca",no_video_selected:"Nenhum vídeo selecionado",not_authenticated:"Não autenticado",not_available:"Não disponível",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Cole o código embed aqui",permissions:"Permissões",preset_colors:"Cores predefinidas",preview:"Visualizar",redirecting_auth:"Redirecionando para autenticação...",refresh_data:"Atualizar dados",remove:"Remover",remove_grouping:"Remover agrupamento",replace:"Substituir",report:"Relatório",request_date:"Data da solicitação",required_field:"Campo obrigatório",resend_code:"Reenviar código",restricted_access:"Acesso restrito",rows_per_page:"Registros por página",save:"Salvar",save_as_draft:"Salvar como Rascunho",save_as_template:"Salvar como Modelo",saving:"Salvando...",search:"Pesquisar",search_placeholder:"Pesquisar...",search_report_placeholder:"Buscar relatório...",search_user_placeholder:"Buscar usuário...",select_all:"Selecionar todos",select_all_columns:"Selecionar todas",select_all_items:"Selecionar todos",select_at_least_one:"Selecione pelo menos um item",select_at_least_one_item:"Selecione ao menos um item",select_date:"Selecione uma data",select_file_format:"Selecione o formato do arquivo",select_items_to_add:"Selecione itens para adicionar...",select_placeholder:"Selecione...",selected:"Selecionados",session_expired:"Sua sessão expirou. Você será redirecionado para fazer login novamente.",sign_access_error:"Erro ao acessar serviço de assinatura",sign_api_key_info:"Informe a API Key do provedor de assinatura",sign_api_key_input:"Insira a API Key do provedor de assinatura",sign_api_key_placeholder:"Insira a chave de API",sign_api_key_required:"Chave de API obrigatória",sign_attempt:"Tentativa de assinatura",sign_auth_required:"Autenticação necessária para assinar",sign_click_to_select:"Clique para selecionar documento",sign_config_save_err:"Erro ao salvar configuração de assinatura",sign_config_save_error:"Erro ao salvar configuração de assinatura",sign_config_saved:"Configuração de assinatura salva",sign_config_saved_success:"Configuração de assinatura salva com sucesso",sign_configured:"Assinatura configurada",sign_configured_unit:"Assinatura digital configurada para esta unidade",sign_digital_config:"Configuração de Assinatura Digital",sign_doc_available:"Documento assinado disponível para download",sign_doc_load_error:"Erro ao carregar documento",sign_doc_process_error:"Erro ao processar documento",sign_doc_sent:"Documento enviado para assinatura",sign_download_signed:"Baixar documento assinado",sign_email_fallback:"E-mail de fallback para assinatura",sign_environment:"Ambiente de assinatura",sign_fetch_failed:"Falha ao buscar documento assinado",sign_file_not_allowed:"Extensão de arquivo não permitida",sign_file_type_not_allowed:"Tipo de arquivo não permitido",sign_incorrect_data:"O signatário reportou dados incorretos.",sign_login_required:"Login necessário para assinar",sign_login_to_sign:"Faça login para utilizar a assinatura digital.",sign_monthly_limit:"Limite mensal de assinaturas atingido",sign_no_access:"Não foi possível obter o acesso para assinatura. Tente novamente.",sign_not_configured:"Assinatura não configurada",sign_not_configured_unit:"Assinatura digital ainda não configurada para esta unidade",sign_preparing_doc:"Preparando documento para assinatura",sign_process_error:"Erro ao processar assinatura",sign_save_config:"Salvar configuração",sign_save_config_btn:"Salvar Configuração",sign_select_pdf:"Selecione um arquivo PDF",sign_sending_doc:"Enviando documento para assinatura",sign_signed_success:"Documento assinado com sucesso",sign_signer_unavailable:"Signer ID não disponível",sign_try_again:"Tentar novamente",sign_update_config:"Atualizar configuração",sign_update_config_btn:"Atualizar Configuração",sign_waiting_provider:"Aguardando provedor de assinatura",sign_widget_error:"Erro no widget de assinatura",something_went_wrong:"Algo deu errado",state:"Estado",status:"Status",status_completed:"Concluído",status_error:"Erro",status_expired:"Expirado",status_processing:"Processando",status_waiting:"Aguardando",steps:"Etapas",subordinates_add_error:"Erro ao adicionar subordinados",subordinates_added_success:"Subordinados adicionados com sucesso",subordinates_sync_error:"Erro ao sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados com sucesso",team_all_groups:"Todos os grupos",terms_confirm_reading:"Confirmar leitura",terms_confirmation_available:"Confirmação disponível em",terms_of_use:"Termos de Uso",terms_read_agree:"Li e concordo",terms_see_later:"Ver depois",terms_updated:"Termos de Uso Atualizados",terms_view:"Visualizar termo de uso",terms_view_short:"View term",try_adjust_search:"Tente ajustar sua busca",try_again:"Tentar Novamente",unit_not_selected:"Nenhuma unidade selecionada",unknown_error:"Erro desconhecido",unsaved_changes:"Alterações não salvas",unsaved_changes_description:"Existem alterações não salvas. Deseja sair sem salvar?",updates:"Atualizações",user:"Usuário",user_info:"Informações do Usuário",user_photo:"Foto do usuário",users_already_leaders:"Usuários já são líderes",verification_code:"Código de verificação",video:"Vídeo",video_title:"Título do vídeo",view_report:"Visualizar relatório",want_to_know_more:"Quero conhecer mais",write_content_here:"Escreva o conteúdo aqui..."},ni={actions:"Actions",activate:"Activate",add_first_item:"Add your first item to get started",add_item:"Add Item",advanced_filter:"Advanced filter",all:"All",allow:"Allow",allowed_items:"Allowed items",also_discover:"Also discover",alt_text:"Alternative Text",anonymous:"Anonymous",ap_action_plan:"Action Plan",ap_action_type:"Action type",ap_add:"Add",ap_add_comment_placeholder:"Add a comment...",ap_add_cost:"Add cost",ap_add_predecessor:"Add predecessor",ap_attachments:"Attachments",ap_belongs_to:"Belongs to",ap_cause:"Cause",ap_change_status:"Change Status",ap_checker:"Checker",ap_clear:"Clear",ap_comments:"Comments",ap_cost_description:"Cost description",ap_costs:"Costs",ap_delete:"Delete",ap_description:"Description",ap_description_placeholder:"Describe the action plan",ap_duration_days:"Duration (days)",ap_edit_progress:"Edit Progress",ap_end_date:"End date",ap_estimated_cost:"Estimated cost",ap_file_duplicate:"Duplicate file",ap_file_upload_error:"Error uploading file",ap_general:"General",ap_general_info:"General Information",ap_history:"History",ap_justification:"Justification",ap_justification_placeholder:"Action plan justification",ap_name:"Name",ap_new_action:"New Action",ap_no_attachments:"No attachments",ap_no_comments:"No comments",ap_no_costs:"No costs recorded",ap_no_history:"No history records",ap_no_predecessors:"No predecessors added",ap_no_progress:"No progress data available",ap_overall_progress:"Overall progress",ap_place:"Place",ap_plan_name_placeholder:"Action plan name",ap_predecessors:"Predecessors",ap_priority:"Priority",ap_priority_high:"High",ap_priority_low:"Low",ap_priority_medium:"Medium",ap_progress:"Progress",ap_progress_comment_placeholder:"Add a comment about the progress",ap_progress_percent:"Progress (%)",ap_report:"Report",ap_report_progress:"Report progress",ap_reporting:"Reporting...",ap_reports_history:"Reports history",ap_responsible:"Responsible",ap_select_action:"Select an action",ap_select_cause:"Select cause",ap_select_checker:"Select checker",ap_select_date:"Select date",ap_select_parent:"Select parent action",ap_select_place:"Select place",ap_select_priority:"Select priority",ap_select_responsible:"Select responsible",ap_select_type:"Select type",ap_start_date:"Start date",ap_status_canceled:"Canceled",ap_status_done:"Completed",ap_status_effectiveness_check:"Effectiveness check",ap_status_running:"In progress",ap_status_suspended:"Suspended",ap_status_waiting_start:"Waiting to start",ap_time_label:"Time",ap_time_spent:"Time spent (HH:MM)",ap_total_cost:"Total realized cost",ap_total_time:"Total time",ap_type_corrective:"Corrective",ap_type_immediate:"Immediate",ap_type_improvement:"Improvement Opportunity",ap_type_preventive:"Preventive",ap_type_standardization:"Standardization",ap_value:"Value",ap_via_app:"Via app",approval_approve:"Approve",approval_execute_action:"Execute action",approval_opinion:"Opinion *",approval_read_less:"Read less",approval_read_more:"Read more",approval_reprove_radio:"Reject and return to step",approval_search_approver:"Search approver...",approval_select_approver:"Select approver",approval_select_approver_placeholder:"Select an approver...",approval_select_step:"Select the step",approval_step_label:"Step",approval_user_group:"User group",audit_description:"Description",audit_esign:"Electronic signature",audit_not_informed:"Not informed",audit_references:"References",audit_security:"Security",audit_trail:"Audit Trail",auth_error:"Error during authentication. Try again.",auth_failed:"Authentication failed. Try again.",auto_login:"Logging in automatically...",back:"Back",bulk_delete_error:"Error deleting items in bulk",bulk_delete_success:"Items deleted successfully",cancel:"Cancel",change_photo:"Change photo",cannot_be_own_leader:"A leader cannot be their own superior",clear_filters:"Clear filters",clear_formatting:"Clear Formatting",clear_search:"Clear search",clear_selection:"Clear selection",close:"Close",collapse_row:"Collapse row",columns:"Columns",conclude:"Finish",confirm_removal:"Confirm removal",could_not_load_info:"Could not load the information",current:"Current",custom_color:"Custom color",dashboard_advanced_filter:"Advanced filter",dashboard_all_access:"All collaborators will have access",dashboard_average:"Average",dashboard_code:"Code",dashboard_distinct_count:"Distinct count",dashboard_edit:"Edit Dashboard",dashboard_exit_fullscreen:"Exit fullscreen",dashboard_export_chart:"Export chart",dashboard_export_table:"Export table",dashboard_max_value:"Maximum value",dashboard_min_value:"Minimum value",dashboard_my:"My dashboards",dashboard_new:"New Dashboard",dashboard_no_data:"The query returned no items for your profile.",dashboard_no_refresh:"Do not refresh",dashboard_normal_page:"Normal page",dashboard_not_shared:"Not shared",dashboard_only_mine:"Only mine",dashboard_only_overdue:"Only overdue",dashboard_only_responsible:"Only the responsible will have access",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remove favorite",dashboard_responsible:"Responsible",dashboard_select_groups:"Select groups, places and specific collaborators",dashboard_shared_unit:"Shared with all unit collaborators",dashboard_status:"Status",dashboard_title:"Title",dashboard_wait_refresh:"Wait to refresh again",dashboard_work_done:"Work done",dashboard_work_planned:"Work planned",deactivate:"Deactivate",deselect_all:"Deselect all",dev_login:"Development Login",download:"Download",edit:"Edit",edit_profile:"Edit Profile",edit_name:"Edit Name",electronic_signature:"Electronic Signature",embed_code:"Embed code",embedded_content:"Embedded content",enter_code:"Enter the code",enter_password:"Enter your password",error_authentication:"Authentication Error",error_connection:"Connection Error",error_copied_clipboard:"Error details were copied to the clipboard.",error_loading:"Error loading",error_loading_data:"Error loading data",error_session_expired:"Session Expired",error_token_expired:"Authentication token expired. Please log in again.",esign_code_description:"A verification code was sent to your email. Enter the code below to confirm the operation.",esign_code_error:"Error validating code. Try again.",esign_invalid_code:"Invalid code. Try again.",esign_invalid_password:"Incorrect password. Try again.",esign_password_description:"Enter your password to confirm the operation.",esign_password_error:"Error validating password. Try again.",esign_resend_error:"Error resending code.",expand_row:"Expand row",expiration_date:"Expiration date",file_error:"File error",file_upload:"File upload",go_to_next_page:"Go to next page",go_to_previous_page:"Go to previous page",group_by_column:"Group by this column",heading_1:"Heading 1",heading_2:"Heading 2",heading_3:"Heading 3",image_description:"Image description",import_flows:"Import Flows",import_manage:"Manage your import flows",inactive:"inactive",inactive_user:"[Inactive user]",input_type:"Input type",invalid_form:"Invalid form. Fill in all required fields.",italic:"Italic",item_details:"Item details",items:"items",items_per_page:"Items per page",know_saber_gestao:"Discover Saber Gestão",know_staff:"Discover Staff",language:"Language",last_update:"Last update",leader:"Leader",leader_create_error:"Error creating leader",leader_not_found:"Leader not found",leader_promoted_success:"Leader promoted successfully",leader_remove_error:"Error removing leader",leader_removed_success:"Leader removed successfully",leader_update_error:"Error updating leader",leader_updated_success:"Leader updated successfully",leadership_add_root:"Add Root Leader",leadership_add_subordinate:"Add Subordinate",leadership_cycle_error:"This association would create a cycle in the hierarchy",leadership_define_leader:"Define Leader",leadership_immediate_superior:"Immediate Superior",leadership_make_root:"Make Root Leader",leadership_make_root_short:"Make Root",leadership_no_hierarchy:"No leadership hierarchy found.",leadership_no_members:"No team members",leadership_no_user_selected:"No user selected",leadership_no_users_available:"No users available",leadership_no_users_found:"No users found",leadership_remove_team:"Remove from team",leadership_select_subordinates:"Select at least one subordinate",learn_qualiex:"Learn how to use Qualiex",leave_without_saving:"Leave without saving",lines_per_page:"Lines per page",link:"Link",login_with_qualiex:"Login with Qualiex",manage_access:"Manage Access",modules:"Modules",more_options:"More options",msg_create_error:"Error creating record",msg_created_success:"Record created successfully",msg_delete_error:"Error deleting record",msg_deleted_success:"Record deleted successfully",msg_load_error:"Error loading data",msg_update_error:"Error updating record",msg_updated_success:"Record updated successfully",new_document:"New Document",new_folder:"New Folder",new_item:"New Item",next:"Next",no_access_page:"It seems you don't have access to this page",no_data_to_display:"No data to display at this time.",no_errors_recorded:"No errors recorded",no_image_selected:"No image selected",no_item_selected:"No item selected",no_items_found:"No items found",no_items_found_empty:"No items found",no_place_found:"No place found",no_place_selected:"No place",no_products:"No products",no_reports_found:"No reports found",no_results:"No results found",no_search_results:"No results for the search",no_video_selected:"No video selected",not_authenticated:"Not authenticated",not_available:"Not available",of:"of",open_popover:"Open Popover",open_wiki:"Open Wiki",ordered_list:"Ordered List",page:"Page",paste_embed_code:"Paste the embed code here",permissions:"Permissions",preset_colors:"Preset colors",preview:"Preview",redirecting_auth:"Redirecting to authentication...",refresh_data:"Refresh data",remove:"Remove",remove_grouping:"Remove grouping",replace:"Replace",report:"Report",request_date:"Request date",required_field:"Required field",resend_code:"Resend code",restricted_access:"Restricted access",rows_per_page:"Rows per page",save:"Save",save_as_draft:"Save as Draft",save_as_template:"Save as Template",saving:"Saving...",search:"Search",search_placeholder:"Search...",search_report_placeholder:"Search report...",search_user_placeholder:"Search user...",select_all:"Select all",select_all_columns:"Select all",select_all_items:"Select all",select_at_least_one:"Select at least one item",select_at_least_one_item:"Select at least one item",select_date:"Select a date",select_file_format:"Select the file format",select_items_to_add:"Select items to add...",select_placeholder:"Select...",selected:"Selected",session_expired:"Your session has expired. You will be redirected to log in again.",sign_access_error:"Error accessing signature service",sign_api_key_info:"Enter the signature provider API Key",sign_api_key_input:"Enter the signature provider API Key",sign_api_key_placeholder:"Enter API key",sign_api_key_required:"API key is required",sign_attempt:"Signature attempt",sign_auth_required:"Authentication required to sign",sign_click_to_select:"Click to select document",sign_config_save_err:"Error saving signature configuration",sign_config_save_error:"Error saving signature configuration",sign_config_saved:"Signature configuration saved",sign_config_saved_success:"Signature configuration saved successfully",sign_configured:"Signature configured",sign_configured_unit:"Digital signature configured for this unit",sign_digital_config:"Digital Signature Configuration",sign_doc_available:"Signed document available for download",sign_doc_load_error:"Error loading document",sign_doc_process_error:"Error processing document",sign_doc_sent:"Document sent for signature",sign_download_signed:"Download signed document",sign_email_fallback:"Signature fallback email",sign_environment:"Signature environment",sign_fetch_failed:"Failed to fetch signed document",sign_file_not_allowed:"File extension not allowed",sign_file_type_not_allowed:"File type not allowed",sign_incorrect_data:"The signer reported incorrect data.",sign_login_required:"Login required to sign",sign_login_to_sign:"Log in to use the digital signature.",sign_monthly_limit:"Monthly signature limit reached",sign_no_access:"Could not obtain access for signing. Try again.",sign_not_configured:"Signature not configured",sign_not_configured_unit:"Digital signature not yet configured for this unit",sign_preparing_doc:"Preparing document for signature",sign_process_error:"Error processing signature",sign_save_config:"Save configuration",sign_save_config_btn:"Save Configuration",sign_select_pdf:"Select a PDF file",sign_sending_doc:"Sending document for signature",sign_signed_success:"Document signed successfully",sign_signer_unavailable:"Signer ID not available",sign_try_again:"Try again",sign_update_config:"Update configuration",sign_update_config_btn:"Update Configuration",sign_waiting_provider:"Waiting for signature provider",sign_widget_error:"Signature widget error",something_went_wrong:"Something went wrong",state:"State",status:"Status",status_completed:"Completed",status_error:"Error",status_expired:"Expired",status_processing:"Processing",status_waiting:"Waiting",steps:"Steps",subordinates_add_error:"Error adding subordinates",subordinates_added_success:"Subordinates added successfully",subordinates_sync_error:"Error syncing subordinates",subordinates_synced_success:"Subordinates synced successfully",team_all_groups:"All groups",terms_confirm_reading:"Confirm reading",terms_confirmation_available:"Confirmation available at",terms_of_use:"Terms of Use",terms_read_agree:"I have read and agree",terms_see_later:"See later",terms_updated:"Terms of Use Updated",terms_view:"View terms of use",terms_view_short:"View term",try_adjust_search:"Try adjusting your search",try_again:"Try Again",unit_not_selected:"No unit selected",unknown_error:"Unknown error",unsaved_changes:"Unsaved changes",unsaved_changes_description:"There are unsaved changes. Do you want to leave without saving?",updates:"Updates",user:"User",user_info:"User Information",user_photo:"User photo",users_already_leaders:"Users are already leaders",verification_code:"Verification code",video:"Video",video_title:"Video title",view_report:"View report",want_to_know_more:"I want to know more",write_content_here:"Write content here..."},oi={actions:"Acciones",activate:"Activar",add_first_item:"Agregue su primer elemento para comenzar",add_item:"Agregar Elemento",advanced_filter:"Filtro avanzado",all:"Todos",allow:"Permitir",allowed_items:"Elementos permitidos",also_discover:"Conozca también",alt_text:"Texto Alternativo",anonymous:"Anónimo",ap_action_plan:"Plan de Acción",ap_action_type:"Tipo de acción",ap_add:"Agregar",ap_add_comment_placeholder:"Agregar comentario...",ap_add_cost:"Agregar costo",ap_add_predecessor:"Agregar predecesor",ap_attachments:"Anexos",ap_belongs_to:"Pertenece a",ap_cause:"Causa",ap_change_status:"Cambiar Estado",ap_checker:"Verificador",ap_clear:"Limpiar",ap_comments:"Comentarios",ap_cost_description:"Descripción del costo",ap_costs:"Costos",ap_delete:"Eliminar",ap_description:"Descripción",ap_description_placeholder:"Describa el plan de acción",ap_duration_days:"Duración (días)",ap_edit_progress:"Editar Progreso",ap_end_date:"Fecha de finalización",ap_estimated_cost:"Costo estimado",ap_file_duplicate:"Archivo duplicado",ap_file_upload_error:"Error al subir archivo",ap_general:"General",ap_general_info:"Información General",ap_history:"Historial",ap_justification:"Justificación",ap_justification_placeholder:"Justificación del plan de acción",ap_name:"Nombre",ap_new_action:"Nueva Acción",ap_no_attachments:"Sin anexos",ap_no_comments:"Sin comentarios",ap_no_costs:"Ningún costo registrado",ap_no_history:"Sin registros en el historial",ap_no_predecessors:"Sin predecesores agregados",ap_no_progress:"Sin datos de progreso disponibles",ap_overall_progress:"Progreso general",ap_place:"Lugar",ap_plan_name_placeholder:"Nombre del plan de acción",ap_predecessors:"Predecesores",ap_priority:"Prioridad",ap_priority_high:"Alta",ap_priority_low:"Baja",ap_priority_medium:"Media",ap_progress:"Progreso",ap_progress_comment_placeholder:"Agregue un comentario sobre el progreso",ap_progress_percent:"Progreso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progreso",ap_reporting:"Reportando...",ap_reports_history:"Historial de reportes",ap_responsible:"Responsable",ap_select_action:"Seleccione una acción",ap_select_cause:"Seleccione la causa",ap_select_checker:"Seleccione el verificador",ap_select_date:"Seleccione la fecha",ap_select_parent:"Seleccione la acción padre",ap_select_place:"Seleccione el lugar",ap_select_priority:"Seleccione la prioridad",ap_select_responsible:"Seleccione el responsable",ap_select_type:"Seleccione el tipo",ap_start_date:"Fecha de inicio",ap_status_canceled:"Cancelada",ap_status_done:"Completada",ap_status_effectiveness_check:"Verificación de eficacia",ap_status_running:"En progreso",ap_status_suspended:"Suspendida",ap_status_waiting_start:"Esperando inicio",ap_time_label:"Tiempo",ap_time_spent:"Tiempo dedicado (HH:MM)",ap_total_cost:"Costo total realizado",ap_total_time:"Tiempo total",ap_type_corrective:"Correctiva",ap_type_immediate:"Inmediata",ap_type_improvement:"Oportunidad de Mejora",ap_type_preventive:"Preventiva",ap_type_standardization:"Estandarización",ap_value:"Valor",ap_via_app:"Vía app",approval_approve:"Aprobar",approval_execute_action:"Ejecutar acción",approval_opinion:"Opinión *",approval_read_less:"Leer menos",approval_read_more:"Leer más",approval_reprove_radio:"Rechazar y retornar a etapa",approval_search_approver:"Buscar aprobador...",approval_select_approver:"Seleccionar aprobador",approval_select_approver_placeholder:"Seleccione un aprobador...",approval_select_step:"Seleccione la etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuarios",audit_description:"Descripción",audit_esign:"Firma electrónica",audit_not_informed:"No informado",audit_references:"Referencias",audit_security:"Seguridad",audit_trail:"Pista de Auditoría",auth_error:"Error durante la autenticación. Intente de nuevo.",auth_failed:"Fallo en la autenticación. Intente de nuevo.",auto_login:"Iniciando sesión automáticamente...",back:"Volver",bulk_delete_error:"Error al eliminar elementos en lote",bulk_delete_success:"Elementos eliminados exitosamente",cancel:"Cancelar",change_photo:"Cambiar foto",cannot_be_own_leader:"Un líder no puede ser su propio superior",clear_filters:"Limpiar filtros",clear_formatting:"Limpiar Formato",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",close:"Cerrar",collapse_row:"Contraer fila",columns:"Columnas",conclude:"Concluir",confirm_removal:"Confirmar eliminación",could_not_load_info:"No se pudo cargar la información",current:"Actual",custom_color:"Color personalizado",dashboard_advanced_filter:"Filtro avanzado",dashboard_all_access:"Todos los colaboradores tendrán acceso",dashboard_average:"Promedio",dashboard_code:"Código",dashboard_distinct_count:"Conteo distinto",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Salir de pantalla completa",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabla",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Mis dashboards",dashboard_new:"Nuevo Dashboard",dashboard_no_data:"La consulta no devolvió elementos para su perfil.",dashboard_no_refresh:"No actualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"No compartido",dashboard_only_mine:"Solo míos",dashboard_only_overdue:"Solo atrasados",dashboard_only_responsible:"Solo el responsable tendrá acceso",dashboard_open_query:"Abrir consulta",dashboard_remove_favorite:"Quitar favorito",dashboard_responsible:"Responsable",dashboard_select_groups:"Seleccione grupos, lugares y colaboradores específicos",dashboard_shared_unit:"Compartido con todos los colaboradores de la unidad",dashboard_status:"Situación",dashboard_title:"Título",dashboard_wait_refresh:"Espere para actualizar nuevamente",dashboard_work_done:"Trabajo ejecutado",dashboard_work_planned:"Trabajo planificado",deactivate:"Desactivar",deselect_all:"Deseleccionar todas",dev_login:"Login Desarrollo",download:"Descargar",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nombre",electronic_signature:"Firma Electrónica",embed_code:"Código embed",embedded_content:"Contenido embebido",enter_code:"Ingrese el código",enter_password:"Ingrese su contraseña",error_authentication:"Error de Autenticación",error_connection:"Error de Conexión",error_copied_clipboard:"Los detalles del error se copiaron al portapapeles.",error_loading:"Error al cargar",error_loading_data:"Error al cargar datos",error_session_expired:"Sesión Expirada",error_token_expired:"Token de autenticación expirado. Inicie sesión nuevamente.",esign_code_description:"Un código de verificación fue enviado a su correo. Ingrese el código a continuación para confirmar la operación.",esign_code_error:"Error al validar el código. Intente de nuevo.",esign_invalid_code:"Código inválido. Intente de nuevo.",esign_invalid_password:"Contraseña incorrecta. Intente de nuevo.",esign_password_description:"Ingrese su contraseña para confirmar la operación.",esign_password_error:"Error al validar la contraseña. Intente de nuevo.",esign_resend_error:"Error al reenviar el código.",expand_row:"Expandir fila",expiration_date:"Fecha de expiración",file_error:"Error en el archivo",file_upload:"Subir archivo",go_to_next_page:"Ir a la página siguiente",go_to_previous_page:"Ir a la página anterior",group_by_column:"Agrupar por esta columna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descripción de la imagen",import_flows:"Flujos de Importación",import_manage:"Gestione sus flujos de importación",inactive:"inactivo",inactive_user:"[Usuario inactivo]",input_type:"Tipo de entrada",invalid_form:"Formulario inválido. Complete todos los campos obligatorios.",italic:"Itálica",item_details:"Detalles del elemento",items:"elementos",items_per_page:"Elementos por página",know_saber_gestao:"Conozca Saber Gestión",know_staff:"Conozca Staff",language:"Idioma",last_update:"Última actualización",leader:"Líder",leader_create_error:"Error al crear líder",leader_not_found:"Líder no encontrado",leader_promoted_success:"Líder promovido exitosamente",leader_remove_error:"Error al eliminar líder",leader_removed_success:"Líder eliminado exitosamente",leader_update_error:"Error al actualizar líder",leader_updated_success:"Líder actualizado exitosamente",leadership_add_root:"Agregar Líder Raíz",leadership_add_subordinate:"Agregar Subordinado",leadership_cycle_error:"Esta asociación crearía un ciclo en la jerarquía",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Inmediato",leadership_make_root:"Hacer Líder Raíz",leadership_make_root_short:"Hacer Raíz",leadership_no_hierarchy:"No se encontró jerarquía de liderazgo.",leadership_no_members:"Ningún miembro en el equipo",leadership_no_user_selected:"Ningún usuario seleccionado",leadership_no_users_available:"Ningún usuario disponible",leadership_no_users_found:"Ningún usuario encontrado",leadership_remove_team:"Quitar del equipo",leadership_select_subordinates:"Seleccione al menos un subordinado",learn_qualiex:"Aprenda a usar Qualiex",leave_without_saving:"Salir sin guardar",lines_per_page:"Líneas por página",link:"Enlace",login_with_qualiex:"Iniciar sesión con Qualiex",manage_access:"Gestionar Accesos",modules:"Módulos",more_options:"Más opciones",msg_create_error:"Error al crear registro",msg_created_success:"Registro creado exitosamente",msg_delete_error:"Error al eliminar registro",msg_deleted_success:"Registro eliminado exitosamente",msg_load_error:"Error al cargar datos",msg_update_error:"Error al actualizar registro",msg_updated_success:"Registro actualizado exitosamente",new_document:"Nuevo Documento",new_folder:"Nueva Carpeta",new_item:"Nuevo Elemento",next:"Siguiente",no_access_page:"Parece que no tienes acceso a esta página",no_data_to_display:"No hay datos para mostrar en este momento.",no_errors_recorded:"Sin errores registrados",no_image_selected:"Ninguna imagen seleccionada",no_item_selected:"Ningún elemento seleccionado",no_items_found:"No se encontraron elementos",no_items_found_empty:"Ningún elemento encontrado",no_place_found:"Ningún lugar encontrado",no_place_selected:"Sin lugar",no_products:"Sin productos",no_reports_found:"Ningún informe encontrado",no_results:"No se encontraron resultados",no_search_results:"Sin resultados para la búsqueda",no_video_selected:"Ningún vídeo seleccionado",not_authenticated:"No autenticado",not_available:"No disponible",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Pegue el código embed aquí",permissions:"Permisos",preset_colors:"Colores predefinidos",preview:"Vista previa",redirecting_auth:"Redirigiendo a autenticación...",refresh_data:"Actualizar datos",remove:"Eliminar",remove_grouping:"Quitar agrupación",replace:"Reemplazar",report:"Informe",request_date:"Fecha de solicitud",required_field:"Campo obligatorio",resend_code:"Reenviar código",restricted_access:"Acceso restringido",rows_per_page:"Registros por página",save:"Guardar",save_as_draft:"Guardar como Borrador",save_as_template:"Guardar como Plantilla",saving:"Guardando...",search:"Buscar",search_placeholder:"Buscar...",search_report_placeholder:"Buscar informe...",search_user_placeholder:"Buscar usuario...",select_all:"Seleccionar todo",select_all_columns:"Seleccionar todas",select_all_items:"Seleccionar todos",select_at_least_one:"Seleccione al menos un elemento",select_at_least_one_item:"Seleccione al menos un elemento",select_date:"Seleccione una fecha",select_file_format:"Seleccione el formato del archivo",select_items_to_add:"Seleccione elementos para agregar...",select_placeholder:"Seleccionar...",selected:"Seleccionados",session_expired:"Su sesión ha expirado. Será redirigido para iniciar sesión nuevamente.",sign_access_error:"Error al acceder al servicio de firma",sign_api_key_info:"Ingrese la API Key del proveedor de firma",sign_api_key_input:"Ingrese la API Key del proveedor de firma",sign_api_key_placeholder:"Ingrese la clave de API",sign_api_key_required:"Clave de API obligatoria",sign_attempt:"Intento de firma",sign_auth_required:"Autenticación requerida para firmar",sign_click_to_select:"Haga clic para seleccionar documento",sign_config_save_err:"Error al guardar configuración de firma",sign_config_save_error:"Error al guardar configuración de firma",sign_config_saved:"Configuración de firma guardada",sign_config_saved_success:"Configuración de firma guardada exitosamente",sign_configured:"Firma configurada",sign_configured_unit:"Firma digital configurada para esta unidad",sign_digital_config:"Configuración de Firma Digital",sign_doc_available:"Documento firmado disponible para descarga",sign_doc_load_error:"Error al cargar documento",sign_doc_process_error:"Error al procesar documento",sign_doc_sent:"Documento enviado para firma",sign_download_signed:"Descargar documento firmado",sign_email_fallback:"Correo de respaldo para firma",sign_environment:"Ambiente de firma",sign_fetch_failed:"Error al obtener documento firmado",sign_file_not_allowed:"Extensión de archivo no permitida",sign_file_type_not_allowed:"Tipo de archivo no permitido",sign_incorrect_data:"El firmante reportó datos incorrectos.",sign_login_required:"Inicio de sesión requerido para firmar",sign_login_to_sign:"Inicie sesión para usar la firma digital.",sign_monthly_limit:"Límite mensual de firmas alcanzado",sign_no_access:"No se pudo obtener acceso para firma. Intente de nuevo.",sign_not_configured:"Firma no configurada",sign_not_configured_unit:"Firma digital aún no configurada para esta unidad",sign_preparing_doc:"Preparando documento para firma",sign_process_error:"Error al procesar firma",sign_save_config:"Guardar configuración",sign_save_config_btn:"Guardar Configuración",sign_select_pdf:"Seleccione un archivo PDF",sign_sending_doc:"Enviando documento para firma",sign_signed_success:"Documento firmado exitosamente",sign_signer_unavailable:"ID del firmante no disponible",sign_try_again:"Intentar de nuevo",sign_update_config:"Actualizar configuración",sign_update_config_btn:"Actualizar Configuración",sign_waiting_provider:"Esperando proveedor de firma",sign_widget_error:"Error en el widget de firma",something_went_wrong:"Algo salió mal",state:"Estado",status:"Estado",status_completed:"Completado",status_error:"Error",status_expired:"Expirado",status_processing:"Procesando",status_waiting:"Esperando",steps:"Etapas",subordinates_add_error:"Error al agregar subordinados",subordinates_added_success:"Subordinados agregados exitosamente",subordinates_sync_error:"Error al sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados exitosamente",team_all_groups:"Todos los grupos",terms_confirm_reading:"Confirmar lectura",terms_confirmation_available:"Confirmación disponible en",terms_of_use:"Términos de Uso",terms_read_agree:"He leído y acepto",terms_see_later:"Ver después",terms_updated:"Términos de Uso Actualizados",terms_view:"Ver términos de uso",terms_view_short:"Ver término",try_adjust_search:"Intente ajustar su búsqueda",try_again:"Intentar de Nuevo",unit_not_selected:"Ninguna unidad seleccionada",unknown_error:"Error desconocido",unsaved_changes:"Cambios sin guardar",unsaved_changes_description:"Hay cambios sin guardar. ¿Desea salir sin guardar?",updates:"Actualizaciones",user:"Usuario",user_info:"Información del Usuario",user_photo:"Foto del usuario",users_already_leaders:"Los usuarios ya son líderes",verification_code:"Código de verificación",video:"Video",video_title:"Título del vídeo",view_report:"Ver informe",want_to_know_more:"Quiero conocer más",write_content_here:"Escriba el contenido aquí..."};const ii="true"===(void 0).VITE_I18N_DEBUG_MODE;function li(a,t){e.addResourceBundle(a,"app",t,!0,!0)}ii&&e.use({type:"postProcessor",name:"debugKeys",process:(e,a)=>`🔑 ${Array.isArray(a)?a[0]:a}`}),e.use(j.initReactI18next).init({resources:{"pt-BR":{core:ri},"en-US":{core:ni},"es-ES":{core:oi}},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,postProcess:ii?["debugKeys"]:[]});const di=t.createContext(void 0),ci={locale:At,timezone:Mt,datetimeFormat:It},ui=async()=>{},mi=({children:e})=>a.jsx(di.Provider,{value:{...ci,setLocale:ui,setTimezone:ui,setDatetimeFormat:ui,isLoading:!1},children:e}),pi=()=>{const e=t.useContext(di);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},hi=t.createContext({moduleAlias:null});function xi({moduleAlias:e=null,children:t}){return a.jsx(hi.Provider,{value:{moduleAlias:e},children:t})}function fi(){return t.useContext(hi)}const gi=ge.Root,vi=ge.CollapsibleTrigger,bi=ge.CollapsibleContent;class ji extends t.Component{constructor(a){super(a),this.copyErrorDetails=()=>{const a=tn.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||e.t("unknown_error")}\n\nStack Trace:\n${this.state.error?.stack||e.t("not_available")}\n\n=== ÚLTIMOS ERROS ===\n${a.map((e,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||e.t("no_errors_recorded")}\n `.trim();navigator.clipboard.writeText(t),l.toast.success("Detalhes copiados!",{description:e.t("error_copied_clipboard")})},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;tn.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=tn.getErrors().slice(0,2);return a.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:a.jsxs(ts,{className:"w-full max-w-2xl",children:[a.jsxs(ss,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),a.jsx(rs,{children:e.t("something_went_wrong")})]}),a.jsxs(os,{className:"space-y-4",children:[a.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),a.jsxs(gi,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[a.jsx(vi,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),a.jsxs(bi,{className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),a.jsxs("div",{className:"text-sm space-y-2",children:[a.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||e.t("unknown_error")}),this.state.error?.stack&&a.jsx(Do,{className:"h-32 w-full rounded border bg-muted p-2",children:a.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&a.jsxs("div",{className:"pt-3 border-t",children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),a.jsx("div",{className:"space-y-2",children:t.map((e,t)=>a.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),a.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),a.jsxs(Xt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),a.jsx(Xt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const yi=ve.Root,wi=te.forwardRef(({className:e,...t},s)=>a.jsx(ve.List,{ref:s,className:Yt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));wi.displayName=ve.List.displayName;const Ni=te.forwardRef(({className:e,...t},s)=>a.jsx(ve.Trigger,{ref:s,className:Yt("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",e),...t}));Ni.displayName=ve.Trigger.displayName;const _i=te.forwardRef(({className:e,...t},s)=>a.jsx(ve.Content,{ref:s,className:Yt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function Ci({className:e}){return a.jsxs("svg",{className:e,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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 ki({className:e}){return a.jsxs("svg",{className:e,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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"})]})}_i.displayName=ve.Content.displayName;const Si="forlogic_";function Ti(){return"undefined"!=typeof window&&"function"==typeof window.clarity}function Pi(){return"undefined"!=typeof window&&"piggyback"===window.__forlogicClarityMode}function Di(e){return Pi()?`${Si}${e}`:e}function Ei(e){return Pi()?`${Si}${e}`:e}function Ai(e){try{e()}catch(a){(void 0).DEV}}function Ii(e){for(const[a,t]of Object.entries(e))null!=t&&""!==t&&E.setTag(Ei(a),t)}function Mi({module:e,isContracted:a,sourceModule:t,alias:s}){Ti()&&Ai(()=>{Ii({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:String(a),source_module:t,alias:s}),E.event(Di("module_menu_click"))})}function Fi({module:e,sourceModule:a,alias:t}){Ti()&&Ai(()=>{Ii({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:"false",source_module:a,alias:t}),E.event(Di("module_interest_click"))})}function Ri({resource:e,sourceModule:a,alias:t}){Ti()&&Ai(()=>{Ii({footer_resource:e,source_module:a,alias:t}),E.event(Di("module_footer_click"))})}function Li({educaUrl:e="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:t="https://sabergestao.com.br/",wikiUrl:s,alias:r,sourceModule:n}){const{t:o}=j.useTranslation(),i=Gt(e||s||"https://educacao.sabergestao.com.br/{alias}/fe",r),l=e=>{Ri({resource:e,sourceModule:n,alias:r})};return a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[a.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-white",children:o("learn_qualiex")}),a.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",onClick:()=>l("educa"),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",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(Ci,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:o("know_saber_gestao")}),a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:()=>l("saber-gestao"),className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(ki,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),a.jsxs("a",{href:s||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",onClick:()=>l("wiki"),className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(d.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}const zi=[{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/{alias}"},{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/{alias}"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",softwareAlias:"performance",url:"https://desempenho.sabergestao.com.br/{alias}"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",softwareAlias:"education",url:"https://educacao.sabergestao.com.br/{alias}"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",softwareAlias:"pdi",url:"https://pdi.sabergestao.com.br/{alias}"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",softwareAlias:"pulse",url:"https://nr1pulso.sabergestao.com.br/{alias}"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",softwareAlias:"staff",url:"https://treinamentos.sabergestao.com.br/{alias}"}]},{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={alias}"},{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={alias}"},{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 Ui({module:e,onClick:t}){return a.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:[a.jsx("div",{className:Yt("w-4 h-4 rounded-sm shrink-0 mt-0.5",e.color)}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:e.name}),e.description&&a.jsx("div",{className:"text-sm text-muted-foreground truncate",children:e.description})]})]})}function Oi(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 Vi({modules:e,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=[...e].sort((e,a)=>e.name.localeCompare(a.name)),l=void 0!==r,d=l?i.filter(e=>r.includes(e.name)):i,c=l?i.filter(e=>!r.includes(e.name)):[],u=Oi(d,o),m=Oi(c,o),p=(e,a)=>{a?s?.(e):n?.(e)};return a.jsxs("div",{className:"space-y-6",children:[u.length>0&&a.jsx("section",{children:a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(e=>a.jsx(Ui,{module:e,onClick:()=>p(e,!0)},e.name))})}),m.length>0&&a.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(e=>a.jsx(Ui,{module:e,onClick:()=>p(e,!1)},e.name))})]})]})}function Bi({onModuleClick:e,contractedModules:s,onModuleInterest:r,nonContractedUrl:n="https://qualiex.com/",educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,alias:d,sourceModule:c}){const[u,m]=t.useState("qualiex"),p=e=>{Fi({module:e,sourceModule:c,alias:d}),window.open(n,"_blank","noopener,noreferrer"),r?.(e)};return a.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[a.jsxs(yi,{value:u,onValueChange:m,className:"flex-1 flex flex-col min-h-0",children:[a.jsx(wi,{className:"w-fit shrink-0",children:zi.map(e=>a.jsxs(Ni,{value:e.id,children:[e.label,a.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),zi.map(t=>a.jsx(_i,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:a.jsx(Vi,{modules:t.modules,onModuleClick:a=>{return r=a,n=t.id,Mi({module:r,isContracted:"qualiex"!==n||!s||s.includes(r.name),sourceModule:c,alias:d}),void e?.(r);var r,n},contractedModules:"qualiex"===t.id?s:void 0,onModuleInterest:p})},t.id))]}),a.jsx(Li,{educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:d,sourceModule:c})]})}const qi={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},$i=6e5;function Wi(e){const{moduleAlias:a}=fi(),{alias:s,user:r,isAuthenticated:n}=Pn(),o=e??a,i=r?.id??null,l=n&&!!s&&!!i,{data:d=[],isLoading:c}=w.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>mn.fetchUserAssociations(i,s),enabled:l,staleTime:$i,gcTime:12e5}),u=t.useMemo(()=>s&&0!==d.length?d.find(e=>e.companyAlias===s)??null:null,[d,s]),m=t.useCallback(e=>{if(!u)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const a=qi[e];return void 0!==a&&u.softwares.includes(a)})},[u]);return{hasAccess:t.useMemo(()=>!o||m(o),[o,m]),isLoading:l&&c,role:t.useMemo(()=>u?{id:u.roleId,name:u.roleName}:null,[u]),association:u,hasAccessTo:m}}function Hi(e){const{association:a}=Wi();return t.useMemo(()=>{if(e)return e;if(!a?.softwares)return;const t=a.softwares,s=zi.find(e=>"qualiex"===e.id);return s?s.modules.filter(e=>{if(!e.softwareAlias)return!1;const a=qi[e.softwareAlias];return void 0!==a&&t.includes(a)}).map(e=>e.name):void 0},[e,a])}function Gi({open:e,onOpenChange:t,onModuleClick:s,contractedModules:r,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:d}){const{alias:c}=Pn(),u=Hi(r);return a.jsx(js,{open:e,onOpenChange:t,children:a.jsxs(ks,{size:"lg",className:"overflow-hidden flex flex-col",children:[a.jsx(Ss,{className:"sr-only",children:a.jsx(Ds,{children:"Módulos"})}),a.jsx(Bi,{onModuleClick:e=>{s?s(e):e.url&&Ht(Gt(e.url,c||void 0))},contractedModules:u,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:c||void 0,sourceModule:d})]})})}function Yi({open:s,onOpenChange:r,onModuleClick:n,contractedModules:o,onModuleInterest:i,userName:l,unitName:c,units:u=[],currentAlias:m,onUnitChange:p,onLogout:h,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,blocking:v=!0,size:b="lg",children:y,sourceModule:w}){const{t:N}=j.useTranslation(),_=t.useMemo(()=>{if(!u.length)return[];const e=new Map;u.forEach(a=>e.set(a.alias,a));const a=Array.from(e.values()),t=a.find(e=>e.alias===m),s=a.filter(e=>e.alias!==m).sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"}));return t?[t,...s]:s},[u,m]);return a.jsx(js,{open:s,onOpenChange:v?void 0:r,children:a.jsxs(ks,{size:b,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:v?e=>e.preventDefault():void 0,onEscapeKeyDown:v?e=>e.preventDefault():void 0,children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[a.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[a.jsx(Ds,{children:N("no_access_page")}),a.jsx(Es,{children:"Selecione um módulo para continuar navegando!"})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.length>1&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[a.jsx(d.Building2,{className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate text-xs",children:c||"Unidade"}),a.jsx(d.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),a.jsx(pr,{align:"end",className:"max-h-[300px] overflow-auto",children:_.map(e=>a.jsxs(hr,{onClick:()=>p?.(e),className:e.alias===m?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate",children:e.name}),e.alias===m&&a.jsx(er,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},e.alias))})]}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"gap-2",children:[a.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:a.jsx(d.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),a.jsx(d.ChevronDown,{className:"h-3 w-3"})]})}),a.jsxs(pr,{align:"end",children:[a.jsxs("div",{className:"px-2 py-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:l||e.t("user")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:c})]}),a.jsx(vr,{}),a.jsxs(hr,{onClick:h,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),y?a.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[a.jsx("div",{className:"flex-1",children:y}),a.jsx(Li,{educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:w})]}):a.jsx(Bi,{onModuleClick:n,contractedModules:o,onModuleInterest:i,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:w})]})})}function Qi(e,a){const{t:t}=j.useTranslation();return a.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a)}function Ki({children:e,contractedModules:s,onModuleClick:r,onModuleInterest:n,educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:d,accessDeniedRoutes:c,sourceModule:u}){const{t:m}=j.useTranslation(),{hasAccess:p,isLoading:h,association:x}=Wi(),{user:f,alias:g,companies:v,isAuthenticated:b,isLoading:y,logout:w,switchUnit:N}=Pn(),_=Hi(s),C=t.useMemo(()=>v?.length?g&&v.find(e=>e.alias===g)||v[0]:null,[v,g]),k=t.useMemo(()=>v?.length?v.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[v]),S=t.useCallback(e=>{const a=v?.find(a=>a.alias===e.alias);if(!a)return;const{pathname:t,search:s,hash:r}=window.location;if(g){const e=t.split("/"),n=e.indexOf(g);if(n>=0)return e[n]=a.alias,void(window.location.href=e.join("/")+s+r)}N(a)},[g,N,v]),T=t.useCallback(e=>{r?r(e):e.url&&Ht(Gt(e.url,g||void 0))},[r,g]),P=t.useMemo(()=>{if(!c)return;const e=window.location.pathname,a=Object.keys(c).find(a=>Qi(e,[a]));return a?c[a]:void 0},[c]);return y||!b||d?.length&&Qi(window.location.pathname,d)?a.jsx(a.Fragment,{children:e}):h?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsx(tr,{size:"lg"})}):p?a.jsx(a.Fragment,{children:e}):a.jsx(Yi,{open:!0,onModuleClick:T,contractedModules:_,onModuleInterest:n,userName:f?.name,unitName:C?.name,units:k,currentAlias:g||void 0,onUnitChange:S,onLogout:w,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:u,blocking:!0,children:P})}let Xi=!1;function Ji(){if(Xi||"undefined"==typeof document)return;Xi=!0;for(const a of["https://fonts.googleapis.com","https://fonts.gstatic.com"])if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=a,a.includes("gstatic")&&(e.crossOrigin="anonymous"),document.head.appendChild(e)}const e=["https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap","https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap"];for(const a of e)if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=a,document.head.appendChild(e)}}function Zi({projectId:e,mode:a="auto"}){const{user:s,alias:r,isAuthenticated:n}=Pn();t.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==a&&e&&!ze()&&!window.__forlogicClarityOwned)if("function"!=typeof window.clarity)try{E.init(e),window.__forlogicClarityOwned=!0,window.__forlogicClarityMode="owned"}catch(t){(void 0).DEV,window.__forlogicClarityMode="inactive"}else window.__forlogicClarityMode="piggyback"},[e,a]),t.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==a&&n&&s&&"function"==typeof window.clarity)try{const e=s.email||s.identifier||"anonymous";E.identify(e,void 0,"modules-menu",s.name||void 0),r&&E.setTag("alias",r),"boolean"==typeof s.isSysAdmin&&E.setTag("isSysAdmin",String(s.isSysAdmin))}catch(e){(void 0).DEV}},[s,r,n,a])}function el({projectId:e,mode:a}){return Zi({projectId:e,mode:a}),null}const al=be.Root,tl=te.forwardRef(({className:e,...t},s)=>a.jsx(be.Item,{ref:s,className:Yt("border-b",e),...t}));tl.displayName="AccordionItem";const sl=te.forwardRef(({className:e,children:t,...s},r)=>a.jsx(be.Header,{className:"flex",children:a.jsxs(be.Trigger,{ref:r,className:Yt("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...s,children:[t,a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));sl.displayName=be.Trigger.displayName;const rl=te.forwardRef(({className:e,children:t,...s},r)=>a.jsx(be.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:a.jsx("div",{className:Yt("pb-4 pt-0",e),children:t})}));rl.displayName=be.Content.displayName;const nl=te.forwardRef(({className:e,...t},s)=>a.jsx(je.Root,{ref:s,className:Yt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));nl.displayName=je.Root.displayName;const ol=te.forwardRef(({className:e,...t},s)=>a.jsx(je.Image,{ref:s,className:Yt("aspect-square h-full w-full",e),...t}));ol.displayName=je.Image.displayName;const il=te.forwardRef(({className:e,...t},s)=>a.jsx(je.Fallback,{ref:s,className:Yt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));il.displayName=je.Fallback.displayName;const ll=te.forwardRef(({...e},t)=>a.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));ll.displayName="Breadcrumb";const dl=te.forwardRef(({className:e,...t},s)=>a.jsx("ol",{ref:s,className:Yt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));dl.displayName="BreadcrumbList";const cl=te.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Yt("inline-flex items-center gap-1.5",e),...t}));cl.displayName="BreadcrumbItem";const ul=te.forwardRef(({asChild:e,className:t,...r},n)=>{const o=e?s.Slot:"a";return a.jsx(o,{ref:n,className:Yt("transition-colors hover:text-foreground",t),...r})});ul.displayName="BreadcrumbLink";const ml=te.forwardRef(({className:e,...t},s)=>a.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Yt("font-normal text-foreground",e),...t}));ml.displayName="BreadcrumbPage";const pl=({children:e,className:t,...s})=>a.jsx("li",{role:"presentation","aria-hidden":"true",className:Yt("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:e??a.jsx(d.ChevronRight,{})});pl.displayName="BreadcrumbSeparator";const hl=({className:e,...t})=>a.jsxs("span",{role:"presentation","aria-hidden":"true",className:Yt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Mais"})]});hl.displayName="BreadcrumbEllipsis";const xl=r.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"}}),fl=te.forwardRef(({className:e,orientation:t,...s},r)=>a.jsx("div",{ref:r,className:Yt(xl({orientation:t}),e),...s}));function gl({className:e,classNames:t,showOutsideDays:s=!0,...r}){return a.jsx(M.DayPicker,{showOutsideDays:s,className:Yt("p-3 pointer-events-auto",e),locale:Tt,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:Yt(Kt({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Yt(Kt({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:Yt(Kt({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:e})=>"left"===e?a.jsx(d.ChevronLeft,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}fl.displayName="ButtonGroup",gl.displayName="Calendar";const vl={Root:function({children:e,className:t}){return a.jsx("div",{className:Yt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:s}){return a.jsx(ts,{className:Yt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:a.jsx(os,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:s}){return a.jsxs("div",{className:Yt("flex justify-between items-center text-sm",s),children:[a.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),a.jsx("span",{className:"text-foreground",children:t})]})}};function bl({date:e,onDateChange:t,placeholder:s,disabled:r=!1,className:n,disabledDates:o}){const{t:l}=j.useTranslation(),c=s??l("select_date");return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",disabled:r,className:Yt("w-full justify-start text-left font-normal",!e&&"text-muted-foreground",n),children:[a.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),e?i.format(e,"d 'de' MMMM 'de' yyyy",{locale:Tt}):a.jsx("span",{children:c})]})}),a.jsx(Sr,{className:"w-auto p-0",align:"start",children:a.jsx(gl,{mode:"single",selected:e,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const jl=({shouldScaleBackground:e=!0,...t})=>a.jsx(F.Drawer.Root,{shouldScaleBackground:e,...t});jl.displayName="Drawer";const yl=F.Drawer.Trigger,wl=F.Drawer.Portal,Nl=F.Drawer.Close,_l=te.forwardRef(({className:e,...t},s)=>a.jsx(F.Drawer.Overlay,{ref:s,className:Yt("fixed inset-0 z-50 bg-black/80",e),...t}));_l.displayName=F.Drawer.Overlay.displayName;const Cl=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(wl,{children:[a.jsx(_l,{}),a.jsxs(F.Drawer.Content,{ref:r,className:Yt("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",e),...s,children:[a.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));Cl.displayName="DrawerContent";const kl=({className:e,...t})=>a.jsx("div",{className:Yt("grid gap-1.5 p-4 text-center sm:text-left",e),...t});kl.displayName="DrawerHeader";const Sl=({className:e,...t})=>a.jsx("div",{className:Yt("mt-auto flex flex-col gap-2 p-4",e),...t});Sl.displayName="DrawerFooter";const Tl=te.forwardRef(({className:e,...t},s)=>a.jsx(F.Drawer.Title,{ref:s,className:Yt("text-lg font-semibold leading-none tracking-tight",e),...t}));Tl.displayName=F.Drawer.Title.displayName;const Pl=te.forwardRef(({className:e,...t},s)=>a.jsx(F.Drawer.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Pl.displayName=F.Drawer.Description.displayName;const Dl={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))]"},El={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Al=ye.Root,Il=ye.Trigger,Ml=te.forwardRef(({className:e,align:t="center",sideOffset:s=4,...r},n)=>a.jsx(ye.Content,{ref:n,align:t,sideOffset:s,className:Yt("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",e),...r}));Ml.displayName=ye.Content.displayName;const Fl=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-slot":"input-group",className:Yt("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",e),...t}));Fl.displayName="InputGroup";const Rl=r.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"}}),Ll=te.forwardRef(({className:e,align:t,...s},r)=>a.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Yt(Rl({align:t}),e),...s}));Ll.displayName="InputGroupAddon";const zl=r.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"}}),Ul=te.forwardRef(({className:e,size:t,variant:s="ghost",...r},n)=>a.jsx(Xt,{ref:n,"data-slot":"input-group-button",variant:s,className:Yt(zl({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",e),...r}));Ul.displayName="InputGroupButton";const Ol=te.forwardRef(({className:e,...t},s)=>a.jsx(Zt,{ref:s,"data-slot":"input-group-control",className:Yt("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Ol.displayName="InputGroupInput";const Vl=te.forwardRef(({className:e,...t},s)=>a.jsx(Js,{ref:s,"data-slot":"input-group-control",className:Yt("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Vl.displayName="InputGroupTextarea";const Bl=te.forwardRef(({className:e,...t},s)=>a.jsx("h1",{ref:s,className:Yt("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",e),...t}));Bl.displayName="H1";const ql=te.forwardRef(({className:e,...t},s)=>a.jsx("h2",{ref:s,className:Yt("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",e),...t}));ql.displayName="H2";const $l=te.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Yt("scroll-m-20 text-2xl font-semibold tracking-tight",e),...t}));$l.displayName="H3";const Wl=te.forwardRef(({className:e,...t},s)=>a.jsx("h4",{ref:s,className:Yt("scroll-m-20 text-xl font-semibold tracking-tight",e),...t}));Wl.displayName="H4";const Hl=te.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("leading-7 [&:not(:first-child)]:mt-6",e),...t}));Hl.displayName="P";const Gl=te.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("text-xl text-muted-foreground",e),...t}));Gl.displayName="Lead";const Yl=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("text-lg font-semibold",e),...t}));Yl.displayName="Large";const Ql=te.forwardRef(({className:e,...t},s)=>a.jsx("small",{ref:s,className:Yt("text-sm font-medium leading-none",e),...t}));Ql.displayName="Small";const Kl=te.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Kl.displayName="Muted";const Xl=te.forwardRef(({className:e,...t},s)=>a.jsx("code",{ref:s,className:Yt("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",e),...t}));Xl.displayName="InlineCode";const Jl=te.forwardRef(({className:e,...t},s)=>a.jsx("blockquote",{ref:s,className:Yt("mt-6 border-l-2 pl-6 italic",e),...t}));Jl.displayName="Blockquote";const Zl=te.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Yt("my-6 ml-6 list-disc [&>li]:mt-2",e),...t}));Zl.displayName="List";const ed=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(we.Root,{ref:r,className:Yt("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...s,children:[t,a.jsx(id,{})]}));ed.displayName=we.Root.displayName;const ad=te.forwardRef(({className:e,...t},s)=>a.jsx(we.List,{ref:s,className:Yt("group flex flex-1 list-none items-center justify-center space-x-1",e),...t}));ad.displayName=we.List.displayName;const td=we.Item,sd=r.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"),rd=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(we.Trigger,{ref:r,className:Yt(sd(),"group",e),...s,children:[t," ",a.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));rd.displayName=we.Trigger.displayName;const nd=te.forwardRef(({className:e,...t},s)=>a.jsx(we.Content,{ref:s,className:Yt("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 ",e),...t}));nd.displayName=we.Content.displayName;const od=we.Link,id=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:Yt("absolute left-0 top-full flex justify-center"),children:a.jsx(we.Viewport,{className:Yt("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)]",e),ref:s,...t})}));id.displayName=we.Viewport.displayName;const ld=te.forwardRef(({className:e,...t},s)=>a.jsx(we.Indicator,{ref:s,className:Yt("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",e),...t,children:a.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));ld.displayName=we.Indicator.displayName;const dd=({className:e,...t})=>a.jsx("nav",{role:"navigation","aria-label":"pagination",className:Yt("mx-auto flex w-full justify-center",e),...t});dd.displayName="Pagination";const cd=te.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Yt("flex flex-row items-center gap-1",e),...t}));cd.displayName="PaginationContent";const ud=te.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Yt("",e),...t}));ud.displayName="PaginationItem";const md=({className:e,isActive:t,size:s="icon",...r})=>a.jsx("a",{"aria-current":t?"page":void 0,className:Yt(Kt({variant:t?"outline":"ghost",size:s}),e),...r});md.displayName="PaginationLink";const pd=({className:t,...s})=>a.jsxs(md,{"aria-label":e.t("go_to_previous_page"),size:"default",className:Yt("gap-1 pl-2.5",t),...s,children:[a.jsx(d.ChevronLeft,{className:"h-4 w-4"}),a.jsx("span",{children:"Previous"})]});pd.displayName="PaginationPrevious";const hd=({className:t,...s})=>a.jsxs(md,{"aria-label":e.t("go_to_next_page"),size:"default",className:Yt("gap-1 pr-2.5",t),...s,children:[a.jsx("span",{children:"Next"}),a.jsx(d.ChevronRight,{className:"h-4 w-4"})]});hd.displayName="PaginationNext";const xd=({className:e,...t})=>a.jsxs("span",{"aria-hidden":!0,className:Yt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"More pages"})]});xd.displayName="PaginationEllipsis";const fd=te.forwardRef(({className:e,value:t,...s},r)=>a.jsx(Ne.Root,{ref:r,className:Yt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...s,children:a.jsx(Ne.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));fd.displayName=Ne.Root.displayName;const gd=te.forwardRef(({className:e,...t},s)=>a.jsx(_e.Root,{className:Yt("grid gap-2",e),...t,ref:s}));gd.displayName=_e.Root.displayName;const vd=te.forwardRef(({className:e,...t},s)=>a.jsx(_e.Item,{ref:s,className:Yt("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",e),...t,children:a.jsx(_e.Indicator,{className:"flex items-center justify-center",children:a.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));vd.displayName=_e.Item.displayName;const bd=Ce.Panel,jd=re.Root,yd=re.Trigger,wd=re.Close,Nd=re.Portal,_d=te.forwardRef(({className:e,...t},s)=>a.jsx(re.Overlay,{className:Yt("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",e),...t,ref:s}));_d.displayName=re.Overlay.displayName;const Cd=r.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"}}),kd=te.forwardRef(({side:e="right",className:t,children:s,...r},n)=>a.jsxs(Nd,{children:[a.jsx(_d,{}),a.jsxs(re.Content,{ref:n,className:Yt(Cd({side:e}),t),...r,children:[s,a.jsxs(re.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kd.displayName=re.Content.displayName;const Sd=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Yt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(ls,{className:"mt-2"})]});Sd.displayName="SheetHeader";const Td=({className:e,...t})=>a.jsx("div",{className:Yt("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",e),...t});Td.displayName="SheetBody";const Pd=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsx("div",{className:Yt("flex flex-row justify-end gap-2",e),...s,children:t})]});Pd.displayName="SheetFooter";const Dd=te.forwardRef(({className:e,...t},s)=>a.jsx(re.Title,{ref:s,className:Yt("text-lg font-semibold text-foreground",e),...t}));Dd.displayName=re.Title.displayName;const Ed=te.forwardRef(({className:e,...t},s)=>a.jsx(re.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Ed.displayName=re.Description.displayName;const Ad="sidebar:state",Id=te.createContext(null);function Md(){const e=te.useContext(Id);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Fd=te.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const d=An(),[c,u]=te.useState(!1),[m,p]=te.useState(()=>{if("undefined"!=typeof window){const a=localStorage.getItem(Ad);return null!==a?"true"===a:e}return e}),h=t??m,x=te.useCallback(e=>{const a="function"==typeof e?e(h):e;s?s(a):p(a),"undefined"!=typeof window&&localStorage.setItem(Ad,String(a))},[s,h]),f=te.useCallback(()=>d?u(e=>!e):x(e=>!e),[d,x,u]);te.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f]);const g=h?"expanded":"collapsed",v=te.useMemo(()=>({state:g,open:h,setOpen:x,isMobile:d,openMobile:c,setOpenMobile:u,toggleSidebar:f}),[g,h,x,d,c,u,f]);return a.jsx(Id.Provider,{value:v,children:a.jsx(jr,{delayDuration:0,children:a.jsx("div",{className:Yt("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})})})});Fd.displayName="SidebarProvider";const Rd=te.forwardRef(({side:e="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=Md();return"none"===s?a.jsx("div",{className:Yt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?a.jsx(jd,{open:c,onOpenChange:u,...o,children:a.jsxs(kd,{"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:e,children:[a.jsx(Dd,{className:"sr-only",children:"Menu de Navegação"}),a.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):a.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":e,children:[a.jsx("div",{className:Yt("duration-200 relative h-[calc(100svh-var(--header-height,0px))] 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]")}),a.jsx("div",{className:Yt("duration-200 fixed z-30 hidden w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","top-[var(--header-height,0px)] h-[calc(100svh-var(--header-height,0px))]","left"===e?"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:a.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})})]})});Rd.displayName="Sidebar";const Ld=te.forwardRef(({className:e,onClick:t,...s},r)=>{const{toggleSidebar:n}=Md();return a.jsxs(Xt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Yt("h-7 w-7",e),onClick:e=>{t?.(e),n()},...s,children:[a.jsx(d.PanelLeft,{}),a.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Ld.displayName="SidebarTrigger";const zd=te.forwardRef(({className:e,...t},s)=>{const{toggleSidebar:r}=Md();return a.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Yt("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",e),...t})});zd.displayName="SidebarRail";const Ud=te.forwardRef(({className:e,...t},s)=>a.jsx("main",{ref:s,className:Yt("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",e),...t}));Ud.displayName="SidebarInset";const Od=te.forwardRef(({className:e,...t},s)=>a.jsx(Zt,{ref:s,"data-sidebar":"input",className:Yt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Od.displayName="SidebarInput";const Vd=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"header",className:Yt("flex flex-col gap-2 p-2",e),...t}));Vd.displayName="SidebarHeader";const Bd=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"footer",className:Yt("flex flex-col gap-2 p-2",e),...t}));Bd.displayName="SidebarFooter";const qd=te.forwardRef(({className:e,...t},s)=>a.jsx(ls,{ref:s,"data-sidebar":"separator",className:Yt("mx-2 w-auto bg-sidebar-border",e),...t}));qd.displayName="SidebarSeparator";const $d=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"content",className:Yt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));$d.displayName="SidebarContent";const Wd=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group",className:Yt("relative flex w-full min-w-0 flex-col p-2",e),...t}));Wd.displayName="SidebarGroup";const Hd=te.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"div";return a.jsx(o,{ref:n,"data-sidebar":"group-label",className:Yt("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",e),...r})});Hd.displayName="SidebarGroupLabel";const Gd=te.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"button";return a.jsx(o,{ref:n,"data-sidebar":"group-action",className:Yt("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",e),...r})});Gd.displayName="SidebarGroupAction";const Yd=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group-content",className:Yt("w-full text-sm",e),...t}));Yd.displayName="SidebarGroupContent";const Qd=te.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu",className:Yt("flex w-full min-w-0 flex-col gap-1",e),...t}));Qd.displayName="SidebarMenu";const Kd=te.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Yt("group/menu-item relative",e),...t}));Kd.displayName="SidebarMenuItem";const Xd=r.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"}}),Jd=te.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=e?s.Slot:"button",{isMobile:u,state:m}=Md(),p=a.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":t,className:Yt(Xd({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:p}),a.jsx(Nr,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});Jd.displayName="SidebarMenuButton";const Zd=te.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...n},o)=>{const i=t?s.Slot:"button";return a.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Yt("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",e),...n})});Zd.displayName="SidebarMenuAction";const ec=te.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Yt("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",e),...t}));ec.displayName="SidebarMenuBadge";const ac=te.forwardRef(({className:e,showIcon:t=!1,...s},r)=>{const n=te.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return a.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Yt("rounded-md h-8 flex gap-2 px-2 items-center",e),...s,children:[t&&a.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),a.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});ac.displayName="SidebarMenuSkeleton";const tc=te.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Yt("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",e),...t}));tc.displayName="SidebarMenuSub";const sc=te.forwardRef(({...e},t)=>a.jsx("li",{ref:t,...e}));sc.displayName="SidebarMenuSubItem";const rc=te.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:n,...o},i)=>{const l=e?s.Slot:"a";return a.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:Yt("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});rc.displayName="SidebarMenuSubButton";const nc=te.forwardRef(({className:e,value:t,defaultValue:s,...r},n)=>{const o=t||s||[0];return a.jsxs(ke.Root,{ref:n,value:t,defaultValue:s,className:Yt("relative flex w-full touch-none select-none items-center",e),...r,children:[a.jsx(ke.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:a.jsx(ke.Range,{className:"absolute h-full bg-primary"})}),o.map((e,t)=>a.jsx(ke.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))]})});nc.displayName=ke.Root.displayName;const oc=Se.Menu,ic=Se.Group,lc=Se.Portal,dc=Se.Sub,cc=Se.RadioGroup,uc=te.forwardRef(({className:e,...t},s)=>a.jsx(Se.Root,{ref:s,className:Yt("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",e),...t}));uc.displayName=Se.Root.displayName;const mc=te.forwardRef(({className:e,...t},s)=>a.jsx(Se.Trigger,{ref:s,className:Yt("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",e),...t}));mc.displayName=Se.Trigger.displayName;const pc=te.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(Se.SubTrigger,{ref:n,className:Yt("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",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));pc.displayName=Se.SubTrigger.displayName;const hc=te.forwardRef(({className:e,...t},s)=>a.jsx(Se.SubContent,{ref:s,className:Yt("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",e),...t}));hc.displayName=Se.SubContent.displayName;const xc=te.forwardRef(({className:e,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>a.jsx(Se.Portal,{children:a.jsx(Se.Content,{ref:o,align:t,alignOffset:s,sideOffset:r,className:Yt("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",e),...n})}));xc.displayName=Se.Content.displayName;const fc=te.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(Se.Item,{ref:r,className:Yt("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",e),...s}));fc.displayName=Se.Item.displayName;const gc=te.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(Se.CheckboxItem,{ref:n,className:Yt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Se.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));gc.displayName=Se.CheckboxItem.displayName;const vc=te.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(Se.RadioItem,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Se.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));vc.displayName=Se.RadioItem.displayName;const bc=te.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(Se.Label,{ref:r,className:Yt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));bc.displayName=Se.Label.displayName;const jc=te.forwardRef(({className:e,...t},s)=>a.jsx(Se.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-muted",e),...t}));jc.displayName=Se.Separator.displayName;const yc=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});yc.displayname="MenubarShortcut";const wc={light:"",dark:".dark"},Nc=te.createContext(null);function _c(){const e=te.useContext(Nc);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Cc=te.forwardRef(({id:e,className:t,children:s,config:r,...n},o)=>{const i=te.useId(),l=`chart-${e||i.replace(/:/g,"")}`;return a.jsx(Nc.Provider,{value:{config:r},children:a.jsxs("div",{"data-chart":l,ref:o,className:Yt("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:[a.jsx(kc,{id:l,config:r}),a.jsx(Te.ResponsiveContainer,{children:s})]})})});Cc.displayName="Chart";const kc=({id:e,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?a.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(wc).map(([a,t])=>`\n${t} [data-chart=${e}] {\n${s.map(([e,t])=>{const s=t.theme?.[a]||t.color;return s?` --color-${e}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Sc=Te.Tooltip,Tc=te.forwardRef(({active:e,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=_c(),f=te.useMemo(()=>{if(n||!t?.length)return null;const[e]=t,s=Ec(x,e,`${p||e?.dataKey||e?.name||"value"}`),r=p||"string"!=typeof i?s?.label:x[i]?.label||i;return l?a.jsx("div",{className:Yt("font-medium",d),children:l(r,t)}):r?a.jsx("div",{className:Yt("font-medium",d),children:r}):null},[i,l,t,n,d,x,p]);if(!e||!t?.length)return null;const g=1===t.length&&"dot"!==r;return a.jsxs("div",{ref:h,className:Yt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:f,a.jsx("div",{className:"grid gap-1.5",children:t.map((e,t)=>{const s=`${m||e.name||e.dataKey||"value"}`,n=Ec(x,e,s),i=u||e.payload?.fill||e.color;return a.jsx("div",{className:Yt("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==e?.value&&e.name?c(e.value,e.name,e,t,e.payload):a.jsxs(a.Fragment,{children:[n?.icon?a.jsx(n.icon,{}):!o&&a.jsx("div",{className:Yt("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}}),a.jsxs("div",{className:Yt("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[a.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,a.jsx("span",{className:"text-muted-foreground",children:n?.label||e.name})]}),void 0!==e.value&&a.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString():e.value})]})]})},e.dataKey||t)})})]})});Tc.displayName="ChartTooltip";const Pc=Te.Legend,Dc=te.forwardRef(({className:e,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=_c();return s?.length?a.jsx("div",{ref:o,className:Yt("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",e),children:s.map(e=>{const s=`${n||e.dataKey||"value"}`,r=Ec(i,e,s);return a.jsxs("div",{className:Yt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?a.jsx(r.icon,{}):a.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),r?.label]},e.value)})}):null});function Ec(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]}Dc.displayName="ChartLegend";const Ac=({onClick:e,isActive:t,disabled:s,children:r,title:n})=>a.jsx("button",{type:"button",onClick:e,disabled:s,title:n,className:Yt("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}),Ic=()=>a.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Mc({image:e,title:t,className:s}){return a.jsx("div",{className:Yt("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:e?a.jsx("img",{src:e,alt:t,className:"w-full h-full object-cover"}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(d.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function Fc({steps:e,currentStepIndex:t,onStepSelect:s,stepLabel:r,className:n}){const{t:o}=j.useTranslation(),i=e.length,l=(t+1)/i*100;return a.jsxs("div",{className:Yt("flex items-center gap-3",n),children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",t+1,"/",i,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(pr,{align:"start",children:e.map((e,r)=>a.jsxs(hr,{onClick:()=>s(r),className:Yt(r===t&&"bg-accent"),children:[r+1,". ",e.title]},e.id))})]}),a.jsx(fd,{value:l,className:"w-32 h-2"})]})}function Rc({currentStepIndex:e,totalSteps:t,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:l,className:c}){const{t:u}=j.useTranslation(),m=0===e,p=e===t-1;return a.jsxs("div",{className:Yt("flex items-center gap-2",c),children:[!m&&a.jsxs(Xt,{variant:"outline",onClick:s,size:"sm",children:[a.jsx(d.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),a.jsxs(Xt,{onClick:p?n:r,size:"sm",children:[p?l:i,!p&&a.jsx(d.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const Lc=te.forwardRef(({open:t,onOpenChange:s,steps:r,onComplete:n,onStepChange:o,continueButtonText:i="Continuar",backButtonText:l="Voltar",finishButtonText:c="Concluir",stepLabel:u=e.t("approval_step_label"),size:m="md",showProgressIndicator:p=!0,currentStepIndex:h,onCurrentStepChange:x,className:f},g)=>{const[v,b]=te.useState(0),j=void 0!==h,y=j?h:v,w=te.useCallback(e=>{j?x?.(e):b(e),o?.(e)},[j,x,o]);te.useEffect(()=>{t||j||b(0)},[t,j]);const N=r[y],_=r.length;return N?a.jsx(js,{open:t,onOpenChange:s,children:a.jsxs(ks,{ref:g,size:m,variant:"informative",className:Yt("p-0 gap-0 overflow-hidden",f),children:[a.jsxs(Ns,{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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Fechar"})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx(Mc,{image:N.image,title:N.title}),a.jsx(Ds,{className:"text-xl font-semibold",children:N.title}),a.jsx(Es,{className:"text-muted-foreground",children:N.description})]})}),a.jsxs("div",{className:"flex-shrink-0",children:[a.jsx(ls,{}),a.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[p&&_>1?a.jsx(Fc,{steps:r,currentStepIndex:y,onStepSelect:e=>{w(e)},stepLabel:u}):a.jsx("div",{}),a.jsx(Rc,{currentStepIndex:y,totalSteps:_,onBack:()=>{y>0&&w(y-1)},onNext:()=>{y<_-1&&w(y+1)},onComplete:()=>{n?.(),s(!1)},backButtonText:l,continueButtonText:i,finishButtonText:c})]})]})]})}):null});function zc({label:e,onClick:t,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:l=!1,menuAlign:c="end",className:u}){const{t:m}=j.useTranslation(),p=i||l;if(!(r.length>0))return a.jsxs(Xt,{variant:n,size:o,disabled:p,onClick:t,className:u,children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]});return a.jsxs("div",{className:Yt("inline-flex rounded-md shadow-sm",u),children:[a.jsxs(Xt,{variant:n,size:o,disabled:p,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:n,size:o,disabled:p,className:Yt("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":m("more_options"),children:a.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),a.jsx(pr,{align:c,className:"min-w-[160px]",children:r.map(e=>{const t=e.icon;return a.jsxs(hr,{onClick:e.onClick,disabled:e.disabled,className:Yt("destructive"===e.variant&&"text-destructive focus:text-destructive"),children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})]})}var Uc;Lc.displayName="OnboardingDialog",exports.ExportFormat=void 0,(Uc=exports.ExportFormat||(exports.ExportFormat={})).CSV="csv",Uc.PDF="pdf",Uc.XLSX="xlsx",Uc.PNG="png",Uc.JPEG="jpeg",Uc.SVG="svg";const Oc=[{value:exports.ExportFormat.CSV,label:"CSV",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.XLSX,label:"XLSX",icon:a.jsx(d.FileSpreadsheet,{className:"h-5 w-5"})}],Vc=[{value:exports.ExportFormat.PNG,label:"PNG",icon:a.jsx(d.Image,{className:"h-5 w-5"})},{value:exports.ExportFormat.JPEG,label:"JPEG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.SVG,label:"SVG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})}];const Bc=t.forwardRef(({value:e,onChange:s,onTimeChange:r,label:n,error:o,format:i="24h",className:l,id:c,...u},m)=>{const p=c??te.useId(),h=t.useCallback(e=>{const a=e.target.value;s?.(a),r?.(a)},[s,r]),x=t.useCallback(e=>{["0","1","2","3","4","5","6","7","8","9","Backspace","Tab",":","ArrowLeft","ArrowRight","Delete"].includes(e.key)||e.preventDefault()},[]);return a.jsxs("div",{className:Yt("grid gap-1.5",l),children:[n&&a.jsx(as,{htmlFor:p,children:n}),a.jsxs("div",{className:"relative",children:[a.jsx(Zt,{ref:m,id:p,type:"time",value:e??"",onChange:h,onKeyDown:x,min:"00:00",max:"23:59",step:60,className:Yt("pr-9",o&&"border-destructive focus-visible:ring-destructive"),...u}),a.jsx(d.Clock,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})});function qc({currentStep:e,totalSteps:t,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){te.useEffect(()=>{process.env.NODE_ENV},[]);const l=Array.from({length:t},(e,a)=>a+1),c=a=>!(a<=e)&&(!!n&&!n(a));return a.jsxs("div",{className:Yt("flex items-center gap-3",o),children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",e,"/",t,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(pr,{align:"start",children:l.map(t=>a.jsxs(hr,{onClick:()=>{var a;(a=t)<e?s(a):n&&!n(a)||s(a)},disabled:c(t),className:Yt("cursor-pointer",t===e&&"bg-muted font-medium",c(t)&&"opacity-50 cursor-not-allowed"),children:[a.jsxs("span",{className:"mr-2 text-muted-foreground",children:[t,"."]}),r?.[t-1]||`Etapa ${t}`,t===e&&a.jsx(d.Check,{className:"h-4 w-4 ml-auto"})]},t))})]}),a.jsx(fd,{value:e/t*100,className:Yt("h-2",i)})]})}function $c(e){const a=an.getAccessToken(),t={"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},"un-alias":e};if(a)try{const e=JSON.parse(atob(a.split(".")[1]));e.sub&&(t["x-waf-rate"]=btoa(e.sub))}catch{}return t}async function Wc(e,a,t){let s=await fetch(e,a);if(401===s.status){if(await un.handleApiError({status:401})){const r={...a,headers:$c(t)};s=await fetch(e,r)}}return s}function Hc(e){const[a,s]=t.useState([]),[r,n]=t.useState(0),[o,i]=t.useState(!1);t.useEffect(()=>{if(!e)return;let a=!1;const t=`${Oe().replace(/\/?$/,"/")}api/common/v1/updates/listUpdatesNotification`;return async function(){i(!0);try{const r=$c(e),o=await Wc(t,{method:"GET",headers:r},e);if(!o.ok)return;const i=await o.json();!a&&i.data?.[0]&&(s(i.data[0].updates??[]),n(i.data[0].valueBadge??0))}catch(r){}finally{a||i(!1)}}(),()=>{a=!0}},[e]);const l=t.useCallback(async()=>{if(!e||r<=0||0===a.length)return;const t=a[0].id,s=`${Oe().replace(/\/?$/,"/")}api/common/v1/Updates/userVisualized/3/undefined`;n(0);try{const a=$c(e),r=JSON.stringify({id:t,idUpdateType:3});await Wc(s,{method:"POST",headers:a,body:r},e)}catch(o){}},[e,r,a]);return{updates:a,badgeCount:r,loading:o,markAsVisualized:l}}Bc.displayName="Timepicker";const Gc=t.forwardRef(({updates:t,badgeCount:s,onOpen:r,onViewAll:n},o)=>{const i=void 0===t,l=Pn(),c=l?.alias??null,u=Hc(i?c:null),m=i?u.updates??[]:t,p=i?u.badgeCount??0:s??0,h=r??(i?u.markAsVisualized:void 0),x=n??(i&&c?()=>{const e=`https://apps4.qualiex.com/common/${c}/up/view`;window.open(e,"_blank","noopener,noreferrer")}:void 0);return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{ref:o,variant:"ghost",size:"sm",className:"relative h-9 w-9 p-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:h,title:e.t("updates"),children:[a.jsx(d.Coffee,{className:"h-7 w-7"}),p>0&&a.jsx("span",{className:"absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:p>99?"99+":p})]})}),a.jsxs(Sr,{align:"end",className:"w-80 p-0",children:[a.jsx("div",{className:"border-b border-border px-4 py-3",children:a.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Atualizações"})}),a.jsx("div",{className:"max-h-72 overflow-y-auto",children:m.length>0?a.jsx("ul",{className:"divide-y divide-border",children:m.map(e=>a.jsxs("li",{className:"px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer",onClick:x,children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.text})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[a.jsx(d.Coffee,{className:"h-8 w-8 text-muted-foreground mb-2"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum café quentinho, ou melhor, atualização quentinha no momento!"})]})}),a.jsx("div",{className:"border-t border-border px-4 py-2",children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"w-full justify-between text-primary hover:text-primary",onClick:x,children:["Ver todas as atualizações",a.jsx(d.ArrowRight,{className:"h-[18px] w-[18px]"})]})})]})]})});var Yc,Qc;Gc.displayName="UpdatesNotification",exports.FileViewerType=void 0,(Yc=exports.FileViewerType||(exports.FileViewerType={}))[Yc.none=0]="none",Yc[Yc.image=1]="image",Yc[Yc.video=2]="video",Yc[Yc.audio=3]="audio",Yc[Yc.wopi=4]="wopi",Yc[Yc.onlineEditor=5]="onlineEditor",Yc[Yc.report=6]="report",exports.FilePrintType=void 0,(Qc=exports.FilePrintType||(exports.FilePrintType={}))[Qc.SimplePrint=0]="SimplePrint",Qc[Qc.ManagedCopy=1]="ManagedCopy",Qc[Qc.NonManagedCopy=2]="NonManagedCopy";const Kc={".jpg":exports.FileViewerType.image,".jpeg":exports.FileViewerType.image,".png":exports.FileViewerType.image,".bmp":exports.FileViewerType.image,".gif":exports.FileViewerType.image,".svg":exports.FileViewerType.image,".webp":exports.FileViewerType.image,".wav":exports.FileViewerType.audio,".mp3":exports.FileViewerType.audio,".mp4":exports.FileViewerType.video,".webm":exports.FileViewerType.video,".ogg":exports.FileViewerType.video,".pdf":exports.FileViewerType.wopi,".ods":exports.FileViewerType.wopi,".xls":exports.FileViewerType.wopi,".xlsb":exports.FileViewerType.wopi,".xlsm":exports.FileViewerType.wopi,".xlsx":exports.FileViewerType.wopi,".doc":exports.FileViewerType.wopi,".docm":exports.FileViewerType.wopi,".docx":exports.FileViewerType.wopi,".dot":exports.FileViewerType.wopi,".dotm":exports.FileViewerType.wopi,".dotx":exports.FileViewerType.wopi,".odt":exports.FileViewerType.wopi,".odp":exports.FileViewerType.wopi,".pot":exports.FileViewerType.wopi,".potm":exports.FileViewerType.wopi,".potx":exports.FileViewerType.wopi,".pps":exports.FileViewerType.wopi,".ppsm":exports.FileViewerType.wopi,".ppsx":exports.FileViewerType.wopi,".ppt":exports.FileViewerType.wopi,".pptm":exports.FileViewerType.wopi,".pptx":exports.FileViewerType.wopi,".gdocs":exports.FileViewerType.onlineEditor,".gsheets":exports.FileViewerType.onlineEditor};function Xc(e){const{t:a}=j.useTranslation();return e?Kc[e.toLowerCase()]??exports.FileViewerType.none:exports.FileViewerType.none}const Jc={".pdf":"wv/wordviewerframe.aspx?PdfMode=1&",".xls":"x/_layouts/xlviewerinternal.aspx?",".xlsb":"x/_layouts/xlviewerinternal.aspx?",".xlsm":"x/_layouts/xlviewerinternal.aspx?",".xlsx":"x/_layouts/xlviewerinternal.aspx?",".ods":"x/_layouts/xlviewerinternal.aspx?",".doc":"wv/wordviewerframe.aspx?",".docm":"wv/wordviewerframe.aspx?",".docx":"wv/wordviewerframe.aspx?",".dot":"wv/wordviewerframe.aspx?",".dotm":"wv/wordviewerframe.aspx?",".dotx":"wv/wordviewerframe.aspx?",".odt":"wv/wordviewerframe.aspx?",".ppt":"p/PowerPointFrame.aspx?",".pptm":"p/PowerPointFrame.aspx?",".pptx":"p/PowerPointFrame.aspx?",".pot":"p/PowerPointFrame.aspx?",".potm":"p/PowerPointFrame.aspx?",".potx":"p/PowerPointFrame.aspx?",".pps":"p/PowerPointFrame.aspx?",".ppsm":"p/PowerPointFrame.aspx?",".ppsx":"p/PowerPointFrame.aspx?",".odp":"p/PowerPointFrame.aspx?"};function Zc(e){const{t:a}=j.useTranslation();return Jc[e?.toLowerCase()]||""}function eu(e){const{t:a}=j.useTranslation(),t=e%60;return`${Math.floor(e/60)}min ${t<10?"0":""}${t}`}function au({open:e,onOpenChange:s,url:r,title:n,className:o,minHeight:i="250px"}){const{t:l}=j.useTranslation(),c=t.useCallback(()=>{s(!1)},[s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&c()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,c]),a.jsx(js,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Yt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",o),children:[a.jsxs("div",{className:"flex items-center justify-end mb-2.5",children:[n&&a.jsx("h2",{className:"text-lg font-medium text-foreground truncate mr-auto",children:n}),a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})]}),a.jsx("iframe",{src:r,className:"border-none w-full",style:{minHeight:i},title:n||l("embedded_content")})]})})}function tu({term:s,open:r,onClose:n,onSign:o,viewOnly:i=!1,title:l=e.t("terms_of_use"),signLabel:c=e.t("terms_read_agree")}){const u=t.useMemo(()=>s.file?function(e,a=""){const{t:t}=j.useTranslation(),s=atob(e),r=[];for(let o=0;o<s.length;o+=512){const e=s.slice(o,o+512),a=new Array(e.length);for(let t=0;t<e.length;t++)a[t]=e.charCodeAt(t);r.push(new Uint8Array(a))}const n=new Blob(r,{type:a});return URL.createObjectURL(n)}(s.file,s.type):null,[s.file,s.type]),m=t.useCallback(()=>{u&&URL.revokeObjectURL(u),n()},[u,n]),p=t.useCallback(()=>{s.hasUserSignature?m():o?.(s.id)},[s,o,m]),h=!i&&!s.hasUserSignature&&o;return a.jsx(js,{open:r,onOpenChange:e=>!e&&m(),children:a.jsxs(ks,{className:Yt("flex flex-col p-0 sm:max-w-[80vw] h-[95vh]","[&>button.absolute]:hidden"),children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[a.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[a.jsx(d.FileText,{className:"h-5 w-5 text-primary"}),l]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsx(Xt,{size:"sm",onClick:p,children:c}),a.jsx(Xt,{variant:"ghost",size:"icon",onClick:m,children:a.jsx(d.X,{className:"h-4 w-4"})})]})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s.file&&u?a.jsx("iframe",{className:"h-full w-full border-0",src:u,title:l}):a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a.jsx("p",{children:"Nenhum termo de uso ativo encontrado."})})})]})})}function su(e){const{t:a}=j.useTranslation();return e.split(" ").slice(0,2).map(e=>e[0]?.toUpperCase()??"").join("")}function ru(e){const{t:a}=j.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function nu(e){const{t:a}=j.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function ou(e){const{t:a}=j.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.allowedIds?.forEach(e=>t.add(e)),s.inheritedIds?.forEach(e=>t.add(e));return t}var iu;exports.ReportRequestStatus=void 0,(iu=exports.ReportRequestStatus||(exports.ReportRequestStatus={}))[iu.WaitingProcessing=1]="WaitingProcessing",iu[iu.Processing=2]="Processing",iu[iu.Completed=3]="Completed",iu[iu.Error=4]="Error",iu[iu.Expired=5]="Expired";const lu={report:e.t("report"),status:e.t("status"),requestDate:e.t("request_date"),lastUpdate:e.t("last_update"),expirationDate:e.t("expiration_date"),viewReport:e.t("view_report"),searchPlaceholder:e.t("search_report_placeholder"),noResults:e.t("no_reports_found"),statusWaiting:e.t("status_waiting"),statusProcessing:e.t("status_processing"),statusCompleted:e.t("status_completed"),statusError:e.t("status_error"),statusExpired:e.t("status_expired")};function du(e){const{t:a}=j.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function cu(e){const{t:a}=j.useTranslation();return e.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const uu={sm:{badge:"px-1.5 py-0.5 text-[11px] gap-1",icon:14},md:{badge:"px-2.5 py-1 text-xs gap-1.5",icon:16},lg:{badge:"px-3 py-1.5 text-sm gap-2",icon:18}};function mu({label:e,color:t,icon:s,showIcon:r,size:n="md",variant:o="filled",backgroundColor:i,className:l}){const d=uu[n],c=r??!!s;return a.jsxs("span",{className:Yt("inline-flex items-center rounded-md font-medium whitespace-nowrap","outline"===o&&"border",d.badge,l),style:(()=>{switch(o){case"outline":return{color:t,borderColor:$t(t,.3),backgroundColor:"transparent"};case"ghost":return{color:t,backgroundColor:"transparent"};default:return{color:t,backgroundColor:i||$t(t,.1)}}})(),children:[c&&s&&a.jsx(s,{size:d.icon,strokeWidth:2}),e]})}var pu,hu,xu,fu,gu,vu,bu,ju,yu,wu,Nu,_u,Cu,ku,Su,Tu,Pu,Du,Eu,Au,Iu,Mu,Fu,Ru,Lu;exports.AggregationType=void 0,(pu=exports.AggregationType||(exports.AggregationType={})).Count="valuecount",pu.Sum="sum",pu.Average="average",pu.DistinctCount="valuecount_distict",pu.Max="max",pu.Min="min",exports.AnalysisFunctionality=void 0,(exports.AnalysisFunctionality||(exports.AnalysisFunctionality={})).ViewAllAnalysis="nes3j6wn",exports.DashboardFunctionality=void 0,(hu=exports.DashboardFunctionality||(exports.DashboardFunctionality={})).RegisterDashboards="EeKs7CYA",hu.RemoveDashboards="3GKZYOQ9",hu.ViewAllDashboards="wYBdQNvZ",hu.EditDashboards="bMFcbwv4",exports.DashboardListType=void 0,(xu=exports.DashboardListType||(exports.DashboardListType={}))[xu.Default=1]="Default",xu[xu.Compact=2]="Compact",exports.DashboardPageTime=void 0,(fu=exports.DashboardPageTime||(exports.DashboardPageTime={}))[fu.FiveSeconds=1]="FiveSeconds",fu[fu.TenSeconds=2]="TenSeconds",fu[fu.FifteenSeconds=3]="FifteenSeconds",fu[fu.ThirtySeconds=4]="ThirtySeconds",fu[fu.OneMinute=5]="OneMinute",fu[fu.ThreeMinutes=6]="ThreeMinutes",fu[fu.FiveMinutes=7]="FiveMinutes",fu[fu.TenMinutes=8]="TenMinutes",exports.DashboardPanelDimension=void 0,(gu=exports.DashboardPanelDimension||(exports.DashboardPanelDimension={}))[gu.Day=1]="Day",gu[gu.Month=2]="Month",gu[gu.Year=3]="Year",exports.DashboardPanelOrderByType=void 0,(vu=exports.DashboardPanelOrderByType||(exports.DashboardPanelOrderByType={}))[vu.Ascending=1]="Ascending",vu[vu.Descending=2]="Descending",exports.DashboardPanelOrderBy=void 0,(bu=exports.DashboardPanelOrderBy||(exports.DashboardPanelOrderBy={}))[bu.Label=1]="Label",bu[bu.Value=2]="Value",exports.DashboardPanelPeriod=void 0,(ju=exports.DashboardPanelPeriod||(exports.DashboardPanelPeriod={}))[ju.LastSevenDays=1]="LastSevenDays",ju[ju.LastWeek=2]="LastWeek",ju[ju.LastMonth=3]="LastMonth",ju[ju.PreviousQuarter=4]="PreviousQuarter",ju[ju.PreviousSemester=5]="PreviousSemester",ju[ju.LastYear=6]="LastYear",ju[ju.SpecificPeriod=7]="SpecificPeriod",ju[ju.CurrentMonth=8]="CurrentMonth",ju[ju.CurrentSemester=9]="CurrentSemester",ju[ju.CurrentWeek=10]="CurrentWeek",ju[ju.CurrentYear=11]="CurrentYear",exports.DashboardPanelType=void 0,(yu=exports.DashboardPanelType||(exports.DashboardPanelType={}))[yu.Text=1]="Text",yu[yu.Area=2]="Area",yu[yu.Bar=3]="Bar",yu[yu.Column=4]="Column",yu[yu.StackedColumn=5]="StackedColumn",yu[yu.Line=6]="Line",yu[yu.List=7]="List",yu[yu.Numeric=8]="Numeric",yu[yu.Pareto=9]="Pareto",yu[yu.Pie=10]="Pie",yu[yu.RiskMatrix=11]="RiskMatrix",yu[yu.Burndown=12]="Burndown",yu[yu.PerformanceColumns=13]="PerformanceColumns",yu[yu.EvolutionLine=14]="EvolutionLine",exports.DashboardUpdateTime=void 0,(wu=exports.DashboardUpdateTime||(exports.DashboardUpdateTime={}))[wu.NotUpdate=1]="NotUpdate",wu[wu.FiveMinutes=2]="FiveMinutes",wu[wu.TenMinutes=3]="TenMinutes",wu[wu.FifteenMinutes=4]="FifteenMinutes",wu[wu.ThirtyMinutes=5]="ThirtyMinutes",wu[wu.OneHour=6]="OneHour",exports.DashboardViewType=void 0,(Nu=exports.DashboardViewType||(exports.DashboardViewType={}))[Nu.NormalPage=1]="NormalPage",Nu[Nu.Carousel=2]="Carousel",exports.DashboardFormTab=void 0,(_u=exports.DashboardFormTab||(exports.DashboardFormTab={}))[_u.General=0]="General",_u[_u.Share=1]="Share",exports.DashboardShareType=void 0,(Cu=exports.DashboardShareType||(exports.DashboardShareType={}))[Cu.NotShared=1]="NotShared",Cu[Cu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",Cu[Cu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.DashboardLanguage=void 0,(ku=exports.DashboardLanguage||(exports.DashboardLanguage={})).PtBr="pt-br",ku.EnUs="en",ku.EsEs="es",exports.MatrixViewType=void 0,(Su=exports.MatrixViewType||(exports.MatrixViewType={}))[Su.Quantity=0]="Quantity",Su[Su.AllRisksList=1]="AllRisksList",exports.PanelItemsPerPanel=void 0,(Tu=exports.PanelItemsPerPanel||(exports.PanelItemsPerPanel={}))[Tu.Five=5]="Five",Tu[Tu.Ten=10]="Ten",Tu[Tu.Fifteen=15]="Fifteen",Tu[Tu.Twenty=20]="Twenty",Tu[Tu.All=0]="All",Tu[Tu.Custom=-1]="Custom",exports.PanelSortType=void 0,(Pu=exports.PanelSortType||(exports.PanelSortType={}))[Pu.AlphabeticalAsc=1]="AlphabeticalAsc",Pu[Pu.AlphabeticalDesc=2]="AlphabeticalDesc",Pu[Pu.CountAsc=3]="CountAsc",Pu[Pu.CountDesc=4]="CountDesc",Pu[Pu.DateAsc=5]="DateAsc",Pu[Pu.DateDesc=6]="DateDesc",exports.PanelState=void 0,(Du=exports.PanelState||(exports.PanelState={}))[Du.Loading=0]="Loading",Du[Du.Loaded=1]="Loaded",Du[Du.Error=3]="Error",Du[Du.NoData=4]="NoData",Du[Du.Unavailable=5]="Unavailable",exports.VisualizationType=void 0,(Eu=exports.VisualizationType||(exports.VisualizationType={}))[Eu.Quantity=1]="Quantity",Eu[Eu.Percentage=2]="Percentage",Eu[Eu.QuantityPercentage=3]="QuantityPercentage",exports.PlanType=void 0,(Au=exports.PlanType||(exports.PlanType={}))[Au.Program=1]="Program",Au[Au.Project=2]="Project",Au[Au.Action=3]="Action",Au[Au.PerformanceProject=4]="PerformanceProject",Au[Au.PerformanceAction=5]="PerformanceAction",exports.QueriesContextType=void 0,(Iu=exports.QueriesContextType||(exports.QueriesContextType={})).OccurrenceActionPlans="xebGnSSq",Iu.OccurrenceGeneral="UFws4AvH",Iu.PlansActionPlans="Kux6CcVC",Iu.PlansProgramProjects="UWjrp6Dw",Iu.PlansIdeas="3g7vNm2w",Iu.RisksGeneral="PZ4b6FhP",Iu.RisksActionPlans="xZErDg57",Iu.RisksAnalysis="UxsioMbH",Iu.RisksIncidences="gNt5IJ2F",Iu.MetrologyGeneral="4MfEPbRY",Iu.MetrologyActivities="hdFM9XQW",Iu.MetrologyServiceOrders="cIrVPdMv",Iu.DecisionsGeneral="CopsnHDB",Iu.DecisionsItems="qLFAayjx",Iu.DecisionsActionPlans="RiQFpxdb",Iu.FlowGeneral="AFV98JoG",Iu.AuditGeneral="gON8LJPi",Iu.AuditPlans="SsCNVOvr",Iu.AuditPlansItems="OpPkCCFm",Iu.AuditActionPlans="P1oGePhh",Iu.CommonGeneral="VVfEzgMQ",Iu.ActionPlans="C6Z4MgGa",Iu.SuppliersEvaluations="fSCeS4mH",Iu.SuppliersGeneral="8qPThkrD",Iu.SuppliersEvaluationsCriteria="RiSIStdY",Iu.SuppliersDocuments="Riua4jMa",Iu.SuppliersMaterialsServices="UpEkatXH",Iu.DocumentsGeneral="FRhhEX2J",Iu.DocumentsPhysicalCopies="PZLtJ23h",Iu.DocumentsObsolete="XDjbga14",Iu.FmeaGeneral="aPwf4uPr",Iu.FmeaActionPlans="vQ8PMrVX",exports.QueriesShareType=void 0,(Mu=exports.QueriesShareType||(exports.QueriesShareType={}))[Mu.NotShared=1]="NotShared",Mu[Mu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",Mu[Mu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.QuickFilterDashboard=void 0,(Fu=exports.QuickFilterDashboard||(exports.QuickFilterDashboard={}))[Fu.All=1]="All",Fu[Fu.OnlyMine=2]="OnlyMine",Fu[Fu.Favorites=3]="Favorites",exports.RiskCriticality=void 0,(Ru=exports.RiskCriticality||(exports.RiskCriticality={}))[Ru.Current=1]="Current",Ru[Ru.Inherent=2]="Inherent",exports.PaletteType=void 0,(Lu=exports.PaletteType||(exports.PaletteType={}))[Lu.Default=1]="Default",Lu[Lu.Pastel=2]="Pastel",Lu[Lu.Vibrant=3]="Vibrant",Lu[Lu.Earth=4]="Earth",Lu[Lu.Ocean=5]="Ocean",Lu[Lu.Floral=6]="Floral",Lu[Lu.Night=7]="Night",Lu[Lu.Winter=8]="Winter",Lu[Lu.Spring=9]="Spring",Lu[Lu.Summer=10]="Summer",Lu[Lu.Fall=11]="Fall",Lu[Lu.Gray=12]="Gray",Lu[Lu.Brown=13]="Brown",Lu[Lu.Blue=14]="Blue",Lu[Lu.Yellow=15]="Yellow",Lu[Lu.Green=16]="Green",Lu[Lu.Purple=17]="Purple",Lu[Lu.Orange=18]="Orange",Lu[Lu.Pink=19]="Pink",Lu[Lu.Red=20]="Red";const zu={jan:1,fev:2,mar:3,abr:4,mai:5,jun:6,jul:7,ago:8,set:9,out:10,nov:11,dez:12},Uu=["total_calibration_cost","total_verification_cost","total_maintenance_cost","last_calibration_cost","last_verification_cost","last_maintenance_cost","total_cost","total_reported_cost","estimated_cost","last_report_cost_reported_cost","occurrence_reported_cost","task_estimated_cost"],Ou=["link","link_risk","risk_link","link_group","group_link","link_occurrence","occurrence_link","link_audit","link_project","link_program","link_ideia","flow_link","decision_link","link_supplier","auditing_link","fmea_link"];function Vu(e){if(!e)return 0;const[a,t]=e.split("/"),s=zu[a?.toLowerCase()]??0;return 12*(parseInt(t)||0)+s}function Bu(e){const a=e.split("/"),t=a[a.length-1];return`${a.slice(0,-1).join("/")}/${encodeURIComponent(t.replace(/[!@#$%^&*()_+={}[\]|\\;:'",.<>?/`~]/g,""))}`}function qu(e){for(const a of Ou)if(e[a])return e[a];return null}function $u(e){const a=[];for(const t of Object.keys(e)){const s=e[t];null!=s&&(s instanceof Date?a.push(`${t}=${s.toISOString()}`):Array.isArray(s)?s.forEach(e=>{a.push(...$u({[t]:e}))}):"string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s||a.push(`${t}=${s}`))}return a}const Wu=/^-?\d+(,\d{3})*(\.\d+)?$/;const Hu=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});const Gu=new Set([exports.DashboardPanelType.Text]),Yu=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.Numeric,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]),Qu=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]);function Ku({config:e,viewOnly:s=!1,complement:r,complementPosition:n="before-options",queryUrlBuilder:o,onRefresh:i,onExport:l,onToggleOnlyMine:c,className:u}){const{t:m}=j.useTranslation(),[p,h]=t.useState(e.onlyMine??!1),x=Gu.has(e.typeId),f=!Yu.has(e.typeId),g=!Qu.has(e.typeId),v=t.useMemo(()=>{if(!e.jsonRules||e.typeId===exports.DashboardPanelType.PerformanceColumns)return!1;try{const a=JSON.parse(e.jsonRules);return a?.rules?.rules?.length>0}catch{return!1}},[e.jsonRules,e.typeId]),b=t.useMemo(()=>o?.(e)??"#",[o,e]),y=t.useCallback(()=>{const e=!p;h(e),c?.(e)},[p,c]),w=[];return p&&w.push(m("dashboard_only_mine")),e.onlyLate&&w.push(m("dashboard_only_overdue")),v&&w.push(m("dashboard_advanced_filter")),a.jsxs("div",{className:Yt("flex items-center justify-between gap-2 border-b bg-muted/30 px-2.5 py-1 text-sm font-medium",u),children:[a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:["before-title"===n&&r,a.jsxs("div",{className:"flex min-w-0 flex-col",children:[a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("span",{className:"block truncate",children:e.title})}),a.jsx(Nr,{children:e.title})]}),w.length>0&&a.jsx("span",{className:"text-[9px] font-normal text-muted-foreground truncate",children:w.join(" | ")})]}),"after-title"===n&&r]}),!s&&a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:["before-options"===n&&r,a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-6 w-6",children:a.jsx(d.MoreVertical,{className:"h-3.5 w-3.5"})})}),a.jsxs(pr,{align:"end",className:"w-48",children:[e.canUpdate&&a.jsxs(hr,{onClick:()=>e.onEdit?.(e.id),children:[a.jsx(d.Pencil,{className:"mr-2 h-3.5 w-3.5"}),"Editar"]}),!x&&a.jsxs(hr,{onClick:i,children:[a.jsx(d.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),"Atualizar"]}),f&&a.jsxs(hr,{disabled:e.noData,onClick:l,children:[a.jsx(d.Download,{className:"mr-2 h-3.5 w-3.5"}),"Exportar"]}),!x&&a.jsxs(hr,{disabled:!e.openQueryEnabled,onClick:()=>window.open(b,"_blank"),children:[a.jsx(d.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Abrir consulta"]}),g&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:y,children:[p&&a.jsx(d.Check,{className:"mr-2 h-3.5 w-3.5"}),!p&&a.jsx("span",{className:"mr-2 w-3.5"}),"Somente meus"]})]}),e.canUpdate&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:()=>e.onDuplicate?.(e.id),children:[a.jsx(d.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Duplicar"]}),a.jsxs(hr,{className:"text-destructive",onClick:()=>e.onRemove?.(e.id),children:[a.jsx(d.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Remover"]})]})]})]}),"after-options"===n&&r]})]})}function Xu({config:e,queryUrl:t,className:s}){return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"Erro ao exibir os dados."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"A consulta não pôde ser realizada."}),a.jsxs("p",{className:"mt-2 text-xs",children:[t&&a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:"Verificar a consulta"}),t&&e.canUpdate&&a.jsx("span",{className:"text-muted-foreground",children:" ou "}),e.canUpdate&&a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>e.onEdit?.(e.id),children:"revisar o painel"})]})]})}function Ju({panelType:e,className:t}){const s=e===exports.DashboardPanelType.Burndown;return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-2 p-4",t),children:[a.jsx(tr,{className:"h-10 w-10 text-muted-foreground/40"}),s&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Aguarde, processando dados..."})]})}function Zu({hasRemovedColumn:t=!1,className:s}){return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx("h2",{className:"text-lg font-normal text-foreground/80 lg:text-base",children:e.t("no_data_to_display")}),a.jsx("p",{className:"text-sm text-muted-foreground lg:text-xs",children:e.t("dashboard_no_data")})]})}function em({onRemove:e,className:t}){return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",t),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"A consulta não pôde ser realizada."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Este recurso não está disponível."}),e&&a.jsx("p",{className:"mt-2 text-xs",children:a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:e,children:"Remover painel"})})]})}const am={[exports.AggregationType.Count]:e.t("dashboard_distinct_count").replace("distinta","").trim()||"Count",[exports.AggregationType.Sum]:"Sum",[exports.AggregationType.Average]:e.t("dashboard_average"),[exports.AggregationType.DistinctCount]:e.t("dashboard_distinct_count"),[exports.AggregationType.Max]:e.t("dashboard_max_value"),[exports.AggregationType.Min]:e.t("dashboard_min_value")};function tm({config:e,state:t,value:s,label:r,viewOnly:n=!1,onClick:o,onRefresh:i,queryUrl:l,queryUrlBuilder:d,className:c}){const{t:u}=j.useTranslation(),m=r??am[e.aggregationType??""]??"",p=function(e,a){if(null==e)return"—";const t=Uu.includes(a.field),s=a.aggregationType===exports.AggregationType.Count||a.aggregationType===exports.AggregationType.DistinctCount;return t&&!s?Hu.format("string"==typeof e?parseFloat(e):e):"number"==typeof e?s?String(e):e.toLocaleString("pt-BR",{maximumFractionDigits:2}):String(e)}(s,e);return a.jsxs("div",{className:Yt("flex h-full flex-col",c),children:[a.jsx(Ku,{config:e,viewOnly:n,onRefresh:i,queryUrlBuilder:d}),t===exports.PanelState.Loading&&a.jsx(Ju,{}),t===exports.PanelState.Loaded&&a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center",o&&"cursor-pointer hover:bg-muted/20 transition-colors"),onClick:o,children:[a.jsx("span",{className:"text-[clamp(1.5rem,7vh,5rem)] font-bold text-foreground leading-tight",children:p}),m&&a.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:m})]}),t===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:l}),t===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function sm({config:e,state:t,htmlContent:s,viewOnly:r=!1,onRefresh:n,queryUrl:o,queryUrlBuilder:i,className:l}){const d=s??e.textTypeString??"";return a.jsxs("div",{className:Yt("flex h-full flex-col",l),children:[a.jsx(Ku,{config:e,viewOnly:r,onRefresh:n,queryUrlBuilder:i}),t===exports.PanelState.Loading&&a.jsx(Ju,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 prose prose-sm max-w-none text-foreground",dangerouslySetInnerHTML:{__html:d}}),t===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:o})]})}function rm({config:e,state:s,data:r=[],columns:n=[],viewOnly:o=!1,onRowClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,enableRowLinks:m=!0,className:p}){const h=t.useMemo(()=>n.filter(e=>!1!==e.visible),[n]),x=t.useCallback(e=>{if(i)i(e);else if(m){const a=qu(e);a&&window.open(Bu(a),"_blank")}},[i,m]);return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Ku,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(Ju,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 bg-muted/60 backdrop-blur-sm",children:a.jsx("tr",{children:h.map(e=>a.jsx("th",{className:"px-2 py-1.5 text-left text-xs font-medium text-muted-foreground whitespace-nowrap border-b",children:e.header||e.columnLabel||e.columnName},e.columnName))})}),a.jsx("tbody",{children:r.map((e,t)=>{const s=m&&!!qu(e);return a.jsx("tr",{className:Yt("border-b border-border/50 transition-colors hover:bg-muted/30",(s||i)&&"cursor-pointer"),onClick:()=>x(e),children:h.map(t=>a.jsx("td",{className:"px-2 py-1.5 text-foreground whitespace-nowrap truncate max-w-[200px]",children:t.render?t.render(e[t.columnName],e):nm(e[t.columnName],t)},t.columnName))},t)})})]})}),s===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function nm(e,a){return null==e?"":e instanceof Date?"datetime"===a.columnType?e.toLocaleString("pt-BR"):e.toLocaleDateString("pt-BR"):"number"==typeof e?e.toLocaleString("pt-BR"):String(e)}const om=["hsl(var(--primary))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))","#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3"];function im({config:e,variant:s,state:r,data:n=[],series:o,colors:i,categoryKey:l="key",yAxisFormat:d,viewOnly:c=!1,onPointClick:u,onRefresh:m,onExport:p,queryUrl:h,queryUrlBuilder:x,className:f}){const g=i?.length?i:e.hexColors?.length?e.hexColors:om,v=t.useMemo(()=>o?.length?o:[{dataKey:"value",name:e.title}],[o,e.title]),b="bar"===s,j="stacked-column"===s,y=t.useMemo(()=>{if(d)return e=>d.replace("{value}",e.toLocaleString("pt-BR"))},[d]);return a.jsxs("div",{className:Yt("flex h-full flex-col",f),children:[a.jsx(Ku,{config:e,viewOnly:c,onRefresh:m,onExport:p,queryUrlBuilder:x}),r===exports.PanelState.Loading&&a.jsx(Ju,{}),r===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:lm({variant:s,data:n,series:v,colors:g,categoryKey:l,isHorizontalBar:b,isStacked:j,yAxisTickFormatter:y,tooltipFormatter:e=>"number"==typeof e?e.toLocaleString("pt-BR"):String(e??""),onPointClick:u})})}),r===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),r===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:h}),r===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function lm({variant:e,data:t,series:s,colors:r,categoryKey:n,isHorizontalBar:o,isStacked:i,yAxisTickFormatter:l,tooltipFormatter:d,onPointClick:c}){const u={tick:{fontSize:11},tickLine:!1,axisLine:!1},m=a.jsx(q.XAxis,{dataKey:o?void 0:n,type:o?"number":"category",...u,angle:o?0:-45,textAnchor:o?"middle":"end",height:o?void 0:60,tickFormatter:o?l:void 0}),p=a.jsx(q.YAxis,{dataKey:o?n:void 0,type:o?"category":"number",...u,width:o?100:60,tickFormatter:o?void 0:l}),h=a.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),x=a.jsx(q.Tooltip,{formatter:d,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),f=s.length>1?a.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}):null,g=c?(e,a)=>c(t[a],a):void 0;return"bar"===e||"column"===e||"stacked-column"===e?a.jsxs(q.BarChart,{data:t,layout:o?"vertical":"horizontal",margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(q.Bar,{dataKey:e.dataKey,name:e.name||e.dataKey,fill:e.color||r[t%r.length],stackId:i?e.stackId||"stack":void 0,radius:i?void 0:[2,2,0,0],onClick:g,cursor:c?"pointer":void 0},e.dataKey))]}):"area"===e?a.jsxs(q.AreaChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>{const s=e.color||r[t%r.length];return a.jsx(q.Area,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:s,fill:s,fillOpacity:.15,strokeWidth:2,dot:!1,activeDot:{r:4,cursor:c?"pointer":void 0}},e.dataKey)})]}):a.jsxs(q.LineChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(q.Line,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:e.color||r[t%r.length],strokeWidth:2,dot:{r:3},activeDot:{r:5,cursor:c?"pointer":void 0}},e.dataKey))]})}const dm=["#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3","#b2df8a","#fb9a99","#fdbf6f","#cab2d6","#ffff99"];function cm({config:e,state:s,data:r=[],colors:n,viewOnly:o=!1,onSliceClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,className:m}){const p=n?.length?n:e.hexColors?.length?e.hexColors:dm,h=t.useMemo(()=>r.map(e=>({...e,name:String(e.key??""),value:e.value??0})),[r]),x=t.useMemo(()=>h.reduce((e,a)=>e+(a.value??0),0),[h]);return a.jsxs("div",{className:Yt("flex h-full flex-col",m),children:[a.jsx(Ku,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(Ju,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(q.PieChart,{children:[a.jsx(q.Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:"80%",label:({name:e,percent:a})=>`${e??""}: ${(100*(a??0)).toFixed(0)}%`,labelLine:!0,onClick:i?(e,a)=>i(r[a],a):void 0,cursor:i?"pointer":void 0,children:h.map((e,t)=>a.jsx(q.Cell,{fill:p[t%p.length]},t))}),a.jsx(q.Tooltip,{formatter:e=>{const a="number"==typeof e?e:0,t=x>0?(a/x*100).toFixed(1):"0";return`${a.toLocaleString("pt-BR")} (${t}%)`}}),a.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}})]})})}),s===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function um({config:e,state:s,data:r=[],barColor:n,lineColor:o="#e31a1c",viewOnly:i=!1,onPointClick:l,onRefresh:d,onExport:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=e.hexColors?.length?e.hexColors:["#1f78b4"],x=n??h[0],f=t.useMemo(()=>{const e=[...r].sort((e,a)=>(a.value??0)-(e.value??0)),a=e.reduce((e,a)=>e+(a.value??0),0);let t=0;return e.map(e=>(t+=e.value??0,{key:String(e.key??""),value:e.value??0,cumulativePercent:a>0?Math.round(t/a*100):0}))},[r]);return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Ku,{config:e,viewOnly:i,onRefresh:d,onExport:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(Ju,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(q.ComposedChart,{data:f,margin:{top:5,right:30,left:0,bottom:5},children:[a.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(q.XAxis,{dataKey:"key",tick:{fontSize:11},angle:-45,textAnchor:"end",height:60}),a.jsx(q.YAxis,{yAxisId:"left",tick:{fontSize:11},tickLine:!1,axisLine:!1}),a.jsx(q.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(q.Tooltip,{formatter:(e,a)=>"% Acumulado"===a?`${e}%`:"number"==typeof e?e.toLocaleString("pt-BR"):e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(q.Bar,{yAxisId:"left",dataKey:"value",name:"Quantidade",fill:x,radius:[2,2,0,0],onClick:l?(e,a)=>l(r[a],a):void 0,cursor:l?"pointer":void 0}),a.jsx(q.Line,{yAxisId:"right",type:"monotone",dataKey:"cumulativePercent",name:"% Acumulado",stroke:o,strokeWidth:2,dot:{r:3,fill:o}})]})})}),s===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function mm({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onRefresh:d,queryUrl:c,queryUrlBuilder:u,className:m}){const{t:p}=j.useTranslation(),h=r??p("dashboard_work_done"),x=n??p("dashboard_work_planned");return a.jsxs("div",{className:Yt("flex h-full flex-col",m),children:[a.jsx(Ku,{config:e,viewOnly:l,onRefresh:d,queryUrlBuilder:u}),t===exports.PanelState.Loading&&a.jsx(Ju,{panelType:exports.DashboardPanelType.Burndown}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(q.AreaChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(q.XAxis,{dataKey:"date",tick:{fontSize:10},angle:-45,textAnchor:"end",height:50}),a.jsx(q.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(q.Tooltip,{formatter:e=>`${e}%`,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(q.Area,{type:"monotone",dataKey:"executedPercentage",name:h,stroke:o,fill:o,fillOpacity:.2,strokeWidth:2,dot:{r:3}}),a.jsx(q.Area,{type:"monotone",dataKey:"plannedPercentage",name:x,stroke:i,fill:i,fillOpacity:.1,strokeWidth:2,dot:{r:3}})]})})}),t===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:c}),t===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function pm({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onPointClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const{t:h}=j.useTranslation(),x=r??h("dashboard_work_done"),f=n??h("dashboard_work_planned");return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Ku,{config:e,viewOnly:l,onRefresh:c,queryUrlBuilder:m}),t===exports.PanelState.Loading&&a.jsx(Ju,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(q.BarChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(q.XAxis,{dataKey:"name",tick:{fontSize:10},angle:-45,textAnchor:"end",height:60}),a.jsx(q.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`}),a.jsx(q.Tooltip,{formatter:e=>"number"==typeof e?`${e}%`:e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(q.Bar,{dataKey:"executedWork",name:x,fill:o,radius:[2,2,0,0],onClick:d?(e,a)=>d(s[a],a):void 0,cursor:d?"pointer":void 0}),a.jsx(q.Bar,{dataKey:"plannedWork",name:f,fill:i,radius:[2,2,0,0]})]})})}),t===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:u}),t===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}function hm({config:e,state:s,rule:r,risks:n=[],matrixViewType:o=exports.MatrixViewType.Quantity,viewOnly:i=!1,onCellClick:l,onRiskClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=t.useMemo(()=>[...r?.parametersY??[]].sort((e,a)=>a.position-e.position),[r?.parametersY]),x=r?.parametersX??[],f=t.useMemo(()=>{const e={};return n.forEach(a=>{const t=`${a.parameterYPosition}-${a.parameterXPosition}`;e[t]||(e[t]=[]),e[t].push(a)}),e},[n]);return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Ku,{config:e,viewOnly:i,onRefresh:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(Ju,{}),s===exports.PanelState.Loaded&&r&&a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsxs("div",{className:"flex gap-4 items-stretch min-w-fit",children:[a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"text-xs font-medium text-muted-foreground [writing-mode:vertical-lr] rotate-180",children:r.name_y})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex mb-1",children:[a.jsx("div",{className:"w-16 shrink-0"}),a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.threat_strategy_type_name}),!r.disable_opportunities&&a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.opportunity_strategy_type_name})]}),h.map((e,t)=>a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0 flex items-center justify-center border border-border/50 text-xs font-medium p-1 text-center",children:e.name}),x.map((s,n)=>{const i=((e,a)=>f[`${a.position}-${e.position}`]??[])(s,e),c=((e,a)=>r?.colorMatrix?.[a]?.[e]??"hsl(var(--muted))")(n,t);return a.jsxs("div",{className:Yt("flex-1 min-w-[60px] min-h-[40px] border border-border/50 flex flex-col items-center justify-center gap-0.5 p-1",(l||d)&&i.length>0&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:c},onClick:()=>i.length>0&&l?.(s,e,i),children:[o===exports.MatrixViewType.Quantity&&i.length>0&&a.jsxs("span",{className:"text-xs font-semibold",children:[i.length," risco",1!==i.length?"s":""]}),o===exports.MatrixViewType.AllRisksList&&i.map(e=>a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{type:"button",className:"text-[10px] text-primary underline hover:text-primary/80",onClick:a=>{a.stopPropagation(),d?.(e)},children:e.code})}),a.jsxs(Nr,{className:"max-w-[250px]",children:[a.jsxs("p",{className:"font-medium",children:[e.code," - ",e.name]}),e.analysisDate&&a.jsxs("p",{className:"text-xs mt-1",children:["Última análise: ",a.jsx("strong",{children:e.analysisDate})]}),e.strategy&&a.jsxs("p",{className:"text-xs",children:["Estratégia: ",a.jsx("strong",{children:e.strategy})]}),e.resultName&&a.jsxs("p",{className:"text-xs",children:["Criticidade: ",a.jsx("strong",{style:{backgroundColor:c},className:"px-1 rounded",children:e.resultName})]})]})]},e.code))]},s.position)})]},e.position)),a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0"}),x.map(e=>a.jsx("div",{className:"flex-1 min-w-[60px] border border-border/50 text-xs font-medium p-1 text-center",children:e.name},e.position))]}),a.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground mt-2",children:r.name_x})]})]})}),s===exports.PanelState.NoData&&a.jsx(Zu,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Xu,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(em,{onRemove:()=>e.onRemove?.(e.id)})]})}const xm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:a,y:t}=e;return"translate3d("+(a?Math.round(a):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:a,scaleY:t}=e;return"scaleX("+a+") scaleY("+t+")"}},Transform:{toString(e){if(e)return[xm.Translate.toString(e),xm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:a,duration:t,easing:s}=e;return a+" "+t+"ms "+s}}});function fm(e){switch(Number(e)){case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Numeric:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.Text:return{x:1,y:1};default:return{x:2,y:2}}}function gm({panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:i}){const{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:m,isDragging:p}=J.useSortable({id:e.id,disabled:!o}),h=t.useMemo(()=>({gridColumn:`${e.col+1} / span ${e.sizeX}`,gridRow:`${e.row+1} / span ${e.sizeY}`,minHeight:e.sizeY*r+(e.sizeY-1)*n+"px",transform:xm.Transform.toString(u),transition:m,zIndex:p?50:void 0,opacity:p?.85:1}),[e,s,r,n,u,m,p]);return a.jsxs("div",{ref:c,style:h,className:Yt("rounded-lg border border-border bg-card shadow-sm overflow-hidden","transition-shadow duration-200",p&&"shadow-lg ring-2 ring-primary/20"),...l,children:[a.jsx("div",{className:Yt("dashboard-panel-drag-handle",o&&"cursor-grab active:cursor-grabbing"),...o?d:{}}),a.jsx("div",{className:"h-full",children:i})]})}function vm({panels:e,columns:s=8,cellHeight:r=160,cellGap:n=10,allowDragging:o=!1,showGridLines:i=!1,renderPanel:l,onLayoutChange:d,className:c}){const[u,m]=t.useState(e);t.useMemo(()=>{m(e)},[e]);const p=X.useSensors(X.useSensor(X.PointerSensor,{activationConstraint:{distance:8}})),h=t.useMemo(()=>0===u.length?1:Math.max(...u.map(e=>e.row+e.sizeY)),[u]),x=t.useMemo(()=>u.map(e=>e.id),[u]),f=t.useCallback(e=>{const{active:a,over:t}=e;if(!t||a.id===t.id)return;const s=u.findIndex(e=>e.id===a.id),r=u.findIndex(e=>e.id===t.id);if(-1===s||-1===r)return;const n=[...u],o={...n[s]},i={...n[r]},l=o.col,c=o.row;o.col=i.col,o.row=i.row,i.col=l,i.row=c,n[s]=o,n[r]=i,m(n),d?.(n)},[u,d]),g=t.useMemo(()=>({display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gridTemplateRows:`repeat(${h}, ${r}px)`,gap:`${n}px`}),[s,h,r,n]);return 0===u.length?a.jsxs("div",{className:Yt("flex flex-col items-center justify-center py-16 text-center",c),children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Nenhum painel adicionado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione painéis para visualizar seus dados aqui."})]}):a.jsx(X.DndContext,{sensors:p,collisionDetection:X.closestCenter,onDragEnd:f,children:a.jsx(J.SortableContext,{items:x,strategy:J.rectSortingStrategy,children:a.jsx("div",{style:g,className:Yt("relative w-full",i&&"bg-muted/30",c),children:u.map(e=>a.jsx(gm,{panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:l(e.id)},e.id))})})})}const bm={[exports.DashboardPanelType.Bar]:"bar",[exports.DashboardPanelType.Column]:"column",[exports.DashboardPanelType.StackedColumn]:"stacked-column",[exports.DashboardPanelType.Area]:"area",[exports.DashboardPanelType.Line]:"line",[exports.DashboardPanelType.EvolutionLine]:"evolution-line"};function jm({config:e,state:t,data:s,numericValue:r,listColumns:n,cartesianData:o,cartesianSeries:i,burndownData:l,performanceData:d,matrixRule:c,matrixRisks:u,onPanelClick:m}){const p=bm[e.typeId];if(p)return a.jsx(im,{config:e,variant:p,state:t,data:o,series:i});switch(e.typeId){case exports.DashboardPanelType.Numeric:return a.jsx(tm,{config:e,state:t,value:r});case exports.DashboardPanelType.Text:return a.jsx(sm,{config:e,state:t});case exports.DashboardPanelType.List:return a.jsx(rm,{config:e,state:t,data:s,columns:n??[]});case exports.DashboardPanelType.Pie:return a.jsx(cm,{config:e,state:t,data:s});case exports.DashboardPanelType.Pareto:return a.jsx(um,{config:e,state:t,data:s});case exports.DashboardPanelType.Burndown:return a.jsx(mm,{config:e,state:t,data:l});case exports.DashboardPanelType.PerformanceColumns:return a.jsx(pm,{config:e,state:t,data:d});case exports.DashboardPanelType.RiskMatrix:return a.jsx(hm,{config:e,state:t,rule:c,risks:u??[]});default:return a.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:["Tipo de painel não suportado (",e.typeId,")"]})}}function ym({dashboard:e,panels:s,pages:r,activePageId:n,canEdit:o=!1,isFullscreen:i=!1,isLoading:l=!1,getPanelData:d,onRefresh:c,onToggleFullscreen:u,onToggleFavorite:m,onEdit:p,onShare:h,onAddPanel:x,onEditPanel:f,onRemovePanel:g,onDuplicatePanel:v,onLayoutChange:b,onPageChange:y,toolbarActions:w,className:N}){const{t:_}=j.useTranslation(),[C,k]=t.useState(!1),S=e.idViewType===exports.DashboardViewType.Carousel,T=t.useMemo(()=>s,[s,S,n]),P=t.useMemo(()=>T.map(e=>{const a=fm(e.typeId);return{id:e.id,col:e.col,row:e.row,sizeX:e.sizeX,sizeY:e.sizeY,minSizeX:a.x,minSizeY:a.y}}),[T]),D=t.useCallback(e=>({id:e.id,title:e.titlePtBr||e.titleEnUs||e.titleEsEs,typeId:e.typeId,queryId:e.queryId,queryContextId:e.queryContextId,queryTitle:e.queryTitle,querySelectedColumns:e.querySelectedColumns,field:e.field??"",fieldType:e.fieldType??"",fieldAuxAxis:e.fieldAuxAxis,fieldAuxAxisType:e.fieldAuxAxisType,aggregationType:e.aggregationType,textTypeString:e.textTypeString,referenceDate:e.referenceDate,period:e.period,initialDate:e.initialDate,finalDate:e.finalDate,dimension:e.dimension,yAxis:e.yAxis,yAxisType:e.yAxisType,orderBy:e.orderBy,orderByType:e.orderByType,secondaryGrouping:e.secondaryGrouping,secondaryGroupingType:e.secondaryGroupingType,onlyLate:e.onlyLate,jsonRules:e.jsonRules,ignoreRules:e.ignoreRules,visualizationType:e.visualizationType,sortType:e.sortType,itemsPerPanel:e.itemsPerPanel,secondaryItemsPerPanel:e.secondaryItemsPerPanel,matrixViewRule:e.matrixViewRule,listPanelColumns:e.listPanelColumns,listPanelListType:e.listPanelListType,paletteId:e.paletteId,hexColors:e.hexColors,showNotInformedData:e.showNotInformedData,fieldAnalysisRule:e.fieldAnalysisRule,fieldCriticality:e.fieldCriticality,fieldPlansType:e.fieldPlansType,fieldPlansSelected:e.fieldPlansSelected,fieldPlansBurndown:e.fieldPlansBurndown,fieldPlansBurndownGroup:e.fieldPlansBurndownGroup,analysisCriteriaId:e.analysisCriteriaId,analysisCriteriaParameter:e.analysisCriteriaParameter,evolutionSecondaryGrouping:e.evolutionSecondaryGrouping,canUpdate:o,hasRemovedColumn:e.hasRemovedColumn,panelSize:{x:e.sizeX,y:e.sizeY},onEdit:f,onRemove:g,onDuplicate:v}),[o,f,g,v]),E=t.useCallback(()=>{C||l||(k(!0),c?.(),setTimeout(()=>k(!1),3e4))},[C,l,c]),A=t.useCallback(e=>{const t=T.find(a=>a.id===e);if(!t)return null;const s=D(t),r=d?.(e)??{state:exports.PanelState.Loaded};return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(Ku,{config:s,onRefresh:()=>{}}),a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(jm,{config:s,...r})})]})},[T,D,d,o,f,g,v]);return a.jsxs("div",{className:Yt("flex flex-col h-full",i&&"fixed inset-0 z-50 bg-background",N),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:e.title}),e.responsibleName&&!i&&a.jsx("span",{className:"text-xs text-muted-foreground truncate hidden sm:inline",children:e.responsibleName})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[w,c&&a.jsx("button",{onClick:E,disabled:C||l,className:Yt("inline-flex items-center justify-center rounded-md p-2 text-sm","hover:bg-accent hover:text-accent-foreground transition-colors","disabled:opacity-50 disabled:pointer-events-none"),title:C?_("dashboard_wait_refresh"):"Atualizar",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m0 0a9 9 0 0 1 9-9m-9 9a9 9 0 0 0 9 9"})})}),u&&a.jsx("button",{onClick:u,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:i?_("dashboard_exit_fullscreen"):"Fullscreen",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i?a.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"}):a.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),o&&!i&&h&&a.jsx("button",{onClick:h,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:"Compartilhar",children:a.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),m&&!i&&a.jsx("button",{onClick:m,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:e.isFavorite?_("dashboard_remove_favorite"):"Favoritar",children:a.jsx("svg",{className:Yt("h-4 w-4",e.isFavorite&&"fill-yellow-400 text-yellow-400"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})]})]}),S&&r&&r.length>1&&a.jsx("div",{className:"flex items-center gap-1 px-4 py-1 border-b border-border bg-card overflow-x-auto",children:r.map(e=>a.jsx("button",{onClick:()=>y?.(e.id),className:Yt("px-3 py-1.5 text-sm rounded-md whitespace-nowrap transition-colors",n===e.id?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:e.name||`Dashboard ${e.position}`},e.id))}),o&&!i&&x&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsxs("button",{onClick:x,className:Yt("inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Adicionar painel"]})}),l&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!l&&a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted/30",children:a.jsx(vm,{panels:P,allowDragging:o,showGridLines:o,renderPanel:A,onLayoutChange:b})})]})}function wm(e,a=exports.DashboardLanguage.PtBr){const{t:t}=j.useTranslation();switch(a){case exports.DashboardLanguage.EnUs:return e.titleEnUs||e.titlePtBr||e.titleEsEs;case exports.DashboardLanguage.EsEs:return e.titleEsEs||e.titleEnUs||e.titlePtBr;default:return e.titlePtBr||e.titleEnUs||e.titleEsEs}}function Nm(e){const{t:a}=j.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}const _m=[{value:exports.QuickFilterDashboard.All,label:"Todos"},{value:exports.QuickFilterDashboard.OnlyMine,label:e.t("dashboard_my")},{value:exports.QuickFilterDashboard.Favorites,label:"Favoritos"}];function Cm({dashboards:e,limit:s,isLoading:r=!1,language:n=exports.DashboardLanguage.PtBr,canAdd:o=!1,canEdit:i=!1,canRemove:l=!1,onOpen:d,onEdit:c,onShare:u,onDuplicate:m,onRemove:p,onAdd:h,onToggleFavorite:x,onRefresh:f,onSearch:g,onQuickFilterChange:v,toolbarExtra:b,className:y}){const{t:w}=j.useTranslation(),[N,_]=t.useState(""),[C,k]=t.useState(exports.QuickFilterDashboard.All),[S,T]=t.useState(null),P=t.useCallback(e=>{_(e),g?.(e)},[g]),D=t.useCallback(e=>{k(e),v?.(e)},[v]),E=t.useMemo(()=>{let a=e;if(N){const e=N.toLowerCase();a=a.filter(a=>a.code?.toLowerCase().includes(e)||wm(a,n).toLowerCase().includes(e)||a.responsibleName?.toLowerCase().includes(e))}switch(C){case exports.QuickFilterDashboard.OnlyMine:break;case exports.QuickFilterDashboard.Favorites:a=a.filter(e=>e.isFavorite)}return a},[e,N,C,n]);return a.jsxs("div",{className:Yt("flex flex-col h-full",y),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboards"}),s&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.countDashboards,"/",s.maxDashboards,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative",children:[a.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"m21 21-4.3-4.3"})]}),a.jsx("input",{type:"text",placeholder:"Buscar...",value:N,onChange:e=>P(e.target.value),className:Yt("h-9 w-48 rounded-md border border-input bg-background pl-9 pr-3 text-sm","placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")})]}),b,o&&h&&a.jsxs("button",{onClick:h,className:Yt("inline-flex items-center gap-1.5 px-3 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Novo"]})]})]}),a.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-card",children:_m.map(e=>a.jsx("button",{onClick:()=>D(e.value),disabled:r,className:Yt("px-3 py-1.5 text-sm rounded-md transition-colors",C===e.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground","disabled:opacity-50"),children:e.label},e.value))}),r&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!r&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-muted/80 backdrop-blur-sm border-b border-border",children:a.jsxs("tr",{children:[a.jsx("th",{className:"w-12 px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Código"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Título"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Responsável"}),a.jsx("th",{className:"w-12 px-3 py-2 text-center font-medium text-muted-foreground",children:a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Última modificação"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Situação"}),a.jsx("th",{className:"w-12 px-3 py-2"})]})}),a.jsxs("tbody",{children:[0===E.length&&a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-3 py-12 text-center text-muted-foreground",children:"Nenhum dashboard encontrado."})}),E.map(e=>a.jsxs("tr",{onClick:()=>d?.(e),className:Yt("border-b border-border cursor-pointer transition-colors","hover:bg-accent/50"),children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),x?.(e)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsx("svg",{className:Yt("h-4 w-4",e.isFavorite?"fill-yellow-400 text-yellow-400":"text-muted-foreground"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-foreground",children:e.code}),a.jsx("td",{className:"px-3 py-2 text-foreground font-medium",children:wm(e,n)}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:e.responsibleName}),a.jsx("td",{className:"px-3 py-2 text-center",children:e.hasSharedIcon&&a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:Nm(e.lastModified)}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("span",{className:Yt("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",e.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),children:e.isActive?"Ativo":"Inativo"})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(S===e.id?null:e.id)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsxs("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"5",r:"1"}),a.jsx("circle",{cx:"12",cy:"12",r:"1"}),a.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),S===e.id&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>T(null)}),a.jsxs("div",{className:"absolute right-0 top-8 z-50 min-w-[160px] rounded-md border border-border bg-popover shadow-md py-1",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),d?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Abrir"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),c?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Editar"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),u?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Compartilhar"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),m?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Duplicar"}),l&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"my-1 border-t border-border"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),p?.(e)},className:"w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-destructive/10 transition-colors",children:"Remover"})]})]})]})]})})]},e.id))]})]})})]})}const km=[{value:exports.DashboardUpdateTime.NotUpdate,label:e.t("dashboard_no_refresh")},{value:exports.DashboardUpdateTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardUpdateTime.TenMinutes,label:"10 minutos"},{value:exports.DashboardUpdateTime.FifteenMinutes,label:"15 minutos"},{value:exports.DashboardUpdateTime.ThirtyMinutes,label:"30 minutos"},{value:exports.DashboardUpdateTime.OneHour,label:"1 hora"}],Sm=[{value:exports.DashboardViewType.NormalPage,label:e.t("dashboard_normal_page")},{value:exports.DashboardViewType.Carousel,label:"Carrossel"}],Tm=[{value:exports.DashboardPageTime.FiveSeconds,label:"5 segundos"},{value:exports.DashboardPageTime.TenSeconds,label:"10 segundos"},{value:exports.DashboardPageTime.FifteenSeconds,label:"15 segundos"},{value:exports.DashboardPageTime.ThirtySeconds,label:"30 segundos"},{value:exports.DashboardPageTime.OneMinute,label:"1 minuto"},{value:exports.DashboardPageTime.ThreeMinutes,label:"3 minutos"},{value:exports.DashboardPageTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardPageTime.TenMinutes,label:"10 minutos"}],Pm=[{value:exports.DashboardShareType.NotShared,label:e.t("dashboard_not_shared"),description:e.t("dashboard_only_responsible")},{value:exports.DashboardShareType.SharedWithAllCollaborators,label:e.t("dashboard_shared_unit"),description:e.t("dashboard_all_access")},{value:exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators,label:e.t("dashboard_select_groups"),description:e.t("dashboard_select_groups")}],Dm=[{key:"pt-br",label:"PT-BR"},{key:"en",label:"EN-US"},{key:"es",label:"ES-ES"}];function Em({dashboard:e,initialTab:s=exports.DashboardFormTab.General,isSaving:r=!1,isQualitfy:n=!1,users:o=[],groups:i=[],places:l=[],collaborators:d=[],onSave:c,onCancel:u,className:m}){const{t:p}=j.useTranslation(),h=!!e,[x,f]=t.useState(s),[g,v]=t.useState({"pt-br":!!e?.titlePtBr||!h,en:!!e?.titleEnUs,es:!!e?.titleEsEs}),[b,y]=t.useState(e?.titlePtBr??""),[w,N]=t.useState(e?.titleEnUs??""),[_,C]=t.useState(e?.titleEsEs??""),[k,S]=t.useState(e?.responsibleId??""),[T,P]=t.useState(e?.isActive??!0),[D,E]=t.useState(e?.idUpdateTime??exports.DashboardUpdateTime.NotUpdate),[A,I]=t.useState(e?.idViewType??exports.DashboardViewType.NormalPage),[M,F]=t.useState(e?.idPageTime??exports.DashboardPageTime.FifteenSeconds),[R,L]=t.useState(e?.idShare??exports.DashboardShareType.NotShared),[z,U]=t.useState(e?.groups??[]),[O,V]=t.useState(e?.places??[]),[B,q]=t.useState(e?.collaborators??[]),$=A===exports.DashboardViewType.Carousel,W=g["pt-br"]||g.en||g.es,H=t.useMemo(()=>!!W&&(!(g["pt-br"]&&!b.trim())&&(!(g.en&&!w.trim())&&!(g.es&&!_.trim()))),[W,g,b,w,_]),G=t.useCallback(e=>{v(a=>({...a,[e]:!a[e]}))},[]),Y=t.useCallback(()=>{H&&!r&&c?.({titlePtBr:g["pt-br"]?b:"",titleEnUs:g.en?w:"",titleEsEs:g.es?_:"",responsibleId:k||void 0,isActive:T,idUpdateTime:D,idViewType:A,idPageTime:$?M:null,idShare:R,groups:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?z:[],places:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?O:[],collaborators:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?B:[]})},[H,r,c,g,b,w,_,k,T,D,A,M,$,R,z,O,B]);return a.jsxs("div",{className:Yt("flex flex-col h-full bg-background",m),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p(h?"dashboard_edit":"dashboard_new")}),h&&e&&a.jsx("span",{className:"text-sm text-muted-foreground",children:e.code})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:u,className:"px-3 py-2 text-sm rounded-md border border-input hover:bg-accent transition-colors",children:"Cancelar"}),a.jsxs("button",{onClick:Y,disabled:!H||r,className:Yt("inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors","disabled:opacity-50 disabled:pointer-events-none"),children:[r?a.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"}):a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Salvar"]})]})]}),a.jsxs("div",{className:"flex border-b border-border bg-card",children:[a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.General),className:Yt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.General?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Geral"}),a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.Share),className:Yt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.Share?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Compartilhamento"})]}),a.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x===exports.DashboardFormTab.General&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium text-foreground",children:"Título *"}),a.jsx("div",{className:"flex gap-2",children:Dm.map(e=>a.jsx("button",{onClick:()=>G(e.key),className:Yt("px-3 py-1 text-xs rounded-md border transition-colors",g[e.key]?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:bg-accent"),children:e.label},e.key))}),!W&&a.jsx("p",{className:"text-xs text-destructive",children:"Selecione pelo menos um idioma"})]}),g["pt-br"]&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Português (BR)"}),a.jsx("input",{value:b,onChange:e=>y(e.target.value),maxLength:200,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[b.length,"/200"]})]}),g.en&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Inglês (US)"}),a.jsx("input",{value:w,onChange:e=>N(e.target.value),maxLength:200,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[w.length,"/200"]})]}),g.es&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Espanhol (ES)"}),a.jsx("input",{value:_,onChange:e=>C(e.target.value),maxLength:200,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[_.length,"/200"]})]}),!e?.isStandard&&o.length>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Responsável"}),a.jsxs("select",{value:k,onChange:e=>S(e.target.value),disabled:!h,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:[a.jsx("option",{value:"",children:"Selecione..."}),o.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Intervalo de atualização"}),a.jsx("select",{value:D,onChange:e=>E(Number(e.target.value)),disabled:n,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:km.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Situação"}),a.jsxs("div",{className:"flex items-center gap-3 h-10",children:[a.jsx("button",{onClick:()=>P(!T),disabled:e?.isGeneralViewUse,className:Yt("relative inline-flex h-6 w-11 items-center rounded-full transition-colors",T?"bg-primary":"bg-muted","disabled:opacity-50"),children:a.jsx("span",{className:Yt("inline-block h-4 w-4 rounded-full bg-white transition-transform",T?"translate-x-6":"translate-x-1")})}),a.jsx("span",{className:"text-sm text-foreground",children:T?"Ativo":"Inativo"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Tipo de visualização"}),a.jsx("select",{value:A,onChange:e=>I(Number(e.target.value)),disabled:n||$,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:Sm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),$&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Trocar página a cada"}),a.jsx("select",{value:M??"",onChange:e=>F(Number(e.target.value)),className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:Tm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]})]})]}),x===exports.DashboardFormTab.Share&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 border border-border",children:[a.jsxs("svg",{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 16v-4"}),a.jsx("path",{d:"M12 8h.01"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure quem pode visualizar este dashboard. O responsável sempre terá acesso."})]}),a.jsx("div",{className:"space-y-3",children:Pm.map(t=>a.jsxs("label",{className:Yt("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",R===t.value?"border-primary bg-primary/5":"border-border hover:bg-accent/50",e?.isGeneralViewUse&&"opacity-50 pointer-events-none"),children:[a.jsx("input",{type:"radio",name:"shareType",value:t.value,checked:R===t.value,onChange:()=>L(t.value),disabled:e?.isGeneralViewUse,className:"mt-1 accent-primary"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:t.label}),a.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]})]},t.value))}),R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators&&a.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Grupos de usuários (",z.length,")"]}),a.jsx("select",{multiple:!0,value:z,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);U(a)},className:Yt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:i.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Locais (",O.length,")"]}),a.jsx("select",{multiple:!0,value:O,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);V(a)},className:Yt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:l.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Colaboradores (",B.length,")"]}),a.jsx("select",{multiple:!0,value:B,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);q(a)},className:Yt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:d.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]})]})]})]})]})}function Am({data:e,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:l,isLoading:c=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:v=!0,onColumnResize:b,enableColumnReorder:y=!1,onReorderColumns:w,storageKey:N,enableExpandableRows:_=!1,renderExpandedContent:C,expandedRowIds:k,onToggleExpand:S,defaultExpandAll:T=!1,rowActionsVariant:P="default",hideActionsColumn:D=!1,actionsHeaderContent:E}){const{t:A}=j.useTranslation(),I=u||A("no_items_found",A("no_items_found_empty")),[M,F]=t.useState(()=>T?new Set(e.map(e=>e.id)):new Set),R=void 0!==k,L=R?new Set(k):M,z=t.useCallback(e=>{R&&S?S(e):F(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[R,S]),{columnWidths:U,isDragging:O,activeColumn:V,handleMouseDown:B}=po({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:b,enabled:v}),q=No({enabled:y&&!!w,onReorder:w??(()=>{})}),$=t.useMemo(()=>{if(v){const e=s.map(e=>U[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return e.map(e=>e/a*100+"%")}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,v,U]);if(c)return a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>a.jsx(Rr,{className:"h-12 w-full"},t))})});if(0===e.length)return a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"text-center text-muted-foreground",children:a.jsx("p",{children:I})})});const W=l&&!D,H=(p?1:0)+(_?1:0)+s.length+(W?1:0);return a.jsx("div",{className:"flex-1 overflow-auto "+(O?"select-none":""),children:a.jsxs(In,{className:Yt("table-fixed w-full",m),children:[a.jsx(Mn,{className:"sticky top-0 bg-background z-10",children:a.jsxs(Ln,{children:[_&&a.jsx(zn,{className:"w-[40px]"}),p&&a.jsx(zn,{className:"w-[40px]",children:a.jsx(Xs,{checked:g,onCheckedChange:f,"aria-label":A("select_all","Selecionar todos")})}),s.map((e,t)=>{const s=v&&!1!==e.resizable,i=V===String(e.key),l=y&&!!w,c=l?q.getDragProps(t):{},u=q.dragFromIndex===t,m=q.dragOverIndex===t&&q.dragFromIndex!==t;return a.jsxs(zn,{className:Yt(e.className,"relative transition-opacity",e.sortable&&"cursor-pointer",l&&q.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:$[t]},...c,children:[!1!==e.sortable&&o?a.jsxs("button",{onClick:()=>o(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(p=String(e.key),r!==p?null:"asc"===n?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):a.jsx("span",{className:"font-medium",children:e.header}),s&&a.jsx(Hn,{direction:"horizontal",onMouseDown:a=>B(String(e.key),a),isDragging:i})]},String(e.key));var p}),W&&a.jsx(zn,{className:"w-[80px] text-right",children:E??A("actions","Ações")})]})}),a.jsx(Fn,{children:e.map(e=>{const r=_&&L.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(Ln,{onClick:()=>i?.(e),className:Yt(i?"cursor-pointer":"","relative","inline"===P&&"group"),children:[_&&a.jsx(Un,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),z(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":r?A("collapse_row","Recolher linha"):A("expand_row","Expandir linha"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),p&&a.jsx(Un,{children:a.jsx(Xs,{checked:h.includes(e.id),onCheckedChange:()=>x?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`${A("select_all","Selecionar todos")} ${e.id}`})}),s.map(t=>a.jsx(Un,{className:t.className,children:a.jsx(Wn,{children:t.render?t.render(e):String(e[t.key]??"-")})},String(t.key))),W&&a.jsx(Un,{className:"text-right",onClick:e=>e.stopPropagation(),children:"inline"===P?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:l(e)}):l(e)})]}),r&&C&&a.jsx(Ln,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(Un,{colSpan:H,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:C(e)})})})]},e.id)})})]})})}function Im({onEdit:e,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:l=[],renderAs:c="dropdown",variant:u="default"}){const{t:m}=j.useTranslation(),p=t.useMemo(()=>{const a=[];return e&&o&&a.push({key:"edit",icon:d.Edit,label:m("edit","Editar"),onClick:e,variant:"default"}),r&&a.push({key:"toggle-status",icon:n?d.PowerOff:d.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),l.forEach(e=>{!1!==e.show&&a.push({key:`custom-${e.label}`,icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),s&&i&&a.push({key:"delete",icon:d.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),a},[e,s,r,n,o,i,l,m]);return 0===p.length?null:"dropdown"===c?a.jsx(jr,{delayDuration:200,children:a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:a.jsx(d.EllipsisVertical,{size:"compact"===u?14:16})})}),a.jsx(pr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(e=>e.disabled?a.jsxs(_r,{disabledReason:e.disabledReason,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key):a.jsxs(hr,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key))})]})}):a.jsx("div",{className:"flex items-center gap-1",children:p.map(e=>a.jsxs(Xt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:e.onClick,className:"compact"===u?"h-7 px-2":"",children:[e.icon&&a.jsx(e.icon,{size:"compact"===u?14:16}),"compact"!==u&&a.jsx("span",{className:"ml-1",children:e.label})]},e.key))})}function Mm({searchValue:e="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=j.useTranslation(),l=e||s.length>0;return a.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{type:"text",placeholder:i("search","Pesquisar"),value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((e,t)=>a.jsx("div",{className:"vertical"===o?"w-full":"",children:e},t)),n&&l&&r&&a.jsxs(Xt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[a.jsx(d.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})}function Fm(e,a){const{t:t}=j.useTranslation(),s=new Set;function r(e){if(e)for(const a of e)s.add(a.id),r(a.children)}return function e(t){for(const s of t){if(s.id===a)return r(s.children),!0;if(s.children&&e(s.children))return!0}return!1}(e),s}function Rm({children:e,itemId:t,enableDrag:s,onDragStartCell:r,onDragEndCell:n,onDragOverCell:o,onDropCell:i,className:l}){return a.jsx(Un,{draggable:s,onDragStart:s?e=>r(t,e):void 0,onDragEnd:s?n:void 0,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(t,e)},className:l,children:e})}function Lm({item:e,level:t,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u="default",enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:j,onDropCell:y,dragCount:w}){const N=o.has(e.id),_=(e.children?.length??0)>0,C=24*t,k="inline"===u,S=f===e.id||p?.has(e.id)&&f&&p?.has(f),T=g===e.id&&f!==e.id,P=p?.has(e.id)??!1,D={itemId:e.id,enableDrag:x,onDragStartCell:v,onDragEndCell:b,onDragOverCell:j,onDropCell:y};return a.jsxs(a.Fragment,{children:[a.jsxs(Ln,{className:Yt(l&&"cursor-pointer",k&&"group",S&&"opacity-40",T&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:l?()=>l(e):void 0,children:[a.jsx(Rm,{...D,children:a.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${C}px`},children:[m&&a.jsx(Xs,{checked:P,onCheckedChange:()=>h?.(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),x&&a.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),_?a.jsx("button",{onClick:a=>{a.stopPropagation(),i(e.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:N?a.jsx(d.ChevronDown,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})}):a.jsx("div",{className:"w-6 shrink-0"}),n??a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"truncate",children:String(e[r]??e.id)}),f===e.id&&w&&w>1&&a.jsx("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary px-1.5 py-0 text-xs font-semibold text-primary-foreground",children:w})]})}),s.map(s=>{const r=e[s.key],n=s.render?s.render(e,t):null!=r?String(r):"—";return a.jsx(Rm,{...D,className:Yt("text-center",s.className),children:s.hoverContent?a.jsxs(Al,{openDelay:200,children:[a.jsx(Il,{asChild:!0,children:a.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),a.jsx(Ml,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:s.hoverContent(e)})]}):n},String(s.key))}),c&&a.jsx(Rm,{...D,className:"text-right",children:a.jsx("div",{onClick:e=>e.stopPropagation(),className:Yt("flex items-center justify-end gap-1",k&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:c(e)})})]}),_&&N&&e.children.map(e=>a.jsx(Lm,{item:e,level:t+1,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u,enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:j,onDropCell:y,dragCount:w},e.id))]})}function zm({onDrop:t,isDragOver:s,onDragOver:r,onDragLeave:n,label:o}){return a.jsxs("div",{className:Yt("absolute top-0 left-0 right-0 z-10 flex items-center justify-center gap-2 py-2 px-4 border-2 border-dashed rounded-md text-sm transition-colors mx-2 mt-2",s?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:r,onDragEnter:r,onDragLeave:n,onDrop:t,children:[a.jsx(d.ArrowUpToLine,{className:"h-4 w-4"}),o??e.t("leadership_make_root_short")]})}function Um({data:s,columns:r,nameKey:n,nameHeader:o=e.t("ap_name"),iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,actionsHeader:p="",rowActionsVariant:h="default",isLoading:x,emptyMessage:f="Nenhum registro encontrado.",className:g,enableSelection:v,selectedIds:b,onSelectItem:y,onSelectAll:w,isAllSelected:N,enableRowDrag:_,onMoveNode:C,onMoveNodes:k,rootDropLabel:S,actionsWidth:T=20,nameMinWidth:P=200}){const[D,E]=t.useState(null),[A,I]=t.useState(null),[M,F]=t.useState(!1),[R,L]=t.useState(1),z=t.useRef(null),U=t.useRef([]),O=t.useRef(null),V=t.useMemo(()=>new Set(b??[]),[b]),B=t.useMemo(()=>{if(!D||!s)return new Set;const e=U.current.length>0?U.current:[D],a=function(e,a){const{t:t}=j.useTranslation(),s=new Set;for(const r of a)Fm(e,r).forEach(e=>s.add(e));return s}(s,e);return e.forEach(e=>a.add(e)),a},[D,s]),q=t.useRef(B);q.current=B;const $=t.useCallback(()=>{z.current=null,U.current=[],O.current=null,E(null),I(null),F(!1),L(1)},[]),W=t.useCallback((e,a)=>{e.length>1&&k?k(e,a):1===e.length&&C?.(e[0],a)},[C,k]),H=t.useCallback((e,a)=>{const t=V.has(e)&&V.size>1?Array.from(V):[e];z.current=e,U.current=t,O.current=null,E(e),L(t.length),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t))},[V]),G=t.useCallback((e,a)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",q.current.has(e)?I(null):(O.current=e,I(e))},[]),Y=t.useCallback((e,a)=>{a.preventDefault(),a.stopPropagation();const t=q.current.has(e)?O.current:e;if(!t)return void $();let s=U.current;if(0===s.length){try{const e=a.dataTransfer.getData("application/x-tree-ids");if(e){const a=JSON.parse(e);Array.isArray(a)&&a.length>0&&(s=a)}}catch{}if(0===s.length){const e=a.dataTransfer.getData("text/plain");e&&(s=[e])}}0===s.length||s.includes(t)||W(s,t),$()},[W,$]),Q=t.useCallback(e=>{e.preventDefault(),e.stopPropagation();let a=U.current;if(0===a.length){try{const t=e.dataTransfer.getData("application/x-tree-ids");if(t){const e=JSON.parse(t);Array.isArray(e)&&e.length>0&&(a=e)}}catch{}if(0===a.length){const t=e.dataTransfer.getData("text/plain");t&&(a=[t])}}0!==a.length?(W(a,null),$()):$()},[W,$]),K=t.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",F(!0)},[]),X=t.useCallback(e=>{_&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[_]),J=t.useCallback(e=>{if(!_)return;const a=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-tree-row-id]"),t=a?.dataset?.treeRowId??O.current;t&&Y(t,e)},[_,Y]);if(x)return a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!s||0===s.length)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[a.jsx(d.User,{className:"h-10 w-10 text-muted-foreground/50"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:f})]});const Z=null!==D;return a.jsxs("div",{className:Yt("border rounded-lg overflow-hidden relative",g),onDragOver:X,onDrop:J,onDragLeave:_?e=>{const a=e.relatedTarget;a&&e.currentTarget.contains(a)||(I(null),F(!1))}:void 0,children:[_&&Z&&a.jsx(zm,{onDrop:Q,isDragOver:M,onDragOver:K,onDragLeave:()=>F(!1),label:S}),a.jsxs(In,{children:[a.jsx(Mn,{children:a.jsxs(Ln,{children:[a.jsx(zn,{className:"text-left",style:{minWidth:P},children:a.jsxs("div",{className:"flex items-center gap-2",children:[v&&a.jsx(Xs,{checked:N??!1,onCheckedChange:()=>w?.()}),o]})}),r.map(e=>a.jsx(zn,{className:Yt("text-center",e.className),style:e.width?{width:e.width}:void 0,children:e.header},String(e.key))),m&&a.jsx(zn,{className:"text-right",style:{width:T},children:p})]})}),a.jsx(Fn,{children:s.map(e=>a.jsx(Lm,{item:e,level:0,columns:r,nameKey:n,iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,rowActionsVariant:h,enableSelection:v,selectedIds:V,onSelectItem:y,enableRowDrag:_,draggedId:D,dragOverId:A,onDragStartCell:H,onDragEndCell:$,onDragOverCell:G,onDropCell:Y,dragCount:R},e.id))})]})]})}function Om(e){const a=N.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 Vm=[{value:"pt-BR",label:"Português (Brasil)"},{value:"en-US",label:"English (US)"},{value:"es-ES",label:"Español"}],Bm=({open:e,onOpenChange:s,user:r,userPhotoUrl:n,userInitials:o})=>{const{t:i,i18n:l}=j.useTranslation(),c=t.useRef(null),[u,m]=t.useState(null),[p,h]=t.useState(l.language||"pt-BR"),x=u||n,f=e=>{e||(m(null),h(l.language||"pt-BR")),s(e)};return a.jsx(js,{open:e,onOpenChange:f,children:a.jsxs(ks,{className:"sm:max-w-md",children:[a.jsx(Ss,{children:a.jsx(Ds,{children:i("edit_profile","Editar Perfil")})}),a.jsxs("div",{className:"space-y-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"relative flex-shrink-0",children:a.jsxs(nl,{className:"w-24 h-24",children:[x&&a.jsx(ol,{src:x,alt:r.name||""}),a.jsx(il,{className:"bg-primary text-primary-foreground font-semibold text-2xl",children:o})]})}),a.jsxs("div",{className:"space-y-1",children:[r.name&&a.jsx("p",{className:"text-base font-semibold",children:r.name}),r.email&&a.jsx("p",{className:"text-sm text-muted-foreground",children:r.email}),a.jsxs(Xt,{variant:"outline",size:"sm",onClick:()=>c.current?.click(),children:[a.jsx(d.Camera,{className:"mr-2 h-4 w-4"}),i("change_photo","Trocar foto")]}),a.jsx("input",{ref:c,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const a=e.target.files?.[0];if(!a)return;const t=URL.createObjectURL(a);m(t)}})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("language","Idioma")}),a.jsxs(Vs,{value:p,onValueChange:h,children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsx(Gs,{children:Vm.map(e=>a.jsx(Qs,{value:e.value,children:e.label},e.value))})]})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>f(!1),children:i("cancel","Cancelar")}),a.jsx(Xt,{onClick:()=>{p!==l.language&&l.changeLanguage(p),s(!1)},children:i("save","Salvar")})]})]})})},qm="true"===(void 0).VITE_SHOW_EDIT_PROFILE,$m=t.memo(({variant:e="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{t:o}=j.useTranslation(),{user:i,companies:l,alias:c,isAuthenticated:u,logout:m,switchUnit:p}=Pn(),{role:h}=Wi(),x=h?.name||null,f=l?.[0]||null,g=c?l?.find(e=>e.alias===c):f,v=l||[],b=r||g||f||f,y=t.useMemo(()=>{if(!i?.id)return null;const e=(new Date).toISOString().slice(0,10);return`https://login-api.qualiex.com/api/Users/Photo/${i.id}/${e}/1?size=48`},[i?.id]),w=t.useMemo(()=>{if(!i?.name)return"";const e=i.name.trim().split(/\s+/);return 1===e.length?e[0].charAt(0).toUpperCase():(e[0].charAt(0)+e[e.length-1].charAt(0)).toUpperCase()},[i?.name]),N=t.useCallback(e=>{n?n(e):p(e)},[n,p]),_=t.useMemo(()=>{if(!v?.length)return[];const e=new Map;v.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===b?.alias),s=a.filter(e=>e.alias!==b?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[v,b?.alias]),[C,k]=t.useState(!1);if(!u||!i)return null;return"dropdown"===e?a.jsxs(a.Fragment,{children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",className:`h-auto p-2 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10 ${s}`,children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("div",{className:"hidden md:block text-right",children:[a.jsxs("p",{className:"text-sm font-medium",children:[i.name?.split(" ")[0],x?` [${x}]`:""]}),a.jsx("p",{className:"text-xs text-primary-foreground/70",children:b?.name||"N/A"})]}),a.jsxs(nl,{className:"w-8 h-8 border border-primary-foreground/30",children:[y&&a.jsx(ol,{src:y,alt:i.name||o("user_photo")}),a.jsx(il,{className:"bg-primary-foreground/20 text-primary-foreground font-semibold text-xs",children:w||a.jsx(d.User,{className:"h-4 w-4"})})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),a.jsxs(pr,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[a.jsxs(dr,{children:[a.jsxs(ur,{children:[a.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),a.jsx(mr,{children:_.map(e=>a.jsxs(hr,{onClick:()=>N(e),className:e.alias===b?.alias?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===b?.alias&&a.jsx(er,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),qm&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:()=>k(!0),children:[a.jsx(d.UserPen,{className:"mr-2 h-4 w-4"}),o("edit_profile","Editar Perfil")]})]}),a.jsx(vr,{}),a.jsxs(hr,{onClick:m,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}),qm&&a.jsx(Bm,{open:C,onOpenChange:k,user:i,userPhotoUrl:y,userInitials:w})]}):a.jsxs(ts,{className:s,children:[a.jsx(ss,{children:a.jsx(rs,{className:"text-lg",children:o("user_info")})}),a.jsxs(os,{className:"space-y-4",children:[a.jsx(()=>a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsxs(nl,{className:"w-10 h-10",children:[y&&a.jsx(ol,{src:y,alt:i.name||o("user_photo")}),a.jsx(il,{className:"bg-primary text-primary-foreground text-white font-semibold text-sm",children:w||a.jsx(d.User,{className:"h-5 w-5"})})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",b?.name||"N/A"]})]})]}),b&&a.jsx("div",{className:"mt-3",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:b.name})]})}),_.length>1&&a.jsxs("div",{className:"mt-2",children:[a.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",_.length]}),a.jsxs("div",{className:"flex flex-wrap gap-1",children:[_.slice(0,3).map(e=>a.jsx(er,{variant:e.alias===b?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>N(e),children:e.name},e.alias)),_.length>3&&a.jsxs(er,{variant:"outline",className:"text-xs",children:["+",_.length-3]})]})]})]}),{}),a.jsx(ls,{}),a.jsxs(Xt,{variant:"outline",onClick:m,size:"sm",className:"w-full",children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Wm=t.createContext({});function Hm({children:e,config:s}){const r=t.useMemo(()=>{const e=Ie(),a=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:a}},[s?.navigation,s?.appName]);return a.jsx(Wm.Provider,{value:r,children:e})}function Gm(){return t.useContext(Wm)}function Ym(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 Qm(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]}function Km({appName:e}){const[s,r]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between w-[258px]",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>r(!0),children:a.jsx("img",{src:We.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),e&&a.jsx("button",{className:"min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground/80 hover:text-primary-foreground/60 transition-colors leading-tight py-1",onClick:()=>r(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(e)})})]}),a.jsx(Gi,{open:s,onOpenChange:r})]})}const Xm=t.memo(function({actions:s}){const r=N.useLocation(),n=N.useNavigate(),{navigation:o,appName:i}=Gm(),l=Ym(o,r.pathname),{metadata:c,headerActions:u}=si(),{setOpenMobile:m}=Md(),{companies:p,alias:h,isSearchVisible:x,clearSearch:f,refreshData:g,switchUnit:v}=Pn(),b=h?p?.find(e=>e.alias===h)||p?.[0]||null:p?.[0]||null,[j,y]=N.useSearchParams(),w=t.useCallback(e=>{const{pathname:a,search:t,hash:s}=r;if(h){const r=a.split("/"),o=r.indexOf(h);if(o>=0)return r[o]=e.alias,void n(r.join("/")+t+s)}v(e)},[h,r,n,v]),[_,C]=t.useState(()=>j.get("search")||""),[k,S]=Qm(_,Re.debounceDelay);t.useEffect(()=>{if(!x)return;const e=new URLSearchParams(j);k?(e.set("search",k),e.set("page","1")):e.delete("search"),y(e)},[k,y,x]);const T=o?.find(e=>e.path===r.pathname)||o?.find(e=>r.pathname.startsWith(e.path+"/")),P=c.title||l,D=c.subtitle||T?.complementaryText||e.t("item_details");return a.jsx("header",{className:"bg-primary border-b border-primary px-2 md:px-4 py-2",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Xt,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:()=>m(!0),children:a.jsx(d.Menu,{size:20})}),a.jsx("div",{className:"hidden md:flex items-center flex-shrink-0",children:a.jsx(Km,{appName:i})}),a.jsx("div",{className:"hidden md:block w-px h-8 bg-primary-foreground/20 flex-shrink-0"}),a.jsxs("div",{className:"flex-shrink-0",children:[c.breadcrumbs&&c.breadcrumbs.length>0&&a.jsx("nav",{className:"flex items-center gap-1 text-xs text-primary-foreground/70 mb-0.5",children:c.breadcrumbs.map((e,t)=>a.jsxs("span",{className:"flex items-center gap-1",children:[t>0&&a.jsx(d.ChevronRight,{className:"h-3 w-3"}),e.href?a.jsx(N.Link,{to:e.href,className:"hover:text-primary-foreground transition-colors",children:e.label}):a.jsx("span",{children:e.label})]},t))}),a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("h1",{className:"text-lg font-semibold text-primary-foreground truncate",children:P})}),D&&a.jsx("div",{className:"text-sm text-primary-foreground/70 truncate",children:D})]}),x&&a.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Zt,{placeholder:"Pesquisar",value:_,onChange:e=>{return a=e.target.value,void C(a);var a},className:"w-full pl-10 pr-8"}),_&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-primary-foreground/10 text-primary-foreground/60",onClick:()=>{S(),C("");const e=new URLSearchParams(j);e.delete("search"),e.delete("page"),y(e)},title:e.t("clear_search"),children:a.jsx(d.X,{size:14})})]}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0 bg-primary-foreground/20 border-primary-foreground/30 text-primary-foreground hover:bg-primary-foreground/30 hover:text-primary-foreground",title:e.t("refresh_data"),children:a.jsx(d.RefreshCw,{size:14})})]}),a.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(u||s)&&a.jsx("div",{className:"flex items-center gap-2",children:u||s}),(void 0).VITE_WIKI_URL&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"h-8 px-3 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:e=>Ht((void 0).VITE_WIKI_URL,e),title:e.t("open_wiki"),children:"Wiki"}),a.jsx(Gc,{}),a.jsx("div",{className:"text-sm",children:a.jsx($m,{variant:"dropdown",selectedUnit:b,onUnitChange:w})})]})]})})}),Jm=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>w.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1});function Zm({config:e,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{t:n}=j.useTranslation(),{actions:o,triggerLabel:i="Criar",triggerIcon:l=d.Plus,variant:c="button"}=e;if(!o||0===o.length)return null;if("split-button"===c){const e=o[0],n=e.icon||l,i=o.slice(1).map(e=>({id:e.id,label:e.label,icon:e.icon,onClick:e.onClick,disabled:e.disabled}));if(t){const t=a.jsx(Xt,{onClick:e.onClick,disabled:s||e.disabled,className:Yt("justify-center px-2 w-full",r),variant:"outline",size:"default",children:a.jsx(n,{className:"h-4 w-4 shrink-0"})});return a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:t}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})}return a.jsx(zc,{label:e.label,onClick:e.onClick,icon:n,actions:i,variant:"outline",disabled:s||e.disabled,className:Yt("w-full",r),menuAlign:"start"})}const u=(e,s,r=!1)=>a.jsxs(a.Fragment,{children:[e,!t&&s&&a.jsx("span",{className:"truncate",children:s}),!t&&r&&a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const e=o[0],n=e.icon||l,i=s||e.disabled,d=a.jsx(Xt,{onClick:e.onClick,disabled:i,className:Yt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(n,{className:"h-4 w-4 shrink-0"}),e.label)});return t?a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:d}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]}):d}const m=a.jsx(Xt,{disabled:s,className:Yt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(l,{className:"h-4 w-4 shrink-0"}),i,!0)});return a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:t?a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:m}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:i})})]}):m}),a.jsx(pr,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:o.map(e=>{const t=e.icon;return a.jsxs(hr,{onClick:e.onClick,disabled:e.disabled,className:"cursor-pointer",children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})}const ep="forlogic-sidebar-pinned",ap=()=>{try{const e=localStorage.getItem(ep);return!!e&&JSON.parse(e)}catch{return!1}};function tp({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=290,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,d]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,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","290px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!c)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),d(r),o?.(r)},r=()=>{u(!1),d(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[c,e,a,s,l,n,o]),t.useEffect(()=>(c?(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=""}),[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const sp=t.createContext(void 0);function rp(){const e=t.useContext(sp);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function np({config:e,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=j.useTranslation(),{open:l,setOpen:c,setOpenMobile:u}=Md(),m=N.useLocation(),{alias:p,user:h}=Pn(),{appName:x}=Gm(),{hasOpenModal:f}=rp(),[g,v]=t.useState(ap),b=An(),y=!!b||l,w=t.useCallback(()=>{b&&u(!1)},[b,u]),_=r?tp({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:l}):null;t.useEffect(()=>{c(!!g)},[g,c]);const C=e=>m.pathname===e||m.pathname.startsWith(e+"/");return a.jsxs(Rd,{collapsible:"icon",className:Yt("app-sidebar bg-background border-r border-border flex flex-col",y?"px-3":"px-1.5"),style:_&&y?{width:`${_.width}px`,transition:"none"}:{transition:"width 300ms ease-in-out"},children:[e?.moduleActions&&e.moduleActions.actions.length>0&&a.jsx("div",{className:"py-3",children:a.jsx(jr,{children:a.jsx(Zm,{config:e.moduleActions,isCollapsed:!y,isDisabled:f})})}),a.jsx($d,{className:Yt(e?.moduleActions&&e.moduleActions.actions.length>0?"pt-0":"pt-3"),children:s||a.jsx(Wd,{className:"p-0",children:a.jsx(Yd,{children:a.jsx(Qd,{className:"gap-1",children:a.jsx(jr,{children:e?.navigation?.map((e,t)=>{if("separator"===e.type)return a.jsx(qd,{className:"my-2"},`sep-${t}`);const s=({item:e,index:t})=>{const r=`${e.path}-${t}-${p??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:o}=Jm({key:r,enabled:Boolean(e.permissionCheck&&p&&h?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),l=e.permissionCheck&&!n,c=o?d.Loader2:l?d.Lock:e.icon;l?i("restricted_access"):e.complementaryText;return e.children&&e.children.length>0?y?a.jsx(gi,{defaultOpen:!0,className:"group/collapsible",children:a.jsxs(Kd,{children:[a.jsx(vi,{asChild:!0,children:a.jsx(Jd,{size:"default",children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label}),a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),a.jsx(bi,{children:a.jsx(tc,{children:e.children.map((e,t)=>a.jsx(s,{item:e,index:t},e.path))})})]})},e.path):a.jsx(Kd,{children:a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("div",{className:Yt("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:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path):a.jsx(Kd,{children:l||o?a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:y?a.jsx(Jd,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.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:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:o?"Verificando acesso...":i("restricted_access")})})]}):y?a.jsx(Jd,{asChild:!0,isActive:C(e.path),size:"default",children:a.jsxs(N.Link,{to:e.path,className:"flex w-full items-center gap-3",onClick:w,children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(N.Link,{to:e.path,onClick:w,className:Yt("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",C(e.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path)};return a.jsx(s,{item:e,index:t},e.path)})})})})})}),!b&&a.jsx("div",{className:Yt("mt-auto pb-4 pt-2 flex",l?"justify-end":"justify-center"),children:a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{onClick:()=>{const e=!g;v(e),(e=>{try{localStorage.setItem(ep,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:l?a.jsx(d.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:l?"Recolher":"Expandir"})})]})}),r&&_&&y&&a.jsx("div",{ref:_.dragRef,onMouseDown:_.handleMouseDown,className:Yt("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-['']",_.isDragging&&"bg-primary/40")})]})}const op=t.memo(function({children:e,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||a.jsx(np,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"290px","--sidebar-width-icon":"58px"}),[]),l=t.useRef(null),d=t.useRef(null),c=t.useCallback(()=>{if(l.current&&d.current){const e=l.current.offsetHeight;d.current.style.setProperty("--header-height",`${e}px`)}},[]);return t.useEffect(()=>{c();const e=new ResizeObserver(c);return l.current&&e.observe(l.current),()=>e.disconnect()},[c]),a.jsx(Hm,{config:r,children:a.jsx(ti,{children:a.jsx(Fd,{defaultOpen:!1,style:i,children:a.jsxs("div",{ref:d,className:"flex flex-col h-screen w-full overflow-hidden",children:[n&&a.jsx("div",{ref:l,className:"flex-shrink-0 sticky top-0 z-40 bg-primary",children:a.jsx(Xm,{})}),a.jsxs("div",{className:"sidebar-container flex flex-1 overflow-hidden",children:[o,a.jsx("main",{className:"relative z-0 flex-1 flex flex-col overflow-hidden",children:a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30",children:e})})]})]})})})})});class ip{static async sendEmail(e){const a=on(),{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 lp=ip;function dp({open:e,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=j.useTranslation(),[m,p]=t.useState([]),[h,x]=t.useState(!1),[f,g]=t.useState(""),{data:v=[],isLoading:b}=Ro({enabled:e}),y=t.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),w=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},N=1===m.length,_=m.length>0;return a.jsx(js,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"max-w-2xl",variant:"form",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsxs(Ds,{className:"flex items-center gap-2",children:[a.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),a.jsxs(Ts,{children:[a.jsxs("div",{className:"relative mb-4",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{placeholder:"Pesquisar...",value:f,onChange:e=>g(e.target.value),className:"pl-9"})]}),a.jsx(Do,{className:"h-[400px] pr-4",children:b?a.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>a.jsx(Rr,{className:"h-16 w-full"},t))}):0===y.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:u(f?"leadership_no_users_found":"leadership_no_users_available")})]}):a.jsx("div",{className:"space-y-2",children:y.map(e=>{const t=e.userId===l,s=c.includes(e.userId||""),r=m.includes(e.userId||"");return a.jsxs("div",{className:Yt("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(e.userId||""),children:[a.jsx(Xs,{checked:r,onCheckedChange:()=>w(e.userId||""),onClick:e=>e.stopPropagation()}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium",children:e.userName}),t&&a.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||s)&&a.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})})]}),a.jsxs(Ps,{className:"flex gap-2 sm:gap-2",children:[a.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&a.jsxs("span",{children:[m.length," selecionado(s)"]})}),N&&o&&a.jsxs(Xt,{onClick:async()=>{if(o&&1===m.length){x(!0);try{await o(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[a.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),_&&i&&a.jsxs(Xt,{onClick:async()=>{if(i&&0!==m.length){x(!0);try{await i(m,r),p([])}finally{x(!1)}}},disabled:h,children:[a.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function cp({place:e,level:s=0,manageAccessConfig:r}){const{t:n}=j.useTranslation(),[o,i]=t.useState(!1),[l,c]=t.useState(!1),u=e.subPlaces&&e.subPlaces.length>0,m=e.isActive??!0,p=e.usersCount??0;return a.jsxs("div",{children:[a.jsxs(gi,{open:o,onOpenChange:i,children:[a.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:[u?a.jsxs(vi,{className:"flex items-center gap-2 flex-1",children:[a.jsx(d.ChevronRight,{className:Yt("h-4 w-4 transition-transform shrink-0",o&&"rotate-90")}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name}),a.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):a.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a.jsx("div",{className:"w-4 shrink-0"}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name})]}),a.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:p})]}),a.jsx(er,{variant:m?"default":"secondary",className:"text-xs",children:m?"Ativo":"Inativo"}),r&&a.jsx(Im,{customActions:[{label:n("manage_access"),icon:d.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),u&&a.jsx(bi,{children:e.subPlaces.map(e=>a.jsx(cp,{place:e,level:s+1,manageAccessConfig:r},e.id))})]}),0===s&&a.jsx(ls,{}),r&&a.jsx(dp,{open:l,onOpenChange:c,placeId:e.id,placeName:e.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(e.id),currentMemberIds:r.getCurrentMemberIds?.(e.id)})]})}const up=new class{get baseUrl(){return Oe()}async makeApiCall(e,a,t){const s=un.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=an.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 un.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 tn.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return tn.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function mp(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 pp(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function hp(){const{alias:a,isAuthenticated:t}=Pn(),s=an.getAccessToken(),{data:r=[]}=Ro({enabled:!0,status:"all"});return w.useQuery({queryKey:["leadership",a],queryFn:async()=>{if(!s||!a)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=on(),{data:n,error:o}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",a);if(o)throw new Error("Erro ao buscar hierarquia de liderança");if(!n||0===n.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const l=n.map(a=>{const t=n.filter(e=>e.id_leader===a.id_user);return{...a,name:i[a.id_user]?.name||e.t("inactive_user"),email:i[a.id_user]?.email||"",subordinatesCount:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))}}),d=new Set(n.map(e=>e.id_user));return new Set(n.filter(e=>e.id_leader&&!d.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e],t=n.filter(a=>a.id_leader===e);l.push({id:`virtual-${e}`,alias:n[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:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))})}),mp(l)},enabled:!!s&&!!a&&t&&r.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const xp="common";function fp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=j.useTranslation();return w.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 yp(t,e,a.id_user,a.id_leader);const{data:r,error:n}=await t.schema(xp).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]}),l.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function gp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=j.useTranslation();return w.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",s("leadership_select_subordinates")));const r=a.users.map(e=>e.id_user),{data:n}=await t.schema(xp).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 d of a.users){if(a.id_leader&&d.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 yp(t,e,d.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(xp).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_added_success",`${t?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{l.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function vp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=j.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await t.schema(xp).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 yp(t,e,r.id_user,a.id_leader,a.id);const{data:n,error:o}=await t.schema(xp).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]}),l.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function bp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=j.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await t.schema(xp).from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function jp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=j.useTranslation();return w.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(xp).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",a),t.schema(xp).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:d,error:c}]=o;if(l)throw l;if(c)throw c;const u=i||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==a),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const s of x)await yp(t,e,s.id_user,a,s.id);for(const j of g){if(j.id_user===a)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await yp(t,e,j.id_user,a)}const v=[];if(h.length){const a=h.map(e=>e.id);v.push(t.schema(xp).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",e))}if(x.length){const s=x.map(e=>e.id);v.push(t.schema(xp).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}));v.push(t.schema(xp).from("leaders").insert(s))}const b=(await Promise.all(v)).find(e=>e?.error);if(b?.error)throw b.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${t.created} adicionados, ${t.updated} atualizados, ${t.unlinked} removidos)`))},onError:e=>{l.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function yp(a,t,s,r,n){const{data:o,error:i}=await a.schema(xp).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(i)throw i;const l=n?o.filter(e=>e.id!==n):o,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error(e.t("leadership_cycle_error"));if(c===s)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const a=l.find(e=>e.id_user===c);c=a?.id_leader||null}}var wp=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,d=l&&l[s.code];t[o]=h.appendErrors(o,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},Np=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&&ee.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:ee.toNestErrors(wp(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const _p=Z.z.object({id_leader:Z.z.string().nullable(),id_users:Z.z.array(Z.z.string()).min(1,e.t("leadership_select_subordinates"))}),Cp=Z.z.object({id_leader:Z.z.string().nullable(),id_users:Z.z.array(Z.z.string())});function kp({value:s,onChange:r,excludeUserIds:n=[],error:o}){const{data:i=[],isLoading:l}=Ro(),[c,u]=t.useState(""),m=t.useRef(null),p=t.useRef(0),h=i.filter(e=>!n.includes(e.userId||"")).filter(e=>{const a=c.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const t=s.includes(e.userId),r=s.includes(a.userId);if(t&&!r)return-1;if(!t&&r)return 1;const n=e.userName||e.userEmail||"",o=a.userName||a.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{m.current&&p.current>0&&(m.current.scrollTop=p.current)},[h]),l?a.jsxs("div",{className:"flex items-center justify-center p-4",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),a.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Zt,{placeholder:e.t("search_user_placeholder"),value:c,onChange:e=>u(e.target.value)}),a.jsx("div",{ref:m,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===h.length?a.jsx("p",{className:"text-sm text-muted-foreground",children:e.t("search_user_placeholder")}):a.jsx("div",{className:"space-y-2",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Xs,{id:e.userId,checked:s.includes(e.userId),onCheckedChange:()=>{return a=e.userId,m.current&&(p.current=m.current.scrollTop),void(s.includes(a)?r(s.filter(e=>e!==a)):r([...s,a]));var a}}),a.jsx(as,{htmlFor:e.userId,className:"flex-1 cursor-pointer",children:e.userName||e.userEmail})]},e.userId))})}),s.length>0&&a.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.length," selecionado(s)"]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})}function Sp({leader:s,prefilledLeaderId:r,onSuccess:n}){const{t:o}=j.useTranslation(),{alias:i}=Pn(),l=!!s,c=s?.id.startsWith("virtual-"),u=gp(),m=fp(),p=vp(),x=jp(),f=bp(),{data:g=[]}=hp(),{data:v=[]}=Ro(),[b,y]=t.useState(""),w=pp(g).map(e=>e.id_user),N=l?pp(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user):[],_=h.useForm({resolver:Np(l?Cp:_p),defaultValues:{id_leader:r||(l?s?.id_leader:null)||null,id_users:l?N:[]}});t.useEffect(()=>{if(s){const e=pp(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user);_.reset({id_leader:s.id_leader||null,id_users:e})}else r?_.reset({id_leader:r,id_users:[]}):_.reset({id_leader:null,id_users:[]})},[i,s?.id,s?.id_user,s?.id_leader,r,g]);const C=u.isPending||m.isPending||p.isPending||x.isPending||f.isPending,k=_.watch("id_leader"),S=_.watch("id_users"),T=l?[s.id_user,...w.filter(e=>e!==s.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...w.filter(e=>!S.includes(e))].filter(Boolean);return a.jsxs("form",{onSubmit:_.handleSubmit(async e=>{try{if(l)if(c){await m.mutateAsync({id_user:s.id_user,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{await p.mutateAsync({id:s.id,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({id_leader:e.id_leader,users:a})}n?.()}catch(a){}}),className:"space-y-4",children:[l&&a.jsxs("div",{children:[a.jsx(as,{children:e.t("leader")}),a.jsx(Zt,{value:v.find(e=>e.userId===s.id_user)?.userName||s.name||e.t("inactive_user"),disabled:!0,className:"bg-muted"})]}),a.jsxs("div",{children:[a.jsx(as,{children:o("leadership_immediate_superior")}),a.jsxs(Vs,{value:k||"none",onValueChange:e=>_.setValue("id_leader","none"===e?null:e),children:[a.jsx($s,{children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsxs(Gs,{children:[a.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:a.jsx(Zt,{placeholder:"Buscar superior...",value:b,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),a.jsxs(Do,{className:"h-[200px]",children:[a.jsx(Qs,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const a=l?e.userId!==s.id_user:!S.includes(e.userId),t=!b||e.userName?.toLowerCase().includes(b.toLowerCase());return a&&t}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(e=>a.jsx(Qs,{value:e.userId,children:e.userName},e.userId))]})]})]},`superior-select-${i}`),_.formState.errors.id_leader&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:_.formState.errors.id_leader.message})]}),a.jsxs("div",{children:[a.jsx(as,{children:"Subordinados *"}),a.jsx(kp,{value:S,onChange:e=>_.setValue("id_users",e),excludeUserIds:T,error:_.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx(Xt,{type:"submit",disabled:C||!l&&0===S.length,children:C&&!f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Atualizando...":"Salvando..."]}):l?"Atualizar":"Criar"}),l&&!k&&0===S.length&&a.jsxs(ds,{children:[a.jsx(cs,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"destructive",disabled:C,className:"ml-auto",children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),a.jsxs(ps,{children:[a.jsxs(hs,{children:[a.jsx(fs,{children:o("confirm_removal")}),a.jsx(gs,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),a.jsxs(xs,{children:[a.jsx(bs,{children:o("cancel")}),a.jsx(vs,{onClick:async()=>{if(s)try{await f.mutateAsync(s.id),n?.()}catch(e){}},children:o("remove")})]})]})]})]})]})}function Tp({open:e,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return a.jsx(js,{open:e,onOpenChange:t,children:a.jsxs(ks,{variant:"form",className:"sm:max-w-[500px]",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Ds,{children:n})}),a.jsx(Ts,{children:a.jsx(Sp,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})})]})})}const Pp="leadership-expanded-nodes",Dp=(e,a)=>{const{t:t}=j.useTranslation();try{localStorage.setItem(`${Pp}-${e}`,JSON.stringify(Array.from(a)))}catch{}};function Ep(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:i,onError:d}=e||{};return{upload:async(e,a)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);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){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await r(e,t);return l.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),i?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),d?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:a}}function Ap(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 Ip(e,a){const t=Ap(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function Mp(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function Fp(e,a){const t=Mp(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function Rp(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Lp(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function zp(e,a){return e/a}function Up(){const{alias:e}=Pn(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let a=!1;return(async()=>{n(!0);try{const t=on(),{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]);return{config:a,isLoading:r,saveConfig:t.useCallback(async(a,t)=>{if(!e)throw new Error("Alias not available");const r=on(),{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])}}const Op=(void 0).VITE_SUPABASE_URL,Vp=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function Bp(e,a,t){const s=an.getSupabaseToken(),r={"Content-Type":"application/json",apikey:Vp};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${Op}/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 qp={async createEnvelopeWithSigner(e){const a="d4sign"===e.provider?"d4sign":"clicksign",t="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await Bp(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 Bp(a,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let $p=null;function Wp(){return window.Clicksign?Promise.resolve():$p||($p=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)}),$p)}const Hp="clicksign-container";function Gp({signerId:e,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const{t:i}=j.useTranslation(),l=t.useRef(null),[c,u]=t.useState(!0),[m,p]=t.useState(null);return t.useEffect(()=>{let a=!1;return l.current&&(l.current.unmount(),l.current=null),p(null),u(!0),Wp().then(()=>{if(a)return;const t=new window.Clicksign(e);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(Hp),t.on("loaded",function(){u(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const a=e,t=document.getElementById(Hp);t&&a?.data?.height&&(t.style.height=a.data.height+"px")}),t.on("error",function(e){u(!1),n?.(e instanceof Error?e:new Error(i("sign_widget_error")))}),t.on("closed",function(){o?.()}),l.current=t}).catch(e=>{a||(p("Falha ao carregar o script de assinatura."),u(!1),n?.(e))}),()=>{a=!0,l.current&&(l.current.unmount(),l.current=null)}},[e,s]),a.jsxs("div",{className:"relative h-full",children:[c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx("p",{className:"text-sm text-destructive",children:m})}),a.jsx("div",{id:Hp,style:{height:"600px"}})]})}function Yp({documentKey:s,signerEmail:r,signerName:n,keySigner:o,environment:i,onSign:l,onError:c}){const u=t.useRef(null),[m,p]=t.useState("loading"),[h,x]=t.useState(null),f="production"===i?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",g=(()=>{const e=new URLSearchParams({email:r,display_name:n||"",disable_preview:"0"});return o&&e.set("key_signer",o),`${f}/${s}?${e.toString()}`})(),v=t.useCallback(a=>"signed"===a.data?(p("ready"),void l?.()):"wrong-data"===a.data?(p("error"),x(e.t("sign_incorrect_data")),void c?.(new Error(e.t("sign_incorrect_data")))):void 0,[l,c]);t.useEffect(()=>(window.addEventListener("message",v,!1),()=>{window.removeEventListener("message",v,!1)}),[v]);const b=t.useCallback(()=>{"loading"===m&&p("ready")},[m]);return"error"===m?a.jsxs(Jo,{variant:"danger",className:"my-4",children:[a.jsx(Zo,{children:e.t("sign_doc_load_error")}),a.jsx(ei,{children:h||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):a.jsxs("div",{className:"relative h-full",children:["loading"===m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),a.jsx("iframe",{ref:u,id:"d4sign-container",src:g,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}var Qp,Kp,Xp,Jp,Zp;exports.ETaskPlanStatus=void 0,(Qp=exports.ETaskPlanStatus||(exports.ETaskPlanStatus={}))[Qp.waitingStart=1]="waitingStart",Qp[Qp.running=2]="running",Qp[Qp.effectivenessCheck=3]="effectivenessCheck",Qp[Qp.done=4]="done",Qp[Qp.suspended=5]="suspended",Qp[Qp.canceled=6]="canceled",exports.ETaskPlanPriority=void 0,(Kp=exports.ETaskPlanPriority||(exports.ETaskPlanPriority={}))[Kp.low=0]="low",Kp[Kp.medium=1]="medium",Kp[Kp.high=2]="high",exports.ETaskPlanAssociationType=void 0,(Xp=exports.ETaskPlanAssociationType||(exports.ETaskPlanAssociationType={}))[Xp.plan=2]="plan",Xp[Xp.occurrence=3]="occurrence",Xp[Xp.risk=4]="risk",Xp[Xp.decisions=5]="decisions",Xp[Xp.audit=6]="audit",Xp[Xp.strategyExtension=7]="strategyExtension",Xp[Xp.standardization=8]="standardization",Xp[Xp.supplier=9]="supplier",Xp[Xp.auditItems=10]="auditItems",exports.ETaskPlanTypeProgress=void 0,(Jp=exports.ETaskPlanTypeProgress||(exports.ETaskPlanTypeProgress={}))[Jp.currentProgress=1]="currentProgress",Jp[Jp.cumulativeProgress=2]="cumulativeProgress",exports.EAttachmentItemStatus=void 0,(Zp=exports.EAttachmentItemStatus||(exports.EAttachmentItemStatus={})).uploading="uploading",Zp.waiting="waiting",Zp.done="done",Zp.error="error",Zp.canceled="canceled",Zp.duplicateItem="duplicateItem";const eh={[exports.ETaskPlanStatus.waitingStart]:"#D6D6D6",[exports.ETaskPlanStatus.running]:"#DAE9F4",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB29",[exports.ETaskPlanStatus.done]:"#DDEECA",[exports.ETaskPlanStatus.suspended]:"#FFF2D6",[exports.ETaskPlanStatus.canceled]:"#F4433629"},ah={[exports.ETaskPlanStatus.waitingStart]:"#666666",[exports.ETaskPlanStatus.running]:"#1B75BB",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB",[exports.ETaskPlanStatus.done]:"#4CAF50",[exports.ETaskPlanStatus.suspended]:"#FF9800",[exports.ETaskPlanStatus.canceled]:"#F44336"},th={[exports.ETaskPlanStatus.waitingStart]:"waiting-start",[exports.ETaskPlanStatus.running]:"running",[exports.ETaskPlanStatus.effectivenessCheck]:"effectiveness-check",[exports.ETaskPlanStatus.done]:"done",[exports.ETaskPlanStatus.suspended]:"suspended",[exports.ETaskPlanStatus.canceled]:"canceled"};function sh(){return{[exports.ETaskPlanStatus.waitingStart]:e.t("ap_status_waiting_start"),[exports.ETaskPlanStatus.running]:e.t("ap_status_running"),[exports.ETaskPlanStatus.effectivenessCheck]:e.t("ap_status_effectiveness_check"),[exports.ETaskPlanStatus.done]:e.t("ap_status_done"),[exports.ETaskPlanStatus.suspended]:e.t("ap_status_suspended"),[exports.ETaskPlanStatus.canceled]:e.t("ap_status_canceled")}}const rh=new Proxy({},{get:(e,a)=>{if("symbol"==typeof a)return;return sh()[a]}});const nh=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];const oh=[{id:exports.ETaskPlanPriority.low,label:"Baixa",color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:"Média",color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:"Alta",color:"#F44336"}],ih=[exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.canceled],lh=[exports.ETaskPlanStatus.waitingStart,exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.suspended];function dh(e){const{actionPlan:a,isNew:s=!1,config:r,onSave:n,onCancel:o,onDelete:i,onChangeStatus:l}=e,[d,c]=t.useState({formData:a||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});t.useEffect(()=>{a&&c(e=>({...e,formData:a,isFormDisabled:r?.disableFields||ih.includes(a.statusId)}))},[a,r?.disableFields]),t.useEffect(()=>{c(a=>({...a,isLoading:e.isLoading||!1}))},[e.isLoading]);const u=t.useCallback((e,a)=>{c(t=>({...t,formData:{...t.formData,[e]:a}}))},[]),m=t.useCallback(e=>{c(a=>({...a,activeTab:e}))},[]),p=t.useCallback(async()=>{if(n){c(e=>({...e,isSaving:!0}));try{await n(d.formData)}finally{c(e=>({...e,isSaving:!1}))}}},[n,d.formData]),h=t.useCallback(async e=>{if(l&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await l(d.formData.id,e)}finally{c(e=>({...e,isLoading:!1}))}}},[l,d.formData.id]),x=t.useCallback(async()=>{if(i&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await i(d.formData.id)}finally{c(e=>({...e,isLoading:!1}))}}},[i,d.formData.id]);return{formData:d.formData,isLoading:d.isLoading,isSaving:d.isSaving,activeTab:d.activeTab,isFormDisabled:d.isFormDisabled,updateField:u,setActiveTab:m,save:p,changeStatus:h,remove:x,cancel:o}}const ch={[exports.ETaskPlanStatus.waitingStart]:{label:"",color:"#8B7355",icon:d.Clock},[exports.ETaskPlanStatus.running]:{label:"",color:"#2E7D5B",icon:d.Play},[exports.ETaskPlanStatus.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:d.ShieldCheck},[exports.ETaskPlanStatus.done]:{label:"",color:"#3D7A40",icon:d.CheckCircle2},[exports.ETaskPlanStatus.suspended]:{label:"",color:"#6B7280",icon:d.Pause},[exports.ETaskPlanStatus.canceled]:{label:"",color:"#B44A4A",icon:d.X}};function uh({status:e,labels:t,className:s,size:r,showIcon:n,variant:o}){const i=sh(),l=ch[e];if(!l)return null;const d=t?.[e]||i[e]||"";return a.jsx(mu,{label:d,color:l.color,icon:l.icon,size:r,showIcon:n,variant:o,className:s})}function mh({formData:e,updateField:s,disabled:r=!1,users:n=[],places:o=[],actionTypes:i,causes:l=[],parentActions:d=[],config:c}){const{t:u}=j.useTranslation(),m=c?.requiredFields,p=i||nh,h=e=>{if(c?.hiddenFields?.includes(e))return!1;if(c?.visibleFields&&c.visibleFields.length>0)return c.visibleFields.includes(e);const a=`${e}Visible`;return!m||!(a in m)||!1!==m[a]},x=e=>m?!!m[e]:"name"===e,f=t.useMemo(()=>{if(e.startDate&&e.endDate){const a=new Date(e.startDate),t=new Date(e.endDate).getTime()-a.getTime();return Math.max(0,Math.ceil(t/864e5))}return e.duration||0},[e.startDate,e.endDate,e.duration]);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),a.jsx(Zt,{value:e.name||"",onChange:e=>s("name",e.target.value),maxLength:500,disabled:r,placeholder:u("ap_plan_name_placeholder")})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("responsibleWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),a.jsxs(Vs,{value:e.responsibleId||"",onValueChange:e=>s("responsibleId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_responsible")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Qs,{value:e.id,children:e.name},e.id))})]})]}),h("checkerWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),a.jsxs(Vs,{value:e.checkerId||"",onValueChange:e=>s("checkerId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_checker")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Qs,{value:e.id,children:e.name},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("place")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),a.jsxs(Vs,{value:e.placeId||"",onValueChange:e=>s("placeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_place")})}),a.jsx(Gs,{children:ph(o).map(e=>a.jsx(Qs,{value:e.id,children:e.name},e.id))})]})]}),h("planType")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),a.jsxs(Vs,{value:e.typeId||"",onValueChange:e=>s("typeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_type")})}),a.jsx(Gs,{children:p.map(e=>a.jsx(Qs,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("priority")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),a.jsxs(Vs,{value:e.priorityType?.toString()||"",onValueChange:e=>s("priorityType",Number(e)),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_priority")})}),a.jsx(Gs,{children:oh.map(e=>a.jsx(Qs,{value:e.id.toString(),children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:e.color}}),e.label]})},e.id))})]})]}),d.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:u("ap_belongs_to")}),a.jsxs(Vs,{value:e.parentId||"",onValueChange:e=>s("parentId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_parent")})}),a.jsx(Gs,{children:d.map(e=>a.jsx(Qs,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[h("startDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),a.jsx(bl,{date:e.startDate?new Date(e.startDate):void 0,onDateChange:e=>s("startDate",e||null),disabled:r,placeholder:u("ap_select_date")})]}),h("endDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),a.jsx(bl,{date:e.endDate?new Date(e.endDate):void 0,onDateChange:e=>s("endDate",e||null),disabled:r,placeholder:u("ap_select_date"),disabledDates:e.startDate?a=>a<new Date(e.startDate):void 0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:u("ap_duration_days")}),a.jsx(Zt,{type:"number",value:f,disabled:!0,className:"bg-muted"})]})]}),h("estimatedCost")&&a.jsxs("div",{className:"space-y-2 max-w-xs",children:[a.jsx(as,{className:Yt(x("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),a.jsx(Zt,{type:"number",min:0,step:.01,value:e.estimatedCost||"",onChange:e=>s("estimatedCost",Number(e.target.value)),disabled:r,className:"pl-9",placeholder:"0,00"})]})]}),h("cause")&&l.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Causa"}),a.jsxs(Vs,{value:e.causeId||"",onValueChange:e=>s("causeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_cause")})}),a.jsx(Gs,{children:l.map(e=>a.jsx(Qs,{value:e.id,children:e.label},e.id))})]})]}),h("description")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),a.jsx(Js,{value:e.description||"",onChange:e=>s("description",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_description_placeholder")})]}),h("justification")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),a.jsx(Js,{value:e.justification||"",onChange:e=>s("justification",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_justification_placeholder")})]})]})}function ph(e,a=0){const t=[];for(const s of e)t.push({...s,depth:a}),s.children?.length&&t.push(...ph(s.children,a+1));return t}function hh(e){const{progress:a,onReportProgress:s,onEditProgress:r,onDeleteProgress:n}=e,[o,i]=t.useState(!1),[l,d]=t.useState(null),c=!!a&&lh.includes(a.status),u=t.useCallback(async e=>{if(s&&a){i(!0);try{const t=100===e.percentProgress;await s({id:a.id,...e,conclude:t})}finally{i(!1)}}},[s,a]),m=t.useCallback(async e=>{if(r){i(!0);try{await r(e)}finally{i(!1),d(null)}}},[r]),p=t.useCallback(async e=>{if(n){i(!0);try{await n(e)}finally{i(!1)}}},[n]);return{progress:a,canReportProgress:c,isSubmitting:o,editingReport:l,setEditingReport:d,reportProgress:u,editProgress:m,deleteProgress:p}}function xh(e){if(!e)return"";let a=(e||"").trim();if(!a)return"00:00";if(a.includes(":")){const e=a.split(":");if(e.length>=2){const a=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let s=parseInt(a)||0,r=parseInt(t)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}if(a=a.replace(/\D/g,""),!a)return"00:00";let t=0,s=0;return 4===a.length?(t=parseInt(a.substring(0,2))||0,s=parseInt(a.substring(2,4))||0,t+=Math.floor(s/60),s%=60):(t=parseInt(a)||0,s=0),`${t.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}function fh(e){if(null==e)return"00:00";const a=String(e).replace(/\D/g,"");if(a.length<3){let e=parseInt(a)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=a.slice(-2),t=a.slice(0,-2);let s=parseInt(t)||0,r=parseInt(e)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}function gh(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function vh({open:e,onOpenChange:s,report:r,onSave:n,isSubmitting:o=!1}){const{t:i}=j.useTranslation(),[l,d]=t.useState(r?.percentProgress||0),[c,u]=t.useState(r?.timeProgress||""),[m,p]=t.useState(r?.comments||""),h=l!==(r?.percentProgress??0)||c!==(r?.timeProgress??"")||m!==(r?.comments??"");t.useEffect(()=>{r&&(d(r.percentProgress),u(r.timeProgress||""),p(r.comments||""))},[r]);return a.jsx(js,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:h,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:i("ap_edit_progress")})}),a.jsxs("div",{className:"space-y-4 py-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_progress_percent")}),a.jsx(Zt,{type:"number",min:0,max:100,value:l,onChange:e=>d(Number(e.target.value))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_time_spent")}),a.jsx(Zt,{value:c,onChange:e=>u(e.target.value),onBlur:()=>u(xh(c)||""),placeholder:"00:00"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_comments")}),a.jsx(Js,{value:m,onChange:e=>p(e.target.value),rows:3,maxLength:4e3})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>s(!1),disabled:o,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{r&&n({...r,percentProgress:l,timeProgress:xh(c)||"00:00",comments:m})},disabled:o,children:o?"Salvando...":"Salvar"})]})]})})}function bh(e){const{t:s}=j.useTranslation(),{progress:r,canReportProgress:n,isSubmitting:o,editingReport:i,setEditingReport:l,reportProgress:d,editProgress:c,deleteProgress:u}=hh(e),[m,p]=t.useState(""),[h,x]=t.useState(""),[f,g]=t.useState("");if(!r)return a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const v=gh(r.percentProgress),b=!m,y=!m&&!h&&!f;return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"font-medium",children:s("ap_overall_progress")}),a.jsxs("span",{className:"font-semibold",style:{color:v||void 0},children:[r.percentProgress,"%"]})]}),a.jsx(fd,{value:r.percentProgress,className:"h-3"}),r.timeProgress&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",fh(r.timeProgress)]})]}),n&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_report_progress")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_progress_percent")}),a.jsx(Zt,{type:"number",min:0,max:100,value:m,onChange:e=>p(e.target.value),placeholder:"0"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_time_spent")}),a.jsx(Zt,{value:h,onChange:e=>x(e.target.value),onBlur:()=>x(xh(h)||""),placeholder:"00:00"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_comments")}),a.jsx(Js,{value:f,onChange:e=>g(e.target.value),rows:3,maxLength:4e3,placeholder:s("ap_progress_comment_placeholder")})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>{p(""),x(""),g("")},disabled:y||o,children:"Limpar"}),a.jsx(Xt,{size:"sm",onClick:async()=>{const e=Number(m);(e||0===e)&&(await d({percentProgress:e,timeProgress:xh(h)||"00:00",comments:f}),p(""),x(""),g(""))},disabled:b||o,children:o?"Reportando...":"Reportar"})]})]}),r.reports.length>0&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_reports_history")}),a.jsx("div",{className:"space-y-2",children:r.reports.map(e=>a.jsx(jh,{report:e,onEdit:()=>l(e),onDelete:()=>u(e.id),disabled:!n},e.id))})]}),a.jsx(vh,{open:!!i,onOpenChange:e=>!e&&l(null),report:i,onSave:c,isSubmitting:o})]})}function jh({report:t,onEdit:s,onDelete:r,disabled:n}){const o=t.date?new Date(t.date):null,i=gh(t.percentProgress);return a.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",children:t.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:t.userName}),o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:o.toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("span",{style:{color:i||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&a.jsxs("span",{children:["Tempo: ",fh(t.timeProgress)]})]}),t.comments&&a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!n&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[a.jsx(hr,{onClick:s,children:e.t("edit")}),a.jsx(hr,{className:"text-destructive",onClick:r,children:e.t("ap_delete")})]})]})]})}function yh({predecessors:e=[],availablePredecessors:s=[],onAdd:r,onRemove:n,disabled:o=!1}){const{t:i}=j.useTranslation(),[l,c]=t.useState(""),u=s.filter(a=>!e.some(e=>e.predecessorId===a.id));return a.jsxs("div",{className:"space-y-6 p-1",children:[!o&&u.length>0&&a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx(as,{children:i("ap_add_predecessor")}),a.jsxs(Vs,{value:l,onValueChange:c,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:i("ap_select_action")})}),a.jsx(Gs,{children:u.map(e=>a.jsx(Qs,{value:e.id,children:e.label},e.id))})]})]}),a.jsxs(Xt,{size:"sm",onClick:()=>{l&&r&&(r(l),c(""))},disabled:!l,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[e.predecessorCode&&a.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.predecessorCode}),a.jsx("span",{className:"text-sm font-medium",children:e.predecessorName}),null!=e.predecessorStatus&&a.jsx(uh,{status:e.predecessorStatus})]}),!o&&n&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsx(pr,{align:"end",children:a.jsx(hr,{className:"text-destructive",onClick:()=>n(e.predecessorId),children:"Remover"})})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function wh({costs:e=[],onAdd:s,onEdit:r,onDelete:n,disabled:o=!1}){const{t:i}=j.useTranslation(),[l,c]=t.useState(""),[u,m]=t.useState(""),p=e.reduce((e,a)=>e+(a.value||0),0);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:i("ap_total_cost")}),a.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",p.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!o&&s&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:i("ap_add_cost")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Descrição"}),a.jsx(Zt,{value:l,onChange:e=>c(e.target.value),placeholder:i("ap_cost_description")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Valor (R$)"}),a.jsx(Zt,{type:"number",min:0,step:.01,value:u,onChange:e=>m(e.target.value),placeholder:"0,00"})]})]}),a.jsx("div",{className:"flex justify-end",children:a.jsxs(Xt,{size:"sm",onClick:()=>{l&&u&&s&&(s({description:l,value:Number(u),date:(new Date).toISOString()}),c(""),m(""))},disabled:!l||!u,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:e.description}),e.date&&a.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(e.date).toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",e.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!o&&(r||n)&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[r&&a.jsx(hr,{onClick:()=>r(e),children:i("edit")}),n&&a.jsx(hr,{className:"text-destructive",onClick:()=>n(e.id),children:i("ap_delete")})]})]})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function Nh({comments:e=[],currentUserId:s,onAdd:r,onEdit:n,onDelete:o,disabled:i=!1,maxLength:l=4e3}){const{t:c}=j.useTranslation(),[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(null),[g,v]=t.useState(""),b=()=>{f(null),v("")};return a.jsxs("div",{className:"space-y-6 p-1",children:[!i&&r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(Js,{value:u,onChange:e=>m(e.target.value),placeholder:c("ap_add_comment_placeholder"),maxLength:l,rows:3}),a.jsxs("div",{className:"flex items-center justify-between",children:[l&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length,"/",l]}),a.jsxs("div",{className:"flex gap-2 ml-auto",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>m(""),disabled:!u||p,children:"Limpar"}),a.jsx(Xt,{size:"sm",onClick:async()=>{if(u.trim()&&r){h(!0);try{await r(u),m("")}finally{h(!1)}}},disabled:!u.trim()||p,children:p?"Enviando...":"Comentar"})]})]})]}),a.jsxs("div",{className:"space-y-1",children:[e.length>0?a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:"text-sm font-medium",children:c("ap_comments")}),a.jsx(er,{variant:"info",className:"text-[10px] px-1.5 py-0",children:e.length})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.MessageSquare,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),e.map(e=>a.jsxs("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground overflow-hidden",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.userEmail}),a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:_h(e.dateEdited||e.dateCreation)}),e.dateEdited&&a.jsx("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),x===e.id?a.jsxs("div",{className:"space-y-2",children:[a.jsx(Js,{value:g,onChange:e=>v(e.target.value),maxLength:l,rows:3}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:b,disabled:p,children:"Cancelar"}),a.jsx(Xt,{size:"sm",onClick:()=>(async e=>{if(g.trim()&&n){h(!0);try{await n({...e,text:g,stringText:g}),f(null),v("")}finally{h(!1)}}})(e),disabled:!g.trim()||p,children:p?"Salvando...":"Salvar"})]})]}):a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.stringText||e.text})]}),!i&&s===e.userId&&x!==e.id&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[n&&a.jsx(hr,{onClick:()=>(e=>{f(e.id),v(e.stringText||e.text)})(e),children:c("edit")}),o&&a.jsx(hr,{className:"text-destructive",onClick:()=>(async e=>{if(o){h(!0);try{await o(e)}finally{h(!1)}}})(e.id),children:"Excluir"})]})]})]},e.id))]})]})}function _h(e){const{t:a}=j.useTranslation();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function Ch({history:e=[],isLoading:t=!1}){const{t:s}=j.useTranslation();return t?a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===e.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Clock,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:s("ap_no_history")})]}):a.jsx("div",{className:"p-1",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),a.jsx("div",{className:"space-y-0",children:e.map((e,t)=>a.jsxs("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[a.jsx("div",{className:"relative z-10 flex-shrink-0 h-8 w-8 rounded-full bg-primary/10 border-2 border-primary/30 flex items-center justify-center",children:e.icon?a.jsx("span",{className:"text-xs text-primary",children:e.icon}):a.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),a.jsxs("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium",children:e.translateEvent||e.eventName}),e.eventDescription&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.eventDescription})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0 h-6 w-6 rounded-full bg-muted overflow-hidden flex items-center justify-center text-[10px] font-medium text-muted-foreground",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-xs font-medium truncate block",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-[10px] text-muted-foreground truncate block",children:e.userEmail})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Calendar,{className:"h-3 w-3"}),a.jsx("span",{children:kh(e.date)})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),a.jsx("span",{children:Sh(e.date)})]}),e.isMobileRequest&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Smartphone,{className:"h-3 w-3"}),a.jsx("span",{children:s("ap_via_app")})]})]})]})]},e.id))})]})})}function kh(e){const{t:a}=j.useTranslation();return new Date(e).toLocaleDateString("pt-BR")}function Sh(e){const{t:a}=j.useTranslation();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function Th({attachments:e=[],onUpload:s,onDelete:r,onRename:n,onDownload:o,onView:i,disabled:l=!1}){const{t:c}=j.useTranslation(),u=t.useRef(null),[m,p]=t.useState(null),[h,x]=t.useState(""),f=async e=>{h.trim()&&n&&(await n(e.id,h),p(null),x(""))},g=()=>{p(null),x("")};return a.jsxs("div",{className:"space-y-4 p-1",children:[!l&&s&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:e=>{const a=e.target.files;if(a&&s){for(let e=0;e<a.length;e++){const t=a.item(e);t&&s(t)}u.current&&(u.current.value="")}}}),a.jsxs(Xt,{size:"sm",onClick:()=>u.current?.click(),children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:Yt("flex items-center gap-3 rounded-lg border bg-card p-3",e.status===exports.EAttachmentItemStatus.error&&"border-destructive/50 bg-destructive/5",e.status===exports.EAttachmentItemStatus.canceled&&"opacity-50"),children:[a.jsx("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:a.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:e.extension.replace(".","").substring(0,4)})}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[m===e.id?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:h,onChange:e=>x(e.target.value),onKeyDown:a=>{"Enter"===a.key&&f(e),"Escape"===a.key&&g()},autoFocus:!0}),a.jsx(Xt,{size:"sm",variant:"outline",onClick:g,children:c("cancel")}),a.jsx(Xt,{size:"sm",onClick:()=>f(e),children:c("save")})]}):a.jsx("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>i?.(e.id),children:e.name}),(e.status===exports.EAttachmentItemStatus.uploading||e.status===exports.EAttachmentItemStatus.waiting)&&a.jsx(fd,{value:e.progress||0,className:"h-1.5"}),e.status===exports.EAttachmentItemStatus.error&&a.jsx("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),e.status===exports.EAttachmentItemStatus.duplicateItem&&a.jsx("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),e.status===exports.EAttachmentItemStatus.canceled&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[e.status===exports.EAttachmentItemStatus.done&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:Ph(e.size)}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[n&&!l&&a.jsx(hr,{onClick:()=>(e=>{const a=e.name.replace(e.extension,"");p(e.id),x(a)})(e),children:"Renomear"}),i&&a.jsx(hr,{onClick:()=>i(e.id),children:"Visualizar"}),o&&a.jsx(hr,{onClick:()=>o(e.id),children:"Download"}),r&&!l&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsx(hr,{className:"text-destructive",onClick:()=>r(e.id),children:"Excluir"})]})]})]})]}),e.status===exports.EAttachmentItemStatus.uploading&&a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>r?.(e.id),children:"Cancelar"})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Paperclip,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function Ph(e){const{t:a}=j.useTranslation();if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(1))} ${["B","KB","MB","GB"][t]}`}const Dh=["application/x-msdownload","application/x-msdos-program","application/x-executable","application/x-javascript","application/javascript","text/javascript","text/vbscript","application/sql","application/x-sh","application/x-shellscript","application/hta","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12"];function Eh(e){if(!e)return"";if(e<1024)return`${e} Bytes`;const a=e/1024;if(a<1024)return`${Math.round(a)} KB`;const t=a/1024;if(t<1024)return`${Math.round(t)} MB`;const s=t/1024;return Math.round(100*s)/100+" GB"}function Ah(e){const a=e.lastIndexOf(".");return-1===a?"":e.substring(a+1).toLowerCase()}var Ih,Mh,Fh;function Rh(e){switch(e.type){case exports.ECustomFormFieldType.text:return e.textValue;case exports.ECustomFormFieldType.number:return e.numberValue;case exports.ECustomFormFieldType.date:return e.dateValue;case exports.ECustomFormFieldType.time:return e.timeValue;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:return e.itemsValue;case exports.ECustomFormFieldType.questions:return e.questionsValue;case exports.ECustomFormFieldType.readOnlyText:return e.textValue;default:return null}}function Lh(e,a){if(!a)return!0;const t=null!=Rh(e)&&""!==Rh(e)&&!(Array.isArray(Rh(e))&&0===Rh(e).length);return!1!==e.isActive||t}function zh({field:e}){return a.jsxs("div",{className:"space-y-1",children:[e.name&&a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&a.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function Uh({field:e,readOnly:t,onChange:s}){const r=e.config,n=r?.multiline??!1,o=t||e.readOnly,i=a=>{s?.({...e,textValue:a})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),n?a.jsx(Js,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o,rows:4}):a.jsx(Zt,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o})]})}function Oh({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e.dateValue?"string"==typeof e.dateValue?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"date",value:n,onChange:a=>{return t=a.target.value,void s?.({...e,dateValue:t||void 0});var t},placeholder:e.placeholder,disabled:r})]})}function Vh({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e=>{if(!e)return;const[a,t]=e.split(":").map(Number);return 60*a+t};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"time",value:(e=>{if(null==e)return"";const a=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`})(e.timeValue),onChange:a=>s?.({...e,timeValue:n(a.target.value)}),placeholder:e.placeholder,disabled:r})]})}function Bh({field:e,readOnly:s,onChange:r}){const n=e.config,o=n?.multiple??!1,i=s||e.readOnly,[l,c]=t.useState(""),u=e.itemsValue||[],m=()=>{if(!l.trim())return;const a={value:crypto.randomUUID(),text:l.trim()};r?.({...e,itemsValue:[...u,a]}),c("")};if(!o){const t=u[0]?.text||"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zt,{type:"url",value:t,onChange:a=>(a=>{const t={value:a,text:a};r?.({...e,itemsValue:a?[t]:[]})})(a.target.value),placeholder:e.placeholder||"https://",disabled:i}),t&&a.jsx(Xt,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:a.jsx(d.ExternalLink,{className:"h-4 w-4"})})})]})]})}return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zt,{type:"url",value:l,onChange:e=>c(e.target.value),placeholder:e.placeholder||"https://",onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),m())}),a.jsx(Xt,{variant:"outline",size:"icon",onClick:m,disabled:!l.trim(),className:"flex-shrink-0",children:a.jsx(d.Plus,{className:"h-4 w-4"})})]}),u.length>0&&a.jsx("div",{className:"space-y-1",children:u.map((t,s)=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("a",{href:t.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:t.text}),!i&&a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>(a=>{const t=u.filter((e,t)=>t!==a);r?.({...e,itemsValue:t})})(s),children:a.jsx(d.Trash2,{className:"h-3 w-3"})})]},t.value))})]})}function qh({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=null!=r?.decimals&&r.decimals>0?(1/Math.pow(10,r.decimals)).toString():"1";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"number",value:e.numberValue??"",onChange:a=>(a=>{if(""===a)return void s?.({...e,numberValue:void 0});const t=parseFloat(a);isNaN(t)||s?.({...e,numberValue:t})})(a.target.value),placeholder:e.placeholder,disabled:n,min:r?.min,max:r?.max,step:o}),null!=r?.min&&null!=r?.max&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",r.min," | Max: ",r.max]})]})}function $h({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=e.itemsValue?.[0]?.value||"",d=a=>{const t=i.find(e=>e.value===a);if(!t)return;const r={value:t.value,text:t.text,isActive:t.isActive};s?.({...e,itemsValue:[r]})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),o===exports.EFieldViewMode.dropdown&&a.jsxs(Vs,{value:l,onValueChange:d,disabled:n,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:e.placeholder||"Selecione..."})}),a.jsx(Gs,{children:i.map(e=>a.jsxs(Qs,{value:e.value,children:[e.text,!1===e.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},e.value))})]}),(o===exports.EFieldViewMode.radio||o===exports.EFieldViewMode.buttons)&&a.jsx(gd,{value:l,onValueChange:d,disabled:n,className:Yt(o===exports.EFieldViewMode.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(vd,{value:t.value,id:`${e.id}-${t.value}`}),a.jsxs(as,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))}),!n&&l&&!e.required&&a.jsx("button",{type:"button",onClick:()=>{s?.({...e,itemsValue:[]})},className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function Wh({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=new Set(e.itemsValue?.map(e=>e.value)||[]);return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(t=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[a.jsx("span",{className:"text-xs",children:t.text}),!n&&a.jsx("button",{type:"button",onClick:()=>(a=>{const t=(e.itemsValue||[]).filter(e=>e.value!==a);s?.({...e,itemsValue:t})})(t.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:a.jsx(d.X,{className:"h-3 w-3"})})]},t.value))}),!n&&a.jsx("div",{className:Yt(o===exports.EFieldViewMode.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:`${e.id}-${t.value}`,checked:l.has(t.value),onCheckedChange:()=>(a=>{const t=e.itemsValue||[],r=t.some(e=>e.value===a.value)?t.filter(e=>e.value!==a.value):[...t,{value:a.value,text:a.text,isActive:a.isActive}];s?.({...e,itemsValue:r})})(t),disabled:n}),a.jsxs(as,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))})]})}function Hh({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.questions||[],i=r?.options||[],l=e.questionsValue||[];return 0===o.length||0===i.length?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:e.name}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx("div",{className:"border rounded-md overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/50",children:[a.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(e=>a.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:e.text},e.value))]})}),a.jsx("tbody",{children:o.map((t,r)=>a.jsxs("tr",{className:Yt(r<o.length-1&&"border-b"),children:[a.jsx("td",{className:"p-2 text-muted-foreground",children:t.text}),i.map(r=>{return a.jsx("td",{className:"text-center p-2",children:a.jsx(gd,{value:(o=t.value,l.find(e=>e.questionValue===o)?.optionValue||""),onValueChange:a=>((a,t,r,n)=>{const o={questionValue:a,questionText:t,optionValue:r,optionText:n},i=l.filter(e=>e.questionValue!==a);i.push(o),s?.({...e,questionsValue:i})})(t.value,t.text,a,r.text),disabled:n,className:"flex justify-center",children:a.jsx(vd,{value:r.value,id:`${e.id}-${t.value}-${r.value}`})})},r.value);var o})]},t.value))})]})})]})}function Gh({field:e,readOnly:t,onChange:s}){const r={field:e,readOnly:t,onChange:s};switch(e.type){case exports.ECustomFormFieldType.readOnlyText:return a.jsx(zh,{...r});case exports.ECustomFormFieldType.text:return a.jsx(Uh,{...r});case exports.ECustomFormFieldType.date:return a.jsx(Oh,{...r});case exports.ECustomFormFieldType.time:return a.jsx(Vh,{...r});case exports.ECustomFormFieldType.url:return a.jsx(Bh,{...r});case exports.ECustomFormFieldType.number:return a.jsx(qh,{...r});case exports.ECustomFormFieldType.singleSelection:return a.jsx($h,{...r});case exports.ECustomFormFieldType.multiSelection:return a.jsx(Wh,{...r});case exports.ECustomFormFieldType.questions:return a.jsx(Hh,{...r});default:return null}}function Yh({queryParams:e,events:s,softwares:r,users:n=[],permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},isLoading:i=!1,onFilter:l,onReset:c,onExport:u,onSoftwareChange:m}){const[p,h]=t.useState(e.softwareId),[x,f]=t.useState(e.eventId),[g,v]=t.useState(e.userId||"all"),[b,j]=t.useState(Qh(e.startDate)),[y,w]=t.useState(Qh(e.endDate)),N=t.useCallback(e=>{const a=parseInt(e);h(a),m?.(a)},[m]),_=t.useCallback(()=>{l({...e,softwareId:p,eventId:x,userId:"all"===g?void 0:g,startDate:new Date(b),endDate:new Date(y),software:r.find(e=>e.id===p)?.software||e.software,event:s.find(e=>e.id===x)?.name||e.event})},[e,p,x,g,b,y,r,s,l]),C=t.useCallback(()=>{const a=new Date;a.setHours(0,0,0,0),j(Qh(a)),w(Qh(a)),f(e.eventId),o.viewAllEvents&&v("all"),c?.()},[e.eventId,o.viewAllEvents,c]),k=o.viewOnlyMyEvents&&!o.viewAllEvents,S=p&&x&&b&&y;return a.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-border bg-card p-3",children:[a.jsxs("div",{className:"flex flex-col gap-1 min-w-[180px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Módulo *"}),a.jsxs(Vs,{value:String(p),onValueChange:N,disabled:i,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsx(Gs,{children:r.map(e=>a.jsx(Qs,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Evento *"}),a.jsxs(Vs,{value:String(x),onValueChange:e=>f(parseInt(e)),disabled:i,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsx(Gs,{children:s.map(e=>a.jsx(Qs,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Usuário *"}),a.jsxs(Vs,{value:g,onValueChange:v,disabled:i||k,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsxs(Gs,{children:[a.jsx(Qs,{value:"all",className:"text-xs",children:"Todos"}),n.map(e=>a.jsx(Qs,{value:e.id,className:"text-xs",children:e.name},e.id))]})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"De *"}),a.jsx(Zt,{type:"date",value:b,onChange:e=>j(e.target.value),className:"h-8 text-xs",max:y,disabled:i})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Até *"}),a.jsx(Zt,{type:"date",value:y,onChange:e=>w(e.target.value),className:"h-8 text-xs",min:b,disabled:i})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsxs(Xt,{variant:"outline",size:"sm",onClick:C,disabled:i,children:[a.jsx(d.RotateCcw,{className:"h-3.5 w-3.5 mr-1"}),"Limpar"]}),o.download&&u&&a.jsxs(Xt,{variant:"outline",size:"sm",onClick:()=>u("xlsx"),disabled:i,children:[a.jsx(d.Download,{className:"h-3.5 w-3.5 mr-1"}),"Exportar"]}),a.jsxs(Xt,{size:"sm",onClick:_,disabled:i||!S,children:[a.jsx(d.Filter,{className:"h-3.5 w-3.5 mr-1"}),"Filtrar"]})]})]})}function Qh(e){return(e instanceof Date?e:new Date(e)).toISOString().split("T")[0]}function Kh(e,a,t,s="Anônimo"){return e.map(e=>({...e,translatedSoftware:Jh(e.software,t),user:e.userEmail||e.userName||s,translatedEvent:Xh(e.eventName,a),date:new Date(e.dateTime)})).sort((e,a)=>(a.date?.getTime()??0)-(e.date?.getTime()??0))}function Xh(e,a){const t=a.find(a=>a.name===e);return t?.translation||e}function Jh(e,a){const t=e.includes(".")?e.split(".").pop():e,s=a.find(e=>e.software===t);return s?.translation||t}function Zh(e,a){const t=[],s={...ox,...a?.labels},r=e.eventName;t.push({name:s.event,value:r});const n=e.entities?.[0];if(n&&(t.push({name:s.entityName,value:ex(n)}),n.description&&t.push({name:s.description,value:n.description}),n.justification&&t.push({name:s.justification,value:n.justification}),n.statusName&&t.push({name:s.status,value:n.statusName}),n.equipmentType&&t.push({name:s.type,value:n.equipmentType}),n.extra?.length)){[...new Set(n.extra.map(e=>e.property))].forEach(e=>{const a=n.extra.filter(a=>a.property===e).map(e=>e.value||"").join(", ");t.push({name:rx(e),value:a})})}e.entities?.forEach(e=>{e.data?.forEach(e=>{if("Removed"===e.property)return;if(""===e.newValue&&!e.tagTranslate)return;const n=ax(e,r,a?.translateProperty),o=tx(e,null,r,s,a);o&&t.push({name:n,value:o})})}),e.entities?.forEach(e=>{if(e.association?.length){const a=e.association.filter(e=>""!==e.id).map(e=>{const a=ex(e);return`(${e.softwareName||e.type}) ${a}`});a.length&&t.push({name:s.references,value:a.join(", ")})}}),n?.isElectronicSigned&&t.push({name:s.security,value:"🛡️ "+s.electronicSigned}),t.push({name:s.accomplishedBy,value:e.userName?`${e.userName} (${e.userEmail})`:e.userEmail});const o=a?.formatDate?a.formatDate(e.dateTime):nx(e.dateTime);return t.push({name:s.accomplishedIn,value:o}),t}function ex(e){return e.code&&e.name&&e.code!==e.name?`${e.code} ${e.name}`:e.name||e.code||""}function ax(e,a,t){if(e.propertyCustomName)return e.propertyCustomName;const s=rx(e.property);return t?t(a,s):s}function tx(e,a,t,s,r){if(e.propertyResource||(e.propertyResource=a?`${a.propertyResource}.${e.property}`:e.property),e.children?.length){if(e.newValue){const a=ax(e,t,r?.translateProperty),n=function(e,a){switch(e.state){case"Added":return a.stateAdded;case"Modified":return e.children?.some(e=>"Removed"===e.property)?a.stateRemoved:a.stateModified;default:return""}}(e,s);let o=`${a}: "${sx(e,"newValue",s,r)}" ${n}`;const i=e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,tx(a,e,t,s,r)));return i.some(Boolean)&&(o+="\n"+i.filter(Boolean).join("\n")),o}return e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,tx(a,e,t,s,r))).filter(Boolean).join("\n")}if("Removed"===e.property)return"";if("Modified"===e.state){const n=sx(e,"oldValue",s,r),o=sx(e,"newValue",s,r);return`${a?ax(e,t,r?.translateProperty)+": ":""}${s.changedFrom} "${n}" ${s.changedTo} "${o}"`}const n=sx(e,"newValue",s,r);return a?`${ax(e,t,r?.translateProperty)}: ${n}`:n}function sx(e,a,t,s){const r=e[a];return null==r||""===r?"Modified"===e.state||"Added"===e.state||"Unchanged"===e.state?t.uninformed:"":"string"==typeof r&&function(e){if("string"!=typeof e)return!1;if(!/^\d{4}[-/]\d{2}[-/]\d{2}/.test(e))return!1;const a=new Date(e);return!isNaN(a.getTime())}(r)?s?.formatDate?s.formatDate(r):nx(r):String(r)}function rx(e){return e.replace(/([A-Z])/g,(e,a,t)=>`${t>0?"-":""}${a.toLowerCase()}`)}function nx(e){try{return new Date(e).toLocaleString()}catch{return e}}exports.ECustomFormFieldType=void 0,(Ih=exports.ECustomFormFieldType||(exports.ECustomFormFieldType={}))[Ih.readOnlyText=1]="readOnlyText",Ih[Ih.text=2]="text",Ih[Ih.date=3]="date",Ih[Ih.time=4]="time",Ih[Ih.url=5]="url",Ih[Ih.number=6]="number",Ih[Ih.singleSelection=7]="singleSelection",Ih[Ih.multiSelection=8]="multiSelection",Ih[Ih.questions=9]="questions",exports.EFieldViewMode=void 0,(Mh=exports.EFieldViewMode||(exports.EFieldViewMode={}))[Mh.dropdown=1]="dropdown",Mh[Mh.buttons=2]="buttons",Mh[Mh.radio=3]="radio",Mh[Mh.checkbox=4]="checkbox",exports.ESelectionFieldDataSource=void 0,(Fh=exports.ESelectionFieldDataSource||(exports.ESelectionFieldDataSource={}))[Fh.custom=1]="custom",Fh[Fh.users=2]="users",Fh[Fh.usersLists=3]="usersLists";const ox={event:"Evento",entityName:"Item",description:e.t("audit_description"),justification:"Justificativa",status:"Status",type:"Tipo",references:e.t("audit_references"),security:e.t("audit_security"),electronicSigned:e.t("audit_esign"),accomplishedBy:"Realizado por",accomplishedIn:"Realizado em",changedFrom:"de",changedTo:"para",uninformed:e.t("audit_not_informed"),stateAdded:"(adicionado)",stateModified:"(modificado)",stateRemoved:"(removido)"};function ix({documentId:e,onFetchDetails:s,onClose:r,labels:n,translateProperty:o,translatePropertyValue:i,formatDate:l}){const[c,u]=t.useState(!1),[m,p]=t.useState([]),[h,x]=t.useState(null),f=t.useCallback(async e=>{u(!0),x(null);try{const a=Zh(await s(e),{translateProperty:o,translatePropertyValue:i,formatDate:l,labels:n});p(a)}catch(a){x("Erro ao carregar detalhes da trilha de auditoria."),p([])}finally{u(!1)}},[s,o,i,l,n]);return t.useEffect(()=>{e&&f(e)},[e,f]),e?a.jsxs("div",{className:"flex flex-col h-full bg-background",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[a.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Detalhes da Auditoria"}),a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(d.X,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:c?a.jsxs("div",{className:"flex items-center justify-center p-6",children:[a.jsx(tr,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando detalhes..."})]}):h?a.jsx("div",{className:"p-6 text-sm text-destructive",children:h}):a.jsx("table",{className:"w-full text-xs",children:a.jsx("tbody",{children:m.map((e,t)=>a.jsxs("tr",{className:t%2==0?"bg-background":"bg-muted/20",children:[a.jsx("td",{className:"px-4 py-2.5 font-semibold text-foreground whitespace-nowrap align-top w-[180px] border-b border-border/50",children:e.name}),a.jsx("td",{className:"px-4 py-2.5 text-muted-foreground break-words border-b border-border/50",children:a.jsx("span",{dangerouslySetInnerHTML:{__html:e.value.replace(/\n/g,"<br />")}})})]},t))})})})]}):null}function lx({open:s,onOpenChange:r,returnSteps:n,initialObservation:o="",title:i=e.t("approval_execute_action"),descriptions:d=[],setDefaultApproverOnInit:c=!0,onSubmit:u}){const[m,p]=t.useState(!0),[h,x]=t.useState(c&&n.length>0?n[0].id:null),[f,g]=t.useState(o),v=e=>{p(e),e&&!c?x(null):!e&&!c&&n.length>0&&x(n[0].id)},b=f!==o||!m;return a.jsx(js,{open:s,onOpenChange:r,children:a.jsxs(ks,{className:"sm:max-w-[480px]",variant:"form",isDirty:b,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:i})}),a.jsxs("div",{className:"space-y-4",children:[d.length>0&&a.jsx("div",{className:"space-y-1 text-sm text-muted-foreground",children:d.map((e,t)=>a.jsx("p",{dangerouslySetInnerHTML:{__html:e}},t))}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:m,onChange:()=>v(!0),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_approve")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:!m,onChange:()=>v(!1),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_reprove_radio")})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:"Etapa"}),a.jsxs(Vs,{value:h??void 0,onValueChange:x,disabled:m,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:e.t("approval_select_step")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Qs,{value:e.id,children:e.name},e.id))})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:e.t("approval_opinion")}),a.jsx(Js,{value:f,onChange:e=>g(e.target.value),maxLength:4e3,rows:4,autoFocus:!0}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/",4e3]})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{if(!f.trim())return void l.toast.error("Formulário inválido. Preencha todos os campos obrigatórios.");const e=m?null:n.find(e=>e.id===h);u({approved:m,returnStepId:m?null:h,returnType:e?.type??null,observation:f})},disabled:!b,children:"Concluir"})]})]})})}function dx({open:e,onOpenChange:s,approvers:r,isLoading:n=!1,ignoreUserIds:o=[],onSubmit:i}){const{t:l}=j.useTranslation(),[d,c]=t.useState(null),u=t.useMemo(()=>{const e=new Set(o);return r.filter(a=>!e.has(a.id))},[r,o]),m=t.useMemo(()=>u.map(e=>({value:e.id,label:e.name})),[u]);return a.jsx(js,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"sm:max-w-[450px]",variant:"form",isDirty:!!d,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:l("approval_select_approver")})}),a.jsx(sr,{isLoading:n,type:"spinner",children:a.jsx("div",{className:"space-y-4",children:a.jsx(Ur,{options:m,value:d??void 0,onValueChange:e=>c("string"==typeof e?e:e?.[0]??null),placeholder:l("approval_select_approver_placeholder"),searchPlaceholder:l("approval_search_approver")})})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{if(!d)return;const e=u.find(e=>e.id===d);e&&i(e)},disabled:!d||n,children:"Concluir"})]})]})})}function cx(e){const{t:a}=j.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}function ux({text:e,maxLength:s=130}){const{t:r}=j.useTranslation(),[n,o]=t.useState(!1);return e.length<=s?a.jsx("span",{children:e}):a.jsxs("span",{children:[n?e:`${e.substring(0,s)}... `,a.jsx("button",{className:"text-primary hover:underline text-sm cursor-pointer",onClick:()=>o(!n),children:r(n?"approval_read_less":"approval_read_more")})]})}function mx({approver:e}){if(1===e.type&&e.approverId)return a.jsxs(nl,{className:"h-9 w-9 shrink-0",children:[a.jsx(ol,{src:e.photoUrl,alt:e.name}),a.jsx(il,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]});const t=2===e.type?d.Users:3===e.type?d.MapPin:d.User;return a.jsx("div",{className:"h-9 w-9 rounded-full bg-muted-foreground/30 flex items-center justify-center shrink-0",children:a.jsx(t,{className:"h-4 w-4 text-background"})})}function px({approver:e}){return e.date?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-green-500/10 text-foreground",children:[a.jsx(d.CheckCircle,{className:"h-3.5 w-3.5 text-green-600"}),"Aprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:cx(e.date)}),1!==e.type&&e.approvedUsername&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["por ",e.approvedUsername]})]}):e.returnDate?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-red-500/10 text-foreground",children:[a.jsx(d.XCircle,{className:"h-3.5 w-3.5 text-red-600"}),"Reprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:cx(e.returnDate)})]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-muted text-muted-foreground",children:[a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),"Aguardando"]})}function hx({approver:e}){const{t:t}=j.useTranslation(),s=1!==e.type||e.approverId?e.name:"A definir";return a.jsxs("div",{children:[2===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:t("approval_user_group")}),3===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Local"}),a.jsx("p",{className:"text-sm font-medium break-words",children:s}),a.jsx(px,{approver:e})]})}var xx;exports.ApprovalFlowReturnStep=void 0,(xx=exports.ApprovalFlowReturnStep||(exports.ApprovalFlowReturnStep={}))[xx.ApprovalFlow=1]="ApprovalFlow",xx[xx.Association=2]="Association",exports.i18n=e,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return j.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return j.useTranslation}}),exports.AUTH_CONFIG=Me,exports.AccessDeniedDialog=Yi,exports.Accordion=al,exports.AccordionContent=rl,exports.AccordionItem=tl,exports.AccordionTrigger=sl,exports.ActionButton=Jt,exports.ActionMenu=Jt,exports.ActionMenuItems=lo,exports.ActionPlanAttachmentsTab=Th,exports.ActionPlanCommentsTab=Nh,exports.ActionPlanCostTab=wh,exports.ActionPlanGeneralTab=mh,exports.ActionPlanHistoryTab=Ch,exports.ActionPlanPage=function(e){const{formData:t,isLoading:s,isSaving:r,activeTab:n,isFormDisabled:o,updateField:i,setActiveTab:l,save:c,changeStatus:u,remove:m,cancel:p}=dh(e),{t:h}=j.useTranslation(),{isNew:x=!1,config:f,users:g,places:v,actionTypes:b,causes:y,parentActions:w,progress:N,predecessors:_,availablePredecessors:C,costs:k,comments:S,history:T,attachments:P,attachmentsSlot:D,commentsSlot:E,historySlot:A,onAddPredecessor:I,onRemovePredecessor:M,onAddCost:F,onEditCost:R,onDeleteCost:L,onAddComment:z,onEditComment:U,onDeleteComment:O,onUploadAttachment:V,onDeleteAttachment:B,onRenameAttachment:q,onDownloadAttachment:$,onViewAttachment:W}=e;if(s&&!t.id)return a.jsx(sr,{isLoading:!0,children:a.jsx("div",{})});const H=function(e){const{t:a}=j.useTranslation();if(!e)return[];return{[exports.ETaskPlanStatus.waitingStart]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.running]:[exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.effectivenessCheck]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.done]:[exports.ETaskPlanStatus.running],[exports.ETaskPlanStatus.suspended]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.canceled]:[exports.ETaskPlanStatus.waitingStart]}[e]||[]}(t.statusId);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[p&&a.jsx(Xt,{variant:"ghost",size:"icon",onClick:p,children:a.jsx(d.ArrowLeft,{className:"h-4 w-4"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:x?h("ap_new_action"):t.name||h("ap_action_plan")}),!x&&t.statusId&&a.jsx(uh,{status:t.statusId})]}),t.code&&a.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:t.code})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!x&&H.length>0&&!o&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"outline",size:"sm",children:"Alterar Status"})}),a.jsx(pr,{align:"end",children:H.map(e=>a.jsx(hr,{onClick:()=>u(e),children:rh[e]},e))})]}),!x&&e.onDelete&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",children:a.jsx(d.MoreVertical,{className:"h-4 w-4"})})}),a.jsx(pr,{align:"end",children:a.jsx(hr,{className:"text-destructive",onClick:m,children:"Excluir"})})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:a.jsxs(yi,{value:n,onValueChange:l,children:[a.jsxs(wi,{className:"mb-6",children:[a.jsx(Ni,{value:"general",children:"Geral"}),!x&&a.jsx(Ni,{value:"progress",children:"Progresso"}),!x&&f?.enablePredecessors&&a.jsx(Ni,{value:"predecessors",children:h("ap_predecessors")}),!x&&f?.enableCosts&&a.jsx(Ni,{value:"costs",children:"Custos"}),!x&&f?.enableAttachments&&a.jsx(Ni,{value:"attachments",children:h("ap_attachments")}),!x&&f?.enableComments&&a.jsx(Ni,{value:"comments",children:h("ap_comments")}),!x&&f?.enableHistory&&a.jsx(Ni,{value:"history",children:"Histórico"})]}),a.jsx(_i,{value:"general",children:a.jsx(mh,{formData:t,updateField:i,disabled:o,users:g,places:v,actionTypes:b,causes:y,parentActions:w,config:f})}),!x&&a.jsx(_i,{value:"progress",children:a.jsx(bh,{...e})}),!x&&f?.enablePredecessors&&a.jsx(_i,{value:"predecessors",children:a.jsx(yh,{predecessors:_,availablePredecessors:C,onAdd:I,onRemove:M,disabled:o})}),!x&&f?.enableCosts&&a.jsx(_i,{value:"costs",children:a.jsx(wh,{costs:k,onAdd:F,onEdit:R,onDelete:L,disabled:o})}),!x&&f?.enableAttachments&&a.jsx(_i,{value:"attachments",children:D||a.jsx(Th,{attachments:P,onUpload:V,onDelete:B,onRename:q,onDownload:$,onView:W,disabled:o})}),!x&&f?.enableComments&&a.jsx(_i,{value:"comments",children:E||a.jsx(Nh,{comments:S,onAdd:z,onEdit:U,onDelete:O,disabled:o})}),!x&&f?.enableHistory&&a.jsx(_i,{value:"history",children:A||a.jsx(Ch,{history:T})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[p&&a.jsx(Xt,{variant:"outline",onClick:p,disabled:r,children:"Cancelar"}),a.jsx(Xt,{onClick:c,disabled:r||o,children:r?"Salvando...":"Salvar"})]})]})},exports.ActionPlanPredecessorsTab=yh,exports.ActionPlanProgressDialog=vh,exports.ActionPlanProgressTab=bh,exports.ActionPlanStatusBadge=uh,exports.Alert=Jo,exports.AlertDescription=ei,exports.AlertDialog=ds,exports.AlertDialogAction=vs,exports.AlertDialogCancel=bs,exports.AlertDialogContent=ps,exports.AlertDialogDescription=gs,exports.AlertDialogFooter=xs,exports.AlertDialogHeader=hs,exports.AlertDialogOverlay=ms,exports.AlertDialogPortal=us,exports.AlertDialogTitle=fs,exports.AlertDialogTrigger=cs,exports.AlertTitle=Zo,exports.AliasRedirect=function(){const{alias:e}=Pn(),{pathname:t,search:s,hash:r}=N.useLocation();return e?a.jsx(N.Navigate,{to:`/${e}${t}${s}${r}`,replace:!0}):null},exports.AliasRouteGuard=function({children:e,paramName:s="alias"}){const r=N.useNavigate(),n=N.useLocation(),o=N.useParams(),{alias:i,isAuthenticated:l,isLoading:d,switchUnit:c}=Pn(),{urlAlias:u,isAliasMismatch:m,isValidAlias:p,isMissing:h,matchedCompany:x}=Qo({paramName:s}),[f,g]=t.useState(!1),v=t.useRef(!1),b=s in o,j=t.useCallback(e=>{const a=o[s],{pathname:t,search:r,hash:i}=n;if(a){const s=t.split("/"),n=s.findIndex(e=>e===a);if(n>=0)return s[n]=e,s.join("/")+r+i}return`/${e}${"/"===t?"":t}${r}${i}`},[o,s,n]);return t.useEffect(()=>{if(b&&!d&&l&&i&&!v.current)if(h)r(j(i),{replace:!0});else if(!u||p){if(m&&x&&!v.current){(async()=>{v.current=!0,g(!0);try{await c(x)}catch(e){i&&r(j(i),{replace:!0})}finally{v.current=!1,g(!1)}})()}}else r(j(i),{replace:!0})},[b,d,l,i,h,u,p,m,x,c,j,r]),d||!l?a.jsx(a.Fragment,{children:e}):f?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(tr,{size:"lg"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Trocando unidade..."})]})}):a.jsx(a.Fragment,{children:e})},exports.AppHeader=Xm,exports.AppLayout=op,exports.AppSidebar=np,exports.ApprovalSidenav=function({config:e,isLoading:s=!1,onClose:r,onApprove:n,onDefineApprover:o,onRefreshSteps:i,availableApprovers:l=[],isLoadingApprovers:c=!1}){const{t:u}=j.useTranslation(),[m,p]=t.useState(!1),[h,x]=t.useState(!1),[f,g]=t.useState(""),[v,b]=t.useState(""),[y,w]=t.useState(!1),[N,_]=t.useState(""),C=s||m,k=t.useCallback((e,a)=>{g(e),b(a??""),x(!0)},[]),S=t.useCallback(async a=>{x(!1),p(!0);if(!await n(e.associationId,{stepApproverId:f,...a}))return k(f,a.observation),void p(!1);r(),p(!1)},[e.associationId,f,n,r,k]),T=t.useCallback(e=>{_(e),w(!0)},[]),P=t.useCallback(async a=>{w(!1),p(!0),await o(e.associationId,N,a),await(i?.(e.associationId)),p(!1)},[e.associationId,N,o,i]),D=e.approvalFlowSteps.find(e=>e.isCurrentStep)?.approvers.filter(e=>1===e.type&&e.approverId).map(e=>e.approverId)??[],E=(a,t)=>e.canApprove&&a.isCurrentStep&&t.approverId&&!t.date&&t.canApprove,A=(a,t)=>!e.flowReproved&&a.isCurrentStep&&1===t.type&&t.canApprove&&(!t.approverId||t.isToBeDefined);return a.jsxs("div",{className:"w-[550px] max-w-[900px] min-w-[400px] h-full flex flex-col bg-background",children:[a.jsxs("div",{className:"shrink-0 shadow-sm px-1 py-2 flex items-center gap-1 border-l-4",style:{borderLeftColor:e.color},children:[a.jsx(Xt,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0",children:a.jsx(d.X,{className:"h-5 w-5"})}),a.jsx("span",{className:"text-lg font-medium",children:e.title})]}),C?a.jsx(sr,{isLoading:!0,type:"spinner",className:"flex-1",children:a.jsx("div",{})}):a.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.approvalFlowInfo.length>0&&a.jsx("div",{className:"space-y-1",children:e.approvalFlowInfo.map((e,t)=>a.jsx("div",{className:Yt("flex items-center gap-1.5 text-sm",e.color&&"rounded-lg px-2 py-1"),style:e.color?{color:e.color,backgroundColor:e.backgroundColor}:void 0,children:e.title?`${e.title}: ${e.value}`:e.value},t))}),a.jsx("hr",{className:"border-border"}),e.approvalFlowSteps.map(t=>a.jsxs("div",{className:Yt("space-y-2",(!t.isCurrentStep||e.flowReproved)&&"opacity-50"),children:[a.jsxs("p",{className:"font-semibold text-sm",children:[t.index,". Etapa: ",t.name]}),t.description&&a.jsx("p",{className:"text-sm text-muted-foreground break-words",children:a.jsx(ux,{text:t.description})}),t.returnDate&&a.jsxs("div",{className:"border-y border-border py-3 mt-3 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs rounded px-1.5 py-0.5 bg-red-500/10 text-red-600",children:"Retorno de etapa"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.returnUserName," em ",cx(t.returnDate)]})]}),t.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground bg-muted rounded p-2 break-words",children:a.jsx(ux,{text:t.returnObservation})})]}),t.approvers.map(e=>a.jsxs("div",{className:"p-2 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[a.jsx(mx,{approver:e}),a.jsx(hx,{approver:e})]}),E(t,e)&&a.jsx(Xt,{size:"sm",onClick:()=>k(e.id),children:"Aprovar"}),A(t,e)&&a.jsx(Xt,{size:"sm",variant:"outline",onClick:()=>T(e.id),children:"Selecionar"})]}),e.observation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(ux,{text:e.observation})}),e.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(ux,{text:e.returnObservation})})]},e.id))]},t.id))]}),a.jsx(lx,{open:h,onOpenChange:x,returnSteps:e.returnSteps,initialObservation:v,title:e.approveDialogTitle,descriptions:e.approveDialogDescriptions,setDefaultApproverOnInit:e.approveDialogSetDefaultApproverOnInit,onSubmit:S}),a.jsx(dx,{open:y,onOpenChange:w,approvers:l,isLoading:c,ignoreUserIds:D,onSubmit:P})]})},exports.ApproveDialog=lx,exports.AuditTrailDetails=ix,exports.AuditTrailFilter=Yh,exports.AuditTrailPage=function({title:s,softwares:r,softwareId:n,permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},callbacks:i,limit:l=2e3,currentUserId:c,labels:u,formatDate:m,anonymousLabel:p=e.t("anonymous")}){const{t:h}=j.useTranslation();s??h("audit_trail");const[x,f]=t.useState(!0),[g,v]=t.useState([]),[b,y]=t.useState([]),[w,N]=t.useState([]),[_,C]=t.useState(null),[k,S]=t.useState(!1),T=t.useRef(null),P=new Date;P.setHours(0,0,0,0);const[D,E]=t.useState({software:r.find(e=>e.id===n)?.software||"",softwareId:n,event:"All",eventId:1,startDate:P,endDate:P,limit:l,softwares:r,userId:o.viewOnlyMyEvents&&!o.viewAllEvents?c:void 0});t.useEffect(()=>{(async()=>{f(!0);try{const[e,a]=await Promise.all([i.onFetchEvents(D.softwareId),i.onFetchUsers?.()??Promise.resolve([])]);y(e),N(a),await A(D,e)}catch(e){}finally{f(!1)}})()},[]);const A=t.useCallback(async(e,a)=>{try{const t=Kh((await i.onFetchTrails(e)).data,a||b,r,p);v(t)}catch(t){}},[i,b,r,p]),I=t.useCallback(async e=>{f(!0),E(e);try{await A(e)}finally{f(!1)}},[A]),M=t.useCallback(async e=>{try{const a=await i.onFetchEvents(e);y(a)}catch(a){}},[i]),F=t.useCallback(e=>{C(e.documentId),S(!0)},[]),R=t.useCallback(()=>{S(!1),C(null)},[]),L=t.useCallback(async()=>{const e={...D,startDate:P,endDate:P,eventId:1,userId:o.viewAllEvents?void 0:c};E(e),f(!0);try{await A(e)}finally{f(!1)}},[D,A]),z=t.useCallback(e=>{i.onExport?.(e,g)},[i,g]),U=t.useCallback(e=>{try{return new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}},[]);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"p-3",children:a.jsx(Yh,{queryParams:D,events:b,softwares:r,users:w,permissions:o,isLoading:x,onFilter:I,onReset:L,onExport:o.download?z:void 0,onSoftwareChange:M})}),a.jsxs("div",{className:"flex flex-1 min-h-0 relative",children:[a.jsxs("div",{className:Yt("flex-1 overflow-auto transition-all duration-300",k?"mr-[400px]":""),children:[x?a.jsxs("div",{className:"flex items-center justify-center h-64",children:[a.jsx(tr,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando trilha de auditoria..."})]}):0===g.length?a.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground",children:[a.jsx(d.FileText,{className:"h-12 w-12 mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:"Nenhum registro encontrado"}),a.jsx("p",{className:"text-xs mt-1",children:"Ajuste os filtros e tente novamente"})]}):a.jsxs("table",{className:"w-full text-xs border-collapse",children:[a.jsx("thead",{className:"sticky top-0 z-10",children:a.jsxs("tr",{className:"bg-muted/60 border-b border-border",children:[a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Layers,{className:"h-3 w-3"}),"Módulo"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),"Data"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.User,{className:"h-3 w-3"}),"Usuário"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.FileText,{className:"h-3 w-3"}),"Evento"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Item"}),a.jsx("th",{className:"px-3 py-2 w-10"})]})}),a.jsx("tbody",{children:g.map((e,t)=>a.jsxs("tr",{onClick:()=>F(e),className:Yt("cursor-pointer border-b border-border/50 transition-colors","hover:bg-accent/50",_===e.documentId&&"bg-accent",t%2==0?"bg-background":"bg-muted/10"),children:[a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedSoftware}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",children:e.date?U(e.date.toISOString()):"—"}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.user}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedEvent}),a.jsx("td",{className:"px-3 py-2 text-foreground truncate max-w-[200px]",title:e.entityName,children:e.entityName}),a.jsx("td",{className:"px-3 py-2",children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.documentId||t))})]}),!x&&g.length>0&&a.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border bg-muted/20",children:[g.length," registro",1!==g.length?"s":""]})]}),a.jsx("div",{ref:T,className:Yt("fixed right-0 top-0 h-full w-[400px] border-l border-border bg-background shadow-lg z-30","transition-transform duration-300 ease-in-out",k?"translate-x-0":"translate-x-full"),children:k&&a.jsx(ix,{documentId:_,onFetchDetails:i.onFetchDetails,onClose:R,labels:u,translateProperty:i.translateProperty,translatePropertyValue:i.translatePropertyValue,formatDate:m||U})})]})]})},exports.AuthErrorInterceptor=cn,exports.AuthProvider=Tn,exports.AuthService=_n,exports.AutoComplete=Ur,exports.Avatar=nl,exports.AvatarFallback=il,exports.AvatarImage=ol,exports.Badge=er,exports.BaseForm=zo,exports.Blockquote=Jl,exports.BodyContent=function({breadcrumbs:e,children:t,className:s}){return a.jsxs("div",{className:Yt("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[e&&e.length>0&&a.jsx(ll,{className:"mb-4",children:a.jsx(dl,{children:e.map((t,s)=>{const r=s===e.length-1;return a.jsxs(te.Fragment,{children:[s>0&&a.jsx(pl,{}),a.jsx(cl,{children:r||!t.href?a.jsx(ml,{children:t.label}):t.asChild&&t.children?a.jsx(ul,{asChild:!0,children:t.children}):a.jsx(ul,{asChild:!0,children:a.jsx(N.Link,{to:t.href||"/",children:t.label})})})]},`${t.label}-${s}`)})})}),a.jsx("div",{className:"space-y-6",children:t})]})},exports.Breadcrumb=ll,exports.BreadcrumbEllipsis=hl,exports.BreadcrumbItem=cl,exports.BreadcrumbLink=ul,exports.BreadcrumbList=dl,exports.BreadcrumbPage=ml,exports.BreadcrumbSeparator=pl,exports.BurndownPanel=mm,exports.Button=Xt,exports.ButtonGroup=fl,exports.CLOSED_STATUSES=ih,exports.CRUD_CONFIG=Fe,exports.CURRENCY_FIELDS=Uu,exports.Calendar=gl,exports.CallbackPage=()=>{const{processCallback:e}=Pn(),s=N.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await e()){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(a){localStorage.removeItem("auth_return_url"),n(a?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e,s]);const l=async()=>{i(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(a){n(a?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsxs(rs,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[a.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),a.jsxs(os,{className:"space-y-4",children:[a.jsx(Jo,{variant:"danger",children:a.jsx(ei,{children:r})}),a.jsx("div",{className:"text-sm text-muted-foreground",children:a.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Xt,{onClick:l,disabled:o,className:"flex-1",children:o?a.jsxs(a.Fragment,{children:[a.jsx(tr,{size:"sm",className:"mr-2"}),"Tentando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),a.jsx(Xt,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(tr,{size:"lg"})}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=ts,exports.CardContent=os,exports.CardDescription=ns,exports.CardFooter=is,exports.CardHeader=ss,exports.CardSkeleton=Bn,exports.CardTitle=rs,exports.CartesianPanel=im,exports.ChartContainer=Cc,exports.ChartLegend=Pc,exports.ChartLegendContent=Dc,exports.ChartStyle=kc,exports.ChartTooltip=Sc,exports.ChartTooltipContent=Tc,exports.Checkbox=Xs,exports.Collapsible=gi,exports.CollapsibleContent=bi,exports.CollapsibleTrigger=vi,exports.ColorPicker=Po,exports.ColumnSettingsPopover=_o,exports.ComboTree=Wr,exports.Combobox=Ur,exports.Command=Tr,exports.CommandDialog=({children:e,...t})=>a.jsx("div",{...t,children:a.jsx(Tr,{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:e})}),exports.CommandEmpty=Er,exports.CommandGroup=Ar,exports.CommandInput=Pr,exports.CommandItem=Mr,exports.CommandList=Dr,exports.CommandSeparator=Ir,exports.CommandShortcut=Fr,exports.ContentContainer=function({title:e,subtitle:t,children:s,className:r,hasHeader:n=!0}){const o=e||t;return a.jsxs("div",{className:Yt("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-visible",r),children:[n&&o&&a.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[e&&a.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),t&&a.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),s&&a.jsx("div",{className:Yt("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Gn,exports.ContextMenuCheckboxItem=so,exports.ContextMenuContent=ao,exports.ContextMenuGroup=Qn,exports.ContextMenuItem=to,exports.ContextMenuLabel=no,exports.ContextMenuPortal=Kn,exports.ContextMenuRadioGroup=Jn,exports.ContextMenuRadioItem=ro,exports.ContextMenuSeparator=oo,exports.ContextMenuShortcut=io,exports.ContextMenuSub=Xn,exports.ContextMenuSubContent=eo,exports.ContextMenuSubTrigger=Zn,exports.ContextMenuTrigger=Yn,exports.CoreProviders=function({children:s,queryClient:r,moduleAlias:n,moduleAccessGuardProps:o,appTranslations:i,clarityProjectId:l,clarityMode:d="auto"}){Ji();const[c]=t.useState(()=>new w.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),u=r??c;t.useEffect(()=>{if(i)for(const[e,a]of Object.entries(i))li(e,a)},[i]);const m={sourceModule:n,...o};return a.jsx(ji,{children:a.jsx(j.I18nextProvider,{i18n:e,children:a.jsx(w.QueryClientProvider,{client:u,children:a.jsxs(Tn,{children:[a.jsx(el,{projectId:l,mode:d}),a.jsx(mi,{children:a.jsx(xi,{moduleAlias:n,children:a.jsx(Ki,{...m,children:s})})})]})})})})},exports.CrudActionBar=bo,exports.CrudActionMenu=Im,exports.CrudGrid=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f,showActionBar:g=!0,showSearch:v=!1,searchValue:b,onSearchChange:y,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:_,filters:C,gridColumns:k=3,renderCard:S,viewMode:T,onViewModeChange:P,listCardRenderer:D,gridCardRenderer:E,showViewToggle:A=!1})=>{const{setSearchVisible:I}=Pn(),M=void 0!==f?!f:g;t.useEffect(()=>{if(!v)return I(!0),()=>I(!1)},[I,v]);const F=m||x.length>0||v||u||C||A,R=_||(()=>{s.bulkDelete?.(s.selectedIds)}),L=T||"grid",z="list"===L,U={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"}[z?1:k],O=M&&F?a.jsx(bo,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:v,searchValue:b,onSearchChange:y,searchPlaceholder:w,showBulkActions:u,selectedCount:s.selectedIds.length,bulkActions:N,onBulkDelete:R,onClearSelection:s.clearSelection,customActions:x,filters:C,viewMode:L,onViewModeChange:P,showViewToggle:A,availableViewModes:["list","grid"]}):null;return s.isLoading?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx(Bn,{count:6})})]}):0===s.entities.length?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx($n,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"})})]}):a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx("div",{className:Yt("grid gap-4",U),children:s.entities.map(e=>{const t=(e=>{const{t:a}=j.useTranslation();return z&&D?D(e):!z&&E?E(e):S?S(e):null})(e);return a.jsxs(Gn,{children:[a.jsx(Yn,{asChild:!0,children:t?a.jsx("div",{className:"cursor-pointer",onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:t}):a.jsx(ts,{className:Yt("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&s.selectedIds.includes(e.id)&&"bg-muted ring-2 ring-primary",z&&"flex-row"),onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:a.jsxs(os,{className:Yt("p-4",z&&"flex items-center gap-4 w-full"),children:[u&&a.jsx("div",{className:Yt(z?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:a.jsx(jo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),z?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:r.map(t=>a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key)))}),(n||o||d)&&a.jsx("div",{onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[u&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(jo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[r.map((t,s)=>a.jsxs("div",{className:Yt("flex justify-between items-start gap-2",s!==r.length-1&&"mb-2"),children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||d)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]})]})]})})}),a.jsx(ao,{className:"w-[160px]",children:a.jsx(lo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:c?c(e):[],renderAs:"context"})})]},e.id)})})})]})},exports.CrudPageInternal=Ho,exports.CrudPagination=Oo,exports.CrudPrimitiveFilterBar=Mm,exports.CrudPrimitivePagination=Uo,exports.CrudPrimitiveTable=Am,exports.CrudTable=ko,exports.CustomFormFields=function({fields:e,readOnly:s=!1,hideInactiveWithoutValue:r=!1,onChange:n,onFieldChange:o}){const i=t.useCallback(a=>{if(o?.(a),n){const t=e.map(e=>e.id===a.id?a:e);n(t)}},[e,n,o]),l=e.filter(e=>Lh(e,r));return 0===l.length?null:a.jsx("div",{className:"space-y-4",children:l.map(e=>a.jsx(Gh,{field:e,readOnly:s,onChange:i},e.id))})},exports.D4SignWidget=Yp,exports.DASHBOARD_STORAGE_KEYS={advancedFilter:"analysisDashboardsListFilter"},exports.DATETIME_FORMATS=Dt,exports.DEFAULT_ACTION_TYPES=nh,exports.DEFAULT_DATETIME_FORMAT=It,exports.DEFAULT_LOCALE=At,exports.DEFAULT_TIMEZONE=Mt,exports.DashboardForm=Em,exports.DashboardGeneralView=function({dashboards:e,limit:s,generalView:r,language:n=exports.DashboardLanguage.PtBr,isLoading:o=!1,canAdd:i=!1,canEdit:l=!1,canRemove:d=!1,canEditStandard:c=!1,activePanels:u=[],activePages:m=[],getPanelData:p,users:h=[],groups:x=[],places:f=[],collaborators:g=[],isSaving:v=!1,onOpen:b,onBackToList:j,onRefresh:y,onRefreshList:w,onToggleFavorite:N,onSave:_,onUpdate:C,onRemove:k,onDuplicate:S,onShare:T,onAddPanel:P,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:A,onLayoutChange:I,onSearch:M,onQuickFilterChange:F,onSetGeneralView:R,viewState:L,onViewStateChange:z,listToolbarExtra:U,viewToolbarActions:O,className:V}){const[B,q]=t.useState({mode:"list"}),$=L??B,W=t.useCallback(e=>{z?z(e):q(e)},[z]),H=t.useMemo(()=>"view"===$.mode||"edit"===$.mode||"share"===$.mode?e.find(e=>e.id===$.dashboardId)??null:null,[e,$]),[G,Y]=t.useState(!1),[Q,K]=t.useState(m[0]?.id);t.useEffect(()=>{m.length>0&&!Q&&K(m[0]?.id)},[m,Q]),t.useEffect(()=>{if("view"!==$.mode||!H||H.idViewType!==exports.DashboardViewType.Carousel||m.length<=1)return;const e=function(e){switch(e){case exports.DashboardPageTime.FiveSeconds:return 5e3;case exports.DashboardPageTime.TenSeconds:return 1e4;case exports.DashboardPageTime.FifteenSeconds:return 15e3;case exports.DashboardPageTime.ThirtySeconds:return 3e4;case exports.DashboardPageTime.OneMinute:return 6e4;case exports.DashboardPageTime.ThreeMinutes:return 18e4;case exports.DashboardPageTime.FiveMinutes:return 3e5;case exports.DashboardPageTime.TenMinutes:return 6e5;default:return 15e3}}(H.idPageTime),a=setInterval(()=>{K(e=>{const a=(m.findIndex(a=>a.id===e)+1)%m.length;return m[a]?.id})},e);return()=>clearInterval(a)},[$,H,m]);const X=t.useCallback(e=>{W({mode:"view",dashboardId:e.id}),K(void 0),b?.(e)},[W,b]),J=t.useCallback(()=>{W({mode:"list"}),Y(!1),j?.()},[W,j]),Z=t.useCallback(()=>{W({mode:"create"})},[W]),ee=t.useCallback(e=>{W({mode:"edit",dashboardId:e.id})},[W]),ae=t.useCallback(e=>{W({mode:"share",dashboardId:e.id})},[W]),te=t.useCallback(e=>{"edit"===$.mode||"share"===$.mode?C?.($.dashboardId,e):_?.(e)},[$,_,C]),se=t.useCallback(()=>{"edit"===$.mode||"share"===$.mode?W({mode:"view",dashboardId:$.dashboardId}):W({mode:"list"})},[$,W]),re=t.useCallback(()=>{H&&N?.(H)},[H,N]),ne=t.useCallback(()=>{H&&ee(H)},[H,ee]),oe=t.useCallback(()=>{H&&ae(H)},[H,ae]);return a.jsxs("div",{className:Yt("flex flex-col h-full",V),children:["list"===$.mode&&a.jsx(Cm,{dashboards:e,limit:s,isLoading:o,language:n,canAdd:i,canEdit:l,canRemove:d,onOpen:X,onEdit:ee,onShare:ae,onDuplicate:S,onRemove:k,onAdd:Z,onToggleFavorite:N,onRefresh:w,onSearch:M,onQuickFilterChange:F,toolbarExtra:U,className:"flex-1"}),"view"===$.mode&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[!G&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:[a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]}),r?.dashboardId===H.id&&a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary",children:[a.jsxs("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),a.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),"Visão geral"]}),l&&R&&r?.dashboardId!==H.id&&a.jsx("button",{onClick:()=>R(H.id),className:"ml-auto text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Definir como visão geral"})]}),a.jsx(ym,{dashboard:H,panels:u,pages:m,activePageId:Q,canEdit:l||c&&!!H.isStandard,isFullscreen:G,isLoading:o,getPanelData:p,onRefresh:y,onToggleFullscreen:()=>Y(e=>!e),onToggleFavorite:re,onEdit:ne,onShare:oe,onAddPanel:P,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:A,onLayoutChange:I,onPageChange:K,toolbarActions:O,className:"flex-1"})]}),"create"===$.mode&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]})}),a.jsx(Em,{users:h,groups:x,places:f,collaborators:g,isSaving:v,onSave:te,onCancel:se,className:"flex-1"})]}),("edit"===$.mode||"share"===$.mode)&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:se,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar"]})}),a.jsx(Em,{dashboard:H,initialTab:"share"===$.mode?exports.DashboardFormTab.Share:exports.DashboardFormTab.General,users:h,groups:x,places:f,collaborators:g,isSaving:v,isQualitfy:!!H.isStandard&&!c,onSave:te,onCancel:se,className:"flex-1"})]})]})},exports.DashboardGrid=vm,exports.DashboardList=Cm,exports.DashboardPanelRenderer=jm,exports.DashboardView=ym,exports.DataFilterBar=Mm,exports.DataList=vl,exports.DataPagination=Uo,exports.DataTable=Am,exports.DatePicker=bl,exports.Dialog=js,exports.DialogBody=Ts,exports.DialogClose=Ns,exports.DialogContent=ks,exports.DialogDescription=Es,exports.DialogFooter=Ps,exports.DialogHeader=Ss,exports.DialogOverlay=_s,exports.DialogPortal=ws,exports.DialogTitle=Ds,exports.DialogTrigger=ys,exports.DialogWizard=function({open:t,onOpenChange:s,currentStep:r,onStepChange:n,steps:o,canGoToStep:i,children:l,title:c,description:u,onSave:m,saveLabel:p=e.t("save"),nextLabel:h=e.t("next"),backLabel:x=e.t("back"),variant:f="form",isDirty:g,size:v="lg",unsavedChangesTitle:b,unsavedChangesDescription:y,cancelText:w,leaveWithoutSavingText:N,className:_,disableNext:C,hideNavigation:k,footerLeft:S}){const{t:T}=j.useTranslation(),P=o.length,D=r>=P,E=r<=1;return a.jsx(js,{open:t,onOpenChange:s,children:a.jsxs(ks,{size:v,variant:f,isDirty:g,unsavedChangesTitle:b,unsavedChangesDescription:y,cancelText:w,leaveWithoutSavingText:N,className:Yt("!p-0 !border-l-0 flex-row overflow-hidden",_),children:[a.jsxs("div",{className:"hidden sm:flex w-56 flex-shrink-0 flex-col bg-primary text-primary-foreground p-6 rounded-l-lg",children:[a.jsx("h3",{className:"text-sm font-medium opacity-80 mb-6",children:"Etapas"}),a.jsx("nav",{className:"flex flex-col gap-1 flex-1",children:o.map((e,t)=>{const s=t+1,o=s===r,l=(e=>e<r)(s),c=(u=s)<=r||!i||i(u);var u;return a.jsxs("button",{type:"button",onClick:()=>(e=>{e!==r&&(e<r?n(e):i&&!i(e)||n(e))})(s),disabled:!c,className:Yt("flex items-center gap-2 py-3 px-2 rounded-md text-left transition-colors text-xs",o&&"bg-primary-foreground/20 font-semibold",!o&&c&&"hover:bg-primary-foreground/10 cursor-pointer",!c&&"opacity-40 cursor-not-allowed"),children:[a.jsx("span",{className:Yt("flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold flex-shrink-0 transition-colors",o&&"bg-primary-foreground text-primary",l&&!o&&"bg-primary-foreground/30 text-primary-foreground",!o&&!l&&"border-2 border-primary-foreground/40 text-primary-foreground/60"),children:l&&!o?a.jsx(d.Check,{className:"h-3.5 w-3.5"}):s}),a.jsx("span",{className:Yt("line-clamp-2",o&&"text-primary-foreground",!o&&"text-primary-foreground/70"),children:e})]},s)})})]}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[a.jsxs(Ss,{className:"p-6 pb-0",children:[a.jsxs("p",{className:"text-xs text-muted-foreground sm:hidden mb-1",children:["Etapa ",r," de ",P]}),a.jsx(Ds,{children:c}),u&&a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]}),a.jsx(Ts,{className:"px-6",children:l}),!k&&a.jsx(Ps,{className:"px-6 pb-6",children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("div",{className:"flex items-center gap-2",children:S}),a.jsxs("div",{className:"flex items-center gap-2",children:[!E&&a.jsx(Xt,{variant:"outline",onClick:()=>n(r-1),children:x}),D?a.jsx(Xt,{onClick:m,disabled:C,children:p}):a.jsx(Xt,{onClick:()=>n(r+1),disabled:C,children:h})]})]})})]})]})})},exports.DisabledMenuItem=_r,exports.DocumentSigner=function({file:s,onDocumentSigned:r,onError:n,showEventLog:o=!1}){const{user:i,alias:c}=Pn(),{config:u,isLoading:m}=Up(),{t:p}=j.useTranslation(),[h,x]=t.useState(null),[f,g]=t.useState(!1),[v,b]=t.useState(null),[y,w]=t.useState("sandbox"),[N,_]=t.useState("clicksign"),[C,k]=t.useState(null),[S,T]=t.useState(null),[P,D]=t.useState(!1),[E,A]=t.useState(0),[I,M]=t.useState(!1),[F,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),U=t.useCallback(e=>{o&&R(a=>[...a,`[${(new Date).toLocaleTimeString()}] ${e}`])},[o]),O=t.useCallback(async a=>{if(x(a),b(null),k(null),T(null),U(`Arquivo selecionado: ${a.name}`),c&&i){g(!0);try{const t=u?.provider??"clicksign";_(t),U(`Provedor resolvido: ${t}`);const s=new FileReader,r=await new Promise((e,t)=>{s.onload=()=>{const a=s.result;e(a)},s.onerror=t,s.readAsDataURL(a)});U(`Criando envelope para assinatura via ${t}...`);const o=await qp.createEnvelopeWithSigner({alias:c,contentBase64:r,filename:a.name,signerEmail:i.email||"",signerName:i.name||"",provider:t});U(`Envelope criado: ${o.envelope_id}`),k({envelope_id:o.envelope_id,document_id:o.document_id,signer_email:o.signer_email,key_signer:o.signer_id}),w(o.environment),_(o.provider||t),"d4sign"===t?(U("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(o.document_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):o.signer_id?(U(`Signer ID obtido: ${o.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(o.signer_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):(U(e.t("sign_signer_unavailable")),l.toast.error(p("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),n?.(new Error(p("sign_signer_unavailable"))))}catch(t){const a=t instanceof Error?t:new Error(p("sign_process_error",p("sign_doc_process_error"))),s=a.message||"";s.includes("MONTHLY_LIMIT_REACHED")?(U(e.t("sign_monthly_limit")),l.toast.error(p("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(U(`Erro: ${s}`),l.toast.error(s)),n?.(a)}finally{g(!1)}}},[c,i,U,n,u]);t.useEffect(()=>{s&&c&&i&&!m&&s!==z.current&&(z.current=s,O(s))},[s,c,i,m,O]);const V=t.useCallback(async()=>{if(!C||!c)return;D(!0),A(0),M(!1),U("Buscando documento assinado...");for(let t=1;t<=6;t++){A(t),U(`Tentativa ${t}/6...`);try{const a=await qp.getSignedDocument({alias:c,envelopeId:C.envelope_id,documentId:C.document_id,provider:N});if(a.download_url)return U(e.t("sign_doc_available")),T(a.download_url),void D(!1)}catch(a){U(`Erro na tentativa ${t}: ${a instanceof Error?a.message:p("unknown_error")}`)}t<6&&(U("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}U(e.t("sign_fetch_failed")),D(!1),M(!0)},[C,c,U,N]),B=t.useCallback(async()=>{U("Documento assinado com sucesso!"),l.toast.success(p("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&c&&(r?.({success:!0,provider:N,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:v||"",environment:y}),await V())},[U,r,C,v,c,y,N,V]);if(!c)return a.jsx(ts,{className:"border-amber-200 bg-amber-50",children:a.jsx(os,{className:"flex items-start gap-3 py-6",children:a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-amber-800",children:p("sign_auth_required","Autenticação necessária")}),a.jsx("p",{className:"text-sm text-amber-700 mt-1",children:p("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const q="d4sign"===N?"D4Sign":"Clicksign",$=()=>o&&F.length>0?a.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:F.map((e,t)=>a.jsx("div",{children:e},t))}):null;return C&&!v&&(S||P||I)?a.jsxs("div",{className:"space-y-4",children:[a.jsx(ts,{className:"border-green-200 bg-green-50",children:a.jsxs(os,{className:"flex flex-col items-center gap-4 py-8",children:[a.jsx(d.CheckCircle2,{className:"h-12 w-12 text-green-600"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-lg font-semibold text-green-800",children:p("sign_signed_success","Documento assinado com sucesso!")}),a.jsx("p",{className:"text-sm text-green-700 mt-1",children:h?.name})]}),P?a.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),p("sign_preparing_doc","Preparando documento assinado...")," (",p("sign_attempt","tentativa")," ",E,"/6)"]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_waiting_provider",`Aguardando processamento pelo ${q}...`)})]}):S?a.jsx(Xt,{asChild:!0,variant:"default",className:"gap-2",children:a.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(d.Download,{className:"h-4 w-4"}),p("sign_download_signed","Baixar documento assinado")]})}):I?a.jsxs("div",{className:"text-center space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),a.jsxs(Xt,{variant:"secondary",className:"gap-2",onClick:V,children:[a.jsx(d.RefreshCw,{className:"h-4 w-4"}),p("sign_try_again","Tentar novamente")]})]}):null]})}),a.jsx($,{})]}):v?a.jsxs("div",{className:"space-y-4",children:["d4sign"===N?a.jsx(Yp,{documentKey:v,signerEmail:C?.signer_email||i?.email||"",signerName:i?.name,keySigner:C?.key_signer,environment:y,onSign:B,onError:n}):a.jsx(Gp,{signerId:v,environment:y,onSign:B,onError:n}),a.jsx($,{})]}):s&&(f||m)?a.jsx(ts,{children:a.jsxs(os,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const a=e.target.files?.[0];a&&"application/pdf"===a.type?O(a):l.toast.error(p("sign_select_pdf","Selecione um arquivo PDF"))}}),f?a.jsx(ts,{children:a.jsxs(os,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsx(ts,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:a.jsxs(os,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[a.jsx(d.Upload,{className:"h-8 w-8 text-muted-foreground"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"font-medium",children:p("sign_select_pdf","Selecione um arquivo PDF")}),a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),a.jsx($,{})]})},exports.Drawer=jl,exports.DrawerClose=Nl,exports.DrawerContent=Cl,exports.DrawerDescription=Pl,exports.DrawerFooter=Sl,exports.DrawerHeader=kl,exports.DrawerOverlay=_l,exports.DrawerPortal=wl,exports.DrawerTitle=Tl,exports.DrawerTrigger=yl,exports.DropdownMenu=nr,exports.DropdownMenuCheckboxItem=xr,exports.DropdownMenuContent=pr,exports.DropdownMenuGroup=ir,exports.DropdownMenuItem=hr,exports.DropdownMenuLabel=gr,exports.DropdownMenuPortal=lr,exports.DropdownMenuRadioGroup=cr,exports.DropdownMenuRadioItem=fr,exports.DropdownMenuSeparator=vr,exports.DropdownMenuShortcut=br,exports.DropdownMenuSub=dr,exports.DropdownMenuSubContent=mr,exports.DropdownMenuSubTrigger=ur,exports.DropdownMenuTrigger=or,exports.ElectronicSignatureDialog=function({open:s,onOpenChange:r,onConfirm:n,onGenerateCode:o,mode:i="code",email:l,maxLength:c=8,title:u=e.t("electronic_signature"),description:m,confirmLabel:p=e.t("conclude"),cancelLabel:h=e.t("cancel"),resendLabel:x=e.t("resend_code"),errorMessage:f}){const g="password"===i,v=g?e.t("esign_password_description"):e.t("esign_code_description"),b=m??v,[j,y]=t.useState(""),[w,N]=t.useState(!1),[_,C]=t.useState(!1),[k,S]=t.useState(null),T=t.useCallback(async()=>{if(j.trim()){N(!0),S(null);try{await n(j)?(y(""),r(!1)):S(f??(g?e.t("esign_invalid_password"):e.t("esign_invalid_code")))}catch{S(f??(g?e.t("esign_password_error"):e.t("esign_code_error")))}finally{N(!1)}}},[j,n,r,f,g]),P=t.useCallback(async()=>{if(o){C(!0),S(null);try{await o()}catch{S(e.t("esign_resend_error"))}finally{C(!1)}}},[o]),D=e=>{e||(y(""),S(null)),r(e)},E=g?d.Lock:d.ShieldCheck,A=g?"Senha":e.t("verification_code"),I=g?e.t("enter_password"):e.t("enter_code");return a.jsx(js,{open:s,onOpenChange:D,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:!!j,children:[a.jsx(Ss,{children:a.jsxs(Ds,{className:"flex items-center gap-2",children:[a.jsx(E,{className:"h-5 w-5 text-primary"}),u]})}),a.jsxs("div",{className:"py-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:b}),!g&&l&&a.jsxs("div",{className:"flex items-center gap-2 text-sm bg-muted/50 rounded-md px-3 py-2",children:[a.jsx(d.Mail,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-muted-foreground",children:"Enviado para:"}),a.jsx("span",{className:"font-medium",children:l})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"signature-input",children:A}),a.jsx(Zt,{id:"signature-input",type:g?"password":"text",value:j,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j.trim()&&(e.preventDefault(),T())},maxLength:g?void 0:c,placeholder:I,autoFocus:!0,className:Yt(k&&"border-destructive focus-visible:ring-destructive")}),k&&a.jsx("p",{className:"text-sm text-destructive",children:k})]}),!g&&a.jsxs(Xt,{variant:"ghost",size:"sm",onClick:P,disabled:_,className:"text-primary",children:[a.jsx(d.RefreshCw,{className:Yt("h-4 w-4 mr-1",_&&"animate-spin")}),x]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>D(!1),disabled:w,children:h}),a.jsx(Xt,{onClick:T,disabled:!j.trim()||w,children:w?"Validando...":p})]})]})})},exports.EllipsisText=Wn,exports.EmailService=ip,exports.EmptyState=$n,exports.EntitySelect=Ur,exports.ErrorBoundary=ji,exports.ExportDialog=function({open:e,onOpenChange:s,onExport:r,mode:n="table",options:o,title:i,description:l,cancelLabel:d="Cancelar",exportLabel:c="Exportar"}){const{t:u}=j.useTranslation(),[m,p]=t.useState(""),h=o??("chart"===n?Vc:Oc),x=i??u("chart"===n?"dashboard_export_chart":"dashboard_export_table"),f=l??u("select_file_format"),g=e=>{e||p(""),s(e)};return a.jsx(js,{open:e,onOpenChange:g,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:!!m,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:x})}),a.jsxs("div",{className:"py-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),a.jsx(gd,{value:m,onValueChange:p,className:"gap-3",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(vd,{value:e.value,id:`export-${e.value}`}),a.jsxs(as,{htmlFor:`export-${e.value}`,className:Yt("flex items-center gap-2 cursor-pointer font-normal",m===e.value&&"font-medium"),children:[e.icon,e.label]})]},e.value))})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>g(!1),children:d}),a.jsx(Xt,{onClick:()=>{m&&(r(m),s(!1),p(""))},disabled:!m,children:c})]})]})})},exports.FORBIDDEN_FILE_TYPES=Dh,exports.FilterBar=Wo,exports.Form=As,exports.FormControl=zs,exports.FormDateField=Oh,exports.FormDescription=Us,exports.FormField=({...e})=>a.jsx(Is.Provider,{value:{name:e.name},children:a.jsx(h.Controller,{...e})}),exports.FormItem=Rs,exports.FormLabel=Ls,exports.FormMessage=Os,exports.FormMultiSelectionField=Wh,exports.FormNumericField=qh,exports.FormQuestionsField=Hh,exports.FormSingleSelectionField=$h,exports.FormSkeleton=function({fields:e=4}){return a.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rr,{className:"h-4 w-24"}),a.jsx(Rr,{className:"h-10 w-full"})]},t)),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Rr,{className:"h-10 w-20"}),a.jsx(Rr,{className:"h-10 w-20"})]})]})},exports.FormTextField=Uh,exports.FormTimeField=Vh,exports.FormUrlField=Bh,exports.Grid=function({children:e,cols:t="auto-fit",gap:s="md",className:r}){return a.jsx("div",{className:Yt("grid",Dl[t],El[s],r),children:e})},exports.H1=Bl,exports.H2=ql,exports.H3=$l,exports.H4=Wl,exports.HeaderSkeleton=function(){return a.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Rr,{className:"h-8 w-8 rounded-full"}),a.jsx(Rr,{className:"h-6 w-32"})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Rr,{className:"h-8 w-8"}),a.jsx(Rr,{className:"h-8 w-24"})]})]})},exports.HoverCard=Al,exports.HoverCardContent=Ml,exports.HoverCardTrigger=Il,exports.IconPicker=Mo,exports.IframeDialog=au,exports.ImageEditor=function({value:e,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:i,uploadOptions:c}){const{t:u}=j.useTranslation(),[m,p]=t.useState(e||{alignment:"center",allowDownload:!1}),h=t.useRef(null),{upload:x,uploading:f}=Ep({uploadFunction:o,deleteFunction:i,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Zt,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),o&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),m.imageFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",m.imageFile," (",Math.round((m.imageSize||0)/1024)," KB)"]})]}),m.imageUrl&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:a.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:a.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"caption",children:"Legenda"}),a.jsx(Js,{id:"caption",placeholder:"Legenda",value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"alt",children:u("alt_text")}),a.jsx(Zt,{id:"alt",placeholder:u("alt_text"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Alinhamento"}),a.jsxs(Vs,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Qs,{value:"left",children:"Esquerda"}),a.jsx(Qs,{value:"center",children:"Centro"}),a.jsx(Qs,{value:"right",children:"Direita"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"width",children:"Largura"}),a.jsx(Zt,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"height",children:"Altura"}),a.jsx(Zt,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"allowDownload",checked:m.allowDownload||!1,onCheckedChange:e=>g("allowDownload",!0===e)}),a.jsx(as,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Xt,{variant:"outline",onClick:n,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{m.imageUrl?r(m):l.toast.error("Erro",{description:u("no_image_selected")})},disabled:!m.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:e,className:t="",style:s}){const{t:r}=j.useTranslation();if(!e.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return a.jsx("div",{className:`flex ${n} my-4 ${t}`,style:s,children:a.jsxs("div",{className:"space-y-2 max-w-full",children:[a.jsx("img",{src:e.imageUrl,alt:e.alt||"",style:{width:e.width?`${e.width}px`:"auto",height:e.height?`${e.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),e.caption&&a.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&a.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[a.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Xl,exports.Input=Zt,exports.InputGroup=Fl,exports.InputGroupAddon=Ll,exports.InputGroupButton=Ul,exports.InputGroupInput=Ol,exports.InputGroupTextarea=Vl,exports.LINK_PROPERTIES=Ou,exports.LOGO_CONFIG=Be,exports.Label=as,exports.Large=Yl,exports.Lead=Gl,exports.LeadershipDialog=Tp,exports.LeadershipForm=Sp,exports.LeadershipPage=function({unassociatedUsers:s=[],onAssociateUser:r,onMoveNode:n,onMoveNodes:o,columns:i,nameHeader:l=e.t("leader"),rootDropLabel:c=e.t("leadership_make_root")}={}){const{alias:u}=Pn(),{data:m,isLoading:p,error:h,refetch:x}=hp(),f=vp(),g=fp(),[v,b]=t.useState(()=>u?(e=>{try{const a=localStorage.getItem(`${Pp}-${e}`);if(a)return new Set(JSON.parse(a))}catch{}return new Set})(u):new Set),[j,y]=t.useState([]),[w,N]=t.useState(new Set),[_,C]=t.useState(!0),[k,S]=t.useState(!1),[T,P]=t.useState(),[D,E]=t.useState(null),A=t.useMemo(()=>m?pp(m):[],[m]),I=t.useMemo(()=>A.map(e=>e.id),[A]),M=I.length>0&&j.length===I.length,F=A.filter(e=>e.children.length>0).every(e=>v.has(e.id));t.useEffect(()=>{if(m&&m.length>0&&u){if(!localStorage.getItem(`${Pp}-${u}`)){const e=m.map(e=>e.id),a=new Set(e);b(a),Dp(u,a)}}},[m,u]);const R=t.useCallback(e=>{b(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),u&&Dp(u,t),t})},[u]),L=t.useCallback(()=>{if(F){const e=new Set;b(e),u&&Dp(u,e)}else{const e=new Set(A.filter(e=>e.children.length>0).map(e=>e.id));b(e),u&&Dp(u,e)}},[F,A,u]),z=t.useCallback(e=>{y(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),U=t.useCallback(()=>{y(M?[]:I)},[M,I]),O=t.useCallback(e=>{N(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),V=t.useCallback(e=>A.find(a=>a.id===e),[A]),B=t.useCallback((e,a)=>{if(n)return void n(e,a);const t=s.find(a=>a.id===e);if(t){if(r){const e=a?V(a):null;r(t.id,e?.id_user||null)}else g.mutate({id_user:t.id,id_leader:a&&V(a)?.id_user||null});return}const o=V(e);if(!o)return;const i=a?V(a):null;f.mutate({id:o.id,id_leader:i?.id_user||null})},[n,s,r,V,f,g]),q=t.useCallback((e,a)=>{o?o(e,a):(e.forEach(e=>B(e,a)),y([]))},[o,B]),$=t.useCallback(e=>{P(e),E(null),S(!0)},[]),W=t.useCallback(()=>{P(void 0),E(null),S(!0)},[]),H=t.useCallback(()=>{S(!1),P(void 0),E(null)},[]),G=t.useCallback((e,a)=>{const t=w.has(e)&&w.size>1?Array.from(w):[e];a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t)),a.currentTarget.style.opacity="0.4"},[w]),Y=t.useMemo(()=>[{key:"subordinatesCount",header:"Subordinados",hoverContent:e=>e.subordinateNames&&e.subordinateNames.length>0?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subordinados diretos:"}),[...e.subordinateNames].sort((e,a)=>e.localeCompare(a)).map(e=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(d.User,{className:"h-3 w-3 text-muted-foreground"}),a.jsx("span",{children:e})]},e))]}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"Sem subordinados diretos"})},{key:"email",header:"Email",className:"text-left",width:180,render:e=>a.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground text-sm",children:[a.jsx(d.Mail,{className:"h-3.5 w-3.5"}),e.email||"—"]})}],[]),Q=i??Y;if(p)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(h)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),a.jsx(Xt,{onClick:()=>x(),children:e.t("try_again")})]})});const K=A.filter(a=>a.name!==e.t("inactive_user")).length;return a.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs(Xt,{size:"sm",onClick:W,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),a.jsx(Xt,{size:"sm",variant:"outline",onClick:L,children:F?a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 mr-1"}),"Colapsar"]}):a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronRight,{className:"h-4 w-4 mr-1"}),"Expandir"]})}),a.jsx("div",{className:"flex items-center gap-2 ml-4",children:a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("span",{className:"text-sm font-medium",children:[K," usuário",1!==K?"s":""," associado",1!==K?"s":""]})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote"})]}),a.jsx(Um,{data:m||[],columns:Q,nameKey:"name",nameHeader:l,expandedIds:v,onToggleExpand:R,iconComponent:a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground shrink-0"}),rowActionsVariant:"inline",enableRowDrag:!0,enableSelection:!0,selectedIds:j,onSelectItem:z,onSelectAll:U,isAllSelected:M,onMoveNode:B,onMoveNodes:q,rootDropLabel:c,emptyMessage:e.t("leadership_no_hierarchy"),renderActions:e=>a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(e),children:a.jsx(d.Pencil,{className:"h-4 w-4"})})}),s.length>0&&a.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>C(e=>!e),className:"w-full px-4 py-2.5 bg-muted/50 border-b flex items-center gap-2 hover:bg-muted/70 transition-colors cursor-pointer",children:[_?a.jsx(d.ChevronDown,{className:"h-4 w-4 text-muted-foreground shrink-0"}):a.jsx(d.ChevronRight,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx(d.UserPlus,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:"Usuários não associados"}),a.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(",s.length,")"]}),w.size>0&&a.jsxs("span",{className:"text-xs text-primary ml-1",children:["(",w.size," selecionado",w.size>1?"s":"",")"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Arraste para a hierarquia acima"})]}),_&&a.jsx("div",{className:"divide-y",children:s.map(e=>a.jsxs("div",{draggable:!0,onDragStart:a=>G(e.id,a),onDragEnd:e=>{e.currentTarget.style.opacity="1"},className:Yt("flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors",w.has(e.id)&&"bg-primary/5"),children:[a.jsx(Xs,{checked:w.has(e.id),onCheckedChange:()=>O(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),a.jsx("span",{className:"text-muted-foreground shrink-0 select-none",children:"⠿"}),a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"text-sm truncate",children:e.name}),a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})]}),a.jsxs("div",{className:"px-3 py-2 bg-muted/20 border rounded-lg text-xs text-muted-foreground flex justify-between",children:[a.jsxs("span",{children:["Usuários associados: ",K]}),s.length>0&&a.jsxs("span",{children:["Usuários não associados: ",s.length]})]}),a.jsx(Tp,{open:k,onOpenChange:H,leader:T,prefilledLeaderId:D,title:T?e.t("edit_name"):D?e.t("leadership_add_subordinate"):e.t("leadership_add_root")},`leadership-dialog-${u}`)]})},exports.List=Zl,exports.ListPanel=rm,exports.LoadingState=sr,exports.LocaleProvider=mi,exports.LoginPage=()=>{const{t:e}=j.useTranslation();return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),a.jsxs(os,{className:"text-center space-y-4",children:[a.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),a.jsx(Xt,{onClick:async()=>{ze()?await _n.loginDev():_n.loginProd()},className:"w-full",size:"lg",children:ze()?e("dev_login"):e("login_with_qualiex")})]})]})})},exports.MESSAGES=qe,exports.MODULES_DATA=zi,exports.MONTHS_MAP=zu,exports.ManageAccessModal=dp,exports.MatrixRiskPanel=hm,exports.Menubar=uc,exports.MenubarCheckboxItem=gc,exports.MenubarContent=xc,exports.MenubarGroup=ic,exports.MenubarItem=fc,exports.MenubarLabel=bc,exports.MenubarMenu=oc,exports.MenubarPortal=lc,exports.MenubarRadioGroup=cc,exports.MenubarRadioItem=vc,exports.MenubarSeparator=jc,exports.MenubarShortcut=yc,exports.MenubarSub=dc,exports.MenubarSubContent=hc,exports.MenubarSubTrigger=pc,exports.MenubarTrigger=mc,exports.ModalStateProvider=function({children:e}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=t.useCallback(e=>{o(e)},[]),c=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:i,unregisterModal:l,setHasOpenModal:d}),[s,c,i,l,d]);return a.jsx(sp.Provider,{value:u,children:e})},exports.ModuleAccessGuard=Ki,exports.ModuleGrid=Vi,exports.ModuleOfferContent=function({title:e,description:t,image:s,icon:r,ctaLabel:n,onCtaClick:o,children:i}){const{t:l}=j.useTranslation(),c=n??l("want_to_know_more");return a.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(s||r)&&a.jsx("div",{className:"flex items-center justify-center",children:s?a.jsx("img",{src:s,alt:e,className:"max-h-48 w-auto object-contain rounded-lg"}):r?a.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:a.jsx(r,{className:"h-12 w-12 text-primary"})}):null}),a.jsxs("div",{className:"space-y-3 max-w-lg",children:[a.jsx("h3",{className:"text-xl font-semibold text-foreground",children:e}),a.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t})]}),i?a.jsx("div",{className:"w-full",children:i}):o?a.jsxs(Xt,{onClick:o,size:"lg",className:"gap-2",children:[a.jsx(d.Sparkles,{className:"h-4 w-4"}),c]}):null]})},exports.ModuleProvider=xi,exports.ModulesContent=Bi,exports.ModulesDialog=Gi,exports.ModulesFooterCards=Li,exports.MultiSelect=Ur,exports.MultiselectPermissions=function({items:s,categories:r,value:n,onChange:o,readonly:i=!1,isLoading:l=!1,title:c=e.t("permissions"),addButtonLabel:u=e.t("allow"),chipsTitle:m=e.t("allowed_items"),chipsPlaceholder:p=e.t("no_item_selected"),searchPlaceholder:h=e.t("search_placeholder"),selectPlaceholder:x=e.t("select_items_to_add"),itemInfoTemplate:f=e=>`${e} ${1===e?"item":"itens"}`,disclaimer:g,disclaimerLink:v,onDisclaimerClick:b,className:y}){const[w,N]=t.useState(r[0]?.id??""),[_,C]=t.useState(""),[k,S]=t.useState([]),[T,P]=t.useState(!1),D=t.useMemo(()=>ou(n[w]),[n,w]),E=t.useMemo(()=>function(e){const{t:a}=j.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.inheritedIds?.forEach(e=>t.add(e));return t}(n[w]),[n,w]),A=t.useMemo(()=>s.filter(e=>D.has(e.id)),[s,D]),I=t.useMemo(()=>{const e=nu(_);return s.filter(a=>!D.has(a.id)&&!(e&&!nu(a.name).includes(e)))},[s,D,_]),M=t.useMemo(()=>{const e={};for(const a of r)e[a.id]=ou(n[a.id]).size;return e},[r,n]),F=t.useCallback(e=>{N(e),S([]),C("")},[]),R=t.useCallback(e=>{S(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=t.useCallback(()=>{if(0===k.length)return;const e=[...n[w]??[]];for(const a of k){const t=s.find(e=>e.id===a),r=t?.group??"default",n=e.find(e=>e.context===r);n?n.allowedIds.includes(a)||(n.allowedIds=[...n.allowedIds,a]):e.push({context:r,allowedIds:[a],inheritedIds:[]})}o({...n,[w]:e}),S([]),C(""),P(!1)},[k,n,w,s,o]),z=t.useCallback(e=>{if(E.has(e))return;const a=(n[w]??[]).map(a=>({...a,allowedIds:a.allowedIds.filter(a=>a!==e)}));o({...n,[w]:a})},[n,w,E,o]);return l?a.jsxs("div",{className:Yt("rounded-md border bg-muted/30 p-4 animate-pulse space-y-3",y),children:[a.jsx("div",{className:"h-4 w-32 bg-muted rounded"}),a.jsx("div",{className:"h-9 w-full bg-muted rounded"}),a.jsx("div",{className:"h-20 w-full bg-muted rounded"})]}):a.jsx("div",{className:Yt("rounded-md border bg-muted/30",y),children:a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c}),a.jsxs(Vs,{value:w,onValueChange:F,children:[a.jsx($s,{className:"h-9 text-sm",children:a.jsx(qs,{})}),a.jsx(Gs,{children:r.map(e=>a.jsx(Qs,{value:e.id,children:a.jsxs("span",{className:"flex items-center gap-2",children:[e.icon,e.name,M[e.id]>0&&a.jsx(er,{variant:"secondary",className:"ml-1 text-xs px-1.5 py-0",children:M[e.id]})]})},e.id))})]})]}),!i&&a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Cr,{open:T,onOpenChange:P,children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",role:"combobox",className:"flex-1 justify-between h-9 text-sm font-normal text-muted-foreground",children:[k.length>0?`${k.length} selecionado${k.length>1?"s":""}`:x,a.jsx(d.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(Sr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:[a.jsx("div",{className:"p-2 border-b",children:a.jsxs("div",{className:"relative",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-8 text-sm",placeholder:h,value:_,onChange:e=>C(e.target.value)})]})}),a.jsx(Do,{className:"max-h-[220px]",children:0===I.length?a.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nenhum item encontrado"}):a.jsx("div",{className:"p-1",children:I.map(e=>{const t=k.includes(e.id);return a.jsxs("div",{className:Yt("flex items-center gap-3 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent",t&&"bg-accent/50"),onClick:()=>R(e.id),children:[a.jsx("div",{className:Yt("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",t&&"bg-primary text-primary-foreground"),children:t&&a.jsx(d.Check,{className:"h-3 w-3"})}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"truncate",children:e.name}),null!=e.count&&a.jsx("span",{className:"text-xs text-muted-foreground",children:f(e.count)})]})]},e.id)})})})]})]}),a.jsxs(Xt,{size:"sm",className:"h-9 gap-1",disabled:0===k.length,onClick:L,children:[a.jsx(d.Plus,{className:"h-4 w-4"}),u]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:m}),a.jsx("div",{className:Yt("rounded-md border bg-background p-3 min-h-[60px]",i&&"bg-muted/50"),children:0===A.length?a.jsx("span",{className:"text-sm text-muted-foreground",children:p}):a.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(e=>{const t=E.has(e.id);return a.jsxs(er,{variant:t?"secondary":"default",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.name,!i&&!t&&a.jsx("button",{type:"button",className:"ml-0.5 rounded-full hover:bg-primary-foreground/20 p-0.5",onClick:()=>z(e.id),children:a.jsx(d.X,{className:"h-3 w-3"})})]},e.id)})})}),i&&g&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.jsx("span",{dangerouslySetInnerHTML:{__html:g}})," ",v&&b&&a.jsx("button",{type:"button",className:"text-primary underline hover:no-underline",onClick:b,children:v})]})]})]})})},exports.Muted=Kl,exports.NavigationMenu=ed,exports.NavigationMenuContent=nd,exports.NavigationMenuIndicator=ld,exports.NavigationMenuItem=td,exports.NavigationMenuLink=od,exports.NavigationMenuList=ad,exports.NavigationMenuTrigger=rd,exports.NavigationMenuViewport=id,exports.NavigationProvider=Hm,exports.NumericPanel=tm,exports.OnboardingDialog=Lc,exports.OnlineEditorDialog=function({open:e,onOpenChange:s,identifier:r,fileName:n,mode:o="edit",type:i="document",onClose:l,className:c}){const[u,m]=t.useState(!0),p=function(e,a="edit",t="document"){return`https://docs.google.com/${t}/d/${e}/${a}?usp=drivesdk?embedded=true&rm=demo`}(r,o,i);t.useEffect(()=>{if(e){m(!0);const e=setTimeout(()=>m(!1),300);return()=>clearTimeout(e)}},[e]);const h=t.useCallback(()=>{l?.(),s(!1)},[l,s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&h()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,h]),a.jsx(js,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Yt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",c),children:[a.jsxs("div",{className:"flex items-center justify-between mb-6 min-h-[30px]",children:[u?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-80px)]",children:n}),a.jsx("div",{className:"flex items-center ml-4 z-20",children:a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})})]}),a.jsx("div",{className:"flex flex-col items-center justify-center min-h-[160px] w-full min-w-[77vw] min-h-[80vh]",children:u?a.jsx(tr,{className:"h-14 w-14"}):a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(tr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{src:p,className:"border-none w-full h-full z-[1] relative",title:n})]})})]})})},exports.P=Hl,exports.PRIORITIES=oh,exports.PROD_PROJECT_ID=Pe,exports.PROGRESS_ALLOWED_STATUSES=lh,exports.PageBreadcrumb=function({items:e,maxItems:t=3,className:s}){const r=e.length>t?[e[0],...e.slice(-(t-1))]:e,n=e.length>t;return a.jsx(ll,{className:s,children:a.jsx(dl,{children:r.map((e,t)=>{const s=0===t,r=n&&1===t;return a.jsxs(cl,{children:[!s&&a.jsx(pl,{}),r&&a.jsxs(a.Fragment,{children:[a.jsx(hl,{}),a.jsx(pl,{})]}),e.isCurrentPage?a.jsx(ml,{children:e.label}):a.jsx(ul,{asChild:!0,children:a.jsx(N.Link,{to:e.href||"/",children:e.label})})]},e.label)})})})},exports.PageMetadataProvider=ti,exports.Pagination=dd,exports.PaginationContent=cd,exports.PaginationEllipsis=xd,exports.PaginationItem=ud,exports.PaginationLink=md,exports.PaginationNext=hd,exports.PaginationPrevious=pd,exports.PanelError=Xu,exports.PanelHeader=Ku,exports.PanelLoader=Ju,exports.PanelNoData=Zu,exports.PanelUnavailable=em,exports.ParetoPanel=um,exports.PerformancePanel=pm,exports.PiePanel=cm,exports.PlaceCard=cp,exports.PlacesList=function({places:e,isLoading:t,manageAccessConfig:s}){return t?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):e&&0!==e.length?a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>a.jsx(cp,{place:e,manageAccessConfig:s},e.id))]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[a.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Cr,exports.PopoverContent=Sr,exports.PopoverTrigger=kr,exports.Progress=fd,exports.ProtectedRoute=({children:s})=>{const{isAuthenticated:r,isLoading:n}=Pn();if(t.useEffect(()=>{if(n)return;if(r)return;if(an.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 s=ze(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{s?await _n.loginDev():_n.loginProd()})()},[r,n]),n&&!r)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Carregando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!r){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Processando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Iniciando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:ze()?e.t("auto_login"):e.t("redirecting_auth")})]})]})})}return a.jsx(a.Fragment,{children:s})},exports.QUALIEX_CONFIG=Ve,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=vn,exports.QualiexErrorInterceptor=un,exports.QualiexUserField=Lo,exports.RadioGroup=gd,exports.RadioGroupItem=vd,exports.ReadOnlyTextField=zh,exports.ReportRequestList=function({requests:e,isLoading:s=!1,onGetReportUrl:r,formatDate:n=cu,labels:o,className:i}){const{t:l}=j.useTranslation(),c={...lu,...o},[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(""),[g,v]=t.useState(""),[b,y]=t.useState(null),w=t.useMemo(()=>{if(!u)return e;const a=du(u);return e.filter(e=>du(e.reportName).includes(a))},[e,u]),N=t.useCallback(async e=>{if(!b){y(e.id);try{const a=await r(e.id);a&&(f(a),v(e.reportName),h(!0))}finally{y(null)}}},[r,b]);return s?a.jsx("div",{className:Yt("space-y-3",i),children:Array.from({length:5}).map((e,t)=>a.jsx(Rr,{className:"h-12 w-full"},t))}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:Yt("space-y-3",i),children:[a.jsxs("div",{className:"relative max-w-sm",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-9 text-sm",placeholder:c.searchPlaceholder,value:u,onChange:e=>m(e.target.value)})]}),a.jsx(Do,{className:"rounded-md border",children:a.jsxs(In,{children:[a.jsx(Mn,{children:a.jsxs(Ln,{children:[a.jsx(zn,{className:"min-w-[140px]",children:c.report}),a.jsx(zn,{className:"min-w-[150px]",children:c.status}),a.jsx(zn,{className:"min-w-[160px]",children:c.requestDate}),a.jsx(zn,{className:"min-w-[160px]",children:c.lastUpdate}),a.jsx(zn,{className:"min-w-[160px]",children:c.expirationDate}),a.jsx(zn,{className:"min-w-[140px]"})]})}),a.jsx(Fn,{children:0===w.length?a.jsx(Ln,{children:a.jsx(Un,{colSpan:6,className:"text-center text-muted-foreground py-8",children:c.noResults})}):w.map(e=>{const t=function(e){const{t:a}=j.useTranslation();return new Date>new Date(e.expirationDate)&&e.statusId===exports.ReportRequestStatus.Completed?exports.ReportRequestStatus.Expired:e.statusId}(e),s=function(e,t){const{t:s}=j.useTranslation();switch(e){case exports.ReportRequestStatus.WaitingProcessing:return{label:t.statusWaiting,icon:a.jsx(d.Hourglass,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50"};case exports.ReportRequestStatus.Processing:return{label:t.statusProcessing,icon:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 animate-spin"}),variant:"outline",className:"text-blue-600 border-blue-300 bg-blue-50"};case exports.ReportRequestStatus.Completed:return{label:t.statusCompleted,icon:a.jsx(d.CheckCircle2,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50"};case exports.ReportRequestStatus.Error:return{label:t.statusError,icon:a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),variant:"danger"};case exports.ReportRequestStatus.Expired:return{label:t.statusExpired,icon:a.jsx(d.TriangleAlert,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-orange-600 border-orange-300 bg-orange-50"};default:return{label:"—",icon:null,variant:"secondary"}}}(t,c),r=t===exports.ReportRequestStatus.Completed,o=t===exports.ReportRequestStatus.Expired;return a.jsxs(Ln,{children:[a.jsx(Un,{className:"font-medium",children:e.reportName}),a.jsx(Un,{children:a.jsxs(er,{variant:s.variant,className:Yt("gap-1",s.className),children:[s.icon,s.label]})}),a.jsx(Un,{className:"text-sm",children:n(new Date(e.requestDate))}),a.jsx(Un,{className:"text-sm",children:n(new Date(e.lastUpdate))}),a.jsx(Un,{className:Yt("text-sm",o&&"text-destructive"),children:n(new Date(e.expirationDate))}),a.jsx(Un,{children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"gap-1.5",disabled:!r||b===e.id,onClick:()=>N(e),children:[b===e.id?a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}):a.jsx(d.Eye,{className:"h-4 w-4"}),c.viewReport]})})]},e.id)})})]})})]}),a.jsx(au,{open:p,onOpenChange:h,url:x,title:g})]})},exports.ResizableHandle=({withHandle:e,className:t,...s})=>a.jsx(Ce.PanelResizeHandle,{className:Yt("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:e&&a.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:a.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=bd,exports.ResizablePanelGroup=({className:e,...t})=>a.jsx(Ce.PanelGroup,{className:Yt("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),exports.RichTextEditor=({value:s,onChange:r,disabled:n,placeholder:o=e.t("write_content_here"),minHeight:i="300px",showModeToggle:l=!0,showVariableHint:c=!0,className:u})=>{const{t:m}=j.useTranslation(),[p,h]=t.useState("visual"),x=$.useEditor({extensions:[W.configure({heading:{levels:[1,2,3]}}),H,G.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Y.TextStyle,Q.Color,K.configure({multicolor:!0})],content:s||"",editable:!n,onUpdate:({editor:e})=>{r(e.getHTML())}});te.useEffect(()=>{x&&s!==x.getHTML()&&x.commands.setContent(s||"")},[s,x]);const f=t.useCallback(()=>{if(!x)return;const e=x.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?x.chain().focus().extendMarkRange("link").setLink({href:a}).run():x.chain().focus().extendMarkRange("link").unsetLink().run())},[x]);return x?a.jsxs("div",{className:Yt("space-y-2",u),children:[l&&a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(Xt,{type:"button",size:"sm",variant:"visual"===p?"default":"outline",onClick:()=>h("visual"),disabled:n,children:[a.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),a.jsxs(Xt,{type:"button",size:"sm",variant:"code"===p?"default":"outline",onClick:()=>h("code"),disabled:n,children:[a.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),a.jsxs(Xt,{type:"button",size:"sm",variant:"preview"===p?"default":"outline",onClick:()=>h("preview"),disabled:n,children:[a.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",a.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===p&&a.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||x?.commands.focus()},children:[a.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[a.jsx(Ac,{onClick:()=>x.chain().focus().toggleHeading({level:1}).run(),isActive:x.isActive("heading",{level:1}),disabled:n,title:e.t("heading_1"),children:a.jsx(d.Heading1,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),isActive:x.isActive("heading",{level:2}),disabled:n,title:e.t("heading_2"),children:a.jsx(d.Heading2,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleHeading({level:3}).run(),isActive:x.isActive("heading",{level:3}),disabled:n,title:e.t("heading_3"),children:a.jsx(d.Heading3,{className:"h-4 w-4"})}),a.jsx(Ic,{}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleBold().run(),isActive:x.isActive("bold"),disabled:n,title:e.t("bold"),children:a.jsx(d.Bold,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleItalic().run(),isActive:x.isActive("italic"),disabled:n,title:e.t("italic"),children:a.jsx(d.Italic,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleUnderline().run(),isActive:x.isActive("underline"),disabled:n,title:"Sublinhado",children:a.jsx(d.Underline,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleStrike().run(),isActive:x.isActive("strike"),disabled:n,title:"Riscado",children:a.jsx(d.Strikethrough,{className:"h-4 w-4"})}),a.jsx(Ic,{}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleBulletList().run(),isActive:x.isActive("bulletList"),disabled:n,title:"Lista",children:a.jsx(d.List,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleOrderedList().run(),isActive:x.isActive("orderedList"),disabled:n,title:m("ordered_list"),children:a.jsx(d.ListOrdered,{className:"h-4 w-4"})}),a.jsx(Ic,{}),a.jsx(Ac,{onClick:()=>x.chain().focus().toggleHighlight().run(),isActive:x.isActive("highlight"),disabled:n,title:"Destacar",children:a.jsx(d.Highlighter,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:f,isActive:x.isActive("link"),disabled:n,title:"Link",children:a.jsx(d.Link,{className:"h-4 w-4"})}),a.jsx(Ic,{}),a.jsx(Ac,{onClick:()=>x.chain().focus().unsetAllMarks().clearNodes().run(),disabled:n,title:m("clear_formatting"),children:a.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),a.jsx(Ic,{}),a.jsx(Ac,{onClick:()=>x.chain().focus().undo().run(),disabled:n||!x.can().undo(),title:"Desfazer",children:a.jsx(d.Undo,{className:"h-4 w-4"})}),a.jsx(Ac,{onClick:()=>x.chain().focus().redo().run(),disabled:n||!x.can().redo(),title:"Refazer",children:a.jsx(d.Redo,{className:"h-4 w-4"})})]}),a.jsx($.EditorContent,{editor:x,className:Yt("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:i}})]}),"code"===p&&a.jsx("textarea",{value:s||"",onChange:e=>r(e.target.value),disabled:n,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===p&&a.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:a.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:a.jsx("div",{dangerouslySetInnerHTML:{__html:s||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Re,exports.STATUS_COLORS=eh,exports.STATUS_LABELS=rh,exports.STATUS_MAP=th,exports.STATUS_TEXT_COLORS=ah,exports.SUPPORTED_LOCALES=Pt,exports.ScrollArea=Do,exports.ScrollBar=Eo,exports.Select=Vs,exports.SelectApproverDialog=dx,exports.SelectContent=Gs,exports.SelectGroup=Bs,exports.SelectItem=Qs,exports.SelectLabel=Ys,exports.SelectScrollDownButton=Hs,exports.SelectScrollUpButton=Ws,exports.SelectSearch=Ur,exports.SelectSeparator=Ks,exports.SelectTrigger=$s,exports.SelectValue=qs,exports.Separator=ls,exports.Sheet=jd,exports.SheetBody=Td,exports.SheetClose=wd,exports.SheetContent=kd,exports.SheetDescription=Ed,exports.SheetFooter=Pd,exports.SheetHeader=Sd,exports.SheetOverlay=_d,exports.SheetPortal=Nd,exports.SheetTitle=Dd,exports.SheetTrigger=yd,exports.Sidebar=Rd,exports.SidebarActionTrigger=Zm,exports.SidebarContent=$d,exports.SidebarFooter=Bd,exports.SidebarGroup=Wd,exports.SidebarGroupAction=Gd,exports.SidebarGroupContent=Yd,exports.SidebarGroupLabel=Hd,exports.SidebarHeader=function({open:e,appName:s}){const[r,n]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx(Vd,{className:"p-0 gap-0",children:e?a.jsxs("div",{className:"flex items-center gap-2 pl-2 min-h-10",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:We.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),s&&a.jsx("button",{className:"flex-1 min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground hover:text-primary-foreground/80 transition-colors leading-tight py-1",onClick:()=>n(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(s)})})]}):a.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:a.jsx("button",{className:"flex items-center justify-center h-10 w-8 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:We.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})})})}),a.jsx(Gi,{open:r,onOpenChange:n})]})},exports.SidebarInput=Od,exports.SidebarInset=Ud,exports.SidebarLogo=Km,exports.SidebarMenu=Qd,exports.SidebarMenuAction=Zd,exports.SidebarMenuBadge=ec,exports.SidebarMenuButton=Jd,exports.SidebarMenuItem=Kd,exports.SidebarMenuSkeleton=ac,exports.SidebarMenuSub=tc,exports.SidebarMenuSubButton=rc,exports.SidebarMenuSubItem=sc,exports.SidebarProvider=Fd,exports.SidebarRail=zd,exports.SidebarSeparator=qd,exports.SidebarSkeleton=function(){return a.jsx("div",{className:"w-64 border-r bg-muted/10",children:a.jsxs("div",{className:"p-4",children:[a.jsx(Rr,{className:"h-8 w-32 mb-6"}),a.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>a.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[a.jsx(Rr,{className:"h-4 w-4"}),a.jsx(Rr,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=Ld,exports.SignConfigForm=function({onSaved:e}){const{config:s,isLoading:r,saveConfig:n}=Up(),{t:o}=j.useTranslation(),[i,c]=t.useState(""),[u,m]=t.useState("sandbox"),[p,h]=t.useState(!1);return t.useEffect(()=>{!r&&s&&(c(s.api_key),m(s.environment))},[s,r]),r?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a.jsxs("div",{className:"space-y-4",children:[s?a.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[a.jsx(d.CheckCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_configured",o("sign_configured_unit"))})]}):a.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_not_configured",o("sign_not_configured_unit"))})]}),a.jsxs(ts,{children:[a.jsx(ss,{children:a.jsx(rs,{className:"text-base",children:o("sign_digital_config")})}),a.jsx(os,{children:a.jsxs("form",{onSubmit:async a=>{if(a.preventDefault(),i.trim()){h(!0);try{await n(i.trim(),u),l.toast.success(o("sign_config_saved",o("sign_config_saved_success"))),e?.()}catch(t){l.toast.error(o("sign_config_save_error",o("sign_config_save_err")))}finally{h(!1)}}else l.toast.error(o("sign_api_key_required",o("sign_api_key_info")))},className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"sign-api-key",children:"API Key"}),a.jsx(Zt,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder",o("sign_api_key_input")),value:i,onChange:e=>c(e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:o("sign_environment","Ambiente")}),a.jsxs(Vs,{value:u,onValueChange:e=>m(e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Qs,{value:"sandbox",children:"Sandbox (Testes)"}),a.jsx(Qs,{value:"production",children:"Produção"})]})]})]}),a.jsxs(Xt,{type:"submit",disabled:p,children:[p&&a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config",o("sign_update_config_btn")):o("sign_save_config",o("sign_save_config_btn"))]})]})})]})]})},exports.SignWidget=Gp,exports.SingleFileUpload=function({storedFile:e,customFileName:s,allowedExtensions:r,customExtensionErrorMessage:n,minSizeInBytes:o=1,maxSizeInBytes:i=314572800,showDownloadButton:l=!0,showViewButton:c=!0,showReplaceButton:u=!0,showCloseButton:m=!0,required:p=!1,touched:h=!1,disabled:x=!1,error:f,onFileSelect:g,onFileRemove:v,onFileReplace:b,onDownload:y,onView:w,className:N}){const{t:_}=j.useTranslation(),C=t.useRef(null),[k,S]=t.useState(null),[T,P]=t.useState(null),[D,E]=t.useState(!1),A=k||e,I=k?.name||e?.name||"",M=k?.size||e?.size;I&&Ah(I);const F=s||I,R=l&&!k&&!!e,L=c&&!k&&!!e,z=!!T||!!f||p&&h&&!A,U=!!A,O=t.useCallback(e=>{if(Dh.includes(e.type))return{type:"forbidden-type"};if(e.size<=o)return{type:"min-size"};if(e.size>=i)return{type:"max-size"};if(r?.length){const a=Ah(e.name);if(!r.includes(a))return{type:"extension",message:n}}return null},[o,i,r,n]),V=t.useCallback(e=>{const a=e.target.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),S(null),void(C.current&&(C.current.value=""));P(null),S(a),g?.(a),C.current&&(C.current.value="")},[O,g]),B=t.useCallback(e=>{if(e.preventDefault(),e.stopPropagation(),x)return;const a=e.dataTransfer.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),void S(null);P(null),S(a),g?.(a)},[x,O,g]),q=t.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),$=t.useCallback(()=>{b?.(),C.current?.click()},[b]),W=t.useCallback(()=>{S(null),P(null),v?.(),C.current&&(C.current.value="")},[v]),H=t.useCallback(async()=>{if(!D&&e&&y){E(!0);try{await y(e)}finally{E(!1)}}},[D,e,y]),G=t.useCallback(()=>{e&&w&&w(e)},[e,w]),Y=t.useCallback(()=>{x||C.current?.click()},[x]),Q=(()=>{if(f)return f;if(!T)return p&&h&&!A?_("required_field"):null;switch(T.type){case"extension":return T.message||_("sign_file_not_allowed");case"forbidden-type":return _("sign_file_type_not_allowed");case"min-size":return`Tamanho mínimo: ${Eh(o)}`;case"max-size":return`Tamanho máximo: ${Eh(i)}`;default:return _("file_error")}})();return a.jsxs("div",{className:Yt("space-y-1",N),children:[a.jsx("div",{className:Yt("rounded-md border border-dashed transition-colors",U&&"border-solid border-border",!U&&"border-muted-foreground/30 hover:border-primary/50 cursor-pointer",z&&"border-destructive border-solid",x&&"opacity-50 pointer-events-none"),children:U?a.jsxs("div",{className:"flex items-center justify-between px-3 min-h-[36px]",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx(d.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.jsx("p",{className:"text-xs truncate",children:F})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[null!=M&&a.jsx("span",{className:"text-xs text-muted-foreground",children:Eh(M)}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[R&&y&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:D,onClick:H,children:a.jsx(d.Download,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Download"})]}),L&&w&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Visualizar"})]}),u&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:$,children:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Substituir"})]}),m&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 bg-muted rounded",onClick:W,children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground"})})}),a.jsx(Nr,{children:_("remove")})]})]})]})]}):a.jsxs("div",{className:"flex items-center justify-center gap-2 min-h-[36px] px-3",tabIndex:0,onClick:Y,onKeyDown:e=>"Enter"===e.key&&Y(),onDrop:B,onDragOver:q,children:[a.jsx(d.CloudUpload,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:["Arraste ou ",a.jsx("span",{className:"text-primary",children:"selecione um arquivo"})]})]})}),Q&&a.jsx("p",{className:"text-xs text-destructive",children:Q}),a.jsx("input",{ref:C,type:"file",className:"hidden",accept:r?.map(e=>`.${e}`).join(","),onChange:V,disabled:x})]})},exports.Skeleton=Rr,exports.Slider=nc,exports.Small=Ql,exports.SonnerToaster=rr,exports.Spinner=tr,exports.SplitButton=zc,exports.Stack=$o,exports.StatusBadge=mu,exports.StepSelector=qc,exports.Stepper=qc,exports.StimulsoftViewer=function({reportApiUrl:e,parameters:s={},minHeight:r="80vh",...n}){const o=t.useMemo(()=>{const a=`${e}/api/reports/v1/Viewer/InitViewer`,t=new URLSearchParams(s).toString();return t?`${a}?${t}`:a},[e,s]);return a.jsx(au,{...n,url:o,minHeight:r})},exports.Switch=Fo,exports.TIMEZONES=Et,exports.TabPageContent=function({children:e,className:t}){return a.jsx("div",{className:Yt("space-y-6",t),children:e})},exports.TabPageHeader=function({title:e,description:t,actions:s,className:r}){return a.jsxs("div",{className:Yt("space-y-4",r),children:[a.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),a.jsx(ls,{})]})},exports.TabPageLayout=function({children:e,className:t}){return a.jsx("div",{className:Yt("flex flex-col h-full",t),children:a.jsx(Do,{className:"flex-1",children:a.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=In,exports.TableBody=Fn,exports.TableCaption=On,exports.TableCell=Un,exports.TableFooter=Rn,exports.TableHead=zn,exports.TableHeader=Mn,exports.TableResizeHandle=Hn,exports.TableRow=Ln,exports.TableRowActions=co,exports.TableSkeleton=Vn,exports.Tabs=yi,exports.TabsContent=_i,exports.TabsList=wi,exports.TabsTrigger=Ni,exports.TeamSelector=function({users:e,value:s,onChange:r,disabled:n=!1,placeholder:o="Buscar membro da equipe...",confirmRemoval:i=!0,confirmTitle:l,confirmMessage:c="Tem certeza que deseja remover este membro da equipe?",emptyMessage:u,className:m}){const{t:p}=j.useTranslation(),h=l??p("leadership_remove_team"),x=u??p("leadership_no_members"),[f,g]=t.useState(""),[v,b]=t.useState(!1),[y,w]=t.useState(null),N=t.useMemo(()=>new Set(s),[s]),_=t.useMemo(()=>e.filter(e=>N.has(e.id)),[e,N]),C=t.useMemo(()=>e.filter(e=>!N.has(e.id)).map(e=>({value:e.id,label:e.name})),[e,N]),k=t.useCallback(e=>{e&&!N.has(e)&&(r([...s,e]),g(""))},[s,r,N]),S=t.useCallback(e=>{i?(w(e),b(!0)):r(s.filter(a=>a!==e))},[s,r,i]),T=t.useCallback(()=>{y&&r(s.filter(e=>e!==y)),b(!1),w(null)},[y,s,r]);return a.jsxs("div",{className:Yt("space-y-3",m),children:[a.jsx("div",{className:"flex items-start gap-3",children:a.jsx("div",{className:"flex-1",children:a.jsx(Ur,{options:C,value:f,onValueChange:e=>{const a="string"==typeof e?e:e?.[0]??"";g(a),a&&k(a)},placeholder:o,searchPlaceholder:"Buscar...",disabled:n})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-muted-foreground",children:"Selecionados"}),a.jsx("span",{className:"text-xs bg-muted text-muted-foreground rounded-full px-2 py-0.5 font-medium",children:_.length})]}),_.length>0?a.jsx("div",{className:"space-y-2",children:_.map(e=>a.jsxs("div",{className:"flex items-center border border-border rounded-lg p-2 gap-3",children:[a.jsxs(nl,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(ol,{src:e.avatar,alt:e.name}),a.jsx(il,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-sm font-medium truncate",title:e.name,dangerouslySetInnerHTML:{__html:e.title||e.name}})}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.roleName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.Shield,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.roleName})]}),e.placeName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.MapPin,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.placeName})]}),a.jsx("button",{type:"button",className:Yt("text-muted-foreground hover:text-destructive transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>!n&&S(e.id),title:p("remove"),children:a.jsx(d.X,{className:"h-4 w-4"})})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[a.jsx(d.User,{className:"h-12 w-12 mb-2 opacity-30"}),a.jsx("p",{className:"text-sm",children:x})]}),a.jsx(js,{open:v,onOpenChange:b,children:a.jsxs(ks,{className:"sm:max-w-[400px]",children:[a.jsx(Ss,{children:a.jsx(Ds,{children:h})}),a.jsx("p",{className:"text-sm text-muted-foreground",children:c}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>b(!1),children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:T,children:"Remover"})]})]})})]})},exports.TermsOfUseDialog=function({term:s,open:r,onClose:n,onAgree:o,title:i=e.t("terms_updated"),seeLaterLabel:l=e.t("terms_see_later"),agreeLabel:c=e.t("terms_read_agree"),viewTermLabel:u=e.t("terms_view")}){const[m,p]=t.useState(!1),h=t.useCallback(()=>{o(s.id)},[o,s.id]);return a.jsxs(a.Fragment,{children:[a.jsx(js,{open:r&&!m,onOpenChange:e=>!e&&n(),children:a.jsxs(ks,{className:"sm:max-w-md",children:[a.jsx(Ss,{children:a.jsxs(Ds,{className:"flex items-center gap-2",children:[a.jsx(d.ShieldCheck,{className:"h-5 w-5 text-primary"}),i]})}),a.jsxs("div",{className:"space-y-4",children:[s.description&&a.jsx(Do,{className:"max-h-48",children:a.jsx("div",{className:"text-sm text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:s.description}})}),s.file&&a.jsxs(Xt,{variant:"link",className:"px-0 text-primary",onClick:()=>p(!0),children:[a.jsx(d.ExternalLink,{className:"mr-1 h-4 w-4"}),u]})]}),a.jsxs(Ps,{className:"gap-2 sm:gap-0",children:[a.jsx(Xt,{variant:"ghost",onClick:n,children:l}),a.jsx(Xt,{onClick:h,children:c})]})]})}),m&&a.jsx(tu,{term:s,open:m,onClose:()=>p(!1),viewOnly:!0})]})},exports.TermsOfUseViewer=tu,exports.TextPanel=sm,exports.Textarea=Js,exports.Timepicker=Bc,exports.Toaster=rr,exports.Toggle=xo,exports.ToggleGroup=go,exports.ToggleGroupItem=vo,exports.TokenManager=an,exports.TokenService=Hr,exports.Tooltip=yr,exports.TooltipContent=Nr,exports.TooltipProvider=jr,exports.TooltipTrigger=wr,exports.TreeSelect=Wr,exports.TreeTable=Um,exports.TruncatedCell=Wn,exports.UpdatesNotification=Gc,exports.UsersGroupsSelector=function({users:s,groups:r=[],value:n,onChange:o,disabled:i=!1,maxHeight:l=350,hideGroupFilter:c=!1,searchPlaceholder:u="Buscar usuário...",selectLabel:m="Selecionar",doneLabel:p="Concluir",allLabel:h="Todos",emptyLabel:x=e.t("leadership_no_user_selected"),selectedLabel:f="selecionado",selectedPluralLabel:g="selecionados",className:v}){const[b,j]=t.useState(!1),[y,w]=t.useState(""),[N,_]=t.useState(void 0),C=t.useMemo(()=>new Set(n),[n]),k=t.useMemo(()=>{let e=s;if(N&&(e=e.filter(e=>e.groupIds?.includes(N))),y){const a=ru(y);e=e.filter(e=>ru(e.name).includes(a)||ru(e.email??"").includes(a))}return e},[s,N,y]),S=t.useMemo(()=>b?k:s.filter(e=>C.has(e.id)),[b,k,s,C]),T=n.length,P=t.useMemo(()=>k.length>0&&k.every(e=>C.has(e.id)),[k,C]),D=t.useCallback(e=>{if(i)return;const a=C.has(e)?n.filter(a=>a!==e):[...n,e];o(a)},[n,C,o,i]),E=t.useCallback(e=>{if(i)return;const a=new Set(k.map(e=>e.id));if(e){const e=new Set([...n,...a]);o(Array.from(e))}else o(n.filter(e=>!a.has(e)))},[n,k,o,i]),A=t.useCallback(()=>{j(e=>!e),w(""),_(void 0)},[]);return a.jsxs("div",{className:Yt("rounded-md border bg-muted/30",v),children:[(!i||T>0)&&a.jsxs("div",{className:Yt("flex items-center justify-between px-4 py-2",!i&&"cursor-pointer hover:bg-muted/50"),onClick:i?void 0:A,children:[a.jsx("span",{className:"text-sm font-medium text-primary uppercase",children:!i&&(b?p:m)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:T>0&&`${T} ${1===T?f:g}`})]}),a.jsxs("div",{className:"px-4 pb-3",children:[b&&a.jsxs("div",{className:"flex gap-3 mb-3",children:[!c&&r.length>0&&a.jsxs(Vs,{value:N??"__all__",onValueChange:e=>_("__all__"===e?void 0:e),children:[a.jsx($s,{className:"w-[200px] h-9 text-sm",children:a.jsx(qs,{placeholder:e.t("approval_user_group")})}),a.jsxs(Gs,{children:[a.jsx(Qs,{value:"__all__",children:e.t("team_all_groups")}),r.map(e=>a.jsx(Qs,{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-9 text-sm",placeholder:u,value:y,onChange:e=>w(e.target.value)})]})]}),!b&&0===T&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:[a.jsx(d.Users,{className:"h-4 w-4 mr-2"}),x]}),b&&k.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Xs,{checked:P,onCheckedChange:e=>E(!!e)}),a.jsx("span",{className:"text-sm",children:h})]}),S.length>0&&a.jsx(Do,{style:{maxHeight:l},className:"pr-2",children:a.jsx("div",{className:"space-y-0.5",children:S.map(e=>a.jsxs("div",{className:Yt("flex items-center gap-3 rounded-md bg-background px-3 py-2 text-sm",b&&!i&&"cursor-pointer hover:bg-accent/50"),onClick:b?()=>D(e.id):void 0,children:[b&&a.jsx(Xs,{checked:C.has(e.id),onCheckedChange:()=>D(e.id),onClick:e=>e.stopPropagation()}),a.jsxs(nl,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(ol,{src:e.avatar,alt:e.name}),a.jsx(il,{className:"text-xs",children:su(e.name)})]}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"font-normal truncate",children:e.name}),e.email&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})}),b&&0===k.length&&a.jsx("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:"Nenhum usuário encontrado"})]})]})},exports.VideoEditor=function({value:s,onChange:r,onSubmit:n,onCancel:o,uploadFunction:i,deleteFunction:c,uploadOptions:u}){const{t:m}=j.useTranslation(),[p,h]=t.useState(s||{inputType:"url",controls:!0}),x=t.useRef(null),f=t.useRef(null),{upload:g,uploading:v}=Ep({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:b,uploading:y}=Ep({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),w=t.useMemo(()=>Lp(p.videoUrl||Rp(p.embedCode)||""),[p.videoUrl,p.embedCode]),N=(e,a)=>{const t={...p,[e]:a};h(t),r(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:m("input_type")}),a.jsxs(Vs,{value:p.inputType||"url",onValueChange:e=>N("inputType",e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Qs,{value:"url",children:"URL"}),a.jsx(Qs,{value:"upload",children:m("file_upload")}),a.jsx(Qs,{value:"embed",children:m("embed_code")})]})]})]}),"upload"===p.inputType&&i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Arquivo"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{ref:x,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||a.name.replace(/\.[^/.]+$/,"")};h(t),r(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:v,children:v?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),p.videoFile&&a.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",p.videoFile," (",Math.round((p.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===p.inputType&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:m("embed_code")}),a.jsx(Js,{placeholder:m("paste_embed_code"),value:p.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Thumbnail"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Zt,{type:"url",placeholder:"URL da thumbnail",value:p.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),a.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await b(a),t={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(t),r(t)}catch(t){}finally{f.current&&(f.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:y,children:y?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),p.thumbnailFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",p.thumbnailFile]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"title",children:"Título"}),a.jsx(Zt,{id:"title",placeholder:m("video_title"),value:p.title||"",onChange:e=>N("title",e.target.value)})]}),a.jsxs("div",{className:"flex gap-6",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"autoplay",checked:p.autoplay||!1,onCheckedChange:e=>N("autoplay",!0===e)}),a.jsx(as,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"controls",checked:!1!==p.controls,onCheckedChange:e=>N("controls",!0===e)}),a.jsx(as,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=p.videoUrl||Rp(p.embedCode)||"";if(!t)return a.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===w)return a.jsxs("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[a.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const s="youtube"===w?Ip(t,p.autoplay):Fp(t,p.autoplay);return a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:p.title||e.t("video"),src:s,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Xt,{variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{p.videoUrl||p.embedCode?n(p):l.toast.error("Erro",{description:m("no_video_selected")})},disabled:!(p.videoUrl||p.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:s="",style:r}){const n=t.videoUrl||Rp(t.embedCode)||"";if(!n)return null;const o=Lp(n);return a.jsx(ts,{className:`overflow-hidden my-4 ${s}`,style:r,children:a.jsxs(os,{className:"p-0",children:["file"===o?a.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[a.jsx("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:t.title||e.t("video"),src:"youtube"===o?Ip(n,t.autoplay):Fp(n,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.ViewerDialog=function({open:e,onOpenChange:s,template:r,viewerType:n,isLoading:o=!1,enableDownload:i=!0,onDownload:l,isDownloading:c=!1,enableFavorite:u=!1,isFavorite:m=!1,onFavorite:p,isFavoriting:h=!1,enableConfirmReading:x=!1,readingConfirmationDate:f,onConfirmReading:g,isConfirmingReading:v=!1,readingConfirmationTimeRemaining:b,onIframeLoad:y,className:w}){const{t:N}=j.useTranslation(),_=t.useRef(null),C=n??Xc(r.extension),k=c||v||h,S=r.code?`${r.code} – ${r.name}`:r.name,T=t.useCallback(()=>{_.current&&y&&y(_.current)},[y]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&s(!1)};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,s]),a.jsx(js,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Yt("max-w-[95vw] max-h-[95vh] p-6 gap-0 [&>button.absolute]:hidden",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"w-[90vw]",w),children:[a.jsxs("div",{className:"flex items-center justify-between mb-4 min-h-[35px]",children:[o?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-200px)]",children:S}),a.jsxs("div",{className:"flex items-center gap-1 ml-4 z-20",children:[!o&&a.jsxs(a.Fragment,{children:[(x||f)&&a.jsx(a.Fragment,{children:f?a.jsxs("div",{className:"flex flex-col mr-2.5",children:[a.jsxs("span",{className:"text-sm font-medium flex items-center gap-1 text-foreground",children:[a.jsx(d.CheckCheck,{className:"h-4 w-4"}),"Leitura confirmada"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-5",children:f.toLocaleDateString()})]}):null!=b&&b>0?a.jsxs("div",{className:"flex items-center gap-1 mr-2.5 text-sm text-muted-foreground",children:[a.jsx("span",{children:N("terms_confirmation_available")}),a.jsx("span",{className:"font-medium min-w-[72px]",children:eu(b)}),a.jsx("span",{children:"segundos"})]}):a.jsxs(Xt,{variant:"default",size:"sm",disabled:k,onClick:()=>g?.(),className:"mr-2.5",children:[a.jsx(d.ShieldCheck,{className:"h-4 w-4 mr-1"}),v?"Confirmando...":N("terms_confirm_reading")]})}),C!==exports.FileViewerType.none&&u&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>p?.(m),children:a.jsx(d.Star,{className:Yt("h-4 w-4",m&&"fill-accent text-accent")})})}),a.jsx(Nr,{children:m?"Desfavoritar":"Favoritar"})]}),C!==exports.FileViewerType.none&&i&&a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>l?.(),children:a.jsx(d.Download,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Download"})]})]}),a.jsxs(yr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>s(!1),children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})]})]}),a.jsx("div",{className:Yt("flex flex-col items-center justify-center min-h-[160px] w-full",o&&"relative -top-5",C===exports.FileViewerType.none&&"min-h-[124px]",C===exports.FileViewerType.image&&"max-h-[85vh]",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"min-w-[77vw] min-h-[80vh]"),children:o?a.jsx(tr,{className:"h-14 w-14"}):a.jsxs(a.Fragment,{children:[(C===exports.FileViewerType.none||!r.url)&&a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-base text-foreground mb-1",children:"Extensão não suportada para visualização."}),a.jsx("b",{className:"text-base text-foreground",children:"Deseja fazer o download do arquivo?"})]}),C===exports.FileViewerType.image&&a.jsx("img",{loading:"eager",src:r.url,alt:r.name,className:"max-w-full max-h-[85vh] object-contain"}),C===exports.FileViewerType.video&&a.jsx("video",{controls:!0,autoPlay:!0,src:r.url,className:"w-full h-full"}),C===exports.FileViewerType.audio&&a.jsx("audio",{controls:!0,autoPlay:!0,src:r.url}),(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(tr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{ref:_,src:r.url,onLoad:T,className:"border-none w-full h-full z-[1] relative",title:r.name})]})]})}),!o&&C===exports.FileViewerType.none&&a.jsxs("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-border",children:[a.jsx(Xt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),i&&a.jsx(Xt,{variant:"default",onClick:()=>l?.(),children:"Download"})]})]})})},exports.addAppTranslations=li,exports.assets=We,exports.badgeVariants=Zs,exports.buildDetailRows=Zh,exports.buildHierarchy=mp,exports.buildModuleUrl=Gt,exports.buildPlacesTree=function(e){e.forEach(a=>{a.children=e.filter(e=>e.parentId===a.id)});const a=e.filter(e=>!e.parentId);return function e(a,t){a?.forEach(a=>{t(a),a.children&&e(a.children,t)})}(a,a=>{a.children=e.filter(e=>e.parentId===a.id)}),a},exports.buildWopiUrl=function(e){const{t:a}=j.useTranslation(),{viewerUrl:t,wopiUrl:s,fileId:r,token:n,extension:o,language:i="pt-br"}=e,l=Zc(o);return l?`${t}${l}ui=${i}&rs=${i}&access_token=${n}&WOPISrc=${encodeURIComponent(`${s}${r}`)}`:null},exports.buttonGroupVariants=xl,exports.buttonVariants=Kt,exports.calculateAspectRatio=zp,exports.camelToDash=rx,exports.cn=Yt,exports.createCrudPage=function(e){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=e,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit: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 a.jsx(Ho,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=Om({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=Om,exports.createService=yn,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=yn({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)=>Dn({queryKey:e.tableName,service:a,entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.createStatusConfig=function(e){return a=>e[a]},exports.createTranslatedMessages=a=>({success:{created:a=>e.t("msg_created_success",`${a} criado com sucesso`).replace("{{entity}}",a),updated:a=>e.t("msg_updated_success",`${a} atualizado com sucesso`).replace("{{entity}}",a),deleted:a=>e.t("msg_deleted_success",`${a} removido com sucesso`).replace("{{entity}}",a)},error:{create:a=>e.t("msg_create_error",`Erro ao criar ${a}`).replace("{{entity}}",a),update:a=>e.t("msg_update_error",`Erro ao atualizar ${a}`).replace("{{entity}}",a),delete:a=>e.t("msg_delete_error",`Erro ao remover ${a}`).replace("{{entity}}",a),load:a=>e.t("msg_load_error",`Erro ao carregar ${a}`).replace("{{entity}}",a)}}),exports.currencyFormatter=Hu,exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=hn,exports.deriveNameField=pn,exports.deriveUsernameField=xn,exports.detectBrowserLocale=Lt,exports.detectBrowserPreferences=()=>{const e=Lt();return{locale:e,timezone:zt(),datetimeFormat:Ut(e)}},exports.detectBrowserTimezone=zt,exports.detectVideoProvider=Lp,exports.emailService=lp,exports.errorService=tn,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.extractNumberFromCurrency=function(e){const a=e.replace(/[^\d,.-]/g,"").replace(/\./g,"").replace(",",".");return parseFloat(a)},exports.extractVimeoId=Mp,exports.extractYouTubeId=Ap,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=>Dt.find(a=>a.value===e),exports.findLocale=e=>Pt.find(a=>a.value===e),exports.findTimezone=e=>Et.find(a=>a.value===e),exports.flattenTree=pp,exports.formatBytes=Eh,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=Bt,exports.formatDatetime=Vt,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.formatTime=fh,exports.formatTimeProgress=xh,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:Yo(e),label:Yo(e),...Go(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.generatePastelBg=$t,exports.getActionTypes=function(){return[{id:"immediate",label:e.t("ap_type_immediate")},{id:"corrective",label:e.t("ap_type_corrective")},{id:"preventive",label:e.t("ap_type_preventive")},{id:"improvement",label:e.t("ap_type_improvement")},{id:"standardization",label:e.t("ap_type_standardization")}]},exports.getContrastRatio=function(e,a){const t=Wt(e),s=Wt(a);return(Math.max(t,s)+.05)/(Math.min(t,s)+.05)},exports.getDefaultPanelSize=function(e){switch(e){case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.List:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Text:case exports.DashboardPanelType.StackedColumn:return{x:4,y:2};case exports.DashboardPanelType.Pareto:case exports.DashboardPanelType.RiskMatrix:case exports.DashboardPanelType.Burndown:case exports.DashboardPanelType.PerformanceColumns:return{x:8,y:2};case exports.DashboardPanelType.Numeric:return{x:1,y:1};default:return{x:2,y:2}}},exports.getEnvironmentConfig=Ae,exports.getFieldValue=Rh,exports.getFileExtension=Ah,exports.getFormFieldValues=function(e){return e.filter(e=>e.type!==exports.ECustomFormFieldType.readOnlyText).map(e=>({formFieldAssociationId:e.id,textValue:e.type===exports.ECustomFormFieldType.text?e.textValue:void 0,numberValue:e.type===exports.ECustomFormFieldType.number?e.numberValue:void 0,dateValue:e.type===exports.ECustomFormFieldType.date?e.dateValue:void 0,timeValue:e.type===exports.ECustomFormFieldType.time?e.timeValue:void 0,itemsValue:[exports.ECustomFormFieldType.url,exports.ECustomFormFieldType.singleSelection,exports.ECustomFormFieldType.multiSelection].includes(e.type)?e.itemsValue:void 0,questionsValue:e.type===exports.ECustomFormFieldType.questions?e.questionsValue:void 0}))},exports.getLinkFromRow=qu,exports.getLuminance=Wt,exports.getMinPanelSize=fm,exports.getOnlineViewerType=function(e){const{t:a}=j.useTranslation();return{".gdocs":"document",".gsheets":"spreadsheets"}[e.toLowerCase()]||"document"},exports.getPriorities=function(){return[{id:exports.ETaskPlanPriority.low,label:e.t("ap_priority_low"),color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:e.t("ap_priority_medium"),color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:e.t("ap_priority_high"),color:"#F44336"}]},exports.getProgressColor=gh,exports.getQualiexApiUrl=Oe,exports.getStatusLabels=sh,exports.getSupabaseClient=on,exports.getViewerType=Xc,exports.getWopiViewer=Zc,exports.handleExternalLink=Ht,exports.inferDatetimeFormat=Ut,exports.inputGroupAddonVariants=Rl,exports.inputGroupButtonVariants=zl,exports.isCurrency=function(e){return!!Wu.test(e)&&!isNaN(parseFloat(e.replace(/,/g,"")))},exports.isDevEnvironment=Ue,exports.isDevSupabaseProject=Ie,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.isLovablePreview=Le,exports.isNullOrEmptyField=function(e){return null==e?.value||""===e.value.trim()},exports.isValidDatetimeFormat=e=>Dt.some(a=>a.value===e),exports.isValidLocale=Ft,exports.isValidTimezone=Rt,exports.loadClicksignScript=Wp,exports.loadForlogicFonts=Ji,exports.logoSrc=He,exports.mergeTranslationFiles=function(...e){return Object.assign({},...e)},exports.navigationMenuTriggerStyle=sd,exports.normalizeVideoUrl=function(e,a,t){switch(a||Lp(e)){case"youtube":return Ip(e,t);case"vimeo":return Fp(e,t);default:return e}},exports.normalizeVimeoUrl=Fp,exports.normalizeYouTubeUrl=Ip,exports.parseIframeSrc=Rp,exports.placeService=up,exports.processTrails=Kh,exports.processUrl=Bu,exports.qualiexApi=mn,exports.resizeKeepingAspect=function(e,a,t,s){const r=zp(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=fn,exports.resolvePageTitle=Ym,exports.setFormFieldValues=function(e,a){return a?.length?e.map(e=>{const t=a.find(a=>a.formFieldAssociationId===e.id);if(!t)return e;const s={...e};switch(e.type){case exports.ECustomFormFieldType.text:s.textValue=t.textValue;break;case exports.ECustomFormFieldType.number:s.numberValue=t.numberValue;break;case exports.ECustomFormFieldType.date:s.dateValue=t.dateValue;break;case exports.ECustomFormFieldType.time:s.timeValue=t.timeValue;break;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:s.itemsValue=t.itemsValue||[];break;case exports.ECustomFormFieldType.questions:s.questionsValue=t.questionsValue||[]}return s}):e},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new w.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.shouldShowField=Lh,exports.shouldUseDevTokens=ze,exports.signService=qp,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=Ge,exports.sortByMonthYear=function(e){return e?.sort((e,a)=>{if(!e?.items?.length||!a?.items?.length)return 0;return Vu(e.items[0]?.keyDate)-Vu(a.items[0]?.keyDate)})},exports.toQueryString=function(e){return e?$u(e).join("&"):null},exports.toggleVariants=ho,exports.trackFooterClick=Ri,exports.trackInterestClick=Fi,exports.trackModuleClick=Mi,exports.trimTextFields=Qt,exports.useActionPlan=dh,exports.useActionPlanProgress=hh,exports.useActiveModules=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Pn();return w.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=on(),{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(!cn.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},exports.useAliasFromUrl=Qo,exports.useAuth=Pn,exports.useBaseForm=So,exports.useClarity=Zi,exports.useColumnManager=wo,exports.useColumnResize=po,exports.useCreateMultipleLeadersMutation=gp,exports.useCreateSingleLeaderMutation=fp,exports.useCrud=Dn,exports.useDebounce=Qm,exports.useDerivedContractedModules=Hi,exports.useFormField=Ms,exports.useHasOpenModal=function(){const{hasOpenModal:e}=rp();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a}=pi(),t=It;return{formatDatetime:s=>Vt(s,t,a,e),formatDate:t=>Bt(t,e,a),locale:e,timezone:a,datetimeFormat:t}},exports.useIsMobile=An,exports.useLeadershipApi=hp,exports.useLocale=pi,exports.useMediaQuery=En,exports.useMediaUpload=Ep,exports.useModalState=rp,exports.useModuleAccess=Wi,exports.useModuleConfig=fi,exports.useNavigation=Gm,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=si(),r=t.useRef({});t.useEffect(()=>{const t=JSON.stringify(r.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(r.current.title!==e.title||r.current.subtitle!==e.subtitle||t)&&(r.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},a(e)),()=>s()},[e.title,e.subtitle,e.breadcrumbs,a,s])},exports.usePageMetadataContext=si,exports.usePageTitle=function(){const e=N.useLocation(),{navigation:a}=Gm();return Ym(a,e.pathname)},exports.usePermissionQuery=Jm,exports.useQualiexUsers=Ro,exports.useRemoveLeaderMutation=bp,exports.useRouteBreadcrumbs=function(){const e=N.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:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,d]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),x=t.useRef(0),f=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,x.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return o?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,o]),t.useEffect(()=>(c?(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=""}),[c]);const v=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:v,getRowHeight:f}},exports.useSidebar=Md,exports.useSidebarResize=tp,exports.useSignConfig=Up,exports.useSyncSubordinatesMutation=jp,exports.useUpdateLeaderMutation=vp,exports.useUpdatesNotification=Hc,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=t.useState(s),[d,c]=t.useState(r),[u,m]=t.useState(!1),[p,h]=t.useState(!1),x=a.length,f=0===i,g=i===x-1,v=a[i],b=x>1?(i+1)/x*100:100,j=t.useCallback(()=>!v?.canProceed||v.canProceed(),[v]),y=t.useMemo(()=>j(),[j,d]),w=t.useMemo(()=>!f&&!v?.disableBack,[f,v]),N=t.useCallback(e=>{c(a=>({...a,...e}))},[]),_=t.useCallback((e,a)=>{c(t=>({...t,[e]:a}))},[]),C=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),k=t.useCallback(async()=>{if(j()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[j,p,d,n]),S=t.useCallback(async()=>{j()&&!u&&(g?await k():l(e=>Math.min(e+1,x-1)))},[j,u,g,x,k]),T=t.useCallback(()=>{w&&!u&&l(e=>Math.max(e-1,0))},[w,u]),P=t.useCallback(e=>{e<0||e>=x||u||(e<=i||e===i+1)&&l(e)},[i,x,u]),D=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:v,data:d,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:T,goTo:P,canProceed:y,canGoBack:w,setData:N,updateField:_,reset:C,complete:k,setLoading:D,progress:b,stepIndex:i,totalSteps:x}},exports.validateFields=function(e){const a=[];return e.forEach(e=>{if(!e.required||e.readOnly||e.type===exports.ECustomFormFieldType.readOnlyText)return;const t=Rh(e);if((null==t||""===t||Array.isArray(t)&&0===t.length)&&a.push(e.id),e.type===exports.ECustomFormFieldType.number&&null!=t){const s=e.config;null!=s?.min&&t<s.min&&a.push(e.id),null!=s?.max&&t>s.max&&a.push(e.id)}}),{valid:0===a.length,invalidFields:[...new Set(a)]}};