forlogic-core 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("i18next"),t=require("react/jsx-runtime"),a=require("react"),r=require("@radix-ui/react-slot"),s=require("class-variance-authority"),n=require("clsx"),o=require("tailwind-merge"),i=require("date-fns"),l=require("sonner"),c=require("lucide-react"),d=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"),b=require("@radix-ui/react-tooltip"),v=require("@radix-ui/react-popover"),y=require("react-i18next"),w=require("@supabase/supabase-js"),j=require("@tanstack/react-query"),N=require("react-router"),_=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"),A=require("@radix-ui/react-switch"),T=require("@radix-ui/react-avatar"),D=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-tabs"),P=require("@radix-ui/react-accordion"),I=require("react-day-picker"),M=require("vaul"),R=require("@radix-ui/react-hover-card"),L=require("@radix-ui/react-navigation-menu"),F=require("@radix-ui/react-progress"),z=require("@radix-ui/react-radio-group"),U=require("react-resizable-panels"),O=require("@radix-ui/react-slider"),B=require("@radix-ui/react-menubar"),q=require("recharts"),V=require("@tiptap/react"),$=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),K=require("@tiptap/extension-color"),Y=require("@tiptap/extension-highlight"),Q=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),J=require("zod"),Z="undefined"!=typeof document?document.currentScript:null;function ee(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var te=ee(a),ae=ee(c),re=ee(d),se=ee(u),ne=ee(m),oe=ee(p),ie=ee(x),le=ee(f),ce=ee(g),de=ee(b),ue=ee(v),me=ee(_),pe=ee(C),he=ee(k),xe=ee(S),fe=ee(A),ge=ee(T),be=ee(D),ve=ee(E),ye=ee(P),we=ee(R),je=ee(L),Ne=ee(F),_e=ee(z),Ce=ee(U),ke=ee(O),Se=ee(B),Ae=ee(q);const Te={storageProjectId:"ccjfvpnndclajkleyqkc",supabaseProjectId:"ccjfvpnndclajkleyqkc",supabaseUrl:"https://ccjfvpnndclajkleyqkc.supabase.co",supabasePublishableKey:"sb_publishable_w-TKU0hE4bjM_uOgt3fK1g_ewrXKJ8J",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",logoutUrl:"https://login.qualiex.com/oauth2/logout",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20",responseType:"id_token token",scope:"openid profile email"},qualiexApiUrl:"https://common-v4-api.qualiex.com",documentsApiUrl:"https://documents-v4-api.qualiex.com",identApiUrl:"",loginApiUrl:"",appBasePath:"",commonV4AppUrl:"https://apps4.qualiex.com/common/",commonV5AppUrl:"https://apps5.qualiex.com/common/"},De={storageProjectId:"ccjfvpnndclajkleyqkc",supabaseProjectId:"tskpcuganynhsppzoqgj",supabaseUrl:"https://tskpcuganynhsppzoqgj.supabase.co",supabasePublishableKey:"sb_publishable_2EIWdYocxgrN4t_f64Ms3g_pKRcbHfL",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",logoutUrl:"https://login-dev.qualiex.com/oauth2/logout",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20",responseType:"id_token token",scope:"openid profile email"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com",documentsApiUrl:"https://documents-v4-api-dev.qualiex.com",identApiUrl:"",loginApiUrl:"",appBasePath:"",commonV4AppUrl:"https://apps4-dev.qualiex.com/common/",commonV5AppUrl:"https://apps5-dev.qualiex.com/common/"};function Ee(){return"DEV"===(void 0).VITE_APP_ENV?"DEV":"PROD"}let Pe={};function Ie(){const e="DEV"===Ee()?De:Te;return{...e,...Pe,oauth:{...e.oauth,...Pe.oauth}}}function Me(){return"DEV"===Ee()}let Re="supabase";function Le(e){Re=e}function Fe(){return"supabase"===Re}const ze={get oauth(){const e=Ie();return{authUrl:e.oauth.authUrl,logoutUrl:e.oauth.logoutUrl,clientId:e.oauth.clientId,responseType:e.oauth.responseType,scope:e.oauth.scope}}};function Ue(e){const t=Ie().appBasePath||"";return`${window.location.origin}${t}${e}`}function Oe(){return Ie().appBasePath||""}function Be(e){const t=Oe();return t&&e.startsWith(t)?e.slice(t.length)||"/":e}const qe={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Ve={debounceDelay:500},$e=()=>{const e=window.location.origin,t=(()=>{try{return window.self!==window.top}catch{return!0}})();return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("lovable.dev")||e.includes("lovable.app")&&t||(void 0).DEV},We=()=>$e()&&Fe(),He=$e,Ge=()=>Ie().qualiexApiUrl,Ke=()=>Ie().documentsApiUrl,Ye=()=>Ie().identApiUrl,Qe=()=>Ie().loginApiUrl,Xe=()=>Ie().commonV4AppUrl,Je=()=>Ie().commonV5AppUrl,Ze={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},et={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},tt={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}`}},at="https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets",rt={qualiex:`${at}/logo-qualiex-white.svg`,qualitfy:`${at}/logo-qualitfy-white.svg`,metroex:`${at}/logo-metroex-white.svg`,qualiexSmall:`${at}/logo-forlogic-white.svg`,saber:`${at}/saber-gestao-white.png`,saberSmall:`${at}/small.svg`},st=`${at}/favicon.png`;let nt={};function ot(e){return nt.logos?.[e]??rt[e]}const it={get qualiex(){return ot("qualiex")},get qualitfy(){return ot("qualitfy")},get metroex(){return ot("metroex")},get saber(){return ot("saber")},get qualiexSmall(){return ot("qualiexSmall")},get saberSmall(){return ot("saberSmall")}};function lt(e){return ot(et.isQualiex?e?.isMetroex?"metroex":e?.isQualitfy?"qualitfy":"qualiex":"saber")}const ct={get logo(){return lt()},get smallLogo(){return ot(et.isQualiex?"qualiexSmall":"saberSmall")},get favicon(){return nt.favicon??st}},dt=ct.logo,ut=ct.smallLogo;function mt(){if("undefined"==typeof document)return;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=ct.favicon,document.head.appendChild(e)}"function"==typeof queueMicrotask?queueMicrotask(mt):Promise.resolve().then(mt);const pt={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 ht(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const xt={date:ht({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:ht({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:ht({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ft={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function gt(e){return(t,a)=>{let r;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;r=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;r=e.values[s]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}const bt={ordinalNumber:(e,t)=>{const a=Number(e),r=a%100;if(r>20||r<10)switch(r%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:gt({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:gt({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:gt({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:gt({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:gt({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function vt(e){return(t,a={})=>{const r=a.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],n=t.match(s);if(!n)return null;const o=n[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let c;c=e.valueCallback?e.valueCallback(l):l,c=a.valueCallback?a.valueCallback(c):c;return{value:c,rest:t.slice(o.length)}}}function yt(e){return(t,a={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],n=t.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(s.length)}}}const wt={ordinalNumber:yt({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:vt({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:vt({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:vt({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:vt({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:vt({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"})},jt={code:"en-US",formatDistance:(e,t,a)=>{let r;const s=pt[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+r:r+" ago":r},formatLong:xt,formatRelative:(e,t,a,r)=>ft[e],localize:bt,match:wt,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Nt={};function _t(){return Nt}const Ct=6048e5;function kt(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function St(e){const t=kt(e);return t.setHours(0,0,0,0),t}function At(e){const t=kt(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function Tt(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Dt(e){const t=kt(e),a=function(e,t){const a=St(e),r=St(t),s=+a-At(a),n=+r-At(r);return Math.round((s-n)/864e5)}(t,function(e){const t=kt(e),a=Tt(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function Et(e,t){const a=_t(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,s=kt(e),n=s.getDay(),o=(n<r?7:0)+n-r;return s.setDate(s.getDate()-o),s.setHours(0,0,0,0),s}function Pt(e){return Et(e,{weekStartsOn:1})}function It(e){const t=kt(e),a=t.getFullYear(),r=Tt(e,0);r.setFullYear(a+1,0,4),r.setHours(0,0,0,0);const s=Pt(r),n=Tt(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const o=Pt(n);return t.getTime()>=s.getTime()?a+1:t.getTime()>=o.getTime()?a:a-1}function Mt(e){const t=kt(e),a=+Pt(t)-+function(e){const t=It(e),a=Tt(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),Pt(a)}(t);return Math.round(a/Ct)+1}function Rt(e,t){const a=kt(e),r=a.getFullYear(),s=_t(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=Tt(e,0);o.setFullYear(r+1,0,n),o.setHours(0,0,0,0);const i=Et(o,t),l=Tt(e,0);l.setFullYear(r,0,n),l.setHours(0,0,0,0);const c=Et(l,t);return a.getTime()>=i.getTime()?r+1:a.getTime()>=c.getTime()?r:r-1}function Lt(e,t){const a=kt(e),r=+Et(a,t)-+function(e,t){const a=_t(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=Rt(e,t),n=Tt(e,0);return n.setFullYear(s,0,r),n.setHours(0,0,0,0),Et(n,t)}(a,t);return Math.round(r/Ct)+1}function Ft(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const zt={y(e,t){const a=e.getFullYear(),r=a>0?a:1-a;return Ft("yy"===t?r%100:r,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):Ft(a+1,2)},d:(e,t)=>Ft(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>Ft(e.getHours()%12||12,t.length),H:(e,t)=>Ft(e.getHours(),t.length),m:(e,t)=>Ft(e.getMinutes(),t.length),s:(e,t)=>Ft(e.getSeconds(),t.length),S(e,t){const a=t.length,r=e.getMilliseconds();return Ft(Math.trunc(r*Math.pow(10,a-3)),t.length)}},Ut="midnight",Ot="noon",Bt="morning",qt="afternoon",Vt="evening",$t="night",Wt={G:function(e,t,a){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"});case"GGGGG":return a.era(r,{width:"narrow"});default:return a.era(r,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),r=t>0?t:1-t;return a.ordinalNumber(r,{unit:"year"})}return zt.y(e,t)},Y:function(e,t,a,r){const s=Rt(e,r),n=s>0?s:1-s;if("YY"===t){return Ft(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):Ft(n,t.length)},R:function(e,t){return Ft(It(e),t.length)},u:function(e,t){return Ft(e.getFullYear(),t.length)},Q:function(e,t,a){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return Ft(r,2);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});default:return a.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,a){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return Ft(r,2);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});default:return a.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,a){const r=e.getMonth();switch(t){case"M":case"MM":return zt.M(e,t);case"Mo":return a.ordinalNumber(r+1,{unit:"month"});case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});default:return a.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,a){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return Ft(r+1,2);case"Lo":return a.ordinalNumber(r+1,{unit:"month"});case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});default:return a.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,a,r){const s=Lt(e,r);return"wo"===t?a.ordinalNumber(s,{unit:"week"}):Ft(s,t.length)},I:function(e,t,a){const r=Mt(e);return"Io"===t?a.ordinalNumber(r,{unit:"week"}):Ft(r,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):zt.d(e,t)},D:function(e,t,a){const r=Dt(e);return"Do"===t?a.ordinalNumber(r,{unit:"dayOfYear"}):Ft(r,t.length)},E:function(e,t,a){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,a,r){const s=e.getDay(),n=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return Ft(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,a,r){const s=e.getDay(),n=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return Ft(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(s,{width:"narrow",context:"standalone"});case"cccccc":return a.day(s,{width:"short",context:"standalone"});default:return a.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,a){const r=e.getDay(),s=0===r?7:r;switch(t){case"i":return String(s);case"ii":return Ft(s,t.length);case"io":return a.ordinalNumber(s,{unit:"day"});case"iii":return a.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,a){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,a){const r=e.getHours();let s;switch(s=12===r?Ot:0===r?Ut:r/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,a){const r=e.getHours();let s;switch(s=r>=17?Vt:r>=12?qt:r>=4?Bt:$t,t){case"B":case"BB":case"BBB":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return zt.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):zt.H(e,t)},K:function(e,t,a){const r=e.getHours()%12;return"Ko"===t?a.ordinalNumber(r,{unit:"hour"}):Ft(r,t.length)},k:function(e,t,a){let r=e.getHours();return 0===r&&(r=24),"ko"===t?a.ordinalNumber(r,{unit:"hour"}):Ft(r,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):zt.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):zt.s(e,t)},S:function(e,t){return zt.S(e,t)},X:function(e,t,a){const r=e.getTimezoneOffset();if(0===r)return"Z";switch(t){case"X":return Gt(r);case"XXXX":case"XX":return Kt(r);default:return Kt(r,":")}},x:function(e,t,a){const r=e.getTimezoneOffset();switch(t){case"x":return Gt(r);case"xxxx":case"xx":return Kt(r);default:return Kt(r,":")}},O:function(e,t,a){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Ht(r,":");default:return"GMT"+Kt(r,":")}},z:function(e,t,a){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Ht(r,":");default:return"GMT"+Kt(r,":")}},t:function(e,t,a){return Ft(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return Ft(e.getTime(),t.length)}};function Ht(e,t=""){const a=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),n=r%60;return 0===n?a+String(s):a+String(s)+t+Ft(n,2)}function Gt(e,t){if(e%60==0){return(e>0?"-":"+")+Ft(Math.abs(e)/60,2)}return Kt(e,t)}function Kt(e,t=""){const a=e>0?"-":"+",r=Math.abs(e);return a+Ft(Math.trunc(r/60),2)+t+Ft(r%60,2)}const Yt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Qt=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Xt={p:Qt,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],r=a[1],s=a[2];if(!s)return Yt(e,t);let n;switch(r){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",Yt(r,t)).replace("{{time}}",Qt(s,t))}},Jt=/^D+$/,Zt=/^Y+$/,ea=["D","DD","YY","YYYY"];function ta(e){if(!(t=e,t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof e))return!1;var t;const a=kt(e);return!isNaN(Number(a))}const aa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ra=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,sa=/^'([^]*?)'?$/,na=/''/g,oa=/[a-zA-Z]/;function ia(e,t,a){const r=_t(),s=a?.locale??r.locale??jt,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,i=kt(e);if(!ta(i))throw new RangeError("Invalid time value");let l=t.match(ra).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,Xt[t])(e,s.formatLong)}return e}).join("").match(aa).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:la(e)};if(Wt[t])return{isToken:!0,value:e};if(t.match(oa))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});s.localize.preprocessor&&(l=s.localize.preprocessor(i,l));const c={firstWeekContainsDate:n,weekStartsOn:o,locale:s};return l.map(r=>{if(!r.isToken)return r.value;const n=r.value;(!a?.useAdditionalWeekYearTokens&&function(e){return Zt.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return Jt.test(e)}(n))&&function(e,t,a){const r=function(e,t,a){const r="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(ea.includes(e))throw new RangeError(r)}(n,t,String(e));return(0,Wt[n[0]])(i,n,s.localize,c)}).join("")}function la(e){const t=e.match(sa);return t?t[1].replace(na,"'"):e}function ca(e,t,a){const r=i.getDefaultOptions(),s=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??r.locale);return"formatToParts"in s?function(e,t){const a=e.formatToParts(t);for(let r=a.length-1;r>=0;--r)if("timeZoneName"===a[r].type)return a[r].value;return}(s,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),r=/ [\w-+ ]+$/.exec(a);return r?r[0].substr(1):""}(s,t)}function da(e,t){const a=function(e){ma[e]||(ma[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 ma[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),r=[];for(let e=0;e<a.length;e++){const t=ua[a[e].type];void 0!==t&&(r[t]=parseInt(a[e].value,10))}return r}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(r[3],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[4],10),parseInt(r[5],10),parseInt(r[6],10)]}(a,e)}const ua={year:0,month:1,day:2,hour:3,minute:4,second:5};const ma={},pa=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"===pa||"06/25/2014 00:00:00"===pa;function xa(e,t,a,r,s,n,o){const i=new Date(0);return i.setUTCFullYear(e,t,a),i.setUTCHours(r,s,n,o),i}const fa=36e5,ga={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function ba(e,t,a){if(!e)return 0;let r,s,n=ga.timezoneZ.exec(e);if(n)return 0;if(n=ga.timezoneHH.exec(e),n)return r=parseInt(n[1],10),ya(r)?-r*fa:NaN;if(n=ga.timezoneHHMM.exec(e),n){r=parseInt(n[2],10);const e=parseInt(n[3],10);return ya(r,e)?(s=Math.abs(r)*fa+6e4*e,"+"===n[1]?-s:s):NaN}if(function(e){if(wa[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),wa[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const r=a?t:function(e){return xa(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),s=va(r,e),n=a?s:function(e,t,a){const r=e.getTime();let s=r-t;const n=va(new Date(s),a);if(t===n)return t;s-=n-t;const o=va(new Date(s),a);if(n===o)return n;return Math.max(n,o)}(t,s,e);return-n}return NaN}function va(e,t){const a=da(e,t),r=xa(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let s=e.getTime();const n=s%1e3;return s-=n>=0?n:1e3+n,r-s}function ya(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const wa={};const ja={X:function(e,t,a){const r=Na(a.timeZone,e);if(0===r)return"Z";switch(t){case"X":return ka(r);case"XXXX":case"XX":return Ca(r);default:return Ca(r,":")}},x:function(e,t,a){const r=Na(a.timeZone,e);switch(t){case"x":return ka(r);case"xxxx":case"xx":return Ca(r);default:return Ca(r,":")}},O:function(e,t,a){const r=Na(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",r=Math.abs(e),s=Math.floor(r/60),n=r%60;if(0===n)return a+String(s);return a+String(s)+t+_a(n,2)}(r,":");default:return"GMT"+Ca(r,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return ca("short",e,a);default:return ca("long",e,a)}}};function Na(e,t){const a=e?ba(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function _a(e,t){const a=e<0?"-":"";let r=Math.abs(e).toString();for(;r.length<t;)r="0"+r;return a+r}function Ca(e,t=""){const a=e>0?"-":"+",r=Math.abs(e);return a+_a(Math.floor(r/60),2)+t+_a(Math.floor(r%60),2)}function ka(e,t){if(e%60==0){return(e>0?"-":"+")+_a(Math.abs(e)/60,2)}return Ca(e,t)}function Sa(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const Aa=36e5,Ta=6e4,Da={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 Ea(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const r=function(e){const t={};let a,r=Da.dateTimePattern.exec(e);r?(t.date=r[1],a=r[3]):(r=Da.datePattern.exec(e),r?(t.date=r[1],a=r[2]):(t.date=null,a=e));if(a){const e=Da.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:s,restDateString:n}=function(e,t){if(e){const a=Da.YYY[t],r=Da.YYYYY[t];let s=Da.YYYY.exec(e)||r.exec(e);if(s){const t=s[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(s=Da.YY.exec(e)||a.exec(e),s){const t=s[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(r.date,a),o=function(e,t){if(null===t)return null;let a,r,s;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=Da.MM.exec(e);if(n)return a=new Date(0),r=parseInt(n[1],10)-1,La(t,r)?(a.setUTCFullYear(t,r),a):new Date(NaN);if(n=Da.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=Ra(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=Da.MMDD.exec(e),n){a=new Date(0),r=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return La(t,r,e)?(a.setUTCFullYear(t,r,e),a):new Date(NaN)}if(n=Da.Www.exec(e),n)return s=parseInt(n[1],10)-1,Fa(s)?Pa(t,s):new Date(NaN);if(n=Da.WwwD.exec(e),n){s=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return Fa(s,e)?Pa(t,s,e):new Date(NaN)}return null}(n,s);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let a,s=0;if(r.time&&(s=function(e){let t,a,r=Da.HH.exec(e);if(r)return t=parseFloat(r[1].replace(",",".")),za(t)?t%24*Aa:NaN;if(r=Da.HHMM.exec(e),r)return t=parseInt(r[1],10),a=parseFloat(r[2].replace(",",".")),za(t,a)?t%24*Aa+a*Ta:NaN;if(r=Da.HHMMSS.exec(e),r){t=parseInt(r[1],10),a=parseInt(r[2],10);const e=parseFloat(r[3].replace(",","."));return za(t,a,e)?t%24*Aa+a*Ta+1e3*e:NaN}return null}(r.time),null===s||isNaN(s)))return new Date(NaN);if(r.timeZone||t.timeZone){if(a=ba(r.timeZone||t.timeZone,new Date(e+s)),isNaN(a))return new Date(NaN)}else a=Sa(new Date(e+s)),a=Sa(new Date(e+s+a));return new Date(e+s+a)}return new Date(NaN)}function Pa(e,t,a){t=t||0,a=a||0;const r=new Date(0);r.setUTCFullYear(e,0,4);const s=7*t+a+1-(r.getUTCDay()||7);return r.setUTCDate(r.getUTCDate()+s),r}const Ia=[31,28,31,30,31,30,31,31,30,31,30,31],Ma=[31,29,31,30,31,30,31,31,30,31,30,31];function Ra(e){return e%400==0||e%4==0&&e%100!=0}function La(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const r=Ra(e);if(r&&a>Ma[t])return!1;if(!r&&a>Ia[t])return!1}return!0}function Fa(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function za(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const Ua=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Oa(e,t,a,r){return function(e,t,a={}){const r=(t=String(t)).match(Ua);if(r){const s=Ea(a.originalDate||e,a);t=r.reduce(function(e,t){if("'"===t[0])return e;const r=e.indexOf(t),n="'"===e[r-1],o=e.replace(t,"'"+ja[t[0]](s,t,a)+"'");return n?o.substring(0,r-1)+o.substring(r+1):o},t)}return ia(e,t,a)}(function(e,t,a){const r=ba(t,e=Ea(e,a),!0),s=new Date(e.getTime()-r),n=new Date(0);return n.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),n.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),n}(e,t,{timeZone:(r={...r,timeZone:t,originalDate:e}).timeZone}),a,r)}const Ba={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"}},qa={date:ht({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:ht({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:ht({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Va={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"},$a={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"},Wa={ordinalNumber:(e,t)=>Number(e)+"º",era:gt({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:gt({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:gt({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:gt({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:gt({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"})},Ha={ordinalNumber:yt({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:vt({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:vt({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:vt({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:vt({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:vt({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"})},Ga={code:"es",formatDistance:(e,t,a)=>{let r;const s=Ba[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+r:"hace "+r:r},formatLong:qa,formatRelative:(e,t,a,r)=>1!==t.getHours()?$a[e]:Va[e],localize:Wa,match:Ha,options:{weekStartsOn:1,firstWeekContainsDate:1}},Ka={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"}},Ya={date:ht({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:ht({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:ht({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Qa={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Xa={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:gt({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:gt({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:gt({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:gt({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:gt({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"})},Ja={ordinalNumber:yt({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:vt({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:vt({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:vt({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:vt({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:vt({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"})},Za={code:"pt-BR",formatDistance:(e,t,a)=>{let r;const s=Ka[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+r:"há "+r:r},formatLong:Ya,formatRelative:(e,t,a,r)=>{const s=Qa[e];return"function"==typeof s?s(t):s},localize:Xa,match:Ja,options:{weekStartsOn:0,firstWeekContainsDate:1}},er=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],tr=[{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"}],ar=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],rr="pt-BR",sr="dd/MM/yyyy HH:mm",nr="America/Sao_Paulo",or=e=>er.some(t=>t.value===e),ir=e=>ar.some(t=>t.value===e),lr=()=>{if("undefined"==typeof navigator)return rr;const e=navigator.language;if(or(e))return e;const t=e.split("-")[0],a=er.find(e=>e.value.startsWith(t));return a?.value||rr},cr=()=>{if("undefined"==typeof Intl)return nr;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return ir(e)?e:nr}catch{return nr}},dr=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||sr),ur={"pt-BR":Za,"en-US":jt,"es-ES":Ga},mr=(e,t=sr,a=nr,r=rr)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const n=ur[r]||Za;try{return Oa(s,a,t,{locale:n})}catch(o){return Oa(s,nr,t,{locale:n})}},pr=(e,t=rr,a=nr)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const s=ur[t]||Za;try{return Oa(r,a,"PP",{locale:s})}catch(n){return Oa(r,nr,"PP",{locale:s})}};function hr(e){const t=e.replace("#",""),a=3===t.length?t.split("").map(e=>e+e).join(""):t;return{r:parseInt(a.substring(0,2),16),g:parseInt(a.substring(2,4),16),b:parseInt(a.substring(4,6),16)}}function xr(e,t=.1){const{r:a,g:r,b:s}=hr(e);return`rgba(${a}, ${r}, ${s}, ${t})`}function fr(e){const{r:t,g:a,b:r}=hr(e),[s,n,o]=[t,a,r].map(e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)});return.2126*s+.7152*n+.0722*o}function gr(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info("Link copiado para a área de transferência")})}function br(e,t){return t?e.replace(/\{alias\}/g,t):e}function vr(e="uuid"){if("short"===e){const e=new Uint8Array(9);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(36).padStart(2,"0")).join("").slice(0,12)}if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(16);crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;const a=Array.from(t,e=>e.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}const yr=["hint","details","code","where","schema","table","column"],wr="Ocorreu um erro ao processar sua solicitação.",jr=[/relation\s+"[^"]+"\s+does not exist/i,/column\s+"[^"]+"\s+of relation/i,/violates row-level security policy/i,/permission denied for (table|schema|function)/i,/password|token|secret|api[_-]?key/i];function Nr(e){const t=function(e){if(!e)return wr;if("string"==typeof e)return e;if(e instanceof Error)return e.message||wr;if("object"==typeof e&&"message"in e)return String(e.message);return wr}(e);return Me()?t:jr.some(e=>e.test(t))?wr:t}function _r(...e){return o.twMerge(n.clsx(e))}const Cr=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Cr);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,r]of Object.entries(e))t[a]=Cr(r);return t}return e},kr=s.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded-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"}}),Sr=te.forwardRef(({className:e,variant:a,size:s,asChild:n=!1,...o},i)=>{const l=n?r.Slot:"button";return t.jsx(l,{className:_r(kr({variant:a,size:s,className:e})),ref:i,...o})});Sr.displayName="Button";const Ar=a.forwardRef(({className:e,children:a,variant:r="action",...s},n)=>t.jsx(Sr,{ref:n,variant:r,size:"icon",className:_r("h-8 w-8",e),...s,children:a||t.jsx(c.EllipsisVertical,{size:16})}));Ar.displayName="ActionButton";const Tr=te.forwardRef(({className:e,type:a,showCharCount:r,maxLength:s,onChange:n,...o},i)=>{const[l,c]=te.useState(0);te.useEffect(()=>{"string"==typeof o.value?c(o.value.length):"string"==typeof o.defaultValue&&c(o.defaultValue.length)},[o.value,o.defaultValue]);return t.jsxs("div",{className:"w-full",children:[t.jsx("input",{type:a,className:_r("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:s,onChange:e=>{c(e.target.value.length),n?.(e)},...o}),r&&s&&t.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[l," / ",s]})]})});Tr.displayName="Input";const Dr=s.cva("text-xs font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Er=te.forwardRef(({className:e,...a},r)=>t.jsx(re.Root,{ref:r,className:_r(Dr(),e),...a}));Er.displayName=re.Root.displayName;const Pr=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("rounded-lg border bg-card text-card-foreground shadow-sm",e),...a}));Pr.displayName="Card";const Ir=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("flex flex-col space-y-1.5 p-6",e),...a}));Ir.displayName="CardHeader";const Mr=te.forwardRef(({className:e,...a},r)=>t.jsx("h3",{ref:r,className:_r("text-2xl font-semibold leading-none tracking-tight",e),...a}));Mr.displayName="CardTitle";const Rr=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Rr.displayName="CardDescription";const Lr=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("p-6 pt-0",e),...a}));Lr.displayName="CardContent";const Fr=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("flex items-center p-6 pt-0",e),...a}));Fr.displayName="CardFooter";const zr=te.forwardRef(({className:e,orientation:a="horizontal",decorative:r=!0,...s},n)=>t.jsx(ne.Root,{ref:n,decorative:r,orientation:a,className:_r("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...s}));zr.displayName=ne.Root.displayName;const Ur=oe.Root,Or=oe.Trigger,Br=oe.Portal,qr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Overlay,{className:_r("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),...a,ref:r}));qr.displayName=oe.Overlay.displayName;const Vr=te.forwardRef(({className:e,...a},r)=>t.jsxs(Br,{children:[t.jsx(qr,{}),t.jsx(oe.Content,{ref:r,className:_r("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),...a})]}));Vr.displayName=oe.Content.displayName;const $r=({className:e,...a})=>t.jsx("div",{className:_r("flex flex-col space-y-2 text-center sm:text-left",e),...a});$r.displayName="AlertDialogHeader";const Wr=({className:e,...a})=>t.jsx("div",{className:_r("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Wr.displayName="AlertDialogFooter";const Hr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Title,{ref:r,className:_r("text-lg font-semibold",e),...a}));Hr.displayName=oe.Title.displayName;const Gr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Gr.displayName=oe.Description.displayName;const Kr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Action,{ref:r,className:_r(kr(),e),...a}));Kr.displayName=oe.Action.displayName;const Yr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Cancel,{ref:r,className:_r(kr({variant:"outline"}),"mt-2 sm:mt-0",e),...a}));Yr.displayName=oe.Cancel.displayName;const Qr=se.Root,Xr=se.Trigger,Jr=se.Portal,Zr=se.Close,es=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Overlay,{ref:r,className:_r("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),...a}));es.displayName=se.Overlay.displayName;const ts={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"}},as=te.forwardRef(({className:a,children:r,size:s,variant:n="informative",isDirty:o,customWidth:i,customMinWidth:l,customMaxWidth:d,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:b,onInteractOutside:v,onEscapeKeyDown:y,...w},j)=>{const[N,_]=te.useState(!1),C=te.useRef(null),k=te.useRef(!1),S=s??(i||l||d||u||m||p?void 0:"md"),A=S?ts[S]:{},T={...i??A.width?{width:i??A.width}:{},...l??A.minWidth?{minWidth:l??A.minWidth}:{},...d??A.maxWidth?{maxWidth:d??A.maxWidth}:{},...u??A.height?{height:u??A.height}:{},...m??A.minHeight?{minHeight:m??A.minHeight}:{},...p??A.maxHeight?{maxHeight:p??A.maxHeight}:{},...b},D=te.useCallback(e=>{"form"===n&&o?(C.current=e,_(!0)):e()},[n,o]),E=te.useRef(null),P="destructive"!==n;if("development"===process.env.NODE_ENV&&r){const e=te.Children.toArray(r);e.some(e=>te.isValidElement(e)&&"DialogFooter"===e.type?.displayName),e.some(e=>te.isValidElement(e)&&"DialogBody"===e.type?.displayName)}return t.jsxs(Jr,{children:[t.jsx(es,{}),t.jsxs(se.Content,{ref:j,className:_r("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",a),style:T,onInteractOutside:e=>{"form"!==n&&"destructive"!==n?v?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==n)return"form"===n&&o?(e.preventDefault(),void D(()=>{k.current=!0,E.current?.click()})):void y?.(e);e.preventDefault()},...w,children:[r,P&&t.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:[t.jsx(c.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]}),t.jsx(Ur,{open:N,onOpenChange:_,children:t.jsxs(Vr,{children:[t.jsxs($r,{children:[t.jsx(Hr,{children:h}),t.jsx(Gr,{children:x})]}),t.jsxs(Wr,{children:[t.jsx(Yr,{onClick:()=>{_(!1),C.current=null},children:f}),t.jsx(Kr,{onClick:()=>{_(!1),C.current?.(),C.current=null},children:g})]})]})})]})});as.displayName=se.Content.displayName;const rs=({className:e,showSeparator:a=!1,children:r,...s})=>t.jsxs("div",{className:_r("flex flex-col flex-shrink-0",e),...s,children:[t.jsx("div",{className:"flex flex-col text-left",children:r}),a&&t.jsx(zr,{className:"mt-2"})]});rs.displayName="DialogHeader";const ss=({className:e,...a})=>t.jsx("div",{className:_r("flex-1 min-h-0 overflow-auto py-4 px-2 -mx-2",e),...a});ss.displayName="DialogBody";const ns=({className:e,children:a,...r})=>t.jsxs("div",{className:"flex-shrink-0 pt-4",children:[t.jsx(zr,{className:"mb-4"}),t.jsx("div",{className:_r("flex flex-row justify-end gap-2",e),...r,children:a})]});ns.displayName="DialogFooter";const os=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Title,{ref:r,className:_r("text-xl font-semibold leading-none tracking-tight",e),...a}));os.displayName=se.Title.displayName;const is=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));is.displayName=se.Description.displayName;const ls=h.FormProvider,cs=te.createContext({}),ds=()=>{const e=te.useContext(cs),t=te.useContext(us),{getFieldState:a,formState:r}=h.useFormContext(),s=a(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...s}},us=te.createContext({}),ms=te.forwardRef(({className:e,...a},r)=>{const s=te.useId();return t.jsx(us.Provider,{value:{id:s},children:t.jsx("div",{ref:r,className:_r("space-y-1.5",e),...a})})});ms.displayName="FormItem";const ps=te.forwardRef(({className:e,...a},r)=>{const{error:s,formItemId:n}=ds();return t.jsx(Er,{ref:r,className:_r(s&&"text-destructive",e),htmlFor:n,...a})});ps.displayName="FormLabel";const hs=te.forwardRef(({...e},a)=>{const{error:s,formItemId:n,formDescriptionId:o,formMessageId:i}=ds();return t.jsx(r.Slot,{ref:a,id:n,"aria-describedby":s?`${o} ${i}`:`${o}`,"aria-invalid":!!s,...e})});hs.displayName="FormControl";const xs=te.forwardRef(({className:e,...a},r)=>{const{formDescriptionId:s}=ds();return t.jsx("p",{ref:r,id:s,className:_r("text-sm text-muted-foreground",e),...a})});xs.displayName="FormDescription";const fs=te.forwardRef(({className:e,children:a,...r},s)=>{const{error:n,formMessageId:o}=ds(),i=n?String(n?.message):a;return i?t.jsx("p",{ref:s,id:o,className:_r("text-sm font-medium text-destructive",e),...r,children:i}):null});fs.displayName="FormMessage";const gs=te.createContext({showCheck:!1}),bs=({showCheck:e=!1,...a})=>t.jsx(gs.Provider,{value:{showCheck:e},children:t.jsx(ie.Root,{...a})}),vs=ie.Group,ys=ie.Value,ws=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(ie.Trigger,{ref:s,className:_r("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),...r,children:[a,t.jsx(ie.Icon,{asChild:!0,children:t.jsx(c.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ws.displayName=ie.Trigger.displayName;const js=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.ScrollUpButton,{ref:r,className:_r("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(c.ChevronUp,{className:"h-4 w-4"})}));js.displayName=ie.ScrollUpButton.displayName;const Ns=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.ScrollDownButton,{ref:r,className:_r("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(c.ChevronDown,{className:"h-4 w-4"})}));Ns.displayName=ie.ScrollDownButton.displayName;const _s=te.forwardRef(({className:e,children:a,position:r="popper",container:s,collisionBoundary:n,...o},i)=>t.jsx(ie.Portal,{container:s,children:t.jsxs(ie.Content,{ref:i,className:_r("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"===r&&"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:r,collisionBoundary:n,...o,children:[t.jsx(js,{}),t.jsx(ie.Viewport,{className:_r("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),t.jsx(Ns,{})]})}));_s.displayName=ie.Content.displayName;const Cs=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.Label,{ref:r,className:_r("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...a}));Cs.displayName=ie.Label.displayName;const ks=te.forwardRef(({className:e,children:a,...r},s)=>{const{showCheck:n}=te.useContext(gs);return t.jsxs(ie.Item,{ref:s,className:_r("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n?"pl-8":"pl-2","data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground data-[state=checked]:font-medium data-[state=checked]:border-l-2 data-[state=checked]:border-primary",n?"data-[state=checked]:pl-[calc(2rem-2px)]":"data-[state=checked]:pl-[calc(0.5rem-2px)]",e),...r,children:[n&&t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ie.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),t.jsx(ie.ItemText,{children:a})]})});ks.displayName=ie.Item.displayName;const Ss=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-muted",e),...a}));Ss.displayName=ie.Separator.displayName;const As=te.forwardRef(({className:e,...a},r)=>t.jsx(le.Root,{ref:r,className:_r("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),...a,children:t.jsx(le.Indicator,{className:_r("flex items-center justify-center text-current"),children:t.jsx(c.Check,{className:"h-4 w-4"})})}));As.displayName=le.Root.displayName;const Ts=te.forwardRef(({className:e,showCharCount:a,maxLength:r,onChange:s,...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 t.jsxs("div",{className:"w-full",children:[t.jsx("textarea",{className:_r("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:r,onChange:e=>{l(e.target.value.length),s?.(e)},...n}),a&&r&&t.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[i," / ",r]})]})});Ts.displayName="Textarea";const Ds=s.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),Es=te.forwardRef(({className:e,variant:a,...r},s)=>t.jsx("div",{ref:s,className:_r(Ds({variant:a}),e),...r}));Es.displayName="Badge";const Ps={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Is({size:e="md",className:a}){return t.jsx(c.Loader2,{className:_r("animate-spin text-muted-foreground",Ps[e],a)})}function Ms({isLoading:e,children:a,className:r,type:s="spinner",size:n="md"}){return e?"overlay"===s?t.jsxs("div",{className:_r("relative",r),children:[a,t.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:t.jsx(Is,{size:n})})]}):"skeleton"===s?t.jsx("div",{className:_r("animate-pulse",r),children:t.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):t.jsx("div",{className:_r("flex items-center justify-center py-8",r),children:t.jsx(Is,{size:n})}):t.jsx(t.Fragment,{children:a})}const Rs=({...e})=>t.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:t.jsx(c.CircleCheckIcon,{className:"h-4 w-4"}),info:t.jsx(c.InfoIcon,{className:"h-4 w-4"}),warning:t.jsx(c.TriangleAlertIcon,{className:"h-4 w-4"}),error:t.jsx(c.OctagonXIcon,{className:"h-4 w-4"}),loading:t.jsx(c.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}),Ls=ce.Root,Fs=ce.Trigger,zs=ce.Group,Us=ce.Portal,Os=ce.Sub,Bs=ce.RadioGroup,qs=te.forwardRef(({className:e,inset:a,children:r,...s},n)=>t.jsxs(ce.SubTrigger,{ref:n,className:_r("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",e),...s,children:[r,t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4"})]}));qs.displayName=ce.SubTrigger.displayName;const Vs=te.forwardRef(({className:e,...a},r)=>t.jsx(ce.SubContent,{ref:r,className:_r("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),...a}));Vs.displayName=ce.SubContent.displayName;const $s=te.forwardRef(({className:e,sideOffset:a=4,...r},s)=>t.jsx(ce.Portal,{children:t.jsx(ce.Content,{ref:s,sideOffset:a,className:_r("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),...r})}));$s.displayName=ce.Content.displayName;const Ws=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(ce.Item,{ref:s,className:_r("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",e),...r}));Ws.displayName=ce.Item.displayName;const Hs=te.forwardRef(({className:e,children:a,checked:r,...s},n)=>t.jsxs(ce.CheckboxItem,{ref:n,className:_r("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:r,...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ce.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),a]}));Hs.displayName=ce.CheckboxItem.displayName;const Gs=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(ce.RadioItem,{ref:s,className:_r("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),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ce.ItemIndicator,{children:t.jsx(c.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Gs.displayName=ce.RadioItem.displayName;const Ks=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(ce.Label,{ref:s,className:_r("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...r}));Ks.displayName=ce.Label.displayName;const Ys=te.forwardRef(({className:e,...a},r)=>t.jsx(ce.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-muted",e),...a}));Ys.displayName=ce.Separator.displayName;const Qs=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest opacity-60",e),...a});Qs.displayName="DropdownMenuShortcut";const Xs=({delayDuration:e=300,...a})=>t.jsx(de.Provider,{delayDuration:e,...a}),Js=de.Root,Zs=de.Trigger,en=te.forwardRef(({className:e,sideOffset:a=4,container:r,...s},n)=>t.jsx(de.Portal,{container:r,children:t.jsx(de.Content,{ref:n,sideOffset:a,className:_r("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})}));en.displayName=de.Content.displayName;const tn=te.forwardRef(({children:e,disabledReason:a,className:r},s)=>{const n=t.jsx(Ws,{ref:s,className:_r("opacity-50 cursor-not-allowed pointer-events-auto",r),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:e});return a?t.jsx(Xs,{delayDuration:100,children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("div",{className:"w-full",children:n})}),t.jsx(en,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});tn.displayName="DisabledMenuItem";const an=ue.Root,rn=ue.Trigger,sn=te.forwardRef(({className:e,align:a="center",sideOffset:r=4,container:s,...n},o)=>t.jsx(ue.Portal,{container:s,children:t.jsx(ue.Content,{ref:o,align:a,sideOffset:r,className:_r("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})}));sn.displayName=ue.Content.displayName;const nn=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a}));nn.displayName="Command";const on=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:t.jsx("input",{ref:r,className:_r("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),...a})}));on.displayName="CommandInput";const ln=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));ln.displayName="CommandList";const cn=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("py-6 text-center text-sm text-muted-foreground",e),...a}));cn.displayName="CommandEmpty";const dn=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("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),...a}));dn.displayName="CommandGroup";const un=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("-mx-1 h-px bg-border",e),...a}));un.displayName="CommandSeparator";const mn=te.forwardRef(({className:e,disabled:a,onSelect:r,value:s,...n},o)=>t.jsx("div",{ref:o,className:_r("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":a,onClick:()=>!a&&r?.(s||""),...n}));mn.displayName="CommandItem";const pn=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});function hn({className:e,...a}){return t.jsx("div",{className:_r("animate-pulse rounded-md bg-muted",e),...a})}pn.displayName="CommandShortcut";const xn=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function fn({multiple:r,options:s,value:n,onChange:o,getOptionValue:i,getOptionLabel:l,renderOption:d,placeholder:u,label:m,icon:p,emptyMessage:h,searchPlaceholder:x,disabled:f,required:g,className:b,sortOptions:v,maxDisplayedBadges:y,popoverContainer:w,onOpen:j,onClose:N,clearable:_,showCheck:C}){const[k,S]=a.useState(!1),[A,T]=a.useState(""),D=a.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),E=a.useMemo(()=>{if(!w)return;let e=w,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),r=a.overflowY||a.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[w]),P=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,i,l,v]),I=a.useMemo(()=>{if(!A)return P;const e=xn(A);return P.filter(t=>xn(t.label).includes(e))},[P,A]),M=a.useMemo(()=>P.filter(e=>D.includes(e.value)),[P,D]),R=e=>{S(e),e?j?.():(T(""),N?.())},L=(e,t)=>{t.preventDefault(),t.stopPropagation(),o&&o(r?D.filter(t=>t!==e):"")},F=y?M.slice(0,y):M,z=y&&M.length>y?M.length-y:0;return t.jsxs("div",{className:_r("space-y-2",b),children:[m&&t.jsxs(Er,{children:[m,g&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs(an,{open:k,onOpenChange:R,modal:!1,children:[r?t.jsx(rn,{asChild:!0,children:t.jsxs("div",{role:"combobox","aria-expanded":k,"aria-disabled":f,tabIndex:f?-1:0,onKeyDown:e=>{f||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),R(!k))},className:_r("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",f&&"pointer-events-none opacity-50 cursor-not-allowed",0===M.length&&"text-muted-foreground"),children:[0===M.length?t.jsxs("span",{className:"flex items-center gap-2",children:[p&&t.jsx(p,{className:"h-4 w-4"}),u]}):t.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[F.map(e=>t.jsxs(Es,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,t.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:t=>{"Enter"===t.key&&L(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>L(e.value,t),children:t.jsx(c.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),z>0&&t.jsxs(Es,{variant:"outline",className:"gap-1",children:["+",z]})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}):t.jsxs("div",{className:"relative",children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",role:"combobox","aria-expanded":k,disabled:f,className:_r("relative w-full justify-start min-h-10 h-auto pr-10",_&&M.length>0&&"pr-16",0===M.length&&"text-muted-foreground"),children:[0===M.length?t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 truncate text-left",children:[p&&t.jsx(p,{className:"h-4 w-4"}),t.jsx("span",{className:"truncate",children:u})]}):t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 truncate text-left",children:[p&&t.jsx(p,{className:"h-4 w-4"}),t.jsx("span",{className:"truncate",children:M[0]?.label})]}),t.jsx(c.ChevronDown,{className:"absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 opacity-50"})]})}),_&&M.length>0&&t.jsx("button",{type:"button",disabled:f,className:"absolute right-8 top-1/2 z-10 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-50",onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>L("",e),title:"Limpar seleção","aria-label":"Limpar seleção",children:t.jsx(c.X,{className:"h-3.5 w-3.5"})})]}),t.jsx(sn,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:E,collisionBoundary:E,children:t.jsxs(nn,{children:[t.jsxs("div",{className:"relative",children:[t.jsx(on,{placeholder:x,value:A,onChange:e=>T(e.target.value)}),A&&t.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:()=>T(""),children:t.jsx(c.X,{className:"h-3.5 w-3.5"})})]}),t.jsx(ln,{children:0===s.length?t.jsx(cn,{children:h}):0===I.length?t.jsx(cn,{children:e.t("no_results")}):t.jsx(dn,{children:I.map(e=>{const a=D.includes(e.value);return t.jsxs(mn,{value:e.value,onSelect:()=>(e=>{if(o)if(r){const t=D.includes(e)?D.filter(t=>t!==e):[...D,e];o(t)}else o(e),S(!1)})(e.value),className:_r("cursor-pointer",a&&"bg-accent text-accent-foreground font-medium border-l-2 border-primary pl-[calc(0.5rem-2px)] data-[selected=true]:bg-accent"),children:[C&&t.jsx(c.Check,{className:_r("mr-2 h-4 w-4",a?"opacity-100":"opacity-0")}),d?d(e.original):e.label]},e.value)})})})]})})]})]})}function gn({multiple:e=!1,options:a,items:r,value:s,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:l=e=>e.label,renderOption:d,placeholder:u,label:m,icon:p,emptyMessage:h,searchPlaceholder:x,disabled:f=!1,required:g=!1,isLoading:b=!1,error:v,className:w,sortOptions:j=!0,maxDisplayedBadges:N,popoverContainer:_,onOpen:C,onClose:k,clearable:S=!0,showCheck:A=!1}){const{t:T}=y.useTranslation(),D=a||r||[],E=o||n,P=u||T("select_placeholder","Selecione..."),I=h||T("no_results",T("no_results")),M=x||T("search_placeholder","Pesquisar...");if(b)return t.jsxs("div",{className:_r("space-y-2",w),children:[m&&t.jsxs(Er,{children:[m,g&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(hn,{className:"h-10 w-full"})]});const R="string"==typeof v?v:v instanceof Error?v.message:v?T("error_loading",T("error_loading")):void 0;return R?t.jsxs("div",{className:_r("space-y-2",w),children:[m&&t.jsxs(Er,{children:[m,g&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[t.jsx(c.AlertCircle,{className:"h-4 w-4"}),t.jsx("span",{className:"text-sm",children:R})]})]}):t.jsx(fn,{multiple:e,options:D,value:s||(e?[]:""),onChange:E,getOptionValue:i,getOptionLabel:l,renderOption:d,placeholder:P,label:m,icon:p,emptyMessage:I,searchPlaceholder:M,disabled:f,required:g,className:w,sortOptions:j,maxDisplayedBadges:N,popoverContainer:_,onOpen:C,onClose:k,clearable:S,showCheck:A})}const bn=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function vn(e,t){if(!t)return null;const a=bn(t),r=[];for(const s of e){const e=bn(s.label).includes(a),n=s.children?vn(s.children,t):null,o=n&&n.length>0;(e||o)&&r.push({...s,children:e?s.children:o?n:s.children})}return r}function yn(e,t){for(const a of e){if(a.value===t)return a.label;if(a.children){const e=yn(a.children,t);if(e)return e}}}function wn({node:e,level:a,expanded:r,onToggleExpand:s,selectedValues:n,onSelect:o,showCheck:i}){const l=e.children&&e.children.length>0,d=n.includes(e.value),u=8+20*a;return t.jsxs("div",{role:"treeitem","aria-expanded":l?r:void 0,"aria-selected":d,className:_r("flex items-center gap-1 rounded-sm py-1.5 pr-2 text-sm cursor-pointer outline-none","hover:bg-accent hover:text-accent-foreground",d&&"bg-accent text-accent-foreground font-medium border-l-2 border-primary"),style:{paddingLeft:u-(d?2:0)+"px"},children:[t.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:t=>{t.stopPropagation(),o(e.value)},children:[i&&t.jsx(c.Check,{className:_r("h-4 w-4 shrink-0",d?"opacity-100":"opacity-0")}),(()=>{const a=d?e.iconSelected??(r?e.iconOpen:null)??e.icon:r?e.iconOpen??e.icon:e.icon;return a?t.jsx(a,{className:_r("h-4 w-4 shrink-0",e.iconClassName||"text-muted-foreground")}):null})(),t.jsx("span",{className:"truncate",children:e.label})]}),l&&t.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:t=>{t.stopPropagation(),s(e.value)},tabIndex:-1,"aria-label":r?"Recolher":"Expandir",children:r?t.jsx(c.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):t.jsx(c.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function jn({nodes:e,level:r,expandedIds:s,onToggleExpand:n,selectedValues:o,onSelect:i,showCheck:l}){return t.jsx(t.Fragment,{children:e.map(e=>{const c=s.has(e.value);return t.jsxs(a.Fragment,{children:[t.jsx(wn,{node:e,level:r,expanded:c,onToggleExpand:n,selectedValues:o,onSelect:i,showCheck:l}),c&&e.children&&e.children.length>0&&t.jsx(jn,{nodes:e.children,level:r+1,expandedIds:s,onToggleExpand:n,selectedValues:o,onSelect:i,showCheck:l})]},e.value)})})}function Nn({multiple:e=!1,options:r,value:s,onChange:n,placeholder:o,label:i,icon:l,emptyMessage:d,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:x,className:f,maxDisplayedBadges:g,popoverContainer:b,onOpen:v,onClose:w,defaultExpanded:j=!0,showCheck:N=!1}){const{t:_}=y.useTranslation(),[C,k]=a.useState(!1),[S,A]=a.useState(""),[T,D]=a.useState(()=>j?function(e){const t=new Set;return function e(a){for(const r of a)r.children&&r.children.length>0&&(t.add(r.value),e(r.children))}(e),t}(r):new Set),E=o||_("select_placeholder","Selecione..."),P=d||_("no_results",_("no_results")),I=u||_("search_placeholder","Pesquisar..."),M=a.useMemo(()=>s?Array.isArray(s)?s:[s]:[],[s]),R=a.useMemo(()=>{if(!b)return;let e=b,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),r=a.overflowY||a.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[b]),L=a.useMemo(()=>vn(r,S),[r,S])??r,F=a.useMemo(()=>S?function(e,t){const a=new Set,r=bn(t);function s(e){if(!e.children||0===e.children.length)return bn(e.label).includes(r);let t=!1;for(const a of e.children)s(a)&&(t=!0);return t&&a.add(e.value),t||bn(e.label).includes(r)}for(const n of e)s(n);return a}(r,S):new Set,[r,S]),z=S?F:T,U=a.useCallback(e=>{S||D(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[S]),O=a.useMemo(()=>M.map(e=>({value:e,label:yn(r,e)||e})),[M,r]),B=e=>{k(e),e?v?.():(A(""),w?.())},q=a.useCallback(t=>{if(n)if(e){const e=M.includes(t)?M.filter(e=>e!==t):[...M,t];n(e)}else n(t),k(!1)},[n,e,M]),V=(t,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(e?M.filter(e=>e!==t):"")},$=g?O.slice(0,g):O,W=g&&O.length>g?O.length-g:0;if(h)return t.jsxs("div",{className:_r("space-y-2",f),children:[i&&t.jsxs(Er,{children:[i,p&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(hn,{className:"h-10 w-full"})]});const H="string"==typeof x?x:x instanceof Error?x.message:x?_("error_loading",_("error_loading")):void 0;return H?t.jsxs("div",{className:_r("space-y-2",f),children:[i&&t.jsxs(Er,{children:[i,p&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[t.jsx(c.AlertCircle,{className:"h-4 w-4"}),t.jsx("span",{className:"text-sm",children:H})]})]}):t.jsxs("div",{className:_r("space-y-2",f),children:[i&&t.jsxs(Er,{children:[i,p&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs(an,{open:C,onOpenChange:B,modal:!1,children:[t.jsx(rn,{asChild:!0,children:e?t.jsxs("div",{role:"combobox","aria-expanded":C,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),B(!C))},className:_r("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===O.length&&"text-muted-foreground"),children:[0===O.length?t.jsxs("span",{className:"flex items-center gap-2",children:[l&&t.jsx(l,{className:"h-4 w-4"}),E]}):t.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[$.map(e=>t.jsxs(Es,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,t.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:t=>{"Enter"===t.key&&V(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>V(e.value,t),children:t.jsx(c.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),W>0&&t.jsxs(Es,{variant:"outline",className:"gap-1",children:["+",W]})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):t.jsxs(Sr,{variant:"outline",role:"combobox","aria-expanded":C,disabled:m,className:_r("w-full justify-between min-h-10 h-auto font-normal",0===O.length&&"text-muted-foreground"),children:[0===O.length?t.jsxs("span",{className:"flex items-center gap-2",children:[l&&t.jsx(l,{className:"h-4 w-4"}),E]}):t.jsxs("span",{className:"flex items-center gap-2",children:[l&&t.jsx(l,{className:"h-4 w-4"}),O[0]?.label]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),t.jsxs(sn,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:R,collisionBoundary:R,children:[t.jsxs("div",{className:"flex items-center border-b px-3",children:[t.jsx(c.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),t.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:I,value:S,onChange:e=>A(e.target.value)}),S&&t.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>A(""),children:t.jsx(c.X,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"max-h-[300px] overflow-y-auto overflow-x-hidden",children:t.jsx("div",{role:"tree",className:"p-1",children:0===L.length?t.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===r.length?P:_("no_search_results",_("no_results"))}):t.jsx(jn,{nodes:L,level:0,expandedIds:z,onToggleExpand:U,selectedValues:M,onSelect:q,showCheck:N})})})]})]})]})}const _n=void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:Z&&"SCRIPT"===Z.tagName.toUpperCase()&&Z.src||new URL("index.js",document.baseURI).href}&&!1,Cn=new Map;function kn(e,t=1/0){if(!_n)return 0;const a=(Cn.get(e)??0)+1;return Cn.set(e,a),a}function Sn(e){if(_n)try{performance.mark(`auth:${e}`)}catch{}}async function An(e,t){if(!_n)return t();const a=performance.now();try{return await t()}finally{performance.now()}}function Tn(e){if(!_n)return;if(0===Cn.size)return;const t={};for(const[a,r]of Cn.entries())t[a]=r}let Dn=null;function En(e,t,a){if(!_n||!t)return;if(a&&"object"==typeof a)for(const r in a)/^co\d+$/.test(r)&&0}const Pn=()=>_n;var In=Object.defineProperty;const Mn=class e{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(t){if(Pn()){return kn(`parseJwtPayload:${t.length}:${t.slice(-8)}`,4),kn("parseJwtPayload:total"),function(e,t){if(!_n)return t();performance.now();try{return t()}finally{performance.now()}}(t.length,()=>e._parseJwtPayloadImpl(t))}return e._parseJwtPayloadImpl(t)}static _parseJwtPayloadImpl(e){try{const s=e.split(".");if(3!==s.length)return null;const n=s[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let s=0;s<t.length;s++)a[s]=t.charCodeAt(s);const r=new TextDecoder("utf-8").decode(a);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(s){return null}}static validateTokens(e,t){const a=[],r=[];try{t.split(".")[1],e.split(".")[1];const s=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!s){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(s.exp&&s.exp<i){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:r}}catch(s){const e=`Erro na validação de tokens: ${s}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}};((e,t,a)=>{t in e?In(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(Mn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);let Rn=Mn;const Ln="qualiex_access_token",Fn="qualiex_id_token",zn="supabase_token",Un="oauth_state",On="oauth_nonce",Bn="selected_alias",qn="manual_logout",Vn="supabase_project_id",$n={setAccessToken:e=>localStorage.setItem(Ln,e),getAccessToken:()=>localStorage.getItem(Ln),setIdToken:e=>localStorage.setItem(Fn,e),getIdToken:()=>localStorage.getItem(Fn),getSupabaseToken:()=>localStorage.getItem(zn),setOAuthState:e=>sessionStorage.setItem(Un,e),getOAuthState:()=>sessionStorage.getItem(Un),clearOAuthState:()=>sessionStorage.removeItem(Un),setOAuthNonce:e=>sessionStorage.setItem(On,e),getOAuthNonce:()=>sessionStorage.getItem(On),clearOAuthNonce:()=>sessionStorage.removeItem(On),setSelectedAlias:e=>localStorage.setItem(Bn,e),getSelectedAlias:()=>localStorage.getItem(Bn),clearSelectedAlias:()=>localStorage.removeItem(Bn),generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!$n.getAccessToken()||!$n.getIdToken()),checkProjectMismatch:()=>{const e=Ie().supabaseProjectId;if(!e)return!1;const t=localStorage.getItem(Vn);return t&&t!==e?($n.clearAll(),localStorage.setItem(Vn,e),!0):(t||localStorage.setItem(Vn,e),!1)},setSupabaseToken:e=>{localStorage.setItem(zn,e),$n._clearValidationCache()},areAllTokensValid:()=>{const e=$n.getAccessToken(),t=$n.getIdToken();if(!e||!t)return!1;try{const a=Rn.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=$n.getAccessToken(),a=$n.getIdToken(),r=$n.getSupabaseToken();return t&&$n.isTokenExpired(t)&&(localStorage.removeItem(Ln),e=!0),a&&$n.isTokenExpired(a)&&(localStorage.removeItem(Fn),e=!0),r&&$n.isTokenExpired(r)&&(localStorage.removeItem(zn),e=!0),e},clearAll:()=>{localStorage.removeItem(Ln),localStorage.removeItem(Fn),localStorage.removeItem(zn),localStorage.removeItem(Bn),sessionStorage.removeItem(Un),sessionStorage.removeItem(On),$n._clearValidationCache()},setManualLogout:()=>localStorage.setItem(qn,"true"),isManualLogout:()=>"true"===localStorage.getItem(qn),clearManualLogout:()=>localStorage.removeItem(qn),isTokenExpired:e=>{try{return Rn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{$n._validationCache.isValid=!1,$n._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=$n.getSupabaseToken();if(!e)return!1;if($n.isTokenExpired(e))return $n._clearValidationCache(),$n._handleExpiredToken(),!1;const t=Date.now();return t-$n._validationCache.timestamp<$n._validationCache.cacheValidityMs?$n._validationCache.isValid:($n._validationCache.isValid=!0,$n._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>$n.isSupabaseTokenValid()?$n.getSupabaseToken():null,_handleExpiredToken:()=>{$n.clearAll()},extractTokenData:()=>{if(kn("TokenManager.extractTokenData"),!$n.isSupabaseTokenValid())return null;const e=$n.getSupabaseToken();if(!e)return null;try{const t=Rn.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,r=t.place_id||null,s=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:r,placeName:s,payload:t}}catch(t){return $n._handleExpiredToken(),null}},getCompanyId:e=>{kn("TokenManager.getCompanyId");const t=$n.getAccessToken();if(t)try{const a=Rn.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=a[t];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}const a=$n.extractTokenData();if(a?.companyId)return a.companyId;const r=$n.getIdToken();if(r)try{const t=Rn.parseJwtPayload(r);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}return null},getAppGroupId:(e,t)=>{kn("TokenManager.getAppGroupId");const a=$n.getAccessToken();if(!a)return null;try{const r=Rn.parseJwtPayload(a);if(!r)return null;for(const a in r)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=r[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>5&&a[0]===e){if(t?.includes(a[5]))continue;const e=Number(a[5]);return Number.isNaN(e)?null:e}if(!e&&a.length>5){if(t?.includes(a[5]))continue;const e=Number(a[5]);return Number.isNaN(e)?null:e}}}}catch{}return null},getCompanyIdInt:e=>{kn("TokenManager.getCompanyIdInt");const t=[$n.getAccessToken(),$n.getIdToken()];for(const a of t)if(a)try{const t=Rn.parseJwtPayload(a);if(!t)continue;for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>1&&t[0]===e)return t[1];if(!e&&t.length>1)return t[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=$n.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{kn("TokenManager.getAllCompaniesData");const e=$n.getIdToken();if(!e)return[];try{const t=Rn.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};var Wn=Object.defineProperty,Hn=(e,t,a)=>((e,t,a)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Gn=new class{constructor(){Hn(this,"errors",[]),Hn(this,"toastCount",0),Hn(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message,r=Nr(a);if(this.errors.push({id:vr("short"),message:a,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),t&&this.shouldShowToast()){const e=this.getErrorTitle(r);l.toast.error(e,{description:r})}}getErrorTitle(t){const a=t.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?e.t("error_session_expired"):a.includes("token")||a.includes("autenticação")?e.t("error_authentication"):a.includes("api")||a.includes("network")?e.t("error_connection"):"Erro"}success(e,t){l.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};["[forlogic-core] ⚠️ VITE_SUPABASE_PUBLISHABLE_KEY contém uma legacy anon key (JWT).","O Supabase desativou legacy API keys. Substitua pela nova publishable key (formato sb_publishable_*).","Todas as requests retornarão 401 Unauthorized.","Causa provável: a integração Supabase do Lovable sobrescreveu o .env com a anon key legada.","Solução: defina VITE_SUPABASE_PK_OVERRIDE no .env com a publishable key correta."].join(" ");function Kn(e){return!!e&&e.startsWith("eyJ")}let Yn=!1;var Qn=Object.defineProperty,Xn=(e,t,a)=>((e,t,a)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);function Jn(){if(Me()){const e=Ie();return{url:e.supabaseUrl,key:e.supabasePublishableKey}}const e=(void 0).VITE_SUPABASE_URL,t=(void 0).VITE_SUPABASE_PK_OVERRIDE||((void 0).VITE_SUPABASE_PUBLISHABLE_KEY??"");return e&&t?{url:e,key:t}:null}const Zn=class e{constructor(e){Xn(this,"client"),Xn(this,"currentToken",null),Xn(this,"config"),this.config=e,function(){const e=(void 0).VITE_SUPABASE_PK_OVERRIDE,t=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;Yn?Kn(t):e&&Kn(t)?Yn=!0:Kn(t)?Yn=!0:Yn=!0}(),this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:this.config.key};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return w.createClient(this.config.url,this.config.key,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>{const a="string"==typeof e?e:e.url;if(a.includes("/auth/v1/user"))return new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}});if(a.includes("apikey="))try{const e=new URL(a,"https://placeholder.local");if(e.searchParams.has("apikey")){e.searchParams.delete("apikey");const r=a.startsWith("http")?e.toString():e.pathname+e.search+e.hash,s={...t,headers:{...t?.headers,apikey:this.config.key}};return fetch(r,s)}}catch{}return fetch(e,t)}}})}static getInstance(){if(!e.instance){const t=Jn();if(!t)throw new Error("[forlogic-core] Supabase não configurado. Defina VITE_SUPABASE_URL e VITE_SUPABASE_PUBLISHABLE_KEY no .env, ou não invoque getSupabaseClient() (use isSupabaseConfigured() para checar antes).");e.instance=new e(t)}return e.instance}getClient(){const e=$n.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Rn.isTokenExpired(e)}catch(t){return Gn.handleError(t instanceof Error?t:"Supabase - Error validating token",!1),!1}}};Xn(Zn,"instance");let eo=Zn;function to(){return eo.getInstance().getClient()}class ao{static async generateToken(e,t,a,r=!1){try{if(!r){const e=$n.getSupabaseToken();if(e&&$n.isSupabaseTokenValid())return e}const s=to();kn("SupabaseTokenService.generateToken:invoke");const{data:n,error:o}=await An(0,()=>s.functions.invoke("validate-token",{body:{access_token:e,alias:t}}));return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token?($n.setSupabaseToken(n.access_token),n.access_token):null}catch(s){return s instanceof Error&&(s.message.includes("401")||s.message.includes("Unauthorized"))&&a?.(),null}}}var ro=Object.defineProperty,so=(e,t,a)=>((e,t,a)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class no{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(e=!1){if(this.regenerationPromise)return this.regenerationPromise;this.regenerationPromise=this._doRegenerate(e);try{return await this.regenerationPromise}finally{this.regenerationPromise=null}}static async _doRegenerate(e=!1){try{const t=$n.getAccessToken(),a=$n.getSelectedAlias();if(!t||!a)return null;const r=await ao.generateToken(t,a,this.onLogoutCallback||void 0,e);return r||null}catch(t){return null}}}so(no,"regenerationPromise",null),so(no,"onLogoutCallback",null);class oo{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&($n.clearAll(),window.location.href=Ue("/login"),!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var io=Object.defineProperty;class lo{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){if(!Fe())return $n.areAllTokensValid()||oo.handleError(e),!1;this.isRetrying=!0;try{return await no.attemptRegeneration()?(this.isRetrying=!1,!0):(oo.handleError(e),this.isRetrying=!1,!1)}catch(r){return oo.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=$n.getAccessToken();return e?$n.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,a)=>{((e,t,a)=>{t in e?io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(lo,"isRetrying",!1);const co=new class{get baseUrl(){return Ge()}async makeApiCall(e,t,a,r){const s=lo.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const n=$n.getAccessToken();if(!n)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const o=r?new URL(r.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)):new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{o.searchParams.append(e,t)});const i=await fetch(o.toString(),{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}async fetchHasCommonV5(e,t){const a=await this.makeApiCall(`/api/common/v1/companies/hasCommonV5/${encodeURIComponent(t)}`,{},e),r=a?.data??a,s=Array.isArray(r)?r[0]:r;return Boolean(s?.hasCommonV5)}mapToQualiexUser(e){let t;return t="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:t}}parseUsersResponse(e,t=""){let a=e;if(e.data)a=e.data;else{if(!Array.isArray(e))return Gn.handleError(`[QualiexApi] Formato de resposta inesperado${t}`,!1),null;a=e}return Array.isArray(a)?a.map(e=>this.mapToQualiexUser(e)):(Gn.handleError(`[QualiexApi] Resposta não é um array${t}`,!1),null)}async fetchUsers(e,t,a="active"){const r={companyId:t,search:"",filterStatus:a};try{const t=await this.makeApiCall("/api/common/v1/companiesusers",r,e);return this.parseUsersResponse(t)??[]}catch(s){if(await lo.handleApiError(s))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",r,e);return this.parseUsersResponse(t," após retry")??[]}catch(n){return Gn.handleError(n instanceof Error?n:"Erro ao buscar usuários após renovação de token",!0),[]}return Gn.handleError(s instanceof Error?s.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(r){return Gn.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t,"active"),r=new Map;return a.forEach(e=>r.set(e.userId,e)),r}async fetchAllUsersMap(e,t){const a=await this.fetchUsers(e,t,"all"),r=new Map;return a.forEach(e=>r.set(e.userId,e)),r}async getUsers(e,t="active"){const a=$n.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId,t):[]}async fetchSoftwares(e){try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(Gn.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(t){if(await lo.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(a){return Gn.handleError(a instanceof Error?a:"Erro ao buscar softwares após renovação de token",!0),[]}return Gn.handleError(t instanceof Error?t.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,t,a){const r=!!a?.baseUrl,s=r?`/Users/${e}/associations`:`/api/common/v1/Users/${e}/associations`,n=r?a.baseUrl:void 0,o=e=>e.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}));try{const e=await this.makeApiCall(s,{},t,n),a=e?.data||e;return Array.isArray(a)?o(a):(Gn.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(i){if(await lo.handleApiError(i))try{const e=await this.makeApiCall(s,{},t,n),a=e?.data||e;return Array.isArray(a)?o(a):[]}catch(l){return Gn.handleError(l instanceof Error?l:"Erro ao buscar associações após renovação de token",!0),[]}return Gn.handleError(i instanceof Error?i.message:"Erro ao buscar associações do usuário",!0),[]}}};function uo(e,t){const a=t||Ze.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function mo(e,t){const a=t||Ze.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function po(e,t){const a=t||Ze.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function ho(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||uo(e.idField),emailField:e.emailField||mo(e.idField),usernameField:e.usernameField||po(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:uo(e),emailField:mo(e),usernameField:po(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const xo=new Map;class fo{static async fetchQualiexUsers(e,t){const a=`${t}_${e}_all`,r=xo.get(a);if(r&&Date.now()-r.timestamp<3e5)return r.users;let s=await co.fetchUsers(e,t,"all");return 0===s.length&&(s=await co.fetchUsers(e,t,"active")),xo.set(a,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,t){const a=new Set;for(const r of e)for(const e of t){const t=r[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const r={...e};for(const s of t){const t=e[s.idField];if(!t)continue;const n=a.get(t);if(n){if(s.nameField){r[s.nameField]||(r[s.nameField]=n.userName||null)}if(s.emailField){r[s.emailField]||(r[s.emailField]=n.userEmail||null)}if(s.usernameField){r[s.usernameField]||(r[s.usernameField]=n.userName||null)}}}return r}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!$n.areAllTokensValid())return e;const a=$n.extractTokenData();if(!a)return e;const{alias:r,companyId:s}=a;if(!r||!s)return e;const n=ho(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(r,s),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return Gn.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}}const go=["responsible_name"],bo=e=>go.includes(e);function vo(e,t,a){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:s,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=r,d=()=>{if(!$n.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return to().schema(i).from(s)},u=(e,t,a,r)=>{let s=d().select(o||"*",{count:"exact"});s=s.eq("is_removed",!1),Object.entries(r).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?s=s.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?s=s.not(e,"is",null):"is_null"===t.operator&&(s=s.is(e,null)):null!==t&&(s=s.eq(e,t)))}),s=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(s,e);const i=t.includes(".");return i||bo(t)||(s=s.order(t,{ascending:"asc"===a})),{query:s,isForeignKey:i}},m=async(e,t,a,s,n)=>{const o=ho(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(bo(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await p.getAll(e);if(!o?.data?.length)return o;const c=await fo.enrichWithUserData(o.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let d;d=i?c.sort((e,r)=>{const s=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],r)||"",o=String(s).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,r)=>{const s=e[t]||"",n=r[t]||"",o=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(c,t,a);const u=((e,t=1,a=25)=>{const r=(t-1)*a,s=r+a;return{data:e.slice(r,s),pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:e.length,itemsPerPage:a,hasNextPage:s<e.length,hasPreviousPage:t>1}}})(d,s,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 fo.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})},p={async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:d}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:r,page:s,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,d),h=((e,t,a)=>{const r=(t-1)*a,s=r+a-1;return e.range(r,s)})(p,o,i),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${s}: ${f.message}`);let b=((e,t,a,r)=>{const s=Math.ceil((t||0)/r);return{data:e,currentPage:a,totalPages:s,totalItems:t||0,itemsPerPage:r,hasNextPage:a<s,hasPreviousPage:a>1}})(x||[],g,o,i);if((e=>{if(!c||!l||0===e.length)return!1;const t=ho(r.userIdFields,r.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await d().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${s}: ${a.message}`);return t},async create(e){const t=Cr(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:r,error:n}=await d().insert(a).select().single();if(n)throw new Error(`Error creating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from create ${s} operation`);return r},async update(e,t){const a={...Cr(t),updated_at:(new Date).toISOString()},{data:r,error:n}=await d().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from update ${s} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await d().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${s}: ${a.message}`)}};return p}const yo={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null},wo=class{static async initialize(){try{const e=Fe();if(e){if($n.checkProjectMismatch())return{...yo}}if(!$n.hasAllTokens()||!$n.areAllTokensValid())return $n.clearExpiredTokens(),{...yo};const t=$n.getAccessToken(),a=$n.getIdToken();$n.clearManualLogout();const r=this.extractUserFromIdToken(a,t),s=this.extractCompaniesFromIdToken(a),n=e?$n.extractTokenData():null,o=this.resolveAliasFromContext(s,t,n?.alias??null);if(e&&(!$n.isSupabaseTokenValid()&&o&&await no.attemptRegeneration(),!$n.isSupabaseTokenValid()))return{...yo};let i=null;if(o){const e=$n.getCompanyId(o),t=s.find(e=>e.alias===o);t&&(i={id:e||t.id,name:t.name,alias:t.alias,appGroupId:$n.getAppGroupId(t.alias)})}const l=n?.placeId??null,c=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:r,alias:o,companies:s,selectedUnit:i,userId:r?.id||null,userAlias:r?.id||null,placeId:l,placeName:c,activePlaceId:l,activePlaceName:c}}catch(e){return{...yo}}}static async loginDev(){if(!Fe())return this.loginProd(),!0;try{const e=to(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL(Ue("/callback"));return r.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e="Lw==";$n.setOAuthState(e);const t=$n.generateOAuthNonce();$n.setOAuthNonce(t);const a=Ue("/callback"),r=new URL(ze.oauth.authUrl);r.searchParams.set("client_id",ze.oauth.clientId),r.searchParams.set("response_type",ze.oauth.responseType),r.searchParams.set("scope",ze.oauth.scope),r.searchParams.set("redirect_uri",a),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),window.location.href=r.toString()}static async processCallback(){try{const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),r=a("access_token"),s=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(r&&s){const e=$n.getAccessToken();e!==r&&$n.clearAll()}const o=Fe();if($n.hasAllTokens()&&$n.areAllTokensValid()){if(o){$n.getValidSupabaseToken()||await no.attemptRegeneration(!0)}return!0}$n.hasAllTokens()&&$n.clearExpiredTokens();const i=r,l=s;if(!i||!l)throw new Error("Tokens não encontrados na URL de callback");$n.setAccessToken(i),$n.setIdToken(l),$n.clearManualLogout();const c=this.extractCompaniesFromIdToken(l),d=this.resolveAliasFromContext(c,i,null);if(!d)throw new Error("Nenhuma empresa encontrada nos tokens");if($n.setSelectedAlias(d),o){if(!await no.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase")}return $n.clearOAuthState(),$n.clearOAuthNonce(),!0}catch(e){throw e}}static async logout(){$n.clearAll(),$n.setManualLogout(),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{}try{const e=Ue("/callback"),t=new URL(ze.oauth.logoutUrl);return t.searchParams.set("client_id",ze.oauth.clientId),t.searchParams.set("redirect_uri",e),t.searchParams.set("response_type",ze.oauth.responseType),t.searchParams.set("scope",ze.oauth.scope),t.searchParams.set("state","Lw=="),void(window.location.href=t.toString())}catch{}window.location.href=Ue("/login")}static decodeToken(e){return Rn.parseJwtPayload(e)}static extractUserFromIdToken(e,t){const a=this.decodeToken(e);if(!a)return null;const r=t?this.decodeToken(t):null;return{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier,isSysAdmin:"1"===r?.admin}}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)a.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,s]=t[e].split("|");r&&s&&a.push({id:"",alias:r.trim(),name:s.trim()})}}});const r=new Map;for(const n of a){if(!n.alias)continue;const e=r.get(n.alias);(!e||!e.id&&n.id)&&r.set(n.alias,n)}const s=Array.from(r.values());a.length,s.length;return s.length,s}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}static getSubdomainAlias(){if("undefined"==typeof window)return null;const e=window.location.hostname;if("localhost"===e||e.startsWith("127.")||e.endsWith(".lovable.app")||e.endsWith(".lovable.dev"))return null;const t=e.split(".");if(t.length<3)return null;const a=t[0];return"www"===a||"admin"===a?null:t.length>=4?t[1]:a}static resolveAliasFromContext(e,t,a){const r=t=>!!t&&e.some(e=>e.alias===t),s=this.getSubdomainAlias();if(r(s))return s;if("undefined"!=typeof window){const e=window.location.hostname.split(".");if(e.length>=4&&r(e[0]))return e[0]}if(r(a))return a;const n=$n.getSelectedAlias();if(r(n))return n;const o=this.extractAliasFromAccessToken(t);return r(o)?o:e[0]?.alias||null}};no.setLogoutCallback(()=>{wo.logout()});let jo=wo;const No=e=>e?.placeId||null,_o=e=>e?.placeName||null,Co=a.createContext(void 0),ko=({children:e,moduleAlias:r})=>{const[s,n]=a.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let o=null;try{o=j.useQueryClient()}catch{}const[i,l]=a.useState(!1),c=a.useRef(0),d=a.useCallback(e=>{n(t=>({...t,...e}))},[]),u=a.useCallback(e=>{n(t=>({...t,isLoading:e}))},[]),m=a.useCallback(()=>{n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=a.useCallback(async e=>{if(e.alias===s.alias)return;const t=++c.current;try{const n=$n.getAccessToken();if(!n)return;const i=$n.getSupabaseToken(),l=s.alias,u=Fe();let m=null;if(u){const a=await ao.generateToken(n,e.alias,void 0,!0);if(c.current!==t)return;if(!a)return;$n.setSupabaseToken(a),m=$n.extractTokenData()}$n.setSelectedAlias(e.alias);const p=m?.alias||e.alias,h=m?.companyId||$n.getCompanyId(e.alias);if(h&&"common"===r)try{const e=await co.fetchHasCommonV5(p,h);if(c.current!==t)return;if(!e){const e=Xe();if(e){i&&$n.setSupabaseToken(i),l&&$n.setSelectedAlias(l);const t=e.endsWith("/")?e:`${e}/`;return void(window.location.href=`${t}${p}`)}}}catch(a){}const x={id:h||e.id,name:e.name,alias:p,appGroupId:$n.getAppGroupId(p)};let f=null,g=null;if(s.user?.id&&p&&h)try{const e=await co.fetchActiveUsersMap(p,h);if(c.current!==t)return;const a=e.get(s.user.id);if(a){const e=(e=>({placeId:No(e),placeName:_o(e)}))(a);f=e.placeId,g=e.placeName}}catch(a){}if(c.current!==t)return;d({alias:p,selectedUnit:x,placeId:f,placeName:g,activePlaceId:f,activePlaceName:g}),o&&await o.clear()}catch(a){}},[d,o,s.user,s.alias,r]),h=a.useCallback(async()=>{kn("AuthContext.processCallback");const e=await An(0,()=>jo.processCallback());if(e){const e=await An(0,()=>jo.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}),o&&o.invalidateQueries({queryKey:["permission"]}))}return e},[d,o]),x=a.useCallback(async()=>{await jo.logout(),m(),o&&await o.clear()},[m,o]),f=a.useCallback(e=>{l(e)},[]),g=a.useCallback(()=>{},[]),b=a.useCallback(()=>{o&&o.invalidateQueries()},[o]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(async()=>{if(e)if($n.areAllTokensValid()){if(Fe()&&!$n.isSupabaseTokenValid())try{await no.attemptRegeneration()||e&&x()}catch(t){e&&x()}}else e&&x()},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await jo.initialize();if(!e)return;t&&t.isAuthenticated?d({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&u(!1)}catch(t){e&&(oo.handleError(t),u(!1))}})(),()=>{e=!1}},[d,u,x]);const v=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,x,h,p,i,f,g,b]);return t.jsx(Co.Provider,{value:v,children:e})},So=()=>{const e=a.useContext(Co);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Ao({queryKey:e,service:t,entityName:r,searchFields:s,additionalFilters:n={},onSuccess:o}){const[i,c]=N.useSearchParams(),d=j.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=So(),{t:h}=y.useTranslation(),x=a.useCallback(t=>{const a=`${e}_${t}`,r=i.get(a);return r||(i.get(t)||"")},[i,e]),f=x("search"),g=x("sortField")||qe.sorting.defaultField,b=x("sortDirection")||qe.sorting.defaultDirection,v=parseInt(x("page")||"1"),w=parseInt(x("limit")||String(qe.pagination.defaultPageSize)),_=f,C=a.useMemo(()=>({search:_,sortField:g,sortDirection:b,page:v,limit:w,...n}),[_,g,b,v,w,n]),k=a.useCallback(()=>t.getAll(C),[t,C]),S=j.useQuery({queryKey:[e,u,m,C],queryFn:k,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${r}". Ensure QueryClientProvider is configured in your app root.`);const A=j.useMutation({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(tt.success.created(r)),o?.()},onError:e=>{l.toast.error(`${tt.error.create(r)}: ${e.message}`)}}),T=j.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(tt.success.updated(r)),o?.()},onError:e=>{l.toast.error(`${tt.error.update(r)}: ${e.message}`)}}),D=j.useMutation({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(tt.success.deleted(r))},onError:e=>{l.toast.error(`${tt.error.delete(r)}: ${e.message}`)}}),E=a.useCallback(t=>{const a={...Object.fromEntries(i)};Object.entries(t).forEach(([t,r])=>{const s=`${e}_${t}`;""===r||0===r?delete a[s]:a[s]=String(r)}),delete a.sortField,delete a.sortDirection,c(a)},[i,c,e]),P=a.useCallback(e=>{E({search:e,page:1})},[E]),I=a.useCallback(e=>{E({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,E]),M=a.useCallback(e=>{E({page:e})},[E]),R=a.useCallback(e=>{E({limit:e,page:1})},[E]),L=a.useCallback(()=>{const t=Object.fromEntries(i),a=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));c(r)},[c,i,e]),[F,z]=a.useState([]),U=a.useCallback(e=>{z(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),O=a.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];z(t=>t.length===e.length?[]:e)},[S?.data?.data]),B=a.useCallback(()=>{z([])},[]),q=a.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&F.length===e.length},[F,S?.data?.data]),V=j.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,a)=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(h("bulk_delete_success",`${a.length} ${r}(s) deletado(s) com sucesso`)),B()},onError:e=>{l.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),$=a.useCallback((e,t)=>{const a=t?t(e):e;e.id?T.mutate({id:e.id,data:a}):A.mutate({...a,alias:u})},[u,A,T]);return{entities: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||qe.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:A?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:D?.isPending??!1,error:S?.error||null,searchTerm:f,sortField:g,sortDirection:b,currentPage:v,itemsPerPage:w,queryKey:e,createEntity:A.mutate,updateEntity:(e,t)=>T.mutate({id:e,data:t}),deleteEntity:D.mutate,save:$,handleSearch:P,handleSort:I,handlePageChange:M,handleItemsPerPageChange:R,clearFilters:L,refetch:S.refetch,selectedIds:F,selectItem:U,selectAll:O,clearSelection:B,isAllSelected:q,bulkDelete:e=>V.mutateAsync(e),isBulkDeleting:V.isPending}}function To(e){const[t,r]=a.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return a.useEffect(()=>{const t=window.matchMedia(e);r(t.matches);const a=e=>{r(e.matches)};return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),t}function Do(e=768){return To(`(max-width: ${e-1}px)`)}const Eo=te.forwardRef(({className:e,...a},r)=>t.jsx("table",{ref:r,className:_r("w-full caption-bottom text-[13px] table-fixed",e),...a}));Eo.displayName="Table";const Po=te.forwardRef(({className:e,...a},r)=>t.jsx("thead",{ref:r,className:_r("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...a}));Po.displayName="TableHeader";const Io=te.forwardRef(({className:e,...a},r)=>t.jsx("tbody",{ref:r,className:_r("[&_tr:last-child]:border-0",e),...a}));Io.displayName="TableBody";const Mo=te.forwardRef(({className:e,...a},r)=>t.jsx("tfoot",{ref:r,className:_r("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a}));Mo.displayName="TableFooter";const Ro=te.forwardRef(({className:e,...a},r)=>t.jsx("tr",{ref:r,className:_r("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",e),...a}));Ro.displayName="TableRow";const Lo=te.forwardRef(({className:e,...a},r)=>t.jsx("th",{ref:r,className:_r("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),...a}));Lo.displayName="TableHead";const Fo=te.forwardRef(({className:e,...a},r)=>t.jsx("td",{ref:r,className:_r("px-4 py-2 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",e),...a}));Fo.displayName="TableCell";const zo=te.forwardRef(({className:e,...a},r)=>t.jsx("caption",{ref:r,className:_r("mt-4 text-sm text-muted-foreground",e),...a}));function Uo({rows:e=5,columns:a=4}){return t.jsx("div",{className:"w-full",children:t.jsxs("div",{className:"rounded-md border",children:[t.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:t.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>t.jsx(hn,{className:"h-4 w-24"},a))})}),t.jsx("div",{children:Array.from({length:e}).map((e,r)=>t.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:t.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>t.jsx(hn,{className:"h-4 w-20"},a))})},r))})]})})}function Oo({count:e=3}){return t.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,a)=>t.jsxs(Pr,{children:[t.jsxs(Ir,{children:[t.jsx(hn,{className:"h-4 w-3/4"}),t.jsx(hn,{className:"h-3 w-1/2"})]}),t.jsx(Lr,{children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(hn,{className:"h-3 w-full"}),t.jsx(hn,{className:"h-3 w-2/3"})]})})]},a))})}zo.displayName="TableCaption";const Bo={default:c.FileX,search:c.Search,error:c.AlertCircle};function qo({icon:e,title:a,description:r,action:s,className:n,variant:o="default"}){const{t:i}=y.useTranslation(),l=!!e,c=Bo[o];return t.jsxs("div",{className:_r("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[t.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:l?e:t.jsx(c,{className:"h-8 w-8 text-muted-foreground"})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),r&&t.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:r}),s&&t.jsx(Sr,{onClick:s.onClick,variant:"outline",children:s.label})]})}function Vo({children:e,className:a}){const r=te.useRef(null),[s,n]=te.useState(!1);te.useEffect(()=>{const e=()=>{const e=r.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return r.current&&t.observe(r.current),()=>t.disconnect()},[e]);const o=t.jsx("div",{ref:r,className:`truncate w-full max-w-full ${a||""}`,children:e});return s?t.jsx(Xs,{delayDuration:300,children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:o}),t.jsx(en,{side:"top",className:"max-w-[400px] break-words",children:e})]})}):o}const $o=te.forwardRef(({direction:e,onMouseDown:a,isDragging:r,className:s},n)=>{const o="horizontal"===e;return t.jsx("div",{ref:n,onMouseDown:a,className:_r("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"],r&&"bg-primary/30",s),children:t.jsx("div",{className:_r("rounded-full bg-border transition-colors group-hover:bg-primary",r&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});$o.displayName="TableResizeHandle";const Wo=me.Root,Ho=me.Trigger,Go=me.Group,Ko=me.Portal,Yo=me.Sub,Qo=me.RadioGroup,Xo=te.forwardRef(({className:e,inset:a,children:r,...s},n)=>t.jsxs(me.SubTrigger,{ref:n,className:_r("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",e),...s,children:[r,t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Xo.displayName=me.SubTrigger.displayName;const Jo=te.forwardRef(({className:e,...a},r)=>t.jsx(me.SubContent,{ref:r,className:_r("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),...a}));Jo.displayName=me.SubContent.displayName;const Zo=te.forwardRef(({className:e,...a},r)=>t.jsx(me.Portal,{children:t.jsx(me.Content,{ref:r,className:_r("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),...a})}));Zo.displayName=me.Content.displayName;const ei=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(me.Item,{ref:s,className:_r("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",e),...r}));ei.displayName=me.Item.displayName;const ti=te.forwardRef(({className:e,children:a,checked:r,...s},n)=>t.jsxs(me.CheckboxItem,{ref:n,className:_r("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:r,...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(me.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),a]}));ti.displayName=me.CheckboxItem.displayName;const ai=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(me.RadioItem,{ref:s,className:_r("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),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(me.ItemIndicator,{children:t.jsx(c.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));ai.displayName=me.RadioItem.displayName;const ri=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(me.Label,{ref:s,className:_r("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",e),...r}));ri.displayName=me.Label.displayName;const si=te.forwardRef(({className:e,...a},r)=>t.jsx(me.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-border",e),...a}));si.displayName=me.Separator.displayName;const ni=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});ni.displayName="ContextMenuShortcut";const oi=({onEdit:e,onDelete:a,onToggleStatus:r,isActive:s=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:l}=y.useTranslation(),d=[];if(e){const t={icon:c.Edit,label:l("edit"),onClick:e};d.push(t)}if(o.forEach(e=>{d.push(e)}),r){const e={icon:s?c.PowerOff:c.Power,label:s?"Inativar":"Ativar",onClick:r};d.push(e)}if(n&&a){const e={icon:c.Trash2,label:l("ap_delete"),onClick:a,destructive:!0};d.push(e)}const u="dropdown"===i?Ws:ei;return t.jsx(t.Fragment,{children:d.map((e,a)=>t.jsxs(u,{onClick:e.onClick,className:_r("whitespace-normal cursor-pointer",e.destructive&&"text-destructive focus:text-destructive"),children:[t.jsx(e.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.label]},a))})},ii=({onEdit:e,onDelete:a,canDelete:r=!0,onToggleStatus:s,isActive:n=!0,customActions:o=[]})=>t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:t.jsx(c.EllipsisVertical,{size:12})})}),t.jsx($s,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:t.jsx(oi,{onEdit:e?t=>{t?.stopPropagation(),e?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:s?e=>{e?.stopPropagation(),s?.()}:void 0,isActive:n,canDelete:r&&!!a,customActions:o,renderAs:"dropdown"})})]}),li=({onEdit:e,onDelete:a,canDelete:r=!0,onToggleStatus:s,isActive:n=!0,customActions:o=[]})=>{const{t:i}=y.useTranslation();return t.jsx(Xs,{delayDuration:200,children:t.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t=>{t.stopPropagation(),e()},children:t.jsx(c.Pencil,{size:14})})}),t.jsx(en,{children:i("edit")})]}),o.map((e,a)=>{const r=e.icon;return t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t=>{t.stopPropagation(),e.onClick()},children:t.jsx(r,{size:14})})}),t.jsx(en,{children:e.label})]},a)}),s&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),s()},children:n?t.jsx(c.ToggleRight,{size:14}):t.jsx(c.ToggleLeft,{size:14})})}),t.jsx(en,{children:n?"Inativar":"Ativar"})]}),a&&r&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:_r("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),a()},children:t.jsx(c.Trash2,{size:14})})}),t.jsx(en,{children:i("ap_delete")})]})]})})},ci=150;function di({columns:e,storageKey:t,onResize:r,enabled:s=!0}){const[n,o]=a.useState(()=>{if(!s||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ci,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ci,e),{})}),[i,l]=a.useState(!1),[c,d]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,t)=>{s&&(t.preventDefault(),t.stopPropagation(),l(!0),d(e),u.current=t.clientX,m.current=n[e]??ci)},[s,n]);a.useEffect(()=>{if(!i||!c)return;const a=e.find(e=>e.key===c),s=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(s,Math.min(n,m.current+t));o(e=>{const t={...e,[c]:a};return r?.(t),t})},h=()=>{l(!1),d(null),t&&o(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,c,e,t,r]),a.useEffect(()=>(i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[i]);const h=a.useCallback(()=>{const a=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ci,e),{});o(a),t&&localStorage.removeItem(t),r?.(a)},[e,t,r]);return{columnWidths:n,isDragging:i,activeColumn:c,handleMouseDown:p,resetWidths:h}}const ui=s.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),mi=te.forwardRef(({className:e,variant:a,size:r,...s},n)=>t.jsx(he.Root,{ref:n,className:_r(ui({variant:a,size:r,className:e})),...s}));mi.displayName=he.Root.displayName;const pi=te.createContext({size:"default",variant:"default"}),hi=te.forwardRef(({className:e,variant:a,size:r,children:s,...n},o)=>t.jsx(pe.Root,{ref:o,className:_r("flex items-center justify-center gap-1",e),...n,children:t.jsx(pi.Provider,{value:{variant:a,size:r},children:s})}));hi.displayName=pe.Root.displayName;const xi=te.forwardRef(({className:e,children:a,variant:r,size:s,...n},o)=>{const i=te.useContext(pi);return t.jsx(pe.Item,{ref:o,className:_r(ui({variant:i.variant||r,size:i.size||s}),e),...n,children:a})});xi.displayName=pe.Item.displayName;const fi=a.memo(function({onNew:e,newButtonLabel:a,showNewButton:r=!0,showSearch:s=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:l=!1,selectedCount:d=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:x,viewMode:f,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],rightSlot:w,className:j}){const{t:N}=y.useTranslation(),_=d>0,C=e&&r||h.length>0,k=x||b||w,S=s&&o;return C||S||k||l&&_?t.jsxs("div",{className:_r("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",j),children:[t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e&&r&&t.jsxs(Sr,{onClick:e,children:[t.jsx(c.Plus,{size:16,className:"mr-2"}),a||"Novo"]}),h.map((e,a)=>{const r=e.icon;return t.jsxs(Sr,{onClick:e.action,variant:e.variant||"outline",disabled:e.disabled,title:e.disabled?e.disabledReason:void 0,children:[r&&t.jsx(r,{size:16,className:"mr-2"}),e.label]},a)})]}),l&&_&&t.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[t.jsx(Es,{variant:"secondary",className:"mr-1 tabular-nums",children:d}),t.jsxs(Xs,{delayDuration:200,children:[u.length>0?u.map((e,a)=>{const r=e.icon,s=e.disabled;return t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:_r("h-8 w-8","destructive"===e.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:s,onClick:()=>e.action([]),children:r?t.jsx(r,{size:16}):t.jsx("span",{className:"text-xs",children:e.label[0]})})}),t.jsx(en,{children:e.label})]},a)}):t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:t.jsx(c.Trash2,{size:16})})}),t.jsx(en,{children:N("ap_delete")})]}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:t.jsx(c.X,{size:16})})}),t.jsx(en,{children:N("clear_selection")})]})]})]}),S&&t.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:t.jsxs("div",{className:"relative w-full",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),k&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[x,b&&f&&g&&t.jsx(hi,{type:"single",value:f,onValueChange:e=>e&&g(e),size:"sm",children:v.map(e=>{const a=(e=>{switch(e){case"table":return c.Table2;case"list":return c.List;case"grid":return c.LayoutGrid}})(e);return t.jsx(xi,{value:e,"aria-label":"Visualizar como "+("table"===e?"tabela":"list"===e?"lista":"grade"),children:t.jsx(a,{className:"h-4 w-4"})},e)})}),w]})]}):null}),gi=a.memo(({checked:e,onCheckedChange:a})=>t.jsx(As,{checked:e,onCheckedChange:a}),(e,t)=>e.checked===t.checked);function bi(e){try{const t=localStorage.getItem(e);if(!t)return null;const a=JSON.parse(t);let r=a.groupByColumns||[];return 0===r.length&&a.groupByColumn&&(r=[a.groupByColumn]),{hiddenColumns:new Set(a.hiddenColumns||[]),columnOrder:a.columnOrder||[],groupByColumns:r}}catch{return null}}function vi({columns:e,storageKey:t,enabled:r=!0,defaultHiddenColumns:s}){const n=a.useMemo(()=>e.map(e=>String(e.key)),[e]),o=a.useMemo(()=>new Set(s??[]),[s]),[i,l]=a.useState(()=>{if(!r)return o;if(!t)return o;const e=bi(t);return e?.hiddenColumns??o}),[c,d]=a.useState(()=>{if(!r||!t)return n;const e=bi(t)?.columnOrder;return e&&e.length>0?e:n}),[u,m]=a.useState(()=>r&&t?bi(t)?.groupByColumns??[]:[]),[p,h]=a.useState(new Set);a.useEffect(()=>{r&&t&&function(e,t){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(t.hiddenColumns),columnOrder:t.columnOrder,groupByColumns:t.groupByColumns}))}catch{}}(t,{hiddenColumns:i,columnOrder:c,groupByColumns:u})},[i,c,u,t,r]),a.useEffect(()=>{const t=new Set(e.map(e=>String(e.key))),a=new Set(c),r=[...t].filter(e=>!a.has(e));if(r.length>0){d(e=>[...e.filter(e=>t.has(e)),...r]);const e=r.filter(e=>o.has(e));e.length>0&&l(t=>new Set([...t,...e]))}},[e,o]);const x=a.useCallback(e=>i.has(e),[i]),f=a.useCallback(e=>{l(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),g=a.useCallback(()=>{l(new Set)},[]),b=a.useCallback(()=>{if(l(o),d(n),m([]),h(new Set),t)try{localStorage.removeItem(t)}catch{}},[n,o,t]),v=a.useCallback((e,t)=>{d(a=>{const r=[...a],[s]=r.splice(e,1);return r.splice(t,0,s),r})},[]),y=a.useCallback(e=>{h(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),w=a.useCallback(e=>{m(e),h(new Set)},[]),j=a.useCallback(e=>{m(t=>t.includes(e)?t:[...t,e])},[]),N=a.useCallback(e=>{m(t=>t.filter(t=>t!==e)),h(t=>{const a=new Set;for(const r of t)r.includes(`${e}:`)||a.add(r);return a})},[]),_=a.useCallback((e,t)=>{m(a=>{const r=[...a],[s]=r.splice(e,1);return r.splice(t,0,s),r}),h(new Set)},[]),C=u[0]??null,k=a.useCallback(e=>{m(e?[e]:[]),h(new Set)},[]),S=a.useMemo(()=>{if(!r)return e;const t=new Map(e.map(e=>[String(e.key),e]));return c.filter(e=>!i.has(e)&&t.has(e)).map(e=>t.get(e))},[e,c,i,r]),A=a.useCallback(e=>{if(0===u.length)return[{groupKey:"__all__",groupValue:"",items:e,count:e.length,level:0}];return function e(t,a,r,s){if(0===a.length)return[{groupKey:s||"__leaf__",groupValue:"",items:t,count:t.length,level:r}];const[n,...o]=a,i=new Map;for(const l of t){const e=String(l[n]??"(vazio)");i.has(e)||i.set(e,[]),i.get(e).push(l)}return Array.from(i.entries()).map(([t,a])=>{const i=s?`${s}|${n}:${t}`:`${n}:${t}`,l=o.length>0?e(a,o,r+1,i):void 0;return{groupKey:i,groupValue:t,items:a,count:a.length,level:r,children:l}})}(e,u,0,"")},[u]);return{visibleColumns:S,allColumns:e,isColumnHidden:x,toggleColumn:f,showAllColumns:g,resetColumns:b,columnOrder:c,reorderColumns:v,groupByColumn:C,setGroupByColumn:k,groupByColumns:u,setGroupByColumns:w,addGroupByColumn:j,removeGroupByColumn:N,reorderGroupByColumns:_,getGroupedData:A,collapsedGroups:p,toggleGroupCollapse:y}}function yi({enabled:e=!1,onReorder:t}){const[r,s]=a.useState(null),[n,o]=a.useState(null),i=a.useCallback(()=>{s(null),o(null)},[]),l=a.useCallback((a,n)=>({draggable:e,onDragStart:t=>{e&&(s(a),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",String(a)),n&&t.dataTransfer.setData("application/column-key",n))},onDragOver:t=>{e&&null!==r&&(t.preventDefault(),t.dataTransfer.dropEffect="move")},onDragEnter:t=>{e&&null!==r&&(t.preventDefault(),o(a))},onDrop:s=>{s.preventDefault(),e&&null!==r&&r!==a?(t(r,a),i()):i()},onDragEnd:()=>{i()}}),[e,r,t,i]);return a.useMemo(()=>({dragFromIndex:r,dragOverIndex:n,isDragging:null!==r,getDragProps:l}),[r,n,l])}function wi({columns:e,columnOrder:r,isColumnHidden:s,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:l,setGroupByColumn:d,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p,resetColumns:h}){const{t:x}=y.useTranslation(),[f,g]=a.useState(null),[b,v]=a.useState(null),w=a.useRef(null),j=new Map(e.map(e=>[String(e.key),e])),N=r.filter(e=>j.has(e)).map(e=>j.get(e)),_=()=>{w.current=null,g(null),v(null)};N.some(e=>s(String(e.key)));const C=N.every(e=>!s(String(e.key)));return t.jsxs(an,{children:[t.jsx(rn,{asChild:!0,children:t.jsx(Sr,{variant:"outline",size:"icon",className:"h-8 w-8",children:t.jsx(c.Columns3,{size:16})})}),t.jsxs(sn,{className:"w-[260px] p-0",align:"end",children:[t.jsx("div",{className:"px-3 py-2 border-b",children:t.jsx("span",{className:"text-sm font-medium",children:x("columns")})}),t.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:t.jsx(Xs,{delayDuration:300,children:N.map((e,a)=>{const r=String(e.key),o=s(r),h=!1!==e.hideable,y=!0===e.groupable,j=u.includes(r)||l===r;return t.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{w.current=e,g(e)})(a),onDragOver:e=>((e,t)=>{e.preventDefault(),v(t)})(e,a),onDrop:()=>(e=>{null!==w.current&&w.current!==e&&i(w.current,e),w.current=null,g(null),v(null)})(a),onDragEnd:_,className:_r("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",f===a&&"opacity-50",b===a&&"border-t-2 border-primary"),children:[t.jsx(c.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx(As,{checked:!o,onCheckedChange:()=>h&&n(r),disabled:!h,className:"shrink-0"}),t.jsx("span",{className:_r("flex-1 truncate",o&&"text-muted-foreground"),children:e.header}),y&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:_r("h-6 w-6 shrink-0",j&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),j?p?p(r):d?.(null):m?m(r):d?.(r)},children:t.jsx(c.Group,{size:14})})}),t.jsx(en,{children:x(j?"remove_grouping":"group_by_column")})]})]},r)})})}),t.jsxs("div",{className:"border-t px-3 py-2 space-y-1",children:[t.jsx(Sr,{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&&t.jsx(Sr,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:h,children:x("reset_default")})]})]})]})}function ji({columns:e,groupByColumns:r,addGroupByColumn:s,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,l]=a.useState(!1),[d,u]=a.useState(null),[m,p]=a.useState(null),h=new Map(e.map(e=>[String(e.key),e])),x=()=>{u(null),p(null)},f=r.length>0;return t.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 t=e.dataTransfer.getData("application/column-key");if(t&&!r.includes(t)){const e=h.get(t);e&&e.groupable&&s(t)}},className:_r("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:[t.jsx(c.Group,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:f?r.map((e,r)=>{const s=h.get(e);if(!s)return null;const i=d===r,l=m===r&&d!==r;return t.jsxs(a.Fragment,{children:[r>0&&t.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),t.jsxs(Es,{variant:"secondary",className:_r("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",l&&"ring-2 ring-primary"),draggable:!0,onDragStart:e=>((e,t)=>{e.stopPropagation(),e.dataTransfer.setData("application/group-chip-index",String(t)),e.dataTransfer.effectAllowed="move",u(t)})(e,r),onDragOver:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),p(t)})(e,r),onDrop:e=>((e,t)=>{e.preventDefault(),e.stopPropagation();const a=e.dataTransfer.getData("application/group-chip-index");if(""!==a){const e=parseInt(a,10);isNaN(e)||e===t||o(e,t)}u(null),p(null)})(e,r),onDragEnd:x,children:[s.header,t.jsx("button",{onClick:t=>{t.stopPropagation(),n(e)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:t.jsx(c.X,{size:12})})]})]},e)}):t.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const Ni=({manager:r,columns:s,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:u,enableBulkActions:m=!1,rowActionsVariant:p="dropdown",onNew:h,newButtonLabel:x,showNewButton:f=!0,customActions:g=[],hideActionBar:b,showActionBar:v=!0,showSearch:w=!1,searchValue:j,onSearchChange:N,searchPlaceholder:_,bulkActions:C=[],onBulkDelete:k,filters:S,viewMode:A,onViewModeChange:T,showViewToggle:D=!1,enableColumnResize:E=!0,resizeStorageKey:P,enableColumnManager:I=!0,columnManagerStorageKey:M,defaultHiddenColumns:R,enableGrouping:L=!1,enableExpandableRows:F=!1,renderExpandedContent:z,expandedRowIds:U,onToggleExpand:O,defaultExpandAll:B=!1,hideActionsColumn:q=!1,readOnly:V=!1})=>{const{t:$}=y.useTranslation(),{setSearchVisible:W}=So(),H=Do(),[G,K]=a.useState(()=>B&&F?new Set(r.entities.map(e=>e.id)):new Set),Y=void 0!==U,Q=Y?new Set(U):G,X=a.useCallback(e=>{Y&&O?O(e):K(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[Y,O]),J=void 0!==b?!b:v;a.useEffect(()=>{if(!w)return W(!0),()=>W(!1)},[W,w]);const Z=vi({columns:s,storageKey:M,enabled:I,defaultHiddenColumns:R}),ee=yi({enabled:I,onReorder:Z.reorderColumns}),te=I?Z.visibleColumns:s,{columnWidths:ae,isDragging:re,activeColumn:se,handleMouseDown:ne}=di({columns:te.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:P?`${P}-columns`:void 0,enabled:E}),oe=a.useMemo(()=>(()=>{if(E){const e=te.map(e=>ae[String(e.key)]??e.width??e.minWidth??150),t=e.reduce((e,t)=>e+t,0);return te.map((a,r)=>({...a,calculatedWidth:e[r],style:{width:e[r]/t*100+"%"}}))}let e=0;const t=te.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,r=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:r,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[te,E,ae]),ie=h||g.length>0||w||m||S||D||I,le=J&&ie,ce=q||V,de=k||(()=>{r.bulkDelete?.(r.selectedIds)}),ue=e=>t.jsx(Fo,{className:"text-center",children:d?d(e):"inline"===p?t.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:t.jsx(li,{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):[]})}):t.jsx(ii,{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):[]})}),me=e=>t.jsx(Zo,{className:"w-[160px]",children:t.jsx(oi,{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"})}),pe=I?t.jsx(wi,{columns:s,columnOrder:Z.columnOrder,isColumnHidden:Z.isColumnHidden,toggleColumn:Z.toggleColumn,showAllColumns:Z.showAllColumns,resetColumns:Z.resetColumns,reorderColumns:Z.reorderColumns,groupByColumn:L?Z.groupByColumn:void 0,setGroupByColumn:L?Z.setGroupByColumn:void 0,groupByColumns:L?Z.groupByColumns:void 0,addGroupByColumn:L?Z.addGroupByColumn:void 0,removeGroupByColumn:L?Z.removeGroupByColumn:void 0}):void 0;if(H)return r.isLoading?t.jsx(Oo,{count:3}):0===r.entities.length?t.jsx(qo,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"}):t.jsxs("div",{className:"flex flex-col h-full",children:[le&&t.jsx(fi,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:w,searchValue:j,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:r.selectedIds.length,bulkActions:C,onBulkDelete:de,onClearSelection:r.clearSelection,customActions:g,filters:S,viewMode:A,onViewModeChange:T,showViewToggle:D}),t.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:r.entities.map(e=>{const a=t.jsx(Pr,{className:_r("overflow-hidden cursor-pointer hover:bg-muted/50",m&&r.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),m?r.selectItem(e.id):n?.(e)},children:t.jsx(Lr,{className:"p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[m&&t.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),t.jsxs("div",{className:"flex-1",children:[te.map(a=>t.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[t.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),t.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(e):String(e[a.key]??"")})]},String(a.key))),(n||o||d)&&t.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(e):t.jsx(ii,{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):[]})})]})]})})},e.id);return V?a:t.jsxs(Wo,{children:[t.jsx(Ho,{asChild:!0,children:a}),me(e)]},e.id)})})]});const he=L&&Z.groupByColumns.length>0?Z.getGroupedData(r.entities):null,xe=null!==he,fe=(F?1:0)+(m?1:0)+te.length+(ce?0:1),ge=e=>{const s=F&&Q.has(e.id),o=t.jsxs(Ro,{className:_r("cursor-pointer hover:bg-muted/50 relative",("inline"===p||ce)&&"group",m&&r.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),m?r.selectItem(e.id):n?.(e)},children:[F&&t.jsx(Fo,{className:"w-[40px] px-2",children:t.jsx("button",{onClick:t=>{t.stopPropagation(),X(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":$(s?"collapse_row":"expand_row"),children:s?t.jsx(c.ChevronDown,{size:16,className:"text-muted-foreground"}):t.jsx(c.ChevronRight,{size:16,className:"text-muted-foreground"})})}),m&&t.jsx(Fo,{onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),te.map(a=>t.jsx(Fo,{className:a.className,children:t.jsx(Vo,{children:a.render?a.render(e):String(e[a.key]??"")})},String(a.key))),!ce&&ue(e)]});return t.jsxs(a.Fragment,{children:[V?o:t.jsxs(Wo,{children:[t.jsx(Ho,{asChild:!0,children:o}),me(e)]}),s&&z&&t.jsx(Ro,{className:"bg-muted/30 hover:bg-muted/30",children:t.jsx(Fo,{colSpan:fe,className:"p-0",children:t.jsx("div",{className:"animate-accordion-down overflow-hidden",children:z(e)})})})]},e.id)},be=(e,r)=>e.map(e=>{const s=Z.collapsedGroups.has(e.groupKey),n=16*e.level,o=Math.max(30,70-15*e.level);return t.jsxs(a.Fragment,{children:[t.jsx(Ro,{className:_r("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>Z.toggleGroupCollapse(e.groupKey),children:t.jsx(Fo,{colSpan:r,className:"py-2 px-4",children:t.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[s?t.jsx(c.ChevronRight,{size:16}):t.jsx(c.ChevronDown,{size:16}),t.jsx("span",{children:e.groupValue}),t.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",e.count,")"]})]})})}),!s&&(e.children?be(e.children,r):e.items.map(ge))]},e.groupKey)});return t.jsxs("div",{className:"flex flex-col h-full",children:[le&&t.jsx(fi,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:w,searchValue:j,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:r.selectedIds.length,bulkActions:C,onBulkDelete:de,onClearSelection:r.clearSelection,customActions:g,filters:S,viewMode:A,onViewModeChange:T,showViewToggle:D}),r.isLoading?t.jsx(Uo,{rows:5,columns:te.length}):t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[L&&t.jsx(ji,{columns:s,groupByColumns:Z.groupByColumns,addGroupByColumn:Z.addGroupByColumn,removeGroupByColumn:Z.removeGroupByColumn,reorderGroupByColumns:Z.reorderGroupByColumns}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs(Eo,{className:"table-fixed w-full",children:[t.jsxs("colgroup",{children:[F&&t.jsx("col",{style:{width:"40px"}}),m&&t.jsx("col",{style:{width:"50px"}}),oe.map((e,a)=>t.jsx("col",{style:e.style},a)),!ce&&t.jsx("col",{style:{width:"inline"===p?"auto":"50px",minWidth:"50px"}})]}),t.jsx(Po,{children:t.jsxs(Ro,{children:[F&&t.jsx(Lo,{className:"w-[40px]"}),m&&t.jsx(Lo,{className:"w-[50px]",children:t.jsx(gi,{checked:r.isAllSelected,onCheckedChange:r.selectAll})}),te.map((e,a)=>{const s=E&&!1!==e.resizable,n=se===String(e.key),o=I?ee.getDragProps(a,String(e.key)):{},i=ee.dragFromIndex===a,l=ee.dragOverIndex===a&&ee.dragFromIndex!==a;return t.jsxs(Lo,{className:_r(e.className,!1!==e.sortable&&"hover:bg-muted/50 cursor-pointer","relative transition-opacity",I&&ee.isDragging&&"cursor-grabbing",i&&"opacity-50",l&&"border-l-2 border-primary"),onClick:!1!==e.sortable?()=>r.handleSort(String(e.key)):void 0,...o,children:[t.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,!1!==e.sortable&&(d=String(e.key),r.sortField!==d?null:"asc"===r.sortDirection?t.jsx(c.ArrowUp,{size:14,className:"ml-1"}):t.jsx(c.ArrowDown,{size:14,className:"ml-1"}))]}),s&&t.jsx($o,{direction:"horizontal",onMouseDown:t=>ne(String(e.key),t),isDragging:n})]},String(e.key));var d}),!ce&&t.jsx(Lo,{className:"w-[50px] text-center",children:pe||e.t("actions")})]})}),t.jsx(Io,{children:0===r.entities.length?t.jsx(Ro,{children:t.jsx(Fo,{colSpan:fe,className:"h-32",children:t.jsx(qo,{title:e.t("no_items_found_empty"),description:"Não há dados para exibir no momento.",variant:"search"})})}):xe?be(he,fe):r.entities.map(ge)})]})})]})]})};function _i(e,t,r,s){const[n,o]=a.useState({}),[i,l]=a.useState({}),c=a.useMemo(()=>e,[e]),d=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let s;if("function"==typeof e.validation?s=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(s=e.validation.custom),s)try{const e=s(t,a);if(e)return e}catch(r){}}};a.useEffect(()=>{if(!s)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},a=e(c),n={};a.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);d(e)&&(a=e.toISOString().split("T")[0])}else d(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),t&&Object.keys(t).forEach(e=>{a.find(t=>t.name===e)||void 0===t[e]||(n[e]=t[e])}),o(n),l({}),r&&r(n)},[c,t,r,s]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},x=()=>{const e=h(c),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const s={...a,[e]:t},n=((e,t)=>{let a={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(c).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,s);return r&&r(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(c).find(t=>t.name===e);if(a){const r=p(a,t,n);r&&l(t=>({...t,[e]:r}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(n)}}}const Ci=[{name:"gray",hue:220,saturation:8},{name:"red",hue:0,saturation:80},{name:"pink",hue:330,saturation:75},{name:"purple",hue:270,saturation:70},{name:"indigo",hue:230,saturation:75},{name:"blue",hue:210,saturation:85},{name:"cyan",hue:190,saturation:75},{name:"teal",hue:170,saturation:65},{name:"green",hue:140,saturation:60},{name:"yellow",hue:45,saturation:90},{name:"orange",hue:25,saturation:90}],ki=[10,22,35,45,55,68,78,87,94].flatMap(e=>Ci.map(({hue:t,saturation:a})=>((e,t,a)=>{a/=100;const r=t=>(t+e/30)%12,s=(t/=100)*Math.min(a,1-a),n=e=>{const t=a-s*Math.max(-1,Math.min(r(e)-3,Math.min(9-r(e),1)));return Math.round(255*t).toString(16).padStart(2,"0")};return`#${n(0)}${n(8)}${n(4)}`})(t,a,e))),Si=({value:e="#3b82f6",onChange:r,label:s,customColorLabel:n,presetColorsLabel:o,showHexValue:i=!0})=>{const{t:l}=y.useTranslation(),d=n??l("custom_color"),u=o??l("preset_colors"),[m,p]=a.useState(!1),h=a.useRef([]),x=Ci.length,f=a.useMemo(()=>{const t=ki.findIndex(t=>t.toLowerCase()===e.toLowerCase());return t>=0?t:0},[e]),[g,b]=a.useState(f);a.useEffect(()=>{m&&(b(f),requestAnimationFrame(()=>{h.current[f]?.focus()}))},[m,f]);const v=e=>{const t=Math.max(0,Math.min(ki.length-1,e));b(t),h.current[t]?.focus()},w=e=>{r?.(e),p(!1)};return t.jsxs("div",{className:"space-y-2",children:[s&&t.jsx(Er,{children:s}),t.jsxs(an,{open:m,onOpenChange:p,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",className:"w-full justify-between text-left font-normal",onKeyDown:e=>{"ArrowDown"!==e.key&&" "!==e.key&&"Spacebar"!==e.key||(e.preventDefault(),p(!0))},children:[t.jsxs("span",{className:"flex items-center min-w-0",children:[t.jsx("span",{className:"h-4 w-4 rounded border mr-2 shrink-0",style:{backgroundColor:e}}),i&&t.jsx("span",{className:"truncate",children:e})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 opacity-50 shrink-0"})]})}),t.jsx(sn,{className:"w-auto p-3",onOpenAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{h.current[f]?.focus()})},children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(Er,{children:u}),t.jsx("div",{className:"grid gap-1 mt-2",style:{gridTemplateColumns:`repeat(${Ci.length}, minmax(0, 1fr))`},onKeyDown:e=>{switch(e.key){case"ArrowRight":e.preventDefault(),v(g+1);break;case"ArrowLeft":e.preventDefault(),v(g-1);break;case"ArrowDown":e.preventDefault(),v(g+x);break;case"ArrowUp":e.preventDefault(),v(g-x);break;case"Home":e.preventDefault(),v(0);break;case"End":e.preventDefault(),v(ki.length-1);break;case"Enter":e.preventDefault(),w(ki[g]);break;case"Tab":e.preventDefault(),p(!1)}},role:"grid",children:ki.map((a,r)=>{const s=a.toLowerCase()===e.toLowerCase();return t.jsx("button",{ref:e=>{h.current[r]=e},type:"button",tabIndex:r===g?0:-1,className:"h-5 w-5 rounded-sm border transition-transform hover:scale-110 hover:z-10 focus:outline-none focus:ring-2 focus:ring-ring focus:z-10 "+(s?"border-foreground ring-2 ring-foreground/30":"border-border/40"),style:{backgroundColor:a},onClick:()=>w(a),"aria-label":`Selecionar cor ${a}`},`${a}-${r}`)})})]}),t.jsxs("div",{children:[t.jsx(Er,{htmlFor:"color-input",children:d}),t.jsx(Tr,{id:"color-input",type:"color",value:e,onChange:e=>r?.(e.target.value),className:"h-8 w-full mt-2"})]})]})})]})]})},Ai=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(xe.Root,{ref:s,className:_r("relative overflow-hidden",e),...r,children:[t.jsx(xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),t.jsx(Ti,{}),t.jsx(xe.Corner,{})]}));Ai.displayName=xe.Root.displayName;const Ti=te.forwardRef(({className:e,orientation:a="vertical",...r},s)=>t.jsx(xe.ScrollAreaScrollbar,{ref:s,orientation:a,className:_r("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:t.jsx(xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Ti.displayName=xe.ScrollAreaScrollbar.displayName;const Di=[{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 Ei({name:e,filled:a,className:r}){return t.jsx("span",{className:`material-symbols-outlined ${r??""}`,style:a?{fontVariationSettings:"'FILL' 1"}:void 0,children:e})}const Pi=({value:e=null,onChange:r,label:s,noIconLabel:n="SEM ÍCONE",color:o="text-foreground/60"})=>{const[i,l]=a.useState(!1),d=a.useRef([]),u=e?function(e){return Di.find(t=>t.name===e)}(e):null,m=a.useMemo(()=>{if(!e)return 0;const t=Di.findIndex(t=>t.name===e);return t>=0?t:0},[e]),[p,h]=a.useState(m);a.useEffect(()=>{i&&(h(m),requestAnimationFrame(()=>{d.current[m]?.focus()}))},[i,m]);const x=a.useCallback(e=>{const t=Math.max(0,Math.min(Di.length-1,e));h(t),d.current[t]?.focus()},[]),f=a.useCallback(e=>{r?.(e),l(!1)},[r]),g=a.useCallback(e=>{"ArrowDown"!==e.key&&" "!==e.key&&"Spacebar"!==e.key||(e.preventDefault(),l(!0))},[]),b=a.useCallback(e=>{switch(e.key){case"ArrowRight":e.preventDefault(),x(p+1);break;case"ArrowLeft":e.preventDefault(),x(p-1);break;case"ArrowDown":e.preventDefault(),x(p+10);break;case"ArrowUp":e.preventDefault(),x(p-10);break;case"Home":e.preventDefault(),x(0);break;case"End":e.preventDefault(),x(Di.length-1);break;case"Enter":e.preventDefault(),f(Di[p]?.name??null);break;case"Tab":e.preventDefault(),l(!1)}},[p,x,f]);return t.jsxs("div",{className:"space-y-2",children:[s&&t.jsx(Er,{children:s}),t.jsxs(an,{open:i,onOpenChange:l,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",className:"justify-start text-left font-normal gap-2",onKeyDown:g,children:[u?t.jsx(Ei,{name:u.name,filled:u.filled,className:`text-xl ${o}`}):t.jsx("span",{className:"text-muted-foreground text-sm",children:n}),t.jsx(c.ChevronDown,{className:"ml-auto h-4 w-4 opacity-50"})]})}),t.jsx(sn,{className:"w-auto max-w-[min(640px,calc(100vw-2rem))] p-3",align:"start",onOpenAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{d.current[m]?.focus()})},children:t.jsxs("div",{className:"space-y-3",children:[t.jsx(Ai,{className:"max-h-[min(480px,calc(100vh-12rem))]",children:t.jsx("div",{className:"grid grid-cols-10 gap-1",onKeyDown:b,role:"grid",children:Di.map((a,r)=>t.jsx("button",{ref:e=>{d.current[r]=e},type:"button",tabIndex:r===p?0:-1,className:`flex items-center justify-center p-1.5 rounded border transition-colors ${o} ${e===a.name?"bg-accent border-ring":"border-transparent hover:bg-accent"}`,onClick:()=>f(a.name),title:a.name,children:t.jsx(Ei,{name:a.name,filled:a.filled,className:"text-2xl"})},a.name))})}),t.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:()=>f(null),children:n})]})})]})]})},Ii=te.forwardRef(({className:e,...a},r)=>t.jsx(fe.Root,{className:_r("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),...a,ref:r,children:t.jsx(fe.Thumb,{className:_r("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Ii.displayName=fe.Root.displayName;const Mi=(e={})=>{const{user:t,alias:a}=So(),{enabled:r=!0,status:s="active"}=e;return j.useQuery({queryKey:["qualiex-users",a,s],queryFn:()=>co.getUsers(a,s),enabled:r&&!!a&&!!t,staleTime:3e5,retry:2,retryDelay:1e3})},Ri=({value:r,onChange:s,multiple:n=!1,label:o,required:i,placeholder:l,icon:c,maxDisplayedBadges:d,className:u,disabled:m,enabled:p,displayFormat:h="name",customDisplayFn:x,filterFn:f,sortOptions:g=!0,popoverContainer:b,onOpen:v,onClose:w})=>{const{t:j}=y.useTranslation(),{data:N=[],isLoading:_,error:C}=Mi({enabled:p}),[k,S]=a.useState(new Map),A=a.useMemo(()=>r?Array.isArray(r)?r.filter(Boolean):[r].filter(Boolean):[],[r]),T=a.useMemo(()=>{if(0===A.length||0===N.length)return"";const e=new Set(N.map(e=>e.userId||e.id||""));return A.filter(t=>t&&!e.has(t)&&!k.has(t)).sort().join(",")},[A,N,k]);a.useEffect(()=>{if(!T)return;const e=T.split(",");let t=!1;const a=$n.extractTokenData();return a?.alias&&a?.companyId?(co.fetchUsers(a.alias,a.companyId,"all").then(a=>{t||S(t=>{const r=new Map(t);for(const s of e){const e=a.find(e=>e.userId===s||e.id===s);e&&r.set(s,{...e,isActive:e.isActive??!1})}return r})}).catch(()=>{}),()=>{t=!0}):void 0},[T]);const D=a.useMemo(()=>f?N.filter(f):N,[N,f]),E=a.useMemo(()=>{if(0===A.length)return D;const t=new Set(D.map(e=>e.userId||e.id||"")),a=A.filter(e=>e&&!t.has(e));if(0===a.length)return D;const r=a.map(t=>{const a=k.get(t);return a||{userId:t,id:t,userName:e.t("inactive_user"),userEmail:"",isActive:!1}});return[...D,...r]},[D,A,k]),P=a.useCallback(t=>{let a;if("custom"===h&&x)a=x(t);else{const e=t.userName||"";switch(h){case"name-email":a=t.userEmail?`${e} (${t.userEmail})`:e;break;case"name-role":a=t.roleName?`${e} - ${t.roleName}`:e;break;default:a=e}}return!1===t.isActive?`${a} (${e.t("inactive")})`:a},[h,x]);return t.jsx(gn,{multiple:n,value:r??(n?[]:""),onChange:s,options:E,isLoading:_,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:P,placeholder:l||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:j("no_results"),label:o,required:i,icon:c,maxDisplayedBadges:d,disabled:m,className:u,sortOptions:g,popoverContainer:b,onOpen:v,onClose:w})};function Li({title:e,sections:r,initialData:s,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:c=!1,usersData:d}){const[u,m]=a.useState(r?.[0]?.id||""),p=a.useRef(null),[h,x]=a.useState(null),f=a.useCallback(e=>{p.current=e,x(e)},[]),g=a.useMemo(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:b,errors:v,updateField:y,handleSubmit:w}=_i(g,s,void 0,i),j=a.useMemo(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[r,b]),N=a.useMemo(()=>{const e=j.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=j.find(e=>!e.disabled);return t?.id||u},[j,u]);a.useEffect(()=>{N!==u&&m(N)},[N,u]);const _=j.find(e=>e.id===N),C=e=>{const a=(e.computedValue,b[e.name]),r=void 0!==a?a:"",s=v[e.name];switch(e.type){case"group":const a="horizontal"===e.layout,n=a?`flex gap-3 w-full ${e.className||""}`:"space-y-3",o=a?_r("space-y-2 w-full",e.wrapperClassName):_r("space-y-2",e.className,e.wrapperClassName);return t.jsxs("div",{className:o,children:[e.label,t.jsx("div",{className:n,children:e.fields?.map(e=>C(e))})]},e.name);case"user-select":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Ri,{value:r||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-destructive":""}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"textarea":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Ts,{id:e.name,value:r||"",onChange:t=>{y(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,rows:e.rows,maxLength:e.maxLength,className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"select":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs(bs,{value:String(r),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[t.jsx(ws,{className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,children:t.jsx(ys,{placeholder:e.placeholder})}),t.jsx(_s,{children:e.options?.map(e=>t.jsx(ks,{value:e.value,children:e.label},e.value))})]}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"multiselect":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(gn,{options:e.options||[],value:Array.isArray(r)?r:[],onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,error:s,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"date":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"date",value:String(r),onChange:t=>y(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:_r("w-full",s?"border-destructive":"",e.disabled?"bg-muted cursor-not-allowed":"")}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"color":return t.jsxs("div",{children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"color",value:r||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),s&&t.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"color-picker":return t.jsxs("div",{children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Si,{value:r||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),s&&t.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"icon-picker":return t.jsxs("div",{children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Pi,{value:r||e.defaultValue||null,onChange:t=>y(e.name,t)}),s&&t.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"custom":if(!e.component)return null;const i=e.component,l="function"==typeof e.componentProps?e.componentProps(b):e.componentProps||{};return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(i,{value:r,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:s,popoverContainer:h,...l}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"number":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"number",value:null!=r?String(r):"",onChange:t=>{const a=t.target.value,r=""===a?null:Number(a);y(e.name,r)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"checkbox":return t.jsxs("div",{className:`flex items-center space-x-2 ${e.className||""}`,children:[t.jsx(As,{id:e.name,checked:!!r,onCheckedChange:t=>y(e.name,t),disabled:e.disabled}),t.jsxs(Er,{htmlFor:e.name,className:"cursor-pointer",children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"switch":return t.jsxs("div",{className:`flex items-center justify-between space-x-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Ii,{id:e.name,checked:!!r,onCheckedChange:t=>y(e.name,t),disabled:e.disabled}),s&&t.jsx("p",{className:"text-sm text-destructive mt-2",children:s})]},e.name);default:return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"text",value:r||"",onChange:t=>{y(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:e.disabled}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name)}},k=a.useCallback(()=>{if(!_)return null;if(_.disabled)return t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:t.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),t.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 t.jsx(e,{formData:b,updateField:y,errors:v,users:d,disabled:_.disabled})}return t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.fields.map(C)})},[_,b,y,v,d,C]),S=t.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[j.length>1&&t.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:t.jsx("div",{className:"flex space-x-2",children:j.map(e=>t.jsx(Sr,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=j.find(t=>t.id===e);t&&!t.disabled&&m(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:c?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):t.jsxs("form",{onSubmit:w(n),className:"space-y-3 md:space-y-4",children:[k(),t.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[t.jsx(Sr,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),t.jsx(Sr,{type:"submit",disabled:c,children:l||"Salvar"})]})]})})]});return t.jsx(Qr,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:t.jsxs(as,{ref:f,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[t.jsxs(rs,{showSeparator:!0,children:[t.jsx(os,{children:e}),t.jsx(is,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Fi({currentPage:e,totalPages:a,totalItems:r,itemsPerPage:s,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:l}=y.useTranslation();if(0===r)return null;const d=(e-1)*s+1,u=Math.min(e*s,r);return t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:l("rows_per_page","Linhas por página")}),t.jsxs(bs,{value:String(s),onValueChange:e=>o(Number(e)),children:[t.jsx(ws,{className:"h-8 w-[70px]",children:t.jsx(ys,{})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"10",children:"10"}),t.jsx(ks,{value:"25",children:"25"}),t.jsx(ks,{value:"50",children:"50"}),t.jsx(ks,{value:"100",children:"100"})]})]})]})}),t.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[d,"-",u," ",l("of","de")," ",r," ",l("items","itens")]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===e,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronsLeft,{size:16})}),t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronLeft,{size:16})}),t.jsxs("div",{className:"flex items-center gap-1 px-2",children:[t.jsx("span",{className:"text-sm font-medium",children:e}),t.jsx("span",{className:"text-sm text-muted-foreground",children:l("of","de")}),t.jsx("span",{className:"text-sm font-medium",children:a})]}),t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===a,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronRight,{size:16})}),t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:e===a,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronsRight,{size:16})})]})]})}function zi({manager:e}){return t.jsx(Fi,{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 Ui={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Oi={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Bi={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function qi({children:e,direction:a="column",gap:r="md",align:s="stretch",justify:n="start",wrap:o=!1,className:i}){return t.jsx("div",{className:_r("flex","column"===a?"flex-col":"flex-row",Ui[r],Oi[s],Bi[n],o&&"flex-wrap",i),children:e})}function Vi({manager:e,filters:a,inline:r=!1}){const{t:s}=y.useTranslation(),{isSearchVisible:n}=So(),o=e.searchTerm,i=t.jsxs(t.Fragment,{children:[a.some(e=>"search"===e.type)&&!n&&t.jsxs("div",{className:"relative flex-1",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(Tr,{placeholder:"Pesquisar",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((e,a)=>t.jsxs(bs,{value:e.value||"",onValueChange:t=>e.onChange?.(t),children:[t.jsx(ws,{className:"w-[180px]",children:t.jsx(ys,{placeholder:e.placeholder})}),t.jsx(_s,{children:e.options.map(e=>t.jsx(ks,{value:e.value,children:e.label},e.value))})]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((e,a)=>{const s=e.component;return t.jsx("div",{className:r?"":"w-full sm:w-auto",children:t.jsx(s,{...e.props})},`custom-${a}`)}),o&&t.jsxs(Sr,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[t.jsx(c.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return r?t.jsx("div",{className:"flex items-center gap-2",children:i}):t.jsx(qi,{direction:"column",gap:"md",className:"mb-6",children:t.jsx(qi,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function $i({manager:e,config:r,formSections:s,onSave:n,onToggleStatus:o,defaultSort:i,readOnly:l=!1}){e&&e.queryKey;const{setSearchVisible:c}=So(),[d,u]=N.useSearchParams(),[m,p]=a.useState(!1),[h,x]=a.useState(null),[f,g]=a.useState({isOpen:!1,entityId:null,entityName:""}),[b,v]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(i&&e){const t=`${e.queryKey}_sortField`,a=`${e.queryKey}_sortDirection`;if(!d.has(t)&&!d.has(a)){const e=Object.fromEntries(d);e[t]=i.column,e[a]=i.direction,u(e)}}},[]);const y=!l&&s.length>0?e=>{r.onEdit?r.onEdit(e):(x(e),p(!0))}:void 0,w=l||"function"!=typeof e?.deleteEntity?void 0:e=>{g({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},j=()=>{g({isOpen:!1,entityId:null,entityName:""})},_=void 0!==r.hideNewButton?!r.hideNewButton:r.showNewButton??!0,C=(r.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 t.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(r.showActionBar??!0)&&t.jsx(fi,{onNew:()=>{r.onNew?r.onNew():(x(null),p(!0))},newButtonLabel:r.newButtonLabel,showNewButton:_,showSearch:r.showSearch,searchValue:e.searchTerm,onSearchChange:e.handleSearch,searchPlaceholder:r.searchPlaceholder,showBulkActions:r.enableBulkActions,selectedCount:e.selectedIds.length,bulkActions:r.bulkActions,onBulkDelete:()=>{v({isOpen:!0,count:e.selectedIds.length})},onClearSelection:e.clearSelection,customActions:C,filters:r.filters&&r.filters.length>0?t.jsx(Vi,{manager:e,filters:r.filters,inline:!0}):void 0}),t.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?t.jsx("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(e.entities,e)}):t.jsx(Ni,{manager:e,columns:r.columns,onEdit:y,onDelete:w,onToggleStatus:o,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions,enableColumnManager:!0,columnManagerStorageKey:`crud-${r.entityName.toLowerCase().replace(/\s+/g,"-")}-columns`,resizeStorageKey:`crud-${r.entityName.toLowerCase().replace(/\s+/g,"-")}-resize`,defaultHiddenColumns:r.defaultHiddenColumns,readOnly:l})}),t.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:t.jsx(zi,{manager:e})}),!r.useCustomRouting&&!r.onNew&&s.length>0&&t.jsx(Li,{open:m,title:h?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:h||void 0,onSubmit:e=>{n(e),p(!1),x(null)},onCancel:()=>{p(!1),x(null)},isLoading:e.isLoading,submitButtonText:h?"Atualizar":"Criar"}),t.jsx(Qr,{open:f.isOpen,onOpenChange:j,children:t.jsxs(as,{size:"sm",variant:"destructive",children:[t.jsx(rs,{showSeparator:!0,children:t.jsx(os,{children:"Você tem certeza absoluta?"})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",t.jsx("strong",{children:f.entityName}),". Esta ação não pode ser desfeita."]})}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:j,children:"Cancelar"}),t.jsx(Sr,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof e?.deleteEntity&&(e.deleteEntity(f.entityId),g({isOpen:!1,entityId:null,entityName:""}))},disabled:e.isDeleting,children:e.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),t.jsx(Qr,{open:b.isOpen,onOpenChange:()=>v({isOpen:!1,count:0}),children:t.jsxs(as,{size:"sm",variant:"destructive",children:[t.jsx(rs,{showSeparator:!0,children:t.jsx(os,{children:"Você tem certeza absoluta?"})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",t.jsx("strong",{children:b.count})," ",1===b.count?r.entityName:r.entityNamePlural,". Esta ação não pode ser desfeita."]})}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>v({isOpen:!1,count:0}),children:"Cancelar"}),t.jsx(Sr,{variant:"destructive",onClick:()=>{e.bulkDelete?.(e.selectedIds),v({isOpen:!1,count:0})},disabled:e.isBulkDeleting,children:e.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Wi(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Hi(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Gi(e={}){const{paramName:t="alias"}=e,r=N.useParams(),{alias:s,companies:n}=So(),o=r[t]||null;return a.useMemo(()=>{if(!o)return{urlAlias:null,isAliasMismatch:!1,isValidAlias:!1,isMissing:!0,matchedCompany:null};const e=n?.find(e=>e.alias===o)||null,t=!!e;return{urlAlias:o,isAliasMismatch:t&&o!==s,isValidAlias:t,isMissing:!1,matchedCompany:e}},[o,s,n])}const Ki=s.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),Yi={info:c.Info,warning:c.Info,danger:c.AlertTriangle,success:c.CheckCircle},Qi=te.forwardRef(({className:e,variant:a="info",showIcon:r=!0,children:s,...n},o)=>{const i=Yi[a||"info"];return t.jsxs("div",{ref:o,role:"alert",className:_r(Ki({variant:a}),e),...n,children:[r&&t.jsx(i,{className:"h-4 w-4"}),s]})});Qi.displayName="Alert";const Xi=te.forwardRef(({className:e,...a},r)=>t.jsx("h5",{ref:r,className:_r("mb-1 font-medium leading-none tracking-tight",e),...a}));Xi.displayName="AlertTitle";const Ji=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("text-sm [&_p]:leading-relaxed",e),...a}));Ji.displayName="AlertDescription";const Zi=te.forwardRef(({className:e,...a},r)=>t.jsx(ge.Root,{ref:r,className:_r("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...a}));Zi.displayName=ge.Root.displayName;const el=te.forwardRef(({className:e,...a},r)=>t.jsx(ge.Image,{ref:r,className:_r("aspect-square h-full w-full",e),...a}));el.displayName=ge.Image.displayName;const tl=te.forwardRef(({className:e,...a},r)=>t.jsx(ge.Fallback,{ref:r,className:_r("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...a}));function al(){return Ge()||"https://common-v4-api.qualiex.com"}function rl(){const e=Qe();if(e)return e;const t=al().match(/^https?:\/\/common-v4-api(-[^.]+)?\.(.+)$/);if(t){return`https://login-api${t[1]||""}.${t[2]}`}return"https://login-api.qualiex.com"}function sl(e){const t=$n.getAccessToken();if(!t)throw new Error("Token Qualiex não encontrado");if(!e)throw new Error("Alias é obrigatório para chamadas à API Qualiex");return{Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json","un-alias":e}}async function nl(e,t,a){const r=async()=>{const r=await fetch(e,{...a,headers:{...sl(t),...a?.headers||{}}});if(!r.ok){const e=new Error(`API Error: ${r.status}`);throw e.status=r.status,e.statusCode=r.status,e}return r};try{return await r()}catch(s){if(await lo.handleApiError(s))return await r();throw s}}async function ol(e){const t=$n.getAccessToken(),a=$n.getIdToken();if(!t||!a)throw new Error("Sessão inválida. Faça login novamente.");const r=function(e){const t=Rn.parseJwtPayload(e),a="string"==typeof t?.subNewId?t.subNewId.trim():"";if(!a)throw new Error("NewId do usuário não encontrado no id-token.");return a}(a),s=$n.getSelectedAlias()?.trim()||$n.extractTokenData()?.alias||"",n=`${rl()}/api/Users/UpdatePhotoByNewIdAsync?newId=${encodeURIComponent(r)}`,o=async()=>{const r=$n.getAccessToken()||t,o=$n.getIdToken()||a,i=$n.getAppGroupId(s)?.toString()??"1",l=new FormData;l.append(e.name,e,e.name);const c=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${r}`,"id-token":o,Accept:"application/json, text/plain, */*",...s?{"un-alias":s}:{},AppGroupId:i},body:l});if(!c.ok){const e=new Error(`Upload falhou: ${c.status} ${c.statusText}`);throw e.status=c.status,e.statusCode=c.status,e}};try{await o()}catch(i){if(await lo.handleApiError(i))try{return void await o()}catch(l){throw Gn.handleError(l instanceof Error?l:"Erro ao enviar foto após renovação de token",!1),l}throw i}}tl.displayName=ge.Fallback.displayName;const il={"en-US":1,"pt-BR":2,"es-ES":3,"fr-FR":4};function ll(e,t){const a=e?.trim();if(a)return a;const r=Rn.parseJwtPayload(t),s="string"==typeof r?.subNewId?r.subNewId.trim():"";if(s)return s;throw new Error("Identificador do usuário não encontrado.")}function cl(e){const t=$n.getSelectedAlias()?.trim();if(t)return t;const a=$n.getSupabaseToken(),r=a?Rn.parseJwtPayload(a):null,s="string"==typeof r?.alias?r.alias.trim():"string"==typeof r?.default?r.default.trim():"string"==typeof r?.user_alias?r.user_alias.trim():"";if(s)return s;const n=Rn.parseJwtPayload(e),o="string"==typeof n?.default?n.default.trim():"string"==typeof n?.alias?n.alias.trim():"string"==typeof n?.user_alias?n.user_alias.trim():"";if(o)return o;for(const i in n||{}){if(!/^co\d+$/.test(i))continue;const e=n?.[i];if("string"!=typeof e)continue;const[t]=e.split(";");if(t?.trim())return t.trim()}}async function dl(e){const t=$n.getAccessToken(),a=$n.getIdToken();if(!t||!a)throw new Error("Sessão inválida. Faça login novamente.");const r=ll(e.newId,a),s=cl(a),n={};e.name&&e.name.trim()&&(n.Name=e.name.trim()),e.email&&e.email.trim()&&(n.Email=e.email.trim());const o=function(e){if(void 0!==e)return null===e||""===e?null:"number"==typeof e?1===e||2===e||3===e||4===e?e:null:il[e]??null}(e.language);void 0!==o&&(n.LanguageId=o);const i=`${rl()}/api/Users/UpdateUserProfile/${encodeURIComponent(r)}`,l=async()=>{const e=$n.getAccessToken()||t,r=$n.getIdToken()||a,o=$n.getAppGroupId(s)?.toString()??"1",l=await fetch(i,{method:"PUT",headers:{Authorization:`Bearer ${e}`,"id-token":r,...s?{"un-alias":s}:{},AppGroupId:o,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const e=new Error(`Falha ao atualizar perfil: ${l.status} ${l.statusText}`);throw e.status=l.status,e.statusCode=l.status,e}};try{await l()}catch(c){if(await lo.handleApiError(c))return void await l();throw c}}const ul={1:"en-US",2:"pt-BR",3:"es-ES",4:"fr-FR"};function ml(e,...t){for(const a of t){const t=e[a];if("string"==typeof t&&t.trim())return t}return null}async function pl(e){const t=$n.getAccessToken(),a=$n.getIdToken();if(!t||!a)throw new Error("Sessão inválida. Faça login novamente.");const r=ll(e,a),s=cl(a),n=`${rl()}/api/Users/GetUserProfileByNewId/${encodeURIComponent(r)}`,o=async()=>{const e=$n.getAccessToken()||t,o=$n.getIdToken()||a,i=$n.getAppGroupId(s)?.toString()??"1",l=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${e}`,"id-token":o,...s?{"un-alias":s}:{},AppGroupId:i,Accept:"application/json, text/plain, */*"}});if(404===l.status){const e=new Error("Usuário não encontrado.");throw e.status=404,e.statusCode=404,e}if(!l.ok){const e=new Error(`Falha ao obter perfil: ${l.status} ${l.statusText}`);throw e.status=l.status,e.statusCode=l.status,e}const c=await l.json(),d=function(e,...t){for(const a of t){const t=e[a];if("number"==typeof t&&Number.isFinite(t))return t;if("string"==typeof t&&t.trim()&&!Number.isNaN(Number(t)))return Number(t)}return null}(c,"languageId","LanguageId"),u=1===d||2===d||3===d||4===d?d:null,m=ml(c,"photoUrl","PhotoUrl");let p=null;if(m)if(/^https?:\/\//i.test(m))p=m;else{const e=m.replace(/^\/+/,""),t=e.includes("?")?"&":"?";p=`${rl()}/api/${e}${t}size=96`}return{newId:r,name:ml(c,"name","Name"),email:ml(c,"email","Email"),languageId:u,language:u?ul[u]:null,photoUrl:p}};try{return await o()}catch(i){if(await lo.handleApiError(i))return await o();throw i}}const hl=[{value:"pt-BR",label:"Português (Brasil)"},{value:"en-US",label:"English (US)"},{value:"es-ES",label:"Español"}],xl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,fl=({open:e,onOpenChange:r,user:s,userPhotoUrl:n,userInitials:o})=>{const{t:i,i18n:d}=y.useTranslation(),u=a.useRef(null),[m,p]=a.useState(null),[h,x]=a.useState(null),[f,g]=a.useState(d.language||"pt-BR"),[b,v]=a.useState(s.name||""),[w,j]=a.useState(s.email||""),[N,_]=a.useState(!1),[C,k]=a.useState(null);a.useEffect(()=>{if(!e)return;v(s.name||""),j(s.email||""),g(d.language||"pt-BR"),k(null);let t=!1;return(async()=>{try{const e=await pl(s.id||void 0);if(t)return;e.name&&v(e.name),e.email&&j(e.email),e.language&&g(e.language),k(e.photoUrl)}catch{}})(),()=>{t=!0}},[e,s.id,s.name,s.email,d.language]);const S=m||C||n,A=e=>{N||(e||(p(null),x(null),g(d.language||"pt-BR"),v(s.name||""),j(s.email||"")),r(e))};return t.jsx(Qr,{open:e,onOpenChange:A,children:t.jsxs(as,{className:"sm:max-w-md",children:[t.jsx(rs,{children:t.jsx(os,{children:i("edit_profile","Editar Perfil")})}),t.jsxs(ss,{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs(Zi,{className:"w-24 h-24 flex-shrink-0 ring-2 ring-border ring-offset-2 ring-offset-background",children:[S&&t.jsx(el,{src:S,alt:s.name||""}),t.jsx(tl,{className:"bg-primary text-primary-foreground font-semibold text-2xl",children:o})]}),t.jsxs("div",{children:[t.jsxs(Sr,{variant:"outline",size:"sm",onClick:()=>u.current?.click(),children:[t.jsx(c.Camera,{className:"mr-2 h-4 w-4"}),i("change_photo","Trocar foto")]}),t.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const t=e.target.files?.[0];if(!t)return;const a=URL.createObjectURL(t);p(a),x(t)}})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"profile-name",children:i("name","Nome")}),t.jsx(Tr,{id:"profile-name",value:b,onChange:e=>v(e.target.value),maxLength:150,autoComplete:"name",readOnly:!0,className:"bg-muted cursor-not-allowed"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"profile-email",children:i("email","E-mail")}),t.jsx(Tr,{id:"profile-email",type:"email",value:w,onChange:e=>j(e.target.value),maxLength:200,autoComplete:"email",readOnly:!0,className:"bg-muted cursor-not-allowed"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:i("language","Idioma")}),t.jsxs(bs,{value:f,onValueChange:g,children:[t.jsx(ws,{children:t.jsx(ys,{})}),t.jsx(_s,{children:hl.map(e=>t.jsx(ks,{value:e.value,children:e.label},e.value))})]})]})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>A(!1),disabled:N,children:i("cancel","Cancelar")}),t.jsxs(Sr,{onClick:async()=>{if(b.trim())if(xl.test(w.trim())){_(!0);try{if(h)try{await ol(h),window.dispatchEvent(new Event("user-photo-updated")),l.toast.success("Foto atualizada com sucesso")}catch(e){const t=e instanceof Error?e.message:String(e);l.toast.error("Falha ao atualizar foto"+(t?`: ${t}`:""))}if(b.trim()!==(s.name||"")||w.trim()!==(s.email||"")||f!==d.language)try{await dl({newId:s.id||void 0,name:b.trim(),email:w.trim(),language:f}),l.toast.success("Perfil atualizado com sucesso")}catch(e){const t=e instanceof Error?e.message:String(e);l.toast.error(t||"Falha ao atualizar perfil")}f!==d.language&&d.changeLanguage(f),x(null),p(null),r(!1)}finally{_(!1)}}else l.toast.error("Informe um e-mail válido.");else l.toast.error("Informe o nome.")},disabled:N,children:[N&&t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),N?i("saving","Salvando..."):i("save","Salvar")]})]})]})})},gl=a.createContext(void 0);function bl({children:e,actions:r}){const{t:s}=y.useTranslation(),[n,o]=a.useState({}),[i,l]=a.useState(r);a.useEffect(()=>{l(r)},[r]);const c=a.useCallback(()=>o({}),[]),d=a.useMemo(()=>({metadata:n,setMetadata:o,clearMetadata:c,headerActions:i,setHeaderActions:l}),[n,c,i]);return t.jsx(gl.Provider,{value:d,children:e})}function vl(){const e=a.useContext(gl);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var yl={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",cannot_be_own_leader:"Um líder não pode ser seu próprio superior",change_photo:"Trocar foto",clear_filters:"Limpar filtros",clear_formatting:"Limpar Formatação",clear_search:"Limpar busca",clear_selection:"Limpar seleção",close:"Fechar",collapse:"Colapsar",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",create:"Criar",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_name:"Editar Nome",edit_profile:"Editar Perfil",electronic_signature:"Assinatura Eletrônica",email:"E-mail",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:"Expandir",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_direct_subordinates:"Subordinados diretos:",leadership_drag_hint:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote",leadership_drag_to_hierarchy:"Arraste para a hierarquia acima",leadership_immediate_superior:"Superior Imediato",leadership_load_error:"Erro ao carregar hierarquia de liderança",leadership_make_root:"Tornar Líder Raiz",leadership_make_root_short:"Tornar Raiz",leadership_no_direct_subordinates:"Sem subordinados diretos",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_confirmation:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita.",leadership_remove_team:"Remover da equipe",leadership_search_superior:"Buscar superior...",leadership_select_subordinates:"Selecione pelo menos um liderado",leadership_unassociated_users:"Usuários não associados",leadership_users_associated:"{{count}} usuário associado",leadership_users_associated_count:"Usuários associados: {{count}}",leadership_users_associated_plural:"{{count}} usuários associados",leadership_users_unassociated_count:"Usuários não associados: {{count}}",learn_qualiex:"Aprenda a usar o Qualiex",leave_without_saving:"Sair sem salvar",lines_per_page:"Linhas por página",link:"Link",loading:"Carregando...",login_with_qualiex:"Entrar com Qualiex",manage_access:"Gerenciar Acessos",mind_map_add_child:"Adicionar filho",mind_map_add_sibling:"Adicionar irmão",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar tudo",mind_map_delete_node:"Excluir nó",mind_map_expand_all:"Expandir tudo",mind_map_export_image:"Exportar como imagem",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar à tela",mind_map_redo:"Refazer",mind_map_undo:"Desfazer",mind_map_zoom_in:"Aproximar",mind_map_zoom_out:"Afastar",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",name:"Nome",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",none_bracketed:"[Nenhum]",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",removing:"Removendo...",replace:"Substituir",report:"Relatório",request_date:"Data da solicitação",required_field:"Campo obrigatório",resend_code:"Reenviar código",reset_default:"Redefinir padrão",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",selected_count:"{{count}} selecionado",selected_count_plural:"{{count}} 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:"Subordinados",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?",update:"Atualizar",updates:"Atualizações",updates_bar_close:"Fechar",updates_dialog_close:"Fechar",updates_dialog_do_not_show_again:"Não exibir novamente",updates_dialog_like:"Curtir",updating:"Atualizando...",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..."},wl={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",cannot_be_own_leader:"A leader cannot be their own superior",change_photo:"Change photo",clear_filters:"Clear filters",clear_formatting:"Clear Formatting",clear_search:"Clear search",clear_selection:"Clear selection",close:"Close",collapse:"Collapse",collapse_row:"Collapse row",columns:"Columns",conclude:"Finish",confirm_removal:"Confirm removal",could_not_load_info:"Could not load the information",create:"Create",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_name:"Edit Name",edit_profile:"Edit Profile",electronic_signature:"Electronic Signature",email:"Email",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:"Expand",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_direct_subordinates:"Direct subordinates:",leadership_drag_hint:"Drag rows to reorganize • Select multiple to move in bulk",leadership_drag_to_hierarchy:"Drag to the hierarchy above",leadership_immediate_superior:"Immediate Superior",leadership_load_error:"Failed to load leadership hierarchy",leadership_make_root:"Make Root Leader",leadership_make_root_short:"Make Root",leadership_no_direct_subordinates:"No direct subordinates",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_confirmation:"Are you sure you want to remove this leader? This action cannot be undone.",leadership_remove_team:"Remove from team",leadership_search_superior:"Search superior...",leadership_select_subordinates:"Select at least one subordinate",leadership_unassociated_users:"Unassociated users",leadership_users_associated:"{{count}} user associated",leadership_users_associated_count:"Associated users: {{count}}",leadership_users_associated_plural:"{{count}} users associated",leadership_users_unassociated_count:"Unassociated users: {{count}}",learn_qualiex:"Learn how to use Qualiex",leave_without_saving:"Leave without saving",lines_per_page:"Lines per page",link:"Link",loading:"Loading...",login_with_qualiex:"Login with Qualiex",manage_access:"Manage Access",mind_map_add_child:"Add child",mind_map_add_sibling:"Add sibling",mind_map_aria_label:"Mind map",mind_map_collapse_all:"Collapse all",mind_map_delete_node:"Delete node",mind_map_expand_all:"Expand all",mind_map_export_image:"Export as image",mind_map_export_json:"Export as JSON",mind_map_fit_to_screen:"Fit to screen",mind_map_redo:"Redo",mind_map_undo:"Undo",mind_map_zoom_in:"Zoom in",mind_map_zoom_out:"Zoom out",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",name:"Name",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",none_bracketed:"[None]",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",removing:"Removing...",replace:"Replace",report:"Report",request_date:"Request date",required_field:"Required field",resend_code:"Resend code",reset_default:"Reset to default",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",selected_count:"{{count}} selected",selected_count_plural:"{{count}} 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:"Subordinates",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?",update:"Update",updates:"Updates",updates_bar_close:"Close",updates_dialog_close:"Close",updates_dialog_do_not_show_again:"Do not show again",updates_dialog_like:"Like",updating:"Updating...",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..."},jl={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",cannot_be_own_leader:"Un líder no puede ser su propio superior",change_photo:"Cambiar foto",clear_filters:"Limpiar filtros",clear_formatting:"Limpiar Formato",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",close:"Cerrar",collapse:"Colapsar",collapse_row:"Contraer fila",columns:"Columnas",conclude:"Concluir",confirm_removal:"Confirmar eliminación",could_not_load_info:"No se pudo cargar la información",create:"Crear",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_name:"Editar Nombre",edit_profile:"Editar Perfil",electronic_signature:"Firma Electrónica",email:"Correo electrónico",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:"Expandir",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_direct_subordinates:"Subordinados directos:",leadership_drag_hint:"Arrastre las filas para reorganizar • Seleccione múltiples para mover en lote",leadership_drag_to_hierarchy:"Arrastre a la jerarquía anterior",leadership_immediate_superior:"Superior Inmediato",leadership_load_error:"Error al cargar la jerarquía de liderazgo",leadership_make_root:"Hacer Líder Raíz",leadership_make_root_short:"Hacer Raíz",leadership_no_direct_subordinates:"Sin subordinados directos",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_confirmation:"¿Está seguro de que desea eliminar este líder? Esta acción no se puede deshacer.",leadership_remove_team:"Quitar del equipo",leadership_search_superior:"Buscar superior...",leadership_select_subordinates:"Seleccione al menos un subordinado",leadership_unassociated_users:"Usuarios no asociados",leadership_users_associated:"{{count}} usuario asociado",leadership_users_associated_count:"Usuarios asociados: {{count}}",leadership_users_associated_plural:"{{count}} usuarios asociados",leadership_users_unassociated_count:"Usuarios no asociados: {{count}}",learn_qualiex:"Aprenda a usar Qualiex",leave_without_saving:"Salir sin guardar",lines_per_page:"Líneas por página",link:"Enlace",loading:"Cargando...",login_with_qualiex:"Iniciar sesión con Qualiex",manage_access:"Gestionar Accesos",mind_map_add_child:"Agregar hijo",mind_map_add_sibling:"Agregar hermano",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar todo",mind_map_delete_node:"Eliminar nodo",mind_map_expand_all:"Expandir todo",mind_map_export_image:"Exportar como imagen",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar a la pantalla",mind_map_redo:"Rehacer",mind_map_undo:"Deshacer",mind_map_zoom_in:"Acercar",mind_map_zoom_out:"Alejar",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",name:"Nombre",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",none_bracketed:"[Ninguno]",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",removing:"Eliminando...",replace:"Reemplazar",report:"Informe",request_date:"Fecha de solicitud",required_field:"Campo obligatorio",resend_code:"Reenviar código",reset_default:"Restablecer predeterminado",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",selected_count:"{{count}} seleccionado",selected_count_plural:"{{count}} 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:"Subordinados",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?",update:"Actualizar",updates:"Actualizaciones",updates_bar_close:"Cerrar",updates_dialog_close:"Cerrar",updates_dialog_do_not_show_again:"No mostrar de nuevo",updates_dialog_like:"Me gusta",updating:"Actualizando...",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 Nl="true"===(void 0).VITE_I18N_DEBUG_MODE;function _l(t,a){e.addResourceBundle(t,"app",a,!0,!0)}Nl&&e.use({type:"postProcessor",name:"debugKeys",process:(e,t)=>`🔑 ${Array.isArray(t)?t[0]:t}`}),e.use(y.initReactI18next).init({resources:{"pt-BR":{core:yl},"en-US":{core:wl},"es-ES":{core:jl}},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:Nl?["debugKeys"]:[]});const Cl=a.createContext({moduleAlias:null,associationsBaseUrl:null,signDocumentsSchema:"common",signDocumentsTable:"sign_documents"});function kl({moduleAlias:e=null,associationsBaseUrl:a=null,signDocumentsSchema:r="common",signDocumentsTable:s="sign_documents",children:n}){return t.jsx(Cl.Provider,{value:{moduleAlias:e,associationsBaseUrl:a,signDocumentsSchema:r,signDocumentsTable:s},children:n})}function Sl(){return a.useContext(Cl)}const Al={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},Tl=6e5;function Dl(e){const{moduleAlias:t,associationsBaseUrl:r}=Sl(),{alias:s,user:n,isAuthenticated:o}=So(),i=e??t,l=n?.id??null,c=o&&!!s&&!!l,{data:d=[],isLoading:u}=j.useQuery({queryKey:["qualiex-associations",l,s,r??null],queryFn:()=>co.fetchUserAssociations(l,s,r?{baseUrl:r}:void 0),enabled:c,staleTime:Tl,gcTime:12e5}),m=a.useMemo(()=>s&&0!==d.length?d.find(e=>e.companyAlias===s)??null:null,[d,s]),p=a.useCallback(e=>{if(!m)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const t=Al[e];return void 0!==t&&m.softwares.includes(t)})},[m]);return{hasAccess:a.useMemo(()=>!i||p(i),[i,p]),isLoading:c&&u,role:a.useMemo(()=>m?{id:m.roleId,name:m.roleName}:null,[m]),association:m,hasAccessTo:p}}const El={"pt-br":"pt-BR","pt-BR":"pt-BR",en:"en-US","en-US":"en-US",es:"es-ES","es-ES":"es-ES",fr:"fr-FR","fr-FR":"fr-FR"};function Pl(){const{association:t}=Dl(),r=t?.language;return a.useEffect(()=>{if(!r)return;const t=El[r];t&&e.language!==t&&e.changeLanguage(t)},[r]),null}const Il=a.createContext(void 0),Ml={locale:rr,timezone:nr,datetimeFormat:sr},Rl=async()=>{},Ll=({children:e})=>t.jsx(Il.Provider,{value:{...Ml,setLocale:Rl,setTimezone:Rl,setDatetimeFormat:Rl,isLoading:!1},children:e}),Fl=()=>{const e=a.useContext(Il);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},zl=be.Root,Ul=be.CollapsibleTrigger,Ol=be.CollapsibleContent;var Bl=Object.defineProperty,ql=(e,t,a)=>((e,t,a)=>t in e?Bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class Vl extends a.Component{constructor(t){super(t),ql(this,"copyErrorDetails",()=>{const t=Gn.getErrors().slice(0,2),a=`\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${t.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||e.t("no_errors_recorded")}\n `.trim();navigator.clipboard.writeText(a),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,t){if((void 0).DEV)throw e;Gn.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Gn.getErrors().slice(0,2);return t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(Pr,{className:"w-full max-w-2xl",children:[t.jsxs(Ir,{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx(c.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),t.jsx(Mr,{children:e.t("something_went_wrong")})]}),t.jsxs(Lr,{className:"space-y-4",children:[t.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),t.jsxs(zl,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[t.jsx(Ul,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[t.jsx(c.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),t.jsxs(Ol,{className:"mt-4 space-y-4",children:[t.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),t.jsxs("div",{className:"text-sm space-y-2",children:[t.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||e.t("unknown_error")}),this.state.error?.stack&&t.jsx(Ai,{className:"h-32 w-full rounded border bg-muted p-2",children:t.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&t.jsxs("div",{className:"pt-3 border-t",children:[t.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),t.jsx("div",{className:"space-y-2",children:a.map((e,a)=>t.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),t.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),t.jsxs(Sr,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[t.jsx(c.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),t.jsx(Sr,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const $l=ve.Root,Wl=te.forwardRef(({className:e,...a},r)=>t.jsx(ve.List,{ref:r,className:_r("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));Wl.displayName=ve.List.displayName;const Hl=te.forwardRef(({className:e,...a},r)=>t.jsx(ve.Trigger,{ref:r,className:_r("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),...a}));Hl.displayName=ve.Trigger.displayName;const Gl=te.forwardRef(({className:e,...a},r)=>t.jsx(ve.Content,{ref:r,className:_r("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));function Kl({className:e}){return t.jsxs("svg",{className:e,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.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"}),t.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"}),t.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 Yl({className:e}){return t.jsxs("svg",{className:e,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.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"}),t.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"}),t.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"})]})}Gl.displayName=ve.Content.displayName;const Ql={init(e){!function(e){try{return t=window,a=document,r="clarity",s="script",n=e,void(a.getElementById("clarity-script")||(t[r]=t[r]||function(){(t[r].q=t[r].q||[]).push(arguments)},(o=a.createElement(s)).async=1,o.src="https://www.clarity.ms/tag/"+n+"?ref=npm",o.id="clarity-script",(i=a.getElementsByTagName(s)[0]).parentNode.insertBefore(o,i)))}catch(l){return}var t,a,r,s,n,o,i}(e)},setTag(e,t){window.clarity("set",e,t)},identify(e,t,a,r){window.clarity("identify",e,t,a,r)},consent(e=!0){window.clarity("consent",e)},consentV2(e={ad_Storage:"granted",analytics_Storage:"granted"}){window.clarity("consentv2",e)},upgrade(e){window.clarity("upgrade",e)},event(e){window.clarity("event",e)}},Xl="forlogic_";function Jl(){return"undefined"!=typeof window&&"function"==typeof window.clarity}function Zl(){return"undefined"!=typeof window&&"piggyback"===window.__forlogicClarityMode}function ec(e){return Zl()?`${Xl}${e}`:e}function tc(e){return Zl()?`${Xl}${e}`:e}function ac(e){try{e()}catch(t){(void 0).DEV}}function rc(e){for(const[t,a]of Object.entries(e))null!=a&&""!==a&&Ql.setTag(tc(t),a)}function sc({module:e,isContracted:t,sourceModule:a,alias:r}){Jl()&&ac(()=>{rc({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:String(t),source_module:a,alias:r}),Ql.event(ec("module_menu_click"))})}function nc({module:e,sourceModule:t,alias:a}){Jl()&&ac(()=>{rc({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:"false",source_module:t,alias:a}),Ql.event(ec("module_interest_click"))})}function oc({resource:e,sourceModule:t,alias:a}){Jl()&&ac(()=>{rc({footer_resource:e,source_module:t,alias:a}),Ql.event(ec("module_footer_click"))})}function ic({educaUrl:e="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:a="https://sabergestao.com.br/",wikiUrl:r,alias:s,sourceModule:n}){const{t:o}=y.useTranslation(),i=br(e||r||"https://educacao.sabergestao.com.br/{alias}/fe",s),l=e=>{oc({resource:e,sourceModule:n,alias:s})};return t.jsxs("div",{className:"flex-shrink-0 pt-4",children:[t.jsx(zr,{className:"mb-4"}),t.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[t.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[t.jsxs("div",{className:"relative z-10",children:[t.jsx("h4",{className:"font-semibold text-sm text-white",children:o("learn_qualiex")}),t.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",t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),t.jsx(Kl,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),t.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[t.jsxs("div",{className:"relative z-10",children:[t.jsx("h4",{className:"font-semibold text-sm text-foreground",children:o("know_saber_gestao")}),t.jsxs("a",{href:a,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",t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),t.jsx(Yl,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),t.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[t.jsxs("div",{className:"relative z-10",children:[t.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),t.jsxs("a",{href:r||"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",t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),t.jsx(c.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}const lc=[{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}"}]},{id:"backoffice",label:"Backoffice",modules:[{name:"Backoffice",description:"Operações administrativas",color:"bg-[#5C6BC0]",url:"https://admin.qualiex.com/{alias}",alwaysContracted:!0}]}];function cc({module:e,onClick:a}){return t.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[t.jsx("div",{className:_r("w-4 h-4 rounded-sm shrink-0 mt-0.5",e.color)}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:e.name}),e.description&&t.jsx("div",{className:"text-sm text-muted-foreground truncate",children:e.description})]})]})}function dc(e,t){if(0===e.length)return e;const a=Math.ceil(e.length/t),r=[];for(let s=0;s<a;s++)for(let n=0;n<t;n++){const t=n*a+s;t<e.length&&r.push(e[t])}return r}function uc({modules:e,onModuleClick:r,contractedModules:s,onModuleInterest:n}){const o=function(){const[e,t]=a.useState(4);return a.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?t(4):window.matchMedia("(min-width: 768px)").matches?t(3):window.matchMedia("(min-width: 640px)").matches?t(2):t(1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...e].sort((e,t)=>e.name.localeCompare(t.name)),l=void 0!==s,c=e=>!0===e.alwaysContracted||!l||s.includes(e.name),d=i.filter(c),u=l?i.filter(e=>!c(e)):[],m=dc(d,o),p=dc(u,o),h=(e,t)=>{t?r?.(e):n?.(e)};return t.jsxs("div",{className:"space-y-6",children:[m.length>0&&t.jsx("section",{children:t.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=>t.jsx(cc,{module:e,onClick:()=>h(e,!0)},e.name))})}),p.length>0&&t.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[t.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:p.map(e=>t.jsx(cc,{module:e,onClick:()=>h(e,!1)},e.name))})]})]})}function mc({onModuleClick:e,contractedModules:r,onModuleInterest:s,nonContractedUrl:n="https://qualiex.com/",educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,alias:c,sourceModule:d,showAdminGroup:u=!1}){const[m,p]=a.useState("qualiex"),h=u?lc.find(e=>"backoffice"===e.id)?.modules??[]:[],x=lc.filter(e=>"backoffice"!==e.id).map(e=>"qualiex"===e.id?{...e,modules:[...e.modules,...h]}:e),f=e=>{nc({module:e,sourceModule:d,alias:c}),window.open(n,"_blank","noopener,noreferrer"),s?.(e)};return t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[t.jsxs($l,{value:m,onValueChange:p,className:"flex-1 flex flex-col min-h-0",children:[t.jsx(Wl,{className:"w-fit shrink-0",children:x.map(e=>t.jsxs(Hl,{value:e.id,children:[e.label,t.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),x.map(a=>t.jsx(Gl,{value:a.id,className:"flex-1 mt-4 overflow-auto pr-2",children:t.jsx(uc,{modules:a.modules,onModuleClick:t=>{return s=t,n=a.id,sc({module:s,isContracted:!!s.alwaysContracted||"qualiex"!==n||!r||r.includes(s.name),sourceModule:d,alias:c}),void e?.(s);var s,n},contractedModules:"qualiex"===a.id?r:void 0,onModuleInterest:f})},a.id))]}),t.jsx(ic,{educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:c,sourceModule:d})]})}function pc(e){const{association:t}=Dl();return a.useMemo(()=>{if(e)return e;if(!t?.softwares)return;const a=t.softwares,r=lc.find(e=>"qualiex"===e.id);return r?r.modules.filter(e=>{if(!e.softwareAlias)return!1;const t=Al[e.softwareAlias];return void 0!==t&&a.includes(t)}).map(e=>e.name):void 0},[e,t])}function hc({open:e,onOpenChange:a,onModuleClick:r,contractedModules:s,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:c,showAdminGroup:d}){const{alias:u,user:m}=So(),p=pc(s),h=d??!!m?.isSysAdmin;return t.jsx(Qr,{open:e,onOpenChange:a,children:t.jsxs(as,{size:"lg",className:"overflow-hidden flex flex-col",children:[t.jsx(rs,{className:"sr-only",children:t.jsx(os,{children:"Módulos"})}),t.jsx(mc,{onModuleClick:e=>{r?r(e):e.url&&gr(br(e.url,u||void 0))},contractedModules:p,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:u||void 0,sourceModule:c,showAdminGroup:h})]})})}function xc({open:r,onOpenChange:s,onModuleClick:n,contractedModules:o,onModuleInterest:i,userName:l,unitName:d,units:u=[],currentAlias:m,onUnitChange:p,onLogout:h,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,blocking:b=!0,size:v="lg",children:w,sourceModule:j}){const{t:N}=y.useTranslation(),_=a.useMemo(()=>{if(!u.length)return[];const e=new Map;u.forEach(t=>e.set(t.alias,t));const t=Array.from(e.values()),a=t.find(e=>e.alias===m),r=t.filter(e=>e.alias!==m).sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"}));return a?[a,...r]:r},[u,m]);return t.jsx(Qr,{open:r,onOpenChange:b?void 0:s,children:t.jsxs(as,{size:v,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:b?e=>e.preventDefault():void 0,onEscapeKeyDown:b?e=>e.preventDefault():void 0,children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[t.jsx(os,{children:N("no_access_page")}),t.jsx(is,{children:"Selecione um módulo para continuar navegando!"})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.length>1&&t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[t.jsx(c.Building2,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:d||"Unidade"}),t.jsx(c.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),t.jsx($s,{align:"end",className:"max-h-[300px] overflow-auto",children:_.map(e=>t.jsxs(Ws,{onClick:()=>p?.(e),className:e.alias===m?"bg-muted":"",children:[t.jsx(c.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate",children:e.name}),e.alias===m&&t.jsx(Es,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},e.alias))})]}),t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"gap-2",children:[t.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:t.jsx(c.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),t.jsx(c.ChevronDown,{className:"h-3 w-3"})]})}),t.jsxs($s,{align:"end",children:[t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsx("p",{className:"text-sm font-medium",children:l||e.t("user")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:d})]}),t.jsx(Ys,{}),t.jsxs(Ws,{onClick:h,children:[t.jsx(c.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),w?t.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[t.jsx("div",{className:"flex-1",children:w}),t.jsx(ic,{educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:j})]}):t.jsx(mc,{onModuleClick:n,contractedModules:o,onModuleInterest:i,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:j})]})})}function fc(e,t){return t.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t)}function gc({children:e,contractedModules:r,onModuleClick:s,onModuleInterest:n,educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:c,noAccessRedirectPath:d,noAccessRedirectMode:u,accessDeniedRoutes:m,sourceModule:p}){const{t:h}=y.useTranslation(),{hasAccess:x,isLoading:f,association:g}=Dl(),{user:b,alias:v,companies:w,isAuthenticated:j,isLoading:N,logout:_,switchUnit:C}=So(),k=pc(r),S=a.useMemo(()=>w?.length?v&&w.find(e=>e.alias===v)||w[0]:null,[w,v]),A=a.useMemo(()=>w?.length?w.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[w]),T=a.useCallback(e=>{const t=w?.find(t=>t.alias===e.alias);if(!t)return;const{pathname:a,search:r,hash:s}=window.location;if(v){const e=a.split("/"),n=e.indexOf(v);if(n>=0)return e[n]=t.alias,void(window.location.href=e.join("/")+r+s)}C(t)},[v,C,w]),D=a.useCallback(e=>{s?s(e):e.url&&gr(br(e.url,v||void 0))},[s,v]),E=a.useMemo(()=>{if(!m)return;const e="undefined"!=typeof window?window.location.pathname:"",t=Object.keys(m).find(t=>fc(e,[t]));return t?m[t]:void 0},[m]),P="undefined"!=typeof window?window.location.pathname:"",I=!(!c?.length||!fc(P,c)),M=!N&&j&&!f&&!x&&!I&&!!d&&"always"===(u??"always")?function(e,t){return t&&e.startsWith("/")?e.split("/")[1]===t?e:`/${t}${e}`:e}(d,v):null;return a.useEffect(()=>{M&&M!==P&&window.location.replace(M)},[M,P]),N||!j||I?t.jsx(t.Fragment,{children:e}):f?t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsx(Is,{size:"lg"})}):x?t.jsx(t.Fragment,{children:e}):M?M===P?t.jsx(t.Fragment,{children:e}):t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsx(Is,{size:"lg"})}):t.jsx(xc,{open:!0,onModuleClick:D,contractedModules:k,onModuleInterest:n,userName:b?.name,unitName:S?.name,units:A,currentAlias:v||void 0,onUnitChange:T,onLogout:_,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:p,blocking:!0,children:E})}let bc=!1;function vc(){if(bc||"undefined"==typeof document)return;bc=!0;for(const t of["https://fonts.googleapis.com","https://fonts.gstatic.com"])if(!document.querySelector(`link[href="${t}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=t,t.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 t of e)if(!document.querySelector(`link[href="${t}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}}function yc({projectId:e,mode:t="auto"}){const{user:r,alias:s,isAuthenticated:n}=So();a.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==t&&e&&!We()&&!window.__forlogicClarityOwned)if("function"!=typeof window.clarity)try{Ql.init(e),window.__forlogicClarityOwned=!0,window.__forlogicClarityMode="owned"}catch(a){(void 0).DEV,window.__forlogicClarityMode="inactive"}else window.__forlogicClarityMode="piggyback"},[e,t]),a.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==t&&n&&r&&"function"==typeof window.clarity)try{const e=r.email||r.identifier||"anonymous";Ql.identify(e,void 0,"modules-menu",r.name||void 0),s&&Ql.setTag("alias",s),"boolean"==typeof r.isSysAdmin&&Ql.setTag("isSysAdmin",String(r.isSysAdmin))}catch(e){(void 0).DEV}},[r,s,n,t])}let wc="legacy";function jc({projectId:e,mode:t}){return yc({projectId:e,mode:t}),null}function Nc(){if(!Fe())return null;const e=Kn((void 0).VITE_SUPABASE_PUBLISHABLE_KEY),a=!!(void 0).VITE_SUPABASE_PK_OVERRIDE;if(!e||a||!(void 0).DEV)return null;const r={background:"rgba(0,0,0,.2)",padding:"1px 4px",borderRadius:4};return t.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,zIndex:99999,background:"#dc2626",color:"#fff",padding:"8px 16px",fontSize:"13px",fontFamily:"Inter, system-ui, sans-serif",textAlign:"center",lineHeight:1.4},children:[t.jsx("strong",{children:"⚠️ Legacy Supabase Key Detectada"})," — O ",t.jsx("code",{style:r,children:"VITE_SUPABASE_PUBLISHABLE_KEY"})," contém uma anon key JWT legada. Adicione ",t.jsx("code",{style:r,children:'VITE_SUPABASE_PK_OVERRIDE="sb_publishable_..."'})," no .env para corrigir."]})}const _c=ye.Root,Cc=te.forwardRef(({className:e,...a},r)=>t.jsx(ye.Item,{ref:r,className:_r("border-b",e),...a}));Cc.displayName="AccordionItem";const kc=te.forwardRef(({className:e,children:a,...r},s)=>t.jsx(ye.Header,{className:"flex",children:t.jsxs(ye.Trigger,{ref:s,className:_r("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...r,children:[a,t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));kc.displayName=ye.Trigger.displayName;const Sc=te.forwardRef(({className:e,children:a,...r},s)=>t.jsx(ye.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:t.jsx("div",{className:_r("pb-4 pt-0",e),children:a})}));Sc.displayName=ye.Content.displayName;const Ac=te.forwardRef(({...e},a)=>t.jsx("nav",{ref:a,"aria-label":"breadcrumb",...e}));Ac.displayName="Breadcrumb";const Tc=te.forwardRef(({className:e,...a},r)=>t.jsx("ol",{ref:r,className:_r("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...a}));Tc.displayName="BreadcrumbList";const Dc=te.forwardRef(({className:e,...a},r)=>t.jsx("li",{ref:r,className:_r("inline-flex items-center gap-1.5",e),...a}));Dc.displayName="BreadcrumbItem";const Ec=te.forwardRef(({asChild:e,className:a,...s},n)=>{const o=e?r.Slot:"a";return t.jsx(o,{ref:n,className:_r("transition-colors hover:text-foreground",a),...s})});Ec.displayName="BreadcrumbLink";const Pc=te.forwardRef(({className:e,...a},r)=>t.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:_r("font-normal text-foreground",e),...a}));Pc.displayName="BreadcrumbPage";const Ic=({children:e,className:a,...r})=>t.jsx("li",{role:"presentation","aria-hidden":"true",className:_r("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...r,children:e??t.jsx(c.ChevronRight,{})});Ic.displayName="BreadcrumbSeparator";const Mc=({className:e,...a})=>t.jsxs("span",{role:"presentation","aria-hidden":"true",className:_r("flex h-9 w-9 items-center justify-center",e),...a,children:[t.jsx(c.MoreHorizontal,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Mais"})]});Mc.displayName="BreadcrumbEllipsis";const Rc=s.cva("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),Lc=te.forwardRef(({className:e,orientation:a,...r},s)=>t.jsx("div",{ref:s,className:_r(Rc({orientation:a}),e),...r}));Lc.displayName="ButtonGroup";const Fc={"pt-BR":Za,"en-US":jt,"es-ES":Ga};function zc({className:e,classNames:a,showOutsideDays:r=!0,captionLayout:s,fromYear:n,toYear:o,startMonth:i,endMonth:l,...d}){const{i18n:u}=y.useTranslation(),m=Fc[u.language]??Za,p=te.useMemo(()=>i??(n?new Date(n,0,1):void 0),[i,n]),h=te.useMemo(()=>l??(o?new Date(o,11,31):void 0),[l,o]),x=s?.startsWith("dropdown");return t.jsx(I.DayPicker,{showOutsideDays:r,className:_r("p-3 pointer-events-auto",e),locale:m,captionLayout:s,startMonth:p,endMonth:h,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:_r("flex h-9 w-full items-center px-8",x?"justify-center gap-1.5":"justify-center"),nav:_r("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1","dropdown"===s&&"hidden"),button_previous:_r(kr({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:_r(kr({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:_r(kr({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",dropdowns:"flex items-center gap-1.5",dropdown_root:"relative inline-flex items-center",dropdown:_r("cursor-pointer appearance-none rounded-md border border-input bg-background","h-8 pl-2.5 pr-7 text-sm font-medium text-foreground","hover:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","transition-colors","bg-[right_0.5rem_center] bg-no-repeat","bg-[url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='16'%20height='16'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='hsl(215%2016%25%2047%25)'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='m6%209%206%206%206-6'/%3E%3C/svg%3E\")]"),caption_label:x?"sr-only":"text-sm font-medium",...a},components:{Chevron:({orientation:e})=>"left"===e?t.jsx(c.ChevronLeft,{className:"h-4 w-4"}):t.jsx(c.ChevronRight,{className:"h-4 w-4"})},...d})}zc.displayName="Calendar";const Uc={Root:function({children:e,className:a}){return t.jsx("div",{className:_r("space-y-4",a),children:e})},Item:function({children:e,onClick:a,className:r}){return t.jsx(Pr,{className:_r("transition-colors",a&&"cursor-pointer hover:bg-muted/50",r),onClick:a,children:t.jsx(Lr,{className:"p-4",children:e})})},Field:function({label:e,value:a,className:r}){return t.jsxs("div",{className:_r("flex justify-between items-center text-sm",r),children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),t.jsx("span",{className:"text-foreground",children:a})]})}};const Oc=({shouldScaleBackground:e=!0,...a})=>t.jsx(M.Drawer.Root,{shouldScaleBackground:e,...a});Oc.displayName="Drawer";const Bc=M.Drawer.Trigger,qc=M.Drawer.Portal,Vc=M.Drawer.Close,$c=te.forwardRef(({className:e,...a},r)=>t.jsx(M.Drawer.Overlay,{ref:r,className:_r("fixed inset-0 z-50 bg-black/80",e),...a}));$c.displayName=M.Drawer.Overlay.displayName;const Wc=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(qc,{children:[t.jsx($c,{}),t.jsxs(M.Drawer.Content,{ref:s,className:_r("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",e),...r,children:[t.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));Wc.displayName="DrawerContent";const Hc=({className:e,...a})=>t.jsx("div",{className:_r("grid gap-1.5 p-4 text-center sm:text-left",e),...a});Hc.displayName="DrawerHeader";const Gc=({className:e,...a})=>t.jsx("div",{className:_r("mt-auto flex flex-col gap-2 p-4",e),...a});Gc.displayName="DrawerFooter";const Kc=te.forwardRef(({className:e,...a},r)=>t.jsx(M.Drawer.Title,{ref:r,className:_r("text-lg font-semibold leading-none tracking-tight",e),...a}));Kc.displayName=M.Drawer.Title.displayName;const Yc=te.forwardRef(({className:e,...a},r)=>t.jsx(M.Drawer.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Yc.displayName=M.Drawer.Description.displayName;const Qc={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))]"},Xc={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Jc=we.Root,Zc=we.Trigger,ed=te.forwardRef(({className:e,align:a="center",sideOffset:r=4,...s},n)=>t.jsx(we.Content,{ref:n,align:a,sideOffset:r,className:_r("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),...s}));ed.displayName=we.Content.displayName;const td=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-slot":"input-group",className:_r("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),...a}));td.displayName="InputGroup";const ad=s.cva("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),rd=te.forwardRef(({className:e,align:a,...r},s)=>t.jsx("div",{ref:s,"data-slot":"input-group-addon",className:_r(ad({align:a}),e),...r}));rd.displayName="InputGroupAddon";const sd=s.cva("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),nd=te.forwardRef(({className:e,size:a,variant:r="ghost",...s},n)=>t.jsx(Sr,{ref:n,"data-slot":"input-group-button",variant:r,className:_r(sd({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",e),...s}));nd.displayName="InputGroupButton";const od=te.forwardRef(({className:e,...a},r)=>t.jsx(Tr,{ref:r,"data-slot":"input-group-control",className:_r("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...a}));od.displayName="InputGroupInput";const id=te.forwardRef(({className:e,...a},r)=>t.jsx(Ts,{ref:r,"data-slot":"input-group-control",className:_r("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...a}));id.displayName="InputGroupTextarea";const ld=te.forwardRef(({className:e,...a},r)=>t.jsx("h1",{ref:r,className:_r("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",e),...a}));ld.displayName="H1";const cd=te.forwardRef(({className:e,...a},r)=>t.jsx("h2",{ref:r,className:_r("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",e),...a}));cd.displayName="H2";const dd=te.forwardRef(({className:e,...a},r)=>t.jsx("h3",{ref:r,className:_r("scroll-m-20 text-2xl font-semibold tracking-tight",e),...a}));dd.displayName="H3";const ud=te.forwardRef(({className:e,...a},r)=>t.jsx("h4",{ref:r,className:_r("scroll-m-20 text-xl font-semibold tracking-tight",e),...a}));ud.displayName="H4";const md=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("leading-7 [&:not(:first-child)]:mt-6",e),...a}));md.displayName="P";const pd=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("text-xl text-muted-foreground",e),...a}));pd.displayName="Lead";const hd=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("text-lg font-semibold",e),...a}));hd.displayName="Large";const xd=te.forwardRef(({className:e,...a},r)=>t.jsx("small",{ref:r,className:_r("text-sm font-medium leading-none",e),...a}));xd.displayName="Small";const fd=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));fd.displayName="Muted";const gd=te.forwardRef(({className:e,...a},r)=>t.jsx("code",{ref:r,className:_r("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",e),...a}));gd.displayName="InlineCode";const bd=te.forwardRef(({className:e,...a},r)=>t.jsx("blockquote",{ref:r,className:_r("mt-6 border-l-2 pl-6 italic",e),...a}));bd.displayName="Blockquote";const vd=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,className:_r("my-6 ml-6 list-disc [&>li]:mt-2",e),...a}));vd.displayName="List";const yd=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(je.Root,{ref:s,className:_r("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...r,children:[a,t.jsx(Sd,{})]}));yd.displayName=je.Root.displayName;const wd=te.forwardRef(({className:e,...a},r)=>t.jsx(je.List,{ref:r,className:_r("group flex flex-1 list-none items-center justify-center space-x-1",e),...a}));wd.displayName=je.List.displayName;const jd=je.Item,Nd=s.cva("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),_d=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(je.Trigger,{ref:s,className:_r(Nd(),"group",e),...r,children:[a," ",t.jsx(c.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));_d.displayName=je.Trigger.displayName;const Cd=te.forwardRef(({className:e,...a},r)=>t.jsx(je.Content,{ref:r,className:_r("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),...a}));Cd.displayName=je.Content.displayName;const kd=je.Link,Sd=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{className:_r("absolute left-0 top-full flex justify-center"),children:t.jsx(je.Viewport,{className:_r("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:r,...a})}));Sd.displayName=je.Viewport.displayName;const Ad=te.forwardRef(({className:e,...a},r)=>t.jsx(je.Indicator,{ref:r,className:_r("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),...a,children:t.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ad.displayName=je.Indicator.displayName;const Td=({className:e,...a})=>t.jsx("nav",{role:"navigation","aria-label":"pagination",className:_r("mx-auto flex w-full justify-center",e),...a});Td.displayName="Pagination";const Dd=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,className:_r("flex flex-row items-center gap-1",e),...a}));Dd.displayName="PaginationContent";const Ed=te.forwardRef(({className:e,...a},r)=>t.jsx("li",{ref:r,className:_r("",e),...a}));Ed.displayName="PaginationItem";const Pd=({className:e,isActive:a,size:r="icon",...s})=>t.jsx("a",{"aria-current":a?"page":void 0,className:_r(kr({variant:a?"outline":"ghost",size:r}),e),...s});Pd.displayName="PaginationLink";const Id=({className:a,...r})=>t.jsxs(Pd,{"aria-label":e.t("go_to_previous_page"),size:"default",className:_r("gap-1 pl-2.5",a),...r,children:[t.jsx(c.ChevronLeft,{className:"h-4 w-4"}),t.jsx("span",{children:"Previous"})]});Id.displayName="PaginationPrevious";const Md=({className:a,...r})=>t.jsxs(Pd,{"aria-label":e.t("go_to_next_page"),size:"default",className:_r("gap-1 pr-2.5",a),...r,children:[t.jsx("span",{children:"Next"}),t.jsx(c.ChevronRight,{className:"h-4 w-4"})]});Md.displayName="PaginationNext";const Rd=({className:e,...a})=>t.jsxs("span",{"aria-hidden":!0,className:_r("flex h-9 w-9 items-center justify-center",e),...a,children:[t.jsx(c.MoreHorizontal,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"More pages"})]});Rd.displayName="PaginationEllipsis";const Ld=te.forwardRef(({className:e,value:a,...r},s)=>t.jsx(Ne.Root,{ref:s,className:_r("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...r,children:t.jsx(Ne.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));Ld.displayName=Ne.Root.displayName;const Fd=te.forwardRef(({className:e,...a},r)=>t.jsx(_e.Root,{className:_r("grid gap-2",e),...a,ref:r}));Fd.displayName=_e.Root.displayName;const zd=te.forwardRef(({className:e,...a},r)=>t.jsx(_e.Item,{ref:r,className:_r("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),...a,children:t.jsx(_e.Indicator,{className:"flex items-center justify-center",children:t.jsx(c.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));zd.displayName=_e.Item.displayName;const Ud=Ce.Panel,Od=se.Root,Bd=se.Trigger,qd=se.Close,Vd=se.Portal,$d=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Overlay,{className:_r("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),...a,ref:r}));$d.displayName=se.Overlay.displayName;const Wd=s.cva("fixed z-50 flex flex-col bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Hd=te.forwardRef(({side:e="right",className:a,children:r,...s},n)=>t.jsxs(Vd,{children:[t.jsx($d,{}),t.jsxs(se.Content,{ref:n,className:_r(Wd({side:e}),a),...s,children:[r,t.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:[t.jsx(c.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Hd.displayName=se.Content.displayName;const Gd=({className:e,showSeparator:a=!1,children:r,...s})=>t.jsxs("div",{className:_r("flex flex-col flex-shrink-0",e),...s,children:[t.jsx("div",{className:"flex flex-col text-left",children:r}),a&&t.jsx(zr,{className:"mt-2"})]});Gd.displayName="SheetHeader";const Kd=({className:e,...a})=>t.jsx("div",{className:_r("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",e),...a});Kd.displayName="SheetBody";const Yd=({className:e,children:a,...r})=>t.jsxs("div",{className:"flex-shrink-0 pt-4",children:[t.jsx(zr,{className:"mb-4"}),t.jsx("div",{className:_r("flex flex-row justify-end gap-2",e),...r,children:a})]});Yd.displayName="SheetFooter";const Qd=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Title,{ref:r,className:_r("text-lg font-semibold text-foreground",e),...a}));Qd.displayName=se.Title.displayName;const Xd=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Xd.displayName=se.Description.displayName;const Jd="sidebar:state",Zd=te.createContext(null);function eu(){const e=te.useContext(Zd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const tu=te.forwardRef(({defaultOpen:e=!0,open:a,onOpenChange:r,className:s,style:n,children:o,...i},l)=>{const c=Do(),[d,u]=te.useState(!1),[m,p]=te.useState(()=>{if("undefined"!=typeof window){const t=localStorage.getItem(Jd);return null!==t?"true"===t:e}return e}),h=a??m,x=te.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Jd,String(t))},[r,h]),f=te.useCallback(()=>c?u(e=>!e):x(e=>!e),[c,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",b=te.useMemo(()=>({state:g,open:h,setOpen:x,isMobile:c,openMobile:d,setOpenMobile:u,toggleSidebar:f}),[g,h,x,c,d,u,f]);return t.jsx(Zd.Provider,{value:b,children:t.jsx(Xs,{delayDuration:0,children:t.jsx("div",{className:_r("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",s),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4rem",...n},ref:l,...i,children:o})})})});tu.displayName="SidebarProvider";const au=te.forwardRef(({side:e="left",variant:a="sidebar",collapsible:r="offcanvas",className:s,children:n,...o},i)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=eu();return"none"===r?t.jsx("div",{className:_r("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:i,...o,children:n}):l?t.jsx(Od,{open:d,onOpenChange:u,...o,children:t.jsxs(Hd,{"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:[t.jsx(Qd,{className:"sr-only",children:"Menu de Navegação"}),t.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):t.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?r:"","data-variant":a,"data-side":e,children:[t.jsx("div",{className:_r("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"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),t.jsx("div",{className:_r("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"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...o,children:t.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})})]})});au.displayName="Sidebar";const ru=te.forwardRef(({className:e,onClick:a,...r},s)=>{const{toggleSidebar:n}=eu();return t.jsxs(Sr,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:_r("h-7 w-7",e),onClick:e=>{a?.(e),n()},...r,children:[t.jsx(c.PanelLeft,{}),t.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ru.displayName="SidebarTrigger";const su=te.forwardRef(({className:e,...a},r)=>{const{toggleSidebar:s}=eu();return t.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:_r("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),...a})});su.displayName="SidebarRail";const nu=te.forwardRef(({className:e,...a},r)=>t.jsx("main",{ref:r,className:_r("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),...a}));nu.displayName="SidebarInset";const ou=te.forwardRef(({className:e,...a},r)=>t.jsx(Tr,{ref:r,"data-sidebar":"input",className:_r("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...a}));ou.displayName="SidebarInput";const iu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"header",className:_r("flex flex-col gap-2 p-2",e),...a}));iu.displayName="SidebarHeader";const lu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"footer",className:_r("flex flex-col gap-2 p-2",e),...a}));lu.displayName="SidebarFooter";const cu=te.forwardRef(({className:e,...a},r)=>t.jsx(zr,{ref:r,"data-sidebar":"separator",className:_r("mx-2 w-auto bg-sidebar-border",e),...a}));cu.displayName="SidebarSeparator";const du=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"content",className:_r("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...a}));du.displayName="SidebarContent";const uu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"group",className:_r("relative flex w-full min-w-0 flex-col p-2",e),...a}));uu.displayName="SidebarGroup";const mu=te.forwardRef(({className:e,asChild:a=!1,...s},n)=>{const o=a?r.Slot:"div";return t.jsx(o,{ref:n,"data-sidebar":"group-label",className:_r("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),...s})});mu.displayName="SidebarGroupLabel";const pu=te.forwardRef(({className:e,asChild:a=!1,...s},n)=>{const o=a?r.Slot:"button";return t.jsx(o,{ref:n,"data-sidebar":"group-action",className:_r("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),...s})});pu.displayName="SidebarGroupAction";const hu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"group-content",className:_r("w-full text-sm",e),...a}));hu.displayName="SidebarGroupContent";const xu=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,"data-sidebar":"menu",className:_r("flex w-full min-w-0 flex-col gap-1",e),...a}));xu.displayName="SidebarMenu";const fu=te.forwardRef(({className:e,...a},r)=>t.jsx("li",{ref:r,"data-sidebar":"menu-item",className:_r("group/menu-item relative",e),...a}));fu.displayName="SidebarMenuItem";const gu=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),bu=te.forwardRef(({asChild:e=!1,isActive:a=!1,variant:s="default",size:n="default",tooltip:o,className:i,...l},c)=>{const d=e?r.Slot:"button",{isMobile:u,state:m}=eu(),p=t.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":n,"data-active":a,className:_r(gu({variant:s,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:p}),t.jsx(en,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});bu.displayName="SidebarMenuButton";const vu=te.forwardRef(({className:e,asChild:a=!1,showOnHover:s=!1,...n},o)=>{const i=a?r.Slot:"button";return t.jsx(i,{ref:o,"data-sidebar":"menu-action",className:_r("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",s&&"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})});vu.displayName="SidebarMenuAction";const yu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:_r("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),...a}));yu.displayName="SidebarMenuBadge";const wu=te.forwardRef(({className:e,showIcon:a=!1,...r},s)=>{const n=te.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return t.jsxs("div",{ref:s,"data-sidebar":"menu-skeleton",className:_r("rounded-md h-8 flex gap-2 px-2 items-center",e),...r,children:[a&&t.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),t.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});wu.displayName="SidebarMenuSkeleton";const ju=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:_r("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),...a}));ju.displayName="SidebarMenuSub";const Nu=te.forwardRef(({...e},a)=>t.jsx("li",{ref:a,...e}));Nu.displayName="SidebarMenuSubItem";const _u=te.forwardRef(({asChild:e=!1,size:a="md",isActive:s,className:n,...o},i)=>{const l=e?r.Slot:"a";return t.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":a,"data-active":s,className:_r("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"===a&&"text-xs","md"===a&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});_u.displayName="SidebarMenuSubButton";const Cu=te.forwardRef(({className:e,value:a,defaultValue:r,...s},n)=>{const o=a||r||[0];return t.jsxs(ke.Root,{ref:n,value:a,defaultValue:r,className:_r("relative flex w-full touch-none select-none items-center",e),...s,children:[t.jsx(ke.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:t.jsx(ke.Range,{className:"absolute h-full bg-primary"})}),o.map((e,a)=>t.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"},a))]})});Cu.displayName=ke.Root.displayName;const ku=Se.Menu,Su=Se.Group,Au=Se.Portal,Tu=Se.Sub,Du=Se.RadioGroup,Eu=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.Root,{ref:r,className:_r("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",e),...a}));Eu.displayName=Se.Root.displayName;const Pu=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.Trigger,{ref:r,className:_r("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),...a}));Pu.displayName=Se.Trigger.displayName;const Iu=te.forwardRef(({className:e,inset:a,children:r,...s},n)=>t.jsxs(Se.SubTrigger,{ref:n,className:_r("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",e),...s,children:[r,t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Iu.displayName=Se.SubTrigger.displayName;const Mu=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.SubContent,{ref:r,className:_r("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),...a}));Mu.displayName=Se.SubContent.displayName;const Ru=te.forwardRef(({className:e,align:a="start",alignOffset:r=-4,sideOffset:s=8,...n},o)=>t.jsx(Se.Portal,{children:t.jsx(Se.Content,{ref:o,align:a,alignOffset:r,sideOffset:s,className:_r("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})}));Ru.displayName=Se.Content.displayName;const Lu=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(Se.Item,{ref:s,className:_r("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",e),...r}));Lu.displayName=Se.Item.displayName;const Fu=te.forwardRef(({className:e,children:a,checked:r,...s},n)=>t.jsxs(Se.CheckboxItem,{ref:n,className:_r("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:r,...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Se.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),a]}));Fu.displayName=Se.CheckboxItem.displayName;const zu=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(Se.RadioItem,{ref:s,className:_r("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),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Se.ItemIndicator,{children:t.jsx(c.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));zu.displayName=Se.RadioItem.displayName;const Uu=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(Se.Label,{ref:s,className:_r("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...r}));Uu.displayName=Se.Label.displayName;const Ou=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-muted",e),...a}));Ou.displayName=Se.Separator.displayName;const Bu=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});Bu.displayname="MenubarShortcut";const qu={light:"",dark:".dark"},Vu=te.createContext(null);function $u(){const e=te.useContext(Vu);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Wu=te.forwardRef(({id:e,className:a,children:r,config:s,...n},o)=>{const i=te.useId(),l=`chart-${e||i.replace(/:/g,"")}`;return t.jsx(Vu.Provider,{value:{config:s},children:t.jsxs("div",{"data-chart":l,ref:o,className:_r("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[t.jsx(Hu,{id:l,config:s}),t.jsx(Ae.ResponsiveContainer,{children:r})]})})});Wu.displayName="Chart";const Hu=({id:e,config:a})=>{const r=Object.entries(a).filter(([,e])=>e.theme||e.color);return r.length?t.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(qu).map(([t,a])=>`\n${a} [data-chart=${e}] {\n${r.map(([e,a])=>{const r=a.theme?.[t]||a.color;return r?` --color-${e}: ${r};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Gu=Ae.Tooltip,Ku=te.forwardRef(({active:e,payload:a,className:r,indicator:s="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:c,formatter:d,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=$u(),f=te.useMemo(()=>{if(n||!a?.length)return null;const[e]=a,r=Xu(x,e,`${p||e?.dataKey||e?.name||"value"}`),s=p||"string"!=typeof i?r?.label:x[i]?.label||i;return l?t.jsx("div",{className:_r("font-medium",c),children:l(s,a)}):s?t.jsx("div",{className:_r("font-medium",c),children:s}):null},[i,l,a,n,c,x,p]);if(!e||!a?.length)return null;const g=1===a.length&&"dot"!==s;return t.jsxs("div",{ref:h,className:_r("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",r),children:[g?null:f,t.jsx("div",{className:"grid gap-1.5",children:a.map((e,a)=>{const r=`${m||e.name||e.dataKey||"value"}`,n=Xu(x,e,r),i=u||e.payload?.fill||e.color;return t.jsx("div",{className:_r("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===s&&"items-center"),children:d&&void 0!==e?.value&&e.name?d(e.value,e.name,e,a,e.payload):t.jsxs(t.Fragment,{children:[n?.icon?t.jsx(n.icon,{}):!o&&t.jsx("div",{className:_r("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===s,"w-1":"line"===s,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===s,"my-0.5":g&&"dashed"===s}),style:{"--color-bg":i,"--color-border":i}}),t.jsxs("div",{className:_r("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[t.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,t.jsx("span",{className:"text-muted-foreground",children:n?.label||e.name})]}),void 0!==e.value&&t.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString():e.value})]})]})},e.dataKey||a)})})]})});Ku.displayName="ChartTooltip";const Yu=Ae.Legend,Qu=te.forwardRef(({className:e,hideIcon:a=!1,payload:r,verticalAlign:s="bottom",nameKey:n},o)=>{const{config:i}=$u();return r?.length?t.jsx("div",{ref:o,className:_r("flex items-center justify-center gap-4","top"===s?"pb-3":"pt-3",e),children:r.map(e=>{const r=`${n||e.dataKey||"value"}`,s=Xu(i,e,r);return t.jsxs("div",{className:_r("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[s?.icon&&!a?t.jsx(s.icon,{}):t.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),s?.label]},e.value)})}):null});function Xu(e,t,a){if("object"!=typeof t||null===t)return;const r="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let s=a;return a in t&&"string"==typeof t[a]?s=t[a]:r&&a in r&&"string"==typeof r[a]&&(s=r[a]),s in e?e[s]:e[a]}Qu.displayName="ChartLegend";const Ju=({onClick:e,isActive:a,disabled:r,children:s,title:n})=>t.jsx("button",{type:"button",onClick:e,disabled:r,title:n,className:_r("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",r&&"opacity-50 cursor-not-allowed"),children:s}),Zu=()=>t.jsx("div",{className:"w-px h-5 bg-border mx-1"});function em({image:e,title:a,className:r}){return t.jsx("div",{className:_r("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",r),children:e?t.jsx("img",{src:e,alt:a,className:"w-full h-full object-cover"}):t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(c.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function tm({steps:e,currentStepIndex:a,onStepSelect:r,stepLabel:s,className:n}){const{t:o}=y.useTranslation(),i=e.length,l=(a+1)/i*100;return t.jsxs("div",{className:_r("flex items-center gap-3",n),children:[t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[s," ",a+1,"/",i,t.jsx(c.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),t.jsx($s,{align:"start",children:e.map((e,s)=>t.jsxs(Ws,{onClick:()=>r(s),className:_r(s===a&&"bg-accent"),children:[s+1,". ",e.title]},e.id))})]}),t.jsx(Ld,{value:l,className:"w-32 h-2"})]})}function am({currentStepIndex:e,totalSteps:a,onBack:r,onNext:s,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:l,className:d}){const{t:u}=y.useTranslation(),m=0===e,p=e===a-1;return t.jsxs("div",{className:_r("flex items-center gap-2",d),children:[!m&&t.jsxs(Sr,{variant:"outline",onClick:r,size:"sm",children:[t.jsx(c.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),t.jsxs(Sr,{onClick:p?n:s,size:"sm",children:[p?l:i,!p&&t.jsx(c.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const rm=te.forwardRef(({open:a,onOpenChange:r,steps:s,onComplete:n,onStepChange:o,continueButtonText:i="Continuar",backButtonText:l="Voltar",finishButtonText:d="Concluir",stepLabel:u=e.t("approval_step_label"),size:m="md",showProgressIndicator:p=!0,currentStepIndex:h,onCurrentStepChange:x,className:f},g)=>{const[b,v]=te.useState(0),y=void 0!==h,w=y?h:b,j=te.useCallback(e=>{y?x?.(e):v(e),o?.(e)},[y,x,o]);te.useEffect(()=>{a||y||v(0)},[a,y]);const N=s[w],_=s.length;return N?t.jsx(Qr,{open:a,onOpenChange:r,children:t.jsxs(as,{ref:g,size:m,variant:"informative",className:_r("p-0 gap-0 overflow-hidden",f),children:[t.jsxs(Zr,{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:[t.jsx(c.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Fechar"})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsxs("div",{className:"p-6 space-y-4",children:[t.jsx(em,{image:N.image,title:N.title}),t.jsx(os,{className:"text-xl font-semibold",children:N.title}),t.jsx(is,{className:"text-muted-foreground",children:N.description})]})}),t.jsxs("div",{className:"flex-shrink-0",children:[t.jsx(zr,{}),t.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[p&&_>1?t.jsx(tm,{steps:s,currentStepIndex:w,onStepSelect:e=>{j(e)},stepLabel:u}):t.jsx("div",{}),t.jsx(am,{currentStepIndex:w,totalSteps:_,onBack:()=>{w>0&&j(w-1)},onNext:()=>{w<_-1&&j(w+1)},onComplete:()=>{n?.(),r(!1)},backButtonText:l,continueButtonText:i,finishButtonText:d})]})]})]})}):null});function sm({label:e,onClick:a,icon:r,actions:s=[],variant:n="default",size:o="default",disabled:i=!1,loading:l=!1,menuAlign:d="end",className:u}){const{t:m}=y.useTranslation(),p=i||l;if(!(s.length>0))return t.jsxs(Sr,{variant:n,size:o,disabled:p,onClick:a,className:u,children:[l?t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):r?t.jsx(r,{className:"mr-2 h-4 w-4"}):null,e]});return t.jsxs("div",{className:_r("inline-flex rounded-md shadow-sm",u),children:[t.jsxs(Sr,{variant:n,size:o,disabled:p,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[l?t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):r?t.jsx(r,{className:"mr-2 h-4 w-4"}):null,e]}),t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:n,size:o,disabled:p,className:_r("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:t.jsx(c.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),t.jsx($s,{align:d,className:"min-w-[160px]",children:s.map(e=>{const a=e.icon;return t.jsxs(Ws,{onClick:e.onClick,disabled:e.disabled,className:_r("destructive"===e.variant&&"text-destructive focus:text-destructive"),children:[a&&t.jsx(a,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})]})}rm.displayName="OnboardingDialog";var nm=(e=>(e.CSV="csv",e.PDF="pdf",e.XLSX="xlsx",e.PNG="png",e.JPEG="jpeg",e.SVG="svg",e))(nm||{});const om=[{value:"csv",label:"CSV",icon:t.jsx(c.FileText,{className:"h-5 w-5"})},{value:"pdf",label:"PDF",icon:t.jsx(c.FileText,{className:"h-5 w-5"})},{value:"xlsx",label:"XLSX",icon:t.jsx(c.FileSpreadsheet,{className:"h-5 w-5"})}],im=[{value:"png",label:"PNG",icon:t.jsx(c.Image,{className:"h-5 w-5"})},{value:"jpeg",label:"JPEG",icon:t.jsx(c.FileImage,{className:"h-5 w-5"})},{value:"svg",label:"SVG",icon:t.jsx(c.FileImage,{className:"h-5 w-5"})},{value:"pdf",label:"PDF",icon:t.jsx(c.FileText,{className:"h-5 w-5"})}];const lm=a.forwardRef(({value:e,onChange:r,onTimeChange:s,label:n,error:o,format:i="24h",className:l,id:d,...u},m)=>{const p=d??te.useId(),h=a.useCallback(e=>{const t=e.target.value;r?.(t),s?.(t)},[r,s]),x=a.useCallback(e=>{["0","1","2","3","4","5","6","7","8","9","Backspace","Tab",":","ArrowLeft","ArrowRight","Delete"].includes(e.key)||e.preventDefault()},[]);return t.jsxs("div",{className:_r("grid gap-1.5",l),children:[n&&t.jsx(Er,{htmlFor:p,children:n}),t.jsxs("div",{className:"relative",children:[t.jsx(Tr,{ref:m,id:p,type:"time",value:e??"",onChange:h,onKeyDown:x,min:"00:00",max:"23:59",step:60,className:_r("pr-9",o&&"border-destructive focus-visible:ring-destructive"),...u}),t.jsx(c.Clock,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]}),o&&t.jsx("p",{className:"text-sm text-destructive",children:o})]})});function cm({currentStep:e,totalSteps:a,onStepChange:r,stepLabels:s,canGoToStep:n,className:o,progressWidth:i="w-32"}){te.useEffect(()=>{process.env.NODE_ENV},[]);const l=Array.from({length:a},(e,t)=>t+1),d=t=>!(t<=e)&&(!!n&&!n(t));return t.jsxs("div",{className:_r("flex items-center gap-3",o),children:[t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",e,"/",a,t.jsx(c.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),t.jsx($s,{align:"start",children:l.map(a=>t.jsxs(Ws,{onClick:()=>{var t;(t=a)<e?r(t):n&&!n(t)||r(t)},disabled:d(a),className:_r("cursor-pointer",a===e&&"bg-muted font-medium",d(a)&&"opacity-50 cursor-not-allowed"),children:[t.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),s?.[a-1]||`Etapa ${a}`,a===e&&t.jsx(c.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),t.jsx(Ld,{value:e/a*100,className:_r("h-2",i)})]})}function dm(e){const t=$n.getAccessToken(),a={"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{},"un-alias":e};if(t)try{const e=JSON.parse(atob(t.split(".")[1]));e.sub&&(a["x-waf-rate"]=btoa(e.sub))}catch{}return a}async function um(e,t,a){let r=await fetch(e,t);if(401===r.status){if(await lo.handleApiError({status:401})){const s={...t,headers:dm(a)};r=await fetch(e,s)}}return r}function mm(e){const[t,r]=a.useState([]),[s,n]=a.useState(0),[o,i]=a.useState(!1);a.useEffect(()=>{if(!e)return;let t=!1;const a=`${Ge().replace(/\/?$/,"/")}api/common/v1/updates/listUpdatesNotification`;return async function(){i(!0);try{const s=dm(e),o=await um(a,{method:"GET",headers:s},e);if(!o.ok)return;const i=await o.json();!t&&i.data?.[0]&&(r(i.data[0].updates??[]),n(i.data[0].valueBadge??0))}catch(s){}finally{t||i(!1)}}(),()=>{t=!0}},[e]);const l=a.useCallback(async()=>{if(!e||s<=0||0===t.length)return;const a=t[0].id,r=`${Ge().replace(/\/?$/,"/")}api/common/v1/Updates/userVisualized/3/undefined`;n(0);try{const t=dm(e),s=JSON.stringify({id:a,idUpdateType:3});await um(r,{method:"POST",headers:t,body:s},e)}catch(o){}},[e,s,t]);return{updates:t,badgeCount:s,loading:o,markAsVisualized:l}}lm.displayName="Timepicker";const pm=a.forwardRef(({updates:a,badgeCount:r,onOpen:s,onViewAll:n,viewAllPath:o},i)=>{const l=void 0===a,d=So(),u=d?.alias??null,m=mm(l?u:null),p=N.useNavigate(),h=l?m.updates??[]:a,x=l?m.badgeCount??0:r??0,f=s??(l?m.markAsVisualized:void 0),g=n??(l&&u?()=>{if(o)return void p(o);const e=Je().replace(/\/?$/,"/");window.open(`${e}${u}/up/view`,"_blank","noopener,noreferrer")}:void 0);return t.jsxs(an,{children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{ref:i,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:f,title:e.t("updates"),children:[t.jsx(c.Coffee,{className:"h-7 w-7"}),x>0&&t.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:x>99?"99+":x})]})}),t.jsxs(sn,{align:"end",className:"w-80 p-0",children:[t.jsx("div",{className:"border-b border-border px-4 py-3",children:t.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Atualizações"})}),t.jsx("div",{className:"max-h-72 overflow-y-auto",children:h.length>0?t.jsx("ul",{className:"divide-y divide-border",children:h.map(e=>t.jsxs("li",{className:"px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer",onClick:g,children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.text})]},e.id))}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[t.jsx(c.Coffee,{className:"h-8 w-8 text-muted-foreground mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum café quentinho, ou melhor, atualização quentinha no momento!"})]})}),t.jsx("div",{className:"border-t border-border px-4 py-2",children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"w-full justify-between text-primary hover:text-primary",onClick:g,children:["Ver todas as atualizações",t.jsx(c.ArrowRight,{className:"h-[18px] w-[18px]"})]})})]})]})});pm.displayName="UpdatesNotification";var hm=(e=>(e[e.none=0]="none",e[e.image=1]="image",e[e.video=2]="video",e[e.audio=3]="audio",e[e.wopi=4]="wopi",e[e.onlineEditor=5]="onlineEditor",e[e.report=6]="report",e))(hm||{}),xm=(e=>(e[e.SimplePrint=0]="SimplePrint",e[e.ManagedCopy=1]="ManagedCopy",e[e.NonManagedCopy=2]="NonManagedCopy",e))(xm||{});const fm={".jpg":1,".jpeg":1,".png":1,".bmp":1,".gif":1,".svg":1,".webp":1,".wav":3,".mp3":3,".mp4":2,".webm":2,".ogg":2,".pdf":4,".ods":4,".xls":4,".xlsb":4,".xlsm":4,".xlsx":4,".doc":4,".docm":4,".docx":4,".dot":4,".dotm":4,".dotx":4,".odt":4,".odp":4,".pot":4,".potm":4,".potx":4,".pps":4,".ppsm":4,".ppsx":4,".ppt":4,".pptm":4,".pptx":4,".gdocs":5,".gsheets":5};function gm(e){const{t:t}=y.useTranslation();return e?fm[e.toLowerCase()]??0:0}const bm={".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 vm(e){const{t:t}=y.useTranslation();return bm[e?.toLowerCase()]||""}function ym(e){const{t:t}=y.useTranslation(),a=e%60;return`${Math.floor(e/60)}min ${a<10?"0":""}${a}`}function wm({open:e,onOpenChange:r,url:s,title:n,className:o,minHeight:i="250px"}){const{t:l}=y.useTranslation(),d=a.useCallback(()=>{r(!1)},[r]);return a.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&d()};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[e,d]),t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:_r("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",o),children:[t.jsxs("div",{className:"flex items-center justify-end mb-2.5",children:[n&&t.jsx("h2",{className:"text-lg font-medium text-foreground truncate mr-auto",children:n}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,children:t.jsx(c.X,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Fechar"})]})]}),t.jsx("iframe",{src:s,className:"border-none w-full",style:{minHeight:i},title:n||l("embedded_content")})]})})}function jm({term:r,open:s,onClose:n,onSign:o,viewOnly:i=!1,title:l=e.t("terms_of_use"),signLabel:d=e.t("terms_read_agree")}){const u=a.useMemo(()=>r.file?function(e,t=""){const{t:a}=y.useTranslation(),r=atob(e),s=[];for(let o=0;o<r.length;o+=512){const e=r.slice(o,o+512),t=new Array(e.length);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a);s.push(new Uint8Array(t))}const n=new Blob(s,{type:t});return URL.createObjectURL(n)}(r.file,r.type):null,[r.file,r.type]),m=a.useCallback(()=>{u&&URL.revokeObjectURL(u),n()},[u,n]),p=a.useCallback(()=>{r.hasUserSignature?m():o?.(r.id)},[r,o,m]),h=!i&&!r.hasUserSignature&&o;return t.jsx(Qr,{open:s,onOpenChange:e=>!e&&m(),children:t.jsxs(as,{className:_r("flex flex-col p-0 sm:max-w-[80vw] h-[95vh]","[&>button.absolute]:hidden"),children:[t.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[t.jsx(c.FileText,{className:"h-5 w-5 text-primary"}),l]}),t.jsxs("div",{className:"flex items-center gap-2",children:[h&&t.jsx(Sr,{size:"sm",onClick:p,children:d}),t.jsx(Sr,{variant:"ghost",size:"icon",onClick:m,children:t.jsx(c.X,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"flex-1 min-h-0",children:r.file&&u?t.jsx("iframe",{className:"h-full w-full border-0",src:u,title:l}):t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t.jsx("p",{children:"Nenhum termo de uso ativo encontrado."})})})]})})}function Nm(e){return e.split(" ").slice(0,2).map(e=>e[0]?.toUpperCase()??"").join("")}function _m(e){return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Cm(e){const{t:t}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function km(e){const{t:t}=y.useTranslation(),a=new Set;if(!e)return a;for(const r of e)r.allowedIds?.forEach(e=>a.add(e)),r.inheritedIds?.forEach(e=>a.add(e));return a}var Sm=(e=>(e[e.WaitingProcessing=1]="WaitingProcessing",e[e.Processing=2]="Processing",e[e.Completed=3]="Completed",e[e.Error=4]="Error",e[e.Expired=5]="Expired",e))(Sm||{});const Am={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 Tm(e){const{t:t}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Dm(e){const{t:t}=y.useTranslation();return e.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Em={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}};var Pm=(e=>(e.Count="valuecount",e.Sum="sum",e.Average="average",e.DistinctCount="valuecount_distict",e.Max="max",e.Min="min",e))(Pm||{}),Im=(e=>(e.ViewAllAnalysis="nes3j6wn",e))(Im||{}),Mm=(e=>(e.RegisterDashboards="EeKs7CYA",e.RemoveDashboards="3GKZYOQ9",e.ViewAllDashboards="wYBdQNvZ",e.EditDashboards="bMFcbwv4",e))(Mm||{}),Rm=(e=>(e[e.Default=1]="Default",e[e.Compact=2]="Compact",e))(Rm||{}),Lm=(e=>(e[e.FiveSeconds=1]="FiveSeconds",e[e.TenSeconds=2]="TenSeconds",e[e.FifteenSeconds=3]="FifteenSeconds",e[e.ThirtySeconds=4]="ThirtySeconds",e[e.OneMinute=5]="OneMinute",e[e.ThreeMinutes=6]="ThreeMinutes",e[e.FiveMinutes=7]="FiveMinutes",e[e.TenMinutes=8]="TenMinutes",e))(Lm||{}),Fm=(e=>(e[e.Day=1]="Day",e[e.Month=2]="Month",e[e.Year=3]="Year",e))(Fm||{}),zm=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=2]="Descending",e))(zm||{}),Um=(e=>(e[e.Label=1]="Label",e[e.Value=2]="Value",e))(Um||{}),Om=(e=>(e[e.LastSevenDays=1]="LastSevenDays",e[e.LastWeek=2]="LastWeek",e[e.LastMonth=3]="LastMonth",e[e.PreviousQuarter=4]="PreviousQuarter",e[e.PreviousSemester=5]="PreviousSemester",e[e.LastYear=6]="LastYear",e[e.SpecificPeriod=7]="SpecificPeriod",e[e.CurrentMonth=8]="CurrentMonth",e[e.CurrentSemester=9]="CurrentSemester",e[e.CurrentWeek=10]="CurrentWeek",e[e.CurrentYear=11]="CurrentYear",e))(Om||{}),Bm=(e=>(e[e.Text=1]="Text",e[e.Area=2]="Area",e[e.Bar=3]="Bar",e[e.Column=4]="Column",e[e.StackedColumn=5]="StackedColumn",e[e.Line=6]="Line",e[e.List=7]="List",e[e.Numeric=8]="Numeric",e[e.Pareto=9]="Pareto",e[e.Pie=10]="Pie",e[e.RiskMatrix=11]="RiskMatrix",e[e.Burndown=12]="Burndown",e[e.PerformanceColumns=13]="PerformanceColumns",e[e.EvolutionLine=14]="EvolutionLine",e))(Bm||{}),qm=(e=>(e[e.NotUpdate=1]="NotUpdate",e[e.FiveMinutes=2]="FiveMinutes",e[e.TenMinutes=3]="TenMinutes",e[e.FifteenMinutes=4]="FifteenMinutes",e[e.ThirtyMinutes=5]="ThirtyMinutes",e[e.OneHour=6]="OneHour",e))(qm||{}),Vm=(e=>(e[e.NormalPage=1]="NormalPage",e[e.Carousel=2]="Carousel",e))(Vm||{}),$m=(e=>(e[e.General=0]="General",e[e.Share=1]="Share",e))($m||{}),Wm=(e=>(e[e.NotShared=1]="NotShared",e[e.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",e[e.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",e))(Wm||{}),Hm=(e=>(e.PtBr="pt-br",e.EnUs="en",e.EsEs="es",e))(Hm||{}),Gm=(e=>(e[e.Quantity=0]="Quantity",e[e.AllRisksList=1]="AllRisksList",e))(Gm||{}),Km=(e=>(e[e.Five=5]="Five",e[e.Ten=10]="Ten",e[e.Fifteen=15]="Fifteen",e[e.Twenty=20]="Twenty",e[e.All=0]="All",e[e.Custom=-1]="Custom",e))(Km||{}),Ym=(e=>(e[e.AlphabeticalAsc=1]="AlphabeticalAsc",e[e.AlphabeticalDesc=2]="AlphabeticalDesc",e[e.CountAsc=3]="CountAsc",e[e.CountDesc=4]="CountDesc",e[e.DateAsc=5]="DateAsc",e[e.DateDesc=6]="DateDesc",e))(Ym||{}),Qm=(e=>(e[e.Loading=0]="Loading",e[e.Loaded=1]="Loaded",e[e.Error=3]="Error",e[e.NoData=4]="NoData",e[e.Unavailable=5]="Unavailable",e))(Qm||{}),Xm=(e=>(e[e.Quantity=1]="Quantity",e[e.Percentage=2]="Percentage",e[e.QuantityPercentage=3]="QuantityPercentage",e))(Xm||{}),Jm=(e=>(e[e.Program=1]="Program",e[e.Project=2]="Project",e[e.Action=3]="Action",e[e.PerformanceProject=4]="PerformanceProject",e[e.PerformanceAction=5]="PerformanceAction",e))(Jm||{}),Zm=(e=>(e.OccurrenceActionPlans="xebGnSSq",e.OccurrenceGeneral="UFws4AvH",e.PlansActionPlans="Kux6CcVC",e.PlansProgramProjects="UWjrp6Dw",e.PlansIdeas="3g7vNm2w",e.RisksGeneral="PZ4b6FhP",e.RisksActionPlans="xZErDg57",e.RisksAnalysis="UxsioMbH",e.RisksIncidences="gNt5IJ2F",e.MetrologyGeneral="4MfEPbRY",e.MetrologyActivities="hdFM9XQW",e.MetrologyServiceOrders="cIrVPdMv",e.DecisionsGeneral="CopsnHDB",e.DecisionsItems="qLFAayjx",e.DecisionsActionPlans="RiQFpxdb",e.FlowGeneral="AFV98JoG",e.AuditGeneral="gON8LJPi",e.AuditPlans="SsCNVOvr",e.AuditPlansItems="OpPkCCFm",e.AuditActionPlans="P1oGePhh",e.CommonGeneral="VVfEzgMQ",e.ActionPlans="C6Z4MgGa",e.SuppliersEvaluations="fSCeS4mH",e.SuppliersGeneral="8qPThkrD",e.SuppliersEvaluationsCriteria="RiSIStdY",e.SuppliersDocuments="Riua4jMa",e.SuppliersMaterialsServices="UpEkatXH",e.DocumentsGeneral="FRhhEX2J",e.DocumentsPhysicalCopies="PZLtJ23h",e.DocumentsObsolete="XDjbga14",e.FmeaGeneral="aPwf4uPr",e.FmeaActionPlans="vQ8PMrVX",e))(Zm||{}),ep=(e=>(e[e.NotShared=1]="NotShared",e[e.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",e[e.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",e))(ep||{}),tp=(e=>(e[e.All=1]="All",e[e.OnlyMine=2]="OnlyMine",e[e.Favorites=3]="Favorites",e))(tp||{}),ap=(e=>(e[e.Current=1]="Current",e[e.Inherent=2]="Inherent",e))(ap||{}),rp=(e=>(e[e.Default=1]="Default",e[e.Pastel=2]="Pastel",e[e.Vibrant=3]="Vibrant",e[e.Earth=4]="Earth",e[e.Ocean=5]="Ocean",e[e.Floral=6]="Floral",e[e.Night=7]="Night",e[e.Winter=8]="Winter",e[e.Spring=9]="Spring",e[e.Summer=10]="Summer",e[e.Fall=11]="Fall",e[e.Gray=12]="Gray",e[e.Brown=13]="Brown",e[e.Blue=14]="Blue",e[e.Yellow=15]="Yellow",e[e.Green=16]="Green",e[e.Purple=17]="Purple",e[e.Orange=18]="Orange",e[e.Pink=19]="Pink",e[e.Red=20]="Red",e))(rp||{});const sp={jan:1,fev:2,mar:3,abr:4,mai:5,jun:6,jul:7,ago:8,set:9,out:10,nov:11,dez:12},np=["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"],op=["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 ip(e){if(!e)return 0;const[t,a]=e.split("/"),r=sp[t?.toLowerCase()]??0;return 12*(parseInt(a)||0)+r}function lp(e){const t=e.split("/"),a=t[t.length-1];return`${t.slice(0,-1).join("/")}/${encodeURIComponent(a.replace(/[!@#$%^&*()_+={}[\]|\\;:'",.<>?/`~]/g,""))}`}function cp(e){for(const t of op)if(e[t])return e[t];return null}function dp(e){const t=[];for(const a of Object.keys(e)){const r=e[a];null!=r&&(r instanceof Date?t.push(`${a}=${r.toISOString()}`):Array.isArray(r)?r.forEach(e=>{t.push(...dp({[a]:e}))}):"string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r||t.push(`${a}=${r}`))}return t}const up=/^-?\d+(,\d{3})*(\.\d+)?$/;const mp=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});const pp=new Set([Bm.Text]),hp=new Set([Bm.Text,Bm.Numeric,Bm.RiskMatrix,Bm.Burndown,Bm.PerformanceColumns]),xp=new Set([Bm.Text,Bm.RiskMatrix,Bm.Burndown,Bm.PerformanceColumns]);function fp({config:e,viewOnly:r=!1,complement:s,complementPosition:n="before-options",queryUrlBuilder:o,onRefresh:i,onExport:l,onToggleOnlyMine:d,className:u}){const{t:m}=y.useTranslation(),[p,h]=a.useState(e.onlyMine??!1),x=pp.has(e.typeId),f=!hp.has(e.typeId),g=!xp.has(e.typeId),b=a.useMemo(()=>{if(!e.jsonRules||e.typeId===Bm.PerformanceColumns)return!1;try{const t=JSON.parse(e.jsonRules);return t?.rules?.rules?.length>0}catch{return!1}},[e.jsonRules,e.typeId]),v=a.useMemo(()=>o?.(e)??"#",[o,e]),w=a.useCallback(()=>{const e=!p;h(e),d?.(e)},[p,d]),j=[];return p&&j.push(m("dashboard_only_mine")),e.onlyLate&&j.push(m("dashboard_only_overdue")),b&&j.push(m("dashboard_advanced_filter")),t.jsxs("div",{className:_r("flex items-center justify-between gap-2 border-b bg-muted/30 px-2.5 py-1 text-sm font-medium",u),children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:["before-title"===n&&s,t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("span",{className:"block truncate",children:e.title})}),t.jsx(en,{children:e.title})]}),j.length>0&&t.jsx("span",{className:"text-[9px] font-normal text-muted-foreground truncate",children:j.join(" | ")})]}),"after-title"===n&&s]}),!r&&t.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:["before-options"===n&&s,t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-6 w-6",children:t.jsx(c.MoreVertical,{className:"h-3.5 w-3.5"})})}),t.jsxs($s,{align:"end",className:"w-48",children:[e.canUpdate&&t.jsxs(Ws,{onClick:()=>e.onEdit?.(e.id),children:[t.jsx(c.Pencil,{className:"mr-2 h-3.5 w-3.5"}),"Editar"]}),!x&&t.jsxs(Ws,{onClick:i,children:[t.jsx(c.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),"Atualizar"]}),f&&t.jsxs(Ws,{disabled:e.noData,onClick:l,children:[t.jsx(c.Download,{className:"mr-2 h-3.5 w-3.5"}),"Exportar"]}),!x&&t.jsxs(Ws,{disabled:!e.openQueryEnabled,onClick:()=>window.open(v,"_blank"),children:[t.jsx(c.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Abrir consulta"]}),g&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{}),t.jsxs(Ws,{onClick:w,children:[p&&t.jsx(c.Check,{className:"mr-2 h-3.5 w-3.5"}),!p&&t.jsx("span",{className:"mr-2 w-3.5"}),"Somente meus"]})]}),e.canUpdate&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{}),t.jsxs(Ws,{onClick:()=>e.onDuplicate?.(e.id),children:[t.jsx(c.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Duplicar"]}),t.jsxs(Ws,{className:"text-destructive",onClick:()=>e.onRemove?.(e.id),children:[t.jsx(c.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Remover"]})]})]})]}),"after-options"===n&&s]})]})}function gp({config:e,queryUrl:a,className:r}){return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",r),children:[t.jsx(c.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),t.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"Erro ao exibir os dados."}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"A consulta não pôde ser realizada."}),t.jsxs("p",{className:"mt-2 text-xs",children:[a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:"Verificar a consulta"}),a&&e.canUpdate&&t.jsx("span",{className:"text-muted-foreground",children:" ou "}),e.canUpdate&&t.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>e.onEdit?.(e.id),children:"revisar o painel"})]})]})}function bp({panelType:e,className:a}){const r=e===Bm.Burndown;return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-2 p-4",a),children:[t.jsx(Is,{className:"h-10 w-10 text-muted-foreground/40"}),r&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Aguarde, processando dados..."})]})}function vp({hasRemovedColumn:a=!1,className:r}){return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",r),children:[t.jsx("h2",{className:"text-lg font-normal text-foreground/80 lg:text-base",children:e.t("no_data_to_display")}),t.jsx("p",{className:"text-sm text-muted-foreground lg:text-xs",children:e.t("dashboard_no_data")})]})}function yp({onRemove:e,className:a}){return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",a),children:[t.jsx(c.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),t.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"A consulta não pôde ser realizada."}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Este recurso não está disponível."}),e&&t.jsx("p",{className:"mt-2 text-xs",children:t.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:e,children:"Remover painel"})})]})}const wp={[Pm.Count]:e.t("dashboard_distinct_count").replace("distinta","").trim()||"Count",[Pm.Sum]:"Sum",[Pm.Average]:e.t("dashboard_average"),[Pm.DistinctCount]:e.t("dashboard_distinct_count"),[Pm.Max]:e.t("dashboard_max_value"),[Pm.Min]:e.t("dashboard_min_value")};function jp({config:e,state:a,value:r,label:s,viewOnly:n=!1,onClick:o,onRefresh:i,queryUrl:l,queryUrlBuilder:c,className:d}){const{t:u}=y.useTranslation(),m=s??wp[e.aggregationType??""]??"",p=function(e,t){if(null==e)return"—";const a=np.includes(t.field),r=t.aggregationType===Pm.Count||t.aggregationType===Pm.DistinctCount;return a&&!r?mp.format("string"==typeof e?parseFloat(e):e):"number"==typeof e?r?String(e):e.toLocaleString("pt-BR",{maximumFractionDigits:2}):String(e)}(r,e);return t.jsxs("div",{className:_r("flex h-full flex-col",d),children:[t.jsx(fp,{config:e,viewOnly:n,onRefresh:i,queryUrlBuilder:c}),a===Qm.Loading&&t.jsx(bp,{}),a===Qm.Loaded&&t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center",o&&"cursor-pointer hover:bg-muted/20 transition-colors"),onClick:o,children:[t.jsx("span",{className:"text-[clamp(1.5rem,7vh,5rem)] font-bold text-foreground leading-tight",children:p}),m&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:m})]}),a===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:l}),a===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Np({config:e,state:a,htmlContent:r,viewOnly:s=!1,onRefresh:n,queryUrl:o,queryUrlBuilder:i,className:l}){const c=r??e.textTypeString??"";return t.jsxs("div",{className:_r("flex h-full flex-col",l),children:[t.jsx(fp,{config:e,viewOnly:s,onRefresh:n,queryUrlBuilder:i}),a===Qm.Loading&&t.jsx(bp,{}),a===Qm.Loaded&&t.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 prose prose-sm max-w-none text-foreground",dangerouslySetInnerHTML:{__html:c}}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:o})]})}function _p({config:e,state:r,data:s=[],columns:n=[],viewOnly:o=!1,onRowClick:i,onRefresh:l,onExport:c,queryUrl:d,queryUrlBuilder:u,enableRowLinks:m=!0,className:p}){const h=a.useMemo(()=>n.filter(e=>!1!==e.visible),[n]),x=a.useCallback(e=>{if(i)i(e);else if(m){const t=cp(e);t&&window.open(lp(t),"_blank")}},[i,m]);return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:o,onRefresh:l,onExport:c,queryUrlBuilder:u}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"sticky top-0 z-10 bg-muted/60 backdrop-blur-sm",children:t.jsx("tr",{children:h.map(e=>t.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))})}),t.jsx("tbody",{children:s.map((e,a)=>{const r=m&&!!cp(e);return t.jsx("tr",{className:_r("border-b border-border/50 transition-colors hover:bg-muted/30",(r||i)&&"cursor-pointer"),onClick:()=>x(e),children:h.map(a=>t.jsx("td",{className:"px-2 py-1.5 text-foreground whitespace-nowrap truncate max-w-[200px]",children:a.render?a.render(e[a.columnName],e):Cp(e[a.columnName],a)},a.columnName))},a)})})]})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:d}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Cp(e,t){return null==e?"":e instanceof Date?"datetime"===t.columnType?e.toLocaleString("pt-BR"):e.toLocaleDateString("pt-BR"):"number"==typeof e?e.toLocaleString("pt-BR"):String(e)}const kp=["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 Sp({config:e,variant:r,state:s,data:n=[],series:o,colors:i,categoryKey:l="key",yAxisFormat:c,viewOnly:d=!1,onPointClick:u,onRefresh:m,onExport:p,queryUrl:h,queryUrlBuilder:x,className:f}){const g=i?.length?i:e.hexColors?.length?e.hexColors:kp,b=a.useMemo(()=>o?.length?o:[{dataKey:"value",name:e.title}],[o,e.title]),v="bar"===r,y="stacked-column"===r,w=a.useMemo(()=>{if(c)return e=>c.replace("{value}",e.toLocaleString("pt-BR"))},[c]);return t.jsxs("div",{className:_r("flex h-full flex-col",f),children:[t.jsx(fp,{config:e,viewOnly:d,onRefresh:m,onExport:p,queryUrlBuilder:x}),s===Qm.Loading&&t.jsx(bp,{}),s===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:Ap({variant:r,data:n,series:b,colors:g,categoryKey:l,isHorizontalBar:v,isStacked:y,yAxisTickFormatter:w,tooltipFormatter:e=>"number"==typeof e?e.toLocaleString("pt-BR"):String(e??""),onPointClick:u})})}),s===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),s===Qm.Error&&t.jsx(gp,{config:e,queryUrl:h}),s===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ap({variant:e,data:a,series:r,colors:s,categoryKey:n,isHorizontalBar:o,isStacked:i,yAxisTickFormatter:l,tooltipFormatter:c,onPointClick:d}){const u={tick:{fontSize:11},tickLine:!1,axisLine:!1},m=t.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=t.jsx(q.YAxis,{dataKey:o?n:void 0,type:o?"category":"number",...u,width:o?100:60,tickFormatter:o?void 0:l}),h=t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),x=t.jsx(q.Tooltip,{formatter:c,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),f=r.length>1?t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}):null,g=d?(e,t)=>d(a[t],t):void 0;return"bar"===e||"column"===e||"stacked-column"===e?t.jsxs(q.BarChart,{data:a,layout:o?"vertical":"horizontal",margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,r.map((e,a)=>t.jsx(q.Bar,{dataKey:e.dataKey,name:e.name||e.dataKey,fill:e.color||s[a%s.length],stackId:i?e.stackId||"stack":void 0,radius:i?void 0:[2,2,0,0],onClick:g,cursor:d?"pointer":void 0},e.dataKey))]}):"area"===e?t.jsxs(q.AreaChart,{data:a,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,r.map((e,a)=>{const r=e.color||s[a%s.length];return t.jsx(q.Area,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:r,fill:r,fillOpacity:.15,strokeWidth:2,dot:!1,activeDot:{r:4,cursor:d?"pointer":void 0}},e.dataKey)})]}):t.jsxs(q.LineChart,{data:a,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,r.map((e,a)=>t.jsx(q.Line,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:e.color||s[a%s.length],strokeWidth:2,dot:{r:3},activeDot:{r:5,cursor:d?"pointer":void 0}},e.dataKey))]})}const Tp=["#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3","#b2df8a","#fb9a99","#fdbf6f","#cab2d6","#ffff99"];function Dp({config:e,state:r,data:s=[],colors:n,viewOnly:o=!1,onSliceClick:i,onRefresh:l,onExport:c,queryUrl:d,queryUrlBuilder:u,className:m}){const p=n?.length?n:e.hexColors?.length?e.hexColors:Tp,h=a.useMemo(()=>s.map(e=>({...e,name:String(e.key??""),value:e.value??0})),[s]),x=a.useMemo(()=>h.reduce((e,t)=>e+(t.value??0),0),[h]);return t.jsxs("div",{className:_r("flex h-full flex-col",m),children:[t.jsx(fp,{config:e,viewOnly:o,onRefresh:l,onExport:c,queryUrlBuilder:u}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.PieChart,{children:[t.jsx(q.Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:"80%",label:({name:e,percent:t})=>`${e??""}: ${(100*(t??0)).toFixed(0)}%`,labelLine:!0,onClick:i?(e,t)=>i(s[t],t):void 0,cursor:i?"pointer":void 0,children:h.map((e,a)=>t.jsx(q.Cell,{fill:p[a%p.length]},a))}),t.jsx(q.Tooltip,{formatter:e=>{const t="number"==typeof e?e:0,a=x>0?(t/x*100).toFixed(1):"0";return`${t.toLocaleString("pt-BR")} (${a}%)`}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}})]})})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:d}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ep({config:e,state:r,data:s=[],barColor:n,lineColor:o="#e31a1c",viewOnly:i=!1,onPointClick:l,onRefresh:c,onExport:d,queryUrl:u,queryUrlBuilder:m,className:p}){const h=e.hexColors?.length?e.hexColors:["#1f78b4"],x=n??h[0],f=a.useMemo(()=>{const e=[...s].sort((e,t)=>(t.value??0)-(e.value??0)),t=e.reduce((e,t)=>e+(t.value??0),0);let a=0;return e.map(e=>(a+=e.value??0,{key:String(e.key??""),value:e.value??0,cumulativePercent:t>0?Math.round(a/t*100):0}))},[s]);return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:i,onRefresh:c,onExport:d,queryUrlBuilder:m}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.ComposedChart,{data:f,margin:{top:5,right:30,left:0,bottom:5},children:[t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),t.jsx(q.XAxis,{dataKey:"key",tick:{fontSize:11},angle:-45,textAnchor:"end",height:60}),t.jsx(q.YAxis,{yAxisId:"left",tick:{fontSize:11},tickLine:!1,axisLine:!1}),t.jsx(q.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}%`,domain:[0,100]}),t.jsx(q.Tooltip,{formatter:(e,t)=>"% Acumulado"===t?`${e}%`:"number"==typeof e?e.toLocaleString("pt-BR"):e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),t.jsx(q.Bar,{yAxisId:"left",dataKey:"value",name:"Quantidade",fill:x,radius:[2,2,0,0],onClick:l?(e,t)=>l(s[t],t):void 0,cursor:l?"pointer":void 0}),t.jsx(q.Line,{yAxisId:"right",type:"monotone",dataKey:"cumulativePercent",name:"% Acumulado",stroke:o,strokeWidth:2,dot:{r:3,fill:o}})]})})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:u}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Pp({config:e,state:a,data:r=[],executedLabel:s,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onRefresh:c,queryUrl:d,queryUrlBuilder:u,className:m}){const{t:p}=y.useTranslation(),h=s??p("dashboard_work_done"),x=n??p("dashboard_work_planned");return t.jsxs("div",{className:_r("flex h-full flex-col",m),children:[t.jsx(fp,{config:e,viewOnly:l,onRefresh:c,queryUrlBuilder:u}),a===Qm.Loading&&t.jsx(bp,{panelType:Bm.Burndown}),a===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.AreaChart,{data:r,margin:{top:5,right:10,left:0,bottom:5},children:[t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),t.jsx(q.XAxis,{dataKey:"date",tick:{fontSize:10},angle:-45,textAnchor:"end",height:50}),t.jsx(q.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`,domain:[0,100]}),t.jsx(q.Tooltip,{formatter:e=>`${e}%`,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),t.jsx(q.Area,{type:"monotone",dataKey:"executedPercentage",name:h,stroke:o,fill:o,fillOpacity:.2,strokeWidth:2,dot:{r:3}}),t.jsx(q.Area,{type:"monotone",dataKey:"plannedPercentage",name:x,stroke:i,fill:i,fillOpacity:.1,strokeWidth:2,dot:{r:3}})]})})}),a===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:d}),a===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ip({config:e,state:a,data:r=[],executedLabel:s,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onPointClick:c,onRefresh:d,queryUrl:u,queryUrlBuilder:m,className:p}){const{t:h}=y.useTranslation(),x=s??h("dashboard_work_done"),f=n??h("dashboard_work_planned");return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:l,onRefresh:d,queryUrlBuilder:m}),a===Qm.Loading&&t.jsx(bp,{}),a===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.BarChart,{data:r,margin:{top:5,right:10,left:0,bottom:5},children:[t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),t.jsx(q.XAxis,{dataKey:"name",tick:{fontSize:10},angle:-45,textAnchor:"end",height:60}),t.jsx(q.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`}),t.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"}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),t.jsx(q.Bar,{dataKey:"executedWork",name:x,fill:o,radius:[2,2,0,0],onClick:c?(e,t)=>c(r[t],t):void 0,cursor:c?"pointer":void 0}),t.jsx(q.Bar,{dataKey:"plannedWork",name:f,fill:i,radius:[2,2,0,0]})]})})}),a===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:u}),a===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Mp({config:e,state:r,rule:s,risks:n=[],matrixViewType:o=Gm.Quantity,viewOnly:i=!1,onCellClick:l,onRiskClick:c,onRefresh:d,queryUrl:u,queryUrlBuilder:m,className:p}){const h=a.useMemo(()=>[...s?.parametersY??[]].sort((e,t)=>t.position-e.position),[s?.parametersY]),x=s?.parametersX??[],f=a.useMemo(()=>{const e={};return n.forEach(t=>{const a=`${t.parameterYPosition}-${t.parameterXPosition}`;e[a]||(e[a]=[]),e[a].push(t)}),e},[n]);return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:i,onRefresh:d,queryUrlBuilder:m}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&s&&t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsxs("div",{className:"flex gap-4 items-stretch min-w-fit",children:[t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("span",{className:"text-xs font-medium text-muted-foreground [writing-mode:vertical-lr] rotate-180",children:s.name_y})}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex mb-1",children:[t.jsx("div",{className:"w-16 shrink-0"}),t.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:s.threat_strategy_type_name}),!s.disable_opportunities&&t.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:s.opportunity_strategy_type_name})]}),h.map((e,a)=>t.jsxs("div",{className:"flex",children:[t.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((r,n)=>{const i=((e,t)=>f[`${t.position}-${e.position}`]??[])(r,e),d=((e,t)=>s?.colorMatrix?.[t]?.[e]??"hsl(var(--muted))")(n,a);return t.jsxs("div",{className:_r("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||c)&&i.length>0&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:d},onClick:()=>i.length>0&&l?.(r,e,i),children:[o===Gm.Quantity&&i.length>0&&t.jsxs("span",{className:"text-xs font-semibold",children:[i.length," risco",1!==i.length?"s":""]}),o===Gm.AllRisksList&&i.map(e=>t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("button",{type:"button",className:"text-[10px] text-primary underline hover:text-primary/80",onClick:t=>{t.stopPropagation(),c?.(e)},children:e.code})}),t.jsxs(en,{className:"max-w-[250px]",children:[t.jsxs("p",{className:"font-medium",children:[e.code," - ",e.name]}),e.analysisDate&&t.jsxs("p",{className:"text-xs mt-1",children:["Última análise: ",t.jsx("strong",{children:e.analysisDate})]}),e.strategy&&t.jsxs("p",{className:"text-xs",children:["Estratégia: ",t.jsx("strong",{children:e.strategy})]}),e.resultName&&t.jsxs("p",{className:"text-xs",children:["Criticidade: ",t.jsx("strong",{style:{backgroundColor:d},className:"px-1 rounded",children:e.resultName})]})]})]},e.code))]},r.position)})]},e.position)),t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-16 shrink-0"}),x.map(e=>t.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))]}),t.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground mt-2",children:s.name_x})]})]})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:u}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}const Rp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:a}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(a?Math.round(a):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:a}=e;return"scaleX("+t+") scaleY("+a+")"}},Transform:{toString(e){if(e)return[Rp.Translate.toString(e),Rp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function Lp(e){switch(Number(e)){case Bm.Area:case Bm.Bar:case Bm.Column:case Bm.Line:case Bm.Numeric:case Bm.Pie:case Bm.Text:return{x:1,y:1};default:return{x:2,y:2}}}function Fp({panel:e,columns:r,cellHeight:s,cellGap:n,allowDragging:o,children:i}){const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:m,isDragging:p}=X.useSortable({id:e.id,disabled:!o}),h=a.useMemo(()=>({gridColumn:`${e.col+1} / span ${e.sizeX}`,gridRow:`${e.row+1} / span ${e.sizeY}`,minHeight:e.sizeY*s+(e.sizeY-1)*n+"px",transform:Rp.Transform.toString(u),transition:m,zIndex:p?50:void 0,opacity:p?.85:1}),[e,r,s,n,u,m,p]);return t.jsxs("div",{ref:d,style:h,className:_r("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:[t.jsx("div",{className:_r("dashboard-panel-drag-handle",o&&"cursor-grab active:cursor-grabbing"),...o?c:{}}),t.jsx("div",{className:"h-full",children:i})]})}function zp({panels:e,columns:r=8,cellHeight:s=160,cellGap:n=10,allowDragging:o=!1,showGridLines:i=!1,renderPanel:l,onLayoutChange:c,className:d}){const[u,m]=a.useState(e);a.useMemo(()=>{m(e)},[e]);const p=Q.useSensors(Q.useSensor(Q.PointerSensor,{activationConstraint:{distance:8}})),h=a.useMemo(()=>0===u.length?1:Math.max(...u.map(e=>e.row+e.sizeY)),[u]),x=a.useMemo(()=>u.map(e=>e.id),[u]),f=a.useCallback(e=>{const{active:t,over:a}=e;if(!a||t.id===a.id)return;const r=u.findIndex(e=>e.id===t.id),s=u.findIndex(e=>e.id===a.id);if(-1===r||-1===s)return;const n=[...u],o={...n[r]},i={...n[s]},l=o.col,d=o.row;o.col=i.col,o.row=i.row,i.col=l,i.row=d,n[r]=o,n[s]=i,m(n),c?.(n)},[u,c]),g=a.useMemo(()=>({display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gridTemplateRows:`repeat(${h}, ${s}px)`,gap:`${n}px`}),[r,h,s,n]);return 0===u.length?t.jsxs("div",{className:_r("flex flex-col items-center justify-center py-16 text-center",d),children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Nenhum painel adicionado"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione painéis para visualizar seus dados aqui."})]}):t.jsx(Q.DndContext,{sensors:p,collisionDetection:Q.closestCenter,onDragEnd:f,children:t.jsx(X.SortableContext,{items:x,strategy:X.rectSortingStrategy,children:t.jsx("div",{style:g,className:_r("relative w-full",i&&"bg-muted/30",d),children:u.map(e=>t.jsx(Fp,{panel:e,columns:r,cellHeight:s,cellGap:n,allowDragging:o,children:l(e.id)},e.id))})})})}const Up={[Bm.Bar]:"bar",[Bm.Column]:"column",[Bm.StackedColumn]:"stacked-column",[Bm.Area]:"area",[Bm.Line]:"line",[Bm.EvolutionLine]:"evolution-line"};function Op({config:e,state:a,data:r,numericValue:s,listColumns:n,cartesianData:o,cartesianSeries:i,burndownData:l,performanceData:c,matrixRule:d,matrixRisks:u,onPanelClick:m}){const p=Up[e.typeId];if(p)return t.jsx(Sp,{config:e,variant:p,state:a,data:o,series:i});switch(e.typeId){case Bm.Numeric:return t.jsx(jp,{config:e,state:a,value:s});case Bm.Text:return t.jsx(Np,{config:e,state:a});case Bm.List:return t.jsx(_p,{config:e,state:a,data:r,columns:n??[]});case Bm.Pie:return t.jsx(Dp,{config:e,state:a,data:r});case Bm.Pareto:return t.jsx(Ep,{config:e,state:a,data:r});case Bm.Burndown:return t.jsx(Pp,{config:e,state:a,data:l});case Bm.PerformanceColumns:return t.jsx(Ip,{config:e,state:a,data:c});case Bm.RiskMatrix:return t.jsx(Mp,{config:e,state:a,rule:d,risks:u??[]});default:return t.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 Bp({dashboard:e,panels:r,pages:s,activePageId:n,canEdit:o=!1,isFullscreen:i=!1,isLoading:l=!1,getPanelData:c,onRefresh:d,onToggleFullscreen:u,onToggleFavorite:m,onEdit:p,onShare:h,onAddPanel:x,onEditPanel:f,onRemovePanel:g,onDuplicatePanel:b,onLayoutChange:v,onPageChange:w,toolbarActions:j,className:N}){const{t:_}=y.useTranslation(),[C,k]=a.useState(!1),S=e.idViewType===Vm.Carousel,A=a.useMemo(()=>r,[r,S,n]),T=a.useMemo(()=>A.map(e=>{const t=Lp(e.typeId);return{id:e.id,col:e.col,row:e.row,sizeX:e.sizeX,sizeY:e.sizeY,minSizeX:t.x,minSizeY:t.y}}),[A]),D=a.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:b}),[o,f,g,b]),E=a.useCallback(()=>{C||l||(k(!0),d?.(),setTimeout(()=>k(!1),3e4))},[C,l,d]),P=a.useCallback(e=>{const a=A.find(t=>t.id===e);if(!a)return null;const r=D(a),s=c?.(e)??{state:Qm.Loaded};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx(fp,{config:r,onRefresh:()=>{}}),t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(Op,{config:r,...s})})]})},[A,D,c,o,f,g,b]);return t.jsxs("div",{className:_r("flex flex-col h-full",i&&"fixed inset-0 z-50 bg-background",N),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-card",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:e.title}),e.responsibleName&&!i&&t.jsx("span",{className:"text-xs text-muted-foreground truncate hidden sm:inline",children:e.responsibleName})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[j,d&&t.jsx("button",{onClick:E,disabled:C||l,className:_r("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:t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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&&t.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:t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i?t.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"}):t.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&&t.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:t.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),m&&!i&&t.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:t.jsx("svg",{className:_r("h-4 w-4",e.isFavorite&&"fill-yellow-400 text-yellow-400"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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&&s&&s.length>1&&t.jsx("div",{className:"flex items-center gap-1 px-4 py-1 border-b border-border bg-card overflow-x-auto",children:s.map(e=>t.jsx("button",{onClick:()=>w?.(e.id),className:_r("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&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsxs("button",{onClick:x,className:_r("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:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})}),"Adicionar painel"]})}),l&&t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!l&&t.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted/30",children:t.jsx(zp,{panels:T,allowDragging:o,showGridLines:o,renderPanel:P,onLayoutChange:v})})]})}function qp(e,t=Hm.PtBr){const{t:a}=y.useTranslation();switch(t){case Hm.EnUs:return e.titleEnUs||e.titlePtBr||e.titleEsEs;case Hm.EsEs:return e.titleEsEs||e.titleEnUs||e.titlePtBr;default:return e.titlePtBr||e.titleEnUs||e.titleEsEs}}function Vp(e){const{t:t}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}const $p=[{value:tp.All,label:"Todos"},{value:tp.OnlyMine,label:e.t("dashboard_my")},{value:tp.Favorites,label:"Favoritos"}];function Wp({dashboards:e,limit:r,isLoading:s=!1,language:n=Hm.PtBr,canAdd:o=!1,canEdit:i=!1,canRemove:l=!1,onOpen:c,onEdit:d,onShare:u,onDuplicate:m,onRemove:p,onAdd:h,onToggleFavorite:x,onRefresh:f,onSearch:g,onQuickFilterChange:b,toolbarExtra:v,className:w}){const{t:j}=y.useTranslation(),[N,_]=a.useState(""),[C,k]=a.useState(tp.All),[S,A]=a.useState(null),T=a.useCallback(e=>{_(e),g?.(e)},[g]),D=a.useCallback(e=>{k(e),b?.(e)},[b]),E=a.useMemo(()=>{let t=e;if(N){const e=N.toLowerCase();t=t.filter(t=>t.code?.toLowerCase().includes(e)||qp(t,n).toLowerCase().includes(e)||t.responsibleName?.toLowerCase().includes(e))}switch(C){case tp.OnlyMine:break;case tp.Favorites:t=t.filter(e=>e.isFavorite)}return t},[e,N,C,n]);return t.jsxs("div",{className:_r("flex flex-col h-full",w),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboards"}),r&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",r.countDashboards,"/",r.maxDashboards,")"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("path",{d:"m21 21-4.3-4.3"})]}),t.jsx("input",{type:"text",placeholder:"Buscar...",value:N,onChange:e=>T(e.target.value),className:_r("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")})]}),v,o&&h&&t.jsxs("button",{onClick:h,className:_r("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:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})}),"Novo"]})]})]}),t.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-card",children:$p.map(e=>t.jsx("button",{onClick:()=>D(e.value),disabled:s,className:_r("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))}),s&&t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!s&&t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"sticky top-0 bg-muted/80 backdrop-blur-sm border-b border-border",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-12 px-3 py-2 text-left font-medium text-muted-foreground",children:t.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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"})})}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Código"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Título"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Responsável"}),t.jsx("th",{className:"w-12 px-3 py-2 text-center font-medium text-muted-foreground",children:t.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Última modificação"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Situação"}),t.jsx("th",{className:"w-12 px-3 py-2"})]})}),t.jsxs("tbody",{children:[0===E.length&&t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-3 py-12 text-center text-muted-foreground",children:"Nenhum dashboard encontrado."})}),E.map(e=>t.jsxs("tr",{onClick:()=>c?.(e),className:_r("border-b border-border cursor-pointer transition-colors","hover:bg-accent/50"),children:[t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:t=>{t.stopPropagation(),x?.(e)},className:"p-1 hover:bg-accent rounded transition-colors",children:t.jsx("svg",{className:_r("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:t.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"})})})}),t.jsx("td",{className:"px-3 py-2 font-mono text-xs text-foreground",children:e.code}),t.jsx("td",{className:"px-3 py-2 text-foreground font-medium",children:qp(e,n)}),t.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:e.responsibleName}),t.jsx("td",{className:"px-3 py-2 text-center",children:e.hasSharedIcon&&t.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:Vp(e.lastModified)}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:_r("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"})}),t.jsx("td",{className:"px-3 py-2",children:t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:t=>{t.stopPropagation(),A(S===e.id?null:e.id)},className:"p-1 hover:bg-accent rounded transition-colors",children:t.jsxs("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1"}),t.jsx("circle",{cx:"12",cy:"12",r:"1"}),t.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),S===e.id&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>A(null)}),t.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:[t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),c?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Abrir"}),i&&t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),d?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Editar"}),i&&t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),u?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Compartilhar"}),t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),m?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Duplicar"}),l&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border"}),t.jsx("button",{onClick:t=>{t.stopPropagation(),A(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 Hp=[{value:qm.NotUpdate,label:e.t("dashboard_no_refresh")},{value:qm.FiveMinutes,label:"5 minutos"},{value:qm.TenMinutes,label:"10 minutos"},{value:qm.FifteenMinutes,label:"15 minutos"},{value:qm.ThirtyMinutes,label:"30 minutos"},{value:qm.OneHour,label:"1 hora"}],Gp=[{value:Vm.NormalPage,label:e.t("dashboard_normal_page")},{value:Vm.Carousel,label:"Carrossel"}],Kp=[{value:Lm.FiveSeconds,label:"5 segundos"},{value:Lm.TenSeconds,label:"10 segundos"},{value:Lm.FifteenSeconds,label:"15 segundos"},{value:Lm.ThirtySeconds,label:"30 segundos"},{value:Lm.OneMinute,label:"1 minuto"},{value:Lm.ThreeMinutes,label:"3 minutos"},{value:Lm.FiveMinutes,label:"5 minutos"},{value:Lm.TenMinutes,label:"10 minutos"}],Yp=[{value:Wm.NotShared,label:e.t("dashboard_not_shared"),description:e.t("dashboard_only_responsible")},{value:Wm.SharedWithAllCollaborators,label:e.t("dashboard_shared_unit"),description:e.t("dashboard_all_access")},{value:Wm.SharedWithUsersGroupsPlacesCollaborators,label:e.t("dashboard_select_groups"),description:e.t("dashboard_select_groups")}],Qp=[{key:"pt-br",label:"PT-BR"},{key:"en",label:"EN-US"},{key:"es",label:"ES-ES"}];function Xp({dashboard:e,initialTab:r=$m.General,isSaving:s=!1,isQualitfy:n=!1,users:o=[],groups:i=[],places:l=[],collaborators:c=[],onSave:d,onCancel:u,className:m}){const{t:p}=y.useTranslation(),h=!!e,[x,f]=a.useState(r),[g,b]=a.useState({"pt-br":!!e?.titlePtBr||!h,en:!!e?.titleEnUs,es:!!e?.titleEsEs}),[v,w]=a.useState(e?.titlePtBr??""),[j,N]=a.useState(e?.titleEnUs??""),[_,C]=a.useState(e?.titleEsEs??""),[k,S]=a.useState(e?.responsibleId??""),[A,T]=a.useState(e?.isActive??!0),[D,E]=a.useState(e?.idUpdateTime??qm.NotUpdate),[P,I]=a.useState(e?.idViewType??Vm.NormalPage),[M,R]=a.useState(e?.idPageTime??Lm.FifteenSeconds),[L,F]=a.useState(e?.idShare??Wm.NotShared),[z,U]=a.useState(e?.groups??[]),[O,B]=a.useState(e?.places??[]),[q,V]=a.useState(e?.collaborators??[]),$=P===Vm.Carousel,W=g["pt-br"]||g.en||g.es,H=a.useMemo(()=>!!W&&(!(g["pt-br"]&&!v.trim())&&(!(g.en&&!j.trim())&&!(g.es&&!_.trim()))),[W,g,v,j,_]),G=a.useCallback(e=>{b(t=>({...t,[e]:!t[e]}))},[]),K=a.useCallback(()=>{H&&!s&&d?.({titlePtBr:g["pt-br"]?v:"",titleEnUs:g.en?j:"",titleEsEs:g.es?_:"",responsibleId:k||void 0,isActive:A,idUpdateTime:D,idViewType:P,idPageTime:$?M:null,idShare:L,groups:L===Wm.SharedWithUsersGroupsPlacesCollaborators?z:[],places:L===Wm.SharedWithUsersGroupsPlacesCollaborators?O:[],collaborators:L===Wm.SharedWithUsersGroupsPlacesCollaborators?q:[]})},[H,s,d,g,v,j,_,k,A,D,P,M,$,L,z,O,q]);return t.jsxs("div",{className:_r("flex flex-col h-full bg-background",m),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p(h?"dashboard_edit":"dashboard_new")}),h&&e&&t.jsx("span",{className:"text-sm text-muted-foreground",children:e.code})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:u,className:"px-3 py-2 text-sm rounded-md border border-input hover:bg-accent transition-colors",children:"Cancelar"}),t.jsxs("button",{onClick:K,disabled:!H||s,className:_r("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:[s?t.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"}):t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Salvar"]})]})]}),t.jsxs("div",{className:"flex border-b border-border bg-card",children:[t.jsx("button",{onClick:()=>f($m.General),className:_r("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===$m.General?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Geral"}),t.jsx("button",{onClick:()=>f($m.Share),className:_r("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===$m.Share?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Compartilhamento"})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x===$m.General&&t.jsxs("div",{className:"max-w-2xl space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Título *"}),t.jsx("div",{className:"flex gap-2",children:Qp.map(e=>t.jsx("button",{onClick:()=>G(e.key),className:_r("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&&t.jsx("p",{className:"text-xs text-destructive",children:"Selecione pelo menos um idioma"})]}),g["pt-br"]&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Português (BR)"}),t.jsx("input",{value:v,onChange:e=>w(e.target.value),maxLength:200,className:_r("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")}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[v.length,"/200"]})]}),g.en&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Inglês (US)"}),t.jsx("input",{value:j,onChange:e=>N(e.target.value),maxLength:200,className:_r("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")}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[j.length,"/200"]})]}),g.es&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Espanhol (ES)"}),t.jsx("input",{value:_,onChange:e=>C(e.target.value),maxLength:200,className:_r("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")}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[_.length,"/200"]})]}),!e?.isStandard&&o.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Responsável"}),t.jsxs("select",{value:k,onChange:e=>S(e.target.value),disabled:!h,className:_r("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:[t.jsx("option",{value:"",children:"Selecione..."}),o.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Intervalo de atualização"}),t.jsx("select",{value:D,onChange:e=>E(Number(e.target.value)),disabled:n,className:_r("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:Hp.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Situação"}),t.jsxs("div",{className:"flex items-center gap-3 h-10",children:[t.jsx("button",{onClick:()=>T(!A),disabled:e?.isGeneralViewUse,className:_r("relative inline-flex h-6 w-11 items-center rounded-full transition-colors",A?"bg-primary":"bg-muted","disabled:opacity-50"),children:t.jsx("span",{className:_r("inline-block h-4 w-4 rounded-full bg-white transition-transform",A?"translate-x-6":"translate-x-1")})}),t.jsx("span",{className:"text-sm text-foreground",children:A?"Ativo":"Inativo"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Tipo de visualização"}),t.jsx("select",{value:P,onChange:e=>I(Number(e.target.value)),disabled:n||$,className:_r("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:Gp.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]}),$&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Trocar página a cada"}),t.jsx("select",{value:M??"",onChange:e=>R(Number(e.target.value)),className:_r("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:Kp.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]})]})]}),x===$m.Share&&t.jsxs("div",{className:"max-w-2xl space-y-6",children:[t.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 border border-border",children:[t.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:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{d:"M12 16v-4"}),t.jsx("path",{d:"M12 8h.01"})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure quem pode visualizar este dashboard. O responsável sempre terá acesso."})]}),t.jsx("div",{className:"space-y-3",children:Yp.map(a=>t.jsxs("label",{className:_r("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",L===a.value?"border-primary bg-primary/5":"border-border hover:bg-accent/50",e?.isGeneralViewUse&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"shareType",value:a.value,checked:L===a.value,onChange:()=>F(a.value),disabled:e?.isGeneralViewUse,className:"mt-1 accent-primary"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:a.label}),t.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]},a.value))}),L===Wm.SharedWithUsersGroupsPlacesCollaborators&&t.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Grupos de usuários (",z.length,")"]}),t.jsx("select",{multiple:!0,value:z,onChange:e=>{const t=Array.from(e.target.selectedOptions,e=>e.value);U(t)},className:_r("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=>t.jsx("option",{value:e.id,children:e.name},e.id))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Locais (",O.length,")"]}),t.jsx("select",{multiple:!0,value:O,onChange:e=>{const t=Array.from(e.target.selectedOptions,e=>e.value);B(t)},className:_r("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=>t.jsx("option",{value:e.id,children:e.name},e.id))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Colaboradores (",q.length,")"]}),t.jsx("select",{multiple:!0,value:q,onChange:e=>{const t=Array.from(e.target.selectedOptions,e=>e.value);V(t)},className:_r("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:c.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))})]})]})]})]})]})}function Jp(){return`n_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Zp(e,t){return{id:t?.id??Jp(),text:e,children:t?.children,collapsed:t?.collapsed,color:t?.color,icon:t?.icon,note:t?.note,side:t?.side}}function eh(e,t){if(e.id===t)return{node:e,parent:null};const a=[];for(const r of e.children??[])a.push({node:r,parent:e});for(;a.length;){const e=a.pop();if(e.node.id===t)return{node:e.node,parent:e.parent};for(const t of e.node.children??[])a.push({node:t,parent:e.node})}return null}function th(e,t){const a=t(e);return a.children?.length?{...a,children:a.children.map(e=>th(e,t))}:a}function ah(e,t,a){return th(e,e=>e.id===t?a(e):e)}function rh(e){return{left:(e.children??[]).filter(e=>"left"===e.side).length,right:(e.children??[]).filter(e=>"left"!==e.side).length}}function sh(e,t,a){const r=Zp(a||"");let s=r.id;return{root:th(e,a=>{if(a.id!==t)return a;let n=r;if(a.id===e.id){const t=rh(e);n={...n,side:t.left<=t.right?"left":"right"}}else n={...n,side:a.side};return s=n.id,{...a,collapsed:!1,children:[...a.children??[],n]}}),newId:s}}function nh(e,t,a){if(e.id===t)return sh(e,t,a);const r=eh(e,t);if(!r||!r.parent)return{root:e,newId:t};const s=r.parent,n=Zp(a||"",{side:r.node.side}),o=n.id;return{root:th(e,e=>{if(e.id!==s.id)return e;const a=(e.children??[]).findIndex(e=>e.id===t),r=[...e.children??[]];return r.splice(a+1,0,n),{...e,children:r}}),newId:o}}function oh(e,t){if(e.id===t)return{root:e,nextSelectedId:t};const a=eh(e,t);if(!a||!a.parent)return{root:e,nextSelectedId:null};const r=a.parent,s=r.children??[],n=s.findIndex(e=>e.id===t),o=s[n+1]?.id??s[n-1]?.id??r.id;return{root:th(e,e=>e.id!==r.id?e:{...e,children:(e.children??[]).filter(e=>e.id!==t)}),nextSelectedId:o}}function ih(e,t,a){if(t===a)return e;if(t===e.id)return e;if(function(e,t,a){const r=eh(e,t);return!!r&&!!eh(r.node,a)}(e,t,a))return e;const r=eh(e,t);if(!r)return e;const s=(()=>{if(a===e.id){const t=rh(e);return{...r.node,side:t.left<=t.right?"left":"right"}}const t=eh(e,a)?.node;return{...r.node,side:t?.side}})(),n=th(e,e=>e.children?.length&&e.children.some(e=>e.id===t)?{...e,children:e.children.filter(e=>e.id!==t)}:e);return th(n,e=>e.id!==a?e:{...e,collapsed:!1,children:[...e.children??[],s]})}function lh(e,t){return ah(e,t,e=>({...e,collapsed:!e.collapsed}))}function ch(e,t){return th(e,a=>a.children?.length?a.id===e.id&&t?a:{...a,collapsed:t}:a)}function dh(e){const{value:t,defaultValue:r,onChange:s,readOnly:n}=e,o=void 0!==t,[i,l]=a.useState(()=>r??t??Zp("Mapa Mental",{id:"root"})),c=o?t:i,[d,u]=a.useState(c.id),m=a.useRef([]),p=a.useRef([]),h=a.useCallback((e,t)=>{n||(m.current.push(t),m.current.length>50&&m.current.shift(),p.current=[],o||l(e),s?.(e))},[o,s,n]),x=a.useCallback((e,t)=>{const a=ah(c,e,e=>({...e,text:t}));h(a,c)},[c,h]),f=a.useCallback((e,t)=>{const a=ah(c,e,e=>({...e,...t}));h(a,c)},[c,h]),g=a.useCallback((e,t="")=>{const{root:a,newId:r}=sh(c,e,t);return h(a,c),u(r),r},[c,h]),b=a.useCallback((e,t="")=>{const{root:a,newId:r}=nh(c,e,t);return h(a,c),u(r),r},[c,h]),v=a.useCallback(e=>{const{root:t,nextSelectedId:a}=oh(c,e);t!==c&&(h(t,c),u(a))},[c,h]),y=a.useCallback((e,t)=>{const a=ih(c,e,t);a!==c&&h(a,c)},[c,h]),w=a.useCallback(e=>{const t=eh(c,e);if(!t||!t.node.children?.length)return;const a=lh(c,e);h(a,c)},[c,h]),j=a.useCallback(()=>{h(ch(c,!1),c)},[c,h]),N=a.useCallback(()=>{h(ch(c,!0),c)},[c,h]),_=a.useCallback(()=>{const e=m.current.pop();e&&(p.current.push(c),o||l(e),s?.(e))},[c,o,s]),C=a.useCallback(()=>{const e=p.current.pop();e&&(m.current.push(c),o||l(e),s?.(e))},[c,o,s]),k=m.current.length>0,S=p.current.length>0,A=a.useMemo(()=>d?eh(c,d)?.node??null:null,[c,d]),T=a.useCallback(e=>{h(e,c)},[c,h]);return{root:c,setRoot:T,selectedId:d,selectedNode:A,setSelectedId:u,renameNode:x,updateNodeProps:f,addChild:g,addSibling:b,removeNode:v,moveNode:y,toggleNode:w,expandAll:j,collapseAll:N,undo:_,redo:C,canUndo:k,canRedo:S}}const uh=180,mh=80,ph=16,hh=60;function xh(e){const t=(e.collapsed?[]:e.children??[]).map(xh);if(!t.length)return{node:e,visibleChildren:t,height:44};const a=t.reduce((e,t)=>e+t.height,0)+ph*(t.length-1);return{node:e,visibleChildren:t,height:Math.max(44,a)}}function fh(e,t,a,r,s,n,o){const i=[],l={node:e.node,parent:t,x:a,y:r,width:180,height:44,side:s,depth:n,visibleChildren:i};if(o.push(l),!e.visibleChildren.length)return l;let c=r+22-(e.visibleChildren.reduce((e,t)=>e+t.height,0)+ph*(e.visibleChildren.length-1))/2;for(const d of e.visibleChildren){const t="right"===s?a+180+mh:a-mh-uh,r=c+d.height/2-22,l=fh(d,e.node,t,r,s,n+1,o);i.push(l),c+=d.height+ph}return l}function gh(e){return a.useMemo(()=>function(e){const t=e.collapsed?[]:e.children??[],a=t.filter(e=>"left"!==e.side).map(xh),r=t.filter(e=>"left"===e.side).map(xh),s=a.reduce((e,t)=>e+t.height,0)+ph*Math.max(0,a.length-1),n=r.reduce((e,t)=>e+t.height,0)+ph*Math.max(0,r.length-1),o=Math.max(s,n,56),i=e=>e.visibleChildren.length?1+Math.max(...e.visibleChildren.map(i)):0,l=a.length?Math.max(...a.map(i))+1:0,c=260*(r.length?Math.max(...r.map(i))+1:0),d=220+260*l+c+120,u=o+120,m=hh+c,p=[],h={node:e,parent:null,x:m,y:hh+o/2-28,width:220,height:56,side:"root",depth:0,visibleChildren:[]};p.push(h);let x=hh+o/2-s/2;for(const b of a){const t=x+b.height/2-22,a=fh(b,e,m+220+mh,t,"right",1,p);h.visibleChildren.push(a),x+=b.height+ph}let f=hh+o/2-n/2;for(const b of r){const t=f+b.height/2-22,a=fh(b,e,m-mh-uh,t,"left",1,p);h.visibleChildren.push(a),f+=b.height+ph}const g=new Map(p.map(e=>[e.node.id,e]));return{nodes:p,byId:g,width:d,height:u}}(e),[e])}function bh(e,t){const{layout:a,selectedId:r,setSelectedId:s}=t;if(!r)return void s(a.nodes[0]?.node.id??null);const n=a.byId.get(r);if(!n)return;if("left"===e||"right"===e){if("root"===n.side){const t=n.visibleChildren.find(t=>t.side===e);return void(t&&s(t.node.id))}if(e===n.side){const e=n.visibleChildren[Math.floor(n.visibleChildren.length/2)];e&&s(e.node.id)}else n.parent&&s(n.parent.id);return}if(!n.parent)return;const o=a.byId.get(n.parent.id);if(!o)return;const i=o.visibleChildren.filter(e=>e.side===n.side),l=i.findIndex(e=>e.node.id===r),c="up"===e?i[l-1]:i[l+1];c&&s(c.node.id)}const vh=({layout:e,selected:a,editing:r,readOnly:s,onSelect:n,onStartEditing:o,onFinishEditing:i,onToggle:l,onDragStart:d,onDragOver:u,onDragLeave:m,onDrop:p,isDropTarget:h,renderNodeContent:x})=>{const f=e.node,g="root"===e.side,b=function(e){return e?ae[e]??null:null}(f.icon),v=!!f.children?.length,y=te.useRef(null),[w,j]=te.useState(f.text);te.useEffect(()=>{if(r){j(f.text);const e=window.setTimeout(()=>{y.current?.focus(),y.current?.select()},0);return()=>window.clearTimeout(e)}},[r,f.text]);const N=()=>{i(w.trim()||f.text)},_=f.color;return t.jsxs("div",{role:"treeitem","aria-selected":a,"aria-expanded":v?!f.collapsed:void 0,tabIndex:a?0:-1,"data-node-id":f.id,draggable:!s&&!g&&!r,onDragStart:d,onDragOver:u,onDragLeave:m,onDrop:p,onClick:e=>{e.stopPropagation(),n()},onDoubleClick:e=>{e.stopPropagation(),s||o()},className:_r("absolute flex items-center gap-2 rounded-lg border bg-card text-card-foreground px-3 select-none transition-shadow","shadow-sm hover:shadow-md cursor-pointer",g&&"font-semibold border-primary/40 bg-primary text-primary-foreground",a&&!g&&"ring-2 ring-primary ring-offset-1",a&&g&&"ring-2 ring-primary-foreground/60 ring-offset-1",h&&"ring-2 ring-accent border-accent"),style:{left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:_},children:[b&&t.jsx(b,{className:_r("h-4 w-4 shrink-0",g&&"text-primary-foreground")}),t.jsx("div",{className:"flex-1 min-w-0",children:r?t.jsx("input",{ref:y,value:w,onChange:e=>j(e.target.value),onBlur:N,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),N()):"Escape"===e.key?(e.preventDefault(),i(null)):e.stopPropagation()},className:_r("w-full bg-transparent outline-none text-sm",g&&"text-primary-foreground placeholder:text-primary-foreground/60")}):x?t.jsx("div",{className:"text-sm truncate",children:x(f)}):t.jsx("div",{className:"text-sm truncate",children:f.text||t.jsx("span",{className:"opacity-50",children:"—"})})}),f.note&&!r&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("button",{type:"button",onClick:e=>e.stopPropagation(),className:_r("shrink-0 rounded p-0.5 hover:bg-muted/40",g&&"hover:bg-primary-foreground/10"),"aria-label":f.note,children:t.jsx(c.FileText,{className:"h-3.5 w-3.5 opacity-70"})})}),t.jsx(en,{className:"max-w-xs whitespace-pre-line",children:f.note})]}),v&&t.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},className:_r("shrink-0 rounded-full border bg-background text-foreground h-5 w-5 flex items-center justify-center -mr-1","shadow-sm hover:bg-muted transition-colors",g&&"border-primary-foreground/30"),"aria-label":f.collapsed?"Expandir":"Colapsar",children:f.collapsed?t.jsx(c.Plus,{className:"h-3 w-3"}):"left"===e.side?t.jsx(c.ChevronRight,{className:"h-3 w-3 rotate-180"}):"right"===e.side?t.jsx(c.ChevronRight,{className:"h-3 w-3"}):t.jsx(c.Minus,{className:"h-3 w-3"})})]})},yh=({parent:e,child:a})=>{const r=a.x+a.width/2<e.x+e.width/2,s=r?e.x:e.x+e.width,n=e.y+e.height/2,o=r?a.x+a.width:a.x,i=a.y+a.height/2,l=(s+o)/2,c=`M ${s} ${n} C ${l} ${n}, ${l} ${i}, ${o} ${i}`;return t.jsx("path",{d:c,fill:"none",stroke:"hsl(var(--border))",strokeWidth:2,strokeLinecap:"round"})},wh=({label:e,icon:a,onClick:r,disabled:s})=>t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",onClick:r,disabled:s,"aria-label":e,className:"h-8 w-8",children:a})}),t.jsx(en,{children:e})]}),jh=e=>{const{t:a}=y.useTranslation();return t.jsxs("div",{className:"flex items-center gap-1 border-b bg-card px-2 py-1.5",children:[t.jsx(wh,{label:a("mind_map_add_child"),icon:t.jsx(c.CornerDownRight,{className:"h-4 w-4"}),onClick:e.onAddChild,disabled:!e.canAddChild}),t.jsx(wh,{label:a("mind_map_add_sibling"),icon:t.jsx(c.Plus,{className:"h-4 w-4"}),onClick:e.onAddSibling,disabled:!e.canAddSibling}),t.jsx(wh,{label:a("mind_map_delete_node"),icon:t.jsx(c.Trash2,{className:"h-4 w-4"}),onClick:e.onDelete,disabled:!e.canDelete}),t.jsx(zr,{orientation:"vertical",className:"mx-1 h-5"}),t.jsx(wh,{label:a("mind_map_expand_all"),icon:t.jsx(c.ChevronsUpDown,{className:"h-4 w-4"}),onClick:e.onExpandAll}),t.jsx(wh,{label:a("mind_map_collapse_all"),icon:t.jsx(c.ChevronsDownUp,{className:"h-4 w-4"}),onClick:e.onCollapseAll}),t.jsx(zr,{orientation:"vertical",className:"mx-1 h-5"}),t.jsx(wh,{label:a("mind_map_zoom_out"),icon:t.jsx(c.ZoomOut,{className:"h-4 w-4"}),onClick:e.onZoomOut}),t.jsx(wh,{label:a("mind_map_zoom_in"),icon:t.jsx(c.ZoomIn,{className:"h-4 w-4"}),onClick:e.onZoomIn}),t.jsx(wh,{label:a("mind_map_fit_to_screen"),icon:t.jsx(c.Maximize2,{className:"h-4 w-4"}),onClick:e.onFit}),t.jsx(zr,{orientation:"vertical",className:"mx-1 h-5"}),t.jsx(wh,{label:a("mind_map_undo"),icon:t.jsx(c.Undo2,{className:"h-4 w-4"}),onClick:e.onUndo,disabled:!e.canUndo}),t.jsx(wh,{label:a("mind_map_redo"),icon:t.jsx(c.Redo2,{className:"h-4 w-4"}),onClick:e.onRedo,disabled:!e.canRedo}),t.jsx("div",{className:"flex-1"}),t.jsx(wh,{label:a("mind_map_export_json"),icon:t.jsx(c.Download,{className:"h-4 w-4"}),onClick:e.onExportJson}),t.jsx(wh,{label:a("mind_map_export_image"),icon:t.jsx(c.Image,{className:"h-4 w-4"}),onClick:e.onExportImage})]})};function Nh(e){return JSON.stringify(e,null,2)}function _h(e){if(!e||"object"!=typeof e)throw new Error("Invalid mind map node: not an object");const t=e;if("string"!=typeof t.text)throw new Error('Invalid mind map node: missing "text"');const a=Array.isArray(t.children)?t.children.map(e=>_h(e)):void 0;return Zp(t.text,{id:"string"==typeof t.id?t.id:void 0,collapsed:"boolean"==typeof t.collapsed?t.collapsed:void 0,color:"string"==typeof t.color?t.color:void 0,icon:"string"==typeof t.icon?t.icon:void 0,note:"string"==typeof t.note?t.note:void 0,side:"left"===t.side||"right"===t.side?t.side:void 0,children:a})}function Ch({data:e,columns:r,sortField:s,sortDirection:n,onSort:o,onRowClick:i,renderActions:l,isLoading:d=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,enableColumnReorder:w=!1,onReorderColumns:j,storageKey:N,enableExpandableRows:_=!1,renderExpandedContent:C,expandedRowIds:k,onToggleExpand:S,defaultExpandAll:A=!1,rowActionsVariant:T="default",hideActionsColumn:D=!1,actionsHeaderContent:E}){const{t:P}=y.useTranslation(),I=u||P("no_items_found",P("no_items_found_empty")),[M,R]=a.useState(()=>A?new Set(e.map(e=>e.id)):new Set),L=void 0!==k,F=L?new Set(k):M,z=a.useCallback(e=>{L&&S?S(e):R(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[L,S]),{columnWidths:U,isDragging:O,activeColumn:B,handleMouseDown:q}=di({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,onResize:v,enabled:b}),V=yi({enabled:w&&!!j,onReorder:j??(()=>{})}),$=a.useMemo(()=>{if(b){const e=r.map(e=>U[String(e.key)]??e.width??e.minWidth??150),t=e.reduce((e,t)=>e+t,0);return e.map(e=>e/t*100+"%")}const e=r.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return r.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[r,b,U]);if(d)return t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,a)=>t.jsx(hn,{className:"h-12 w-full"},a))})});if(0===e.length)return t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx("p",{children:I})})});const W=l&&!D,H=(p?1:0)+(_?1:0)+r.length+(W?1:0);return t.jsx("div",{className:"flex-1 overflow-auto "+(O?"select-none":""),children:t.jsxs(Eo,{className:_r("table-fixed w-full",m),children:[t.jsx(Po,{className:"sticky top-0 bg-background z-10",children:t.jsxs(Ro,{children:[_&&t.jsx(Lo,{className:"w-[40px]"}),p&&t.jsx(Lo,{className:"w-[40px]",children:t.jsx(As,{checked:g,onCheckedChange:f,"aria-label":P("select_all","Selecionar todos")})}),r.map((e,a)=>{const r=b&&!1!==e.resizable,i=B===String(e.key),l=w&&!!j,d=l?V.getDragProps(a):{},u=V.dragFromIndex===a,m=V.dragOverIndex===a&&V.dragFromIndex!==a;return t.jsxs(Lo,{className:_r(e.className,"relative transition-opacity",e.sortable&&"cursor-pointer",l&&V.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:$[a]},...d,children:[!1!==e.sortable&&o?t.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),s!==p?null:"asc"===n?t.jsx(c.ArrowUp,{size:14,className:"ml-1"}):t.jsx(c.ArrowDown,{size:14,className:"ml-1"}))]}):t.jsx("span",{className:"font-medium",children:e.header}),r&&t.jsx($o,{direction:"horizontal",onMouseDown:t=>q(String(e.key),t),isDragging:i})]},String(e.key));var p}),W&&t.jsx(Lo,{className:"w-[80px] text-right",children:E??P("actions","Ações")})]})}),t.jsx(Io,{children:e.map(e=>{const s=_&&F.has(e.id);return t.jsxs(a.Fragment,{children:[t.jsxs(Ro,{onClick:()=>i?.(e),className:_r(i?"cursor-pointer":"","relative","inline"===T&&"group"),children:[_&&t.jsx(Fo,{className:"w-[40px] px-2",children:t.jsx("button",{onClick:t=>{t.stopPropagation(),z(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":s?P("collapse_row","Recolher linha"):P("expand_row","Expandir linha"),children:s?t.jsx(c.ChevronDown,{size:16,className:"text-muted-foreground"}):t.jsx(c.ChevronRight,{size:16,className:"text-muted-foreground"})})}),p&&t.jsx(Fo,{children:t.jsx(As,{checked:h.includes(e.id),onCheckedChange:()=>x?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`${P("select_all","Selecionar todos")} ${e.id}`})}),r.map(a=>t.jsx(Fo,{className:a.className,children:t.jsx(Vo,{children:a.render?a.render(e):String(e[a.key]??"-")})},String(a.key))),W&&t.jsx(Fo,{className:"text-right",onClick:e=>e.stopPropagation(),children:"inline"===T?t.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:l(e)}):l(e)})]}),s&&C&&t.jsx(Ro,{className:"bg-muted/30 hover:bg-muted/30",children:t.jsx(Fo,{colSpan:H,className:"p-0",children:t.jsx("div",{className:"animate-accordion-down overflow-hidden",children:C(e)})})})]},e.id)})})]})})}function kh({searchValue:e="",onSearchChange:a,customFilters:r=[],onClearFilters:s,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=y.useTranslation(),l=e||r.length>0;return t.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&t.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{type:"text",placeholder:i("search","Pesquisar"),value:e,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),r.map((e,a)=>t.jsx("div",{className:"vertical"===o?"w-full":"",children:e},a)),n&&l&&s&&t.jsxs(Sr,{variant:"ghost",size:"sm",onClick:s,className:"h-9 px-3 whitespace-nowrap",children:[t.jsx(c.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})}function Sh(e,t){const a=new Set;function r(e){if(e)for(const t of e)a.add(t.id),r(t.children)}return function e(a){for(const s of a){if(s.id===t)return r(s.children),!0;if(s.children&&e(s.children))return!0}return!1}(e),a}function Ah({children:e,itemId:a,enableDrag:r,onDragStartCell:s,onDragEndCell:n,onDragOverCell:o,onDropCell:i,className:l}){return t.jsx(Fo,{draggable:r,onDragStart:r?e=>s(a,e):void 0,onDragEnd:r?n:void 0,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),o(a,e)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o(a,e)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(a,e)},className:l,children:e})}function Th({item:e,level:a,columns:r,nameKey:s,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:d,rowActionsVariant:u="default",enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:b,onDragEndCell:v,onDragOverCell:y,onDropCell:w,dragCount:j}){const N=o.has(e.id),_=(e.children?.length??0)>0,C=24*a,k="inline"===u,S=f===e.id||p?.has(e.id)&&f&&p?.has(f),A=g===e.id&&f!==e.id,T=p?.has(e.id)??!1,D={itemId:e.id,enableDrag:x,onDragStartCell:b,onDragEndCell:v,onDragOverCell:y,onDropCell:w};return t.jsxs(t.Fragment,{children:[t.jsxs(Ro,{className:_r(l&&"cursor-pointer",k&&"group",S&&"opacity-40",A&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:l?()=>l(e):void 0,children:[t.jsx(Ah,{...D,children:t.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${C}px`},children:[m&&t.jsx(As,{checked:T,onCheckedChange:()=>h?.(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),x&&t.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),_?t.jsx("button",{onClick:t=>{t.stopPropagation(),i(e.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:N?t.jsx(c.ChevronDown,{className:"h-4 w-4"}):t.jsx(c.ChevronRight,{className:"h-4 w-4"})}):t.jsx("div",{className:"w-6 shrink-0"}),n??t.jsx(c.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate",children:String(e[s]??e.id)}),f===e.id&&j&&j>1&&t.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:j})]})}),r.map(r=>{const s=e[r.key],n=r.render?r.render(e,a):null!=s?String(s):"—";return t.jsx(Ah,{...D,className:_r("text-center",r.className),children:r.hoverContent?t.jsxs(Jc,{openDelay:200,children:[t.jsx(Zc,{asChild:!0,children:t.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),t.jsx(ed,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:r.hoverContent(e)})]}):n},String(r.key))}),d&&t.jsx(Ah,{...D,className:"text-right",children:t.jsx("div",{onClick:e=>e.stopPropagation(),className:_r("flex items-center justify-end gap-1",k&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:d(e)})})]}),_&&N&&e.children.map(e=>t.jsx(Th,{item:e,level:a+1,columns:r,nameKey:s,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:d,rowActionsVariant:u,enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:b,onDragEndCell:v,onDragOverCell:y,onDropCell:w,dragCount:j},e.id))]})}function Dh({onDrop:a,isDragOver:r,onDragOver:s,onDragLeave:n,label:o}){return t.jsxs("div",{className:_r("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",r?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:s,onDragEnter:s,onDragLeave:n,onDrop:a,children:[t.jsx(c.ArrowUpToLine,{className:"h-4 w-4"}),o??e.t("leadership_make_root_short")]})}function Eh(e){const t=N.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const r=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(r)}}}const Ph="true"===(void 0).VITE_SHOW_EDIT_PROFILE,Ih=a.memo(({variant:e="card",className:r="",selectedUnit:s,onUnitChange:n})=>{const{t:o}=y.useTranslation(),{user:i,companies:l,alias:d,isAuthenticated:u,logout:m,switchUnit:p}=So(),{role:h}=Dl(),x=h?.name||null,f=l?.[0]||null,g=d?l?.find(e=>e.alias===d):f,b=l||[],v=s||g||f||f,[w,j]=a.useState(0);a.useEffect(()=>{const e=()=>j(e=>e+1);return window.addEventListener("user-photo-updated",e),()=>window.removeEventListener("user-photo-updated",e)},[]);const N=a.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&v=${w}`},[i?.id,w]),_=a.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=96&v=${w}`},[i?.id,w]),C=a.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]),k=a.useCallback(e=>{n?n(e):p(e)},[n,p]),S=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===v?.alias),r=t.filter(e=>e.alias!==v?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...r]:r},[b,v?.alias]),[A,T]=a.useState(!1);if(!u||!i)return null;const D=()=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsxs(Zi,{className:"w-10 h-10",children:[N&&t.jsx(el,{src:N,alt:i.name||o("user_photo")}),t.jsx(tl,{className:"bg-primary text-primary-foreground text-white font-semibold text-sm",children:C||t.jsx(c.User,{className:"h-5 w-5"})})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",v?.name||"N/A"]})]})]}),v&&t.jsx("div",{className:"mt-3",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(c.Building2,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium",children:v.name})]})}),S.length>1&&t.jsxs("div",{className:"mt-2",children:[t.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",S.length]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[S.slice(0,3).map(e=>t.jsx(Es,{variant:e.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>k(e),children:e.name},e.alias)),S.length>3&&t.jsxs(Es,{variant:"outline",className:"text-xs",children:["+",S.length-3]})]})]})]});return"dropdown"===e?t.jsxs(t.Fragment,{children:[t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",className:`h-auto p-2 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10 ${r}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("div",{className:"hidden md:block text-right",children:[t.jsxs("p",{className:"text-sm font-medium",children:[i.name?.split(" ")[0],x?` [${x}]`:""]}),t.jsx("p",{className:"text-xs text-primary-foreground/70",children:v?.name||"N/A"})]}),t.jsxs(Zi,{className:"w-8 h-8 border border-primary-foreground/30",children:[N&&t.jsx(el,{src:N,alt:i.name||o("user_photo")}),t.jsx(tl,{className:"bg-primary-foreground/20 text-primary-foreground font-semibold text-xs",children:C||t.jsx(c.User,{className:"h-4 w-4"})})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4"})]})})}),t.jsxs($s,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[t.jsxs(Os,{children:[t.jsxs(qs,{children:[t.jsx(c.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),t.jsx(Vs,{children:S.map(e=>t.jsxs(Ws,{onClick:()=>k(e),className:e.alias===v?.alias?"bg-muted":"",children:[t.jsx(c.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===v?.alias&&t.jsx(Es,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Ph&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{}),t.jsxs(Ws,{onClick:()=>T(!0),children:[t.jsx(c.UserPen,{className:"mr-2 h-4 w-4"}),o("edit_profile","Editar Perfil")]})]}),t.jsx(Ys,{}),t.jsxs(Ws,{onClick:m,children:[t.jsx(c.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}),Ph&&t.jsx(fl,{open:A,onOpenChange:T,user:i,userPhotoUrl:_,userInitials:C})]}):t.jsxs(Pr,{className:r,children:[t.jsx(Ir,{children:t.jsx(Mr,{className:"text-lg",children:o("user_info")})}),t.jsxs(Lr,{className:"space-y-4",children:[t.jsx(D,{}),t.jsx(zr,{}),t.jsxs(Sr,{variant:"outline",onClick:m,size:"sm",className:"w-full",children:[t.jsx(c.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Mh=a.createContext({});function Rh({children:e,config:r}){const s=a.useMemo(()=>({navigation:r?.navigation,appName:r?.appName??void 0}),[r?.navigation,r?.appName]);return t.jsx(Mh.Provider,{value:s,children:e})}function Lh(){return a.useContext(Mh)}function Fh(e,t){if(!e)return"";const a=e.find(e=>e.path===t);if(a)return a.label;const r=e.find(e=>t.startsWith(e.path+"/"));return r?.label||""}function zh(e,t){const[r,s]=a.useState(e),n=a.useRef(void 0),o=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(o(),n.current=setTimeout(()=>{s(e)},t),o),[e,t,o]),[r,o]}function Uh({appName:e}){const[r,s]=a.useState(!1),{association:n}=Dl(),o=lt({isQualitfy:n?.isQualitfy,isMetroex:n?.isMetroex});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>s(!0),children:t.jsx("img",{src:o,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),e&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,className:"h-7 w-px shrink-0 bg-primary-foreground/30"}),t.jsx("button",{className:"min-w-0 text-sm font-medium text-left cursor-pointer text-primary-foreground/90 hover:text-primary-foreground/70 transition-colors leading-tight py-1",onClick:()=>s(!0),children:t.jsx("span",{className:"line-clamp-2",children:(e=>{const a=e.split(" ");if(a.length<=1)return t.jsxs("span",{className:"whitespace-nowrap",children:[e," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const r=a[a.length-1],s=a.slice(0,-1).join(" ");return t.jsxs(t.Fragment,{children:[s," ",t.jsxs("span",{className:"whitespace-nowrap",children:[r," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(e)})})]})]}),t.jsx(hc,{open:r,onOpenChange:s})]})}const Oh=a.memo(function({actions:r}){const s=N.useLocation(),n=N.useNavigate(),{navigation:o,appName:i}=Lh(),l=Fh(o,s.pathname),{metadata:d,headerActions:u}=vl(),{setOpenMobile:m}=eu(),{companies:p,alias:h,isSearchVisible:x,clearSearch:f,refreshData:g,switchUnit:b}=So(),v=h?p?.find(e=>e.alias===h)||p?.[0]||null:p?.[0]||null,[y,w]=N.useSearchParams(),j=a.useCallback(e=>{const{pathname:t,search:a,hash:r}=s;if(h){const s=t.split("/"),o=s.indexOf(h);if(o>=0)return s[o]=e.alias,void n(s.join("/")+a+r)}b(e)},[h,s,n,b]),[_,C]=a.useState(()=>y.get("search")||""),[k,S]=zh(_,Ve.debounceDelay);a.useEffect(()=>{if(!x)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),w(e)},[k,w,x]);const A=o?.find(e=>e.path===s.pathname)||o?.find(e=>s.pathname.startsWith(e.path+"/")),T=d.title||l,D=d.subtitle||A?.complementaryText||"";return t.jsx("header",{className:"bg-primary border-b border-primary px-2 md:px-4 py-2",children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(Sr,{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:t.jsx(c.Menu,{size:20})}),t.jsx("div",{className:"hidden md:flex items-center flex-shrink-0",children:t.jsx(Uh,{appName:i})}),t.jsx("div",{className:"hidden md:block w-px h-8 bg-primary-foreground/20 flex-shrink-0"}),t.jsxs("div",{className:"flex-shrink-0",children:[d.breadcrumbs&&d.breadcrumbs.length>0&&t.jsx("nav",{className:"flex items-center gap-1 text-xs text-primary-foreground/70 mb-0.5",children:d.breadcrumbs.map((e,a)=>t.jsxs("span",{className:"flex items-center gap-1",children:[a>0&&t.jsx(c.ChevronRight,{className:"h-3 w-3"}),e.href?t.jsx(N.Link,{to:e.href,className:"hover:text-primary-foreground transition-colors",children:e.label}):t.jsx("span",{children:e.label})]},a))}),t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("h1",{className:"text-lg font-semibold text-primary-foreground truncate",children:T})}),D&&t.jsx("div",{className:"text-sm text-primary-foreground/70 truncate",children:D})]}),x&&t.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(Tr,{placeholder:"Pesquisar",value:_,onChange:e=>(e=>{C(e)})(e.target.value),className:"w-full pl-10 pr-8"}),_&&t.jsx(Sr,{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(y);e.delete("search"),e.delete("page"),w(e)},title:e.t("clear_search"),children:t.jsx(c.X,{size:14})})]}),t.jsx(Sr,{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:t.jsx(c.RefreshCw,{size:14})})]}),t.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(u||r)&&t.jsx("div",{className:"flex items-center gap-2",children:u||r}),(void 0).VITE_WIKI_URL&&t.jsx(Sr,{variant:"ghost",size:"sm",className:"h-8 px-3 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:e=>gr((void 0).VITE_WIKI_URL,e),title:e.t("open_wiki"),children:"Wiki"}),t.jsx(pm,{}),t.jsx("div",{className:"text-sm",children:t.jsx(Ih,{variant:"dropdown",selectedUnit:v,onUnitChange:j})})]})]})})}),Bh=({key:e,enabled:t,checkFn:a,staleTime:r=3e5,gcTime:s=6e5})=>j.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1});function qh({config:e,isCollapsed:a=!1,isDisabled:r=!1,className:s}){const{t:n}=y.useTranslation(),{actions:o,triggerLabel:i="Criar",triggerIcon:l=c.Plus,variant:d="button"}=e;if(!o||0===o.length)return null;if("split-button"===d){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(a){const a=t.jsx(Sr,{onClick:e.onClick,disabled:r||e.disabled,className:_r("justify-center px-2 w-full",s),variant:"outline",size:"default",children:t.jsx(n,{className:"h-4 w-4 shrink-0"})});return t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:a}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]})}return t.jsx(sm,{label:e.label,onClick:e.onClick,icon:n,actions:i,variant:"outline",disabled:r||e.disabled,className:_r("w-full",s),menuAlign:"start"})}const u=(e,r,s=!1)=>t.jsxs(t.Fragment,{children:[e,!a&&r&&t.jsx("span",{className:"truncate",children:r}),!a&&s&&t.jsx(c.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const e=o[0],n=e.icon||l,i=r||e.disabled,c=t.jsx(Sr,{onClick:e.onClick,disabled:i,className:_r("w-full gap-2 justify-start",a&&"justify-center px-2",s),variant:"outline",size:"default",children:u(t.jsx(n,{className:"h-4 w-4 shrink-0"}),e.label)});return a?t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:c}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]}):c}const m=t.jsx(Sr,{disabled:r,className:_r("w-full gap-2 justify-start",a&&"justify-center px-2",s),variant:"outline",size:"default",children:u(t.jsx(l,{className:"h-4 w-4 shrink-0"}),i,!0)});return t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:a?t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:m}),t.jsx(en,{side:"right",children:t.jsx("p",{children:i})})]}):m}),t.jsx($s,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:o.map(e=>{const a=e.icon;return t.jsxs(Ws,{onClick:e.onClick,disabled:e.disabled,className:"cursor-pointer",children:[a&&t.jsx(a,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})}const Vh="forlogic-sidebar-pinned",$h=()=>{try{const e=localStorage.getItem(Vh);return!!e&&JSON.parse(e)}catch{return!1}};function Wh({direction:e="right",minWidth:t=224,maxWidth:r=384,defaultWidth:s=290,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,c]=a.useState(()=>{if("undefined"==typeof window)return s;const e=localStorage.getItem(n);return e?parseInt(e):s}),[d,u]=a.useState(!1),m=a.useRef(null);a.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","290px"))},[l,i]);const p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!d)return;const a=a=>{let s;s="left"===e?window.innerWidth-a.clientX:a.clientX,s=Math.max(t,Math.min(r,s)),c(s),o?.(s)},s=()=>{u(!1),c(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",s)}},[d,e,t,r,l,n,o]),a.useEffect(()=>(d?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d,e]),{width:l,isDragging:d,dragRef:m,handleMouseDown:p}}const Hh=a.createContext(void 0);function Gh(){const e=a.useContext(Hh);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Kh({config:e,customContent:r,resizable:s=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=y.useTranslation(),{open:l,setOpen:d,setOpenMobile:u}=eu(),m=N.useLocation(),{alias:p,user:h}=So(),{appName:x}=Lh(),{hasOpenModal:f}=Gh(),[g,b]=a.useState($h),v=Do(),w=!!v||l,j=a.useCallback(()=>{v&&u(!1)},[v,u]),_=s?Wh({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{d(!!g)},[g,d]);const C=e=>m.pathname===e||m.pathname.startsWith(e+"/");return t.jsxs(au,{collapsible:"icon",className:_r("app-sidebar bg-background border-r border-border flex flex-col",w?"px-3":"px-1.5"),style:_&&w?{width:`${_.width}px`,transition:"none"}:{transition:"width 300ms ease-in-out"},children:[e?.moduleActions&&e.moduleActions.actions.length>0&&t.jsx("div",{className:"py-3",children:t.jsx(Xs,{children:t.jsx(qh,{config:e.moduleActions,isCollapsed:!w,isDisabled:f})})}),t.jsx(du,{className:_r(e?.moduleActions&&e.moduleActions.actions.length>0?"pt-0":"pt-3"),children:r||t.jsx(uu,{className:"p-0",children:t.jsx(hu,{children:t.jsx(xu,{className:"gap-1",children:t.jsx(Xs,{children:e?.navigation?.map((e,a)=>{if("separator"===e.type)return t.jsx(cu,{className:"my-2"},`sep-${a}`);const r=({item:e,index:a})=>{const s=`${e.path}-${a}-${p??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:o}=Bh({key:s,enabled:Boolean(e.permissionCheck&&p&&h?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),l=e.permissionCheck&&!n,d=o?c.Loader2:l?c.Lock:e.icon;l?i("restricted_access"):e.complementaryText;return e.children&&e.children.length>0?w?t.jsx(zl,{defaultOpen:!0,className:"group/collapsible",children:t.jsxs(fu,{children:[t.jsx(Ul,{asChild:!0,children:t.jsx(bu,{size:"default",children:t.jsxs("div",{className:"flex w-full items-center gap-3",children:[t.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:t.jsx(d,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-medium sidebar-text",children:e.label}),t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),t.jsx(Ol,{children:t.jsx(ju,{children:e.children.map((e,a)=>t.jsx(r,{item:e,index:a},e.path))})})]})},e.path):t.jsx(fu,{children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("div",{className:_r("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:t.jsx(d,{className:"h-4 w-4"})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]})},e.path):t.jsx(fu,{children:l||o?t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:w?t.jsx(bu,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:t.jsxs("div",{className:"flex w-full items-center gap-3",children:[t.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:t.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),t.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):t.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:t.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:o?"Verificando acesso...":i("restricted_access")})})]}):w?t.jsx(bu,{asChild:!0,isActive:C(e.path),size:"default",children:t.jsxs(N.Link,{to:e.path,className:"flex w-full items-center gap-3",onClick:j,children:[t.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:t.jsx(d,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(N.Link,{to:e.path,onClick:j,className:_r("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:t.jsx(d,{className:"h-4 w-4"})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]})},e.path)};return t.jsx(r,{item:e,index:a},e.path)})})})})})}),!v&&t.jsx("div",{className:_r("mt-auto pb-4 pt-2 flex items-center gap-2",w?"justify-end px-1":"justify-center flex-col"),children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("button",{id:"btn-expand-side-nav",onClick:()=>{const e=!g;b(e),(e=>{try{localStorage.setItem(Vh,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?t.jsx(c.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):t.jsx(c.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:l?"Recolher":"Expandir"})})]})}),s&&_&&w&&t.jsx("div",{ref:_.dragRef,onMouseDown:_.handleMouseDown,className:_r("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")})]})}function Yh(e){if("string"!=typeof e)return;return e.trim()||void 0}function Qh(){const{alias:e,isAuthenticated:t,isLoading:r,selectedUnit:s}=So(),n=s?.id??null,o=!!$n.getAccessToken(),i=function(e,t){const a=Yh(t);if(a)return a;const r=$n,s=Yh(r.getCurrentCompanyId?.());if(s)return s;const n=$n.extractTokenData(),o=Yh(n?.companyId)??Yh(n?.company_id);if(o)return o;if(e){const t=Yh($n.getCompanyId(e));if(t)return t}}(e,n),l=!!e&&!!t&&o,c=l&&!!i,[,d]=a.useReducer(e=>e+1,0);a.useEffect(()=>{if(!t||o&&i)return;const e=window.setInterval(()=>d(),500);return()=>window.clearInterval(e)},[t,o,i]);let u=null;return r?u="Carregando autenticação...":t?e?o?i||(u="Aguardando unidade ativa..."):u="Aguardando token de acesso Qualiex...":u="Aguardando alias...":u="Usuário não autenticado",{alias:e,companyId:i,hasAccessToken:o,isAuthLoading:!!r,isAuthenticated:!!t,isReadyForQualiex:l,isReadyForQualiexWithCompany:c,isWaitingCompanyId:!!t&&o&&!i,waitingReason:u}}async function Xh(e,t){const a=await nl(`${al()}/api/common/v1/updates/userView/${t}`,e),r=await a.json(),s=r?.data??r;return Array.isArray(s)?s:[]}async function Jh(e,t,a,r){const s=void 0===r?"undefined":String(r),n={id:t,idUpdateType:a};void 0!==r&&(n.liked=r),await nl(`${al()}/api/common/v1/Updates/userVisualized/${a}/${s}`,e,{method:"POST",body:JSON.stringify(n)})}const Zh=3e5;function ex(){const{alias:e,isReadyForQualiex:t}=Qh();return j.useQuery({queryKey:["user-updates","bar",e],queryFn:()=>Xh(e,1),enabled:t,staleTime:Zh})}function tx(){const{alias:e,isReadyForQualiex:t}=Qh();return j.useQuery({queryKey:["user-updates","dialog",e],queryFn:()=>Xh(e,2),enabled:t,staleTime:Zh})}function ax({item:e,onDismiss:a}){const{t:r}=y.useTranslation(),s=e.text||e.title,n=e.color||"hsl(var(--primary))";return t.jsxs("div",{"data-testid":`updates-bar-${e.id}`,role:"status",style:{backgroundColor:n},className:"w-full flex items-center justify-center gap-3 px-4 py-2 text-sm text-white relative",children:[e.url?t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 hover:underline",children:[s,t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]}):t.jsx("span",{children:s}),t.jsx("button",{type:"button",onClick:()=>a(e.id),"aria-label":r("updates_bar_close","Fechar"),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60",children:t.jsx(c.X,{className:"h-4 w-4"})})]})}function rx(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function sx(e,t){const a=rx(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function nx(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function ox(e,t){const a=nx(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function ix(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function lx(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function cx({item:e,open:r,onClose:s}){const{t:n}=y.useTranslation(),[o,i]=a.useState(!1),[l,d]=a.useState(!1);a.useEffect(()=>{i(!1),d(!1)},[e.id]);const u=e.countLiked+(o?1:0);return t.jsx(Qr,{open:r,onOpenChange:e=>{e||s({liked:o,doNotShowAgain:l})},children:t.jsxs(as,{size:"md",children:[t.jsx(rs,{showSeparator:!0,children:t.jsx(os,{style:e.color?{color:e.color}:void 0,children:e.title})}),t.jsxs(ss,{children:[(()=>{const a=e.urlVideo??e.videoUrl??e.url??"",r=a?rx(a):null;return r?t.jsx("div",{className:"mb-3 aspect-video w-full overflow-hidden rounded-lg border bg-black",children:t.jsx("iframe",{src:`https://www.youtube.com/embed/${r}`,className:"h-full w-full",title:e.title,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}):null})(),t.jsx("div",{className:"text-sm leading-relaxed [&_a]:text-primary [&_a]:underline [&_strong]:font-semibold [&_p]:mb-2 [&_ul]:list-disc [&_ul]:ml-5 [&_ol]:list-decimal [&_ol]:ml-5 [&_img]:max-w-full [&_iframe]:max-w-full",dangerouslySetInnerHTML:{__html:e.description}})]}),t.jsxs(ns,{className:"!justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>i(e=>!e),"aria-pressed":o,"aria-label":n("updates_dialog_like","Curtir"),className:_r("inline-flex items-center justify-center h-8 w-8 rounded-full border transition-colors",o?"bg-primary/10 border-primary text-primary":"border-input text-muted-foreground hover:text-foreground hover:bg-accent"),children:t.jsx(c.Heart,{className:_r("h-4 w-4",o&&"fill-current")})}),t.jsx("span",{className:"inline-flex items-center justify-center min-w-[1.5rem] h-6 px-2 rounded-full bg-primary text-primary-foreground text-xs font-medium",children:u})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground cursor-pointer select-none",children:[t.jsx(As,{checked:l,onCheckedChange:e=>d(!0===e)}),n("updates_dialog_do_not_show_again","Não exibir novamente")]}),t.jsx(Sr,{variant:"ghost",onClick:()=>s({liked:o,doNotShowAgain:l}),children:n("updates_dialog_close","Fechar")})]})]})]})})}function dx(e){return e&&e.trim()?e.trim():"anon"}function ux(e){try{const t=localStorage.getItem(e);if(!t)return new Set;const a=JSON.parse(t);return new Set(Array.isArray(a)?a.map(String):[])}catch{return new Set}}function mx(e,t){try{localStorage.setItem(e,JSON.stringify(Array.from(t)))}catch{}}function px(e,t){if(!e)return e;const a=(t||"").trim().split(" ")[0]||"Colaborador";return e.replace(/@nome_usuario|@nome_usuário/g,a)}function hx(){const{alias:e}=Qh(),{user:r}=So(),s=a.useMemo(()=>(r?.name||"").trim().split(" ")[0]||"Colaborador",[r?.name]),{data:n=[]}=ex(),{data:o=[]}=tx(),i=a.useMemo(()=>function(e){return`updates.bar.dismissed.${dx(e)}`}(e),[e]),l=a.useMemo(()=>function(e){return`updates.dialog.seen.${dx(e)}`}(e),[e]),[c,d]=a.useState(()=>ux(i)),[u,m]=a.useState(()=>ux(l)),[p,h]=a.useState(new Set),[x,f]=a.useState(0);if(a.useEffect(()=>{d(ux(i)),m(ux(l)),h(new Set),f(0)},[i,l]),!e)return null;const g=n.find(e=>!c.has(e.id)),b=o.filter(e=>!u.has(e.id)&&!p.has(e.id))[x],v=g&&{...g,title:px(g.title,s),text:px(g.text,s),description:px(g.description,s)},y=b&&{...b,title:px(b.title,s),description:px(b.description,s)};return t.jsxs(t.Fragment,{children:[v&&t.jsx(ax,{item:v,onDismiss:async t=>{const a=new Set(c);a.add(t),d(a),mx(i,a);try{await Jh(e,t,1)}catch{}}}),y&&t.jsx(cx,{item:y,open:!0,onClose:async({liked:t,doNotShowAgain:a})=>{if(!b)return;const r=b.id;if(!a)return h(e=>{const t=new Set(e);return t.add(r),t}),void f(0);const s=new Set(u);s.add(r),m(s),mx(l,s),f(0);try{await Jh(e,r,2,t)}catch{}}})]})}const xx=a.memo(function({children:e,sidebar:r,sidebarConfig:s,showHeader:n=!0,showSidebar:o=!0}){const i=a.useMemo(()=>o?r||t.jsx(Kh,{config:s}):null,[r,s,o]),l=a.useMemo(()=>({"--sidebar-width":"290px","--sidebar-width-icon":"58px"}),[]),c=a.useRef(null),d=a.useRef(null),u=a.useCallback(()=>{if(c.current&&d.current){const e=c.current.offsetHeight;d.current.style.setProperty("--header-height",`${e}px`)}},[]);return a.useEffect(()=>{u();const e=new ResizeObserver(u);return c.current&&e.observe(c.current),()=>e.disconnect()},[u]),t.jsx(Rh,{config:s,children:t.jsx(bl,{children:t.jsx(tu,{defaultOpen:!1,style:l,children:t.jsxs("div",{ref:d,className:"flex flex-col h-screen w-full overflow-hidden",children:[n&&t.jsxs("div",{ref:c,className:"flex-shrink-0 sticky top-0 z-40 bg-primary",children:[t.jsx(Oh,{}),t.jsx(hx,{})]}),t.jsxs("div",{className:"sidebar-container flex flex-1 overflow-hidden",children:[i,t.jsx("main",{className:"relative z-0 flex-1 flex flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30",children:e})})]})]})})})})});class fx{static async sendEmail(e){const t=to(),{data:a,error:r}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(r)throw r;return a}}const gx=fx,bx=J.z.string().trim().toLowerCase().min(3,"E-mail muito curto").max(254,"E-mail muito longo").email("E-mail inválido"),vx=J.z.string().trim().toLowerCase().min(2,"Alias muito curto").max(64,"Alias muito longo").regex(/^[a-z0-9][a-z0-9-]*[a-z0-9]$/,"Alias contém caracteres inválidos"),yx=J.z.string().uuid("UUID inválido"),wx=J.z.string().trim().min(1,"userId obrigatório").max(64,"userId muito longo").regex(/^[a-zA-Z0-9._-]+$/,"userId contém caracteres inválidos"),jx=J.z.object({page:J.z.coerce.number().int().min(1).default(1),pageSize:J.z.coerce.number().int().min(1).max(500).default(50)});function Nx(e){const[t,r]=a.useState(!1),{uploadFunction:s,deleteFunction:n,defaultOptions:o,onSuccess:i,onError:c}=e||{};return{upload:async(e,t)=>{if(!s){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}r(!0);try{const a={...o,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){if(!a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const r=await s(e,a);return l.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),i?.(r),r}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),c?.(e),e}finally{r(!1)}},deleteMedia:async(e,t)=>{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,t),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:t}}function _x(e,t){return e/t}const Cx=["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 kx(e){if(!e)return"";if(e<1024)return`${e} Bytes`;const t=e/1024;if(t<1024)return`${Math.round(t)} KB`;const a=t/1024;if(a<1024)return`${Math.round(a)} MB`;const r=a/1024;return Math.round(100*r)/100+" GB"}function Sx(e){const t=e.lastIndexOf(".");return-1===t?"":e.substring(t+1).toLowerCase()}function Ax({storedFile:e,customFileName:r,allowedExtensions:s,customExtensionErrorMessage:n,minSizeInBytes:o=1,maxSizeInBytes:i=314572800,showDownloadButton:l=!0,showViewButton:d=!0,showReplaceButton:u=!0,showCloseButton:m=!0,required:p=!1,touched:h=!1,disabled:x=!1,error:f,onFileSelect:g,onFileRemove:b,onFileReplace:v,onDownload:w,onView:j,className:N}){const{t:_}=y.useTranslation(),C=a.useRef(null),[k,S]=a.useState(null),[A,T]=a.useState(null),[D,E]=a.useState(!1),P=k||e,I=k?.name||e?.name||"",M=k?.size||e?.size;I&&Sx(I);const R=r||I,L=l&&!k&&!!e,F=d&&!k&&!!e,z=!!A||!!f||p&&h&&!P,U=!!P,O=a.useCallback(e=>{if(Cx.includes(e.type))return{type:"forbidden-type"};if(e.size<=o)return{type:"min-size"};if(e.size>=i)return{type:"max-size"};if(s?.length){const t=Sx(e.name);if(!s.includes(t))return{type:"extension",message:n}}return null},[o,i,s,n]),B=a.useCallback(e=>{const t=e.target.files?.[0];if(!t)return;const a=O(t);if(a)return T(a),S(null),void(C.current&&(C.current.value=""));T(null),S(t),g?.(t),C.current&&(C.current.value="")},[O,g]),q=a.useCallback(e=>{if(e.preventDefault(),e.stopPropagation(),x)return;const t=e.dataTransfer.files?.[0];if(!t)return;const a=O(t);if(a)return T(a),void S(null);T(null),S(t),g?.(t)},[x,O,g]),V=a.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),$=a.useCallback(()=>{v?.(),C.current?.click()},[v]),W=a.useCallback(()=>{S(null),T(null),b?.(),C.current&&(C.current.value="")},[b]),H=a.useCallback(async()=>{if(!D&&e&&w){E(!0);try{await w(e)}finally{E(!1)}}},[D,e,w]),G=a.useCallback(()=>{e&&j&&j(e)},[e,j]),K=a.useCallback(()=>{x||C.current?.click()},[x]),Y=(()=>{if(f)return f;if(!A)return p&&h&&!P?_("required_field"):null;switch(A.type){case"extension":return A.message||_("sign_file_not_allowed");case"forbidden-type":return _("sign_file_type_not_allowed");case"min-size":return`Tamanho mínimo: ${kx(o)}`;case"max-size":return`Tamanho máximo: ${kx(i)}`;default:return _("file_error")}})();return t.jsxs("div",{className:_r("space-y-1",N),children:[t.jsx("div",{className:_r("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?t.jsxs("div",{className:"flex items-center justify-between px-3 min-h-[36px]",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx(c.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("p",{className:"text-xs truncate",children:R})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[null!=M&&t.jsx("span",{className:"text-xs text-muted-foreground",children:kx(M)}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[L&&w&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:D,onClick:H,children:t.jsx(c.Download,{className:"h-3.5 w-3.5 text-primary"})})}),t.jsx(en,{children:"Download"})]}),F&&j&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,children:t.jsx(c.Eye,{className:"h-3.5 w-3.5 text-primary"})})}),t.jsx(en,{children:"Visualizar"})]}),u&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:$,children:t.jsx(c.RefreshCw,{className:"h-3.5 w-3.5 text-primary"})})}),t.jsx(en,{children:"Substituir"})]}),m&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 bg-muted rounded",onClick:W,children:t.jsx(c.X,{className:"h-3 w-3 text-muted-foreground"})})}),t.jsx(en,{children:_("remove")})]})]})]})]}):t.jsxs("div",{className:"flex items-center justify-center gap-2 min-h-[36px] px-3",tabIndex:0,onClick:K,onKeyDown:e=>"Enter"===e.key&&K(),onDrop:q,onDragOver:V,children:[t.jsx(c.CloudUpload,{className:"h-4 w-4 text-muted-foreground"}),t.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:["Arraste ou ",t.jsx("span",{className:"text-primary",children:"selecione um arquivo"})]})]})}),Y&&t.jsx("p",{className:"text-xs text-destructive",children:Y}),t.jsx("input",{ref:C,type:"file",className:"hidden",accept:s?.map(e=>`.${e}`).join(","),onChange:B,disabled:x})]})}function Tx(){return`${Ke().replace(/\/+$/,"")}/api/documents/v1`}function Dx(){const e=$n.getSelectedAlias()||$n.extractTokenData()?.alias||"";if(!e)throw new Error("Alias da unidade não encontrado (Documents API exige o header un-alias).");return e}function Ex(){const e=$n.getAccessToken();if(!e)throw new Error("Token Qualiex não encontrado.");return{Authorization:`Bearer ${e}`,"un-alias":Dx()}}function Px(){return{...Ex(),Accept:"application/json"}}function Ix(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t):""}const Mx={async upload(e,t,a,r){const s={name:a.name,extension:Ix(a.name),size:a.size,plataformType:1,association:{type:e,associationId:t,associationFieldId:r??null}},n=new FormData;n.append("command",JSON.stringify(s)),n.append(a.name,a,a.name);const o=await fetch(`${Tx()}/files/Upload`,{method:"POST",headers:Ex(),body:n});if(!o.ok)throw new Error(await o.text().catch(()=>"")||"Falha no upload do arquivo.");const i=await o.json().catch(()=>null),l=i?.resultData??i?.ResultData??{};return{id:l.id??"",code:l.code,size:l.size}},async downloadUrl(e,t=10){const a=await fetch(`${Tx()}/files/Download/${encodeURIComponent(e)}?minutesToExpire=${t}`,{headers:Px()});if(!a.ok)return null;const r=await a.json().catch(()=>null);return r?.url??null},async listByAssociation(e,t,a){const r=new URLSearchParams({type:String(e),associationId:t,page:"1",limit:"100"});a&&r.set("associationFieldId",a);const s=await fetch(`${Tx()}/files?${r.toString()}`,{headers:Px()});if(!s.ok)return[];const n=await s.json().catch(()=>null);return(n?.data??[]).map(r=>{const s=r.associations??[],n=s.find(r=>r.type===e&&r.associationId===t&&(!a||r.associationFieldId===a))??s[0];return{id:r.id,name:r.name,extension:r.extension,size:r.size,associationRowId:n?.id}})},async remove(e,t){if(!e)return!1;return(await fetch(`${Tx()}/files/associations`,{method:"DELETE",headers:{...Px(),"Content-Type":"application/json"},body:JSON.stringify({filesAssociationsIds:[e],justification:t??null})})).ok},async count(e,t,a){const r=new URLSearchParams({type:String(e),associationId:t});a&&r.set("associationFieldId",a);const s=await fetch(`${Tx()}/files/Count?${r.toString()}`,{headers:Px()});if(!s.ok)return 0;const n=await s.json().catch(()=>null);return n?.count??n?.total??0}},Rx=e=>({id:e.id,name:e.name,extension:e.extension,size:e.size??0});var Lx=(e=>(e[e.readOnlyText=1]="readOnlyText",e[e.text=2]="text",e[e.date=3]="date",e[e.time=4]="time",e[e.url=5]="url",e[e.number=6]="number",e[e.singleSelection=7]="singleSelection",e[e.multiSelection=8]="multiSelection",e[e.questions=9]="questions",e))(Lx||{}),Fx=(e=>(e[e.dropdown=1]="dropdown",e[e.buttons=2]="buttons",e[e.radio=3]="radio",e[e.checkbox=4]="checkbox",e))(Fx||{}),zx=(e=>(e[e.custom=1]="custom",e[e.users=2]="users",e[e.usersLists=3]="usersLists",e))(zx||{});function Ux(e){switch(e.type){case 2:case 1:return e.textValue;case 6:return e.numberValue;case 3:return e.dateValue;case 4:return e.timeValue;case 5:case 7:case 8:return e.itemsValue;case 9:return e.questionsValue;default:return null}}function Ox(e,t){if(!t)return!0;const a=null!=Ux(e)&&""!==Ux(e)&&!(Array.isArray(Ux(e))&&0===Ux(e).length);return!1!==e.isActive||a}function Bx({field:e}){return t.jsxs("div",{className:"space-y-1",children:[e.name&&t.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function qx({field:e,readOnly:a,onChange:r}){const s=e.config,n=s?.multiline??!1,o=a||e.readOnly,i=t=>{r?.({...e,textValue:t})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),n?t.jsx(Ts,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o,rows:4}):t.jsx(Tr,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o})]})}function Vx({field:e,readOnly:a,onChange:r}){const s=a||e.readOnly,n=e.dateValue?"string"==typeof e.dateValue?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(Tr,{type:"date",value:n,onChange:t=>{return a=t.target.value,void r?.({...e,dateValue:a||void 0});var a},placeholder:e.placeholder,disabled:s})]})}function $x({field:e,readOnly:a,onChange:r}){const s=a||e.readOnly,n=e=>{if(!e)return;const[t,a]=e.split(":").map(Number);return 60*t+a};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(Tr,{type:"time",value:(e=>{if(null==e)return"";const t=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`})(e.timeValue),onChange:t=>r?.({...e,timeValue:n(t.target.value)}),placeholder:e.placeholder,disabled:s})]})}function Wx({field:e,readOnly:r,onChange:s}){const n=e.config,o=n?.multiple??!1,i=r||e.readOnly,[l,d]=a.useState(""),u=e.itemsValue||[],m=()=>{if(!l.trim())return;const t={value:crypto.randomUUID(),text:l.trim()};s?.({...e,itemsValue:[...u,t]}),d("")};if(!o){const a=u[0]?.text||"";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Tr,{type:"url",value:a,onChange:t=>(t=>{const a={value:t,text:t};s?.({...e,itemsValue:t?[a]:[]})})(t.target.value),placeholder:e.placeholder||"https://",disabled:i}),a&&t.jsx(Sr,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:t.jsx(c.ExternalLink,{className:"h-4 w-4"})})})]})]})}return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!i&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Tr,{type:"url",value:l,onChange:e=>d(e.target.value),placeholder:e.placeholder||"https://",onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),m())}),t.jsx(Sr,{variant:"outline",size:"icon",onClick:m,disabled:!l.trim(),className:"flex-shrink-0",children:t.jsx(c.Plus,{className:"h-4 w-4"})})]}),u.length>0&&t.jsx("div",{className:"space-y-1",children:u.map((a,r)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("a",{href:a.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:a.text}),!i&&t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>(t=>{const a=u.filter((e,a)=>a!==t);s?.({...e,itemsValue:a})})(r),children:t.jsx(c.Trash2,{className:"h-3 w-3"})})]},a.value))})]})}function Hx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=null!=s?.decimals&&s.decimals>0?(1/Math.pow(10,s.decimals)).toString():"1";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(Tr,{type:"number",value:e.numberValue??"",onChange:t=>(t=>{if(""===t)return void r?.({...e,numberValue:void 0});const a=parseFloat(t);isNaN(a)||r?.({...e,numberValue:a})})(t.target.value),placeholder:e.placeholder,disabled:n,min:s?.min,max:s?.max,step:o}),null!=s?.min&&null!=s?.max&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",s.min," | Max: ",s.max]})]})}function Gx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=s?.viewMode??Fx.dropdown,i=s?.data?.filter(t=>!1!==t.isActive||e.itemsValue?.some(e=>e.value===t.value))||[],l=e.itemsValue?.[0]?.value||"",c=t=>{const a=i.find(e=>e.value===t);if(!a)return;const s={value:a.value,text:a.text,isActive:a.isActive};r?.({...e,itemsValue:[s]})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),o===Fx.dropdown&&t.jsxs(bs,{value:l,onValueChange:c,disabled:n,children:[t.jsx(ws,{children:t.jsx(ys,{placeholder:e.placeholder||"Selecione..."})}),t.jsx(_s,{children:i.map(e=>t.jsxs(ks,{value:e.value,children:[e.text,!1===e.isActive&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},e.value))})]}),(o===Fx.radio||o===Fx.buttons)&&t.jsx(Fd,{value:l,onValueChange:c,disabled:n,className:_r(o===Fx.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(a=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(zd,{value:a.value,id:`${e.id}-${a.value}`}),t.jsxs(Er,{htmlFor:`${e.id}-${a.value}`,className:"text-sm font-normal cursor-pointer",children:[a.text,!1===a.isActive&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},a.value))}),!n&&l&&!e.required&&t.jsx("button",{type:"button",onClick:()=>{r?.({...e,itemsValue:[]})},className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function Kx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=s?.viewMode??Fx.dropdown,i=s?.data?.filter(t=>!1!==t.isActive||e.itemsValue?.some(e=>e.value===t.value))||[],l=new Set(e.itemsValue?.map(e=>e.value)||[]);return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(a=>t.jsxs(Es,{variant:"secondary",className:"gap-1 pr-1",children:[t.jsx("span",{className:"text-xs",children:a.text}),!n&&t.jsx("button",{type:"button",onClick:()=>(t=>{const a=(e.itemsValue||[]).filter(e=>e.value!==t);r?.({...e,itemsValue:a})})(a.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:t.jsx(c.X,{className:"h-3 w-3"})})]},a.value))}),!n&&t.jsx("div",{className:_r(o===Fx.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(a=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:`${e.id}-${a.value}`,checked:l.has(a.value),onCheckedChange:()=>(t=>{const a=e.itemsValue||[],s=a.some(e=>e.value===t.value)?a.filter(e=>e.value!==t.value):[...a,{value:t.value,text:t.text,isActive:t.isActive}];r?.({...e,itemsValue:s})})(a),disabled:n}),t.jsxs(Er,{htmlFor:`${e.id}-${a.value}`,className:"text-sm font-normal cursor-pointer",children:[a.text,!1===a.isActive&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},a.value))})]})}function Yx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=s?.questions||[],i=s?.options||[],l=e.questionsValue||[];return 0===o.length||0===i.length?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{children:e.name}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx("div",{className:"border rounded-md overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b bg-muted/50",children:[t.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(e=>t.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:e.text},e.value))]})}),t.jsx("tbody",{children:o.map((a,s)=>t.jsxs("tr",{className:_r(s<o.length-1&&"border-b"),children:[t.jsx("td",{className:"p-2 text-muted-foreground",children:a.text}),i.map(s=>{return t.jsx("td",{className:"text-center p-2",children:t.jsx(Fd,{value:(o=a.value,l.find(e=>e.questionValue===o)?.optionValue||""),onValueChange:t=>((t,a,s,n)=>{const o={questionValue:t,questionText:a,optionValue:s,optionText:n},i=l.filter(e=>e.questionValue!==t);i.push(o),r?.({...e,questionsValue:i})})(a.value,a.text,t,s.text),disabled:n,className:"flex justify-center",children:t.jsx(zd,{value:s.value,id:`${e.id}-${a.value}-${s.value}`})})},s.value);var o})]},a.value))})]})})]})}function Qx({field:e,readOnly:a,onChange:r}){const s={field:e,readOnly:a,onChange:r};switch(e.type){case Lx.readOnlyText:return t.jsx(Bx,{...s});case Lx.text:return t.jsx(qx,{...s});case Lx.date:return t.jsx(Vx,{...s});case Lx.time:return t.jsx($x,{...s});case Lx.url:return t.jsx(Wx,{...s});case Lx.number:return t.jsx(Hx,{...s});case Lx.singleSelection:return t.jsx(Gx,{...s});case Lx.multiSelection:return t.jsx(Kx,{...s});case Lx.questions:return t.jsx(Yx,{...s});default:return null}}function Xx({open:r,onOpenChange:s,returnSteps:n,initialObservation:o="",title:i=e.t("approval_execute_action"),descriptions:c=[],setDefaultApproverOnInit:d=!0,onSubmit:u}){const[m,p]=a.useState(!0),[h,x]=a.useState(d&&n.length>0?n[0].id:null),[f,g]=a.useState(o),b=e=>{p(e),e&&!d?x(null):!e&&!d&&n.length>0&&x(n[0].id)},v=f!==o||!m;return t.jsx(Qr,{open:r,onOpenChange:s,children:t.jsxs(as,{className:"sm:max-w-[480px]",variant:"form",isDirty:v,children:[t.jsx(rs,{children:t.jsx(os,{children:i})}),t.jsxs("div",{className:"space-y-4",children:[c.length>0&&t.jsx("div",{className:"space-y-1 text-sm text-muted-foreground",children:c.map((e,a)=>t.jsx("p",{dangerouslySetInnerHTML:{__html:e}},a))}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"radio",name:"approved",checked:m,onChange:()=>b(!0),className:"accent-primary"}),t.jsx("span",{className:"text-sm",children:e.t("approval_approve")})]}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"radio",name:"approved",checked:!m,onChange:()=>b(!1),className:"accent-primary"}),t.jsx("span",{className:"text-sm",children:e.t("approval_reprove_radio")})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{children:"Etapa"}),t.jsxs(bs,{value:h??void 0,onValueChange:x,disabled:m,children:[t.jsx(ws,{children:t.jsx(ys,{placeholder:e.t("approval_select_step")})}),t.jsx(_s,{children:n.map(e=>t.jsx(ks,{value:e.id,children:e.name},e.id))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{children:e.t("approval_opinion")}),t.jsx(Ts,{value:f,onChange:e=>g(e.target.value),maxLength:4e3,rows:4,autoFocus:!0}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/",4e3]})]})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),t.jsx(Sr,{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:!v,children:"Concluir"})]})]})})}function Jx({open:e,onOpenChange:r,approvers:s,isLoading:n=!1,ignoreUserIds:o=[],onSubmit:i}){const{t:l}=y.useTranslation(),[c,d]=a.useState(null),u=a.useMemo(()=>{const e=new Set(o);return s.filter(t=>!e.has(t.id))},[s,o]),m=a.useMemo(()=>u.map(e=>({value:e.id,label:e.name})),[u]);return t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:"sm:max-w-[450px]",variant:"form",isDirty:!!c,children:[t.jsx(rs,{children:t.jsx(os,{children:l("approval_select_approver")})}),t.jsx(Ms,{isLoading:n,type:"spinner",children:t.jsx("div",{className:"space-y-4",children:t.jsx(gn,{options:m,value:c??void 0,onValueChange:e=>d("string"==typeof e?e:e?.[0]??null),placeholder:l("approval_select_approver_placeholder"),searchPlaceholder:l("approval_search_approver")})})}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),t.jsx(Sr,{onClick:()=>{if(!c)return;const e=u.find(e=>e.id===c);e&&i(e)},disabled:!c||n,children:"Concluir"})]})]})})}function Zx(e){const{t:t}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}function ef({text:e,maxLength:r=130}){const{t:s}=y.useTranslation(),[n,o]=a.useState(!1);return e.length<=r?t.jsx("span",{children:e}):t.jsxs("span",{children:[n?e:`${e.substring(0,r)}... `,t.jsx("button",{className:"text-primary hover:underline text-sm cursor-pointer",onClick:()=>o(!n),children:s(n?"approval_read_less":"approval_read_more")})]})}function tf({approver:e}){if(1===e.type&&e.approverId)return t.jsxs(Zi,{className:"h-9 w-9 shrink-0",children:[t.jsx(el,{src:e.photoUrl,alt:e.name}),t.jsx(tl,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]});const a=2===e.type?c.Users:3===e.type?c.MapPin:c.User;return t.jsx("div",{className:"h-9 w-9 rounded-full bg-muted-foreground/30 flex items-center justify-center shrink-0",children:t.jsx(a,{className:"h-4 w-4 text-background"})})}function af({approver:e}){return e.date?t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-green-500/10 text-foreground",children:[t.jsx(c.CheckCircle,{className:"h-3.5 w-3.5 text-green-600"}),"Aprovado"]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Zx(e.date)}),1!==e.type&&e.approvedUsername&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["por ",e.approvedUsername]})]}):e.returnDate?t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-red-500/10 text-foreground",children:[t.jsx(c.XCircle,{className:"h-3.5 w-3.5 text-red-600"}),"Reprovado"]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Zx(e.returnDate)})]}):t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-muted text-muted-foreground",children:[t.jsx(c.AlertCircle,{className:"h-3.5 w-3.5"}),"Aguardando"]})}function rf({approver:e}){const{t:a}=y.useTranslation(),r=1!==e.type||e.approverId?e.name:"A definir";return t.jsxs("div",{children:[2===e.type&&t.jsx("p",{className:"text-xs text-muted-foreground",children:a("approval_user_group")}),3===e.type&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Local"}),t.jsx("p",{className:"text-sm font-medium break-words",children:r}),t.jsx(af,{approver:e})]})}var sf=(e=>(e[e.ApprovalFlow=1]="ApprovalFlow",e[e.Association=2]="Association",e))(sf||{});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}}),exports.DialogPrimitive=se,Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return y.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return y.useTranslation}}),exports.AccordionPrimitive=ye,exports.AUTH_CONFIG=ze,exports.AccessDeniedDialog=xc,exports.Accordion=_c,exports.AccordionContent=Sc,exports.AccordionItem=Cc,exports.AccordionTrigger=kc,exports.ActionButton=Ar,exports.ActionMenu=Ar,exports.ActionMenuItems=oi,exports.AggregationType=Pm,exports.Alert=Qi,exports.AlertDescription=Ji,exports.AlertDialog=Ur,exports.AlertDialogAction=Kr,exports.AlertDialogCancel=Yr,exports.AlertDialogContent=Vr,exports.AlertDialogDescription=Gr,exports.AlertDialogFooter=Wr,exports.AlertDialogHeader=$r,exports.AlertDialogOverlay=qr,exports.AlertDialogPortal=Br,exports.AlertDialogTitle=Hr,exports.AlertDialogTrigger=Or,exports.AlertTitle=Xi,exports.AliasRedirect=function(){const{alias:e}=So(),{pathname:a,search:r,hash:s}=N.useLocation();return e?t.jsx(N.Navigate,{to:`/${e}${a}${r}${s}`,replace:!0}):null},exports.AliasRouteGuard=function({children:e,paramName:r="alias"}){const s=N.useNavigate(),n=N.useLocation(),o=N.useParams(),{alias:i,isAuthenticated:l,isLoading:c,switchUnit:d,companies:u}=So(),{urlAlias:m,isAliasMismatch:p,isValidAlias:h,isMissing:x,matchedCompany:f}=Gi({paramName:r}),[g,b]=a.useState(!1),v=a.useRef(!1),y=r in o,w=a.useCallback(e=>{const t=o[r],{pathname:a,search:s,hash:i}=n;if(t){const r=a.split("/"),n=r.findIndex(e=>e===t);if(n>=0)return r[n]=e,r.join("/")+s+i}return`/${e}${"/"===a?"":a}${s}${i}`},[o,r,n]);return a.useEffect(()=>{if(y&&!c&&l&&i&&!v.current)if(x)s(w(i),{replace:!0});else if(!m||h){if(p&&f&&!v.current){(async()=>{v.current=!0,b(!0);try{await d(f)}catch(e){i&&s(w(i),{replace:!0})}finally{v.current=!1,b(!1)}})()}}else{if(!u||0===u.length)return;s(w(i),{replace:!0})}},[y,c,l,i,x,m,h,p,f,d,w,s,u]),c||!l?t.jsx(t.Fragment,{children:e}):g?t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(Is,{size:"lg"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Trocando unidade..."})]})}):t.jsx(t.Fragment,{children:e})},exports.AnalysisFunctionality=Im,exports.AppHeader=Oh,exports.AppLayout=xx,exports.AppSidebar=Kh,exports.ApprovalFlowReturnStep=sf,exports.ApprovalSidenav=function({config:e,isLoading:r=!1,onClose:s,onApprove:n,onDefineApprover:o,onRefreshSteps:i,availableApprovers:l=[],isLoadingApprovers:d=!1}){const{t:u}=y.useTranslation(),[m,p]=a.useState(!1),[h,x]=a.useState(!1),[f,g]=a.useState(""),[b,v]=a.useState(""),[w,j]=a.useState(!1),[N,_]=a.useState(""),C=r||m,k=a.useCallback((e,t)=>{g(e),v(t??""),x(!0)},[]),S=a.useCallback(async t=>{x(!1),p(!0);if(!await n(e.associationId,{stepApproverId:f,...t}))return k(f,t.observation),void p(!1);s(),p(!1)},[e.associationId,f,n,s,k]),A=a.useCallback(e=>{_(e),j(!0)},[]),T=a.useCallback(async t=>{j(!1),p(!0),await o(e.associationId,N,t),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=(t,a)=>e.canApprove&&t.isCurrentStep&&a.approverId&&!a.date&&a.canApprove,P=(t,a)=>!e.flowReproved&&t.isCurrentStep&&1===a.type&&a.canApprove&&(!a.approverId||a.isToBeDefined);return t.jsxs("div",{className:"w-[550px] max-w-[900px] min-w-[400px] h-full flex flex-col bg-background",children:[t.jsxs("div",{className:"shrink-0 shadow-sm px-1 py-2 flex items-center gap-1 border-l-4",style:{borderLeftColor:e.color},children:[t.jsx(Sr,{variant:"ghost",size:"icon",onClick:s,className:"shrink-0",children:t.jsx(c.X,{className:"h-5 w-5"})}),t.jsx("span",{className:"text-lg font-medium",children:e.title})]}),C?t.jsx(Ms,{isLoading:!0,type:"spinner",className:"flex-1",children:t.jsx("div",{})}):t.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.approvalFlowInfo.length>0&&t.jsx("div",{className:"space-y-1",children:e.approvalFlowInfo.map((e,a)=>t.jsx("div",{className:_r("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},a))}),t.jsx("hr",{className:"border-border"}),e.approvalFlowSteps.map(a=>t.jsxs("div",{className:_r("space-y-2",(!a.isCurrentStep||e.flowReproved)&&"opacity-50"),children:[t.jsxs("p",{className:"font-semibold text-sm",children:[a.index,". Etapa: ",a.name]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground break-words",children:t.jsx(ef,{text:a.description})}),a.returnDate&&t.jsxs("div",{className:"border-y border-border py-3 mt-3 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs rounded px-1.5 py-0.5 bg-red-500/10 text-red-600",children:"Retorno de etapa"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.returnUserName," em ",Zx(a.returnDate)]})]}),a.returnObservation&&t.jsx("p",{className:"text-sm text-muted-foreground bg-muted rounded p-2 break-words",children:t.jsx(ef,{text:a.returnObservation})})]}),a.approvers.map(e=>t.jsxs("div",{className:"p-2 space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx(tf,{approver:e}),t.jsx(rf,{approver:e})]}),E(a,e)&&t.jsx(Sr,{size:"sm",onClick:()=>k(e.id),children:"Aprovar"}),P(a,e)&&t.jsx(Sr,{size:"sm",variant:"outline",onClick:()=>A(e.id),children:"Selecionar"})]}),e.observation&&t.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:t.jsx(ef,{text:e.observation})}),e.returnObservation&&t.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:t.jsx(ef,{text:e.returnObservation})})]},e.id))]},a.id))]}),t.jsx(Xx,{open:h,onOpenChange:x,returnSteps:e.returnSteps,initialObservation:b,title:e.approveDialogTitle,descriptions:e.approveDialogDescriptions,setDefaultApproverOnInit:e.approveDialogSetDefaultApproverOnInit,onSubmit:S}),t.jsx(Jx,{open:w,onOpenChange:j,approvers:l,isLoading:d,ignoreUserIds:D,onSubmit:T})]})},exports.ApproveDialog=Xx,exports.AuthErrorInterceptor=oo,exports.AuthProvider=ko,exports.AuthService=jo,exports.AutoComplete=gn,exports.Avatar=Zi,exports.AvatarFallback=tl,exports.AvatarImage=el,exports.Badge=Es,exports.BaseForm=Li,exports.Blockquote=bd,exports.BodyContent=function({breadcrumbs:e,children:a,className:r}){return t.jsxs("div",{className:_r("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",r),children:[e&&e.length>0&&t.jsx(Ac,{className:"mb-4",children:t.jsx(Tc,{children:e.map((a,r)=>{const s=r===e.length-1;return t.jsxs(te.Fragment,{children:[r>0&&t.jsx(Ic,{}),t.jsx(Dc,{children:s||!a.href?t.jsx(Pc,{children:a.label}):a.asChild&&a.children?t.jsx(Ec,{asChild:!0,children:a.children}):t.jsx(Ec,{asChild:!0,children:t.jsx(N.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${r}`)})})}),t.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=Ac,exports.BreadcrumbEllipsis=Mc,exports.BreadcrumbItem=Dc,exports.BreadcrumbLink=Ec,exports.BreadcrumbList=Tc,exports.BreadcrumbPage=Pc,exports.BreadcrumbSeparator=Ic,exports.BurndownPanel=Pp,exports.Button=Sr,exports.ButtonGroup=Lc,exports.CRUD_CONFIG=qe,exports.CURRENCY_FIELDS=np,exports.Calendar=zc,exports.CallbackPage=()=>{const{processCallback:e}=So(),r=N.useNavigate(),[s,n]=a.useState(null),[o,i]=a.useState(!1);a.useEffect(()=>{let t=!1;if(Pn()){Cn.clear(),function(){if(_n&&"undefined"!=typeof PerformanceObserver&&!Dn)try{Dn=new PerformanceObserver(e=>{for(const t of e.getEntries())t.duration}),Dn.observe({type:"longtask",buffered:!0})}catch{}}(),Sn("callback:start");try{const e=$n.getAccessToken(),t=$n.getIdToken();if(e){En(0,e,Rn.parseJwtPayload(e))}if(t){En(0,t,Rn.parseJwtPayload(t))}}catch{}}const a=Pn()?window.setTimeout(()=>{t||Tn()},15e3):0;return(async()=>{try{const a=await e();if(t=!0,Pn()&&(Sn("callback:processCallback:end"),function(e,t,a){if(!_n)return null;try{return performance.measure(`auth:${e}`,`auth:${t}`,`auth:${a}`).duration}catch{return null}}("callback (total)","callback:start","callback:processCallback:end"),Tn()),a){window.history.replaceState({},document.title,Ue("/"));const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),r(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(a){t=!0,Pn()&&Tn(),localStorage.removeItem("auth_return_url"),n(a?.message||"Erro durante a autenticação. Tente novamente.")}})(),()=>{a&&window.clearTimeout(a),function(){if(Dn){try{Dn.disconnect()}catch{}Dn=null}}()}},[e,r]);const l=async()=>{i(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro ao tentar novamente.")}finally{i(!1)}},d=()=>{window.location.href=Ue("/")};return s?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsxs(Mr,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[t.jsx(c.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),t.jsxs(Lr,{className:"space-y-4",children:[t.jsx(Qi,{variant:"danger",children:t.jsx(Ji,{children:s})}),t.jsx("div",{className:"text-sm text-muted-foreground",children:t.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Sr,{onClick:l,disabled:o,className:"flex-1",children:o?t.jsxs(t.Fragment,{children:[t.jsx(Is,{size:"sm",className:"mr-2"}),"Tentando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),t.jsx(Sr,{onClick:d,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx(Is,{size:"lg"})}),t.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Pr,exports.CardContent=Lr,exports.CardDescription=Rr,exports.CardFooter=Fr,exports.CardHeader=Ir,exports.CardSkeleton=Oo,exports.CardTitle=Mr,exports.CartesianPanel=Sp,exports.ChartContainer=Wu,exports.ChartLegend=Yu,exports.ChartLegendContent=Qu,exports.ChartStyle=Hu,exports.ChartTooltip=Gu,exports.ChartTooltipContent=Ku,exports.Checkbox=As,exports.Collapsible=zl,exports.CollapsibleContent=Ol,exports.CollapsibleTrigger=Ul,exports.ColorPicker=Si,exports.ColumnSettingsPopover=wi,exports.ComboTree=Nn,exports.Combobox=gn,exports.Command=nn,exports.CommandDialog=({children:e,...a})=>t.jsx("div",{...a,children:t.jsx(nn,{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=cn,exports.CommandGroup=dn,exports.CommandInput=on,exports.CommandItem=mn,exports.CommandList=ln,exports.CommandSeparator=un,exports.CommandShortcut=pn,exports.ContentContainer=function({title:e,subtitle:a,children:r,className:s,hasHeader:n=!0}){const o=e||a;return t.jsxs("div",{className:_r("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-visible",s),children:[n&&o&&t.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[e&&t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),a&&t.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),r&&t.jsx("div",{className:_r("p-6",!n&&o&&"pt-4"),children:r})]})},exports.ContextMenu=Wo,exports.ContextMenuCheckboxItem=ti,exports.ContextMenuContent=Zo,exports.ContextMenuGroup=Go,exports.ContextMenuItem=ei,exports.ContextMenuLabel=ri,exports.ContextMenuPortal=Ko,exports.ContextMenuRadioGroup=Qo,exports.ContextMenuRadioItem=ai,exports.ContextMenuSeparator=si,exports.ContextMenuShortcut=ni,exports.ContextMenuSub=Yo,exports.ContextMenuSubContent=Jo,exports.ContextMenuSubTrigger=Xo,exports.ContextMenuTrigger=Ho,exports.CoreProviders=function({children:r,queryClient:s,moduleAlias:n,associationsBaseUrl:o,signDocumentsSchema:i="common",signDocumentsTable:l="sign_documents",moduleAccessGuardProps:c,appTranslations:d,clarityProjectId:u,clarityMode:m="auto",backend:p="supabase",securityMode:h="legacy"}){Le(p),wc=h,vc();const[x]=a.useState(()=>new j.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),f=s??x;a.useEffect(()=>{if(d)for(const[e,t]of Object.entries(d))_l(e,t)},[d]);const g={sourceModule:n,...c};return t.jsxs(Vl,{children:[t.jsx(Nc,{}),t.jsx(y.I18nextProvider,{i18n:e,children:t.jsx(j.QueryClientProvider,{client:f,children:t.jsxs(ko,{moduleAlias:n,children:[t.jsx(jc,{projectId:u,mode:m}),t.jsx(Ll,{children:t.jsxs(kl,{moduleAlias:n,associationsBaseUrl:o,signDocumentsSchema:i,signDocumentsTable:l,children:[t.jsx(Pl,{}),t.jsx(gc,{...g,children:r})]})})]})})})]})},exports.CrudActionBar=fi,exports.CrudActionMenu=function({onEdit:e,onDelete:r,onToggleStatus:s,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:l=[],renderAs:d="dropdown",variant:u="default"}){const{t:m}=y.useTranslation(),p=a.useMemo(()=>{const t=[];return e&&o&&t.push({key:"edit",icon:c.Edit,label:m("edit","Editar"),onClick:e,variant:"default"}),s&&t.push({key:"toggle-status",icon:n?c.PowerOff:c.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:s,variant:"default"}),l.forEach(e=>{!1!==e.show&&t.push({key:`custom-${e.label}`,icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),r&&i&&t.push({key:"delete",icon:c.Trash2,label:m("remove","Remover"),onClick:r,variant:"destructive"}),t},[e,r,s,n,o,i,l,m]);return 0===p.length?null:"dropdown"===d?t.jsx(Xs,{delayDuration:200,children:t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:t.jsx(c.EllipsisVertical,{size:"compact"===u?14:16})})}),t.jsx($s,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(e=>e.disabled?t.jsxs(tn,{disabledReason:e.disabledReason,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&t.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key):t.jsxs(Ws,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&t.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key))})]})}):t.jsx("div",{className:"flex items-center gap-1",children:p.map(e=>t.jsxs(Sr,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:e.onClick,className:"compact"===u?"h-7 px-2":"",children:[e.icon&&t.jsx(e.icon,{size:"compact"===u?14:16}),"compact"!==u&&t.jsx("span",{className:"ml-1",children:e.label})]},e.key))})},exports.CrudGrid=({manager:r,columns:s,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:d,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f,showActionBar:g=!0,showSearch:b=!1,searchValue:v,onSearchChange:w,searchPlaceholder:j,bulkActions:N=[],onBulkDelete:_,filters:C,gridColumns:k=3,renderCard:S,viewMode:A,onViewModeChange:T,listCardRenderer:D,gridCardRenderer:E,showViewToggle:P=!1})=>{const{setSearchVisible:I}=So(),M=void 0!==f?!f:g;a.useEffect(()=>{if(!b)return I(!0),()=>I(!1)},[I,b]);const R=m||x.length>0||b||u||C||P,L=_||(()=>{r.bulkDelete?.(r.selectedIds)}),F=A||"grid",z="list"===F,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&&R?t.jsx(fi,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:j,showBulkActions:u,selectedCount:r.selectedIds.length,bulkActions:N,onBulkDelete:L,onClearSelection:r.clearSelection,customActions:x,filters:C,viewMode:F,onViewModeChange:T,showViewToggle:P,availableViewModes:["list","grid"]}):null;return r.isLoading?t.jsxs("div",{className:"flex flex-col h-full",children:[O,t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsx(Oo,{count:6})})]}):0===r.entities.length?t.jsxs("div",{className:"flex flex-col h-full",children:[O,t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(qo,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"})})]}):t.jsxs("div",{className:"flex flex-col h-full",children:[O,t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsx("div",{className:_r("grid gap-4",U),children:r.entities.map(e=>{const a=(e=>{const{t:t}=y.useTranslation();return z&&D?D(e):!z&&E?E(e):S?S(e):null})(e);return t.jsxs(Wo,{children:[t.jsx(Ho,{asChild:!0,children:a?t.jsx("div",{className:"cursor-pointer",onClick:t=>{t.stopPropagation(),u?r.selectItem(e.id):n?.(e)},children:a}):t.jsx(Pr,{className:_r("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&r.selectedIds.includes(e.id)&&"bg-muted ring-2 ring-primary",z&&"flex-row"),onClick:t=>{t.stopPropagation(),u?r.selectItem(e.id):n?.(e)},children:t.jsxs(Lr,{className:_r("p-4",z&&"flex items-center gap-4 w-full"),children:[u&&t.jsx("div",{className:_r(z?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),z?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),t.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(e):String(e[a.key]??"")})]},String(a.key)))}),(n||o||c)&&t.jsx("div",{onClick:e=>e.stopPropagation(),children:c?c(e):t.jsx(ii,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:d?d(e):[]})})]}):t.jsxs("div",{className:"flex items-start gap-3",children:[u&&t.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>t.jsxs("div",{className:_r("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[t.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),t.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(e):String(e[a.key]??"")})]},String(a.key))),(n||o||c)&&t.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(e):t.jsx(ii,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:d?d(e):[]})})]})]})]})})}),t.jsx(Zo,{className:"w-[160px]",children:t.jsx(oi,{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:d?d(e):[],renderAs:"context"})})]},e.id)})})})]})},exports.CrudPageInternal=$i,exports.CrudPagination=zi,exports.CrudPrimitiveFilterBar=kh,exports.CrudPrimitivePagination=Fi,exports.CrudPrimitiveTable=Ch,exports.CrudTable=Ni,exports.CustomFormFields=function({fields:e,readOnly:r=!1,hideInactiveWithoutValue:s=!1,onChange:n,onFieldChange:o}){const i=a.useCallback(t=>{if(o?.(t),n){const a=e.map(e=>e.id===t.id?t:e);n(a)}},[e,n,o]),l=e.filter(e=>Ox(e,s));return 0===l.length?null:t.jsx("div",{className:"space-y-4",children:l.map(e=>t.jsx(Qx,{field:e,readOnly:r,onChange:i},e.id))})},exports.DASHBOARD_STORAGE_KEYS={advancedFilter:"analysisDashboardsListFilter"},exports.DATETIME_FORMATS=tr,exports.DEFAULT_DATETIME_FORMAT=sr,exports.DEFAULT_LOCALE=rr,exports.DEFAULT_TIMEZONE=nr,exports.DashboardForm=Xp,exports.DashboardFormTab=$m,exports.DashboardFunctionality=Mm,exports.DashboardGeneralView=function({dashboards:e,limit:r,generalView:s,language:n=Hm.PtBr,isLoading:o=!1,canAdd:i=!1,canEdit:l=!1,canRemove:c=!1,canEditStandard:d=!1,activePanels:u=[],activePages:m=[],getPanelData:p,users:h=[],groups:x=[],places:f=[],collaborators:g=[],isSaving:b=!1,onOpen:v,onBackToList:y,onRefresh:w,onRefreshList:j,onToggleFavorite:N,onSave:_,onUpdate:C,onRemove:k,onDuplicate:S,onShare:A,onAddPanel:T,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:P,onLayoutChange:I,onSearch:M,onQuickFilterChange:R,onSetGeneralView:L,viewState:F,onViewStateChange:z,listToolbarExtra:U,viewToolbarActions:O,className:B}){const[q,V]=a.useState({mode:"list"}),$=F??q,W=a.useCallback(e=>{z?z(e):V(e)},[z]),H=a.useMemo(()=>"view"===$.mode||"edit"===$.mode||"share"===$.mode?e.find(e=>e.id===$.dashboardId)??null:null,[e,$]),[G,K]=a.useState(!1),[Y,Q]=a.useState(m[0]?.id);a.useEffect(()=>{m.length>0&&!Y&&Q(m[0]?.id)},[m,Y]),a.useEffect(()=>{if("view"!==$.mode||!H||H.idViewType!==Vm.Carousel||m.length<=1)return;const e=function(e){switch(e){case Lm.FiveSeconds:return 5e3;case Lm.TenSeconds:return 1e4;case Lm.FifteenSeconds:return 15e3;case Lm.ThirtySeconds:return 3e4;case Lm.OneMinute:return 6e4;case Lm.ThreeMinutes:return 18e4;case Lm.FiveMinutes:return 3e5;case Lm.TenMinutes:return 6e5;default:return 15e3}}(H.idPageTime),t=setInterval(()=>{Q(e=>{const t=(m.findIndex(t=>t.id===e)+1)%m.length;return m[t]?.id})},e);return()=>clearInterval(t)},[$,H,m]);const X=a.useCallback(e=>{W({mode:"view",dashboardId:e.id}),Q(void 0),v?.(e)},[W,v]),J=a.useCallback(()=>{W({mode:"list"}),K(!1),y?.()},[W,y]),Z=a.useCallback(()=>{W({mode:"create"})},[W]),ee=a.useCallback(e=>{W({mode:"edit",dashboardId:e.id})},[W]),te=a.useCallback(e=>{W({mode:"share",dashboardId:e.id})},[W]),ae=a.useCallback(e=>{"edit"===$.mode||"share"===$.mode?C?.($.dashboardId,e):_?.(e)},[$,_,C]),re=a.useCallback(()=>{"edit"===$.mode||"share"===$.mode?W({mode:"view",dashboardId:$.dashboardId}):W({mode:"list"})},[$,W]),se=a.useCallback(()=>{H&&N?.(H)},[H,N]),ne=a.useCallback(()=>{H&&ee(H)},[H,ee]),oe=a.useCallback(()=>{H&&te(H)},[H,te]);return t.jsxs("div",{className:_r("flex flex-col h-full",B),children:["list"===$.mode&&t.jsx(Wp,{dashboards:e,limit:r,isLoading:o,language:n,canAdd:i,canEdit:l,canRemove:c,onOpen:X,onEdit:ee,onShare:te,onDuplicate:S,onRemove:k,onAdd:Z,onToggleFavorite:N,onRefresh:j,onSearch:M,onQuickFilterChange:R,toolbarExtra:U,className:"flex-1"}),"view"===$.mode&&H&&t.jsxs("div",{className:"flex flex-col h-full",children:[!G&&t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:[t.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]}),s?.dashboardId===H.id&&t.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:[t.jsxs("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),t.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),"Visão geral"]}),l&&L&&s?.dashboardId!==H.id&&t.jsx("button",{onClick:()=>L(H.id),className:"ml-auto text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Definir como visão geral"})]}),t.jsx(Bp,{dashboard:H,panels:u,pages:m,activePageId:Y,canEdit:l||d&&!!H.isStandard,isFullscreen:G,isLoading:o,getPanelData:p,onRefresh:w,onToggleFullscreen:()=>K(e=>!e),onToggleFavorite:se,onEdit:ne,onShare:oe,onAddPanel:T,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:P,onLayoutChange:I,onPageChange:Q,toolbarActions:O,className:"flex-1"})]}),"create"===$.mode&&t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:t.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]})}),t.jsx(Xp,{users:h,groups:x,places:f,collaborators:g,isSaving:b,onSave:ae,onCancel:re,className:"flex-1"})]}),("edit"===$.mode||"share"===$.mode)&&H&&t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:t.jsxs("button",{onClick:re,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar"]})}),t.jsx(Xp,{dashboard:H,initialTab:"share"===$.mode?$m.Share:$m.General,users:h,groups:x,places:f,collaborators:g,isSaving:b,isQualitfy:!!H.isStandard&&!d,onSave:ae,onCancel:re,className:"flex-1"})]})]})},exports.DashboardGrid=zp,exports.DashboardLanguage=Hm,exports.DashboardList=Wp,exports.DashboardListType=Rm,exports.DashboardPageTime=Lm,exports.DashboardPanelDimension=Fm,exports.DashboardPanelOrderBy=Um,exports.DashboardPanelOrderByType=zm,exports.DashboardPanelPeriod=Om,exports.DashboardPanelRenderer=Op,exports.DashboardPanelType=Bm,exports.DashboardShareType=Wm,exports.DashboardUpdateTime=qm,exports.DashboardView=Bp,exports.DashboardViewType=Vm,exports.DataFilterBar=kh,exports.DataList=Uc,exports.DataPagination=Fi,exports.DataTable=Ch,exports.DatePicker=function({date:e,onDateChange:a,placeholder:r,disabled:s=!1,className:n,disabledDates:o,captionLayout:l,fromYear:d,toYear:u}){const{t:m}=y.useTranslation(),p=r??m("select_date");return t.jsxs(an,{children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",disabled:s,className:_r("w-full justify-start text-left font-normal",!e&&"text-muted-foreground",n),children:[t.jsx(c.Calendar,{className:"mr-2 h-4 w-4"}),e?i.format(e,"d 'de' MMMM 'de' yyyy",{locale:Za}):t.jsx("span",{children:p})]})}),t.jsx(sn,{className:"w-auto p-0",align:"start",children:t.jsx(zc,{mode:"single",selected:e,onSelect:a,disabled:o,captionLayout:l,fromYear:d,toYear:u,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=Qr,exports.DialogBody=ss,exports.DialogClose=Zr,exports.DialogContent=as,exports.DialogDescription=is,exports.DialogFooter=ns,exports.DialogHeader=rs,exports.DialogOverlay=es,exports.DialogPortal=Jr,exports.DialogTitle=os,exports.DialogTrigger=Xr,exports.DialogWizard=function({open:a,onOpenChange:r,currentStep:s,onStepChange:n,steps:o,canGoToStep:i,children:l,title:d,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:b="lg",unsavedChangesTitle:v,unsavedChangesDescription:w,cancelText:j,leaveWithoutSavingText:N,className:_,disableNext:C,hideNavigation:k,footerLeft:S}){const{t:A}=y.useTranslation(),T=o.length,D=s>=T,E=s<=1;return t.jsx(Qr,{open:a,onOpenChange:r,children:t.jsxs(as,{size:b,variant:f,isDirty:g,unsavedChangesTitle:v,unsavedChangesDescription:w,cancelText:j,leaveWithoutSavingText:N,className:_r("!p-0 !border-l-0 flex-row overflow-hidden",_),children:[t.jsxs("div",{className:"hidden sm:flex w-56 flex-shrink-0 flex-col bg-primary text-primary-foreground p-6 rounded-l-lg",children:[t.jsx("h3",{className:"text-sm font-medium opacity-80 mb-6",children:"Etapas"}),t.jsx("nav",{className:"flex flex-col gap-1 flex-1",children:o.map((e,a)=>{const r=a+1,o=r===s,l=(e=>e<s)(r),d=(u=r)<=s||!i||i(u);var u;return t.jsxs("button",{type:"button",onClick:()=>(e=>{e!==s&&(e<s?n(e):i&&!i(e)||n(e))})(r),disabled:!d,className:_r("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&&d&&"hover:bg-primary-foreground/10 cursor-pointer",!d&&"opacity-40 cursor-not-allowed"),children:[t.jsx("span",{className:_r("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?t.jsx(c.Check,{className:"h-3.5 w-3.5"}):r}),t.jsx("span",{className:_r("line-clamp-2",o&&"text-primary-foreground",!o&&"text-primary-foreground/70"),children:e})]},r)})})]}),t.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[t.jsxs(rs,{className:"p-6 pb-0",children:[t.jsxs("p",{className:"text-xs text-muted-foreground sm:hidden mb-1",children:["Etapa ",s," de ",T]}),t.jsx(os,{children:d}),u&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]}),t.jsx(ss,{className:"px-6",children:l}),!k&&t.jsx(ns,{className:"px-6 pb-6",children:t.jsxs("div",{className:"flex items-center justify-between w-full",children:[t.jsx("div",{className:"flex items-center gap-2",children:S}),t.jsxs("div",{className:"flex items-center gap-2",children:[!E&&t.jsx(Sr,{variant:"outline",onClick:()=>n(s-1),children:x}),D?t.jsx(Sr,{onClick:m,disabled:C,children:p}):t.jsx(Sr,{onClick:()=>n(s+1),disabled:C,children:h})]})]})})]})]})})},exports.DisabledMenuItem=tn,exports.DocumentFileUpload=function({association:e,canUpload:r=!0,canRemove:s=!0,canDownload:n=!0,canView:o=!0,maxFiles:i,allowedExtensions:c,maxSizeInBytes:d,disabled:u=!1,label:m,onFilesChanged:p,className:h}){const[x,f]=a.useState([]),[g,b]=a.useState(!1),[v,y]=a.useState(0),w=a.useRef(p);w.current=p;const{type:j,associationId:N,associationFieldId:_}=e,C=a.useCallback(async()=>{if(!N)return void f([]);const e=await Mx.listByAssociation(j,N,_);f(e),w.current?.(e.length)},[j,N,_]);a.useEffect(()=>{C()},[C]);const k=a.useCallback(async e=>{if(N){b(!0);try{await Mx.upload(j,N,e,_),y(e=>e+1),await C()}catch{l.toast.error("Falha ao enviar o arquivo.")}finally{b(!1)}}},[j,N,_,C]),S=a.useCallback(async(e,t)=>{const a=await Mx.downloadUrl(e.id);if(a)if(t){const t=document.createElement("a");t.href=a,t.download=e.name,t.click()}else window.open(a,"_blank","noopener,noreferrer");else l.toast.error("Não foi possível abrir o arquivo.")},[]),A=a.useCallback(async e=>{if(e.associationRowId){b(!0);try{if(!await Mx.remove(e.associationRowId))throw new Error;await C()}catch{l.toast.error("Falha ao remover o arquivo.")}finally{b(!1)}}},[C]),T=r&&(null==i||x.length<i);return t.jsxs("div",{className:h,children:[m&&t.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:m}),t.jsxs("div",{className:"space-y-2",children:[x.map(e=>t.jsx(Ax,{storedFile:Rx(e),showReplaceButton:!1,showDownloadButton:n,showViewButton:o,showCloseButton:s,disabled:u||g,onDownload:()=>S(e,!0),onView:()=>S(e,!1),onFileRemove:()=>A(e)},e.associationRowId||e.id)),T&&t.jsx(Ax,{allowedExtensions:c,maxSizeInBytes:d,showReplaceButton:!1,showDownloadButton:!1,showViewButton:!1,showCloseButton:!1,disabled:u||g,onFileSelect:k},`add-${v}`)]})]})},exports.Drawer=Oc,exports.DrawerClose=Vc,exports.DrawerContent=Wc,exports.DrawerDescription=Yc,exports.DrawerFooter=Gc,exports.DrawerHeader=Hc,exports.DrawerOverlay=$c,exports.DrawerPortal=qc,exports.DrawerTitle=Kc,exports.DrawerTrigger=Bc,exports.DropdownMenu=Ls,exports.DropdownMenuCheckboxItem=Hs,exports.DropdownMenuContent=$s,exports.DropdownMenuGroup=zs,exports.DropdownMenuItem=Ws,exports.DropdownMenuLabel=Ks,exports.DropdownMenuPortal=Us,exports.DropdownMenuRadioGroup=Bs,exports.DropdownMenuRadioItem=Gs,exports.DropdownMenuSeparator=Ys,exports.DropdownMenuShortcut=Qs,exports.DropdownMenuSub=Os,exports.DropdownMenuSubContent=Vs,exports.DropdownMenuSubTrigger=qs,exports.DropdownMenuTrigger=Fs,exports.ECustomFormFieldType=Lx,exports.EDocumentAssociationType={Docs:17,Trainings:19},exports.EFieldViewMode=Fx,exports.ESelectionFieldDataSource=zx,exports.EditProfileDialog=fl,exports.ElectronicSignatureDialog=function({open:r,onOpenChange:s,onConfirm:n,onGenerateCode:o,mode:i="code",email:l,maxLength:d=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,b=g?e.t("esign_password_description"):e.t("esign_code_description"),v=m??b,[y,w]=a.useState(""),[j,N]=a.useState(!1),[_,C]=a.useState(!1),[k,S]=a.useState(null),A=a.useCallback(async()=>{if(y.trim()){N(!0),S(null);try{await n(y)?(w(""),s(!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)}}},[y,n,s,f,g]),T=a.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||(w(""),S(null)),s(e)},E=g?c.Lock:c.ShieldCheck,P=g?"Senha":e.t("verification_code"),I=g?e.t("enter_password"):e.t("enter_code");return t.jsx(Qr,{open:r,onOpenChange:D,children:t.jsxs(as,{className:"sm:max-w-md",variant:"form",isDirty:!!y,children:[t.jsx(rs,{children:t.jsxs(os,{className:"flex items-center gap-2",children:[t.jsx(E,{className:"h-5 w-5 text-primary"}),u]})}),t.jsxs("div",{className:"py-4 space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:v}),!g&&l&&t.jsxs("div",{className:"flex items-center gap-2 text-sm bg-muted/50 rounded-md px-3 py-2",children:[t.jsx(c.Mail,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-muted-foreground",children:"Enviado para:"}),t.jsx("span",{className:"font-medium",children:l})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"signature-input",children:P}),t.jsx(Tr,{id:"signature-input",type:g?"password":"text",value:y,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&(e.preventDefault(),A())},maxLength:g?void 0:d,placeholder:I,autoFocus:!0,className:_r(k&&"border-destructive focus-visible:ring-destructive")}),k&&t.jsx("p",{className:"text-sm text-destructive",children:k})]}),!g&&t.jsxs(Sr,{variant:"ghost",size:"sm",onClick:T,disabled:_,className:"text-primary",children:[t.jsx(c.RefreshCw,{className:_r("h-4 w-4 mr-1",_&&"animate-spin")}),x]})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>D(!1),disabled:j,children:h}),t.jsx(Sr,{onClick:A,disabled:!y.trim()||j,children:j?"Validando...":p})]})]})})},exports.EllipsisText=Vo,exports.EmailService=fx,exports.EmptyState=qo,exports.EntitySelect=gn,exports.ErrorBoundary=Vl,exports.ExportDialog=function({open:e,onOpenChange:r,onExport:s,mode:n="table",options:o,title:i,description:l,cancelLabel:c="Cancelar",exportLabel:d="Exportar"}){const{t:u}=y.useTranslation(),[m,p]=a.useState(""),h=o??("chart"===n?im:om),x=i??u("chart"===n?"dashboard_export_chart":"dashboard_export_table"),f=l??u("select_file_format"),g=e=>{e||p(""),r(e)};return t.jsx(Qr,{open:e,onOpenChange:g,children:t.jsxs(as,{className:"sm:max-w-md",variant:"form",isDirty:!!m,children:[t.jsx(rs,{children:t.jsx(os,{children:x})}),t.jsxs("div",{className:"py-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),t.jsx(Fd,{value:m,onValueChange:p,className:"gap-3",children:h.map(e=>t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(zd,{value:e.value,id:`export-${e.value}`}),t.jsxs(Er,{htmlFor:`export-${e.value}`,className:_r("flex items-center gap-2 cursor-pointer font-normal",m===e.value&&"font-medium"),children:[e.icon,e.label]})]},e.value))})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>g(!1),children:c}),t.jsx(Sr,{onClick:()=>{m&&(s(m),r(!1),p(""))},disabled:!m,children:d})]})]})})},exports.ExportFormat=nm,exports.FORBIDDEN_FILE_TYPES=Cx,exports.FilePrintType=xm,exports.FileViewerType=hm,exports.FilterBar=Vi,exports.Form=ls,exports.FormControl=hs,exports.FormDateField=Vx,exports.FormDescription=xs,exports.FormField=({...e})=>t.jsx(cs.Provider,{value:{name:e.name},children:t.jsx(h.Controller,{...e})}),exports.FormItem=ms,exports.FormLabel=ps,exports.FormMessage=fs,exports.FormMultiSelectionField=Kx,exports.FormNumericField=Hx,exports.FormQuestionsField=Yx,exports.FormSingleSelectionField=Gx,exports.FormSkeleton=function({fields:e=4}){return t.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,a)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx(hn,{className:"h-4 w-24"}),t.jsx(hn,{className:"h-10 w-full"})]},a)),t.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[t.jsx(hn,{className:"h-10 w-20"}),t.jsx(hn,{className:"h-10 w-20"})]})]})},exports.FormTextField=qx,exports.FormTimeField=$x,exports.FormUrlField=Wx,exports.Grid=function({children:e,cols:a="auto-fit",gap:r="md",className:s}){return t.jsx("div",{className:_r("grid",Qc[a],Xc[r],s),children:e})},exports.H1=ld,exports.H2=cd,exports.H3=dd,exports.H4=ud,exports.HeaderSkeleton=function(){return t.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(hn,{className:"h-8 w-8 rounded-full"}),t.jsx(hn,{className:"h-6 w-32"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(hn,{className:"h-8 w-8"}),t.jsx(hn,{className:"h-8 w-24"})]})]})},exports.HoverCard=Jc,exports.HoverCardContent=ed,exports.HoverCardTrigger=Zc,exports.IconPicker=Pi,exports.IframeDialog=wm,exports.ImageEditor=function({value:e,onChange:r,onSubmit:s,onCancel:n,uploadFunction:o,deleteFunction:i,uploadOptions:d}){const{t:u}=y.useTranslation(),[m,p]=a.useState(e||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=Nx({uploadFunction:o,deleteFunction:i,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,t)=>{const a={...m,[e]:t};p(a),r(a)};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"URL"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Tr,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),o&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await x(t),a={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(a),r(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),t.jsx(Sr,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?t.jsxs(t.Fragment,{children:[t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),m.imageFile&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",m.imageFile," (",Math.round((m.imageSize||0)/1024)," KB)"]})]}),m.imageUrl&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Preview"}),t.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:t.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:t.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"})})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"caption",children:"Legenda"}),t.jsx(Ts,{id:"caption",placeholder:"Legenda",value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"alt",children:u("alt_text")}),t.jsx(Tr,{id:"alt",placeholder:u("alt_text"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Alinhamento"}),t.jsxs(bs,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[t.jsx(ws,{children:t.jsx(ys,{})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"left",children:"Esquerda"}),t.jsx(ks,{value:"center",children:"Centro"}),t.jsx(ks,{value:"right",children:"Direita"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"width",children:"Largura"}),t.jsx(Tr,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"height",children:"Altura"}),t.jsx(Tr,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:"allowDownload",checked:m.allowDownload||!1,onCheckedChange:e=>g("allowDownload",!0===e)}),t.jsx(Er,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[t.jsx(Sr,{variant:"outline",onClick:n,children:"Cancelar"}),t.jsx(Sr,{onClick:()=>{m.imageUrl?s(m):l.toast.error("Erro",{description:u("no_image_selected")})},disabled:!m.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:e,className:a="",style:r}){const{t:s}=y.useTranslation();if(!e.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return t.jsx("div",{className:`flex ${n} my-4 ${a}`,style:r,children:t.jsxs("div",{className:"space-y-2 max-w-full",children:[t.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&&t.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&t.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[t.jsx(c.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=gd,exports.Input=Tr,exports.InputGroup=td,exports.InputGroupAddon=rd,exports.InputGroupButton=nd,exports.InputGroupInput=od,exports.InputGroupTextarea=id,exports.LINK_PROPERTIES=op,exports.LOGO_CONFIG=et,exports.Label=Er,exports.LanguageBootstrap=Pl,exports.Large=hd,exports.Lead=pd,exports.List=vd,exports.ListPanel=_p,exports.LoadingState=Ms,exports.LocaleProvider=Ll,exports.LoginPage=()=>{const{t:e}=y.useTranslation();return t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),t.jsxs(Lr,{className:"text-center space-y-4",children:[t.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),t.jsx(Sr,{onClick:async()=>{We()?await jo.loginDev():jo.loginProd()},className:"w-full",size:"lg",children:We()?e("dev_login"):e("login_with_qualiex")})]})]})})},exports.MESSAGES=tt,exports.MODULES_DATA=lc,exports.MONTHS_MAP=sp,exports.MatrixRiskPanel=Mp,exports.MatrixViewType=Gm,exports.Menubar=Eu,exports.MenubarCheckboxItem=Fu,exports.MenubarContent=Ru,exports.MenubarGroup=Su,exports.MenubarItem=Lu,exports.MenubarLabel=Uu,exports.MenubarMenu=ku,exports.MenubarPortal=Au,exports.MenubarRadioGroup=Du,exports.MenubarRadioItem=zu,exports.MenubarSeparator=Ou,exports.MenubarShortcut=Bu,exports.MenubarSub=Tu,exports.MenubarSubContent=Mu,exports.MenubarSubTrigger=Iu,exports.MenubarTrigger=Pu,exports.MindMap=({value:e,defaultValue:r,onChange:s,onNodeSelect:n,readOnly:o=!1,hideToolbar:i=!1,extraShortcuts:l,renderNodeContent:c,className:d,height:u=600})=>{const{t:m}=y.useTranslation(),p=dh({value:e,defaultValue:r,onChange:s,readOnly:o}),h=gh(p.root),x=function(){const[e,t]=a.useState({x:0,y:0,scale:1}),r=a.useRef(!1),s=a.useRef({x:0,y:0,tx:0,ty:0}),n=a.useCallback(t=>{0!==t.button&&1!==t.button||(r.current=!0,s.current={x:t.clientX,y:t.clientY,tx:e.x,ty:e.y},t.currentTarget.setPointerCapture(t.pointerId))},[e.x,e.y]),o=a.useCallback(e=>{r.current&&t(t=>({...t,x:s.current.tx+(e.clientX-s.current.x),y:s.current.ty+(e.clientY-s.current.y)}))},[]),i=a.useCallback(e=>{if(r.current){r.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),l=a.useCallback((e,a,r)=>{t(t=>{const s=Math.min(2.5,Math.max(.3,t.scale+e));if(s===t.scale)return t;if(void 0===a||void 0===r)return{...t,scale:s};const n=s/t.scale;return{scale:s,x:a-(a-t.x)*n,y:r-(r-t.y)*n}})},[]),c=a.useCallback(()=>l(.15),[l]),d=a.useCallback(()=>l(-.15),[l]),u=a.useCallback(()=>t({x:0,y:0,scale:1}),[]),m=a.useCallback((e,a,r,s)=>{const n=Math.min((r-64)/e,(s-64)/a,1.5),o=Math.max(.3,n);t({scale:o,x:(r-e*o)/2,y:(s-a*o)/2})},[]),p=a.useCallback(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=e.currentTarget.getBoundingClientRect(),a=e.clientX-t.left,r=e.clientY-t.top;l(e.deltaY>0?-.1:.1,a,r)},[l]);return a.useEffect(()=>{const e=()=>r.current=!1;return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]),{transform:e,setTransform:t,zoomIn:c,zoomOut:d,reset:u,fitTo:m,onBackgroundPointerDown:n,onPointerMove:o,onPointerUp:i,onWheel:p}}(),f=te.useRef(null),g=te.useRef(null),b=te.useRef(null),[v,w]=te.useState(null),[j,N]=te.useState(null);te.useEffect(()=>{n?.(p.selectedNode)},[p.selectedNode,n]),function({api:e,layout:t,containerRef:r,onStartEditing:s,readOnly:n,extraShortcuts:o}){a.useEffect(()=>{const a=a=>{const i=r.current;if(!i)return;if(!i.contains(document.activeElement))return;const l=a.target;if(l?.isContentEditable)return;if(l&&("INPUT"===l.tagName||"TEXTAREA"===l.tagName))return;const c={layout:t,selectedId:e.selectedId,setSelectedId:e.setSelectedId},d=e.selectedId;for(const t of o??[])if(t.key.toLowerCase()===a.key.toLowerCase()&&!!t.ctrl===(a.ctrlKey||a.metaKey)&&!!t.shift===a.shiftKey&&!!t.alt===a.altKey)return a.preventDefault(),void t.handler({selectedId:e.selectedId,root:e.root,setRoot:e.setRoot,select:e.setSelectedId});if((a.ctrlKey||a.metaKey)&&"z"===a.key.toLowerCase())return a.preventDefault(),void(a.shiftKey?e.redo():e.undo());if("ArrowUp"===a.key)return a.preventDefault(),void bh("up",c);if("ArrowDown"===a.key)return a.preventDefault(),void bh("down",c);if("ArrowLeft"===a.key)return a.preventDefault(),void bh("left",c);if("ArrowRight"===a.key)return a.preventDefault(),void bh("right",c);if(d){if(" "===a.key)return a.preventDefault(),void e.toggleNode(d);if("F2"===a.key){if(n)return;return a.preventDefault(),void s(d)}if(!n){if("Enter"===a.key&&!a.shiftKey)return a.preventDefault(),d===e.root.id?e.addChild(d,""):e.addSibling(d,""),void setTimeout(()=>{e.selectedId&&s(e.selectedId)},0);if("Insert"===a.key||"Tab"===a.key)return a.preventDefault(),e.addChild(d,""),void setTimeout(()=>{e.selectedId&&s(e.selectedId)},0);if("Delete"===a.key||"Backspace"===a.key){if(d===e.root.id)return;return a.preventDefault(),void e.removeNode(d)}}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t,r,s,n,o])}({api:p,layout:h,containerRef:f,onStartEditing:e=>{o||w(e)},readOnly:o,extraShortcuts:l});const _=te.useRef(!1);te.useEffect(()=>{if(_.current)return;const e=g.current;if(!e)return;const{clientWidth:t,clientHeight:a}=e;t>0&&a>0&&h.width>0&&(x.fitTo(h.width,h.height,t,a),_.current=!0)},[h.width,h.height,x]);const C=p.selectedId,k=p.selectedNode,S=C===p.root.id,A=te.useRef(null),T=e=>t=>{if(o)return;const a=A.current;if(!a||a===e)return;const r=eh(p.root,a);r&&eh(r.node,e)||(t.preventDefault(),t.dataTransfer.dropEffect="move",N(e))},D=()=>N(null),E=e=>t=>{t.preventDefault();const a=A.current;N(null),A.current=null,a&&a!==e&&p.moveNode(a,e)};return t.jsx(Xs,{children:t.jsxs("div",{ref:f,tabIndex:0,role:"tree","aria-label":m("mind_map_aria_label"),className:_r("relative flex flex-col rounded-lg border bg-muted/20 overflow-hidden focus:outline-none",d),style:{height:u},onClick:()=>f.current?.focus(),children:[!i&&t.jsx(jh,{canAddChild:!!k&&!o,canAddSibling:!!k&&!o,canDelete:!!k&&!S&&!o,canUndo:p.canUndo&&!o,canRedo:p.canRedo&&!o,onAddChild:()=>{if(!C)return;const e=p.addChild(C,"");w(e)},onAddSibling:()=>{if(!C)return;if(S){const e=p.addChild(C,"");return void w(e)}const e=p.addSibling(C,"");w(e)},onDelete:()=>{C&&!S&&p.removeNode(C)},onExpandAll:p.expandAll,onCollapseAll:p.collapseAll,onFit:()=>{const e=g.current;e&&x.fitTo(h.width,h.height,e.clientWidth,e.clientHeight)},onZoomIn:x.zoomIn,onZoomOut:x.zoomOut,onUndo:p.undo,onRedo:p.redo,onExportJson:()=>{!function(e,t,a="application/json"){const r=new Blob([e],{type:a}),s=URL.createObjectURL(r),n=document.createElement("a");n.href=s,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}(Nh(p.root),"mind-map.json")},onExportImage:async()=>{if(b.current)try{await async function(e,t="mind-map.png"){const a=e.cloneNode(!0),r=(new XMLSerializer).serializeToString(a),s=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(r)))}`,n=new Image;await new Promise((e,t)=>{n.onload=()=>e(),n.onerror=()=>t(new Error("Failed to load SVG snapshot")),n.src=s});const o=e.clientWidth||Number(e.getAttribute("width"))||1200,i=e.clientHeight||Number(e.getAttribute("height"))||800,l=document.createElement("canvas");l.width=2*o,l.height=2*i;const c=l.getContext("2d");if(!c)throw new Error("Canvas 2D context unavailable");c.fillStyle="#ffffff",c.fillRect(0,0,l.width,l.height),c.drawImage(n,0,0,l.width,l.height);const d=await new Promise(e=>l.toBlob(e,"image/png"));if(!d)throw new Error("Failed to create PNG blob");const u=URL.createObjectURL(d),m=document.createElement("a");m.href=u,m.download=t,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}(b.current,"mind-map.png")}catch(e){}}}),t.jsx("div",{ref:g,className:"relative flex-1 overflow-hidden cursor-grab active:cursor-grabbing",onPointerDown:e=>{e.target===e.currentTarget&&(x.onBackgroundPointerDown(e),p.setSelectedId(null))},onPointerMove:x.onPointerMove,onPointerUp:x.onPointerUp,onWheel:x.onWheel,children:t.jsxs("div",{className:"absolute origin-top-left",style:{transform:`translate(${x.transform.x}px, ${x.transform.y}px) scale(${x.transform.scale})`,width:h.width,height:h.height},children:[t.jsx("svg",{ref:b,width:h.width,height:h.height,className:"absolute inset-0 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:h.nodes.map(e=>e.visibleChildren.map(a=>t.jsx(yh,{parent:e,child:a},`${e.node.id}-${a.node.id}`)))}),h.nodes.map(e=>{return t.jsx(vh,{layout:e,selected:C===e.node.id,editing:v===e.node.id,readOnly:o,onSelect:()=>p.setSelectedId(e.node.id),onStartEditing:()=>w(e.node.id),onFinishEditing:t=>{null!==t&&p.renameNode(e.node.id,t),w(null)},onToggle:()=>p.toggleNode(e.node.id),onDragStart:(a=e.node.id,e=>{o||a===p.root.id||(A.current=a,e.dataTransfer.setData("text/plain",a),e.dataTransfer.effectAllowed="move")}),onDragOver:T(e.node.id),onDragLeave:D,onDrop:E(e.node.id),isDropTarget:j===e.node.id,renderNodeContent:c},e.node.id);var a})]})})]})})},exports.ModalStateProvider=function({children:e}){const[r,s]=a.useState(new Set),[n,o]=a.useState(!1),i=a.useCallback(e=>{s(t=>{const a=new Set(t);return a.add(e),a})},[]),l=a.useCallback(e=>{s(t=>{const a=new Set(t);return a.delete(e),a})},[]),c=a.useCallback(e=>{o(e)},[]),d=a.useMemo(()=>r.size>0||n,[r,n]),u=a.useMemo(()=>({openModals:r,hasOpenModal:d,registerModal:i,unregisterModal:l,setHasOpenModal:c}),[r,d,i,l,c]);return t.jsx(Hh.Provider,{value:u,children:e})},exports.ModuleAccessGuard=gc,exports.ModuleGrid=uc,exports.ModuleOfferContent=function({title:e,description:a,image:r,icon:s,ctaLabel:n,onCtaClick:o,children:i}){const{t:l}=y.useTranslation(),d=n??l("want_to_know_more");return t.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(r||s)&&t.jsx("div",{className:"flex items-center justify-center",children:r?t.jsx("img",{src:r,alt:e,className:"max-h-48 w-auto object-contain rounded-lg"}):s?t.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:t.jsx(s,{className:"h-12 w-12 text-primary"})}):null}),t.jsxs("div",{className:"space-y-3 max-w-lg",children:[t.jsx("h3",{className:"text-xl font-semibold text-foreground",children:e}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]}),i?t.jsx("div",{className:"w-full",children:i}):o?t.jsxs(Sr,{onClick:o,size:"lg",className:"gap-2",children:[t.jsx(c.Sparkles,{className:"h-4 w-4"}),d]}):null]})},exports.ModuleProvider=kl,exports.ModulesContent=mc,exports.ModulesDialog=hc,exports.ModulesFooterCards=ic,exports.MultiSelect=gn,exports.MultiselectPermissions=function({items:r,categories:s,value:n,onChange:o,readonly:i=!1,isLoading:l=!1,title:d=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:b,onDisclaimerClick:v,className:w}){const[j,N]=a.useState(s[0]?.id??""),[_,C]=a.useState(""),[k,S]=a.useState([]),[A,T]=a.useState(!1),D=a.useMemo(()=>km(n[j]),[n,j]),E=a.useMemo(()=>function(e){const{t:t}=y.useTranslation(),a=new Set;if(!e)return a;for(const r of e)r.inheritedIds?.forEach(e=>a.add(e));return a}(n[j]),[n,j]),P=a.useMemo(()=>r.filter(e=>D.has(e.id)),[r,D]),I=a.useMemo(()=>{const e=Cm(_);return r.filter(t=>!D.has(t.id)&&!(e&&!Cm(t.name).includes(e)))},[r,D,_]),M=a.useMemo(()=>{const e={};for(const t of s)e[t.id]=km(n[t.id]).size;return e},[s,n]),R=a.useCallback(e=>{N(e),S([]),C("")},[]),L=a.useCallback(e=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),F=a.useCallback(()=>{if(0===k.length)return;const e=[...n[j]??[]];for(const t of k){const a=r.find(e=>e.id===t),s=a?.group??"default",n=e.find(e=>e.context===s);n?n.allowedIds.includes(t)||(n.allowedIds=[...n.allowedIds,t]):e.push({context:s,allowedIds:[t],inheritedIds:[]})}o({...n,[j]:e}),S([]),C(""),T(!1)},[k,n,j,r,o]),z=a.useCallback(e=>{if(E.has(e))return;const t=(n[j]??[]).map(t=>({...t,allowedIds:t.allowedIds.filter(t=>t!==e)}));o({...n,[j]:t})},[n,j,E,o]);return l?t.jsxs("div",{className:_r("rounded-md border bg-muted/30 p-4 animate-pulse space-y-3",w),children:[t.jsx("div",{className:"h-4 w-32 bg-muted rounded"}),t.jsx("div",{className:"h-9 w-full bg-muted rounded"}),t.jsx("div",{className:"h-20 w-full bg-muted rounded"})]}):t.jsx("div",{className:_r("rounded-md border bg-muted/30",w),children:t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:d}),t.jsxs(bs,{value:j,onValueChange:R,children:[t.jsx(ws,{className:"h-9 text-sm",children:t.jsx(ys,{})}),t.jsx(_s,{children:s.map(e=>t.jsx(ks,{value:e.id,children:t.jsxs("span",{className:"flex items-center gap-2",children:[e.icon,e.name,M[e.id]>0&&t.jsx(Es,{variant:"secondary",className:"ml-1 text-xs px-1.5 py-0",children:M[e.id]})]})},e.id))})]})]}),!i&&t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(an,{open:A,onOpenChange:T,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{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,t.jsx(c.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsxs(sn,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:[t.jsx("div",{className:"p-2 border-b",children:t.jsxs("div",{className:"relative",children:[t.jsx(c.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{className:"pl-8 h-8 text-sm",placeholder:h,value:_,onChange:e=>C(e.target.value)})]})}),t.jsx(Ai,{className:"max-h-[220px]",children:0===I.length?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nenhum item encontrado"}):t.jsx("div",{className:"p-1",children:I.map(e=>{const a=k.includes(e.id);return t.jsxs("div",{className:_r("flex items-center gap-3 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent",a&&"bg-accent/50"),onClick:()=>L(e.id),children:[t.jsx("div",{className:_r("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",a&&"bg-primary text-primary-foreground"),children:a&&t.jsx(c.Check,{className:"h-3 w-3"})}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"truncate",children:e.name}),null!=e.count&&t.jsx("span",{className:"text-xs text-muted-foreground",children:f(e.count)})]})]},e.id)})})})]})]}),t.jsxs(Sr,{size:"sm",className:"h-9 gap-1",disabled:0===k.length,onClick:F,children:[t.jsx(c.Plus,{className:"h-4 w-4"}),u]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:m}),t.jsx("div",{className:_r("rounded-md border bg-background p-3 min-h-[60px]",i&&"bg-muted/50"),children:0===P.length?t.jsx("span",{className:"text-sm text-muted-foreground",children:p}):t.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(e=>{const a=E.has(e.id);return t.jsxs(Es,{variant:a?"secondary":"default",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.name,!i&&!a&&t.jsx("button",{type:"button",className:"ml-0.5 rounded-full hover:bg-primary-foreground/20 p-0.5",onClick:()=>z(e.id),children:t.jsx(c.X,{className:"h-3 w-3"})})]},e.id)})})}),i&&g&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.jsx("span",{dangerouslySetInnerHTML:{__html:g}})," ",b&&v&&t.jsx("button",{type:"button",className:"text-primary underline hover:no-underline",onClick:v,children:b})]})]})]})})},exports.Muted=fd,exports.NavigationMenu=yd,exports.NavigationMenuContent=Cd,exports.NavigationMenuIndicator=Ad,exports.NavigationMenuItem=jd,exports.NavigationMenuLink=kd,exports.NavigationMenuList=wd,exports.NavigationMenuTrigger=_d,exports.NavigationMenuViewport=Sd,exports.NavigationProvider=Rh,exports.NumericPanel=jp,exports.OnboardingDialog=rm,exports.OnlineEditorDialog=function({open:e,onOpenChange:r,identifier:s,fileName:n,mode:o="edit",type:i="document",onClose:l,className:d}){const[u,m]=a.useState(!0),p=function(e,t="edit",a="document"){return`https://docs.google.com/${a}/d/${e}/${t}?usp=drivesdk?embedded=true&rm=demo`}(s,o,i);a.useEffect(()=>{if(e){m(!0);const e=setTimeout(()=>m(!1),300);return()=>clearTimeout(e)}},[e]);const h=a.useCallback(()=>{l?.(),r(!1)},[l,r]);return a.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&h()};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[e,h]),t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:_r("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",d),children:[t.jsxs("div",{className:"flex items-center justify-between mb-6 min-h-[30px]",children:[u?t.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):t.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-80px)]",children:n}),t.jsx("div",{className:"flex items-center ml-4 z-20",children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:t.jsx(c.X,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Fechar"})]})})]}),t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[160px] w-full min-w-[77vw] min-h-[80vh]",children:u?t.jsx(Is,{className:"h-14 w-14"}):t.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[t.jsx(Is,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),t.jsx("iframe",{src:p,className:"border-none w-full h-full z-[1] relative",title:n})]})})]})})},exports.P=md,exports.PageBreadcrumb=function({items:e,maxItems:a=3,className:r}){const s=e.length>a?[e[0],...e.slice(-(a-1))]:e,n=e.length>a;return t.jsx(Ac,{className:r,children:t.jsx(Tc,{children:s.map((e,a)=>{const r=0===a,s=n&&1===a;return t.jsxs(Dc,{children:[!r&&t.jsx(Ic,{}),s&&t.jsxs(t.Fragment,{children:[t.jsx(Mc,{}),t.jsx(Ic,{})]}),e.isCurrentPage?t.jsx(Pc,{children:e.label}):t.jsx(Ec,{asChild:!0,children:t.jsx(N.Link,{to:e.href||"/",children:e.label})})]},e.label)})})})},exports.PageMetadataProvider=bl,exports.Pagination=Td,exports.PaginationContent=Dd,exports.PaginationEllipsis=Rd,exports.PaginationItem=Ed,exports.PaginationLink=Pd,exports.PaginationNext=Md,exports.PaginationPrevious=Id,exports.PaletteType=rp,exports.PanelError=gp,exports.PanelHeader=fp,exports.PanelItemsPerPanel=Km,exports.PanelLoader=bp,exports.PanelNoData=vp,exports.PanelSortType=Ym,exports.PanelState=Qm,exports.PanelUnavailable=yp,exports.ParetoPanel=Ep,exports.PerformancePanel=Ip,exports.PiePanel=Dp,exports.PlanType=Jm,exports.Popover=an,exports.PopoverContent=sn,exports.PopoverTrigger=rn,exports.Progress=Ld,exports.ProtectedRoute=({children:r})=>{const{isAuthenticated:s,isLoading:n}=So();if(a.useEffect(()=>{if(n)return;if(s)return;if($n.isManualLogout())return void(window.location.pathname.endsWith("/login")||(window.location.href=Ue("/login")));const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const r=We(),o=Be(window.location.pathname),i=o+window.location.search+window.location.hash;["/","/login","/callback"].includes(o)||localStorage.setItem("auth_return_url",i);(async()=>{r?await jo.loginDev():jo.loginProd()})()},[s,n]),n&&!s)return t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Carregando..."})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Processando..."})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Iniciando..."})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:We()?e.t("auto_login"):e.t("redirecting_auth")})]})]})})}return t.jsx(t.Fragment,{children:r})},exports.QUALIEX_CONFIG=Ze,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=fo,exports.QualiexErrorInterceptor=lo,exports.QualiexUserField=Ri,exports.QueriesContextType=Zm,exports.QueriesShareType=ep,exports.QuickFilterDashboard=tp,exports.RadioGroup=Fd,exports.RadioGroupItem=zd,exports.ReadOnlyTextField=Bx,exports.ReportRequestList=function({requests:e,isLoading:r=!1,onGetReportUrl:s,formatDate:n=Dm,labels:o,className:i}){const{t:l}=y.useTranslation(),d={...Am,...o},[u,m]=a.useState(""),[p,h]=a.useState(!1),[x,f]=a.useState(""),[g,b]=a.useState(""),[v,w]=a.useState(null),j=a.useMemo(()=>{if(!u)return e;const t=Tm(u);return e.filter(e=>Tm(e.reportName).includes(t))},[e,u]),N=a.useCallback(async e=>{if(!v){w(e.id);try{const t=await s(e.id);t&&(f(t),b(e.reportName),h(!0))}finally{w(null)}}},[s,v]);return r?t.jsx("div",{className:_r("space-y-3",i),children:Array.from({length:5}).map((e,a)=>t.jsx(hn,{className:"h-12 w-full"},a))}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:_r("space-y-3",i),children:[t.jsxs("div",{className:"relative max-w-sm",children:[t.jsx(c.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{className:"pl-8 h-9 text-sm",placeholder:d.searchPlaceholder,value:u,onChange:e=>m(e.target.value)})]}),t.jsx(Ai,{className:"rounded-md border",children:t.jsxs(Eo,{children:[t.jsx(Po,{children:t.jsxs(Ro,{children:[t.jsx(Lo,{className:"min-w-[140px]",children:d.report}),t.jsx(Lo,{className:"min-w-[150px]",children:d.status}),t.jsx(Lo,{className:"min-w-[160px]",children:d.requestDate}),t.jsx(Lo,{className:"min-w-[160px]",children:d.lastUpdate}),t.jsx(Lo,{className:"min-w-[160px]",children:d.expirationDate}),t.jsx(Lo,{className:"min-w-[140px]"})]})}),t.jsx(Io,{children:0===j.length?t.jsx(Ro,{children:t.jsx(Fo,{colSpan:6,className:"text-center text-muted-foreground py-8",children:d.noResults})}):j.map(e=>{const a=function(e){const{t:t}=y.useTranslation();return new Date>new Date(e.expirationDate)&&3===e.statusId?5:e.statusId}(e),r=function(e,a){const{t:r}=y.useTranslation();switch(e){case 1:return{label:a.statusWaiting,icon:t.jsx(c.Hourglass,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50"};case 2:return{label:a.statusProcessing,icon:t.jsx(c.RefreshCw,{className:"h-3.5 w-3.5 animate-spin"}),variant:"outline",className:"text-blue-600 border-blue-300 bg-blue-50"};case 3:return{label:a.statusCompleted,icon:t.jsx(c.CheckCircle2,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50"};case 4:return{label:a.statusError,icon:t.jsx(c.AlertCircle,{className:"h-3.5 w-3.5"}),variant:"danger"};case 5:return{label:a.statusExpired,icon:t.jsx(c.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"}}}(a,d),s=3===a,o=5===a;return t.jsxs(Ro,{children:[t.jsx(Fo,{className:"font-medium",children:e.reportName}),t.jsx(Fo,{children:t.jsxs(Es,{variant:r.variant,className:_r("gap-1",r.className),children:[r.icon,r.label]})}),t.jsx(Fo,{className:"text-sm",children:n(new Date(e.requestDate))}),t.jsx(Fo,{className:"text-sm",children:n(new Date(e.lastUpdate))}),t.jsx(Fo,{className:_r("text-sm",o&&"text-destructive"),children:n(new Date(e.expirationDate))}),t.jsx(Fo,{children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"gap-1.5",disabled:!s||v===e.id,onClick:()=>N(e),children:[v===e.id?t.jsx(c.Loader2,{className:"h-4 w-4 animate-spin"}):t.jsx(c.Eye,{className:"h-4 w-4"}),d.viewReport]})})]},e.id)})})]})})]}),t.jsx(wm,{open:p,onOpenChange:h,url:x,title:g})]})},exports.ReportRequestStatus=Sm,exports.ResizableHandle=({withHandle:e,className:a,...r})=>t.jsx(Ce.PanelResizeHandle,{className:_r("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...r,children:e&&t.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsx(c.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Ud,exports.ResizablePanelGroup=({className:e,...a})=>t.jsx(Ce.PanelGroup,{className:_r("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),exports.RichTextEditor=({value:r,onChange:s,disabled:n,placeholder:o=e.t("write_content_here"),minHeight:i="300px",showModeToggle:l=!0,showVariableHint:d=!0,className:u})=>{const{t:m}=y.useTranslation(),[p,h]=a.useState("visual"),x=V.useEditor({extensions:[$.configure({heading:{levels:[1,2,3]}}),W,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,K.Color,Y.configure({multicolor:!0})],content:r||"",editable:!n,onUpdate:({editor:e})=>{s(e.getHTML())}});te.useEffect(()=>{x&&r!==x.getHTML()&&x.commands.setContent(r||"")},[r,x]);const f=a.useCallback(()=>{if(!x)return;const e=x.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?x.chain().focus().extendMarkRange("link").setLink({href:t}).run():x.chain().focus().extendMarkRange("link").unsetLink().run())},[x]);return x?t.jsxs("div",{className:_r("space-y-2",u),children:[l&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex gap-1",children:[t.jsxs(Sr,{type:"button",size:"sm",variant:"visual"===p?"default":"outline",onClick:()=>h("visual"),disabled:n,children:[t.jsx(c.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),t.jsxs(Sr,{type:"button",size:"sm",variant:"code"===p?"default":"outline",onClick:()=>h("code"),disabled:n,children:[t.jsx(c.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),t.jsxs(Sr,{type:"button",size:"sm",variant:"preview"===p?"default":"outline",onClick:()=>h("preview"),disabled:n,children:[t.jsx(c.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),d&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",t.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===p&&t.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||x?.commands.focus()},children:[t.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHeading({level:1}).run(),isActive:x.isActive("heading",{level:1}),disabled:n,title:e.t("heading_1"),children:t.jsx(c.Heading1,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),isActive:x.isActive("heading",{level:2}),disabled:n,title:e.t("heading_2"),children:t.jsx(c.Heading2,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHeading({level:3}).run(),isActive:x.isActive("heading",{level:3}),disabled:n,title:e.t("heading_3"),children:t.jsx(c.Heading3,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleBold().run(),isActive:x.isActive("bold"),disabled:n,title:e.t("bold"),children:t.jsx(c.Bold,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleItalic().run(),isActive:x.isActive("italic"),disabled:n,title:e.t("italic"),children:t.jsx(c.Italic,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleUnderline().run(),isActive:x.isActive("underline"),disabled:n,title:"Sublinhado",children:t.jsx(c.Underline,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleStrike().run(),isActive:x.isActive("strike"),disabled:n,title:"Riscado",children:t.jsx(c.Strikethrough,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleBulletList().run(),isActive:x.isActive("bulletList"),disabled:n,title:"Lista",children:t.jsx(c.List,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleOrderedList().run(),isActive:x.isActive("orderedList"),disabled:n,title:m("ordered_list"),children:t.jsx(c.ListOrdered,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHighlight().run(),isActive:x.isActive("highlight"),disabled:n,title:"Destacar",children:t.jsx(c.Highlighter,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:f,isActive:x.isActive("link"),disabled:n,title:"Link",children:t.jsx(c.Link,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().unsetAllMarks().clearNodes().run(),disabled:n,title:m("clear_formatting"),children:t.jsx(c.RemoveFormatting,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().undo().run(),disabled:n||!x.can().undo(),title:"Desfazer",children:t.jsx(c.Undo,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().redo().run(),disabled:n||!x.can().redo(),title:"Refazer",children:t.jsx(c.Redo,{className:"h-4 w-4"})})]}),t.jsx(V.EditorContent,{editor:x,className:_r("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&&t.jsx("textarea",{value:r||"",onChange:e=>s(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&&t.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:t.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:t.jsx("div",{dangerouslySetInnerHTML:{__html:r||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null},exports.RiskCriticality=ap,exports.SEARCH_CONFIG=Ve,exports.SUPPORTED_LOCALES=er,exports.ScrollArea=Ai,exports.ScrollBar=Ti,exports.Select=bs,exports.SelectApproverDialog=Jx,exports.SelectContent=_s,exports.SelectGroup=vs,exports.SelectItem=ks,exports.SelectLabel=Cs,exports.SelectScrollDownButton=Ns,exports.SelectScrollUpButton=js,exports.SelectSearch=gn,exports.SelectSeparator=Ss,exports.SelectTrigger=ws,exports.SelectValue=ys,exports.Separator=zr,exports.Sheet=Od,exports.SheetBody=Kd,exports.SheetClose=qd,exports.SheetContent=Hd,exports.SheetDescription=Xd,exports.SheetFooter=Yd,exports.SheetHeader=Gd,exports.SheetOverlay=$d,exports.SheetPortal=Vd,exports.SheetTitle=Qd,exports.SheetTrigger=Bd,exports.Sidebar=au,exports.SidebarActionTrigger=qh,exports.SidebarContent=du,exports.SidebarFooter=lu,exports.SidebarGroup=uu,exports.SidebarGroupAction=pu,exports.SidebarGroupContent=hu,exports.SidebarGroupLabel=mu,exports.SidebarHeader=function({open:e,appName:r}){const[s,n]=a.useState(!1),{association:o}=Dl(),i=lt({isQualitfy:o?.isQualitfy,isMetroex:o?.isMetroex});return t.jsxs(t.Fragment,{children:[t.jsx(iu,{className:"p-0 gap-0",children:e?t.jsxs("div",{className:"flex items-center gap-2 pl-2 min-h-10",children:[t.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>n(!0),children:t.jsx("img",{src:i,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),r&&t.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:t.jsx("span",{className:"line-clamp-2",children:(e=>{const a=e.split(" ");if(a.length<=1)return t.jsxs("span",{className:"whitespace-nowrap",children:[e," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const r=a[a.length-1],s=a.slice(0,-1).join(" ");return t.jsxs(t.Fragment,{children:[s," ",t.jsxs("span",{className:"whitespace-nowrap",children:[r," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(r)})})]}):t.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:t.jsx("button",{className:"flex items-center justify-center h-10 w-8 cursor-pointer",onClick:()=>n(!0),children:t.jsx("img",{src:ct.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})})})}),t.jsx(hc,{open:s,onOpenChange:n})]})},exports.SidebarInput=ou,exports.SidebarInset=nu,exports.SidebarLogo=Uh,exports.SidebarMenu=xu,exports.SidebarMenuAction=vu,exports.SidebarMenuBadge=yu,exports.SidebarMenuButton=bu,exports.SidebarMenuItem=fu,exports.SidebarMenuSkeleton=wu,exports.SidebarMenuSub=ju,exports.SidebarMenuSubButton=_u,exports.SidebarMenuSubItem=Nu,exports.SidebarProvider=tu,exports.SidebarRail=su,exports.SidebarSeparator=cu,exports.SidebarSkeleton=function(){return t.jsx("div",{className:"w-64 border-r bg-muted/10",children:t.jsxs("div",{className:"p-4",children:[t.jsx(hn,{className:"h-8 w-32 mb-6"}),t.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,a)=>t.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[t.jsx(hn,{className:"h-4 w-4"}),t.jsx(hn,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=ru,exports.SingleFileUpload=Ax,exports.Skeleton=hn,exports.Slider=Cu,exports.Small=xd,exports.SonnerToaster=Rs,exports.Spinner=Is,exports.SplitButton=sm,exports.Stack=qi,exports.StatusBadge=function({label:e,color:a,icon:r,showIcon:s,size:n="md",variant:o="filled",backgroundColor:i,className:l}){const c=Em[n],d=s??!!r;return t.jsxs("span",{className:_r("inline-flex items-center rounded-md font-medium whitespace-nowrap","outline"===o&&"border",c.badge,l),style:(()=>{switch(o){case"outline":return{color:a,borderColor:xr(a,.3),backgroundColor:"transparent"};case"ghost":return{color:a,backgroundColor:"transparent"};default:return{color:a,backgroundColor:i||xr(a,.1)}}})(),children:[d&&r&&t.jsx(r,{size:c.icon,strokeWidth:2}),e]})},exports.StepSelector=cm,exports.Stepper=cm,exports.StimulsoftViewer=function({reportApiUrl:e,parameters:r={},minHeight:s="80vh",...n}){const o=a.useMemo(()=>{const t=`${e}/api/reports/v1/Viewer/InitViewer`,a=new URLSearchParams(r).toString();return a?`${t}?${a}`:t},[e,r]);return t.jsx(wm,{...n,url:o,minHeight:s})},exports.Switch=Ii,exports.TIMEZONES=ar,exports.TabPageContent=function({children:e,className:a}){return t.jsx("div",{className:_r("space-y-6",a),children:e})},exports.TabPageHeader=function({title:e,description:a,actions:r,className:s}){return t.jsxs("div",{className:_r("space-y-4",s),children:[t.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),a&&t.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),r&&t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:r})]}),t.jsx(zr,{})]})},exports.TabPageLayout=function({children:e,className:a}){return t.jsx("div",{className:_r("flex flex-col h-full",a),children:t.jsx(Ai,{className:"flex-1",children:t.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=Eo,exports.TableBody=Io,exports.TableCaption=zo,exports.TableCell=Fo,exports.TableFooter=Mo,exports.TableHead=Lo,exports.TableHeader=Po,exports.TableResizeHandle=$o,exports.TableRow=Ro,exports.TableRowActions=ii,exports.TableSkeleton=Uo,exports.Tabs=$l,exports.TabsContent=Gl,exports.TabsList=Wl,exports.TabsTrigger=Hl,exports.TeamSelector=function({users:e,value:r,onChange:s,disabled:n=!1,placeholder:o="Buscar membro da equipe...",confirmRemoval:i=!0,confirmTitle:l,confirmMessage:d="Tem certeza que deseja remover este membro da equipe?",emptyMessage:u,className:m}){const{t:p}=y.useTranslation(),h=l??p("leadership_remove_team"),x=u??p("leadership_no_members"),[f,g]=a.useState(""),[b,v]=a.useState(!1),[w,j]=a.useState(null),N=a.useMemo(()=>new Set(r),[r]),_=a.useMemo(()=>e.filter(e=>N.has(e.id)),[e,N]),C=a.useMemo(()=>e.filter(e=>!N.has(e.id)).map(e=>({value:e.id,label:e.name})),[e,N]),k=a.useCallback(e=>{e&&!N.has(e)&&(s([...r,e]),g(""))},[r,s,N]),S=a.useCallback(e=>{i?(j(e),v(!0)):s(r.filter(t=>t!==e))},[r,s,i]),A=a.useCallback(()=>{w&&s(r.filter(e=>e!==w)),v(!1),j(null)},[w,r,s]);return t.jsxs("div",{className:_r("space-y-3",m),children:[t.jsx("div",{className:"flex items-start gap-3",children:t.jsx("div",{className:"flex-1",children:t.jsx(gn,{options:C,value:f,onValueChange:e=>{const t="string"==typeof e?e:e?.[0]??"";g(t),t&&k(t)},placeholder:o,searchPlaceholder:"Buscar...",disabled:n})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Selecionados"}),t.jsx("span",{className:"text-xs bg-muted text-muted-foreground rounded-full px-2 py-0.5 font-medium",children:_.length})]}),_.length>0?t.jsx("div",{className:"space-y-2",children:_.map(e=>t.jsxs("div",{className:"flex items-center border border-border rounded-lg p-2 gap-3",children:[t.jsxs(Zi,{className:"h-8 w-8 shrink-0",children:[e.avatar&&t.jsx(el,{src:e.avatar,alt:e.name}),t.jsx(tl,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium truncate",title:e.name,dangerouslySetInnerHTML:{__html:e.title||e.name}})}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.roleName&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(c.Shield,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate max-w-[120px]",children:e.roleName})]}),e.placeName&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(c.MapPin,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate max-w-[120px]",children:e.placeName})]}),t.jsx("button",{type:"button",className:_r("text-muted-foreground hover:text-destructive transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>!n&&S(e.id),title:p("remove"),children:t.jsx(c.X,{className:"h-4 w-4"})})]})]},e.id))}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[t.jsx(c.User,{className:"h-12 w-12 mb-2 opacity-30"}),t.jsx("p",{className:"text-sm",children:x})]}),t.jsx(Qr,{open:b,onOpenChange:v,children:t.jsxs(as,{className:"sm:max-w-[400px]",children:[t.jsx(rs,{children:t.jsx(os,{children:h})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:d}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"ghost",onClick:()=>v(!1),children:"Cancelar"}),t.jsx(Sr,{variant:"destructive",onClick:A,children:"Remover"})]})]})})]})},exports.TermsOfUseDialog=function({term:r,open:s,onClose:n,onAgree:o,title:i=e.t("terms_updated"),seeLaterLabel:l=e.t("terms_see_later"),agreeLabel:d=e.t("terms_read_agree"),viewTermLabel:u=e.t("terms_view")}){const[m,p]=a.useState(!1),h=a.useCallback(()=>{o(r.id)},[o,r.id]);return t.jsxs(t.Fragment,{children:[t.jsx(Qr,{open:s&&!m,onOpenChange:e=>!e&&n(),children:t.jsxs(as,{className:"sm:max-w-md",children:[t.jsx(rs,{children:t.jsxs(os,{className:"flex items-center gap-2",children:[t.jsx(c.ShieldCheck,{className:"h-5 w-5 text-primary"}),i]})}),t.jsxs("div",{className:"space-y-4",children:[r.description&&t.jsx(Ai,{className:"max-h-48",children:t.jsx("div",{className:"text-sm text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:r.description}})}),r.file&&t.jsxs(Sr,{variant:"link",className:"px-0 text-primary",onClick:()=>p(!0),children:[t.jsx(c.ExternalLink,{className:"mr-1 h-4 w-4"}),u]})]}),t.jsxs(ns,{className:"gap-2 sm:gap-0",children:[t.jsx(Sr,{variant:"ghost",onClick:n,children:l}),t.jsx(Sr,{onClick:h,children:d})]})]})}),m&&t.jsx(jm,{term:r,open:m,onClose:()=>p(!1),viewOnly:!0})]})},exports.TermsOfUseViewer=jm,exports.TextPanel=Np,exports.Textarea=Ts,exports.Timepicker=lm,exports.Toaster=Rs,exports.Toggle=mi,exports.ToggleGroup=hi,exports.ToggleGroupItem=xi,exports.TokenManager=$n,exports.TokenService=Rn,exports.Tooltip=Js,exports.TooltipContent=en,exports.TooltipProvider=Xs,exports.TooltipTrigger=Zs,exports.TreeSelect=Nn,exports.TreeTable=function({data:r,columns:s,nameKey:n,nameHeader:o=e.t("ap_name"),iconComponent:i,expandedIds:l,onToggleExpand:d,onRowClick:u,renderActions:m,actionsHeader:p="",rowActionsVariant:h="default",isLoading:x,emptyMessage:f="Nenhum registro encontrado.",className:g,enableSelection:b,selectedIds:v,onSelectItem:y,onSelectAll:w,isAllSelected:j,enableRowDrag:N,onMoveNode:_,onMoveNodes:C,rootDropLabel:k,actionsWidth:S=20,nameMinWidth:A=200}){const[T,D]=a.useState(null),[E,P]=a.useState(null),[I,M]=a.useState(!1),[R,L]=a.useState(1),F=a.useRef(null),z=a.useRef([]),U=a.useRef(null),O=a.useMemo(()=>new Set(v??[]),[v]),B=a.useMemo(()=>{if(!T||!r)return new Set;const e=z.current.length>0?z.current:[T],t=function(e,t){const a=new Set;for(const r of t)Sh(e,r).forEach(e=>a.add(e));return a}(r,e);return e.forEach(e=>t.add(e)),t},[T,r]),q=a.useRef(B);q.current=B;const V=a.useCallback(()=>{F.current=null,z.current=[],U.current=null,D(null),P(null),M(!1),L(1)},[]),$=a.useCallback((e,t)=>{e.length>1&&C?C(e,t):1===e.length&&_?.(e[0],t)},[_,C]),W=a.useCallback((e,t)=>{const a=O.has(e)&&O.size>1?Array.from(O):[e];F.current=e,z.current=a,U.current=null,D(e),L(a.length),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e),t.dataTransfer.setData("application/x-tree-ids",JSON.stringify(a))},[O]),H=a.useCallback((e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move",q.current.has(e)?P(null):(U.current=e,P(e))},[]),G=a.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation();const a=q.current.has(e)?U.current:e;if(!a)return void V();let r=z.current;if(0===r.length){try{const e=t.dataTransfer.getData("application/x-tree-ids");if(e){const t=JSON.parse(e);Array.isArray(t)&&t.length>0&&(r=t)}}catch{}if(0===r.length){const e=t.dataTransfer.getData("text/plain");e&&(r=[e])}}0===r.length||r.includes(a)||$(r,a),V()},[$,V]),K=a.useCallback(e=>{e.preventDefault(),e.stopPropagation();let t=z.current;if(0===t.length){try{const a=e.dataTransfer.getData("application/x-tree-ids");if(a){const e=JSON.parse(a);Array.isArray(e)&&e.length>0&&(t=e)}}catch{}if(0===t.length){const a=e.dataTransfer.getData("text/plain");a&&(t=[a])}}0!==t.length?($(t,null),V()):V()},[$,V]),Y=a.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",M(!0)},[]),Q=a.useCallback(e=>{N&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[N]),X=a.useCallback(e=>{if(!N)return;const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-tree-row-id]"),a=t?.dataset?.treeRowId??U.current;a&&G(a,e)},[N,G]);if(x)return t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!r||0===r.length)return t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[t.jsx(c.User,{className:"h-10 w-10 text-muted-foreground/50"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:f})]});const J=null!==T;return t.jsxs("div",{className:_r("border rounded-lg overflow-hidden relative",g),onDragOver:Q,onDrop:X,onDragLeave:N?e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(P(null),M(!1))}:void 0,children:[N&&J&&t.jsx(Dh,{onDrop:K,isDragOver:I,onDragOver:Y,onDragLeave:()=>M(!1),label:k}),t.jsxs(Eo,{children:[t.jsx(Po,{children:t.jsxs(Ro,{children:[t.jsx(Lo,{className:"text-left",style:{minWidth:A},children:t.jsxs("div",{className:"flex items-center gap-2",children:[b&&t.jsx(As,{checked:j??!1,onCheckedChange:()=>w?.()}),o]})}),s.map(e=>t.jsx(Lo,{className:_r("text-center",e.className),style:e.width?{width:e.width}:void 0,children:e.header},String(e.key))),m&&t.jsx(Lo,{className:"text-right",style:{width:S},children:p})]})}),t.jsx(Io,{children:r.map(e=>t.jsx(Th,{item:e,level:0,columns:s,nameKey:n,iconComponent:i,expandedIds:l,onToggleExpand:d,onRowClick:u,renderActions:m,rowActionsVariant:h,enableSelection:b,selectedIds:O,onSelectItem:y,enableRowDrag:N,draggedId:T,dragOverId:E,onDragStartCell:W,onDragEndCell:V,onDragOverCell:H,onDropCell:G,dragCount:R},e.id))})]})]})},exports.TruncatedCell=Vo,exports.UpdatesBar=ax,exports.UpdatesDialog=cx,exports.UpdatesNotification=pm,exports.UserUpdatesViewer=hx,exports.UsersGroupsSelector=function({users:r,groups:s=[],value:n,onChange:o,disabled:i=!1,maxHeight:l=350,hideGroupFilter:d=!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:b}){const[v,y]=a.useState(!1),[w,j]=a.useState(""),[N,_]=a.useState(void 0),C=a.useMemo(()=>new Set(n),[n]),k=a.useMemo(()=>{let e=r;if(N&&(e=e.filter(e=>e.groupIds?.includes(N))),w){const t=_m(w);e=e.filter(e=>_m(e.name).includes(t)||_m(e.email??"").includes(t))}return e},[r,N,w]),S=a.useMemo(()=>v?k:r.filter(e=>C.has(e.id)),[v,k,r,C]),A=n.length,T=a.useMemo(()=>k.length>0&&k.every(e=>C.has(e.id)),[k,C]),D=a.useCallback(e=>{if(i)return;const t=C.has(e)?n.filter(t=>t!==e):[...n,e];o(t)},[n,C,o,i]),E=a.useCallback(e=>{if(i)return;const t=new Set(k.map(e=>e.id));if(e){const e=new Set([...n,...t]);o(Array.from(e))}else o(n.filter(e=>!t.has(e)))},[n,k,o,i]),P=a.useCallback(()=>{y(e=>!e),j(""),_(void 0)},[]);return t.jsxs("div",{className:_r("rounded-md border bg-muted/30",b),children:[(!i||A>0)&&t.jsxs("div",{className:_r("flex items-center justify-between px-4 py-2",!i&&"cursor-pointer hover:bg-muted/50"),onClick:i?void 0:P,children:[t.jsx("span",{className:"text-sm font-medium text-primary uppercase",children:!i&&(v?p:m)}),t.jsx("span",{className:"text-xs text-muted-foreground",children:A>0&&`${A} ${1===A?f:g}`})]}),t.jsxs("div",{className:"px-4 pb-3",children:[v&&t.jsxs("div",{className:"flex gap-3 mb-3",children:[!d&&s.length>0&&t.jsxs(bs,{value:N??"__all__",onValueChange:e=>_("__all__"===e?void 0:e),children:[t.jsx(ws,{className:"w-[200px] h-9 text-sm",children:t.jsx(ys,{placeholder:e.t("approval_user_group")})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"__all__",children:e.t("team_all_groups")}),s.map(e=>t.jsx(ks,{value:e.id,children:e.name},e.id))]})]}),t.jsxs("div",{className:"relative flex-1",children:[t.jsx(c.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{className:"pl-8 h-9 text-sm",placeholder:u,value:w,onChange:e=>j(e.target.value)})]})]}),!v&&0===A&&t.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:[t.jsx(c.Users,{className:"h-4 w-4 mr-2"}),x]}),v&&k.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(As,{checked:T,onCheckedChange:e=>E(!!e)}),t.jsx("span",{className:"text-sm",children:h})]}),S.length>0&&t.jsx(Ai,{style:{maxHeight:l},className:"pr-2",children:t.jsx("div",{className:"space-y-0.5",children:S.map(e=>t.jsxs("div",{className:_r("flex items-center gap-3 rounded-md bg-background px-3 py-2 text-sm",v&&!i&&"cursor-pointer hover:bg-accent/50"),onClick:v?()=>D(e.id):void 0,children:[v&&t.jsx(As,{checked:C.has(e.id),onCheckedChange:()=>D(e.id),onClick:e=>e.stopPropagation()}),t.jsxs(Zi,{className:"h-8 w-8 shrink-0",children:[e.avatar&&t.jsx(el,{src:e.avatar,alt:e.name}),t.jsx(tl,{className:"text-xs",children:Nm(e.name)})]}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"font-normal truncate",children:e.name}),e.email&&t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})}),v&&0===k.length&&t.jsx("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:"Nenhum usuário encontrado"})]})]})},exports.VideoEditor=function({value:r,onChange:s,onSubmit:n,onCancel:o,uploadFunction:i,deleteFunction:d,uploadOptions:u}){const{t:m}=y.useTranslation(),[p,h]=a.useState(r||{inputType:"url",controls:!0}),x=a.useRef(null),f=a.useRef(null),{upload:g,uploading:b}=Nx({uploadFunction:i,deleteFunction:d,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:w}=Nx({uploadFunction:i,deleteFunction:d,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),j=a.useMemo(()=>lx(p.videoUrl||ix(p.embedCode)||""),[p.videoUrl,p.embedCode]),N=(e,t)=>{const a={...p,[e]:t};h(a),s(a)};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:m("input_type")}),t.jsxs(bs,{value:p.inputType||"url",onValueChange:e=>N("inputType",e),children:[t.jsx(ws,{children:t.jsx(ys,{})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"url",children:"URL"}),t.jsx(ks,{value:"upload",children:m("file_upload")}),t.jsx(ks,{value:"embed",children:m("embed_code")})]})]})]}),"upload"===p.inputType&&i&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Arquivo"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{ref:x,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||t.name.replace(/\.[^/.]+$/,"")};h(a),s(a)}catch(a){}finally{x.current&&(x.current.value="")}},className:"hidden"}),t.jsx(Sr,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:b,children:b?t.jsxs(t.Fragment,{children:[t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),p.videoFile&&t.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&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:m("embed_code")}),t.jsx(Ts,{placeholder:m("paste_embed_code"),value:p.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Thumbnail"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Tr,{type:"url",placeholder:"URL da thumbnail",value:p.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),t.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await v(t),a={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(a),s(a)}catch(a){}finally{f.current&&(f.current.value="")}},className:"hidden"}),t.jsx(Sr,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:w,children:w?t.jsxs(t.Fragment,{children:[t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),p.thumbnailFile&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",p.thumbnailFile]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"title",children:"Título"}),t.jsx(Tr,{id:"title",placeholder:m("video_title"),value:p.title||"",onChange:e=>N("title",e.target.value)})]}),t.jsxs("div",{className:"flex gap-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:"autoplay",checked:p.autoplay||!1,onCheckedChange:e=>N("autoplay",!0===e)}),t.jsx(Er,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:"controls",checked:!1!==p.controls,onCheckedChange:e=>N("controls",!0===e)}),t.jsx(Er,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Preview"}),t.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=p.videoUrl||ix(p.embedCode)||"";if(!a)return t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===j)return t.jsxs("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[t.jsx("source",{src:a}),"Seu navegador não suporta este vídeo."]});const r="youtube"===j?sx(a,p.autoplay):ox(a,p.autoplay);return t.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:t.jsx("iframe",{title:p.title||e.t("video"),src:r,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[t.jsx(Sr,{variant:"outline",onClick:o,children:"Cancelar"}),t.jsx(Sr,{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:a,className:r="",style:s}){const n=a.videoUrl||ix(a.embedCode)||"";if(!n)return null;const o=lx(n);return t.jsx(Pr,{className:`overflow-hidden my-4 ${r}`,style:s,children:t.jsxs(Lr,{className:"p-0",children:["file"===o?t.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[t.jsx("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):t.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:t.jsx("iframe",{title:a.title||e.t("video"),src:"youtube"===o?sx(n,a.autoplay):ox(n,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&t.jsx("div",{className:"p-4",children:t.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.ViewerDialog=function({open:e,onOpenChange:r,template:s,viewerType:n,isLoading:o=!1,enableDownload:i=!0,onDownload:l,isDownloading:d=!1,enableFavorite:u=!1,isFavorite:m=!1,onFavorite:p,isFavoriting:h=!1,enableConfirmReading:x=!1,readingConfirmationDate:f,onConfirmReading:g,isConfirmingReading:b=!1,readingConfirmationTimeRemaining:v,onIframeLoad:w,className:j}){const{t:N}=y.useTranslation(),_=a.useRef(null),C=n??gm(s.extension),k=d||b||h,S=s.code?`${s.code} – ${s.name}`:s.name,A=a.useCallback(()=>{_.current&&w&&w(_.current)},[w]);return a.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&r(!1)};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[e,r]),t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:_r("max-w-[95vw] max-h-[95vh] p-6 gap-0 [&>button.absolute]:hidden",(4===C||6===C)&&"w-[90vw]",j),children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 min-h-[35px]",children:[o?t.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):t.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-200px)]",children:S}),t.jsxs("div",{className:"flex items-center gap-1 ml-4 z-20",children:[!o&&t.jsxs(t.Fragment,{children:[(x||f)&&t.jsx(t.Fragment,{children:f?t.jsxs("div",{className:"flex flex-col mr-2.5",children:[t.jsxs("span",{className:"text-sm font-medium flex items-center gap-1 text-foreground",children:[t.jsx(c.CheckCheck,{className:"h-4 w-4"}),"Leitura confirmada"]}),t.jsx("span",{className:"text-xs text-muted-foreground ml-5",children:f.toLocaleDateString()})]}):null!=v&&v>0?t.jsxs("div",{className:"flex items-center gap-1 mr-2.5 text-sm text-muted-foreground",children:[t.jsx("span",{children:N("terms_confirmation_available")}),t.jsx("span",{className:"font-medium min-w-[72px]",children:ym(v)}),t.jsx("span",{children:"segundos"})]}):t.jsxs(Sr,{variant:"default",size:"sm",disabled:k,onClick:()=>g?.(),className:"mr-2.5",children:[t.jsx(c.ShieldCheck,{className:"h-4 w-4 mr-1"}),b?"Confirmando...":N("terms_confirm_reading")]})}),0!==C&&u&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>p?.(m),children:t.jsx(c.Star,{className:_r("h-4 w-4",m&&"fill-accent text-accent")})})}),t.jsx(en,{children:m?"Desfavoritar":"Favoritar"})]}),0!==C&&i&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>l?.(),children:t.jsx(c.Download,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Download"})]})]}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>r(!1),children:t.jsx(c.X,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Fechar"})]})]})]}),t.jsx("div",{className:_r("flex flex-col items-center justify-center min-h-[160px] w-full",o&&"relative -top-5",0===C&&"min-h-[124px]",1===C&&"max-h-[85vh]",(4===C||6===C)&&"min-w-[77vw] min-h-[80vh]"),children:o?t.jsx(Is,{className:"h-14 w-14"}):t.jsxs(t.Fragment,{children:[(0===C||!s.url)&&t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-base text-foreground mb-1",children:"Extensão não suportada para visualização."}),t.jsx("b",{className:"text-base text-foreground",children:"Deseja fazer o download do arquivo?"})]}),1===C&&t.jsx("img",{loading:"eager",src:s.url,alt:s.name,className:"max-w-full max-h-[85vh] object-contain"}),2===C&&t.jsx("video",{controls:!0,autoPlay:!0,src:s.url,className:"w-full h-full"}),3===C&&t.jsx("audio",{controls:!0,autoPlay:!0,src:s.url}),(4===C||6===C)&&t.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[t.jsx(Is,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),t.jsx("iframe",{ref:_,src:s.url,onLoad:A,className:"border-none w-full h-full z-[1] relative",title:s.name})]})]})}),!o&&0===C&&t.jsxs("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-border",children:[t.jsx(Sr,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),i&&t.jsx(Sr,{variant:"default",onClick:()=>l?.(),children:"Download"})]})]})})},exports.VisualizationType=Xm,exports.addAppTranslations=_l,exports.addChild=sh,exports.addSibling=nh,exports.aliasSchema=vx,exports.appRedirectUrl=Ue,exports.applyFavicon=mt,exports.assets=ct,exports.badgeVariants=Ds,exports.brandLogos=it,exports.buildModuleUrl=br,exports.buildPlacesTree=function(e){e.forEach(t=>{t.children=e.filter(e=>e.parentId===t.id)});const t=e.filter(e=>!e.parentId);return function e(t,a){t?.forEach(t=>{a(t),t.children&&e(t.children,a)})}(t,t=>{t.children=e.filter(e=>e.parentId===t.id)}),t},exports.buildQualiexHeaders=sl,exports.buildWopiUrl=function(e){const{t:t}=y.useTranslation(),{viewerUrl:a,wopiUrl:r,fileId:s,token:n,extension:o,language:i="pt-br"}=e,l=vm(o);return l?`${a}${l}ui=${i}&rs=${i}&access_token=${n}&WOPISrc=${encodeURIComponent(`${r}${s}`)}`:null},exports.buttonGroupVariants=Rc,exports.buttonVariants=kr,exports.calculateAspectRatio=_x,exports.cn=_r,exports.configureBrandAssets=function(e){nt={...nt,...e,logos:{...nt.logos,...e.logos}}},exports.configureEnvironment=function(e){Pe={...Pe,...e,oauth:{...Pe.oauth,...e.oauth}}},exports.createCrudPage=function(e){return({manager:a})=>{const{manager:r,config:s,onSave:n,onEdit:o,onToggleStatus:i}=e,l=a??r,c={entityName:s.entityName,entityNamePlural:s.entityNamePlural,filters:s.filters||[],columns:s.columns,cardFields:s.cardFields||[],enableBulkActions:s.enableBulkActions??!1,bulkActions:s.bulkActions||[],customActions:s.customActions,customRowActions:s.customRowActions,customListView:s.customListView,onEdit:o||s.onEdit,onNew:s.onNew,useCustomRouting:s.useCustomRouting,hideNewButton:s.hideNewButton,showNewButton:s.showNewButton,newButtonLabel:s.newButtonLabel,showSearch:s.showSearch,searchPlaceholder:s.searchPlaceholder,showActionBar:s.showActionBar};return t.jsx($i,{manager:l,config:c,formSections:s.formSections,onSave:n,onToggleStatus:i,defaultSort:s.defaultSort,readOnly:s.readOnly})}},exports.createCrudRoutingConfig=function(e,t){const a=Eh({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createMindMapNode=Zp,exports.createRoutingHandlers=Eh,exports.createService=vo,exports.createSimpleSaveHandler=function(e,t,a){return r=>{if(r.id){const t=a(r);e.updateEntity(r.id,t)}else{const a=t(r);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=vo({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment??!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,r)=>Ao({queryKey:e.tableName,service:t,entityName:e.entityName,additionalFilters:a,onSuccess:r})}},exports.createStatusConfig=function(e){return t=>e[t]},exports.createTranslatedMessages=t=>({success:{created:t=>e.t("msg_created_success",`${t} criado com sucesso`).replace("{{entity}}",t),updated:t=>e.t("msg_updated_success",`${t} atualizado com sucesso`).replace("{{entity}}",t),deleted:t=>e.t("msg_deleted_success",`${t} removido com sucesso`).replace("{{entity}}",t)},error:{create:t=>e.t("msg_create_error",`Erro ao criar ${t}`).replace("{{entity}}",t),update:t=>e.t("msg_update_error",`Erro ao atualizar ${t}`).replace("{{entity}}",t),delete:t=>e.t("msg_delete_error",`Erro ao remover ${t}`).replace("{{entity}}",t),load:t=>e.t("msg_load_error",`Erro ao carregar ${t}`).replace("{{entity}}",t)}}),exports.currencyFormatter=mp,exports.debounce=(e,t)=>{let a;return(...r)=>{clearTimeout(a),a=setTimeout(()=>e(...r),t)}},exports.deriveEmailField=mo,exports.deriveNameField=uo,exports.deriveUsernameField=po,exports.detectBrowserLocale=lr,exports.detectBrowserPreferences=()=>{const e=lr();return{locale:e,timezone:cr(),datetimeFormat:dr(e)}},exports.detectBrowserTimezone=cr,exports.detectVideoProvider=lx,exports.documentsFilesApi=Mx,exports.emailSchema=bx,exports.emailService=gx,exports.errorService=Gn,exports.exportMindMap=Nh,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractNumberFromCurrency=function(e){const t=e.replace(/[^\d,.-]/g,"").replace(/\./g,"").replace(",",".");return parseFloat(t)},exports.extractVimeoId=nx,exports.extractYouTubeId=rx,exports.findDatetimeFormat=e=>tr.find(t=>t.value===e),exports.findLocale=e=>er.find(t=>t.value===e),exports.findNode=eh,exports.findTimezone=e=>ar.find(t=>t.value===e),exports.formatBytes=kx,exports.formatCurrency=(e,t="BRL",a="pt-BR")=>null==e?"":new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=pr,exports.formatDatetime=mr,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,t,a={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],s={key:e,header:Hi(e),label:Hi(e),...Wi(e,a),sortable:!0,searchable:"string"==typeof a};r.push(s)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.generateId=vr,exports.generateNodeId=Jp,exports.generatePastelBg=xr,exports.getAppBasePath=Oe,exports.getAppEnv=Ee,exports.getBackendMode=function(){return Re},exports.getCommonBaseUrl=al,exports.getCommonV4AppUrl=Xe,exports.getCommonV5AppUrl=Je,exports.getContrastRatio=function(e,t){const a=fr(e),r=fr(t);return(Math.max(a,r)+.05)/(Math.min(a,r)+.05)},exports.getDefaultPanelSize=function(e){switch(e){case Bm.Bar:case Bm.Column:case Bm.Pie:case Bm.List:case Bm.Line:case Bm.Area:case Bm.Text:case Bm.StackedColumn:return{x:4,y:2};case Bm.Pareto:case Bm.RiskMatrix:case Bm.Burndown:case Bm.PerformanceColumns:return{x:8,y:2};case Bm.Numeric:return{x:1,y:1};default:return{x:2,y:2}}},exports.getDocumentsApiUrl=Ke,exports.getEnvironmentConfig=Ie,exports.getFieldValue=Ux,exports.getFileExtension=Sx,exports.getFormFieldValues=function(e){return e.filter(e=>1!==e.type).map(e=>({formFieldAssociationId:e.id,textValue:2===e.type?e.textValue:void 0,numberValue:6===e.type?e.numberValue:void 0,dateValue:3===e.type?e.dateValue:void 0,timeValue:4===e.type?e.timeValue:void 0,itemsValue:[5,7,8].includes(e.type)?e.itemsValue:void 0,questionsValue:9===e.type?e.questionsValue:void 0}))},exports.getIdentApiUrlOverride=Ye,exports.getIdentBaseUrl=function(){const e=Ye();if(e)return e;const t=al().match(/^https?:\/\/common-v4-api(-[^.]+)?\.(.+)$/);if(t){return`https://ident-api${t[1]||""}.${t[2]}`}return"https://ident-api.qualiex.com"},exports.getLinkFromRow=cp,exports.getLoginApiUrlOverride=Qe,exports.getLuminance=fr,exports.getMinPanelSize=Lp,exports.getOnlineViewerType=function(e){const{t:t}=y.useTranslation();return{".gdocs":"document",".gsheets":"spreadsheets"}[e.toLowerCase()]||"document"},exports.getQualiexApiUrl=Ge,exports.getSecurityMode=function(){return wc},exports.getSupabaseClient=to,exports.getUserProfile=pl,exports.getViewerType=gm,exports.getWopiViewer=vm,exports.handleExternalLink=gr,exports.importMindMap=function(e){return _h(JSON.parse(e))},exports.inferDatetimeFormat=dr,exports.inputGroupAddonVariants=ad,exports.inputGroupButtonVariants=sd,exports.isCurrency=function(e){return!!up.test(e)&&!isNaN(parseFloat(e.replace(/,/g,"")))},exports.isDevEnv=Me,exports.isDevEnvironment=He,exports.isImageUrl=function(e){const t=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const a=new URL(e);return t.some(e=>a.pathname.toLowerCase().endsWith(e))}catch{const a=e.toLowerCase();return t.some(e=>a.endsWith(e))}},exports.isLovablePreview=$e,exports.isNullOrEmptyField=function(e){return null==e?.value||""===e.value.trim()},exports.isSupabaseBackend=Fe,exports.isSupabaseConfigured=function(){return null!==Jn()},exports.isValidDatetimeFormat=e=>tr.some(t=>t.value===e),exports.isValidLocale=or,exports.isValidTimezone=ir,exports.loadForlogicFonts=vc,exports.logoSrc=dt,exports.markUpdateVisualized=Jh,exports.mergeTranslationFiles=function(...e){return Object.assign({},...e)},exports.moveNode=ih,exports.navigationMenuTriggerStyle=Nd,exports.normalizeVideoUrl=function(e,t,a){switch(t||lx(e)){case"youtube":return sx(e,a);case"vimeo":return ox(e,a);default:return e}},exports.normalizeVimeoUrl=ox,exports.normalizeYouTubeUrl=sx,exports.paginationSchema=jx,exports.parseIframeSrc=ix,exports.processUrl=lp,exports.qualiexApi=co,exports.qualiexFetch=nl,exports.removeNode=oh,exports.resizeKeepingAspect=function(e,t,a,r){const s=_x(e,t);return a&&!r?{width:a,height:Math.round(a/s)}:r&&!a?{width:Math.round(r*s),height:r}:{width:e,height:t}},exports.resolveBrandLogo=lt,exports.resolveFieldMappings=ho,exports.resolvePageTitle=Fh,exports.safeStringSchema=(e=1e3)=>J.z.string().trim().max(e,`Texto excede ${e} caracteres`).refine(e=>!/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/.test(e),"Contém caracteres inválidos"),exports.sanitizeErrorMessage=Nr,exports.setBackendMode=Le,exports.setCollapsedAll=ch,exports.setFormFieldValues=function(e,t){return t?.length?e.map(e=>{const a=t.find(t=>t.formFieldAssociationId===e.id);if(!a)return e;const r={...e};switch(e.type){case 2:r.textValue=a.textValue;break;case 6:r.numberValue=a.numberValue;break;case 3:r.dateValue=a.dateValue;break;case 4:r.timeValue=a.timeValue;break;case 5:case 7:case 8:r.itemsValue=a.itemsValue||[];break;case 9:r.questionsValue=a.questionsValue||[]}return r}):e},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new j.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.shouldShowField=Ox,exports.shouldUseDevTokens=We,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=ut,exports.sortByMonthYear=function(e){return e?.sort((e,t)=>{if(!e?.items?.length||!t?.items?.length)return 0;return ip(e.items[0]?.keyDate)-ip(t.items[0]?.keyDate)})},exports.stripTechHeaders=function(e){if(!e||"object"!=typeof e)return e;const t={...e};for(const a of yr)delete t[a];return t},exports.timestampId=()=>Date.now().toString(),exports.toQueryString=function(e){return e?dp(e).join("&"):null},exports.toRouterPath=Be,exports.toggleCollapsed=lh,exports.toggleVariants=ui,exports.trackFooterClick=oc,exports.trackInterestClick=nc,exports.trackModuleClick=sc,exports.trimTextFields=Cr,exports.updateUserProfile=dl,exports.uploadUserPhoto=ol,exports.useActiveModules=(e={})=>{const{enabled:t=!0}=e,{alias:a}=So();return j.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=to(),{data:t,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(r){if(!oo.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!a})},exports.useAliasFromUrl=Gi,exports.useAuth=So,exports.useBaseForm=_i,exports.useClarity=yc,exports.useColumnManager=vi,exports.useColumnResize=di,exports.useCrud=Ao,exports.useDebounce=zh,exports.useDerivedContractedModules=pc,exports.useFormField=ds,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Gh();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Fl(),a=sr;return{formatDatetime:r=>mr(r,a,t,e),formatDate:a=>pr(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useIsMobile=Do,exports.useLocale=Fl,exports.useMediaQuery=To,exports.useMediaUpload=Nx,exports.useModalState=Gh,exports.useModuleAccess=Dl,exports.useModuleConfig=Sl,exports.useNavigation=Lh,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:r}=vl(),s=a.useRef({});a.useEffect(()=>{const a=JSON.stringify(s.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(s.current.title!==e.title||s.current.subtitle!==e.subtitle||a)&&(s.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},t(e)),()=>r()},[e.title,e.subtitle,e.breadcrumbs,t,r])},exports.usePageMetadataContext=vl,exports.usePageTitle=function(){const e=N.useLocation(),{navigation:t}=Lh();return Fh(t,e.pathname)},exports.usePermissionQuery=Bh,exports.useQualiexReady=Qh,exports.useQualiexUsers=Mi,exports.useRouteBreadcrumbs=function(){const e=N.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,s)=>{r+=`/${e}`;const n=s===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:r,isCurrentPage:n})}),a})()},exports.useRowResize=function({rowIds:e,defaultHeight:t=48,minHeight:r=32,maxHeight:s=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,c]=a.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[d,u]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{i&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[i,l,t]);a.useEffect(()=>{if(!d||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(r,Math.min(s,x.current+t));c(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&c(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[d,m,r,s,n,o]),a.useEffect(()=>(d?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d]);const b=a.useCallback(()=>{c({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:d,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}},exports.useSidebar=eu,exports.useSidebarResize=Wh,exports.useUpdatesNotification=mm,exports.useUserUpdatesBar=ex,exports.useUserUpdatesDialog=tx,exports.useWizard=function(e){const{steps:t,initialStep:r=0,initialData:s={},onComplete:n,onCancel:o}=e,[i,l]=a.useState(r),[c,d]=a.useState(s),[u,m]=a.useState(!1),[p,h]=a.useState(!1),x=t.length,f=0===i,g=i===x-1,b=t[i],v=x>1?(i+1)/x*100:100,y=a.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),w=a.useMemo(()=>y(),[y,c]),j=a.useMemo(()=>!f&&!b?.disableBack,[f,b]),N=a.useCallback(e=>{d(t=>({...t,...e}))},[]),_=a.useCallback((e,t)=>{d(a=>({...a,[e]:t}))},[]),C=a.useCallback(()=>{l(r),d(s),m(!1),h(!1),o?.()},[r,s,o]),k=a.useCallback(async()=>{if(y()&&!p){h(!0);try{await(n?.(c))}finally{h(!1)}}},[y,p,c,n]),S=a.useCallback(async()=>{y()&&!u&&(g?await k():l(e=>Math.min(e+1,x-1)))},[y,u,g,x,k]),A=a.useCallback(()=>{j&&!u&&l(e=>Math.max(e-1,0))},[j,u]),T=a.useCallback(e=>{e<0||e>=x||u||(e<=i||e===i+1)&&l(e)},[i,x,u]),D=a.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:c,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:A,goTo:T,canProceed:w,canGoBack:j,setData:N,updateField:_,reset:C,complete:k,setLoading:D,progress:v,stepIndex:i,totalSteps:x}},exports.userIdSchema=wx,exports.uuidSchema=yx,exports.validateFields=function(e){const t=[];return e.forEach(e=>{if(!e.required||e.readOnly||1===e.type)return;const a=Ux(e);if((null==a||""===a||Array.isArray(a)&&0===a.length)&&t.push(e.id),6===e.type&&null!=a){const r=e.config;null!=r?.min&&a<r.min&&t.push(e.id),null!=r?.max&&a>r.max&&t.push(e.id)}}),{valid:0===t.length,invalidFields:[...new Set(t)]}};
|
|
1
|
+
"use strict";var e=require("i18next"),t=require("react/jsx-runtime"),a=require("react"),r=require("@radix-ui/react-slot"),s=require("class-variance-authority"),n=require("clsx"),o=require("tailwind-merge"),i=require("date-fns"),l=require("sonner"),c=require("lucide-react"),d=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"),b=require("@radix-ui/react-tooltip"),v=require("@radix-ui/react-popover"),y=require("react-i18next"),w=require("@supabase/supabase-js"),j=require("@tanstack/react-query"),N=require("react-router"),_=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"),A=require("@radix-ui/react-switch"),T=require("@radix-ui/react-avatar"),D=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-tabs"),P=require("@radix-ui/react-accordion"),I=require("react-day-picker"),M=require("vaul"),R=require("@radix-ui/react-hover-card"),L=require("@radix-ui/react-navigation-menu"),F=require("@radix-ui/react-progress"),z=require("@radix-ui/react-radio-group"),U=require("react-resizable-panels"),O=require("@radix-ui/react-slider"),B=require("@radix-ui/react-menubar"),q=require("recharts"),V=require("@tiptap/react"),$=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),K=require("@tiptap/extension-color"),Y=require("@tiptap/extension-highlight"),Q=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),J=require("zod"),Z="undefined"!=typeof document?document.currentScript:null;function ee(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var te=ee(a),ae=ee(c),re=ee(d),se=ee(u),ne=ee(m),oe=ee(p),ie=ee(x),le=ee(f),ce=ee(g),de=ee(b),ue=ee(v),me=ee(_),pe=ee(C),he=ee(k),xe=ee(S),fe=ee(A),ge=ee(T),be=ee(D),ve=ee(E),ye=ee(P),we=ee(R),je=ee(L),Ne=ee(F),_e=ee(z),Ce=ee(U),ke=ee(O),Se=ee(B),Ae=ee(q);const Te={storageProjectId:"ccjfvpnndclajkleyqkc",supabaseProjectId:"ccjfvpnndclajkleyqkc",supabaseUrl:"https://ccjfvpnndclajkleyqkc.supabase.co",supabasePublishableKey:"sb_publishable_w-TKU0hE4bjM_uOgt3fK1g_ewrXKJ8J",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",logoutUrl:"https://login.qualiex.com/oauth2/logout",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20",responseType:"id_token token",scope:"openid profile email"},qualiexApiUrl:"https://common-v4-api.qualiex.com",documentsApiUrl:"https://documents-v4-api.qualiex.com",identApiUrl:"",loginApiUrl:"",appBasePath:"",commonV4AppUrl:"https://apps4.qualiex.com/common/",commonV5AppUrl:"https://apps5.qualiex.com/common/"},De={storageProjectId:"ccjfvpnndclajkleyqkc",supabaseProjectId:"tskpcuganynhsppzoqgj",supabaseUrl:"https://tskpcuganynhsppzoqgj.supabase.co",supabasePublishableKey:"sb_publishable_2EIWdYocxgrN4t_f64Ms3g_pKRcbHfL",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",logoutUrl:"https://login-dev.qualiex.com/oauth2/logout",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20",responseType:"id_token token",scope:"openid profile email"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com",documentsApiUrl:"https://documents-v4-api-dev.qualiex.com",identApiUrl:"",loginApiUrl:"",appBasePath:"",commonV4AppUrl:"https://apps4-dev.qualiex.com/common/",commonV5AppUrl:"https://apps5-dev.qualiex.com/common/"};function Ee(){return"DEV"===(void 0).VITE_APP_ENV?"DEV":"PROD"}let Pe={};function Ie(){const e="DEV"===Ee()?De:Te;return{...e,...Pe,oauth:{...e.oauth,...Pe.oauth}}}function Me(){return"DEV"===Ee()}let Re="supabase";function Le(e){Re=e}function Fe(){return"supabase"===Re}const ze={get oauth(){const e=Ie();return{authUrl:e.oauth.authUrl,logoutUrl:e.oauth.logoutUrl,clientId:e.oauth.clientId,responseType:e.oauth.responseType,scope:e.oauth.scope}}};function Ue(e){const t=Ie().appBasePath||"";return`${window.location.origin}${t}${e}`}function Oe(){return Ie().appBasePath||""}function Be(e){const t=Oe();return t&&e.startsWith(t)?e.slice(t.length)||"/":e}const qe={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Ve={debounceDelay:500},$e=()=>{const e=window.location.origin,t=(()=>{try{return window.self!==window.top}catch{return!0}})();return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("lovable.dev")||e.includes("lovable.app")&&t||(void 0).DEV},We=()=>$e()&&Fe(),He=$e,Ge=()=>Ie().qualiexApiUrl,Ke=()=>Ie().documentsApiUrl,Ye=()=>Ie().identApiUrl,Qe=()=>Ie().loginApiUrl,Xe=()=>Ie().commonV4AppUrl,Je=()=>Ie().commonV5AppUrl,Ze={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},et={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},tt={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}`}},at="https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets",rt={qualiex:`${at}/logo-qualiex-white.svg`,qualitfy:`${at}/logo-qualitfy-white.svg`,metroex:`${at}/logo-metroex-white.svg`,qualiexSmall:`${at}/logo-forlogic-white.svg`,saber:`${at}/saber-gestao-white.png`,saberSmall:`${at}/small.svg`},st=`${at}/favicon.png`;let nt={};function ot(e){return nt.logos?.[e]??rt[e]}const it={get qualiex(){return ot("qualiex")},get qualitfy(){return ot("qualitfy")},get metroex(){return ot("metroex")},get saber(){return ot("saber")},get qualiexSmall(){return ot("qualiexSmall")},get saberSmall(){return ot("saberSmall")}};function lt(e){return ot(et.isQualiex?e?.isMetroex?"metroex":e?.isQualitfy?"qualitfy":"qualiex":"saber")}const ct={get logo(){return lt()},get smallLogo(){return ot(et.isQualiex?"qualiexSmall":"saberSmall")},get favicon(){return nt.favicon??st}},dt=ct.logo,ut=ct.smallLogo;function mt(){if("undefined"==typeof document)return;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=ct.favicon,document.head.appendChild(e)}"function"==typeof queueMicrotask?queueMicrotask(mt):Promise.resolve().then(mt);const pt={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 ht(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const xt={date:ht({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:ht({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:ht({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ft={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function gt(e){return(t,a)=>{let r;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;r=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;r=e.values[s]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}const bt={ordinalNumber:(e,t)=>{const a=Number(e),r=a%100;if(r>20||r<10)switch(r%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:gt({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:gt({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:gt({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:gt({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:gt({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function vt(e){return(t,a={})=>{const r=a.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],n=t.match(s);if(!n)return null;const o=n[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let c;c=e.valueCallback?e.valueCallback(l):l,c=a.valueCallback?a.valueCallback(c):c;return{value:c,rest:t.slice(o.length)}}}function yt(e){return(t,a={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],n=t.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(s.length)}}}const wt={ordinalNumber:yt({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:vt({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:vt({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:vt({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:vt({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:vt({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"})},jt={code:"en-US",formatDistance:(e,t,a)=>{let r;const s=pt[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+r:r+" ago":r},formatLong:xt,formatRelative:(e,t,a,r)=>ft[e],localize:bt,match:wt,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Nt={};function _t(){return Nt}const Ct=6048e5;function kt(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function St(e){const t=kt(e);return t.setHours(0,0,0,0),t}function At(e){const t=kt(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function Tt(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Dt(e){const t=kt(e),a=function(e,t){const a=St(e),r=St(t),s=+a-At(a),n=+r-At(r);return Math.round((s-n)/864e5)}(t,function(e){const t=kt(e),a=Tt(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function Et(e,t){const a=_t(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,s=kt(e),n=s.getDay(),o=(n<r?7:0)+n-r;return s.setDate(s.getDate()-o),s.setHours(0,0,0,0),s}function Pt(e){return Et(e,{weekStartsOn:1})}function It(e){const t=kt(e),a=t.getFullYear(),r=Tt(e,0);r.setFullYear(a+1,0,4),r.setHours(0,0,0,0);const s=Pt(r),n=Tt(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const o=Pt(n);return t.getTime()>=s.getTime()?a+1:t.getTime()>=o.getTime()?a:a-1}function Mt(e){const t=kt(e),a=+Pt(t)-+function(e){const t=It(e),a=Tt(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),Pt(a)}(t);return Math.round(a/Ct)+1}function Rt(e,t){const a=kt(e),r=a.getFullYear(),s=_t(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=Tt(e,0);o.setFullYear(r+1,0,n),o.setHours(0,0,0,0);const i=Et(o,t),l=Tt(e,0);l.setFullYear(r,0,n),l.setHours(0,0,0,0);const c=Et(l,t);return a.getTime()>=i.getTime()?r+1:a.getTime()>=c.getTime()?r:r-1}function Lt(e,t){const a=kt(e),r=+Et(a,t)-+function(e,t){const a=_t(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=Rt(e,t),n=Tt(e,0);return n.setFullYear(s,0,r),n.setHours(0,0,0,0),Et(n,t)}(a,t);return Math.round(r/Ct)+1}function Ft(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const zt={y(e,t){const a=e.getFullYear(),r=a>0?a:1-a;return Ft("yy"===t?r%100:r,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):Ft(a+1,2)},d:(e,t)=>Ft(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>Ft(e.getHours()%12||12,t.length),H:(e,t)=>Ft(e.getHours(),t.length),m:(e,t)=>Ft(e.getMinutes(),t.length),s:(e,t)=>Ft(e.getSeconds(),t.length),S(e,t){const a=t.length,r=e.getMilliseconds();return Ft(Math.trunc(r*Math.pow(10,a-3)),t.length)}},Ut="midnight",Ot="noon",Bt="morning",qt="afternoon",Vt="evening",$t="night",Wt={G:function(e,t,a){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"});case"GGGGG":return a.era(r,{width:"narrow"});default:return a.era(r,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),r=t>0?t:1-t;return a.ordinalNumber(r,{unit:"year"})}return zt.y(e,t)},Y:function(e,t,a,r){const s=Rt(e,r),n=s>0?s:1-s;if("YY"===t){return Ft(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):Ft(n,t.length)},R:function(e,t){return Ft(It(e),t.length)},u:function(e,t){return Ft(e.getFullYear(),t.length)},Q:function(e,t,a){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return Ft(r,2);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});default:return a.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,a){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return Ft(r,2);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});default:return a.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,a){const r=e.getMonth();switch(t){case"M":case"MM":return zt.M(e,t);case"Mo":return a.ordinalNumber(r+1,{unit:"month"});case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});default:return a.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,a){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return Ft(r+1,2);case"Lo":return a.ordinalNumber(r+1,{unit:"month"});case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});default:return a.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,a,r){const s=Lt(e,r);return"wo"===t?a.ordinalNumber(s,{unit:"week"}):Ft(s,t.length)},I:function(e,t,a){const r=Mt(e);return"Io"===t?a.ordinalNumber(r,{unit:"week"}):Ft(r,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):zt.d(e,t)},D:function(e,t,a){const r=Dt(e);return"Do"===t?a.ordinalNumber(r,{unit:"dayOfYear"}):Ft(r,t.length)},E:function(e,t,a){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,a,r){const s=e.getDay(),n=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return Ft(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,a,r){const s=e.getDay(),n=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return Ft(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(s,{width:"narrow",context:"standalone"});case"cccccc":return a.day(s,{width:"short",context:"standalone"});default:return a.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,a){const r=e.getDay(),s=0===r?7:r;switch(t){case"i":return String(s);case"ii":return Ft(s,t.length);case"io":return a.ordinalNumber(s,{unit:"day"});case"iii":return a.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,a){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,a){const r=e.getHours();let s;switch(s=12===r?Ot:0===r?Ut:r/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,a){const r=e.getHours();let s;switch(s=r>=17?Vt:r>=12?qt:r>=4?Bt:$t,t){case"B":case"BB":case"BBB":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return zt.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):zt.H(e,t)},K:function(e,t,a){const r=e.getHours()%12;return"Ko"===t?a.ordinalNumber(r,{unit:"hour"}):Ft(r,t.length)},k:function(e,t,a){let r=e.getHours();return 0===r&&(r=24),"ko"===t?a.ordinalNumber(r,{unit:"hour"}):Ft(r,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):zt.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):zt.s(e,t)},S:function(e,t){return zt.S(e,t)},X:function(e,t,a){const r=e.getTimezoneOffset();if(0===r)return"Z";switch(t){case"X":return Gt(r);case"XXXX":case"XX":return Kt(r);default:return Kt(r,":")}},x:function(e,t,a){const r=e.getTimezoneOffset();switch(t){case"x":return Gt(r);case"xxxx":case"xx":return Kt(r);default:return Kt(r,":")}},O:function(e,t,a){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Ht(r,":");default:return"GMT"+Kt(r,":")}},z:function(e,t,a){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Ht(r,":");default:return"GMT"+Kt(r,":")}},t:function(e,t,a){return Ft(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return Ft(e.getTime(),t.length)}};function Ht(e,t=""){const a=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),n=r%60;return 0===n?a+String(s):a+String(s)+t+Ft(n,2)}function Gt(e,t){if(e%60==0){return(e>0?"-":"+")+Ft(Math.abs(e)/60,2)}return Kt(e,t)}function Kt(e,t=""){const a=e>0?"-":"+",r=Math.abs(e);return a+Ft(Math.trunc(r/60),2)+t+Ft(r%60,2)}const Yt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Qt=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Xt={p:Qt,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],r=a[1],s=a[2];if(!s)return Yt(e,t);let n;switch(r){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",Yt(r,t)).replace("{{time}}",Qt(s,t))}},Jt=/^D+$/,Zt=/^Y+$/,ea=["D","DD","YY","YYYY"];function ta(e){if(!(t=e,t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof e))return!1;var t;const a=kt(e);return!isNaN(Number(a))}const aa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ra=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,sa=/^'([^]*?)'?$/,na=/''/g,oa=/[a-zA-Z]/;function ia(e,t,a){const r=_t(),s=a?.locale??r.locale??jt,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,i=kt(e);if(!ta(i))throw new RangeError("Invalid time value");let l=t.match(ra).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,Xt[t])(e,s.formatLong)}return e}).join("").match(aa).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:la(e)};if(Wt[t])return{isToken:!0,value:e};if(t.match(oa))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});s.localize.preprocessor&&(l=s.localize.preprocessor(i,l));const c={firstWeekContainsDate:n,weekStartsOn:o,locale:s};return l.map(r=>{if(!r.isToken)return r.value;const n=r.value;(!a?.useAdditionalWeekYearTokens&&function(e){return Zt.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return Jt.test(e)}(n))&&function(e,t,a){const r=function(e,t,a){const r="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(ea.includes(e))throw new RangeError(r)}(n,t,String(e));return(0,Wt[n[0]])(i,n,s.localize,c)}).join("")}function la(e){const t=e.match(sa);return t?t[1].replace(na,"'"):e}function ca(e,t,a){const r=i.getDefaultOptions(),s=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??r.locale);return"formatToParts"in s?function(e,t){const a=e.formatToParts(t);for(let r=a.length-1;r>=0;--r)if("timeZoneName"===a[r].type)return a[r].value;return}(s,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),r=/ [\w-+ ]+$/.exec(a);return r?r[0].substr(1):""}(s,t)}function da(e,t){const a=function(e){ma[e]||(ma[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 ma[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),r=[];for(let e=0;e<a.length;e++){const t=ua[a[e].type];void 0!==t&&(r[t]=parseInt(a[e].value,10))}return r}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(r[3],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[4],10),parseInt(r[5],10),parseInt(r[6],10)]}(a,e)}const ua={year:0,month:1,day:2,hour:3,minute:4,second:5};const ma={},pa=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"===pa||"06/25/2014 00:00:00"===pa;function xa(e,t,a,r,s,n,o){const i=new Date(0);return i.setUTCFullYear(e,t,a),i.setUTCHours(r,s,n,o),i}const fa=36e5,ga={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function ba(e,t,a){if(!e)return 0;let r,s,n=ga.timezoneZ.exec(e);if(n)return 0;if(n=ga.timezoneHH.exec(e),n)return r=parseInt(n[1],10),ya(r)?-r*fa:NaN;if(n=ga.timezoneHHMM.exec(e),n){r=parseInt(n[2],10);const e=parseInt(n[3],10);return ya(r,e)?(s=Math.abs(r)*fa+6e4*e,"+"===n[1]?-s:s):NaN}if(function(e){if(wa[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),wa[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const r=a?t:function(e){return xa(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),s=va(r,e),n=a?s:function(e,t,a){const r=e.getTime();let s=r-t;const n=va(new Date(s),a);if(t===n)return t;s-=n-t;const o=va(new Date(s),a);if(n===o)return n;return Math.max(n,o)}(t,s,e);return-n}return NaN}function va(e,t){const a=da(e,t),r=xa(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let s=e.getTime();const n=s%1e3;return s-=n>=0?n:1e3+n,r-s}function ya(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const wa={};const ja={X:function(e,t,a){const r=Na(a.timeZone,e);if(0===r)return"Z";switch(t){case"X":return ka(r);case"XXXX":case"XX":return Ca(r);default:return Ca(r,":")}},x:function(e,t,a){const r=Na(a.timeZone,e);switch(t){case"x":return ka(r);case"xxxx":case"xx":return Ca(r);default:return Ca(r,":")}},O:function(e,t,a){const r=Na(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",r=Math.abs(e),s=Math.floor(r/60),n=r%60;if(0===n)return a+String(s);return a+String(s)+t+_a(n,2)}(r,":");default:return"GMT"+Ca(r,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return ca("short",e,a);default:return ca("long",e,a)}}};function Na(e,t){const a=e?ba(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function _a(e,t){const a=e<0?"-":"";let r=Math.abs(e).toString();for(;r.length<t;)r="0"+r;return a+r}function Ca(e,t=""){const a=e>0?"-":"+",r=Math.abs(e);return a+_a(Math.floor(r/60),2)+t+_a(Math.floor(r%60),2)}function ka(e,t){if(e%60==0){return(e>0?"-":"+")+_a(Math.abs(e)/60,2)}return Ca(e,t)}function Sa(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const Aa=36e5,Ta=6e4,Da={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 Ea(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const r=function(e){const t={};let a,r=Da.dateTimePattern.exec(e);r?(t.date=r[1],a=r[3]):(r=Da.datePattern.exec(e),r?(t.date=r[1],a=r[2]):(t.date=null,a=e));if(a){const e=Da.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:s,restDateString:n}=function(e,t){if(e){const a=Da.YYY[t],r=Da.YYYYY[t];let s=Da.YYYY.exec(e)||r.exec(e);if(s){const t=s[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(s=Da.YY.exec(e)||a.exec(e),s){const t=s[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(r.date,a),o=function(e,t){if(null===t)return null;let a,r,s;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=Da.MM.exec(e);if(n)return a=new Date(0),r=parseInt(n[1],10)-1,La(t,r)?(a.setUTCFullYear(t,r),a):new Date(NaN);if(n=Da.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=Ra(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=Da.MMDD.exec(e),n){a=new Date(0),r=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return La(t,r,e)?(a.setUTCFullYear(t,r,e),a):new Date(NaN)}if(n=Da.Www.exec(e),n)return s=parseInt(n[1],10)-1,Fa(s)?Pa(t,s):new Date(NaN);if(n=Da.WwwD.exec(e),n){s=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return Fa(s,e)?Pa(t,s,e):new Date(NaN)}return null}(n,s);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let a,s=0;if(r.time&&(s=function(e){let t,a,r=Da.HH.exec(e);if(r)return t=parseFloat(r[1].replace(",",".")),za(t)?t%24*Aa:NaN;if(r=Da.HHMM.exec(e),r)return t=parseInt(r[1],10),a=parseFloat(r[2].replace(",",".")),za(t,a)?t%24*Aa+a*Ta:NaN;if(r=Da.HHMMSS.exec(e),r){t=parseInt(r[1],10),a=parseInt(r[2],10);const e=parseFloat(r[3].replace(",","."));return za(t,a,e)?t%24*Aa+a*Ta+1e3*e:NaN}return null}(r.time),null===s||isNaN(s)))return new Date(NaN);if(r.timeZone||t.timeZone){if(a=ba(r.timeZone||t.timeZone,new Date(e+s)),isNaN(a))return new Date(NaN)}else a=Sa(new Date(e+s)),a=Sa(new Date(e+s+a));return new Date(e+s+a)}return new Date(NaN)}function Pa(e,t,a){t=t||0,a=a||0;const r=new Date(0);r.setUTCFullYear(e,0,4);const s=7*t+a+1-(r.getUTCDay()||7);return r.setUTCDate(r.getUTCDate()+s),r}const Ia=[31,28,31,30,31,30,31,31,30,31,30,31],Ma=[31,29,31,30,31,30,31,31,30,31,30,31];function Ra(e){return e%400==0||e%4==0&&e%100!=0}function La(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const r=Ra(e);if(r&&a>Ma[t])return!1;if(!r&&a>Ia[t])return!1}return!0}function Fa(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function za(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const Ua=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Oa(e,t,a,r){return function(e,t,a={}){const r=(t=String(t)).match(Ua);if(r){const s=Ea(a.originalDate||e,a);t=r.reduce(function(e,t){if("'"===t[0])return e;const r=e.indexOf(t),n="'"===e[r-1],o=e.replace(t,"'"+ja[t[0]](s,t,a)+"'");return n?o.substring(0,r-1)+o.substring(r+1):o},t)}return ia(e,t,a)}(function(e,t,a){const r=ba(t,e=Ea(e,a),!0),s=new Date(e.getTime()-r),n=new Date(0);return n.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),n.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),n}(e,t,{timeZone:(r={...r,timeZone:t,originalDate:e}).timeZone}),a,r)}const Ba={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"}},qa={date:ht({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:ht({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:ht({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Va={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"},$a={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"},Wa={ordinalNumber:(e,t)=>Number(e)+"º",era:gt({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:gt({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:gt({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:gt({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:gt({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"})},Ha={ordinalNumber:yt({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:vt({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:vt({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:vt({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:vt({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:vt({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"})},Ga={code:"es",formatDistance:(e,t,a)=>{let r;const s=Ba[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+r:"hace "+r:r},formatLong:qa,formatRelative:(e,t,a,r)=>1!==t.getHours()?$a[e]:Va[e],localize:Wa,match:Ha,options:{weekStartsOn:1,firstWeekContainsDate:1}},Ka={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"}},Ya={date:ht({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:ht({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:ht({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Qa={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Xa={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:gt({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:gt({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:gt({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:gt({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:gt({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"})},Ja={ordinalNumber:yt({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:vt({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:vt({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:vt({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:vt({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:vt({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"})},Za={code:"pt-BR",formatDistance:(e,t,a)=>{let r;const s=Ka[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+r:"há "+r:r},formatLong:Ya,formatRelative:(e,t,a,r)=>{const s=Qa[e];return"function"==typeof s?s(t):s},localize:Xa,match:Ja,options:{weekStartsOn:0,firstWeekContainsDate:1}},er=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],tr=[{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"}],ar=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],rr="pt-BR",sr="dd/MM/yyyy HH:mm",nr="America/Sao_Paulo",or=e=>er.some(t=>t.value===e),ir=e=>ar.some(t=>t.value===e),lr=()=>{if("undefined"==typeof navigator)return rr;const e=navigator.language;if(or(e))return e;const t=e.split("-")[0],a=er.find(e=>e.value.startsWith(t));return a?.value||rr},cr=()=>{if("undefined"==typeof Intl)return nr;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return ir(e)?e:nr}catch{return nr}},dr=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||sr),ur={"pt-BR":Za,"en-US":jt,"es-ES":Ga},mr=(e,t=sr,a=nr,r=rr)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const n=ur[r]||Za;try{return Oa(s,a,t,{locale:n})}catch(o){return Oa(s,nr,t,{locale:n})}},pr=(e,t=rr,a=nr)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const s=ur[t]||Za;try{return Oa(r,a,"PP",{locale:s})}catch(n){return Oa(r,nr,"PP",{locale:s})}};function hr(e){const t=e.replace("#",""),a=3===t.length?t.split("").map(e=>e+e).join(""):t;return{r:parseInt(a.substring(0,2),16),g:parseInt(a.substring(2,4),16),b:parseInt(a.substring(4,6),16)}}function xr(e,t=.1){const{r:a,g:r,b:s}=hr(e);return`rgba(${a}, ${r}, ${s}, ${t})`}function fr(e){const{r:t,g:a,b:r}=hr(e),[s,n,o]=[t,a,r].map(e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)});return.2126*s+.7152*n+.0722*o}function gr(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info("Link copiado para a área de transferência")})}function br(e,t){return t?e.replace(/\{alias\}/g,t):e}function vr(e="uuid"){if("short"===e){const e=new Uint8Array(9);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(36).padStart(2,"0")).join("").slice(0,12)}if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(16);crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;const a=Array.from(t,e=>e.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}const yr=["hint","details","code","where","schema","table","column"],wr="Ocorreu um erro ao processar sua solicitação.",jr=[/relation\s+"[^"]+"\s+does not exist/i,/column\s+"[^"]+"\s+of relation/i,/violates row-level security policy/i,/permission denied for (table|schema|function)/i,/password|token|secret|api[_-]?key/i];function Nr(e){const t=function(e){if(!e)return wr;if("string"==typeof e)return e;if(e instanceof Error)return e.message||wr;if("object"==typeof e&&"message"in e)return String(e.message);return wr}(e);return Me()?t:jr.some(e=>e.test(t))?wr:t}function _r(...e){return o.twMerge(n.clsx(e))}const Cr=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Cr);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,r]of Object.entries(e))t[a]=Cr(r);return t}return e},kr=s.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded-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"}}),Sr=te.forwardRef(({className:e,variant:a,size:s,asChild:n=!1,...o},i)=>{const l=n?r.Slot:"button";return t.jsx(l,{className:_r(kr({variant:a,size:s,className:e})),ref:i,...o})});Sr.displayName="Button";const Ar=a.forwardRef(({className:e,children:a,variant:r="action",...s},n)=>t.jsx(Sr,{ref:n,variant:r,size:"icon",className:_r("h-8 w-8",e),...s,children:a||t.jsx(c.EllipsisVertical,{size:16})}));Ar.displayName="ActionButton";const Tr=te.forwardRef(({className:e,type:a,showCharCount:r,maxLength:s,onChange:n,...o},i)=>{const[l,c]=te.useState(0);te.useEffect(()=>{"string"==typeof o.value?c(o.value.length):"string"==typeof o.defaultValue&&c(o.defaultValue.length)},[o.value,o.defaultValue]);return t.jsxs("div",{className:"w-full",children:[t.jsx("input",{type:a,className:_r("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:s,onChange:e=>{c(e.target.value.length),n?.(e)},...o}),r&&s&&t.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[l," / ",s]})]})});Tr.displayName="Input";const Dr=s.cva("text-xs font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Er=te.forwardRef(({className:e,...a},r)=>t.jsx(re.Root,{ref:r,className:_r(Dr(),e),...a}));Er.displayName=re.Root.displayName;const Pr=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("rounded-lg border bg-card text-card-foreground shadow-sm",e),...a}));Pr.displayName="Card";const Ir=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("flex flex-col space-y-1.5 p-6",e),...a}));Ir.displayName="CardHeader";const Mr=te.forwardRef(({className:e,...a},r)=>t.jsx("h3",{ref:r,className:_r("text-2xl font-semibold leading-none tracking-tight",e),...a}));Mr.displayName="CardTitle";const Rr=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Rr.displayName="CardDescription";const Lr=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("p-6 pt-0",e),...a}));Lr.displayName="CardContent";const Fr=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("flex items-center p-6 pt-0",e),...a}));Fr.displayName="CardFooter";const zr=te.forwardRef(({className:e,orientation:a="horizontal",decorative:r=!0,...s},n)=>t.jsx(ne.Root,{ref:n,decorative:r,orientation:a,className:_r("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...s}));zr.displayName=ne.Root.displayName;const Ur=oe.Root,Or=oe.Trigger,Br=oe.Portal,qr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Overlay,{className:_r("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),...a,ref:r}));qr.displayName=oe.Overlay.displayName;const Vr=te.forwardRef(({className:e,...a},r)=>t.jsxs(Br,{children:[t.jsx(qr,{}),t.jsx(oe.Content,{ref:r,className:_r("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),...a})]}));Vr.displayName=oe.Content.displayName;const $r=({className:e,...a})=>t.jsx("div",{className:_r("flex flex-col space-y-2 text-center sm:text-left",e),...a});$r.displayName="AlertDialogHeader";const Wr=({className:e,...a})=>t.jsx("div",{className:_r("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Wr.displayName="AlertDialogFooter";const Hr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Title,{ref:r,className:_r("text-lg font-semibold",e),...a}));Hr.displayName=oe.Title.displayName;const Gr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Gr.displayName=oe.Description.displayName;const Kr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Action,{ref:r,className:_r(kr(),e),...a}));Kr.displayName=oe.Action.displayName;const Yr=te.forwardRef(({className:e,...a},r)=>t.jsx(oe.Cancel,{ref:r,className:_r(kr({variant:"outline"}),"mt-2 sm:mt-0",e),...a}));Yr.displayName=oe.Cancel.displayName;const Qr=se.Root,Xr=se.Trigger,Jr=se.Portal,Zr=se.Close,es=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Overlay,{ref:r,className:_r("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),...a}));es.displayName=se.Overlay.displayName;const ts={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"}},as=te.forwardRef(({className:a,children:r,size:s,variant:n="informative",isDirty:o,customWidth:i,customMinWidth:l,customMaxWidth:d,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:b,onInteractOutside:v,onEscapeKeyDown:y,...w},j)=>{const[N,_]=te.useState(!1),C=te.useRef(null),k=te.useRef(!1),S=s??(i||l||d||u||m||p?void 0:"md"),A=S?ts[S]:{},T={...i??A.width?{width:i??A.width}:{},...l??A.minWidth?{minWidth:l??A.minWidth}:{},...d??A.maxWidth?{maxWidth:d??A.maxWidth}:{},...u??A.height?{height:u??A.height}:{},...m??A.minHeight?{minHeight:m??A.minHeight}:{},...p??A.maxHeight?{maxHeight:p??A.maxHeight}:{},...b},D=te.useCallback(e=>{"form"===n&&o?(C.current=e,_(!0)):e()},[n,o]),E=te.useRef(null),P="destructive"!==n;if("development"===process.env.NODE_ENV&&r){const e=te.Children.toArray(r);e.some(e=>te.isValidElement(e)&&"DialogFooter"===e.type?.displayName),e.some(e=>te.isValidElement(e)&&"DialogBody"===e.type?.displayName)}return t.jsxs(Jr,{children:[t.jsx(es,{}),t.jsxs(se.Content,{ref:j,className:_r("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",a),style:T,onInteractOutside:e=>{"form"!==n&&"destructive"!==n?v?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==n)return"form"===n&&o?(e.preventDefault(),void D(()=>{k.current=!0,E.current?.click()})):void y?.(e);e.preventDefault()},...w,children:[r,P&&t.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:[t.jsx(c.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]}),t.jsx(Ur,{open:N,onOpenChange:_,children:t.jsxs(Vr,{children:[t.jsxs($r,{children:[t.jsx(Hr,{children:h}),t.jsx(Gr,{children:x})]}),t.jsxs(Wr,{children:[t.jsx(Yr,{onClick:()=>{_(!1),C.current=null},children:f}),t.jsx(Kr,{onClick:()=>{_(!1),C.current?.(),C.current=null},children:g})]})]})})]})});as.displayName=se.Content.displayName;const rs=({className:e,showSeparator:a=!1,children:r,...s})=>t.jsxs("div",{className:_r("flex flex-col flex-shrink-0",e),...s,children:[t.jsx("div",{className:"flex flex-col text-left",children:r}),a&&t.jsx(zr,{className:"mt-2"})]});rs.displayName="DialogHeader";const ss=({className:e,...a})=>t.jsx("div",{className:_r("flex-1 min-h-0 overflow-auto py-4 px-2 -mx-2",e),...a});ss.displayName="DialogBody";const ns=({className:e,children:a,...r})=>t.jsxs("div",{className:"flex-shrink-0 pt-4",children:[t.jsx(zr,{className:"mb-4"}),t.jsx("div",{className:_r("flex flex-row justify-end gap-2",e),...r,children:a})]});ns.displayName="DialogFooter";const os=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Title,{ref:r,className:_r("text-xl font-semibold leading-none tracking-tight",e),...a}));os.displayName=se.Title.displayName;const is=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));is.displayName=se.Description.displayName;const ls=h.FormProvider,cs=te.createContext({}),ds=()=>{const e=te.useContext(cs),t=te.useContext(us),{getFieldState:a,formState:r}=h.useFormContext(),s=a(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...s}},us=te.createContext({}),ms=te.forwardRef(({className:e,...a},r)=>{const s=te.useId();return t.jsx(us.Provider,{value:{id:s},children:t.jsx("div",{ref:r,className:_r("space-y-1.5",e),...a})})});ms.displayName="FormItem";const ps=te.forwardRef(({className:e,...a},r)=>{const{error:s,formItemId:n}=ds();return t.jsx(Er,{ref:r,className:_r(s&&"text-destructive",e),htmlFor:n,...a})});ps.displayName="FormLabel";const hs=te.forwardRef(({...e},a)=>{const{error:s,formItemId:n,formDescriptionId:o,formMessageId:i}=ds();return t.jsx(r.Slot,{ref:a,id:n,"aria-describedby":s?`${o} ${i}`:`${o}`,"aria-invalid":!!s,...e})});hs.displayName="FormControl";const xs=te.forwardRef(({className:e,...a},r)=>{const{formDescriptionId:s}=ds();return t.jsx("p",{ref:r,id:s,className:_r("text-sm text-muted-foreground",e),...a})});xs.displayName="FormDescription";const fs=te.forwardRef(({className:e,children:a,...r},s)=>{const{error:n,formMessageId:o}=ds(),i=n?String(n?.message):a;return i?t.jsx("p",{ref:s,id:o,className:_r("text-sm font-medium text-destructive",e),...r,children:i}):null});fs.displayName="FormMessage";const gs=te.createContext({showCheck:!1}),bs=({showCheck:e=!1,...a})=>t.jsx(gs.Provider,{value:{showCheck:e},children:t.jsx(ie.Root,{...a})}),vs=ie.Group,ys=ie.Value,ws=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(ie.Trigger,{ref:s,className:_r("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),...r,children:[a,t.jsx(ie.Icon,{asChild:!0,children:t.jsx(c.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ws.displayName=ie.Trigger.displayName;const js=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.ScrollUpButton,{ref:r,className:_r("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(c.ChevronUp,{className:"h-4 w-4"})}));js.displayName=ie.ScrollUpButton.displayName;const Ns=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.ScrollDownButton,{ref:r,className:_r("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(c.ChevronDown,{className:"h-4 w-4"})}));Ns.displayName=ie.ScrollDownButton.displayName;const _s=te.forwardRef(({className:e,children:a,position:r="popper",container:s,collisionBoundary:n,...o},i)=>t.jsx(ie.Portal,{container:s,children:t.jsxs(ie.Content,{ref:i,className:_r("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"===r&&"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:r,collisionBoundary:n,...o,children:[t.jsx(js,{}),t.jsx(ie.Viewport,{className:_r("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),t.jsx(Ns,{})]})}));_s.displayName=ie.Content.displayName;const Cs=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.Label,{ref:r,className:_r("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...a}));Cs.displayName=ie.Label.displayName;const ks=te.forwardRef(({className:e,children:a,...r},s)=>{const{showCheck:n}=te.useContext(gs);return t.jsxs(ie.Item,{ref:s,className:_r("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n?"pl-8":"pl-2","data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground data-[state=checked]:font-medium data-[state=checked]:border-l-2 data-[state=checked]:border-primary",n?"data-[state=checked]:pl-[calc(2rem-2px)]":"data-[state=checked]:pl-[calc(0.5rem-2px)]",e),...r,children:[n&&t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ie.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),t.jsx(ie.ItemText,{children:a})]})});ks.displayName=ie.Item.displayName;const Ss=te.forwardRef(({className:e,...a},r)=>t.jsx(ie.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-muted",e),...a}));Ss.displayName=ie.Separator.displayName;const As=te.forwardRef(({className:e,...a},r)=>t.jsx(le.Root,{ref:r,className:_r("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),...a,children:t.jsx(le.Indicator,{className:_r("flex items-center justify-center text-current"),children:t.jsx(c.Check,{className:"h-4 w-4"})})}));As.displayName=le.Root.displayName;const Ts=te.forwardRef(({className:e,showCharCount:a,maxLength:r,onChange:s,...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 t.jsxs("div",{className:"w-full",children:[t.jsx("textarea",{className:_r("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:r,onChange:e=>{l(e.target.value.length),s?.(e)},...n}),a&&r&&t.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[i," / ",r]})]})});Ts.displayName="Textarea";const Ds=s.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),Es=te.forwardRef(({className:e,variant:a,...r},s)=>t.jsx("div",{ref:s,className:_r(Ds({variant:a}),e),...r}));Es.displayName="Badge";const Ps={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Is({size:e="md",className:a}){return t.jsx(c.Loader2,{className:_r("animate-spin text-muted-foreground",Ps[e],a)})}function Ms({isLoading:e,children:a,className:r,type:s="spinner",size:n="md"}){return e?"overlay"===s?t.jsxs("div",{className:_r("relative",r),children:[a,t.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:t.jsx(Is,{size:n})})]}):"skeleton"===s?t.jsx("div",{className:_r("animate-pulse",r),children:t.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):t.jsx("div",{className:_r("flex items-center justify-center py-8",r),children:t.jsx(Is,{size:n})}):t.jsx(t.Fragment,{children:a})}const Rs=({...e})=>t.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:t.jsx(c.CircleCheckIcon,{className:"h-4 w-4"}),info:t.jsx(c.InfoIcon,{className:"h-4 w-4"}),warning:t.jsx(c.TriangleAlertIcon,{className:"h-4 w-4"}),error:t.jsx(c.OctagonXIcon,{className:"h-4 w-4"}),loading:t.jsx(c.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}),Ls=ce.Root,Fs=ce.Trigger,zs=ce.Group,Us=ce.Portal,Os=ce.Sub,Bs=ce.RadioGroup,qs=te.forwardRef(({className:e,inset:a,children:r,...s},n)=>t.jsxs(ce.SubTrigger,{ref:n,className:_r("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",e),...s,children:[r,t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4"})]}));qs.displayName=ce.SubTrigger.displayName;const Vs=te.forwardRef(({className:e,...a},r)=>t.jsx(ce.SubContent,{ref:r,className:_r("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),...a}));Vs.displayName=ce.SubContent.displayName;const $s=te.forwardRef(({className:e,sideOffset:a=4,...r},s)=>t.jsx(ce.Portal,{children:t.jsx(ce.Content,{ref:s,sideOffset:a,className:_r("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),...r})}));$s.displayName=ce.Content.displayName;const Ws=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(ce.Item,{ref:s,className:_r("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",e),...r}));Ws.displayName=ce.Item.displayName;const Hs=te.forwardRef(({className:e,children:a,checked:r,...s},n)=>t.jsxs(ce.CheckboxItem,{ref:n,className:_r("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:r,...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ce.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),a]}));Hs.displayName=ce.CheckboxItem.displayName;const Gs=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(ce.RadioItem,{ref:s,className:_r("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),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ce.ItemIndicator,{children:t.jsx(c.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Gs.displayName=ce.RadioItem.displayName;const Ks=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(ce.Label,{ref:s,className:_r("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...r}));Ks.displayName=ce.Label.displayName;const Ys=te.forwardRef(({className:e,...a},r)=>t.jsx(ce.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-muted",e),...a}));Ys.displayName=ce.Separator.displayName;const Qs=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest opacity-60",e),...a});Qs.displayName="DropdownMenuShortcut";const Xs=({delayDuration:e=300,...a})=>t.jsx(de.Provider,{delayDuration:e,...a}),Js=de.Root,Zs=de.Trigger,en=te.forwardRef(({className:e,sideOffset:a=4,container:r,...s},n)=>t.jsx(de.Portal,{container:r,children:t.jsx(de.Content,{ref:n,sideOffset:a,className:_r("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})}));en.displayName=de.Content.displayName;const tn=te.forwardRef(({children:e,disabledReason:a,className:r},s)=>{const n=t.jsx(Ws,{ref:s,className:_r("opacity-50 cursor-not-allowed pointer-events-auto",r),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:e});return a?t.jsx(Xs,{delayDuration:100,children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("div",{className:"w-full",children:n})}),t.jsx(en,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});tn.displayName="DisabledMenuItem";const an=ue.Root,rn=ue.Trigger,sn=te.forwardRef(({className:e,align:a="center",sideOffset:r=4,container:s,...n},o)=>t.jsx(ue.Portal,{container:s,children:t.jsx(ue.Content,{ref:o,align:a,sideOffset:r,className:_r("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})}));sn.displayName=ue.Content.displayName;const nn=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a}));nn.displayName="Command";const on=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:t.jsx("input",{ref:r,className:_r("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),...a})}));on.displayName="CommandInput";const ln=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));ln.displayName="CommandList";const cn=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("py-6 text-center text-sm text-muted-foreground",e),...a}));cn.displayName="CommandEmpty";const dn=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("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),...a}));dn.displayName="CommandGroup";const un=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("-mx-1 h-px bg-border",e),...a}));un.displayName="CommandSeparator";const mn=te.forwardRef(({className:e,disabled:a,onSelect:r,value:s,...n},o)=>t.jsx("div",{ref:o,className:_r("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":a,onClick:()=>!a&&r?.(s||""),...n}));mn.displayName="CommandItem";const pn=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});function hn({className:e,...a}){return t.jsx("div",{className:_r("animate-pulse rounded-md bg-muted",e),...a})}pn.displayName="CommandShortcut";const xn=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function fn({multiple:r,options:s,value:n,onChange:o,getOptionValue:i,getOptionLabel:l,renderOption:d,placeholder:u,label:m,icon:p,emptyMessage:h,searchPlaceholder:x,disabled:f,required:g,className:b,sortOptions:v,maxDisplayedBadges:y,popoverContainer:w,onOpen:j,onClose:N,clearable:_,showCheck:C}){const[k,S]=a.useState(!1),[A,T]=a.useState(""),D=a.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),E=a.useMemo(()=>{if(!w)return;let e=w,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),r=a.overflowY||a.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[w]),P=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,i,l,v]),I=a.useMemo(()=>{if(!A)return P;const e=xn(A);return P.filter(t=>xn(t.label).includes(e))},[P,A]),M=a.useMemo(()=>P.filter(e=>D.includes(e.value)),[P,D]),R=e=>{S(e),e?j?.():(T(""),N?.())},L=(e,t)=>{t.preventDefault(),t.stopPropagation(),o&&o(r?D.filter(t=>t!==e):"")},F=y?M.slice(0,y):M,z=y&&M.length>y?M.length-y:0;return t.jsxs("div",{className:_r("space-y-2",b),children:[m&&t.jsxs(Er,{children:[m,g&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs(an,{open:k,onOpenChange:R,modal:!1,children:[r?t.jsx(rn,{asChild:!0,children:t.jsxs("div",{role:"combobox","aria-expanded":k,"aria-disabled":f,tabIndex:f?-1:0,onKeyDown:e=>{f||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),R(!k))},className:_r("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",f&&"pointer-events-none opacity-50 cursor-not-allowed",0===M.length&&"text-muted-foreground"),children:[0===M.length?t.jsxs("span",{className:"flex items-center gap-2",children:[p&&t.jsx(p,{className:"h-4 w-4"}),u]}):t.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[F.map(e=>t.jsxs(Es,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,t.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:t=>{"Enter"===t.key&&L(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>L(e.value,t),children:t.jsx(c.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),z>0&&t.jsxs(Es,{variant:"outline",className:"gap-1",children:["+",z]})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}):t.jsxs("div",{className:"relative",children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",role:"combobox","aria-expanded":k,disabled:f,className:_r("relative w-full justify-start min-h-10 h-auto pr-10",_&&M.length>0&&"pr-16",0===M.length&&"text-muted-foreground"),children:[0===M.length?t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 truncate text-left",children:[p&&t.jsx(p,{className:"h-4 w-4"}),t.jsx("span",{className:"truncate",children:u})]}):t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 truncate text-left",children:[p&&t.jsx(p,{className:"h-4 w-4"}),t.jsx("span",{className:"truncate",children:M[0]?.label})]}),t.jsx(c.ChevronDown,{className:"absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 opacity-50"})]})}),_&&M.length>0&&t.jsx("button",{type:"button",disabled:f,className:"absolute right-8 top-1/2 z-10 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-50",onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>L("",e),title:"Limpar seleção","aria-label":"Limpar seleção",children:t.jsx(c.X,{className:"h-3.5 w-3.5"})})]}),t.jsx(sn,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:E,collisionBoundary:E,children:t.jsxs(nn,{children:[t.jsxs("div",{className:"relative",children:[t.jsx(on,{placeholder:x,value:A,onChange:e=>T(e.target.value)}),A&&t.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:()=>T(""),children:t.jsx(c.X,{className:"h-3.5 w-3.5"})})]}),t.jsx(ln,{children:0===s.length?t.jsx(cn,{children:h}):0===I.length?t.jsx(cn,{children:e.t("no_results")}):t.jsx(dn,{children:I.map(e=>{const a=D.includes(e.value);return t.jsxs(mn,{value:e.value,onSelect:()=>(e=>{if(o)if(r){const t=D.includes(e)?D.filter(t=>t!==e):[...D,e];o(t)}else o(e),S(!1)})(e.value),className:_r("cursor-pointer",a&&"bg-accent text-accent-foreground font-medium border-l-2 border-primary pl-[calc(0.5rem-2px)] data-[selected=true]:bg-accent"),children:[C&&t.jsx(c.Check,{className:_r("mr-2 h-4 w-4",a?"opacity-100":"opacity-0")}),d?d(e.original):e.label]},e.value)})})})]})})]})]})}function gn({multiple:e=!1,options:a,items:r,value:s,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:l=e=>e.label,renderOption:d,placeholder:u,label:m,icon:p,emptyMessage:h,searchPlaceholder:x,disabled:f=!1,required:g=!1,isLoading:b=!1,error:v,className:w,sortOptions:j=!0,maxDisplayedBadges:N,popoverContainer:_,onOpen:C,onClose:k,clearable:S=!0,showCheck:A=!1}){const{t:T}=y.useTranslation(),D=a||r||[],E=o||n,P=u||T("select_placeholder","Selecione..."),I=h||T("no_results",T("no_results")),M=x||T("search_placeholder","Pesquisar...");if(b)return t.jsxs("div",{className:_r("space-y-2",w),children:[m&&t.jsxs(Er,{children:[m,g&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(hn,{className:"h-10 w-full"})]});const R="string"==typeof v?v:v instanceof Error?v.message:v?T("error_loading",T("error_loading")):void 0;return R?t.jsxs("div",{className:_r("space-y-2",w),children:[m&&t.jsxs(Er,{children:[m,g&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[t.jsx(c.AlertCircle,{className:"h-4 w-4"}),t.jsx("span",{className:"text-sm",children:R})]})]}):t.jsx(fn,{multiple:e,options:D,value:s||(e?[]:""),onChange:E,getOptionValue:i,getOptionLabel:l,renderOption:d,placeholder:P,label:m,icon:p,emptyMessage:I,searchPlaceholder:M,disabled:f,required:g,className:w,sortOptions:j,maxDisplayedBadges:N,popoverContainer:_,onOpen:C,onClose:k,clearable:S,showCheck:A})}const bn=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function vn(e,t){if(!t)return null;const a=bn(t),r=[];for(const s of e){const e=bn(s.label).includes(a),n=s.children?vn(s.children,t):null,o=n&&n.length>0;(e||o)&&r.push({...s,children:e?s.children:o?n:s.children})}return r}function yn(e,t){for(const a of e){if(a.value===t)return a.label;if(a.children){const e=yn(a.children,t);if(e)return e}}}function wn({node:e,level:a,expanded:r,onToggleExpand:s,selectedValues:n,onSelect:o,showCheck:i}){const l=e.children&&e.children.length>0,d=n.includes(e.value),u=8+20*a;return t.jsxs("div",{role:"treeitem","aria-expanded":l?r:void 0,"aria-selected":d,className:_r("flex items-center gap-1 rounded-sm py-1.5 pr-2 text-sm cursor-pointer outline-none","hover:bg-accent hover:text-accent-foreground",d&&"bg-accent text-accent-foreground font-medium border-l-2 border-primary"),style:{paddingLeft:u-(d?2:0)+"px"},children:[t.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:t=>{t.stopPropagation(),o(e.value)},children:[i&&t.jsx(c.Check,{className:_r("h-4 w-4 shrink-0",d?"opacity-100":"opacity-0")}),(()=>{const a=d?e.iconSelected??(r?e.iconOpen:null)??e.icon:r?e.iconOpen??e.icon:e.icon;return a?t.jsx(a,{className:_r("h-4 w-4 shrink-0",e.iconClassName||"text-muted-foreground")}):null})(),t.jsx("span",{className:"truncate",children:e.label})]}),l&&t.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:t=>{t.stopPropagation(),s(e.value)},tabIndex:-1,"aria-label":r?"Recolher":"Expandir",children:r?t.jsx(c.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):t.jsx(c.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function jn({nodes:e,level:r,expandedIds:s,onToggleExpand:n,selectedValues:o,onSelect:i,showCheck:l}){return t.jsx(t.Fragment,{children:e.map(e=>{const c=s.has(e.value);return t.jsxs(a.Fragment,{children:[t.jsx(wn,{node:e,level:r,expanded:c,onToggleExpand:n,selectedValues:o,onSelect:i,showCheck:l}),c&&e.children&&e.children.length>0&&t.jsx(jn,{nodes:e.children,level:r+1,expandedIds:s,onToggleExpand:n,selectedValues:o,onSelect:i,showCheck:l})]},e.value)})})}function Nn({multiple:e=!1,options:r,value:s,onChange:n,placeholder:o,label:i,icon:l,emptyMessage:d,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:x,className:f,maxDisplayedBadges:g,popoverContainer:b,onOpen:v,onClose:w,defaultExpanded:j=!0,showCheck:N=!1}){const{t:_}=y.useTranslation(),[C,k]=a.useState(!1),[S,A]=a.useState(""),[T,D]=a.useState(()=>j?function(e){const t=new Set;return function e(a){for(const r of a)r.children&&r.children.length>0&&(t.add(r.value),e(r.children))}(e),t}(r):new Set),E=o||_("select_placeholder","Selecione..."),P=d||_("no_results",_("no_results")),I=u||_("search_placeholder","Pesquisar..."),M=a.useMemo(()=>s?Array.isArray(s)?s:[s]:[],[s]),R=a.useMemo(()=>{if(!b)return;let e=b,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),r=a.overflowY||a.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[b]),L=a.useMemo(()=>vn(r,S),[r,S])??r,F=a.useMemo(()=>S?function(e,t){const a=new Set,r=bn(t);function s(e){if(!e.children||0===e.children.length)return bn(e.label).includes(r);let t=!1;for(const a of e.children)s(a)&&(t=!0);return t&&a.add(e.value),t||bn(e.label).includes(r)}for(const n of e)s(n);return a}(r,S):new Set,[r,S]),z=S?F:T,U=a.useCallback(e=>{S||D(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[S]),O=a.useMemo(()=>M.map(e=>({value:e,label:yn(r,e)||e})),[M,r]),B=e=>{k(e),e?v?.():(A(""),w?.())},q=a.useCallback(t=>{if(n)if(e){const e=M.includes(t)?M.filter(e=>e!==t):[...M,t];n(e)}else n(t),k(!1)},[n,e,M]),V=(t,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(e?M.filter(e=>e!==t):"")},$=g?O.slice(0,g):O,W=g&&O.length>g?O.length-g:0;if(h)return t.jsxs("div",{className:_r("space-y-2",f),children:[i&&t.jsxs(Er,{children:[i,p&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(hn,{className:"h-10 w-full"})]});const H="string"==typeof x?x:x instanceof Error?x.message:x?_("error_loading",_("error_loading")):void 0;return H?t.jsxs("div",{className:_r("space-y-2",f),children:[i&&t.jsxs(Er,{children:[i,p&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[t.jsx(c.AlertCircle,{className:"h-4 w-4"}),t.jsx("span",{className:"text-sm",children:H})]})]}):t.jsxs("div",{className:_r("space-y-2",f),children:[i&&t.jsxs(Er,{children:[i,p&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs(an,{open:C,onOpenChange:B,modal:!1,children:[t.jsx(rn,{asChild:!0,children:e?t.jsxs("div",{role:"combobox","aria-expanded":C,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),B(!C))},className:_r("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===O.length&&"text-muted-foreground"),children:[0===O.length?t.jsxs("span",{className:"flex items-center gap-2",children:[l&&t.jsx(l,{className:"h-4 w-4"}),E]}):t.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[$.map(e=>t.jsxs(Es,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,t.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:t=>{"Enter"===t.key&&V(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>V(e.value,t),children:t.jsx(c.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),W>0&&t.jsxs(Es,{variant:"outline",className:"gap-1",children:["+",W]})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):t.jsxs(Sr,{variant:"outline",role:"combobox","aria-expanded":C,disabled:m,className:_r("w-full justify-between min-h-10 h-auto font-normal",0===O.length&&"text-muted-foreground"),children:[0===O.length?t.jsxs("span",{className:"flex items-center gap-2",children:[l&&t.jsx(l,{className:"h-4 w-4"}),E]}):t.jsxs("span",{className:"flex items-center gap-2",children:[l&&t.jsx(l,{className:"h-4 w-4"}),O[0]?.label]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),t.jsxs(sn,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:R,collisionBoundary:R,children:[t.jsxs("div",{className:"flex items-center border-b px-3",children:[t.jsx(c.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),t.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:I,value:S,onChange:e=>A(e.target.value)}),S&&t.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>A(""),children:t.jsx(c.X,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"max-h-[300px] overflow-y-auto overflow-x-hidden",children:t.jsx("div",{role:"tree",className:"p-1",children:0===L.length?t.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===r.length?P:_("no_search_results",_("no_results"))}):t.jsx(jn,{nodes:L,level:0,expandedIds:z,onToggleExpand:U,selectedValues:M,onSelect:q,showCheck:N})})})]})]})]})}const _n=void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:Z&&"SCRIPT"===Z.tagName.toUpperCase()&&Z.src||new URL("index.js",document.baseURI).href}&&!1,Cn=new Map;function kn(e,t=1/0){if(!_n)return 0;const a=(Cn.get(e)??0)+1;return Cn.set(e,a),a}function Sn(e){if(_n)try{performance.mark(`auth:${e}`)}catch{}}async function An(e,t){if(!_n)return t();const a=performance.now();try{return await t()}finally{performance.now()}}function Tn(e){if(!_n)return;if(0===Cn.size)return;const t={};for(const[a,r]of Cn.entries())t[a]=r}let Dn=null;function En(e,t,a){if(!_n||!t)return;if(a&&"object"==typeof a)for(const r in a)/^co\d+$/.test(r)&&0}const Pn=()=>_n;var In=Object.defineProperty;const Mn=class e{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(t){if(Pn()){return kn(`parseJwtPayload:${t.length}:${t.slice(-8)}`,4),kn("parseJwtPayload:total"),function(e,t){if(!_n)return t();performance.now();try{return t()}finally{performance.now()}}(t.length,()=>e._parseJwtPayloadImpl(t))}return e._parseJwtPayloadImpl(t)}static _parseJwtPayloadImpl(e){try{const s=e.split(".");if(3!==s.length)return null;const n=s[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let s=0;s<t.length;s++)a[s]=t.charCodeAt(s);const r=new TextDecoder("utf-8").decode(a);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(s){return null}}static validateTokens(e,t){const a=[],r=[];try{t.split(".")[1],e.split(".")[1];const s=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!s){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(s.exp&&s.exp<i){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:r}}catch(s){const e=`Erro na validação de tokens: ${s}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}};((e,t,a)=>{t in e?In(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(Mn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);let Rn=Mn;const Ln="qualiex_access_token",Fn="qualiex_id_token",zn="supabase_token",Un="oauth_state",On="oauth_nonce",Bn="selected_alias",qn="manual_logout",Vn="supabase_project_id",$n={setAccessToken:e=>localStorage.setItem(Ln,e),getAccessToken:()=>localStorage.getItem(Ln),setIdToken:e=>localStorage.setItem(Fn,e),getIdToken:()=>localStorage.getItem(Fn),getSupabaseToken:()=>localStorage.getItem(zn),setOAuthState:e=>sessionStorage.setItem(Un,e),getOAuthState:()=>sessionStorage.getItem(Un),clearOAuthState:()=>sessionStorage.removeItem(Un),setOAuthNonce:e=>sessionStorage.setItem(On,e),getOAuthNonce:()=>sessionStorage.getItem(On),clearOAuthNonce:()=>sessionStorage.removeItem(On),setSelectedAlias:e=>localStorage.setItem(Bn,e),getSelectedAlias:()=>localStorage.getItem(Bn),clearSelectedAlias:()=>localStorage.removeItem(Bn),generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!$n.getAccessToken()||!$n.getIdToken()),checkProjectMismatch:()=>{const e=Ie().supabaseProjectId;if(!e)return!1;const t=localStorage.getItem(Vn);return t&&t!==e?($n.clearAll(),localStorage.setItem(Vn,e),!0):(t||localStorage.setItem(Vn,e),!1)},setSupabaseToken:e=>{localStorage.setItem(zn,e),$n._clearValidationCache()},areAllTokensValid:()=>{const e=$n.getAccessToken(),t=$n.getIdToken();if(!e||!t)return!1;try{const a=Rn.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=$n.getAccessToken(),a=$n.getIdToken(),r=$n.getSupabaseToken();return t&&$n.isTokenExpired(t)&&(localStorage.removeItem(Ln),e=!0),a&&$n.isTokenExpired(a)&&(localStorage.removeItem(Fn),e=!0),r&&$n.isTokenExpired(r)&&(localStorage.removeItem(zn),e=!0),e},clearAll:()=>{localStorage.removeItem(Ln),localStorage.removeItem(Fn),localStorage.removeItem(zn),localStorage.removeItem(Bn),sessionStorage.removeItem(Un),sessionStorage.removeItem(On),$n._clearValidationCache()},setManualLogout:()=>localStorage.setItem(qn,"true"),isManualLogout:()=>"true"===localStorage.getItem(qn),clearManualLogout:()=>localStorage.removeItem(qn),isTokenExpired:e=>{try{return Rn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{$n._validationCache.isValid=!1,$n._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=$n.getSupabaseToken();if(!e)return!1;if($n.isTokenExpired(e))return $n._clearValidationCache(),$n._handleExpiredToken(),!1;const t=Date.now();return t-$n._validationCache.timestamp<$n._validationCache.cacheValidityMs?$n._validationCache.isValid:($n._validationCache.isValid=!0,$n._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>$n.isSupabaseTokenValid()?$n.getSupabaseToken():null,_handleExpiredToken:()=>{$n.clearAll()},extractTokenData:()=>{if(kn("TokenManager.extractTokenData"),!$n.isSupabaseTokenValid())return null;const e=$n.getSupabaseToken();if(!e)return null;try{const t=Rn.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,r=t.place_id||null,s=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:r,placeName:s,payload:t}}catch(t){return $n._handleExpiredToken(),null}},getCompanyId:e=>{kn("TokenManager.getCompanyId");const t=$n.getAccessToken();if(t)try{const a=Rn.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=a[t];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}const a=$n.extractTokenData();if(a?.companyId)return a.companyId;const r=$n.getIdToken();if(r)try{const t=Rn.parseJwtPayload(r);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}return null},getAppGroupId:(e,t)=>{kn("TokenManager.getAppGroupId");const a=$n.getAccessToken();if(!a)return null;try{const r=Rn.parseJwtPayload(a);if(!r)return null;for(const a in r)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=r[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>5&&a[0]===e){if(t?.includes(a[5]))continue;const e=Number(a[5]);return Number.isNaN(e)?null:e}if(!e&&a.length>5){if(t?.includes(a[5]))continue;const e=Number(a[5]);return Number.isNaN(e)?null:e}}}}catch{}return null},getCompanyIdInt:e=>{kn("TokenManager.getCompanyIdInt");const t=[$n.getAccessToken(),$n.getIdToken()];for(const a of t)if(a)try{const t=Rn.parseJwtPayload(a);if(!t)continue;for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>1&&t[0]===e)return t[1];if(!e&&t.length>1)return t[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=$n.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{kn("TokenManager.getAllCompaniesData");const e=$n.getIdToken();if(!e)return[];try{const t=Rn.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};var Wn=Object.defineProperty,Hn=(e,t,a)=>((e,t,a)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Gn=new class{constructor(){Hn(this,"errors",[]),Hn(this,"toastCount",0),Hn(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message,r=Nr(a);if(this.errors.push({id:vr("short"),message:a,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),t&&this.shouldShowToast()){const e=this.getErrorTitle(r);l.toast.error(e,{description:r})}}getErrorTitle(t){const a=t.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?e.t("error_session_expired"):a.includes("token")||a.includes("autenticação")?e.t("error_authentication"):a.includes("api")||a.includes("network")?e.t("error_connection"):"Erro"}success(e,t){l.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};["[forlogic-core] ⚠️ VITE_SUPABASE_PUBLISHABLE_KEY contém uma legacy anon key (JWT).","O Supabase desativou legacy API keys. Substitua pela nova publishable key (formato sb_publishable_*).","Todas as requests retornarão 401 Unauthorized.","Causa provável: a integração Supabase do Lovable sobrescreveu o .env com a anon key legada.","Solução: defina VITE_SUPABASE_PK_OVERRIDE no .env com a publishable key correta."].join(" ");function Kn(e){return!!e&&e.startsWith("eyJ")}let Yn=!1;var Qn=Object.defineProperty,Xn=(e,t,a)=>((e,t,a)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);function Jn(){if(Me()){const e=Ie();return{url:e.supabaseUrl,key:e.supabasePublishableKey}}const e=(void 0).VITE_SUPABASE_URL,t=(void 0).VITE_SUPABASE_PK_OVERRIDE||((void 0).VITE_SUPABASE_PUBLISHABLE_KEY??"");return e&&t?{url:e,key:t}:null}const Zn=class e{constructor(e){Xn(this,"client"),Xn(this,"currentToken",null),Xn(this,"config"),this.config=e,function(){const e=(void 0).VITE_SUPABASE_PK_OVERRIDE,t=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;Yn?Kn(t):e&&Kn(t)?Yn=!0:Kn(t)?Yn=!0:Yn=!0}(),this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:this.config.key};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return w.createClient(this.config.url,this.config.key,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>{const a="string"==typeof e?e:e.url;if(a.includes("/auth/v1/user"))return new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}});if(a.includes("apikey="))try{const e=new URL(a,"https://placeholder.local");if(e.searchParams.has("apikey")){e.searchParams.delete("apikey");const r=a.startsWith("http")?e.toString():e.pathname+e.search+e.hash,s={...t,headers:{...t?.headers,apikey:this.config.key}};return fetch(r,s)}}catch{}return fetch(e,t)}}})}static getInstance(){if(!e.instance){const t=Jn();if(!t)throw new Error("[forlogic-core] Supabase não configurado. Defina VITE_SUPABASE_URL e VITE_SUPABASE_PUBLISHABLE_KEY no .env, ou não invoque getSupabaseClient() (use isSupabaseConfigured() para checar antes).");e.instance=new e(t)}return e.instance}getClient(){const e=$n.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Rn.isTokenExpired(e)}catch(t){return Gn.handleError(t instanceof Error?t:"Supabase - Error validating token",!1),!1}}};Xn(Zn,"instance");let eo=Zn;function to(){return eo.getInstance().getClient()}class ao{static async generateToken(e,t,a,r=!1){try{if(!r){const e=$n.getSupabaseToken();if(e&&$n.isSupabaseTokenValid())return e}const s=to();kn("SupabaseTokenService.generateToken:invoke");const{data:n,error:o}=await An(0,()=>s.functions.invoke("validate-token",{body:{access_token:e,alias:t}}));return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token?($n.setSupabaseToken(n.access_token),n.access_token):null}catch(s){return s instanceof Error&&(s.message.includes("401")||s.message.includes("Unauthorized"))&&a?.(),null}}}var ro=Object.defineProperty,so=(e,t,a)=>((e,t,a)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class no{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(e=!1){if(this.regenerationPromise)return this.regenerationPromise;this.regenerationPromise=this._doRegenerate(e);try{return await this.regenerationPromise}finally{this.regenerationPromise=null}}static async _doRegenerate(e=!1){try{const t=$n.getAccessToken(),a=$n.getSelectedAlias();if(!t||!a)return null;const r=await ao.generateToken(t,a,this.onLogoutCallback||void 0,e);return r||null}catch(t){return null}}}so(no,"regenerationPromise",null),so(no,"onLogoutCallback",null);class oo{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&($n.clearAll(),window.location.href=Ue("/login"),!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var io=Object.defineProperty;class lo{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){if(!Fe())return $n.areAllTokensValid()||oo.handleError(e),!1;this.isRetrying=!0;try{return await no.attemptRegeneration()?(this.isRetrying=!1,!0):(oo.handleError(e),this.isRetrying=!1,!1)}catch(r){return oo.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=$n.getAccessToken();return e?$n.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,a)=>{((e,t,a)=>{t in e?io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(lo,"isRetrying",!1);const co=new class{get baseUrl(){return Ge()}async makeApiCall(e,t,a,r){const s=lo.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const n=$n.getAccessToken();if(!n)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const o=r?new URL(r.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)):new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{o.searchParams.append(e,t)});const i=await fetch(o.toString(),{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}async fetchHasCommonV5(e,t){const a=await this.makeApiCall(`/api/common/v1/companies/hasCommonV5/${encodeURIComponent(t)}`,{},e),r=a?.data??a,s=Array.isArray(r)?r[0]:r;return Boolean(s?.hasCommonV5)}mapToQualiexUser(e){let t;return t="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:t}}parseUsersResponse(e,t=""){let a=e;if(e.data)a=e.data;else{if(!Array.isArray(e))return Gn.handleError(`[QualiexApi] Formato de resposta inesperado${t}`,!1),null;a=e}return Array.isArray(a)?a.map(e=>this.mapToQualiexUser(e)):(Gn.handleError(`[QualiexApi] Resposta não é um array${t}`,!1),null)}async fetchUsers(e,t,a="active"){const r={companyId:t,search:"",filterStatus:a};try{const t=await this.makeApiCall("/api/common/v1/companiesusers",r,e);return this.parseUsersResponse(t)??[]}catch(s){if(await lo.handleApiError(s))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",r,e);return this.parseUsersResponse(t," após retry")??[]}catch(n){return Gn.handleError(n instanceof Error?n:"Erro ao buscar usuários após renovação de token",!0),[]}return Gn.handleError(s instanceof Error?s.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(r){return Gn.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t,"active"),r=new Map;return a.forEach(e=>r.set(e.userId,e)),r}async fetchAllUsersMap(e,t){const a=await this.fetchUsers(e,t,"all"),r=new Map;return a.forEach(e=>r.set(e.userId,e)),r}async getUsers(e,t="active"){const a=$n.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId,t):[]}async fetchSoftwares(e){try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(Gn.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(t){if(await lo.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(a){return Gn.handleError(a instanceof Error?a:"Erro ao buscar softwares após renovação de token",!0),[]}return Gn.handleError(t instanceof Error?t.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,t,a){const r=!!a?.baseUrl,s=r?`/Users/${e}/associations`:`/api/common/v1/Users/${e}/associations`,n=r?a.baseUrl:void 0,o=e=>e.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}));try{const e=await this.makeApiCall(s,{},t,n),a=e?.data||e;return Array.isArray(a)?o(a):(Gn.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(i){if(await lo.handleApiError(i))try{const e=await this.makeApiCall(s,{},t,n),a=e?.data||e;return Array.isArray(a)?o(a):[]}catch(l){return Gn.handleError(l instanceof Error?l:"Erro ao buscar associações após renovação de token",!0),[]}return Gn.handleError(i instanceof Error?i.message:"Erro ao buscar associações do usuário",!0),[]}}};function uo(e,t){const a=t||Ze.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function mo(e,t){const a=t||Ze.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function po(e,t){const a=t||Ze.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function ho(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||uo(e.idField),emailField:e.emailField||mo(e.idField),usernameField:e.usernameField||po(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:uo(e),emailField:mo(e),usernameField:po(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const xo=new Map;class fo{static async fetchQualiexUsers(e,t){const a=`${t}_${e}_all`,r=xo.get(a);if(r&&Date.now()-r.timestamp<3e5)return r.users;let s=await co.fetchUsers(e,t,"all");return 0===s.length&&(s=await co.fetchUsers(e,t,"active")),xo.set(a,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,t){const a=new Set;for(const r of e)for(const e of t){const t=r[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const r={...e};for(const s of t){const t=e[s.idField];if(!t)continue;const n=a.get(t);if(n){if(s.nameField){r[s.nameField]||(r[s.nameField]=n.userName||null)}if(s.emailField){r[s.emailField]||(r[s.emailField]=n.userEmail||null)}if(s.usernameField){r[s.usernameField]||(r[s.usernameField]=n.userName||null)}}}return r}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!$n.areAllTokensValid())return e;const a=$n.extractTokenData();if(!a)return e;const{alias:r,companyId:s}=a;if(!r||!s)return e;const n=ho(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(r,s),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return Gn.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}}const go=["responsible_name"],bo=e=>go.includes(e);function vo(e,t,a){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:s,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=r,d=()=>{if(!$n.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return to().schema(i).from(s)},u=(e,t,a,r)=>{let s=d().select(o||"*",{count:"exact"});s=s.eq("is_removed",!1),Object.entries(r).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?s=s.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?s=s.not(e,"is",null):"is_null"===t.operator&&(s=s.is(e,null)):null!==t&&(s=s.eq(e,t)))}),s=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(s,e);const i=t.includes(".");return i||bo(t)||(s=s.order(t,{ascending:"asc"===a})),{query:s,isForeignKey:i}},m=async(e,t,a,s,n)=>{const o=ho(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(bo(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await p.getAll(e);if(!o?.data?.length)return o;const c=await fo.enrichWithUserData(o.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let d;d=i?c.sort((e,r)=>{const s=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],r)||"",o=String(s).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,r)=>{const s=e[t]||"",n=r[t]||"",o=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(c,t,a);const u=((e,t=1,a=25)=>{const r=(t-1)*a,s=r+a;return{data:e.slice(r,s),pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:e.length,itemsPerPage:a,hasNextPage:s<e.length,hasPreviousPage:t>1}}})(d,s,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 fo.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})},p={async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:d}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:r,page:s,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,d),h=((e,t,a)=>{const r=(t-1)*a,s=r+a-1;return e.range(r,s)})(p,o,i),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${s}: ${f.message}`);let b=((e,t,a,r)=>{const s=Math.ceil((t||0)/r);return{data:e,currentPage:a,totalPages:s,totalItems:t||0,itemsPerPage:r,hasNextPage:a<s,hasPreviousPage:a>1}})(x||[],g,o,i);if((e=>{if(!c||!l||0===e.length)return!1;const t=ho(r.userIdFields,r.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await d().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${s}: ${a.message}`);return t},async create(e){const t=Cr(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:r,error:n}=await d().insert(a).select().single();if(n)throw new Error(`Error creating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from create ${s} operation`);return r},async update(e,t){const a={...Cr(t),updated_at:(new Date).toISOString()},{data:r,error:n}=await d().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from update ${s} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await d().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${s}: ${a.message}`)}};return p}const yo={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null},wo=class{static async initialize(){try{const e=Fe();if(e){if($n.checkProjectMismatch())return{...yo}}if(!$n.hasAllTokens()||!$n.areAllTokensValid())return $n.clearExpiredTokens(),{...yo};const t=$n.getAccessToken(),a=$n.getIdToken();$n.clearManualLogout();const r=this.extractUserFromIdToken(a,t),s=this.extractCompaniesFromIdToken(a),n=e?$n.extractTokenData():null,o=this.resolveAliasFromContext(s,t,n?.alias??null);if(e&&(!$n.isSupabaseTokenValid()&&o&&await no.attemptRegeneration(),!$n.isSupabaseTokenValid()))return{...yo};let i=null;if(o){const e=$n.getCompanyId(o),t=s.find(e=>e.alias===o);t&&(i={id:e||t.id,name:t.name,alias:t.alias,appGroupId:$n.getAppGroupId(t.alias)})}const l=n?.placeId??null,c=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:r,alias:o,companies:s,selectedUnit:i,userId:r?.id||null,userAlias:r?.id||null,placeId:l,placeName:c,activePlaceId:l,activePlaceName:c}}catch(e){return{...yo}}}static async loginDev(){if(!Fe())return this.loginProd(),!0;try{const e=to(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL(Ue("/callback"));return r.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e="Lw==";$n.setOAuthState(e);const t=$n.generateOAuthNonce();$n.setOAuthNonce(t);const a=Ue("/callback"),r=new URL(ze.oauth.authUrl);r.searchParams.set("client_id",ze.oauth.clientId),r.searchParams.set("response_type",ze.oauth.responseType),r.searchParams.set("scope",ze.oauth.scope),r.searchParams.set("redirect_uri",a),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),window.location.href=r.toString()}static async processCallback(){try{const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),r=a("access_token"),s=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(r&&s){const e=$n.getAccessToken();e!==r&&$n.clearAll()}const o=Fe();if($n.hasAllTokens()&&$n.areAllTokensValid()){if(o){$n.getValidSupabaseToken()||await no.attemptRegeneration(!0)}return!0}$n.hasAllTokens()&&$n.clearExpiredTokens();const i=r,l=s;if(!i||!l)throw new Error("Tokens não encontrados na URL de callback");$n.setAccessToken(i),$n.setIdToken(l),$n.clearManualLogout();const c=this.extractCompaniesFromIdToken(l),d=this.resolveAliasFromContext(c,i,null);if(!d)throw new Error("Nenhuma empresa encontrada nos tokens");if($n.setSelectedAlias(d),o){if(!await no.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase")}return $n.clearOAuthState(),$n.clearOAuthNonce(),!0}catch(e){throw e}}static async logout(){$n.clearAll(),$n.setManualLogout(),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{}try{const e=Ue("/callback"),t=new URL(ze.oauth.logoutUrl);return t.searchParams.set("client_id",ze.oauth.clientId),t.searchParams.set("redirect_uri",e),t.searchParams.set("response_type",ze.oauth.responseType),t.searchParams.set("scope",ze.oauth.scope),t.searchParams.set("state","Lw=="),void(window.location.href=t.toString())}catch{}window.location.href=Ue("/login")}static decodeToken(e){return Rn.parseJwtPayload(e)}static extractUserFromIdToken(e,t){const a=this.decodeToken(e);if(!a)return null;const r=t?this.decodeToken(t):null;return{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier,isSysAdmin:"1"===r?.admin}}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)a.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,s]=t[e].split("|");r&&s&&a.push({id:"",alias:r.trim(),name:s.trim()})}}});const r=new Map;for(const n of a){if(!n.alias)continue;const e=r.get(n.alias);(!e||!e.id&&n.id)&&r.set(n.alias,n)}const s=Array.from(r.values());a.length,s.length;return s.length,s}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}static getSubdomainAlias(){if("undefined"==typeof window)return null;const e=window.location.hostname;if("localhost"===e||e.startsWith("127.")||e.endsWith(".lovable.app")||e.endsWith(".lovable.dev"))return null;const t=e.split(".");if(t.length<3)return null;const a=t[0];return"www"===a||"admin"===a?null:t.length>=4?t[1]:a}static resolveAliasFromContext(e,t,a){const r=t=>!!t&&e.some(e=>e.alias===t),s=this.getSubdomainAlias();if(r(s))return s;if("undefined"!=typeof window){const e=window.location.hostname.split(".");if(e.length>=4&&r(e[0]))return e[0]}if(r(a))return a;const n=$n.getSelectedAlias();if(r(n))return n;const o=this.extractAliasFromAccessToken(t);return r(o)?o:e[0]?.alias||null}};no.setLogoutCallback(()=>{wo.logout()});let jo=wo;const No=e=>e?.placeId||null,_o=e=>e?.placeName||null,Co=a.createContext(void 0),ko=({children:e,moduleAlias:r})=>{const[s,n]=a.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let o=null;try{o=j.useQueryClient()}catch{}const[i,l]=a.useState(!1),c=a.useRef(0),d=a.useCallback(e=>{n(t=>({...t,...e}))},[]),u=a.useCallback(e=>{n(t=>({...t,isLoading:e}))},[]),m=a.useCallback(()=>{n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=a.useCallback(async e=>{if(e.alias===s.alias)return;const t=++c.current;try{const n=$n.getAccessToken();if(!n)return;const i=$n.getSupabaseToken(),l=s.alias,u=Fe();let m=null;if(u){const a=await ao.generateToken(n,e.alias,void 0,!0);if(c.current!==t)return;if(!a)return;$n.setSupabaseToken(a),m=$n.extractTokenData()}$n.setSelectedAlias(e.alias);const p=m?.alias||e.alias,h=m?.companyId||$n.getCompanyId(e.alias);if(h&&"common"===r)try{const e=await co.fetchHasCommonV5(p,h);if(c.current!==t)return;if(!e){const e=Xe();if(e){i&&$n.setSupabaseToken(i),l&&$n.setSelectedAlias(l);const t=e.endsWith("/")?e:`${e}/`;return void(window.location.href=`${t}${p}`)}}}catch(a){}const x={id:h||e.id,name:e.name,alias:p,appGroupId:$n.getAppGroupId(p)};let f=null,g=null;if(s.user?.id&&p&&h)try{const e=await co.fetchActiveUsersMap(p,h);if(c.current!==t)return;const a=e.get(s.user.id);if(a){const e=(e=>({placeId:No(e),placeName:_o(e)}))(a);f=e.placeId,g=e.placeName}}catch(a){}if(c.current!==t)return;d({alias:p,selectedUnit:x,placeId:f,placeName:g,activePlaceId:f,activePlaceName:g}),o&&await o.clear()}catch(a){}},[d,o,s.user,s.alias,r]),h=a.useCallback(async()=>{kn("AuthContext.processCallback");const e=await An(0,()=>jo.processCallback());if(e){const e=await An(0,()=>jo.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}),o&&o.invalidateQueries({queryKey:["permission"]}))}return e},[d,o]),x=a.useCallback(async()=>{await jo.logout(),m(),o&&await o.clear()},[m,o]),f=a.useCallback(e=>{l(e)},[]),g=a.useCallback(()=>{},[]),b=a.useCallback(()=>{o&&o.invalidateQueries()},[o]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(async()=>{if(e)if($n.areAllTokensValid()){if(Fe()&&!$n.isSupabaseTokenValid())try{await no.attemptRegeneration()||e&&x()}catch(t){e&&x()}}else e&&x()},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await jo.initialize();if(!e)return;t&&t.isAuthenticated?d({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&u(!1)}catch(t){e&&(oo.handleError(t),u(!1))}})(),()=>{e=!1}},[d,u,x]);const v=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,x,h,p,i,f,g,b]);return t.jsx(Co.Provider,{value:v,children:e})},So=()=>{const e=a.useContext(Co);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Ao({queryKey:e,service:t,entityName:r,searchFields:s,additionalFilters:n={},onSuccess:o}){const[i,c]=N.useSearchParams(),d=j.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=So(),{t:h}=y.useTranslation(),x=a.useCallback(t=>{const a=`${e}_${t}`,r=i.get(a);return r||(i.get(t)||"")},[i,e]),f=x("search"),g=x("sortField")||qe.sorting.defaultField,b=x("sortDirection")||qe.sorting.defaultDirection,v=parseInt(x("page")||"1"),w=parseInt(x("limit")||String(qe.pagination.defaultPageSize)),_=f,C=a.useMemo(()=>({search:_,sortField:g,sortDirection:b,page:v,limit:w,...n}),[_,g,b,v,w,n]),k=a.useCallback(()=>t.getAll(C),[t,C]),S=j.useQuery({queryKey:[e,u,m,C],queryFn:k,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${r}". Ensure QueryClientProvider is configured in your app root.`);const A=j.useMutation({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(tt.success.created(r)),o?.()},onError:e=>{l.toast.error(`${tt.error.create(r)}: ${e.message}`)}}),T=j.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(tt.success.updated(r)),o?.()},onError:e=>{l.toast.error(`${tt.error.update(r)}: ${e.message}`)}}),D=j.useMutation({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(tt.success.deleted(r))},onError:e=>{l.toast.error(`${tt.error.delete(r)}: ${e.message}`)}}),E=a.useCallback(t=>{const a={...Object.fromEntries(i)};Object.entries(t).forEach(([t,r])=>{const s=`${e}_${t}`;""===r||0===r?delete a[s]:a[s]=String(r)}),delete a.sortField,delete a.sortDirection,c(a)},[i,c,e]),P=a.useCallback(e=>{E({search:e,page:1})},[E]),I=a.useCallback(e=>{E({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,E]),M=a.useCallback(e=>{E({page:e})},[E]),R=a.useCallback(e=>{E({limit:e,page:1})},[E]),L=a.useCallback(()=>{const t=Object.fromEntries(i),a=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));c(r)},[c,i,e]),[F,z]=a.useState([]),U=a.useCallback(e=>{z(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),O=a.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];z(t=>t.length===e.length?[]:e)},[S?.data?.data]),B=a.useCallback(()=>{z([])},[]),q=a.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&F.length===e.length},[F,S?.data?.data]),V=j.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,a)=>{d.invalidateQueries({queryKey:[e]}),l.toast.success(h("bulk_delete_success",`${a.length} ${r}(s) deletado(s) com sucesso`)),B()},onError:e=>{l.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),$=a.useCallback((e,t)=>{const a=t?t(e):e;e.id?T.mutate({id:e.id,data:a}):A.mutate({...a,alias:u})},[u,A,T]);return{entities: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||qe.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:A?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:D?.isPending??!1,error:S?.error||null,searchTerm:f,sortField:g,sortDirection:b,currentPage:v,itemsPerPage:w,queryKey:e,createEntity:A.mutate,updateEntity:(e,t)=>T.mutate({id:e,data:t}),deleteEntity:D.mutate,save:$,handleSearch:P,handleSort:I,handlePageChange:M,handleItemsPerPageChange:R,clearFilters:L,refetch:S.refetch,selectedIds:F,selectItem:U,selectAll:O,clearSelection:B,isAllSelected:q,bulkDelete:e=>V.mutateAsync(e),isBulkDeleting:V.isPending}}function To(e){const[t,r]=a.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return a.useEffect(()=>{const t=window.matchMedia(e);r(t.matches);const a=e=>{r(e.matches)};return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),t}function Do(e=768){return To(`(max-width: ${e-1}px)`)}const Eo=te.forwardRef(({className:e,...a},r)=>t.jsx("table",{ref:r,className:_r("w-full caption-bottom text-[13px] table-fixed",e),...a}));Eo.displayName="Table";const Po=te.forwardRef(({className:e,...a},r)=>t.jsx("thead",{ref:r,className:_r("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...a}));Po.displayName="TableHeader";const Io=te.forwardRef(({className:e,...a},r)=>t.jsx("tbody",{ref:r,className:_r("[&_tr:last-child]:border-0",e),...a}));Io.displayName="TableBody";const Mo=te.forwardRef(({className:e,...a},r)=>t.jsx("tfoot",{ref:r,className:_r("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a}));Mo.displayName="TableFooter";const Ro=te.forwardRef(({className:e,...a},r)=>t.jsx("tr",{ref:r,className:_r("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",e),...a}));Ro.displayName="TableRow";const Lo=te.forwardRef(({className:e,...a},r)=>t.jsx("th",{ref:r,className:_r("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),...a}));Lo.displayName="TableHead";const Fo=te.forwardRef(({className:e,...a},r)=>t.jsx("td",{ref:r,className:_r("px-4 py-2 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",e),...a}));Fo.displayName="TableCell";const zo=te.forwardRef(({className:e,...a},r)=>t.jsx("caption",{ref:r,className:_r("mt-4 text-sm text-muted-foreground",e),...a}));function Uo({rows:e=5,columns:a=4}){return t.jsx("div",{className:"w-full",children:t.jsxs("div",{className:"rounded-md border",children:[t.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:t.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>t.jsx(hn,{className:"h-4 w-24"},a))})}),t.jsx("div",{children:Array.from({length:e}).map((e,r)=>t.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:t.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>t.jsx(hn,{className:"h-4 w-20"},a))})},r))})]})})}function Oo({count:e=3}){return t.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,a)=>t.jsxs(Pr,{children:[t.jsxs(Ir,{children:[t.jsx(hn,{className:"h-4 w-3/4"}),t.jsx(hn,{className:"h-3 w-1/2"})]}),t.jsx(Lr,{children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(hn,{className:"h-3 w-full"}),t.jsx(hn,{className:"h-3 w-2/3"})]})})]},a))})}zo.displayName="TableCaption";const Bo={default:c.FileX,search:c.Search,error:c.AlertCircle};function qo({icon:e,title:a,description:r,action:s,className:n,variant:o="default"}){const{t:i}=y.useTranslation(),l=!!e,c=Bo[o];return t.jsxs("div",{className:_r("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[t.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:l?e:t.jsx(c,{className:"h-8 w-8 text-muted-foreground"})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),r&&t.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:r}),s&&t.jsx(Sr,{onClick:s.onClick,variant:"outline",children:s.label})]})}function Vo({children:e,className:a}){const r=te.useRef(null),[s,n]=te.useState(!1);te.useEffect(()=>{const e=()=>{const e=r.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return r.current&&t.observe(r.current),()=>t.disconnect()},[e]);const o=t.jsx("div",{ref:r,className:`truncate w-full max-w-full ${a||""}`,children:e});return s?t.jsx(Xs,{delayDuration:300,children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:o}),t.jsx(en,{side:"top",className:"max-w-[400px] break-words",children:e})]})}):o}const $o=te.forwardRef(({direction:e,onMouseDown:a,isDragging:r,className:s},n)=>{const o="horizontal"===e;return t.jsx("div",{ref:n,onMouseDown:a,className:_r("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"],r&&"bg-primary/30",s),children:t.jsx("div",{className:_r("rounded-full bg-border transition-colors group-hover:bg-primary",r&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});$o.displayName="TableResizeHandle";const Wo=me.Root,Ho=me.Trigger,Go=me.Group,Ko=me.Portal,Yo=me.Sub,Qo=me.RadioGroup,Xo=te.forwardRef(({className:e,inset:a,children:r,...s},n)=>t.jsxs(me.SubTrigger,{ref:n,className:_r("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",e),...s,children:[r,t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Xo.displayName=me.SubTrigger.displayName;const Jo=te.forwardRef(({className:e,...a},r)=>t.jsx(me.SubContent,{ref:r,className:_r("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),...a}));Jo.displayName=me.SubContent.displayName;const Zo=te.forwardRef(({className:e,...a},r)=>t.jsx(me.Portal,{children:t.jsx(me.Content,{ref:r,className:_r("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),...a})}));Zo.displayName=me.Content.displayName;const ei=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(me.Item,{ref:s,className:_r("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",e),...r}));ei.displayName=me.Item.displayName;const ti=te.forwardRef(({className:e,children:a,checked:r,...s},n)=>t.jsxs(me.CheckboxItem,{ref:n,className:_r("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:r,...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(me.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),a]}));ti.displayName=me.CheckboxItem.displayName;const ai=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(me.RadioItem,{ref:s,className:_r("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),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(me.ItemIndicator,{children:t.jsx(c.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));ai.displayName=me.RadioItem.displayName;const ri=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(me.Label,{ref:s,className:_r("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",e),...r}));ri.displayName=me.Label.displayName;const si=te.forwardRef(({className:e,...a},r)=>t.jsx(me.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-border",e),...a}));si.displayName=me.Separator.displayName;const ni=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});ni.displayName="ContextMenuShortcut";const oi=({onEdit:e,onDelete:a,onToggleStatus:r,isActive:s=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:l}=y.useTranslation(),d=[];if(e){const t={icon:c.Edit,label:l("edit"),onClick:e};d.push(t)}if(o.forEach(e=>{d.push(e)}),r){const e={icon:s?c.PowerOff:c.Power,label:s?"Inativar":"Ativar",onClick:r};d.push(e)}if(n&&a){const e={icon:c.Trash2,label:l("ap_delete"),onClick:a,destructive:!0};d.push(e)}const u="dropdown"===i?Ws:ei;return t.jsx(t.Fragment,{children:d.map((e,a)=>t.jsxs(u,{onClick:e.onClick,className:_r("whitespace-normal cursor-pointer",e.destructive&&"text-destructive focus:text-destructive"),children:[t.jsx(e.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.label]},a))})},ii=({onEdit:e,onDelete:a,canDelete:r=!0,onToggleStatus:s,isActive:n=!0,customActions:o=[]})=>t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:t.jsx(c.EllipsisVertical,{size:12})})}),t.jsx($s,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:t.jsx(oi,{onEdit:e?t=>{t?.stopPropagation(),e?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:s?e=>{e?.stopPropagation(),s?.()}:void 0,isActive:n,canDelete:r&&!!a,customActions:o,renderAs:"dropdown"})})]}),li=({onEdit:e,onDelete:a,canDelete:r=!0,onToggleStatus:s,isActive:n=!0,customActions:o=[]})=>{const{t:i}=y.useTranslation();return t.jsx(Xs,{delayDuration:200,children:t.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t=>{t.stopPropagation(),e()},children:t.jsx(c.Pencil,{size:14})})}),t.jsx(en,{children:i("edit")})]}),o.map((e,a)=>{const r=e.icon;return t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t=>{t.stopPropagation(),e.onClick()},children:t.jsx(r,{size:14})})}),t.jsx(en,{children:e.label})]},a)}),s&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),s()},children:n?t.jsx(c.ToggleRight,{size:14}):t.jsx(c.ToggleLeft,{size:14})})}),t.jsx(en,{children:n?"Inativar":"Ativar"})]}),a&&r&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:_r("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),a()},children:t.jsx(c.Trash2,{size:14})})}),t.jsx(en,{children:i("ap_delete")})]})]})})},ci=150;function di({columns:e,storageKey:t,onResize:r,enabled:s=!0}){const[n,o]=a.useState(()=>{if(!s||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ci,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ci,e),{})}),[i,l]=a.useState(!1),[c,d]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,t)=>{s&&(t.preventDefault(),t.stopPropagation(),l(!0),d(e),u.current=t.clientX,m.current=n[e]??ci)},[s,n]);a.useEffect(()=>{if(!i||!c)return;const a=e.find(e=>e.key===c),s=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(s,Math.min(n,m.current+t));o(e=>{const t={...e,[c]:a};return r?.(t),t})},h=()=>{l(!1),d(null),t&&o(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,c,e,t,r]),a.useEffect(()=>(i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[i]);const h=a.useCallback(()=>{const a=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ci,e),{});o(a),t&&localStorage.removeItem(t),r?.(a)},[e,t,r]);return{columnWidths:n,isDragging:i,activeColumn:c,handleMouseDown:p,resetWidths:h}}const ui=s.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),mi=te.forwardRef(({className:e,variant:a,size:r,...s},n)=>t.jsx(he.Root,{ref:n,className:_r(ui({variant:a,size:r,className:e})),...s}));mi.displayName=he.Root.displayName;const pi=te.createContext({size:"default",variant:"default"}),hi=te.forwardRef(({className:e,variant:a,size:r,children:s,...n},o)=>t.jsx(pe.Root,{ref:o,className:_r("flex items-center justify-center gap-1",e),...n,children:t.jsx(pi.Provider,{value:{variant:a,size:r},children:s})}));hi.displayName=pe.Root.displayName;const xi=te.forwardRef(({className:e,children:a,variant:r,size:s,...n},o)=>{const i=te.useContext(pi);return t.jsx(pe.Item,{ref:o,className:_r(ui({variant:i.variant||r,size:i.size||s}),e),...n,children:a})});xi.displayName=pe.Item.displayName;const fi=a.memo(function({onNew:e,newButtonLabel:a,showNewButton:r=!0,showSearch:s=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:l=!1,selectedCount:d=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:x,viewMode:f,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],rightSlot:w,className:j}){const{t:N}=y.useTranslation(),_=d>0,C=e&&r||h.length>0,k=x||b||w,S=s&&o;return C||S||k||l&&_?t.jsxs("div",{className:_r("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",j),children:[t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e&&r&&t.jsxs(Sr,{onClick:e,children:[t.jsx(c.Plus,{size:16,className:"mr-2"}),a||"Novo"]}),h.map((e,a)=>{const r=e.icon;return t.jsxs(Sr,{onClick:e.action,variant:e.variant||"outline",disabled:e.disabled,title:e.disabled?e.disabledReason:void 0,children:[r&&t.jsx(r,{size:16,className:"mr-2"}),e.label]},a)})]}),l&&_&&t.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[t.jsx(Es,{variant:"secondary",className:"mr-1 tabular-nums",children:d}),t.jsxs(Xs,{delayDuration:200,children:[u.length>0?u.map((e,a)=>{const r=e.icon,s=e.disabled;return t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:_r("h-8 w-8","destructive"===e.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:s,onClick:()=>e.action([]),children:r?t.jsx(r,{size:16}):t.jsx("span",{className:"text-xs",children:e.label[0]})})}),t.jsx(en,{children:e.label})]},a)}):t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:t.jsx(c.Trash2,{size:16})})}),t.jsx(en,{children:N("ap_delete")})]}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:t.jsx(c.X,{size:16})})}),t.jsx(en,{children:N("clear_selection")})]})]})]}),S&&t.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:t.jsxs("div",{className:"relative w-full",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),k&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[x,b&&f&&g&&t.jsx(hi,{type:"single",value:f,onValueChange:e=>e&&g(e),size:"sm",children:v.map(e=>{const a=(e=>{switch(e){case"table":return c.Table2;case"list":return c.List;case"grid":return c.LayoutGrid}})(e);return t.jsx(xi,{value:e,"aria-label":"Visualizar como "+("table"===e?"tabela":"list"===e?"lista":"grade"),children:t.jsx(a,{className:"h-4 w-4"})},e)})}),w]})]}):null}),gi=a.memo(({checked:e,onCheckedChange:a})=>t.jsx(As,{checked:e,onCheckedChange:a}),(e,t)=>e.checked===t.checked);function bi(e){try{const t=localStorage.getItem(e);if(!t)return null;const a=JSON.parse(t);let r=a.groupByColumns||[];return 0===r.length&&a.groupByColumn&&(r=[a.groupByColumn]),{hiddenColumns:new Set(a.hiddenColumns||[]),columnOrder:a.columnOrder||[],groupByColumns:r}}catch{return null}}function vi({columns:e,storageKey:t,enabled:r=!0,defaultHiddenColumns:s}){const n=a.useMemo(()=>e.map(e=>String(e.key)),[e]),o=a.useMemo(()=>new Set(s??[]),[s]),[i,l]=a.useState(()=>{if(!r)return o;if(!t)return o;const e=bi(t);return e?.hiddenColumns??o}),[c,d]=a.useState(()=>{if(!r||!t)return n;const e=bi(t)?.columnOrder;return e&&e.length>0?e:n}),[u,m]=a.useState(()=>r&&t?bi(t)?.groupByColumns??[]:[]),[p,h]=a.useState(new Set);a.useEffect(()=>{r&&t&&function(e,t){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(t.hiddenColumns),columnOrder:t.columnOrder,groupByColumns:t.groupByColumns}))}catch{}}(t,{hiddenColumns:i,columnOrder:c,groupByColumns:u})},[i,c,u,t,r]),a.useEffect(()=>{const t=new Set(e.map(e=>String(e.key))),a=new Set(c),r=[...t].filter(e=>!a.has(e));if(r.length>0){d(e=>[...e.filter(e=>t.has(e)),...r]);const e=r.filter(e=>o.has(e));e.length>0&&l(t=>new Set([...t,...e]))}},[e,o]);const x=a.useCallback(e=>i.has(e),[i]),f=a.useCallback(e=>{l(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),g=a.useCallback(()=>{l(new Set)},[]),b=a.useCallback(()=>{if(l(o),d(n),m([]),h(new Set),t)try{localStorage.removeItem(t)}catch{}},[n,o,t]),v=a.useCallback((e,t)=>{d(a=>{const r=[...a],[s]=r.splice(e,1);return r.splice(t,0,s),r})},[]),y=a.useCallback(e=>{h(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),w=a.useCallback(e=>{m(e),h(new Set)},[]),j=a.useCallback(e=>{m(t=>t.includes(e)?t:[...t,e])},[]),N=a.useCallback(e=>{m(t=>t.filter(t=>t!==e)),h(t=>{const a=new Set;for(const r of t)r.includes(`${e}:`)||a.add(r);return a})},[]),_=a.useCallback((e,t)=>{m(a=>{const r=[...a],[s]=r.splice(e,1);return r.splice(t,0,s),r}),h(new Set)},[]),C=u[0]??null,k=a.useCallback(e=>{m(e?[e]:[]),h(new Set)},[]),S=a.useMemo(()=>{if(!r)return e;const t=new Map(e.map(e=>[String(e.key),e]));return c.filter(e=>!i.has(e)&&t.has(e)).map(e=>t.get(e))},[e,c,i,r]),A=a.useCallback(e=>{if(0===u.length)return[{groupKey:"__all__",groupValue:"",items:e,count:e.length,level:0}];return function e(t,a,r,s){if(0===a.length)return[{groupKey:s||"__leaf__",groupValue:"",items:t,count:t.length,level:r}];const[n,...o]=a,i=new Map;for(const l of t){const e=String(l[n]??"(vazio)");i.has(e)||i.set(e,[]),i.get(e).push(l)}return Array.from(i.entries()).map(([t,a])=>{const i=s?`${s}|${n}:${t}`:`${n}:${t}`,l=o.length>0?e(a,o,r+1,i):void 0;return{groupKey:i,groupValue:t,items:a,count:a.length,level:r,children:l}})}(e,u,0,"")},[u]);return{visibleColumns:S,allColumns:e,isColumnHidden:x,toggleColumn:f,showAllColumns:g,resetColumns:b,columnOrder:c,reorderColumns:v,groupByColumn:C,setGroupByColumn:k,groupByColumns:u,setGroupByColumns:w,addGroupByColumn:j,removeGroupByColumn:N,reorderGroupByColumns:_,getGroupedData:A,collapsedGroups:p,toggleGroupCollapse:y}}function yi({enabled:e=!1,onReorder:t}){const[r,s]=a.useState(null),[n,o]=a.useState(null),i=a.useCallback(()=>{s(null),o(null)},[]),l=a.useCallback((a,n)=>({draggable:e,onDragStart:t=>{e&&(s(a),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",String(a)),n&&t.dataTransfer.setData("application/column-key",n))},onDragOver:t=>{e&&null!==r&&(t.preventDefault(),t.dataTransfer.dropEffect="move")},onDragEnter:t=>{e&&null!==r&&(t.preventDefault(),o(a))},onDrop:s=>{s.preventDefault(),e&&null!==r&&r!==a?(t(r,a),i()):i()},onDragEnd:()=>{i()}}),[e,r,t,i]);return a.useMemo(()=>({dragFromIndex:r,dragOverIndex:n,isDragging:null!==r,getDragProps:l}),[r,n,l])}function wi({columns:e,columnOrder:r,isColumnHidden:s,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:l,setGroupByColumn:d,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p,resetColumns:h}){const{t:x}=y.useTranslation(),[f,g]=a.useState(null),[b,v]=a.useState(null),w=a.useRef(null),j=new Map(e.map(e=>[String(e.key),e])),N=r.filter(e=>j.has(e)).map(e=>j.get(e)),_=()=>{w.current=null,g(null),v(null)};N.some(e=>s(String(e.key)));const C=N.every(e=>!s(String(e.key)));return t.jsxs(an,{children:[t.jsx(rn,{asChild:!0,children:t.jsx(Sr,{variant:"outline",size:"icon",className:"h-8 w-8",children:t.jsx(c.Columns3,{size:16})})}),t.jsxs(sn,{className:"w-[260px] p-0",align:"end",children:[t.jsx("div",{className:"px-3 py-2 border-b",children:t.jsx("span",{className:"text-sm font-medium",children:x("columns")})}),t.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:t.jsx(Xs,{delayDuration:300,children:N.map((e,a)=>{const r=String(e.key),o=s(r),h=!1!==e.hideable,y=!0===e.groupable,j=u.includes(r)||l===r;return t.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{w.current=e,g(e)})(a),onDragOver:e=>((e,t)=>{e.preventDefault(),v(t)})(e,a),onDrop:()=>(e=>{null!==w.current&&w.current!==e&&i(w.current,e),w.current=null,g(null),v(null)})(a),onDragEnd:_,className:_r("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",f===a&&"opacity-50",b===a&&"border-t-2 border-primary"),children:[t.jsx(c.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx(As,{checked:!o,onCheckedChange:()=>h&&n(r),disabled:!h,className:"shrink-0"}),t.jsx("span",{className:_r("flex-1 truncate",o&&"text-muted-foreground"),children:e.header}),y&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:_r("h-6 w-6 shrink-0",j&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),j?p?p(r):d?.(null):m?m(r):d?.(r)},children:t.jsx(c.Group,{size:14})})}),t.jsx(en,{children:x(j?"remove_grouping":"group_by_column")})]})]},r)})})}),t.jsxs("div",{className:"border-t px-3 py-2 space-y-1",children:[t.jsx(Sr,{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&&t.jsx(Sr,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:h,children:x("reset_default")})]})]})]})}function ji({columns:e,groupByColumns:r,addGroupByColumn:s,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,l]=a.useState(!1),[d,u]=a.useState(null),[m,p]=a.useState(null),h=new Map(e.map(e=>[String(e.key),e])),x=()=>{u(null),p(null)},f=r.length>0;return t.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 t=e.dataTransfer.getData("application/column-key");if(t&&!r.includes(t)){const e=h.get(t);e&&e.groupable&&s(t)}},className:_r("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:[t.jsx(c.Group,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:f?r.map((e,r)=>{const s=h.get(e);if(!s)return null;const i=d===r,l=m===r&&d!==r;return t.jsxs(a.Fragment,{children:[r>0&&t.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),t.jsxs(Es,{variant:"secondary",className:_r("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",l&&"ring-2 ring-primary"),draggable:!0,onDragStart:e=>((e,t)=>{e.stopPropagation(),e.dataTransfer.setData("application/group-chip-index",String(t)),e.dataTransfer.effectAllowed="move",u(t)})(e,r),onDragOver:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),p(t)})(e,r),onDrop:e=>((e,t)=>{e.preventDefault(),e.stopPropagation();const a=e.dataTransfer.getData("application/group-chip-index");if(""!==a){const e=parseInt(a,10);isNaN(e)||e===t||o(e,t)}u(null),p(null)})(e,r),onDragEnd:x,children:[s.header,t.jsx("button",{onClick:t=>{t.stopPropagation(),n(e)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:t.jsx(c.X,{size:12})})]})]},e)}):t.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const Ni=({manager:r,columns:s,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:u,enableBulkActions:m=!1,rowActionsVariant:p="dropdown",onNew:h,newButtonLabel:x,showNewButton:f=!0,customActions:g=[],hideActionBar:b,showActionBar:v=!0,showSearch:w=!1,searchValue:j,onSearchChange:N,searchPlaceholder:_,bulkActions:C=[],onBulkDelete:k,filters:S,viewMode:A,onViewModeChange:T,showViewToggle:D=!1,enableColumnResize:E=!0,resizeStorageKey:P,enableColumnManager:I=!0,columnManagerStorageKey:M,defaultHiddenColumns:R,enableGrouping:L=!1,enableExpandableRows:F=!1,renderExpandedContent:z,expandedRowIds:U,onToggleExpand:O,defaultExpandAll:B=!1,hideActionsColumn:q=!1,readOnly:V=!1})=>{const{t:$}=y.useTranslation(),{setSearchVisible:W}=So(),H=Do(),[G,K]=a.useState(()=>B&&F?new Set(r.entities.map(e=>e.id)):new Set),Y=void 0!==U,Q=Y?new Set(U):G,X=a.useCallback(e=>{Y&&O?O(e):K(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[Y,O]),J=void 0!==b?!b:v;a.useEffect(()=>{if(!w)return W(!0),()=>W(!1)},[W,w]);const Z=vi({columns:s,storageKey:M,enabled:I,defaultHiddenColumns:R}),ee=yi({enabled:I,onReorder:Z.reorderColumns}),te=I?Z.visibleColumns:s,{columnWidths:ae,isDragging:re,activeColumn:se,handleMouseDown:ne}=di({columns:te.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:P?`${P}-columns`:void 0,enabled:E}),oe=a.useMemo(()=>(()=>{if(E){const e=te.map(e=>ae[String(e.key)]??e.width??e.minWidth??150),t=e.reduce((e,t)=>e+t,0);return te.map((a,r)=>({...a,calculatedWidth:e[r],style:{width:e[r]/t*100+"%"}}))}let e=0;const t=te.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,r=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:r,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[te,E,ae]),ie=h||g.length>0||w||m||S||D||I,le=J&&ie,ce=q||V,de=k||(()=>{r.bulkDelete?.(r.selectedIds)}),ue=e=>t.jsx(Fo,{className:"text-center",children:d?d(e):"inline"===p?t.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:t.jsx(li,{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):[]})}):t.jsx(ii,{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):[]})}),me=e=>t.jsx(Zo,{className:"w-[160px]",children:t.jsx(oi,{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"})}),pe=I?t.jsx(wi,{columns:s,columnOrder:Z.columnOrder,isColumnHidden:Z.isColumnHidden,toggleColumn:Z.toggleColumn,showAllColumns:Z.showAllColumns,resetColumns:Z.resetColumns,reorderColumns:Z.reorderColumns,groupByColumn:L?Z.groupByColumn:void 0,setGroupByColumn:L?Z.setGroupByColumn:void 0,groupByColumns:L?Z.groupByColumns:void 0,addGroupByColumn:L?Z.addGroupByColumn:void 0,removeGroupByColumn:L?Z.removeGroupByColumn:void 0}):void 0;if(H)return r.isLoading?t.jsx(Oo,{count:3}):0===r.entities.length?t.jsx(qo,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"}):t.jsxs("div",{className:"flex flex-col h-full",children:[le&&t.jsx(fi,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:w,searchValue:j,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:r.selectedIds.length,bulkActions:C,onBulkDelete:de,onClearSelection:r.clearSelection,customActions:g,filters:S,viewMode:A,onViewModeChange:T,showViewToggle:D}),t.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:r.entities.map(e=>{const a=t.jsx(Pr,{className:_r("overflow-hidden cursor-pointer hover:bg-muted/50",m&&r.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),m?r.selectItem(e.id):n?.(e)},children:t.jsx(Lr,{className:"p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[m&&t.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),t.jsxs("div",{className:"flex-1",children:[te.map(a=>t.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[t.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),t.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(e):String(e[a.key]??"")})]},String(a.key))),(n||o||d)&&t.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(e):t.jsx(ii,{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):[]})})]})]})})},e.id);return V?a:t.jsxs(Wo,{children:[t.jsx(Ho,{asChild:!0,children:a}),me(e)]},e.id)})})]});const he=L&&Z.groupByColumns.length>0?Z.getGroupedData(r.entities):null,xe=null!==he,fe=(F?1:0)+(m?1:0)+te.length+(ce?0:1),ge=e=>{const s=F&&Q.has(e.id),o=t.jsxs(Ro,{className:_r("cursor-pointer hover:bg-muted/50 relative",("inline"===p||ce)&&"group",m&&r.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),m?r.selectItem(e.id):n?.(e)},children:[F&&t.jsx(Fo,{className:"w-[40px] px-2",children:t.jsx("button",{onClick:t=>{t.stopPropagation(),X(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":$(s?"collapse_row":"expand_row"),children:s?t.jsx(c.ChevronDown,{size:16,className:"text-muted-foreground"}):t.jsx(c.ChevronRight,{size:16,className:"text-muted-foreground"})})}),m&&t.jsx(Fo,{onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),te.map(a=>t.jsx(Fo,{className:a.className,children:t.jsx(Vo,{children:a.render?a.render(e):String(e[a.key]??"")})},String(a.key))),!ce&&ue(e)]});return t.jsxs(a.Fragment,{children:[V?o:t.jsxs(Wo,{children:[t.jsx(Ho,{asChild:!0,children:o}),me(e)]}),s&&z&&t.jsx(Ro,{className:"bg-muted/30 hover:bg-muted/30",children:t.jsx(Fo,{colSpan:fe,className:"p-0",children:t.jsx("div",{className:"animate-accordion-down overflow-hidden",children:z(e)})})})]},e.id)},be=(e,r)=>e.map(e=>{const s=Z.collapsedGroups.has(e.groupKey),n=16*e.level,o=Math.max(30,70-15*e.level);return t.jsxs(a.Fragment,{children:[t.jsx(Ro,{className:_r("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>Z.toggleGroupCollapse(e.groupKey),children:t.jsx(Fo,{colSpan:r,className:"py-2 px-4",children:t.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[s?t.jsx(c.ChevronRight,{size:16}):t.jsx(c.ChevronDown,{size:16}),t.jsx("span",{children:e.groupValue}),t.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",e.count,")"]})]})})}),!s&&(e.children?be(e.children,r):e.items.map(ge))]},e.groupKey)});return t.jsxs("div",{className:"flex flex-col h-full",children:[le&&t.jsx(fi,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:w,searchValue:j,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:r.selectedIds.length,bulkActions:C,onBulkDelete:de,onClearSelection:r.clearSelection,customActions:g,filters:S,viewMode:A,onViewModeChange:T,showViewToggle:D}),r.isLoading?t.jsx(Uo,{rows:5,columns:te.length}):t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[L&&t.jsx(ji,{columns:s,groupByColumns:Z.groupByColumns,addGroupByColumn:Z.addGroupByColumn,removeGroupByColumn:Z.removeGroupByColumn,reorderGroupByColumns:Z.reorderGroupByColumns}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs(Eo,{className:"table-fixed w-full",children:[t.jsxs("colgroup",{children:[F&&t.jsx("col",{style:{width:"40px"}}),m&&t.jsx("col",{style:{width:"50px"}}),oe.map((e,a)=>t.jsx("col",{style:e.style},a)),!ce&&t.jsx("col",{style:{width:"inline"===p?"auto":"50px",minWidth:"50px"}})]}),t.jsx(Po,{children:t.jsxs(Ro,{children:[F&&t.jsx(Lo,{className:"w-[40px]"}),m&&t.jsx(Lo,{className:"w-[50px]",children:t.jsx(gi,{checked:r.isAllSelected,onCheckedChange:r.selectAll})}),te.map((e,a)=>{const s=E&&!1!==e.resizable,n=se===String(e.key),o=I?ee.getDragProps(a,String(e.key)):{},i=ee.dragFromIndex===a,l=ee.dragOverIndex===a&&ee.dragFromIndex!==a;return t.jsxs(Lo,{className:_r(e.className,!1!==e.sortable&&"hover:bg-muted/50 cursor-pointer","relative transition-opacity",I&&ee.isDragging&&"cursor-grabbing",i&&"opacity-50",l&&"border-l-2 border-primary"),onClick:!1!==e.sortable?()=>r.handleSort(String(e.key)):void 0,...o,children:[t.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,!1!==e.sortable&&(d=String(e.key),r.sortField!==d?null:"asc"===r.sortDirection?t.jsx(c.ArrowUp,{size:14,className:"ml-1"}):t.jsx(c.ArrowDown,{size:14,className:"ml-1"}))]}),s&&t.jsx($o,{direction:"horizontal",onMouseDown:t=>ne(String(e.key),t),isDragging:n})]},String(e.key));var d}),!ce&&t.jsx(Lo,{className:"w-[50px] text-center",children:pe||e.t("actions")})]})}),t.jsx(Io,{children:0===r.entities.length?t.jsx(Ro,{children:t.jsx(Fo,{colSpan:fe,className:"h-32",children:t.jsx(qo,{title:e.t("no_items_found_empty"),description:"Não há dados para exibir no momento.",variant:"search"})})}):xe?be(he,fe):r.entities.map(ge)})]})})]})]})};function _i(e,t,r,s){const[n,o]=a.useState({}),[i,l]=a.useState({}),c=a.useMemo(()=>e,[e]),d=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let s;if("function"==typeof e.validation?s=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(s=e.validation.custom),s)try{const e=s(t,a);if(e)return e}catch(r){}}};a.useEffect(()=>{if(!s)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},a=e(c),n={};a.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);d(e)&&(a=e.toISOString().split("T")[0])}else d(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),t&&Object.keys(t).forEach(e=>{a.find(t=>t.name===e)||void 0===t[e]||(n[e]=t[e])}),o(n),l({}),r&&r(n)},[c,t,r,s]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},x=()=>{const e=h(c),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const s={...a,[e]:t},n=((e,t)=>{let a={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(c).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,s);return r&&r(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(c).find(t=>t.name===e);if(a){const r=p(a,t,n);r&&l(t=>({...t,[e]:r}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(n)}}}const Ci=[{name:"gray",hue:220,saturation:8},{name:"red",hue:0,saturation:80},{name:"pink",hue:330,saturation:75},{name:"purple",hue:270,saturation:70},{name:"indigo",hue:230,saturation:75},{name:"blue",hue:210,saturation:85},{name:"cyan",hue:190,saturation:75},{name:"teal",hue:170,saturation:65},{name:"green",hue:140,saturation:60},{name:"yellow",hue:45,saturation:90},{name:"orange",hue:25,saturation:90}],ki=[10,22,35,45,55,68,78,87,94].flatMap(e=>Ci.map(({hue:t,saturation:a})=>((e,t,a)=>{a/=100;const r=t=>(t+e/30)%12,s=(t/=100)*Math.min(a,1-a),n=e=>{const t=a-s*Math.max(-1,Math.min(r(e)-3,Math.min(9-r(e),1)));return Math.round(255*t).toString(16).padStart(2,"0")};return`#${n(0)}${n(8)}${n(4)}`})(t,a,e))),Si=({value:e="#3b82f6",onChange:r,label:s,customColorLabel:n,presetColorsLabel:o,showHexValue:i=!0})=>{const{t:l}=y.useTranslation(),d=n??l("custom_color"),u=o??l("preset_colors"),[m,p]=a.useState(!1),h=a.useRef([]),x=Ci.length,f=a.useMemo(()=>{const t=ki.findIndex(t=>t.toLowerCase()===e.toLowerCase());return t>=0?t:0},[e]),[g,b]=a.useState(f);a.useEffect(()=>{m&&(b(f),requestAnimationFrame(()=>{h.current[f]?.focus()}))},[m,f]);const v=e=>{const t=Math.max(0,Math.min(ki.length-1,e));b(t),h.current[t]?.focus()},w=e=>{r?.(e),p(!1)};return t.jsxs("div",{className:"space-y-2",children:[s&&t.jsx(Er,{children:s}),t.jsxs(an,{open:m,onOpenChange:p,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",className:"w-full justify-between text-left font-normal",onKeyDown:e=>{"ArrowDown"!==e.key&&" "!==e.key&&"Spacebar"!==e.key||(e.preventDefault(),p(!0))},children:[t.jsxs("span",{className:"flex items-center min-w-0",children:[t.jsx("span",{className:"h-4 w-4 rounded border mr-2 shrink-0",style:{backgroundColor:e}}),i&&t.jsx("span",{className:"truncate",children:e})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4 opacity-50 shrink-0"})]})}),t.jsx(sn,{className:"w-auto p-3",onOpenAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{h.current[f]?.focus()})},children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(Er,{children:u}),t.jsx("div",{className:"grid gap-1 mt-2",style:{gridTemplateColumns:`repeat(${Ci.length}, minmax(0, 1fr))`},onKeyDown:e=>{switch(e.key){case"ArrowRight":e.preventDefault(),v(g+1);break;case"ArrowLeft":e.preventDefault(),v(g-1);break;case"ArrowDown":e.preventDefault(),v(g+x);break;case"ArrowUp":e.preventDefault(),v(g-x);break;case"Home":e.preventDefault(),v(0);break;case"End":e.preventDefault(),v(ki.length-1);break;case"Enter":e.preventDefault(),w(ki[g]);break;case"Tab":e.preventDefault(),p(!1)}},role:"grid",children:ki.map((a,r)=>{const s=a.toLowerCase()===e.toLowerCase();return t.jsx("button",{ref:e=>{h.current[r]=e},type:"button",tabIndex:r===g?0:-1,className:"h-5 w-5 rounded-sm border transition-transform hover:scale-110 hover:z-10 focus:outline-none focus:ring-2 focus:ring-ring focus:z-10 "+(s?"border-foreground ring-2 ring-foreground/30":"border-border/40"),style:{backgroundColor:a},onClick:()=>w(a),"aria-label":`Selecionar cor ${a}`},`${a}-${r}`)})})]}),t.jsxs("div",{children:[t.jsx(Er,{htmlFor:"color-input",children:d}),t.jsx(Tr,{id:"color-input",type:"color",value:e,onChange:e=>r?.(e.target.value),className:"h-8 w-full mt-2"})]})]})})]})]})},Ai=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(xe.Root,{ref:s,className:_r("relative overflow-hidden",e),...r,children:[t.jsx(xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),t.jsx(Ti,{}),t.jsx(xe.Corner,{})]}));Ai.displayName=xe.Root.displayName;const Ti=te.forwardRef(({className:e,orientation:a="vertical",...r},s)=>t.jsx(xe.ScrollAreaScrollbar,{ref:s,orientation:a,className:_r("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:t.jsx(xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Ti.displayName=xe.ScrollAreaScrollbar.displayName;const Di=[{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 Ei({name:e,filled:a,className:r}){return t.jsx("span",{className:`material-symbols-outlined ${r??""}`,style:a?{fontVariationSettings:"'FILL' 1"}:void 0,children:e})}const Pi=({value:e=null,onChange:r,label:s,noIconLabel:n="SEM ÍCONE",color:o="text-foreground/60"})=>{const[i,l]=a.useState(!1),d=a.useRef([]),u=e?function(e){return Di.find(t=>t.name===e)}(e):null,m=a.useMemo(()=>{if(!e)return 0;const t=Di.findIndex(t=>t.name===e);return t>=0?t:0},[e]),[p,h]=a.useState(m);a.useEffect(()=>{i&&(h(m),requestAnimationFrame(()=>{d.current[m]?.focus()}))},[i,m]);const x=a.useCallback(e=>{const t=Math.max(0,Math.min(Di.length-1,e));h(t),d.current[t]?.focus()},[]),f=a.useCallback(e=>{r?.(e),l(!1)},[r]),g=a.useCallback(e=>{"ArrowDown"!==e.key&&" "!==e.key&&"Spacebar"!==e.key||(e.preventDefault(),l(!0))},[]),b=a.useCallback(e=>{switch(e.key){case"ArrowRight":e.preventDefault(),x(p+1);break;case"ArrowLeft":e.preventDefault(),x(p-1);break;case"ArrowDown":e.preventDefault(),x(p+10);break;case"ArrowUp":e.preventDefault(),x(p-10);break;case"Home":e.preventDefault(),x(0);break;case"End":e.preventDefault(),x(Di.length-1);break;case"Enter":e.preventDefault(),f(Di[p]?.name??null);break;case"Tab":e.preventDefault(),l(!1)}},[p,x,f]);return t.jsxs("div",{className:"space-y-2",children:[s&&t.jsx(Er,{children:s}),t.jsxs(an,{open:i,onOpenChange:l,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",className:"justify-start text-left font-normal gap-2",onKeyDown:g,children:[u?t.jsx(Ei,{name:u.name,filled:u.filled,className:`text-xl ${o}`}):t.jsx("span",{className:"text-muted-foreground text-sm",children:n}),t.jsx(c.ChevronDown,{className:"ml-auto h-4 w-4 opacity-50"})]})}),t.jsx(sn,{className:"w-auto max-w-[min(640px,calc(100vw-2rem))] p-3",align:"start",onOpenAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{d.current[m]?.focus()})},children:t.jsxs("div",{className:"space-y-3",children:[t.jsx(Ai,{className:"max-h-[min(480px,calc(100vh-12rem))]",children:t.jsx("div",{className:"grid grid-cols-10 gap-1",onKeyDown:b,role:"grid",children:Di.map((a,r)=>t.jsx("button",{ref:e=>{d.current[r]=e},type:"button",tabIndex:r===p?0:-1,className:`flex items-center justify-center p-1.5 rounded border transition-colors ${o} ${e===a.name?"bg-accent border-ring":"border-transparent hover:bg-accent"}`,onClick:()=>f(a.name),title:a.name,children:t.jsx(Ei,{name:a.name,filled:a.filled,className:"text-2xl"})},a.name))})}),t.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:()=>f(null),children:n})]})})]})]})},Ii=te.forwardRef(({className:e,...a},r)=>t.jsx(fe.Root,{className:_r("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),...a,ref:r,children:t.jsx(fe.Thumb,{className:_r("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Ii.displayName=fe.Root.displayName;const Mi=(e={})=>{const{user:t,alias:a}=So(),{enabled:r=!0,status:s="active"}=e;return j.useQuery({queryKey:["qualiex-users",a,s],queryFn:()=>co.getUsers(a,s),enabled:r&&!!a&&!!t,staleTime:3e5,retry:2,retryDelay:1e3})},Ri=({value:r,onChange:s,multiple:n=!1,label:o,required:i,placeholder:l,icon:c,maxDisplayedBadges:d,className:u,disabled:m,enabled:p,displayFormat:h="name",customDisplayFn:x,filterFn:f,sortOptions:g=!0,popoverContainer:b,onOpen:v,onClose:w})=>{const{t:j}=y.useTranslation(),{data:N=[],isLoading:_,error:C}=Mi({enabled:p}),[k,S]=a.useState(new Map),A=a.useMemo(()=>r?Array.isArray(r)?r.filter(Boolean):[r].filter(Boolean):[],[r]),T=a.useMemo(()=>{if(0===A.length||0===N.length)return"";const e=new Set(N.map(e=>e.userId||e.id||""));return A.filter(t=>t&&!e.has(t)&&!k.has(t)).sort().join(",")},[A,N,k]);a.useEffect(()=>{if(!T)return;const e=T.split(",");let t=!1;const a=$n.extractTokenData();return a?.alias&&a?.companyId?(co.fetchUsers(a.alias,a.companyId,"all").then(a=>{t||S(t=>{const r=new Map(t);for(const s of e){const e=a.find(e=>e.userId===s||e.id===s);e&&r.set(s,{...e,isActive:e.isActive??!1})}return r})}).catch(()=>{}),()=>{t=!0}):void 0},[T]);const D=a.useMemo(()=>f?N.filter(f):N,[N,f]),E=a.useMemo(()=>{if(0===A.length)return D;const t=new Set(D.map(e=>e.userId||e.id||"")),a=A.filter(e=>e&&!t.has(e));if(0===a.length)return D;const r=a.map(t=>{const a=k.get(t);return a||{userId:t,id:t,userName:e.t("inactive_user"),userEmail:"",isActive:!1}});return[...D,...r]},[D,A,k]),P=a.useCallback(t=>{let a;if("custom"===h&&x)a=x(t);else{const e=t.userName||"";switch(h){case"name-email":a=t.userEmail?`${e} (${t.userEmail})`:e;break;case"name-role":a=t.roleName?`${e} - ${t.roleName}`:e;break;default:a=e}}return!1===t.isActive?`${a} (${e.t("inactive")})`:a},[h,x]);return t.jsx(gn,{multiple:n,value:r??(n?[]:""),onChange:s,options:E,isLoading:_,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:P,placeholder:l||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:j("no_results"),label:o,required:i,icon:c,maxDisplayedBadges:d,disabled:m,className:u,sortOptions:g,popoverContainer:b,onOpen:v,onClose:w})};function Li({title:e,sections:r,initialData:s,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:c=!1,usersData:d}){const[u,m]=a.useState(r?.[0]?.id||""),p=a.useRef(null),[h,x]=a.useState(null),f=a.useCallback(e=>{p.current=e,x(e)},[]),g=a.useMemo(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:b,errors:v,updateField:y,handleSubmit:w}=_i(g,s,void 0,i),j=a.useMemo(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[r,b]),N=a.useMemo(()=>{const e=j.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=j.find(e=>!e.disabled);return t?.id||u},[j,u]);a.useEffect(()=>{N!==u&&m(N)},[N,u]);const _=j.find(e=>e.id===N),C=e=>{const a=(e.computedValue,b[e.name]),r=void 0!==a?a:"",s=v[e.name];switch(e.type){case"group":const a="horizontal"===e.layout,n=a?`flex gap-3 w-full ${e.className||""}`:"space-y-3",o=a?_r("space-y-2 w-full",e.wrapperClassName):_r("space-y-2",e.className,e.wrapperClassName);return t.jsxs("div",{className:o,children:[e.label,t.jsx("div",{className:n,children:e.fields?.map(e=>C(e))})]},e.name);case"user-select":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Ri,{value:r||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-destructive":""}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"textarea":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Ts,{id:e.name,value:r||"",onChange:t=>{y(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,rows:e.rows,maxLength:e.maxLength,className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"select":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsxs(bs,{value:String(r),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[t.jsx(ws,{className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,children:t.jsx(ys,{placeholder:e.placeholder})}),t.jsx(_s,{children:e.options?.map(e=>t.jsx(ks,{value:e.value,children:e.label},e.value))})]}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"multiselect":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(gn,{options:e.options||[],value:Array.isArray(r)?r:[],onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,error:s,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"date":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"date",value:String(r),onChange:t=>y(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:_r("w-full",s?"border-destructive":"",e.disabled?"bg-muted cursor-not-allowed":"")}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"color":return t.jsxs("div",{children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"color",value:r||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),s&&t.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"color-picker":return t.jsxs("div",{children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Si,{value:r||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),s&&t.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"icon-picker":return t.jsxs("div",{children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Pi,{value:r||e.defaultValue||null,onChange:t=>y(e.name,t)}),s&&t.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"custom":if(!e.component)return null;const i=e.component,l="function"==typeof e.componentProps?e.componentProps(b):e.componentProps||{};return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(i,{value:r,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:s,popoverContainer:h,...l}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"number":return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"number",value:null!=r?String(r):"",onChange:t=>{const a=t.target.value,r=""===a?null:Number(a);y(e.name,r)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"checkbox":return t.jsxs("div",{className:`flex items-center space-x-2 ${e.className||""}`,children:[t.jsx(As,{id:e.name,checked:!!r,onCheckedChange:t=>y(e.name,t),disabled:e.disabled}),t.jsxs(Er,{htmlFor:e.name,className:"cursor-pointer",children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name);case"switch":return t.jsxs("div",{className:`flex items-center justify-between space-x-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Ii,{id:e.name,checked:!!r,onCheckedChange:t=>y(e.name,t),disabled:e.disabled}),s&&t.jsx("p",{className:"text-sm text-destructive mt-2",children:s})]},e.name);default:return t.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[t.jsxs(Er,{htmlFor:e.name,children:[e.label,e.required&&t.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.jsx(Tr,{id:e.name,type:"text",value:r||"",onChange:t=>{y(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:e.disabled}),s&&t.jsx("p",{className:"text-sm text-destructive",children:s})]},e.name)}},k=a.useCallback(()=>{if(!_)return null;if(_.disabled)return t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:t.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),t.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 t.jsx(e,{formData:b,updateField:y,errors:v,users:d,disabled:_.disabled})}return t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.fields.map(C)})},[_,b,y,v,d,C]),S=t.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[j.length>1&&t.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:t.jsx("div",{className:"flex space-x-2",children:j.map(e=>t.jsx(Sr,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=j.find(t=>t.id===e);t&&!t.disabled&&m(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:c?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):t.jsxs("form",{onSubmit:w(n),className:"space-y-3 md:space-y-4",children:[k(),t.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[t.jsx(Sr,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),t.jsx(Sr,{type:"submit",disabled:c,children:l||"Salvar"})]})]})})]});return t.jsx(Qr,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:t.jsxs(as,{ref:f,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[t.jsxs(rs,{showSeparator:!0,children:[t.jsx(os,{children:e}),t.jsx(is,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Fi({currentPage:e,totalPages:a,totalItems:r,itemsPerPage:s,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:l}=y.useTranslation();if(0===r)return null;const d=(e-1)*s+1,u=Math.min(e*s,r);return t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:l("rows_per_page","Linhas por página")}),t.jsxs(bs,{value:String(s),onValueChange:e=>o(Number(e)),children:[t.jsx(ws,{className:"h-8 w-[70px]",children:t.jsx(ys,{})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"10",children:"10"}),t.jsx(ks,{value:"25",children:"25"}),t.jsx(ks,{value:"50",children:"50"}),t.jsx(ks,{value:"100",children:"100"})]})]})]})}),t.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[d,"-",u," ",l("of","de")," ",r," ",l("items","itens")]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===e,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronsLeft,{size:16})}),t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronLeft,{size:16})}),t.jsxs("div",{className:"flex items-center gap-1 px-2",children:[t.jsx("span",{className:"text-sm font-medium",children:e}),t.jsx("span",{className:"text-sm text-muted-foreground",children:l("of","de")}),t.jsx("span",{className:"text-sm font-medium",children:a})]}),t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===a,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronRight,{size:16})}),t.jsx(Sr,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:e===a,className:"h-8 w-8 p-0",children:t.jsx(c.ChevronsRight,{size:16})})]})]})}function zi({manager:e}){return t.jsx(Fi,{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 Ui={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Oi={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Bi={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function qi({children:e,direction:a="column",gap:r="md",align:s="stretch",justify:n="start",wrap:o=!1,className:i}){return t.jsx("div",{className:_r("flex","column"===a?"flex-col":"flex-row",Ui[r],Oi[s],Bi[n],o&&"flex-wrap",i),children:e})}function Vi({manager:e,filters:a,inline:r=!1}){const{t:s}=y.useTranslation(),{isSearchVisible:n}=So(),o=e.searchTerm,i=t.jsxs(t.Fragment,{children:[a.some(e=>"search"===e.type)&&!n&&t.jsxs("div",{className:"relative flex-1",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(Tr,{placeholder:"Pesquisar",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((e,a)=>t.jsxs(bs,{value:e.value||"",onValueChange:t=>e.onChange?.(t),children:[t.jsx(ws,{className:"w-[180px]",children:t.jsx(ys,{placeholder:e.placeholder})}),t.jsx(_s,{children:e.options.map(e=>t.jsx(ks,{value:e.value,children:e.label},e.value))})]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((e,a)=>{const s=e.component;return t.jsx("div",{className:r?"":"w-full sm:w-auto",children:t.jsx(s,{...e.props})},`custom-${a}`)}),o&&t.jsxs(Sr,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[t.jsx(c.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return r?t.jsx("div",{className:"flex items-center gap-2",children:i}):t.jsx(qi,{direction:"column",gap:"md",className:"mb-6",children:t.jsx(qi,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function $i({manager:e,config:r,formSections:s,onSave:n,onToggleStatus:o,defaultSort:i,readOnly:l=!1}){e&&e.queryKey;const{setSearchVisible:c}=So(),[d,u]=N.useSearchParams(),[m,p]=a.useState(!1),[h,x]=a.useState(null),[f,g]=a.useState({isOpen:!1,entityId:null,entityName:""}),[b,v]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(i&&e){const t=`${e.queryKey}_sortField`,a=`${e.queryKey}_sortDirection`;if(!d.has(t)&&!d.has(a)){const e=Object.fromEntries(d);e[t]=i.column,e[a]=i.direction,u(e)}}},[]);const y=!l&&s.length>0?e=>{r.onEdit?r.onEdit(e):(x(e),p(!0))}:void 0,w=l||"function"!=typeof e?.deleteEntity?void 0:e=>{g({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},j=()=>{g({isOpen:!1,entityId:null,entityName:""})},_=void 0!==r.hideNewButton?!r.hideNewButton:r.showNewButton??!0,C=(r.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 t.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(r.showActionBar??!0)&&t.jsx(fi,{onNew:()=>{r.onNew?r.onNew():(x(null),p(!0))},newButtonLabel:r.newButtonLabel,showNewButton:_,showSearch:r.showSearch,searchValue:e.searchTerm,onSearchChange:e.handleSearch,searchPlaceholder:r.searchPlaceholder,showBulkActions:r.enableBulkActions,selectedCount:e.selectedIds.length,bulkActions:r.bulkActions,onBulkDelete:()=>{v({isOpen:!0,count:e.selectedIds.length})},onClearSelection:e.clearSelection,customActions:C,filters:r.filters&&r.filters.length>0?t.jsx(Vi,{manager:e,filters:r.filters,inline:!0}):void 0}),t.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?t.jsx("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(e.entities,e)}):t.jsx(Ni,{manager:e,columns:r.columns,onEdit:y,onDelete:w,onToggleStatus:o,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions,enableColumnManager:!0,columnManagerStorageKey:`crud-${r.entityName.toLowerCase().replace(/\s+/g,"-")}-columns`,resizeStorageKey:`crud-${r.entityName.toLowerCase().replace(/\s+/g,"-")}-resize`,defaultHiddenColumns:r.defaultHiddenColumns,readOnly:l})}),t.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:t.jsx(zi,{manager:e})}),!r.useCustomRouting&&!r.onNew&&s.length>0&&t.jsx(Li,{open:m,title:h?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:h||void 0,onSubmit:e=>{n(e),p(!1),x(null)},onCancel:()=>{p(!1),x(null)},isLoading:e.isLoading,submitButtonText:h?"Atualizar":"Criar"}),t.jsx(Qr,{open:f.isOpen,onOpenChange:j,children:t.jsxs(as,{size:"sm",variant:"destructive",children:[t.jsx(rs,{showSeparator:!0,children:t.jsx(os,{children:"Você tem certeza absoluta?"})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",t.jsx("strong",{children:f.entityName}),". Esta ação não pode ser desfeita."]})}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:j,children:"Cancelar"}),t.jsx(Sr,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof e?.deleteEntity&&(e.deleteEntity(f.entityId),g({isOpen:!1,entityId:null,entityName:""}))},disabled:e.isDeleting,children:e.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),t.jsx(Qr,{open:b.isOpen,onOpenChange:()=>v({isOpen:!1,count:0}),children:t.jsxs(as,{size:"sm",variant:"destructive",children:[t.jsx(rs,{showSeparator:!0,children:t.jsx(os,{children:"Você tem certeza absoluta?"})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",t.jsx("strong",{children:b.count})," ",1===b.count?r.entityName:r.entityNamePlural,". Esta ação não pode ser desfeita."]})}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>v({isOpen:!1,count:0}),children:"Cancelar"}),t.jsx(Sr,{variant:"destructive",onClick:()=>{e.bulkDelete?.(e.selectedIds),v({isOpen:!1,count:0})},disabled:e.isBulkDeleting,children:e.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Wi(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Hi(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Gi(e={}){const{paramName:t="alias"}=e,r=N.useParams(),{alias:s,companies:n}=So(),o=r[t]||null;return a.useMemo(()=>{if(!o)return{urlAlias:null,isAliasMismatch:!1,isValidAlias:!1,isMissing:!0,matchedCompany:null};const e=n?.find(e=>e.alias===o)||null,t=!!e;return{urlAlias:o,isAliasMismatch:t&&o!==s,isValidAlias:t,isMissing:!1,matchedCompany:e}},[o,s,n])}const Ki=s.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),Yi={info:c.Info,warning:c.Info,danger:c.AlertTriangle,success:c.CheckCircle},Qi=te.forwardRef(({className:e,variant:a="info",showIcon:r=!0,children:s,...n},o)=>{const i=Yi[a||"info"];return t.jsxs("div",{ref:o,role:"alert",className:_r(Ki({variant:a}),e),...n,children:[r&&t.jsx(i,{className:"h-4 w-4"}),s]})});Qi.displayName="Alert";const Xi=te.forwardRef(({className:e,...a},r)=>t.jsx("h5",{ref:r,className:_r("mb-1 font-medium leading-none tracking-tight",e),...a}));Xi.displayName="AlertTitle";const Ji=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("text-sm [&_p]:leading-relaxed",e),...a}));Ji.displayName="AlertDescription";const Zi=te.forwardRef(({className:e,...a},r)=>t.jsx(ge.Root,{ref:r,className:_r("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...a}));Zi.displayName=ge.Root.displayName;const el=te.forwardRef(({className:e,...a},r)=>t.jsx(ge.Image,{ref:r,className:_r("aspect-square h-full w-full",e),...a}));el.displayName=ge.Image.displayName;const tl=te.forwardRef(({className:e,...a},r)=>t.jsx(ge.Fallback,{ref:r,className:_r("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...a}));function al(){return Ge()||"https://common-v4-api.qualiex.com"}function rl(){const e=Qe();if(e)return e;const t=al().match(/^https?:\/\/common-v4-api(-[^.]+)?\.(.+)$/);if(t){return`https://login-api${t[1]||""}.${t[2]}`}return"https://login-api.qualiex.com"}function sl(e){const t=$n.getAccessToken();if(!t)throw new Error("Token Qualiex não encontrado");if(!e)throw new Error("Alias é obrigatório para chamadas à API Qualiex");return{Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json","un-alias":e}}async function nl(e,t,a){const r=async()=>{const r=await fetch(e,{...a,headers:{...sl(t),...a?.headers||{}}});if(!r.ok){const e=new Error(`API Error: ${r.status}`);throw e.status=r.status,e.statusCode=r.status,e}return r};try{return await r()}catch(s){if(await lo.handleApiError(s))return await r();throw s}}async function ol(e){const t=$n.getAccessToken(),a=$n.getIdToken();if(!t||!a)throw new Error("Sessão inválida. Faça login novamente.");const r=function(e){const t=Rn.parseJwtPayload(e),a="string"==typeof t?.subNewId?t.subNewId.trim():"";if(!a)throw new Error("NewId do usuário não encontrado no id-token.");return a}(a),s=$n.getSelectedAlias()?.trim()||$n.extractTokenData()?.alias||"",n=`${rl()}/api/Users/UpdatePhotoByNewIdAsync?newId=${encodeURIComponent(r)}`,o=async()=>{const r=$n.getAccessToken()||t,o=$n.getIdToken()||a,i=$n.getAppGroupId(s)?.toString()??"1",l=new FormData;l.append(e.name,e,e.name);const c=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${r}`,"id-token":o,Accept:"application/json, text/plain, */*",...s?{"un-alias":s}:{},AppGroupId:i},body:l});if(!c.ok){const e=new Error(`Upload falhou: ${c.status} ${c.statusText}`);throw e.status=c.status,e.statusCode=c.status,e}};try{await o()}catch(i){if(await lo.handleApiError(i))try{return void await o()}catch(l){throw Gn.handleError(l instanceof Error?l:"Erro ao enviar foto após renovação de token",!1),l}throw i}}tl.displayName=ge.Fallback.displayName;const il={"en-US":1,"pt-BR":2,"es-ES":3,"fr-FR":4};function ll(e,t){const a=e?.trim();if(a)return a;const r=Rn.parseJwtPayload(t),s="string"==typeof r?.subNewId?r.subNewId.trim():"";if(s)return s;throw new Error("Identificador do usuário não encontrado.")}function cl(e){const t=$n.getSelectedAlias()?.trim();if(t)return t;const a=$n.getSupabaseToken(),r=a?Rn.parseJwtPayload(a):null,s="string"==typeof r?.alias?r.alias.trim():"string"==typeof r?.default?r.default.trim():"string"==typeof r?.user_alias?r.user_alias.trim():"";if(s)return s;const n=Rn.parseJwtPayload(e),o="string"==typeof n?.default?n.default.trim():"string"==typeof n?.alias?n.alias.trim():"string"==typeof n?.user_alias?n.user_alias.trim():"";if(o)return o;for(const i in n||{}){if(!/^co\d+$/.test(i))continue;const e=n?.[i];if("string"!=typeof e)continue;const[t]=e.split(";");if(t?.trim())return t.trim()}}async function dl(e){const t=$n.getAccessToken(),a=$n.getIdToken();if(!t||!a)throw new Error("Sessão inválida. Faça login novamente.");const r=ll(e.newId,a),s=cl(a),n={};e.name&&e.name.trim()&&(n.Name=e.name.trim()),e.email&&e.email.trim()&&(n.Email=e.email.trim());const o=function(e){if(void 0!==e)return null===e||""===e?null:"number"==typeof e?1===e||2===e||3===e||4===e?e:null:il[e]??null}(e.language);void 0!==o&&(n.LanguageId=o);const i=`${rl()}/api/Users/UpdateUserProfile/${encodeURIComponent(r)}`,l=async()=>{const e=$n.getAccessToken()||t,r=$n.getIdToken()||a,o=$n.getAppGroupId(s)?.toString()??"1",l=await fetch(i,{method:"PUT",headers:{Authorization:`Bearer ${e}`,"id-token":r,...s?{"un-alias":s}:{},AppGroupId:o,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const e=new Error(`Falha ao atualizar perfil: ${l.status} ${l.statusText}`);throw e.status=l.status,e.statusCode=l.status,e}};try{await l()}catch(c){if(await lo.handleApiError(c))return void await l();throw c}}const ul={1:"en-US",2:"pt-BR",3:"es-ES",4:"fr-FR"};function ml(e,...t){for(const a of t){const t=e[a];if("string"==typeof t&&t.trim())return t}return null}async function pl(e){const t=$n.getAccessToken(),a=$n.getIdToken();if(!t||!a)throw new Error("Sessão inválida. Faça login novamente.");const r=ll(e,a),s=cl(a),n=`${rl()}/api/Users/GetUserProfileByNewId/${encodeURIComponent(r)}`,o=async()=>{const e=$n.getAccessToken()||t,o=$n.getIdToken()||a,i=$n.getAppGroupId(s)?.toString()??"1",l=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${e}`,"id-token":o,...s?{"un-alias":s}:{},AppGroupId:i,Accept:"application/json, text/plain, */*"}});if(404===l.status){const e=new Error("Usuário não encontrado.");throw e.status=404,e.statusCode=404,e}if(!l.ok){const e=new Error(`Falha ao obter perfil: ${l.status} ${l.statusText}`);throw e.status=l.status,e.statusCode=l.status,e}const c=await l.json(),d=function(e,...t){for(const a of t){const t=e[a];if("number"==typeof t&&Number.isFinite(t))return t;if("string"==typeof t&&t.trim()&&!Number.isNaN(Number(t)))return Number(t)}return null}(c,"languageId","LanguageId"),u=1===d||2===d||3===d||4===d?d:null,m=ml(c,"photoUrl","PhotoUrl");let p=null;if(m)if(/^https?:\/\//i.test(m))p=m;else{const e=m.replace(/^\/+/,""),t=e.includes("?")?"&":"?";p=`${rl()}/api/${e}${t}size=96`}return{newId:r,name:ml(c,"name","Name"),email:ml(c,"email","Email"),languageId:u,language:u?ul[u]:null,photoUrl:p}};try{return await o()}catch(i){if(await lo.handleApiError(i))return await o();throw i}}const hl=[{value:"pt-BR",label:"Português (Brasil)"},{value:"en-US",label:"English (US)"},{value:"es-ES",label:"Español"}],xl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,fl=({open:e,onOpenChange:r,user:s,userPhotoUrl:n,userInitials:o})=>{const{t:i,i18n:d}=y.useTranslation(),u=a.useRef(null),[m,p]=a.useState(null),[h,x]=a.useState(null),[f,g]=a.useState(d.language||"pt-BR"),[b,v]=a.useState(s.name||""),[w,j]=a.useState(s.email||""),[N,_]=a.useState(!1),[C,k]=a.useState(null);a.useEffect(()=>{if(!e)return;v(s.name||""),j(s.email||""),g(d.language||"pt-BR"),k(null);let t=!1;return(async()=>{try{const e=await pl(s.id||void 0);if(t)return;e.name&&v(e.name),e.email&&j(e.email),e.language&&g(e.language),k(e.photoUrl)}catch{}})(),()=>{t=!0}},[e,s.id,s.name,s.email,d.language]);const S=m||C||n,A=e=>{N||(e||(p(null),x(null),g(d.language||"pt-BR"),v(s.name||""),j(s.email||"")),r(e))};return t.jsx(Qr,{open:e,onOpenChange:A,children:t.jsxs(as,{className:"sm:max-w-md",children:[t.jsx(rs,{children:t.jsx(os,{children:i("edit_profile","Editar Perfil")})}),t.jsxs(ss,{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs(Zi,{className:"w-24 h-24 flex-shrink-0 ring-2 ring-border ring-offset-2 ring-offset-background",children:[S&&t.jsx(el,{src:S,alt:s.name||""}),t.jsx(tl,{className:"bg-primary text-primary-foreground font-semibold text-2xl",children:o})]}),t.jsxs("div",{children:[t.jsxs(Sr,{variant:"outline",size:"sm",onClick:()=>u.current?.click(),children:[t.jsx(c.Camera,{className:"mr-2 h-4 w-4"}),i("change_photo","Trocar foto")]}),t.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const t=e.target.files?.[0];if(!t)return;const a=URL.createObjectURL(t);p(a),x(t)}})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"profile-name",children:i("name","Nome")}),t.jsx(Tr,{id:"profile-name",value:b,onChange:e=>v(e.target.value),maxLength:150,autoComplete:"name",readOnly:!0,className:"bg-muted cursor-not-allowed"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"profile-email",children:i("email","E-mail")}),t.jsx(Tr,{id:"profile-email",type:"email",value:w,onChange:e=>j(e.target.value),maxLength:200,autoComplete:"email",readOnly:!0,className:"bg-muted cursor-not-allowed"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:i("language","Idioma")}),t.jsxs(bs,{value:f,onValueChange:g,children:[t.jsx(ws,{children:t.jsx(ys,{})}),t.jsx(_s,{children:hl.map(e=>t.jsx(ks,{value:e.value,children:e.label},e.value))})]})]})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>A(!1),disabled:N,children:i("cancel","Cancelar")}),t.jsxs(Sr,{onClick:async()=>{if(b.trim())if(xl.test(w.trim())){_(!0);try{if(h)try{await ol(h),window.dispatchEvent(new Event("user-photo-updated")),l.toast.success("Foto atualizada com sucesso")}catch(e){const t=e instanceof Error?e.message:String(e);l.toast.error("Falha ao atualizar foto"+(t?`: ${t}`:""))}if(b.trim()!==(s.name||"")||w.trim()!==(s.email||"")||f!==d.language)try{await dl({newId:s.id||void 0,name:b.trim(),email:w.trim(),language:f}),l.toast.success("Perfil atualizado com sucesso")}catch(e){const t=e instanceof Error?e.message:String(e);l.toast.error(t||"Falha ao atualizar perfil")}f!==d.language&&d.changeLanguage(f),x(null),p(null),r(!1)}finally{_(!1)}}else l.toast.error("Informe um e-mail válido.");else l.toast.error("Informe o nome.")},disabled:N,children:[N&&t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),N?i("saving","Salvando..."):i("save","Salvar")]})]})]})})},gl=a.createContext(void 0);function bl({children:e,actions:r}){const{t:s}=y.useTranslation(),[n,o]=a.useState({}),[i,l]=a.useState(r);a.useEffect(()=>{l(r)},[r]);const c=a.useCallback(()=>o({}),[]),d=a.useMemo(()=>({metadata:n,setMetadata:o,clearMetadata:c,headerActions:i,setHeaderActions:l}),[n,c,i]);return t.jsx(gl.Provider,{value:d,children:e})}function vl(){const e=a.useContext(gl);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var yl={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",cannot_be_own_leader:"Um líder não pode ser seu próprio superior",change_photo:"Trocar foto",clear_filters:"Limpar filtros",clear_formatting:"Limpar Formatação",clear_search:"Limpar busca",clear_selection:"Limpar seleção",close:"Fechar",collapse:"Colapsar",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",create:"Criar",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_name:"Editar Nome",edit_profile:"Editar Perfil",electronic_signature:"Assinatura Eletrônica",email:"E-mail",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:"Expandir",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_direct_subordinates:"Subordinados diretos:",leadership_drag_hint:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote",leadership_drag_to_hierarchy:"Arraste para a hierarquia acima",leadership_immediate_superior:"Superior Imediato",leadership_load_error:"Erro ao carregar hierarquia de liderança",leadership_make_root:"Tornar Líder Raiz",leadership_make_root_short:"Tornar Raiz",leadership_no_direct_subordinates:"Sem subordinados diretos",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_confirmation:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita.",leadership_remove_team:"Remover da equipe",leadership_search_superior:"Buscar superior...",leadership_select_subordinates:"Selecione pelo menos um liderado",leadership_unassociated_users:"Usuários não associados",leadership_users_associated:"{{count}} usuário associado",leadership_users_associated_count:"Usuários associados: {{count}}",leadership_users_associated_plural:"{{count}} usuários associados",leadership_users_unassociated_count:"Usuários não associados: {{count}}",learn_qualiex:"Aprenda a usar o Qualiex",leave_without_saving:"Sair sem salvar",lines_per_page:"Linhas por página",link:"Link",loading:"Carregando...",login_with_qualiex:"Entrar com Qualiex",manage_access:"Gerenciar Acessos",mind_map_add_child:"Adicionar filho",mind_map_add_sibling:"Adicionar irmão",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar tudo",mind_map_delete_node:"Excluir nó",mind_map_expand_all:"Expandir tudo",mind_map_export_image:"Exportar como imagem",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar à tela",mind_map_redo:"Refazer",mind_map_undo:"Desfazer",mind_map_zoom_in:"Aproximar",mind_map_zoom_out:"Afastar",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",name:"Nome",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",none_bracketed:"[Nenhum]",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",removing:"Removendo...",replace:"Substituir",report:"Relatório",request_date:"Data da solicitação",required_field:"Campo obrigatório",resend_code:"Reenviar código",reset_default:"Redefinir padrão",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",selected_count:"{{count}} selecionado",selected_count_plural:"{{count}} 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:"Subordinados",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?",update:"Atualizar",updates:"Atualizações",updates_bar_close:"Fechar",updates_dialog_close:"Fechar",updates_dialog_do_not_show_again:"Não exibir novamente",updates_dialog_like:"Curtir",updating:"Atualizando...",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..."},wl={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",cannot_be_own_leader:"A leader cannot be their own superior",change_photo:"Change photo",clear_filters:"Clear filters",clear_formatting:"Clear Formatting",clear_search:"Clear search",clear_selection:"Clear selection",close:"Close",collapse:"Collapse",collapse_row:"Collapse row",columns:"Columns",conclude:"Finish",confirm_removal:"Confirm removal",could_not_load_info:"Could not load the information",create:"Create",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_name:"Edit Name",edit_profile:"Edit Profile",electronic_signature:"Electronic Signature",email:"Email",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:"Expand",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_direct_subordinates:"Direct subordinates:",leadership_drag_hint:"Drag rows to reorganize • Select multiple to move in bulk",leadership_drag_to_hierarchy:"Drag to the hierarchy above",leadership_immediate_superior:"Immediate Superior",leadership_load_error:"Failed to load leadership hierarchy",leadership_make_root:"Make Root Leader",leadership_make_root_short:"Make Root",leadership_no_direct_subordinates:"No direct subordinates",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_confirmation:"Are you sure you want to remove this leader? This action cannot be undone.",leadership_remove_team:"Remove from team",leadership_search_superior:"Search superior...",leadership_select_subordinates:"Select at least one subordinate",leadership_unassociated_users:"Unassociated users",leadership_users_associated:"{{count}} user associated",leadership_users_associated_count:"Associated users: {{count}}",leadership_users_associated_plural:"{{count}} users associated",leadership_users_unassociated_count:"Unassociated users: {{count}}",learn_qualiex:"Learn how to use Qualiex",leave_without_saving:"Leave without saving",lines_per_page:"Lines per page",link:"Link",loading:"Loading...",login_with_qualiex:"Login with Qualiex",manage_access:"Manage Access",mind_map_add_child:"Add child",mind_map_add_sibling:"Add sibling",mind_map_aria_label:"Mind map",mind_map_collapse_all:"Collapse all",mind_map_delete_node:"Delete node",mind_map_expand_all:"Expand all",mind_map_export_image:"Export as image",mind_map_export_json:"Export as JSON",mind_map_fit_to_screen:"Fit to screen",mind_map_redo:"Redo",mind_map_undo:"Undo",mind_map_zoom_in:"Zoom in",mind_map_zoom_out:"Zoom out",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",name:"Name",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",none_bracketed:"[None]",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",removing:"Removing...",replace:"Replace",report:"Report",request_date:"Request date",required_field:"Required field",resend_code:"Resend code",reset_default:"Reset to default",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",selected_count:"{{count}} selected",selected_count_plural:"{{count}} 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:"Subordinates",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?",update:"Update",updates:"Updates",updates_bar_close:"Close",updates_dialog_close:"Close",updates_dialog_do_not_show_again:"Do not show again",updates_dialog_like:"Like",updating:"Updating...",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..."},jl={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",cannot_be_own_leader:"Un líder no puede ser su propio superior",change_photo:"Cambiar foto",clear_filters:"Limpiar filtros",clear_formatting:"Limpiar Formato",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",close:"Cerrar",collapse:"Colapsar",collapse_row:"Contraer fila",columns:"Columnas",conclude:"Concluir",confirm_removal:"Confirmar eliminación",could_not_load_info:"No se pudo cargar la información",create:"Crear",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_name:"Editar Nombre",edit_profile:"Editar Perfil",electronic_signature:"Firma Electrónica",email:"Correo electrónico",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:"Expandir",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_direct_subordinates:"Subordinados directos:",leadership_drag_hint:"Arrastre las filas para reorganizar • Seleccione múltiples para mover en lote",leadership_drag_to_hierarchy:"Arrastre a la jerarquía anterior",leadership_immediate_superior:"Superior Inmediato",leadership_load_error:"Error al cargar la jerarquía de liderazgo",leadership_make_root:"Hacer Líder Raíz",leadership_make_root_short:"Hacer Raíz",leadership_no_direct_subordinates:"Sin subordinados directos",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_confirmation:"¿Está seguro de que desea eliminar este líder? Esta acción no se puede deshacer.",leadership_remove_team:"Quitar del equipo",leadership_search_superior:"Buscar superior...",leadership_select_subordinates:"Seleccione al menos un subordinado",leadership_unassociated_users:"Usuarios no asociados",leadership_users_associated:"{{count}} usuario asociado",leadership_users_associated_count:"Usuarios asociados: {{count}}",leadership_users_associated_plural:"{{count}} usuarios asociados",leadership_users_unassociated_count:"Usuarios no asociados: {{count}}",learn_qualiex:"Aprenda a usar Qualiex",leave_without_saving:"Salir sin guardar",lines_per_page:"Líneas por página",link:"Enlace",loading:"Cargando...",login_with_qualiex:"Iniciar sesión con Qualiex",manage_access:"Gestionar Accesos",mind_map_add_child:"Agregar hijo",mind_map_add_sibling:"Agregar hermano",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar todo",mind_map_delete_node:"Eliminar nodo",mind_map_expand_all:"Expandir todo",mind_map_export_image:"Exportar como imagen",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar a la pantalla",mind_map_redo:"Rehacer",mind_map_undo:"Deshacer",mind_map_zoom_in:"Acercar",mind_map_zoom_out:"Alejar",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",name:"Nombre",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",none_bracketed:"[Ninguno]",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",removing:"Eliminando...",replace:"Reemplazar",report:"Informe",request_date:"Fecha de solicitud",required_field:"Campo obligatorio",resend_code:"Reenviar código",reset_default:"Restablecer predeterminado",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",selected_count:"{{count}} seleccionado",selected_count_plural:"{{count}} 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:"Subordinados",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?",update:"Actualizar",updates:"Actualizaciones",updates_bar_close:"Cerrar",updates_dialog_close:"Cerrar",updates_dialog_do_not_show_again:"No mostrar de nuevo",updates_dialog_like:"Me gusta",updating:"Actualizando...",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 Nl="true"===(void 0).VITE_I18N_DEBUG_MODE;function _l(t,a){e.addResourceBundle(t,"app",a,!0,!0)}Nl&&e.use({type:"postProcessor",name:"debugKeys",process:(e,t)=>`🔑 ${Array.isArray(t)?t[0]:t}`}),e.use(y.initReactI18next).init({resources:{"pt-BR":{core:yl},"en-US":{core:wl},"es-ES":{core:jl}},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:Nl?["debugKeys"]:[]});const Cl=a.createContext({moduleAlias:null,associationsBaseUrl:null,signDocumentsSchema:"common",signDocumentsTable:"sign_documents"});function kl({moduleAlias:e=null,associationsBaseUrl:a=null,signDocumentsSchema:r="common",signDocumentsTable:s="sign_documents",children:n}){return t.jsx(Cl.Provider,{value:{moduleAlias:e,associationsBaseUrl:a,signDocumentsSchema:r,signDocumentsTable:s},children:n})}function Sl(){return a.useContext(Cl)}const Al={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},Tl=6e5;function Dl(e){const{moduleAlias:t,associationsBaseUrl:r}=Sl(),{alias:s,user:n,isAuthenticated:o}=So(),i=e??t,l=n?.id??null,c=o&&!!s&&!!l,{data:d=[],isLoading:u}=j.useQuery({queryKey:["qualiex-associations",l,s,r??null],queryFn:()=>co.fetchUserAssociations(l,s,r?{baseUrl:r}:void 0),enabled:c,staleTime:Tl,gcTime:12e5}),m=a.useMemo(()=>s&&0!==d.length?d.find(e=>e.companyAlias===s)??null:null,[d,s]),p=a.useCallback(e=>{if(!m)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const t=Al[e];return void 0!==t&&m.softwares.includes(t)})},[m]);return{hasAccess:a.useMemo(()=>!i||p(i),[i,p]),isLoading:c&&u,role:a.useMemo(()=>m?{id:m.roleId,name:m.roleName}:null,[m]),association:m,hasAccessTo:p}}const El={"pt-br":"pt-BR","pt-BR":"pt-BR",en:"en-US","en-US":"en-US",es:"es-ES","es-ES":"es-ES",fr:"fr-FR","fr-FR":"fr-FR"};function Pl(){const{association:t}=Dl(),r=t?.language;return a.useEffect(()=>{if(!r)return;const t=El[r];t&&e.language!==t&&e.changeLanguage(t)},[r]),null}const Il=a.createContext(void 0),Ml={locale:rr,timezone:nr,datetimeFormat:sr},Rl=async()=>{},Ll=({children:e})=>t.jsx(Il.Provider,{value:{...Ml,setLocale:Rl,setTimezone:Rl,setDatetimeFormat:Rl,isLoading:!1},children:e}),Fl=()=>{const e=a.useContext(Il);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},zl=be.Root,Ul=be.CollapsibleTrigger,Ol=be.CollapsibleContent;var Bl=Object.defineProperty,ql=(e,t,a)=>((e,t,a)=>t in e?Bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class Vl extends a.Component{constructor(t){super(t),ql(this,"copyErrorDetails",()=>{const t=Gn.getErrors().slice(0,2),a=`\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${t.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||e.t("no_errors_recorded")}\n `.trim();navigator.clipboard.writeText(a),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,t){if((void 0).DEV)throw e;Gn.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Gn.getErrors().slice(0,2);return t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(Pr,{className:"w-full max-w-2xl",children:[t.jsxs(Ir,{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx(c.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),t.jsx(Mr,{children:e.t("something_went_wrong")})]}),t.jsxs(Lr,{className:"space-y-4",children:[t.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),t.jsxs(zl,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[t.jsx(Ul,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[t.jsx(c.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),t.jsxs(Ol,{className:"mt-4 space-y-4",children:[t.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),t.jsxs("div",{className:"text-sm space-y-2",children:[t.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||e.t("unknown_error")}),this.state.error?.stack&&t.jsx(Ai,{className:"h-32 w-full rounded border bg-muted p-2",children:t.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&t.jsxs("div",{className:"pt-3 border-t",children:[t.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),t.jsx("div",{className:"space-y-2",children:a.map((e,a)=>t.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),t.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),t.jsxs(Sr,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[t.jsx(c.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),t.jsx(Sr,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const $l=ve.Root,Wl=te.forwardRef(({className:e,...a},r)=>t.jsx(ve.List,{ref:r,className:_r("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));Wl.displayName=ve.List.displayName;const Hl=te.forwardRef(({className:e,...a},r)=>t.jsx(ve.Trigger,{ref:r,className:_r("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),...a}));Hl.displayName=ve.Trigger.displayName;const Gl=te.forwardRef(({className:e,...a},r)=>t.jsx(ve.Content,{ref:r,className:_r("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));function Kl({className:e}){return t.jsxs("svg",{className:e,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.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"}),t.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"}),t.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 Yl({className:e}){return t.jsxs("svg",{className:e,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.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"}),t.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"}),t.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"})]})}Gl.displayName=ve.Content.displayName;const Ql={init(e){!function(e){try{return t=window,a=document,r="clarity",s="script",n=e,void(a.getElementById("clarity-script")||(t[r]=t[r]||function(){(t[r].q=t[r].q||[]).push(arguments)},(o=a.createElement(s)).async=1,o.src="https://www.clarity.ms/tag/"+n+"?ref=npm",o.id="clarity-script",(i=a.getElementsByTagName(s)[0]).parentNode.insertBefore(o,i)))}catch(l){return}var t,a,r,s,n,o,i}(e)},setTag(e,t){window.clarity("set",e,t)},identify(e,t,a,r){window.clarity("identify",e,t,a,r)},consent(e=!0){window.clarity("consent",e)},consentV2(e={ad_Storage:"granted",analytics_Storage:"granted"}){window.clarity("consentv2",e)},upgrade(e){window.clarity("upgrade",e)},event(e){window.clarity("event",e)}},Xl="forlogic_";function Jl(){return"undefined"!=typeof window&&"function"==typeof window.clarity}function Zl(){return"undefined"!=typeof window&&"piggyback"===window.__forlogicClarityMode}function ec(e){return Zl()?`${Xl}${e}`:e}function tc(e){return Zl()?`${Xl}${e}`:e}function ac(e){try{e()}catch(t){(void 0).DEV}}function rc(e){for(const[t,a]of Object.entries(e))null!=a&&""!==a&&Ql.setTag(tc(t),a)}function sc({module:e,isContracted:t,sourceModule:a,alias:r}){Jl()&&ac(()=>{rc({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:String(t),source_module:a,alias:r}),Ql.event(ec("module_menu_click"))})}function nc({module:e,sourceModule:t,alias:a}){Jl()&&ac(()=>{rc({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:"false",source_module:t,alias:a}),Ql.event(ec("module_interest_click"))})}function oc({resource:e,sourceModule:t,alias:a}){Jl()&&ac(()=>{rc({footer_resource:e,source_module:t,alias:a}),Ql.event(ec("module_footer_click"))})}function ic({educaUrl:e="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:a="https://sabergestao.com.br/",wikiUrl:r,alias:s,sourceModule:n}){const{t:o}=y.useTranslation(),i=br(e||r||"https://educacao.sabergestao.com.br/{alias}/fe",s),l=e=>{oc({resource:e,sourceModule:n,alias:s})};return t.jsxs("div",{className:"flex-shrink-0 pt-4",children:[t.jsx(zr,{className:"mb-4"}),t.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[t.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[t.jsxs("div",{className:"relative z-10",children:[t.jsx("h4",{className:"font-semibold text-sm text-white",children:o("learn_qualiex")}),t.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",t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),t.jsx(Kl,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),t.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[t.jsxs("div",{className:"relative z-10",children:[t.jsx("h4",{className:"font-semibold text-sm text-foreground",children:o("know_saber_gestao")}),t.jsxs("a",{href:a,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",t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),t.jsx(Yl,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),t.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[t.jsxs("div",{className:"relative z-10",children:[t.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),t.jsxs("a",{href:r||"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",t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),t.jsx(c.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}const lc=[{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}"}]},{id:"backoffice",label:"Backoffice",modules:[{name:"Backoffice",description:"Operações administrativas",color:"bg-[#5C6BC0]",url:"https://admin.qualiex.com/{alias}",alwaysContracted:!0}]}];function cc({module:e,onClick:a}){return t.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[t.jsx("div",{className:_r("w-4 h-4 rounded-sm shrink-0 mt-0.5",e.color)}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:e.name}),e.description&&t.jsx("div",{className:"text-sm text-muted-foreground truncate",children:e.description})]})]})}function dc(e,t){if(0===e.length)return e;const a=Math.ceil(e.length/t),r=[];for(let s=0;s<a;s++)for(let n=0;n<t;n++){const t=n*a+s;t<e.length&&r.push(e[t])}return r}function uc({modules:e,onModuleClick:r,contractedModules:s,onModuleInterest:n}){const o=function(){const[e,t]=a.useState(4);return a.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?t(4):window.matchMedia("(min-width: 768px)").matches?t(3):window.matchMedia("(min-width: 640px)").matches?t(2):t(1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...e].sort((e,t)=>e.name.localeCompare(t.name)),l=void 0!==s,c=e=>!0===e.alwaysContracted||!l||s.includes(e.name),d=i.filter(c),u=l?i.filter(e=>!c(e)):[],m=dc(d,o),p=dc(u,o),h=(e,t)=>{t?r?.(e):n?.(e)};return t.jsxs("div",{className:"space-y-6",children:[m.length>0&&t.jsx("section",{children:t.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=>t.jsx(cc,{module:e,onClick:()=>h(e,!0)},e.name))})}),p.length>0&&t.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[t.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:p.map(e=>t.jsx(cc,{module:e,onClick:()=>h(e,!1)},e.name))})]})]})}function mc({onModuleClick:e,contractedModules:r,onModuleInterest:s,nonContractedUrl:n="https://qualiex.com/",educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,alias:c,sourceModule:d,showAdminGroup:u=!1}){const[m,p]=a.useState("qualiex"),h=u?lc.find(e=>"backoffice"===e.id)?.modules??[]:[],x=lc.filter(e=>"backoffice"!==e.id).map(e=>"qualiex"===e.id?{...e,modules:[...e.modules,...h]}:e),f=e=>{nc({module:e,sourceModule:d,alias:c}),window.open(n,"_blank","noopener,noreferrer"),s?.(e)};return t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[t.jsxs($l,{value:m,onValueChange:p,className:"flex-1 flex flex-col min-h-0",children:[t.jsx(Wl,{className:"w-fit shrink-0",children:x.map(e=>t.jsxs(Hl,{value:e.id,children:[e.label,t.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),x.map(a=>t.jsx(Gl,{value:a.id,className:"flex-1 mt-4 overflow-auto pr-2",children:t.jsx(uc,{modules:a.modules,onModuleClick:t=>{return s=t,n=a.id,sc({module:s,isContracted:!!s.alwaysContracted||"qualiex"!==n||!r||r.includes(s.name),sourceModule:d,alias:c}),void e?.(s);var s,n},contractedModules:"qualiex"===a.id?r:void 0,onModuleInterest:f})},a.id))]}),t.jsx(ic,{educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:c,sourceModule:d})]})}function pc(e){const{association:t}=Dl();return a.useMemo(()=>{if(e)return e;if(!t?.softwares)return;const a=t.softwares,r=lc.find(e=>"qualiex"===e.id);return r?r.modules.filter(e=>{if(!e.softwareAlias)return!1;const t=Al[e.softwareAlias];return void 0!==t&&a.includes(t)}).map(e=>e.name):void 0},[e,t])}function hc({open:e,onOpenChange:a,onModuleClick:r,contractedModules:s,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:c,showAdminGroup:d}){const{alias:u,user:m}=So(),p=pc(s),h=d??!!m?.isSysAdmin;return t.jsx(Qr,{open:e,onOpenChange:a,children:t.jsxs(as,{size:"lg",className:"overflow-hidden flex flex-col",children:[t.jsx(rs,{className:"sr-only",children:t.jsx(os,{children:"Módulos"})}),t.jsx(mc,{onModuleClick:e=>{r?r(e):e.url&&gr(br(e.url,u||void 0))},contractedModules:p,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:u||void 0,sourceModule:c,showAdminGroup:h})]})})}function xc({open:r,onOpenChange:s,onModuleClick:n,contractedModules:o,onModuleInterest:i,userName:l,unitName:d,units:u=[],currentAlias:m,onUnitChange:p,onLogout:h,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,blocking:b=!0,size:v="lg",children:w,sourceModule:j}){const{t:N}=y.useTranslation(),_=a.useMemo(()=>{if(!u.length)return[];const e=new Map;u.forEach(t=>e.set(t.alias,t));const t=Array.from(e.values()),a=t.find(e=>e.alias===m),r=t.filter(e=>e.alias!==m).sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"}));return a?[a,...r]:r},[u,m]);return t.jsx(Qr,{open:r,onOpenChange:b?void 0:s,children:t.jsxs(as,{size:v,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:b?e=>e.preventDefault():void 0,onEscapeKeyDown:b?e=>e.preventDefault():void 0,children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[t.jsx(os,{children:N("no_access_page")}),t.jsx(is,{children:"Selecione um módulo para continuar navegando!"})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.length>1&&t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[t.jsx(c.Building2,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:d||"Unidade"}),t.jsx(c.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),t.jsx($s,{align:"end",className:"max-h-[300px] overflow-auto",children:_.map(e=>t.jsxs(Ws,{onClick:()=>p?.(e),className:e.alias===m?"bg-muted":"",children:[t.jsx(c.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate",children:e.name}),e.alias===m&&t.jsx(Es,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},e.alias))})]}),t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"gap-2",children:[t.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:t.jsx(c.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),t.jsx(c.ChevronDown,{className:"h-3 w-3"})]})}),t.jsxs($s,{align:"end",children:[t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsx("p",{className:"text-sm font-medium",children:l||e.t("user")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:d})]}),t.jsx(Ys,{}),t.jsxs(Ws,{onClick:h,children:[t.jsx(c.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),w?t.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[t.jsx("div",{className:"flex-1",children:w}),t.jsx(ic,{educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:j})]}):t.jsx(mc,{onModuleClick:n,contractedModules:o,onModuleInterest:i,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:j})]})})}function fc(e,t){return t.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t)}function gc({children:e,contractedModules:r,onModuleClick:s,onModuleInterest:n,educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:c,noAccessRedirectPath:d,noAccessRedirectMode:u,accessDeniedRoutes:m,sourceModule:p}){const{t:h}=y.useTranslation(),{hasAccess:x,isLoading:f,association:g}=Dl(),{user:b,alias:v,companies:w,isAuthenticated:j,isLoading:N,logout:_,switchUnit:C}=So(),k=pc(r),S=a.useMemo(()=>w?.length?v&&w.find(e=>e.alias===v)||w[0]:null,[w,v]),A=a.useMemo(()=>w?.length?w.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[w]),T=a.useCallback(e=>{const t=w?.find(t=>t.alias===e.alias);if(!t)return;const{pathname:a,search:r,hash:s}=window.location;if(v){const e=a.split("/"),n=e.indexOf(v);if(n>=0)return e[n]=t.alias,void(window.location.href=e.join("/")+r+s)}C(t)},[v,C,w]),D=a.useCallback(e=>{s?s(e):e.url&&gr(br(e.url,v||void 0))},[s,v]),E=a.useMemo(()=>{if(!m)return;const e="undefined"!=typeof window?window.location.pathname:"",t=Object.keys(m).find(t=>fc(e,[t]));return t?m[t]:void 0},[m]),P="undefined"!=typeof window?window.location.pathname:"",I=!(!c?.length||!fc(P,c)),M=!N&&j&&!f&&!x&&!I&&!!d&&"always"===(u??"always")?function(e,t){return t&&e.startsWith("/")?e.split("/")[1]===t?e:`/${t}${e}`:e}(d,v):null;return a.useEffect(()=>{M&&M!==P&&window.location.replace(M)},[M,P]),N||!j||I?t.jsx(t.Fragment,{children:e}):f?t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsx(Is,{size:"lg"})}):x?t.jsx(t.Fragment,{children:e}):M?M===P?t.jsx(t.Fragment,{children:e}):t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsx(Is,{size:"lg"})}):t.jsx(xc,{open:!0,onModuleClick:D,contractedModules:k,onModuleInterest:n,userName:b?.name,unitName:S?.name,units:A,currentAlias:v||void 0,onUnitChange:T,onLogout:_,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:p,blocking:!0,children:E})}let bc=!1;function vc(){if(bc||"undefined"==typeof document)return;bc=!0;for(const t of["https://fonts.googleapis.com","https://fonts.gstatic.com"])if(!document.querySelector(`link[href="${t}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=t,t.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 t of e)if(!document.querySelector(`link[href="${t}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}}function yc({projectId:e,mode:t="auto"}){const{user:r,alias:s,isAuthenticated:n}=So();a.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==t&&e&&!We()&&!window.__forlogicClarityOwned)if("function"!=typeof window.clarity)try{Ql.init(e),window.__forlogicClarityOwned=!0,window.__forlogicClarityMode="owned"}catch(a){(void 0).DEV,window.__forlogicClarityMode="inactive"}else window.__forlogicClarityMode="piggyback"},[e,t]),a.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==t&&n&&r&&"function"==typeof window.clarity)try{const e=r.email||r.identifier||"anonymous";Ql.identify(e,void 0,"modules-menu",r.name||void 0),s&&Ql.setTag("alias",s),"boolean"==typeof r.isSysAdmin&&Ql.setTag("isSysAdmin",String(r.isSysAdmin))}catch(e){(void 0).DEV}},[r,s,n,t])}let wc="legacy";function jc({projectId:e,mode:t}){return yc({projectId:e,mode:t}),null}function Nc(){if(!Fe())return null;const e=Kn((void 0).VITE_SUPABASE_PUBLISHABLE_KEY),a=!!(void 0).VITE_SUPABASE_PK_OVERRIDE;if(!e||a||!(void 0).DEV)return null;const r={background:"rgba(0,0,0,.2)",padding:"1px 4px",borderRadius:4};return t.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,zIndex:99999,background:"#dc2626",color:"#fff",padding:"8px 16px",fontSize:"13px",fontFamily:"Inter, system-ui, sans-serif",textAlign:"center",lineHeight:1.4},children:[t.jsx("strong",{children:"⚠️ Legacy Supabase Key Detectada"})," — O ",t.jsx("code",{style:r,children:"VITE_SUPABASE_PUBLISHABLE_KEY"})," contém uma anon key JWT legada. Adicione ",t.jsx("code",{style:r,children:'VITE_SUPABASE_PK_OVERRIDE="sb_publishable_..."'})," no .env para corrigir."]})}const _c=ye.Root,Cc=te.forwardRef(({className:e,...a},r)=>t.jsx(ye.Item,{ref:r,className:_r("border-b",e),...a}));Cc.displayName="AccordionItem";const kc=te.forwardRef(({className:e,children:a,...r},s)=>t.jsx(ye.Header,{className:"flex",children:t.jsxs(ye.Trigger,{ref:s,className:_r("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...r,children:[a,t.jsx(c.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));kc.displayName=ye.Trigger.displayName;const Sc=te.forwardRef(({className:e,children:a,...r},s)=>t.jsx(ye.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:t.jsx("div",{className:_r("pb-4 pt-0",e),children:a})}));Sc.displayName=ye.Content.displayName;const Ac=te.forwardRef(({...e},a)=>t.jsx("nav",{ref:a,"aria-label":"breadcrumb",...e}));Ac.displayName="Breadcrumb";const Tc=te.forwardRef(({className:e,...a},r)=>t.jsx("ol",{ref:r,className:_r("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...a}));Tc.displayName="BreadcrumbList";const Dc=te.forwardRef(({className:e,...a},r)=>t.jsx("li",{ref:r,className:_r("inline-flex items-center gap-1.5",e),...a}));Dc.displayName="BreadcrumbItem";const Ec=te.forwardRef(({asChild:e,className:a,...s},n)=>{const o=e?r.Slot:"a";return t.jsx(o,{ref:n,className:_r("transition-colors hover:text-foreground",a),...s})});Ec.displayName="BreadcrumbLink";const Pc=te.forwardRef(({className:e,...a},r)=>t.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:_r("font-normal text-foreground",e),...a}));Pc.displayName="BreadcrumbPage";const Ic=({children:e,className:a,...r})=>t.jsx("li",{role:"presentation","aria-hidden":"true",className:_r("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...r,children:e??t.jsx(c.ChevronRight,{})});Ic.displayName="BreadcrumbSeparator";const Mc=({className:e,...a})=>t.jsxs("span",{role:"presentation","aria-hidden":"true",className:_r("flex h-9 w-9 items-center justify-center",e),...a,children:[t.jsx(c.MoreHorizontal,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Mais"})]});Mc.displayName="BreadcrumbEllipsis";const Rc=s.cva("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),Lc=te.forwardRef(({className:e,orientation:a,...r},s)=>t.jsx("div",{ref:s,className:_r(Rc({orientation:a}),e),...r}));Lc.displayName="ButtonGroup";const Fc={"pt-BR":Za,"en-US":jt,"es-ES":Ga};function zc({className:e,classNames:a,showOutsideDays:r=!0,captionLayout:s,fromYear:n,toYear:o,startMonth:i,endMonth:l,...d}){const{i18n:u}=y.useTranslation(),m=Fc[u.language]??Za,p=te.useMemo(()=>i??(n?new Date(n,0,1):void 0),[i,n]),h=te.useMemo(()=>l??(o?new Date(o,11,31):void 0),[l,o]),x=s?.startsWith("dropdown");return t.jsx(I.DayPicker,{showOutsideDays:r,className:_r("p-3 pointer-events-auto",e),locale:m,captionLayout:s,startMonth:p,endMonth:h,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:_r("flex h-9 w-full items-center px-8",x?"justify-center gap-1.5":"justify-center"),nav:_r("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1","dropdown"===s&&"hidden"),button_previous:_r(kr({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:_r(kr({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:_r(kr({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",dropdowns:"flex items-center gap-1.5",dropdown_root:"relative inline-flex items-center",dropdown:_r("cursor-pointer appearance-none rounded-md border border-input bg-background","h-8 pl-2.5 pr-7 text-sm font-medium text-foreground","hover:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","transition-colors","bg-[right_0.5rem_center] bg-no-repeat","bg-[url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='16'%20height='16'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='hsl(215%2016%25%2047%25)'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='m6%209%206%206%206-6'/%3E%3C/svg%3E\")]"),caption_label:x?"sr-only":"text-sm font-medium",...a},components:{Chevron:({orientation:e})=>"left"===e?t.jsx(c.ChevronLeft,{className:"h-4 w-4"}):t.jsx(c.ChevronRight,{className:"h-4 w-4"})},...d})}zc.displayName="Calendar";const Uc={Root:function({children:e,className:a}){return t.jsx("div",{className:_r("space-y-4",a),children:e})},Item:function({children:e,onClick:a,className:r}){return t.jsx(Pr,{className:_r("transition-colors",a&&"cursor-pointer hover:bg-muted/50",r),onClick:a,children:t.jsx(Lr,{className:"p-4",children:e})})},Field:function({label:e,value:a,className:r}){return t.jsxs("div",{className:_r("flex justify-between items-center text-sm",r),children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),t.jsx("span",{className:"text-foreground",children:a})]})}};const Oc=({shouldScaleBackground:e=!0,...a})=>t.jsx(M.Drawer.Root,{shouldScaleBackground:e,...a});Oc.displayName="Drawer";const Bc=M.Drawer.Trigger,qc=M.Drawer.Portal,Vc=M.Drawer.Close,$c=te.forwardRef(({className:e,...a},r)=>t.jsx(M.Drawer.Overlay,{ref:r,className:_r("fixed inset-0 z-50 bg-black/80",e),...a}));$c.displayName=M.Drawer.Overlay.displayName;const Wc=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(qc,{children:[t.jsx($c,{}),t.jsxs(M.Drawer.Content,{ref:s,className:_r("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",e),...r,children:[t.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));Wc.displayName="DrawerContent";const Hc=({className:e,...a})=>t.jsx("div",{className:_r("grid gap-1.5 p-4 text-center sm:text-left",e),...a});Hc.displayName="DrawerHeader";const Gc=({className:e,...a})=>t.jsx("div",{className:_r("mt-auto flex flex-col gap-2 p-4",e),...a});Gc.displayName="DrawerFooter";const Kc=te.forwardRef(({className:e,...a},r)=>t.jsx(M.Drawer.Title,{ref:r,className:_r("text-lg font-semibold leading-none tracking-tight",e),...a}));Kc.displayName=M.Drawer.Title.displayName;const Yc=te.forwardRef(({className:e,...a},r)=>t.jsx(M.Drawer.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Yc.displayName=M.Drawer.Description.displayName;const Qc={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))]"},Xc={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Jc=we.Root,Zc=we.Trigger,ed=te.forwardRef(({className:e,align:a="center",sideOffset:r=4,...s},n)=>t.jsx(we.Content,{ref:n,align:a,sideOffset:r,className:_r("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),...s}));ed.displayName=we.Content.displayName;const td=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-slot":"input-group",className:_r("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),...a}));td.displayName="InputGroup";const ad=s.cva("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),rd=te.forwardRef(({className:e,align:a,...r},s)=>t.jsx("div",{ref:s,"data-slot":"input-group-addon",className:_r(ad({align:a}),e),...r}));rd.displayName="InputGroupAddon";const sd=s.cva("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),nd=te.forwardRef(({className:e,size:a,variant:r="ghost",...s},n)=>t.jsx(Sr,{ref:n,"data-slot":"input-group-button",variant:r,className:_r(sd({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",e),...s}));nd.displayName="InputGroupButton";const od=te.forwardRef(({className:e,...a},r)=>t.jsx(Tr,{ref:r,"data-slot":"input-group-control",className:_r("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...a}));od.displayName="InputGroupInput";const id=te.forwardRef(({className:e,...a},r)=>t.jsx(Ts,{ref:r,"data-slot":"input-group-control",className:_r("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...a}));id.displayName="InputGroupTextarea";const ld=te.forwardRef(({className:e,...a},r)=>t.jsx("h1",{ref:r,className:_r("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",e),...a}));ld.displayName="H1";const cd=te.forwardRef(({className:e,...a},r)=>t.jsx("h2",{ref:r,className:_r("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",e),...a}));cd.displayName="H2";const dd=te.forwardRef(({className:e,...a},r)=>t.jsx("h3",{ref:r,className:_r("scroll-m-20 text-2xl font-semibold tracking-tight",e),...a}));dd.displayName="H3";const ud=te.forwardRef(({className:e,...a},r)=>t.jsx("h4",{ref:r,className:_r("scroll-m-20 text-xl font-semibold tracking-tight",e),...a}));ud.displayName="H4";const md=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("leading-7 [&:not(:first-child)]:mt-6",e),...a}));md.displayName="P";const pd=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("text-xl text-muted-foreground",e),...a}));pd.displayName="Lead";const hd=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,className:_r("text-lg font-semibold",e),...a}));hd.displayName="Large";const xd=te.forwardRef(({className:e,...a},r)=>t.jsx("small",{ref:r,className:_r("text-sm font-medium leading-none",e),...a}));xd.displayName="Small";const fd=te.forwardRef(({className:e,...a},r)=>t.jsx("p",{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));fd.displayName="Muted";const gd=te.forwardRef(({className:e,...a},r)=>t.jsx("code",{ref:r,className:_r("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",e),...a}));gd.displayName="InlineCode";const bd=te.forwardRef(({className:e,...a},r)=>t.jsx("blockquote",{ref:r,className:_r("mt-6 border-l-2 pl-6 italic",e),...a}));bd.displayName="Blockquote";const vd=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,className:_r("my-6 ml-6 list-disc [&>li]:mt-2",e),...a}));vd.displayName="List";const yd=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(je.Root,{ref:s,className:_r("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...r,children:[a,t.jsx(Sd,{})]}));yd.displayName=je.Root.displayName;const wd=te.forwardRef(({className:e,...a},r)=>t.jsx(je.List,{ref:r,className:_r("group flex flex-1 list-none items-center justify-center space-x-1",e),...a}));wd.displayName=je.List.displayName;const jd=je.Item,Nd=s.cva("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),_d=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(je.Trigger,{ref:s,className:_r(Nd(),"group",e),...r,children:[a," ",t.jsx(c.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));_d.displayName=je.Trigger.displayName;const Cd=te.forwardRef(({className:e,...a},r)=>t.jsx(je.Content,{ref:r,className:_r("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),...a}));Cd.displayName=je.Content.displayName;const kd=je.Link,Sd=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{className:_r("absolute left-0 top-full flex justify-center"),children:t.jsx(je.Viewport,{className:_r("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:r,...a})}));Sd.displayName=je.Viewport.displayName;const Ad=te.forwardRef(({className:e,...a},r)=>t.jsx(je.Indicator,{ref:r,className:_r("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),...a,children:t.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ad.displayName=je.Indicator.displayName;const Td=({className:e,...a})=>t.jsx("nav",{role:"navigation","aria-label":"pagination",className:_r("mx-auto flex w-full justify-center",e),...a});Td.displayName="Pagination";const Dd=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,className:_r("flex flex-row items-center gap-1",e),...a}));Dd.displayName="PaginationContent";const Ed=te.forwardRef(({className:e,...a},r)=>t.jsx("li",{ref:r,className:_r("",e),...a}));Ed.displayName="PaginationItem";const Pd=({className:e,isActive:a,size:r="icon",...s})=>t.jsx("a",{"aria-current":a?"page":void 0,className:_r(kr({variant:a?"outline":"ghost",size:r}),e),...s});Pd.displayName="PaginationLink";const Id=({className:a,...r})=>t.jsxs(Pd,{"aria-label":e.t("go_to_previous_page"),size:"default",className:_r("gap-1 pl-2.5",a),...r,children:[t.jsx(c.ChevronLeft,{className:"h-4 w-4"}),t.jsx("span",{children:"Previous"})]});Id.displayName="PaginationPrevious";const Md=({className:a,...r})=>t.jsxs(Pd,{"aria-label":e.t("go_to_next_page"),size:"default",className:_r("gap-1 pr-2.5",a),...r,children:[t.jsx("span",{children:"Next"}),t.jsx(c.ChevronRight,{className:"h-4 w-4"})]});Md.displayName="PaginationNext";const Rd=({className:e,...a})=>t.jsxs("span",{"aria-hidden":!0,className:_r("flex h-9 w-9 items-center justify-center",e),...a,children:[t.jsx(c.MoreHorizontal,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"More pages"})]});Rd.displayName="PaginationEllipsis";const Ld=te.forwardRef(({className:e,value:a,...r},s)=>t.jsx(Ne.Root,{ref:s,className:_r("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...r,children:t.jsx(Ne.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));Ld.displayName=Ne.Root.displayName;const Fd=te.forwardRef(({className:e,...a},r)=>t.jsx(_e.Root,{className:_r("grid gap-2",e),...a,ref:r}));Fd.displayName=_e.Root.displayName;const zd=te.forwardRef(({className:e,...a},r)=>t.jsx(_e.Item,{ref:r,className:_r("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),...a,children:t.jsx(_e.Indicator,{className:"flex items-center justify-center",children:t.jsx(c.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));zd.displayName=_e.Item.displayName;const Ud=Ce.Panel,Od=se.Root,Bd=se.Trigger,qd=se.Close,Vd=se.Portal,$d=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Overlay,{className:_r("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),...a,ref:r}));$d.displayName=se.Overlay.displayName;const Wd=s.cva("fixed z-50 flex flex-col bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Hd=te.forwardRef(({side:e="right",className:a,children:r,...s},n)=>t.jsxs(Vd,{children:[t.jsx($d,{}),t.jsxs(se.Content,{ref:n,className:_r(Wd({side:e}),a),...s,children:[r,t.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:[t.jsx(c.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Hd.displayName=se.Content.displayName;const Gd=({className:e,showSeparator:a=!1,children:r,...s})=>t.jsxs("div",{className:_r("flex flex-col flex-shrink-0",e),...s,children:[t.jsx("div",{className:"flex flex-col text-left",children:r}),a&&t.jsx(zr,{className:"mt-2"})]});Gd.displayName="SheetHeader";const Kd=({className:e,...a})=>t.jsx("div",{className:_r("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",e),...a});Kd.displayName="SheetBody";const Yd=({className:e,children:a,...r})=>t.jsxs("div",{className:"flex-shrink-0 pt-4",children:[t.jsx(zr,{className:"mb-4"}),t.jsx("div",{className:_r("flex flex-row justify-end gap-2",e),...r,children:a})]});Yd.displayName="SheetFooter";const Qd=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Title,{ref:r,className:_r("text-lg font-semibold text-foreground",e),...a}));Qd.displayName=se.Title.displayName;const Xd=te.forwardRef(({className:e,...a},r)=>t.jsx(se.Description,{ref:r,className:_r("text-sm text-muted-foreground",e),...a}));Xd.displayName=se.Description.displayName;const Jd="sidebar:state",Zd=te.createContext(null);function eu(){const e=te.useContext(Zd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const tu=te.forwardRef(({defaultOpen:e=!0,open:a,onOpenChange:r,className:s,style:n,children:o,...i},l)=>{const c=Do(),[d,u]=te.useState(!1),[m,p]=te.useState(()=>{if("undefined"!=typeof window){const t=localStorage.getItem(Jd);return null!==t?"true"===t:e}return e}),h=a??m,x=te.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Jd,String(t))},[r,h]),f=te.useCallback(()=>c?u(e=>!e):x(e=>!e),[c,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",b=te.useMemo(()=>({state:g,open:h,setOpen:x,isMobile:c,openMobile:d,setOpenMobile:u,toggleSidebar:f}),[g,h,x,c,d,u,f]);return t.jsx(Zd.Provider,{value:b,children:t.jsx(Xs,{delayDuration:0,children:t.jsx("div",{className:_r("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",s),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4rem",...n},ref:l,...i,children:o})})})});tu.displayName="SidebarProvider";const au=te.forwardRef(({side:e="left",variant:a="sidebar",collapsible:r="offcanvas",className:s,children:n,...o},i)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=eu();return"none"===r?t.jsx("div",{className:_r("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:i,...o,children:n}):l?t.jsx(Od,{open:d,onOpenChange:u,...o,children:t.jsxs(Hd,{"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:[t.jsx(Qd,{className:"sr-only",children:"Menu de Navegação"}),t.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):t.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?r:"","data-variant":a,"data-side":e,children:[t.jsx("div",{className:_r("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"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),t.jsx("div",{className:_r("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"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...o,children:t.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})})]})});au.displayName="Sidebar";const ru=te.forwardRef(({className:e,onClick:a,...r},s)=>{const{toggleSidebar:n}=eu();return t.jsxs(Sr,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:_r("h-7 w-7",e),onClick:e=>{a?.(e),n()},...r,children:[t.jsx(c.PanelLeft,{}),t.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ru.displayName="SidebarTrigger";const su=te.forwardRef(({className:e,...a},r)=>{const{toggleSidebar:s}=eu();return t.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:_r("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),...a})});su.displayName="SidebarRail";const nu=te.forwardRef(({className:e,...a},r)=>t.jsx("main",{ref:r,className:_r("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),...a}));nu.displayName="SidebarInset";const ou=te.forwardRef(({className:e,...a},r)=>t.jsx(Tr,{ref:r,"data-sidebar":"input",className:_r("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...a}));ou.displayName="SidebarInput";const iu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"header",className:_r("flex flex-col gap-2 p-2",e),...a}));iu.displayName="SidebarHeader";const lu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"footer",className:_r("flex flex-col gap-2 p-2",e),...a}));lu.displayName="SidebarFooter";const cu=te.forwardRef(({className:e,...a},r)=>t.jsx(zr,{ref:r,"data-sidebar":"separator",className:_r("mx-2 w-auto bg-sidebar-border",e),...a}));cu.displayName="SidebarSeparator";const du=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"content",className:_r("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...a}));du.displayName="SidebarContent";const uu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"group",className:_r("relative flex w-full min-w-0 flex-col p-2",e),...a}));uu.displayName="SidebarGroup";const mu=te.forwardRef(({className:e,asChild:a=!1,...s},n)=>{const o=a?r.Slot:"div";return t.jsx(o,{ref:n,"data-sidebar":"group-label",className:_r("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),...s})});mu.displayName="SidebarGroupLabel";const pu=te.forwardRef(({className:e,asChild:a=!1,...s},n)=>{const o=a?r.Slot:"button";return t.jsx(o,{ref:n,"data-sidebar":"group-action",className:_r("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),...s})});pu.displayName="SidebarGroupAction";const hu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"group-content",className:_r("w-full text-sm",e),...a}));hu.displayName="SidebarGroupContent";const xu=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,"data-sidebar":"menu",className:_r("flex w-full min-w-0 flex-col gap-1",e),...a}));xu.displayName="SidebarMenu";const fu=te.forwardRef(({className:e,...a},r)=>t.jsx("li",{ref:r,"data-sidebar":"menu-item",className:_r("group/menu-item relative",e),...a}));fu.displayName="SidebarMenuItem";const gu=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),bu=te.forwardRef(({asChild:e=!1,isActive:a=!1,variant:s="default",size:n="default",tooltip:o,className:i,...l},c)=>{const d=e?r.Slot:"button",{isMobile:u,state:m}=eu(),p=t.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":n,"data-active":a,className:_r(gu({variant:s,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:p}),t.jsx(en,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});bu.displayName="SidebarMenuButton";const vu=te.forwardRef(({className:e,asChild:a=!1,showOnHover:s=!1,...n},o)=>{const i=a?r.Slot:"button";return t.jsx(i,{ref:o,"data-sidebar":"menu-action",className:_r("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",s&&"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})});vu.displayName="SidebarMenuAction";const yu=te.forwardRef(({className:e,...a},r)=>t.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:_r("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),...a}));yu.displayName="SidebarMenuBadge";const wu=te.forwardRef(({className:e,showIcon:a=!1,...r},s)=>{const n=te.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return t.jsxs("div",{ref:s,"data-sidebar":"menu-skeleton",className:_r("rounded-md h-8 flex gap-2 px-2 items-center",e),...r,children:[a&&t.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),t.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});wu.displayName="SidebarMenuSkeleton";const ju=te.forwardRef(({className:e,...a},r)=>t.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:_r("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),...a}));ju.displayName="SidebarMenuSub";const Nu=te.forwardRef(({...e},a)=>t.jsx("li",{ref:a,...e}));Nu.displayName="SidebarMenuSubItem";const _u=te.forwardRef(({asChild:e=!1,size:a="md",isActive:s,className:n,...o},i)=>{const l=e?r.Slot:"a";return t.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":a,"data-active":s,className:_r("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"===a&&"text-xs","md"===a&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});_u.displayName="SidebarMenuSubButton";const Cu=te.forwardRef(({className:e,value:a,defaultValue:r,...s},n)=>{const o=a||r||[0];return t.jsxs(ke.Root,{ref:n,value:a,defaultValue:r,className:_r("relative flex w-full touch-none select-none items-center",e),...s,children:[t.jsx(ke.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:t.jsx(ke.Range,{className:"absolute h-full bg-primary"})}),o.map((e,a)=>t.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"},a))]})});Cu.displayName=ke.Root.displayName;const ku=Se.Menu,Su=Se.Group,Au=Se.Portal,Tu=Se.Sub,Du=Se.RadioGroup,Eu=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.Root,{ref:r,className:_r("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",e),...a}));Eu.displayName=Se.Root.displayName;const Pu=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.Trigger,{ref:r,className:_r("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),...a}));Pu.displayName=Se.Trigger.displayName;const Iu=te.forwardRef(({className:e,inset:a,children:r,...s},n)=>t.jsxs(Se.SubTrigger,{ref:n,className:_r("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",e),...s,children:[r,t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Iu.displayName=Se.SubTrigger.displayName;const Mu=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.SubContent,{ref:r,className:_r("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),...a}));Mu.displayName=Se.SubContent.displayName;const Ru=te.forwardRef(({className:e,align:a="start",alignOffset:r=-4,sideOffset:s=8,...n},o)=>t.jsx(Se.Portal,{children:t.jsx(Se.Content,{ref:o,align:a,alignOffset:r,sideOffset:s,className:_r("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})}));Ru.displayName=Se.Content.displayName;const Lu=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(Se.Item,{ref:s,className:_r("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",e),...r}));Lu.displayName=Se.Item.displayName;const Fu=te.forwardRef(({className:e,children:a,checked:r,...s},n)=>t.jsxs(Se.CheckboxItem,{ref:n,className:_r("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:r,...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Se.ItemIndicator,{children:t.jsx(c.Check,{className:"h-4 w-4"})})}),a]}));Fu.displayName=Se.CheckboxItem.displayName;const zu=te.forwardRef(({className:e,children:a,...r},s)=>t.jsxs(Se.RadioItem,{ref:s,className:_r("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),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Se.ItemIndicator,{children:t.jsx(c.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));zu.displayName=Se.RadioItem.displayName;const Uu=te.forwardRef(({className:e,inset:a,...r},s)=>t.jsx(Se.Label,{ref:s,className:_r("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...r}));Uu.displayName=Se.Label.displayName;const Ou=te.forwardRef(({className:e,...a},r)=>t.jsx(Se.Separator,{ref:r,className:_r("-mx-1 my-1 h-px bg-muted",e),...a}));Ou.displayName=Se.Separator.displayName;const Bu=({className:e,...a})=>t.jsx("span",{className:_r("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});Bu.displayname="MenubarShortcut";const qu={light:"",dark:".dark"},Vu=te.createContext(null);function $u(){const e=te.useContext(Vu);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Wu=te.forwardRef(({id:e,className:a,children:r,config:s,...n},o)=>{const i=te.useId(),l=`chart-${e||i.replace(/:/g,"")}`;return t.jsx(Vu.Provider,{value:{config:s},children:t.jsxs("div",{"data-chart":l,ref:o,className:_r("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[t.jsx(Hu,{id:l,config:s}),t.jsx(Ae.ResponsiveContainer,{children:r})]})})});Wu.displayName="Chart";const Hu=({id:e,config:a})=>{const r=Object.entries(a).filter(([,e])=>e.theme||e.color);return r.length?t.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(qu).map(([t,a])=>`\n${a} [data-chart=${e}] {\n${r.map(([e,a])=>{const r=a.theme?.[t]||a.color;return r?` --color-${e}: ${r};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Gu=Ae.Tooltip,Ku=te.forwardRef(({active:e,payload:a,className:r,indicator:s="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:c,formatter:d,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=$u(),f=te.useMemo(()=>{if(n||!a?.length)return null;const[e]=a,r=Xu(x,e,`${p||e?.dataKey||e?.name||"value"}`),s=p||"string"!=typeof i?r?.label:x[i]?.label||i;return l?t.jsx("div",{className:_r("font-medium",c),children:l(s,a)}):s?t.jsx("div",{className:_r("font-medium",c),children:s}):null},[i,l,a,n,c,x,p]);if(!e||!a?.length)return null;const g=1===a.length&&"dot"!==s;return t.jsxs("div",{ref:h,className:_r("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",r),children:[g?null:f,t.jsx("div",{className:"grid gap-1.5",children:a.map((e,a)=>{const r=`${m||e.name||e.dataKey||"value"}`,n=Xu(x,e,r),i=u||e.payload?.fill||e.color;return t.jsx("div",{className:_r("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===s&&"items-center"),children:d&&void 0!==e?.value&&e.name?d(e.value,e.name,e,a,e.payload):t.jsxs(t.Fragment,{children:[n?.icon?t.jsx(n.icon,{}):!o&&t.jsx("div",{className:_r("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===s,"w-1":"line"===s,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===s,"my-0.5":g&&"dashed"===s}),style:{"--color-bg":i,"--color-border":i}}),t.jsxs("div",{className:_r("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[t.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,t.jsx("span",{className:"text-muted-foreground",children:n?.label||e.name})]}),void 0!==e.value&&t.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString():e.value})]})]})},e.dataKey||a)})})]})});Ku.displayName="ChartTooltip";const Yu=Ae.Legend,Qu=te.forwardRef(({className:e,hideIcon:a=!1,payload:r,verticalAlign:s="bottom",nameKey:n},o)=>{const{config:i}=$u();return r?.length?t.jsx("div",{ref:o,className:_r("flex items-center justify-center gap-4","top"===s?"pb-3":"pt-3",e),children:r.map(e=>{const r=`${n||e.dataKey||"value"}`,s=Xu(i,e,r);return t.jsxs("div",{className:_r("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[s?.icon&&!a?t.jsx(s.icon,{}):t.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),s?.label]},e.value)})}):null});function Xu(e,t,a){if("object"!=typeof t||null===t)return;const r="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let s=a;return a in t&&"string"==typeof t[a]?s=t[a]:r&&a in r&&"string"==typeof r[a]&&(s=r[a]),s in e?e[s]:e[a]}Qu.displayName="ChartLegend";const Ju=({onClick:e,isActive:a,disabled:r,children:s,title:n})=>t.jsx("button",{type:"button",onClick:e,disabled:r,title:n,className:_r("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",r&&"opacity-50 cursor-not-allowed"),children:s}),Zu=()=>t.jsx("div",{className:"w-px h-5 bg-border mx-1"});function em({image:e,title:a,className:r}){return t.jsx("div",{className:_r("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",r),children:e?t.jsx("img",{src:e,alt:a,className:"w-full h-full object-cover"}):t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(c.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function tm({steps:e,currentStepIndex:a,onStepSelect:r,stepLabel:s,className:n}){const{t:o}=y.useTranslation(),i=e.length,l=(a+1)/i*100;return t.jsxs("div",{className:_r("flex items-center gap-3",n),children:[t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[s," ",a+1,"/",i,t.jsx(c.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),t.jsx($s,{align:"start",children:e.map((e,s)=>t.jsxs(Ws,{onClick:()=>r(s),className:_r(s===a&&"bg-accent"),children:[s+1,". ",e.title]},e.id))})]}),t.jsx(Ld,{value:l,className:"w-32 h-2"})]})}function am({currentStepIndex:e,totalSteps:a,onBack:r,onNext:s,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:l,className:d}){const{t:u}=y.useTranslation(),m=0===e,p=e===a-1;return t.jsxs("div",{className:_r("flex items-center gap-2",d),children:[!m&&t.jsxs(Sr,{variant:"outline",onClick:r,size:"sm",children:[t.jsx(c.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),t.jsxs(Sr,{onClick:p?n:s,size:"sm",children:[p?l:i,!p&&t.jsx(c.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const rm=te.forwardRef(({open:a,onOpenChange:r,steps:s,onComplete:n,onStepChange:o,continueButtonText:i="Continuar",backButtonText:l="Voltar",finishButtonText:d="Concluir",stepLabel:u=e.t("approval_step_label"),size:m="md",showProgressIndicator:p=!0,currentStepIndex:h,onCurrentStepChange:x,className:f},g)=>{const[b,v]=te.useState(0),y=void 0!==h,w=y?h:b,j=te.useCallback(e=>{y?x?.(e):v(e),o?.(e)},[y,x,o]);te.useEffect(()=>{a||y||v(0)},[a,y]);const N=s[w],_=s.length;return N?t.jsx(Qr,{open:a,onOpenChange:r,children:t.jsxs(as,{ref:g,size:m,variant:"informative",className:_r("p-0 gap-0 overflow-hidden",f),children:[t.jsxs(Zr,{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:[t.jsx(c.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Fechar"})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsxs("div",{className:"p-6 space-y-4",children:[t.jsx(em,{image:N.image,title:N.title}),t.jsx(os,{className:"text-xl font-semibold",children:N.title}),t.jsx(is,{className:"text-muted-foreground",children:N.description})]})}),t.jsxs("div",{className:"flex-shrink-0",children:[t.jsx(zr,{}),t.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[p&&_>1?t.jsx(tm,{steps:s,currentStepIndex:w,onStepSelect:e=>{j(e)},stepLabel:u}):t.jsx("div",{}),t.jsx(am,{currentStepIndex:w,totalSteps:_,onBack:()=>{w>0&&j(w-1)},onNext:()=>{w<_-1&&j(w+1)},onComplete:()=>{n?.(),r(!1)},backButtonText:l,continueButtonText:i,finishButtonText:d})]})]})]})}):null});function sm({label:e,onClick:a,icon:r,actions:s=[],variant:n="default",size:o="default",disabled:i=!1,loading:l=!1,menuAlign:d="end",className:u}){const{t:m}=y.useTranslation(),p=i||l;if(!(s.length>0))return t.jsxs(Sr,{variant:n,size:o,disabled:p,onClick:a,className:u,children:[l?t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):r?t.jsx(r,{className:"mr-2 h-4 w-4"}):null,e]});return t.jsxs("div",{className:_r("inline-flex rounded-md shadow-sm",u),children:[t.jsxs(Sr,{variant:n,size:o,disabled:p,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[l?t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):r?t.jsx(r,{className:"mr-2 h-4 w-4"}):null,e]}),t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:n,size:o,disabled:p,className:_r("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:t.jsx(c.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),t.jsx($s,{align:d,className:"min-w-[160px]",children:s.map(e=>{const a=e.icon;return t.jsxs(Ws,{onClick:e.onClick,disabled:e.disabled,className:_r("destructive"===e.variant&&"text-destructive focus:text-destructive"),children:[a&&t.jsx(a,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})]})}rm.displayName="OnboardingDialog";var nm=(e=>(e.CSV="csv",e.PDF="pdf",e.XLSX="xlsx",e.PNG="png",e.JPEG="jpeg",e.SVG="svg",e))(nm||{});const om=[{value:"csv",label:"CSV",icon:t.jsx(c.FileText,{className:"h-5 w-5"})},{value:"pdf",label:"PDF",icon:t.jsx(c.FileText,{className:"h-5 w-5"})},{value:"xlsx",label:"XLSX",icon:t.jsx(c.FileSpreadsheet,{className:"h-5 w-5"})}],im=[{value:"png",label:"PNG",icon:t.jsx(c.Image,{className:"h-5 w-5"})},{value:"jpeg",label:"JPEG",icon:t.jsx(c.FileImage,{className:"h-5 w-5"})},{value:"svg",label:"SVG",icon:t.jsx(c.FileImage,{className:"h-5 w-5"})},{value:"pdf",label:"PDF",icon:t.jsx(c.FileText,{className:"h-5 w-5"})}];const lm=a.forwardRef(({value:e,onChange:r,onTimeChange:s,label:n,error:o,format:i="24h",className:l,id:d,...u},m)=>{const p=d??te.useId(),h=a.useCallback(e=>{const t=e.target.value;r?.(t),s?.(t)},[r,s]),x=a.useCallback(e=>{["0","1","2","3","4","5","6","7","8","9","Backspace","Tab",":","ArrowLeft","ArrowRight","Delete"].includes(e.key)||e.preventDefault()},[]);return t.jsxs("div",{className:_r("grid gap-1.5",l),children:[n&&t.jsx(Er,{htmlFor:p,children:n}),t.jsxs("div",{className:"relative",children:[t.jsx(Tr,{ref:m,id:p,type:"time",value:e??"",onChange:h,onKeyDown:x,min:"00:00",max:"23:59",step:60,className:_r("pr-9",o&&"border-destructive focus-visible:ring-destructive"),...u}),t.jsx(c.Clock,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]}),o&&t.jsx("p",{className:"text-sm text-destructive",children:o})]})});function cm({currentStep:e,totalSteps:a,onStepChange:r,stepLabels:s,canGoToStep:n,className:o,progressWidth:i="w-32"}){te.useEffect(()=>{process.env.NODE_ENV},[]);const l=Array.from({length:a},(e,t)=>t+1),d=t=>!(t<=e)&&(!!n&&!n(t));return t.jsxs("div",{className:_r("flex items-center gap-3",o),children:[t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",e,"/",a,t.jsx(c.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),t.jsx($s,{align:"start",children:l.map(a=>t.jsxs(Ws,{onClick:()=>{var t;(t=a)<e?r(t):n&&!n(t)||r(t)},disabled:d(a),className:_r("cursor-pointer",a===e&&"bg-muted font-medium",d(a)&&"opacity-50 cursor-not-allowed"),children:[t.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),s?.[a-1]||`Etapa ${a}`,a===e&&t.jsx(c.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),t.jsx(Ld,{value:e/a*100,className:_r("h-2",i)})]})}function dm(e){const t=$n.getAccessToken(),a={"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{},"un-alias":e};if(t)try{const e=JSON.parse(atob(t.split(".")[1]));e.sub&&(a["x-waf-rate"]=btoa(e.sub))}catch{}return a}async function um(e,t,a){let r=await fetch(e,t);if(401===r.status){if(await lo.handleApiError({status:401})){const s={...t,headers:dm(a)};r=await fetch(e,s)}}return r}function mm(e){const[t,r]=a.useState([]),[s,n]=a.useState(0),[o,i]=a.useState(!1);a.useEffect(()=>{if(!e)return;let t=!1;const a=`${Ge().replace(/\/?$/,"/")}api/common/v1/updates/listUpdatesNotification`;return async function(){i(!0);try{const s=dm(e),o=await um(a,{method:"GET",headers:s},e);if(!o.ok)return;const i=await o.json();!t&&i.data?.[0]&&(r(i.data[0].updates??[]),n(i.data[0].valueBadge??0))}catch(s){}finally{t||i(!1)}}(),()=>{t=!0}},[e]);const l=a.useCallback(async()=>{if(!e||s<=0||0===t.length)return;const a=t[0].id,r=`${Ge().replace(/\/?$/,"/")}api/common/v1/Updates/userVisualized/3/undefined`;n(0);try{const t=dm(e),s=JSON.stringify({id:a,idUpdateType:3});await um(r,{method:"POST",headers:t,body:s},e)}catch(o){}},[e,s,t]);return{updates:t,badgeCount:s,loading:o,markAsVisualized:l}}lm.displayName="Timepicker";const pm=a.forwardRef(({updates:a,badgeCount:r,onOpen:s,onViewAll:n,viewAllPath:o},i)=>{const l=void 0===a,d=So(),u=d?.alias??null,m=mm(l?u:null),p=N.useNavigate(),h=l?m.updates??[]:a,x=l?m.badgeCount??0:r??0,f=s??(l?m.markAsVisualized:void 0),g=n??(l&&u?()=>{if(o)return void p(o);const e=Je().replace(/\/?$/,"/");window.open(`${e}${u}/up/view`,"_blank","noopener,noreferrer")}:void 0);return t.jsxs(an,{children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{ref:i,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:f,title:e.t("updates"),children:[t.jsx(c.Coffee,{className:"h-7 w-7"}),x>0&&t.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:x>99?"99+":x})]})}),t.jsxs(sn,{align:"end",className:"w-80 p-0",children:[t.jsx("div",{className:"border-b border-border px-4 py-3",children:t.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Atualizações"})}),t.jsx("div",{className:"max-h-72 overflow-y-auto",children:h.length>0?t.jsx("ul",{className:"divide-y divide-border",children:h.map(e=>t.jsxs("li",{className:"px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer",onClick:g,children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.text})]},e.id))}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[t.jsx(c.Coffee,{className:"h-8 w-8 text-muted-foreground mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum café quentinho, ou melhor, atualização quentinha no momento!"})]})}),t.jsx("div",{className:"border-t border-border px-4 py-2",children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"w-full justify-between text-primary hover:text-primary",onClick:g,children:["Ver todas as atualizações",t.jsx(c.ArrowRight,{className:"h-[18px] w-[18px]"})]})})]})]})});pm.displayName="UpdatesNotification";var hm=(e=>(e[e.none=0]="none",e[e.image=1]="image",e[e.video=2]="video",e[e.audio=3]="audio",e[e.wopi=4]="wopi",e[e.onlineEditor=5]="onlineEditor",e[e.report=6]="report",e))(hm||{}),xm=(e=>(e[e.SimplePrint=0]="SimplePrint",e[e.ManagedCopy=1]="ManagedCopy",e[e.NonManagedCopy=2]="NonManagedCopy",e))(xm||{});const fm={".jpg":1,".jpeg":1,".png":1,".bmp":1,".gif":1,".svg":1,".webp":1,".wav":3,".mp3":3,".mp4":2,".webm":2,".ogg":2,".pdf":4,".ods":4,".xls":4,".xlsb":4,".xlsm":4,".xlsx":4,".doc":4,".docm":4,".docx":4,".dot":4,".dotm":4,".dotx":4,".odt":4,".odp":4,".pot":4,".potm":4,".potx":4,".pps":4,".ppsm":4,".ppsx":4,".ppt":4,".pptm":4,".pptx":4,".gdocs":5,".gsheets":5};function gm(e){const{t:t}=y.useTranslation();return e?fm[e.toLowerCase()]??0:0}const bm={".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 vm(e){const{t:t}=y.useTranslation();return bm[e?.toLowerCase()]||""}function ym(e){const{t:t}=y.useTranslation(),a=e%60;return`${Math.floor(e/60)}min ${a<10?"0":""}${a}`}function wm({open:e,onOpenChange:r,url:s,title:n,className:o,minHeight:i="250px"}){const{t:l}=y.useTranslation(),d=a.useCallback(()=>{r(!1)},[r]);return a.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&d()};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[e,d]),t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:_r("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",o),children:[t.jsxs("div",{className:"flex items-center justify-end mb-2.5",children:[n&&t.jsx("h2",{className:"text-lg font-medium text-foreground truncate mr-auto",children:n}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,children:t.jsx(c.X,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Fechar"})]})]}),t.jsx("iframe",{src:s,className:"border-none w-full",style:{minHeight:i},title:n||l("embedded_content")})]})})}function jm({term:r,open:s,onClose:n,onSign:o,viewOnly:i=!1,title:l=e.t("terms_of_use"),signLabel:d=e.t("terms_read_agree")}){const u=a.useMemo(()=>r.file?function(e,t=""){const{t:a}=y.useTranslation(),r=atob(e),s=[];for(let o=0;o<r.length;o+=512){const e=r.slice(o,o+512),t=new Array(e.length);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a);s.push(new Uint8Array(t))}const n=new Blob(s,{type:t});return URL.createObjectURL(n)}(r.file,r.type):null,[r.file,r.type]),m=a.useCallback(()=>{u&&URL.revokeObjectURL(u),n()},[u,n]),p=a.useCallback(()=>{r.hasUserSignature?m():o?.(r.id)},[r,o,m]),h=!i&&!r.hasUserSignature&&o;return t.jsx(Qr,{open:s,onOpenChange:e=>!e&&m(),children:t.jsxs(as,{className:_r("flex flex-col p-0 sm:max-w-[80vw] h-[95vh]","[&>button.absolute]:hidden"),children:[t.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[t.jsx(c.FileText,{className:"h-5 w-5 text-primary"}),l]}),t.jsxs("div",{className:"flex items-center gap-2",children:[h&&t.jsx(Sr,{size:"sm",onClick:p,children:d}),t.jsx(Sr,{variant:"ghost",size:"icon",onClick:m,children:t.jsx(c.X,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"flex-1 min-h-0",children:r.file&&u?t.jsx("iframe",{className:"h-full w-full border-0",src:u,title:l}):t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t.jsx("p",{children:"Nenhum termo de uso ativo encontrado."})})})]})})}function Nm(e){return e.split(" ").slice(0,2).map(e=>e[0]?.toUpperCase()??"").join("")}function _m(e){return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Cm(e){const{t:t}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function km(e){const{t:t}=y.useTranslation(),a=new Set;if(!e)return a;for(const r of e)r.allowedIds?.forEach(e=>a.add(e)),r.inheritedIds?.forEach(e=>a.add(e));return a}var Sm=(e=>(e[e.WaitingProcessing=1]="WaitingProcessing",e[e.Processing=2]="Processing",e[e.Completed=3]="Completed",e[e.Error=4]="Error",e[e.Expired=5]="Expired",e))(Sm||{});const Am={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 Tm(e){const{t:t}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Dm(e){const{t:t}=y.useTranslation();return e.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Em={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}};var Pm=(e=>(e.Count="valuecount",e.Sum="sum",e.Average="average",e.DistinctCount="valuecount_distict",e.Max="max",e.Min="min",e))(Pm||{}),Im=(e=>(e.ViewAllAnalysis="nes3j6wn",e))(Im||{}),Mm=(e=>(e.RegisterDashboards="EeKs7CYA",e.RemoveDashboards="3GKZYOQ9",e.ViewAllDashboards="wYBdQNvZ",e.EditDashboards="bMFcbwv4",e))(Mm||{}),Rm=(e=>(e[e.Default=1]="Default",e[e.Compact=2]="Compact",e))(Rm||{}),Lm=(e=>(e[e.FiveSeconds=1]="FiveSeconds",e[e.TenSeconds=2]="TenSeconds",e[e.FifteenSeconds=3]="FifteenSeconds",e[e.ThirtySeconds=4]="ThirtySeconds",e[e.OneMinute=5]="OneMinute",e[e.ThreeMinutes=6]="ThreeMinutes",e[e.FiveMinutes=7]="FiveMinutes",e[e.TenMinutes=8]="TenMinutes",e))(Lm||{}),Fm=(e=>(e[e.Day=1]="Day",e[e.Month=2]="Month",e[e.Year=3]="Year",e))(Fm||{}),zm=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=2]="Descending",e))(zm||{}),Um=(e=>(e[e.Label=1]="Label",e[e.Value=2]="Value",e))(Um||{}),Om=(e=>(e[e.LastSevenDays=1]="LastSevenDays",e[e.LastWeek=2]="LastWeek",e[e.LastMonth=3]="LastMonth",e[e.PreviousQuarter=4]="PreviousQuarter",e[e.PreviousSemester=5]="PreviousSemester",e[e.LastYear=6]="LastYear",e[e.SpecificPeriod=7]="SpecificPeriod",e[e.CurrentMonth=8]="CurrentMonth",e[e.CurrentSemester=9]="CurrentSemester",e[e.CurrentWeek=10]="CurrentWeek",e[e.CurrentYear=11]="CurrentYear",e))(Om||{}),Bm=(e=>(e[e.Text=1]="Text",e[e.Area=2]="Area",e[e.Bar=3]="Bar",e[e.Column=4]="Column",e[e.StackedColumn=5]="StackedColumn",e[e.Line=6]="Line",e[e.List=7]="List",e[e.Numeric=8]="Numeric",e[e.Pareto=9]="Pareto",e[e.Pie=10]="Pie",e[e.RiskMatrix=11]="RiskMatrix",e[e.Burndown=12]="Burndown",e[e.PerformanceColumns=13]="PerformanceColumns",e[e.EvolutionLine=14]="EvolutionLine",e))(Bm||{}),qm=(e=>(e[e.NotUpdate=1]="NotUpdate",e[e.FiveMinutes=2]="FiveMinutes",e[e.TenMinutes=3]="TenMinutes",e[e.FifteenMinutes=4]="FifteenMinutes",e[e.ThirtyMinutes=5]="ThirtyMinutes",e[e.OneHour=6]="OneHour",e))(qm||{}),Vm=(e=>(e[e.NormalPage=1]="NormalPage",e[e.Carousel=2]="Carousel",e))(Vm||{}),$m=(e=>(e[e.General=0]="General",e[e.Share=1]="Share",e))($m||{}),Wm=(e=>(e[e.NotShared=1]="NotShared",e[e.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",e[e.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",e))(Wm||{}),Hm=(e=>(e.PtBr="pt-br",e.EnUs="en",e.EsEs="es",e))(Hm||{}),Gm=(e=>(e[e.Quantity=0]="Quantity",e[e.AllRisksList=1]="AllRisksList",e))(Gm||{}),Km=(e=>(e[e.Five=5]="Five",e[e.Ten=10]="Ten",e[e.Fifteen=15]="Fifteen",e[e.Twenty=20]="Twenty",e[e.All=0]="All",e[e.Custom=-1]="Custom",e))(Km||{}),Ym=(e=>(e[e.AlphabeticalAsc=1]="AlphabeticalAsc",e[e.AlphabeticalDesc=2]="AlphabeticalDesc",e[e.CountAsc=3]="CountAsc",e[e.CountDesc=4]="CountDesc",e[e.DateAsc=5]="DateAsc",e[e.DateDesc=6]="DateDesc",e))(Ym||{}),Qm=(e=>(e[e.Loading=0]="Loading",e[e.Loaded=1]="Loaded",e[e.Error=3]="Error",e[e.NoData=4]="NoData",e[e.Unavailable=5]="Unavailable",e))(Qm||{}),Xm=(e=>(e[e.Quantity=1]="Quantity",e[e.Percentage=2]="Percentage",e[e.QuantityPercentage=3]="QuantityPercentage",e))(Xm||{}),Jm=(e=>(e[e.Program=1]="Program",e[e.Project=2]="Project",e[e.Action=3]="Action",e[e.PerformanceProject=4]="PerformanceProject",e[e.PerformanceAction=5]="PerformanceAction",e))(Jm||{}),Zm=(e=>(e.OccurrenceActionPlans="xebGnSSq",e.OccurrenceGeneral="UFws4AvH",e.PlansActionPlans="Kux6CcVC",e.PlansProgramProjects="UWjrp6Dw",e.PlansIdeas="3g7vNm2w",e.RisksGeneral="PZ4b6FhP",e.RisksActionPlans="xZErDg57",e.RisksAnalysis="UxsioMbH",e.RisksIncidences="gNt5IJ2F",e.MetrologyGeneral="4MfEPbRY",e.MetrologyActivities="hdFM9XQW",e.MetrologyServiceOrders="cIrVPdMv",e.DecisionsGeneral="CopsnHDB",e.DecisionsItems="qLFAayjx",e.DecisionsActionPlans="RiQFpxdb",e.FlowGeneral="AFV98JoG",e.AuditGeneral="gON8LJPi",e.AuditPlans="SsCNVOvr",e.AuditPlansItems="OpPkCCFm",e.AuditActionPlans="P1oGePhh",e.CommonGeneral="VVfEzgMQ",e.ActionPlans="C6Z4MgGa",e.SuppliersEvaluations="fSCeS4mH",e.SuppliersGeneral="8qPThkrD",e.SuppliersEvaluationsCriteria="RiSIStdY",e.SuppliersDocuments="Riua4jMa",e.SuppliersMaterialsServices="UpEkatXH",e.DocumentsGeneral="FRhhEX2J",e.DocumentsPhysicalCopies="PZLtJ23h",e.DocumentsObsolete="XDjbga14",e.FmeaGeneral="aPwf4uPr",e.FmeaActionPlans="vQ8PMrVX",e))(Zm||{}),ep=(e=>(e[e.NotShared=1]="NotShared",e[e.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",e[e.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",e))(ep||{}),tp=(e=>(e[e.All=1]="All",e[e.OnlyMine=2]="OnlyMine",e[e.Favorites=3]="Favorites",e))(tp||{}),ap=(e=>(e[e.Current=1]="Current",e[e.Inherent=2]="Inherent",e))(ap||{}),rp=(e=>(e[e.Default=1]="Default",e[e.Pastel=2]="Pastel",e[e.Vibrant=3]="Vibrant",e[e.Earth=4]="Earth",e[e.Ocean=5]="Ocean",e[e.Floral=6]="Floral",e[e.Night=7]="Night",e[e.Winter=8]="Winter",e[e.Spring=9]="Spring",e[e.Summer=10]="Summer",e[e.Fall=11]="Fall",e[e.Gray=12]="Gray",e[e.Brown=13]="Brown",e[e.Blue=14]="Blue",e[e.Yellow=15]="Yellow",e[e.Green=16]="Green",e[e.Purple=17]="Purple",e[e.Orange=18]="Orange",e[e.Pink=19]="Pink",e[e.Red=20]="Red",e))(rp||{});const sp={jan:1,fev:2,mar:3,abr:4,mai:5,jun:6,jul:7,ago:8,set:9,out:10,nov:11,dez:12},np=["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"],op=["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 ip(e){if(!e)return 0;const[t,a]=e.split("/"),r=sp[t?.toLowerCase()]??0;return 12*(parseInt(a)||0)+r}function lp(e){const t=e.split("/"),a=t[t.length-1];return`${t.slice(0,-1).join("/")}/${encodeURIComponent(a.replace(/[!@#$%^&*()_+={}[\]|\\;:'",.<>?/`~]/g,""))}`}function cp(e){for(const t of op)if(e[t])return e[t];return null}function dp(e){const t=[];for(const a of Object.keys(e)){const r=e[a];null!=r&&(r instanceof Date?t.push(`${a}=${r.toISOString()}`):Array.isArray(r)?r.forEach(e=>{t.push(...dp({[a]:e}))}):"string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r||t.push(`${a}=${r}`))}return t}const up=/^-?\d+(,\d{3})*(\.\d+)?$/;const mp=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});const pp=new Set([Bm.Text]),hp=new Set([Bm.Text,Bm.Numeric,Bm.RiskMatrix,Bm.Burndown,Bm.PerformanceColumns]),xp=new Set([Bm.Text,Bm.RiskMatrix,Bm.Burndown,Bm.PerformanceColumns]);function fp({config:e,viewOnly:r=!1,complement:s,complementPosition:n="before-options",queryUrlBuilder:o,onRefresh:i,onExport:l,onToggleOnlyMine:d,className:u}){const{t:m}=y.useTranslation(),[p,h]=a.useState(e.onlyMine??!1),x=pp.has(e.typeId),f=!hp.has(e.typeId),g=!xp.has(e.typeId),b=a.useMemo(()=>{if(!e.jsonRules||e.typeId===Bm.PerformanceColumns)return!1;try{const t=JSON.parse(e.jsonRules);return t?.rules?.rules?.length>0}catch{return!1}},[e.jsonRules,e.typeId]),v=a.useMemo(()=>o?.(e)??"#",[o,e]),w=a.useCallback(()=>{const e=!p;h(e),d?.(e)},[p,d]),j=[];return p&&j.push(m("dashboard_only_mine")),e.onlyLate&&j.push(m("dashboard_only_overdue")),b&&j.push(m("dashboard_advanced_filter")),t.jsxs("div",{className:_r("flex items-center justify-between gap-2 border-b bg-muted/30 px-2.5 py-1 text-sm font-medium",u),children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:["before-title"===n&&s,t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("span",{className:"block truncate",children:e.title})}),t.jsx(en,{children:e.title})]}),j.length>0&&t.jsx("span",{className:"text-[9px] font-normal text-muted-foreground truncate",children:j.join(" | ")})]}),"after-title"===n&&s]}),!r&&t.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:["before-options"===n&&s,t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-6 w-6",children:t.jsx(c.MoreVertical,{className:"h-3.5 w-3.5"})})}),t.jsxs($s,{align:"end",className:"w-48",children:[e.canUpdate&&t.jsxs(Ws,{onClick:()=>e.onEdit?.(e.id),children:[t.jsx(c.Pencil,{className:"mr-2 h-3.5 w-3.5"}),"Editar"]}),!x&&t.jsxs(Ws,{onClick:i,children:[t.jsx(c.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),"Atualizar"]}),f&&t.jsxs(Ws,{disabled:e.noData,onClick:l,children:[t.jsx(c.Download,{className:"mr-2 h-3.5 w-3.5"}),"Exportar"]}),!x&&t.jsxs(Ws,{disabled:!e.openQueryEnabled,onClick:()=>window.open(v,"_blank"),children:[t.jsx(c.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Abrir consulta"]}),g&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{}),t.jsxs(Ws,{onClick:w,children:[p&&t.jsx(c.Check,{className:"mr-2 h-3.5 w-3.5"}),!p&&t.jsx("span",{className:"mr-2 w-3.5"}),"Somente meus"]})]}),e.canUpdate&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{}),t.jsxs(Ws,{onClick:()=>e.onDuplicate?.(e.id),children:[t.jsx(c.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Duplicar"]}),t.jsxs(Ws,{className:"text-destructive",onClick:()=>e.onRemove?.(e.id),children:[t.jsx(c.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Remover"]})]})]})]}),"after-options"===n&&s]})]})}function gp({config:e,queryUrl:a,className:r}){return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",r),children:[t.jsx(c.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),t.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"Erro ao exibir os dados."}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"A consulta não pôde ser realizada."}),t.jsxs("p",{className:"mt-2 text-xs",children:[a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:"Verificar a consulta"}),a&&e.canUpdate&&t.jsx("span",{className:"text-muted-foreground",children:" ou "}),e.canUpdate&&t.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>e.onEdit?.(e.id),children:"revisar o painel"})]})]})}function bp({panelType:e,className:a}){const r=e===Bm.Burndown;return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-2 p-4",a),children:[t.jsx(Is,{className:"h-10 w-10 text-muted-foreground/40"}),r&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Aguarde, processando dados..."})]})}function vp({hasRemovedColumn:a=!1,className:r}){return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",r),children:[t.jsx("h2",{className:"text-lg font-normal text-foreground/80 lg:text-base",children:e.t("no_data_to_display")}),t.jsx("p",{className:"text-sm text-muted-foreground lg:text-xs",children:e.t("dashboard_no_data")})]})}function yp({onRemove:e,className:a}){return t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",a),children:[t.jsx(c.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),t.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"A consulta não pôde ser realizada."}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Este recurso não está disponível."}),e&&t.jsx("p",{className:"mt-2 text-xs",children:t.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:e,children:"Remover painel"})})]})}const wp={[Pm.Count]:e.t("dashboard_distinct_count").replace("distinta","").trim()||"Count",[Pm.Sum]:"Sum",[Pm.Average]:e.t("dashboard_average"),[Pm.DistinctCount]:e.t("dashboard_distinct_count"),[Pm.Max]:e.t("dashboard_max_value"),[Pm.Min]:e.t("dashboard_min_value")};function jp({config:e,state:a,value:r,label:s,viewOnly:n=!1,onClick:o,onRefresh:i,queryUrl:l,queryUrlBuilder:c,className:d}){const{t:u}=y.useTranslation(),m=s??wp[e.aggregationType??""]??"",p=function(e,t){if(null==e)return"—";const a=np.includes(t.field),r=t.aggregationType===Pm.Count||t.aggregationType===Pm.DistinctCount;return a&&!r?mp.format("string"==typeof e?parseFloat(e):e):"number"==typeof e?r?String(e):e.toLocaleString("pt-BR",{maximumFractionDigits:2}):String(e)}(r,e);return t.jsxs("div",{className:_r("flex h-full flex-col",d),children:[t.jsx(fp,{config:e,viewOnly:n,onRefresh:i,queryUrlBuilder:c}),a===Qm.Loading&&t.jsx(bp,{}),a===Qm.Loaded&&t.jsxs("div",{className:_r("flex flex-1 flex-col items-center justify-center",o&&"cursor-pointer hover:bg-muted/20 transition-colors"),onClick:o,children:[t.jsx("span",{className:"text-[clamp(1.5rem,7vh,5rem)] font-bold text-foreground leading-tight",children:p}),m&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:m})]}),a===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:l}),a===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Np({config:e,state:a,htmlContent:r,viewOnly:s=!1,onRefresh:n,queryUrl:o,queryUrlBuilder:i,className:l}){const c=r??e.textTypeString??"";return t.jsxs("div",{className:_r("flex h-full flex-col",l),children:[t.jsx(fp,{config:e,viewOnly:s,onRefresh:n,queryUrlBuilder:i}),a===Qm.Loading&&t.jsx(bp,{}),a===Qm.Loaded&&t.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 prose prose-sm max-w-none text-foreground",dangerouslySetInnerHTML:{__html:c}}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:o})]})}function _p({config:e,state:r,data:s=[],columns:n=[],viewOnly:o=!1,onRowClick:i,onRefresh:l,onExport:c,queryUrl:d,queryUrlBuilder:u,enableRowLinks:m=!0,className:p}){const h=a.useMemo(()=>n.filter(e=>!1!==e.visible),[n]),x=a.useCallback(e=>{if(i)i(e);else if(m){const t=cp(e);t&&window.open(lp(t),"_blank")}},[i,m]);return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:o,onRefresh:l,onExport:c,queryUrlBuilder:u}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"sticky top-0 z-10 bg-muted/60 backdrop-blur-sm",children:t.jsx("tr",{children:h.map(e=>t.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))})}),t.jsx("tbody",{children:s.map((e,a)=>{const r=m&&!!cp(e);return t.jsx("tr",{className:_r("border-b border-border/50 transition-colors hover:bg-muted/30",(r||i)&&"cursor-pointer"),onClick:()=>x(e),children:h.map(a=>t.jsx("td",{className:"px-2 py-1.5 text-foreground whitespace-nowrap truncate max-w-[200px]",children:a.render?a.render(e[a.columnName],e):Cp(e[a.columnName],a)},a.columnName))},a)})})]})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:d}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Cp(e,t){return null==e?"":e instanceof Date?"datetime"===t.columnType?e.toLocaleString("pt-BR"):e.toLocaleDateString("pt-BR"):"number"==typeof e?e.toLocaleString("pt-BR"):String(e)}const kp=["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 Sp({config:e,variant:r,state:s,data:n=[],series:o,colors:i,categoryKey:l="key",yAxisFormat:c,viewOnly:d=!1,onPointClick:u,onRefresh:m,onExport:p,queryUrl:h,queryUrlBuilder:x,className:f}){const g=i?.length?i:e.hexColors?.length?e.hexColors:kp,b=a.useMemo(()=>o?.length?o:[{dataKey:"value",name:e.title}],[o,e.title]),v="bar"===r,y="stacked-column"===r,w=a.useMemo(()=>{if(c)return e=>c.replace("{value}",e.toLocaleString("pt-BR"))},[c]);return t.jsxs("div",{className:_r("flex h-full flex-col",f),children:[t.jsx(fp,{config:e,viewOnly:d,onRefresh:m,onExport:p,queryUrlBuilder:x}),s===Qm.Loading&&t.jsx(bp,{}),s===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:Ap({variant:r,data:n,series:b,colors:g,categoryKey:l,isHorizontalBar:v,isStacked:y,yAxisTickFormatter:w,tooltipFormatter:e=>"number"==typeof e?e.toLocaleString("pt-BR"):String(e??""),onPointClick:u})})}),s===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),s===Qm.Error&&t.jsx(gp,{config:e,queryUrl:h}),s===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ap({variant:e,data:a,series:r,colors:s,categoryKey:n,isHorizontalBar:o,isStacked:i,yAxisTickFormatter:l,tooltipFormatter:c,onPointClick:d}){const u={tick:{fontSize:11},tickLine:!1,axisLine:!1},m=t.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=t.jsx(q.YAxis,{dataKey:o?n:void 0,type:o?"category":"number",...u,width:o?100:60,tickFormatter:o?void 0:l}),h=t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),x=t.jsx(q.Tooltip,{formatter:c,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),f=r.length>1?t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}):null,g=d?(e,t)=>d(a[t],t):void 0;return"bar"===e||"column"===e||"stacked-column"===e?t.jsxs(q.BarChart,{data:a,layout:o?"vertical":"horizontal",margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,r.map((e,a)=>t.jsx(q.Bar,{dataKey:e.dataKey,name:e.name||e.dataKey,fill:e.color||s[a%s.length],stackId:i?e.stackId||"stack":void 0,radius:i?void 0:[2,2,0,0],onClick:g,cursor:d?"pointer":void 0},e.dataKey))]}):"area"===e?t.jsxs(q.AreaChart,{data:a,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,r.map((e,a)=>{const r=e.color||s[a%s.length];return t.jsx(q.Area,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:r,fill:r,fillOpacity:.15,strokeWidth:2,dot:!1,activeDot:{r:4,cursor:d?"pointer":void 0}},e.dataKey)})]}):t.jsxs(q.LineChart,{data:a,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,r.map((e,a)=>t.jsx(q.Line,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:e.color||s[a%s.length],strokeWidth:2,dot:{r:3},activeDot:{r:5,cursor:d?"pointer":void 0}},e.dataKey))]})}const Tp=["#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3","#b2df8a","#fb9a99","#fdbf6f","#cab2d6","#ffff99"];function Dp({config:e,state:r,data:s=[],colors:n,viewOnly:o=!1,onSliceClick:i,onRefresh:l,onExport:c,queryUrl:d,queryUrlBuilder:u,className:m}){const p=n?.length?n:e.hexColors?.length?e.hexColors:Tp,h=a.useMemo(()=>s.map(e=>({...e,name:String(e.key??""),value:e.value??0})),[s]),x=a.useMemo(()=>h.reduce((e,t)=>e+(t.value??0),0),[h]);return t.jsxs("div",{className:_r("flex h-full flex-col",m),children:[t.jsx(fp,{config:e,viewOnly:o,onRefresh:l,onExport:c,queryUrlBuilder:u}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.PieChart,{children:[t.jsx(q.Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:"80%",label:({name:e,percent:t})=>`${e??""}: ${(100*(t??0)).toFixed(0)}%`,labelLine:!0,onClick:i?(e,t)=>i(s[t],t):void 0,cursor:i?"pointer":void 0,children:h.map((e,a)=>t.jsx(q.Cell,{fill:p[a%p.length]},a))}),t.jsx(q.Tooltip,{formatter:e=>{const t="number"==typeof e?e:0,a=x>0?(t/x*100).toFixed(1):"0";return`${t.toLocaleString("pt-BR")} (${a}%)`}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}})]})})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:d}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ep({config:e,state:r,data:s=[],barColor:n,lineColor:o="#e31a1c",viewOnly:i=!1,onPointClick:l,onRefresh:c,onExport:d,queryUrl:u,queryUrlBuilder:m,className:p}){const h=e.hexColors?.length?e.hexColors:["#1f78b4"],x=n??h[0],f=a.useMemo(()=>{const e=[...s].sort((e,t)=>(t.value??0)-(e.value??0)),t=e.reduce((e,t)=>e+(t.value??0),0);let a=0;return e.map(e=>(a+=e.value??0,{key:String(e.key??""),value:e.value??0,cumulativePercent:t>0?Math.round(a/t*100):0}))},[s]);return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:i,onRefresh:c,onExport:d,queryUrlBuilder:m}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.ComposedChart,{data:f,margin:{top:5,right:30,left:0,bottom:5},children:[t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),t.jsx(q.XAxis,{dataKey:"key",tick:{fontSize:11},angle:-45,textAnchor:"end",height:60}),t.jsx(q.YAxis,{yAxisId:"left",tick:{fontSize:11},tickLine:!1,axisLine:!1}),t.jsx(q.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}%`,domain:[0,100]}),t.jsx(q.Tooltip,{formatter:(e,t)=>"% Acumulado"===t?`${e}%`:"number"==typeof e?e.toLocaleString("pt-BR"):e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),t.jsx(q.Bar,{yAxisId:"left",dataKey:"value",name:"Quantidade",fill:x,radius:[2,2,0,0],onClick:l?(e,t)=>l(s[t],t):void 0,cursor:l?"pointer":void 0}),t.jsx(q.Line,{yAxisId:"right",type:"monotone",dataKey:"cumulativePercent",name:"% Acumulado",stroke:o,strokeWidth:2,dot:{r:3,fill:o}})]})})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:u}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Pp({config:e,state:a,data:r=[],executedLabel:s,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onRefresh:c,queryUrl:d,queryUrlBuilder:u,className:m}){const{t:p}=y.useTranslation(),h=s??p("dashboard_work_done"),x=n??p("dashboard_work_planned");return t.jsxs("div",{className:_r("flex h-full flex-col",m),children:[t.jsx(fp,{config:e,viewOnly:l,onRefresh:c,queryUrlBuilder:u}),a===Qm.Loading&&t.jsx(bp,{panelType:Bm.Burndown}),a===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.AreaChart,{data:r,margin:{top:5,right:10,left:0,bottom:5},children:[t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),t.jsx(q.XAxis,{dataKey:"date",tick:{fontSize:10},angle:-45,textAnchor:"end",height:50}),t.jsx(q.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`,domain:[0,100]}),t.jsx(q.Tooltip,{formatter:e=>`${e}%`,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),t.jsx(q.Area,{type:"monotone",dataKey:"executedPercentage",name:h,stroke:o,fill:o,fillOpacity:.2,strokeWidth:2,dot:{r:3}}),t.jsx(q.Area,{type:"monotone",dataKey:"plannedPercentage",name:x,stroke:i,fill:i,fillOpacity:.1,strokeWidth:2,dot:{r:3}})]})})}),a===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:d}),a===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Ip({config:e,state:a,data:r=[],executedLabel:s,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onPointClick:c,onRefresh:d,queryUrl:u,queryUrlBuilder:m,className:p}){const{t:h}=y.useTranslation(),x=s??h("dashboard_work_done"),f=n??h("dashboard_work_planned");return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:l,onRefresh:d,queryUrlBuilder:m}),a===Qm.Loading&&t.jsx(bp,{}),a===Qm.Loaded&&t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(q.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(q.BarChart,{data:r,margin:{top:5,right:10,left:0,bottom:5},children:[t.jsx(q.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),t.jsx(q.XAxis,{dataKey:"name",tick:{fontSize:10},angle:-45,textAnchor:"end",height:60}),t.jsx(q.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`}),t.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"}}),t.jsx(q.Legend,{wrapperStyle:{fontSize:"11px"}}),t.jsx(q.Bar,{dataKey:"executedWork",name:x,fill:o,radius:[2,2,0,0],onClick:c?(e,t)=>c(r[t],t):void 0,cursor:c?"pointer":void 0}),t.jsx(q.Bar,{dataKey:"plannedWork",name:f,fill:i,radius:[2,2,0,0]})]})})}),a===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),a===Qm.Error&&t.jsx(gp,{config:e,queryUrl:u}),a===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}function Mp({config:e,state:r,rule:s,risks:n=[],matrixViewType:o=Gm.Quantity,viewOnly:i=!1,onCellClick:l,onRiskClick:c,onRefresh:d,queryUrl:u,queryUrlBuilder:m,className:p}){const h=a.useMemo(()=>[...s?.parametersY??[]].sort((e,t)=>t.position-e.position),[s?.parametersY]),x=s?.parametersX??[],f=a.useMemo(()=>{const e={};return n.forEach(t=>{const a=`${t.parameterYPosition}-${t.parameterXPosition}`;e[a]||(e[a]=[]),e[a].push(t)}),e},[n]);return t.jsxs("div",{className:_r("flex h-full flex-col",p),children:[t.jsx(fp,{config:e,viewOnly:i,onRefresh:d,queryUrlBuilder:m}),r===Qm.Loading&&t.jsx(bp,{}),r===Qm.Loaded&&s&&t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsxs("div",{className:"flex gap-4 items-stretch min-w-fit",children:[t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("span",{className:"text-xs font-medium text-muted-foreground [writing-mode:vertical-lr] rotate-180",children:s.name_y})}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex mb-1",children:[t.jsx("div",{className:"w-16 shrink-0"}),t.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:s.threat_strategy_type_name}),!s.disable_opportunities&&t.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:s.opportunity_strategy_type_name})]}),h.map((e,a)=>t.jsxs("div",{className:"flex",children:[t.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((r,n)=>{const i=((e,t)=>f[`${t.position}-${e.position}`]??[])(r,e),d=((e,t)=>s?.colorMatrix?.[t]?.[e]??"hsl(var(--muted))")(n,a);return t.jsxs("div",{className:_r("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||c)&&i.length>0&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:d},onClick:()=>i.length>0&&l?.(r,e,i),children:[o===Gm.Quantity&&i.length>0&&t.jsxs("span",{className:"text-xs font-semibold",children:[i.length," risco",1!==i.length?"s":""]}),o===Gm.AllRisksList&&i.map(e=>t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("button",{type:"button",className:"text-[10px] text-primary underline hover:text-primary/80",onClick:t=>{t.stopPropagation(),c?.(e)},children:e.code})}),t.jsxs(en,{className:"max-w-[250px]",children:[t.jsxs("p",{className:"font-medium",children:[e.code," - ",e.name]}),e.analysisDate&&t.jsxs("p",{className:"text-xs mt-1",children:["Última análise: ",t.jsx("strong",{children:e.analysisDate})]}),e.strategy&&t.jsxs("p",{className:"text-xs",children:["Estratégia: ",t.jsx("strong",{children:e.strategy})]}),e.resultName&&t.jsxs("p",{className:"text-xs",children:["Criticidade: ",t.jsx("strong",{style:{backgroundColor:d},className:"px-1 rounded",children:e.resultName})]})]})]},e.code))]},r.position)})]},e.position)),t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-16 shrink-0"}),x.map(e=>t.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))]}),t.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground mt-2",children:s.name_x})]})]})}),r===Qm.NoData&&t.jsx(vp,{hasRemovedColumn:e.hasRemovedColumn}),r===Qm.Error&&t.jsx(gp,{config:e,queryUrl:u}),r===Qm.Unavailable&&t.jsx(yp,{onRemove:()=>e.onRemove?.(e.id)})]})}const Rp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:a}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(a?Math.round(a):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:a}=e;return"scaleX("+t+") scaleY("+a+")"}},Transform:{toString(e){if(e)return[Rp.Translate.toString(e),Rp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function Lp(e){switch(Number(e)){case Bm.Area:case Bm.Bar:case Bm.Column:case Bm.Line:case Bm.Numeric:case Bm.Pie:case Bm.Text:return{x:1,y:1};default:return{x:2,y:2}}}function Fp({panel:e,columns:r,cellHeight:s,cellGap:n,allowDragging:o,children:i}){const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:m,isDragging:p}=X.useSortable({id:e.id,disabled:!o}),h=a.useMemo(()=>({gridColumn:`${e.col+1} / span ${e.sizeX}`,gridRow:`${e.row+1} / span ${e.sizeY}`,minHeight:e.sizeY*s+(e.sizeY-1)*n+"px",transform:Rp.Transform.toString(u),transition:m,zIndex:p?50:void 0,opacity:p?.85:1}),[e,r,s,n,u,m,p]);return t.jsxs("div",{ref:d,style:h,className:_r("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:[t.jsx("div",{className:_r("dashboard-panel-drag-handle",o&&"cursor-grab active:cursor-grabbing"),...o?c:{}}),t.jsx("div",{className:"h-full",children:i})]})}function zp({panels:e,columns:r=8,cellHeight:s=160,cellGap:n=10,allowDragging:o=!1,showGridLines:i=!1,renderPanel:l,onLayoutChange:c,className:d}){const[u,m]=a.useState(e);a.useMemo(()=>{m(e)},[e]);const p=Q.useSensors(Q.useSensor(Q.PointerSensor,{activationConstraint:{distance:8}})),h=a.useMemo(()=>0===u.length?1:Math.max(...u.map(e=>e.row+e.sizeY)),[u]),x=a.useMemo(()=>u.map(e=>e.id),[u]),f=a.useCallback(e=>{const{active:t,over:a}=e;if(!a||t.id===a.id)return;const r=u.findIndex(e=>e.id===t.id),s=u.findIndex(e=>e.id===a.id);if(-1===r||-1===s)return;const n=[...u],o={...n[r]},i={...n[s]},l=o.col,d=o.row;o.col=i.col,o.row=i.row,i.col=l,i.row=d,n[r]=o,n[s]=i,m(n),c?.(n)},[u,c]),g=a.useMemo(()=>({display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gridTemplateRows:`repeat(${h}, ${s}px)`,gap:`${n}px`}),[r,h,s,n]);return 0===u.length?t.jsxs("div",{className:_r("flex flex-col items-center justify-center py-16 text-center",d),children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Nenhum painel adicionado"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione painéis para visualizar seus dados aqui."})]}):t.jsx(Q.DndContext,{sensors:p,collisionDetection:Q.closestCenter,onDragEnd:f,children:t.jsx(X.SortableContext,{items:x,strategy:X.rectSortingStrategy,children:t.jsx("div",{style:g,className:_r("relative w-full",i&&"bg-muted/30",d),children:u.map(e=>t.jsx(Fp,{panel:e,columns:r,cellHeight:s,cellGap:n,allowDragging:o,children:l(e.id)},e.id))})})})}const Up={[Bm.Bar]:"bar",[Bm.Column]:"column",[Bm.StackedColumn]:"stacked-column",[Bm.Area]:"area",[Bm.Line]:"line",[Bm.EvolutionLine]:"evolution-line"};function Op({config:e,state:a,data:r,numericValue:s,listColumns:n,cartesianData:o,cartesianSeries:i,burndownData:l,performanceData:c,matrixRule:d,matrixRisks:u,onPanelClick:m}){const p=Up[e.typeId];if(p)return t.jsx(Sp,{config:e,variant:p,state:a,data:o,series:i});switch(e.typeId){case Bm.Numeric:return t.jsx(jp,{config:e,state:a,value:s});case Bm.Text:return t.jsx(Np,{config:e,state:a});case Bm.List:return t.jsx(_p,{config:e,state:a,data:r,columns:n??[]});case Bm.Pie:return t.jsx(Dp,{config:e,state:a,data:r});case Bm.Pareto:return t.jsx(Ep,{config:e,state:a,data:r});case Bm.Burndown:return t.jsx(Pp,{config:e,state:a,data:l});case Bm.PerformanceColumns:return t.jsx(Ip,{config:e,state:a,data:c});case Bm.RiskMatrix:return t.jsx(Mp,{config:e,state:a,rule:d,risks:u??[]});default:return t.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 Bp({dashboard:e,panels:r,pages:s,activePageId:n,canEdit:o=!1,isFullscreen:i=!1,isLoading:l=!1,getPanelData:c,onRefresh:d,onToggleFullscreen:u,onToggleFavorite:m,onEdit:p,onShare:h,onAddPanel:x,onEditPanel:f,onRemovePanel:g,onDuplicatePanel:b,onLayoutChange:v,onPageChange:w,toolbarActions:j,className:N}){const{t:_}=y.useTranslation(),[C,k]=a.useState(!1),S=e.idViewType===Vm.Carousel,A=a.useMemo(()=>r,[r,S,n]),T=a.useMemo(()=>A.map(e=>{const t=Lp(e.typeId);return{id:e.id,col:e.col,row:e.row,sizeX:e.sizeX,sizeY:e.sizeY,minSizeX:t.x,minSizeY:t.y}}),[A]),D=a.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:b}),[o,f,g,b]),E=a.useCallback(()=>{C||l||(k(!0),d?.(),setTimeout(()=>k(!1),3e4))},[C,l,d]),P=a.useCallback(e=>{const a=A.find(t=>t.id===e);if(!a)return null;const r=D(a),s=c?.(e)??{state:Qm.Loaded};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx(fp,{config:r,onRefresh:()=>{}}),t.jsx("div",{className:"flex-1 min-h-0 p-2",children:t.jsx(Op,{config:r,...s})})]})},[A,D,c,o,f,g,b]);return t.jsxs("div",{className:_r("flex flex-col h-full",i&&"fixed inset-0 z-50 bg-background",N),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-card",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:e.title}),e.responsibleName&&!i&&t.jsx("span",{className:"text-xs text-muted-foreground truncate hidden sm:inline",children:e.responsibleName})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[j,d&&t.jsx("button",{onClick:E,disabled:C||l,className:_r("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:t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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&&t.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:t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i?t.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"}):t.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&&t.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:t.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),m&&!i&&t.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:t.jsx("svg",{className:_r("h-4 w-4",e.isFavorite&&"fill-yellow-400 text-yellow-400"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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&&s&&s.length>1&&t.jsx("div",{className:"flex items-center gap-1 px-4 py-1 border-b border-border bg-card overflow-x-auto",children:s.map(e=>t.jsx("button",{onClick:()=>w?.(e.id),className:_r("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&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsxs("button",{onClick:x,className:_r("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:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})}),"Adicionar painel"]})}),l&&t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!l&&t.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted/30",children:t.jsx(zp,{panels:T,allowDragging:o,showGridLines:o,renderPanel:P,onLayoutChange:v})})]})}function qp(e,t=Hm.PtBr){const{t:a}=y.useTranslation();switch(t){case Hm.EnUs:return e.titleEnUs||e.titlePtBr||e.titleEsEs;case Hm.EsEs:return e.titleEsEs||e.titleEnUs||e.titlePtBr;default:return e.titlePtBr||e.titleEnUs||e.titleEsEs}}function Vp(e){const{t:t}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}const $p=[{value:tp.All,label:"Todos"},{value:tp.OnlyMine,label:e.t("dashboard_my")},{value:tp.Favorites,label:"Favoritos"}];function Wp({dashboards:e,limit:r,isLoading:s=!1,language:n=Hm.PtBr,canAdd:o=!1,canEdit:i=!1,canRemove:l=!1,onOpen:c,onEdit:d,onShare:u,onDuplicate:m,onRemove:p,onAdd:h,onToggleFavorite:x,onRefresh:f,onSearch:g,onQuickFilterChange:b,toolbarExtra:v,className:w}){const{t:j}=y.useTranslation(),[N,_]=a.useState(""),[C,k]=a.useState(tp.All),[S,A]=a.useState(null),T=a.useCallback(e=>{_(e),g?.(e)},[g]),D=a.useCallback(e=>{k(e),b?.(e)},[b]),E=a.useMemo(()=>{let t=e;if(N){const e=N.toLowerCase();t=t.filter(t=>t.code?.toLowerCase().includes(e)||qp(t,n).toLowerCase().includes(e)||t.responsibleName?.toLowerCase().includes(e))}switch(C){case tp.OnlyMine:break;case tp.Favorites:t=t.filter(e=>e.isFavorite)}return t},[e,N,C,n]);return t.jsxs("div",{className:_r("flex flex-col h-full",w),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboards"}),r&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",r.countDashboards,"/",r.maxDashboards,")"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative",children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("path",{d:"m21 21-4.3-4.3"})]}),t.jsx("input",{type:"text",placeholder:"Buscar...",value:N,onChange:e=>T(e.target.value),className:_r("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")})]}),v,o&&h&&t.jsxs("button",{onClick:h,className:_r("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:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})}),"Novo"]})]})]}),t.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-card",children:$p.map(e=>t.jsx("button",{onClick:()=>D(e.value),disabled:s,className:_r("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))}),s&&t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!s&&t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"sticky top-0 bg-muted/80 backdrop-blur-sm border-b border-border",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-12 px-3 py-2 text-left font-medium text-muted-foreground",children:t.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.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"})})}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Código"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Título"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Responsável"}),t.jsx("th",{className:"w-12 px-3 py-2 text-center font-medium text-muted-foreground",children:t.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Última modificação"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Situação"}),t.jsx("th",{className:"w-12 px-3 py-2"})]})}),t.jsxs("tbody",{children:[0===E.length&&t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-3 py-12 text-center text-muted-foreground",children:"Nenhum dashboard encontrado."})}),E.map(e=>t.jsxs("tr",{onClick:()=>c?.(e),className:_r("border-b border-border cursor-pointer transition-colors","hover:bg-accent/50"),children:[t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:t=>{t.stopPropagation(),x?.(e)},className:"p-1 hover:bg-accent rounded transition-colors",children:t.jsx("svg",{className:_r("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:t.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"})})})}),t.jsx("td",{className:"px-3 py-2 font-mono text-xs text-foreground",children:e.code}),t.jsx("td",{className:"px-3 py-2 text-foreground font-medium",children:qp(e,n)}),t.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:e.responsibleName}),t.jsx("td",{className:"px-3 py-2 text-center",children:e.hasSharedIcon&&t.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:Vp(e.lastModified)}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:_r("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"})}),t.jsx("td",{className:"px-3 py-2",children:t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:t=>{t.stopPropagation(),A(S===e.id?null:e.id)},className:"p-1 hover:bg-accent rounded transition-colors",children:t.jsxs("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1"}),t.jsx("circle",{cx:"12",cy:"12",r:"1"}),t.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),S===e.id&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>A(null)}),t.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:[t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),c?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Abrir"}),i&&t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),d?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Editar"}),i&&t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),u?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Compartilhar"}),t.jsx("button",{onClick:t=>{t.stopPropagation(),A(null),m?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Duplicar"}),l&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border"}),t.jsx("button",{onClick:t=>{t.stopPropagation(),A(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 Hp=[{value:qm.NotUpdate,label:e.t("dashboard_no_refresh")},{value:qm.FiveMinutes,label:"5 minutos"},{value:qm.TenMinutes,label:"10 minutos"},{value:qm.FifteenMinutes,label:"15 minutos"},{value:qm.ThirtyMinutes,label:"30 minutos"},{value:qm.OneHour,label:"1 hora"}],Gp=[{value:Vm.NormalPage,label:e.t("dashboard_normal_page")},{value:Vm.Carousel,label:"Carrossel"}],Kp=[{value:Lm.FiveSeconds,label:"5 segundos"},{value:Lm.TenSeconds,label:"10 segundos"},{value:Lm.FifteenSeconds,label:"15 segundos"},{value:Lm.ThirtySeconds,label:"30 segundos"},{value:Lm.OneMinute,label:"1 minuto"},{value:Lm.ThreeMinutes,label:"3 minutos"},{value:Lm.FiveMinutes,label:"5 minutos"},{value:Lm.TenMinutes,label:"10 minutos"}],Yp=[{value:Wm.NotShared,label:e.t("dashboard_not_shared"),description:e.t("dashboard_only_responsible")},{value:Wm.SharedWithAllCollaborators,label:e.t("dashboard_shared_unit"),description:e.t("dashboard_all_access")},{value:Wm.SharedWithUsersGroupsPlacesCollaborators,label:e.t("dashboard_select_groups"),description:e.t("dashboard_select_groups")}],Qp=[{key:"pt-br",label:"PT-BR"},{key:"en",label:"EN-US"},{key:"es",label:"ES-ES"}];function Xp({dashboard:e,initialTab:r=$m.General,isSaving:s=!1,isQualitfy:n=!1,users:o=[],groups:i=[],places:l=[],collaborators:c=[],onSave:d,onCancel:u,className:m}){const{t:p}=y.useTranslation(),h=!!e,[x,f]=a.useState(r),[g,b]=a.useState({"pt-br":!!e?.titlePtBr||!h,en:!!e?.titleEnUs,es:!!e?.titleEsEs}),[v,w]=a.useState(e?.titlePtBr??""),[j,N]=a.useState(e?.titleEnUs??""),[_,C]=a.useState(e?.titleEsEs??""),[k,S]=a.useState(e?.responsibleId??""),[A,T]=a.useState(e?.isActive??!0),[D,E]=a.useState(e?.idUpdateTime??qm.NotUpdate),[P,I]=a.useState(e?.idViewType??Vm.NormalPage),[M,R]=a.useState(e?.idPageTime??Lm.FifteenSeconds),[L,F]=a.useState(e?.idShare??Wm.NotShared),[z,U]=a.useState(e?.groups??[]),[O,B]=a.useState(e?.places??[]),[q,V]=a.useState(e?.collaborators??[]),$=P===Vm.Carousel,W=g["pt-br"]||g.en||g.es,H=a.useMemo(()=>!!W&&(!(g["pt-br"]&&!v.trim())&&(!(g.en&&!j.trim())&&!(g.es&&!_.trim()))),[W,g,v,j,_]),G=a.useCallback(e=>{b(t=>({...t,[e]:!t[e]}))},[]),K=a.useCallback(()=>{H&&!s&&d?.({titlePtBr:g["pt-br"]?v:"",titleEnUs:g.en?j:"",titleEsEs:g.es?_:"",responsibleId:k||void 0,isActive:A,idUpdateTime:D,idViewType:P,idPageTime:$?M:null,idShare:L,groups:L===Wm.SharedWithUsersGroupsPlacesCollaborators?z:[],places:L===Wm.SharedWithUsersGroupsPlacesCollaborators?O:[],collaborators:L===Wm.SharedWithUsersGroupsPlacesCollaborators?q:[]})},[H,s,d,g,v,j,_,k,A,D,P,M,$,L,z,O,q]);return t.jsxs("div",{className:_r("flex flex-col h-full bg-background",m),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p(h?"dashboard_edit":"dashboard_new")}),h&&e&&t.jsx("span",{className:"text-sm text-muted-foreground",children:e.code})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:u,className:"px-3 py-2 text-sm rounded-md border border-input hover:bg-accent transition-colors",children:"Cancelar"}),t.jsxs("button",{onClick:K,disabled:!H||s,className:_r("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:[s?t.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"}):t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Salvar"]})]})]}),t.jsxs("div",{className:"flex border-b border-border bg-card",children:[t.jsx("button",{onClick:()=>f($m.General),className:_r("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===$m.General?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Geral"}),t.jsx("button",{onClick:()=>f($m.Share),className:_r("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===$m.Share?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Compartilhamento"})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x===$m.General&&t.jsxs("div",{className:"max-w-2xl space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Título *"}),t.jsx("div",{className:"flex gap-2",children:Qp.map(e=>t.jsx("button",{onClick:()=>G(e.key),className:_r("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&&t.jsx("p",{className:"text-xs text-destructive",children:"Selecione pelo menos um idioma"})]}),g["pt-br"]&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Português (BR)"}),t.jsx("input",{value:v,onChange:e=>w(e.target.value),maxLength:200,className:_r("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")}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[v.length,"/200"]})]}),g.en&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Inglês (US)"}),t.jsx("input",{value:j,onChange:e=>N(e.target.value),maxLength:200,className:_r("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")}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[j.length,"/200"]})]}),g.es&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Espanhol (ES)"}),t.jsx("input",{value:_,onChange:e=>C(e.target.value),maxLength:200,className:_r("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")}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[_.length,"/200"]})]}),!e?.isStandard&&o.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Responsável"}),t.jsxs("select",{value:k,onChange:e=>S(e.target.value),disabled:!h,className:_r("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:[t.jsx("option",{value:"",children:"Selecione..."}),o.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Intervalo de atualização"}),t.jsx("select",{value:D,onChange:e=>E(Number(e.target.value)),disabled:n,className:_r("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:Hp.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Situação"}),t.jsxs("div",{className:"flex items-center gap-3 h-10",children:[t.jsx("button",{onClick:()=>T(!A),disabled:e?.isGeneralViewUse,className:_r("relative inline-flex h-6 w-11 items-center rounded-full transition-colors",A?"bg-primary":"bg-muted","disabled:opacity-50"),children:t.jsx("span",{className:_r("inline-block h-4 w-4 rounded-full bg-white transition-transform",A?"translate-x-6":"translate-x-1")})}),t.jsx("span",{className:"text-sm text-foreground",children:A?"Ativo":"Inativo"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Tipo de visualização"}),t.jsx("select",{value:P,onChange:e=>I(Number(e.target.value)),disabled:n||$,className:_r("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:Gp.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]}),$&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm text-muted-foreground",children:"Trocar página a cada"}),t.jsx("select",{value:M??"",onChange:e=>R(Number(e.target.value)),className:_r("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:Kp.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]})]})]}),x===$m.Share&&t.jsxs("div",{className:"max-w-2xl space-y-6",children:[t.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 border border-border",children:[t.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:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{d:"M12 16v-4"}),t.jsx("path",{d:"M12 8h.01"})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure quem pode visualizar este dashboard. O responsável sempre terá acesso."})]}),t.jsx("div",{className:"space-y-3",children:Yp.map(a=>t.jsxs("label",{className:_r("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",L===a.value?"border-primary bg-primary/5":"border-border hover:bg-accent/50",e?.isGeneralViewUse&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"shareType",value:a.value,checked:L===a.value,onChange:()=>F(a.value),disabled:e?.isGeneralViewUse,className:"mt-1 accent-primary"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:a.label}),t.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]},a.value))}),L===Wm.SharedWithUsersGroupsPlacesCollaborators&&t.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Grupos de usuários (",z.length,")"]}),t.jsx("select",{multiple:!0,value:z,onChange:e=>{const t=Array.from(e.target.selectedOptions,e=>e.value);U(t)},className:_r("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=>t.jsx("option",{value:e.id,children:e.name},e.id))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Locais (",O.length,")"]}),t.jsx("select",{multiple:!0,value:O,onChange:e=>{const t=Array.from(e.target.selectedOptions,e=>e.value);B(t)},className:_r("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=>t.jsx("option",{value:e.id,children:e.name},e.id))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Colaboradores (",q.length,")"]}),t.jsx("select",{multiple:!0,value:q,onChange:e=>{const t=Array.from(e.target.selectedOptions,e=>e.value);V(t)},className:_r("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:c.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))})]})]})]})]})]})}function Jp(){return`n_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Zp(e,t){return{id:t?.id??Jp(),text:e,children:t?.children,collapsed:t?.collapsed,color:t?.color,icon:t?.icon,note:t?.note,side:t?.side}}function eh(e,t){if(e.id===t)return{node:e,parent:null};const a=[];for(const r of e.children??[])a.push({node:r,parent:e});for(;a.length;){const e=a.pop();if(e.node.id===t)return{node:e.node,parent:e.parent};for(const t of e.node.children??[])a.push({node:t,parent:e.node})}return null}function th(e,t){const a=t(e);return a.children?.length?{...a,children:a.children.map(e=>th(e,t))}:a}function ah(e,t,a){return th(e,e=>e.id===t?a(e):e)}function rh(e){return{left:(e.children??[]).filter(e=>"left"===e.side).length,right:(e.children??[]).filter(e=>"left"!==e.side).length}}function sh(e,t,a){const r=Zp(a||"");let s=r.id;return{root:th(e,a=>{if(a.id!==t)return a;let n=r;if(a.id===e.id){const t=rh(e);n={...n,side:t.left<=t.right?"left":"right"}}else n={...n,side:a.side};return s=n.id,{...a,collapsed:!1,children:[...a.children??[],n]}}),newId:s}}function nh(e,t,a){if(e.id===t)return sh(e,t,a);const r=eh(e,t);if(!r||!r.parent)return{root:e,newId:t};const s=r.parent,n=Zp(a||"",{side:r.node.side}),o=n.id;return{root:th(e,e=>{if(e.id!==s.id)return e;const a=(e.children??[]).findIndex(e=>e.id===t),r=[...e.children??[]];return r.splice(a+1,0,n),{...e,children:r}}),newId:o}}function oh(e,t){if(e.id===t)return{root:e,nextSelectedId:t};const a=eh(e,t);if(!a||!a.parent)return{root:e,nextSelectedId:null};const r=a.parent,s=r.children??[],n=s.findIndex(e=>e.id===t),o=s[n+1]?.id??s[n-1]?.id??r.id;return{root:th(e,e=>e.id!==r.id?e:{...e,children:(e.children??[]).filter(e=>e.id!==t)}),nextSelectedId:o}}function ih(e,t,a){if(t===a)return e;if(t===e.id)return e;if(function(e,t,a){const r=eh(e,t);return!!r&&!!eh(r.node,a)}(e,t,a))return e;const r=eh(e,t);if(!r)return e;const s=(()=>{if(a===e.id){const t=rh(e);return{...r.node,side:t.left<=t.right?"left":"right"}}const t=eh(e,a)?.node;return{...r.node,side:t?.side}})(),n=th(e,e=>e.children?.length&&e.children.some(e=>e.id===t)?{...e,children:e.children.filter(e=>e.id!==t)}:e);return th(n,e=>e.id!==a?e:{...e,collapsed:!1,children:[...e.children??[],s]})}function lh(e,t){return ah(e,t,e=>({...e,collapsed:!e.collapsed}))}function ch(e,t){return th(e,a=>a.children?.length?a.id===e.id&&t?a:{...a,collapsed:t}:a)}function dh(e){const{value:t,defaultValue:r,onChange:s,readOnly:n}=e,o=void 0!==t,[i,l]=a.useState(()=>r??t??Zp("Mapa Mental",{id:"root"})),c=o?t:i,[d,u]=a.useState(c.id),m=a.useRef([]),p=a.useRef([]),h=a.useCallback((e,t)=>{n||(m.current.push(t),m.current.length>50&&m.current.shift(),p.current=[],o||l(e),s?.(e))},[o,s,n]),x=a.useCallback((e,t)=>{const a=ah(c,e,e=>({...e,text:t}));h(a,c)},[c,h]),f=a.useCallback((e,t)=>{const a=ah(c,e,e=>({...e,...t}));h(a,c)},[c,h]),g=a.useCallback((e,t="")=>{const{root:a,newId:r}=sh(c,e,t);return h(a,c),u(r),r},[c,h]),b=a.useCallback((e,t="")=>{const{root:a,newId:r}=nh(c,e,t);return h(a,c),u(r),r},[c,h]),v=a.useCallback(e=>{const{root:t,nextSelectedId:a}=oh(c,e);t!==c&&(h(t,c),u(a))},[c,h]),y=a.useCallback((e,t)=>{const a=ih(c,e,t);a!==c&&h(a,c)},[c,h]),w=a.useCallback(e=>{const t=eh(c,e);if(!t||!t.node.children?.length)return;const a=lh(c,e);h(a,c)},[c,h]),j=a.useCallback(()=>{h(ch(c,!1),c)},[c,h]),N=a.useCallback(()=>{h(ch(c,!0),c)},[c,h]),_=a.useCallback(()=>{const e=m.current.pop();e&&(p.current.push(c),o||l(e),s?.(e))},[c,o,s]),C=a.useCallback(()=>{const e=p.current.pop();e&&(m.current.push(c),o||l(e),s?.(e))},[c,o,s]),k=m.current.length>0,S=p.current.length>0,A=a.useMemo(()=>d?eh(c,d)?.node??null:null,[c,d]),T=a.useCallback(e=>{h(e,c)},[c,h]);return{root:c,setRoot:T,selectedId:d,selectedNode:A,setSelectedId:u,renameNode:x,updateNodeProps:f,addChild:g,addSibling:b,removeNode:v,moveNode:y,toggleNode:w,expandAll:j,collapseAll:N,undo:_,redo:C,canUndo:k,canRedo:S}}const uh=180,mh=80,ph=16,hh=60;function xh(e){const t=(e.collapsed?[]:e.children??[]).map(xh);if(!t.length)return{node:e,visibleChildren:t,height:44};const a=t.reduce((e,t)=>e+t.height,0)+ph*(t.length-1);return{node:e,visibleChildren:t,height:Math.max(44,a)}}function fh(e,t,a,r,s,n,o){const i=[],l={node:e.node,parent:t,x:a,y:r,width:180,height:44,side:s,depth:n,visibleChildren:i};if(o.push(l),!e.visibleChildren.length)return l;let c=r+22-(e.visibleChildren.reduce((e,t)=>e+t.height,0)+ph*(e.visibleChildren.length-1))/2;for(const d of e.visibleChildren){const t="right"===s?a+180+mh:a-mh-uh,r=c+d.height/2-22,l=fh(d,e.node,t,r,s,n+1,o);i.push(l),c+=d.height+ph}return l}function gh(e){return a.useMemo(()=>function(e){const t=e.collapsed?[]:e.children??[],a=t.filter(e=>"left"!==e.side).map(xh),r=t.filter(e=>"left"===e.side).map(xh),s=a.reduce((e,t)=>e+t.height,0)+ph*Math.max(0,a.length-1),n=r.reduce((e,t)=>e+t.height,0)+ph*Math.max(0,r.length-1),o=Math.max(s,n,56),i=e=>e.visibleChildren.length?1+Math.max(...e.visibleChildren.map(i)):0,l=a.length?Math.max(...a.map(i))+1:0,c=260*(r.length?Math.max(...r.map(i))+1:0),d=220+260*l+c+120,u=o+120,m=hh+c,p=[],h={node:e,parent:null,x:m,y:hh+o/2-28,width:220,height:56,side:"root",depth:0,visibleChildren:[]};p.push(h);let x=hh+o/2-s/2;for(const b of a){const t=x+b.height/2-22,a=fh(b,e,m+220+mh,t,"right",1,p);h.visibleChildren.push(a),x+=b.height+ph}let f=hh+o/2-n/2;for(const b of r){const t=f+b.height/2-22,a=fh(b,e,m-mh-uh,t,"left",1,p);h.visibleChildren.push(a),f+=b.height+ph}const g=new Map(p.map(e=>[e.node.id,e]));return{nodes:p,byId:g,width:d,height:u}}(e),[e])}function bh(e,t){const{layout:a,selectedId:r,setSelectedId:s}=t;if(!r)return void s(a.nodes[0]?.node.id??null);const n=a.byId.get(r);if(!n)return;if("left"===e||"right"===e){if("root"===n.side){const t=n.visibleChildren.find(t=>t.side===e);return void(t&&s(t.node.id))}if(e===n.side){const e=n.visibleChildren[Math.floor(n.visibleChildren.length/2)];e&&s(e.node.id)}else n.parent&&s(n.parent.id);return}if(!n.parent)return;const o=a.byId.get(n.parent.id);if(!o)return;const i=o.visibleChildren.filter(e=>e.side===n.side),l=i.findIndex(e=>e.node.id===r),c="up"===e?i[l-1]:i[l+1];c&&s(c.node.id)}const vh=({layout:e,selected:a,editing:r,readOnly:s,onSelect:n,onStartEditing:o,onFinishEditing:i,onToggle:l,onDragStart:d,onDragOver:u,onDragLeave:m,onDrop:p,isDropTarget:h,renderNodeContent:x})=>{const f=e.node,g="root"===e.side,b=function(e){return e?ae[e]??null:null}(f.icon),v=!!f.children?.length,y=te.useRef(null),[w,j]=te.useState(f.text);te.useEffect(()=>{if(r){j(f.text);const e=window.setTimeout(()=>{y.current?.focus(),y.current?.select()},0);return()=>window.clearTimeout(e)}},[r,f.text]);const N=()=>{i(w.trim()||f.text)},_=f.color;return t.jsxs("div",{role:"treeitem","aria-selected":a,"aria-expanded":v?!f.collapsed:void 0,tabIndex:a?0:-1,"data-node-id":f.id,draggable:!s&&!g&&!r,onDragStart:d,onDragOver:u,onDragLeave:m,onDrop:p,onClick:e=>{e.stopPropagation(),n()},onDoubleClick:e=>{e.stopPropagation(),s||o()},className:_r("absolute flex items-center gap-2 rounded-lg border bg-card text-card-foreground px-3 select-none transition-shadow","shadow-sm hover:shadow-md cursor-pointer",g&&"font-semibold border-primary/40 bg-primary text-primary-foreground",a&&!g&&"ring-2 ring-primary ring-offset-1",a&&g&&"ring-2 ring-primary-foreground/60 ring-offset-1",h&&"ring-2 ring-accent border-accent"),style:{left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:_},children:[b&&t.jsx(b,{className:_r("h-4 w-4 shrink-0",g&&"text-primary-foreground")}),t.jsx("div",{className:"flex-1 min-w-0",children:r?t.jsx("input",{ref:y,value:w,onChange:e=>j(e.target.value),onBlur:N,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),N()):"Escape"===e.key?(e.preventDefault(),i(null)):e.stopPropagation()},className:_r("w-full bg-transparent outline-none text-sm",g&&"text-primary-foreground placeholder:text-primary-foreground/60")}):x?t.jsx("div",{className:"text-sm truncate",children:x(f)}):t.jsx("div",{className:"text-sm truncate",children:f.text||t.jsx("span",{className:"opacity-50",children:"—"})})}),f.note&&!r&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("button",{type:"button",onClick:e=>e.stopPropagation(),className:_r("shrink-0 rounded p-0.5 hover:bg-muted/40",g&&"hover:bg-primary-foreground/10"),"aria-label":f.note,children:t.jsx(c.FileText,{className:"h-3.5 w-3.5 opacity-70"})})}),t.jsx(en,{className:"max-w-xs whitespace-pre-line",children:f.note})]}),v&&t.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},className:_r("shrink-0 rounded-full border bg-background text-foreground h-5 w-5 flex items-center justify-center -mr-1","shadow-sm hover:bg-muted transition-colors",g&&"border-primary-foreground/30"),"aria-label":f.collapsed?"Expandir":"Colapsar",children:f.collapsed?t.jsx(c.Plus,{className:"h-3 w-3"}):"left"===e.side?t.jsx(c.ChevronRight,{className:"h-3 w-3 rotate-180"}):"right"===e.side?t.jsx(c.ChevronRight,{className:"h-3 w-3"}):t.jsx(c.Minus,{className:"h-3 w-3"})})]})},yh=({parent:e,child:a})=>{const r=a.x+a.width/2<e.x+e.width/2,s=r?e.x:e.x+e.width,n=e.y+e.height/2,o=r?a.x+a.width:a.x,i=a.y+a.height/2,l=(s+o)/2,c=`M ${s} ${n} C ${l} ${n}, ${l} ${i}, ${o} ${i}`;return t.jsx("path",{d:c,fill:"none",stroke:"hsl(var(--border))",strokeWidth:2,strokeLinecap:"round"})},wh=({label:e,icon:a,onClick:r,disabled:s})=>t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",onClick:r,disabled:s,"aria-label":e,className:"h-8 w-8",children:a})}),t.jsx(en,{children:e})]}),jh=e=>{const{t:a}=y.useTranslation();return t.jsxs("div",{className:"flex items-center gap-1 border-b bg-card px-2 py-1.5",children:[t.jsx(wh,{label:a("mind_map_add_child"),icon:t.jsx(c.CornerDownRight,{className:"h-4 w-4"}),onClick:e.onAddChild,disabled:!e.canAddChild}),t.jsx(wh,{label:a("mind_map_add_sibling"),icon:t.jsx(c.Plus,{className:"h-4 w-4"}),onClick:e.onAddSibling,disabled:!e.canAddSibling}),t.jsx(wh,{label:a("mind_map_delete_node"),icon:t.jsx(c.Trash2,{className:"h-4 w-4"}),onClick:e.onDelete,disabled:!e.canDelete}),t.jsx(zr,{orientation:"vertical",className:"mx-1 h-5"}),t.jsx(wh,{label:a("mind_map_expand_all"),icon:t.jsx(c.ChevronsUpDown,{className:"h-4 w-4"}),onClick:e.onExpandAll}),t.jsx(wh,{label:a("mind_map_collapse_all"),icon:t.jsx(c.ChevronsDownUp,{className:"h-4 w-4"}),onClick:e.onCollapseAll}),t.jsx(zr,{orientation:"vertical",className:"mx-1 h-5"}),t.jsx(wh,{label:a("mind_map_zoom_out"),icon:t.jsx(c.ZoomOut,{className:"h-4 w-4"}),onClick:e.onZoomOut}),t.jsx(wh,{label:a("mind_map_zoom_in"),icon:t.jsx(c.ZoomIn,{className:"h-4 w-4"}),onClick:e.onZoomIn}),t.jsx(wh,{label:a("mind_map_fit_to_screen"),icon:t.jsx(c.Maximize2,{className:"h-4 w-4"}),onClick:e.onFit}),t.jsx(zr,{orientation:"vertical",className:"mx-1 h-5"}),t.jsx(wh,{label:a("mind_map_undo"),icon:t.jsx(c.Undo2,{className:"h-4 w-4"}),onClick:e.onUndo,disabled:!e.canUndo}),t.jsx(wh,{label:a("mind_map_redo"),icon:t.jsx(c.Redo2,{className:"h-4 w-4"}),onClick:e.onRedo,disabled:!e.canRedo}),t.jsx("div",{className:"flex-1"}),t.jsx(wh,{label:a("mind_map_export_json"),icon:t.jsx(c.Download,{className:"h-4 w-4"}),onClick:e.onExportJson}),t.jsx(wh,{label:a("mind_map_export_image"),icon:t.jsx(c.Image,{className:"h-4 w-4"}),onClick:e.onExportImage})]})};function Nh(e){return JSON.stringify(e,null,2)}function _h(e){if(!e||"object"!=typeof e)throw new Error("Invalid mind map node: not an object");const t=e;if("string"!=typeof t.text)throw new Error('Invalid mind map node: missing "text"');const a=Array.isArray(t.children)?t.children.map(e=>_h(e)):void 0;return Zp(t.text,{id:"string"==typeof t.id?t.id:void 0,collapsed:"boolean"==typeof t.collapsed?t.collapsed:void 0,color:"string"==typeof t.color?t.color:void 0,icon:"string"==typeof t.icon?t.icon:void 0,note:"string"==typeof t.note?t.note:void 0,side:"left"===t.side||"right"===t.side?t.side:void 0,children:a})}function Ch({data:e,columns:r,sortField:s,sortDirection:n,onSort:o,onRowClick:i,renderActions:l,isLoading:d=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,enableColumnReorder:w=!1,onReorderColumns:j,storageKey:N,enableExpandableRows:_=!1,renderExpandedContent:C,expandedRowIds:k,onToggleExpand:S,defaultExpandAll:A=!1,rowActionsVariant:T="default",hideActionsColumn:D=!1,actionsHeaderContent:E}){const{t:P}=y.useTranslation(),I=u||P("no_items_found",P("no_items_found_empty")),[M,R]=a.useState(()=>A?new Set(e.map(e=>e.id)):new Set),L=void 0!==k,F=L?new Set(k):M,z=a.useCallback(e=>{L&&S?S(e):R(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[L,S]),{columnWidths:U,isDragging:O,activeColumn:B,handleMouseDown:q}=di({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,onResize:v,enabled:b}),V=yi({enabled:w&&!!j,onReorder:j??(()=>{})}),$=a.useMemo(()=>{if(b){const e=r.map(e=>U[String(e.key)]??e.width??e.minWidth??150),t=e.reduce((e,t)=>e+t,0);return e.map(e=>e/t*100+"%")}const e=r.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return r.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[r,b,U]);if(d)return t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,a)=>t.jsx(hn,{className:"h-12 w-full"},a))})});if(0===e.length)return t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx("p",{children:I})})});const W=l&&!D,H=(p?1:0)+(_?1:0)+r.length+(W?1:0);return t.jsx("div",{className:"flex-1 overflow-auto "+(O?"select-none":""),children:t.jsxs(Eo,{className:_r("table-fixed w-full",m),children:[t.jsx(Po,{className:"sticky top-0 bg-background z-10",children:t.jsxs(Ro,{children:[_&&t.jsx(Lo,{className:"w-[40px]"}),p&&t.jsx(Lo,{className:"w-[40px]",children:t.jsx(As,{checked:g,onCheckedChange:f,"aria-label":P("select_all","Selecionar todos")})}),r.map((e,a)=>{const r=b&&!1!==e.resizable,i=B===String(e.key),l=w&&!!j,d=l?V.getDragProps(a):{},u=V.dragFromIndex===a,m=V.dragOverIndex===a&&V.dragFromIndex!==a;return t.jsxs(Lo,{className:_r(e.className,"relative transition-opacity",e.sortable&&"cursor-pointer",l&&V.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:$[a]},...d,children:[!1!==e.sortable&&o?t.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),s!==p?null:"asc"===n?t.jsx(c.ArrowUp,{size:14,className:"ml-1"}):t.jsx(c.ArrowDown,{size:14,className:"ml-1"}))]}):t.jsx("span",{className:"font-medium",children:e.header}),r&&t.jsx($o,{direction:"horizontal",onMouseDown:t=>q(String(e.key),t),isDragging:i})]},String(e.key));var p}),W&&t.jsx(Lo,{className:"w-[80px] text-right",children:E??P("actions","Ações")})]})}),t.jsx(Io,{children:e.map(e=>{const s=_&&F.has(e.id);return t.jsxs(a.Fragment,{children:[t.jsxs(Ro,{onClick:()=>i?.(e),className:_r(i?"cursor-pointer":"","relative","inline"===T&&"group"),children:[_&&t.jsx(Fo,{className:"w-[40px] px-2",children:t.jsx("button",{onClick:t=>{t.stopPropagation(),z(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":s?P("collapse_row","Recolher linha"):P("expand_row","Expandir linha"),children:s?t.jsx(c.ChevronDown,{size:16,className:"text-muted-foreground"}):t.jsx(c.ChevronRight,{size:16,className:"text-muted-foreground"})})}),p&&t.jsx(Fo,{children:t.jsx(As,{checked:h.includes(e.id),onCheckedChange:()=>x?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`${P("select_all","Selecionar todos")} ${e.id}`})}),r.map(a=>t.jsx(Fo,{className:a.className,children:t.jsx(Vo,{children:a.render?a.render(e):String(e[a.key]??"-")})},String(a.key))),W&&t.jsx(Fo,{className:"text-right",onClick:e=>e.stopPropagation(),children:"inline"===T?t.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:l(e)}):l(e)})]}),s&&C&&t.jsx(Ro,{className:"bg-muted/30 hover:bg-muted/30",children:t.jsx(Fo,{colSpan:H,className:"p-0",children:t.jsx("div",{className:"animate-accordion-down overflow-hidden",children:C(e)})})})]},e.id)})})]})})}function kh({searchValue:e="",onSearchChange:a,customFilters:r=[],onClearFilters:s,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=y.useTranslation(),l=e||r.length>0;return t.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&t.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{type:"text",placeholder:i("search","Pesquisar"),value:e,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),r.map((e,a)=>t.jsx("div",{className:"vertical"===o?"w-full":"",children:e},a)),n&&l&&s&&t.jsxs(Sr,{variant:"ghost",size:"sm",onClick:s,className:"h-9 px-3 whitespace-nowrap",children:[t.jsx(c.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})}function Sh(e,t){const a=new Set;function r(e){if(e)for(const t of e)a.add(t.id),r(t.children)}return function e(a){for(const s of a){if(s.id===t)return r(s.children),!0;if(s.children&&e(s.children))return!0}return!1}(e),a}function Ah({children:e,itemId:a,enableDrag:r,onDragStartCell:s,onDragEndCell:n,onDragOverCell:o,onDropCell:i,className:l}){return t.jsx(Fo,{draggable:r,onDragStart:r?e=>s(a,e):void 0,onDragEnd:r?n:void 0,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),o(a,e)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o(a,e)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(a,e)},className:l,children:e})}function Th({item:e,level:a,columns:r,nameKey:s,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:d,rowActionsVariant:u="default",enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:b,onDragEndCell:v,onDragOverCell:y,onDropCell:w,dragCount:j}){const N=o.has(e.id),_=(e.children?.length??0)>0,C=24*a,k="inline"===u,S=f===e.id||p?.has(e.id)&&f&&p?.has(f),A=g===e.id&&f!==e.id,T=p?.has(e.id)??!1,D={itemId:e.id,enableDrag:x,onDragStartCell:b,onDragEndCell:v,onDragOverCell:y,onDropCell:w};return t.jsxs(t.Fragment,{children:[t.jsxs(Ro,{className:_r(l&&"cursor-pointer",k&&"group",S&&"opacity-40",A&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:l?()=>l(e):void 0,children:[t.jsx(Ah,{...D,children:t.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${C}px`},children:[m&&t.jsx(As,{checked:T,onCheckedChange:()=>h?.(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),x&&t.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),_?t.jsx("button",{onClick:t=>{t.stopPropagation(),i(e.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:N?t.jsx(c.ChevronDown,{className:"h-4 w-4"}):t.jsx(c.ChevronRight,{className:"h-4 w-4"})}):t.jsx("div",{className:"w-6 shrink-0"}),n??t.jsx(c.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate",children:String(e[s]??e.id)}),f===e.id&&j&&j>1&&t.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:j})]})}),r.map(r=>{const s=e[r.key],n=r.render?r.render(e,a):null!=s?String(s):"—";return t.jsx(Ah,{...D,className:_r("text-center",r.className),children:r.hoverContent?t.jsxs(Jc,{openDelay:200,children:[t.jsx(Zc,{asChild:!0,children:t.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),t.jsx(ed,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:r.hoverContent(e)})]}):n},String(r.key))}),d&&t.jsx(Ah,{...D,className:"text-right",children:t.jsx("div",{onClick:e=>e.stopPropagation(),className:_r("flex items-center justify-end gap-1",k&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:d(e)})})]}),_&&N&&e.children.map(e=>t.jsx(Th,{item:e,level:a+1,columns:r,nameKey:s,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:d,rowActionsVariant:u,enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:b,onDragEndCell:v,onDragOverCell:y,onDropCell:w,dragCount:j},e.id))]})}function Dh({onDrop:a,isDragOver:r,onDragOver:s,onDragLeave:n,label:o}){return t.jsxs("div",{className:_r("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",r?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:s,onDragEnter:s,onDragLeave:n,onDrop:a,children:[t.jsx(c.ArrowUpToLine,{className:"h-4 w-4"}),o??e.t("leadership_make_root_short")]})}function Eh(e){const t=N.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const r=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(r)}}}const Ph="true"===(void 0).VITE_SHOW_EDIT_PROFILE,Ih=a.memo(({variant:e="card",className:r="",selectedUnit:s,onUnitChange:n})=>{const{t:o}=y.useTranslation(),{user:i,companies:l,alias:d,isAuthenticated:u,logout:m,switchUnit:p}=So(),{role:h}=Dl(),x=h?.name||null,f=l?.[0]||null,g=d?l?.find(e=>e.alias===d):f,b=l||[],v=s||g||f||f,[w,j]=a.useState(0);a.useEffect(()=>{const e=()=>j(e=>e+1);return window.addEventListener("user-photo-updated",e),()=>window.removeEventListener("user-photo-updated",e)},[]);const N=a.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&v=${w}`},[i?.id,w]),_=a.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=96&v=${w}`},[i?.id,w]),C=a.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]),k=a.useCallback(e=>{n?n(e):p(e)},[n,p]),S=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===v?.alias),r=t.filter(e=>e.alias!==v?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...r]:r},[b,v?.alias]),[A,T]=a.useState(!1);if(!u||!i)return null;const D=()=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsxs(Zi,{className:"w-10 h-10",children:[N&&t.jsx(el,{src:N,alt:i.name||o("user_photo")}),t.jsx(tl,{className:"bg-primary text-primary-foreground text-white font-semibold text-sm",children:C||t.jsx(c.User,{className:"h-5 w-5"})})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",v?.name||"N/A"]})]})]}),v&&t.jsx("div",{className:"mt-3",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(c.Building2,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium",children:v.name})]})}),S.length>1&&t.jsxs("div",{className:"mt-2",children:[t.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",S.length]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[S.slice(0,3).map(e=>t.jsx(Es,{variant:e.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>k(e),children:e.name},e.alias)),S.length>3&&t.jsxs(Es,{variant:"outline",className:"text-xs",children:["+",S.length-3]})]})]})]});return"dropdown"===e?t.jsxs(t.Fragment,{children:[t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",className:`h-auto p-2 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10 ${r}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("div",{className:"hidden md:block text-right",children:[t.jsxs("p",{className:"text-sm font-medium",children:[i.name?.split(" ")[0],x?` [${x}]`:""]}),t.jsx("p",{className:"text-xs text-primary-foreground/70",children:v?.name||"N/A"})]}),t.jsxs(Zi,{className:"w-8 h-8 border border-primary-foreground/30",children:[N&&t.jsx(el,{src:N,alt:i.name||o("user_photo")}),t.jsx(tl,{className:"bg-primary-foreground/20 text-primary-foreground font-semibold text-xs",children:C||t.jsx(c.User,{className:"h-4 w-4"})})]}),t.jsx(c.ChevronDown,{className:"h-4 w-4"})]})})}),t.jsxs($s,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[t.jsxs(Os,{children:[t.jsxs(qs,{children:[t.jsx(c.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),t.jsx(Vs,{children:S.map(e=>t.jsxs(Ws,{onClick:()=>k(e),className:e.alias===v?.alias?"bg-muted":"",children:[t.jsx(c.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===v?.alias&&t.jsx(Es,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Ph&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{}),t.jsxs(Ws,{onClick:()=>T(!0),children:[t.jsx(c.UserPen,{className:"mr-2 h-4 w-4"}),o("edit_profile","Editar Perfil")]})]}),t.jsx(Ys,{}),t.jsxs(Ws,{onClick:m,children:[t.jsx(c.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}),Ph&&t.jsx(fl,{open:A,onOpenChange:T,user:i,userPhotoUrl:_,userInitials:C})]}):t.jsxs(Pr,{className:r,children:[t.jsx(Ir,{children:t.jsx(Mr,{className:"text-lg",children:o("user_info")})}),t.jsxs(Lr,{className:"space-y-4",children:[t.jsx(D,{}),t.jsx(zr,{}),t.jsxs(Sr,{variant:"outline",onClick:m,size:"sm",className:"w-full",children:[t.jsx(c.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Mh=a.createContext({});function Rh({children:e,config:r}){const s=a.useMemo(()=>({navigation:r?.navigation,appName:r?.appName??void 0}),[r?.navigation,r?.appName]);return t.jsx(Mh.Provider,{value:s,children:e})}function Lh(){return a.useContext(Mh)}function Fh(e,t){if(!e)return"";const a=e.find(e=>e.path===t);if(a)return a.label;const r=e.find(e=>t.startsWith(e.path+"/"));return r?.label||""}function zh(e,t){const[r,s]=a.useState(e),n=a.useRef(void 0),o=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(o(),n.current=setTimeout(()=>{s(e)},t),o),[e,t,o]),[r,o]}function Uh({appName:e}){const[r,s]=a.useState(!1),{association:n}=Dl(),o=lt({isQualitfy:n?.isQualitfy,isMetroex:n?.isMetroex});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>s(!0),children:t.jsx("img",{src:o,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),e&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,className:"h-7 w-px shrink-0 bg-primary-foreground/30"}),t.jsx("button",{className:"min-w-0 text-sm font-medium text-left cursor-pointer text-primary-foreground/90 hover:text-primary-foreground/70 transition-colors leading-tight py-1",onClick:()=>s(!0),children:t.jsx("span",{className:"line-clamp-2",children:(e=>{const a=e.split(" ");if(a.length<=1)return t.jsxs("span",{className:"whitespace-nowrap",children:[e," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const r=a[a.length-1],s=a.slice(0,-1).join(" ");return t.jsxs(t.Fragment,{children:[s," ",t.jsxs("span",{className:"whitespace-nowrap",children:[r," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(e)})})]})]}),t.jsx(hc,{open:r,onOpenChange:s})]})}const Oh=a.memo(function({actions:r}){const s=N.useLocation(),n=N.useNavigate(),{navigation:o,appName:i}=Lh(),l=Fh(o,s.pathname),{metadata:d,headerActions:u}=vl(),{setOpenMobile:m}=eu(),{companies:p,alias:h,isSearchVisible:x,clearSearch:f,refreshData:g,switchUnit:b}=So(),v=h?p?.find(e=>e.alias===h)||p?.[0]||null:p?.[0]||null,[y,w]=N.useSearchParams(),j=a.useCallback(e=>{const{pathname:t,search:a,hash:r}=s;if(h){const s=t.split("/"),o=s.indexOf(h);if(o>=0)return s[o]=e.alias,void n(s.join("/")+a+r)}b(e)},[h,s,n,b]),[_,C]=a.useState(()=>y.get("search")||""),[k,S]=zh(_,Ve.debounceDelay);a.useEffect(()=>{if(!x)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),w(e)},[k,w,x]);const A=o?.find(e=>e.path===s.pathname)||o?.find(e=>s.pathname.startsWith(e.path+"/")),T=d.title||l,D=d.subtitle||A?.complementaryText||"";return t.jsx("header",{className:"bg-primary border-b border-primary px-2 md:px-4 py-2",children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(Sr,{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:t.jsx(c.Menu,{size:20})}),t.jsx("div",{className:"hidden md:flex items-center flex-shrink-0",children:t.jsx(Uh,{appName:i})}),t.jsx("div",{className:"hidden md:block w-px h-8 bg-primary-foreground/20 flex-shrink-0"}),t.jsxs("div",{className:"flex-shrink-0",children:[d.breadcrumbs&&d.breadcrumbs.length>0&&t.jsx("nav",{className:"flex items-center gap-1 text-xs text-primary-foreground/70 mb-0.5",children:d.breadcrumbs.map((e,a)=>t.jsxs("span",{className:"flex items-center gap-1",children:[a>0&&t.jsx(c.ChevronRight,{className:"h-3 w-3"}),e.href?t.jsx(N.Link,{to:e.href,className:"hover:text-primary-foreground transition-colors",children:e.label}):t.jsx("span",{children:e.label})]},a))}),t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("h1",{className:"text-lg font-semibold text-primary-foreground truncate",children:T})}),D&&t.jsx("div",{className:"text-sm text-primary-foreground/70 truncate",children:D})]}),x&&t.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(c.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(Tr,{placeholder:"Pesquisar",value:_,onChange:e=>(e=>{C(e)})(e.target.value),className:"w-full pl-10 pr-8"}),_&&t.jsx(Sr,{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(y);e.delete("search"),e.delete("page"),w(e)},title:e.t("clear_search"),children:t.jsx(c.X,{size:14})})]}),t.jsx(Sr,{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:t.jsx(c.RefreshCw,{size:14})})]}),t.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(u||r)&&t.jsx("div",{className:"flex items-center gap-2",children:u||r}),(void 0).VITE_WIKI_URL&&t.jsx(Sr,{variant:"ghost",size:"sm",className:"h-8 px-3 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:e=>gr((void 0).VITE_WIKI_URL,e),title:e.t("open_wiki"),children:"Wiki"}),t.jsx(pm,{}),t.jsx("div",{className:"text-sm",children:t.jsx(Ih,{variant:"dropdown",selectedUnit:v,onUnitChange:j})})]})]})})}),Bh=({key:e,enabled:t,checkFn:a,staleTime:r=3e5,gcTime:s=6e5})=>j.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1});function qh({config:e,isCollapsed:a=!1,isDisabled:r=!1,className:s}){const{t:n}=y.useTranslation(),{actions:o,triggerLabel:i="Criar",triggerIcon:l=c.Plus,variant:d="button"}=e;if(!o||0===o.length)return null;if("split-button"===d){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(a){const a=t.jsx(Sr,{onClick:e.onClick,disabled:r||e.disabled,className:_r("justify-center px-2 w-full",s),variant:"outline",size:"default",children:t.jsx(n,{className:"h-4 w-4 shrink-0"})});return t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:a}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]})}return t.jsx(sm,{label:e.label,onClick:e.onClick,icon:n,actions:i,variant:"outline",disabled:r||e.disabled,className:_r("w-full",s),menuAlign:"start"})}const u=(e,r,s=!1)=>t.jsxs(t.Fragment,{children:[e,!a&&r&&t.jsx("span",{className:"truncate",children:r}),!a&&s&&t.jsx(c.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const e=o[0],n=e.icon||l,i=r||e.disabled,c=t.jsx(Sr,{onClick:e.onClick,disabled:i,className:_r("w-full gap-2 justify-start",a&&"justify-center px-2",s),variant:"outline",size:"default",children:u(t.jsx(n,{className:"h-4 w-4 shrink-0"}),e.label)});return a?t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:c}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]}):c}const m=t.jsx(Sr,{disabled:r,className:_r("w-full gap-2 justify-start",a&&"justify-center px-2",s),variant:"outline",size:"default",children:u(t.jsx(l,{className:"h-4 w-4 shrink-0"}),i,!0)});return t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:a?t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:m}),t.jsx(en,{side:"right",children:t.jsx("p",{children:i})})]}):m}),t.jsx($s,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:o.map(e=>{const a=e.icon;return t.jsxs(Ws,{onClick:e.onClick,disabled:e.disabled,className:"cursor-pointer",children:[a&&t.jsx(a,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})}const Vh="forlogic-sidebar-pinned",$h=()=>{try{const e=localStorage.getItem(Vh);return!!e&&JSON.parse(e)}catch{return!1}};function Wh({direction:e="right",minWidth:t=224,maxWidth:r=384,defaultWidth:s=290,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,c]=a.useState(()=>{if("undefined"==typeof window)return s;const e=localStorage.getItem(n);return e?parseInt(e):s}),[d,u]=a.useState(!1),m=a.useRef(null);a.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","290px"))},[l,i]);const p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!d)return;const a=a=>{let s;s="left"===e?window.innerWidth-a.clientX:a.clientX,s=Math.max(t,Math.min(r,s)),c(s),o?.(s)},s=()=>{u(!1),c(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",s)}},[d,e,t,r,l,n,o]),a.useEffect(()=>(d?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d,e]),{width:l,isDragging:d,dragRef:m,handleMouseDown:p}}const Hh=a.createContext(void 0);function Gh(){const e=a.useContext(Hh);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Kh({config:e,customContent:r,resizable:s=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=y.useTranslation(),{open:l,setOpen:d,setOpenMobile:u}=eu(),m=N.useLocation(),{alias:p,user:h}=So(),{appName:x}=Lh(),{hasOpenModal:f}=Gh(),[g,b]=a.useState($h),v=Do(),w=!!v||l,j=a.useCallback(()=>{v&&u(!1)},[v,u]),_=s?Wh({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{d(!!g)},[g,d]);const C=e=>m.pathname===e||m.pathname.startsWith(e+"/");return t.jsxs(au,{collapsible:"icon",className:_r("app-sidebar bg-background border-r border-border flex flex-col",w?"px-3":"px-1.5"),style:_&&w?{width:`${_.width}px`,transition:"none"}:{transition:"width 300ms ease-in-out"},children:[e?.moduleActions&&e.moduleActions.actions.length>0&&t.jsx("div",{className:"py-3",children:t.jsx(Xs,{children:t.jsx(qh,{config:e.moduleActions,isCollapsed:!w,isDisabled:f})})}),t.jsx(du,{className:_r(e?.moduleActions&&e.moduleActions.actions.length>0?"pt-0":"pt-3"),children:r||t.jsx(uu,{className:"p-0",children:t.jsx(hu,{children:t.jsx(xu,{className:"gap-1",children:t.jsx(Xs,{children:e?.navigation?.map((e,a)=>{if("separator"===e.type)return t.jsx(cu,{className:"my-2"},`sep-${a}`);const r=({item:e,index:a})=>{const s=`${e.path}-${a}-${p??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:o}=Bh({key:s,enabled:Boolean(e.permissionCheck&&p&&h?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),l=e.permissionCheck&&!n,d=o?c.Loader2:l?c.Lock:e.icon;l?i("restricted_access"):e.complementaryText;return e.children&&e.children.length>0?w?t.jsx(zl,{defaultOpen:!0,className:"group/collapsible",children:t.jsxs(fu,{children:[t.jsx(Ul,{asChild:!0,children:t.jsx(bu,{size:"default",children:t.jsxs("div",{className:"flex w-full items-center gap-3",children:[t.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:t.jsx(d,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-medium sidebar-text",children:e.label}),t.jsx(c.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),t.jsx(Ol,{children:t.jsx(ju,{children:e.children.map((e,a)=>t.jsx(r,{item:e,index:a},e.path))})})]})},e.path):t.jsx(fu,{children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("div",{className:_r("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:t.jsx(d,{className:"h-4 w-4"})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]})},e.path):t.jsx(fu,{children:l||o?t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:w?t.jsx(bu,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:t.jsxs("div",{className:"flex w-full items-center gap-3",children:[t.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:t.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),t.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):t.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:t.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:o?"Verificando acesso...":i("restricted_access")})})]}):w?t.jsx(bu,{asChild:!0,isActive:C(e.path),size:"default",children:t.jsxs(N.Link,{to:e.path,className:"flex w-full items-center gap-3",onClick:j,children:[t.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:t.jsx(d,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(N.Link,{to:e.path,onClick:j,className:_r("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:t.jsx(d,{className:"h-4 w-4"})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:e.label})})]})},e.path)};return t.jsx(r,{item:e,index:a},e.path)})})})})})}),!v&&t.jsx("div",{className:_r("mt-auto pb-4 pt-2 flex items-center gap-2",w?"justify-end px-1":"justify-center flex-col"),children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx("button",{id:"btn-expand-side-nav",onClick:()=>{const e=!g;b(e),(e=>{try{localStorage.setItem(Vh,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?t.jsx(c.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):t.jsx(c.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),t.jsx(en,{side:"right",children:t.jsx("p",{children:l?"Recolher":"Expandir"})})]})}),s&&_&&w&&t.jsx("div",{ref:_.dragRef,onMouseDown:_.handleMouseDown,className:_r("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")})]})}function Yh(e){if("string"!=typeof e)return;return e.trim()||void 0}function Qh(){const{alias:e,isAuthenticated:t,isLoading:r,selectedUnit:s}=So(),n=s?.id??null,o=!!$n.getAccessToken(),i=function(e,t){const a=Yh(t);if(a)return a;const r=$n,s=Yh(r.getCurrentCompanyId?.());if(s)return s;const n=$n.extractTokenData(),o=Yh(n?.companyId)??Yh(n?.company_id);if(o)return o;if(e){const t=Yh($n.getCompanyId(e));if(t)return t}}(e,n),l=!!e&&!!t&&o,c=l&&!!i,[,d]=a.useReducer(e=>e+1,0);a.useEffect(()=>{if(!t||o&&i)return;const e=window.setInterval(()=>d(),500);return()=>window.clearInterval(e)},[t,o,i]);let u=null;return r?u="Carregando autenticação...":t?e?o?i||(u="Aguardando unidade ativa..."):u="Aguardando token de acesso Qualiex...":u="Aguardando alias...":u="Usuário não autenticado",{alias:e,companyId:i,hasAccessToken:o,isAuthLoading:!!r,isAuthenticated:!!t,isReadyForQualiex:l,isReadyForQualiexWithCompany:c,isWaitingCompanyId:!!t&&o&&!i,waitingReason:u}}async function Xh(e,t){const a=await nl(`${al()}/api/common/v1/updates/userView/${t}`,e),r=await a.json(),s=r?.data??r;return Array.isArray(s)?s:[]}async function Jh(e,t,a,r){const s=void 0===r?"undefined":String(r),n={id:t,idUpdateType:a};void 0!==r&&(n.liked=r),await nl(`${al()}/api/common/v1/Updates/userVisualized/${a}/${s}`,e,{method:"POST",body:JSON.stringify(n)})}const Zh=3e5;function ex(){const{alias:e,isReadyForQualiex:t}=Qh();return j.useQuery({queryKey:["user-updates","bar",e],queryFn:()=>Xh(e,1),enabled:t,staleTime:Zh})}function tx(){const{alias:e,isReadyForQualiex:t}=Qh();return j.useQuery({queryKey:["user-updates","dialog",e],queryFn:()=>Xh(e,2),enabled:t,staleTime:Zh})}function ax({item:e,onDismiss:a}){const{t:r}=y.useTranslation(),s=e.text||e.title,n=e.color||"hsl(var(--primary))";return t.jsxs("div",{"data-testid":`updates-bar-${e.id}`,role:"status",style:{backgroundColor:n},className:"w-full flex items-center justify-center gap-3 px-4 py-2 text-sm text-white relative",children:[e.url?t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 hover:underline",children:[s,t.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})]}):t.jsx("span",{children:s}),t.jsx("button",{type:"button",onClick:()=>a(e.id),"aria-label":r("updates_bar_close","Fechar"),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60",children:t.jsx(c.X,{className:"h-4 w-4"})})]})}function rx(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function sx(e,t){const a=rx(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function nx(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function ox(e,t){const a=nx(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function ix(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function lx(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function cx({item:e,open:r,onClose:s}){const{t:n}=y.useTranslation(),[o,i]=a.useState(!1),[l,d]=a.useState(!1);a.useEffect(()=>{i(!1),d(!1)},[e.id]);const u=e.countLiked+(o?1:0);return t.jsx(Qr,{open:r,onOpenChange:e=>{e||s({liked:o,doNotShowAgain:l})},children:t.jsxs(as,{size:"md",children:[t.jsx(rs,{showSeparator:!0,children:t.jsx(os,{style:e.color?{color:e.color}:void 0,children:e.title})}),t.jsxs(ss,{children:[(()=>{const a=e.urlVideo??e.videoUrl??e.url??"",r=a?rx(a):null;return r?t.jsx("div",{className:"mb-3 aspect-video w-full overflow-hidden rounded-lg border bg-black",children:t.jsx("iframe",{src:`https://www.youtube.com/embed/${r}`,className:"h-full w-full",title:e.title,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}):null})(),t.jsx("div",{className:"text-sm leading-relaxed [&_a]:text-primary [&_a]:underline [&_strong]:font-semibold [&_p]:mb-2 [&_ul]:list-disc [&_ul]:ml-5 [&_ol]:list-decimal [&_ol]:ml-5 [&_img]:max-w-full [&_iframe]:max-w-full",dangerouslySetInnerHTML:{__html:e.description}})]}),t.jsxs(ns,{className:"!justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>i(e=>!e),"aria-pressed":o,"aria-label":n("updates_dialog_like","Curtir"),className:_r("inline-flex items-center justify-center h-8 w-8 rounded-full border transition-colors",o?"bg-primary/10 border-primary text-primary":"border-input text-muted-foreground hover:text-foreground hover:bg-accent"),children:t.jsx(c.Heart,{className:_r("h-4 w-4",o&&"fill-current")})}),t.jsx("span",{className:"inline-flex items-center justify-center min-w-[1.5rem] h-6 px-2 rounded-full bg-primary text-primary-foreground text-xs font-medium",children:u})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground cursor-pointer select-none",children:[t.jsx(As,{checked:l,onCheckedChange:e=>d(!0===e)}),n("updates_dialog_do_not_show_again","Não exibir novamente")]}),t.jsx(Sr,{variant:"ghost",onClick:()=>s({liked:o,doNotShowAgain:l}),children:n("updates_dialog_close","Fechar")})]})]})]})})}function dx(e){return e&&e.trim()?e.trim():"anon"}function ux(e){try{const t=localStorage.getItem(e);if(!t)return new Set;const a=JSON.parse(t);return new Set(Array.isArray(a)?a.map(String):[])}catch{return new Set}}function mx(e,t){try{localStorage.setItem(e,JSON.stringify(Array.from(t)))}catch{}}function px(e,t){if(!e)return e;const a=(t||"").trim().split(" ")[0]||"Colaborador";return e.replace(/@nome_usuario|@nome_usuário/g,a)}function hx(){const{alias:e}=Qh(),{user:r}=So(),s=a.useMemo(()=>(r?.name||"").trim().split(" ")[0]||"Colaborador",[r?.name]),{data:n=[]}=ex(),{data:o=[]}=tx(),i=a.useMemo(()=>function(e){return`updates.bar.dismissed.${dx(e)}`}(e),[e]),l=a.useMemo(()=>function(e){return`updates.dialog.seen.${dx(e)}`}(e),[e]),[c,d]=a.useState(()=>ux(i)),[u,m]=a.useState(()=>ux(l)),[p,h]=a.useState(new Set),[x,f]=a.useState(0);if(a.useEffect(()=>{d(ux(i)),m(ux(l)),h(new Set),f(0)},[i,l]),!e)return null;const g=n.find(e=>!c.has(e.id)),b=o.filter(e=>!u.has(e.id)&&!p.has(e.id))[x],v=g&&{...g,title:px(g.title,s),text:px(g.text,s),description:px(g.description,s)},y=b&&{...b,title:px(b.title,s),description:px(b.description,s)};return t.jsxs(t.Fragment,{children:[v&&t.jsx(ax,{item:v,onDismiss:async t=>{const a=new Set(c);a.add(t),d(a),mx(i,a);try{await Jh(e,t,1)}catch{}}}),y&&t.jsx(cx,{item:y,open:!0,onClose:async({liked:t,doNotShowAgain:a})=>{if(!b)return;const r=b.id;if(!a)return h(e=>{const t=new Set(e);return t.add(r),t}),void f(0);const s=new Set(u);s.add(r),m(s),mx(l,s),f(0);try{await Jh(e,r,2,t)}catch{}}})]})}const xx=a.memo(function({children:e,sidebar:r,sidebarConfig:s,showHeader:n=!0,showSidebar:o=!0}){const i=a.useMemo(()=>o?r||t.jsx(Kh,{config:s}):null,[r,s,o]),l=a.useMemo(()=>({"--sidebar-width":"290px","--sidebar-width-icon":"58px"}),[]),c=a.useRef(null),d=a.useRef(null),u=a.useCallback(()=>{if(c.current&&d.current){const e=c.current.offsetHeight;d.current.style.setProperty("--header-height",`${e}px`)}},[]);return a.useEffect(()=>{u();const e=new ResizeObserver(u);return c.current&&e.observe(c.current),()=>e.disconnect()},[u]),t.jsx(Rh,{config:s,children:t.jsx(bl,{children:t.jsx(tu,{defaultOpen:!1,style:l,children:t.jsxs("div",{ref:d,className:"flex flex-col h-screen w-full overflow-hidden",children:[n&&t.jsxs("div",{ref:c,className:"flex-shrink-0 sticky top-0 z-40 bg-primary",children:[t.jsx(Oh,{}),t.jsx(hx,{})]}),t.jsxs("div",{className:"sidebar-container flex flex-1 overflow-hidden",children:[i,t.jsx("main",{className:"relative z-0 flex-1 flex flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30",children:e})})]})]})})})})});class fx{static async sendEmail(e){const t=to(),{data:a,error:r}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(r)throw r;return a}}const gx=fx,bx=J.z.string().trim().toLowerCase().min(3,"E-mail muito curto").max(254,"E-mail muito longo").email("E-mail inválido"),vx=J.z.string().trim().toLowerCase().min(2,"Alias muito curto").max(64,"Alias muito longo").regex(/^[a-z0-9][a-z0-9-]*[a-z0-9]$/,"Alias contém caracteres inválidos"),yx=J.z.string().uuid("UUID inválido"),wx=J.z.string().trim().min(1,"userId obrigatório").max(64,"userId muito longo").regex(/^[a-zA-Z0-9._-]+$/,"userId contém caracteres inválidos"),jx=J.z.object({page:J.z.coerce.number().int().min(1).default(1),pageSize:J.z.coerce.number().int().min(1).max(500).default(50)});function Nx(e){const[t,r]=a.useState(!1),{uploadFunction:s,deleteFunction:n,defaultOptions:o,onSuccess:i,onError:c}=e||{};return{upload:async(e,t)=>{if(!s){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}r(!0);try{const a={...o,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){if(!a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const r=await s(e,a);return l.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),i?.(r),r}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),c?.(e),e}finally{r(!1)}},deleteMedia:async(e,t)=>{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,t),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:t}}function _x(e,t){return e/t}const Cx=["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 kx(e){if(!e)return"";if(e<1024)return`${e} Bytes`;const t=e/1024;if(t<1024)return`${Math.round(t)} KB`;const a=t/1024;if(a<1024)return`${Math.round(a)} MB`;const r=a/1024;return Math.round(100*r)/100+" GB"}function Sx(e){const t=e.lastIndexOf(".");return-1===t?"":e.substring(t+1).toLowerCase()}function Ax({storedFile:e,customFileName:r,allowedExtensions:s,customExtensionErrorMessage:n,minSizeInBytes:o=1,maxSizeInBytes:i=314572800,showDownloadButton:l=!0,showViewButton:d=!0,showReplaceButton:u=!0,showCloseButton:m=!0,required:p=!1,touched:h=!1,disabled:x=!1,error:f,onFileSelect:g,onFileRemove:b,onFileReplace:v,onDownload:w,onView:j,className:N}){const{t:_}=y.useTranslation(),C=a.useRef(null),[k,S]=a.useState(null),[A,T]=a.useState(null),[D,E]=a.useState(!1),P=k||e,I=k?.name||e?.name||"",M=k?.size||e?.size;I&&Sx(I);const R=r||I,L=l&&!k&&!!e,F=d&&!k&&!!e,z=!!A||!!f||p&&h&&!P,U=!!P,O=a.useCallback(e=>{if(Cx.includes(e.type))return{type:"forbidden-type"};if(e.size<=o)return{type:"min-size"};if(e.size>=i)return{type:"max-size"};if(s?.length){const t=Sx(e.name);if(!s.includes(t))return{type:"extension",message:n}}return null},[o,i,s,n]),B=a.useCallback(e=>{const t=e.target.files?.[0];if(!t)return;const a=O(t);if(a)return T(a),S(null),void(C.current&&(C.current.value=""));T(null),S(t),g?.(t),C.current&&(C.current.value="")},[O,g]),q=a.useCallback(e=>{if(e.preventDefault(),e.stopPropagation(),x)return;const t=e.dataTransfer.files?.[0];if(!t)return;const a=O(t);if(a)return T(a),void S(null);T(null),S(t),g?.(t)},[x,O,g]),V=a.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),$=a.useCallback(()=>{v?.(),C.current?.click()},[v]),W=a.useCallback(()=>{S(null),T(null),b?.(),C.current&&(C.current.value="")},[b]),H=a.useCallback(async()=>{if(!D&&e&&w){E(!0);try{await w(e)}finally{E(!1)}}},[D,e,w]),G=a.useCallback(()=>{e&&j&&j(e)},[e,j]),K=a.useCallback(()=>{x||C.current?.click()},[x]),Y=(()=>{if(f)return f;if(!A)return p&&h&&!P?_("required_field"):null;switch(A.type){case"extension":return A.message||_("sign_file_not_allowed");case"forbidden-type":return _("sign_file_type_not_allowed");case"min-size":return`Tamanho mínimo: ${kx(o)}`;case"max-size":return`Tamanho máximo: ${kx(i)}`;default:return _("file_error")}})();return t.jsxs("div",{className:_r("space-y-1",N),children:[t.jsx("div",{className:_r("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?t.jsxs("div",{className:"flex items-center justify-between px-3 min-h-[36px]",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx(c.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("p",{className:"text-xs truncate",children:R})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[null!=M&&t.jsx("span",{className:"text-xs text-muted-foreground",children:kx(M)}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[L&&w&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:D,onClick:H,children:t.jsx(c.Download,{className:"h-3.5 w-3.5 text-primary"})})}),t.jsx(en,{children:"Download"})]}),F&&j&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,children:t.jsx(c.Eye,{className:"h-3.5 w-3.5 text-primary"})})}),t.jsx(en,{children:"Visualizar"})]}),u&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:$,children:t.jsx(c.RefreshCw,{className:"h-3.5 w-3.5 text-primary"})})}),t.jsx(en,{children:"Substituir"})]}),m&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 bg-muted rounded",onClick:W,children:t.jsx(c.X,{className:"h-3 w-3 text-muted-foreground"})})}),t.jsx(en,{children:_("remove")})]})]})]})]}):t.jsxs("div",{className:"flex items-center justify-center gap-2 min-h-[36px] px-3",tabIndex:0,onClick:K,onKeyDown:e=>"Enter"===e.key&&K(),onDrop:q,onDragOver:V,children:[t.jsx(c.CloudUpload,{className:"h-4 w-4 text-muted-foreground"}),t.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:["Arraste ou ",t.jsx("span",{className:"text-primary",children:"selecione um arquivo"})]})]})}),Y&&t.jsx("p",{className:"text-xs text-destructive",children:Y}),t.jsx("input",{ref:C,type:"file",className:"hidden",accept:s?.map(e=>`.${e}`).join(","),onChange:B,disabled:x})]})}function Tx(){return`${Ke().replace(/\/+$/,"")}/api/documents/v1`}function Dx(){const e=$n.getSelectedAlias()||$n.extractTokenData()?.alias||"";if(!e)throw new Error("Alias da unidade não encontrado (Documents API exige o header un-alias).");return e}function Ex(){const e=$n.getAccessToken();if(!e)throw new Error("Token Qualiex não encontrado.");return{Authorization:`Bearer ${e}`,"un-alias":Dx()}}function Px(){return{...Ex(),Accept:"application/json"}}function Ix(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t):""}const Mx={async upload(e,t,a,r){const s={name:a.name,extension:Ix(a.name),size:a.size,plataformType:1,association:{type:e,associationId:t,associationFieldId:r??null}},n=new FormData;n.append("command",JSON.stringify(s)),n.append(a.name,a,a.name);const o=await fetch(`${Tx()}/files/Upload`,{method:"POST",headers:Ex(),body:n});if(!o.ok)throw new Error(await o.text().catch(()=>"")||"Falha no upload do arquivo.");const i=await o.json().catch(()=>null),l=i?.resultData??i?.ResultData??{};return{id:l.id??"",code:l.code,size:l.size}},async downloadUrl(e,t=10){const a=await fetch(`${Tx()}/files/Download/${encodeURIComponent(e)}?minutesToExpire=${t}`,{headers:Px()});if(!a.ok)return null;const r=await a.json().catch(()=>null);return r?.url??null},async listByAssociation(e,t,a){const r=new URLSearchParams({type:String(e),associationId:t,page:"1",limit:"100"});a&&r.set("associationFieldId",a);const s=await fetch(`${Tx()}/files?${r.toString()}`,{headers:Px()});if(!s.ok)return[];const n=await s.json().catch(()=>null);return(n?.data??[]).map(r=>{const s=r.associations??[],n=s.find(r=>r.type===e&&r.associationId===t&&(!a||r.associationFieldId===a))??s[0];return{id:r.id,name:r.name,extension:r.extension,size:r.size,associationRowId:n?.id}})},async remove(e,t){if(!e)return!1;return(await fetch(`${Tx()}/files/associations`,{method:"DELETE",headers:{...Px(),"Content-Type":"application/json"},body:JSON.stringify({filesAssociationsIds:[e],justification:t??null})})).ok},async count(e,t,a){const r=new URLSearchParams({type:String(e),associationId:t});a&&r.set("associationFieldId",a);const s=await fetch(`${Tx()}/files/Count?${r.toString()}`,{headers:Px()});if(!s.ok)return 0;const n=await s.json().catch(()=>null);return n?.count??n?.total??0}},Rx=e=>({id:e.id,name:e.name,extension:e.extension,size:e.size??0});var Lx=(e=>(e[e.readOnlyText=1]="readOnlyText",e[e.text=2]="text",e[e.date=3]="date",e[e.time=4]="time",e[e.url=5]="url",e[e.number=6]="number",e[e.singleSelection=7]="singleSelection",e[e.multiSelection=8]="multiSelection",e[e.questions=9]="questions",e))(Lx||{}),Fx=(e=>(e[e.dropdown=1]="dropdown",e[e.buttons=2]="buttons",e[e.radio=3]="radio",e[e.checkbox=4]="checkbox",e))(Fx||{}),zx=(e=>(e[e.custom=1]="custom",e[e.users=2]="users",e[e.usersLists=3]="usersLists",e))(zx||{});function Ux(e){switch(e.type){case 2:case 1:return e.textValue;case 6:return e.numberValue;case 3:return e.dateValue;case 4:return e.timeValue;case 5:case 7:case 8:return e.itemsValue;case 9:return e.questionsValue;default:return null}}function Ox(e,t){if(!t)return!0;const a=null!=Ux(e)&&""!==Ux(e)&&!(Array.isArray(Ux(e))&&0===Ux(e).length);return!1!==e.isActive||a}function Bx({field:e}){return t.jsxs("div",{className:"space-y-1",children:[e.name&&t.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function qx({field:e,readOnly:a,onChange:r}){const s=e.config,n=s?.multiline??!1,o=a||e.readOnly,i=t=>{r?.({...e,textValue:t})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),n?t.jsx(Ts,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o,rows:4}):t.jsx(Tr,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o})]})}function Vx({field:e,readOnly:a,onChange:r}){const s=a||e.readOnly,n=e.dateValue?"string"==typeof e.dateValue?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(Tr,{type:"date",value:n,onChange:t=>{return a=t.target.value,void r?.({...e,dateValue:a||void 0});var a},placeholder:e.placeholder,disabled:s})]})}function $x({field:e,readOnly:a,onChange:r}){const s=a||e.readOnly,n=e=>{if(!e)return;const[t,a]=e.split(":").map(Number);return 60*t+a};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(Tr,{type:"time",value:(e=>{if(null==e)return"";const t=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`})(e.timeValue),onChange:t=>r?.({...e,timeValue:n(t.target.value)}),placeholder:e.placeholder,disabled:s})]})}function Wx({field:e,readOnly:r,onChange:s}){const n=e.config,o=n?.multiple??!1,i=r||e.readOnly,[l,d]=a.useState(""),u=e.itemsValue||[],m=()=>{if(!l.trim())return;const t={value:crypto.randomUUID(),text:l.trim()};s?.({...e,itemsValue:[...u,t]}),d("")};if(!o){const a=u[0]?.text||"";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Tr,{type:"url",value:a,onChange:t=>(t=>{const a={value:t,text:t};s?.({...e,itemsValue:t?[a]:[]})})(t.target.value),placeholder:e.placeholder||"https://",disabled:i}),a&&t.jsx(Sr,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:t.jsx(c.ExternalLink,{className:"h-4 w-4"})})})]})]})}return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!i&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Tr,{type:"url",value:l,onChange:e=>d(e.target.value),placeholder:e.placeholder||"https://",onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),m())}),t.jsx(Sr,{variant:"outline",size:"icon",onClick:m,disabled:!l.trim(),className:"flex-shrink-0",children:t.jsx(c.Plus,{className:"h-4 w-4"})})]}),u.length>0&&t.jsx("div",{className:"space-y-1",children:u.map((a,r)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("a",{href:a.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:a.text}),!i&&t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>(t=>{const a=u.filter((e,a)=>a!==t);s?.({...e,itemsValue:a})})(r),children:t.jsx(c.Trash2,{className:"h-3 w-3"})})]},a.value))})]})}function Hx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=null!=s?.decimals&&s.decimals>0?(1/Math.pow(10,s.decimals)).toString():"1";return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx(Tr,{type:"number",value:e.numberValue??"",onChange:t=>(t=>{if(""===t)return void r?.({...e,numberValue:void 0});const a=parseFloat(t);isNaN(a)||r?.({...e,numberValue:a})})(t.target.value),placeholder:e.placeholder,disabled:n,min:s?.min,max:s?.max,step:o}),null!=s?.min&&null!=s?.max&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",s.min," | Max: ",s.max]})]})}function Gx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=s?.viewMode??Fx.dropdown,i=s?.data?.filter(t=>!1!==t.isActive||e.itemsValue?.some(e=>e.value===t.value))||[],l=e.itemsValue?.[0]?.value||"",c=t=>{const a=i.find(e=>e.value===t);if(!a)return;const s={value:a.value,text:a.text,isActive:a.isActive};r?.({...e,itemsValue:[s]})};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),o===Fx.dropdown&&t.jsxs(bs,{value:l,onValueChange:c,disabled:n,children:[t.jsx(ws,{children:t.jsx(ys,{placeholder:e.placeholder||"Selecione..."})}),t.jsx(_s,{children:i.map(e=>t.jsxs(ks,{value:e.value,children:[e.text,!1===e.isActive&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},e.value))})]}),(o===Fx.radio||o===Fx.buttons)&&t.jsx(Fd,{value:l,onValueChange:c,disabled:n,className:_r(o===Fx.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(a=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(zd,{value:a.value,id:`${e.id}-${a.value}`}),t.jsxs(Er,{htmlFor:`${e.id}-${a.value}`,className:"text-sm font-normal cursor-pointer",children:[a.text,!1===a.isActive&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},a.value))}),!n&&l&&!e.required&&t.jsx("button",{type:"button",onClick:()=>{r?.({...e,itemsValue:[]})},className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function Kx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=s?.viewMode??Fx.dropdown,i=s?.data?.filter(t=>!1!==t.isActive||e.itemsValue?.some(e=>e.value===t.value))||[],l=new Set(e.itemsValue?.map(e=>e.value)||[]);return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(a=>t.jsxs(Es,{variant:"secondary",className:"gap-1 pr-1",children:[t.jsx("span",{className:"text-xs",children:a.text}),!n&&t.jsx("button",{type:"button",onClick:()=>(t=>{const a=(e.itemsValue||[]).filter(e=>e.value!==t);r?.({...e,itemsValue:a})})(a.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:t.jsx(c.X,{className:"h-3 w-3"})})]},a.value))}),!n&&t.jsx("div",{className:_r(o===Fx.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(a=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:`${e.id}-${a.value}`,checked:l.has(a.value),onCheckedChange:()=>(t=>{const a=e.itemsValue||[],s=a.some(e=>e.value===t.value)?a.filter(e=>e.value!==t.value):[...a,{value:t.value,text:t.text,isActive:t.isActive}];r?.({...e,itemsValue:s})})(a),disabled:n}),t.jsxs(Er,{htmlFor:`${e.id}-${a.value}`,className:"text-sm font-normal cursor-pointer",children:[a.text,!1===a.isActive&&t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},a.value))})]})}function Yx({field:e,readOnly:a,onChange:r}){const s=e.config,n=a||e.readOnly,o=s?.questions||[],i=s?.options||[],l=e.questionsValue||[];return 0===o.length||0===i.length?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{children:e.name}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{className:_r(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),t.jsx("div",{className:"border rounded-md overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b bg-muted/50",children:[t.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(e=>t.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:e.text},e.value))]})}),t.jsx("tbody",{children:o.map((a,s)=>t.jsxs("tr",{className:_r(s<o.length-1&&"border-b"),children:[t.jsx("td",{className:"p-2 text-muted-foreground",children:a.text}),i.map(s=>{return t.jsx("td",{className:"text-center p-2",children:t.jsx(Fd,{value:(o=a.value,l.find(e=>e.questionValue===o)?.optionValue||""),onValueChange:t=>((t,a,s,n)=>{const o={questionValue:t,questionText:a,optionValue:s,optionText:n},i=l.filter(e=>e.questionValue!==t);i.push(o),r?.({...e,questionsValue:i})})(a.value,a.text,t,s.text),disabled:n,className:"flex justify-center",children:t.jsx(zd,{value:s.value,id:`${e.id}-${a.value}-${s.value}`})})},s.value);var o})]},a.value))})]})})]})}function Qx({field:e,readOnly:a,onChange:r}){const s={field:e,readOnly:a,onChange:r};switch(e.type){case Lx.readOnlyText:return t.jsx(Bx,{...s});case Lx.text:return t.jsx(qx,{...s});case Lx.date:return t.jsx(Vx,{...s});case Lx.time:return t.jsx($x,{...s});case Lx.url:return t.jsx(Wx,{...s});case Lx.number:return t.jsx(Hx,{...s});case Lx.singleSelection:return t.jsx(Gx,{...s});case Lx.multiSelection:return t.jsx(Kx,{...s});case Lx.questions:return t.jsx(Yx,{...s});default:return null}}function Xx({open:r,onOpenChange:s,returnSteps:n,initialObservation:o="",title:i=e.t("approval_execute_action"),descriptions:c=[],setDefaultApproverOnInit:d=!0,onSubmit:u}){const[m,p]=a.useState(!0),[h,x]=a.useState(d&&n.length>0?n[0].id:null),[f,g]=a.useState(o),b=e=>{p(e),e&&!d?x(null):!e&&!d&&n.length>0&&x(n[0].id)},v=f!==o||!m;return t.jsx(Qr,{open:r,onOpenChange:s,children:t.jsxs(as,{className:"sm:max-w-[480px]",variant:"form",isDirty:v,children:[t.jsx(rs,{children:t.jsx(os,{children:i})}),t.jsxs("div",{className:"space-y-4",children:[c.length>0&&t.jsx("div",{className:"space-y-1 text-sm text-muted-foreground",children:c.map((e,a)=>t.jsx("p",{dangerouslySetInnerHTML:{__html:e}},a))}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"radio",name:"approved",checked:m,onChange:()=>b(!0),className:"accent-primary"}),t.jsx("span",{className:"text-sm",children:e.t("approval_approve")})]}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"radio",name:"approved",checked:!m,onChange:()=>b(!1),className:"accent-primary"}),t.jsx("span",{className:"text-sm",children:e.t("approval_reprove_radio")})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{children:"Etapa"}),t.jsxs(bs,{value:h??void 0,onValueChange:x,disabled:m,children:[t.jsx(ws,{children:t.jsx(ys,{placeholder:e.t("approval_select_step")})}),t.jsx(_s,{children:n.map(e=>t.jsx(ks,{value:e.id,children:e.name},e.id))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Er,{children:e.t("approval_opinion")}),t.jsx(Ts,{value:f,onChange:e=>g(e.target.value),maxLength:4e3,rows:4,autoFocus:!0}),t.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/",4e3]})]})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),t.jsx(Sr,{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:!v,children:"Concluir"})]})]})})}function Jx({open:e,onOpenChange:r,approvers:s,isLoading:n=!1,ignoreUserIds:o=[],onSubmit:i}){const{t:l}=y.useTranslation(),[c,d]=a.useState(null),u=a.useMemo(()=>{const e=new Set(o);return s.filter(t=>!e.has(t.id))},[s,o]),m=a.useMemo(()=>u.map(e=>({value:e.id,label:e.name})),[u]);return t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:"sm:max-w-[450px]",variant:"form",isDirty:!!c,children:[t.jsx(rs,{children:t.jsx(os,{children:l("approval_select_approver")})}),t.jsx(Ms,{isLoading:n,type:"spinner",children:t.jsx("div",{className:"space-y-4",children:t.jsx(gn,{options:m,value:c??void 0,onValueChange:e=>d("string"==typeof e?e:e?.[0]??null),placeholder:l("approval_select_approver_placeholder"),searchPlaceholder:l("approval_search_approver")})})}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),t.jsx(Sr,{onClick:()=>{if(!c)return;const e=u.find(e=>e.id===c);e&&i(e)},disabled:!c||n,children:"Concluir"})]})]})})}function Zx(e){const{t:t}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}function ef({text:e,maxLength:r=130}){const{t:s}=y.useTranslation(),[n,o]=a.useState(!1);return e.length<=r?t.jsx("span",{children:e}):t.jsxs("span",{children:[n?e:`${e.substring(0,r)}... `,t.jsx("button",{className:"text-primary hover:underline text-sm cursor-pointer",onClick:()=>o(!n),children:s(n?"approval_read_less":"approval_read_more")})]})}function tf({approver:e}){if(1===e.type&&e.approverId)return t.jsxs(Zi,{className:"h-9 w-9 shrink-0",children:[t.jsx(el,{src:e.photoUrl,alt:e.name}),t.jsx(tl,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]});const a=2===e.type?c.Users:3===e.type?c.MapPin:c.User;return t.jsx("div",{className:"h-9 w-9 rounded-full bg-muted-foreground/30 flex items-center justify-center shrink-0",children:t.jsx(a,{className:"h-4 w-4 text-background"})})}function af({approver:e}){return e.date?t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-green-500/10 text-foreground",children:[t.jsx(c.CheckCircle,{className:"h-3.5 w-3.5 text-green-600"}),"Aprovado"]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Zx(e.date)}),1!==e.type&&e.approvedUsername&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["por ",e.approvedUsername]})]}):e.returnDate?t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-red-500/10 text-foreground",children:[t.jsx(c.XCircle,{className:"h-3.5 w-3.5 text-red-600"}),"Reprovado"]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Zx(e.returnDate)})]}):t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-muted text-muted-foreground",children:[t.jsx(c.AlertCircle,{className:"h-3.5 w-3.5"}),"Aguardando"]})}function rf({approver:e}){const{t:a}=y.useTranslation(),r=1!==e.type||e.approverId?e.name:"A definir";return t.jsxs("div",{children:[2===e.type&&t.jsx("p",{className:"text-xs text-muted-foreground",children:a("approval_user_group")}),3===e.type&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Local"}),t.jsx("p",{className:"text-sm font-medium break-words",children:r}),t.jsx(af,{approver:e})]})}var sf=(e=>(e[e.ApprovalFlow=1]="ApprovalFlow",e[e.Association=2]="Association",e))(sf||{});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}}),exports.DialogPrimitive=se,Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return y.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return y.useTranslation}}),exports.AccordionPrimitive=ye,exports.AUTH_CONFIG=ze,exports.AccessDeniedDialog=xc,exports.Accordion=_c,exports.AccordionContent=Sc,exports.AccordionItem=Cc,exports.AccordionTrigger=kc,exports.ActionButton=Ar,exports.ActionMenu=Ar,exports.ActionMenuItems=oi,exports.AggregationType=Pm,exports.Alert=Qi,exports.AlertDescription=Ji,exports.AlertDialog=Ur,exports.AlertDialogAction=Kr,exports.AlertDialogCancel=Yr,exports.AlertDialogContent=Vr,exports.AlertDialogDescription=Gr,exports.AlertDialogFooter=Wr,exports.AlertDialogHeader=$r,exports.AlertDialogOverlay=qr,exports.AlertDialogPortal=Br,exports.AlertDialogTitle=Hr,exports.AlertDialogTrigger=Or,exports.AlertTitle=Xi,exports.AliasRedirect=function(){const{alias:e}=So(),{pathname:a,search:r,hash:s}=N.useLocation();return e?t.jsx(N.Navigate,{to:`/${e}${a}${r}${s}`,replace:!0}):null},exports.AliasRouteGuard=function({children:e,paramName:r="alias"}){const s=N.useNavigate(),n=N.useLocation(),o=N.useParams(),{alias:i,isAuthenticated:l,isLoading:c,switchUnit:d,companies:u}=So(),{urlAlias:m,isAliasMismatch:p,isValidAlias:h,isMissing:x,matchedCompany:f}=Gi({paramName:r}),[g,b]=a.useState(!1),v=a.useRef(!1),y=r in o,w=a.useCallback(e=>{const t=o[r],{pathname:a,search:s,hash:i}=n;if(t){const r=a.split("/"),n=r.findIndex(e=>e===t);if(n>=0)return r[n]=e,r.join("/")+s+i}return`/${e}${"/"===a?"":a}${s}${i}`},[o,r,n]);return a.useEffect(()=>{if(y&&!c&&l&&i&&!v.current)if(x)s(w(i),{replace:!0});else if(!m||h){if(p&&f&&!v.current){(async()=>{v.current=!0,b(!0);try{await d(f)}catch(e){i&&s(w(i),{replace:!0})}finally{v.current=!1,b(!1)}})()}}else{if(!u||0===u.length)return;s(w(i),{replace:!0})}},[y,c,l,i,x,m,h,p,f,d,w,s,u]),c||!l?t.jsx(t.Fragment,{children:e}):g?t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(Is,{size:"lg"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Trocando unidade..."})]})}):t.jsx(t.Fragment,{children:e})},exports.AnalysisFunctionality=Im,exports.AppHeader=Oh,exports.AppLayout=xx,exports.AppSidebar=Kh,exports.ApprovalFlowReturnStep=sf,exports.ApprovalSidenav=function({config:e,isLoading:r=!1,onClose:s,onApprove:n,onDefineApprover:o,onRefreshSteps:i,availableApprovers:l=[],isLoadingApprovers:d=!1}){const{t:u}=y.useTranslation(),[m,p]=a.useState(!1),[h,x]=a.useState(!1),[f,g]=a.useState(""),[b,v]=a.useState(""),[w,j]=a.useState(!1),[N,_]=a.useState(""),C=r||m,k=a.useCallback((e,t)=>{g(e),v(t??""),x(!0)},[]),S=a.useCallback(async t=>{x(!1),p(!0);if(!await n(e.associationId,{stepApproverId:f,...t}))return k(f,t.observation),void p(!1);s(),p(!1)},[e.associationId,f,n,s,k]),A=a.useCallback(e=>{_(e),j(!0)},[]),T=a.useCallback(async t=>{j(!1),p(!0),await o(e.associationId,N,t),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=(t,a)=>e.canApprove&&t.isCurrentStep&&a.approverId&&!a.date&&a.canApprove,P=(t,a)=>!e.flowReproved&&t.isCurrentStep&&1===a.type&&a.canApprove&&(!a.approverId||a.isToBeDefined);return t.jsxs("div",{className:"w-[550px] max-w-[900px] min-w-[400px] h-full flex flex-col bg-background",children:[t.jsxs("div",{className:"shrink-0 shadow-sm px-1 py-2 flex items-center gap-1 border-l-4",style:{borderLeftColor:e.color},children:[t.jsx(Sr,{variant:"ghost",size:"icon",onClick:s,className:"shrink-0",children:t.jsx(c.X,{className:"h-5 w-5"})}),t.jsx("span",{className:"text-lg font-medium",children:e.title})]}),C?t.jsx(Ms,{isLoading:!0,type:"spinner",className:"flex-1",children:t.jsx("div",{})}):t.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.approvalFlowInfo.length>0&&t.jsx("div",{className:"space-y-1",children:e.approvalFlowInfo.map((e,a)=>t.jsx("div",{className:_r("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},a))}),t.jsx("hr",{className:"border-border"}),e.approvalFlowSteps.map(a=>t.jsxs("div",{className:_r("space-y-2",(!a.isCurrentStep||e.flowReproved)&&"opacity-50"),children:[t.jsxs("p",{className:"font-semibold text-sm",children:[a.index,". Etapa: ",a.name]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground break-words",children:t.jsx(ef,{text:a.description})}),a.returnDate&&t.jsxs("div",{className:"border-y border-border py-3 mt-3 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs rounded px-1.5 py-0.5 bg-red-500/10 text-red-600",children:"Retorno de etapa"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.returnUserName," em ",Zx(a.returnDate)]})]}),a.returnObservation&&t.jsx("p",{className:"text-sm text-muted-foreground bg-muted rounded p-2 break-words",children:t.jsx(ef,{text:a.returnObservation})})]}),a.approvers.map(e=>t.jsxs("div",{className:"p-2 space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx(tf,{approver:e}),t.jsx(rf,{approver:e})]}),E(a,e)&&t.jsx(Sr,{size:"sm",onClick:()=>k(e.id),children:"Aprovar"}),P(a,e)&&t.jsx(Sr,{size:"sm",variant:"outline",onClick:()=>A(e.id),children:"Selecionar"})]}),e.observation&&t.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:t.jsx(ef,{text:e.observation})}),e.returnObservation&&t.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:t.jsx(ef,{text:e.returnObservation})})]},e.id))]},a.id))]}),t.jsx(Xx,{open:h,onOpenChange:x,returnSteps:e.returnSteps,initialObservation:b,title:e.approveDialogTitle,descriptions:e.approveDialogDescriptions,setDefaultApproverOnInit:e.approveDialogSetDefaultApproverOnInit,onSubmit:S}),t.jsx(Jx,{open:w,onOpenChange:j,approvers:l,isLoading:d,ignoreUserIds:D,onSubmit:T})]})},exports.ApproveDialog=Xx,exports.AuthErrorInterceptor=oo,exports.AuthProvider=ko,exports.AuthService=jo,exports.AutoComplete=gn,exports.Avatar=Zi,exports.AvatarFallback=tl,exports.AvatarImage=el,exports.Badge=Es,exports.BaseForm=Li,exports.Blockquote=bd,exports.BodyContent=function({breadcrumbs:e,children:a,className:r}){return t.jsxs("div",{className:_r("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",r),children:[e&&e.length>0&&t.jsx(Ac,{className:"mb-4",children:t.jsx(Tc,{children:e.map((a,r)=>{const s=r===e.length-1;return t.jsxs(te.Fragment,{children:[r>0&&t.jsx(Ic,{}),t.jsx(Dc,{children:s||!a.href?t.jsx(Pc,{children:a.label}):a.asChild&&a.children?t.jsx(Ec,{asChild:!0,children:a.children}):t.jsx(Ec,{asChild:!0,children:t.jsx(N.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${r}`)})})}),t.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=Ac,exports.BreadcrumbEllipsis=Mc,exports.BreadcrumbItem=Dc,exports.BreadcrumbLink=Ec,exports.BreadcrumbList=Tc,exports.BreadcrumbPage=Pc,exports.BreadcrumbSeparator=Ic,exports.BurndownPanel=Pp,exports.Button=Sr,exports.ButtonGroup=Lc,exports.CRUD_CONFIG=qe,exports.CURRENCY_FIELDS=np,exports.Calendar=zc,exports.CallbackPage=()=>{const{processCallback:e}=So(),r=N.useNavigate(),[s,n]=a.useState(null),[o,i]=a.useState(!1);a.useEffect(()=>{let t=!1;if(Pn()){Cn.clear(),function(){if(_n&&"undefined"!=typeof PerformanceObserver&&!Dn)try{Dn=new PerformanceObserver(e=>{for(const t of e.getEntries())t.duration}),Dn.observe({type:"longtask",buffered:!0})}catch{}}(),Sn("callback:start");try{const e=$n.getAccessToken(),t=$n.getIdToken();if(e){En(0,e,Rn.parseJwtPayload(e))}if(t){En(0,t,Rn.parseJwtPayload(t))}}catch{}}const a=Pn()?window.setTimeout(()=>{t||Tn()},15e3):0;return(async()=>{try{const a=await e();if(t=!0,Pn()&&(Sn("callback:processCallback:end"),function(e,t,a){if(!_n)return null;try{return performance.measure(`auth:${e}`,`auth:${t}`,`auth:${a}`).duration}catch{return null}}("callback (total)","callback:start","callback:processCallback:end"),Tn()),a){window.history.replaceState({},document.title,Ue("/"));const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),r(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(a){t=!0,Pn()&&Tn(),localStorage.removeItem("auth_return_url"),n(a?.message||"Erro durante a autenticação. Tente novamente.")}})(),()=>{a&&window.clearTimeout(a),function(){if(Dn){try{Dn.disconnect()}catch{}Dn=null}}()}},[e,r]);const l=async()=>{i(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro ao tentar novamente.")}finally{i(!1)}},d=()=>{window.location.href=Ue("/")};return s?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsxs(Mr,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[t.jsx(c.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),t.jsxs(Lr,{className:"space-y-4",children:[t.jsx(Qi,{variant:"danger",children:t.jsx(Ji,{children:s})}),t.jsx("div",{className:"text-sm text-muted-foreground",children:t.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Sr,{onClick:l,disabled:o,className:"flex-1",children:o?t.jsxs(t.Fragment,{children:[t.jsx(Is,{size:"sm",className:"mr-2"}),"Tentando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),t.jsx(Sr,{onClick:d,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx(Is,{size:"lg"})}),t.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Pr,exports.CardContent=Lr,exports.CardDescription=Rr,exports.CardFooter=Fr,exports.CardHeader=Ir,exports.CardSkeleton=Oo,exports.CardTitle=Mr,exports.CartesianPanel=Sp,exports.ChartContainer=Wu,exports.ChartLegend=Yu,exports.ChartLegendContent=Qu,exports.ChartStyle=Hu,exports.ChartTooltip=Gu,exports.ChartTooltipContent=Ku,exports.Checkbox=As,exports.Collapsible=zl,exports.CollapsibleContent=Ol,exports.CollapsibleTrigger=Ul,exports.ColorPicker=Si,exports.ColumnSettingsPopover=wi,exports.ComboTree=Nn,exports.Combobox=gn,exports.Command=nn,exports.CommandDialog=({children:e,...a})=>t.jsx("div",{...a,children:t.jsx(nn,{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=cn,exports.CommandGroup=dn,exports.CommandInput=on,exports.CommandItem=mn,exports.CommandList=ln,exports.CommandSeparator=un,exports.CommandShortcut=pn,exports.ContentContainer=function({title:e,subtitle:a,children:r,className:s,hasHeader:n=!0}){const o=e||a;return t.jsxs("div",{className:_r("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-visible",s),children:[n&&o&&t.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[e&&t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),a&&t.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),r&&t.jsx("div",{className:_r("p-6",!n&&o&&"pt-4"),children:r})]})},exports.ContextMenu=Wo,exports.ContextMenuCheckboxItem=ti,exports.ContextMenuContent=Zo,exports.ContextMenuGroup=Go,exports.ContextMenuItem=ei,exports.ContextMenuLabel=ri,exports.ContextMenuPortal=Ko,exports.ContextMenuRadioGroup=Qo,exports.ContextMenuRadioItem=ai,exports.ContextMenuSeparator=si,exports.ContextMenuShortcut=ni,exports.ContextMenuSub=Yo,exports.ContextMenuSubContent=Jo,exports.ContextMenuSubTrigger=Xo,exports.ContextMenuTrigger=Ho,exports.CoreProviders=function({children:r,queryClient:s,moduleAlias:n,associationsBaseUrl:o,signDocumentsSchema:i="common",signDocumentsTable:l="sign_documents",moduleAccessGuardProps:c,appTranslations:d,clarityProjectId:u,clarityMode:m="auto",backend:p="supabase",securityMode:h="legacy"}){Le(p),wc=h,vc();const[x]=a.useState(()=>new j.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),f=s??x;a.useEffect(()=>{if(d)for(const[e,t]of Object.entries(d))_l(e,t)},[d]);const g={sourceModule:n,...c};return t.jsxs(Vl,{children:[t.jsx(Nc,{}),t.jsx(y.I18nextProvider,{i18n:e,children:t.jsx(j.QueryClientProvider,{client:f,children:t.jsxs(ko,{moduleAlias:n,children:[t.jsx(jc,{projectId:u,mode:m}),t.jsx(Ll,{children:t.jsxs(kl,{moduleAlias:n,associationsBaseUrl:o,signDocumentsSchema:i,signDocumentsTable:l,children:[t.jsx(Pl,{}),t.jsx(gc,{...g,children:r})]})})]})})})]})},exports.CrudActionBar=fi,exports.CrudActionMenu=function({onEdit:e,onDelete:r,onToggleStatus:s,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:l=[],renderAs:d="dropdown",variant:u="default"}){const{t:m}=y.useTranslation(),p=a.useMemo(()=>{const t=[];return e&&o&&t.push({key:"edit",icon:c.Edit,label:m("edit","Editar"),onClick:e,variant:"default"}),s&&t.push({key:"toggle-status",icon:n?c.PowerOff:c.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:s,variant:"default"}),l.forEach(e=>{!1!==e.show&&t.push({key:`custom-${e.label}`,icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),r&&i&&t.push({key:"delete",icon:c.Trash2,label:m("remove","Remover"),onClick:r,variant:"destructive"}),t},[e,r,s,n,o,i,l,m]);return 0===p.length?null:"dropdown"===d?t.jsx(Xs,{delayDuration:200,children:t.jsxs(Ls,{children:[t.jsx(Fs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:t.jsx(c.EllipsisVertical,{size:"compact"===u?14:16})})}),t.jsx($s,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(e=>e.disabled?t.jsxs(tn,{disabledReason:e.disabledReason,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&t.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key):t.jsxs(Ws,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&t.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key))})]})}):t.jsx("div",{className:"flex items-center gap-1",children:p.map(e=>t.jsxs(Sr,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:e.onClick,className:"compact"===u?"h-7 px-2":"",children:[e.icon&&t.jsx(e.icon,{size:"compact"===u?14:16}),"compact"!==u&&t.jsx("span",{className:"ml-1",children:e.label})]},e.key))})},exports.CrudGrid=({manager:r,columns:s,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:d,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f,showActionBar:g=!0,showSearch:b=!1,searchValue:v,onSearchChange:w,searchPlaceholder:j,bulkActions:N=[],onBulkDelete:_,filters:C,gridColumns:k=3,renderCard:S,viewMode:A,onViewModeChange:T,listCardRenderer:D,gridCardRenderer:E,showViewToggle:P=!1})=>{const{setSearchVisible:I}=So(),M=void 0!==f?!f:g;a.useEffect(()=>{if(!b)return I(!0),()=>I(!1)},[I,b]);const R=m||x.length>0||b||u||C||P,L=_||(()=>{r.bulkDelete?.(r.selectedIds)}),F=A||"grid",z="list"===F,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&&R?t.jsx(fi,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:j,showBulkActions:u,selectedCount:r.selectedIds.length,bulkActions:N,onBulkDelete:L,onClearSelection:r.clearSelection,customActions:x,filters:C,viewMode:F,onViewModeChange:T,showViewToggle:P,availableViewModes:["list","grid"]}):null;return r.isLoading?t.jsxs("div",{className:"flex flex-col h-full",children:[O,t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsx(Oo,{count:6})})]}):0===r.entities.length?t.jsxs("div",{className:"flex flex-col h-full",children:[O,t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(qo,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"})})]}):t.jsxs("div",{className:"flex flex-col h-full",children:[O,t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsx("div",{className:_r("grid gap-4",U),children:r.entities.map(e=>{const a=(e=>{const{t:t}=y.useTranslation();return z&&D?D(e):!z&&E?E(e):S?S(e):null})(e);return t.jsxs(Wo,{children:[t.jsx(Ho,{asChild:!0,children:a?t.jsx("div",{className:"cursor-pointer",onClick:t=>{t.stopPropagation(),u?r.selectItem(e.id):n?.(e)},children:a}):t.jsx(Pr,{className:_r("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&r.selectedIds.includes(e.id)&&"bg-muted ring-2 ring-primary",z&&"flex-row"),onClick:t=>{t.stopPropagation(),u?r.selectItem(e.id):n?.(e)},children:t.jsxs(Lr,{className:_r("p-4",z&&"flex items-center gap-4 w-full"),children:[u&&t.jsx("div",{className:_r(z?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),z?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),t.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(e):String(e[a.key]??"")})]},String(a.key)))}),(n||o||c)&&t.jsx("div",{onClick:e=>e.stopPropagation(),children:c?c(e):t.jsx(ii,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:d?d(e):[]})})]}):t.jsxs("div",{className:"flex items-start gap-3",children:[u&&t.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:t.jsx(gi,{checked:r.selectedIds.includes(e.id),onCheckedChange:()=>r.selectItem(e.id)})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>t.jsxs("div",{className:_r("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[t.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),t.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(e):String(e[a.key]??"")})]},String(a.key))),(n||o||c)&&t.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(e):t.jsx(ii,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:d?d(e):[]})})]})]})]})})}),t.jsx(Zo,{className:"w-[160px]",children:t.jsx(oi,{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:d?d(e):[],renderAs:"context"})})]},e.id)})})})]})},exports.CrudPageInternal=$i,exports.CrudPagination=zi,exports.CrudPrimitiveFilterBar=kh,exports.CrudPrimitivePagination=Fi,exports.CrudPrimitiveTable=Ch,exports.CrudTable=Ni,exports.CustomFormFields=function({fields:e,readOnly:r=!1,hideInactiveWithoutValue:s=!1,onChange:n,onFieldChange:o}){const i=a.useCallback(t=>{if(o?.(t),n){const a=e.map(e=>e.id===t.id?t:e);n(a)}},[e,n,o]),l=e.filter(e=>Ox(e,s));return 0===l.length?null:t.jsx("div",{className:"space-y-4",children:l.map(e=>t.jsx(Qx,{field:e,readOnly:r,onChange:i},e.id))})},exports.DASHBOARD_STORAGE_KEYS={advancedFilter:"analysisDashboardsListFilter"},exports.DATETIME_FORMATS=tr,exports.DEFAULT_DATETIME_FORMAT=sr,exports.DEFAULT_LOCALE=rr,exports.DEFAULT_TIMEZONE=nr,exports.DashboardForm=Xp,exports.DashboardFormTab=$m,exports.DashboardFunctionality=Mm,exports.DashboardGeneralView=function({dashboards:e,limit:r,generalView:s,language:n=Hm.PtBr,isLoading:o=!1,canAdd:i=!1,canEdit:l=!1,canRemove:c=!1,canEditStandard:d=!1,activePanels:u=[],activePages:m=[],getPanelData:p,users:h=[],groups:x=[],places:f=[],collaborators:g=[],isSaving:b=!1,onOpen:v,onBackToList:y,onRefresh:w,onRefreshList:j,onToggleFavorite:N,onSave:_,onUpdate:C,onRemove:k,onDuplicate:S,onShare:A,onAddPanel:T,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:P,onLayoutChange:I,onSearch:M,onQuickFilterChange:R,onSetGeneralView:L,viewState:F,onViewStateChange:z,listToolbarExtra:U,viewToolbarActions:O,className:B}){const[q,V]=a.useState({mode:"list"}),$=F??q,W=a.useCallback(e=>{z?z(e):V(e)},[z]),H=a.useMemo(()=>"view"===$.mode||"edit"===$.mode||"share"===$.mode?e.find(e=>e.id===$.dashboardId)??null:null,[e,$]),[G,K]=a.useState(!1),[Y,Q]=a.useState(m[0]?.id);a.useEffect(()=>{m.length>0&&!Y&&Q(m[0]?.id)},[m,Y]),a.useEffect(()=>{if("view"!==$.mode||!H||H.idViewType!==Vm.Carousel||m.length<=1)return;const e=function(e){switch(e){case Lm.FiveSeconds:return 5e3;case Lm.TenSeconds:return 1e4;case Lm.FifteenSeconds:return 15e3;case Lm.ThirtySeconds:return 3e4;case Lm.OneMinute:return 6e4;case Lm.ThreeMinutes:return 18e4;case Lm.FiveMinutes:return 3e5;case Lm.TenMinutes:return 6e5;default:return 15e3}}(H.idPageTime),t=setInterval(()=>{Q(e=>{const t=(m.findIndex(t=>t.id===e)+1)%m.length;return m[t]?.id})},e);return()=>clearInterval(t)},[$,H,m]);const X=a.useCallback(e=>{W({mode:"view",dashboardId:e.id}),Q(void 0),v?.(e)},[W,v]),J=a.useCallback(()=>{W({mode:"list"}),K(!1),y?.()},[W,y]),Z=a.useCallback(()=>{W({mode:"create"})},[W]),ee=a.useCallback(e=>{W({mode:"edit",dashboardId:e.id})},[W]),te=a.useCallback(e=>{W({mode:"share",dashboardId:e.id})},[W]),ae=a.useCallback(e=>{"edit"===$.mode||"share"===$.mode?C?.($.dashboardId,e):_?.(e)},[$,_,C]),re=a.useCallback(()=>{"edit"===$.mode||"share"===$.mode?W({mode:"view",dashboardId:$.dashboardId}):W({mode:"list"})},[$,W]),se=a.useCallback(()=>{H&&N?.(H)},[H,N]),ne=a.useCallback(()=>{H&&ee(H)},[H,ee]),oe=a.useCallback(()=>{H&&te(H)},[H,te]);return t.jsxs("div",{className:_r("flex flex-col h-full",B),children:["list"===$.mode&&t.jsx(Wp,{dashboards:e,limit:r,isLoading:o,language:n,canAdd:i,canEdit:l,canRemove:c,onOpen:X,onEdit:ee,onShare:te,onDuplicate:S,onRemove:k,onAdd:Z,onToggleFavorite:N,onRefresh:j,onSearch:M,onQuickFilterChange:R,toolbarExtra:U,className:"flex-1"}),"view"===$.mode&&H&&t.jsxs("div",{className:"flex flex-col h-full",children:[!G&&t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:[t.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]}),s?.dashboardId===H.id&&t.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:[t.jsxs("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),t.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),"Visão geral"]}),l&&L&&s?.dashboardId!==H.id&&t.jsx("button",{onClick:()=>L(H.id),className:"ml-auto text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Definir como visão geral"})]}),t.jsx(Bp,{dashboard:H,panels:u,pages:m,activePageId:Y,canEdit:l||d&&!!H.isStandard,isFullscreen:G,isLoading:o,getPanelData:p,onRefresh:w,onToggleFullscreen:()=>K(e=>!e),onToggleFavorite:se,onEdit:ne,onShare:oe,onAddPanel:T,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:P,onLayoutChange:I,onPageChange:Q,toolbarActions:O,className:"flex-1"})]}),"create"===$.mode&&t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:t.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]})}),t.jsx(Xp,{users:h,groups:x,places:f,collaborators:g,isSaving:b,onSave:ae,onCancel:re,className:"flex-1"})]}),("edit"===$.mode||"share"===$.mode)&&H&&t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:t.jsxs("button",{onClick:re,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar"]})}),t.jsx(Xp,{dashboard:H,initialTab:"share"===$.mode?$m.Share:$m.General,users:h,groups:x,places:f,collaborators:g,isSaving:b,isQualitfy:!!H.isStandard&&!d,onSave:ae,onCancel:re,className:"flex-1"})]})]})},exports.DashboardGrid=zp,exports.DashboardLanguage=Hm,exports.DashboardList=Wp,exports.DashboardListType=Rm,exports.DashboardPageTime=Lm,exports.DashboardPanelDimension=Fm,exports.DashboardPanelOrderBy=Um,exports.DashboardPanelOrderByType=zm,exports.DashboardPanelPeriod=Om,exports.DashboardPanelRenderer=Op,exports.DashboardPanelType=Bm,exports.DashboardShareType=Wm,exports.DashboardUpdateTime=qm,exports.DashboardView=Bp,exports.DashboardViewType=Vm,exports.DataFilterBar=kh,exports.DataList=Uc,exports.DataPagination=Fi,exports.DataTable=Ch,exports.DatePicker=function({date:e,onDateChange:a,placeholder:r,disabled:s=!1,className:n,disabledDates:o,captionLayout:l,fromYear:d,toYear:u}){const{t:m}=y.useTranslation(),p=r??m("select_date");return t.jsxs(an,{children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{variant:"outline",disabled:s,className:_r("w-full justify-start text-left font-normal",!e&&"text-muted-foreground",n),children:[t.jsx(c.Calendar,{className:"mr-2 h-4 w-4"}),e?i.format(e,"d 'de' MMMM 'de' yyyy",{locale:Za}):t.jsx("span",{children:p})]})}),t.jsx(sn,{className:"w-auto p-0",align:"start",children:t.jsx(zc,{mode:"single",selected:e,onSelect:a,disabled:o,captionLayout:l,fromYear:d,toYear:u,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=Qr,exports.DialogBody=ss,exports.DialogClose=Zr,exports.DialogContent=as,exports.DialogDescription=is,exports.DialogFooter=ns,exports.DialogHeader=rs,exports.DialogOverlay=es,exports.DialogPortal=Jr,exports.DialogTitle=os,exports.DialogTrigger=Xr,exports.DialogWizard=function({open:a,onOpenChange:r,currentStep:s,onStepChange:n,steps:o,canGoToStep:i,children:l,title:d,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:b="lg",unsavedChangesTitle:v,unsavedChangesDescription:w,cancelText:j,leaveWithoutSavingText:N,className:_,disableNext:C,hideNavigation:k,footerLeft:S}){const{t:A}=y.useTranslation(),T=o.length,D=s>=T,E=s<=1;return t.jsx(Qr,{open:a,onOpenChange:r,children:t.jsxs(as,{size:b,variant:f,isDirty:g,unsavedChangesTitle:v,unsavedChangesDescription:w,cancelText:j,leaveWithoutSavingText:N,className:_r("!p-0 !border-l-0 flex-row overflow-hidden",_),children:[t.jsxs("div",{className:"hidden sm:flex w-56 flex-shrink-0 flex-col bg-primary text-primary-foreground p-6 rounded-l-lg",children:[t.jsx("h3",{className:"text-sm font-medium opacity-80 mb-6",children:"Etapas"}),t.jsx("nav",{className:"flex flex-col gap-1 flex-1",children:o.map((e,a)=>{const r=a+1,o=r===s,l=(e=>e<s)(r),d=(u=r)<=s||!i||i(u);var u;return t.jsxs("button",{type:"button",onClick:()=>(e=>{e!==s&&(e<s?n(e):i&&!i(e)||n(e))})(r),disabled:!d,className:_r("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&&d&&"hover:bg-primary-foreground/10 cursor-pointer",!d&&"opacity-40 cursor-not-allowed"),children:[t.jsx("span",{className:_r("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?t.jsx(c.Check,{className:"h-3.5 w-3.5"}):r}),t.jsx("span",{className:_r("line-clamp-2",o&&"text-primary-foreground",!o&&"text-primary-foreground/70"),children:e})]},r)})})]}),t.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[t.jsxs(rs,{className:"p-6 pb-0",children:[t.jsxs("p",{className:"text-xs text-muted-foreground sm:hidden mb-1",children:["Etapa ",s," de ",T]}),t.jsx(os,{children:d}),u&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]}),t.jsx(ss,{className:"px-6",children:l}),!k&&t.jsx(ns,{className:"px-6 pb-6",children:t.jsxs("div",{className:"flex items-center justify-between w-full",children:[t.jsx("div",{className:"flex items-center gap-2",children:S}),t.jsxs("div",{className:"flex items-center gap-2",children:[!E&&t.jsx(Sr,{variant:"outline",onClick:()=>n(s-1),children:x}),D?t.jsx(Sr,{onClick:m,disabled:C,children:p}):t.jsx(Sr,{onClick:()=>n(s+1),disabled:C,children:h})]})]})})]})]})})},exports.DisabledMenuItem=tn,exports.DocumentFileUpload=function({association:e,canUpload:r=!0,canRemove:s=!0,canDownload:n=!0,canView:o=!0,maxFiles:i,allowedExtensions:c,maxSizeInBytes:d,disabled:u=!1,label:m,onFilesChanged:p,className:h}){const[x,f]=a.useState([]),[g,b]=a.useState(!1),[v,y]=a.useState(0),w=a.useRef(p);w.current=p;const{type:j,associationId:N,associationFieldId:_}=e,C=a.useCallback(async()=>{if(!N)return void f([]);const e=await Mx.listByAssociation(j,N,_);f(e),w.current?.(e.length)},[j,N,_]);a.useEffect(()=>{C()},[C]);const k=a.useCallback(async e=>{if(N){b(!0);try{await Mx.upload(j,N,e,_),y(e=>e+1),await C()}catch{l.toast.error("Falha ao enviar o arquivo.")}finally{b(!1)}}},[j,N,_,C]),S=a.useCallback(async(e,t)=>{const a=await Mx.downloadUrl(e.id);if(a)if(t){const t=document.createElement("a");t.href=a,t.download=e.name,t.click()}else window.open(a,"_blank","noopener,noreferrer");else l.toast.error("Não foi possível abrir o arquivo.")},[]),A=a.useCallback(async e=>{if(e.associationRowId){b(!0);try{if(!await Mx.remove(e.associationRowId))throw new Error;await C()}catch{l.toast.error("Falha ao remover o arquivo.")}finally{b(!1)}}},[C]),T=r&&(null==i||x.length<i);return t.jsxs("div",{className:h,children:[m&&t.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:m}),t.jsxs("div",{className:"space-y-2",children:[x.map(e=>t.jsx(Ax,{storedFile:Rx(e),showReplaceButton:!1,showDownloadButton:n,showViewButton:o,showCloseButton:s,disabled:u||g,onDownload:()=>S(e,!0),onView:()=>S(e,!1),onFileRemove:()=>A(e)},e.associationRowId||e.id)),T&&t.jsx(Ax,{allowedExtensions:c,maxSizeInBytes:d,showReplaceButton:!1,showDownloadButton:!1,showViewButton:!1,showCloseButton:!1,disabled:u||g,onFileSelect:k},`add-${v}`)]})]})},exports.Drawer=Oc,exports.DrawerClose=Vc,exports.DrawerContent=Wc,exports.DrawerDescription=Yc,exports.DrawerFooter=Gc,exports.DrawerHeader=Hc,exports.DrawerOverlay=$c,exports.DrawerPortal=qc,exports.DrawerTitle=Kc,exports.DrawerTrigger=Bc,exports.DropdownMenu=Ls,exports.DropdownMenuCheckboxItem=Hs,exports.DropdownMenuContent=$s,exports.DropdownMenuGroup=zs,exports.DropdownMenuItem=Ws,exports.DropdownMenuLabel=Ks,exports.DropdownMenuPortal=Us,exports.DropdownMenuRadioGroup=Bs,exports.DropdownMenuRadioItem=Gs,exports.DropdownMenuSeparator=Ys,exports.DropdownMenuShortcut=Qs,exports.DropdownMenuSub=Os,exports.DropdownMenuSubContent=Vs,exports.DropdownMenuSubTrigger=qs,exports.DropdownMenuTrigger=Fs,exports.ECustomFormFieldType=Lx,exports.EDocumentAssociationType={Docs:17,Trainings:19},exports.EFieldViewMode=Fx,exports.ESelectionFieldDataSource=zx,exports.EditProfileDialog=fl,exports.ElectronicSignatureDialog=function({open:r,onOpenChange:s,onConfirm:n,onGenerateCode:o,mode:i="code",email:l,maxLength:d=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,b=g?e.t("esign_password_description"):e.t("esign_code_description"),v=m??b,[y,w]=a.useState(""),[j,N]=a.useState(!1),[_,C]=a.useState(!1),[k,S]=a.useState(null),A=a.useCallback(async()=>{if(y.trim()){N(!0),S(null);try{await n(y)?(w(""),s(!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)}}},[y,n,s,f,g]),T=a.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||(w(""),S(null)),s(e)},E=g?c.Lock:c.ShieldCheck,P=g?"Senha":e.t("verification_code"),I=g?e.t("enter_password"):e.t("enter_code");return t.jsx(Qr,{open:r,onOpenChange:D,children:t.jsxs(as,{className:"sm:max-w-md",variant:"form",isDirty:!!y,children:[t.jsx(rs,{children:t.jsxs(os,{className:"flex items-center gap-2",children:[t.jsx(E,{className:"h-5 w-5 text-primary"}),u]})}),t.jsxs("div",{className:"py-4 space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:v}),!g&&l&&t.jsxs("div",{className:"flex items-center gap-2 text-sm bg-muted/50 rounded-md px-3 py-2",children:[t.jsx(c.Mail,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-muted-foreground",children:"Enviado para:"}),t.jsx("span",{className:"font-medium",children:l})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"signature-input",children:P}),t.jsx(Tr,{id:"signature-input",type:g?"password":"text",value:y,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&(e.preventDefault(),A())},maxLength:g?void 0:d,placeholder:I,autoFocus:!0,className:_r(k&&"border-destructive focus-visible:ring-destructive")}),k&&t.jsx("p",{className:"text-sm text-destructive",children:k})]}),!g&&t.jsxs(Sr,{variant:"ghost",size:"sm",onClick:T,disabled:_,className:"text-primary",children:[t.jsx(c.RefreshCw,{className:_r("h-4 w-4 mr-1",_&&"animate-spin")}),x]})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>D(!1),disabled:j,children:h}),t.jsx(Sr,{onClick:A,disabled:!y.trim()||j,children:j?"Validando...":p})]})]})})},exports.EllipsisText=Vo,exports.EmailService=fx,exports.EmptyState=qo,exports.EntitySelect=gn,exports.ErrorBoundary=Vl,exports.ExportDialog=function({open:e,onOpenChange:r,onExport:s,mode:n="table",options:o,title:i,description:l,cancelLabel:c="Cancelar",exportLabel:d="Exportar"}){const{t:u}=y.useTranslation(),[m,p]=a.useState(""),h=o??("chart"===n?im:om),x=i??u("chart"===n?"dashboard_export_chart":"dashboard_export_table"),f=l??u("select_file_format"),g=e=>{e||p(""),r(e)};return t.jsx(Qr,{open:e,onOpenChange:g,children:t.jsxs(as,{className:"sm:max-w-md",variant:"form",isDirty:!!m,children:[t.jsx(rs,{children:t.jsx(os,{children:x})}),t.jsxs("div",{className:"py-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),t.jsx(Fd,{value:m,onValueChange:p,className:"gap-3",children:h.map(e=>t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(zd,{value:e.value,id:`export-${e.value}`}),t.jsxs(Er,{htmlFor:`export-${e.value}`,className:_r("flex items-center gap-2 cursor-pointer font-normal",m===e.value&&"font-medium"),children:[e.icon,e.label]})]},e.value))})]}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"outline",onClick:()=>g(!1),children:c}),t.jsx(Sr,{onClick:()=>{m&&(s(m),r(!1),p(""))},disabled:!m,children:d})]})]})})},exports.ExportFormat=nm,exports.FORBIDDEN_FILE_TYPES=Cx,exports.FilePrintType=xm,exports.FileViewerType=hm,exports.FilterBar=Vi,exports.Form=ls,exports.FormControl=hs,exports.FormDateField=Vx,exports.FormDescription=xs,exports.FormField=({...e})=>t.jsx(cs.Provider,{value:{name:e.name},children:t.jsx(h.Controller,{...e})}),exports.FormItem=ms,exports.FormLabel=ps,exports.FormMessage=fs,exports.FormMultiSelectionField=Kx,exports.FormNumericField=Hx,exports.FormQuestionsField=Yx,exports.FormSingleSelectionField=Gx,exports.FormSkeleton=function({fields:e=4}){return t.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,a)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx(hn,{className:"h-4 w-24"}),t.jsx(hn,{className:"h-10 w-full"})]},a)),t.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[t.jsx(hn,{className:"h-10 w-20"}),t.jsx(hn,{className:"h-10 w-20"})]})]})},exports.FormTextField=qx,exports.FormTimeField=$x,exports.FormUrlField=Wx,exports.Grid=function({children:e,cols:a="auto-fit",gap:r="md",className:s}){return t.jsx("div",{className:_r("grid",Qc[a],Xc[r],s),children:e})},exports.H1=ld,exports.H2=cd,exports.H3=dd,exports.H4=ud,exports.HeaderSkeleton=function(){return t.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(hn,{className:"h-8 w-8 rounded-full"}),t.jsx(hn,{className:"h-6 w-32"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(hn,{className:"h-8 w-8"}),t.jsx(hn,{className:"h-8 w-24"})]})]})},exports.HoverCard=Jc,exports.HoverCardContent=ed,exports.HoverCardTrigger=Zc,exports.IconPicker=Pi,exports.IframeDialog=wm,exports.ImageEditor=function({value:e,onChange:r,onSubmit:s,onCancel:n,uploadFunction:o,deleteFunction:i,uploadOptions:d}){const{t:u}=y.useTranslation(),[m,p]=a.useState(e||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=Nx({uploadFunction:o,deleteFunction:i,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,t)=>{const a={...m,[e]:t};p(a),r(a)};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"URL"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Tr,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),o&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await x(t),a={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(a),r(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),t.jsx(Sr,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?t.jsxs(t.Fragment,{children:[t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),m.imageFile&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",m.imageFile," (",Math.round((m.imageSize||0)/1024)," KB)"]})]}),m.imageUrl&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Preview"}),t.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:t.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:t.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"})})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"caption",children:"Legenda"}),t.jsx(Ts,{id:"caption",placeholder:"Legenda",value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"alt",children:u("alt_text")}),t.jsx(Tr,{id:"alt",placeholder:u("alt_text"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Alinhamento"}),t.jsxs(bs,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[t.jsx(ws,{children:t.jsx(ys,{})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"left",children:"Esquerda"}),t.jsx(ks,{value:"center",children:"Centro"}),t.jsx(ks,{value:"right",children:"Direita"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"width",children:"Largura"}),t.jsx(Tr,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"height",children:"Altura"}),t.jsx(Tr,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:"allowDownload",checked:m.allowDownload||!1,onCheckedChange:e=>g("allowDownload",!0===e)}),t.jsx(Er,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[t.jsx(Sr,{variant:"outline",onClick:n,children:"Cancelar"}),t.jsx(Sr,{onClick:()=>{m.imageUrl?s(m):l.toast.error("Erro",{description:u("no_image_selected")})},disabled:!m.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:e,className:a="",style:r}){const{t:s}=y.useTranslation();if(!e.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return t.jsx("div",{className:`flex ${n} my-4 ${a}`,style:r,children:t.jsxs("div",{className:"space-y-2 max-w-full",children:[t.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&&t.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&t.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[t.jsx(c.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=gd,exports.Input=Tr,exports.InputGroup=td,exports.InputGroupAddon=rd,exports.InputGroupButton=nd,exports.InputGroupInput=od,exports.InputGroupTextarea=id,exports.LINK_PROPERTIES=op,exports.LOGO_CONFIG=et,exports.Label=Er,exports.LanguageBootstrap=Pl,exports.Large=hd,exports.Lead=pd,exports.List=vd,exports.ListPanel=_p,exports.LoadingState=Ms,exports.LocaleProvider=Ll,exports.LoginPage=()=>{const{t:e}=y.useTranslation();return t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),t.jsxs(Lr,{className:"text-center space-y-4",children:[t.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),t.jsx(Sr,{onClick:async()=>{We()?await jo.loginDev():jo.loginProd()},className:"w-full",size:"lg",children:We()?e("dev_login"):e("login_with_qualiex")})]})]})})},exports.MESSAGES=tt,exports.MODULES_DATA=lc,exports.MONTHS_MAP=sp,exports.MatrixRiskPanel=Mp,exports.MatrixViewType=Gm,exports.Menubar=Eu,exports.MenubarCheckboxItem=Fu,exports.MenubarContent=Ru,exports.MenubarGroup=Su,exports.MenubarItem=Lu,exports.MenubarLabel=Uu,exports.MenubarMenu=ku,exports.MenubarPortal=Au,exports.MenubarRadioGroup=Du,exports.MenubarRadioItem=zu,exports.MenubarSeparator=Ou,exports.MenubarShortcut=Bu,exports.MenubarSub=Tu,exports.MenubarSubContent=Mu,exports.MenubarSubTrigger=Iu,exports.MenubarTrigger=Pu,exports.MindMap=({value:e,defaultValue:r,onChange:s,onNodeSelect:n,readOnly:o=!1,hideToolbar:i=!1,extraShortcuts:l,renderNodeContent:c,className:d,height:u=600})=>{const{t:m}=y.useTranslation(),p=dh({value:e,defaultValue:r,onChange:s,readOnly:o}),h=gh(p.root),x=function(){const[e,t]=a.useState({x:0,y:0,scale:1}),r=a.useRef(!1),s=a.useRef({x:0,y:0,tx:0,ty:0}),n=a.useCallback(t=>{0!==t.button&&1!==t.button||(r.current=!0,s.current={x:t.clientX,y:t.clientY,tx:e.x,ty:e.y},t.currentTarget.setPointerCapture(t.pointerId))},[e.x,e.y]),o=a.useCallback(e=>{r.current&&t(t=>({...t,x:s.current.tx+(e.clientX-s.current.x),y:s.current.ty+(e.clientY-s.current.y)}))},[]),i=a.useCallback(e=>{if(r.current){r.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),l=a.useCallback((e,a,r)=>{t(t=>{const s=Math.min(2.5,Math.max(.3,t.scale+e));if(s===t.scale)return t;if(void 0===a||void 0===r)return{...t,scale:s};const n=s/t.scale;return{scale:s,x:a-(a-t.x)*n,y:r-(r-t.y)*n}})},[]),c=a.useCallback(()=>l(.15),[l]),d=a.useCallback(()=>l(-.15),[l]),u=a.useCallback(()=>t({x:0,y:0,scale:1}),[]),m=a.useCallback((e,a,r,s)=>{const n=Math.min((r-64)/e,(s-64)/a,1.5),o=Math.max(.3,n);t({scale:o,x:(r-e*o)/2,y:(s-a*o)/2})},[]),p=a.useCallback(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=e.currentTarget.getBoundingClientRect(),a=e.clientX-t.left,r=e.clientY-t.top;l(e.deltaY>0?-.1:.1,a,r)},[l]);return a.useEffect(()=>{const e=()=>r.current=!1;return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]),{transform:e,setTransform:t,zoomIn:c,zoomOut:d,reset:u,fitTo:m,onBackgroundPointerDown:n,onPointerMove:o,onPointerUp:i,onWheel:p}}(),f=te.useRef(null),g=te.useRef(null),b=te.useRef(null),[v,w]=te.useState(null),[j,N]=te.useState(null);te.useEffect(()=>{n?.(p.selectedNode)},[p.selectedNode,n]),function({api:e,layout:t,containerRef:r,onStartEditing:s,readOnly:n,extraShortcuts:o}){a.useEffect(()=>{const a=a=>{const i=r.current;if(!i)return;if(!i.contains(document.activeElement))return;const l=a.target;if(l?.isContentEditable)return;if(l&&("INPUT"===l.tagName||"TEXTAREA"===l.tagName))return;const c={layout:t,selectedId:e.selectedId,setSelectedId:e.setSelectedId},d=e.selectedId;for(const t of o??[])if(t.key.toLowerCase()===a.key.toLowerCase()&&!!t.ctrl===(a.ctrlKey||a.metaKey)&&!!t.shift===a.shiftKey&&!!t.alt===a.altKey)return a.preventDefault(),void t.handler({selectedId:e.selectedId,root:e.root,setRoot:e.setRoot,select:e.setSelectedId});if((a.ctrlKey||a.metaKey)&&"z"===a.key.toLowerCase())return a.preventDefault(),void(a.shiftKey?e.redo():e.undo());if("ArrowUp"===a.key)return a.preventDefault(),void bh("up",c);if("ArrowDown"===a.key)return a.preventDefault(),void bh("down",c);if("ArrowLeft"===a.key)return a.preventDefault(),void bh("left",c);if("ArrowRight"===a.key)return a.preventDefault(),void bh("right",c);if(d){if(" "===a.key)return a.preventDefault(),void e.toggleNode(d);if("F2"===a.key){if(n)return;return a.preventDefault(),void s(d)}if(!n){if("Enter"===a.key&&!a.shiftKey)return a.preventDefault(),d===e.root.id?e.addChild(d,""):e.addSibling(d,""),void setTimeout(()=>{e.selectedId&&s(e.selectedId)},0);if("Insert"===a.key||"Tab"===a.key)return a.preventDefault(),e.addChild(d,""),void setTimeout(()=>{e.selectedId&&s(e.selectedId)},0);if("Delete"===a.key||"Backspace"===a.key){if(d===e.root.id)return;return a.preventDefault(),void e.removeNode(d)}}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t,r,s,n,o])}({api:p,layout:h,containerRef:f,onStartEditing:e=>{o||w(e)},readOnly:o,extraShortcuts:l});const _=te.useRef(!1);te.useEffect(()=>{if(_.current)return;const e=g.current;if(!e)return;const{clientWidth:t,clientHeight:a}=e;t>0&&a>0&&h.width>0&&(x.fitTo(h.width,h.height,t,a),_.current=!0)},[h.width,h.height,x]);const C=p.selectedId,k=p.selectedNode,S=C===p.root.id,A=te.useRef(null),T=e=>t=>{if(o)return;const a=A.current;if(!a||a===e)return;const r=eh(p.root,a);r&&eh(r.node,e)||(t.preventDefault(),t.dataTransfer.dropEffect="move",N(e))},D=()=>N(null),E=e=>t=>{t.preventDefault();const a=A.current;N(null),A.current=null,a&&a!==e&&p.moveNode(a,e)};return t.jsx(Xs,{children:t.jsxs("div",{ref:f,tabIndex:0,role:"tree","aria-label":m("mind_map_aria_label"),className:_r("relative flex flex-col rounded-lg border bg-muted/20 overflow-hidden focus:outline-none",d),style:{height:u},onClick:()=>f.current?.focus(),children:[!i&&t.jsx(jh,{canAddChild:!!k&&!o,canAddSibling:!!k&&!o,canDelete:!!k&&!S&&!o,canUndo:p.canUndo&&!o,canRedo:p.canRedo&&!o,onAddChild:()=>{if(!C)return;const e=p.addChild(C,"");w(e)},onAddSibling:()=>{if(!C)return;if(S){const e=p.addChild(C,"");return void w(e)}const e=p.addSibling(C,"");w(e)},onDelete:()=>{C&&!S&&p.removeNode(C)},onExpandAll:p.expandAll,onCollapseAll:p.collapseAll,onFit:()=>{const e=g.current;e&&x.fitTo(h.width,h.height,e.clientWidth,e.clientHeight)},onZoomIn:x.zoomIn,onZoomOut:x.zoomOut,onUndo:p.undo,onRedo:p.redo,onExportJson:()=>{!function(e,t,a="application/json"){const r=new Blob([e],{type:a}),s=URL.createObjectURL(r),n=document.createElement("a");n.href=s,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}(Nh(p.root),"mind-map.json")},onExportImage:async()=>{if(b.current)try{await async function(e,t="mind-map.png"){const a=e.cloneNode(!0),r=(new XMLSerializer).serializeToString(a),s=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(r)))}`,n=new Image;await new Promise((e,t)=>{n.onload=()=>e(),n.onerror=()=>t(new Error("Failed to load SVG snapshot")),n.src=s});const o=e.clientWidth||Number(e.getAttribute("width"))||1200,i=e.clientHeight||Number(e.getAttribute("height"))||800,l=document.createElement("canvas");l.width=2*o,l.height=2*i;const c=l.getContext("2d");if(!c)throw new Error("Canvas 2D context unavailable");c.fillStyle="#ffffff",c.fillRect(0,0,l.width,l.height),c.drawImage(n,0,0,l.width,l.height);const d=await new Promise(e=>l.toBlob(e,"image/png"));if(!d)throw new Error("Failed to create PNG blob");const u=URL.createObjectURL(d),m=document.createElement("a");m.href=u,m.download=t,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}(b.current,"mind-map.png")}catch(e){}}}),t.jsx("div",{ref:g,className:"relative flex-1 overflow-hidden cursor-grab active:cursor-grabbing",onPointerDown:e=>{e.target===e.currentTarget&&(x.onBackgroundPointerDown(e),p.setSelectedId(null))},onPointerMove:x.onPointerMove,onPointerUp:x.onPointerUp,onWheel:x.onWheel,children:t.jsxs("div",{className:"absolute origin-top-left",style:{transform:`translate(${x.transform.x}px, ${x.transform.y}px) scale(${x.transform.scale})`,width:h.width,height:h.height},children:[t.jsx("svg",{ref:b,width:h.width,height:h.height,className:"absolute inset-0 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:h.nodes.map(e=>e.visibleChildren.map(a=>t.jsx(yh,{parent:e,child:a},`${e.node.id}-${a.node.id}`)))}),h.nodes.map(e=>{return t.jsx(vh,{layout:e,selected:C===e.node.id,editing:v===e.node.id,readOnly:o,onSelect:()=>p.setSelectedId(e.node.id),onStartEditing:()=>w(e.node.id),onFinishEditing:t=>{null!==t&&p.renameNode(e.node.id,t),w(null)},onToggle:()=>p.toggleNode(e.node.id),onDragStart:(a=e.node.id,e=>{o||a===p.root.id||(A.current=a,e.dataTransfer.setData("text/plain",a),e.dataTransfer.effectAllowed="move")}),onDragOver:T(e.node.id),onDragLeave:D,onDrop:E(e.node.id),isDropTarget:j===e.node.id,renderNodeContent:c},e.node.id);var a})]})})]})})},exports.ModalStateProvider=function({children:e}){const[r,s]=a.useState(new Set),[n,o]=a.useState(!1),i=a.useCallback(e=>{s(t=>{const a=new Set(t);return a.add(e),a})},[]),l=a.useCallback(e=>{s(t=>{const a=new Set(t);return a.delete(e),a})},[]),c=a.useCallback(e=>{o(e)},[]),d=a.useMemo(()=>r.size>0||n,[r,n]),u=a.useMemo(()=>({openModals:r,hasOpenModal:d,registerModal:i,unregisterModal:l,setHasOpenModal:c}),[r,d,i,l,c]);return t.jsx(Hh.Provider,{value:u,children:e})},exports.ModuleAccessGuard=gc,exports.ModuleGrid=uc,exports.ModuleOfferContent=function({title:e,description:a,image:r,icon:s,ctaLabel:n,onCtaClick:o,children:i}){const{t:l}=y.useTranslation(),d=n??l("want_to_know_more");return t.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(r||s)&&t.jsx("div",{className:"flex items-center justify-center",children:r?t.jsx("img",{src:r,alt:e,className:"max-h-48 w-auto object-contain rounded-lg"}):s?t.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:t.jsx(s,{className:"h-12 w-12 text-primary"})}):null}),t.jsxs("div",{className:"space-y-3 max-w-lg",children:[t.jsx("h3",{className:"text-xl font-semibold text-foreground",children:e}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a})]}),i?t.jsx("div",{className:"w-full",children:i}):o?t.jsxs(Sr,{onClick:o,size:"lg",className:"gap-2",children:[t.jsx(c.Sparkles,{className:"h-4 w-4"}),d]}):null]})},exports.ModuleProvider=kl,exports.ModulesContent=mc,exports.ModulesDialog=hc,exports.ModulesFooterCards=ic,exports.MultiSelect=gn,exports.MultiselectPermissions=function({items:r,categories:s,value:n,onChange:o,readonly:i=!1,isLoading:l=!1,title:d=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:b,onDisclaimerClick:v,className:w}){const[j,N]=a.useState(s[0]?.id??""),[_,C]=a.useState(""),[k,S]=a.useState([]),[A,T]=a.useState(!1),D=a.useMemo(()=>km(n[j]),[n,j]),E=a.useMemo(()=>function(e){const{t:t}=y.useTranslation(),a=new Set;if(!e)return a;for(const r of e)r.inheritedIds?.forEach(e=>a.add(e));return a}(n[j]),[n,j]),P=a.useMemo(()=>r.filter(e=>D.has(e.id)),[r,D]),I=a.useMemo(()=>{const e=Cm(_);return r.filter(t=>!D.has(t.id)&&!(e&&!Cm(t.name).includes(e)))},[r,D,_]),M=a.useMemo(()=>{const e={};for(const t of s)e[t.id]=km(n[t.id]).size;return e},[s,n]),R=a.useCallback(e=>{N(e),S([]),C("")},[]),L=a.useCallback(e=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),F=a.useCallback(()=>{if(0===k.length)return;const e=[...n[j]??[]];for(const t of k){const a=r.find(e=>e.id===t),s=a?.group??"default",n=e.find(e=>e.context===s);n?n.allowedIds.includes(t)||(n.allowedIds=[...n.allowedIds,t]):e.push({context:s,allowedIds:[t],inheritedIds:[]})}o({...n,[j]:e}),S([]),C(""),T(!1)},[k,n,j,r,o]),z=a.useCallback(e=>{if(E.has(e))return;const t=(n[j]??[]).map(t=>({...t,allowedIds:t.allowedIds.filter(t=>t!==e)}));o({...n,[j]:t})},[n,j,E,o]);return l?t.jsxs("div",{className:_r("rounded-md border bg-muted/30 p-4 animate-pulse space-y-3",w),children:[t.jsx("div",{className:"h-4 w-32 bg-muted rounded"}),t.jsx("div",{className:"h-9 w-full bg-muted rounded"}),t.jsx("div",{className:"h-20 w-full bg-muted rounded"})]}):t.jsx("div",{className:_r("rounded-md border bg-muted/30",w),children:t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:d}),t.jsxs(bs,{value:j,onValueChange:R,children:[t.jsx(ws,{className:"h-9 text-sm",children:t.jsx(ys,{})}),t.jsx(_s,{children:s.map(e=>t.jsx(ks,{value:e.id,children:t.jsxs("span",{className:"flex items-center gap-2",children:[e.icon,e.name,M[e.id]>0&&t.jsx(Es,{variant:"secondary",className:"ml-1 text-xs px-1.5 py-0",children:M[e.id]})]})},e.id))})]})]}),!i&&t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(an,{open:A,onOpenChange:T,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Sr,{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,t.jsx(c.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsxs(sn,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:[t.jsx("div",{className:"p-2 border-b",children:t.jsxs("div",{className:"relative",children:[t.jsx(c.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{className:"pl-8 h-8 text-sm",placeholder:h,value:_,onChange:e=>C(e.target.value)})]})}),t.jsx(Ai,{className:"max-h-[220px]",children:0===I.length?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nenhum item encontrado"}):t.jsx("div",{className:"p-1",children:I.map(e=>{const a=k.includes(e.id);return t.jsxs("div",{className:_r("flex items-center gap-3 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent",a&&"bg-accent/50"),onClick:()=>L(e.id),children:[t.jsx("div",{className:_r("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",a&&"bg-primary text-primary-foreground"),children:a&&t.jsx(c.Check,{className:"h-3 w-3"})}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"truncate",children:e.name}),null!=e.count&&t.jsx("span",{className:"text-xs text-muted-foreground",children:f(e.count)})]})]},e.id)})})})]})]}),t.jsxs(Sr,{size:"sm",className:"h-9 gap-1",disabled:0===k.length,onClick:F,children:[t.jsx(c.Plus,{className:"h-4 w-4"}),u]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:m}),t.jsx("div",{className:_r("rounded-md border bg-background p-3 min-h-[60px]",i&&"bg-muted/50"),children:0===P.length?t.jsx("span",{className:"text-sm text-muted-foreground",children:p}):t.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(e=>{const a=E.has(e.id);return t.jsxs(Es,{variant:a?"secondary":"default",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.name,!i&&!a&&t.jsx("button",{type:"button",className:"ml-0.5 rounded-full hover:bg-primary-foreground/20 p-0.5",onClick:()=>z(e.id),children:t.jsx(c.X,{className:"h-3 w-3"})})]},e.id)})})}),i&&g&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.jsx("span",{dangerouslySetInnerHTML:{__html:g}})," ",b&&v&&t.jsx("button",{type:"button",className:"text-primary underline hover:no-underline",onClick:v,children:b})]})]})]})})},exports.Muted=fd,exports.NavigationMenu=yd,exports.NavigationMenuContent=Cd,exports.NavigationMenuIndicator=Ad,exports.NavigationMenuItem=jd,exports.NavigationMenuLink=kd,exports.NavigationMenuList=wd,exports.NavigationMenuTrigger=_d,exports.NavigationMenuViewport=Sd,exports.NavigationProvider=Rh,exports.NumericPanel=jp,exports.OnboardingDialog=rm,exports.OnlineEditorDialog=function({open:e,onOpenChange:r,identifier:s,fileName:n,mode:o="edit",type:i="document",onClose:l,className:d}){const[u,m]=a.useState(!0),p=function(e,t="edit",a="document"){return`https://docs.google.com/${a}/d/${e}/${t}?usp=drivesdk?embedded=true&rm=demo`}(s,o,i);a.useEffect(()=>{if(e){m(!0);const e=setTimeout(()=>m(!1),300);return()=>clearTimeout(e)}},[e]);const h=a.useCallback(()=>{l?.(),r(!1)},[l,r]);return a.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&h()};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[e,h]),t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:_r("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",d),children:[t.jsxs("div",{className:"flex items-center justify-between mb-6 min-h-[30px]",children:[u?t.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):t.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-80px)]",children:n}),t.jsx("div",{className:"flex items-center ml-4 z-20",children:t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:t.jsx(c.X,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Fechar"})]})})]}),t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[160px] w-full min-w-[77vw] min-h-[80vh]",children:u?t.jsx(Is,{className:"h-14 w-14"}):t.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[t.jsx(Is,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),t.jsx("iframe",{src:p,className:"border-none w-full h-full z-[1] relative",title:n})]})})]})})},exports.P=md,exports.PageBreadcrumb=function({items:e,maxItems:a=3,className:r}){const s=e.length>a?[e[0],...e.slice(-(a-1))]:e,n=e.length>a;return t.jsx(Ac,{className:r,children:t.jsx(Tc,{children:s.map((e,a)=>{const r=0===a,s=n&&1===a;return t.jsxs(Dc,{children:[!r&&t.jsx(Ic,{}),s&&t.jsxs(t.Fragment,{children:[t.jsx(Mc,{}),t.jsx(Ic,{})]}),e.isCurrentPage?t.jsx(Pc,{children:e.label}):t.jsx(Ec,{asChild:!0,children:t.jsx(N.Link,{to:e.href||"/",children:e.label})})]},e.label)})})})},exports.PageMetadataProvider=bl,exports.Pagination=Td,exports.PaginationContent=Dd,exports.PaginationEllipsis=Rd,exports.PaginationItem=Ed,exports.PaginationLink=Pd,exports.PaginationNext=Md,exports.PaginationPrevious=Id,exports.PaletteType=rp,exports.PanelError=gp,exports.PanelHeader=fp,exports.PanelItemsPerPanel=Km,exports.PanelLoader=bp,exports.PanelNoData=vp,exports.PanelSortType=Ym,exports.PanelState=Qm,exports.PanelUnavailable=yp,exports.ParetoPanel=Ep,exports.PerformancePanel=Ip,exports.PiePanel=Dp,exports.PlanType=Jm,exports.Popover=an,exports.PopoverContent=sn,exports.PopoverTrigger=rn,exports.Progress=Ld,exports.ProtectedRoute=({children:r})=>{const{isAuthenticated:s,isLoading:n}=So();if(a.useEffect(()=>{if(n)return;if(s)return;if($n.isManualLogout())return void(window.location.pathname.endsWith("/login")||(window.location.href=Ue("/login")));const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const r=We(),o=Be(window.location.pathname),i=o+window.location.search+window.location.hash;["/","/login","/callback"].includes(o)||localStorage.setItem("auth_return_url",i);(async()=>{r?await jo.loginDev():jo.loginProd()})()},[s,n]),n&&!s)return t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Carregando..."})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Processando..."})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t.jsxs(Pr,{className:"w-full max-w-md",children:[t.jsx(Ir,{className:"text-center",children:t.jsx(Mr,{className:"text-xl font-semibold",children:"Iniciando..."})}),t.jsxs(Lr,{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:We()?e.t("auto_login"):e.t("redirecting_auth")})]})]})})}return t.jsx(t.Fragment,{children:r})},exports.QUALIEX_CONFIG=Ze,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=fo,exports.QualiexErrorInterceptor=lo,exports.QualiexUserField=Ri,exports.QueriesContextType=Zm,exports.QueriesShareType=ep,exports.QuickFilterDashboard=tp,exports.RadioGroup=Fd,exports.RadioGroupItem=zd,exports.ReadOnlyTextField=Bx,exports.ReportRequestList=function({requests:e,isLoading:r=!1,onGetReportUrl:s,formatDate:n=Dm,labels:o,className:i}){const{t:l}=y.useTranslation(),d={...Am,...o},[u,m]=a.useState(""),[p,h]=a.useState(!1),[x,f]=a.useState(""),[g,b]=a.useState(""),[v,w]=a.useState(null),j=a.useMemo(()=>{if(!u)return e;const t=Tm(u);return e.filter(e=>Tm(e.reportName).includes(t))},[e,u]),N=a.useCallback(async e=>{if(!v){w(e.id);try{const t=await s(e.id);t&&(f(t),b(e.reportName),h(!0))}finally{w(null)}}},[s,v]);return r?t.jsx("div",{className:_r("space-y-3",i),children:Array.from({length:5}).map((e,a)=>t.jsx(hn,{className:"h-12 w-full"},a))}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:_r("space-y-3",i),children:[t.jsxs("div",{className:"relative max-w-sm",children:[t.jsx(c.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{className:"pl-8 h-9 text-sm",placeholder:d.searchPlaceholder,value:u,onChange:e=>m(e.target.value)})]}),t.jsx(Ai,{className:"rounded-md border",children:t.jsxs(Eo,{children:[t.jsx(Po,{children:t.jsxs(Ro,{children:[t.jsx(Lo,{className:"min-w-[140px]",children:d.report}),t.jsx(Lo,{className:"min-w-[150px]",children:d.status}),t.jsx(Lo,{className:"min-w-[160px]",children:d.requestDate}),t.jsx(Lo,{className:"min-w-[160px]",children:d.lastUpdate}),t.jsx(Lo,{className:"min-w-[160px]",children:d.expirationDate}),t.jsx(Lo,{className:"min-w-[140px]"})]})}),t.jsx(Io,{children:0===j.length?t.jsx(Ro,{children:t.jsx(Fo,{colSpan:6,className:"text-center text-muted-foreground py-8",children:d.noResults})}):j.map(e=>{const a=function(e){const{t:t}=y.useTranslation();return new Date>new Date(e.expirationDate)&&3===e.statusId?5:e.statusId}(e),r=function(e,a){const{t:r}=y.useTranslation();switch(e){case 1:return{label:a.statusWaiting,icon:t.jsx(c.Hourglass,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50"};case 2:return{label:a.statusProcessing,icon:t.jsx(c.RefreshCw,{className:"h-3.5 w-3.5 animate-spin"}),variant:"outline",className:"text-blue-600 border-blue-300 bg-blue-50"};case 3:return{label:a.statusCompleted,icon:t.jsx(c.CheckCircle2,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50"};case 4:return{label:a.statusError,icon:t.jsx(c.AlertCircle,{className:"h-3.5 w-3.5"}),variant:"danger"};case 5:return{label:a.statusExpired,icon:t.jsx(c.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"}}}(a,d),s=3===a,o=5===a;return t.jsxs(Ro,{children:[t.jsx(Fo,{className:"font-medium",children:e.reportName}),t.jsx(Fo,{children:t.jsxs(Es,{variant:r.variant,className:_r("gap-1",r.className),children:[r.icon,r.label]})}),t.jsx(Fo,{className:"text-sm",children:n(new Date(e.requestDate))}),t.jsx(Fo,{className:"text-sm",children:n(new Date(e.lastUpdate))}),t.jsx(Fo,{className:_r("text-sm",o&&"text-destructive"),children:n(new Date(e.expirationDate))}),t.jsx(Fo,{children:t.jsxs(Sr,{variant:"ghost",size:"sm",className:"gap-1.5",disabled:!s||v===e.id,onClick:()=>N(e),children:[v===e.id?t.jsx(c.Loader2,{className:"h-4 w-4 animate-spin"}):t.jsx(c.Eye,{className:"h-4 w-4"}),d.viewReport]})})]},e.id)})})]})})]}),t.jsx(wm,{open:p,onOpenChange:h,url:x,title:g})]})},exports.ReportRequestStatus=Sm,exports.ResizableHandle=({withHandle:e,className:a,...r})=>t.jsx(Ce.PanelResizeHandle,{className:_r("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...r,children:e&&t.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsx(c.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Ud,exports.ResizablePanelGroup=({className:e,...a})=>t.jsx(Ce.PanelGroup,{className:_r("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),exports.RichTextEditor=({value:r,onChange:s,disabled:n,placeholder:o=e.t("write_content_here"),minHeight:i="300px",showModeToggle:l=!0,showVariableHint:d=!0,className:u})=>{const{t:m}=y.useTranslation(),[p,h]=a.useState("visual"),x=V.useEditor({extensions:[$.configure({heading:{levels:[1,2,3]}}),W,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,K.Color,Y.configure({multicolor:!0})],content:r||"",editable:!n,onUpdate:({editor:e})=>{s(e.getHTML())}});te.useEffect(()=>{x&&r!==x.getHTML()&&x.commands.setContent(r||"")},[r,x]);const f=a.useCallback(()=>{if(!x)return;const e=x.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?x.chain().focus().extendMarkRange("link").setLink({href:t}).run():x.chain().focus().extendMarkRange("link").unsetLink().run())},[x]);return x?t.jsxs("div",{className:_r("space-y-2",u),children:[l&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex gap-1",children:[t.jsxs(Sr,{type:"button",size:"sm",variant:"visual"===p?"default":"outline",onClick:()=>h("visual"),disabled:n,children:[t.jsx(c.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),t.jsxs(Sr,{type:"button",size:"sm",variant:"code"===p?"default":"outline",onClick:()=>h("code"),disabled:n,children:[t.jsx(c.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),t.jsxs(Sr,{type:"button",size:"sm",variant:"preview"===p?"default":"outline",onClick:()=>h("preview"),disabled:n,children:[t.jsx(c.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),d&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",t.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===p&&t.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||x?.commands.focus()},children:[t.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHeading({level:1}).run(),isActive:x.isActive("heading",{level:1}),disabled:n,title:e.t("heading_1"),children:t.jsx(c.Heading1,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),isActive:x.isActive("heading",{level:2}),disabled:n,title:e.t("heading_2"),children:t.jsx(c.Heading2,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHeading({level:3}).run(),isActive:x.isActive("heading",{level:3}),disabled:n,title:e.t("heading_3"),children:t.jsx(c.Heading3,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleBold().run(),isActive:x.isActive("bold"),disabled:n,title:e.t("bold"),children:t.jsx(c.Bold,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleItalic().run(),isActive:x.isActive("italic"),disabled:n,title:e.t("italic"),children:t.jsx(c.Italic,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleUnderline().run(),isActive:x.isActive("underline"),disabled:n,title:"Sublinhado",children:t.jsx(c.Underline,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleStrike().run(),isActive:x.isActive("strike"),disabled:n,title:"Riscado",children:t.jsx(c.Strikethrough,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleBulletList().run(),isActive:x.isActive("bulletList"),disabled:n,title:"Lista",children:t.jsx(c.List,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleOrderedList().run(),isActive:x.isActive("orderedList"),disabled:n,title:m("ordered_list"),children:t.jsx(c.ListOrdered,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().toggleHighlight().run(),isActive:x.isActive("highlight"),disabled:n,title:"Destacar",children:t.jsx(c.Highlighter,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:f,isActive:x.isActive("link"),disabled:n,title:"Link",children:t.jsx(c.Link,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().unsetAllMarks().clearNodes().run(),disabled:n,title:m("clear_formatting"),children:t.jsx(c.RemoveFormatting,{className:"h-4 w-4"})}),t.jsx(Zu,{}),t.jsx(Ju,{onClick:()=>x.chain().focus().undo().run(),disabled:n||!x.can().undo(),title:"Desfazer",children:t.jsx(c.Undo,{className:"h-4 w-4"})}),t.jsx(Ju,{onClick:()=>x.chain().focus().redo().run(),disabled:n||!x.can().redo(),title:"Refazer",children:t.jsx(c.Redo,{className:"h-4 w-4"})})]}),t.jsx(V.EditorContent,{editor:x,className:_r("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&&t.jsx("textarea",{value:r||"",onChange:e=>s(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&&t.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:t.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:t.jsx("div",{dangerouslySetInnerHTML:{__html:r||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null},exports.RiskCriticality=ap,exports.SEARCH_CONFIG=Ve,exports.SUPPORTED_LOCALES=er,exports.ScrollArea=Ai,exports.ScrollBar=Ti,exports.Select=bs,exports.SelectApproverDialog=Jx,exports.SelectContent=_s,exports.SelectGroup=vs,exports.SelectItem=ks,exports.SelectLabel=Cs,exports.SelectScrollDownButton=Ns,exports.SelectScrollUpButton=js,exports.SelectSearch=gn,exports.SelectSeparator=Ss,exports.SelectTrigger=ws,exports.SelectValue=ys,exports.Separator=zr,exports.Sheet=Od,exports.SheetBody=Kd,exports.SheetClose=qd,exports.SheetContent=Hd,exports.SheetDescription=Xd,exports.SheetFooter=Yd,exports.SheetHeader=Gd,exports.SheetOverlay=$d,exports.SheetPortal=Vd,exports.SheetTitle=Qd,exports.SheetTrigger=Bd,exports.Sidebar=au,exports.SidebarActionTrigger=qh,exports.SidebarContent=du,exports.SidebarFooter=lu,exports.SidebarGroup=uu,exports.SidebarGroupAction=pu,exports.SidebarGroupContent=hu,exports.SidebarGroupLabel=mu,exports.SidebarHeader=function({open:e,appName:r}){const[s,n]=a.useState(!1),{association:o}=Dl(),i=lt({isQualitfy:o?.isQualitfy,isMetroex:o?.isMetroex});return t.jsxs(t.Fragment,{children:[t.jsx(iu,{className:"p-0 gap-0",children:e?t.jsxs("div",{className:"flex items-center gap-2 pl-2 min-h-10",children:[t.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>n(!0),children:t.jsx("img",{src:i,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),r&&t.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:t.jsx("span",{className:"line-clamp-2",children:(e=>{const a=e.split(" ");if(a.length<=1)return t.jsxs("span",{className:"whitespace-nowrap",children:[e," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const r=a[a.length-1],s=a.slice(0,-1).join(" ");return t.jsxs(t.Fragment,{children:[s," ",t.jsxs("span",{className:"whitespace-nowrap",children:[r," ",t.jsx(c.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(r)})})]}):t.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:t.jsx("button",{className:"flex items-center justify-center h-10 w-8 cursor-pointer",onClick:()=>n(!0),children:t.jsx("img",{src:ct.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})})})}),t.jsx(hc,{open:s,onOpenChange:n})]})},exports.SidebarInput=ou,exports.SidebarInset=nu,exports.SidebarLogo=Uh,exports.SidebarMenu=xu,exports.SidebarMenuAction=vu,exports.SidebarMenuBadge=yu,exports.SidebarMenuButton=bu,exports.SidebarMenuItem=fu,exports.SidebarMenuSkeleton=wu,exports.SidebarMenuSub=ju,exports.SidebarMenuSubButton=_u,exports.SidebarMenuSubItem=Nu,exports.SidebarProvider=tu,exports.SidebarRail=su,exports.SidebarSeparator=cu,exports.SidebarSkeleton=function(){return t.jsx("div",{className:"w-64 border-r bg-muted/10",children:t.jsxs("div",{className:"p-4",children:[t.jsx(hn,{className:"h-8 w-32 mb-6"}),t.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,a)=>t.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[t.jsx(hn,{className:"h-4 w-4"}),t.jsx(hn,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=ru,exports.SingleFileUpload=Ax,exports.Skeleton=hn,exports.Slider=Cu,exports.Small=xd,exports.SonnerToaster=Rs,exports.Spinner=Is,exports.SplitButton=sm,exports.Stack=qi,exports.StatusBadge=function({label:e,color:a,icon:r,showIcon:s,size:n="md",variant:o="filled",backgroundColor:i,className:l}){const c=Em[n],d=s??!!r;return t.jsxs("span",{className:_r("inline-flex items-center rounded-md font-medium whitespace-nowrap","outline"===o&&"border",c.badge,l),style:(()=>{switch(o){case"outline":return{color:a,borderColor:xr(a,.3),backgroundColor:"transparent"};case"ghost":return{color:a,backgroundColor:"transparent"};default:return{color:a,backgroundColor:i||xr(a,.1)}}})(),children:[d&&r&&t.jsx(r,{size:c.icon,strokeWidth:2}),e]})},exports.StepSelector=cm,exports.Stepper=cm,exports.StimulsoftViewer=function({reportApiUrl:e,parameters:r={},minHeight:s="80vh",...n}){const o=a.useMemo(()=>{const t=`${e}/api/reports/v1/Viewer/InitViewer`,a=new URLSearchParams(r).toString();return a?`${t}?${a}`:t},[e,r]);return t.jsx(wm,{...n,url:o,minHeight:s})},exports.Switch=Ii,exports.TIMEZONES=ar,exports.TabPageContent=function({children:e,className:a}){return t.jsx("div",{className:_r("space-y-6",a),children:e})},exports.TabPageHeader=function({title:e,description:a,actions:r,className:s}){return t.jsxs("div",{className:_r("space-y-4",s),children:[t.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),a&&t.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),r&&t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:r})]}),t.jsx(zr,{})]})},exports.TabPageLayout=function({children:e,className:a}){return t.jsx("div",{className:_r("flex flex-col h-full",a),children:t.jsx(Ai,{className:"flex-1",children:t.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=Eo,exports.TableBody=Io,exports.TableCaption=zo,exports.TableCell=Fo,exports.TableFooter=Mo,exports.TableHead=Lo,exports.TableHeader=Po,exports.TableResizeHandle=$o,exports.TableRow=Ro,exports.TableRowActions=ii,exports.TableSkeleton=Uo,exports.Tabs=$l,exports.TabsContent=Gl,exports.TabsList=Wl,exports.TabsTrigger=Hl,exports.TeamSelector=function({users:e,value:r,onChange:s,disabled:n=!1,placeholder:o="Buscar membro da equipe...",confirmRemoval:i=!0,confirmTitle:l,confirmMessage:d="Tem certeza que deseja remover este membro da equipe?",emptyMessage:u,className:m}){const{t:p}=y.useTranslation(),h=l??p("leadership_remove_team"),x=u??p("leadership_no_members"),[f,g]=a.useState(""),[b,v]=a.useState(!1),[w,j]=a.useState(null),N=a.useMemo(()=>new Set(r),[r]),_=a.useMemo(()=>e.filter(e=>N.has(e.id)),[e,N]),C=a.useMemo(()=>e.filter(e=>!N.has(e.id)).map(e=>({value:e.id,label:e.name})),[e,N]),k=a.useCallback(e=>{e&&!N.has(e)&&(s([...r,e]),g(""))},[r,s,N]),S=a.useCallback(e=>{i?(j(e),v(!0)):s(r.filter(t=>t!==e))},[r,s,i]),A=a.useCallback(()=>{w&&s(r.filter(e=>e!==w)),v(!1),j(null)},[w,r,s]);return t.jsxs("div",{className:_r("space-y-3",m),children:[t.jsx("div",{className:"flex items-start gap-3",children:t.jsx("div",{className:"flex-1",children:t.jsx(gn,{options:C,value:f,onValueChange:e=>{const t="string"==typeof e?e:e?.[0]??"";g(t),t&&k(t)},placeholder:o,searchPlaceholder:"Buscar...",disabled:n})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Selecionados"}),t.jsx("span",{className:"text-xs bg-muted text-muted-foreground rounded-full px-2 py-0.5 font-medium",children:_.length})]}),_.length>0?t.jsx("div",{className:"space-y-2",children:_.map(e=>t.jsxs("div",{className:"flex items-center border border-border rounded-lg p-2 gap-3",children:[t.jsxs(Zi,{className:"h-8 w-8 shrink-0",children:[e.avatar&&t.jsx(el,{src:e.avatar,alt:e.name}),t.jsx(tl,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium truncate",title:e.name,dangerouslySetInnerHTML:{__html:e.title||e.name}})}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.roleName&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(c.Shield,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate max-w-[120px]",children:e.roleName})]}),e.placeName&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(c.MapPin,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate max-w-[120px]",children:e.placeName})]}),t.jsx("button",{type:"button",className:_r("text-muted-foreground hover:text-destructive transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>!n&&S(e.id),title:p("remove"),children:t.jsx(c.X,{className:"h-4 w-4"})})]})]},e.id))}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[t.jsx(c.User,{className:"h-12 w-12 mb-2 opacity-30"}),t.jsx("p",{className:"text-sm",children:x})]}),t.jsx(Qr,{open:b,onOpenChange:v,children:t.jsxs(as,{className:"sm:max-w-[400px]",children:[t.jsx(rs,{children:t.jsx(os,{children:h})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:d}),t.jsxs(ns,{children:[t.jsx(Sr,{variant:"ghost",onClick:()=>v(!1),children:"Cancelar"}),t.jsx(Sr,{variant:"destructive",onClick:A,children:"Remover"})]})]})})]})},exports.TermsOfUseDialog=function({term:r,open:s,onClose:n,onAgree:o,title:i=e.t("terms_updated"),seeLaterLabel:l=e.t("terms_see_later"),agreeLabel:d=e.t("terms_read_agree"),viewTermLabel:u=e.t("terms_view")}){const[m,p]=a.useState(!1),h=a.useCallback(()=>{o(r.id)},[o,r.id]);return t.jsxs(t.Fragment,{children:[t.jsx(Qr,{open:s&&!m,onOpenChange:e=>!e&&n(),children:t.jsxs(as,{className:"sm:max-w-md",children:[t.jsx(rs,{children:t.jsxs(os,{className:"flex items-center gap-2",children:[t.jsx(c.ShieldCheck,{className:"h-5 w-5 text-primary"}),i]})}),t.jsxs("div",{className:"space-y-4",children:[r.description&&t.jsx(Ai,{className:"max-h-48",children:t.jsx("div",{className:"text-sm text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:r.description}})}),r.file&&t.jsxs(Sr,{variant:"link",className:"px-0 text-primary",onClick:()=>p(!0),children:[t.jsx(c.ExternalLink,{className:"mr-1 h-4 w-4"}),u]})]}),t.jsxs(ns,{className:"gap-2 sm:gap-0",children:[t.jsx(Sr,{variant:"ghost",onClick:n,children:l}),t.jsx(Sr,{onClick:h,children:d})]})]})}),m&&t.jsx(jm,{term:r,open:m,onClose:()=>p(!1),viewOnly:!0})]})},exports.TermsOfUseViewer=jm,exports.TextPanel=Np,exports.Textarea=Ts,exports.Timepicker=lm,exports.Toaster=Rs,exports.Toggle=mi,exports.ToggleGroup=hi,exports.ToggleGroupItem=xi,exports.TokenManager=$n,exports.TokenService=Rn,exports.Tooltip=Js,exports.TooltipContent=en,exports.TooltipProvider=Xs,exports.TooltipTrigger=Zs,exports.TreeSelect=Nn,exports.TreeTable=function({data:r,columns:s,nameKey:n,nameHeader:o=e.t("ap_name"),iconComponent:i,expandedIds:l,onToggleExpand:d,onRowClick:u,renderActions:m,actionsHeader:p="",rowActionsVariant:h="default",isLoading:x,emptyMessage:f="Nenhum registro encontrado.",className:g,enableSelection:b,selectedIds:v,onSelectItem:y,onSelectAll:w,isAllSelected:j,enableRowDrag:N,onMoveNode:_,onMoveNodes:C,rootDropLabel:k,actionsWidth:S=20,nameMinWidth:A=200}){const[T,D]=a.useState(null),[E,P]=a.useState(null),[I,M]=a.useState(!1),[R,L]=a.useState(1),F=a.useRef(null),z=a.useRef([]),U=a.useRef(null),O=a.useMemo(()=>new Set(v??[]),[v]),B=a.useMemo(()=>{if(!T||!r)return new Set;const e=z.current.length>0?z.current:[T],t=function(e,t){const a=new Set;for(const r of t)Sh(e,r).forEach(e=>a.add(e));return a}(r,e);return e.forEach(e=>t.add(e)),t},[T,r]),q=a.useRef(B);q.current=B;const V=a.useCallback(()=>{F.current=null,z.current=[],U.current=null,D(null),P(null),M(!1),L(1)},[]),$=a.useCallback((e,t)=>{e.length>1&&C?C(e,t):1===e.length&&_?.(e[0],t)},[_,C]),W=a.useCallback((e,t)=>{const a=O.has(e)&&O.size>1?Array.from(O):[e];F.current=e,z.current=a,U.current=null,D(e),L(a.length),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e),t.dataTransfer.setData("application/x-tree-ids",JSON.stringify(a))},[O]),H=a.useCallback((e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move",q.current.has(e)?P(null):(U.current=e,P(e))},[]),G=a.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation();const a=q.current.has(e)?U.current:e;if(!a)return void V();let r=z.current;if(0===r.length){try{const e=t.dataTransfer.getData("application/x-tree-ids");if(e){const t=JSON.parse(e);Array.isArray(t)&&t.length>0&&(r=t)}}catch{}if(0===r.length){const e=t.dataTransfer.getData("text/plain");e&&(r=[e])}}0===r.length||r.includes(a)||$(r,a),V()},[$,V]),K=a.useCallback(e=>{e.preventDefault(),e.stopPropagation();let t=z.current;if(0===t.length){try{const a=e.dataTransfer.getData("application/x-tree-ids");if(a){const e=JSON.parse(a);Array.isArray(e)&&e.length>0&&(t=e)}}catch{}if(0===t.length){const a=e.dataTransfer.getData("text/plain");a&&(t=[a])}}0!==t.length?($(t,null),V()):V()},[$,V]),Y=a.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",M(!0)},[]),Q=a.useCallback(e=>{N&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[N]),X=a.useCallback(e=>{if(!N)return;const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-tree-row-id]"),a=t?.dataset?.treeRowId??U.current;a&&G(a,e)},[N,G]);if(x)return t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!r||0===r.length)return t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[t.jsx(c.User,{className:"h-10 w-10 text-muted-foreground/50"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:f})]});const J=null!==T;return t.jsxs("div",{className:_r("border rounded-lg overflow-hidden relative",g),onDragOver:Q,onDrop:X,onDragLeave:N?e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(P(null),M(!1))}:void 0,children:[N&&J&&t.jsx(Dh,{onDrop:K,isDragOver:I,onDragOver:Y,onDragLeave:()=>M(!1),label:k}),t.jsxs(Eo,{children:[t.jsx(Po,{children:t.jsxs(Ro,{children:[t.jsx(Lo,{className:"text-left",style:{minWidth:A},children:t.jsxs("div",{className:"flex items-center gap-2",children:[b&&t.jsx(As,{checked:j??!1,onCheckedChange:()=>w?.()}),o]})}),s.map(e=>t.jsx(Lo,{className:_r("text-center",e.className),style:e.width?{width:e.width}:void 0,children:e.header},String(e.key))),m&&t.jsx(Lo,{className:"text-right",style:{width:S},children:p})]})}),t.jsx(Io,{children:r.map(e=>t.jsx(Th,{item:e,level:0,columns:s,nameKey:n,iconComponent:i,expandedIds:l,onToggleExpand:d,onRowClick:u,renderActions:m,rowActionsVariant:h,enableSelection:b,selectedIds:O,onSelectItem:y,enableRowDrag:N,draggedId:T,dragOverId:E,onDragStartCell:W,onDragEndCell:V,onDragOverCell:H,onDropCell:G,dragCount:R},e.id))})]})]})},exports.TruncatedCell=Vo,exports.UpdatesBar=ax,exports.UpdatesDialog=cx,exports.UpdatesNotification=pm,exports.UserUpdatesViewer=hx,exports.UsersGroupsSelector=function({users:r,groups:s=[],value:n,onChange:o,disabled:i=!1,maxHeight:l=350,hideGroupFilter:d=!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:b}){const[v,y]=a.useState(!1),[w,j]=a.useState(""),[N,_]=a.useState(void 0),C=a.useMemo(()=>new Set(n),[n]),k=a.useMemo(()=>{let e=r;if(N&&(e=e.filter(e=>e.groupIds?.includes(N))),w){const t=_m(w);e=e.filter(e=>_m(e.name).includes(t)||_m(e.email??"").includes(t))}return e},[r,N,w]),S=a.useMemo(()=>v?k:r.filter(e=>C.has(e.id)),[v,k,r,C]),A=n.length,T=a.useMemo(()=>k.length>0&&k.every(e=>C.has(e.id)),[k,C]),D=a.useCallback(e=>{if(i)return;const t=C.has(e)?n.filter(t=>t!==e):[...n,e];o(t)},[n,C,o,i]),E=a.useCallback(e=>{if(i)return;const t=new Set(k.map(e=>e.id));if(e){const e=new Set([...n,...t]);o(Array.from(e))}else o(n.filter(e=>!t.has(e)))},[n,k,o,i]),P=a.useCallback(()=>{y(e=>!e),j(""),_(void 0)},[]);return t.jsxs("div",{className:_r("rounded-md border bg-muted/30",b),children:[(!i||A>0)&&t.jsxs("div",{className:_r("flex items-center justify-between px-4 py-2",!i&&"cursor-pointer hover:bg-muted/50"),onClick:i?void 0:P,children:[t.jsx("span",{className:"text-sm font-medium text-primary uppercase",children:!i&&(v?p:m)}),t.jsx("span",{className:"text-xs text-muted-foreground",children:A>0&&`${A} ${1===A?f:g}`})]}),t.jsxs("div",{className:"px-4 pb-3",children:[v&&t.jsxs("div",{className:"flex gap-3 mb-3",children:[!d&&s.length>0&&t.jsxs(bs,{value:N??"__all__",onValueChange:e=>_("__all__"===e?void 0:e),children:[t.jsx(ws,{className:"w-[200px] h-9 text-sm",children:t.jsx(ys,{placeholder:e.t("approval_user_group")})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"__all__",children:e.t("team_all_groups")}),s.map(e=>t.jsx(ks,{value:e.id,children:e.name},e.id))]})]}),t.jsxs("div",{className:"relative flex-1",children:[t.jsx(c.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(Tr,{className:"pl-8 h-9 text-sm",placeholder:u,value:w,onChange:e=>j(e.target.value)})]})]}),!v&&0===A&&t.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:[t.jsx(c.Users,{className:"h-4 w-4 mr-2"}),x]}),v&&k.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(As,{checked:T,onCheckedChange:e=>E(!!e)}),t.jsx("span",{className:"text-sm",children:h})]}),S.length>0&&t.jsx(Ai,{style:{maxHeight:l},className:"pr-2",children:t.jsx("div",{className:"space-y-0.5",children:S.map(e=>t.jsxs("div",{className:_r("flex items-center gap-3 rounded-md bg-background px-3 py-2 text-sm",v&&!i&&"cursor-pointer hover:bg-accent/50"),onClick:v?()=>D(e.id):void 0,children:[v&&t.jsx(As,{checked:C.has(e.id),onCheckedChange:()=>D(e.id),onClick:e=>e.stopPropagation()}),t.jsxs(Zi,{className:"h-8 w-8 shrink-0",children:[e.avatar&&t.jsx(el,{src:e.avatar,alt:e.name}),t.jsx(tl,{className:"text-xs",children:Nm(e.name)})]}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"font-normal truncate",children:e.name}),e.email&&t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})}),v&&0===k.length&&t.jsx("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:"Nenhum usuário encontrado"})]})]})},exports.VideoEditor=function({value:r,onChange:s,onSubmit:n,onCancel:o,uploadFunction:i,deleteFunction:d,uploadOptions:u}){const{t:m}=y.useTranslation(),[p,h]=a.useState(r||{inputType:"url",controls:!0}),x=a.useRef(null),f=a.useRef(null),{upload:g,uploading:b}=Nx({uploadFunction:i,deleteFunction:d,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:w}=Nx({uploadFunction:i,deleteFunction:d,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),j=a.useMemo(()=>lx(p.videoUrl||ix(p.embedCode)||""),[p.videoUrl,p.embedCode]),N=(e,t)=>{const a={...p,[e]:t};h(a),s(a)};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:m("input_type")}),t.jsxs(bs,{value:p.inputType||"url",onValueChange:e=>N("inputType",e),children:[t.jsx(ws,{children:t.jsx(ys,{})}),t.jsxs(_s,{children:[t.jsx(ks,{value:"url",children:"URL"}),t.jsx(ks,{value:"upload",children:m("file_upload")}),t.jsx(ks,{value:"embed",children:m("embed_code")})]})]})]}),"upload"===p.inputType&&i&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Arquivo"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{ref:x,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||t.name.replace(/\.[^/.]+$/,"")};h(a),s(a)}catch(a){}finally{x.current&&(x.current.value="")}},className:"hidden"}),t.jsx(Sr,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:b,children:b?t.jsxs(t.Fragment,{children:[t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),p.videoFile&&t.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&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:m("embed_code")}),t.jsx(Ts,{placeholder:m("paste_embed_code"),value:p.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Thumbnail"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Tr,{type:"url",placeholder:"URL da thumbnail",value:p.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),t.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await v(t),a={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(a),s(a)}catch(a){}finally{f.current&&(f.current.value="")}},className:"hidden"}),t.jsx(Sr,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:w,children:w?t.jsxs(t.Fragment,{children:[t.jsx(c.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):t.jsxs(t.Fragment,{children:[t.jsx(c.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),p.thumbnailFile&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",p.thumbnailFile]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{htmlFor:"title",children:"Título"}),t.jsx(Tr,{id:"title",placeholder:m("video_title"),value:p.title||"",onChange:e=>N("title",e.target.value)})]}),t.jsxs("div",{className:"flex gap-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:"autoplay",checked:p.autoplay||!1,onCheckedChange:e=>N("autoplay",!0===e)}),t.jsx(Er,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{id:"controls",checked:!1!==p.controls,onCheckedChange:e=>N("controls",!0===e)}),t.jsx(Er,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Er,{children:"Preview"}),t.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=p.videoUrl||ix(p.embedCode)||"";if(!a)return t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===j)return t.jsxs("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[t.jsx("source",{src:a}),"Seu navegador não suporta este vídeo."]});const r="youtube"===j?sx(a,p.autoplay):ox(a,p.autoplay);return t.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:t.jsx("iframe",{title:p.title||e.t("video"),src:r,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[t.jsx(Sr,{variant:"outline",onClick:o,children:"Cancelar"}),t.jsx(Sr,{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:a,className:r="",style:s}){const n=a.videoUrl||ix(a.embedCode)||"";if(!n)return null;const o=lx(n);return t.jsx(Pr,{className:`overflow-hidden my-4 ${r}`,style:s,children:t.jsxs(Lr,{className:"p-0",children:["file"===o?t.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[t.jsx("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):t.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:t.jsx("iframe",{title:a.title||e.t("video"),src:"youtube"===o?sx(n,a.autoplay):ox(n,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&t.jsx("div",{className:"p-4",children:t.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.ViewerDialog=function({open:e,onOpenChange:r,template:s,viewerType:n,isLoading:o=!1,enableDownload:i=!0,onDownload:l,isDownloading:d=!1,enableFavorite:u=!1,isFavorite:m=!1,onFavorite:p,isFavoriting:h=!1,enableConfirmReading:x=!1,readingConfirmationDate:f,onConfirmReading:g,isConfirmingReading:b=!1,readingConfirmationTimeRemaining:v,onIframeLoad:w,className:j}){const{t:N}=y.useTranslation(),_=a.useRef(null),C=n??gm(s.extension),k=d||b||h,S=s.code?`${s.code} – ${s.name}`:s.name,A=a.useCallback(()=>{_.current&&w&&w(_.current)},[w]);return a.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&r(!1)};return window.addEventListener("keyup",t),()=>window.removeEventListener("keyup",t)},[e,r]),t.jsx(Qr,{open:e,onOpenChange:r,children:t.jsxs(as,{className:_r("max-w-[95vw] max-h-[95vh] p-6 gap-0 [&>button.absolute]:hidden",(4===C||6===C)&&"w-[90vw]",j),children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 min-h-[35px]",children:[o?t.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):t.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-200px)]",children:S}),t.jsxs("div",{className:"flex items-center gap-1 ml-4 z-20",children:[!o&&t.jsxs(t.Fragment,{children:[(x||f)&&t.jsx(t.Fragment,{children:f?t.jsxs("div",{className:"flex flex-col mr-2.5",children:[t.jsxs("span",{className:"text-sm font-medium flex items-center gap-1 text-foreground",children:[t.jsx(c.CheckCheck,{className:"h-4 w-4"}),"Leitura confirmada"]}),t.jsx("span",{className:"text-xs text-muted-foreground ml-5",children:f.toLocaleDateString()})]}):null!=v&&v>0?t.jsxs("div",{className:"flex items-center gap-1 mr-2.5 text-sm text-muted-foreground",children:[t.jsx("span",{children:N("terms_confirmation_available")}),t.jsx("span",{className:"font-medium min-w-[72px]",children:ym(v)}),t.jsx("span",{children:"segundos"})]}):t.jsxs(Sr,{variant:"default",size:"sm",disabled:k,onClick:()=>g?.(),className:"mr-2.5",children:[t.jsx(c.ShieldCheck,{className:"h-4 w-4 mr-1"}),b?"Confirmando...":N("terms_confirm_reading")]})}),0!==C&&u&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>p?.(m),children:t.jsx(c.Star,{className:_r("h-4 w-4",m&&"fill-accent text-accent")})})}),t.jsx(en,{children:m?"Desfavoritar":"Favoritar"})]}),0!==C&&i&&t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>l?.(),children:t.jsx(c.Download,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Download"})]})]}),t.jsxs(Js,{children:[t.jsx(Zs,{asChild:!0,children:t.jsx(Sr,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>r(!1),children:t.jsx(c.X,{className:"h-4 w-4"})})}),t.jsx(en,{children:"Fechar"})]})]})]}),t.jsx("div",{className:_r("flex flex-col items-center justify-center min-h-[160px] w-full",o&&"relative -top-5",0===C&&"min-h-[124px]",1===C&&"max-h-[85vh]",(4===C||6===C)&&"min-w-[77vw] min-h-[80vh]"),children:o?t.jsx(Is,{className:"h-14 w-14"}):t.jsxs(t.Fragment,{children:[(0===C||!s.url)&&t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-base text-foreground mb-1",children:"Extensão não suportada para visualização."}),t.jsx("b",{className:"text-base text-foreground",children:"Deseja fazer o download do arquivo?"})]}),1===C&&t.jsx("img",{loading:"eager",src:s.url,alt:s.name,className:"max-w-full max-h-[85vh] object-contain"}),2===C&&t.jsx("video",{controls:!0,autoPlay:!0,src:s.url,className:"w-full h-full"}),3===C&&t.jsx("audio",{controls:!0,autoPlay:!0,src:s.url}),(4===C||6===C)&&t.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[t.jsx(Is,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),t.jsx("iframe",{ref:_,src:s.url,onLoad:A,className:"border-none w-full h-full z-[1] relative",title:s.name})]})]})}),!o&&0===C&&t.jsxs("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-border",children:[t.jsx(Sr,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),i&&t.jsx(Sr,{variant:"default",onClick:()=>l?.(),children:"Download"})]})]})})},exports.VisualizationType=Xm,exports.addAppTranslations=_l,exports.addChild=sh,exports.addSibling=nh,exports.aliasSchema=vx,exports.appRedirectUrl=Ue,exports.applyFavicon=mt,exports.assets=ct,exports.badgeVariants=Ds,exports.brandLogos=it,exports.buildModuleUrl=br,exports.buildPlacesTree=function(e){e.forEach(t=>{t.children=e.filter(e=>e.parentId===t.id)});const t=e.filter(e=>!e.parentId);return function e(t,a){t?.forEach(t=>{a(t),t.children&&e(t.children,a)})}(t,t=>{t.children=e.filter(e=>e.parentId===t.id)}),t},exports.buildQualiexHeaders=sl,exports.buildWopiUrl=function(e){const{t:t}=y.useTranslation(),{viewerUrl:a,wopiUrl:r,fileId:s,token:n,extension:o,language:i="pt-br"}=e,l=vm(o);return l?`${a}${l}ui=${i}&rs=${i}&access_token=${n}&WOPISrc=${encodeURIComponent(`${r}${s}`)}`:null},exports.buttonGroupVariants=Rc,exports.buttonVariants=kr,exports.calculateAspectRatio=_x,exports.cn=_r,exports.configureBrandAssets=function(e){nt={...nt,...e,logos:{...nt.logos,...e.logos}}},exports.configureEnvironment=function(e){Pe={...Pe,...e,oauth:{...Pe.oauth,...e.oauth}}},exports.createCrudPage=function(e){return({manager:a})=>{const{manager:r,config:s,onSave:n,onEdit:o,onToggleStatus:i}=e,l=a??r,c={entityName:s.entityName,entityNamePlural:s.entityNamePlural,filters:s.filters||[],columns:s.columns,cardFields:s.cardFields||[],enableBulkActions:s.enableBulkActions??!1,bulkActions:s.bulkActions||[],customActions:s.customActions,customRowActions:s.customRowActions,customListView:s.customListView,onEdit:o||s.onEdit,onNew:s.onNew,useCustomRouting:s.useCustomRouting,hideNewButton:s.hideNewButton,showNewButton:s.showNewButton,newButtonLabel:s.newButtonLabel,showSearch:s.showSearch,searchPlaceholder:s.searchPlaceholder,showActionBar:s.showActionBar,defaultHiddenColumns:s.defaultHiddenColumns};return t.jsx($i,{manager:l,config:c,formSections:s.formSections,onSave:n,onToggleStatus:i,defaultSort:s.defaultSort,readOnly:s.readOnly})}},exports.createCrudRoutingConfig=function(e,t){const a=Eh({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createMindMapNode=Zp,exports.createRoutingHandlers=Eh,exports.createService=vo,exports.createSimpleSaveHandler=function(e,t,a){return r=>{if(r.id){const t=a(r);e.updateEntity(r.id,t)}else{const a=t(r);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=vo({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment??!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,r)=>Ao({queryKey:e.tableName,service:t,entityName:e.entityName,additionalFilters:a,onSuccess:r})}},exports.createStatusConfig=function(e){return t=>e[t]},exports.createTranslatedMessages=t=>({success:{created:t=>e.t("msg_created_success",`${t} criado com sucesso`).replace("{{entity}}",t),updated:t=>e.t("msg_updated_success",`${t} atualizado com sucesso`).replace("{{entity}}",t),deleted:t=>e.t("msg_deleted_success",`${t} removido com sucesso`).replace("{{entity}}",t)},error:{create:t=>e.t("msg_create_error",`Erro ao criar ${t}`).replace("{{entity}}",t),update:t=>e.t("msg_update_error",`Erro ao atualizar ${t}`).replace("{{entity}}",t),delete:t=>e.t("msg_delete_error",`Erro ao remover ${t}`).replace("{{entity}}",t),load:t=>e.t("msg_load_error",`Erro ao carregar ${t}`).replace("{{entity}}",t)}}),exports.currencyFormatter=mp,exports.debounce=(e,t)=>{let a;return(...r)=>{clearTimeout(a),a=setTimeout(()=>e(...r),t)}},exports.deriveEmailField=mo,exports.deriveNameField=uo,exports.deriveUsernameField=po,exports.detectBrowserLocale=lr,exports.detectBrowserPreferences=()=>{const e=lr();return{locale:e,timezone:cr(),datetimeFormat:dr(e)}},exports.detectBrowserTimezone=cr,exports.detectVideoProvider=lx,exports.documentsFilesApi=Mx,exports.emailSchema=bx,exports.emailService=gx,exports.errorService=Gn,exports.exportMindMap=Nh,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractNumberFromCurrency=function(e){const t=e.replace(/[^\d,.-]/g,"").replace(/\./g,"").replace(",",".");return parseFloat(t)},exports.extractVimeoId=nx,exports.extractYouTubeId=rx,exports.findDatetimeFormat=e=>tr.find(t=>t.value===e),exports.findLocale=e=>er.find(t=>t.value===e),exports.findNode=eh,exports.findTimezone=e=>ar.find(t=>t.value===e),exports.formatBytes=kx,exports.formatCurrency=(e,t="BRL",a="pt-BR")=>null==e?"":new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=pr,exports.formatDatetime=mr,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,t,a={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],s={key:e,header:Hi(e),label:Hi(e),...Wi(e,a),sortable:!0,searchable:"string"==typeof a};r.push(s)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.generateId=vr,exports.generateNodeId=Jp,exports.generatePastelBg=xr,exports.getAppBasePath=Oe,exports.getAppEnv=Ee,exports.getBackendMode=function(){return Re},exports.getCommonBaseUrl=al,exports.getCommonV4AppUrl=Xe,exports.getCommonV5AppUrl=Je,exports.getContrastRatio=function(e,t){const a=fr(e),r=fr(t);return(Math.max(a,r)+.05)/(Math.min(a,r)+.05)},exports.getDefaultPanelSize=function(e){switch(e){case Bm.Bar:case Bm.Column:case Bm.Pie:case Bm.List:case Bm.Line:case Bm.Area:case Bm.Text:case Bm.StackedColumn:return{x:4,y:2};case Bm.Pareto:case Bm.RiskMatrix:case Bm.Burndown:case Bm.PerformanceColumns:return{x:8,y:2};case Bm.Numeric:return{x:1,y:1};default:return{x:2,y:2}}},exports.getDocumentsApiUrl=Ke,exports.getEnvironmentConfig=Ie,exports.getFieldValue=Ux,exports.getFileExtension=Sx,exports.getFormFieldValues=function(e){return e.filter(e=>1!==e.type).map(e=>({formFieldAssociationId:e.id,textValue:2===e.type?e.textValue:void 0,numberValue:6===e.type?e.numberValue:void 0,dateValue:3===e.type?e.dateValue:void 0,timeValue:4===e.type?e.timeValue:void 0,itemsValue:[5,7,8].includes(e.type)?e.itemsValue:void 0,questionsValue:9===e.type?e.questionsValue:void 0}))},exports.getIdentApiUrlOverride=Ye,exports.getIdentBaseUrl=function(){const e=Ye();if(e)return e;const t=al().match(/^https?:\/\/common-v4-api(-[^.]+)?\.(.+)$/);if(t){return`https://ident-api${t[1]||""}.${t[2]}`}return"https://ident-api.qualiex.com"},exports.getLinkFromRow=cp,exports.getLoginApiUrlOverride=Qe,exports.getLuminance=fr,exports.getMinPanelSize=Lp,exports.getOnlineViewerType=function(e){const{t:t}=y.useTranslation();return{".gdocs":"document",".gsheets":"spreadsheets"}[e.toLowerCase()]||"document"},exports.getQualiexApiUrl=Ge,exports.getSecurityMode=function(){return wc},exports.getSupabaseClient=to,exports.getUserProfile=pl,exports.getViewerType=gm,exports.getWopiViewer=vm,exports.handleExternalLink=gr,exports.importMindMap=function(e){return _h(JSON.parse(e))},exports.inferDatetimeFormat=dr,exports.inputGroupAddonVariants=ad,exports.inputGroupButtonVariants=sd,exports.isCurrency=function(e){return!!up.test(e)&&!isNaN(parseFloat(e.replace(/,/g,"")))},exports.isDevEnv=Me,exports.isDevEnvironment=He,exports.isImageUrl=function(e){const t=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const a=new URL(e);return t.some(e=>a.pathname.toLowerCase().endsWith(e))}catch{const a=e.toLowerCase();return t.some(e=>a.endsWith(e))}},exports.isLovablePreview=$e,exports.isNullOrEmptyField=function(e){return null==e?.value||""===e.value.trim()},exports.isSupabaseBackend=Fe,exports.isSupabaseConfigured=function(){return null!==Jn()},exports.isValidDatetimeFormat=e=>tr.some(t=>t.value===e),exports.isValidLocale=or,exports.isValidTimezone=ir,exports.loadForlogicFonts=vc,exports.logoSrc=dt,exports.markUpdateVisualized=Jh,exports.mergeTranslationFiles=function(...e){return Object.assign({},...e)},exports.moveNode=ih,exports.navigationMenuTriggerStyle=Nd,exports.normalizeVideoUrl=function(e,t,a){switch(t||lx(e)){case"youtube":return sx(e,a);case"vimeo":return ox(e,a);default:return e}},exports.normalizeVimeoUrl=ox,exports.normalizeYouTubeUrl=sx,exports.paginationSchema=jx,exports.parseIframeSrc=ix,exports.processUrl=lp,exports.qualiexApi=co,exports.qualiexFetch=nl,exports.removeNode=oh,exports.resizeKeepingAspect=function(e,t,a,r){const s=_x(e,t);return a&&!r?{width:a,height:Math.round(a/s)}:r&&!a?{width:Math.round(r*s),height:r}:{width:e,height:t}},exports.resolveBrandLogo=lt,exports.resolveFieldMappings=ho,exports.resolvePageTitle=Fh,exports.safeStringSchema=(e=1e3)=>J.z.string().trim().max(e,`Texto excede ${e} caracteres`).refine(e=>!/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/.test(e),"Contém caracteres inválidos"),exports.sanitizeErrorMessage=Nr,exports.setBackendMode=Le,exports.setCollapsedAll=ch,exports.setFormFieldValues=function(e,t){return t?.length?e.map(e=>{const a=t.find(t=>t.formFieldAssociationId===e.id);if(!a)return e;const r={...e};switch(e.type){case 2:r.textValue=a.textValue;break;case 6:r.numberValue=a.numberValue;break;case 3:r.dateValue=a.dateValue;break;case 4:r.timeValue=a.timeValue;break;case 5:case 7:case 8:r.itemsValue=a.itemsValue||[];break;case 9:r.questionsValue=a.questionsValue||[]}return r}):e},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new j.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.shouldShowField=Ox,exports.shouldUseDevTokens=We,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=ut,exports.sortByMonthYear=function(e){return e?.sort((e,t)=>{if(!e?.items?.length||!t?.items?.length)return 0;return ip(e.items[0]?.keyDate)-ip(t.items[0]?.keyDate)})},exports.stripTechHeaders=function(e){if(!e||"object"!=typeof e)return e;const t={...e};for(const a of yr)delete t[a];return t},exports.timestampId=()=>Date.now().toString(),exports.toQueryString=function(e){return e?dp(e).join("&"):null},exports.toRouterPath=Be,exports.toggleCollapsed=lh,exports.toggleVariants=ui,exports.trackFooterClick=oc,exports.trackInterestClick=nc,exports.trackModuleClick=sc,exports.trimTextFields=Cr,exports.updateUserProfile=dl,exports.uploadUserPhoto=ol,exports.useActiveModules=(e={})=>{const{enabled:t=!0}=e,{alias:a}=So();return j.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=to(),{data:t,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(r){if(!oo.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!a})},exports.useAliasFromUrl=Gi,exports.useAuth=So,exports.useBaseForm=_i,exports.useClarity=yc,exports.useColumnManager=vi,exports.useColumnResize=di,exports.useCrud=Ao,exports.useDebounce=zh,exports.useDerivedContractedModules=pc,exports.useFormField=ds,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Gh();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Fl(),a=sr;return{formatDatetime:r=>mr(r,a,t,e),formatDate:a=>pr(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useIsMobile=Do,exports.useLocale=Fl,exports.useMediaQuery=To,exports.useMediaUpload=Nx,exports.useModalState=Gh,exports.useModuleAccess=Dl,exports.useModuleConfig=Sl,exports.useNavigation=Lh,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:r}=vl(),s=a.useRef({});a.useEffect(()=>{const a=JSON.stringify(s.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(s.current.title!==e.title||s.current.subtitle!==e.subtitle||a)&&(s.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},t(e)),()=>r()},[e.title,e.subtitle,e.breadcrumbs,t,r])},exports.usePageMetadataContext=vl,exports.usePageTitle=function(){const e=N.useLocation(),{navigation:t}=Lh();return Fh(t,e.pathname)},exports.usePermissionQuery=Bh,exports.useQualiexReady=Qh,exports.useQualiexUsers=Mi,exports.useRouteBreadcrumbs=function(){const e=N.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,s)=>{r+=`/${e}`;const n=s===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:r,isCurrentPage:n})}),a})()},exports.useRowResize=function({rowIds:e,defaultHeight:t=48,minHeight:r=32,maxHeight:s=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,c]=a.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[d,u]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{i&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[i,l,t]);a.useEffect(()=>{if(!d||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(r,Math.min(s,x.current+t));c(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&c(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[d,m,r,s,n,o]),a.useEffect(()=>(d?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[d]);const b=a.useCallback(()=>{c({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:d,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}},exports.useSidebar=eu,exports.useSidebarResize=Wh,exports.useUpdatesNotification=mm,exports.useUserUpdatesBar=ex,exports.useUserUpdatesDialog=tx,exports.useWizard=function(e){const{steps:t,initialStep:r=0,initialData:s={},onComplete:n,onCancel:o}=e,[i,l]=a.useState(r),[c,d]=a.useState(s),[u,m]=a.useState(!1),[p,h]=a.useState(!1),x=t.length,f=0===i,g=i===x-1,b=t[i],v=x>1?(i+1)/x*100:100,y=a.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),w=a.useMemo(()=>y(),[y,c]),j=a.useMemo(()=>!f&&!b?.disableBack,[f,b]),N=a.useCallback(e=>{d(t=>({...t,...e}))},[]),_=a.useCallback((e,t)=>{d(a=>({...a,[e]:t}))},[]),C=a.useCallback(()=>{l(r),d(s),m(!1),h(!1),o?.()},[r,s,o]),k=a.useCallback(async()=>{if(y()&&!p){h(!0);try{await(n?.(c))}finally{h(!1)}}},[y,p,c,n]),S=a.useCallback(async()=>{y()&&!u&&(g?await k():l(e=>Math.min(e+1,x-1)))},[y,u,g,x,k]),A=a.useCallback(()=>{j&&!u&&l(e=>Math.max(e-1,0))},[j,u]),T=a.useCallback(e=>{e<0||e>=x||u||(e<=i||e===i+1)&&l(e)},[i,x,u]),D=a.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:c,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:A,goTo:T,canProceed:w,canGoBack:j,setData:N,updateField:_,reset:C,complete:k,setLoading:D,progress:v,stepIndex:i,totalSteps:x}},exports.userIdSchema=wx,exports.uuidSchema=yx,exports.validateFields=function(e){const t=[];return e.forEach(e=>{if(!e.required||e.readOnly||1===e.type)return;const a=Ux(e);if((null==a||""===a||Array.isArray(a)&&0===a.length)&&t.push(e.id),6===e.type&&null!=a){const r=e.config;null!=r?.min&&a<r.min&&t.push(e.id),null!=r?.max&&a>r.max&&t.push(e.id)}}),{valid:0===t.length,invalidFields:[...new Set(t)]}};
|